@dynamic-labs-wallet/forward-mpc-client 0.3.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1,8 +1,20 @@
1
- import { EventEmitter } from 'eventemitter3';
2
- import { TraceContext, HashAlgorithm, BaseWebSocketMessage } from '@dynamic-labs-wallet/forward-mpc-shared';
1
+ import EventEmitter$1, { EventEmitter } from 'eventemitter3';
2
+ import { TraceContext, HashAlgorithm, BaseWebSocketMessage, encryptKeyshare, WebSocketError } from '@dynamic-labs-wallet/forward-mpc-shared';
3
3
  export { BaseWebSocketMessage, ErrorResponse, HandshakeV1RequestMessage, HandshakeV1ResponseMessage, SignMessageV1RequestMessage, SignMessageV1ResponseMessage, WebSocketError, WebSocketErrorType } from '@dynamic-labs-wallet/forward-mpc-shared';
4
4
  import { SigningAlgorithm } from '@dynamic-labs-wallet/core';
5
+ export { SigningAlgorithm } from '@dynamic-labs-wallet/core';
5
6
 
7
+ /**
8
+ * Result of attestation document verification
9
+ */
10
+ interface AttestationVerificationResult {
11
+ /** Whether the attestation document is valid */
12
+ valid: boolean;
13
+ /** Any verification errors */
14
+ errors: string[];
15
+ /** Timestamp when verification was performed */
16
+ timestamp: number;
17
+ }
6
18
  /**
7
19
  * Configuration for attestation verification
8
20
  */
@@ -14,6 +26,12 @@ interface AttestationVerificationConfig {
14
26
  /** Maximum age of attestation document in milliseconds */
15
27
  maxAge?: number;
16
28
  }
29
+ /**
30
+ * Verifies a Nitro attestation document received during handshake.
31
+ */
32
+ interface AttestationVerifier {
33
+ verify(attestationDocBase64: string, expectedChallenge: string, nonce: Uint8Array): Promise<AttestationVerificationResult>;
34
+ }
17
35
 
