@explorins/pers-signer 1.0.11 → 1.0.16
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 -981
- package/dist/browser.cjs.js.map +1 -1
- package/dist/browser.d.ts +334 -469
- package/dist/browser.esm.js +820 -967
- package/dist/browser.esm.js.map +1 -1
- package/dist/index.cjs.js +890 -973
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +597 -576
- package/dist/index.esm.js +886 -961
- package/dist/index.esm.js.map +1 -1
- package/dist/react-native.cjs.js +820 -982
- package/dist/react-native.cjs.js.map +1 -1
- package/dist/react-native.d.ts +334 -469
- package/dist/react-native.esm.js +821 -968
- 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
|
|
25
|
-
*/
|
|
26
|
-
static getWallet(authToken: string, walletId: string): Promise<any>;
|
|
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
|
|
17
|
+
* @param signerToken - Signer JWT token
|
|
18
|
+
* @returns Promise resolving to wallet data
|
|
32
19
|
*/
|
|
33
|
-
static
|
|
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
|
|
376
|
-
*/
|
|
377
|
-
interface AuthToken {
|
|
378
|
-
token: string;
|
|
379
|
-
expiresAt: Date;
|
|
380
|
-
refreshToken?: string;
|
|
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
|
|
357
|
+
* Authentication types for 3-function split architecture
|
|
413
358
|
*/
|
|
414
|
-
interface
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
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,10 @@ 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
|
-
metadata?: TransactionMetadata;
|
|
551
|
-
walletRegistrationFailed?: boolean;
|
|
552
|
-
walletErrorDetails?: string;
|
|
553
480
|
}
|
|
554
481
|
|
|
555
482
|
/**
|
|
@@ -559,7 +486,7 @@ interface TransactionSigningParams {
|
|
|
559
486
|
*/
|
|
560
487
|
declare class TransactionSigningService {
|
|
561
488
|
private webAuthnProvider;
|
|
562
|
-
constructor(
|
|
489
|
+
constructor(config: PersSignerConfig);
|
|
563
490
|
/**
|
|
564
491
|
* Prepare transaction for signing - fetch and validate
|
|
565
492
|
*/
|
|
@@ -572,6 +499,11 @@ declare class TransactionSigningService {
|
|
|
572
499
|
* Execute the transaction signing with WebAuthn coordination
|
|
573
500
|
*/
|
|
574
501
|
private executeTransactionSigning;
|
|
502
|
+
getPersSigningData(data: {
|
|
503
|
+
transactionId: string;
|
|
504
|
+
authTokens: SigningAuthTokens;
|
|
505
|
+
tenantId: string;
|
|
506
|
+
}): Promise<CounterfactualWalletTransactionResponse | LegacyTransaction>;
|
|
575
507
|
/**
|
|
576
508
|
* Main transaction signing orchestration method
|
|
577
509
|
* Handles the complete flow from preparation to submission
|
|
@@ -579,7 +511,7 @@ declare class TransactionSigningService {
|
|
|
579
511
|
* @returns Promise resolving to transaction signing result
|
|
580
512
|
* @throws TransactionSigningError for validation and operation failures
|
|
581
513
|
*/
|
|
582
|
-
signTransaction(params: TransactionSigningParams): Promise<TransactionSigningResult>;
|
|
514
|
+
signTransaction(params: TransactionSigningParams, signingData: CounterfactualWalletTransactionResponse | LegacyTransaction): Promise<TransactionSigningResult>;
|
|
583
515
|
}
|
|
584
516
|
|
|
585
517
|
/**
|
|
@@ -698,19 +630,7 @@ declare class TransactionSubmissionHandler {
|
|
|
698
630
|
* @param metadata - Optional metadata to include as parameters
|
|
699
631
|
* @returns Promise resolving to the complete redirect URL
|
|
700
632
|
*/
|
|
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>;
|
|
633
|
+
static createRedirectUrl(returnUrl: string, transactionHash: string): Promise<string>;
|
|
714
634
|
}
|
|
715
635
|
|
|
716
636
|
/**
|
|
@@ -718,11 +638,6 @@ declare class TransactionSubmissionHandler {
|
|
|
718
638
|
* Manages global state flags to ensure only one WebAuthn operation runs at a time
|
|
719
639
|
*/
|
|
720
640
|
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
641
|
/**
|
|
727
642
|
* Check if a WebAuthn operation is currently in progress
|
|
728
643
|
* @returns True if an operation is in progress, false otherwise
|
|
@@ -739,7 +654,7 @@ declare class WebAuthnCoordinator {
|
|
|
739
654
|
* Platform-agnostic configuration provider
|
|
740
655
|
* Abstracts environment variable access for cross-platform compatibility
|
|
741
656
|
*/
|
|
742
|
-
interface
|
|
657
|
+
interface PlatformConfig {
|
|
743
658
|
apiUrl: string;
|
|
744
659
|
appId?: string;
|
|
745
660
|
relyingParty: {
|
|
@@ -749,7 +664,7 @@ interface ServiceConfig {
|
|
|
749
664
|
};
|
|
750
665
|
}
|
|
751
666
|
interface ConfigProvider {
|
|
752
|
-
getServiceConfig():
|
|
667
|
+
getServiceConfig(): PlatformConfig;
|
|
753
668
|
}
|
|
754
669
|
/**
|
|
755
670
|
* Web platform configuration provider
|
|
@@ -757,8 +672,8 @@ interface ConfigProvider {
|
|
|
757
672
|
*/
|
|
758
673
|
declare class WebConfigProvider implements ConfigProvider {
|
|
759
674
|
private config;
|
|
760
|
-
constructor(config:
|
|
761
|
-
getServiceConfig():
|
|
675
|
+
constructor(config: PlatformConfig);
|
|
676
|
+
getServiceConfig(): PlatformConfig;
|
|
762
677
|
}
|
|
763
678
|
/**
|
|
764
679
|
* React Native configuration provider
|
|
@@ -766,16 +681,16 @@ declare class WebConfigProvider implements ConfigProvider {
|
|
|
766
681
|
*/
|
|
767
682
|
declare class ReactNativeConfigProvider implements ConfigProvider {
|
|
768
683
|
private config;
|
|
769
|
-
constructor(config:
|
|
770
|
-
getServiceConfig():
|
|
684
|
+
constructor(config: PlatformConfig);
|
|
685
|
+
getServiceConfig(): PlatformConfig;
|
|
771
686
|
}
|
|
772
687
|
/**
|
|
773
688
|
* Static configuration provider for testing or custom setups
|
|
774
689
|
*/
|
|
775
690
|
declare class StaticConfigProvider implements ConfigProvider {
|
|
776
691
|
private config;
|
|
777
|
-
constructor(config:
|
|
778
|
-
getServiceConfig():
|
|
692
|
+
constructor(config: PlatformConfig);
|
|
693
|
+
getServiceConfig(): PlatformConfig;
|
|
779
694
|
}
|
|
780
695
|
/**
|
|
781
696
|
* Set the global configuration provider
|
|
@@ -789,7 +704,7 @@ declare function getConfigProvider(): ConfigProvider;
|
|
|
789
704
|
/**
|
|
790
705
|
* Get the service configuration
|
|
791
706
|
*/
|
|
792
|
-
declare function getServiceConfig():
|
|
707
|
+
declare function getServiceConfig(): PlatformConfig;
|
|
793
708
|
|
|
794
709
|
/**
|
|
795
710
|
* Platform-agnostic HTTP client abstraction
|
|
@@ -835,50 +750,44 @@ declare function setHttpClient(client: HttpClient): void;
|
|
|
835
750
|
declare function getHttpClient(): HttpClient;
|
|
836
751
|
|
|
837
752
|
/**
|
|
838
|
-
* PERS Blockchain Signer SDK
|
|
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
|
+
* });
|
|
839
772
|
*
|
|
840
|
-
*
|
|
841
|
-
*
|
|
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
|
+
* ```
|
|
842
779
|
*/
|
|
843
780
|
|
|
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
781
|
/**
|
|
859
|
-
*
|
|
860
|
-
|
|
861
|
-
interface
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
}
|
|
866
|
-
|
|
867
|
-
* Authenticated user with all required tokens
|
|
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
|
|
868
790
|
*/
|
|
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
791
|
interface PersSignerConfig {
|
|
883
792
|
tenantId?: string;
|
|
884
793
|
ethersProviderUrl?: string;
|
|
@@ -886,112 +795,158 @@ interface PersSignerConfig {
|
|
|
886
795
|
apiUrl?: string;
|
|
887
796
|
relyingPartyName?: string;
|
|
888
797
|
}
|
|
889
|
-
interface SigningResult {
|
|
890
|
-
success: boolean;
|
|
891
|
-
transactionHash?: string;
|
|
892
|
-
error?: string;
|
|
893
|
-
}
|
|
894
798
|
/**
|
|
895
|
-
*
|
|
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.
|
|
896
803
|
*
|
|
897
|
-
*
|
|
898
|
-
*
|
|
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
|
|
899
812
|
*/
|
|
900
813
|
declare class PersSignerSDK {
|
|
901
814
|
private config;
|
|
902
|
-
private
|
|
903
|
-
private signingService;
|
|
815
|
+
private authenticationService;
|
|
904
816
|
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
817
|
/**
|
|
957
|
-
*
|
|
958
|
-
|
|
959
|
-
|
|
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
|
|
818
|
+
* Initialize the PERS Signer SDK
|
|
819
|
+
*
|
|
820
|
+
* @param {PersSignerConfig} config - SDK configuration object
|
|
821
|
+
* @throws {Error} If required configuration is missing
|
|
982
822
|
*/
|
|
823
|
+
constructor(config: PersSignerConfig);
|
|
983
824
|
/**
|
|
984
|
-
* Authenticate user
|
|
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
|
+
* ```
|
|
985
886
|
*/
|
|
986
|
-
|
|
887
|
+
signTransaction(signingData: CounterfactualWalletTransactionResponse$1 | LegacyTransaction, jwtToken: string): Promise<TransactionSigningResult>;
|
|
987
888
|
/**
|
|
988
|
-
*
|
|
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
|
+
* ```
|
|
989
933
|
*/
|
|
990
|
-
|
|
934
|
+
submitTransaction(signingResult: TransactionSigningResult, jwtToken: string): Promise<SubmissionResult>;
|
|
991
935
|
/**
|
|
992
|
-
*
|
|
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
|
+
* ```
|
|
993
948
|
*/
|
|
994
|
-
|
|
949
|
+
clearCache(): void;
|
|
995
950
|
}
|
|
996
951
|
|
|
997
952
|
/**
|
|
@@ -1017,150 +972,68 @@ interface WalletItem {
|
|
|
1017
972
|
}
|
|
1018
973
|
|
|
1019
974
|
/**
|
|
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
|
|
975
|
+
* Authenticated user with all required tokens
|
|
1115
976
|
*/
|
|
1116
|
-
interface
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
enabled: boolean;
|
|
1121
|
-
trackingId?: string;
|
|
1122
|
-
};
|
|
977
|
+
interface SignerAuthenticatedUser {
|
|
978
|
+
identifier: string;
|
|
979
|
+
signerAuthToken: string;
|
|
980
|
+
persAccessToken: string;
|
|
1123
981
|
}
|
|
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
982
|
/**
|
|
1132
983
|
* Authentication service for user login and registration
|
|
1133
984
|
* Uses constructor-based dependency injection for WebAuthn provider
|
|
985
|
+
* Updated for new v1 API endpoints
|
|
1134
986
|
*/
|
|
1135
987
|
declare class AuthenticationService {
|
|
988
|
+
private signerToken;
|
|
989
|
+
private config;
|
|
1136
990
|
private webAuthnProvider;
|
|
1137
|
-
constructor(
|
|
991
|
+
constructor(config: PersSignerConfig);
|
|
1138
992
|
/**
|
|
1139
|
-
*
|
|
1140
|
-
* @param
|
|
1141
|
-
* @returns Promise resolving to
|
|
993
|
+
* Login with PERS token to get signer JWT
|
|
994
|
+
* @param persToken - PERS JWT from PERS authentication
|
|
995
|
+
* @returns Promise resolving to login response or provider challenge data
|
|
1142
996
|
*/
|
|
1143
|
-
|
|
997
|
+
loginWithPersToken(persToken: string): Promise<JWTLoginResponse | unknown>;
|
|
1144
998
|
/**
|
|
1145
|
-
*
|
|
1146
|
-
* @param
|
|
1147
|
-
* @returns Promise resolving to
|
|
999
|
+
* Verify signer token validity
|
|
1000
|
+
* @param token - Signer JWT to verify
|
|
1001
|
+
* @returns Promise resolving to verification result
|
|
1148
1002
|
*/
|
|
1149
|
-
|
|
1003
|
+
verifyToken(token: string): Promise<VerifyTokenResponse>;
|
|
1150
1004
|
/**
|
|
1151
|
-
*
|
|
1152
|
-
* @param
|
|
1153
|
-
* @returns Promise resolving to
|
|
1005
|
+
* Initialize user registration
|
|
1006
|
+
* @param persToken - PERS JWT token (registration is public)
|
|
1007
|
+
* @returns Promise resolving to registration challenge
|
|
1154
1008
|
*/
|
|
1155
|
-
|
|
1009
|
+
initializeRegistration(persToken: string): Promise<unknown>;
|
|
1156
1010
|
/**
|
|
1157
|
-
* Get
|
|
1158
|
-
* @
|
|
1159
|
-
* @returns Promise resolving to user info or null
|
|
1011
|
+
* Get current signer token
|
|
1012
|
+
* @returns The current signer JWT token
|
|
1160
1013
|
*/
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1014
|
+
getSignerToken(): string | null;
|
|
1015
|
+
/**
|
|
1016
|
+
* Set signer token (for external token management)
|
|
1017
|
+
* @param token - Signer JWT token
|
|
1018
|
+
*/
|
|
1019
|
+
setSignerToken(token: string): void;
|
|
1020
|
+
/**
|
|
1021
|
+
* Complete registration with WebAuthn challenge data (v1 API format)
|
|
1022
|
+
* @param tmpAuthToken - Temporary auth token from init registration (temporaryAuthenticationToken)
|
|
1023
|
+
* @param signedChallenge - WebAuthn credential response (will be restructured for backend)
|
|
1024
|
+
* @param persToken - PERS JWT token (authToken)
|
|
1025
|
+
* @returns Promise resolving to registration result
|
|
1026
|
+
*/
|
|
1027
|
+
completeRegistrationWithChallenge(tmpAuthToken: string | null, signedChallenge: any, persToken: string): Promise<JWTLoginResponse | unknown>;
|
|
1028
|
+
/**
|
|
1029
|
+
* Combined authentication flow - handles both login and registration
|
|
1030
|
+
* @param identifier - User identifier (email/userId)
|
|
1031
|
+
* @param persAccessToken - PERS JWT token for authentication
|
|
1032
|
+
* @param webAuthnProvider - WebAuthn provider for credential creation
|
|
1033
|
+
* @param relyingPartyConfig - Configuration for WebAuthn relying party
|
|
1034
|
+
* @returns Promise resolving to authenticated user with signer token
|
|
1035
|
+
*/
|
|
1036
|
+
combinedAuthentication(identifier: string, persAccessToken: string): Promise<SignerAuthenticatedUser>;
|
|
1164
1037
|
}
|
|
1165
1038
|
|
|
1166
1039
|
/**
|
|
@@ -1177,19 +1050,11 @@ declare function getBrowserWebAuthnProvider(): Promise<WebAuthnProvider>;
|
|
|
1177
1050
|
* Includes only browser-compatible dependencies
|
|
1178
1051
|
*/
|
|
1179
1052
|
|
|
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
1053
|
/**
|
|
1189
1054
|
* Create a new PersSignerSDK instance with browser WebAuthn provider
|
|
1190
1055
|
* @param config - SDK configuration (ethersProviderUrl is required)
|
|
1191
1056
|
*/
|
|
1192
1057
|
declare function createPersSignerSDK(config: Omit<PersSignerConfig, 'webAuthnProvider'>): Promise<PersSignerSDK>;
|
|
1193
1058
|
|
|
1194
|
-
export { AuthenticationService, FetchHttpClient, KeyWallet, PersService, PersSignerSDK, ReactNativeConfigProvider, SIGNABLE_STATUSES, SigningService, StaticConfigProvider, TransactionErrorHandler, TransactionSigningErrorCode, TransactionSigningService, TransactionSubmissionHandler, TransactionValidator, WalletService, WebAuthnCoordinator, WebConfigProvider,
|
|
1195
|
-
export type {
|
|
1059
|
+
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 };
|