import { ECPublicKey } from '2key-ratchet'; import { EventEmitter } from 'events'; /** * Generates 6 digit string from server's identity and client's identity keys. * * @param serverIdentity Server's identity public key * @param clientIdentity Client's identity public key * @returns */ declare function challenge(serverIdentity: ECPublicKey, clientIdentity: ECPublicKey): Promise; declare const SERVER_WELL_KNOWN = "/.well-known/webcrypto-socket"; declare type LogLevel = "error" | "warn" | "info" | "debug"; declare type LogHandler = (level: LogLevel, source: string, message: string, data?: LogData) => void; interface LogData { [key: string]: any; } declare abstract class EventLogEmitter extends EventEmitter { abstract source: string; on(event: "info", listener: LogHandler): this; on(event: string | symbol, listener: (...args: any[]) => void): this; once(event: "info", listener: LogHandler): this; once(event: string | symbol, listener: (...args: any[]) => void): this; emit(event: "info", level: LogLevel, source: string, message: string, data?: LogData): boolean; emit(event: string | symbol, ...args: any[]): boolean; protected log(level: LogLevel, message: string, data?: LogData): void; } declare class Event { readonly target: T; readonly event: string; constructor(target: T, event: string); } interface CryptoServicePolicy { requirePasswordOnAllKeys: boolean; maxNumberOfKeys: number; maxKeyAge: number; } interface CryptoServiceAlgorithm { name: string; } interface CryptoServiceRsaAlgorithm extends CryptoServiceAlgorithm { modulusLengths: number[]; publicExponents: ArrayBufferView; } interface CryptoServiceSecretAlgorithm extends CryptoServiceAlgorithm { lengths: number[]; } interface CryptoServiceEcAlgorithm extends CryptoServiceAlgorithm { namedCurves: string[]; } interface CryptoServiceEcdhAlgorithm extends CryptoServiceEcAlgorithm { derivedKeyTypes: CryptoServiceSecretAlgorithm[]; } interface CryptoService { name: string; policy: CryptoServicePolicy; supportedAlgorithms: CryptoServiceAlgorithm[]; } interface ServerInfo { id: string; type: string; version: string; cryptoServices: CryptoService[]; preKey: string; } interface Version { major: number; minor: number; } interface TokenInfo { /** * application-defined label, assigned during token initialization. */ label: string; /** * ID of the device manufacturer. */ manufacturerID: string; /** * model of the device. */ model: string; /** * character-string serial number of the device */ serialNumber: string; /** * bit flags indicating capabilities and status of the device */ flags: number; /** * maximum number of sessions that can be opened with the token at one time by a single application */ maxSessionCount: number; /** * number of sessions that this application currently has open with the token */ sessionCount: number; /** * maximum number of read/write sessions that can be opened * with the token at one time by a single application */ maxRwSessionCount: number; /** * number of read/write sessions that this application currently has open with the token */ rwSessionCount: number; /** * maximum length in bytes of the PIN */ maxPinLen: number; /** * minimum length in bytes of the PIN */ minPinLen: number; /** * the total amount of memory on the token in bytes in which objects may be stored */ totalPublicMemory: number; /** * the amount of free (unused) memory on the token in bytes for objects */ freePublicMemory: number; /** * the total amount of memory on the token in bytes in which private objects may be stored */ totalPrivateMemory: number; /** * the amount of free (unused) memory on the token in bytes for private objects */ freePrivateMemory: number; /** * version number of hardware */ hardwareVersion: Version; firmwareVersion: Version; } interface ProviderCrypto { name: string; card: string; id: string; readOnly: boolean; library?: string; atr?: string; algorithms: string[]; isHardware: boolean; isRemovable: boolean; token?: TokenInfo; } interface IModule { name: string; providers: ProviderCrypto[]; } interface Assoc { [key: string]: T; } interface TokenInfoEvent { removed: ProviderCrypto[]; added: ProviderCrypto[]; error?: Error; } export { Assoc, CryptoService, CryptoServiceAlgorithm, CryptoServiceEcAlgorithm, CryptoServiceEcdhAlgorithm, CryptoServicePolicy, CryptoServiceRsaAlgorithm, CryptoServiceSecretAlgorithm, Event, EventLogEmitter, IModule, LogData, LogHandler, LogLevel, ProviderCrypto, SERVER_WELL_KNOWN, ServerInfo, TokenInfo, TokenInfoEvent, Version, challenge };