@explorins/pers-signer 1.0.12 → 1.0.17
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.cjs.js +819 -990
- package/dist/browser.cjs.js.map +1 -1
- package/dist/browser.d.ts +365 -499
- package/dist/browser.esm.js +820 -976
- package/dist/browser.esm.js.map +1 -1
- package/dist/index.cjs.js +890 -982
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +627 -605
- package/dist/index.esm.js +886 -970
- package/dist/index.esm.js.map +1 -1
- package/dist/react-native.cjs.js +820 -991
- package/dist/react-native.cjs.js.map +1 -1
- package/dist/react-native.d.ts +365 -499
- package/dist/react-native.esm.js +821 -977
- package/dist/react-native.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/browser.d.ts
CHANGED
|
@@ -1,36 +1,23 @@
|
|
|
1
1
|
import * as _explorins_web3_ts_types from '@explorins/web3-ts/types';
|
|
2
|
-
import { AnyTransactionData } from '@explorins/web3-ts/types';
|
|
2
|
+
import { AnyTransactionData, LegacyTransaction } from '@explorins/web3-ts/types';
|
|
3
3
|
export { AnyTransactionData } from '@explorins/web3-ts/types';
|
|
4
4
|
import * as _explorins_pers_shared_browser from '@explorins/pers-shared/browser';
|
|
5
|
-
import { TenantPublicDTO, SessionAuthContextResponseDTO,
|
|
5
|
+
import { TenantPublicDTO, SessionAuthContextResponseDTO, TransactionFormat, TransactionRequestResponseDTO, CounterfactualWalletTransactionResponse, TransactionStatus } from '@explorins/pers-shared/browser';
|
|
6
6
|
export { TransactionFormat, TransactionRequestResponseDTO, TransactionStatus } from '@explorins/pers-shared/browser';
|
|
7
7
|
import { AbstractSigner, Provider, TransactionRequest, TypedDataDomain, TypedDataField } from 'ethers';
|
|
8
|
+
import { CounterfactualWalletTransactionResponse as CounterfactualWalletTransactionResponse$1 } from '@explorins/pers-shared';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* Wallet management service
|
|
11
|
-
*
|
|
12
|
+
* Updated for v1 API endpoints per migration reference
|
|
12
13
|
*/
|
|
13
14
|
declare class WalletService {
|
|
14
15
|
/**
|
|
15
16
|
* List all wallets for authenticated user
|
|
16
|
-
* @param
|
|
17
|
-
* @returns Promise resolving to wallet
|
|
18
|
-
*/
|
|
19
|
-
static listWallets(authToken: string): Promise<any>;
|
|
20
|
-
/**
|
|
21
|
-
* Get wallet by ID (when backend supports it)
|
|
22
|
-
* @param authToken - Authentication token
|
|
23
|
-
* @param walletId - Wallet identifier
|
|
24
|
-
* @returns Promise resolving to wallet details
|
|
17
|
+
* @param signerToken - Signer JWT token
|
|
18
|
+
* @returns Promise resolving to wallet data
|
|
25
19
|
*/
|
|
26
|
-
static
|
|
27
|
-
/**
|
|
28
|
-
* Create new wallet (when backend supports it)
|
|
29
|
-
* @param authToken - Authentication token
|
|
30
|
-
* @param walletConfig - Wallet configuration
|
|
31
|
-
* @returns Promise resolving to wallet creation result
|
|
32
|
-
*/
|
|
33
|
-
static createWallet(authToken: string, walletConfig: any): Promise<any>;
|
|
20
|
+
static listWallets(signerToken: string): Promise<unknown>;
|
|
34
21
|
}
|
|
35
22
|
|
|
36
23
|
/**
|
|
@@ -47,7 +34,9 @@ declare class PersService {
|
|
|
47
34
|
private static config;
|
|
48
35
|
private static tenantCache;
|
|
49
36
|
private static currentProjectKey;
|
|
37
|
+
private static currentTenantId;
|
|
50
38
|
private static useStaging;
|
|
39
|
+
private static readonly TENANT_CACHE_TTL;
|
|
51
40
|
/**
|
|
52
41
|
* Configure the PERS API settings
|
|
53
42
|
* @param config - The configuration object
|
|
@@ -76,8 +65,16 @@ declare class PersService {
|
|
|
76
65
|
* @returns Promise with tenant information
|
|
77
66
|
*/
|
|
78
67
|
static initializeTenant(tenantId: string, authToken?: string): Promise<TenantPublicDTO>;
|
|
68
|
+
/**
|
|
69
|
+
* Ensure tenant is initialized and current, with automatic revalidation
|
|
70
|
+
* @param tenantId - The tenant ID to ensure is initialized
|
|
71
|
+
* @param authToken - Optional auth token for authentication
|
|
72
|
+
* @returns Promise with tenant information
|
|
73
|
+
*/
|
|
74
|
+
static ensureTenantInitialized(tenantId: string, authToken?: string): Promise<TenantPublicDTO>;
|
|
79
75
|
/**
|
|
80
76
|
* Get the current project key (either from tenant or fallback)
|
|
77
|
+
* @param tenantId - Optional tenant ID to ensure is initialized
|
|
81
78
|
* @returns The project key to use for API calls
|
|
82
79
|
*/
|
|
83
80
|
private static getProjectKey;
|
|
@@ -89,19 +86,11 @@ declare class PersService {
|
|
|
89
86
|
* Authenticates a user with the PERS backend using their auth token
|
|
90
87
|
*
|
|
91
88
|
* @param authToken - The authentication token received from DFNS after login/registration
|
|
89
|
+
* @param tenantId - Optional tenant ID for automatic initialization
|
|
92
90
|
* @returns A promise that resolves to the authentication response
|
|
93
91
|
* @throws If the request fails
|
|
94
92
|
*/
|
|
95
|
-
static authenticateUser(authToken: string): Promise<SessionAuthContextResponseDTO>;
|
|
96
|
-
/**
|
|
97
|
-
* Prepares a transaction by calling the backend endpoint
|
|
98
|
-
*
|
|
99
|
-
* @param form - The transaction details
|
|
100
|
-
* @param persAccessToken - The PERS access token for authentication (Bearer)
|
|
101
|
-
* @returns A promise that resolves to the transaction preparation response
|
|
102
|
-
* @throws If the request fails
|
|
103
|
-
*/
|
|
104
|
-
static prepareTransaction(form: any, persAccessToken: string): Promise<TransactionRequestResponseDTO>;
|
|
93
|
+
static authenticateUser(authToken: string, tenantId: string): Promise<SessionAuthContextResponseDTO>;
|
|
105
94
|
/**
|
|
106
95
|
* Submits a transaction by calling the backend endpoint
|
|
107
96
|
*
|
|
@@ -109,53 +98,20 @@ declare class PersService {
|
|
|
109
98
|
* @param signedTransactionOrSignature - The signed transaction data or EIP-712 signature
|
|
110
99
|
* @param persAccessToken - The PERS access token for authentication (Bearer)
|
|
111
100
|
* @param submissionType - The transaction format type
|
|
101
|
+
* @param tenantId - Optional tenant ID for automatic initialization
|
|
112
102
|
* @returns A promise that resolves to the transaction submission response
|
|
113
103
|
* @throws If the request fails
|
|
114
104
|
*/
|
|
115
|
-
static submitTransaction(transactionId: string, signedTransactionOrSignature: string, persAccessToken: string, submissionType: TransactionFormat): Promise<
|
|
105
|
+
static submitTransaction(transactionId: string, signedTransactionOrSignature: string, persAccessToken: string, submissionType: TransactionFormat, tenantId: string): Promise<TransactionRequestResponseDTO>;
|
|
116
106
|
/**
|
|
117
107
|
* Fetches a prepared transaction for signing by transactionId
|
|
118
108
|
* @param transactionId - The transaction ID to fetch
|
|
119
109
|
* @param persAccessToken - The PERS access token for authentication (Bearer)
|
|
110
|
+
* @param tenantId - Optional tenant ID for automatic initialization
|
|
120
111
|
* @returns The prepared transaction data
|
|
121
112
|
* @throws If the request fails
|
|
122
113
|
*/
|
|
123
|
-
static fetchPreparedTransaction(transactionId: string, persAccessToken: string): Promise<TransactionRequestResponseDTO>;
|
|
124
|
-
/**
|
|
125
|
-
* Claims a reward from the PERS blockchain system
|
|
126
|
-
* @param rewardId - The ID of the reward to claim
|
|
127
|
-
* @param pointsCost - The points cost for the reward
|
|
128
|
-
* @param persAccessToken - The PERS access token for authentication (Bearer)
|
|
129
|
-
* @returns The reward claim response including reward image URL
|
|
130
|
-
* @throws If the request fails
|
|
131
|
-
*/
|
|
132
|
-
static claimReward(rewardId: string, pointsCost: number, persAccessToken: string): Promise<any>;
|
|
133
|
-
/**
|
|
134
|
-
* Get all active campaigns
|
|
135
|
-
* @returns Promise with list of active campaigns
|
|
136
|
-
*/
|
|
137
|
-
static getActiveCampaigns(): Promise<CampaignDTO[]>;
|
|
138
|
-
/**
|
|
139
|
-
* Claims a campaign for a user
|
|
140
|
-
* @param campaignId - The ID of the campaign to claim
|
|
141
|
-
* @param persAccessToken - The PERS access token for authentication (Bearer)
|
|
142
|
-
* @returns Promise with the campaign claim response
|
|
143
|
-
* @throws If the request fails
|
|
144
|
-
*/
|
|
145
|
-
static claimCampaign(campaignId: string, persAccessToken: string): Promise<CampaignClaimDTO>;
|
|
146
|
-
/**
|
|
147
|
-
* Gets all campaign claims for the authenticated user
|
|
148
|
-
* @param persAccessToken - The PERS access token for authentication (Bearer)
|
|
149
|
-
* @returns Promise with list of user's campaign claims
|
|
150
|
-
* @throws If the request fails
|
|
151
|
-
*/
|
|
152
|
-
static getUserCampaignClaims(persAccessToken: string): Promise<CampaignClaimDTO[]>;
|
|
153
|
-
/**
|
|
154
|
-
* Gets all available rewards for redemption
|
|
155
|
-
* @returns Promise with list of available rewards that can be exchanged for points
|
|
156
|
-
* @throws If the request fails
|
|
157
|
-
*/
|
|
158
|
-
static getAvailableRedemptions(): Promise<any[]>;
|
|
114
|
+
static fetchPreparedTransaction(transactionId: string, persAccessToken: string, tenantId: string): Promise<TransactionRequestResponseDTO>;
|
|
159
115
|
/**
|
|
160
116
|
* Helper method to determine if transaction data is available for signing
|
|
161
117
|
* @param transactionResponse - Response from prepare or fetch transaction
|
|
@@ -207,7 +163,8 @@ interface SignResponse {
|
|
|
207
163
|
signature: {
|
|
208
164
|
r: string;
|
|
209
165
|
s: string;
|
|
210
|
-
|
|
166
|
+
v: number;
|
|
167
|
+
encoded: string;
|
|
211
168
|
};
|
|
212
169
|
network: "KeyECDSA";
|
|
213
170
|
dateRequested: string;
|
|
@@ -240,29 +197,9 @@ interface RegistrationResult {
|
|
|
240
197
|
status?: number;
|
|
241
198
|
message?: string;
|
|
242
199
|
}
|
|
243
|
-
/**
|
|
244
|
-
* Wallet listing response
|
|
245
|
-
*/
|
|
246
|
-
interface WalletListResponse$1 {
|
|
247
|
-
wallets: WalletItem$1[];
|
|
248
|
-
status?: number;
|
|
249
|
-
message?: string;
|
|
250
|
-
}
|
|
251
200
|
/**
|
|
252
201
|
* Individual wallet item
|
|
253
202
|
*/
|
|
254
|
-
interface WalletItem$1 {
|
|
255
|
-
id: string;
|
|
256
|
-
address: string;
|
|
257
|
-
network: string;
|
|
258
|
-
status: string;
|
|
259
|
-
signingKey?: unknown;
|
|
260
|
-
dateCreated?: string;
|
|
261
|
-
custodial?: boolean;
|
|
262
|
-
tags?: string[];
|
|
263
|
-
boundToEvmNetwork?: boolean;
|
|
264
|
-
[key: string]: unknown;
|
|
265
|
-
}
|
|
266
203
|
/**
|
|
267
204
|
* Hash signing request
|
|
268
205
|
*/
|
|
@@ -312,6 +249,62 @@ interface RelyingPartyConfig {
|
|
|
312
249
|
origin?: string;
|
|
313
250
|
}
|
|
314
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
|
+
|
|
315
308
|
/**
|
|
316
309
|
* Signing service for cryptographic operations
|
|
317
310
|
* Handles hash signing and typed data signing with WebAuthn
|
|
@@ -327,7 +320,7 @@ declare class SigningService {
|
|
|
327
320
|
* @param hash - Hash to sign
|
|
328
321
|
* @returns Promise resolving to signature response
|
|
329
322
|
*/
|
|
330
|
-
signHash(authToken: string, walletId: string, hash: string): Promise<
|
|
323
|
+
signHash(authToken: string, walletId: string, hash: string): Promise<CompleteSignatureResponse['data']>;
|
|
331
324
|
/**
|
|
332
325
|
* Sign EIP-712 typed data using the specified wallet
|
|
333
326
|
* @param authToken - Authentication token
|
|
@@ -337,7 +330,7 @@ declare class SigningService {
|
|
|
337
330
|
* @param value - Data to sign
|
|
338
331
|
* @returns Promise resolving to signature response
|
|
339
332
|
*/
|
|
340
|
-
signTypedData(authToken: string, walletId: string, domain: any, types: Record<string, any[]>, value: Record<string, any>): Promise<
|
|
333
|
+
signTypedData(authToken: string, walletId: string, domain: any, types: Record<string, any[]>, value: Record<string, any>): Promise<CompleteSignatureResponse['data']>;
|
|
341
334
|
/**
|
|
342
335
|
* Generic signing method that handles the complete signing flow
|
|
343
336
|
* @param authToken - Authentication token
|
|
@@ -353,7 +346,7 @@ declare class SigningService {
|
|
|
353
346
|
* @param requests - Array of signing requests
|
|
354
347
|
* @returns Promise resolving to array of signature responses
|
|
355
348
|
*/
|
|
356
|
-
signBatch(authToken: string, walletId: string, requests: SigningRequest[]): Promise<
|
|
349
|
+
signBatch(authToken: string, walletId: string, requests: SigningRequest[]): Promise<CompleteSignatureResponse['data'][]>;
|
|
357
350
|
}
|
|
358
351
|
|
|
359
352
|
/**
|
|
@@ -361,65 +354,19 @@ declare class SigningService {
|
|
|
361
354
|
*/
|
|
362
355
|
|
|
363
356
|
/**
|
|
364
|
-
*
|
|
365
|
-
*/
|
|
366
|
-
interface WalletConfig {
|
|
367
|
-
id: string;
|
|
368
|
-
name: string;
|
|
369
|
-
address?: string;
|
|
370
|
-
credentialId?: string;
|
|
371
|
-
publicKey?: string;
|
|
372
|
-
createdAt?: Date;
|
|
373
|
-
}
|
|
374
|
-
/**
|
|
375
|
-
* Authentication token structure
|
|
357
|
+
* Authentication types for 3-function split architecture
|
|
376
358
|
*/
|
|
377
|
-
interface
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
* User authentication state
|
|
384
|
-
*/
|
|
385
|
-
interface AuthState {
|
|
386
|
-
isAuthenticated: boolean;
|
|
387
|
-
token?: AuthToken;
|
|
388
|
-
user?: UserProfile;
|
|
389
|
-
wallets?: WalletConfig[];
|
|
390
|
-
}
|
|
391
|
-
/**
|
|
392
|
-
* User profile information
|
|
393
|
-
*/
|
|
394
|
-
interface UserProfile {
|
|
395
|
-
id: string;
|
|
396
|
-
username: string;
|
|
397
|
-
email?: string;
|
|
398
|
-
createdAt: Date;
|
|
399
|
-
lastLoginAt?: Date;
|
|
400
|
-
}
|
|
401
|
-
/**
|
|
402
|
-
* Prepared transaction from PERS service
|
|
403
|
-
*/
|
|
404
|
-
interface PreparedTransaction {
|
|
405
|
-
id: string;
|
|
406
|
-
transactionData: AnyTransactionData;
|
|
407
|
-
metadata?: Record<string, any>;
|
|
408
|
-
createdAt: Date;
|
|
409
|
-
expiresAt?: Date;
|
|
410
|
-
}
|
|
411
|
-
/**
|
|
412
|
-
* Transaction signing result
|
|
413
|
-
*/
|
|
414
|
-
interface SigningResult$1 {
|
|
415
|
-
signature: string;
|
|
416
|
-
transactionHash?: string;
|
|
417
|
-
rawTransaction?: string;
|
|
359
|
+
interface AuthenticatedUser {
|
|
360
|
+
identifier: string;
|
|
361
|
+
signerAuthToken: string;
|
|
362
|
+
persAccessToken: string;
|
|
363
|
+
tenantId: string;
|
|
364
|
+
expiresAt: number;
|
|
418
365
|
}
|
|
419
366
|
/**
|
|
420
367
|
* Service configuration options
|
|
421
368
|
*/
|
|
422
|
-
interface ServiceConfig
|
|
369
|
+
interface ServiceConfig {
|
|
423
370
|
apiUrl: string;
|
|
424
371
|
environment: 'development' | 'staging' | 'production';
|
|
425
372
|
timeout?: number;
|
|
@@ -434,15 +381,6 @@ interface ServiceError {
|
|
|
434
381
|
details?: any;
|
|
435
382
|
timestamp: Date;
|
|
436
383
|
}
|
|
437
|
-
/**
|
|
438
|
-
* API response wrapper
|
|
439
|
-
*/
|
|
440
|
-
interface ApiResponse<T = any> {
|
|
441
|
-
success: boolean;
|
|
442
|
-
data?: T;
|
|
443
|
-
error?: ServiceError;
|
|
444
|
-
metadata?: Record<string, any>;
|
|
445
|
-
}
|
|
446
384
|
|
|
447
385
|
interface GetWalletResponse {
|
|
448
386
|
id: string;
|
|
@@ -503,21 +441,12 @@ interface TransactionStatusInfo {
|
|
|
503
441
|
interface TransactionSigningResult {
|
|
504
442
|
success: boolean;
|
|
505
443
|
transactionId: string;
|
|
506
|
-
transactionHash?: string;
|
|
507
444
|
signature?: string;
|
|
445
|
+
signingData?: CounterfactualWalletTransactionResponse | LegacyTransaction;
|
|
508
446
|
error?: string;
|
|
509
447
|
statusInfo?: TransactionStatusInfo;
|
|
510
|
-
shouldRedirect?: boolean;
|
|
511
|
-
redirectUrl?: string;
|
|
512
448
|
shouldShowStatus?: boolean;
|
|
513
449
|
}
|
|
514
|
-
/**
|
|
515
|
-
* Transaction result for localStorage storage
|
|
516
|
-
*/
|
|
517
|
-
interface StoredTransactionResult {
|
|
518
|
-
transactionId: string;
|
|
519
|
-
transactionHash: string;
|
|
520
|
-
}
|
|
521
450
|
/**
|
|
522
451
|
* Transaction submission result for internal processing
|
|
523
452
|
*/
|
|
@@ -525,18 +454,18 @@ interface SubmissionResult {
|
|
|
525
454
|
submitResult: TransactionRequestResponseDTO;
|
|
526
455
|
shouldRedirect: boolean;
|
|
527
456
|
redirectUrl?: string;
|
|
457
|
+
transactionHash: string | null;
|
|
458
|
+
success: boolean;
|
|
459
|
+
error?: string;
|
|
528
460
|
}
|
|
529
461
|
/**
|
|
530
462
|
* Metadata for transaction parameters - string values only
|
|
531
463
|
*/
|
|
532
|
-
interface TransactionMetadata {
|
|
533
|
-
[key: string]: string;
|
|
534
|
-
}
|
|
535
464
|
/**
|
|
536
465
|
* Authentication tokens required for transaction signing
|
|
537
466
|
*/
|
|
538
467
|
interface SigningAuthTokens {
|
|
539
|
-
|
|
468
|
+
signerAuthToken: string;
|
|
540
469
|
persAccessToken: string;
|
|
541
470
|
}
|
|
542
471
|
/**
|
|
@@ -544,12 +473,211 @@ interface SigningAuthTokens {
|
|
|
544
473
|
*/
|
|
545
474
|
interface TransactionSigningParams {
|
|
546
475
|
transactionId: string;
|
|
476
|
+
tenantId: string;
|
|
547
477
|
authTokens: SigningAuthTokens;
|
|
548
478
|
ethersProviderUrl: string;
|
|
549
479
|
returnUrl?: string;
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
/**
|
|
483
|
+
* PERS Blockchain Signer SDK
|
|
484
|
+
*
|
|
485
|
+
* A lightweight blockchain transaction signing SDK with WebAuthn authentication.
|
|
486
|
+
* Provides 5 focused methods for complete transaction lifecycle management:
|
|
487
|
+
*
|
|
488
|
+
* 1. loginUser(jwtToken) - Authenticate user with 5-minute caching
|
|
489
|
+
* 2. signTransaction(signingData, jwtToken) - Sign transactions with auto-login
|
|
490
|
+
* 3. submitTransaction(signedTx, jwtToken) - Submit signed transactions to blockchain
|
|
491
|
+
* 4. signPersTransaction(jwtToken) - Legacy one-liner for backward compatibility
|
|
492
|
+
* 5. signAndSubmitPersTransaction(jwtToken) - Complete sign + submit flow
|
|
493
|
+
*
|
|
494
|
+
* @example
|
|
495
|
+
* ```typescript
|
|
496
|
+
* import { createPersSignerSDK } from '@explorins/pers-signer';
|
|
497
|
+
*
|
|
498
|
+
* const sdk = createPersSignerSDK({
|
|
499
|
+
* webAuthnProvider: myWebAuthnProvider,
|
|
500
|
+
* ethersProviderUrl: 'https://ethereum-rpc.com'
|
|
501
|
+
* });
|
|
502
|
+
*
|
|
503
|
+
* // Quick sign and submit
|
|
504
|
+
* const result = await sdk.signAndSubmitPersTransaction(jwtToken);
|
|
505
|
+
* if (result.success) {
|
|
506
|
+
* console.log('Transaction submitted:', result.transactionHash);
|
|
507
|
+
* }
|
|
508
|
+
* ```
|
|
509
|
+
*/
|
|
510
|
+
|
|
511
|
+
/**
|
|
512
|
+
* Configuration interface for the PERS Signer SDK
|
|
513
|
+
*
|
|
514
|
+
* @interface PersSignerConfig
|
|
515
|
+
* @property {string} [tenantId] - Optional tenant identifier for multi-tenant applications
|
|
516
|
+
* @property {string} [ethersProviderUrl] - Custom Ethereum RPC provider URL
|
|
517
|
+
* @property {WebAuthnProvider} webAuthnProvider - WebAuthn provider for secure authentication
|
|
518
|
+
* @property {string} [apiUrl] - Custom API base URL (defaults to production)
|
|
519
|
+
* @property {string} [relyingPartyName] - WebAuthn relying party name for authentication
|
|
520
|
+
*/
|
|
521
|
+
interface ExtendedPersSignerConfig {
|
|
522
|
+
ethersProviderUrl?: string;
|
|
523
|
+
webAuthnProvider: WebAuthnProvider;
|
|
524
|
+
apiUrl?: string;
|
|
525
|
+
relyingPartyName?: string;
|
|
526
|
+
}
|
|
527
|
+
interface PersSignerConfig extends Omit<ExtendedPersSignerConfig, 'webAuthnProvider'> {
|
|
528
|
+
}
|
|
529
|
+
/**
|
|
530
|
+
* PERS Blockchain Signer SDK Class
|
|
531
|
+
*
|
|
532
|
+
* Main SDK class providing blockchain transaction signing capabilities with WebAuthn authentication.
|
|
533
|
+
* Implements a clean 5-method API for complete transaction lifecycle management.
|
|
534
|
+
*
|
|
535
|
+
* Features:
|
|
536
|
+
* - WebAuthn-based secure authentication
|
|
537
|
+
* - 5-minute user session caching
|
|
538
|
+
* - Automatic transaction data fetching
|
|
539
|
+
* - Blockchain transaction signing and submission
|
|
540
|
+
* - Multi-tenant support
|
|
541
|
+
*
|
|
542
|
+
* @class PersSignerSDK
|
|
543
|
+
*/
|
|
544
|
+
declare class PersSignerSDK {
|
|
545
|
+
private config;
|
|
546
|
+
private authenticationService;
|
|
547
|
+
private transactionSigningService;
|
|
548
|
+
/**
|
|
549
|
+
* Initialize the PERS Signer SDK
|
|
550
|
+
*
|
|
551
|
+
* @param {ExtendedPersSignerConfig} config - SDK configuration object
|
|
552
|
+
* @throws {Error} If required configuration is missing
|
|
553
|
+
*/
|
|
554
|
+
constructor(config: ExtendedPersSignerConfig);
|
|
555
|
+
/**
|
|
556
|
+
* Authenticate user and cache session for 5 minutes
|
|
557
|
+
*
|
|
558
|
+
* Validates JWT token, authenticates with both signer and PERS backends,
|
|
559
|
+
* and caches the authenticated user session to avoid repeated authentication.
|
|
560
|
+
*
|
|
561
|
+
* @param {string} jwtToken - JWT token containing user identifier and tenant info
|
|
562
|
+
* @returns {Promise<AuthenticatedUser>} Authenticated user with access tokens
|
|
563
|
+
* @throws {Error} If JWT is invalid, expired, or authentication fails
|
|
564
|
+
*
|
|
565
|
+
* @example
|
|
566
|
+
* ```typescript
|
|
567
|
+
* try {
|
|
568
|
+
* const user = await sdk.loginUser(jwtToken);
|
|
569
|
+
* console.log('Authenticated:', user.identifier);
|
|
570
|
+
* } catch (error) {
|
|
571
|
+
* console.error('Authentication failed:', error.message);
|
|
572
|
+
* }
|
|
573
|
+
* ```
|
|
574
|
+
*/
|
|
575
|
+
loginUser(jwtToken: string): Promise<AuthenticatedUser>;
|
|
576
|
+
/**
|
|
577
|
+
* Sign a PERS transaction (legacy compatibility method)
|
|
578
|
+
*
|
|
579
|
+
* Automatically handles user authentication, transaction data fetching,
|
|
580
|
+
* and transaction signing in a single call. This is the legacy method
|
|
581
|
+
* maintained for backward compatibility.
|
|
582
|
+
*
|
|
583
|
+
* @param {string} jwtToken - JWT token containing transaction ID and user info
|
|
584
|
+
* @returns {Promise<TransactionSigningResult>} Signing result with signature and metadata
|
|
585
|
+
* @throws {Error} If authentication fails, transaction ID missing, or signing fails
|
|
586
|
+
*
|
|
587
|
+
* @example
|
|
588
|
+
* ```typescript
|
|
589
|
+
* try {
|
|
590
|
+
* const result = await sdk.signPersTransaction(jwtToken);
|
|
591
|
+
* if (result.success) {
|
|
592
|
+
* console.log('Transaction signed:', result.signature);
|
|
593
|
+
* }
|
|
594
|
+
* } catch (error) {
|
|
595
|
+
* console.error('Signing failed:', error.message);
|
|
596
|
+
* }
|
|
597
|
+
* ```
|
|
598
|
+
*/
|
|
599
|
+
signPersTransaction(jwtToken: string): Promise<TransactionSigningResult>;
|
|
600
|
+
/**
|
|
601
|
+
* Sign a transaction with provided signing data
|
|
602
|
+
*
|
|
603
|
+
* Low-level method to sign transactions when you already have the signing data.
|
|
604
|
+
* Automatically handles user authentication and applies the blockchain signature.
|
|
605
|
+
*
|
|
606
|
+
* @param {CounterfactualWalletTransactionResponse | LegacyTransaction} signingData - Transaction data to sign
|
|
607
|
+
* @param {string} jwtToken - JWT token containing transaction ID and user info
|
|
608
|
+
* @returns {Promise<TransactionSigningResult>} Signing result with signature and metadata
|
|
609
|
+
* @throws {Error} If authentication fails, transaction ID missing, or signing fails
|
|
610
|
+
*
|
|
611
|
+
* @example
|
|
612
|
+
* ```typescript
|
|
613
|
+
* const signingData = await getTransactionData(transactionId);
|
|
614
|
+
* const result = await sdk.signTransaction(signingData, jwtToken);
|
|
615
|
+
* console.log('Signed transaction:', result.signature);
|
|
616
|
+
* ```
|
|
617
|
+
*/
|
|
618
|
+
signTransaction(signingData: CounterfactualWalletTransactionResponse$1 | LegacyTransaction, jwtToken: string): Promise<TransactionSigningResult>;
|
|
619
|
+
/**
|
|
620
|
+
* Complete transaction flow: sign and submit in one call
|
|
621
|
+
*
|
|
622
|
+
* Convenience method that combines signing and submission into a single operation.
|
|
623
|
+
* This is the recommended method for most use cases as it handles the complete
|
|
624
|
+
* transaction lifecycle automatically.
|
|
625
|
+
*
|
|
626
|
+
* @param {string} jwtToken - JWT token containing transaction ID and user info
|
|
627
|
+
* @returns {Promise<SubmissionResult>} Submission result with transaction hash and status
|
|
628
|
+
* @throws {Error} If authentication, signing, or submission fails
|
|
629
|
+
*
|
|
630
|
+
* @example
|
|
631
|
+
* ```typescript
|
|
632
|
+
* try {
|
|
633
|
+
* const result = await sdk.signAndSubmitPersTransaction(jwtToken);
|
|
634
|
+
* if (result.success) {
|
|
635
|
+
* console.log('Transaction completed:', result.transactionHash);
|
|
636
|
+
* if (result.shouldRedirect) {
|
|
637
|
+
* window.location.href = result.redirectUrl;
|
|
638
|
+
* }
|
|
639
|
+
* }
|
|
640
|
+
* } catch (error) {
|
|
641
|
+
* console.error('Transaction failed:', error.message);
|
|
642
|
+
* }
|
|
643
|
+
* ```
|
|
644
|
+
*/
|
|
645
|
+
signAndSubmitPersTransaction(jwtToken: string): Promise<SubmissionResult>;
|
|
646
|
+
/**
|
|
647
|
+
* Submit a signed transaction to the blockchain
|
|
648
|
+
*
|
|
649
|
+
* Takes a signed transaction result and submits it to the blockchain network.
|
|
650
|
+
* Returns detailed submission results including transaction hash and any
|
|
651
|
+
* redirect information for UI flows.
|
|
652
|
+
*
|
|
653
|
+
* @param {TransactionSigningResult} signingResult - Result from a successful transaction signing
|
|
654
|
+
* @param {string} jwtToken - JWT token containing tenant and user info
|
|
655
|
+
* @returns {Promise<SubmissionResult>} Submission result with transaction hash and status
|
|
656
|
+
* @throws {Error} If signing result is invalid, JWT is missing tenantId, or submission fails
|
|
657
|
+
*
|
|
658
|
+
* @example
|
|
659
|
+
* ```typescript
|
|
660
|
+
* const signedTx = await sdk.signPersTransaction(jwtToken);
|
|
661
|
+
* const result = await sdk.submitTransaction(signedTx, jwtToken);
|
|
662
|
+
* console.log('Transaction submitted:', result.transactionHash);
|
|
663
|
+
* ```
|
|
664
|
+
*/
|
|
665
|
+
submitTransaction(signingResult: TransactionSigningResult, jwtToken: string): Promise<SubmissionResult>;
|
|
666
|
+
/**
|
|
667
|
+
* Clear user authentication cache
|
|
668
|
+
*
|
|
669
|
+
* Removes all cached user sessions, forcing fresh authentication
|
|
670
|
+
* on the next method call. Useful for logout scenarios or when
|
|
671
|
+
* switching between different user contexts.
|
|
672
|
+
*
|
|
673
|
+
* @example
|
|
674
|
+
* ```typescript
|
|
675
|
+
* // Clear cache on user logout
|
|
676
|
+
* sdk.clearCache();
|
|
677
|
+
* console.log('User cache cleared');
|
|
678
|
+
* ```
|
|
679
|
+
*/
|
|
680
|
+
clearCache(): void;
|
|
553
681
|
}
|
|
554
682
|
|
|
555
683
|
/**
|
|
@@ -559,7 +687,7 @@ interface TransactionSigningParams {
|
|
|
559
687
|
*/
|
|
560
688
|
declare class TransactionSigningService {
|
|
561
689
|
private webAuthnProvider;
|
|
562
|
-
constructor(
|
|
690
|
+
constructor(config: ExtendedPersSignerConfig);
|
|
563
691
|
/**
|
|
564
692
|
* Prepare transaction for signing - fetch and validate
|
|
565
693
|
*/
|
|
@@ -572,6 +700,11 @@ declare class TransactionSigningService {
|
|
|
572
700
|
* Execute the transaction signing with WebAuthn coordination
|
|
573
701
|
*/
|
|
574
702
|
private executeTransactionSigning;
|
|
703
|
+
getPersSigningData(data: {
|
|
704
|
+
transactionId: string;
|
|
705
|
+
authTokens: SigningAuthTokens;
|
|
706
|
+
tenantId: string;
|
|
707
|
+
}): Promise<CounterfactualWalletTransactionResponse | LegacyTransaction>;
|
|
575
708
|
/**
|
|
576
709
|
* Main transaction signing orchestration method
|
|
577
710
|
* Handles the complete flow from preparation to submission
|
|
@@ -579,7 +712,7 @@ declare class TransactionSigningService {
|
|
|
579
712
|
* @returns Promise resolving to transaction signing result
|
|
580
713
|
* @throws TransactionSigningError for validation and operation failures
|
|
581
714
|
*/
|
|
582
|
-
signTransaction(params: TransactionSigningParams): Promise<TransactionSigningResult>;
|
|
715
|
+
signTransaction(params: TransactionSigningParams, signingData: CounterfactualWalletTransactionResponse | LegacyTransaction): Promise<TransactionSigningResult>;
|
|
583
716
|
}
|
|
584
717
|
|
|
585
718
|
/**
|
|
@@ -698,19 +831,7 @@ declare class TransactionSubmissionHandler {
|
|
|
698
831
|
* @param metadata - Optional metadata to include as parameters
|
|
699
832
|
* @returns Promise resolving to the complete redirect URL
|
|
700
833
|
*/
|
|
701
|
-
static createRedirectUrl(returnUrl: string, transactionHash: string
|
|
702
|
-
/**
|
|
703
|
-
* Submit transaction and handle success flow
|
|
704
|
-
* @param preparedTransaction - The prepared transaction
|
|
705
|
-
* @param signature - The transaction signature
|
|
706
|
-
* @param signingData - The signing data used
|
|
707
|
-
* @param authTokens - Authentication tokens
|
|
708
|
-
* @param transactionId - Transaction ID for tracking
|
|
709
|
-
* @param returnUrl - Optional return URL for redirect
|
|
710
|
-
* @param metadata - Optional metadata for redirect parameters
|
|
711
|
-
* @returns Promise resolving to submission result
|
|
712
|
-
*/
|
|
713
|
-
static handleTransactionSubmission(preparedTransaction: TransactionRequestResponseDTO, signature: string, signingData: AnyTransactionData, authTokens: SigningAuthTokens, returnUrl?: string, metadata?: TransactionMetadata): Promise<SubmissionResult>;
|
|
834
|
+
static createRedirectUrl(returnUrl: string, transactionHash: string): Promise<string>;
|
|
714
835
|
}
|
|
715
836
|
|
|
716
837
|
/**
|
|
@@ -718,11 +839,6 @@ declare class TransactionSubmissionHandler {
|
|
|
718
839
|
* Manages global state flags to ensure only one WebAuthn operation runs at a time
|
|
719
840
|
*/
|
|
720
841
|
declare class WebAuthnCoordinator {
|
|
721
|
-
/**
|
|
722
|
-
* Clear the landing authentication flag
|
|
723
|
-
* Used when starting a new transaction signing flow
|
|
724
|
-
*/
|
|
725
|
-
static clearLandingAuthentication(): void;
|
|
726
842
|
/**
|
|
727
843
|
* Check if a WebAuthn operation is currently in progress
|
|
728
844
|
* @returns True if an operation is in progress, false otherwise
|
|
@@ -739,7 +855,7 @@ declare class WebAuthnCoordinator {
|
|
|
739
855
|
* Platform-agnostic configuration provider
|
|
740
856
|
* Abstracts environment variable access for cross-platform compatibility
|
|
741
857
|
*/
|
|
742
|
-
interface
|
|
858
|
+
interface PlatformConfig {
|
|
743
859
|
apiUrl: string;
|
|
744
860
|
appId?: string;
|
|
745
861
|
relyingParty: {
|
|
@@ -749,7 +865,7 @@ interface ServiceConfig {
|
|
|
749
865
|
};
|
|
750
866
|
}
|
|
751
867
|
interface ConfigProvider {
|
|
752
|
-
getServiceConfig():
|
|
868
|
+
getServiceConfig(): PlatformConfig;
|
|
753
869
|
}
|
|
754
870
|
/**
|
|
755
871
|
* Web platform configuration provider
|
|
@@ -757,8 +873,8 @@ interface ConfigProvider {
|
|
|
757
873
|
*/
|
|
758
874
|
declare class WebConfigProvider implements ConfigProvider {
|
|
759
875
|
private config;
|
|
760
|
-
constructor(config:
|
|
761
|
-
getServiceConfig():
|
|
876
|
+
constructor(config: PlatformConfig);
|
|
877
|
+
getServiceConfig(): PlatformConfig;
|
|
762
878
|
}
|
|
763
879
|
/**
|
|
764
880
|
* React Native configuration provider
|
|
@@ -766,16 +882,16 @@ declare class WebConfigProvider implements ConfigProvider {
|
|
|
766
882
|
*/
|
|
767
883
|
declare class ReactNativeConfigProvider implements ConfigProvider {
|
|
768
884
|
private config;
|
|
769
|
-
constructor(config:
|
|
770
|
-
getServiceConfig():
|
|
885
|
+
constructor(config: PlatformConfig);
|
|
886
|
+
getServiceConfig(): PlatformConfig;
|
|
771
887
|
}
|
|
772
888
|
/**
|
|
773
889
|
* Static configuration provider for testing or custom setups
|
|
774
890
|
*/
|
|
775
891
|
declare class StaticConfigProvider implements ConfigProvider {
|
|
776
892
|
private config;
|
|
777
|
-
constructor(config:
|
|
778
|
-
getServiceConfig():
|
|
893
|
+
constructor(config: PlatformConfig);
|
|
894
|
+
getServiceConfig(): PlatformConfig;
|
|
779
895
|
}
|
|
780
896
|
/**
|
|
781
897
|
* Set the global configuration provider
|
|
@@ -789,7 +905,7 @@ declare function getConfigProvider(): ConfigProvider;
|
|
|
789
905
|
/**
|
|
790
906
|
* Get the service configuration
|
|
791
907
|
*/
|
|
792
|
-
declare function getServiceConfig():
|
|
908
|
+
declare function getServiceConfig(): PlatformConfig;
|
|
793
909
|
|
|
794
910
|
/**
|
|
795
911
|
* Platform-agnostic HTTP client abstraction
|
|
@@ -834,166 +950,6 @@ declare function setHttpClient(client: HttpClient): void;
|
|
|
834
950
|
*/
|
|
835
951
|
declare function getHttpClient(): HttpClient;
|
|
836
952
|
|
|
837
|
-
/**
|
|
838
|
-
* PERS Blockchain Signer SDK - Simple Orchestrator
|
|
839
|
-
*
|
|
840
|
-
* Lightweight SDK that orchestrates existing services.
|
|
841
|
-
* Uses environment configuration and existing infrastructure.
|
|
842
|
-
*/
|
|
843
|
-
|
|
844
|
-
interface JWTPayload {
|
|
845
|
-
email?: string;
|
|
846
|
-
userId?: string;
|
|
847
|
-
tenantId?: string;
|
|
848
|
-
exp?: number;
|
|
849
|
-
[key: string]: any;
|
|
850
|
-
}
|
|
851
|
-
interface PersAuthResult {
|
|
852
|
-
user: {
|
|
853
|
-
email?: string;
|
|
854
|
-
id?: string;
|
|
855
|
-
};
|
|
856
|
-
accessToken: string;
|
|
857
|
-
}
|
|
858
|
-
/**
|
|
859
|
-
* User information for authentication
|
|
860
|
-
*/
|
|
861
|
-
interface SignerUserInfo {
|
|
862
|
-
identifier: string;
|
|
863
|
-
email?: string;
|
|
864
|
-
id?: string;
|
|
865
|
-
}
|
|
866
|
-
/**
|
|
867
|
-
* Authenticated user with all required tokens
|
|
868
|
-
*/
|
|
869
|
-
interface SignerAuthenticatedUser {
|
|
870
|
-
identifier: string;
|
|
871
|
-
signerAuthToken: string;
|
|
872
|
-
persAccessToken: string;
|
|
873
|
-
}
|
|
874
|
-
interface AuthenticationResult {
|
|
875
|
-
user: SignerAuthenticatedUser;
|
|
876
|
-
isExpired: boolean;
|
|
877
|
-
}
|
|
878
|
-
interface JWTExtractionResult {
|
|
879
|
-
payload: JWTPayload | null;
|
|
880
|
-
isExpired: boolean;
|
|
881
|
-
}
|
|
882
|
-
interface PersSignerConfig {
|
|
883
|
-
tenantId?: string;
|
|
884
|
-
ethersProviderUrl?: string;
|
|
885
|
-
webAuthnProvider: WebAuthnProvider;
|
|
886
|
-
apiUrl?: string;
|
|
887
|
-
relyingPartyName?: string;
|
|
888
|
-
}
|
|
889
|
-
interface SigningResult {
|
|
890
|
-
success: boolean;
|
|
891
|
-
transactionHash?: string;
|
|
892
|
-
error?: string;
|
|
893
|
-
}
|
|
894
|
-
/**
|
|
895
|
-
* Main PERS Signer SDK class
|
|
896
|
-
*
|
|
897
|
-
* Simple orchestrator that uses existing services and environment configuration.
|
|
898
|
-
* No complex initialization needed - services are already configured.
|
|
899
|
-
*/
|
|
900
|
-
declare class PersSignerSDK {
|
|
901
|
-
private config;
|
|
902
|
-
private authService;
|
|
903
|
-
private signingService;
|
|
904
|
-
private transactionSigningService;
|
|
905
|
-
private webAuthnProvider;
|
|
906
|
-
constructor(config: PersSignerConfig);
|
|
907
|
-
/**
|
|
908
|
-
* Re-export TransactionSigningService with WebAuthn provider already injected
|
|
909
|
-
* This provides the same interface as the original service but with automatic provider injection
|
|
910
|
-
*/
|
|
911
|
-
get TransactionSigningService(): TransactionSigningService;
|
|
912
|
-
/**
|
|
913
|
-
* Complete user onboarding flow - same as web project
|
|
914
|
-
* Uses existing AuthenticationService and PersService
|
|
915
|
-
*/
|
|
916
|
-
authenticateUser(userInfo: SignerUserInfo): Promise<SignerAuthenticatedUser>;
|
|
917
|
-
/**
|
|
918
|
-
* Complete PERS transaction signing flow - exactly like web project
|
|
919
|
-
* Uses existing TransactionSigningService with injected WebAuthn provider
|
|
920
|
-
*/
|
|
921
|
-
signPersTransaction(user: SignerAuthenticatedUser, transactionId: string): Promise<SigningResult>;
|
|
922
|
-
/**
|
|
923
|
-
* Register new user - uses existing AuthenticationService
|
|
924
|
-
*/
|
|
925
|
-
registerUser(identifier: string): Promise<{
|
|
926
|
-
authToken: string;
|
|
927
|
-
}>;
|
|
928
|
-
/**
|
|
929
|
-
* Login existing user - uses existing AuthenticationService
|
|
930
|
-
*/
|
|
931
|
-
loginUser(identifier: string): Promise<string>;
|
|
932
|
-
/**
|
|
933
|
-
* Add wallet to PERS user - uses existing PersService
|
|
934
|
-
*/
|
|
935
|
-
addWalletToPersUser(signerAuthToken: string): Promise<string>;
|
|
936
|
-
/**
|
|
937
|
-
* Retrieve transaction data from PERS - uses existing PersService
|
|
938
|
-
*/
|
|
939
|
-
retrieveTransactionData(transactionId: string, persAccessToken: string): Promise<TransactionRequestResponseDTO>;
|
|
940
|
-
/**
|
|
941
|
-
* Sign transaction data - uses existing SigningService
|
|
942
|
-
* Follows same patterns as KeyWallet.signPersTransaction
|
|
943
|
-
*/
|
|
944
|
-
signTransactionData(signerAuthToken: string, signingData: AnyTransactionData): Promise<string>;
|
|
945
|
-
/**
|
|
946
|
-
* Submit signed transaction to PERS - uses existing PersService
|
|
947
|
-
*/
|
|
948
|
-
submitTransaction(transactionId: string, signature: string, persAccessToken: string, transactionFormat?: TransactionFormat): Promise<{
|
|
949
|
-
transactionHash?: string;
|
|
950
|
-
success: boolean;
|
|
951
|
-
}>;
|
|
952
|
-
/**
|
|
953
|
-
* Check if user exists - uses existing AuthenticationService
|
|
954
|
-
*/
|
|
955
|
-
checkUserExists(identifier: string): Promise<boolean>;
|
|
956
|
-
/**
|
|
957
|
-
* Get user wallets - uses existing WalletService
|
|
958
|
-
*/
|
|
959
|
-
getUserWallets(signerAuthToken: string): Promise<any>;
|
|
960
|
-
/**
|
|
961
|
-
* Get transaction status - uses existing PersService
|
|
962
|
-
*/
|
|
963
|
-
getTransactionStatus(transactionId: string, persAccessToken: string): Promise<{
|
|
964
|
-
status: string;
|
|
965
|
-
transactionHash?: string;
|
|
966
|
-
}>;
|
|
967
|
-
/**
|
|
968
|
-
* Initialize tenant - uses existing PersService
|
|
969
|
-
*/
|
|
970
|
-
initializeTenant(tenantId: string): Promise<void>;
|
|
971
|
-
/**
|
|
972
|
-
* Extract and validate JWT token from URL search parameters
|
|
973
|
-
* Uses a simpler approach compatible with browser environments
|
|
974
|
-
*/
|
|
975
|
-
extractJWTFromURL(searchParams: URLSearchParams): JWTExtractionResult;
|
|
976
|
-
/**
|
|
977
|
-
* Initialize tenant from JWT payload using existing PersService
|
|
978
|
-
*/
|
|
979
|
-
initializeTenantFromJWT(payload: JWTPayload): Promise<string>;
|
|
980
|
-
/**
|
|
981
|
-
* Authenticate user with PERS API using existing PersService pattern
|
|
982
|
-
*/
|
|
983
|
-
/**
|
|
984
|
-
* Authenticate user with PERS API using existing PersService
|
|
985
|
-
*/
|
|
986
|
-
authenticatePersUser(jwtToken: string, projectKey: string): Promise<PersAuthResult>;
|
|
987
|
-
/**
|
|
988
|
-
* Combined PERS + DFNS authentication flow
|
|
989
|
-
*/
|
|
990
|
-
combinedAuthentication(identifier: string, persAccessToken: string): Promise<SignerAuthenticatedUser>;
|
|
991
|
-
/**
|
|
992
|
-
* Complete JWT-based authentication flow (legacy PERS flow)
|
|
993
|
-
*/
|
|
994
|
-
authenticateWithJWT(searchParams: URLSearchParams): Promise<AuthenticationResult | null>;
|
|
995
|
-
}
|
|
996
|
-
|
|
997
953
|
/**
|
|
998
954
|
* Wallet list response from WalletService
|
|
999
955
|
*/
|
|
@@ -1017,150 +973,68 @@ interface WalletItem {
|
|
|
1017
973
|
}
|
|
1018
974
|
|
|
1019
975
|
/**
|
|
1020
|
-
*
|
|
1021
|
-
*/
|
|
1022
|
-
/**
|
|
1023
|
-
* Creates a URL search string that preserves all current parameters
|
|
1024
|
-
* @param paramsToExclude Array of parameter names to exclude from the result
|
|
1025
|
-
* @param paramsToAdd Object with additional parameters to add or override
|
|
1026
|
-
* @param baseParams Optional URLSearchParams object to use instead of window.location.search
|
|
1027
|
-
* @returns A search string with '?' prefix if there are parameters, or empty string if no parameters
|
|
1028
|
-
*/
|
|
1029
|
-
declare function createSearchString(paramsToExclude?: string[], paramsToAdd?: Record<string, string>, baseParams?: URLSearchParams | string): string;
|
|
1030
|
-
/**
|
|
1031
|
-
* Creates a URL path with search parameters
|
|
1032
|
-
* @param basePath The base path without search parameters
|
|
1033
|
-
* @param paramsToExclude Array of parameter names to exclude from the result
|
|
1034
|
-
* @param paramsToAdd Object with additional parameters to add or override
|
|
1035
|
-
* @param baseParams Optional URLSearchParams object to use instead of window.location.search
|
|
1036
|
-
* @returns A full path with search parameters
|
|
1037
|
-
*/
|
|
1038
|
-
declare function createUrlWithSearchParams(basePath: string, paramsToExclude?: string[], paramsToAdd?: Record<string, string>, baseParams?: URLSearchParams | string): string;
|
|
1039
|
-
/**
|
|
1040
|
-
* Combines the current search parameters with new ones
|
|
1041
|
-
* @param searchParams The current URLSearchParams object
|
|
1042
|
-
* @param additionalParams Object with parameters to add or update
|
|
1043
|
-
* @returns A new URLSearchParams object
|
|
1044
|
-
*/
|
|
1045
|
-
declare function mergeSearchParams(searchParams: URLSearchParams, additionalParams?: Record<string, string>): URLSearchParams;
|
|
1046
|
-
/**
|
|
1047
|
-
* Gets a specific search parameter value
|
|
1048
|
-
* @param key The parameter name to get
|
|
1049
|
-
* @param search Optional search string to parse (defaults to window.location.search)
|
|
1050
|
-
* @returns The parameter value or null if not found
|
|
1051
|
-
*/
|
|
1052
|
-
declare function getSearchParam(key: string, search?: string): string | null;
|
|
1053
|
-
/**
|
|
1054
|
-
* Gets all search parameters as a URLSearchParams object
|
|
1055
|
-
* @param search Optional search string to parse (defaults to window.location.search)
|
|
1056
|
-
* @returns A URLSearchParams object
|
|
1057
|
-
*/
|
|
1058
|
-
declare function getAllSearchParams(search?: string): URLSearchParams;
|
|
1059
|
-
/**
|
|
1060
|
-
* Removes a specific search parameter
|
|
1061
|
-
* @param key The parameter name to remove
|
|
1062
|
-
* @param search Optional search string to parse (defaults to window.location.search)
|
|
1063
|
-
* @returns A new search string without the specified parameter
|
|
1064
|
-
*/
|
|
1065
|
-
declare function removeSearchParam(key: string, search?: string): string;
|
|
1066
|
-
/**
|
|
1067
|
-
* Updates or adds a specific search parameter
|
|
1068
|
-
* @param key The parameter name to update
|
|
1069
|
-
* @param value The new value for the parameter
|
|
1070
|
-
* @param search Optional search string to parse (defaults to window.location.search)
|
|
1071
|
-
* @returns A new search string with the updated parameter
|
|
1072
|
-
*/
|
|
1073
|
-
declare function updateSearchParam(key: string, value: string, search?: string): string;
|
|
1074
|
-
|
|
1075
|
-
/**
|
|
1076
|
-
* Utility for debugging search parameter handling
|
|
1077
|
-
*/
|
|
1078
|
-
/**
|
|
1079
|
-
* Logs the current search parameters with a custom message
|
|
1080
|
-
* This is useful for debugging search parameter preservation across navigation
|
|
1081
|
-
*
|
|
1082
|
-
* @param message - A descriptive message to identify where the logging happens
|
|
1083
|
-
* @param additionalData - Optional additional data to log
|
|
1084
|
-
*/
|
|
1085
|
-
declare function logSearchParams(message: string, additionalData?: any): void;
|
|
1086
|
-
/**
|
|
1087
|
-
* Creates a search parameter tracking hook that can be used in React components
|
|
1088
|
-
* Logs search parameter changes when the component mounts/updates
|
|
1089
|
-
*
|
|
1090
|
-
* @param componentName - The name of the component (for logging)
|
|
1091
|
-
*/
|
|
1092
|
-
declare function createSearchParamLogger(componentName: string): () => void;
|
|
1093
|
-
|
|
1094
|
-
/**
|
|
1095
|
-
* Generates a RFC4122 version 4 compliant UUID
|
|
1096
|
-
* @returns A randomly generated UUID
|
|
1097
|
-
*/
|
|
1098
|
-
declare function generateUUID(): string;
|
|
1099
|
-
/**
|
|
1100
|
-
* Create a semi-anonymous username for users
|
|
1101
|
-
* @returns A username in the format "user_[random string]"
|
|
1102
|
-
*/
|
|
1103
|
-
declare function generateAnonymousUsername(): string;
|
|
1104
|
-
/**
|
|
1105
|
-
* Create a guest username for the application with a random prefix
|
|
1106
|
-
* @returns A guest email in the format "randomstring_guest@explorins.com"
|
|
1107
|
-
*/
|
|
1108
|
-
declare function generateGuestUsername(): string;
|
|
1109
|
-
|
|
1110
|
-
/**
|
|
1111
|
-
* Utility functions for tenant-specific operations
|
|
1112
|
-
*/
|
|
1113
|
-
/**
|
|
1114
|
-
* Represents a tenant configuration
|
|
976
|
+
* Authenticated user with all required tokens
|
|
1115
977
|
*/
|
|
1116
|
-
interface
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
enabled: boolean;
|
|
1121
|
-
trackingId?: string;
|
|
1122
|
-
};
|
|
978
|
+
interface SignerAuthenticatedUser {
|
|
979
|
+
identifier: string;
|
|
980
|
+
signerAuthToken: string;
|
|
981
|
+
persAccessToken: string;
|
|
1123
982
|
}
|
|
1124
|
-
/**
|
|
1125
|
-
* Initialize tenant-specific analytics
|
|
1126
|
-
* @param tenantId The tenant ID
|
|
1127
|
-
* @param getTenantConfig Function to retrieve tenant configuration
|
|
1128
|
-
*/
|
|
1129
|
-
declare const initTenantAnalytics: (tenantId: string, getTenantConfig: (id: string) => TenantConfig | null) => void;
|
|
1130
|
-
|
|
1131
983
|
/**
|
|
1132
984
|
* Authentication service for user login and registration
|
|
1133
985
|
* Uses constructor-based dependency injection for WebAuthn provider
|
|
986
|
+
* Updated for new v1 API endpoints
|
|
1134
987
|
*/
|
|
1135
988
|
declare class AuthenticationService {
|
|
989
|
+
private signerToken;
|
|
990
|
+
private config;
|
|
1136
991
|
private webAuthnProvider;
|
|
1137
|
-
constructor(
|
|
992
|
+
constructor(config: ExtendedPersSignerConfig);
|
|
1138
993
|
/**
|
|
1139
|
-
*
|
|
1140
|
-
* @param
|
|
1141
|
-
* @returns Promise resolving to
|
|
994
|
+
* Login with PERS token to get signer JWT
|
|
995
|
+
* @param persToken - PERS JWT from PERS authentication
|
|
996
|
+
* @returns Promise resolving to login response or provider challenge data
|
|
1142
997
|
*/
|
|
1143
|
-
|
|
998
|
+
loginWithPersToken(persToken: string): Promise<JWTLoginResponse | unknown>;
|
|
1144
999
|
/**
|
|
1145
|
-
*
|
|
1146
|
-
* @param
|
|
1147
|
-
* @returns Promise resolving to
|
|
1000
|
+
* Verify signer token validity
|
|
1001
|
+
* @param token - Signer JWT to verify
|
|
1002
|
+
* @returns Promise resolving to verification result
|
|
1148
1003
|
*/
|
|
1149
|
-
|
|
1004
|
+
verifyToken(token: string): Promise<VerifyTokenResponse>;
|
|
1150
1005
|
/**
|
|
1151
|
-
*
|
|
1152
|
-
* @param
|
|
1153
|
-
* @returns Promise resolving to
|
|
1006
|
+
* Initialize user registration
|
|
1007
|
+
* @param persToken - PERS JWT token (registration is public)
|
|
1008
|
+
* @returns Promise resolving to registration challenge
|
|
1154
1009
|
*/
|
|
1155
|
-
|
|
1010
|
+
initializeRegistration(persToken: string): Promise<unknown>;
|
|
1156
1011
|
/**
|
|
1157
|
-
* Get
|
|
1158
|
-
* @
|
|
1159
|
-
* @returns Promise resolving to user info or null
|
|
1012
|
+
* Get current signer token
|
|
1013
|
+
* @returns The current signer JWT token
|
|
1160
1014
|
*/
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1015
|
+
getSignerToken(): string | null;
|
|
1016
|
+
/**
|
|
1017
|
+
* Set signer token (for external token management)
|
|
1018
|
+
* @param token - Signer JWT token
|
|
1019
|
+
*/
|
|
1020
|
+
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
|
+
/**
|
|
1030
|
+
* Combined authentication flow - handles both login and registration
|
|
1031
|
+
* @param identifier - User identifier (email/userId)
|
|
1032
|
+
* @param persAccessToken - PERS JWT token for authentication
|
|
1033
|
+
* @param webAuthnProvider - WebAuthn provider for credential creation
|
|
1034
|
+
* @param relyingPartyConfig - Configuration for WebAuthn relying party
|
|
1035
|
+
* @returns Promise resolving to authenticated user with signer token
|
|
1036
|
+
*/
|
|
1037
|
+
combinedAuthentication(identifier: string, persAccessToken: string): Promise<SignerAuthenticatedUser>;
|
|
1164
1038
|
}
|
|
1165
1039
|
|
|
1166
1040
|
/**
|
|
@@ -1177,19 +1051,11 @@ declare function getBrowserWebAuthnProvider(): Promise<WebAuthnProvider>;
|
|
|
1177
1051
|
* Includes only browser-compatible dependencies
|
|
1178
1052
|
*/
|
|
1179
1053
|
|
|
1180
|
-
/**
|
|
1181
|
-
* Create a new AuthenticationService instance with browser WebAuthn provider
|
|
1182
|
-
*/
|
|
1183
|
-
declare function createAuthenticationService(): Promise<AuthenticationService>;
|
|
1184
|
-
/**
|
|
1185
|
-
* Create a new SigningService instance with browser WebAuthn provider
|
|
1186
|
-
*/
|
|
1187
|
-
declare function createSigningService(): Promise<SigningService>;
|
|
1188
1054
|
/**
|
|
1189
1055
|
* Create a new PersSignerSDK instance with browser WebAuthn provider
|
|
1190
1056
|
* @param config - SDK configuration (ethersProviderUrl is required)
|
|
1191
1057
|
*/
|
|
1192
|
-
declare function createPersSignerSDK(config:
|
|
1058
|
+
declare function createPersSignerSDK(config: PersSignerConfig): Promise<PersSignerSDK>;
|
|
1193
1059
|
|
|
1194
|
-
export { AuthenticationService, FetchHttpClient, KeyWallet, PersService, PersSignerSDK, ReactNativeConfigProvider, SIGNABLE_STATUSES, SigningService, StaticConfigProvider, TransactionErrorHandler, TransactionSigningErrorCode, TransactionSigningService, TransactionSubmissionHandler, TransactionValidator, WalletService, WebAuthnCoordinator, WebConfigProvider,
|
|
1195
|
-
export type {
|
|
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 };
|