@ldclabs/cose-ts
Version:
Implemented Keys, Algorithms (RFC9053), COSE (RFC9052) and CWT (RFC8392) in TypeScript.
31 lines (30 loc) • 1.46 kB
TypeScript
export type Label = number | string;
export type Value = number | string | Uint8Array | boolean | Value[] | RawMap;
export type RawMap = Map<Label, Value>;
export type AssertFn<T> = (value: unknown, name: string) => T;
export declare function assertText(value: unknown, name: string): string;
export declare function assertInt(value: unknown, name: string): number;
export declare function assertIntOrText(value: unknown, name: string): number | string;
export declare function assertBytes(value: unknown, name: string): Uint8Array;
export declare function assertBool(value: unknown, name: string): boolean;
export declare function assertMap(value: unknown, name: string): RawMap;
export declare class KVMap {
private _raw;
static fromBytes(data: Uint8Array): KVMap;
constructor(kv?: RawMap);
has(key: Label): boolean;
delete(key: Label): boolean;
getInt(key: Label, name?: string): number;
getText(key: Label, name?: string): string;
getBytes(key: Label, name?: string): Uint8Array;
getBool(key: Label, name?: string): boolean;
getType<T>(key: Label, assertFn: AssertFn<T>, name?: string): T;
getArray<T>(key: Label, assertFn: AssertFn<T>, name?: string): T[];
getParam<T>(key: Label): T | undefined;
setParam(key: Label, value: Value): this;
getCBORParam<T>(key: Label): T | undefined;
setCBORParam<T>(key: Label, value: T): this;
clone(): RawMap;
toRaw(): RawMap;
toBytes(): Uint8Array;
}