Skip to content

createWrappedKeyId

createWrappedKeyId<Brand, Kind>(brand, opts): WrappedKeyCodec<Brand, Kind>

Defined in: src/codecs/wrapped/index.ts:276

Construct a WrappedKeyCodec for brand and the given kind.

opts.kind fixes the integer type at construction time — one brand, one kind. opts.keys is a non-empty ordered wrapping keyring: the first entry is current (used by wrap); all entries are tried on unwrap; duplicate operator secrets are rejected at construction.

Brand extends string

Kind extends WrappedKind

Brand & ValidBrand<Brand>

WrappedKeyOptions<Kind>

WrappedKeyCodec<Brand, Kind>

const key = await importWrappingKey(new Uint8Array(32));
const invoices = createWrappedKeyId("inv", { kind: "u32", keys: [key] });
const id = await invoices.wrap(42); // Id<"inv">
await invoices.unwrap(id); // 42