UNPKG

@code-yeongyu/senpi

Version:

Coding agent CLI with read, bash, edit, write tools and session management

101 lines • 4.67 kB
import { type HpkeRecipient } from "./hpke.ts"; export { SealedFormatError, type SealedFormatErrorCode } from "./hpke.ts"; export type ProviderId = string; export type DeviceId = string; export type SecretField = "apiKey" | `credential:${number}` | `header:${string}` | `modelHeader:${string}:${string}` | "urlUserinfo" | `urlPath:${number}` | `urlQuery:${string}`; declare const sourceDigestBrand: unique symbol; declare const dekIdBrand: unique symbol; export type SourceDigest = string & { readonly [sourceDigestBrand]: true; }; export type DekId = string & { readonly [dekIdBrand]: true; }; /** The one boundary parser for a source digest read from an entry; a FieldAad cannot be built without one. */ export declare function parseSourceDigest(value: string): SourceDigest; /** The one boundary parser for a dekId read from an entry; a FieldAad cannot be built without one. */ export declare function parseDekId(value: string): DekId; export interface FieldAad { readonly account: string; readonly provider: ProviderId; readonly owner: DeviceId; readonly sourceDigest: SourceDigest; readonly field: SecretField; readonly dekId: DekId; } export type WrapKind = "cfg" | "dek" | "proj"; export interface WrapPosition { readonly account: string; readonly kind: WrapKind; readonly id: string; } export interface WrapAad extends WrapPosition { readonly recipientKeyId: string; } export interface ConfigAad { readonly accountId: string; readonly version: number; readonly cfgKeyId: string; } export declare const HPKE_SUITE = "DHKEM(P-256,HKDF-SHA256)/HKDF-SHA256/AES-256-GCM"; export interface HpkeWrap { readonly suite: typeof HPKE_SUITE; readonly enc: string; readonly ct: string; } export interface SealedBlob { readonly nonce: string; readonly ct: string; } export type FieldSource = "literal" | "env" | "command" | "oauth_access"; export interface SealedFieldMeta { readonly source: FieldSource; readonly resolvedAt: number; readonly expiresAt?: number; readonly refreshable: boolean; } export type SealedField = ({ readonly v: 1; readonly state: "sealed"; readonly meta: SealedFieldMeta; } & SealedBlob) | { readonly v: 1; readonly state: "unresolved"; readonly meta: { readonly source: "env" | "command" | "oauth_access"; readonly attemptedAt: number; readonly refreshable: true; }; }; export interface ConfigEnvelope extends ConfigAad { readonly v: 1; readonly cfg: SealedBlob; } /** A recipient that knows its own key id: the opener's id, never one read from a stored wrap, enters the AAD. */ export interface KeyedRecipient extends HpkeRecipient { readonly keyId: string; } type Bytes = Uint8Array<ArrayBuffer>; /** @internal Exposed for the encoding vectors. */ export declare function fieldAadBytes(aad: FieldAad): Bytes; /** @internal Exposed for the encoding vectors. */ export declare function wrapAadBytes(aad: WrapAad): Bytes; /** @internal Exposed for the encoding vectors. */ export declare function configAadBytes(aad: ConfigAad): Bytes; /** Strict: no padding, no foreign characters, no non-zero trailing bits, so one byte string has one encoding. */ export declare function decodeBase64Url(value: string): Bytes; /** @internal Raw AES-256-GCM open, exposed for the external known-answer vector. Any failure is `open_failed`. */ export declare function aes256GcmOpen(key: Uint8Array, nonce: Uint8Array, aad: Uint8Array, ct: Uint8Array): Promise<Bytes>; /** Seals one secret under the provider DEK. Empty secrets are never sealed. */ export declare function sealField(dek: Uint8Array, aad: FieldAad, secret: string, meta: SealedFieldMeta): Promise<Extract<SealedField, { state: "sealed"; }>>; /** Opens a sealed field under the AAD the opener rebuilt from the entry and the requested position. */ export declare function openField(dek: Uint8Array, aad: FieldAad, field: SealedField): Promise<Bytes>; export declare function sealConfig(kCfg: Uint8Array, aad: ConfigAad, plaintext: Uint8Array): Promise<SealedBlob>; /** Opens the config object; its AAD is rebuilt from the envelope's own public fields. */ export declare function openConfig(kCfg: Uint8Array, envelope: ConfigEnvelope): Promise<Bytes>; export declare function wrapKey(recipientPublicKey: Uint8Array, aad: WrapAad, key: Uint8Array): Promise<HpkeWrap>; /** Opens a wrap at `position` with the recipient's own key id; nothing read from the wrap enters the AAD. */ export declare function unwrapKey(recipient: KeyedRecipient, position: WrapPosition, wrap: HpkeWrap): Promise<Bytes>; //# sourceMappingURL=sealed-format.d.ts.map