@explorins/pers-signer 1.0.12 → 1.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.cjs.js +819 -990
- package/dist/browser.cjs.js.map +1 -1
- package/dist/browser.d.ts +334 -469
- 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 +597 -576
- 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 +334 -469
- 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,11 +1,228 @@
|
|
|
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
|
|
|
10
|
+
/**
|
|
11
|
+
* Type definitions for the new PERS Signer API v1
|
|
12
|
+
* Based on API_MIGRATION_REFERENCE.md - Updated for wrapped responses
|
|
13
|
+
*/
|
|
14
|
+
interface SignerApiResponse<T = unknown> {
|
|
15
|
+
success: boolean;
|
|
16
|
+
data?: T;
|
|
17
|
+
}
|
|
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;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
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;
|
|
42
|
+
};
|
|
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;
|
|
64
|
+
};
|
|
65
|
+
tenantId: string;
|
|
66
|
+
}
|
|
67
|
+
interface ListWalletsRequest {
|
|
68
|
+
}
|
|
69
|
+
interface ListWalletsResponse {
|
|
70
|
+
success: true;
|
|
71
|
+
data: {
|
|
72
|
+
wallets?: Array<unknown>;
|
|
73
|
+
[key: string]: unknown;
|
|
74
|
+
};
|
|
75
|
+
}
|
|
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
|
+
};
|
|
101
|
+
}
|
|
102
|
+
interface HealthCheckResponse {
|
|
103
|
+
success: boolean;
|
|
104
|
+
}
|
|
105
|
+
|
|
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
|
+
|
|
9
226
|
/**
|
|
10
227
|
* Types for WebAuthn provider abstraction
|
|
11
228
|
*/
|
|
@@ -42,7 +259,8 @@ interface SignResponse {
|
|
|
42
259
|
signature: {
|
|
43
260
|
r: string;
|
|
44
261
|
s: string;
|
|
45
|
-
|
|
262
|
+
v: number;
|
|
263
|
+
encoded: string;
|
|
46
264
|
};
|
|
47
265
|
network: "KeyECDSA";
|
|
48
266
|
dateRequested: string;
|
|
@@ -75,29 +293,9 @@ interface RegistrationResult {
|
|
|
75
293
|
status?: number;
|
|
76
294
|
message?: string;
|
|
77
295
|
}
|
|
78
|
-
/**
|
|
79
|
-
* Wallet listing response
|
|
80
|
-
*/
|
|
81
|
-
interface WalletListResponse$1 {
|
|
82
|
-
wallets: WalletItem$1[];
|
|
83
|
-
status?: number;
|
|
84
|
-
message?: string;
|
|
85
|
-
}
|
|
86
296
|
/**
|
|
87
297
|
* Individual wallet item
|
|
88
298
|
*/
|
|
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;
|
|
100
|
-
}
|
|
101
299
|
/**
|
|
102
300
|
* Hash signing request
|
|
103
301
|
*/
|
|
@@ -147,68 +345,6 @@ interface RelyingPartyConfig {
|
|
|
147
345
|
origin?: string;
|
|
148
346
|
}
|
|
149
347
|
|
|
150
|
-
/**
|
|
151
|
-
* Authentication service for user login and registration
|
|
152
|
-
* Uses constructor-based dependency injection for WebAuthn provider
|
|
153
|
-
*/
|
|
154
|
-
declare class AuthenticationService {
|
|
155
|
-
private webAuthnProvider;
|
|
156
|
-
constructor(webAuthnProvider: WebAuthnProvider);
|
|
157
|
-
/**
|
|
158
|
-
* Authenticate user with username
|
|
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>;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
/**
|
|
186
|
-
* Wallet management service
|
|
187
|
-
* Handles wallet listing and management operations
|
|
188
|
-
*/
|
|
189
|
-
declare class WalletService {
|
|
190
|
-
/**
|
|
191
|
-
* List all wallets for authenticated user
|
|
192
|
-
* @param authToken - Authentication token
|
|
193
|
-
* @returns Promise resolving to wallet list
|
|
194
|
-
*/
|
|
195
|
-
static listWallets(authToken: string): Promise<any>;
|
|
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
348
|
/**
|
|
213
349
|
* Signing service for cryptographic operations
|
|
214
350
|
* Handles hash signing and typed data signing with WebAuthn
|
|
@@ -224,7 +360,7 @@ declare class SigningService {
|
|
|
224
360
|
* @param hash - Hash to sign
|
|
225
361
|
* @returns Promise resolving to signature response
|
|
226
362
|
*/
|
|
227
|
-
signHash(authToken: string, walletId: string, hash: string): Promise<
|
|
363
|
+
signHash(authToken: string, walletId: string, hash: string): Promise<CompleteSignatureResponse['data']>;
|
|
228
364
|
/**
|
|
229
365
|
* Sign EIP-712 typed data using the specified wallet
|
|
230
366
|
* @param authToken - Authentication token
|
|
@@ -234,7 +370,7 @@ declare class SigningService {
|
|
|
234
370
|
* @param value - Data to sign
|
|
235
371
|
* @returns Promise resolving to signature response
|
|
236
372
|
*/
|
|
237
|
-
signTypedData(authToken: string, walletId: string, domain: any, types: Record<string, any[]>, value: Record<string, any>): Promise<
|
|
373
|
+
signTypedData(authToken: string, walletId: string, domain: any, types: Record<string, any[]>, value: Record<string, any>): Promise<CompleteSignatureResponse['data']>;
|
|
238
374
|
/**
|
|
239
375
|
* Generic signing method that handles the complete signing flow
|
|
240
376
|
* @param authToken - Authentication token
|
|
@@ -242,153 +378,15 @@ declare class SigningService {
|
|
|
242
378
|
* @param request - Signing request object
|
|
243
379
|
* @returns Promise resolving to signature response
|
|
244
380
|
*/
|
|
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[]>;
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
/**
|
|
257
|
-
* Service for interacting with PERS (Phygital Experience Rewards System) backend API
|
|
258
|
-
*/
|
|
259
|
-
/**
|
|
260
|
-
* Configuration interface for PERS API
|
|
261
|
-
*/
|
|
262
|
-
interface PersApiConfig {
|
|
263
|
-
baseUrl: string;
|
|
264
|
-
projectKey?: string;
|
|
265
|
-
}
|
|
266
|
-
declare class PersService {
|
|
267
|
-
private static config;
|
|
268
|
-
private static tenantCache;
|
|
269
|
-
private static currentProjectKey;
|
|
270
|
-
private static useStaging;
|
|
271
|
-
/**
|
|
272
|
-
* Configure the PERS API settings
|
|
273
|
-
* @param config - The configuration object
|
|
274
|
-
*/
|
|
275
|
-
static configure(config: Partial<PersApiConfig>): void;
|
|
276
|
-
/**
|
|
277
|
-
* Enable staging mode when project key is not available
|
|
278
|
-
* @param enableStaging Whether to use staging environment
|
|
279
|
-
*/
|
|
280
|
-
static setStagingMode(enableStaging: boolean): void;
|
|
281
|
-
/**
|
|
282
|
-
* Get current configuration
|
|
283
|
-
*/
|
|
284
|
-
static getConfig(): PersApiConfig;
|
|
285
|
-
/**
|
|
286
|
-
* Get tenant information by tenant ID
|
|
287
|
-
* @param tenantId - The tenant ID to retrieve
|
|
288
|
-
* @param authToken - Optional auth token for authentication
|
|
289
|
-
* @returns Promise with tenant public information
|
|
290
|
-
*/
|
|
291
|
-
static getTenantById(tenantId: string, authToken?: string): Promise<TenantPublicDTO>;
|
|
292
|
-
/**
|
|
293
|
-
* Initialize tenant configuration from JWT
|
|
294
|
-
* @param tenantId - The tenant ID from JWT payload
|
|
295
|
-
* @param authToken - Optional auth token for authentication
|
|
296
|
-
* @returns Promise with tenant information
|
|
297
|
-
*/
|
|
298
|
-
static initializeTenant(tenantId: string, authToken?: string): Promise<TenantPublicDTO>;
|
|
299
|
-
/**
|
|
300
|
-
* Get the current project key (either from tenant or fallback)
|
|
301
|
-
* @returns The project key to use for API calls
|
|
302
|
-
*/
|
|
303
|
-
private static getProjectKey;
|
|
304
|
-
/**
|
|
305
|
-
* Clear tenant cache and reset project key
|
|
306
|
-
*/
|
|
307
|
-
static clearTenantCache(): void;
|
|
308
|
-
/**
|
|
309
|
-
* Authenticates a user with the PERS backend using their auth token
|
|
310
|
-
*
|
|
311
|
-
* @param authToken - The authentication token received from DFNS after login/registration
|
|
312
|
-
* @returns A promise that resolves to the authentication response
|
|
313
|
-
* @throws If the request fails
|
|
314
|
-
*/
|
|
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>;
|
|
325
|
-
/**
|
|
326
|
-
* Submits a transaction by calling the backend endpoint
|
|
327
|
-
*
|
|
328
|
-
* @param transactionId - The ID of the transaction to submit
|
|
329
|
-
* @param signedTransactionOrSignature - The signed transaction data or EIP-712 signature
|
|
330
|
-
* @param persAccessToken - The PERS access token for authentication (Bearer)
|
|
331
|
-
* @param submissionType - The transaction format type
|
|
332
|
-
* @returns A promise that resolves to the transaction submission response
|
|
333
|
-
* @throws If the request fails
|
|
334
|
-
*/
|
|
335
|
-
static submitTransaction(transactionId: string, signedTransactionOrSignature: string, persAccessToken: string, submissionType: TransactionFormat): Promise<any>;
|
|
336
|
-
/**
|
|
337
|
-
* Fetches a prepared transaction for signing by transactionId
|
|
338
|
-
* @param transactionId - The transaction ID to fetch
|
|
339
|
-
* @param persAccessToken - The PERS access token for authentication (Bearer)
|
|
340
|
-
* @returns The prepared transaction data
|
|
341
|
-
* @throws If the request fails
|
|
342
|
-
*/
|
|
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[]>;
|
|
379
|
-
/**
|
|
380
|
-
* Helper method to determine if transaction data is available for signing
|
|
381
|
-
* @param transactionResponse - Response from prepare or fetch transaction
|
|
382
|
-
* @returns boolean indicating if transaction can be signed
|
|
383
|
-
*/
|
|
384
|
-
static isTransactionReadyForSigning(transactionResponse: TransactionRequestResponseDTO): boolean;
|
|
381
|
+
private signRequest;
|
|
385
382
|
/**
|
|
386
|
-
*
|
|
387
|
-
* @param
|
|
388
|
-
* @
|
|
389
|
-
* @
|
|
383
|
+
* Sign multiple requests in batch (when backend supports it)
|
|
384
|
+
* @param authToken - Authentication token
|
|
385
|
+
* @param walletId - Wallet identifier
|
|
386
|
+
* @param requests - Array of signing requests
|
|
387
|
+
* @returns Promise resolving to array of signature responses
|
|
390
388
|
*/
|
|
391
|
-
|
|
389
|
+
signBatch(authToken: string, walletId: string, requests: SigningRequest[]): Promise<CompleteSignatureResponse['data'][]>;
|
|
392
390
|
}
|
|
393
391
|
|
|
394
392
|
/**
|
|
@@ -396,65 +394,19 @@ declare class PersService {
|
|
|
396
394
|
*/
|
|
397
395
|
|
|
398
396
|
/**
|
|
399
|
-
*
|
|
400
|
-
*/
|
|
401
|
-
interface WalletConfig {
|
|
402
|
-
id: string;
|
|
403
|
-
name: string;
|
|
404
|
-
address?: string;
|
|
405
|
-
credentialId?: string;
|
|
406
|
-
publicKey?: string;
|
|
407
|
-
createdAt?: Date;
|
|
408
|
-
}
|
|
409
|
-
/**
|
|
410
|
-
* Authentication token structure
|
|
411
|
-
*/
|
|
412
|
-
interface AuthToken {
|
|
413
|
-
token: string;
|
|
414
|
-
expiresAt: Date;
|
|
415
|
-
refreshToken?: string;
|
|
416
|
-
}
|
|
417
|
-
/**
|
|
418
|
-
* User authentication state
|
|
419
|
-
*/
|
|
420
|
-
interface AuthState {
|
|
421
|
-
isAuthenticated: boolean;
|
|
422
|
-
token?: AuthToken;
|
|
423
|
-
user?: UserProfile;
|
|
424
|
-
wallets?: WalletConfig[];
|
|
425
|
-
}
|
|
426
|
-
/**
|
|
427
|
-
* User profile information
|
|
428
|
-
*/
|
|
429
|
-
interface UserProfile {
|
|
430
|
-
id: string;
|
|
431
|
-
username: string;
|
|
432
|
-
email?: string;
|
|
433
|
-
createdAt: Date;
|
|
434
|
-
lastLoginAt?: Date;
|
|
435
|
-
}
|
|
436
|
-
/**
|
|
437
|
-
* Prepared transaction from PERS service
|
|
438
|
-
*/
|
|
439
|
-
interface PreparedTransaction {
|
|
440
|
-
id: string;
|
|
441
|
-
transactionData: AnyTransactionData;
|
|
442
|
-
metadata?: Record<string, any>;
|
|
443
|
-
createdAt: Date;
|
|
444
|
-
expiresAt?: Date;
|
|
445
|
-
}
|
|
446
|
-
/**
|
|
447
|
-
* Transaction signing result
|
|
397
|
+
* Authentication types for 3-function split architecture
|
|
448
398
|
*/
|
|
449
|
-
interface
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
399
|
+
interface AuthenticatedUser {
|
|
400
|
+
identifier: string;
|
|
401
|
+
signerAuthToken: string;
|
|
402
|
+
persAccessToken: string;
|
|
403
|
+
tenantId: string;
|
|
404
|
+
expiresAt: number;
|
|
453
405
|
}
|
|
454
406
|
/**
|
|
455
407
|
* Service configuration options
|
|
456
408
|
*/
|
|
457
|
-
interface ServiceConfig
|
|
409
|
+
interface ServiceConfig {
|
|
458
410
|
apiUrl: string;
|
|
459
411
|
environment: 'development' | 'staging' | 'production';
|
|
460
412
|
timeout?: number;
|
|
@@ -469,15 +421,6 @@ interface ServiceError {
|
|
|
469
421
|
details?: any;
|
|
470
422
|
timestamp: Date;
|
|
471
423
|
}
|
|
472
|
-
/**
|
|
473
|
-
* API response wrapper
|
|
474
|
-
*/
|
|
475
|
-
interface ApiResponse<T = any> {
|
|
476
|
-
success: boolean;
|
|
477
|
-
data?: T;
|
|
478
|
-
error?: ServiceError;
|
|
479
|
-
metadata?: Record<string, any>;
|
|
480
|
-
}
|
|
481
424
|
|
|
482
425
|
interface GetWalletResponse {
|
|
483
426
|
id: string;
|
|
@@ -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: PersSignerConfig);
|
|
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,69 +790,44 @@ declare function setHttpClient(client: HttpClient): void;
|
|
|
870
790
|
declare function getHttpClient(): HttpClient;
|
|
871
791
|
|
|
872
792
|
/**
|
|
873
|
-
*
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
*
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
*
|
|
883
|
-
* Falls back to browser implementation for React Native Web (Expo Web)
|
|
884
|
-
*/
|
|
885
|
-
|
|
886
|
-
/**
|
|
887
|
-
* Get WebAuthn provider for React Native environments
|
|
888
|
-
*/
|
|
889
|
-
declare function getReactNativeWebAuthnProvider(): Promise<WebAuthnProvider>;
|
|
890
|
-
|
|
891
|
-
/**
|
|
892
|
-
* PERS Blockchain Signer SDK - Simple Orchestrator
|
|
793
|
+
* PERS Blockchain Signer SDK
|
|
794
|
+
*
|
|
795
|
+
* A lightweight blockchain transaction signing SDK with WebAuthn authentication.
|
|
796
|
+
* Provides 5 focused methods for complete transaction lifecycle management:
|
|
797
|
+
*
|
|
798
|
+
* 1. loginUser(jwtToken) - Authenticate user with 5-minute caching
|
|
799
|
+
* 2. signTransaction(signingData, jwtToken) - Sign transactions with auto-login
|
|
800
|
+
* 3. submitTransaction(signedTx, jwtToken) - Submit signed transactions to blockchain
|
|
801
|
+
* 4. signPersTransaction(jwtToken) - Legacy one-liner for backward compatibility
|
|
802
|
+
* 5. signAndSubmitPersTransaction(jwtToken) - Complete sign + submit flow
|
|
893
803
|
*
|
|
894
|
-
*
|
|
895
|
-
*
|
|
804
|
+
* @example
|
|
805
|
+
* ```typescript
|
|
806
|
+
* import { createPersSignerSDK } from '@explorins/pers-signer';
|
|
807
|
+
*
|
|
808
|
+
* const sdk = createPersSignerSDK({
|
|
809
|
+
* webAuthnProvider: myWebAuthnProvider,
|
|
810
|
+
* ethersProviderUrl: 'https://ethereum-rpc.com'
|
|
811
|
+
* });
|
|
812
|
+
*
|
|
813
|
+
* // Quick sign and submit
|
|
814
|
+
* const result = await sdk.signAndSubmitPersTransaction(jwtToken);
|
|
815
|
+
* if (result.success) {
|
|
816
|
+
* console.log('Transaction submitted:', result.transactionHash);
|
|
817
|
+
* }
|
|
818
|
+
* ```
|
|
896
819
|
*/
|
|
897
820
|
|
|
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
|
-
/**
|
|
913
|
-
* User information for authentication
|
|
914
|
-
*/
|
|
915
|
-
interface SignerUserInfo {
|
|
916
|
-
identifier: string;
|
|
917
|
-
email?: string;
|
|
918
|
-
id?: string;
|
|
919
|
-
}
|
|
920
821
|
/**
|
|
921
|
-
*
|
|
822
|
+
* Configuration interface for the PERS Signer SDK
|
|
823
|
+
*
|
|
824
|
+
* @interface PersSignerConfig
|
|
825
|
+
* @property {string} [tenantId] - Optional tenant identifier for multi-tenant applications
|
|
826
|
+
* @property {string} [ethersProviderUrl] - Custom Ethereum RPC provider URL
|
|
827
|
+
* @property {WebAuthnProvider} webAuthnProvider - WebAuthn provider for secure authentication
|
|
828
|
+
* @property {string} [apiUrl] - Custom API base URL (defaults to production)
|
|
829
|
+
* @property {string} [relyingPartyName] - WebAuthn relying party name for authentication
|
|
922
830
|
*/
|
|
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
831
|
interface PersSignerConfig {
|
|
937
832
|
tenantId?: string;
|
|
938
833
|
ethersProviderUrl?: string;
|
|
@@ -940,116 +835,180 @@ interface PersSignerConfig {
|
|
|
940
835
|
apiUrl?: string;
|
|
941
836
|
relyingPartyName?: string;
|
|
942
837
|
}
|
|
943
|
-
interface SigningResult {
|
|
944
|
-
success: boolean;
|
|
945
|
-
transactionHash?: string;
|
|
946
|
-
error?: string;
|
|
947
|
-
}
|
|
948
838
|
/**
|
|
949
|
-
*
|
|
839
|
+
* PERS Blockchain Signer SDK Class
|
|
840
|
+
*
|
|
841
|
+
* Main SDK class providing blockchain transaction signing capabilities with WebAuthn authentication.
|
|
842
|
+
* Implements a clean 5-method API for complete transaction lifecycle management.
|
|
843
|
+
*
|
|
844
|
+
* Features:
|
|
845
|
+
* - WebAuthn-based secure authentication
|
|
846
|
+
* - 5-minute user session caching
|
|
847
|
+
* - Automatic transaction data fetching
|
|
848
|
+
* - Blockchain transaction signing and submission
|
|
849
|
+
* - Multi-tenant support
|
|
950
850
|
*
|
|
951
|
-
*
|
|
952
|
-
* No complex initialization needed - services are already configured.
|
|
851
|
+
* @class PersSignerSDK
|
|
953
852
|
*/
|
|
954
853
|
declare class PersSignerSDK {
|
|
955
854
|
private config;
|
|
956
|
-
private
|
|
957
|
-
private signingService;
|
|
855
|
+
private authenticationService;
|
|
958
856
|
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
|
-
/**
|
|
977
|
-
* Register new user - uses existing AuthenticationService
|
|
978
|
-
*/
|
|
979
|
-
registerUser(identifier: string): Promise<{
|
|
980
|
-
authToken: string;
|
|
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
|
|
997
|
-
*/
|
|
998
|
-
signTransactionData(signerAuthToken: string, signingData: AnyTransactionData): Promise<string>;
|
|
999
|
-
/**
|
|
1000
|
-
* Submit signed transaction to PERS - uses existing PersService
|
|
1001
|
-
*/
|
|
1002
|
-
submitTransaction(transactionId: string, signature: string, persAccessToken: string, transactionFormat?: TransactionFormat): Promise<{
|
|
1003
|
-
transactionHash?: string;
|
|
1004
|
-
success: boolean;
|
|
1005
|
-
}>;
|
|
1006
|
-
/**
|
|
1007
|
-
* Check if user exists - uses existing AuthenticationService
|
|
1008
|
-
*/
|
|
1009
|
-
checkUserExists(identifier: string): Promise<boolean>;
|
|
1010
|
-
/**
|
|
1011
|
-
* Get user wallets - uses existing WalletService
|
|
1012
|
-
*/
|
|
1013
|
-
getUserWallets(signerAuthToken: string): Promise<any>;
|
|
1014
|
-
/**
|
|
1015
|
-
* Get transaction status - uses existing PersService
|
|
1016
|
-
*/
|
|
1017
|
-
getTransactionStatus(transactionId: string, persAccessToken: string): Promise<{
|
|
1018
|
-
status: string;
|
|
1019
|
-
transactionHash?: string;
|
|
1020
|
-
}>;
|
|
1021
|
-
/**
|
|
1022
|
-
* Initialize tenant - uses existing PersService
|
|
1023
|
-
*/
|
|
1024
|
-
initializeTenant(tenantId: string): Promise<void>;
|
|
1025
|
-
/**
|
|
1026
|
-
* Extract and validate JWT token from URL search parameters
|
|
1027
|
-
* Uses a simpler approach compatible with browser environments
|
|
1028
|
-
*/
|
|
1029
|
-
extractJWTFromURL(searchParams: URLSearchParams): JWTExtractionResult;
|
|
1030
|
-
/**
|
|
1031
|
-
* Initialize tenant from JWT payload using existing PersService
|
|
1032
|
-
*/
|
|
1033
|
-
initializeTenantFromJWT(payload: JWTPayload): Promise<string>;
|
|
1034
857
|
/**
|
|
1035
|
-
*
|
|
858
|
+
* Initialize the PERS Signer SDK
|
|
859
|
+
*
|
|
860
|
+
* @param {PersSignerConfig} config - SDK configuration object
|
|
861
|
+
* @throws {Error} If required configuration is missing
|
|
1036
862
|
*/
|
|
863
|
+
constructor(config: PersSignerConfig);
|
|
1037
864
|
/**
|
|
1038
|
-
* Authenticate user
|
|
865
|
+
* Authenticate user and cache session for 5 minutes
|
|
866
|
+
*
|
|
867
|
+
* Validates JWT token, authenticates with both signer and PERS backends,
|
|
868
|
+
* and caches the authenticated user session to avoid repeated authentication.
|
|
869
|
+
*
|
|
870
|
+
* @param {string} jwtToken - JWT token containing user identifier and tenant info
|
|
871
|
+
* @returns {Promise<AuthenticatedUser>} Authenticated user with access tokens
|
|
872
|
+
* @throws {Error} If JWT is invalid, expired, or authentication fails
|
|
873
|
+
*
|
|
874
|
+
* @example
|
|
875
|
+
* ```typescript
|
|
876
|
+
* try {
|
|
877
|
+
* const user = await sdk.loginUser(jwtToken);
|
|
878
|
+
* console.log('Authenticated:', user.identifier);
|
|
879
|
+
* } catch (error) {
|
|
880
|
+
* console.error('Authentication failed:', error.message);
|
|
881
|
+
* }
|
|
882
|
+
* ```
|
|
883
|
+
*/
|
|
884
|
+
loginUser(jwtToken: string): Promise<AuthenticatedUser>;
|
|
885
|
+
/**
|
|
886
|
+
* Sign a PERS transaction (legacy compatibility method)
|
|
887
|
+
*
|
|
888
|
+
* Automatically handles user authentication, transaction data fetching,
|
|
889
|
+
* and transaction signing in a single call. This is the legacy method
|
|
890
|
+
* maintained for backward compatibility.
|
|
891
|
+
*
|
|
892
|
+
* @param {string} jwtToken - JWT token containing transaction ID and user info
|
|
893
|
+
* @returns {Promise<TransactionSigningResult>} Signing result with signature and metadata
|
|
894
|
+
* @throws {Error} If authentication fails, transaction ID missing, or signing fails
|
|
895
|
+
*
|
|
896
|
+
* @example
|
|
897
|
+
* ```typescript
|
|
898
|
+
* try {
|
|
899
|
+
* const result = await sdk.signPersTransaction(jwtToken);
|
|
900
|
+
* if (result.success) {
|
|
901
|
+
* console.log('Transaction signed:', result.signature);
|
|
902
|
+
* }
|
|
903
|
+
* } catch (error) {
|
|
904
|
+
* console.error('Signing failed:', error.message);
|
|
905
|
+
* }
|
|
906
|
+
* ```
|
|
907
|
+
*/
|
|
908
|
+
signPersTransaction(jwtToken: string): Promise<TransactionSigningResult>;
|
|
909
|
+
/**
|
|
910
|
+
* Sign a transaction with provided signing data
|
|
911
|
+
*
|
|
912
|
+
* Low-level method to sign transactions when you already have the signing data.
|
|
913
|
+
* Automatically handles user authentication and applies the blockchain signature.
|
|
914
|
+
*
|
|
915
|
+
* @param {CounterfactualWalletTransactionResponse | LegacyTransaction} signingData - Transaction data to sign
|
|
916
|
+
* @param {string} jwtToken - JWT token containing transaction ID and user info
|
|
917
|
+
* @returns {Promise<TransactionSigningResult>} Signing result with signature and metadata
|
|
918
|
+
* @throws {Error} If authentication fails, transaction ID missing, or signing fails
|
|
919
|
+
*
|
|
920
|
+
* @example
|
|
921
|
+
* ```typescript
|
|
922
|
+
* const signingData = await getTransactionData(transactionId);
|
|
923
|
+
* const result = await sdk.signTransaction(signingData, jwtToken);
|
|
924
|
+
* console.log('Signed transaction:', result.signature);
|
|
925
|
+
* ```
|
|
1039
926
|
*/
|
|
1040
|
-
|
|
927
|
+
signTransaction(signingData: CounterfactualWalletTransactionResponse$1 | LegacyTransaction, jwtToken: string): Promise<TransactionSigningResult>;
|
|
1041
928
|
/**
|
|
1042
|
-
*
|
|
929
|
+
* Complete transaction flow: sign and submit in one call
|
|
930
|
+
*
|
|
931
|
+
* Convenience method that combines signing and submission into a single operation.
|
|
932
|
+
* This is the recommended method for most use cases as it handles the complete
|
|
933
|
+
* transaction lifecycle automatically.
|
|
934
|
+
*
|
|
935
|
+
* @param {string} jwtToken - JWT token containing transaction ID and user info
|
|
936
|
+
* @returns {Promise<SubmissionResult>} Submission result with transaction hash and status
|
|
937
|
+
* @throws {Error} If authentication, signing, or submission fails
|
|
938
|
+
*
|
|
939
|
+
* @example
|
|
940
|
+
* ```typescript
|
|
941
|
+
* try {
|
|
942
|
+
* const result = await sdk.signAndSubmitPersTransaction(jwtToken);
|
|
943
|
+
* if (result.success) {
|
|
944
|
+
* console.log('Transaction completed:', result.transactionHash);
|
|
945
|
+
* if (result.shouldRedirect) {
|
|
946
|
+
* window.location.href = result.redirectUrl;
|
|
947
|
+
* }
|
|
948
|
+
* }
|
|
949
|
+
* } catch (error) {
|
|
950
|
+
* console.error('Transaction failed:', error.message);
|
|
951
|
+
* }
|
|
952
|
+
* ```
|
|
953
|
+
*/
|
|
954
|
+
signAndSubmitPersTransaction(jwtToken: string): Promise<SubmissionResult>;
|
|
955
|
+
/**
|
|
956
|
+
* Submit a signed transaction to the blockchain
|
|
957
|
+
*
|
|
958
|
+
* Takes a signed transaction result and submits it to the blockchain network.
|
|
959
|
+
* Returns detailed submission results including transaction hash and any
|
|
960
|
+
* redirect information for UI flows.
|
|
961
|
+
*
|
|
962
|
+
* @param {TransactionSigningResult} signingResult - Result from a successful transaction signing
|
|
963
|
+
* @param {string} jwtToken - JWT token containing tenant and user info
|
|
964
|
+
* @returns {Promise<SubmissionResult>} Submission result with transaction hash and status
|
|
965
|
+
* @throws {Error} If signing result is invalid, JWT is missing tenantId, or submission fails
|
|
966
|
+
*
|
|
967
|
+
* @example
|
|
968
|
+
* ```typescript
|
|
969
|
+
* const signedTx = await sdk.signPersTransaction(jwtToken);
|
|
970
|
+
* const result = await sdk.submitTransaction(signedTx, jwtToken);
|
|
971
|
+
* console.log('Transaction submitted:', result.transactionHash);
|
|
972
|
+
* ```
|
|
1043
973
|
*/
|
|
1044
|
-
|
|
974
|
+
submitTransaction(signingResult: TransactionSigningResult, jwtToken: string): Promise<SubmissionResult>;
|
|
1045
975
|
/**
|
|
1046
|
-
*
|
|
976
|
+
* Clear user authentication cache
|
|
977
|
+
*
|
|
978
|
+
* Removes all cached user sessions, forcing fresh authentication
|
|
979
|
+
* on the next method call. Useful for logout scenarios or when
|
|
980
|
+
* switching between different user contexts.
|
|
981
|
+
*
|
|
982
|
+
* @example
|
|
983
|
+
* ```typescript
|
|
984
|
+
* // Clear cache on user logout
|
|
985
|
+
* sdk.clearCache();
|
|
986
|
+
* console.log('User cache cleared');
|
|
987
|
+
* ```
|
|
1047
988
|
*/
|
|
1048
|
-
|
|
989
|
+
clearCache(): void;
|
|
1049
990
|
}
|
|
1050
991
|
/**
|
|
1051
|
-
*
|
|
1052
|
-
*
|
|
992
|
+
* Create a new PERS Signer SDK instance
|
|
993
|
+
*
|
|
994
|
+
* Factory function to create and configure a new SDK instance with the provided
|
|
995
|
+
* configuration. This is the recommended way to initialize the SDK.
|
|
996
|
+
*
|
|
997
|
+
* @param {PersSignerConfig} config - SDK configuration object
|
|
998
|
+
* @returns {PersSignerSDK} Configured SDK instance ready for use
|
|
999
|
+
* @throws {Error} If required configuration is missing or invalid
|
|
1000
|
+
*
|
|
1001
|
+
* @example
|
|
1002
|
+
* ```typescript
|
|
1003
|
+
* import { createPersSignerSDK, getWebAuthnProvider } from '@explorins/pers-signer';
|
|
1004
|
+
*
|
|
1005
|
+
* const webAuthnProvider = await getWebAuthnProvider();
|
|
1006
|
+
* const sdk = createPersSignerSDK({
|
|
1007
|
+
* webAuthnProvider,
|
|
1008
|
+
* ethersProviderUrl: 'https://mainnet.infura.io/v3/YOUR_KEY',
|
|
1009
|
+
* tenantId: 'your-tenant-id'
|
|
1010
|
+
* });
|
|
1011
|
+
* ```
|
|
1053
1012
|
*/
|
|
1054
1013
|
declare function createPersSignerSDK(config: PersSignerConfig): PersSignerSDK;
|
|
1055
1014
|
|
|
@@ -1076,116 +1035,178 @@ interface WalletItem {
|
|
|
1076
1035
|
}
|
|
1077
1036
|
|
|
1078
1037
|
/**
|
|
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
|
|
1038
|
+
* Authenticated user with all required tokens
|
|
1103
1039
|
*/
|
|
1104
|
-
|
|
1040
|
+
interface SignerAuthenticatedUser {
|
|
1041
|
+
identifier: string;
|
|
1042
|
+
signerAuthToken: string;
|
|
1043
|
+
persAccessToken: string;
|
|
1044
|
+
}
|
|
1105
1045
|
/**
|
|
1106
|
-
*
|
|
1107
|
-
*
|
|
1108
|
-
*
|
|
1109
|
-
* @returns The parameter value or null if not found
|
|
1046
|
+
* Authentication service for user login and registration
|
|
1047
|
+
* Uses constructor-based dependency injection for WebAuthn provider
|
|
1048
|
+
* Updated for new v1 API endpoints
|
|
1110
1049
|
*/
|
|
1111
|
-
declare
|
|
1050
|
+
declare class AuthenticationService {
|
|
1051
|
+
private signerToken;
|
|
1052
|
+
private config;
|
|
1053
|
+
private webAuthnProvider;
|
|
1054
|
+
constructor(config: PersSignerConfig);
|
|
1055
|
+
/**
|
|
1056
|
+
* Login with PERS token to get signer JWT
|
|
1057
|
+
* @param persToken - PERS JWT from PERS authentication
|
|
1058
|
+
* @returns Promise resolving to login response or provider challenge data
|
|
1059
|
+
*/
|
|
1060
|
+
loginWithPersToken(persToken: string): Promise<JWTLoginResponse | unknown>;
|
|
1061
|
+
/**
|
|
1062
|
+
* Verify signer token validity
|
|
1063
|
+
* @param token - Signer JWT to verify
|
|
1064
|
+
* @returns Promise resolving to verification result
|
|
1065
|
+
*/
|
|
1066
|
+
verifyToken(token: string): Promise<VerifyTokenResponse>;
|
|
1067
|
+
/**
|
|
1068
|
+
* Initialize user registration
|
|
1069
|
+
* @param persToken - PERS JWT token (registration is public)
|
|
1070
|
+
* @returns Promise resolving to registration challenge
|
|
1071
|
+
*/
|
|
1072
|
+
initializeRegistration(persToken: string): Promise<unknown>;
|
|
1073
|
+
/**
|
|
1074
|
+
* Get current signer token
|
|
1075
|
+
* @returns The current signer JWT token
|
|
1076
|
+
*/
|
|
1077
|
+
getSignerToken(): string | null;
|
|
1078
|
+
/**
|
|
1079
|
+
* Set signer token (for external token management)
|
|
1080
|
+
* @param token - Signer JWT token
|
|
1081
|
+
*/
|
|
1082
|
+
setSignerToken(token: string): void;
|
|
1083
|
+
/**
|
|
1084
|
+
* Complete registration with WebAuthn challenge data (v1 API format)
|
|
1085
|
+
* @param tmpAuthToken - Temporary auth token from init registration (temporaryAuthenticationToken)
|
|
1086
|
+
* @param signedChallenge - WebAuthn credential response (will be restructured for backend)
|
|
1087
|
+
* @param persToken - PERS JWT token (authToken)
|
|
1088
|
+
* @returns Promise resolving to registration result
|
|
1089
|
+
*/
|
|
1090
|
+
completeRegistrationWithChallenge(tmpAuthToken: string | null, signedChallenge: any, persToken: string): Promise<JWTLoginResponse | unknown>;
|
|
1091
|
+
/**
|
|
1092
|
+
* Combined authentication flow - handles both login and registration
|
|
1093
|
+
* @param identifier - User identifier (email/userId)
|
|
1094
|
+
* @param persAccessToken - PERS JWT token for authentication
|
|
1095
|
+
* @param webAuthnProvider - WebAuthn provider for credential creation
|
|
1096
|
+
* @param relyingPartyConfig - Configuration for WebAuthn relying party
|
|
1097
|
+
* @returns Promise resolving to authenticated user with signer token
|
|
1098
|
+
*/
|
|
1099
|
+
combinedAuthentication(identifier: string, persAccessToken: string): Promise<SignerAuthenticatedUser>;
|
|
1100
|
+
}
|
|
1101
|
+
|
|
1112
1102
|
/**
|
|
1113
|
-
*
|
|
1114
|
-
*
|
|
1115
|
-
* @returns A URLSearchParams object
|
|
1103
|
+
* Health check service for signer API
|
|
1104
|
+
* Handles health check operations for the new v1 API
|
|
1116
1105
|
*/
|
|
1117
|
-
declare
|
|
1106
|
+
declare class HealthService {
|
|
1107
|
+
/**
|
|
1108
|
+
* Perform health check on the signer API
|
|
1109
|
+
* @returns Promise resolving to health check result
|
|
1110
|
+
*/
|
|
1111
|
+
static checkHealth(): Promise<HealthCheckResponse>;
|
|
1112
|
+
}
|
|
1113
|
+
|
|
1118
1114
|
/**
|
|
1119
|
-
*
|
|
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
|
|
1115
|
+
* Browser-specific WebAuthn provider using DFNS browser SDK
|
|
1123
1116
|
*/
|
|
1124
|
-
|
|
1117
|
+
|
|
1125
1118
|
/**
|
|
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
|
|
1119
|
+
* Get WebAuthn provider for browser environments
|
|
1131
1120
|
*/
|
|
1132
|
-
declare function
|
|
1121
|
+
declare function getBrowserWebAuthnProvider(): Promise<WebAuthnProvider>;
|
|
1133
1122
|
|
|
1134
1123
|
/**
|
|
1135
|
-
*
|
|
1124
|
+
* React Native-specific WebAuthn provider using DFNS React Native SDK
|
|
1125
|
+
* Falls back to browser implementation for React Native Web (Expo Web)
|
|
1136
1126
|
*/
|
|
1127
|
+
|
|
1137
1128
|
/**
|
|
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
|
|
1129
|
+
* Get WebAuthn provider for React Native environments
|
|
1143
1130
|
*/
|
|
1144
|
-
declare function
|
|
1131
|
+
declare function getReactNativeWebAuthnProvider(): Promise<WebAuthnProvider>;
|
|
1132
|
+
|
|
1145
1133
|
/**
|
|
1146
|
-
*
|
|
1147
|
-
* Logs search parameter changes when the component mounts/updates
|
|
1134
|
+
* JWT Utility Functions
|
|
1148
1135
|
*
|
|
1149
|
-
*
|
|
1136
|
+
* Browser-compatible JWT handling without external dependencies
|
|
1150
1137
|
*/
|
|
1151
|
-
|
|
1152
|
-
|
|
1138
|
+
interface JWTPayload {
|
|
1139
|
+
email?: string;
|
|
1140
|
+
identifierEmail?: string;
|
|
1141
|
+
userId?: string;
|
|
1142
|
+
tenantId?: string;
|
|
1143
|
+
transactionId?: string;
|
|
1144
|
+
exp?: number;
|
|
1145
|
+
[key: string]: any;
|
|
1146
|
+
}
|
|
1147
|
+
interface JWTExtractionResult {
|
|
1148
|
+
payload: JWTPayload | null;
|
|
1149
|
+
isExpired: boolean;
|
|
1150
|
+
}
|
|
1153
1151
|
/**
|
|
1154
|
-
*
|
|
1155
|
-
*
|
|
1152
|
+
* Extract and validate JWT token payload
|
|
1153
|
+
* Uses a browser-compatible approach without external dependencies
|
|
1156
1154
|
*/
|
|
1157
|
-
declare function
|
|
1155
|
+
declare function extractJWTFromToken(jwtToken: string): JWTExtractionResult;
|
|
1158
1156
|
/**
|
|
1159
|
-
*
|
|
1160
|
-
* @returns A username in the format "user_[random string]"
|
|
1157
|
+
* Check if a JWT token is expired
|
|
1161
1158
|
*/
|
|
1162
|
-
declare function
|
|
1159
|
+
declare function isJWTExpired(jwtToken: string): boolean;
|
|
1163
1160
|
/**
|
|
1164
|
-
*
|
|
1165
|
-
* @returns A guest email in the format "randomstring_guest@explorins.com"
|
|
1161
|
+
* Get JWT payload without validation
|
|
1166
1162
|
*/
|
|
1167
|
-
declare function
|
|
1163
|
+
declare function getJWTPayload(jwtToken: string): JWTPayload | null;
|
|
1168
1164
|
|
|
1169
1165
|
/**
|
|
1170
|
-
*
|
|
1166
|
+
* In-memory User Cache
|
|
1167
|
+
*
|
|
1168
|
+
* Provides secure, storage-free user authentication caching
|
|
1169
|
+
* Uses memory-only storage with TTL expiration for security
|
|
1171
1170
|
*/
|
|
1171
|
+
|
|
1172
1172
|
/**
|
|
1173
|
-
*
|
|
1173
|
+
* In-memory user cache with TTL expiration
|
|
1174
|
+
* Security-first approach - no persistent storage
|
|
1174
1175
|
*/
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1176
|
+
declare class UserCache {
|
|
1177
|
+
private static cache;
|
|
1178
|
+
private static readonly DEFAULT_TTL_MS;
|
|
1179
|
+
/**
|
|
1180
|
+
* Get cached user by identifier
|
|
1181
|
+
* @param identifier - User identifier (email/userId)
|
|
1182
|
+
* @returns Cached user or null if not found/expired
|
|
1183
|
+
*/
|
|
1184
|
+
static get(identifier: string): AuthenticatedUser | null;
|
|
1185
|
+
/**
|
|
1186
|
+
* Cache user with TTL
|
|
1187
|
+
* @param identifier - User identifier
|
|
1188
|
+
* @param user - Authenticated user data
|
|
1189
|
+
* @param ttlMs - Time to live in milliseconds (default: 5 minutes)
|
|
1190
|
+
*/
|
|
1191
|
+
static set(identifier: string, user: AuthenticatedUser, ttlMs?: number): void;
|
|
1192
|
+
/**
|
|
1193
|
+
* Remove user from cache
|
|
1194
|
+
* @param identifier - User identifier
|
|
1195
|
+
*/
|
|
1196
|
+
static delete(identifier: string): boolean;
|
|
1197
|
+
/**
|
|
1198
|
+
* Clear all cached users
|
|
1199
|
+
*/
|
|
1200
|
+
static clear(): void;
|
|
1201
|
+
/**
|
|
1202
|
+
* Get cache size (for debugging)
|
|
1203
|
+
*/
|
|
1204
|
+
static size(): number;
|
|
1205
|
+
/**
|
|
1206
|
+
* Clean up expired entries
|
|
1207
|
+
*/
|
|
1208
|
+
static cleanup(): number;
|
|
1182
1209
|
}
|
|
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
1210
|
|
|
1190
|
-
export { AuthenticationService, FetchHttpClient, KeyWallet, PersService, PersSignerSDK, ReactNativeConfigProvider, SIGNABLE_STATUSES, SigningService, StaticConfigProvider, TransactionErrorHandler, TransactionSigningErrorCode, TransactionSigningService, TransactionSubmissionHandler, TransactionValidator, WalletService, WebAuthnCoordinator, WebConfigProvider, createPersSignerSDK,
|
|
1191
|
-
export type {
|
|
1211
|
+
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, ServiceConfig, ServiceError, SignResponse, SignerApiError, SignerApiResponse, SigningAuthTokens, SigningChallenge, SigningRequest, SubmissionResult, TransactionSigningError, TransactionSigningParams, TransactionSigningResult, TransactionStatusInfo, TypedDataSigningRequest, UserCredentials, WalletItem, WalletListResponse, WebAuthnConfig, WebAuthnProvider };
|