/** * Auth Types * * Types for authentication operations including challenge creation, * signature verification, and backend authentication. */ import type { BaseAPI } from "../api"; import type { AuthState, BackendAuthResponse, ChallengeResponse, TokenRefreshResponse } from "./responses"; /** * Auth API interface. * Provides methods for frontend and backend authentication. * Handles challenge creation, signature verification, and backend auth. */ export interface AuthAPI extends BaseAPI { /** * Complete authentication flow for frontend applications. * * This method handles the entire authentication process: * 1. Creates a challenge * 2. Signs the challenge message * 3. Verifies the signature and returns JWT tokens * * @param clientId - Client ID of the application * @returns Promise resolving to the authentication state with JWT tokens */ authenticate(clientId: string): Promise; /** * Signs a challenge message using the wallet client. * * Signs the provided message using the wallet's private key. * This is used in the authentication flow to prove ownership of the wallet. * * @param message - The message to sign * @returns Promise resolving to the signature */ signChallenge(message: string): Promise; /** * Creates a challenge for frontend authentication. * Generates a unique nonce and message that the user must sign with their wallet. * @param address - Wallet address of the user * @param clientId - Client ID of the application * @returns Promise resolving to the challenge response */ createChallenge(address: string, clientId: string): Promise; /** * Verifies a signature for frontend authentication. * Validates the signature against the challenge and returns JWT tokens. * @param address - Wallet address of the user * @param signature - Signature of the challenge message * @param nonce - Nonce from the challenge response * @param clientId - Client ID of the application * @returns Promise resolving to the authentication state with JWT tokens */ verifySignature(address: string, signature: string, nonce: string, clientId: string): Promise; /** * Authenticates a backend service using a secret key. * Returns JWT tokens for API access. * @param secretKey - Secret key of the application * @returns Promise resolving to the backend auth response with JWT tokens */ authenticateBackend(secretKey: string): Promise; /** * Refreshes an access token using a refresh token. * @param refreshToken - The refresh token to use * @returns Promise resolving to new access and refresh tokens */ refreshToken(refreshToken: string): Promise; /** * Revokes the current session's refresh token. * The server identifies the token to revoke from the access token in the Authorization header. * @returns Promise resolving when the token is revoked */ revokeToken(): Promise; /** * Sets the wallet client for signing operations. * Used when the wallet becomes available after SDK initialization. * @param walletClient - The wallet client to set */ setWalletClient(walletClient: unknown): void; } export type { ApplicationInfo, AuthState, BackendAuthResponse, ChallengeResponse, TokenRefreshResponse, User, } from "./responses";