Skip to content

Errors

Every error is a TrustError with a mode, a code of the form <mode>/<kebab-case> and a message. Every message ends with the next step.

import { findTrustError } from "@geometer/trust/masked-ai";
try {
await ai.chat.completions.create({ /* ... */ });
} catch (err) {
const problem = findTrustError(err); // finds the TrustError, even inside another library's error
if (problem?.code === "masked-ai/unmaskable-part") {
// show problem.message: it says what to do
}
}

The openai and @anthropic-ai/sdk clients wrap an error from a custom fetch as APIConnectionError("Connection error.") and keep ours in .cause. They also retry it. So every AI example creates the client with maxRetries: 0 and reads errors with findTrustError(err), not instanceof. Every entry point exports TrustError and findTrustError.

Errors from a route reach the browser as JSON (error.code, error.message) with the status shown below. The route’s message is short and safe to show to your users (for example “Please sign in to use this feature.”); what to do about it as a developer is in this table, not in the message.

Code Why Next step
vault/locked A method was called after lock() or after the Vault locked itself. Call openVault again.
vault/unlock-cancelled The user closed the passkey prompt, or none answered. Ask again.
vault/unlock-needed The unlock method asked for does not exist, or it is the last one. Also: this Vault was opened from “remember this device” and the call changes keys (addPasskey, addUnlock, setPassphrase, removePasskey, removePassphrase, newRecoveryCode, rotateKey, retireKey); the message is “Unlock with your passkey or passphrase to change keys”. Pass unlock: { passphrase }, use the recovery code with recoverVault, or add another method before removing this one. For a remembered Vault: ask the user to unlock and call openVault({ ..., skipRemembered: true }).
vault/passkey-unsupported This browser, page or passkey cannot make the Vault key (no WebAuthn, no PRF, not https, or a preview frame from another site). Use unlock: { passkey: true, fallbackPassphrase } so the user is asked for a passphrase only here, or unlock: { passphrase }.
vault/passkey-failed The passkey step failed for another reason, or the passkey is already enrolled. Try again.
vault/wrong-passphrase The passphrase does not open the key file. Ask again, or use the recovery code.
vault/weak-passphrase Under 15 characters, too common, contains the app name or user id, a run of 6 identical or consecutive characters, or equals the old one. Ask for four or more random words.
vault/bad-recovery-code The recovery code is wrong, or belongs to another Vault, or was replaced. Check each group against the written copy; look for a newer code.
vault/recovery-code-handler-missing Setup, recovery or rotation makes a recovery code but no onRecoveryCode was passed. Nothing was saved. Pass onRecoveryCode: ({ code }) => show(code).
vault/key-file-missing The key store has no key file but this device opened one before, or it vanished. Check the user id, the app name and the key store table. Do not create a new one. Only if the Vault is truly lost, call startOverVault (it needs archive).
vault/key-file-damaged The key file was changed outside Trust, or Vault built one it cannot read back and so did not save it (nothing was changed). Restore it from a backup of your database; if nothing was changed outside, reload and try again, and report it if it repeats.
vault/device-note-unreadable This device’s saved Vault history could not be read right now, or IndexedDB would not open for a reason other than being missing or blocked (after retries). Nothing was changed. Try again; reload the page if it keeps failing.
vault/key-file-rolled-back Someone put back an older key file. Do not keep writing. Restore the newest key file from your backups.
vault/key-changed The key changed on another device, or the Vault was started over there. Unlock again.
vault/key-file-behind This device never saw the newer key file and a value uses a key the file does not know: the key file may be an older copy. encrypt and key changes are refused (the mark survives a reload). Do not write. Restore the newest key file from a backup. It clears when a newer key file is accepted, or when the user resolves it with vault.resolveKeyFileBehind. A device that took the key file without having seen the Vault before (a new device, or acceptStartOverVault) is in this state from the start.
vault/key-file-replaced This device opened a different Vault for this user before. If the user started over on another device, ask them, then call acceptStartOverVault (their own secrets must open the new Vault). Otherwise restore the key file from a database backup.
vault/key-store-failed Your database refused to load or save the key file, or could not be asked during a re-check. The original error is in .cause. The Vault stays open after a failed re-check. Check the key table or collection and its access rules, and that the user is signed in. Try again.
vault/key-store-conflict Another device changed the key file at the same moment. Try again.
vault/key-store-unsafe The key store cannot create or replace safely, or reports a key file it will not return (a row hidden by access rules). Use supabaseKeyStore or firebaseKeyStore, and check the access rules for this user.
vault/key-store-misconfigured The adapter was set up wrong, for example firebaseKeyStore without functions. Fix the setup as the message says.
vault/wrong-context decrypt got a different table, id or field than encrypt, or the value was moved. Use the exact table, id and field from the encrypt call.
vault/wrong-key The value was encrypted with a key this Vault does not have (another user, another app, or a newer key on another device). Check the user and app. Unlock again to load the newest key file.
vault/retired-key The value was written under a key that was retired, by you or automatically (a Vault keeps 32 previous keys). Restore it from a backup made before the rotation.
vault/changed-data The stored value was changed or is cut short. Restore the value from a backup. It cannot be repaired.
vault/not-encrypted The text is not a Vault value. Decrypt only what encrypt returned.
vault/wrong-type The value was saved as text and read as JSON, or the other way round. Use decrypt for encrypt, decryptJSON for encryptJSON.
vault/unknown-version The value or key file came from a newer format. Update @geometer/trust.
vault/too-large The value is larger than a record can hold. Store large files outside the Vault.
vault/bad-input An option or argument has the wrong shape (also: a passphrase with an unassigned character, startOverVault without archive). Fix it as the message says.
vault/bad-argument An internal helper got a wrong value. Report it with the message.
vault/too-many-unlock-methods The Vault holds as many unlock methods as it can. Remove one with removePasskey(slotId).
vault/webcrypto-missing No crypto.subtle: the page is not secure. Open the app over https or http://localhost, or use Node 22.18 or later.
vault/passphrase-derivation-failed The browser could not run the passphrase function (memory or worker). Try again; use a passkey if it keeps failing.

