Suite of AT Protocol TypeScript libraries built on web standards
1export interface Signer {
2 jwtAlg: string;
3 sign(msg: Uint8Array): Uint8Array;
4}
5
6export interface Didable {
7 did(): string;
8}
9
10export interface Keypair extends Signer, Didable {}
11
12/**
13 * Keypair with an export method.
14 * @prop export - Exports the keypair as a Uint8Array.
15 */
16export interface ExportableKeypair extends Keypair {
17 export(): Promise<Uint8Array>;
18}
19
20/**
21 * DID key plugin with key compression and signature verification utilities.
22 * @prop prefix - The DID key prefix.
23 * @prop jwtAlg - The JWT algorithm used for signing.
24 * @prop verifySignature - Verifies a signature for the given message bytes.
25 * @prop compressPubkey - Compresses a public key.
26 * @prop decompressPubkey - Decompresses a compressed public key.
27 */
28export type DidKeyPlugin = {
29 prefix: Uint8Array;
30 jwtAlg: string;
31 verifySignature: (
32 did: string,
33 msg: Uint8Array,
34 data: Uint8Array,
35 opts?: VerifyOptions,
36 ) => boolean;
37
38 compressPubkey: (uncompressed: Uint8Array) => Uint8Array;
39 decompressPubkey: (compressed: Uint8Array) => Uint8Array;
40};
41
42/**
43 * Options for less strict signature verification.
44 * These options are only recommended for testing purposes.
45 * @prop allowMalleableSig - Don't enforce low-S signatures. Explicitly against specification. Only recommended for testing purposes.
46 * @prop allowDerSig - Allow DER-encoded signatures. Only recommended for testing purposes.
47 */
48export type VerifyOptions = {
49 allowMalleableSig?: boolean;
50 allowDerSig?: boolean;
51};