Daytona.Secret reference
CreateSecret
Section titled “CreateSecret”Source:
packages/daytona/src/CreateSecret.ts
Store secrets in Daytona at runtime: a credential per user, injected
into that user’s sandboxes without the sandbox (or an agent in it)
ever seeing the value. Daytona swaps the placeholder for the value only
on requests to the secret’s hosts.
The host gets its own Daytona API key with manage:secrets. Secrets
have no labels, so each one it creates carries stack/stage/id in its
description. They are not deleted when the stack is destroyed: list them
(list()) and match the description to clean them up.
CreateSecret: A Credential per User
Section titled “CreateSecret: A Credential per User”const secrets = yield* Daytona.CreateSecret();const github = yield* secrets.put({ name: `github-${user}`, value: token, hosts: ["api.github.com"],});const sandbox = yield* sandboxes.create({ secrets: [{ GITHUB_TOKEN: github.name }] });Secret
Section titled “Secret”Source:
packages/daytona/src/Secret.ts
A secret stored in Daytona. A sandbox gets a placeholder in place of
the value, and Daytona’s egress proxy substitutes the real value only on
requests to the secret’s hosts, so code in the sandbox (or an agent
running there) can use a credential without being able to read it.
Declare a secret here for credentials the whole app shares. For a secret
per user, create it at runtime with CreateSecret.
Secret: Creating a Secret
Section titled “Secret: Creating a Secret”export const NpmToken = Daytona.Secret("NpmToken", { value: Config.Redacted("NPM_TOKEN"), hosts: ["registry.npmjs.org"],});Secret: Using a Secret in a Sandbox
Section titled “Secret: Using a Secret in a Sandbox”export const DevBox = Daytona.Sandbox("DevBox", { snapshot: Base, secrets: { NPM_TOKEN: NpmToken },});