@explorins/pers-signer 1.0.16 → 1.0.18

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/browser.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import * as _explorins_web3_ts_types from '@explorins/web3-ts/types';
2
- import { AnyTransactionData, LegacyTransaction } from '@explorins/web3-ts/types';
3
- export { AnyTransactionData } from '@explorins/web3-ts/types';
2
+ import { LegacyTransaction, AnyTransactionData } from '@explorins/web3-ts/types';
3
+ export { AnyTransactionData, BaseTransaction, CounterfactualWalletEIP712Data, EIP1559Transaction, EIP2930Transaction, EIP712TransactionData, EIP712TypedData, LegacyTransaction } from '@explorins/web3-ts/types';
4
4
  import * as _explorins_pers_shared_browser from '@explorins/pers-shared/browser';
5
5
  import { TenantPublicDTO, SessionAuthContextResponseDTO, TransactionFormat, TransactionRequestResponseDTO, CounterfactualWalletTransactionResponse, TransactionStatus } from '@explorins/pers-shared/browser';
6
- export { TransactionFormat, TransactionRequestResponseDTO, TransactionStatus } from '@explorins/pers-shared/browser';
6
+ export { CampaignClaimDTO, CampaignDTO, SessionAuthResponseDTO, TRANSACTION_FORMATS, TRANSACTION_FORMAT_DESCRIPTIONS, TransactionFormat, TransactionRequestResponseDTO, TransactionStatus, TransactionSubmissionRequestDTO } from '@explorins/pers-shared/browser';
7
7
  import { AbstractSigner, Provider, TransactionRequest, TypedDataDomain, TypedDataField } from 'ethers';
8
8
  import { CounterfactualWalletTransactionResponse as CounterfactualWalletTransactionResponse$1 } from '@explorins/pers-shared';
9
9
 
@@ -249,6 +249,29 @@ interface RelyingPartyConfig {
249
249
  origin?: string;
250
250
  }
251
251
 
252
+ /**
253
+ * Type definitions for the new PERS Signer API v1
254
+ * Based on API_MIGRATION_REFERENCE.md - Updated for wrapped responses
255
+ */
256
+ interface SignerApiResponse<T = unknown> {
257
+ success: boolean;
258
+ data?: T;
259
+ }
260
+ interface SignerApiError {
261
+ status: number;
262
+ error: string;
263
+ message: string;
264
+ request_id: string;
265
+ timestamp: string;
266
+ suggestion?: {
267
+ action: string;
268
+ text: string;
269
+ endpoint: string;
270
+ };
271
+ }
272
+ interface LoginRequest {
273
+ authToken: string;
274
+ }
252
275
  interface JWTLoginResponse {
253
276
  success: true;
254
277
  access_token: string;
@@ -261,6 +284,14 @@ interface JWTLoginResponse {
261
284
  };
262
285
  provider: string;
263
286
  }
287
+ interface WrappedProviderResponse {
288
+ success: true;
289
+ data: unknown;
290
+ }
291
+ type LoginResponse = JWTLoginResponse | WrappedProviderResponse;
292
+ interface VerifyTokenRequest {
293
+ token: string;
294
+ }
264
295
  interface VerifyTokenResponse {
265
296
  valid: boolean;
266
297
  provider: string;
@@ -278,6 +309,45 @@ interface VerifyTokenResponse {
278
309
  };
279
310
  tenantId: string;
280
311
  }
