Repository navigation
Add secrets management and secret delivery to sandboxes - #139
Draft
AHarmlessPyro wants to merge 1 commit into
Draft
AHarmlessPyro wants to merge 1 commit into
AHarmlessPyro wants to merge 1 commit into
Conversation
Adds client.secrets (sync and async) for the API-key routes: public key, list, create, get, update, add_version, delete and delete_version. Values are encrypted client-side as a compact JWE (RSA-OAEP-256 + A256GCM) bound to the secret's encryption context, after checking the key's policy and RFC 7638 key ID. Secrets resolve by ID or exact name. Sandbox image launches accept `secrets` for the startup command, and exec/processes.start accept `secrets`, starting through the control API and waiting through the runtime. Sandboxes and snapshots expose contains_secrets. Control API errors honour the server's `retryable` flag and a machine code sent as `error`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NhbFMc29f5JN5JxCciajJV
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds sandbox secrets to the SDK, mirroring the
hx vm secretsCLI in metlo-labs/browserctrl#1519. It covers only the routes an API key can reach, and needs that server stack (#1513–#1518) deployed with the secrets feature enabled for the team.client.secrets(sync and async)getby ID makes one request.encryptionContext. The API only receives the envelope.kid.cryptography, which is a new dependency (>=41.0.0).strorbytes, used byte-for-byte: 1 byte to 32 KiB, UTF-8, no NUL. These rules are checked locally.createwith a value checks the value and fetches and verifies the key before creating the secret, so a bad value or key leaves nothing behind.secret_value_not_stored. The error names the secret and points toadd_version, because retryingcreatewould fail with "name taken".Using secrets
create:secretsis for image launches only. Snapshot launches with secrets are rejected locally.POST /api/sandbox/:id/processes.timeout_secbecomestimeoutMs.envandsecretsnames are rejected locally.execwith secrets then closes stdin, ignoring a 409 from a command that already exited. It waits through the runtime in chunks, and treats a 408 as still running.secret_process_failedwith{processId, sandboxId}.secret_process_outcome_unknown. So does a start response with no process ID. The command may be running, so neither is marked retryable.SandboxDetail/Sandbox/SandboxSnapshotSummaryexposecontains_secrets.Errors (all control requests)
retryableflag overrides the status-code default. Runtime errors are unchanged, since vm-service's proxy marks its own gateway errors non-retryable.errornext to amessage(e.g.API_KEY_SCOPE_DENIED) becomesHyperbrowserError.code.detailsstill carries the full body (requiredScopes,sandboxId,causeCode, …).Testing
poetry run pytest tests --ignore=tests/sandbox/e2e: 713 passed. Newtests/test_secrets.pycovers:retryableparsing in both the control request path and the transporttests/test_typing_contract.pyandtests/test_typed_request_surface.pypass with CI's mypy 1.14.1 and pyright 1.1.411. The typecheck fixtures cover the new calls.ruff checkis clean. Pyright onhyperbrowser/reports no new errors overmain.🤖 Generated with Claude Code
https://claude.ai/code/session_01NhbFMc29f5JN5JxCciajJV