Both routes need authorize(request). It decides who may spend your AI key.

Code Status Why Next step
sealed-ai/no-authorize, masked-ai/no-authorize at setup The route was made without authorize. Pass authorize: (request) => ... that checks the signed-in user. See the recipe for your stack.
sealed-ai/not-authorized, masked-ai/not-authorized 401 authorize returned false or threw. Send the user’s sign-in token (Supabase, Firebase) or session cookie (Next.js) with the call. Check that the user is signed in.
sealed-ai/bad-path, masked-ai/bad-path 404, 400 Nothing follows /sealed-ai or /masked-ai in the path, or the path has a .. segment. Mount the route so it receives /<mode>/v1/chat/completions, and point baseURL at it.
sealed-ai/path-not-allowed, masked-ai/path-not-allowed 403 The call is not one the route makes with your key. Call other endpoints from your own server code.
sealed-ai/method-not-allowed, masked-ai/method-not-allowed 405 A method other than GET or POST. Use the openai or @anthropic-ai/sdk client.
sealed-ai/body-too-large, masked-ai/body-too-large 413 The body is over the limit (4 MB sealed, 2 MB masked). Send less text, or raise maxBodyBytes.
sealed-ai/upstream-timeout, masked-ai/upstream-timeout 504 The provider (or AMD, or GitHub) did not answer in time: first byte within upstreamTimeoutMs (default 60 s), small public calls within publicTimeoutMs (Sealed AI, default 10 s). Nothing was sent on. Try again; raise the timeout only if your model is slow to start.
sealed-ai/service-busy 503 AMD’s certificate service or GitHub is rate-limiting your server (429 or 503). The route caches certificates, so this is rare. Try again in a minute.
masked-ai/service-busy 503 The limits.store could not be reached (it threw), so the route would not drop your cap. Fix the store (Redis, Upstash, Supabase) or its connection. sealed-ai/service-busy is also answered for this reason.
sealed-ai/rate-limited, masked-ai/rate-limited 429 The user (or the route as a whole) passed a limit set in limits. The body says “Too many requests. Please wait a minute.” and Retry-After gives the seconds to wait. Nothing was sent to the provider. Show the message and wait Retry-After seconds. If real users hit it, raise the limit in limits.
sealed-ai/cross-origin, masked-ai/cross-origin 403 A browser marked the call as coming from another website (Sec-Fetch-Site: cross-site or same-site, or an Origin that is not this host). The body says “This request is not allowed from this website.” Call the route from your own site. If your front end is on another origin, list it in allowedOrigins. Calls with no browser headers (curl, servers) are not affected.
sealed-ai/limits-no-user, masked-ai/limits-no-user 500 limits.perUser is set but the route cannot tell who the user is. Return { user: id } from authorize, or add limits.key.
sealed-ai/upstream-unreachable, masked-ai/upstream-unreachable 502 Your server could not reach the provider (or AMD, or GitHub for release records). Check the server’s internet access and baseURL; try again.

Route setup errors, thrown when the server starts:

