@dynamic-labs-wallet/forward-mpc-client 0.8.2 → 0.10.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.cjs +6 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -181
- package/dist/index.d.ts +5 -181
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/utils-pzTJsc5g.d.cts +180 -0
- package/dist/utils-pzTJsc5g.d.ts +180 -0
- package/dist/utils.cjs +119 -0
- package/dist/utils.cjs.map +1 -0
- package/dist/utils.d.cts +2 -0
- package/dist/utils.d.ts +2 -0
- package/dist/utils.js +115 -0
- package/dist/utils.js.map +1 -0
- package/package.json +13 -9
package/dist/index.d.cts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import EventEmitter$1, { EventEmitter } from 'eventemitter3';
|
|
2
|
-
import { BaseWebSocketMessage, TraceContext, HashAlgorithm, encryptKeyshare
|
|
2
|
+
import { BaseWebSocketMessage, TraceContext, HashAlgorithm, encryptKeyshare } 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
|
-
import { SigningAlgorithm } from '@dynamic-labs-wallet/
|
|
5
|
-
export { SigningAlgorithm } from '@dynamic-labs-wallet/
|
|
4
|
+
import { SigningAlgorithm } from '@dynamic-labs-wallet/primitives';
|
|
5
|
+
export { SigningAlgorithm } from '@dynamic-labs-wallet/primitives';
|
|
6
|
+
export { A as AttestationErrorCode, C as ClientError, a as ClientSessionEstablishFailedError, b as ClientUnsupportedAlgorithmError, E as ErrorCode, F as ForwardMPCError, c as ForwardMPCErrorType, d as ForwardMpcErrorClassification, e as ForwardMpcErrorType, S as SessionAttestationError, f as SessionDisposedError, g as SessionError, h as SessionHandshakeError, i as SessionHandshakeInvalidResponseError, j as SessionMessageParseError, k as SessionRemoteError, l as SessionRequestTimeoutError, m as SessionServerError, T as TransportConnectionError, n as TransportConnectionTimeoutError, o as TransportError, p as TransportNotConnectedError, q as classifyForwardMpcError, r as isAttestationError, s as isForwardMpcError } from './utils-pzTJsc5g.cjs';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Result of attestation document verification
|
|
@@ -278,183 +279,6 @@ declare class ForwardMPCClientV2 extends EventEmitter$1<ClientV2Events> {
|
|
|
278
279
|
declare class ForwardMPCClientSingleton extends ForwardMPCClientV2 {
|
|
279
280
|
}
|
|
280
281
|
|
|
281
|
-
declare const ErrorCode: {
|
|
282
|
-
readonly CONNECTION_FAILED: "CONNECTION_FAILED";
|
|
283
|
-
readonly CONNECTION_TIMEOUT: "CONNECTION_TIMEOUT";
|
|
284
|
-
readonly NOT_CONNECTED: "NOT_CONNECTED";
|
|
285
|
-
readonly HANDSHAKE_FAILED: "HANDSHAKE_FAILED";
|
|
286
|
-
readonly HANDSHAKE_INVALID_RESPONSE: "HANDSHAKE_INVALID_RESPONSE";
|
|
287
|
-
readonly ATTESTATION_FAILED: "ATTESTATION_FAILED";
|
|
288
|
-
readonly ATTESTATION_PCR_MISMATCH: "ATTESTATION_PCR_MISMATCH";
|
|
289
|
-
readonly ATTESTATION_CHALLENGE_MISMATCH: "ATTESTATION_CHALLENGE_MISMATCH";
|
|
290
|
-
readonly ATTESTATION_NONCE_MISMATCH: "ATTESTATION_NONCE_MISMATCH";
|
|
291
|
-
readonly ATTESTATION_NONCE_MISSING: "ATTESTATION_NONCE_MISSING";
|
|
292
|
-
readonly ATTESTATION_DOCUMENT_MISSING: "ATTESTATION_DOCUMENT_MISSING";
|
|
293
|
-
readonly REQUEST_TIMEOUT: "REQUEST_TIMEOUT";
|
|
294
|
-
readonly SESSION_DISPOSED: "SESSION_DISPOSED";
|
|
295
|
-
readonly SERVER_ERROR: "SERVER_ERROR";
|
|
296
|
-
readonly MESSAGE_PARSE_FAILED: "MESSAGE_PARSE_FAILED";
|
|
297
|
-
readonly SESSION_ESTABLISH_FAILED: "SESSION_ESTABLISH_FAILED";
|
|
298
|
-
readonly UNSUPPORTED_ALGORITHM: "UNSUPPORTED_ALGORITHM";
|
|
299
|
-
};
|
|
300
|
-
type ErrorCode = (typeof ErrorCode)[keyof typeof ErrorCode];
|
|
301
|
-
/**
|
|
302
|
-
* Focused subset of ErrorCode for attestation verification failures.
|
|
303
|
-
* Use with `error.code` to distinguish failure modes on SessionAttestationError.
|
|
304
|
-
*/
|
|
305
|
-
declare const AttestationErrorCode: {
|
|
306
|
-
/** Generic / unrecognised attestation failure */
|
|
307
|
-
readonly FAILED: "ATTESTATION_FAILED";
|
|
308
|
-
/** PCR8 hash mismatch — enclave measurement changed */
|
|
309
|
-
readonly PCR_MISMATCH: "ATTESTATION_PCR_MISMATCH";
|
|
310
|
-
/** Challenge / ciphertext binding mismatch */
|
|
311
|
-
readonly CHALLENGE_MISMATCH: "ATTESTATION_CHALLENGE_MISMATCH";
|
|
312
|
-
/** Nonce value mismatch — possible tampering */
|
|
313
|
-
readonly NONCE_MISMATCH: "ATTESTATION_NONCE_MISMATCH";
|
|
314
|
-
/** Nonce field missing from attestation document */
|
|
315
|
-
readonly NONCE_MISSING: "ATTESTATION_NONCE_MISSING";
|
|
316
|
-
/** Server did not return an attestation document */
|
|
317
|
-
readonly DOCUMENT_MISSING: "ATTESTATION_DOCUMENT_MISSING";
|
|
318
|
-
};
|
|
319
|
-
type AttestationErrorCode = (typeof AttestationErrorCode)[keyof typeof AttestationErrorCode];
|
|
320
|
-
declare const ForwardMPCErrorType: {
|
|
321
|
-
readonly TRANSPORT: "transport";
|
|
322
|
-
readonly SESSION: "session";
|
|
323
|
-
readonly CLIENT: "client";
|
|
324
|
-
};
|
|
325
|
-
type ForwardMPCErrorType = (typeof ForwardMPCErrorType)[keyof typeof ForwardMPCErrorType];
|
|
326
|
-
/**
|
|
327
|
-
* Abstract root for all Forward MPC errors.
|
|
328
|
-
* `instanceof ForwardMPCError` is true for every error thrown by this library.
|
|
329
|
-
*/
|
|
330
|
-
declare abstract class ForwardMPCError extends Error {
|
|
331
|
-
readonly code: ErrorCode;
|
|
332
|
-
readonly type: ForwardMPCErrorType;
|
|
333
|
-
readonly context?: Record<string, unknown>;
|
|
334
|
-
constructor(message: string, code: ErrorCode, type: ForwardMPCErrorType, context?: Record<string, unknown>);
|
|
335
|
-
toJSON(): Record<string, unknown>;
|
|
336
|
-
}
|
|
337
|
-
/** Abstract base for errors originating from the WebSocket / transport layer. */
|
|
338
|
-
declare abstract class TransportError extends ForwardMPCError {
|
|
339
|
-
constructor(message: string, code: ErrorCode, context?: Record<string, unknown>);
|
|
340
|
-
}
|
|
341
|
-
/** Abstract base for errors originating from the session / crypto / protocol layer. */
|
|
342
|
-
declare abstract class SessionError extends ForwardMPCError {
|
|
343
|
-
constructor(message: string, code: ErrorCode, context?: Record<string, unknown>);
|
|
344
|
-
}
|
|
345
|
-
/** Abstract base for errors originating from the client / application layer. */
|
|
346
|
-
declare abstract class ClientError extends ForwardMPCError {
|
|
347
|
-
constructor(message: string, code: ErrorCode, context?: Record<string, unknown>);
|
|
348
|
-
}
|
|
349
|
-
declare class TransportConnectionError extends TransportError {
|
|
350
|
-
constructor(context?: Record<string, unknown>);
|
|
351
|
-
}
|
|
352
|
-
declare class TransportConnectionTimeoutError extends TransportError {
|
|
353
|
-
constructor(context?: Record<string, unknown>);
|
|
354
|
-
}
|
|
355
|
-
declare class TransportNotConnectedError extends TransportError {
|
|
356
|
-
constructor(context?: Record<string, unknown>);
|
|
357
|
-
}
|
|
358
|
-
declare class SessionHandshakeError extends SessionError {
|
|
359
|
-
constructor(reason: string, context?: Record<string, unknown>);
|
|
360
|
-
}
|
|
361
|
-
declare class SessionHandshakeInvalidResponseError extends SessionError {
|
|
362
|
-
constructor(context?: Record<string, unknown>);
|
|
363
|
-
}
|
|
364
|
-
/**
|
|
365
|
-
* Attestation verification failure.
|
|
366
|
-
* Use `error.code` to distinguish failure reasons (e.g. ATTESTATION_PCR_MISMATCH)
|
|
367
|
-
* and `error.cause` to inspect the original verifier error.
|
|
368
|
-
*/
|
|
369
|
-
declare class SessionAttestationError extends SessionError {
|
|
370
|
-
readonly cause?: unknown;
|
|
371
|
-
constructor(message?: string, code?: ErrorCode, context?: Record<string, unknown>, cause?: unknown);
|
|
372
|
-
}
|
|
373
|
-
declare class SessionRequestTimeoutError extends SessionError {
|
|
374
|
-
constructor(context?: Record<string, unknown>);
|
|
375
|
-
}
|
|
376
|
-
declare class SessionDisposedError extends SessionError {
|
|
377
|
-
constructor(context?: Record<string, unknown>);
|
|
378
|
-
}
|
|
379
|
-
declare class SessionServerError extends SessionError {
|
|
380
|
-
constructor(reason: string, context?: Record<string, unknown>);
|
|
381
|
-
}
|
|
382
|
-
declare class SessionMessageParseError extends SessionError {
|
|
383
|
-
constructor(context?: Record<string, unknown>);
|
|
384
|
-
}
|
|
385
|
-
/**
|
|
386
|
-
* The remote server returned an explicit error response.
|
|
387
|
-
* Carries the full WebSocketError payload so callers can inspect
|
|
388
|
-
* `serverError.type` and `serverError.details`.
|
|
389
|
-
*/
|
|
390
|
-
declare class SessionRemoteError extends SessionError {
|
|
391
|
-
readonly serverError: WebSocketError;
|
|
392
|
-
constructor(serverError: WebSocketError, context?: Record<string, unknown>);
|
|
393
|
-
}
|
|
394
|
-
declare class ClientUnsupportedAlgorithmError extends ClientError {
|
|
395
|
-
constructor(context?: Record<string, unknown>);
|
|
396
|
-
}
|
|
397
|
-
declare class ClientSessionEstablishFailedError extends ClientError {
|
|
398
|
-
constructor(context?: Record<string, unknown>);
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
/**
|
|
402
|
-
* Error classification result from Forward MPC operations.
|
|
403
|
-
*/
|
|
404
|
-
type ForwardMpcErrorType = 'ATTESTATION_FAILURE' | 'FORWARD_MPC_TIMEOUT' | 'FORWARD_MPC_ERROR';
|
|
405
|
-
/**
|
|
406
|
-
* Result of classifying a Forward MPC error.
|
|
407
|
-
*/
|
|
408
|
-
interface ForwardMpcErrorClassification {
|
|
409
|
-
/** The type of error encountered */
|
|
410
|
-
errorType: ForwardMpcErrorType;
|
|
411
|
-
/** Error code from ForwardMPCError, if available */
|
|
412
|
-
errorCode: string | undefined;
|
|
413
|
-
/** Error message */
|
|
414
|
-
errorMessage: string;
|
|
415
|
-
/** Attestation verification errors, if this is an attestation failure */
|
|
416
|
-
attestationErrors?: unknown[];
|
|
417
|
-
/** Whether the session was established before the error occurred */
|
|
418
|
-
sessionEstablished: boolean;
|
|
419
|
-
/** Whether this error should trigger a fallback to relay-based MPC */
|
|
420
|
-
shouldFallback: boolean;
|
|
421
|
-
}
|
|
422
|
-
/**
|
|
423
|
-
* Classifies a Forward MPC error and returns structured data for logging.
|
|
424
|
-
* Use this to standardize error handling across keygen, signing, and connect operations.
|
|
425
|
-
*
|
|
426
|
-
* @param error - The error to classify
|
|
427
|
-
* @returns Classification result with error details and recommended action
|
|
428
|
-
*
|
|
429
|
-
* @example
|
|
430
|
-
* ```typescript
|
|
431
|
-
* try {
|
|
432
|
-
* await forwardMpcClient.sign(...);
|
|
433
|
-
* } catch (error) {
|
|
434
|
-
* const classification = classifyForwardMpcError(error);
|
|
435
|
-
* logger.warn(`Forward MPC ${operation} failed`, {
|
|
436
|
-
* ...classification,
|
|
437
|
-
* chainName,
|
|
438
|
-
* environmentId,
|
|
439
|
-
* });
|
|
440
|
-
* if (classification.shouldFallback) {
|
|
441
|
-
* // Fall through to relay-based MPC
|
|
442
|
-
* } else {
|
|
443
|
-
* throw error;
|
|
444
|
-
* }
|
|
445
|
-
* }
|
|
446
|
-
* ```
|
|
447
|
-
*/
|
|
448
|
-
declare function classifyForwardMpcError(error: unknown): ForwardMpcErrorClassification;
|
|
449
|
-
/**
|
|
450
|
-
* Type guard to check if an error is a Forward MPC error that should be handled.
|
|
451
|
-
*/
|
|
452
|
-
declare function isForwardMpcError(error: unknown): error is ForwardMPCError;
|
|
453
|
-
/**
|
|
454
|
-
* Type guard to check if an error is an attestation failure.
|
|
455
|
-
*/
|
|
456
|
-
declare function isAttestationError(error: unknown): error is SessionAttestationError;
|
|
457
|
-
|
|
458
282
|
/**
|
|
459
283
|
* Nitro Enclave Attestation Document Verifier
|
|
460
284
|
* Uses Evervault's official WASM attestation bindings
|
|
@@ -487,4 +311,4 @@ declare class NitroAttestationVerifier implements AttestationVerifier {
|
|
|
487
311
|
verify(attestationDocBase64: string, expectedChallenge: string, nonce: Uint8Array): Promise<AttestationVerificationResult>;
|
|
488
312
|
}
|
|
489
313
|
|
|
490
|
-
export {
|
|
314
|
+
export { type AttestationVerificationConfig, type AttestationVerificationResult, type AttestationVerifier, type ClientEvents, type ClientV2Events, type ExternalLogger, ForwardMPCClient, type ForwardMPCClientOptions, ForwardMPCClientSingleton, ForwardMPCClientV2, type ForwardMPCClientV2Options, type KeygenParams, type KeygenResult, NitroAttestationVerifier, type ReceiveKeyParams, type ReceiveKeyResult, type SignMessageParams, type SignMessageResult };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import EventEmitter$1, { EventEmitter } from 'eventemitter3';
|
|
2
|
-
import { BaseWebSocketMessage, TraceContext, HashAlgorithm, encryptKeyshare
|
|
2
|
+
import { BaseWebSocketMessage, TraceContext, HashAlgorithm, encryptKeyshare } 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
|
-
import { SigningAlgorithm } from '@dynamic-labs-wallet/
|
|
5
|
-
export { SigningAlgorithm } from '@dynamic-labs-wallet/
|
|
4
|
+
import { SigningAlgorithm } from '@dynamic-labs-wallet/primitives';
|
|
5
|
+
export { SigningAlgorithm } from '@dynamic-labs-wallet/primitives';
|
|
6
|
+
export { A as AttestationErrorCode, C as ClientError, a as ClientSessionEstablishFailedError, b as ClientUnsupportedAlgorithmError, E as ErrorCode, F as ForwardMPCError, c as ForwardMPCErrorType, d as ForwardMpcErrorClassification, e as ForwardMpcErrorType, S as SessionAttestationError, f as SessionDisposedError, g as SessionError, h as SessionHandshakeError, i as SessionHandshakeInvalidResponseError, j as SessionMessageParseError, k as SessionRemoteError, l as SessionRequestTimeoutError, m as SessionServerError, T as TransportConnectionError, n as TransportConnectionTimeoutError, o as TransportError, p as TransportNotConnectedError, q as classifyForwardMpcError, r as isAttestationError, s as isForwardMpcError } from './utils-pzTJsc5g.js';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Result of attestation document verification
|
|
@@ -278,183 +279,6 @@ declare class ForwardMPCClientV2 extends EventEmitter$1<ClientV2Events> {
|
|
|
278
279
|
declare class ForwardMPCClientSingleton extends ForwardMPCClientV2 {
|
|
279
280
|
}
|
|
280
281
|
|
|
281
|
-
declare const ErrorCode: {
|
|
282
|
-
readonly CONNECTION_FAILED: "CONNECTION_FAILED";
|
|
283
|
-
readonly CONNECTION_TIMEOUT: "CONNECTION_TIMEOUT";
|
|
284
|
-
readonly NOT_CONNECTED: "NOT_CONNECTED";
|
|
285
|
-
readonly HANDSHAKE_FAILED: "HANDSHAKE_FAILED";
|
|
286
|
-
readonly HANDSHAKE_INVALID_RESPONSE: "HANDSHAKE_INVALID_RESPONSE";
|
|
287
|
-
readonly ATTESTATION_FAILED: "ATTESTATION_FAILED";
|
|
288
|
-
readonly ATTESTATION_PCR_MISMATCH: "ATTESTATION_PCR_MISMATCH";
|
|
289
|
-
readonly ATTESTATION_CHALLENGE_MISMATCH: "ATTESTATION_CHALLENGE_MISMATCH";
|
|
290
|
-
readonly ATTESTATION_NONCE_MISMATCH: "ATTESTATION_NONCE_MISMATCH";
|
|
291
|
-
readonly ATTESTATION_NONCE_MISSING: "ATTESTATION_NONCE_MISSING";
|
|
292
|
-
readonly ATTESTATION_DOCUMENT_MISSING: "ATTESTATION_DOCUMENT_MISSING";
|
|
293
|
-
readonly REQUEST_TIMEOUT: "REQUEST_TIMEOUT";
|
|
294
|
-
readonly SESSION_DISPOSED: "SESSION_DISPOSED";
|
|
295
|
-
readonly SERVER_ERROR: "SERVER_ERROR";
|
|
296
|
-
readonly MESSAGE_PARSE_FAILED: "MESSAGE_PARSE_FAILED";
|
|
297
|
-
readonly SESSION_ESTABLISH_FAILED: "SESSION_ESTABLISH_FAILED";
|
|
298
|
-
readonly UNSUPPORTED_ALGORITHM: "UNSUPPORTED_ALGORITHM";
|
|
299
|
-
};
|
|
300
|
-
type ErrorCode = (typeof ErrorCode)[keyof typeof ErrorCode];
|
|
301
|
-
/**
|
|
302
|
-
* Focused subset of ErrorCode for attestation verification failures.
|
|
303
|
-
* Use with `error.code` to distinguish failure modes on SessionAttestationError.
|
|
304
|
-
*/
|
|
305
|
-
declare const AttestationErrorCode: {
|
|
306
|
-
/** Generic / unrecognised attestation failure */
|
|
307
|
-
readonly FAILED: "ATTESTATION_FAILED";
|
|
308
|
-
/** PCR8 hash mismatch — enclave measurement changed */
|
|
309
|
-
readonly PCR_MISMATCH: "ATTESTATION_PCR_MISMATCH";
|
|
310
|
-
/** Challenge / ciphertext binding mismatch */
|
|
311
|
-
readonly CHALLENGE_MISMATCH: "ATTESTATION_CHALLENGE_MISMATCH";
|
|
312
|
-
/** Nonce value mismatch — possible tampering */
|
|
313
|
-
readonly NONCE_MISMATCH: "ATTESTATION_NONCE_MISMATCH";
|
|
314
|
-
/** Nonce field missing from attestation document */
|
|
315
|
-
readonly NONCE_MISSING: "ATTESTATION_NONCE_MISSING";
|
|
316
|
-
/** Server did not return an attestation document */
|
|
317
|
-
readonly DOCUMENT_MISSING: "ATTESTATION_DOCUMENT_MISSING";
|
|
318
|
-
};
|
|
319
|
-
type AttestationErrorCode = (typeof AttestationErrorCode)[keyof typeof AttestationErrorCode];
|
|
320
|
-
declare const ForwardMPCErrorType: {
|
|
321
|
-
readonly TRANSPORT: "transport";
|
|
322
|
-
readonly SESSION: "session";
|
|
323
|
-
readonly CLIENT: "client";
|
|
324
|
-
};
|
|
325
|
-
type ForwardMPCErrorType = (typeof ForwardMPCErrorType)[keyof typeof ForwardMPCErrorType];
|
|
326
|
-
/**
|
|
327
|
-
* Abstract root for all Forward MPC errors.
|
|
328
|
-
* `instanceof ForwardMPCError` is true for every error thrown by this library.
|
|
329
|
-
*/
|
|
330
|
-
declare abstract class ForwardMPCError extends Error {
|
|
331
|
-
readonly code: ErrorCode;
|
|
332
|
-
readonly type: ForwardMPCErrorType;
|
|
333
|
-
readonly context?: Record<string, unknown>;
|
|
334
|
-
constructor(message: string, code: ErrorCode, type: ForwardMPCErrorType, context?: Record<string, unknown>);
|
|
335
|
-
toJSON(): Record<string, unknown>;
|
|
336
|
-
}
|
|
337
|
-
/** Abstract base for errors originating from the WebSocket / transport layer. */
|
|
338
|
-
declare abstract class TransportError extends ForwardMPCError {
|
|
339
|
-
constructor(message: string, code: ErrorCode, context?: Record<string, unknown>);
|
|
340
|
-
}
|
|
341
|
-
/** Abstract base for errors originating from the session / crypto / protocol layer. */
|
|
342
|
-
declare abstract class SessionError extends ForwardMPCError {
|
|
343
|
-
constructor(message: string, code: ErrorCode, context?: Record<string, unknown>);
|
|
344
|
-
}
|
|
345
|
-
/** Abstract base for errors originating from the client / application layer. */
|
|
346
|
-
declare abstract class ClientError extends ForwardMPCError {
|
|
347
|
-
constructor(message: string, code: ErrorCode, context?: Record<string, unknown>);
|
|
348
|
-
}
|
|
349
|
-
declare class TransportConnectionError extends TransportError {
|
|
350
|
-
constructor(context?: Record<string, unknown>);
|
|
351
|
-
}
|
|
352
|
-
declare class TransportConnectionTimeoutError extends TransportError {
|
|
353
|
-
constructor(context?: Record<string, unknown>);
|
|
354
|
-
}
|
|
355
|
-
declare class TransportNotConnectedError extends TransportError {
|
|
356
|
-
constructor(context?: Record<string, unknown>);
|
|
357
|
-
}
|
|
358
|
-
declare class SessionHandshakeError extends SessionError {
|
|
359
|
-
constructor(reason: string, context?: Record<string, unknown>);
|
|
360
|
-
}
|
|
361
|
-
declare class SessionHandshakeInvalidResponseError extends SessionError {
|
|
362
|
-
constructor(context?: Record<string, unknown>);
|
|
363
|
-
}
|
|
364
|
-
/**
|
|
365
|
-
* Attestation verification failure.
|
|
366
|
-
* Use `error.code` to distinguish failure reasons (e.g. ATTESTATION_PCR_MISMATCH)
|
|
367
|
-
* and `error.cause` to inspect the original verifier error.
|
|
368
|
-
*/
|
|
369
|
-
declare class SessionAttestationError extends SessionError {
|
|
370
|
-
readonly cause?: unknown;
|
|
371
|
-
constructor(message?: string, code?: ErrorCode, context?: Record<string, unknown>, cause?: unknown);
|
|
372
|
-
}
|
|
373
|
-
declare class SessionRequestTimeoutError extends SessionError {
|
|
374
|
-
constructor(context?: Record<string, unknown>);
|
|
375
|
-
}
|
|
376
|
-
declare class SessionDisposedError extends SessionError {
|
|
377
|
-
constructor(context?: Record<string, unknown>);
|
|
378
|
-
}
|
|
379
|
-
declare class SessionServerError extends SessionError {
|
|
380
|
-
constructor(reason: string, context?: Record<string, unknown>);
|
|
381
|
-
}
|
|
382
|
-
declare class SessionMessageParseError extends SessionError {
|
|
383
|
-
constructor(context?: Record<string, unknown>);
|
|
384
|
-
}
|
|
385
|
-
/**
|
|
386
|
-
* The remote server returned an explicit error response.
|
|
387
|
-
* Carries the full WebSocketError payload so callers can inspect
|
|
388
|
-
* `serverError.type` and `serverError.details`.
|
|
389
|
-
*/
|
|
390
|
-
declare class SessionRemoteError extends SessionError {
|
|
391
|
-
readonly serverError: WebSocketError;
|
|
392
|
-
constructor(serverError: WebSocketError, context?: Record<string, unknown>);
|
|
393
|
-
}
|
|
394
|
-
declare class ClientUnsupportedAlgorithmError extends ClientError {
|
|
395
|
-
constructor(context?: Record<string, unknown>);
|
|
396
|
-
}
|
|
397
|
-
declare class ClientSessionEstablishFailedError extends ClientError {
|
|
398
|
-
constructor(context?: Record<string, unknown>);
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
/**
|
|
402
|
-
* Error classification result from Forward MPC operations.
|
|
403
|
-
*/
|
|
404
|
-
type ForwardMpcErrorType = 'ATTESTATION_FAILURE' | 'FORWARD_MPC_TIMEOUT' | 'FORWARD_MPC_ERROR';
|
|
405
|
-
/**
|
|
406
|
-
* Result of classifying a Forward MPC error.
|
|
407
|
-
*/
|
|
408
|
-
interface ForwardMpcErrorClassification {
|
|
409
|
-
/** The type of error encountered */
|
|
410
|
-
errorType: ForwardMpcErrorType;
|
|
411
|
-
/** Error code from ForwardMPCError, if available */
|
|
412
|
-
errorCode: string | undefined;
|
|
413
|
-
/** Error message */
|
|
414
|
-
errorMessage: string;
|
|
415
|
-
/** Attestation verification errors, if this is an attestation failure */
|
|
416
|
-
attestationErrors?: unknown[];
|
|
417
|
-
/** Whether the session was established before the error occurred */
|
|
418
|
-
sessionEstablished: boolean;
|
|
419
|
-
/** Whether this error should trigger a fallback to relay-based MPC */
|
|
420
|
-
shouldFallback: boolean;
|
|
421
|
-
}
|
|
422
|
-
/**
|
|
423
|
-
* Classifies a Forward MPC error and returns structured data for logging.
|
|
424
|
-
* Use this to standardize error handling across keygen, signing, and connect operations.
|
|
425
|
-
*
|
|
426
|
-
* @param error - The error to classify
|
|
427
|
-
* @returns Classification result with error details and recommended action
|
|
428
|
-
*
|
|
429
|
-
* @example
|
|
430
|
-
* ```typescript
|
|
431
|
-
* try {
|
|
432
|
-
* await forwardMpcClient.sign(...);
|
|
433
|
-
* } catch (error) {
|
|
434
|
-
* const classification = classifyForwardMpcError(error);
|
|
435
|
-
* logger.warn(`Forward MPC ${operation} failed`, {
|
|
436
|
-
* ...classification,
|
|
437
|
-
* chainName,
|
|
438
|
-
* environmentId,
|
|
439
|
-
* });
|
|
440
|
-
* if (classification.shouldFallback) {
|
|
441
|
-
* // Fall through to relay-based MPC
|
|
442
|
-
* } else {
|
|
443
|
-
* throw error;
|
|
444
|
-
* }
|
|
445
|
-
* }
|
|
446
|
-
* ```
|
|
447
|
-
*/
|
|
448
|
-
declare function classifyForwardMpcError(error: unknown): ForwardMpcErrorClassification;
|
|
449
|
-
/**
|
|
450
|
-
* Type guard to check if an error is a Forward MPC error that should be handled.
|
|
451
|
-
*/
|
|
452
|
-
declare function isForwardMpcError(error: unknown): error is ForwardMPCError;
|
|
453
|
-
/**
|
|
454
|
-
* Type guard to check if an error is an attestation failure.
|
|
455
|
-
*/
|
|
456
|
-
declare function isAttestationError(error: unknown): error is SessionAttestationError;
|
|
457
|
-
|
|
458
282
|
/**
|
|
459
283
|
* Nitro Enclave Attestation Document Verifier
|
|
460
284
|
* Uses Evervault's official WASM attestation bindings
|
|
@@ -487,4 +311,4 @@ declare class NitroAttestationVerifier implements AttestationVerifier {
|
|
|
487
311
|
verify(attestationDocBase64: string, expectedChallenge: string, nonce: Uint8Array): Promise<AttestationVerificationResult>;
|
|
488
312
|
}
|
|
489
313
|
|
|
490
|
-
export {
|
|
314
|
+
export { type AttestationVerificationConfig, type AttestationVerificationResult, type AttestationVerifier, type ClientEvents, type ClientV2Events, type ExternalLogger, ForwardMPCClient, type ForwardMPCClientOptions, ForwardMPCClientSingleton, ForwardMPCClientV2, type ForwardMPCClientV2Options, type KeygenParams, type KeygenResult, NitroAttestationVerifier, type ReceiveKeyParams, type ReceiveKeyResult, type SignMessageParams, type SignMessageResult };
|
package/dist/index.js
CHANGED
|
@@ -5,8 +5,8 @@ import init, { PCRs, validateAttestationDocPcrs, getUserData, getNonce } from '@
|
|
|
5
5
|
import { sha256 } from '@noble/hashes/sha2.js';
|
|
6
6
|
import { randomBytes, hexToBytes } from '@noble/hashes/utils.js';
|
|
7
7
|
import { either } from 'fp-ts';
|
|
8
|
-
import { SigningAlgorithm } from '@dynamic-labs-wallet/
|
|
9
|
-
export { SigningAlgorithm } from '@dynamic-labs-wallet/
|
|
8
|
+
import { SigningAlgorithm } from '@dynamic-labs-wallet/primitives';
|
|
9
|
+
export { SigningAlgorithm } from '@dynamic-labs-wallet/primitives';
|
|
10
10
|
import { WebSocket } from 'isows';
|
|
11
11
|
|
|
12
12
|
var __defProp = Object.defineProperty;
|
|
@@ -591,6 +591,8 @@ var ForwardMPCClient = class extends EventEmitter {
|
|
|
591
591
|
}
|
|
592
592
|
}
|
|
593
593
|
};
|
|
594
|
+
|
|
595
|
+
// src/client-v2/errors.ts
|
|
594
596
|
var ErrorCode = {
|
|
595
597
|
// Transport
|
|
596
598
|
CONNECTION_FAILED: "CONNECTION_FAILED",
|