import { Salter } from './salter.ts'; import { Algos } from './manager.ts'; import { Tier } from './salter.ts'; import { Signer } from './signer.ts'; import { HabState, KeyState } from './keyState.ts'; /** External module definition */ export interface ExternalModuleType { new (pidx: number, args: IdentifierManagerParams): IdentifierManager; } export interface ExternalModule { type: string; name: string; module: ExternalModuleType; } export type IdentifierManagerResult = [string[], string[]]; export type SignResult = string[]; export interface IdentifierManagerParams { [key: string]: unknown; } export interface SaltyManagerParams extends IdentifierManagerParams { pidx: number; kidx: number; tier: Tier; transferable: boolean; stem: string | undefined; icodes: string[] | undefined; ncodes: string[] | undefined; dcode: string | undefined; sxlt: string | undefined; } export interface RandyManagerParams extends IdentifierManagerParams { nxts?: string[]; prxs?: string[]; transferable: boolean; } export interface GroupManagerParams extends IdentifierManagerParams { mhab: HabState; } /** * Interface for KERI identifier (prefix) creation, rotation, and signing. * @param T Type of the key keeper */ export interface IdentifierManager { algo: Algos; signers: Signer[]; params(): T; incept(transferable: boolean): Promise; rotate(ncodes: string[], transferable: boolean, states?: KeyState[], rstates?: KeyState[]): Promise; sign(ser: Uint8Array, indexed?: boolean, indices?: number[], ondices?: number[]): Promise; } /** * Creates IdentifierManager instances based on the algorithm and key indexes. */ export declare class IdentifierManagerFactory { private salter; private modules; /** * Creates a factory for generating IdentifierManagers. Requires a salt to be specified. * Allows external key management modules to be configured. * @param salter * @param externalModules */ constructor(salter: Salter, externalModules?: ExternalModule[]); /** * * @param algo * @param pidx * @param kargs */ new(algo: Algos, pidx: number, kargs: any): IdentifierManager | GroupIdentifierManager; /** * Generates an algorithm-specific IdentifierManager instance with correct keys based on * the indexes provided by the HabState. * @param aid HabState with the algorithm and key indexes * @returns IdentifierManager instance */ get(aid: HabState): IdentifierManager; } export declare class SaltyIdentifierManager implements IdentifierManager { private aeid; private encrypter; private decrypter; private salter; private pidx; private kidx; private tier; private transferable; private stem; private code; private count; private icodes; private ncode; private ncount; private ncodes; private dcode; private sxlt; private bran; private creator; algo: Algos; signers: Signer[]; constructor(salter: Salter, pidx: number, kidx?: number, tier?: Tier, transferable?: boolean, stem?: string | undefined, code?: string, count?: number, icodes?: string[] | undefined, ncode?: string, ncount?: number, ncodes?: string[] | undefined, dcode?: string, bran?: string | undefined, sxlt?: string | undefined); params(): SaltyManagerParams; incept(transferable: boolean): Promise; rotate(ncodes: string[], transferable: boolean): Promise<[string[], string[]]>; sign(ser: Uint8Array, indexed?: boolean, indices?: number[] | undefined, ondices?: number[] | undefined): Promise; } export declare class RandyIdentifierManager implements IdentifierManager { private salter; private code; private count; private icodes; private transferable; private ncount; private ncodes; private ncode; private dcode; private prxs; private nxts; private aeid; private encrypter; private decrypter; private creator; algo: Algos; signers: Signer[]; constructor(salter: Salter, code: string | undefined, count: number | undefined, icodes: string[] | undefined, transferable: boolean | undefined, ncode: string | undefined, ncount: number | undefined, ncodes: string[], dcode?: string, prxs?: string[] | undefined, nxts?: string[] | undefined); params(): RandyManagerParams; incept(transferable: boolean): Promise; rotate(ncodes: string[], transferable: boolean): Promise; sign(ser: Uint8Array, indexed?: boolean, indices?: number[] | undefined, ondices?: number[] | undefined): Promise; } export declare class GroupIdentifierManager implements IdentifierManager { private manager; private mhab; private gkeys; private gdigs; algo: Algos; signers: Signer[]; constructor(manager: IdentifierManagerFactory, mhab: HabState, states?: KeyState[] | undefined, rstates?: KeyState[] | undefined, keys?: string[], ndigs?: string[]); incept(): Promise; /** * Performs a multisig rotation * @param _ncodes * @param _transferable * @param states * @param rstates key state records for the prior establishment event indicating next key digests. * You should pass in the current key */ rotate(_ncodes: string[], _transferable: boolean, states: KeyState[], rstates: KeyState[]): Promise; sign(ser: Uint8Array, indexed?: boolean): Promise; params(): { mhab: HabState; keys: string[]; ndigs: string[]; }; }