Skip to content

typetorch settings secrets: move the record's tokens to the Roblox Secrets Store - #50

Open
phasenull wants to merge 2 commits into
mainfrom
feat/secrets-store
Open

phasenull wants to merge 2 commits into
mainfrom
feat/secrets-store

Conversation

@phasenull

Copy link
Copy Markdown
Member

This PR adds typetorch settings secrets, which moves the settings record's tokens into the experience's Roblox Secrets Store. The record then only names each secret, still signed with tt1settings as before, so a leaked Open Cloud key with datastore read no longer gets the backend key. Companion PRs: kernel and framework, both on branch feat/secrets-store.

CLI changes

  • settings.ts:
    • SettingsBody.secrets, SECRET_PATHS, secretsProblems, inlineDropped, withoutInline and copiesOfBackendKey.
    • backend.key may be missing only while secrets["backend.key"] names a secret.
    • withBackend (backend setup): the map follows the key's copies, and values dropped by inline off stay dropped. A Basin sink's own token is never mapped to the backend secret. A new backend setup --inline-secrets flag writes the values inline again.
    • describeFields shows where the key lives. maskSecrets keeps secret names visible.
  • New secretstore.ts:
    • listSecrets: the Open Cloud List Secrets endpoint (metadata only; only id and domain are kept), with pages.
    • domainCovers, storeProblems, suggestDomain.
    • creatorHubSteps, which never prints a value.
  • New commands/secrets.ts (typetorch settings secrets ...):
    • status: the map, the inline copies left, and the store check.
    • set <path> <name>: names a secret and prints the Creator Hub steps plus a 401 hint. backend.key also names its equal-valued copies, fleet.token and a DuckDB analytics.token.
    • unset <path>: refused while no inline value is left.
    • inline off [--force]: refused unless every named secret is in the store with a domain that covers its hosts. --force skips the check when the deploy key lacks universe.secret:read.
  • doctor:
    • Warns when tokens sit inline with no secret named, and checks named secrets against the store.
    • A secret-only record's backend is probed with your TYPETORCH_API_KEY, or skipped as info without it.
  • Not done: the CLI never creates or updates secrets. Open Cloud needs a libsodium sealed box, which Node's crypto can't do, and nothing was installed. It prints the Creator Hub steps instead.

Design (same in all three PRs)

The settings record (TypeTorch/settings) gets one optional, signed field:

"secrets": { "backend.key": "typetorch_backend_key", "fleet.token": "typetorch_backend_key", "analytics.token": "...", "analytics.identityToken": "..." }
  • It maps a token's path to the name of an entry in the experience's Roblox Secrets Store. It holds names only, never values. The signature scheme (tt1settings) is unchanged.
  • Readers prefer the named secret and fall back to the inline value:
    • The secret is read with HttpService:GetSecret(name) in a pcall. It is cached for 10 min, and a miss for 60 s.
    • Every request sends it as Authorization = secret:AddPrefix("Bearer ").
  • A Secret's value never enters Luau memory, so it can't reach a log, a debug answer or a bundle. Inline values are scrubbed as before.
  • Each credential is treated as an opaque string. No field is renamed, merged or reinterpreted, and nothing changes what a credential authenticates as. Only where the value is stored changes.
  • fleet.token and a DuckDB analytics.token are copies of backend.key that the CLI writes itself. The CLI names the same secret for them only when the values are equal.
  • Where a Secret can't go: a Secret only works in a request's URL or headers. Every use of backend.key, fleet.token, analytics.token and analytics.identityToken in kernel and framework is a Authorization: Bearer header, so all four can move. The notify HMAC keys (backend.notify.keys) feed hmacSha256 in Luau (framework notifications/token.ts), so they stay inline in the record. They are the one remaining DataStore-readable secret, with a narrow use: forging notification launch data.
  • Backward compatible both ways:
    • Old kernels and frameworks ignore secrets and keep using the inline values, which stay until the owner runs settings secrets inline off.
    • New kernels and frameworks reading an old record (no map) behave exactly as before.
    • A malformed secrets map or name is dropped on its own, never the whole record. Old kernels accept the record, so refusing it on new ones would blank settings fleet-wide.

