import { BaseProfile, AttestationData, User, TransactionResult } from "./types"; import { PolkadotClient, PolkadotSigner } from "polkadot-api"; import { CredentialsHandler, WebAuthn as PasskeysAuthenticator } from "@virtonetwork/authenticators-webauthn"; import NonceManager from "./nonceManager"; export default class Auth { private readonly baseUrl; private readonly credentialsHandler; private readonly clientFactory; private _client; private _passkeysAuthenticator; private _sessionSigner; private _currentUserId; private _nonceManager; private readonly sessionDuration; constructor(baseUrl: string, credentialsHandler: CredentialsHandler, clientFactory: () => Promise, nonceManager?: NonceManager, expiresIn?: number); /** * Set the NonceManager instance for this Auth instance * This allows the Auth to increment nonces after successful connections * * @param nonceManager - The NonceManager instance to use */ setNonceManager(nonceManager: NonceManager): void; private getClient; register(user: User): Promise; /** * This method is only available in browser environments as it uses WebAuthn APIs. * It performs the complete registration process by: * 1. Preparing registration data on the client side using WebAuthn * 2. Completing the registration on the server side * * @throws {VError} If credential creation fails * @param user - The user object containing profile and metadata * @returns Promise with the registration result */ prepareRegistration(user: User): Promise<{ attestation: AttestationData; hashedUserId: string; credentialId: string; userId: string; passAccountAddress: string; }>; completeRegistration(attestation: AttestationData, hashedUserId: string, credentialId: string, userId: string, address: string): Promise; /** * Resets the Auth state, clearing any stored PasskeysAuthenticator and session signer * This is useful when switching between different users or starting fresh */ reset(): void; /** * Checks if a PasskeysAuthenticator is available for use * * @returns true if a PasskeysAuthenticator is available, false otherwise */ isAuthenticated(): boolean; /** * Checks if a session signer is available for use * * @returns true if a session signer is available, false otherwise */ hasSessionSigner(): boolean; /** * Gets the stored PasskeysAuthenticator instance * * @returns The PasskeysAuthenticator instance or null if not available */ get passkeysAuthenticator(): PasskeysAuthenticator | null; /** * Gets the stored session signer * * @returns The session signer or null if not available */ get sessionSigner(): any | null; get currentUserId(): string | null; /** * Get the public key from a PasskeysAuthenticator as an SS58 address * * @param sessionSigner - The session signer instance * @returns The SS58 encoded address * * @example * const address = auth.getAddressFromAuthenticator(auth.passkeysAuthenticator); * console.log("User address:", address); */ getAddressFromAuthenticator(sessionSigner: any): string; connect(userId: string): Promise<{ sessionKey: import("polkadot-api").SS58String; sessionSigner: PolkadotSigner & { sign: import("@virtonetwork/signer/dist/esm/sr25519").SignFn; }; address: string; transaction: unknown; }>; prepareConnection(userId: string): Promise<{ hashedUserId: Uint8Array; userId: string; }>; completeConnection(): Promise<{ sessionKey: import("polkadot-api").SS58String; sessionSigner: PolkadotSigner & { sign: import("@virtonetwork/signer/dist/esm/sr25519").SignFn; }; address: string; transaction: unknown; }>; /** * Signs a command using the user's wallet * This method retrieves the user's wallet from the session manager and uses it to sign the provided command * * @param userId - The ID of the user whose wallet will be used to sign * @param command - The command object containing the data to be signed * @returns Promise with the signed extrinsic and original command data * @throws Will throw an error if the wallet cannot be retrieved from the session manager */ isRegistered(userId: string): Promise; private blockHashChallenge; addMember(userId: string): Promise; isMember(address: string): Promise; sign(extrinsic: string): Promise; } //# sourceMappingURL=auth.d.ts.map