@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/index.d.ts
CHANGED
|
@@ -1,256 +1,167 @@
|
|
|
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, TransactionStatus, CounterfactualWalletTransactionResponse } from '@explorins/pers-shared/browser';
|
|
6
6
|
export { TransactionFormat, TransactionRequestResponseDTO, TransactionStatus } from '@explorins/pers-shared/browser';
|
|
7
|
+
import { CounterfactualWalletTransactionResponse as CounterfactualWalletTransactionResponse$1 } from '@explorins/pers-shared';
|
|
7
8
|
import { AbstractSigner, Provider, TransactionRequest, TypedDataDomain, TypedDataField } from 'ethers';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
|
-
*
|
|
11
|
+
* Type definitions for the new PERS Signer API v1
|
|
12
|
+
* Based on API_MIGRATION_REFERENCE.md - Updated for wrapped responses
|
|
11
13
|
*/
|
|
12
|
-
interface
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
interface SignerApiResponse<T = unknown> {
|
|
15
|
+
success: boolean;
|
|
16
|
+
data?: T;
|
|
15
17
|
}
|
|
16
|
-
interface
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
interface SignerApiError {
|
|
19
|
+
status: number;
|
|
20
|
+
error: string;
|
|
21
|
+
message: string;
|
|
22
|
+
request_id: string;
|
|
23
|
+
timestamp: string;
|
|
24
|
+
suggestion?: {
|
|
25
|
+
action: string;
|
|
26
|
+
text: string;
|
|
27
|
+
endpoint: string;
|
|
21
28
|
};
|
|
22
29
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
appId: string;
|
|
36
|
-
};
|
|
37
|
-
requestBody: {
|
|
38
|
-
hash: string;
|
|
39
|
-
kind: "Hash";
|
|
30
|
+
interface LoginRequest {
|
|
31
|
+
authToken: string;
|
|
32
|
+
}
|
|
33
|
+
interface JWTLoginResponse {
|
|
34
|
+
success: true;
|
|
35
|
+
access_token: string;
|
|
36
|
+
token_type: "Bearer";
|
|
37
|
+
expires_in: number;
|
|
38
|
+
user: {
|
|
39
|
+
id: string;
|
|
40
|
+
username: string;
|
|
41
|
+
org_id: string;
|
|
40
42
|
};
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
provider: string;
|
|
44
|
+
}
|
|
45
|
+
interface WrappedProviderResponse {
|
|
46
|
+
success: true;
|
|
47
|
+
data: unknown;
|
|
48
|
+
}
|
|
49
|
+
type LoginResponse = JWTLoginResponse | WrappedProviderResponse;
|
|
50
|
+
interface VerifyTokenResponse {
|
|
51
|
+
valid: boolean;
|
|
52
|
+
provider: string;
|
|
53
|
+
claims: {
|
|
54
|
+
sub: string;
|
|
55
|
+
iss: string;
|
|
56
|
+
aud: string;
|
|
57
|
+
exp: number;
|
|
58
|
+
iat: number;
|
|
59
|
+
user_id: string;
|
|
60
|
+
username: string;
|
|
61
|
+
org_id: string;
|
|
62
|
+
provider: string;
|
|
63
|
+
permissions: unknown;
|
|
46
64
|
};
|
|
47
|
-
|
|
48
|
-
dateRequested: string;
|
|
49
|
-
dateSigned: string;
|
|
50
|
-
walletId: string;
|
|
65
|
+
tenantId: string;
|
|
51
66
|
}
|
|
52
|
-
|
|
53
|
-
* Authentication response from login/register operations
|
|
54
|
-
*/
|
|
55
|
-
interface AuthResponse {
|
|
56
|
-
token: string;
|
|
57
|
-
message?: string;
|
|
58
|
-
status?: number;
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Registration challenge response
|
|
62
|
-
*/
|
|
63
|
-
interface RegistrationChallenge {
|
|
64
|
-
temporaryAuthenticationToken: string;
|
|
65
|
-
challenge: any;
|
|
66
|
-
status?: number;
|
|
67
|
-
message?: string;
|
|
67
|
+
interface ListWalletsRequest {
|
|
68
68
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
status?: number;
|
|
76
|
-
message?: string;
|
|
69
|
+
interface ListWalletsResponse {
|
|
70
|
+
success: true;
|
|
71
|
+
data: {
|
|
72
|
+
wallets?: Array<unknown>;
|
|
73
|
+
[key: string]: unknown;
|
|
74
|
+
};
|
|
77
75
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
76
|
+
interface CompleteSignatureResponse {
|
|
77
|
+
success: true;
|
|
78
|
+
data: {
|
|
79
|
+
signature?: {
|
|
80
|
+
r: string;
|
|
81
|
+
s: string;
|
|
82
|
+
recid: number;
|
|
83
|
+
encoded: string;
|
|
84
|
+
} | string;
|
|
85
|
+
transaction?: unknown;
|
|
86
|
+
dateRequested?: string;
|
|
87
|
+
dateSigned?: string;
|
|
88
|
+
id?: string;
|
|
89
|
+
keyId?: string;
|
|
90
|
+
network?: string;
|
|
91
|
+
requestBody?: {
|
|
92
|
+
kind?: 'Eip712' | 'Hash' | string;
|
|
93
|
+
blockchainKind?: string;
|
|
94
|
+
[key: string]: unknown;
|
|
95
|
+
};
|
|
96
|
+
requester?: unknown;
|
|
97
|
+
status?: string;
|
|
98
|
+
walletId?: string;
|
|
99
|
+
[key: string]: unknown;
|
|
100
|
+
};
|
|
85
101
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
*/
|
|
89
|
-
interface WalletItem$1 {
|
|
90
|
-
id: string;
|
|
91
|
-
address: string;
|
|
92
|
-
network: string;
|
|
93
|
-
status: string;
|
|
94
|
-
signingKey?: unknown;
|
|
95
|
-
dateCreated?: string;
|
|
96
|
-
custodial?: boolean;
|
|
97
|
-
tags?: string[];
|
|
98
|
-
boundToEvmNetwork?: boolean;
|
|
99
|
-
[key: string]: unknown;
|
|
102
|
+
interface HealthCheckResponse {
|
|
103
|
+
success: boolean;
|
|
100
104
|
}
|
|
105
|
+
|
|
101
106
|
/**
|
|
102
|
-
*
|
|
107
|
+
* Types for WebAuthn provider abstraction
|
|
103
108
|
*/
|
|
104
|
-
interface
|
|
105
|
-
|
|
106
|
-
|
|
109
|
+
interface WebAuthnProvider {
|
|
110
|
+
create(challenge: any): Promise<any>;
|
|
111
|
+
sign(challenge: any): Promise<any>;
|
|
107
112
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
types: Record<string, any[]>;
|
|
115
|
-
domain: any;
|
|
116
|
-
message: Record<string, any>;
|
|
113
|
+
interface WebAuthnConfig {
|
|
114
|
+
relyingParty: {
|
|
115
|
+
id: string;
|
|
116
|
+
name: string;
|
|
117
|
+
origin?: string;
|
|
118
|
+
};
|
|
117
119
|
}
|
|
120
|
+
|
|
118
121
|
/**
|
|
119
|
-
*
|
|
122
|
+
* Shared type definitions for the blockchain signer shared library
|
|
120
123
|
*/
|
|
121
|
-
|
|
124
|
+
|
|
122
125
|
/**
|
|
123
|
-
*
|
|
126
|
+
* Authentication types for 3-function split architecture
|
|
124
127
|
*/
|
|
125
|
-
interface
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
status?: number;
|
|
132
|
-
message?: string;
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* User credentials for authentication
|
|
136
|
-
*/
|
|
137
|
-
interface UserCredentials {
|
|
138
|
-
username: string;
|
|
139
|
-
appId?: string;
|
|
128
|
+
interface AuthenticatedUser {
|
|
129
|
+
identifier: string;
|
|
130
|
+
signerAuthToken: string;
|
|
131
|
+
persAccessToken: string;
|
|
132
|
+
tenantId: string;
|
|
133
|
+
expiresAt: number;
|
|
140
134
|
}
|
|
141
135
|
/**
|
|
142
|
-
*
|
|
136
|
+
* Service configuration options
|
|
143
137
|
*/
|
|
144
|
-
interface
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
138
|
+
interface ServiceConfig {
|
|
139
|
+
apiUrl: string;
|
|
140
|
+
environment: 'development' | 'staging' | 'production';
|
|
141
|
+
timeout?: number;
|
|
142
|
+
retryAttempts?: number;
|
|
148
143
|
}
|
|
149
|
-
|
|
150
144
|
/**
|
|
151
|
-
*
|
|
152
|
-
* Uses constructor-based dependency injection for WebAuthn provider
|
|
145
|
+
* Error types for service operations
|
|
153
146
|
*/
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
* @param username - User identifier
|
|
160
|
-
* @returns Promise resolving to authentication token
|
|
161
|
-
*/
|
|
162
|
-
login(username: string): Promise<string>;
|
|
163
|
-
/**
|
|
164
|
-
* Register new user with WebAuthn credential
|
|
165
|
-
* @param username - User identifier
|
|
166
|
-
* @returns Promise resolving to registration result
|
|
167
|
-
*/
|
|
168
|
-
register(username: string): Promise<RegistrationResult>;
|
|
169
|
-
/**
|
|
170
|
-
* Validate authentication token (when backend supports it)
|
|
171
|
-
* @param authToken - Token to validate
|
|
172
|
-
* @returns Promise resolving to validation result
|
|
173
|
-
*/
|
|
174
|
-
validateToken(authToken: string): Promise<boolean>;
|
|
175
|
-
/**
|
|
176
|
-
* Get user information (when backend supports it)
|
|
177
|
-
* @param authToken - Authentication token
|
|
178
|
-
* @returns Promise resolving to user info or null
|
|
179
|
-
*/
|
|
180
|
-
getUser(authToken: string): Promise<{
|
|
181
|
-
username: string;
|
|
182
|
-
} | null>;
|
|
147
|
+
interface ServiceError {
|
|
148
|
+
code: string;
|
|
149
|
+
message: string;
|
|
150
|
+
details?: any;
|
|
151
|
+
timestamp: Date;
|
|
183
152
|
}
|
|
184
153
|
|
|
185
154
|
/**
|
|
186
155
|
* Wallet management service
|
|
187
|
-
*
|
|
156
|
+
* Updated for v1 API endpoints per migration reference
|
|
188
157
|
*/
|
|
189
158
|
declare class WalletService {
|
|
190
159
|
/**
|
|
191
160
|
* List all wallets for authenticated user
|
|
192
|
-
* @param
|
|
193
|
-
* @returns Promise resolving to wallet
|
|
161
|
+
* @param signerToken - Signer JWT token
|
|
162
|
+
* @returns Promise resolving to wallet data
|
|
194
163
|
*/
|
|
195
|
-
static listWallets(
|
|
196
|
-
/**
|
|
197
|
-
* Get wallet by ID (when backend supports it)
|
|
198
|
-
* @param authToken - Authentication token
|
|
199
|
-
* @param walletId - Wallet identifier
|
|
200
|
-
* @returns Promise resolving to wallet details
|
|
201
|
-
*/
|
|
202
|
-
static getWallet(authToken: string, walletId: string): Promise<any>;
|
|
203
|
-
/**
|
|
204
|
-
* Create new wallet (when backend supports it)
|
|
205
|
-
* @param authToken - Authentication token
|
|
206
|
-
* @param walletConfig - Wallet configuration
|
|
207
|
-
* @returns Promise resolving to wallet creation result
|
|
208
|
-
*/
|
|
209
|
-
static createWallet(authToken: string, walletConfig: any): Promise<any>;
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
/**
|
|
213
|
-
* Signing service for cryptographic operations
|
|
214
|
-
* Handles hash signing and typed data signing with WebAuthn
|
|
215
|
-
* Uses constructor-based dependency injection for WebAuthn provider
|
|
216
|
-
*/
|
|
217
|
-
declare class SigningService {
|
|
218
|
-
private webAuthnProvider;
|
|
219
|
-
constructor(webAuthnProvider: WebAuthnProvider);
|
|
220
|
-
/**
|
|
221
|
-
* Sign a hash using the specified wallet
|
|
222
|
-
* @param authToken - Authentication token
|
|
223
|
-
* @param walletId - Wallet identifier
|
|
224
|
-
* @param hash - Hash to sign
|
|
225
|
-
* @returns Promise resolving to signature response
|
|
226
|
-
*/
|
|
227
|
-
signHash(authToken: string, walletId: string, hash: string): Promise<SignResponse>;
|
|
228
|
-
/**
|
|
229
|
-
* Sign EIP-712 typed data using the specified wallet
|
|
230
|
-
* @param authToken - Authentication token
|
|
231
|
-
* @param walletId - Wallet identifier
|
|
232
|
-
* @param domain - EIP-712 domain
|
|
233
|
-
* @param types - EIP-712 types definition
|
|
234
|
-
* @param value - Data to sign
|
|
235
|
-
* @returns Promise resolving to signature response
|
|
236
|
-
*/
|
|
237
|
-
signTypedData(authToken: string, walletId: string, domain: any, types: Record<string, any[]>, value: Record<string, any>): Promise<SignResponse>;
|
|
238
|
-
/**
|
|
239
|
-
* Generic signing method that handles the complete signing flow
|
|
240
|
-
* @param authToken - Authentication token
|
|
241
|
-
* @param walletId - Wallet identifier
|
|
242
|
-
* @param request - Signing request object
|
|
243
|
-
* @returns Promise resolving to signature response
|
|
244
|
-
*/
|
|
245
|
-
private signRequest;
|
|
246
|
-
/**
|
|
247
|
-
* Sign multiple requests in batch (when backend supports it)
|
|
248
|
-
* @param authToken - Authentication token
|
|
249
|
-
* @param walletId - Wallet identifier
|
|
250
|
-
* @param requests - Array of signing requests
|
|
251
|
-
* @returns Promise resolving to array of signature responses
|
|
252
|
-
*/
|
|
253
|
-
signBatch(authToken: string, walletId: string, requests: SigningRequest[]): Promise<SignResponse[]>;
|
|
164
|
+
static listWallets(signerToken: string): Promise<unknown>;
|
|
254
165
|
}
|
|
255
166
|
|
|
256
167
|
/**
|
|
@@ -267,7 +178,9 @@ declare class PersService {
|
|
|
267
178
|
private static config;
|
|
268
179
|
private static tenantCache;
|
|
269
180
|
private static currentProjectKey;
|
|
181
|
+
private static currentTenantId;
|
|
270
182
|
private static useStaging;
|
|
183
|
+
private static readonly TENANT_CACHE_TTL;
|
|
271
184
|
/**
|
|
272
185
|
* Configure the PERS API settings
|
|
273
186
|
* @param config - The configuration object
|
|
@@ -296,8 +209,16 @@ declare class PersService {
|
|
|
296
209
|
* @returns Promise with tenant information
|
|
297
210
|
*/
|
|
298
211
|
static initializeTenant(tenantId: string, authToken?: string): Promise<TenantPublicDTO>;
|
|
212
|
+
/**
|
|
213
|
+
* Ensure tenant is initialized and current, with automatic revalidation
|
|
214
|
+
* @param tenantId - The tenant ID to ensure is initialized
|
|
215
|
+
* @param authToken - Optional auth token for authentication
|
|
216
|
+
* @returns Promise with tenant information
|
|
217
|
+
*/
|
|
218
|
+
static ensureTenantInitialized(tenantId: string, authToken?: string): Promise<TenantPublicDTO>;
|
|
299
219
|
/**
|
|
300
220
|
* Get the current project key (either from tenant or fallback)
|
|
221
|
+
* @param tenantId - Optional tenant ID to ensure is initialized
|
|
301
222
|
* @returns The project key to use for API calls
|
|
302
223
|
*/
|
|
303
224
|
private static getProjectKey;
|
|
@@ -309,19 +230,11 @@ declare class PersService {
|
|
|
309
230
|
* Authenticates a user with the PERS backend using their auth token
|
|
310
231
|
*
|
|
311
232
|
* @param authToken - The authentication token received from DFNS after login/registration
|
|
233
|
+
* @param tenantId - Optional tenant ID for automatic initialization
|
|
312
234
|
* @returns A promise that resolves to the authentication response
|
|
313
235
|
* @throws If the request fails
|
|
314
236
|
*/
|
|
315
|
-
static authenticateUser(authToken: string): Promise<SessionAuthContextResponseDTO>;
|
|
316
|
-
/**
|
|
317
|
-
* Prepares a transaction by calling the backend endpoint
|
|
318
|
-
*
|
|
319
|
-
* @param form - The transaction details
|
|
320
|
-
* @param persAccessToken - The PERS access token for authentication (Bearer)
|
|
321
|
-
* @returns A promise that resolves to the transaction preparation response
|
|
322
|
-
* @throws If the request fails
|
|
323
|
-
*/
|
|
324
|
-
static prepareTransaction(form: any, persAccessToken: string): Promise<TransactionRequestResponseDTO>;
|
|
237
|
+
static authenticateUser(authToken: string, tenantId: string): Promise<SessionAuthContextResponseDTO>;
|
|
325
238
|
/**
|
|
326
239
|
* Submits a transaction by calling the backend endpoint
|
|
327
240
|
*
|
|
@@ -329,53 +242,20 @@ declare class PersService {
|
|
|
329
242
|
* @param signedTransactionOrSignature - The signed transaction data or EIP-712 signature
|
|
330
243
|
* @param persAccessToken - The PERS access token for authentication (Bearer)
|
|
331
244
|
* @param submissionType - The transaction format type
|
|
245
|
+
* @param tenantId - Optional tenant ID for automatic initialization
|
|
332
246
|
* @returns A promise that resolves to the transaction submission response
|
|
333
247
|
* @throws If the request fails
|
|
334
248
|
*/
|
|
335
|
-
static submitTransaction(transactionId: string, signedTransactionOrSignature: string, persAccessToken: string, submissionType: TransactionFormat): Promise<
|
|
249
|
+
static submitTransaction(transactionId: string, signedTransactionOrSignature: string, persAccessToken: string, submissionType: TransactionFormat, tenantId: string): Promise<TransactionRequestResponseDTO>;
|
|
336
250
|
/**
|
|
337
251
|
* Fetches a prepared transaction for signing by transactionId
|
|
338
252
|
* @param transactionId - The transaction ID to fetch
|
|
339
253
|
* @param persAccessToken - The PERS access token for authentication (Bearer)
|
|
254
|
+
* @param tenantId - Optional tenant ID for automatic initialization
|
|
340
255
|
* @returns The prepared transaction data
|
|
341
256
|
* @throws If the request fails
|
|
342
257
|
*/
|
|
343
|
-
static fetchPreparedTransaction(transactionId: string, persAccessToken: string): Promise<TransactionRequestResponseDTO>;
|
|
344
|
-
/**
|
|
345
|
-
* Claims a reward from the PERS blockchain system
|
|
346
|
-
* @param rewardId - The ID of the reward to claim
|
|
347
|
-
* @param pointsCost - The points cost for the reward
|
|
348
|
-
* @param persAccessToken - The PERS access token for authentication (Bearer)
|
|
349
|
-
* @returns The reward claim response including reward image URL
|
|
350
|
-
* @throws If the request fails
|
|
351
|
-
*/
|
|
352
|
-
static claimReward(rewardId: string, pointsCost: number, persAccessToken: string): Promise<any>;
|
|
353
|
-
/**
|
|
354
|
-
* Get all active campaigns
|
|
355
|
-
* @returns Promise with list of active campaigns
|
|
356
|
-
*/
|
|
357
|
-
static getActiveCampaigns(): Promise<CampaignDTO[]>;
|
|
358
|
-
/**
|
|
359
|
-
* Claims a campaign for a user
|
|
360
|
-
* @param campaignId - The ID of the campaign to claim
|
|
361
|
-
* @param persAccessToken - The PERS access token for authentication (Bearer)
|
|
362
|
-
* @returns Promise with the campaign claim response
|
|
363
|
-
* @throws If the request fails
|
|
364
|
-
*/
|
|
365
|
-
static claimCampaign(campaignId: string, persAccessToken: string): Promise<CampaignClaimDTO>;
|
|
366
|
-
/**
|
|
367
|
-
* Gets all campaign claims for the authenticated user
|
|
368
|
-
* @param persAccessToken - The PERS access token for authentication (Bearer)
|
|
369
|
-
* @returns Promise with list of user's campaign claims
|
|
370
|
-
* @throws If the request fails
|
|
371
|
-
*/
|
|
372
|
-
static getUserCampaignClaims(persAccessToken: string): Promise<CampaignClaimDTO[]>;
|
|
373
|
-
/**
|
|
374
|
-
* Gets all available rewards for redemption
|
|
375
|
-
* @returns Promise with list of available rewards that can be exchanged for points
|
|
376
|
-
* @throws If the request fails
|
|
377
|
-
*/
|
|
378
|
-
static getAvailableRedemptions(): Promise<any[]>;
|
|
258
|
+
static fetchPreparedTransaction(transactionId: string, persAccessToken: string, tenantId: string): Promise<TransactionRequestResponseDTO>;
|
|
379
259
|
/**
|
|
380
260
|
* Helper method to determine if transaction data is available for signing
|
|
381
261
|
* @param transactionResponse - Response from prepare or fetch transaction
|
|
@@ -392,91 +272,154 @@ declare class PersService {
|
|
|
392
272
|
}
|
|
393
273
|
|
|
394
274
|
/**
|
|
395
|
-
*
|
|
275
|
+
* Key service response types and interfaces
|
|
396
276
|
*/
|
|
397
|
-
|
|
398
277
|
/**
|
|
399
|
-
*
|
|
278
|
+
* Signature response from key signing operations
|
|
400
279
|
*/
|
|
401
|
-
interface
|
|
280
|
+
interface SignResponse {
|
|
402
281
|
id: string;
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
282
|
+
keyId: string;
|
|
283
|
+
requester: {
|
|
284
|
+
userId: string;
|
|
285
|
+
appId: string;
|
|
286
|
+
};
|
|
287
|
+
requestBody: {
|
|
288
|
+
hash: string;
|
|
289
|
+
kind: "Hash";
|
|
290
|
+
};
|
|
291
|
+
status: "Signed";
|
|
292
|
+
signature: {
|
|
293
|
+
r: string;
|
|
294
|
+
s: string;
|
|
295
|
+
v: number;
|
|
296
|
+
encoded: string;
|
|
297
|
+
};
|
|
298
|
+
network: "KeyECDSA";
|
|
299
|
+
dateRequested: string;
|
|
300
|
+
dateSigned: string;
|
|
301
|
+
walletId: string;
|
|
408
302
|
}
|
|
409
303
|
/**
|
|
410
|
-
* Authentication
|
|
304
|
+
* Authentication response from login/register operations
|
|
411
305
|
*/
|
|
412
|
-
interface
|
|
306
|
+
interface AuthResponse {
|
|
413
307
|
token: string;
|
|
414
|
-
|
|
415
|
-
|
|
308
|
+
message?: string;
|
|
309
|
+
status?: number;
|
|
416
310
|
}
|
|
417
311
|
/**
|
|
418
|
-
*
|
|
312
|
+
* Registration challenge response
|
|
419
313
|
*/
|
|
420
|
-
interface
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
314
|
+
interface RegistrationChallenge {
|
|
315
|
+
temporaryAuthenticationToken: string;
|
|
316
|
+
challenge: any;
|
|
317
|
+
status?: number;
|
|
318
|
+
message?: string;
|
|
425
319
|
}
|
|
426
320
|
/**
|
|
427
|
-
*
|
|
321
|
+
* Registration completion response
|
|
428
322
|
*/
|
|
429
|
-
interface
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
lastLoginAt?: Date;
|
|
323
|
+
interface RegistrationResult {
|
|
324
|
+
token: string;
|
|
325
|
+
walletId?: string;
|
|
326
|
+
status?: number;
|
|
327
|
+
message?: string;
|
|
435
328
|
}
|
|
436
329
|
/**
|
|
437
|
-
*
|
|
330
|
+
* Individual wallet item
|
|
438
331
|
*/
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
332
|
+
/**
|
|
333
|
+
* Hash signing request
|
|
334
|
+
*/
|
|
335
|
+
interface HashSigningRequest {
|
|
336
|
+
kind: "Hash";
|
|
337
|
+
hash: string;
|
|
445
338
|
}
|
|
446
339
|
/**
|
|
447
|
-
*
|
|
340
|
+
* EIP-712 typed data signing request
|
|
448
341
|
*/
|
|
449
|
-
interface
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
342
|
+
interface TypedDataSigningRequest {
|
|
343
|
+
blockchainKind: "Evm";
|
|
344
|
+
kind: "Eip712";
|
|
345
|
+
types: Record<string, any[]>;
|
|
346
|
+
domain: any;
|
|
347
|
+
message: Record<string, any>;
|
|
453
348
|
}
|
|
454
349
|
/**
|
|
455
|
-
*
|
|
350
|
+
* Generic signing request
|
|
456
351
|
*/
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
352
|
+
type SigningRequest = HashSigningRequest | TypedDataSigningRequest;
|
|
353
|
+
/**
|
|
354
|
+
* Signing challenge response
|
|
355
|
+
*/
|
|
356
|
+
interface SigningChallenge {
|
|
357
|
+
requestBody: any;
|
|
358
|
+
challenge: {
|
|
359
|
+
challengeIdentifier: string;
|
|
360
|
+
[key: string]: any;
|
|
361
|
+
};
|
|
362
|
+
status?: number;
|
|
363
|
+
message?: string;
|
|
462
364
|
}
|
|
463
365
|
/**
|
|
464
|
-
*
|
|
366
|
+
* User credentials for authentication
|
|
465
367
|
*/
|
|
466
|
-
interface
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
details?: any;
|
|
470
|
-
timestamp: Date;
|
|
368
|
+
interface UserCredentials {
|
|
369
|
+
username: string;
|
|
370
|
+
appId?: string;
|
|
471
371
|
}
|
|
472
372
|
/**
|
|
473
|
-
*
|
|
373
|
+
* Relying party configuration for WebAuthn
|
|
474
374
|
*/
|
|
475
|
-
interface
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
375
|
+
interface RelyingPartyConfig {
|
|
376
|
+
id: string;
|
|
377
|
+
name: string;
|
|
378
|
+
origin?: string;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
/**
|
|
382
|
+
* Signing service for cryptographic operations
|
|
383
|
+
* Handles hash signing and typed data signing with WebAuthn
|
|
384
|
+
* Uses constructor-based dependency injection for WebAuthn provider
|
|
385
|
+
*/
|
|
386
|
+
declare class SigningService {
|
|
387
|
+
private webAuthnProvider;
|
|
388
|
+
constructor(webAuthnProvider: WebAuthnProvider);
|
|
389
|
+
/**
|
|
390
|
+
* Sign a hash using the specified wallet
|
|
391
|
+
* @param authToken - Authentication token
|
|
392
|
+
* @param walletId - Wallet identifier
|
|
393
|
+
* @param hash - Hash to sign
|
|
394
|
+
* @returns Promise resolving to signature response
|
|
395
|
+
*/
|
|
396
|
+
signHash(authToken: string, walletId: string, hash: string): Promise<CompleteSignatureResponse['data']>;
|
|
397
|
+
/**
|
|
398
|
+
* Sign EIP-712 typed data using the specified wallet
|
|
399
|
+
* @param authToken - Authentication token
|
|
400
|
+
* @param walletId - Wallet identifier
|
|
401
|
+
* @param domain - EIP-712 domain
|
|
402
|
+
* @param types - EIP-712 types definition
|
|
403
|
+
* @param value - Data to sign
|
|
404
|
+
* @returns Promise resolving to signature response
|
|
405
|
+
*/
|
|
406
|
+
signTypedData(authToken: string, walletId: string, domain: any, types: Record<string, any[]>, value: Record<string, any>): Promise<CompleteSignatureResponse['data']>;
|
|
407
|
+
/**
|
|
408
|
+
* Generic signing method that handles the complete signing flow
|
|
409
|
+
* @param authToken - Authentication token
|
|
410
|
+
* @param walletId - Wallet identifier
|
|
411
|
+
* @param request - Signing request object
|
|
412
|
+
* @returns Promise resolving to signature response
|
|
413
|
+
*/
|
|
414
|
+
private signRequest;
|
|
415
|
+
/**
|
|
416
|
+
* Sign multiple requests in batch (when backend supports it)
|
|
417
|
+
* @param authToken - Authentication token
|
|
418
|
+
* @param walletId - Wallet identifier
|
|
419
|
+
* @param requests - Array of signing requests
|
|
420
|
+
* @returns Promise resolving to array of signature responses
|
|
421
|
+
*/
|
|
422
|
+
signBatch(authToken: string, walletId: string, requests: SigningRequest[]): Promise<CompleteSignatureResponse['data'][]>;
|
|
480
423
|
}
|
|
481
424
|
|
|
482
425
|
interface GetWalletResponse {
|
|
@@ -538,21 +481,12 @@ interface TransactionStatusInfo {
|
|
|
538
481
|
interface TransactionSigningResult {
|
|
539
482
|
success: boolean;
|
|
540
483
|
transactionId: string;
|
|
541
|
-
transactionHash?: string;
|
|
542
484
|
signature?: string;
|
|
485
|
+
signingData?: CounterfactualWalletTransactionResponse | LegacyTransaction;
|
|
543
486
|
error?: string;
|
|
544
487
|
statusInfo?: TransactionStatusInfo;
|
|
545
|
-
shouldRedirect?: boolean;
|
|
546
|
-
redirectUrl?: string;
|
|
547
488
|
shouldShowStatus?: boolean;
|
|
548
489
|
}
|
|
549
|
-
/**
|
|
550
|
-
* Transaction result for localStorage storage
|
|
551
|
-
*/
|
|
552
|
-
interface StoredTransactionResult {
|
|
553
|
-
transactionId: string;
|
|
554
|
-
transactionHash: string;
|
|
555
|
-
}
|
|
556
490
|
/**
|
|
557
491
|
* Transaction submission result for internal processing
|
|
558
492
|
*/
|
|
@@ -560,18 +494,18 @@ interface SubmissionResult {
|
|
|
560
494
|
submitResult: TransactionRequestResponseDTO;
|
|
561
495
|
shouldRedirect: boolean;
|
|
562
496
|
redirectUrl?: string;
|
|
497
|
+
transactionHash: string | null;
|
|
498
|
+
success: boolean;
|
|
499
|
+
error?: string;
|
|
563
500
|
}
|
|
564
501
|
/**
|
|
565
502
|
* Metadata for transaction parameters - string values only
|
|
566
503
|
*/
|
|
567
|
-
interface TransactionMetadata {
|
|
568
|
-
[key: string]: string;
|
|
569
|
-
}
|
|
570
504
|
/**
|
|
571
505
|
* Authentication tokens required for transaction signing
|
|
572
506
|
*/
|
|
573
507
|
interface SigningAuthTokens {
|
|
574
|
-
|
|
508
|
+
signerAuthToken: string;
|
|
575
509
|
persAccessToken: string;
|
|
576
510
|
}
|
|
577
511
|
/**
|
|
@@ -579,12 +513,10 @@ interface SigningAuthTokens {
|
|
|
579
513
|
*/
|
|
580
514
|
interface TransactionSigningParams {
|
|
581
515
|
transactionId: string;
|
|
516
|
+
tenantId: string;
|
|
582
517
|
authTokens: SigningAuthTokens;
|
|
583
518
|
ethersProviderUrl: string;
|
|
584
519
|
returnUrl?: string;
|
|
585
|
-
metadata?: TransactionMetadata;
|
|
586
|
-
walletRegistrationFailed?: boolean;
|
|
587
|
-
walletErrorDetails?: string;
|
|
588
520
|
}
|
|
589
521
|
|
|
590
522
|
/**
|
|
@@ -594,7 +526,7 @@ interface TransactionSigningParams {
|
|
|
594
526
|
*/
|
|
595
527
|
declare class TransactionSigningService {
|
|
596
528
|
private webAuthnProvider;
|
|
597
|
-
constructor(
|
|
529
|
+
constructor(config: ExtendedPersSignerConfig);
|
|
598
530
|
/**
|
|
599
531
|
* Prepare transaction for signing - fetch and validate
|
|
600
532
|
*/
|
|
@@ -607,6 +539,11 @@ declare class TransactionSigningService {
|
|
|
607
539
|
* Execute the transaction signing with WebAuthn coordination
|
|
608
540
|
*/
|
|
609
541
|
private executeTransactionSigning;
|
|
542
|
+
getPersSigningData(data: {
|
|
543
|
+
transactionId: string;
|
|
544
|
+
authTokens: SigningAuthTokens;
|
|
545
|
+
tenantId: string;
|
|
546
|
+
}): Promise<CounterfactualWalletTransactionResponse | LegacyTransaction>;
|
|
610
547
|
/**
|
|
611
548
|
* Main transaction signing orchestration method
|
|
612
549
|
* Handles the complete flow from preparation to submission
|
|
@@ -614,7 +551,7 @@ declare class TransactionSigningService {
|
|
|
614
551
|
* @returns Promise resolving to transaction signing result
|
|
615
552
|
* @throws TransactionSigningError for validation and operation failures
|
|
616
553
|
*/
|
|
617
|
-
signTransaction(params: TransactionSigningParams): Promise<TransactionSigningResult>;
|
|
554
|
+
signTransaction(params: TransactionSigningParams, signingData: CounterfactualWalletTransactionResponse | LegacyTransaction): Promise<TransactionSigningResult>;
|
|
618
555
|
}
|
|
619
556
|
|
|
620
557
|
/**
|
|
@@ -733,19 +670,7 @@ declare class TransactionSubmissionHandler {
|
|
|
733
670
|
* @param metadata - Optional metadata to include as parameters
|
|
734
671
|
* @returns Promise resolving to the complete redirect URL
|
|
735
672
|
*/
|
|
736
|
-
static createRedirectUrl(returnUrl: string, transactionHash: string
|
|
737
|
-
/**
|
|
738
|
-
* Submit transaction and handle success flow
|
|
739
|
-
* @param preparedTransaction - The prepared transaction
|
|
740
|
-
* @param signature - The transaction signature
|
|
741
|
-
* @param signingData - The signing data used
|
|
742
|
-
* @param authTokens - Authentication tokens
|
|
743
|
-
* @param transactionId - Transaction ID for tracking
|
|
744
|
-
* @param returnUrl - Optional return URL for redirect
|
|
745
|
-
* @param metadata - Optional metadata for redirect parameters
|
|
746
|
-
* @returns Promise resolving to submission result
|
|
747
|
-
*/
|
|
748
|
-
static handleTransactionSubmission(preparedTransaction: TransactionRequestResponseDTO, signature: string, signingData: AnyTransactionData, authTokens: SigningAuthTokens, returnUrl?: string, metadata?: TransactionMetadata): Promise<SubmissionResult>;
|
|
673
|
+
static createRedirectUrl(returnUrl: string, transactionHash: string): Promise<string>;
|
|
749
674
|
}
|
|
750
675
|
|
|
751
676
|
/**
|
|
@@ -753,11 +678,6 @@ declare class TransactionSubmissionHandler {
|
|
|
753
678
|
* Manages global state flags to ensure only one WebAuthn operation runs at a time
|
|
754
679
|
*/
|
|
755
680
|
declare class WebAuthnCoordinator {
|
|
756
|
-
/**
|
|
757
|
-
* Clear the landing authentication flag
|
|
758
|
-
* Used when starting a new transaction signing flow
|
|
759
|
-
*/
|
|
760
|
-
static clearLandingAuthentication(): void;
|
|
761
681
|
/**
|
|
762
682
|
* Check if a WebAuthn operation is currently in progress
|
|
763
683
|
* @returns True if an operation is in progress, false otherwise
|
|
@@ -774,7 +694,7 @@ declare class WebAuthnCoordinator {
|
|
|
774
694
|
* Platform-agnostic configuration provider
|
|
775
695
|
* Abstracts environment variable access for cross-platform compatibility
|
|
776
696
|
*/
|
|
777
|
-
interface
|
|
697
|
+
interface PlatformConfig {
|
|
778
698
|
apiUrl: string;
|
|
779
699
|
appId?: string;
|
|
780
700
|
relyingParty: {
|
|
@@ -784,7 +704,7 @@ interface ServiceConfig {
|
|
|
784
704
|
};
|
|
785
705
|
}
|
|
786
706
|
interface ConfigProvider {
|
|
787
|
-
getServiceConfig():
|
|
707
|
+
getServiceConfig(): PlatformConfig;
|
|
788
708
|
}
|
|
789
709
|
/**
|
|
790
710
|
* Web platform configuration provider
|
|
@@ -792,8 +712,8 @@ interface ConfigProvider {
|
|
|
792
712
|
*/
|
|
793
713
|
declare class WebConfigProvider implements ConfigProvider {
|
|
794
714
|
private config;
|
|
795
|
-
constructor(config:
|
|
796
|
-
getServiceConfig():
|
|
715
|
+
constructor(config: PlatformConfig);
|
|
716
|
+
getServiceConfig(): PlatformConfig;
|
|
797
717
|
}
|
|
798
718
|
/**
|
|
799
719
|
* React Native configuration provider
|
|
@@ -801,16 +721,16 @@ declare class WebConfigProvider implements ConfigProvider {
|
|
|
801
721
|
*/
|
|
802
722
|
declare class ReactNativeConfigProvider implements ConfigProvider {
|
|
803
723
|
private config;
|
|
804
|
-
constructor(config:
|
|
805
|
-
getServiceConfig():
|
|
724
|
+
constructor(config: PlatformConfig);
|
|
725
|
+
getServiceConfig(): PlatformConfig;
|
|
806
726
|
}
|
|
807
727
|
/**
|
|
808
728
|
* Static configuration provider for testing or custom setups
|
|
809
729
|
*/
|
|
810
730
|
declare class StaticConfigProvider implements ConfigProvider {
|
|
811
731
|
private config;
|
|
812
|
-
constructor(config:
|
|
813
|
-
getServiceConfig():
|
|
732
|
+
constructor(config: PlatformConfig);
|
|
733
|
+
getServiceConfig(): PlatformConfig;
|
|
814
734
|
}
|
|
815
735
|
/**
|
|
816
736
|
* Set the global configuration provider
|
|
@@ -824,7 +744,7 @@ declare function getConfigProvider(): ConfigProvider;
|
|
|
824
744
|
/**
|
|
825
745
|
* Get the service configuration
|
|
826
746
|
*/
|
|
827
|
-
declare function getServiceConfig():
|
|
747
|
+
declare function getServiceConfig(): PlatformConfig;
|
|
828
748
|
|
|
829
749
|
/**
|
|
830
750
|
* Platform-agnostic HTTP client abstraction
|
|
@@ -870,322 +790,424 @@ declare function setHttpClient(client: HttpClient): void;
|
|
|
870
790
|
declare function getHttpClient(): HttpClient;
|
|
871
791
|
|
|
872
792
|
/**
|
|
873
|
-
*
|
|
874
|
-
*/
|
|
875
|
-
|
|
876
|
-
/**
|
|
877
|
-
* Get WebAuthn provider for browser environments
|
|
878
|
-
*/
|
|
879
|
-
declare function getBrowserWebAuthnProvider(): Promise<WebAuthnProvider>;
|
|
880
|
-
|
|
881
|
-
/**
|
|
882
|
-
* React Native-specific WebAuthn provider using DFNS React Native SDK
|
|
883
|
-
* Falls back to browser implementation for React Native Web (Expo Web)
|
|
793
|
+
* Wallet list response from WalletService
|
|
884
794
|
*/
|
|
885
|
-
|
|
795
|
+
interface WalletListResponse {
|
|
796
|
+
items: WalletItem[];
|
|
797
|
+
}
|
|
886
798
|
/**
|
|
887
|
-
*
|
|
799
|
+
* Individual wallet item from wallet list - compatible with KeyWallet constructor
|
|
888
800
|
*/
|
|
889
|
-
|
|
801
|
+
interface WalletItem {
|
|
802
|
+
id: string;
|
|
803
|
+
address: string;
|
|
804
|
+
network: string;
|
|
805
|
+
status: string;
|
|
806
|
+
signingKey?: unknown;
|
|
807
|
+
dateCreated?: string;
|
|
808
|
+
custodial?: boolean;
|
|
809
|
+
tags?: string[];
|
|
810
|
+
boundToEvmNetwork?: boolean;
|
|
811
|
+
[key: string]: unknown;
|
|
812
|
+
}
|
|
890
813
|
|
|
891
814
|
/**
|
|
892
|
-
* PERS Blockchain Signer SDK
|
|
815
|
+
* PERS Blockchain Signer SDK
|
|
816
|
+
*
|
|
817
|
+
* A lightweight blockchain transaction signing SDK with WebAuthn authentication.
|
|
818
|
+
* Provides 5 focused methods for complete transaction lifecycle management:
|
|
819
|
+
*
|
|
820
|
+
* 1. loginUser(jwtToken) - Authenticate user with 5-minute caching
|
|
821
|
+
* 2. signTransaction(signingData, jwtToken) - Sign transactions with auto-login
|
|
822
|
+
* 3. submitTransaction(signedTx, jwtToken) - Submit signed transactions to blockchain
|
|
823
|
+
* 4. signPersTransaction(jwtToken) - Legacy one-liner for backward compatibility
|
|
824
|
+
* 5. signAndSubmitPersTransaction(jwtToken) - Complete sign + submit flow
|
|
825
|
+
*
|
|
826
|
+
* @example
|
|
827
|
+
* ```typescript
|
|
828
|
+
* import { createPersSignerSDK } from '@explorins/pers-signer';
|
|
893
829
|
*
|
|
894
|
-
*
|
|
895
|
-
*
|
|
830
|
+
* const sdk = createPersSignerSDK({
|
|
831
|
+
* webAuthnProvider: myWebAuthnProvider,
|
|
832
|
+
* ethersProviderUrl: 'https://ethereum-rpc.com'
|
|
833
|
+
* });
|
|
834
|
+
*
|
|
835
|
+
* // Quick sign and submit
|
|
836
|
+
* const result = await sdk.signAndSubmitPersTransaction(jwtToken);
|
|
837
|
+
* if (result.success) {
|
|
838
|
+
* console.log('Transaction submitted:', result.transactionHash);
|
|
839
|
+
* }
|
|
840
|
+
* ```
|
|
896
841
|
*/
|
|
897
842
|
|
|
898
|
-
interface JWTPayload {
|
|
899
|
-
email?: string;
|
|
900
|
-
userId?: string;
|
|
901
|
-
tenantId?: string;
|
|
902
|
-
exp?: number;
|
|
903
|
-
[key: string]: any;
|
|
904
|
-
}
|
|
905
|
-
interface PersAuthResult {
|
|
906
|
-
user: {
|
|
907
|
-
email?: string;
|
|
908
|
-
id?: string;
|
|
909
|
-
};
|
|
910
|
-
accessToken: string;
|
|
911
|
-
}
|
|
912
843
|
/**
|
|
913
|
-
*
|
|
914
|
-
|
|
915
|
-
interface
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
}
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
interface SignerAuthenticatedUser {
|
|
924
|
-
identifier: string;
|
|
925
|
-
signerAuthToken: string;
|
|
926
|
-
persAccessToken: string;
|
|
927
|
-
}
|
|
928
|
-
interface AuthenticationResult {
|
|
929
|
-
user: SignerAuthenticatedUser;
|
|
930
|
-
isExpired: boolean;
|
|
931
|
-
}
|
|
932
|
-
interface JWTExtractionResult {
|
|
933
|
-
payload: JWTPayload | null;
|
|
934
|
-
isExpired: boolean;
|
|
935
|
-
}
|
|
936
|
-
interface PersSignerConfig {
|
|
937
|
-
tenantId?: string;
|
|
844
|
+
* Configuration interface for the PERS Signer SDK
|
|
845
|
+
*
|
|
846
|
+
* @interface PersSignerConfig
|
|
847
|
+
* @property {string} [tenantId] - Optional tenant identifier for multi-tenant applications
|
|
848
|
+
* @property {string} [ethersProviderUrl] - Custom Ethereum RPC provider URL
|
|
849
|
+
* @property {WebAuthnProvider} webAuthnProvider - WebAuthn provider for secure authentication
|
|
850
|
+
* @property {string} [apiUrl] - Custom API base URL (defaults to production)
|
|
851
|
+
* @property {string} [relyingPartyName] - WebAuthn relying party name for authentication
|
|
852
|
+
*/
|
|
853
|
+
interface ExtendedPersSignerConfig {
|
|
938
854
|
ethersProviderUrl?: string;
|
|
939
855
|
webAuthnProvider: WebAuthnProvider;
|
|
940
856
|
apiUrl?: string;
|
|
941
857
|
relyingPartyName?: string;
|
|
942
858
|
}
|
|
943
|
-
interface
|
|
944
|
-
success: boolean;
|
|
945
|
-
transactionHash?: string;
|
|
946
|
-
error?: string;
|
|
859
|
+
interface PersSignerConfig extends Omit<ExtendedPersSignerConfig, 'webAuthnProvider'> {
|
|
947
860
|
}
|
|
948
861
|
/**
|
|
949
|
-
*
|
|
862
|
+
* PERS Blockchain Signer SDK Class
|
|
863
|
+
*
|
|
864
|
+
* Main SDK class providing blockchain transaction signing capabilities with WebAuthn authentication.
|
|
865
|
+
* Implements a clean 5-method API for complete transaction lifecycle management.
|
|
866
|
+
*
|
|
867
|
+
* Features:
|
|
868
|
+
* - WebAuthn-based secure authentication
|
|
869
|
+
* - 5-minute user session caching
|
|
870
|
+
* - Automatic transaction data fetching
|
|
871
|
+
* - Blockchain transaction signing and submission
|
|
872
|
+
* - Multi-tenant support
|
|
950
873
|
*
|
|
951
|
-
*
|
|
952
|
-
* No complex initialization needed - services are already configured.
|
|
874
|
+
* @class PersSignerSDK
|
|
953
875
|
*/
|
|
954
876
|
declare class PersSignerSDK {
|
|
955
877
|
private config;
|
|
956
|
-
private
|
|
957
|
-
private signingService;
|
|
878
|
+
private authenticationService;
|
|
958
879
|
private transactionSigningService;
|
|
959
|
-
private webAuthnProvider;
|
|
960
|
-
constructor(config: PersSignerConfig);
|
|
961
|
-
/**
|
|
962
|
-
* Re-export TransactionSigningService with WebAuthn provider already injected
|
|
963
|
-
* This provides the same interface as the original service but with automatic provider injection
|
|
964
|
-
*/
|
|
965
|
-
get TransactionSigningService(): TransactionSigningService;
|
|
966
|
-
/**
|
|
967
|
-
* Complete user onboarding flow - same as web project
|
|
968
|
-
* Uses existing AuthenticationService and PersService
|
|
969
|
-
*/
|
|
970
|
-
authenticateUser(userInfo: SignerUserInfo): Promise<SignerAuthenticatedUser>;
|
|
971
|
-
/**
|
|
972
|
-
* Complete PERS transaction signing flow - exactly like web project
|
|
973
|
-
* Uses existing TransactionSigningService with injected WebAuthn provider
|
|
974
|
-
*/
|
|
975
|
-
signPersTransaction(user: SignerAuthenticatedUser, transactionId: string): Promise<SigningResult>;
|
|
976
880
|
/**
|
|
977
|
-
*
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
}>;
|
|
982
|
-
/**
|
|
983
|
-
* Login existing user - uses existing AuthenticationService
|
|
984
|
-
*/
|
|
985
|
-
loginUser(identifier: string): Promise<string>;
|
|
986
|
-
/**
|
|
987
|
-
* Add wallet to PERS user - uses existing PersService
|
|
988
|
-
*/
|
|
989
|
-
addWalletToPersUser(signerAuthToken: string): Promise<string>;
|
|
990
|
-
/**
|
|
991
|
-
* Retrieve transaction data from PERS - uses existing PersService
|
|
992
|
-
*/
|
|
993
|
-
retrieveTransactionData(transactionId: string, persAccessToken: string): Promise<TransactionRequestResponseDTO>;
|
|
994
|
-
/**
|
|
995
|
-
* Sign transaction data - uses existing SigningService
|
|
996
|
-
* Follows same patterns as KeyWallet.signPersTransaction
|
|
881
|
+
* Initialize the PERS Signer SDK
|
|
882
|
+
*
|
|
883
|
+
* @param {ExtendedPersSignerConfig} config - SDK configuration object
|
|
884
|
+
* @throws {Error} If required configuration is missing
|
|
997
885
|
*/
|
|
998
|
-
|
|
886
|
+
constructor(config: ExtendedPersSignerConfig);
|
|
999
887
|
/**
|
|
1000
|
-
*
|
|
888
|
+
* Authenticate user and cache session for 5 minutes
|
|
889
|
+
*
|
|
890
|
+
* Validates JWT token, authenticates with both signer and PERS backends,
|
|
891
|
+
* and caches the authenticated user session to avoid repeated authentication.
|
|
892
|
+
*
|
|
893
|
+
* @param {string} jwtToken - JWT token containing user identifier and tenant info
|
|
894
|
+
* @returns {Promise<AuthenticatedUser>} Authenticated user with access tokens
|
|
895
|
+
* @throws {Error} If JWT is invalid, expired, or authentication fails
|
|
896
|
+
*
|
|
897
|
+
* @example
|
|
898
|
+
* ```typescript
|
|
899
|
+
* try {
|
|
900
|
+
* const user = await sdk.loginUser(jwtToken);
|
|
901
|
+
* console.log('Authenticated:', user.identifier);
|
|
902
|
+
* } catch (error) {
|
|
903
|
+
* console.error('Authentication failed:', error.message);
|
|
904
|
+
* }
|
|
905
|
+
* ```
|
|
906
|
+
*/
|
|
907
|
+
loginUser(jwtToken: string): Promise<AuthenticatedUser>;
|
|
908
|
+
/**
|
|
909
|
+
* Sign a PERS transaction (legacy compatibility method)
|
|
910
|
+
*
|
|
911
|
+
* Automatically handles user authentication, transaction data fetching,
|
|
912
|
+
* and transaction signing in a single call. This is the legacy method
|
|
913
|
+
* maintained for backward compatibility.
|
|
914
|
+
*
|
|
915
|
+
* @param {string} jwtToken - JWT token containing transaction ID and user info
|
|
916
|
+
* @returns {Promise<TransactionSigningResult>} Signing result with signature and metadata
|
|
917
|
+
* @throws {Error} If authentication fails, transaction ID missing, or signing fails
|
|
918
|
+
*
|
|
919
|
+
* @example
|
|
920
|
+
* ```typescript
|
|
921
|
+
* try {
|
|
922
|
+
* const result = await sdk.signPersTransaction(jwtToken);
|
|
923
|
+
* if (result.success) {
|
|
924
|
+
* console.log('Transaction signed:', result.signature);
|
|
925
|
+
* }
|
|
926
|
+
* } catch (error) {
|
|
927
|
+
* console.error('Signing failed:', error.message);
|
|
928
|
+
* }
|
|
929
|
+
* ```
|
|
930
|
+
*/
|
|
931
|
+
signPersTransaction(jwtToken: string): Promise<TransactionSigningResult>;
|
|
932
|
+
/**
|
|
933
|
+
* Sign a transaction with provided signing data
|
|
934
|
+
*
|
|
935
|
+
* Low-level method to sign transactions when you already have the signing data.
|
|
936
|
+
* Automatically handles user authentication and applies the blockchain signature.
|
|
937
|
+
*
|
|
938
|
+
* @param {CounterfactualWalletTransactionResponse | LegacyTransaction} signingData - Transaction data to sign
|
|
939
|
+
* @param {string} jwtToken - JWT token containing transaction ID and user info
|
|
940
|
+
* @returns {Promise<TransactionSigningResult>} Signing result with signature and metadata
|
|
941
|
+
* @throws {Error} If authentication fails, transaction ID missing, or signing fails
|
|
942
|
+
*
|
|
943
|
+
* @example
|
|
944
|
+
* ```typescript
|
|
945
|
+
* const signingData = await getTransactionData(transactionId);
|
|
946
|
+
* const result = await sdk.signTransaction(signingData, jwtToken);
|
|
947
|
+
* console.log('Signed transaction:', result.signature);
|
|
948
|
+
* ```
|
|
1001
949
|
*/
|
|
1002
|
-
|
|
1003
|
-
transactionHash?: string;
|
|
1004
|
-
success: boolean;
|
|
1005
|
-
}>;
|
|
950
|
+
signTransaction(signingData: CounterfactualWalletTransactionResponse$1 | LegacyTransaction, jwtToken: string): Promise<TransactionSigningResult>;
|
|
1006
951
|
/**
|
|
1007
|
-
*
|
|
952
|
+
* Complete transaction flow: sign and submit in one call
|
|
953
|
+
*
|
|
954
|
+
* Convenience method that combines signing and submission into a single operation.
|
|
955
|
+
* This is the recommended method for most use cases as it handles the complete
|
|
956
|
+
* transaction lifecycle automatically.
|
|
957
|
+
*
|
|
958
|
+
* @param {string} jwtToken - JWT token containing transaction ID and user info
|
|
959
|
+
* @returns {Promise<SubmissionResult>} Submission result with transaction hash and status
|
|
960
|
+
* @throws {Error} If authentication, signing, or submission fails
|
|
961
|
+
*
|
|
962
|
+
* @example
|
|
963
|
+
* ```typescript
|
|
964
|
+
* try {
|
|
965
|
+
* const result = await sdk.signAndSubmitPersTransaction(jwtToken);
|
|
966
|
+
* if (result.success) {
|
|
967
|
+
* console.log('Transaction completed:', result.transactionHash);
|
|
968
|
+
* if (result.shouldRedirect) {
|
|
969
|
+
* window.location.href = result.redirectUrl;
|
|
970
|
+
* }
|
|
971
|
+
* }
|
|
972
|
+
* } catch (error) {
|
|
973
|
+
* console.error('Transaction failed:', error.message);
|
|
974
|
+
* }
|
|
975
|
+
* ```
|
|
976
|
+
*/
|
|
977
|
+
signAndSubmitPersTransaction(jwtToken: string): Promise<SubmissionResult>;
|
|
978
|
+
/**
|
|
979
|
+
* Submit a signed transaction to the blockchain
|
|
980
|
+
*
|
|
981
|
+
* Takes a signed transaction result and submits it to the blockchain network.
|
|
982
|
+
* Returns detailed submission results including transaction hash and any
|
|
983
|
+
* redirect information for UI flows.
|
|
984
|
+
*
|
|
985
|
+
* @param {TransactionSigningResult} signingResult - Result from a successful transaction signing
|
|
986
|
+
* @param {string} jwtToken - JWT token containing tenant and user info
|
|
987
|
+
* @returns {Promise<SubmissionResult>} Submission result with transaction hash and status
|
|
988
|
+
* @throws {Error} If signing result is invalid, JWT is missing tenantId, or submission fails
|
|
989
|
+
*
|
|
990
|
+
* @example
|
|
991
|
+
* ```typescript
|
|
992
|
+
* const signedTx = await sdk.signPersTransaction(jwtToken);
|
|
993
|
+
* const result = await sdk.submitTransaction(signedTx, jwtToken);
|
|
994
|
+
* console.log('Transaction submitted:', result.transactionHash);
|
|
995
|
+
* ```
|
|
1008
996
|
*/
|
|
1009
|
-
|
|
997
|
+
submitTransaction(signingResult: TransactionSigningResult, jwtToken: string): Promise<SubmissionResult>;
|
|
1010
998
|
/**
|
|
1011
|
-
*
|
|
999
|
+
* Clear user authentication cache
|
|
1000
|
+
*
|
|
1001
|
+
* Removes all cached user sessions, forcing fresh authentication
|
|
1002
|
+
* on the next method call. Useful for logout scenarios or when
|
|
1003
|
+
* switching between different user contexts.
|
|
1004
|
+
*
|
|
1005
|
+
* @example
|
|
1006
|
+
* ```typescript
|
|
1007
|
+
* // Clear cache on user logout
|
|
1008
|
+
* sdk.clearCache();
|
|
1009
|
+
* console.log('User cache cleared');
|
|
1010
|
+
* ```
|
|
1012
1011
|
*/
|
|
1013
|
-
|
|
1012
|
+
clearCache(): void;
|
|
1013
|
+
}
|
|
1014
|
+
/**
|
|
1015
|
+
* Create a new PERS Signer SDK instance
|
|
1016
|
+
*
|
|
1017
|
+
* Factory function to create and configure a new SDK instance with the provided
|
|
1018
|
+
* configuration. This is the recommended way to initialize the SDK.
|
|
1019
|
+
*
|
|
1020
|
+
* @param {PersSignerConfig} config - SDK configuration object
|
|
1021
|
+
* @returns {PersSignerSDK} Configured SDK instance ready for use
|
|
1022
|
+
* @throws {Error} If required configuration is missing or invalid
|
|
1023
|
+
*
|
|
1024
|
+
* @example
|
|
1025
|
+
* ```typescript
|
|
1026
|
+
* import { createPersSignerSDK, getWebAuthnProvider } from '@explorins/pers-signer';
|
|
1027
|
+
*
|
|
1028
|
+
* const webAuthnProvider = await getWebAuthnProvider();
|
|
1029
|
+
* const sdk = createPersSignerSDK({
|
|
1030
|
+
* webAuthnProvider,
|
|
1031
|
+
* ethersProviderUrl: 'https://mainnet.infura.io/v3/YOUR_KEY',
|
|
1032
|
+
* tenantId: 'your-tenant-id'
|
|
1033
|
+
* });
|
|
1034
|
+
* ```
|
|
1035
|
+
*/
|
|
1036
|
+
declare function createPersSignerSDK(config: ExtendedPersSignerConfig): PersSignerSDK;
|
|
1037
|
+
|
|
1038
|
+
/**
|
|
1039
|
+
* Authenticated user with all required tokens
|
|
1040
|
+
*/
|
|
1041
|
+
interface SignerAuthenticatedUser {
|
|
1042
|
+
identifier: string;
|
|
1043
|
+
signerAuthToken: string;
|
|
1044
|
+
persAccessToken: string;
|
|
1045
|
+
}
|
|
1046
|
+
/**
|
|
1047
|
+
* Authentication service for user login and registration
|
|
1048
|
+
* Uses constructor-based dependency injection for WebAuthn provider
|
|
1049
|
+
* Updated for new v1 API endpoints
|
|
1050
|
+
*/
|
|
1051
|
+
declare class AuthenticationService {
|
|
1052
|
+
private signerToken;
|
|
1053
|
+
private config;
|
|
1054
|
+
private webAuthnProvider;
|
|
1055
|
+
constructor(config: ExtendedPersSignerConfig);
|
|
1014
1056
|
/**
|
|
1015
|
-
*
|
|
1057
|
+
* Login with PERS token to get signer JWT
|
|
1058
|
+
* @param persToken - PERS JWT from PERS authentication
|
|
1059
|
+
* @returns Promise resolving to login response or provider challenge data
|
|
1016
1060
|
*/
|
|
1017
|
-
|
|
1018
|
-
status: string;
|
|
1019
|
-
transactionHash?: string;
|
|
1020
|
-
}>;
|
|
1061
|
+
loginWithPersToken(persToken: string): Promise<JWTLoginResponse | unknown>;
|
|
1021
1062
|
/**
|
|
1022
|
-
*
|
|
1063
|
+
* Verify signer token validity
|
|
1064
|
+
* @param token - Signer JWT to verify
|
|
1065
|
+
* @returns Promise resolving to verification result
|
|
1023
1066
|
*/
|
|
1024
|
-
|
|
1067
|
+
verifyToken(token: string): Promise<VerifyTokenResponse>;
|
|
1025
1068
|
/**
|
|
1026
|
-
*
|
|
1027
|
-
*
|
|
1069
|
+
* Initialize user registration
|
|
1070
|
+
* @param persToken - PERS JWT token (registration is public)
|
|
1071
|
+
* @returns Promise resolving to registration challenge
|
|
1028
1072
|
*/
|
|
1029
|
-
|
|
1073
|
+
initializeRegistration(persToken: string): Promise<unknown>;
|
|
1030
1074
|
/**
|
|
1031
|
-
*
|
|
1075
|
+
* Get current signer token
|
|
1076
|
+
* @returns The current signer JWT token
|
|
1032
1077
|
*/
|
|
1033
|
-
|
|
1078
|
+
getSignerToken(): string | null;
|
|
1034
1079
|
/**
|
|
1035
|
-
*
|
|
1080
|
+
* Set signer token (for external token management)
|
|
1081
|
+
* @param token - Signer JWT token
|
|
1036
1082
|
*/
|
|
1083
|
+
setSignerToken(token: string): void;
|
|
1037
1084
|
/**
|
|
1038
|
-
*
|
|
1085
|
+
* Complete registration with WebAuthn challenge data (v1 API format)
|
|
1086
|
+
* @param tmpAuthToken - Temporary auth token from init registration (temporaryAuthenticationToken)
|
|
1087
|
+
* @param signedChallenge - WebAuthn credential response (will be restructured for backend)
|
|
1088
|
+
* @param persToken - PERS JWT token (authToken)
|
|
1089
|
+
* @returns Promise resolving to registration result
|
|
1039
1090
|
*/
|
|
1040
|
-
|
|
1091
|
+
completeRegistrationWithChallenge(tmpAuthToken: string | null, signedChallenge: any, persToken: string): Promise<JWTLoginResponse | unknown>;
|
|
1041
1092
|
/**
|
|
1042
|
-
* Combined
|
|
1093
|
+
* Combined authentication flow - handles both login and registration
|
|
1094
|
+
* @param identifier - User identifier (email/userId)
|
|
1095
|
+
* @param persAccessToken - PERS JWT token for authentication
|
|
1096
|
+
* @param webAuthnProvider - WebAuthn provider for credential creation
|
|
1097
|
+
* @param relyingPartyConfig - Configuration for WebAuthn relying party
|
|
1098
|
+
* @returns Promise resolving to authenticated user with signer token
|
|
1043
1099
|
*/
|
|
1044
1100
|
combinedAuthentication(identifier: string, persAccessToken: string): Promise<SignerAuthenticatedUser>;
|
|
1045
|
-
/**
|
|
1046
|
-
* Complete JWT-based authentication flow (legacy PERS flow)
|
|
1047
|
-
*/
|
|
1048
|
-
authenticateWithJWT(searchParams: URLSearchParams): Promise<AuthenticationResult | null>;
|
|
1049
1101
|
}
|
|
1050
|
-
/**
|
|
1051
|
-
* Factory function to create SDK
|
|
1052
|
-
* Requires WebAuthnProvider from platform-specific entry point
|
|
1053
|
-
*/
|
|
1054
|
-
declare function createPersSignerSDK(config: PersSignerConfig): PersSignerSDK;
|
|
1055
1102
|
|
|
1056
1103
|
/**
|
|
1057
|
-
*
|
|
1058
|
-
|
|
1059
|
-
interface WalletListResponse {
|
|
1060
|
-
items: WalletItem[];
|
|
1061
|
-
}
|
|
1062
|
-
/**
|
|
1063
|
-
* Individual wallet item from wallet list - compatible with KeyWallet constructor
|
|
1104
|
+
* Health check service for signer API
|
|
1105
|
+
* Handles health check operations for the new v1 API
|
|
1064
1106
|
*/
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
dateCreated?: string;
|
|
1072
|
-
custodial?: boolean;
|
|
1073
|
-
tags?: string[];
|
|
1074
|
-
boundToEvmNetwork?: boolean;
|
|
1075
|
-
[key: string]: unknown;
|
|
1107
|
+
declare class HealthService {
|
|
1108
|
+
/**
|
|
1109
|
+
* Perform health check on the signer API
|
|
1110
|
+
* @returns Promise resolving to health check result
|
|
1111
|
+
*/
|
|
1112
|
+
static checkHealth(): Promise<HealthCheckResponse>;
|
|
1076
1113
|
}
|
|
1077
1114
|
|
|
1078
1115
|
/**
|
|
1079
|
-
*
|
|
1080
|
-
*/
|
|
1081
|
-
/**
|
|
1082
|
-
* Creates a URL search string that preserves all current parameters
|
|
1083
|
-
* @param paramsToExclude Array of parameter names to exclude from the result
|
|
1084
|
-
* @param paramsToAdd Object with additional parameters to add or override
|
|
1085
|
-
* @param baseParams Optional URLSearchParams object to use instead of window.location.search
|
|
1086
|
-
* @returns A search string with '?' prefix if there are parameters, or empty string if no parameters
|
|
1087
|
-
*/
|
|
1088
|
-
declare function createSearchString(paramsToExclude?: string[], paramsToAdd?: Record<string, string>, baseParams?: URLSearchParams | string): string;
|
|
1089
|
-
/**
|
|
1090
|
-
* Creates a URL path with search parameters
|
|
1091
|
-
* @param basePath The base path without search parameters
|
|
1092
|
-
* @param paramsToExclude Array of parameter names to exclude from the result
|
|
1093
|
-
* @param paramsToAdd Object with additional parameters to add or override
|
|
1094
|
-
* @param baseParams Optional URLSearchParams object to use instead of window.location.search
|
|
1095
|
-
* @returns A full path with search parameters
|
|
1096
|
-
*/
|
|
1097
|
-
declare function createUrlWithSearchParams(basePath: string, paramsToExclude?: string[], paramsToAdd?: Record<string, string>, baseParams?: URLSearchParams | string): string;
|
|
1098
|
-
/**
|
|
1099
|
-
* Combines the current search parameters with new ones
|
|
1100
|
-
* @param searchParams The current URLSearchParams object
|
|
1101
|
-
* @param additionalParams Object with parameters to add or update
|
|
1102
|
-
* @returns A new URLSearchParams object
|
|
1103
|
-
*/
|
|
1104
|
-
declare function mergeSearchParams(searchParams: URLSearchParams, additionalParams?: Record<string, string>): URLSearchParams;
|
|
1105
|
-
/**
|
|
1106
|
-
* Gets a specific search parameter value
|
|
1107
|
-
* @param key The parameter name to get
|
|
1108
|
-
* @param search Optional search string to parse (defaults to window.location.search)
|
|
1109
|
-
* @returns The parameter value or null if not found
|
|
1110
|
-
*/
|
|
1111
|
-
declare function getSearchParam(key: string, search?: string): string | null;
|
|
1112
|
-
/**
|
|
1113
|
-
* Gets all search parameters as a URLSearchParams object
|
|
1114
|
-
* @param search Optional search string to parse (defaults to window.location.search)
|
|
1115
|
-
* @returns A URLSearchParams object
|
|
1116
|
-
*/
|
|
1117
|
-
declare function getAllSearchParams(search?: string): URLSearchParams;
|
|
1118
|
-
/**
|
|
1119
|
-
* Removes a specific search parameter
|
|
1120
|
-
* @param key The parameter name to remove
|
|
1121
|
-
* @param search Optional search string to parse (defaults to window.location.search)
|
|
1122
|
-
* @returns A new search string without the specified parameter
|
|
1116
|
+
* Browser-specific WebAuthn provider using DFNS browser SDK
|
|
1123
1117
|
*/
|
|
1124
|
-
|
|
1118
|
+
|
|
1125
1119
|
/**
|
|
1126
|
-
*
|
|
1127
|
-
* @param key The parameter name to update
|
|
1128
|
-
* @param value The new value for the parameter
|
|
1129
|
-
* @param search Optional search string to parse (defaults to window.location.search)
|
|
1130
|
-
* @returns A new search string with the updated parameter
|
|
1120
|
+
* Get WebAuthn provider for browser environments
|
|
1131
1121
|
*/
|
|
1132
|
-
declare function
|
|
1122
|
+
declare function getBrowserWebAuthnProvider(): Promise<WebAuthnProvider>;
|
|
1133
1123
|
|
|
1134
1124
|
/**
|
|
1135
|
-
*
|
|
1125
|
+
* React Native-specific WebAuthn provider using DFNS React Native SDK
|
|
1126
|
+
* Falls back to browser implementation for React Native Web (Expo Web)
|
|
1136
1127
|
*/
|
|
1128
|
+
|
|
1137
1129
|
/**
|
|
1138
|
-
*
|
|
1139
|
-
* This is useful for debugging search parameter preservation across navigation
|
|
1140
|
-
*
|
|
1141
|
-
* @param message - A descriptive message to identify where the logging happens
|
|
1142
|
-
* @param additionalData - Optional additional data to log
|
|
1130
|
+
* Get WebAuthn provider for React Native environments
|
|
1143
1131
|
*/
|
|
1144
|
-
declare function
|
|
1132
|
+
declare function getReactNativeWebAuthnProvider(): Promise<WebAuthnProvider>;
|
|
1133
|
+
|
|
1145
1134
|
/**
|
|
1146
|
-
*
|
|
1147
|
-
* Logs search parameter changes when the component mounts/updates
|
|
1135
|
+
* JWT Utility Functions
|
|
1148
1136
|
*
|
|
1149
|
-
*
|
|
1137
|
+
* Browser-compatible JWT handling without external dependencies
|
|
1150
1138
|
*/
|
|
1151
|
-
|
|
1152
|
-
|
|
1139
|
+
interface JWTPayload {
|
|
1140
|
+
email?: string;
|
|
1141
|
+
identifierEmail?: string;
|
|
1142
|
+
userId?: string;
|
|
1143
|
+
tenantId?: string;
|
|
1144
|
+
transactionId?: string;
|
|
1145
|
+
exp?: number;
|
|
1146
|
+
[key: string]: any;
|
|
1147
|
+
}
|
|
1148
|
+
interface JWTExtractionResult {
|
|
1149
|
+
payload: JWTPayload | null;
|
|
1150
|
+
isExpired: boolean;
|
|
1151
|
+
}
|
|
1153
1152
|
/**
|
|
1154
|
-
*
|
|
1155
|
-
*
|
|
1153
|
+
* Extract and validate JWT token payload
|
|
1154
|
+
* Uses a browser-compatible approach without external dependencies
|
|
1156
1155
|
*/
|
|
1157
|
-
declare function
|
|
1156
|
+
declare function extractJWTFromToken(jwtToken: string): JWTExtractionResult;
|
|
1158
1157
|
/**
|
|
1159
|
-
*
|
|
1160
|
-
* @returns A username in the format "user_[random string]"
|
|
1158
|
+
* Check if a JWT token is expired
|
|
1161
1159
|
*/
|
|
1162
|
-
declare function
|
|
1160
|
+
declare function isJWTExpired(jwtToken: string): boolean;
|
|
1163
1161
|
/**
|
|
1164
|
-
*
|
|
1165
|
-
* @returns A guest email in the format "randomstring_guest@explorins.com"
|
|
1162
|
+
* Get JWT payload without validation
|
|
1166
1163
|
*/
|
|
1167
|
-
declare function
|
|
1164
|
+
declare function getJWTPayload(jwtToken: string): JWTPayload | null;
|
|
1168
1165
|
|
|
1169
1166
|
/**
|
|
1170
|
-
*
|
|
1167
|
+
* In-memory User Cache
|
|
1168
|
+
*
|
|
1169
|
+
* Provides secure, storage-free user authentication caching
|
|
1170
|
+
* Uses memory-only storage with TTL expiration for security
|
|
1171
1171
|
*/
|
|
1172
|
+
|
|
1172
1173
|
/**
|
|
1173
|
-
*
|
|
1174
|
+
* In-memory user cache with TTL expiration
|
|
1175
|
+
* Security-first approach - no persistent storage
|
|
1174
1176
|
*/
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1177
|
+
declare class UserCache {
|
|
1178
|
+
private static cache;
|
|
1179
|
+
private static readonly DEFAULT_TTL_MS;
|
|
1180
|
+
/**
|
|
1181
|
+
* Get cached user by identifier
|
|
1182
|
+
* @param identifier - User identifier (email/userId)
|
|
1183
|
+
* @returns Cached user or null if not found/expired
|
|
1184
|
+
*/
|
|
1185
|
+
static get(identifier: string): AuthenticatedUser | null;
|
|
1186
|
+
/**
|
|
1187
|
+
* Cache user with TTL
|
|
1188
|
+
* @param identifier - User identifier
|
|
1189
|
+
* @param user - Authenticated user data
|
|
1190
|
+
* @param ttlMs - Time to live in milliseconds (default: 5 minutes)
|
|
1191
|
+
*/
|
|
1192
|
+
static set(identifier: string, user: AuthenticatedUser, ttlMs?: number): void;
|
|
1193
|
+
/**
|
|
1194
|
+
* Remove user from cache
|
|
1195
|
+
* @param identifier - User identifier
|
|
1196
|
+
*/
|
|
1197
|
+
static delete(identifier: string): boolean;
|
|
1198
|
+
/**
|
|
1199
|
+
* Clear all cached users
|
|
1200
|
+
*/
|
|
1201
|
+
static clear(): void;
|
|
1202
|
+
/**
|
|
1203
|
+
* Get cache size (for debugging)
|
|
1204
|
+
*/
|
|
1205
|
+
static size(): number;
|
|
1206
|
+
/**
|
|
1207
|
+
* Clean up expired entries
|
|
1208
|
+
*/
|
|
1209
|
+
static cleanup(): number;
|
|
1182
1210
|
}
|
|
1183
|
-
/**
|
|
1184
|
-
* Initialize tenant-specific analytics
|
|
1185
|
-
* @param tenantId The tenant ID
|
|
1186
|
-
* @param getTenantConfig Function to retrieve tenant configuration
|
|
1187
|
-
*/
|
|
1188
|
-
declare const initTenantAnalytics: (tenantId: string, getTenantConfig: (id: string) => TenantConfig | null) => void;
|
|
1189
1211
|
|
|
1190
|
-
export { AuthenticationService, FetchHttpClient, KeyWallet, PersService, PersSignerSDK, ReactNativeConfigProvider, SIGNABLE_STATUSES, SigningService, StaticConfigProvider, TransactionErrorHandler, TransactionSigningErrorCode, TransactionSigningService, TransactionSubmissionHandler, TransactionValidator, WalletService, WebAuthnCoordinator, WebConfigProvider, createPersSignerSDK,
|
|
1191
|
-
export type {
|
|
1212
|
+
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 };
|
|
1213
|
+
export type { AuthResponse, AuthenticatedUser, CombinedTransactionStatus, ConfigProvider, HashSigningRequest, HttpClient, HttpRequestOptions, HttpResponse, JWTExtractionResult, JWTPayload, ListWalletsRequest, ListWalletsResponse, LoginRequest, LoginResponse, PersSignerConfig, RegistrationChallenge, RegistrationResult, RelyingPartyConfig, ServiceConfig, ServiceError, SignResponse, SignerApiError, SignerApiResponse, SigningAuthTokens, SigningChallenge, SigningRequest, SubmissionResult, TransactionSigningError, TransactionSigningParams, TransactionSigningResult, TransactionStatusInfo, TypedDataSigningRequest, UserCredentials, WalletItem, WalletListResponse, WebAuthnConfig, WebAuthnProvider };
|