Rollout order

  1. Merge and release the kernel (this audit's KERNEL_VERSION bump, then typetorch kernel deploy publishes the place) and the framework (FRAMEWORK_VERSION bump, then a deploy of every branch). Order between the two doesn't matter.
  2. Release the CLI. Every dev must update. An old CLI refuses every settings write once the inline key is gone (its backendProblems requires backend.key), and an old backend setup would write the key inline again.
  3. Creator Hub. Only the experience or group owner can do this: Creator Dashboard > the experience > Secrets > Create Secret.
    • Name it e.g. typetorch_backend_key.
    • The value is the backend's game key (TYPETORCH_API_KEY).
    • The domain is the backend's host. If backend.ingest is set, it must also cover the ingest host: a shared *.parent, or *.
    • Repeat for a Basin token (domain: the two stream hosts) if you use Basin.
    • For Studio play tests, add Local Secrets under File > Experience Settings > Security (optional; without them Studio keeps the inline value).
    • Optionally add universe.secret:read to the deploy key so the CLI can check the store.
  4. typetorch settings secrets set backend.key typetorch_backend_key. This writes the map and keeps the inline values. Within a minute, typetorch doctor should show live servers.
    • A 401 means the pasted value is wrong. The kernel falls back to the inline key and warns. Analytics and notify keep the Secret, so fix the value in Creator Hub.
  5. Gate for removing inline values: run typetorch settings secrets inline off only when ALL of these hold.
    • Every live server runs the new kernel: the place is published and pre-publish servers are drained.
    • Every build any path can still run contains the new framework: the live heads, auto-rollback / last-known-good candidates, TypeTorchBackup, BootstrapHeads, pins and dev branches. The framework hot-swaps, so an older payload reached by a rollback would have no analytics or notify auth.
    • Every dev's CLI is updated.
    • inline off refuses unless every named secret is listed in the store with a domain that covers its hosts. --force skips that check when the deploy key can't list secrets.
  6. To roll back: typetorch backend setup --inline-secrets writes the key inline again, then typetorch settings secrets unset backend.key.

Roblox API: verified vs assumed

Verified from the docs (create.roblox.com: Secrets stores, HttpService.GetSecret, Secret, the Open Cloud universes reference and the secrets-store guide) and the @rbxts/types declarations:

  • HttpService:GetSecret(key): Secret is server-only. Printing a Secret gives Secret(name).
  • A Secret has only AddPrefix and AddSuffix. It can go in the URL and headers, never the body.
  • @rbxts/types 1.0.956: RequestAsyncRequest.Url: string | Secret and HttpHeaders = Record<string, string | Secret>.
  • Limits: 500 secrets per experience, values up to 1024 characters. Names must be alphanumeric or _, 1-64 characters, not starting with a digit.
  • Domain: an exact host, *.domain or *. An empty domain means the secret can't be used in a header or URL at all.
  • Local playtests see only Local Secrets (File > Experience Settings > Security). Otherwise they get "Can't find secret with given key".
  • Open Cloud GET /cloud/v2/universes/{id}/secrets (Beta, scope universe.secret:read) lists metadata (id, domain, times), never content.
  • Create/Update (universe.secret:write) need the value in a libsodium sealed box under the universe's public key. Node's crypto has no XSalsa20-Poly1305 and the CLI ships no crypto library, so the CLI never creates secrets and prints the Creator Hub steps instead.

Assumed or unverified (no live GetSecret or RequestAsync call was made; nothing touched Creator Hub or Open Cloud):

  • What RequestAsync does when a Secret's domain doesn't match the URL. It is assumed to error like a refused request.
  • Whether *.example.com also covers example.com. Doctor assumes it does not.
  • Whether AddPrefix("Bearer ") counts toward the 1024-character limit.
  • Whether GetSecret yields.
  • Whether a cached Secret object sees a value updated in Creator Hub. It is assumed only new lookups do: the cache is 10 min, and new servers read it fresh.
  • The exact error text for a missing secret on a live server.
  • Whether API keys can be granted universe.secret:read. The docs list the scope for API keys and OAuth.
  • The exact Creator Hub menu path.

KERNEL_VERSION (0.5.9), FRAMEWORK_VERSION (0.7.5) and the CLI version (0.19.0) are not bumped. In the gate above, "the new kernel/framework" means the first releases that contain these PRs. CHANGELOG.md (gitignored) was not updated, because it lives in the main checkouts.

Merges with the audit PRs

Tests

  • tsc --noEmit: clean.
  • bun test: 924 pass, 4 skip, 0 fail. The new test/secrets.test.ts has 16 tests:
    • domain rules, the suggested domain and store problems;
    • list paging, missing scope, and no content read;
    • the Creator Hub steps, which never print a value;
    • record rules: the key is optional only with a secret, and bad names or paths are refused;
    • hosts per path, including ingest and Basin streams;
    • withBackend keeps dropped values out and follows copies; --inline-secrets writes them again; a Basin token is unmapped;
    • masking and describeFields;
    • the command end to end on a fake DataStore and secrets list (set, inline off refusals and success, unset, status);
    • the doctor checks.
  • No real Open Cloud call was made.

🤖 Generated with Claude Code

phasenull and others added 2 commits December 5, 2026 14:54
… tokens

`typetorch settings secrets` (status / set / unset / inline off) writes the signed record's
`secrets` map ({ [path] = secret name }) for backend.key (and its copies fleet.token and a DuckDB
analytics.token), analytics.token and analytics.identityToken. Inline values stay until
`inline off`, which checks the Secrets Store list (universe.secret:read, metadata only) for every
named secret and its domain first; later backend setup writes keep them out
(--inline-secrets writes them again). backend.key may be missing when a secret names it.
doctor warns about inline tokens and checks the named secrets. The CLI never creates secrets
(Open Cloud needs a libsodium sealed box; no crypto library ships): it prints Creator Hub steps.
The signature scheme is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…secret-only key it can't check

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant