export type CredentialPayload = { headers: Record; secret?: string; keyId?: string; } & Record; /** The at-rest form. All byte fields base64. The fingerprint is a short keyed hash (HMAC) * of the payload — enough for an operator to recognize "the key ending a1b2…", never * enough to recover anything. `v: 1` wraps the DEK under a key the host holds; `v: 2` has a * vault's transit engine wrap it (company decision 0034), naming the transit key that did. */ export type SealedCredential = SealedUnderKey | SealedByVault; type SealedBody = { iv: string; ciphertext: string; placedAt: string; fingerprint: string; rotatedAt?: string; /** where the credential may be sent (`origin=https://…`), part of the AEAD's associated data: a record opens for * its own destination and no other, so a root or link pointed elsewhere never carries it there (the executor also * sends it to the hosts its vendor's pack declares: code, not configuration) */ bound?: string; }; export type SealedByVault = SealedBody & { v: 2; /** `/` of the transit key that wrapped the DEK */ transitKey: string; /** the vault's own ciphertext of the DEK (`vault:vN:…`) */ wrappedDek: string; }; export type SealedUnderKey = { v: 1; dekIv: string; wrappedDek: string; iv: string; ciphertext: string; placedAt: string; fingerprint: string; /** when a vendor last rotated a field of it (an OAuth refresh token): placedAt and fingerprint stay the credential's * identity across rotations, the ledgers keyed by the fingerprint with them */ rotatedAt?: string; /** as SealedBody's: the destination the credential is bound to, in its associated data */ bound?: string; }; export interface CredentialStorage { getSealed(namespace: string, vendor: string): Promise; putSealed(namespace: string, vendor: string, sealed: SealedCredential): Promise; deleteSealed(namespace: string, vendor: string): Promise; /** Purge every vendor's sealed record for the namespace — the lifecycle DELETE calls * this: a deleted namespace's credentials must not survive to be inherited by * whoever re-provisions the name. */ deleteNamespace(namespace: string): Promise; } export declare function sealCredential(kekSecret: string, payload: CredentialPayload, placedAt: string, slot?: string, bound?: string): Promise; export declare function openSealedCredential(kekSecret: string, sealed: SealedCredential, slot?: string, bound?: string): Promise; /** What a rewrap made of a record: its new form, current (already under the newest version), or not this sealer's to * vouch for (another key's, or an answer whose version it could not read): only `current` says nothing is left. */ export type Rewrapped = { status: 'rewrapped'; sealed: SealedCredential; } | { status: 'current'; } | { status: 'foreign'; reason: string; }; /** Seals and opens credentials. A host chooses one (`setSealer`); a key it holds (`keySealer`), or a vault that holds * the key and wraps for it (`transitSealer`). */ export interface Sealer { /** `bound`: the destination the credential may be sent to, sealed into the record (see SealedBody) */ seal(payload: CredentialPayload, placedAt: string, slot?: string, bound?: string): Promise; /** `bound`: the destination it is opened for; a record bound elsewhere refuses */ open(sealed: SealedCredential, slot?: string, bound?: string): Promise; /** The record with its DEK wrapped under the newest version of its key, without the DEK leaving the sealer (a * vault's `transit/rewrap` after a rotation): `rewrapped` with its new form, `current` when it already is, `foreign` * when it is not this sealer's to vouch for. What an operator's sweep runs after rotating a key, before raising its * minimum decryption version. */ rewrap?(sealed: SealedCredential): Promise; } /** Wraps under a key the host holds (the user's key file, a deployment secret): `v: 1` records. */ export declare function keySealer(kekSecret: () => string): Sealer; export type TransitSealerOptions = { /** the vault's address (`https://…`, or `http://` to loopback) */ addr: string; /** a token that may encrypt, decrypt and hmac with the key */ token: () => string | Promise; /** the transit key's name */ key: string; /** the transit engine's mount (default `transit`) */ mount?: string; namespace?: string; /** the transit key that keys every fingerprint (default `-fingerprint`): one that is never rotated, so a * credential's fingerprint, and every ledger keyed by it, stays as it was while the wrapping key is rotated and its * min_encryption_version raised (an hmac at a pinned version of a rotated key is refused once that version is too * old). A wrapping key's old versions are never trimmed: a record's DEK stays under the version that wrapped it */ fingerprintKey?: string; /** how long an opened DEK is kept in memory, ms (default 60 000): a burst of vendor calls asks the vault once */ dekCacheMs?: number; /** how long a vault call may take, ms (default 10 000) */ timeoutMs?: number; fetch?: typeof fetch; /** renew the token (auth/token/renew-self) after calls, at most daily (default true); false where something else * holds and renews it (the hosted Worlds' supervisor) */ renew?: boolean; }; /** * OpenBao's (or Vault's) transit engine wraps each credential's DEK: the key never leaves the vault. The payload is * sealed as `v: 1` seals it (a random DEK, AES-GCM, the slot as AAD); the vault encrypts the DEK and keys the * fingerprint (`transit/hmac`). `v: 2` records name `/`; a record from another key refuses. */ export declare function transitSealer(options: TransitSealerOptions): Sealer; export {};