Code Why Next step
sealed-ai/bad-provider, masked-ai/bad-provider provider is not one of the accepted values ("tinfoil"; or "openai", "anthropic", "gemini", "openai-compatible"). Fix provider.
sealed-ai/missing-api-key, masked-ai/missing-api-key apiKey is empty. Read the key from a server environment variable and check it is set.
masked-ai/missing-base-url "openai-compatible" needs baseURL. Add it, for example https://openrouter.ai/api/v1.
sealed-ai/bad-base-url, masked-ai/bad-base-url baseURL is not a valid address. Write it in full.
sealed-ai/insecure-base-url, masked-ai/insecure-base-url baseURL is not https (http is only for localhost). Use https.
sealed-ai/bad-max-body, masked-ai/bad-max-body maxBodyBytes is not a positive whole number. Fix it.
sealed-ai/bad-limits, masked-ai/bad-limits limits is not valid: a limit that is not a positive whole number, an unknown name (a typo such as requestsPerHour), a key that is not a function, a store without increment, or (Sealed AI) maxOutputTokens, which cannot work on encrypted bodies. Fix it as the message says, for example limits: { perUser: { requestsPerMinute: 10, requestsPerDay: 200 } }.
sealed-ai/bad-allowed-origins, masked-ai/bad-allowed-origins An allowedOrigins entry is not a full origin (*, no scheme, a path, a non-http address). Write each as https://app.example.com.
sealed-ai/bad-option, masked-ai/bad-option A timeout option (upstreamTimeoutMs, publicTimeoutMs) is not a positive whole number of milliseconds. Fix it.

Browser guards, thrown before anything is sent:

Code Why Next step
sealed-ai/key-in-browser, masked-ai/key-in-browser A real-looking provider key is in a header. Use apiKey: "not-used" and keep the key in the route. Rotate the old key.
sealed-ai/not-via-route, masked-ai/not-via-route The baseURL does not go through /sealed-ai/ or /masked-ai/. Set baseURL to your route as the message shows.
Code Why Next step
sealed-ai/not-verified The browser could not check the AI server, so nothing was sent. The message says which step failed (the route answered 401, a document could not be fetched, the evidence or release check failed, the browser lacks WebAssembly or Ed25519). Do not send the chat another way. Follow the message; try again later. If it keeps failing, tell your Geometer contact.
sealed-ai/service-busy, sealed-ai/upstream-timeout In the browser: the certificate or release service is busy (429 or 503), or an evidence call through your route did not answer within evidenceTimeoutMs (20 s) or answered 504. Nothing was sent. A copy kept on the device that is still valid is used instead, an expired one never is. Try again in a minute. These are not setup mistakes.
sealed-ai/release-too-old The server runs a provider release older than the SDK’s floor (or your minRelease). Update @geometer/trust, or ask the provider to deploy a current release.
sealed-ai/bad-response The answer failed the seal check, or was cut or changed on the way. Nothing after that point is shown. Try again. If it keeps failing, something between you and the server is altering answers.
sealed-ai/plain-body The route got a body that was not sealed (400). Add fetch: sealedFetch() to the browser client.
sealed-ai/unsupported-path The browser client only seals POST to chat completions and responses. Use the client’s chat methods, or call that endpoint from your server.
sealed-ai/bad-option expectedMeasurement or minRelease is not in the right form. Fix the option as the message says.
sealed-ai/no-expected-measurement release: false without expectedMeasurement. Pin the measurement, or leave release alone.
Code Why Next step
masked-ai/unmaskable-part The request has an image, file or audio part (a Gemini inlineData or fileData part too). Nothing was sent. Remove it, or describe it in text.
masked-ai/body-not-json The body is not JSON. Use the openai or @anthropic-ai/sdk client.
masked-ai/unsupported-method A method other than POST (GET passes through). Use the client’s chat methods.
masked-ai/unsupported-path The endpoint is not chat completions, responses, messages or Gemini generateContent / streamGenerateContent. Use one of those, or call the endpoint from your server.
masked-ai/unsupported-media-type The route got a body that is not application/json (415). Use the client, which sets it.
Code Why Next step
proof/no-receipts There is nothing to export yet. Make a Vault, Sealed AI or Masked AI call first.
proof/write-failed A receipt could not be written (storage blocked, or another tab kept writing). The chat is not affected. It reaches you through onReceiptError. Check that the browser allows storage for this site; try again.
proof/receipt-invalid A receipt is not in the exact form it was written. Do not rely on it. Export the receipts again from the device that wrote them.
proof/ledger-damaged A stored receipt entry no longer matches its hash. Do not rely on this device’s receipts. Export what is left and check it with trust-verify.