@explorins/pers-signer 1.0.17 → 1.0.25

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,12 +1,69 @@
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, 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 { TransactionFormat, TransactionRequestResponseDTO } 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
 
10
+ interface JWTLoginResponse {
11
+ success: true;
12
+ access_token: string;
13
+ token_type: "Bearer";
14
+ expires_in: number;
15
+ user: {
16
+ id: string;
17
+ username: string;
18
+ org_id: string;
19
+ };
20
+ provider?: string;
21
+ }
22
+ interface VerifyTokenResponse {
23
+ valid: boolean;
24
+ provider: string;
25
+ claims: {
26
+ sub: string;
27
+ iss: string;
28
+ aud: string;
29
+ exp: number;
30
+ iat: number;
31
+ user_id: string;
32
+ username: string;
33
+ org_id: string;
34
+ provider: string;
35
+ permissions: unknown;
36
+ };
37
+ tenantId: string;
38
+ }
39
+ interface SigningKey {
40
+ curve: string;
41
+ publicKey: string;
42
+ scheme: string;
43
+ }
44
+ interface Wallet {
45
+ address?: string;
46
+ chainId?: number;
47
+ custodial?: boolean;
48
+ dateCreated?: string;
49
+ externalId?: string;
50
+ id: string;
51
+ name?: string;
52
+ network?: string;
53
+ provider?: string;
54
+ signingKey?: SigningKey;
55
+ status?: string;
56
+ tags?: string[];
57
+ }
58
+ interface CompleteSignatureResponse {
59
+ success: true;
60
+ data: {
61
+ status: string;
62
+ challenge?: unknown;
63
+ signature?: number[];
64
+ };
65
+ }
66
+
10
67
  /**
11
68
  * Wallet management service
12
69
  * Updated for v1 API endpoints per migration reference
@@ -17,7 +74,7 @@ declare class WalletService {
17
74
  * @param signerToken - Signer JWT token
18
75
  * @returns Promise resolving to wallet data
19
76
  */
20
- static listWallets(signerToken: string): Promise<unknown>;
77
+ static listWallets(signerToken: string): Promise<Wallet[]>;
21
78
  }
22
79
 
23
80
  /**
@@ -35,18 +92,12 @@ declare class PersService {
35
92
  private static tenantCache;
36
93
  private static currentProjectKey;
37
94
  private static currentTenantId;
38
- private static useStaging;
39
95
  private static readonly TENANT_CACHE_TTL;
40
96
  /**
41
97
  * Configure the PERS API settings
42
98
  * @param config - The configuration object
43
99
  */
44
100
  static configure(config: Partial<PersApiConfig>): void;
45
- /**
46
- * Enable staging mode when project key is not available
47
- * @param enableStaging Whether to use staging environment
48
- */
49
- static setStagingMode(enableStaging: boolean): void;
50
101
  /**
51
102
  * Get current configuration
52
103
  */
