UNPKG

@slide-computer/signer-agent

Version:

Initiate transactions with signers on the Internet Computer

55 lines (54 loc) 2.13 kB
import type { Connection } from "@slide-computer/signer"; import { DelegationChain } from "@dfinity/identity"; import { type SignerStorage } from "@slide-computer/signer-storage"; import { SignIdentity } from "@dfinity/agent"; import { PartialIdentity } from "@dfinity/identity/lib/cjs/identity/partial"; declare const ECDSA_KEY_LABEL = "ECDSA"; declare const ED25519_KEY_LABEL = "Ed25519"; type BaseKeyType = typeof ECDSA_KEY_LABEL | typeof ED25519_KEY_LABEL; export interface StoicConnectionOptions { /** * Expiration of the connection in nanoseconds * @default BigInt(8) hours * BigInt(3_600_000_000_000) nanoseconds */ maxTimeToLive?: bigint; /** * An {@link SignIdentity} or {@link PartialIdentity} to authenticate via delegation. */ identity?: SignIdentity | PartialIdentity; /** * type to use for the base key * @default 'ECDSA' * If you are using a custom storage provider that does not support CryptoKey storage, * you should use 'Ed25519' as the key type, as it can serialize to a string */ keyType?: BaseKeyType; /** * Optional storage with get, set, and remove * @default Uses {@link IdbStorage} by default */ storage?: SignerStorage; /** * Optional, used to generate random bytes and Stoic app CryptoKeyPair * @default globalThis.crypto */ crypto?: Pick<Crypto, "getRandomValues" | "subtle">; /** * Disconnect monitoring interval in ms * @default 3000 */ disconnectMonitoringInterval?: number; } export declare class StoicConnection implements Connection { #private; constructor(options: Required<StoicConnectionOptions>, delegationChain?: DelegationChain, accounts?: number); get connected(): boolean; get identity(): SignIdentity; get delegationChain(): DelegationChain | undefined; get accounts(): number | undefined; static create(options?: StoicConnectionOptions): Promise<StoicConnection>; connect(): Promise<void>; disconnect(): Promise<void>; addEventListener(event: "disconnect", listener: () => void): () => void; } export {};