@explorins/pers-signer 1.0.16 → 1.0.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.cjs.js +48 -40
- package/dist/browser.cjs.js.map +1 -1
- package/dist/browser.d.ts +382 -325
- package/dist/browser.esm.js +41 -41
- package/dist/browser.esm.js.map +1 -1
- package/dist/index.cjs.js +48 -40
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +309 -292
- package/dist/index.esm.js +41 -41
- package/dist/index.esm.js.map +1 -1
- package/dist/react-native.cjs.js +48 -40
- package/dist/react-native.cjs.js.map +1 -1
- package/dist/react-native.d.ts +382 -325
- package/dist/react-native.esm.js +41 -41
- package/dist/react-native.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as _explorins_web3_ts_types from '@explorins/web3-ts/types';
|
|
2
|
-
import {
|
|
3
|
-
export { AnyTransactionData } from '@explorins/web3-ts/types';
|
|
2
|
+
import { LegacyTransaction, AnyTransactionData } from '@explorins/web3-ts/types';
|
|
3
|
+
export { AnyTransactionData, BaseTransaction, CounterfactualWalletEIP712Data, EIP1559Transaction, EIP2930Transaction, EIP712TransactionData, EIP712TypedData, LegacyTransaction } from '@explorins/web3-ts/types';
|
|
4
4
|
import * as _explorins_pers_shared_browser from '@explorins/pers-shared/browser';
|
|
5
|
-
import {
|
|
6
|
-
export { TransactionFormat, TransactionRequestResponseDTO, TransactionStatus } from '@explorins/pers-shared/browser';
|
|
5
|
+
import { CounterfactualWalletTransactionResponse, TransactionStatus, TransactionRequestResponseDTO, TenantPublicDTO, SessionAuthContextResponseDTO, TransactionFormat } from '@explorins/pers-shared/browser';
|
|
6
|
+
export { CampaignClaimDTO, CampaignDTO, SessionAuthResponseDTO, TRANSACTION_FORMATS, TRANSACTION_FORMAT_DESCRIPTIONS, TransactionFormat, TransactionRequestResponseDTO, TransactionStatus, TransactionSubmissionRequestDTO } from '@explorins/pers-shared/browser';
|
|
7
7
|
import { CounterfactualWalletTransactionResponse as CounterfactualWalletTransactionResponse$1 } from '@explorins/pers-shared';
|
|
8
8
|
import { AbstractSigner, Provider, TransactionRequest, TypedDataDomain, TypedDataField } from 'ethers';
|
|
9
9
|
|
|
@@ -47,6 +47,9 @@ interface WrappedProviderResponse {
|
|
|
47
47
|
data: unknown;
|
|
48
48
|
}
|
|
49
49
|
type LoginResponse = JWTLoginResponse | WrappedProviderResponse;
|
|
50
|
+
interface VerifyTokenRequest {
|
|
51
|
+
token: string;
|
|
52
|
+
}
|
|
50
53
|
interface VerifyTokenResponse {
|
|
51
54
|
valid: boolean;
|
|
52
55
|
provider: string;
|
|
@@ -64,6 +67,19 @@ interface VerifyTokenResponse {
|
|
|
64
67
|
};
|
|
65
68
|
tenantId: string;
|
|
66
69
|
}
|
|
70
|
+
interface InitRegistrationRequest {
|
|
71
|
+
authToken: string;
|
|
72
|
+
}
|
|
73
|
+
interface InitRegistrationResponse {
|
|
74
|
+
success: true;
|
|
75
|
+
data: {
|
|
76
|
+
challenge?: string;
|
|
77
|
+
temporaryAuthenticationToken?: string;
|
|
78
|
+
user?: object;
|
|
79
|
+
[key: string]: unknown;
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
type CompleteRegistrationResponse = JWTLoginResponse | WrappedProviderResponse;
|
|
67
83
|
interface ListWalletsRequest {
|
|
68
84
|
}
|
|
69
85
|
interface ListWalletsResponse {
|
|
@@ -73,6 +89,23 @@ interface ListWalletsResponse {
|
|
|
73
89
|
[key: string]: unknown;
|
|
74
90
|
};
|
|
75
91
|
}
|
|
92
|
+
interface InitSignatureRequest {
|
|
93
|
+
walletId: string;
|
|
94
|
+
request: unknown;
|
|
95
|
+
}
|
|
96
|
+
interface InitSignatureResponse {
|
|
97
|
+
success: true;
|
|
98
|
+
data: {
|
|
99
|
+
requestBody: unknown;
|
|
100
|
+
challenge: unknown;
|
|
101
|
+
[key: string]: unknown;
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
interface CompleteSignatureRequest {
|
|
105
|
+
walletId: string;
|
|
106
|
+
requestBody: unknown;
|
|
107
|
+
signedChallenge: unknown;
|
|
108
|
+
}
|
|
76
109
|
interface CompleteSignatureResponse {
|
|
77
110
|
success: true;
|
|
78
111
|
data: {
|
|
@@ -103,126 +136,6 @@ interface HealthCheckResponse {
|
|
|
103
136
|
success: boolean;
|
|
104
137
|
}
|
|
105
138
|
|
|
106
|
-
/**
|
|
107
|
-
* Wallet management service
|
|
108
|
-
* Updated for v1 API endpoints per migration reference
|
|
109
|
-
*/
|
|
110
|
-
declare class WalletService {
|
|
111
|
-
/**
|
|
112
|
-
* List all wallets for authenticated user
|
|
113
|
-
* @param signerToken - Signer JWT token
|
|
114
|
-
* @returns Promise resolving to wallet data
|
|
115
|
-
*/
|
|
116
|
-
static listWallets(signerToken: string): Promise<unknown>;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Service for interacting with PERS (Phygital Experience Rewards System) backend API
|
|
121
|
-
*/
|
|
122
|
-
/**
|
|
123
|
-
* Configuration interface for PERS API
|
|
124
|
-
*/
|
|
125
|
-
interface PersApiConfig {
|
|
126
|
-
baseUrl: string;
|
|
127
|
-
projectKey?: string;
|
|
128
|
-
}
|
|
129
|
-
declare class PersService {
|
|
130
|
-
private static config;
|
|
131
|
-
private static tenantCache;
|
|
132
|
-
private static currentProjectKey;
|
|
133
|
-
private static currentTenantId;
|
|
134
|
-
private static useStaging;
|
|
135
|
-
private static readonly TENANT_CACHE_TTL;
|
|
136
|
-
/**
|
|
137
|
-
* Configure the PERS API settings
|
|
138
|
-
* @param config - The configuration object
|
|
139
|
-
*/
|
|
140
|
-
static configure(config: Partial<PersApiConfig>): void;
|
|
141
|
-
/**
|
|
142
|
-
* Enable staging mode when project key is not available
|
|
143
|
-
* @param enableStaging Whether to use staging environment
|
|
144
|
-
*/
|
|
145
|
-
static setStagingMode(enableStaging: boolean): void;
|
|
146
|
-
/**
|
|
147
|
-
* Get current configuration
|
|
148
|
-
*/
|
|
149
|
-
static getConfig(): PersApiConfig;
|
|
150
|
-
/**
|
|
151
|
-
* Get tenant information by tenant ID
|
|
152
|
-
* @param tenantId - The tenant ID to retrieve
|
|
153
|
-
* @param authToken - Optional auth token for authentication
|
|
154
|
-
* @returns Promise with tenant public information
|
|
155
|
-
*/
|
|
156
|
-
static getTenantById(tenantId: string, authToken?: string): Promise<TenantPublicDTO>;
|
|
157
|
-
/**
|
|
158
|
-
* Initialize tenant configuration from JWT
|
|
159
|
-
* @param tenantId - The tenant ID from JWT payload
|
|
160
|
-
* @param authToken - Optional auth token for authentication
|
|
161
|
-
* @returns Promise with tenant information
|
|
162
|
-
*/
|
|
163
|
-
static initializeTenant(tenantId: string, authToken?: string): Promise<TenantPublicDTO>;
|
|
164
|
-
/**
|
|
165
|
-
* Ensure tenant is initialized and current, with automatic revalidation
|
|
166
|
-
* @param tenantId - The tenant ID to ensure is initialized
|
|
167
|
-
* @param authToken - Optional auth token for authentication
|
|
168
|
-
* @returns Promise with tenant information
|
|
169
|
-
*/
|
|
170
|
-
static ensureTenantInitialized(tenantId: string, authToken?: string): Promise<TenantPublicDTO>;
|
|
171
|
-
/**
|
|
172
|
-
* Get the current project key (either from tenant or fallback)
|
|
173
|
-
* @param tenantId - Optional tenant ID to ensure is initialized
|
|
174
|
-
* @returns The project key to use for API calls
|
|
175
|
-
*/
|
|
176
|
-
private static getProjectKey;
|
|
177
|
-
/**
|
|
178
|
-
* Clear tenant cache and reset project key
|
|
179
|
-
*/
|
|
180
|
-
static clearTenantCache(): void;
|
|
181
|
-
/**
|
|
182
|
-
* Authenticates a user with the PERS backend using their auth token
|
|
183
|
-
*
|
|
184
|
-
* @param authToken - The authentication token received from DFNS after login/registration
|
|
185
|
-
* @param tenantId - Optional tenant ID for automatic initialization
|
|
186
|
-
* @returns A promise that resolves to the authentication response
|
|
187
|
-
* @throws If the request fails
|
|
188
|
-
*/
|
|
189
|
-
static authenticateUser(authToken: string, tenantId: string): Promise<SessionAuthContextResponseDTO>;
|
|
190
|
-
/**
|
|
191
|
-
* Submits a transaction by calling the backend endpoint
|
|
192
|
-
*
|
|
193
|
-
* @param transactionId - The ID of the transaction to submit
|
|
194
|
-
* @param signedTransactionOrSignature - The signed transaction data or EIP-712 signature
|
|
195
|
-
* @param persAccessToken - The PERS access token for authentication (Bearer)
|
|
196
|
-
* @param submissionType - The transaction format type
|
|
197
|
-
* @param tenantId - Optional tenant ID for automatic initialization
|
|
198
|
-
* @returns A promise that resolves to the transaction submission response
|
|
199
|
-
* @throws If the request fails
|
|
200
|
-
*/
|
|
201
|
-
static submitTransaction(transactionId: string, signedTransactionOrSignature: string, persAccessToken: string, submissionType: TransactionFormat, tenantId: string): Promise<TransactionRequestResponseDTO>;
|
|
202
|
-
/**
|
|
203
|
-
* Fetches a prepared transaction for signing by transactionId
|
|
204
|
-
* @param transactionId - The transaction ID to fetch
|
|
205
|
-
* @param persAccessToken - The PERS access token for authentication (Bearer)
|
|
206
|
-
* @param tenantId - Optional tenant ID for automatic initialization
|
|
207
|
-
* @returns The prepared transaction data
|
|
208
|
-
* @throws If the request fails
|
|
209
|
-
*/
|
|
210
|
-
static fetchPreparedTransaction(transactionId: string, persAccessToken: string, tenantId: string): Promise<TransactionRequestResponseDTO>;
|
|
211
|
-
/**
|
|
212
|
-
* Helper method to determine if transaction data is available for signing
|
|
213
|
-
* @param transactionResponse - Response from prepare or fetch transaction
|
|
214
|
-
* @returns boolean indicating if transaction can be signed
|
|
215
|
-
*/
|
|
216
|
-
static isTransactionReadyForSigning(transactionResponse: TransactionRequestResponseDTO): boolean;
|
|
217
|
-
/**
|
|
218
|
-
* Helper method to get transaction data from response
|
|
219
|
-
* @param transactionResponse - Response from prepare or fetch transaction
|
|
220
|
-
* @returns The transaction data ready for signing
|
|
221
|
-
* @throws If transaction data is not available
|
|
222
|
-
*/
|
|
223
|
-
static getTransactionDataForSigning(transactionResponse: TransactionRequestResponseDTO): _explorins_pers_shared_browser.CounterfactualWalletTransactionResponse | _explorins_web3_ts_types.LegacyTransaction;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
139
|
/**
|
|
227
140
|
* Types for WebAuthn provider abstraction
|
|
228
141
|
*/
|
|
@@ -330,19 +243,271 @@ interface SigningChallenge {
|
|
|
330
243
|
message?: string;
|
|
331
244
|
}
|
|
332
245
|
/**
|
|
333
|
-
* User credentials for authentication
|
|
246
|
+
* User credentials for authentication
|
|
247
|
+
*/
|
|
248
|
+
interface UserCredentials {
|
|
249
|
+
username: string;
|
|
250
|
+
appId?: string;
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Relying party configuration for WebAuthn
|
|
254
|
+
*/
|
|
255
|
+
interface RelyingPartyConfig {
|
|
256
|
+
id: string;
|
|
257
|
+
name: string;
|
|
258
|
+
origin?: string;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Combined transaction status type that includes both PERS and additional statuses
|
|
263
|
+
*/
|
|
264
|
+
type CombinedTransactionStatus = TransactionStatus;
|
|
265
|
+
/**
|
|
266
|
+
* Transaction statuses that allow signing
|
|
267
|
+
*/
|
|
268
|
+
declare const SIGNABLE_STATUSES: readonly [TransactionStatus.PENDING_SIGNATURE, TransactionStatus.CREATED];
|
|
269
|
+
/**
|
|
270
|
+
* Transaction status information for UI display
|
|
271
|
+
*/
|
|
272
|
+
interface TransactionStatusInfo {
|
|
273
|
+
transactionId: string;
|
|
274
|
+
transactionStatus: CombinedTransactionStatus;
|
|
275
|
+
message: string;
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Transaction signing result
|
|
279
|
+
*/
|
|
280
|
+
interface TransactionSigningResult {
|
|
281
|
+
success: boolean;
|
|
282
|
+
transactionId: string;
|
|
283
|
+
signature?: string;
|
|
284
|
+
signingData?: CounterfactualWalletTransactionResponse | LegacyTransaction;
|
|
285
|
+
error?: string;
|
|
286
|
+
statusInfo?: TransactionStatusInfo;
|
|
287
|
+
shouldShowStatus?: boolean;
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Transaction submission result for internal processing
|
|
291
|
+
*/
|
|
292
|
+
interface SubmissionResult {
|
|
293
|
+
submitResult: TransactionRequestResponseDTO;
|
|
294
|
+
shouldRedirect: boolean;
|
|
295
|
+
redirectUrl?: string;
|
|
296
|
+
transactionHash: string | null;
|
|
297
|
+
success: boolean;
|
|
298
|
+
error?: string;
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Metadata for transaction parameters - string values only
|
|
302
|
+
*/
|
|
303
|
+
/**
|
|
304
|
+
* Authentication tokens required for transaction signing
|
|
305
|
+
*/
|
|
306
|
+
interface SigningAuthTokens {
|
|
307
|
+
signerAuthToken: string;
|
|
308
|
+
persAccessToken: string;
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Transaction signing parameters
|
|
312
|
+
*/
|
|
313
|
+
interface TransactionSigningParams {
|
|
314
|
+
transactionId: string;
|
|
315
|
+
tenantId: string;
|
|
316
|
+
authTokens: SigningAuthTokens;
|
|
317
|
+
ethersProviderUrl: string;
|
|
318
|
+
returnUrl?: string;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* Wallet list response from WalletService
|
|
323
|
+
*/
|
|
324
|
+
interface WalletListResponse {
|
|
325
|
+
items: WalletItem[];
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* Individual wallet item from wallet list - compatible with KeyWallet constructor
|
|
329
|
+
*/
|
|
330
|
+
interface WalletItem {
|
|
331
|
+
id: string;
|
|
332
|
+
address: string;
|
|
333
|
+
network: string;
|
|
334
|
+
status: string;
|
|
335
|
+
signingKey?: unknown;
|
|
336
|
+
dateCreated?: string;
|
|
337
|
+
custodial?: boolean;
|
|
338
|
+
tags?: string[];
|
|
339
|
+
boundToEvmNetwork?: boolean;
|
|
340
|
+
[key: string]: unknown;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* Error codes for transaction signing operations
|
|
345
|
+
*/
|
|
346
|
+
declare enum TransactionSigningErrorCode {
|
|
347
|
+
INVALID_TOKENS = "INVALID_TOKENS",
|
|
348
|
+
TRANSACTION_NOT_FOUND = "TRANSACTION_NOT_FOUND",
|
|
349
|
+
TRANSACTION_NOT_PENDING = "TRANSACTION_NOT_PENDING",
|
|
350
|
+
WALLET_NOT_AVAILABLE = "WALLET_NOT_AVAILABLE",
|
|
351
|
+
WEBAUTHN_OPERATION_IN_PROGRESS = "WEBAUTHN_OPERATION_IN_PROGRESS",
|
|
352
|
+
SIGNING_CANCELLED = "SIGNING_CANCELLED",
|
|
353
|
+
PERS_AUTH_FAILED = "PERS_AUTH_FAILED",
|
|
354
|
+
AUTH_FAILED = "AUTH_FAILED",
|
|
355
|
+
TRANSACTION_NOT_READY = "TRANSACTION_NOT_READY",
|
|
356
|
+
SUBMISSION_FAILED = "SUBMISSION_FAILED",
|
|
357
|
+
SERVER_ERROR = "SERVER_ERROR",
|
|
358
|
+
UNKNOWN_ERROR = "UNKNOWN_ERROR"
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* Structured error for transaction signing operations
|
|
362
|
+
*/
|
|
363
|
+
interface TransactionSigningError extends Error {
|
|
364
|
+
code: TransactionSigningErrorCode;
|
|
365
|
+
transactionId?: string;
|
|
366
|
+
originalError?: unknown;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
/**
|
|
370
|
+
* Central type definitions for the blockchain signer shared library
|
|
371
|
+
* Single source of truth for all type exports
|
|
372
|
+
*/
|
|
373
|
+
|
|
374
|
+
/**
|
|
375
|
+
* Authentication types for 3-function split architecture
|
|
376
|
+
*/
|
|
377
|
+
interface AuthenticatedUser {
|
|
378
|
+
identifier: string;
|
|
379
|
+
signerAuthToken: string;
|
|
380
|
+
persAccessToken: string;
|
|
381
|
+
expiresAt: number;
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* Error types for service operations
|
|
385
|
+
*/
|
|
386
|
+
interface ServiceError {
|
|
387
|
+
code: string;
|
|
388
|
+
message: string;
|
|
389
|
+
details?: any;
|
|
390
|
+
timestamp: Date;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
/**
|
|
394
|
+
* Wallet management service
|
|
395
|
+
* Updated for v1 API endpoints per migration reference
|
|
396
|
+
*/
|
|
397
|
+
declare class WalletService {
|
|
398
|
+
/**
|
|
399
|
+
* List all wallets for authenticated user
|
|
400
|
+
* @param signerToken - Signer JWT token
|
|
401
|
+
* @returns Promise resolving to wallet data
|
|
402
|
+
*/
|
|
403
|
+
static listWallets(signerToken: string): Promise<unknown>;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
/**
|
|
407
|
+
* Service for interacting with PERS (Phygital Experience Rewards System) backend API
|
|
334
408
|
*/
|
|
335
|
-
interface UserCredentials {
|
|
336
|
-
username: string;
|
|
337
|
-
appId?: string;
|
|
338
|
-
}
|
|
339
409
|
/**
|
|
340
|
-
*
|
|
410
|
+
* Configuration interface for PERS API
|
|
341
411
|
*/
|
|
342
|
-
interface
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
412
|
+
interface PersApiConfig {
|
|
413
|
+
baseUrl: string;
|
|
414
|
+
projectKey?: string;
|
|
415
|
+
}
|
|
416
|
+
declare class PersService {
|
|
417
|
+
private static config;
|
|
418
|
+
private static tenantCache;
|
|
419
|
+
private static currentProjectKey;
|
|
420
|
+
private static currentTenantId;
|
|
421
|
+
private static useStaging;
|
|
422
|
+
private static readonly TENANT_CACHE_TTL;
|
|
423
|
+
/**
|
|
424
|
+
* Configure the PERS API settings
|
|
425
|
+
* @param config - The configuration object
|
|
426
|
+
*/
|
|
427
|
+
static configure(config: Partial<PersApiConfig>): void;
|
|
428
|
+
/**
|
|
429
|
+
* Enable staging mode when project key is not available
|
|
430
|
+
* @param enableStaging Whether to use staging environment
|
|
431
|
+
*/
|
|
432
|
+
static setStagingMode(enableStaging: boolean): void;
|
|
433
|
+
/**
|
|
434
|
+
* Get current configuration
|
|
435
|
+
*/
|
|
436
|
+
static getConfig(): PersApiConfig;
|
|
437
|
+
/**
|
|
438
|
+
* Get tenant information by tenant ID
|
|
439
|
+
* @param tenantId - The tenant ID to retrieve
|
|
440
|
+
* @param authToken - Optional auth token for authentication
|
|
441
|
+
* @returns Promise with tenant public information
|
|
442
|
+
*/
|
|
443
|
+
static getTenantById(tenantId: string, authToken?: string): Promise<TenantPublicDTO>;
|
|
444
|
+
/**
|
|
445
|
+
* Initialize tenant configuration from JWT
|
|
446
|
+
* @param tenantId - The tenant ID from JWT payload
|
|
447
|
+
* @param authToken - Optional auth token for authentication
|
|
448
|
+
* @returns Promise with tenant information
|
|
449
|
+
*/
|
|
450
|
+
static initializeTenant(tenantId: string, authToken?: string): Promise<TenantPublicDTO>;
|
|
451
|
+
/**
|
|
452
|
+
* Ensure tenant is initialized and current, with automatic revalidation
|
|
453
|
+
* @param tenantId - The tenant ID to ensure is initialized
|
|
454
|
+
* @param authToken - Optional auth token for authentication
|
|
455
|
+
* @returns Promise with tenant information
|
|
456
|
+
*/
|
|
457
|
+
static ensureTenantInitialized(tenantId: string, authToken?: string): Promise<TenantPublicDTO>;
|
|
458
|
+
/**
|
|
459
|
+
* Get the current project key (either from tenant or fallback)
|
|
460
|
+
* @param tenantId - Optional tenant ID to ensure is initialized
|
|
461
|
+
* @returns The project key to use for API calls
|
|
462
|
+
*/
|
|
463
|
+
private static getProjectKey;
|
|
464
|
+
/**
|
|
465
|
+
* Clear tenant cache and reset project key
|
|
466
|
+
*/
|
|
467
|
+
static clearTenantCache(): void;
|
|
468
|
+
/**
|
|
469
|
+
* Authenticates a user with the PERS backend using their auth token
|
|
470
|
+
*
|
|
471
|
+
* @param authToken - The authentication token received from DFNS after login/registration
|
|
472
|
+
* @param tenantId - Optional tenant ID for automatic initialization
|
|
473
|
+
* @returns A promise that resolves to the authentication response
|
|
474
|
+
* @throws If the request fails
|
|
475
|
+
*/
|
|
476
|
+
static authenticateUser(authToken: string, tenantId: string): Promise<SessionAuthContextResponseDTO>;
|
|
477
|
+
/**
|
|
478
|
+
* Submits a transaction by calling the backend endpoint
|
|
479
|
+
*
|
|
480
|
+
* @param transactionId - The ID of the transaction to submit
|
|
481
|
+
* @param signedTransactionOrSignature - The signed transaction data or EIP-712 signature
|
|
482
|
+
* @param persAccessToken - The PERS access token for authentication (Bearer)
|
|
483
|
+
* @param submissionType - The transaction format type
|
|
484
|
+
* @param tenantId - Optional tenant ID for automatic initialization
|
|
485
|
+
* @returns A promise that resolves to the transaction submission response
|
|
486
|
+
* @throws If the request fails
|
|
487
|
+
*/
|
|
488
|
+
static submitTransaction(transactionId: string, signedTransactionOrSignature: string, persAccessToken: string, submissionType: TransactionFormat, tenantId: string): Promise<TransactionRequestResponseDTO>;
|
|
489
|
+
/**
|
|
490
|
+
* Fetches a prepared transaction for signing by transactionId
|
|
491
|
+
* @param transactionId - The transaction ID to fetch
|
|
492
|
+
* @param persAccessToken - The PERS access token for authentication (Bearer)
|
|
493
|
+
* @param tenantId - Optional tenant ID for automatic initialization
|
|
494
|
+
* @returns The prepared transaction data
|
|
495
|
+
* @throws If the request fails
|
|
496
|
+
*/
|
|
497
|
+
static fetchPreparedTransaction(transactionId: string, persAccessToken: string, tenantId: string): Promise<TransactionRequestResponseDTO>;
|
|
498
|
+
/**
|
|
499
|
+
* Helper method to determine if transaction data is available for signing
|
|
500
|
+
* @param transactionResponse - Response from prepare or fetch transaction
|
|
501
|
+
* @returns boolean indicating if transaction can be signed
|
|
502
|
+
*/
|
|
503
|
+
static isTransactionReadyForSigning(transactionResponse: TransactionRequestResponseDTO): boolean;
|
|
504
|
+
/**
|
|
505
|
+
* Helper method to get transaction data from response
|
|
506
|
+
* @param transactionResponse - Response from prepare or fetch transaction
|
|
507
|
+
* @returns The transaction data ready for signing
|
|
508
|
+
* @throws If transaction data is not available
|
|
509
|
+
*/
|
|
510
|
+
static getTransactionDataForSigning(transactionResponse: TransactionRequestResponseDTO): _explorins_pers_shared_browser.CounterfactualWalletTransactionResponse | _explorins_web3_ts_types.LegacyTransaction;
|
|
346
511
|
}
|
|
347
512
|
|
|
348
513
|
/**
|
|
@@ -389,39 +554,6 @@ declare class SigningService {
|
|
|
389
554
|
signBatch(authToken: string, walletId: string, requests: SigningRequest[]): Promise<CompleteSignatureResponse['data'][]>;
|
|
390
555
|
}
|
|
391
556
|
|
|
392
|
-
/**
|
|
393
|
-
* Shared type definitions for the blockchain signer shared library
|
|
394
|
-
*/
|
|
395
|
-
|
|
396
|
-
/**
|
|
397
|
-
* Authentication types for 3-function split architecture
|
|
398
|
-
*/
|
|
399
|
-
interface AuthenticatedUser {
|
|
400
|
-
identifier: string;
|
|
401
|
-
signerAuthToken: string;
|
|
402
|
-
persAccessToken: string;
|
|
403
|
-
tenantId: string;
|
|
404
|
-
expiresAt: number;
|
|
405
|
-
}
|
|
406
|
-
/**
|
|
407
|
-
* Service configuration options
|
|
408
|
-
*/
|
|
409
|
-
interface ServiceConfig {
|
|
410
|
-
apiUrl: string;
|
|
411
|
-
environment: 'development' | 'staging' | 'production';
|
|
412
|
-
timeout?: number;
|
|
413
|
-
retryAttempts?: number;
|
|
414
|
-
}
|
|
415
|
-
/**
|
|
416
|
-
* Error types for service operations
|
|
417
|
-
*/
|
|
418
|
-
interface ServiceError {
|
|
419
|
-
code: string;
|
|
420
|
-
message: string;
|
|
421
|
-
details?: any;
|
|
422
|
-
timestamp: Date;
|
|
423
|
-
}
|
|
424
|
-
|
|
425
557
|
interface GetWalletResponse {
|
|
426
558
|
id: string;
|
|
427
559
|
signingKey: {
|
|
@@ -459,66 +591,6 @@ declare class KeyWallet extends AbstractSigner {
|
|
|
459
591
|
signPersTransaction(transactionData: AnyTransactionData): Promise<string>;
|
|
460
592
|
}
|
|
461
593
|
|
|
462
|
-
/**
|
|
463
|
-
* Combined transaction status type that includes both PERS and additional statuses
|
|
464
|
-
*/
|
|
465
|
-
type CombinedTransactionStatus = TransactionStatus;
|
|
466
|
-
/**
|
|
467
|
-
* Transaction statuses that allow signing
|
|
468
|
-
*/
|
|
469
|
-
declare const SIGNABLE_STATUSES: readonly [TransactionStatus.PENDING_SIGNATURE, TransactionStatus.CREATED];
|
|
470
|
-
/**
|
|
471
|
-
* Transaction status information for UI display
|
|
472
|
-
*/
|
|
473
|
-
interface TransactionStatusInfo {
|
|
474
|
-
transactionId: string;
|
|
475
|
-
transactionStatus: CombinedTransactionStatus;
|
|
476
|
-
message: string;
|
|
477
|
-
}
|
|
478
|
-
/**
|
|
479
|
-
* Transaction signing result
|
|
480
|
-
*/
|
|
481
|
-
interface TransactionSigningResult {
|
|
482
|
-
success: boolean;
|
|
483
|
-
transactionId: string;
|
|
484
|
-
signature?: string;
|
|
485
|
-
signingData?: CounterfactualWalletTransactionResponse | LegacyTransaction;
|
|
486
|
-
error?: string;
|
|
487
|
-
statusInfo?: TransactionStatusInfo;
|
|
488
|
-
shouldShowStatus?: boolean;
|
|
489
|
-
}
|
|
490
|
-
/**
|
|
491
|
-
* Transaction submission result for internal processing
|
|
492
|
-
*/
|
|
493
|
-
interface SubmissionResult {
|
|
494
|
-
submitResult: TransactionRequestResponseDTO;
|
|
495
|
-
shouldRedirect: boolean;
|
|
496
|
-
redirectUrl?: string;
|
|
497
|
-
transactionHash: string | null;
|
|
498
|
-
success: boolean;
|
|
499
|
-
error?: string;
|
|
500
|
-
}
|
|
501
|
-
/**
|
|
502
|
-
* Metadata for transaction parameters - string values only
|
|
503
|
-
*/
|
|
504
|
-
/**
|
|
505
|
-
* Authentication tokens required for transaction signing
|
|
506
|
-
*/
|
|
507
|
-
interface SigningAuthTokens {
|
|
508
|
-
signerAuthToken: string;
|
|
509
|
-
persAccessToken: string;
|
|
510
|
-
}
|
|
511
|
-
/**
|
|
512
|
-
* Transaction signing parameters
|
|
513
|
-
*/
|
|
514
|
-
interface TransactionSigningParams {
|
|
515
|
-
transactionId: string;
|
|
516
|
-
tenantId: string;
|
|
517
|
-
authTokens: SigningAuthTokens;
|
|
518
|
-
ethersProviderUrl: string;
|
|
519
|
-
returnUrl?: string;
|
|
520
|
-
}
|
|
521
|
-
|
|
522
594
|
/**
|
|
523
595
|
* Service for orchestrating transaction signing operations
|
|
524
596
|
* Handles the complete flow from transaction preparation to submission
|
|
@@ -526,7 +598,7 @@ interface TransactionSigningParams {
|
|
|
526
598
|
*/
|
|
527
599
|
declare class TransactionSigningService {
|
|
528
600
|
private webAuthnProvider;
|
|
529
|
-
constructor(config:
|
|
601
|
+
constructor(config: ExtendedPersSignerConfig);
|
|
530
602
|
/**
|
|
531
603
|
* Prepare transaction for signing - fetch and validate
|
|
532
604
|
*/
|
|
@@ -554,32 +626,6 @@ declare class TransactionSigningService {
|
|
|
554
626
|
signTransaction(params: TransactionSigningParams, signingData: CounterfactualWalletTransactionResponse | LegacyTransaction): Promise<TransactionSigningResult>;
|
|
555
627
|
}
|
|
556
628
|
|
|
557
|
-
/**
|
|
558
|
-
* Error codes for transaction signing operations
|
|
559
|
-
*/
|
|
560
|
-
declare enum TransactionSigningErrorCode {
|
|
561
|
-
INVALID_TOKENS = "INVALID_TOKENS",
|
|
562
|
-
TRANSACTION_NOT_FOUND = "TRANSACTION_NOT_FOUND",
|
|
563
|
-
TRANSACTION_NOT_PENDING = "TRANSACTION_NOT_PENDING",
|
|
564
|
-
WALLET_NOT_AVAILABLE = "WALLET_NOT_AVAILABLE",
|
|
565
|
-
WEBAUTHN_OPERATION_IN_PROGRESS = "WEBAUTHN_OPERATION_IN_PROGRESS",
|
|
566
|
-
SIGNING_CANCELLED = "SIGNING_CANCELLED",
|
|
567
|
-
PERS_AUTH_FAILED = "PERS_AUTH_FAILED",
|
|
568
|
-
AUTH_FAILED = "AUTH_FAILED",
|
|
569
|
-
TRANSACTION_NOT_READY = "TRANSACTION_NOT_READY",
|
|
570
|
-
SUBMISSION_FAILED = "SUBMISSION_FAILED",
|
|
571
|
-
SERVER_ERROR = "SERVER_ERROR",
|
|
572
|
-
UNKNOWN_ERROR = "UNKNOWN_ERROR"
|
|
573
|
-
}
|
|
574
|
-
/**
|
|
575
|
-
* Structured error for transaction signing operations
|
|
576
|
-
*/
|
|
577
|
-
interface TransactionSigningError extends Error {
|
|
578
|
-
code: TransactionSigningErrorCode;
|
|
579
|
-
transactionId?: string;
|
|
580
|
-
originalError?: unknown;
|
|
581
|
-
}
|
|
582
|
-
|
|
583
629
|
/**
|
|
584
630
|
* Handles all error-related operations for transaction signing
|
|
585
631
|
*/
|
|
@@ -828,13 +874,14 @@ declare function getHttpClient(): HttpClient;
|
|
|
828
874
|
* @property {string} [apiUrl] - Custom API base URL (defaults to production)
|
|
829
875
|
* @property {string} [relyingPartyName] - WebAuthn relying party name for authentication
|
|
830
876
|
*/
|
|
831
|
-
interface
|
|
832
|
-
tenantId?: string;
|
|
877
|
+
interface ExtendedPersSignerConfig {
|
|
833
878
|
ethersProviderUrl?: string;
|
|
834
879
|
webAuthnProvider: WebAuthnProvider;
|
|
835
880
|
apiUrl?: string;
|
|
836
881
|
relyingPartyName?: string;
|
|
837
882
|
}
|
|
883
|
+
interface PersSignerConfig extends Omit<ExtendedPersSignerConfig, 'webAuthnProvider'> {
|
|
884
|
+
}
|
|
838
885
|
/**
|
|
839
886
|
* PERS Blockchain Signer SDK Class
|
|
840
887
|
*
|
|
@@ -857,10 +904,10 @@ declare class PersSignerSDK {
|
|
|
857
904
|
/**
|
|
858
905
|
* Initialize the PERS Signer SDK
|
|
859
906
|
*
|
|
860
|
-
* @param {
|
|
907
|
+
* @param {ExtendedPersSignerConfig} config - SDK configuration object
|
|
861
908
|
* @throws {Error} If required configuration is missing
|
|
862
909
|
*/
|
|
863
|
-
constructor(config:
|
|
910
|
+
constructor(config: ExtendedPersSignerConfig);
|
|
864
911
|
/**
|
|
865
912
|
* Authenticate user and cache session for 5 minutes
|
|
866
913
|
*
|
|
@@ -1010,38 +1057,8 @@ declare class PersSignerSDK {
|
|
|
1010
1057
|
* });
|
|
1011
1058
|
* ```
|
|
1012
1059
|
*/
|
|
1013
|
-
declare function createPersSignerSDK(config:
|
|
1014
|
-
|
|
1015
|
-
/**
|
|
1016
|
-
* Wallet list response from WalletService
|
|
1017
|
-
*/
|
|
1018
|
-
interface WalletListResponse {
|
|
1019
|
-
items: WalletItem[];
|
|
1020
|
-
}
|
|
1021
|
-
/**
|
|
1022
|
-
* Individual wallet item from wallet list - compatible with KeyWallet constructor
|
|
1023
|
-
*/
|
|
1024
|
-
interface WalletItem {
|
|
1025
|
-
id: string;
|
|
1026
|
-
address: string;
|
|
1027
|
-
network: string;
|
|
1028
|
-
status: string;
|
|
1029
|
-
signingKey?: unknown;
|
|
1030
|
-
dateCreated?: string;
|
|
1031
|
-
custodial?: boolean;
|
|
1032
|
-
tags?: string[];
|
|
1033
|
-
boundToEvmNetwork?: boolean;
|
|
1034
|
-
[key: string]: unknown;
|
|
1035
|
-
}
|
|
1060
|
+
declare function createPersSignerSDK(config: ExtendedPersSignerConfig): PersSignerSDK;
|
|
1036
1061
|
|
|
1037
|
-
/**
|
|
1038
|
-
* Authenticated user with all required tokens
|
|
1039
|
-
*/
|
|
1040
|
-
interface SignerAuthenticatedUser {
|
|
1041
|
-
identifier: string;
|
|
1042
|
-
signerAuthToken: string;
|
|
1043
|
-
persAccessToken: string;
|
|
1044
|
-
}
|
|
1045
1062
|
/**
|
|
1046
1063
|
* Authentication service for user login and registration
|
|
1047
1064
|
* Uses constructor-based dependency injection for WebAuthn provider
|
|
@@ -1051,7 +1068,7 @@ declare class AuthenticationService {
|
|
|
1051
1068
|
private signerToken;
|
|
1052
1069
|
private config;
|
|
1053
1070
|
private webAuthnProvider;
|
|
1054
|
-
constructor(config:
|
|
1071
|
+
constructor(config: ExtendedPersSignerConfig);
|
|
1055
1072
|
/**
|
|
1056
1073
|
* Login with PERS token to get signer JWT
|
|
1057
1074
|
* @param persToken - PERS JWT from PERS authentication
|
|
@@ -1096,7 +1113,7 @@ declare class AuthenticationService {
|
|
|
1096
1113
|
* @param relyingPartyConfig - Configuration for WebAuthn relying party
|
|
1097
1114
|
* @returns Promise resolving to authenticated user with signer token
|
|
1098
1115
|
*/
|
|
1099
|
-
combinedAuthentication(identifier: string, persAccessToken: string): Promise<
|
|
1116
|
+
combinedAuthentication(identifier: string, persAccessToken: string): Promise<AuthenticatedUser>;
|
|
1100
1117
|
}
|
|
1101
1118
|
|
|
1102
1119
|
/**
|
|
@@ -1209,4 +1226,4 @@ declare class UserCache {
|
|
|
1209
1226
|
}
|
|
1210
1227
|
|
|
1211
1228
|
export { AuthenticationService, FetchHttpClient, HealthService, KeyWallet, PersService, PersSignerSDK, ReactNativeConfigProvider, SIGNABLE_STATUSES, SigningService, StaticConfigProvider, TransactionErrorHandler, TransactionSigningErrorCode, TransactionSigningService, TransactionSubmissionHandler, TransactionValidator, UserCache, WalletService, WebAuthnCoordinator, WebConfigProvider, createPersSignerSDK, extractJWTFromToken, getBrowserWebAuthnProvider, getConfigProvider, getHttpClient, getJWTPayload, getReactNativeWebAuthnProvider, getServiceConfig, isJWTExpired, setConfigProvider, setHttpClient };
|
|
1212
|
-
export type { AuthResponse, AuthenticatedUser, CombinedTransactionStatus, ConfigProvider, HashSigningRequest, HttpClient, HttpRequestOptions, HttpResponse, JWTExtractionResult, JWTPayload, ListWalletsRequest, ListWalletsResponse, LoginRequest, LoginResponse, PersSignerConfig, RegistrationChallenge, RegistrationResult, RelyingPartyConfig,
|
|
1229
|
+
export type { AuthResponse, AuthenticatedUser, CombinedTransactionStatus, CompleteRegistrationResponse, CompleteSignatureRequest, CompleteSignatureResponse, ConfigProvider, HashSigningRequest, HealthCheckResponse, HttpClient, HttpRequestOptions, HttpResponse, InitRegistrationRequest, InitRegistrationResponse, InitSignatureRequest, InitSignatureResponse, JWTExtractionResult, JWTPayload, ListWalletsRequest, ListWalletsResponse, LoginRequest, LoginResponse, PersSignerConfig, RegistrationChallenge, RegistrationResult, RelyingPartyConfig, ServiceError, SignResponse, SignerApiError, SignerApiResponse, SigningAuthTokens, SigningChallenge, SigningRequest, SubmissionResult, TransactionSigningError, TransactionSigningParams, TransactionSigningResult, TransactionStatusInfo, TypedDataSigningRequest, UserCredentials, VerifyTokenRequest, VerifyTokenResponse, WalletItem, WalletListResponse, WebAuthnConfig, WebAuthnProvider };
|