@@ -57,21 +108,21 @@ declare class PersService {
57
108
  * @param authToken - Optional auth token for authentication
58
109
  * @returns Promise with tenant public information
59
110
  */
60
- static getTenantById(tenantId: string, authToken?: string): Promise<TenantPublicDTO>;
111
+ static getTenantById(tenantId: string, authToken: string): Promise<TenantPublicDTO>;
61
112
  /**
62
113
  * Initialize tenant configuration from JWT
63
114
  * @param tenantId - The tenant ID from JWT payload
64
115
  * @param authToken - Optional auth token for authentication
65
116
  * @returns Promise with tenant information
66
117
  */
67
- static initializeTenant(tenantId: string, authToken?: string): Promise<TenantPublicDTO>;
118
+ static initializeTenant(tenantId: string, authToken: string): Promise<TenantPublicDTO>;
68
119
  /**
69
120
  * Ensure tenant is initialized and current, with automatic revalidation
70
121
  * @param tenantId - The tenant ID to ensure is initialized
71
122
  * @param authToken - Optional auth token for authentication
72
123
  * @returns Promise with tenant information
73
124
  */
74
- static ensureTenantInitialized(tenantId: string, authToken?: string): Promise<TenantPublicDTO>;
125
+ static ensureTenantInitialized(tenantId: string, authToken: string): Promise<TenantPublicDTO>;
75
126
  /**
76
127
  * Get the current project key (either from tenant or fallback)
77
128
  * @param tenantId - Optional tenant ID to ensure is initialized
@@ -85,7 +136,7 @@ declare class PersService {
85
136
  /**
86
137
  * Authenticates a user with the PERS backend using their auth token
87
138
  *
88
- * @param authToken - The authentication token received from DFNS after login/registration
139
+ * @param authToken - The authentication token received from backend after login/registration
89
140
  * @param tenantId - Optional tenant ID for automatic initialization
90
141
  * @returns A promise that resolves to the authentication response
91
142
  * @throws If the request fails
@@ -127,12 +178,78 @@ declare class PersService {
127
178
  static getTransactionDataForSigning(transactionResponse: TransactionRequestResponseDTO): _explorins_pers_shared_browser.CounterfactualWalletTransactionResponse | _explorins_web3_ts_types.LegacyTransaction;
128
179
  }
129
180
 
181
+ interface GetWalletResponse {
182
+ id: string;
183
+ signingKey: {
184
+ publicKey: string;
185
+ };
186
+ }
187
+ type WalletMetadata = GetWalletResponse & {
188
+ boundToEvmNetwork: boolean;
189
+ };
190
+
130
191
  /**
131
192
  * Types for WebAuthn provider abstraction
132
193
  */
194
+ interface WebAuthnAssertion {
195
+ kind: 'Fido2';
196
+ credentialAssertion: {
197
+ credId: string;
198
+ clientData: string;
199
+ authenticatorData: string;
200
+ signature: string;
201
+ userHandle?: string;
202
+ };
203
+ }
204
+ interface WebAuthnAttestation {
205
+ id: string;
206
+ clientDataJSON: string;
207
+ attestationObject: string;
208
+ }
209
+ interface WebAuthnCredential {
210
+ id: string;
211
+ transports?: AuthenticatorTransport[];
212
+ }
213
+ interface WebAuthnSignChallenge {
214
+ challenge: string;
215
+ challengeIdentifier?: string;
216
+ allowCredentials?: {
217
+ webauthn?: WebAuthnCredential[];
218
+ key?: any[];
219
+ };
220
+ rpId?: string;
221
+ userVerification?: UserVerificationRequirement;
222
+ timeout?: number;
223
+ [key: string]: any;
224
+ }
225
+ interface WebAuthnCreateChallenge {
226
+ challenge: string;
227
+ user: {
228
+ id: string;
229
+ name: string;
230
+ displayName: string;
231
+ };
232
+ rp: {
233
+ id: string;
234
+ name: string;
235
+ };
236
+ pubKeyCredParams: {
237
+ type: "public-key";
238
+ alg: number;
239
+ }[];
240
+ authenticatorSelection?: AuthenticatorSelectionCriteria;
241
+ attestation?: AttestationConveyancePreference;
242
+ timeout?: number;
243
+ excludeCredentials?: {
244
+ id: string;
245
+ type: "public-key";
246
+ transports?: AuthenticatorTransport[];
247
+ }[];
248
+ [key: string]: any;
249
+ }
133
250
  interface WebAuthnProvider {
134
- create(challenge: any): Promise<any>;
135
- sign(challenge: any): Promise<any>;
251
+ create(challenge: WebAuthnCreateChallenge): Promise<WebAuthnAttestation>;
252
+ sign(challenge: WebAuthnSignChallenge): Promise<WebAuthnAssertion>;
136
253
  }
137
254
  interface WebAuthnConfig {
138
255
  relyingParty: {
@@ -142,61 +259,6 @@ interface WebAuthnConfig {
142
259
  };
143
260
  }
144
261
 
145
- /**
146
- * Key service response types and interfaces
147
- */
148
- /**
149
- * Signature response from key signing operations
150
- */
151
- interface SignResponse {
152
- id: string;
153
- keyId: string;
154
- requester: {
155
- userId: string;
156
- appId: string;
157
- };
158
- requestBody: {
159
- hash: string;
160
- kind: "Hash";
161
- };
162
- status: "Signed";
163
- signature: {
164
- r: string;
165
- s: string;
166
- v: number;
167
- encoded: string;
168
- };
169
- network: "KeyECDSA";
170
- dateRequested: string;
171
- dateSigned: string;
172
- walletId: string;
173
- }
174
- /**
175
- * Authentication response from login/register operations
176
- */
177
- interface AuthResponse {
178
- token: string;
179
- message?: string;
180
- status?: number;
181
- }
182
- /**
183
- * Registration challenge response
184
- */
185
- interface RegistrationChallenge {
186
- temporaryAuthenticationToken: string;
187
- challenge: any;
188
- status?: number;
189
- message?: string;
190
- }
191
- /**
192
- * Registration completion response
193
- */
194
- interface RegistrationResult {
195
- token: string;
196
- walletId?: string;
197
- status?: number;
198
- message?: string;
199
- }
200
262
  /**
201
263
  * Individual wallet item
202
264
  */
@@ -221,89 +283,6 @@ interface TypedDataSigningRequest {
221
283
  * Generic signing request
222
284
  */
223
285
  type SigningRequest = HashSigningRequest | TypedDataSigningRequest;
224
- /**
225
- * Signing challenge response
226
- */
227
- interface SigningChallenge {
228
- requestBody: any;
229
- challenge: {
230
- challengeIdentifier: string;
231
- [key: string]: any;
232
- };
233
- status?: number;
234
- message?: string;
235
- }
236
- /**
237
- * User credentials for authentication
238
- */
239
- interface UserCredentials {
240
- username: string;
241
- appId?: string;
242
- }
243
- /**
244
- * Relying party configuration for WebAuthn
245
- */
246
- interface RelyingPartyConfig {
247
- id: string;
248
- name: string;
249
- origin?: string;
250
- }
251
-
252
- interface JWTLoginResponse {
253
- success: true;
254
- access_token: string;
255
- token_type: "Bearer";
256
- expires_in: number;
257
- user: {
258
- id: string;
259
- username: string;
260
- org_id: string;
261
- };
262
- provider: string;
263
- }
264
- interface VerifyTokenResponse {
265
- valid: boolean;
266
- provider: string;
267
- claims: {
268
- sub: string;
269
- iss: string;
270
- aud: string;
271
- exp: number;
272
- iat: number;
273
- user_id: string;
274
- username: string;
275
- org_id: string;
276
- provider: string;
277
- permissions: unknown;
278
- };
279
- tenantId: string;
280
- }
281
- interface CompleteSignatureResponse {
282
- success: true;
283
- data: {
284
- signature?: {
285
- r: string;
286
- s: string;
287
- recid: number;
288
- encoded: string;
289
- } | string;
290
- transaction?: unknown;
291
- dateRequested?: string;
292
- dateSigned?: string;
293
- id?: string;
294
- keyId?: string;
295
- network?: string;
296
- requestBody?: {
297
- kind?: 'Eip712' | 'Hash' | string;
298
- blockchainKind?: string;
299
- [key: string]: unknown;
300
- };
301
- requester?: unknown;
302
- status?: string;
303
- walletId?: string;
304
- [key: string]: unknown;
305
- };
306
- }
307
286
 
308
287
  /**
309
288
  * Signing service for cryptographic operations
@@ -349,84 +328,10 @@ declare class SigningService {
349
328
  signBatch(authToken: string, walletId: string, requests: SigningRequest[]): Promise<CompleteSignatureResponse['data'][]>;
350
329
  }
351
330
 
352
- /**
353
- * Shared type definitions for the blockchain signer shared library
354
- */
355
-
356
- /**
357
- * Authentication types for 3-function split architecture
358
- */
359
- interface AuthenticatedUser {
360
- identifier: string;
361
- signerAuthToken: string;
362
- persAccessToken: string;
363
- tenantId: string;
364
- expiresAt: number;
365
- }
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
- /**
376
- * Error types for service operations
377
- */
378
- interface ServiceError {
379
- code: string;
380
- message: string;
381
- details?: any;
382
- timestamp: Date;
383
- }
384
-
385
- interface GetWalletResponse {
386
- id: string;
387
- signingKey: {
388
- publicKey: string;
389
- };
390
- }
391
-
392
- type WalletOptions = {
393
- wallet: WalletMetadata;
394
- authToken: string;
395
- signingService: SigningService;
396
- };
397
- type WalletMetadata = GetWalletResponse & {
398
- boundToEvmNetwork: boolean;
399
- };
400
- declare class KeyWallet extends AbstractSigner {
401
- private options;
402
- private address?;
403
- private authToken;
404
- private metadata;
405
- private signingService;
406
- constructor(options: WalletOptions, provider?: Provider | null);
407
- connect(provider: Provider | null): KeyWallet;
408
- getAddress(): Promise<string>;
409
- private signHash;
410
- signTransaction(tx: TransactionRequest): Promise<string>;
411
- signMessage(message: string | Uint8Array): Promise<string>;
412
- signTypedData(domain: TypedDataDomain, types: Record<string, TypedDataField[]>, value: Record<string, any>): Promise<string>;
413
- /**
414
- * Signs a PERS transaction based on its format
415
- * Handles different transaction types: Legacy, EIP-2930, EIP-1559, and EIP-712
416
- * @param transactionData - The transaction data from PERS API
417
- * @returns The signature string
418
- */
419
- signPersTransaction(transactionData: AnyTransactionData): Promise<string>;
420
- }
421
-
422
331
  /**
423
332
  * Combined transaction status type that includes both PERS and additional statuses
424
333
  */
425
334
  type CombinedTransactionStatus = TransactionStatus;
426
- /**
427
- * Transaction statuses that allow signing
428
- */
429
- declare const SIGNABLE_STATUSES: readonly [TransactionStatus.PENDING_SIGNATURE, TransactionStatus.CREATED];
430
335
  /**
431
336
  * Transaction status information for UI display
432
337
  */
@@ -479,6 +384,111 @@ interface TransactionSigningParams {
479
384
  returnUrl?: string;
480
385
  }
481
386
 
387
+ /**
388
+ * Error codes for transaction signing operations
389
+ */
390
+ declare enum TransactionSigningErrorCode {
391
+ INVALID_TOKENS = "INVALID_TOKENS",
392
+ TRANSACTION_NOT_FOUND = "TRANSACTION_NOT_FOUND",
393
+ TRANSACTION_NOT_PENDING = "TRANSACTION_NOT_PENDING",
394
+ WALLET_NOT_AVAILABLE = "WALLET_NOT_AVAILABLE",
395
+ WEBAUTHN_OPERATION_IN_PROGRESS = "WEBAUTHN_OPERATION_IN_PROGRESS",
396
+ SIGNING_CANCELLED = "SIGNING_CANCELLED",
397
+ PERS_AUTH_FAILED = "PERS_AUTH_FAILED",
398
+ AUTH_FAILED = "AUTH_FAILED",
399
+ TRANSACTION_NOT_READY = "TRANSACTION_NOT_READY",
400
+ SUBMISSION_FAILED = "SUBMISSION_FAILED",
401
+ SERVER_ERROR = "SERVER_ERROR",
402
+ UNKNOWN_ERROR = "UNKNOWN_ERROR"
403
+ }
404
+ /**
405
+ * Structured error for transaction signing operations
406
+ */
407
+ interface TransactionSigningError extends Error {
408
+ code: TransactionSigningErrorCode;
409
+ transactionId?: string;
410
+ originalError?: unknown;
411
+ }
412
+
413
+ /**
414
+ * Signing status types for type-safe status updates
415
+ * Using const pattern instead of enum for better bundling compatibility
416
+ */
417
+ declare const SigningStatus: {
418
+ readonly INITIALIZING: "initializing";
419
+ readonly AUTHENTICATING: "authenticating";
420
+ readonly PREPARING: "preparing";
421
+ readonly SIGNING: "signing";
422
+ readonly SUBMITTING: "submitting";
423
+ readonly COMPLETED: "completed";
424
+ readonly ERROR: "error";
425
+ readonly EXPIRED: "expired";
426
+ };
427
+ /**
428
+ * Type for signing status values
429
+ */
430
+ type SigningStatus = typeof SigningStatus[keyof typeof SigningStatus];
431
+ /**
432
+ * Status update data interface
433
+ */
434
+ interface StatusUpdateData {
435
+ transactionId?: string;
436
+ transactionHash?: string;
437
+ error?: string;
438
+ [key: string]: any;
439
+ }
440
+ /**
441
+ * Status update callback interface for tracking transaction progress
442
+ *
443
+ * @interface StatusCallback
444
+ * @property {function} onStatusUpdate - Callback function that receives type-safe status updates
445
+ */
446
+ interface StatusCallback {
447
+ onStatusUpdate?: (status: SigningStatus, message: string, data?: StatusUpdateData) => void;
448
+ }
449
+
450
+ /**
451
+ * Central type definitions for the blockchain signer shared library
452
+ * Single source of truth for all type exports
453
+ */
454
+
455
+ /**
456
+ * Authentication types for 3-function split architecture
457
+ */
458
+ interface AuthenticatedUser {
459
+ identifier: string;
460
+ signerAuthToken: string;
461
+ persAccessToken: string;
462
+ expiresAt: number;
463
+ }
464
+
465
+ type WalletOptions = {
466
+ wallet: WalletMetadata;
467
+ authToken: string;
468
+ signingService: SigningService;
469
+ };
470
+ declare class KeyWallet extends AbstractSigner {
471
+ private options;
472
+ private address?;
473
+ private authToken;
474
+ private metadata;
475
+ private signingService;
476
+ constructor(options: WalletOptions, provider?: Provider | null);
477
+ connect(provider: Provider | null): KeyWallet;
478
+ getAddress(): Promise<string>;
479
+ private signHash;
480
+ signTransaction(tx: TransactionRequest): Promise<string>;
481
+ signMessage(message: string | Uint8Array): Promise<string>;
482
+ signTypedData(domain: TypedDataDomain, types: Record<string, TypedDataField[]>, value: Record<string, any>): Promise<string>;
483
+ /**
484
+ * Signs a PERS transaction based on its format
485
+ * Handles different transaction types: Legacy, EIP-2930, EIP-1559, and EIP-712
486
+ * @param transactionData - The transaction data from PERS API
487
+ * @returns The signature string
488
+ */
489
+ signPersTransaction(transactionData: AnyTransactionData): Promise<string>;
490
+ }
491
+
482
492
  /**
483
493
  * PERS Blockchain Signer SDK
484
494
  *
@@ -517,12 +527,14 @@ interface TransactionSigningParams {
517
527
  * @property {WebAuthnProvider} webAuthnProvider - WebAuthn provider for secure authentication
518
528
  * @property {string} [apiUrl] - Custom API base URL (defaults to production)
519
529
  * @property {string} [relyingPartyName] - WebAuthn relying party name for authentication
530
+ * @property {StatusCallback} [globalStatusCallback] - Optional global status callback for all operations
520
531
  */
521
532
  interface ExtendedPersSignerConfig {
522
533
  ethersProviderUrl?: string;
523
534
  webAuthnProvider: WebAuthnProvider;
524
535
  apiUrl?: string;
525
536
  relyingPartyName?: string;
537
+ globalStatusCallback?: StatusCallback;
526
538
  }
527
539
  interface PersSignerConfig extends Omit<ExtendedPersSignerConfig, 'webAuthnProvider'> {
528
540
  }
@@ -552,6 +564,11 @@ declare class PersSignerSDK {
552
564
  * @throws {Error} If required configuration is missing
553
565
  */
554
566
  constructor(config: ExtendedPersSignerConfig);
567
+ /**
568
+ * Helper method to trigger both global and method-specific status callbacks
569
+ * @private
570
+ */
571
+ private triggerStatusUpdate;
555
572
  /**
556
573
  * Authenticate user and cache session for 5 minutes
557
574
  *
@@ -559,20 +576,23 @@ declare class PersSignerSDK {
559
576
  * and caches the authenticated user session to avoid repeated authentication.
560
577
  *
561
578
  * @param {string} jwtToken - JWT token containing user identifier and tenant info
579
+ * @param {StatusCallback} [statusCallback] - Optional callback for status updates
562
580
  * @returns {Promise<AuthenticatedUser>} Authenticated user with access tokens
563
581
  * @throws {Error} If JWT is invalid, expired, or authentication fails
564
582
  *
565
583
  * @example
566
584
  * ```typescript
567
585
  * try {
568
- * const user = await sdk.loginUser(jwtToken);
586
+ * const user = await sdk.loginUser(jwtToken, {
587
+ * onStatusUpdate: (status, message) => console.log(`${status}: ${message}`)
588
+ * });
569
589
  * console.log('Authenticated:', user.identifier);
570
590
  * } catch (error) {
571
591
  * console.error('Authentication failed:', error.message);
572
592
  * }
573
593
  * ```
574
594
  */
575
- loginUser(jwtToken: string): Promise<AuthenticatedUser>;
595
+ loginUser(jwtToken: string, statusCallback?: StatusCallback): Promise<AuthenticatedUser>;
576
596
  /**
577
597
  * Sign a PERS transaction (legacy compatibility method)
578
598
  *
@@ -581,13 +601,16 @@ declare class PersSignerSDK {
581
601
  * maintained for backward compatibility.
582
602
  *
583
603
  * @param {string} jwtToken - JWT token containing transaction ID and user info
604
+ * @param {StatusCallback} [statusCallback] - Optional callback for status updates
584
605
  * @returns {Promise<TransactionSigningResult>} Signing result with signature and metadata
585
606
  * @throws {Error} If authentication fails, transaction ID missing, or signing fails
586
607
  *
587
608
  * @example
588
609
  * ```typescript
589
610
  * try {
590
- * const result = await sdk.signPersTransaction(jwtToken);
611
+ * const result = await sdk.signPersTransaction(jwtToken, {
612
+ * onStatusUpdate: (status, message) => console.log(`${status}: ${message}`)
613
+ * });
591
614
  * if (result.success) {
592
615
  * console.log('Transaction signed:', result.signature);
593
616
  * }
@@ -596,7 +619,7 @@ declare class PersSignerSDK {
596
619
  * }
597
620
  * ```
598
621
  */
599
- signPersTransaction(jwtToken: string): Promise<TransactionSigningResult>;
622
+ signPersTransaction(jwtToken: string, statusCallback?: StatusCallback): Promise<TransactionSigningResult>;
600
623
  /**
601
624
  * Sign a transaction with provided signing data
602
625
  *
@@ -605,17 +628,20 @@ declare class PersSignerSDK {
605
628
  *
606
629
  * @param {CounterfactualWalletTransactionResponse | LegacyTransaction} signingData - Transaction data to sign
607
630
  * @param {string} jwtToken - JWT token containing transaction ID and user info
631
+ * @param {StatusCallback} [statusCallback] - Optional callback for status updates
608
632
  * @returns {Promise<TransactionSigningResult>} Signing result with signature and metadata
609
633
  * @throws {Error} If authentication fails, transaction ID missing, or signing fails
610
634
  *
611
635
  * @example
612
636
  * ```typescript
613
637
  * const signingData = await getTransactionData(transactionId);
614
- * const result = await sdk.signTransaction(signingData, jwtToken);
638
+ * const result = await sdk.signTransaction(signingData, jwtToken, {
639
+ * onStatusUpdate: (status, message) => console.log(`${status}: ${message}`)
640
+ * });
615
641
  * console.log('Signed transaction:', result.signature);
616
642
  * ```
617
643
  */
618
- signTransaction(signingData: CounterfactualWalletTransactionResponse$1 | LegacyTransaction, jwtToken: string): Promise<TransactionSigningResult>;
644
+ signTransaction(signingData: CounterfactualWalletTransactionResponse$1 | LegacyTransaction, jwtToken: string, statusCallback?: StatusCallback): Promise<TransactionSigningResult>;
619
645
  /**
620
646
  * Complete transaction flow: sign and submit in one call
621
647
  *
@@ -624,13 +650,18 @@ declare class PersSignerSDK {
624
650
  * transaction lifecycle automatically.
625
651
  *
626
652
  * @param {string} jwtToken - JWT token containing transaction ID and user info
653
+ * @param {StatusCallback} [statusCallback] - Optional callback for status updates
627
654
  * @returns {Promise<SubmissionResult>} Submission result with transaction hash and status
628
655
  * @throws {Error} If authentication, signing, or submission fails
629
656
  *
630
657
  * @example
631
658
  * ```typescript
632
659
  * try {
633
- * const result = await sdk.signAndSubmitPersTransaction(jwtToken);
660
+ * const result = await sdk.signAndSubmitPersTransaction(jwtToken, {
661
+ * onStatusUpdate: (status, message) => {
662
+ * console.log(`Status: ${status} - ${message}`);
663
+ * }
664
+ * });
634
665
  * if (result.success) {
635
666
  * console.log('Transaction completed:', result.transactionHash);
636
667
  * if (result.shouldRedirect) {
@@ -642,7 +673,7 @@ declare class PersSignerSDK {
642
673
  * }
643
674
  * ```
644
675
  */
645
- signAndSubmitPersTransaction(jwtToken: string): Promise<SubmissionResult>;
676
+ signAndSubmitPersTransaction(jwtToken: string, statusCallback?: StatusCallback): Promise<SubmissionResult>;
646
677
  /**
647
678
  * Submit a signed transaction to the blockchain
648
679
  *
@@ -652,17 +683,20 @@ declare class PersSignerSDK {
652
683
  *
653
684
  * @param {TransactionSigningResult} signingResult - Result from a successful transaction signing
654
685
  * @param {string} jwtToken - JWT token containing tenant and user info
686
+ * @param {StatusCallback} [statusCallback] - Optional callback for status updates
655
687
  * @returns {Promise<SubmissionResult>} Submission result with transaction hash and status
656
688
  * @throws {Error} If signing result is invalid, JWT is missing tenantId, or submission fails
657
689
  *
658
690
  * @example
659
691
  * ```typescript
660
692
  * const signedTx = await sdk.signPersTransaction(jwtToken);
661
- * const result = await sdk.submitTransaction(signedTx, jwtToken);
693
+ * const result = await sdk.submitTransaction(signedTx, jwtToken, {
694
+ * onStatusUpdate: (status, message) => console.log(`${status}: ${message}`)
695
+ * });
662
696
  * console.log('Transaction submitted:', result.transactionHash);
663
697
  * ```
664
698
  */
665
- submitTransaction(signingResult: TransactionSigningResult, jwtToken: string): Promise<SubmissionResult>;
699
+ submitTransaction(signingResult: TransactionSigningResult, jwtToken: string, statusCallback?: StatusCallback): Promise<SubmissionResult>;
666
700
  /**
667
701
  * Clear user authentication cache
668
702
  *
@@ -715,32 +749,6 @@ declare class TransactionSigningService {
715
749
  signTransaction(params: TransactionSigningParams, signingData: CounterfactualWalletTransactionResponse | LegacyTransaction): Promise<TransactionSigningResult>;
716
750
  }
717
751
 
718
- /**
719
- * Error codes for transaction signing operations
720
- */
721
- declare enum TransactionSigningErrorCode {
722
- INVALID_TOKENS = "INVALID_TOKENS",
723
- TRANSACTION_NOT_FOUND = "TRANSACTION_NOT_FOUND",
724
- TRANSACTION_NOT_PENDING = "TRANSACTION_NOT_PENDING",
725
- WALLET_NOT_AVAILABLE = "WALLET_NOT_AVAILABLE",
726
- WEBAUTHN_OPERATION_IN_PROGRESS = "WEBAUTHN_OPERATION_IN_PROGRESS",
727
- SIGNING_CANCELLED = "SIGNING_CANCELLED",
728
- PERS_AUTH_FAILED = "PERS_AUTH_FAILED",
729
- AUTH_FAILED = "AUTH_FAILED",
730
- TRANSACTION_NOT_READY = "TRANSACTION_NOT_READY",
731
- SUBMISSION_FAILED = "SUBMISSION_FAILED",
732
- SERVER_ERROR = "SERVER_ERROR",
733
- UNKNOWN_ERROR = "UNKNOWN_ERROR"
734
- }
735
- /**
736
- * Structured error for transaction signing operations
737
- */
738
- interface TransactionSigningError extends Error {
739
- code: TransactionSigningErrorCode;
740
- transactionId?: string;
741
- originalError?: unknown;
742
- }
743
-
744
752
  /**
745
753
  * Handles all error-related operations for transaction signing
746
754
  */
@@ -787,11 +795,9 @@ declare class TransactionErrorHandler {
787
795
  error?: {
788
796
  code?: string;
789
797
  message?: string;
790
- developerMessage?: string;
791
798
  };
792
799
  code?: string;
793
800
  message?: string;
794
- developerMessage?: string;
795
801
  }, transactionId: string): never;
796
802
  /**
797
803
  * Process PERS API errors and handle TRANSACTION_NOT_PENDING cases
@@ -950,36 +956,6 @@ declare function setHttpClient(client: HttpClient): void;
950
956
  */
951
957
  declare function getHttpClient(): HttpClient;
952
958
 
953
- /**
954
- * Wallet list response from WalletService
955
- */
956
- interface WalletListResponse {
957
- items: WalletItem[];
958
- }
959
- /**
960
- * Individual wallet item from wallet list - compatible with KeyWallet constructor
961
- */
962
- interface WalletItem {
963
- id: string;
964
- address: string;
965
- network: string;
966
- status: string;
967
- signingKey?: unknown;
968
- dateCreated?: string;
969
- custodial?: boolean;
970
- tags?: string[];
971
- boundToEvmNetwork?: boolean;
972
- [key: string]: unknown;
973
- }
974
-
975
- /**
976
- * Authenticated user with all required tokens
977
- */
978
- interface SignerAuthenticatedUser {
979
- identifier: string;
980
- signerAuthToken: string;
981
- persAccessToken: string;
982
- }
983
959
  /**
984
960
  * Authentication service for user login and registration
985
961
  * Uses constructor-based dependency injection for WebAuthn provider
@@ -987,7 +963,6 @@ interface SignerAuthenticatedUser {
987
963
  */
988
964
  declare class AuthenticationService {
989
965
  private signerToken;
990
- private config;
991
966
  private webAuthnProvider;
992
967
  constructor(config: ExtendedPersSignerConfig);
993
968
  /**
@@ -1003,11 +978,11 @@ declare class AuthenticationService {
1003
978
  */
1004
979
  verifyToken(token: string): Promise<VerifyTokenResponse>;
1005
980
  /**
1006
- * Initialize user registration
1007
- * @param persToken - PERS JWT token (registration is public)
1008
- * @returns Promise resolving to registration challenge
981
+ * Register user with unified flow
982
+ * @param persToken - PERS JWT token
983
+ * @returns Promise resolving to authenticated user data
1009
984
  */
1010
- initializeRegistration(persToken: string): Promise<unknown>;
985
+ registerUser(persToken: string): Promise<JWTLoginResponse>;
1011
986
  /**
1012
987
  * Get current signer token
1013
988
  * @returns The current signer JWT token
@@ -1018,14 +993,6 @@ declare class AuthenticationService {
1018
993
  * @param token - Signer JWT token
1019
994
  */
1020
995
  setSignerToken(token: string): void;
1021
- /**
1022
- * Complete registration with WebAuthn challenge data (v1 API format)
1023
- * @param tmpAuthToken - Temporary auth token from init registration (temporaryAuthenticationToken)
1024
- * @param signedChallenge - WebAuthn credential response (will be restructured for backend)
1025
- * @param persToken - PERS JWT token (authToken)
1026
- * @returns Promise resolving to registration result
1027
- */
1028
- completeRegistrationWithChallenge(tmpAuthToken: string | null, signedChallenge: any, persToken: string): Promise<JWTLoginResponse | unknown>;
1029
996
  /**
1030
997
  * Combined authentication flow - handles both login and registration
1031
998
  * @param identifier - User identifier (email/userId)
@@ -1034,11 +1001,12 @@ declare class AuthenticationService {
1034
1001
  * @param relyingPartyConfig - Configuration for WebAuthn relying party
1035
1002
  * @returns Promise resolving to authenticated user with signer token
1036
1003
  */
1037
- combinedAuthentication(identifier: string, persAccessToken: string): Promise<SignerAuthenticatedUser>;
1004
+ combinedAuthentication(identifier: string, persAccessToken: string): Promise<AuthenticatedUser>;
1038
1005
  }
1039
1006
 
1040
1007
  /**
1041
- * Browser-specific WebAuthn provider using DFNS browser SDK
1008
+ * Browser-specific WebAuthn provider using native browser APIs
1009
+ * Fully agnostic implementation without external SDK dependencies
1042
1010
  */
1043
1011
 
1044
1012
  /**
@@ -1048,14 +1016,53 @@ declare function getBrowserWebAuthnProvider(): Promise<WebAuthnProvider>;
1048
1016
 
1049
1017
  /**
1050
1018
  * Browser-specific entry point for the PERS Signer SDK
1051
- * Includes only browser-compatible dependencies
1019
+ *
1020
+ * This module provides browser-optimized SDK functionality with automatic WebAuthn provider setup.
1021
+ * Use this entry point for all browser-based applications (React, Vue, Angular, etc.).
1022
+ *
1023
+ * @example
1024
+ * ```typescript
1025
+ * import { createPersSignerSDK } from '@explorins/pers-signer/browser';
1026
+ *
1027
+ * // Simple initialization - WebAuthn provider is handled automatically
1028
+ * const sdk = await createPersSignerSDK({
1029
+ * ethersProviderUrl: 'https://mainnet.infura.io/v3/YOUR_KEY'
1030
+ * });
1031
+ *
1032
+ * // Complete transaction flow
1033
+ * const result = await sdk.signAndSubmitPersTransaction(jwtToken);
1034
+ * if (result.success) {
1035
+ * console.log('Transaction completed:', result.transactionHash);
1036
+ * }
1037
+ * ```
1052
1038
  */
1053
1039
 
1054
1040
  /**
1055
1041
  * Create a new PersSignerSDK instance with browser WebAuthn provider
1056
- * @param config - SDK configuration (ethersProviderUrl is required)
1042
+ *
1043
+ * This is the recommended way to initialize the SDK in browser environments.
1044
+ * The WebAuthn provider is automatically configured for browser usage.
1045
+ *
1046
+ * @param config - SDK configuration object
1047
+ * @param config.ethersProviderUrl - Optional custom Ethereum RPC provider URL
1048
+ * @param config.apiUrl - Optional custom API base URL (defaults to production)
1049
+ * @param config.relyingPartyName - Optional WebAuthn relying party name
1050
+ * @param config.globalStatusCallback - Optional global status callback for all operations
1051
+ * @returns Promise resolving to configured PersSignerSDK instance
1052
+ *
1053
+ * @example
1054
+ * ```typescript
1055
+ * import { createPersSignerSDK } from '@explorins/pers-signer/browser';
1056
+ *
1057
+ * const sdk = await createPersSignerSDK({
1058
+ * ethersProviderUrl: 'https://mainnet.infura.io/v3/YOUR_KEY'
1059
+ * });
1060
+ *
1061
+ * // Use the SDK
1062
+ * const result = await sdk.signAndSubmitPersTransaction(jwtToken);
1063
+ * ```
1057
1064
  */
1058
1065
  declare function createPersSignerSDK(config: PersSignerConfig): Promise<PersSignerSDK>;
1059
1066
 
1060
- 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 };
1061
- 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 };
1067
+ export { AuthenticationService, FetchHttpClient, KeyWallet, PersService, PersSignerSDK, ReactNativeConfigProvider, SigningService, SigningStatus, StaticConfigProvider, TransactionErrorHandler, TransactionSigningService, TransactionSubmissionHandler, TransactionValidator, WalletService, WebAuthnCoordinator, WebConfigProvider, createPersSignerSDK, getBrowserWebAuthnProvider, getConfigProvider, getHttpClient, getServiceConfig, getBrowserWebAuthnProvider as getWebAuthnProvider, setConfigProvider, setHttpClient };
1068
+ export type { AuthenticatedUser, ConfigProvider, HttpClient, HttpRequestOptions, HttpResponse, PersSignerConfig, PlatformConfig, StatusCallback, StatusUpdateData, SubmissionResult, TransactionSigningResult, WebAuthnConfig, WebAuthnProvider };