feat(seal): add a fetch option for key server requests - #1184
Merged
Conversation
nikos-terzo
temporarily deployed
to
sui-typescript-aws-kms-test-env
August 8, 2026 07:45 — with
GitHub Actions
Inactive
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
nikos-terzo
temporarily deployed
to
sui-typescript-aws-kms-test-env
August 8, 2026 08:10 — with
GitHub Actions
Inactive
nikos-terzo
temporarily deployed
to
sui-typescript-aws-kms-test-env
August 8, 2026 08:14 — with
GitHub Actions
Inactive
nikos-terzo
force-pushed
the
nikos-terzo/seal-custom-fetch
branch
from
August 8, 2026 08:16
a7c4e0c to
c3fdb6d
Compare
nikos-terzo
temporarily deployed
to
sui-typescript-aws-kms-test-env
August 8, 2026 08:16 — with
GitHub Actions
Inactive
Contributor
Author
|
To the reviewers, regarding the AI Assistance Notice, even though I used AI to understand the solution and write the code, I reviewed the code line by line and it is how I would have written it. |
hayes-mysten
approved these changes
Aug 8, 2026
4 tasks
Contributor
Style Guide AuditAudited 1 file(s) against the Sui Documentation Style Guide. 1 violation(s) found. All must be fixed before merge.
|
1 similar comment
Contributor
Style Guide AuditAudited 1 file(s) against the Sui Documentation Style Guide. 1 violation(s) found. All must be fixed before merge.
|
Optional fetch on SealClientOptions, used for /v1/fetch_key and /v1/service verification requests. Lets apps customize how requests are sent, e.g. credentials: 'include' to send session cookies to a backend that attaches aggregator API keys server-side. Defaults to the global fetch. Includes client-level tests and a docs entry. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Drops the as-unknown-as casts at the SealClient call sites; the helper now returns exactly what retrieveKeyServers and SealClient expect. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
nikos-terzo
force-pushed
the
nikos-terzo/seal-custom-fetch
branch
from
August 10, 2026 20:51
c3fdb6d to
9067469
Compare
nikos-terzo
deployed
to
sui-typescript-aws-kms-test-env
August 10, 2026 20:51 — with
GitHub Actions
Active
nikos-terzo
deployed
to
sui-typescript-aws-kms-test-env
August 10, 2026 20:57 — with
GitHub Actions
Active
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.
Description
Adds an optional
fetchtoSealClientOptions, used for all key server requests (/v1/fetch_keyand/v1/serviceverification). Mirrors thefetchoption ofSuiHTTPTransport. Defaults to the globalfetch; no behavior change otherwise.Use case: the seal-mpc aggregator authenticates apps with an API key, which is a secret — it can't be shipped to the browser — so apps route
fetch_keythrough their own backend, which attaches the key server-side (MystenLabs/console#428).SealClientstill has to run in the browser: it's what guarantees that only the user can decrypt their data. If the backend ran it instead, the backend would see the decryption keys and could read user data.That leaves authenticating the browser→backend leg, which is typically the app's session cookie. On a same-origin backend that just works — but when the API lives on a different origin than the app (the usual setup), cookies are only sent if the request opts in with
credentials: 'include', and the SDK'sfetchdoesn't and can't. The cookie also can't be copied into theapiKeyName/apiKeyheader slot because it's HttpOnly.apiKeyis also fixed at construction, so rotating credentials force rebuilding the whole client. MystenLabs/console#379 shows the workaround this forces today: a dedicated short-lived token endpoint, a custom header, and client rebuilds on every rotation.With this option, such apps pass
fetch: (url, init) => fetch(url, { ...init, credentials: 'include' })and their existing session just rides along. This is likely a common shape for any cookie-authenticated app fronting a keyed seal-mpc aggregator.Test plan
Client-level unit tests:
SealClientbuilt with a custom fetch must route bothverifyKeyServer(/v1/service) andfetchKeysForAllIds(/v1/fetch_key) through it, never through the (stubbed) global fetch.pnpm --filter @mysten/seal vitest run test/unit/key-server.test.ts— 10/10 passing.Also red/green-tested this in Walrus Console (MystenLabs/console#459) by patching globalThis.fetch around each decrypt equivalent to this option, since the SDK reads the global at request time.
AI Assistance Notice
🤖 Generated with Claude Code