UNPKG

askexperts

Version:

AskExperts SDK: build and use AI experts - ask them questions and pay with bitcoin on an open protocol

31 lines (30 loc) 1.05 kB
/** * Interface for HTTP requests with authorization headers */ export interface AuthRequest { headers: { authorization?: string; [key: string]: any; }; method: string; originalUrl: string; cookies: any; rawBody?: Buffer; req?: any; } /** * Parse and validate a NIP-98 authentication token * @param origin - Origin URL for validation * @param req - Request object with headers and other properties * @returns Public key if token is valid, empty string otherwise */ export declare function parseAuthToken(origin: string, req: AuthRequest): Promise<string>; /** * Create a NIP-98 auth token for WebSocket connection * @param privateKey - The private key to sign the event with (as Uint8Array) * @param url - The URL to connect to * @param method - The HTTP method (usually 'GET' for WebSocket) * @param body - Optional request body * @returns The authorization header value */ export declare function createAuthToken(privateKey: Uint8Array, url: string, method: string, body?: string): string;