312
+ interface InitRegistrationRequest {
313
+ authToken: string;
314
+ }
315
+ interface InitRegistrationResponse {
316
+ success: true;
317
+ data: {
318
+ challenge?: string;
319
+ temporaryAuthenticationToken?: string;
320
+ user?: object;
321
+ [key: string]: unknown;
322
+ };
323
+ }
324
+ type CompleteRegistrationResponse = JWTLoginResponse | WrappedProviderResponse;
325
+ interface ListWalletsRequest {
326
+ }
327
+ interface ListWalletsResponse {
328
+ success: true;
329
+ data: {
330
+ wallets?: Array<unknown>;
331
+ [key: string]: unknown;
332
+ };
333
+ }
334
+ interface InitSignatureRequest {
335
+ walletId: string;
336
+ request: unknown;
337
+ }
338
+ interface InitSignatureResponse {
339
+ success: true;
340
+ data: {
341
+ requestBody: unknown;
342
+ challenge: unknown;
343
+ [key: string]: unknown;
344
+ };
345
+ }
346
+ interface CompleteSignatureRequest {
347
+ walletId: string;
348
+ requestBody: unknown;
349
+ signedChallenge: unknown;
350
+ }
281
351
  interface CompleteSignatureResponse {
282
352
  success: true;
283
353
  data: {
@@ -304,6 +374,9 @@ interface CompleteSignatureResponse {
304
374
  [key: string]: unknown;
305
375
  };
306
376
  }
377
+ interface HealthCheckResponse {
378
+ success: boolean;
379
+ }
307
380
 
308
381
  /**
309
382
  * Signing service for cryptographic operations
@@ -350,7 +423,116 @@ declare class SigningService {
350
423
  }
351
424
 
352
425
  /**
353
- * Shared type definitions for the blockchain signer shared library
426
+ * Combined transaction status type that includes both PERS and additional statuses
427
+ */
428
+ type CombinedTransactionStatus = TransactionStatus;
429
+ /**
430
+ * Transaction statuses that allow signing
431
+ */
432
+ declare const SIGNABLE_STATUSES: readonly [TransactionStatus.PENDING_SIGNATURE, TransactionStatus.CREATED];
433
+ /**
434
+ * Transaction status information for UI display
435
+ */
436
+ interface TransactionStatusInfo {
437
+ transactionId: string;
438
+ transactionStatus: CombinedTransactionStatus;
439
+ message: string;
440
+ }
441
+ /**
442
+ * Transaction signing result
443
+ */
444
+ interface TransactionSigningResult {
445
+ success: boolean;
446
+ transactionId: string;
447
+ signature?: string;
448
+ signingData?: CounterfactualWalletTransactionResponse | LegacyTransaction;
449
+ error?: string;
450
+ statusInfo?: TransactionStatusInfo;
451
+ shouldShowStatus?: boolean;
452
+ }
453
+ /**
454
+ * Transaction submission result for internal processing
455
+ */
456
+ interface SubmissionResult {
457
+ submitResult: TransactionRequestResponseDTO;
458
+ shouldRedirect: boolean;
459
+ redirectUrl?: string;
460
+ transactionHash: string | null;
461
+ success: boolean;
462
+ error?: string;
463
+ }
464
+ /**
465
+ * Metadata for transaction parameters - string values only
466
+ */
467
+ /**
468
+ * Authentication tokens required for transaction signing
469
+ */
470
+ interface SigningAuthTokens {
471
+ signerAuthToken: string;
472
+ persAccessToken: string;
473
+ }
474
+ /**
475
+ * Transaction signing parameters
476
+ */
477
+ interface TransactionSigningParams {
478
+ transactionId: string;
479
+ tenantId: string;
480
+ authTokens: SigningAuthTokens;
481
+ ethersProviderUrl: string;
482
+ returnUrl?: string;
483
+ }
484
+
485
+ /**
486
+ * Wallet list response from WalletService
487
+ */
488
+ interface WalletListResponse {
489
+ items: WalletItem[];
490
+ }
491
+ /**
492
+ * Individual wallet item from wallet list - compatible with KeyWallet constructor
493
+ */
494
+ interface WalletItem {
495
+ id: string;
496
+ address: string;
497
+ network: string;
498
+ status: string;
499
+ signingKey?: unknown;
500
+ dateCreated?: string;
501
+ custodial?: boolean;
502
+ tags?: string[];
503
+ boundToEvmNetwork?: boolean;
504
+ [key: string]: unknown;
505
+ }
506
+
507
+ /**
508
+ * Error codes for transaction signing operations
509
+ */
510
+ declare enum TransactionSigningErrorCode {
511
+ INVALID_TOKENS = "INVALID_TOKENS",
512
+ TRANSACTION_NOT_FOUND = "TRANSACTION_NOT_FOUND",
513
+ TRANSACTION_NOT_PENDING = "TRANSACTION_NOT_PENDING",
514
+ WALLET_NOT_AVAILABLE = "WALLET_NOT_AVAILABLE",
515
+ WEBAUTHN_OPERATION_IN_PROGRESS = "WEBAUTHN_OPERATION_IN_PROGRESS",
516
+ SIGNING_CANCELLED = "SIGNING_CANCELLED",
517
+ PERS_AUTH_FAILED = "PERS_AUTH_FAILED",
518
+ AUTH_FAILED = "AUTH_FAILED",
519
+ TRANSACTION_NOT_READY = "TRANSACTION_NOT_READY",
520
+ SUBMISSION_FAILED = "SUBMISSION_FAILED",
521
+ SERVER_ERROR = "SERVER_ERROR",
522
+ UNKNOWN_ERROR = "UNKNOWN_ERROR"
523
+ }
524
+ /**
525
+ * Structured error for transaction signing operations
526
+ */
527
+ interface TransactionSigningError extends Error {
528
+ code: TransactionSigningErrorCode;
529
+ transactionId?: string;
530
+ originalError?: unknown;
531
+ }
532
+
533
+ /**
534
+ * Central type definitions for the blockchain signer shared library
535
+ * Single source of truth for all type exports
354
536
  */
355
537
 
356
538
  /**
@@ -360,18 +542,8 @@ interface AuthenticatedUser {
360
542
  identifier: string;
361
543
  signerAuthToken: string;
362
544
  persAccessToken: string;
363
- tenantId: string;
364
545
  expiresAt: number;
365
546
  }
366
- /**
367
- * Service configuration options
368
- */
369
- interface ServiceConfig {
370
- apiUrl: string;
371
- environment: 'development' | 'staging' | 'production';
372
- timeout?: number;
373
- retryAttempts?: number;
374
- }
375
547
  /**
376
548
  * Error types for service operations
377
549
  */
@@ -420,63 +592,204 @@ declare class KeyWallet extends AbstractSigner {
420
592
  }
421
593
 
422
594
  /**
423
- * Combined transaction status type that includes both PERS and additional statuses
424
- */
425
- type CombinedTransactionStatus = TransactionStatus;
426
- /**
427
- * Transaction statuses that allow signing
428
- */
429
- declare const SIGNABLE_STATUSES: readonly [TransactionStatus.PENDING_SIGNATURE, TransactionStatus.CREATED];
430
- /**
431
- * Transaction status information for UI display
432
- */
433
- interface TransactionStatusInfo {
434
- transactionId: string;
435
- transactionStatus: CombinedTransactionStatus;
436
- message: string;
437
- }
438
- /**
439
- * Transaction signing result
595
+ * PERS Blockchain Signer SDK
596
+ *
597
+ * A lightweight blockchain transaction signing SDK with WebAuthn authentication.
598
+ * Provides 5 focused methods for complete transaction lifecycle management:
599
+ *
600
+ * 1. loginUser(jwtToken) - Authenticate user with 5-minute caching
601
+ * 2. signTransaction(signingData, jwtToken) - Sign transactions with auto-login
602
+ * 3. submitTransaction(signedTx, jwtToken) - Submit signed transactions to blockchain
603
+ * 4. signPersTransaction(jwtToken) - Legacy one-liner for backward compatibility
604
+ * 5. signAndSubmitPersTransaction(jwtToken) - Complete sign + submit flow
605
+ *
606
+ * @example
607
+ * ```typescript
608
+ * import { createPersSignerSDK } from '@explorins/pers-signer';
609
+ *
610
+ * const sdk = createPersSignerSDK({
611
+ * webAuthnProvider: myWebAuthnProvider,
612
+ * ethersProviderUrl: 'https://ethereum-rpc.com'
613
+ * });
614
+ *
615
+ * // Quick sign and submit
616
+ * const result = await sdk.signAndSubmitPersTransaction(jwtToken);
617
+ * if (result.success) {
618
+ * console.log('Transaction submitted:', result.transactionHash);
619
+ * }
620
+ * ```
440
621
  */
441
- interface TransactionSigningResult {
442
- success: boolean;
443
- transactionId: string;
444
- signature?: string;
445
- signingData?: CounterfactualWalletTransactionResponse | LegacyTransaction;
446
- error?: string;
447
- statusInfo?: TransactionStatusInfo;
448
- shouldShowStatus?: boolean;
449
- }
622
+
450
623
  /**
451
- * Transaction submission result for internal processing
624
+ * Configuration interface for the PERS Signer SDK
625
+ *
626
+ * @interface PersSignerConfig
627
+ * @property {string} [tenantId] - Optional tenant identifier for multi-tenant applications
628
+ * @property {string} [ethersProviderUrl] - Custom Ethereum RPC provider URL
629
+ * @property {WebAuthnProvider} webAuthnProvider - WebAuthn provider for secure authentication
630
+ * @property {string} [apiUrl] - Custom API base URL (defaults to production)
631
+ * @property {string} [relyingPartyName] - WebAuthn relying party name for authentication
452
632
  */
453
- interface SubmissionResult {
454
- submitResult: TransactionRequestResponseDTO;
455
- shouldRedirect: boolean;
456
- redirectUrl?: string;
457
- transactionHash: string | null;
458
- success: boolean;
459
- error?: string;
633
+ interface ExtendedPersSignerConfig {
634
+ ethersProviderUrl?: string;
635
+ webAuthnProvider: WebAuthnProvider;
636
+ apiUrl?: string;
637
+ relyingPartyName?: string;
460
638
  }
461
- /**
462
- * Metadata for transaction parameters - string values only
463
- */
464
- /**
465
- * Authentication tokens required for transaction signing
466
- */
467
- interface SigningAuthTokens {
468
- signerAuthToken: string;
469
- persAccessToken: string;
639
+ interface PersSignerConfig extends Omit<ExtendedPersSignerConfig, 'webAuthnProvider'> {
470
640
  }
471
641
  /**
472
- * Transaction signing parameters
642
+ * PERS Blockchain Signer SDK Class
643
+ *
644
+ * Main SDK class providing blockchain transaction signing capabilities with WebAuthn authentication.
645
+ * Implements a clean 5-method API for complete transaction lifecycle management.
646
+ *
647
+ * Features:
648
+ * - WebAuthn-based secure authentication
649
+ * - 5-minute user session caching
650
+ * - Automatic transaction data fetching
651
+ * - Blockchain transaction signing and submission
652
+ * - Multi-tenant support
653
+ *
654
+ * @class PersSignerSDK
473
655
  */
474
- interface TransactionSigningParams {
475
- transactionId: string;
476
- tenantId: string;
477
- authTokens: SigningAuthTokens;
478
- ethersProviderUrl: string;
479
- returnUrl?: string;
656
+ declare class PersSignerSDK {
657
+ private config;
658
+ private authenticationService;
659
+ private transactionSigningService;
660
+ /**
661
+ * Initialize the PERS Signer SDK
662
+ *
663
+ * @param {ExtendedPersSignerConfig} config - SDK configuration object
664
+ * @throws {Error} If required configuration is missing
665
+ */
666
+ constructor(config: ExtendedPersSignerConfig);
667
+ /**
668
+ * Authenticate user and cache session for 5 minutes
669
+ *
670
+ * Validates JWT token, authenticates with both signer and PERS backends,
671
+ * and caches the authenticated user session to avoid repeated authentication.
672
+ *
673
+ * @param {string} jwtToken - JWT token containing user identifier and tenant info
674
+ * @returns {Promise<AuthenticatedUser>} Authenticated user with access tokens
675
+ * @throws {Error} If JWT is invalid, expired, or authentication fails
676
+ *
677
+ * @example
678
+ * ```typescript
679
+ * try {
680
+ * const user = await sdk.loginUser(jwtToken);
681
+ * console.log('Authenticated:', user.identifier);
682
+ * } catch (error) {
683
+ * console.error('Authentication failed:', error.message);
684
+ * }
685
+ * ```
686
+ */
687
+ loginUser(jwtToken: string): Promise<AuthenticatedUser>;
688
+ /**
689
+ * Sign a PERS transaction (legacy compatibility method)
690
+ *
691
+ * Automatically handles user authentication, transaction data fetching,
692
+ * and transaction signing in a single call. This is the legacy method
693
+ * maintained for backward compatibility.
694
+ *
695
+ * @param {string} jwtToken - JWT token containing transaction ID and user info
696
+ * @returns {Promise<TransactionSigningResult>} Signing result with signature and metadata
697
+ * @throws {Error} If authentication fails, transaction ID missing, or signing fails
698
+ *
699
+ * @example
700
+ * ```typescript
701
+ * try {
702
+ * const result = await sdk.signPersTransaction(jwtToken);
703
+ * if (result.success) {
704
+ * console.log('Transaction signed:', result.signature);
705
+ * }
706
+ * } catch (error) {
707
+ * console.error('Signing failed:', error.message);
708
+ * }
709
+ * ```
710
+ */
711
+ signPersTransaction(jwtToken: string): Promise<TransactionSigningResult>;
712
+ /**
713
+ * Sign a transaction with provided signing data
714
+ *
715
+ * Low-level method to sign transactions when you already have the signing data.
716
+ * Automatically handles user authentication and applies the blockchain signature.
717
+ *
718
+ * @param {CounterfactualWalletTransactionResponse | LegacyTransaction} signingData - Transaction data to sign
719
+ * @param {string} jwtToken - JWT token containing transaction ID and user info
720
+ * @returns {Promise<TransactionSigningResult>} Signing result with signature and metadata
721
+ * @throws {Error} If authentication fails, transaction ID missing, or signing fails
722
+ *
723
+ * @example
724
+ * ```typescript
725
+ * const signingData = await getTransactionData(transactionId);
726
+ * const result = await sdk.signTransaction(signingData, jwtToken);
727
+ * console.log('Signed transaction:', result.signature);
728
+ * ```
729
+ */
730
+ signTransaction(signingData: CounterfactualWalletTransactionResponse$1 | LegacyTransaction, jwtToken: string): Promise<TransactionSigningResult>;
731
+ /**
732
+ * Complete transaction flow: sign and submit in one call
733
+ *
734
+ * Convenience method that combines signing and submission into a single operation.
735
+ * This is the recommended method for most use cases as it handles the complete
736
+ * transaction lifecycle automatically.
737
+ *
738
+ * @param {string} jwtToken - JWT token containing transaction ID and user info
739
+ * @returns {Promise<SubmissionResult>} Submission result with transaction hash and status
740
+ * @throws {Error} If authentication, signing, or submission fails
741
+ *
742
+ * @example
743
+ * ```typescript
744
+ * try {
745
+ * const result = await sdk.signAndSubmitPersTransaction(jwtToken);
746
+ * if (result.success) {
747
+ * console.log('Transaction completed:', result.transactionHash);
748
+ * if (result.shouldRedirect) {
749
+ * window.location.href = result.redirectUrl;
750
+ * }
751
+ * }
752
+ * } catch (error) {
753
+ * console.error('Transaction failed:', error.message);
754
+ * }
755
+ * ```
756
+ */
757
+ signAndSubmitPersTransaction(jwtToken: string): Promise<SubmissionResult>;
758
+ /**
759
+ * Submit a signed transaction to the blockchain
760
+ *
761
+ * Takes a signed transaction result and submits it to the blockchain network.
762
+ * Returns detailed submission results including transaction hash and any
763
+ * redirect information for UI flows.
764
+ *
765
+ * @param {TransactionSigningResult} signingResult - Result from a successful transaction signing
766
+ * @param {string} jwtToken - JWT token containing tenant and user info
767
+ * @returns {Promise<SubmissionResult>} Submission result with transaction hash and status
768
+ * @throws {Error} If signing result is invalid, JWT is missing tenantId, or submission fails
769
+ *
770
+ * @example
771
+ * ```typescript
772
+ * const signedTx = await sdk.signPersTransaction(jwtToken);
773
+ * const result = await sdk.submitTransaction(signedTx, jwtToken);
774
+ * console.log('Transaction submitted:', result.transactionHash);
775
+ * ```
776
+ */
777
+ submitTransaction(signingResult: TransactionSigningResult, jwtToken: string): Promise<SubmissionResult>;
778
+ /**
779
+ * Clear user authentication cache
780
+ *
781
+ * Removes all cached user sessions, forcing fresh authentication
782
+ * on the next method call. Useful for logout scenarios or when
783
+ * switching between different user contexts.
784
+ *
785
+ * @example
786
+ * ```typescript
787
+ * // Clear cache on user logout
788
+ * sdk.clearCache();
789
+ * console.log('User cache cleared');
790
+ * ```
791
+ */
792
+ clearCache(): void;
480
793
  }
481
794
 
482
795
  /**
@@ -486,7 +799,7 @@ interface TransactionSigningParams {
486
799
  */
487
800
  declare class TransactionSigningService {
488
801
  private webAuthnProvider;
489
- constructor(config: PersSignerConfig);
802
+ constructor(config: ExtendedPersSignerConfig);
490
803
  /**
491
804
  * Prepare transaction for signing - fetch and validate
492
805
  */
@@ -514,32 +827,6 @@ declare class TransactionSigningService {
514
827
  signTransaction(params: TransactionSigningParams, signingData: CounterfactualWalletTransactionResponse | LegacyTransaction): Promise<TransactionSigningResult>;
515
828
  }
516
829
 
517
- /**
518
- * Error codes for transaction signing operations
519
- */
520
- declare enum TransactionSigningErrorCode {
521
- INVALID_TOKENS = "INVALID_TOKENS",
522
- TRANSACTION_NOT_FOUND = "TRANSACTION_NOT_FOUND",
523
- TRANSACTION_NOT_PENDING = "TRANSACTION_NOT_PENDING",
524
- WALLET_NOT_AVAILABLE = "WALLET_NOT_AVAILABLE",
525
- WEBAUTHN_OPERATION_IN_PROGRESS = "WEBAUTHN_OPERATION_IN_PROGRESS",
526
- SIGNING_CANCELLED = "SIGNING_CANCELLED",
527
- PERS_AUTH_FAILED = "PERS_AUTH_FAILED",
528
- AUTH_FAILED = "AUTH_FAILED",
529
- TRANSACTION_NOT_READY = "TRANSACTION_NOT_READY",
530
- SUBMISSION_FAILED = "SUBMISSION_FAILED",
531
- SERVER_ERROR = "SERVER_ERROR",
532
- UNKNOWN_ERROR = "UNKNOWN_ERROR"
533
- }
534
- /**
535
- * Structured error for transaction signing operations
536
- */
537
- interface TransactionSigningError extends Error {
538
- code: TransactionSigningErrorCode;
539
- transactionId?: string;
540
- originalError?: unknown;
541
- }
542
-
543
830
  /**
544
831
  * Handles all error-related operations for transaction signing
545
832
  */
@@ -749,236 +1036,6 @@ declare function setHttpClient(client: HttpClient): void;
749
1036
  */
750
1037
  declare function getHttpClient(): HttpClient;
751
1038
 
752
- /**
753
- * PERS Blockchain Signer SDK
754
- *
755
- * A lightweight blockchain transaction signing SDK with WebAuthn authentication.
756
- * Provides 5 focused methods for complete transaction lifecycle management:
757
- *
758
- * 1. loginUser(jwtToken) - Authenticate user with 5-minute caching
759
- * 2. signTransaction(signingData, jwtToken) - Sign transactions with auto-login
760
- * 3. submitTransaction(signedTx, jwtToken) - Submit signed transactions to blockchain
761
- * 4. signPersTransaction(jwtToken) - Legacy one-liner for backward compatibility
762
- * 5. signAndSubmitPersTransaction(jwtToken) - Complete sign + submit flow
763
- *
764
- * @example
765
- * ```typescript
766
- * import { createPersSignerSDK } from '@explorins/pers-signer';
767
- *
768
- * const sdk = createPersSignerSDK({
769
- * webAuthnProvider: myWebAuthnProvider,
770
- * ethersProviderUrl: 'https://ethereum-rpc.com'
771
- * });
772
- *
773
- * // Quick sign and submit
774
- * const result = await sdk.signAndSubmitPersTransaction(jwtToken);
775
- * if (result.success) {
776
- * console.log('Transaction submitted:', result.transactionHash);
777
- * }
778
- * ```
779
- */
780
-
781
- /**
782
- * Configuration interface for the PERS Signer SDK
783
- *
784
- * @interface PersSignerConfig
785
- * @property {string} [tenantId] - Optional tenant identifier for multi-tenant applications
786
- * @property {string} [ethersProviderUrl] - Custom Ethereum RPC provider URL
787
- * @property {WebAuthnProvider} webAuthnProvider - WebAuthn provider for secure authentication
788
- * @property {string} [apiUrl] - Custom API base URL (defaults to production)
789
- * @property {string} [relyingPartyName] - WebAuthn relying party name for authentication
790
- */
791
- interface PersSignerConfig {
792
- tenantId?: string;
793
- ethersProviderUrl?: string;
794
- webAuthnProvider: WebAuthnProvider;
795
- apiUrl?: string;
796
- relyingPartyName?: string;
797
- }
798
- /**
799
- * PERS Blockchain Signer SDK Class
800
- *
801
- * Main SDK class providing blockchain transaction signing capabilities with WebAuthn authentication.
802
- * Implements a clean 5-method API for complete transaction lifecycle management.
803
- *
804
- * Features:
805
- * - WebAuthn-based secure authentication
806
- * - 5-minute user session caching
807
- * - Automatic transaction data fetching
808
- * - Blockchain transaction signing and submission
809
- * - Multi-tenant support
810
- *
811
- * @class PersSignerSDK
812
- */
813
- declare class PersSignerSDK {
814
- private config;
815
- private authenticationService;
816
- private transactionSigningService;
817
- /**
818
- * Initialize the PERS Signer SDK
819
- *
820
- * @param {PersSignerConfig} config - SDK configuration object
821
- * @throws {Error} If required configuration is missing
822
- */
823
- constructor(config: PersSignerConfig);
824
- /**
825
- * Authenticate user and cache session for 5 minutes
826
- *
827
- * Validates JWT token, authenticates with both signer and PERS backends,
828
- * and caches the authenticated user session to avoid repeated authentication.
829
- *
830
- * @param {string} jwtToken - JWT token containing user identifier and tenant info
831
- * @returns {Promise<AuthenticatedUser>} Authenticated user with access tokens
832
- * @throws {Error} If JWT is invalid, expired, or authentication fails
833
- *
834
- * @example
835
- * ```typescript
836
- * try {
837
- * const user = await sdk.loginUser(jwtToken);
838
- * console.log('Authenticated:', user.identifier);
839
- * } catch (error) {
840
- * console.error('Authentication failed:', error.message);
841
- * }
842
- * ```
843
- */
844
- loginUser(jwtToken: string): Promise<AuthenticatedUser>;
845
- /**
846
- * Sign a PERS transaction (legacy compatibility method)
847
- *
848
- * Automatically handles user authentication, transaction data fetching,
849
- * and transaction signing in a single call. This is the legacy method
850
- * maintained for backward compatibility.
851
- *
852
- * @param {string} jwtToken - JWT token containing transaction ID and user info
853
- * @returns {Promise<TransactionSigningResult>} Signing result with signature and metadata
854
- * @throws {Error} If authentication fails, transaction ID missing, or signing fails
855
- *
856
- * @example
857
- * ```typescript
858
- * try {
859
- * const result = await sdk.signPersTransaction(jwtToken);
860
- * if (result.success) {
861
- * console.log('Transaction signed:', result.signature);
862
- * }
863
- * } catch (error) {
864
- * console.error('Signing failed:', error.message);
865
- * }
866
- * ```
867
- */
868
- signPersTransaction(jwtToken: string): Promise<TransactionSigningResult>;
869
- /**
870
- * Sign a transaction with provided signing data
871
- *
872
- * Low-level method to sign transactions when you already have the signing data.
873
- * Automatically handles user authentication and applies the blockchain signature.
874
- *
875
- * @param {CounterfactualWalletTransactionResponse | LegacyTransaction} signingData - Transaction data to sign
876
- * @param {string} jwtToken - JWT token containing transaction ID and user info
877
- * @returns {Promise<TransactionSigningResult>} Signing result with signature and metadata
878
- * @throws {Error} If authentication fails, transaction ID missing, or signing fails
879
- *
880
- * @example
881
- * ```typescript
882
- * const signingData = await getTransactionData(transactionId);
883
- * const result = await sdk.signTransaction(signingData, jwtToken);
884
- * console.log('Signed transaction:', result.signature);
885
- * ```
886
- */
887
- signTransaction(signingData: CounterfactualWalletTransactionResponse$1 | LegacyTransaction, jwtToken: string): Promise<TransactionSigningResult>;
888
- /**
889
- * Complete transaction flow: sign and submit in one call
890
- *
891
- * Convenience method that combines signing and submission into a single operation.
892
- * This is the recommended method for most use cases as it handles the complete
893
- * transaction lifecycle automatically.
894
- *
895
- * @param {string} jwtToken - JWT token containing transaction ID and user info
896
- * @returns {Promise<SubmissionResult>} Submission result with transaction hash and status
897
- * @throws {Error} If authentication, signing, or submission fails
898
- *
899
- * @example
900
- * ```typescript
901
- * try {
902
- * const result = await sdk.signAndSubmitPersTransaction(jwtToken);
903
- * if (result.success) {
904
- * console.log('Transaction completed:', result.transactionHash);
905
- * if (result.shouldRedirect) {
906
- * window.location.href = result.redirectUrl;
907
- * }
908
- * }
909
- * } catch (error) {
910
- * console.error('Transaction failed:', error.message);
911
- * }
912
- * ```
913
- */
914
- signAndSubmitPersTransaction(jwtToken: string): Promise<SubmissionResult>;
915
- /**
916
- * Submit a signed transaction to the blockchain
917
- *
918
- * Takes a signed transaction result and submits it to the blockchain network.
919
- * Returns detailed submission results including transaction hash and any
920
- * redirect information for UI flows.
921
- *
922
- * @param {TransactionSigningResult} signingResult - Result from a successful transaction signing
923
- * @param {string} jwtToken - JWT token containing tenant and user info
924
- * @returns {Promise<SubmissionResult>} Submission result with transaction hash and status
925
- * @throws {Error} If signing result is invalid, JWT is missing tenantId, or submission fails
926
- *
927
- * @example
928
- * ```typescript
929
- * const signedTx = await sdk.signPersTransaction(jwtToken);
930
- * const result = await sdk.submitTransaction(signedTx, jwtToken);
931
- * console.log('Transaction submitted:', result.transactionHash);
932
- * ```
933
- */
934
- submitTransaction(signingResult: TransactionSigningResult, jwtToken: string): Promise<SubmissionResult>;
935
- /**
936
- * Clear user authentication cache
937
- *
938
- * Removes all cached user sessions, forcing fresh authentication
939
- * on the next method call. Useful for logout scenarios or when
940
- * switching between different user contexts.
941
- *
942
- * @example
943
- * ```typescript
944
- * // Clear cache on user logout
945
- * sdk.clearCache();
946
- * console.log('User cache cleared');
947
- * ```
948
- */
949
- clearCache(): void;
950
- }
951
-
952
- /**
953
- * Wallet list response from WalletService
954
- */
955
- interface WalletListResponse {
956
- items: WalletItem[];
957
- }
958
- /**
959
- * Individual wallet item from wallet list - compatible with KeyWallet constructor
960
- */
961
- interface WalletItem {
962
- id: string;
963
- address: string;
964
- network: string;
965
- status: string;
966
- signingKey?: unknown;
967
- dateCreated?: string;
968
- custodial?: boolean;
969
- tags?: string[];
970
- boundToEvmNetwork?: boolean;
971
- [key: string]: unknown;
972
- }
973
-
974
- /**
975
- * Authenticated user with all required tokens
976
- */
977
- interface SignerAuthenticatedUser {
978
- identifier: string;
979
- signerAuthToken: string;
980
- persAccessToken: string;
981
- }
982
1039
  /**
983
1040
  * Authentication service for user login and registration
984
1041
  * Uses constructor-based dependency injection for WebAuthn provider
@@ -988,7 +1045,7 @@ declare class AuthenticationService {
988
1045
  private signerToken;
989
1046
  private config;
990
1047
  private webAuthnProvider;
991
- constructor(config: PersSignerConfig);
1048
+ constructor(config: ExtendedPersSignerConfig);
992
1049
  /**
993
1050
  * Login with PERS token to get signer JWT
994
1051
  * @param persToken - PERS JWT from PERS authentication
@@ -1033,7 +1090,7 @@ declare class AuthenticationService {
1033
1090
  * @param relyingPartyConfig - Configuration for WebAuthn relying party
1034
1091
  * @returns Promise resolving to authenticated user with signer token
1035
1092
  */
1036
- combinedAuthentication(identifier: string, persAccessToken: string): Promise<SignerAuthenticatedUser>;
1093
+ combinedAuthentication(identifier: string, persAccessToken: string): Promise<AuthenticatedUser>;
1037
1094
  }
1038
1095
 
1039
1096
  /**
@@ -1054,7 +1111,7 @@ declare function getBrowserWebAuthnProvider(): Promise<WebAuthnProvider>;
1054
1111
  * Create a new PersSignerSDK instance with browser WebAuthn provider
1055
1112
  * @param config - SDK configuration (ethersProviderUrl is required)
1056
1113
  */
1057
- declare function createPersSignerSDK(config: Omit<PersSignerConfig, 'webAuthnProvider'>): Promise<PersSignerSDK>;
1114
+ declare function createPersSignerSDK(config: PersSignerConfig): Promise<PersSignerSDK>;
1058
1115
 
1059
1116
  export { AuthenticationService, FetchHttpClient, KeyWallet, PersService, PersSignerSDK, ReactNativeConfigProvider, SIGNABLE_STATUSES, SigningService, StaticConfigProvider, TransactionErrorHandler, TransactionSigningErrorCode, TransactionSigningService, TransactionSubmissionHandler, TransactionValidator, WalletService, WebAuthnCoordinator, WebConfigProvider, createPersSignerSDK, getBrowserWebAuthnProvider, getConfigProvider, getHttpClient, getServiceConfig, getBrowserWebAuthnProvider as getWebAuthnProvider, setConfigProvider, setHttpClient };
1060
- export type { AuthResponse, AuthenticatedUser, CombinedTransactionStatus, ConfigProvider, HashSigningRequest, HttpClient, HttpRequestOptions, HttpResponse, PersSignerConfig, PlatformConfig, RegistrationChallenge, RegistrationResult, RelyingPartyConfig, ServiceConfig, ServiceError, SignResponse, SigningAuthTokens, SigningChallenge, SigningRequest, SubmissionResult, TransactionSigningError, TransactionSigningParams, TransactionSigningResult, TransactionStatusInfo, TypedDataSigningRequest, UserCredentials, WalletItem, WalletListResponse, WebAuthnConfig, WebAuthnProvider };
1117
+ export type { AuthResponse, AuthenticatedUser, CombinedTransactionStatus, CompleteRegistrationResponse, CompleteSignatureRequest, CompleteSignatureResponse, ConfigProvider, HashSigningRequest, HealthCheckResponse, HttpClient, HttpRequestOptions, HttpResponse, InitRegistrationRequest, InitRegistrationResponse, InitSignatureRequest, InitSignatureResponse, ListWalletsRequest, ListWalletsResponse, LoginRequest, LoginResponse, PersSignerConfig, PlatformConfig, RegistrationChallenge, RegistrationResult, RelyingPartyConfig, ServiceError, SignResponse, SignerApiError, SignerApiResponse, SigningAuthTokens, SigningChallenge, SigningRequest, SubmissionResult, TransactionSigningError, TransactionSigningParams, TransactionSigningResult, TransactionStatusInfo, TypedDataSigningRequest, UserCredentials, VerifyTokenRequest, VerifyTokenResponse, WalletItem, WalletListResponse, WebAuthnConfig, WebAuthnProvider };