@bsv/authsocket-client
Version:
Mutually Authenticated Web Sockets Client
43 lines • 1.79 kB
TypeScript
import { Socket as IoClientSocket, ManagerOptions, SocketOptions } from 'socket.io-client';
import { RequestedCertificateSet, SessionManager, Peer, WalletInterface, OriginatorDomainNameStringUnder250Bytes } from '@bsv/sdk';
/**
* Internal class that wraps a Socket.IO client connection with BRC-103 mutual authentication,
* enabling secure and identity-aware communication with a server.
*/
declare class AuthSocketClientImpl {
private readonly ioSocket;
private readonly peer;
connected: boolean;
id: string;
serverIdentityKey: string | undefined;
private readonly eventCallbacks;
/**
* Creates an instance of AuthSocketClient.
*
* @param ioSocket - The underlying Socket.IO client socket instance.
* @param peer - The BRC-103 Peer instance responsible for managing authenticated
* communication, including message signing and verification.
*/
constructor(ioSocket: IoClientSocket, peer: Peer);
on(eventName: string, callback: (data?: any) => void): this;
emit(eventName: string, data: any): this;
disconnect(): void;
private fireEventCallbacks;
private encodeEventPayload;
private decodeEventPayload;
}
/**
* Factory function for creating a new AuthSocketClientImpl instance.
*
* @param url - The server URL
* @param opts - Contains wallet, requested certificates, and other optional settings
*/
export declare function AuthSocketClient(url: string, opts: {
wallet: WalletInterface;
requestedCertificates?: RequestedCertificateSet;
sessionManager?: SessionManager;
managerOptions?: Partial<ManagerOptions & SocketOptions>;
originator?: OriginatorDomainNameStringUnder250Bytes;
}): AuthSocketClientImpl;
export {};
//# sourceMappingURL=AuthSocketClient.d.ts.map