UNPKG

@code-yeongyu/senpi

Version:

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

80 lines • 3.78 kB
export type DeviceId = string; export interface ServiceSig { readonly alg: "ECDSA-P256-SHA256"; readonly keyId: string; /** Base64 of the DER-encoded ECDSA signature, as KMS `Sign` returns it. */ readonly sig: string; } export interface DeviceKemEntry { readonly kind: "device-kem"; readonly deviceId: DeviceId; readonly kemPk: string; readonly sig: string; } export interface ServiceKeyAttestation { readonly deviceId: DeviceId; readonly checkedAt: number; readonly sig: string; } export type ServiceKeyKind = "custody" | "placement-registry"; export interface ServiceKeyEntry { readonly kind: ServiceKeyKind; readonly accountId: string; readonly generation: number; /** Custody only: the P-256 key-agreement key (base64 SPKI DER) and its id. */ readonly kemKeyId?: string; readonly kemPk?: string; /** The ECDSA P-256 signing key (base64 SPKI DER) and its id. */ readonly sigKeyId: string; readonly sigPk: string; readonly kmsKeyArns: readonly string[]; /** Which pinned `KeyPolicyTemplate` the KMS keys were created with. */ readonly templateVersion: number; readonly role: "current" | "standby"; /** Placement-registry only: the `sigKeyId` of the registry generation this entry revokes. */ readonly supersedes?: string; readonly createdAt: number; readonly serviceSig: ServiceSig; /** Informational only: never consulted by any validity decision. */ readonly attestations: readonly ServiceKeyAttestation[]; } /** * This device's view of its account roster: UNKNOWN until a roster sync has been proven good. A known view keeps * the verified roster's `rv`, `iat` and `exp` (ms) and the local monotonic time it was received (15.15 H-1). */ export type RosterView = { readonly state: "unknown"; } | { readonly state: "known"; readonly serviceEntries: readonly ServiceKeyEntry[]; readonly rosterVersion: number; readonly rosterIssuedAt: number; readonly rosterExpiresAt: number; readonly receivedMono: number; }; /** * The view as of wall-clock `now` and monotonic `nowMono`: `unknown` at the earlier of the roster's lifetime * elapsed on the monotonic clock since receipt and `max(now, iat) >= exp` on the wall clock (15.15 H-1, 15.16 M-1). */ export declare function rosterViewAt(view: RosterView, now: number, nowMono: number): RosterView; /** The view to hold after verifying `incoming`: it replaces `held` only when strictly newer (15.16 M-2). */ export declare function heldRosterView(held: RosterView, incoming: RosterView): RosterView; export declare function parseDeviceKemEntry(value: unknown): DeviceKemEntry | undefined; /** * Strict parser for a service key entry. Kind-specific shape is enforced here so later checks never see * a custody entry without a KEM key, a registry entry carrying one, or `supersedes` on a custody entry. */ export declare function parseServiceKeyEntry(value: unknown): ServiceKeyEntry | undefined; /** * The bytes `serviceSig` covers: the canonical JSON of every field except `serviceSig` itself and the * informational `attestations` (devices append those after signing). Absent optional fields are omitted, * never serialized as null. */ export declare function serviceEntrySigningPayload(entry: ServiceKeyEntry): Uint8Array<ArrayBuffer>; /** * `serviceSig` is a self-signature: made with the entry's own signing key (`keyId === sigKeyId`) over * `serviceEntrySigningPayload`. It proves the entry's fields were signed by that KMS key; whether the key * itself is trustworthy is decided only by this device's own `checkServiceKey` record. */ export declare function verifyServiceSig(entry: ServiceKeyEntry): Promise<boolean>; //# sourceMappingURL=roster-entries.d.ts.map