import type { SignatureScheme, Signer } from "./Signer.js"; import type { Session } from "./Session.js"; import type { Awaitable } from "./Awaitable.js"; import { MessageType } from "./MessageType.js"; export type DidIdentifier = `did:${string}`; export interface AbstractSessionData { topic: string; did: DidIdentifier; publicKey: string; context: { timestamp: number; duration: number | null; }; } export interface SessionSigner { scheme: SignatureScheme>; match: (did: DidIdentifier) => boolean; isReadOnly: () => boolean; getDid: () => Awaitable; getDidParts: () => number; getAddressFromDid: (did: DidIdentifier) => string; getCurrentTimestamp: () => number; listAllSessions: (topic: string, did?: DidIdentifier) => string[]; clearAll: (topic: string) => Awaitable; hasSession: (topic: string, did?: DidIdentifier) => Promise; clearSession: (topic: string) => Awaitable; getSession: (topic: string, options?: { did?: DidIdentifier; } | { address: string; }) => Awaitable<{ payload: Session; signer: Signer>; } | null>; newSession: (topic: string) => Awaitable<{ payload: Session; signer: Signer>; }>; /** * Request a signature from the signer's Wallet, and use it to return a session. */ authorize(data: AbstractSessionData, authorizationData?: AuthorizationData): Awaitable>; /** * Verify that `session.data` authorizes `session.publicKey` to take actions on behalf of the user `session.did`. */ verifySession: (topic: string, session: Session) => Awaitable; /** * A unique identifier based on the signer's arguments, used to trigger React effects. * This should not change unless user-provided arguments to the signers change. * * For example, the key for `new SIWESigner()` should always remain the same, even if * a different burner wallet is generated on every call. */ key: string; }