18
36
  interface ForwardMPCClientOptions {
19
37
  reconnectAttempts?: number;
@@ -129,4 +147,254 @@ declare class ForwardMPCClient extends EventEmitter {
129
147
  private verifyAttestationDocument;
130
148
  }
131
149
 
132
- export { type ClientEvents, ForwardMPCClient, type ForwardMPCClientOptions };
150
+ /**
151
+ * When an ExternalLogger is provided, the library routes all log calls through
152
+ * it. The signature matches the Datadog Browser SDK logger so that the same
153
+ * instance can be passed directly.
154
+ *
155
+ * Compatible with the Datadog Browser SDK logger interface (@datadog/browser-logs).
156
+ */
157
+ interface ExternalLogger {
158
+ debug(message: string, messageContext?: object, error?: Error): void;
159
+ info(message: string, messageContext?: object, error?: Error): void;
160
+ warn(message: string, messageContext?: object, error?: Error): void;
161
+ error(message: string, messageContext?: object, error?: Error): void;
162
+ }
163
+
164
+ interface BaseMessageParams {
165
+ traceContext?: TraceContext;
166
+ userId?: string;
167
+ environmentId?: string;
168
+ }
169
+ interface BaseMPCMessageParams {
170
+ relayDomain: string;
171
+ roomUuid: string;
172
+ signingAlgo: SigningAlgorithm;
173
+ }
174
+ interface SignMessageParams extends BaseMessageParams, BaseMPCMessageParams {
175
+ keyshare: Parameters<typeof encryptKeyshare>[0];
176
+ message: Uint8Array | string;
177
+ hashAlgo?: HashAlgorithm;
178
+ derivationPath?: Uint32Array;
179
+ tweak?: Uint8Array;
180
+ }
181
+ interface KeygenParams extends BaseMessageParams, BaseMPCMessageParams {
182
+ keygenInit: {
183
+ keygenId: string;
184
+ keygenSecret: string;
185
+ };
186
+ numParties: number;
187
+ threshold: number;
188
+ keygenIds: string[];
189
+ }
190
+ type ReceiveKeyParams = Omit<KeygenParams, 'signingAlgo'>;
191
+ interface SignMessageResult {
192
+ signature: Uint8Array;
193
+ }
194
+ interface KeygenResult {
195
+ pubkey: Uint8Array;
196
+ secretShare: string;
197
+ }
198
+ interface ReceiveKeyResult {
199
+ pubkey: Uint8Array;
200
+ secretShare: string;
201
+ }
202
+
203
+ interface ForwardMPCClientV2Options {
204
+ reconnectAttempts?: number;
205
+ reconnectInterval?: number;
206
+ connectionTimeout?: number;
207
+ requestTimeout?: number;
208
+ attestationConfig?: AttestationVerificationConfig;
209
+ attestationVerifier?: AttestationVerifier;
210
+ /**
211
+ * Disables attestation verification. DO NOT use in production.
212
+ * @deprecated Use only for local development and testing.
213
+ */
214
+ dangerouslyBypassAttestation?: boolean;
215
+ logger?: ExternalLogger;
216
+ }
217
+ interface ClientV2Events {
218
+ connected: () => void;
219
+ disconnected: () => void;
220
+ error: (error: Error) => void;
221
+ }
222
+ declare class ForwardMPCClientV2 extends EventEmitter$1<ClientV2Events> {
223
+ protected readonly url: string;
224
+ protected readonly options: ForwardMPCClientV2Options;
225
+ private readonly transport;
226
+ private readonly sessionOptions;
227
+ private readonly logger;
228
+ private session;
229
+ private _connectPromise;
230
+ private _handshaking;
231
+ private _disconnectedIntentionally;
232
+ constructor(url: string, options?: ForwardMPCClientV2Options);
233
+ get connected(): boolean;
234
+ /**
235
+ * Opens the WebSocket connection and performs the ML-KEM-768 handshake.
236
+ * Resolves once the session is fully established (and attested, if configured).
237
+ * Concurrent calls coalesce on a single in-flight promise.
238
+ */
239
+ connect(traceContext?: TraceContext): Promise<void>;
240
+ /**
241
+ * Disposes the current session (zeroing crypto material) and closes the transport.
242
+ */
243
+ disconnect(): void;
244
+ signMessage(params: SignMessageParams): Promise<SignMessageResult>;
245
+ /**
246
+ * MPC key generation for ECDSA and BIP340.
247
+ * ED25519 is not supported here — use receiveKey() instead.
248
+ */
249
+ keygen(params: KeygenParams): Promise<KeygenResult>;
250
+ /**
251
+ * Receives an ED25519 key generated by another party (ExportableEd25519).
252
+ */
253
+ receiveKey(params: ReceiveKeyParams): Promise<ReceiveKeyResult>;
254
+ /**
255
+ * Ensures an active session exists, auto-connecting if needed.
256
+ */
257
+ private ensureSession;
258
+ private _runHandshake;
259
+ private _doConnect;
260
+ /**
261
+ * Called when the transport connects (both initial and after auto-reconnect).
262
+ * The `_handshaking` flag is set synchronously at the top of `_doConnect`
263
+ * before any await, so it reliably indicates when we already own the handshake.
264
+ *
265
+ * For transport-initiated reconnects, `_connectPromise` is set so that
266
+ * concurrent `connect()` or `ensureSession()` callers coalesce on the
267
+ * in-flight handshake rather than initiating a second one.
268
+ */
269
+ private onTransportConnected;
270
+ private onTransportDisconnected;
271
+ }
272
+
273
+ /**
274
+ * @deprecated Use {@link ForwardMPCClientV2} directly and manage the instance
275
+ * lifecycle yourself. This class will be removed in a future version.
276
+ */
277
+ declare class ForwardMPCClientSingleton extends ForwardMPCClientV2 {
278
+ }
279
+
280
+ declare const ErrorCode: {
281
+ readonly CONNECTION_FAILED: "CONNECTION_FAILED";
282
+ readonly CONNECTION_TIMEOUT: "CONNECTION_TIMEOUT";
283
+ readonly NOT_CONNECTED: "NOT_CONNECTED";
284
+ readonly HANDSHAKE_FAILED: "HANDSHAKE_FAILED";
285
+ readonly HANDSHAKE_INVALID_RESPONSE: "HANDSHAKE_INVALID_RESPONSE";
286
+ readonly ATTESTATION_FAILED: "ATTESTATION_FAILED";
287
+ readonly ATTESTATION_NONCE_MISSING: "ATTESTATION_NONCE_MISSING";
288
+ readonly REQUEST_TIMEOUT: "REQUEST_TIMEOUT";
289
+ readonly SESSION_DISPOSED: "SESSION_DISPOSED";
290
+ readonly SERVER_ERROR: "SERVER_ERROR";
291
+ readonly MESSAGE_PARSE_FAILED: "MESSAGE_PARSE_FAILED";
292
+ readonly SESSION_ESTABLISH_FAILED: "SESSION_ESTABLISH_FAILED";
293
+ readonly UNSUPPORTED_ALGORITHM: "UNSUPPORTED_ALGORITHM";
294
+ };
295
+ type ErrorCode = (typeof ErrorCode)[keyof typeof ErrorCode];
296
+ declare const ForwardMPCErrorType: {
297
+ readonly TRANSPORT: "transport";
298
+ readonly SESSION: "session";
299
+ readonly CLIENT: "client";
300
+ };
301
+ type ForwardMPCErrorType = (typeof ForwardMPCErrorType)[keyof typeof ForwardMPCErrorType];
302
+ /**
303
+ * Abstract root for all Forward MPC errors.
304
+ * `instanceof ForwardMPCError` is true for every error thrown by this library.
305
+ */
306
+ declare abstract class ForwardMPCError extends Error {
307
+ readonly code: ErrorCode;
308
+ readonly type: ForwardMPCErrorType;
309
+ readonly context?: Record<string, unknown>;
310
+ constructor(message: string, code: ErrorCode, type: ForwardMPCErrorType, context?: Record<string, unknown>);
311
+ toJSON(): Record<string, unknown>;
312
+ }
313
+ /** Abstract base for errors originating from the WebSocket / transport layer. */
314
+ declare abstract class TransportError extends ForwardMPCError {
315
+ constructor(message: string, code: ErrorCode, context?: Record<string, unknown>);
316
+ }
317
+ /** Abstract base for errors originating from the session / crypto / protocol layer. */
318
+ declare abstract class SessionError extends ForwardMPCError {
319
+ constructor(message: string, code: ErrorCode, context?: Record<string, unknown>);
320
+ }
321
+ /** Abstract base for errors originating from the client / application layer. */
322
+ declare abstract class ClientError extends ForwardMPCError {
323
+ constructor(message: string, code: ErrorCode, context?: Record<string, unknown>);
324
+ }
325
+ declare class TransportConnectionError extends TransportError {
326
+ constructor(context?: Record<string, unknown>);
327
+ }
328
+ declare class TransportConnectionTimeoutError extends TransportError {
329
+ constructor(context?: Record<string, unknown>);
330
+ }
331
+ declare class TransportNotConnectedError extends TransportError {
332
+ constructor(context?: Record<string, unknown>);
333
+ }
334
+ declare class SessionHandshakeError extends SessionError {
335
+ constructor(reason: string, context?: Record<string, unknown>);
336
+ }
337
+ declare class SessionHandshakeInvalidResponseError extends SessionError {
338
+ constructor(context?: Record<string, unknown>);
339
+ }
340
+ declare class SessionAttestationError extends SessionError {
341
+ constructor(context?: Record<string, unknown>);
342
+ }
343
+ declare class SessionAttestationNonceMissingError extends SessionError {
344
+ constructor(context?: Record<string, unknown>);
345
+ }
346
+ declare class SessionRequestTimeoutError extends SessionError {
347
+ constructor(context?: Record<string, unknown>);
348
+ }
349
+ declare class SessionDisposedError extends SessionError {
350
+ constructor(context?: Record<string, unknown>);
351
+ }
352
+ declare class SessionServerError extends SessionError {
353
+ constructor(reason: string, context?: Record<string, unknown>);
354
+ }
355
+ declare class SessionMessageParseError extends SessionError {
356
+ constructor(context?: Record<string, unknown>);
357
+ }
358
+ /**
359
+ * The remote server returned an explicit error response.
360
+ * Carries the full WebSocketError payload so callers can inspect
361
+ * `serverError.type` and `serverError.details`.
362
+ */
363
+ declare class SessionRemoteError extends SessionError {
364
+ readonly serverError: WebSocketError;
365
+ constructor(serverError: WebSocketError, context?: Record<string, unknown>);
366
+ }
367
+ declare class ClientUnsupportedAlgorithmError extends ClientError {
368
+ constructor(context?: Record<string, unknown>);
369
+ }
370
+ declare class ClientSessionEstablishFailedError extends ClientError {
371
+ constructor(context?: Record<string, unknown>);
372
+ }
373
+
374
+ /**
375
+ * Nitro Enclave Attestation Document Verifier
376
+ * Uses Evervault's official WASM attestation bindings
377
+ * Optimized for client-side usage with hex string input
378
+ */
379
+ declare class NitroAttestationVerifier implements AttestationVerifier {
380
+ private readonly config;
381
+ private wasmInitPromise;
382
+ constructor(config: AttestationVerificationConfig);
383
+ /**
384
+ * Initialises the WASM module exactly once. Concurrent callers share the
385
+ * same in-flight promise, preventing duplicate initialisation.
386
+ * On failure the promise is cleared so the next call may retry.
387
+ */
388
+ private ensureWasmInitialized;
389
+ /**
390
+ * Verify an attestation document using Evervault WASM bindings
391
+ * Accepts base64-encoded attestation document directly
392
+ *
393
+ * @param attestationDocBase64 - Base64-encoded attestation document
394
+ * @param expectedChallenge - Expected challenge (ciphertext hash)
395
+ * @param nonce - Expected nonce (REQUIRED for security)
396
+ */
397
+ verify(attestationDocBase64: string, expectedChallenge: string, nonce: Uint8Array): Promise<AttestationVerificationResult>;
398
+ }
399
+
400
+ export { type AttestationVerificationConfig, type AttestationVerificationResult, type AttestationVerifier, ClientError, type ClientEvents, ClientSessionEstablishFailedError, ClientUnsupportedAlgorithmError, type ClientV2Events, ErrorCode, type ExternalLogger, ForwardMPCClient, type ForwardMPCClientOptions, ForwardMPCClientSingleton, ForwardMPCClientV2, type ForwardMPCClientV2Options, ForwardMPCError, ForwardMPCErrorType, type KeygenParams, type KeygenResult, NitroAttestationVerifier, type ReceiveKeyParams, type ReceiveKeyResult, SessionAttestationError, SessionAttestationNonceMissingError, SessionDisposedError, SessionError, SessionHandshakeError, SessionHandshakeInvalidResponseError, SessionMessageParseError, SessionRemoteError, SessionRequestTimeoutError, SessionServerError, type SignMessageParams, type SignMessageResult, TransportConnectionError, TransportConnectionTimeoutError, TransportError, TransportNotConnectedError };
package/dist/index.d.ts CHANGED
@@ -1,8 +1,20 @@
1
- import { EventEmitter } from 'eventemitter3';
2
- import { TraceContext, HashAlgorithm, BaseWebSocketMessage } from '@dynamic-labs-wallet/forward-mpc-shared';
1
+ import EventEmitter$1, { EventEmitter } from 'eventemitter3';
2
+ import { TraceContext, HashAlgorithm, BaseWebSocketMessage, encryptKeyshare, WebSocketError } from '@dynamic-labs-wallet/forward-mpc-shared';
3
3
  export { BaseWebSocketMessage, ErrorResponse, HandshakeV1RequestMessage, HandshakeV1ResponseMessage, SignMessageV1RequestMessage, SignMessageV1ResponseMessage, WebSocketError, WebSocketErrorType } from '@dynamic-labs-wallet/forward-mpc-shared';
4
4
  import { SigningAlgorithm } from '@dynamic-labs-wallet/core';
5
+ export { SigningAlgorithm } from '@dynamic-labs-wallet/core';
5
6
 
7
+ /**
8
+ * Result of attestation document verification
9
+ */
10
+ interface AttestationVerificationResult {
11
+ /** Whether the attestation document is valid */
12
+ valid: boolean;
13
+ /** Any verification errors */
14
+ errors: string[];
15
+ /** Timestamp when verification was performed */
16
+ timestamp: number;
17
+ }
6
18
  /**
7
19
  * Configuration for attestation verification
8
20
  */
@@ -14,6 +26,12 @@ interface AttestationVerificationConfig {
14
26
  /** Maximum age of attestation document in milliseconds */
15
27
  maxAge?: number;
16
28
  }
29
+ /**
30
+ * Verifies a Nitro attestation document received during handshake.
31
+ */
32
+ interface AttestationVerifier {
33
+ verify(attestationDocBase64: string, expectedChallenge: string, nonce: Uint8Array): Promise<AttestationVerificationResult>;
34
+ }
17
35
 
18
36
  interface ForwardMPCClientOptions {
19
37
  reconnectAttempts?: number;
@@ -129,4 +147,254 @@ declare class ForwardMPCClient extends EventEmitter {
129
147
  private verifyAttestationDocument;
130
148
  }
131
149
 
132
- export { type ClientEvents, ForwardMPCClient, type ForwardMPCClientOptions };
150
+ /**
151
+ * When an ExternalLogger is provided, the library routes all log calls through
152
+ * it. The signature matches the Datadog Browser SDK logger so that the same
153
+ * instance can be passed directly.
154
+ *
155
+ * Compatible with the Datadog Browser SDK logger interface (@datadog/browser-logs).
156
+ */
157
+ interface ExternalLogger {
158
+ debug(message: string, messageContext?: object, error?: Error): void;
159
+ info(message: string, messageContext?: object, error?: Error): void;
160
+ warn(message: string, messageContext?: object, error?: Error): void;
161
+ error(message: string, messageContext?: object, error?: Error): void;
162
+ }
163
+
164
+ interface BaseMessageParams {
165
+ traceContext?: TraceContext;
166
+ userId?: string;
167
+ environmentId?: string;
168
+ }
169
+ interface BaseMPCMessageParams {
170
+ relayDomain: string;
171
+ roomUuid: string;
172
+ signingAlgo: SigningAlgorithm;
173
+ }
174
+ interface SignMessageParams extends BaseMessageParams, BaseMPCMessageParams {
175
+ keyshare: Parameters<typeof encryptKeyshare>[0];
176
+ message: Uint8Array | string;
177
+ hashAlgo?: HashAlgorithm;
178
+ derivationPath?: Uint32Array;
179
+ tweak?: Uint8Array;
180
+ }
181
+ interface KeygenParams extends BaseMessageParams, BaseMPCMessageParams {
182
+ keygenInit: {
183
+ keygenId: string;
184
+ keygenSecret: string;
185
+ };
186
+ numParties: number;
187
+ threshold: number;
188
+ keygenIds: string[];
189
+ }
190
+ type ReceiveKeyParams = Omit<KeygenParams, 'signingAlgo'>;
191
+ interface SignMessageResult {
192
+ signature: Uint8Array;
193
+ }
194
+ interface KeygenResult {
195
+ pubkey: Uint8Array;
196
+ secretShare: string;
197
+ }
198
+ interface ReceiveKeyResult {
199
+ pubkey: Uint8Array;
200
+ secretShare: string;
201
+ }
202
+
203
+ interface ForwardMPCClientV2Options {
204
+ reconnectAttempts?: number;
205
+ reconnectInterval?: number;
206
+ connectionTimeout?: number;
207
+ requestTimeout?: number;
208
+ attestationConfig?: AttestationVerificationConfig;
209
+ attestationVerifier?: AttestationVerifier;
210
+ /**
211
+ * Disables attestation verification. DO NOT use in production.
212
+ * @deprecated Use only for local development and testing.
213
+ */
214
+ dangerouslyBypassAttestation?: boolean;
215
+ logger?: ExternalLogger;
216
+ }
217
+ interface ClientV2Events {
218
+ connected: () => void;
219
+ disconnected: () => void;
220
+ error: (error: Error) => void;
221
+ }
222
+ declare class ForwardMPCClientV2 extends EventEmitter$1<ClientV2Events> {
223
+ protected readonly url: string;
224
+ protected readonly options: ForwardMPCClientV2Options;
225
+ private readonly transport;
226
+ private readonly sessionOptions;
227
+ private readonly logger;
228
+ private session;
229
+ private _connectPromise;
230
+ private _handshaking;
231
+ private _disconnectedIntentionally;
232
+ constructor(url: string, options?: ForwardMPCClientV2Options);
233
+ get connected(): boolean;
234
+ /**
235
+ * Opens the WebSocket connection and performs the ML-KEM-768 handshake.
236
+ * Resolves once the session is fully established (and attested, if configured).
237
+ * Concurrent calls coalesce on a single in-flight promise.
238
+ */
239
+ connect(traceContext?: TraceContext): Promise<void>;
240
+ /**
241
+ * Disposes the current session (zeroing crypto material) and closes the transport.
242
+ */
243
+ disconnect(): void;
244
+ signMessage(params: SignMessageParams): Promise<SignMessageResult>;
245
+ /**
246
+ * MPC key generation for ECDSA and BIP340.
247
+ * ED25519 is not supported here — use receiveKey() instead.
248
+ */
249
+ keygen(params: KeygenParams): Promise<KeygenResult>;
250
+ /**
251
+ * Receives an ED25519 key generated by another party (ExportableEd25519).
252
+ */
253
+ receiveKey(params: ReceiveKeyParams): Promise<ReceiveKeyResult>;
254
+ /**
255
+ * Ensures an active session exists, auto-connecting if needed.
256
+ */
257
+ private ensureSession;
258
+ private _runHandshake;
259
+ private _doConnect;
260
+ /**
261
+ * Called when the transport connects (both initial and after auto-reconnect).
262
+ * The `_handshaking` flag is set synchronously at the top of `_doConnect`
263
+ * before any await, so it reliably indicates when we already own the handshake.
264
+ *
265
+ * For transport-initiated reconnects, `_connectPromise` is set so that
266
+ * concurrent `connect()` or `ensureSession()` callers coalesce on the
267
+ * in-flight handshake rather than initiating a second one.
268
+ */
269
+ private onTransportConnected;
270
+ private onTransportDisconnected;
271
+ }
272
+
273
+ /**
274
+ * @deprecated Use {@link ForwardMPCClientV2} directly and manage the instance
275
+ * lifecycle yourself. This class will be removed in a future version.
276
+ */
277
+ declare class ForwardMPCClientSingleton extends ForwardMPCClientV2 {
278
+ }
279
+
280
+ declare const ErrorCode: {
281
+ readonly CONNECTION_FAILED: "CONNECTION_FAILED";
282
+ readonly CONNECTION_TIMEOUT: "CONNECTION_TIMEOUT";
283
+ readonly NOT_CONNECTED: "NOT_CONNECTED";
284
+ readonly HANDSHAKE_FAILED: "HANDSHAKE_FAILED";
285
+ readonly HANDSHAKE_INVALID_RESPONSE: "HANDSHAKE_INVALID_RESPONSE";
286
+ readonly ATTESTATION_FAILED: "ATTESTATION_FAILED";
287
+ readonly ATTESTATION_NONCE_MISSING: "ATTESTATION_NONCE_MISSING";
288
+ readonly REQUEST_TIMEOUT: "REQUEST_TIMEOUT";
289
+ readonly SESSION_DISPOSED: "SESSION_DISPOSED";
290
+ readonly SERVER_ERROR: "SERVER_ERROR";
291
+ readonly MESSAGE_PARSE_FAILED: "MESSAGE_PARSE_FAILED";
292
+ readonly SESSION_ESTABLISH_FAILED: "SESSION_ESTABLISH_FAILED";
293
+ readonly UNSUPPORTED_ALGORITHM: "UNSUPPORTED_ALGORITHM";
294
+ };
295
+ type ErrorCode = (typeof ErrorCode)[keyof typeof ErrorCode];
296
+ declare const ForwardMPCErrorType: {
297
+ readonly TRANSPORT: "transport";
298
+ readonly SESSION: "session";
299
+ readonly CLIENT: "client";
300
+ };
301
+ type ForwardMPCErrorType = (typeof ForwardMPCErrorType)[keyof typeof ForwardMPCErrorType];
302
+ /**
303
+ * Abstract root for all Forward MPC errors.
304
+ * `instanceof ForwardMPCError` is true for every error thrown by this library.
305
+ */
306
+ declare abstract class ForwardMPCError extends Error {
307
+ readonly code: ErrorCode;
308
+ readonly type: ForwardMPCErrorType;
309
+ readonly context?: Record<string, unknown>;
310
+ constructor(message: string, code: ErrorCode, type: ForwardMPCErrorType, context?: Record<string, unknown>);
311
+ toJSON(): Record<string, unknown>;
312
+ }
313
+ /** Abstract base for errors originating from the WebSocket / transport layer. */
314
+ declare abstract class TransportError extends ForwardMPCError {
315
+ constructor(message: string, code: ErrorCode, context?: Record<string, unknown>);
316
+ }
317
+ /** Abstract base for errors originating from the session / crypto / protocol layer. */
318
+ declare abstract class SessionError extends ForwardMPCError {
319
+ constructor(message: string, code: ErrorCode, context?: Record<string, unknown>);
320
+ }
321
+ /** Abstract base for errors originating from the client / application layer. */
322
+ declare abstract class ClientError extends ForwardMPCError {
323
+ constructor(message: string, code: ErrorCode, context?: Record<string, unknown>);
324
+ }
325
+ declare class TransportConnectionError extends TransportError {
326
+ constructor(context?: Record<string, unknown>);
327
+ }
328
+ declare class TransportConnectionTimeoutError extends TransportError {
329
+ constructor(context?: Record<string, unknown>);
330
+ }
331
+ declare class TransportNotConnectedError extends TransportError {
332
+ constructor(context?: Record<string, unknown>);
333
+ }
334
+ declare class SessionHandshakeError extends SessionError {
335
+ constructor(reason: string, context?: Record<string, unknown>);
336
+ }
337
+ declare class SessionHandshakeInvalidResponseError extends SessionError {
338
+ constructor(context?: Record<string, unknown>);
339
+ }
340
+ declare class SessionAttestationError extends SessionError {
341
+ constructor(context?: Record<string, unknown>);
342
+ }
343
+ declare class SessionAttestationNonceMissingError extends SessionError {
344
+ constructor(context?: Record<string, unknown>);
345
+ }
346
+ declare class SessionRequestTimeoutError extends SessionError {
347
+ constructor(context?: Record<string, unknown>);
348
+ }
349
+ declare class SessionDisposedError extends SessionError {
350
+ constructor(context?: Record<string, unknown>);
351
+ }
352
+ declare class SessionServerError extends SessionError {
353
+ constructor(reason: string, context?: Record<string, unknown>);
354
+ }
355
+ declare class SessionMessageParseError extends SessionError {
356
+ constructor(context?: Record<string, unknown>);
357
+ }
358
+ /**
359
+ * The remote server returned an explicit error response.
360
+ * Carries the full WebSocketError payload so callers can inspect
361
+ * `serverError.type` and `serverError.details`.
362
+ */
363
+ declare class SessionRemoteError extends SessionError {
364
+ readonly serverError: WebSocketError;
365
+ constructor(serverError: WebSocketError, context?: Record<string, unknown>);
366
+ }
367
+ declare class ClientUnsupportedAlgorithmError extends ClientError {
368
+ constructor(context?: Record<string, unknown>);
369
+ }
370
+ declare class ClientSessionEstablishFailedError extends ClientError {
371
+ constructor(context?: Record<string, unknown>);
372
+ }
373
+
374
+ /**
375
+ * Nitro Enclave Attestation Document Verifier
376
+ * Uses Evervault's official WASM attestation bindings
377
+ * Optimized for client-side usage with hex string input
378
+ */
379
+ declare class NitroAttestationVerifier implements AttestationVerifier {
380
+ private readonly config;
381
+ private wasmInitPromise;
382
+ constructor(config: AttestationVerificationConfig);
383
+ /**
384
+ * Initialises the WASM module exactly once. Concurrent callers share the
385
+ * same in-flight promise, preventing duplicate initialisation.
386
+ * On failure the promise is cleared so the next call may retry.
387
+ */
388
+ private ensureWasmInitialized;
389
+ /**
390
+ * Verify an attestation document using Evervault WASM bindings
391
+ * Accepts base64-encoded attestation document directly
392
+ *
393
+ * @param attestationDocBase64 - Base64-encoded attestation document
394
+ * @param expectedChallenge - Expected challenge (ciphertext hash)
395
+ * @param nonce - Expected nonce (REQUIRED for security)
396
+ */
397
+ verify(attestationDocBase64: string, expectedChallenge: string, nonce: Uint8Array): Promise<AttestationVerificationResult>;
398
+ }
399
+
400
+ export { type AttestationVerificationConfig, type AttestationVerificationResult, type AttestationVerifier, ClientError, type ClientEvents, ClientSessionEstablishFailedError, ClientUnsupportedAlgorithmError, type ClientV2Events, ErrorCode, type ExternalLogger, ForwardMPCClient, type ForwardMPCClientOptions, ForwardMPCClientSingleton, ForwardMPCClientV2, type ForwardMPCClientV2Options, ForwardMPCError, ForwardMPCErrorType, type KeygenParams, type KeygenResult, NitroAttestationVerifier, type ReceiveKeyParams, type ReceiveKeyResult, SessionAttestationError, SessionAttestationNonceMissingError, SessionDisposedError, SessionError, SessionHandshakeError, SessionHandshakeInvalidResponseError, SessionMessageParseError, SessionRemoteError, SessionRequestTimeoutError, SessionServerError, type SignMessageParams, type SignMessageResult, TransportConnectionError, TransportConnectionTimeoutError, TransportError, TransportNotConnectedError };