@explorins/pers-signer 1.0.18 → 1.0.26
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 +730 -9709
- package/dist/browser.cjs.js.map +1 -1
- package/dist/browser.d.ts +252 -301
- package/dist/browser.esm.js +712 -9680
- package/dist/browser.esm.js.map +1 -1
- package/dist/index.cjs.js +813 -10180
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +177 -109
- package/dist/index.esm.js +814 -10182
- package/dist/index.esm.js.map +1 -1
- package/dist/react-native.cjs.js +862 -10018
- package/dist/react-native.cjs.js.map +1 -1
- package/dist/react-native.d.ts +254 -302
- package/dist/react-native.esm.js +844 -9989
- package/dist/react-native.esm.js.map +1 -1
- package/package.json +7 -6
package/dist/browser.d.ts
CHANGED
|
@@ -1,12 +1,69 @@
|
|
|
1
1
|
import * as _explorins_web3_ts_types from '@explorins/web3-ts/types';
|
|
2
2
|
import { LegacyTransaction, AnyTransactionData } from '@explorins/web3-ts/types';
|
|
3
|
-
export { AnyTransactionData,
|
|
3
|
+
export { AnyTransactionData, LegacyTransaction } from '@explorins/web3-ts/types';
|
|
4
4
|
import * as _explorins_pers_shared_browser from '@explorins/pers-shared/browser';
|
|
5
5
|
import { TenantPublicDTO, SessionAuthContextResponseDTO, TransactionFormat, TransactionRequestResponseDTO, CounterfactualWalletTransactionResponse, TransactionStatus } from '@explorins/pers-shared/browser';
|
|
6
|
-
export {
|
|
6
|
+
export { TransactionFormat, TransactionRequestResponseDTO } from '@explorins/pers-shared/browser';
|
|
7
7
|
import { AbstractSigner, Provider, TransactionRequest, TypedDataDomain, TypedDataField } from 'ethers';
|
|
8
8
|
import { CounterfactualWalletTransactionResponse as CounterfactualWalletTransactionResponse$1 } from '@explorins/pers-shared';
|
|
9
9
|
|
|
10
|
+
interface JWTLoginResponse {
|
|
11
|
+
success: true;
|
|
12
|
+
access_token: string;
|
|
13
|
+
token_type: "Bearer";
|
|
14
|
+
expires_in: number;
|
|
15
|
+
user: {
|
|
16
|
+
id: string;
|
|
17
|
+
username: string;
|
|
18
|
+
org_id: string;
|
|
19
|
+
};
|
|
20
|
+
provider?: string;
|
|
21
|
+
}
|
|
22
|
+
interface VerifyTokenResponse {
|
|
23
|
+
valid: boolean;
|
|
24
|
+
provider: string;
|
|
25
|
+
claims: {
|
|
26
|
+
sub: string;
|
|
27
|
+
iss: string;
|
|
28
|
+
aud: string;
|
|
29
|
+
exp: number;
|
|
30
|
+
iat: number;
|
|
31
|
+
user_id: string;
|
|
32
|
+
username: string;
|
|
33
|
+
org_id: string;
|
|
34
|
+
provider: string;
|
|
35
|
+
permissions: unknown;
|
|
36
|
+
};
|
|
37
|
+
tenantId: string;
|
|
38
|
+
}
|
|
39
|
+
interface SigningKey {
|
|
40
|
+
curve: string;
|
|
41
|
+
publicKey: string;
|
|
42
|
+
scheme: string;
|
|
43
|
+
}
|
|
44
|
+
interface Wallet {
|
|
45
|
+
address?: string;
|
|
46
|
+
chainId?: number;
|
|
47
|
+
custodial?: boolean;
|
|
48
|
+
dateCreated?: string;
|
|
49
|
+
externalId?: string;
|
|
50
|
+
id: string;
|
|
51
|
+
name?: string;
|
|
52
|
+
network?: string;
|
|
53
|
+
provider?: string;
|
|
54
|
+
signingKey?: SigningKey;
|
|
55
|
+
status?: string;
|
|
56
|
+
tags?: string[];
|
|
57
|
+
}
|
|
58
|
+
interface CompleteSignatureResponse {
|
|
59
|
+
success: true;
|
|
60
|
+
data: {
|
|
61
|
+
status: string;
|
|
62
|
+
challenge?: unknown;
|
|
63
|
+
signature?: number[];
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
10
67
|
/**
|
|
11
68
|
* Wallet management service
|
|
12
69
|
* Updated for v1 API endpoints per migration reference
|
|
@@ -17,7 +74,7 @@ declare class WalletService {
|
|
|
17
74
|
* @param signerToken - Signer JWT token
|
|
18
75
|
* @returns Promise resolving to wallet data
|
|
19
76
|
*/
|
|
20
|
-
static listWallets(signerToken: string): Promise<
|
|
77
|
+
static listWallets(signerToken: string): Promise<Wallet[]>;
|
|
21
78
|
}
|
|
22
79
|
|
|
23
80
|
/**
|
|
@@ -35,18 +92,12 @@ declare class PersService {
|
|
|
35
92
|
private static tenantCache;
|
|
36
93
|
private static currentProjectKey;
|
|
37
94
|
private static currentTenantId;
|
|
38
|
-
private static useStaging;
|
|
39
95
|
private static readonly TENANT_CACHE_TTL;
|
|
40
96
|
/**
|
|
41
97
|
* Configure the PERS API settings
|
|
42
98
|
* @param config - The configuration object
|
|
43
99
|
*/
|
|
44
100
|
static configure(config: Partial<PersApiConfig>): void;
|
|
45
|
-
/**
|
|
46
|
-
* Enable staging mode when project key is not available
|
|
47
|
-
* @param enableStaging Whether to use staging environment
|
|
48
|
-
*/
|
|
49
|
-
static setStagingMode(enableStaging: boolean): void;
|
|
50
101
|
/**
|
|
51
102
|
* Get current configuration
|
|
52
103
|
*/
|
|
@@ -57,21 +108,21 @@ declare class PersService {
|
|
|
57
108
|
* @param authToken - Optional auth token for authentication
|
|
58
109
|
* @returns Promise with tenant public information
|
|
59
110
|
*/
|
|
60
|
-
static getTenantById(tenantId: string, authToken
|
|
111
|
+
static getTenantById(tenantId: string, authToken: string): Promise<TenantPublicDTO>;
|
|
61
112
|
/**
|
|
62
113
|
* Initialize tenant configuration from JWT
|
|
63
114
|
* @param tenantId - The tenant ID from JWT payload
|
|
64
115
|
* @param authToken - Optional auth token for authentication
|
|
65
116
|
* @returns Promise with tenant information
|
|
66
117
|
*/
|
|
67
|
-
static initializeTenant(tenantId: string, authToken
|
|
118
|
+
static initializeTenant(tenantId: string, authToken: string): Promise<TenantPublicDTO>;
|
|
68
119
|
/**
|
|
69
120
|
* Ensure tenant is initialized and current, with automatic revalidation
|
|
70
121
|
* @param tenantId - The tenant ID to ensure is initialized
|
|
71
122
|
* @param authToken - Optional auth token for authentication
|
|
72
123
|
* @returns Promise with tenant information
|
|
73
124
|
*/
|
|
74
|
-
static ensureTenantInitialized(tenantId: string, authToken
|
|
125
|
+
static ensureTenantInitialized(tenantId: string, authToken: string): Promise<TenantPublicDTO>;
|
|
75
126
|
/**
|
|
76
127
|
* Get the current project key (either from tenant or fallback)
|
|
77
128
|
* @param tenantId - Optional tenant ID to ensure is initialized
|
|
@@ -85,7 +136,7 @@ declare class PersService {
|
|
|
85
136
|
/**
|
|
86
137
|
* Authenticates a user with the PERS backend using their auth token
|
|
87
138
|
*
|
|
88
|
-
* @param authToken - The authentication token received from
|
|
139
|
+
* @param authToken - The authentication token received from backend after login/registration
|
|
89
140
|
* @param tenantId - Optional tenant ID for automatic initialization
|
|
90
141
|
* @returns A promise that resolves to the authentication response
|
|
91
142
|
* @throws If the request fails
|
|
@@ -127,12 +178,78 @@ declare class PersService {
|
|
|
127
178
|
static getTransactionDataForSigning(transactionResponse: TransactionRequestResponseDTO): _explorins_pers_shared_browser.CounterfactualWalletTransactionResponse | _explorins_web3_ts_types.LegacyTransaction;
|
|
128
179
|
}
|
|
129
180
|
|
|
181
|
+
interface GetWalletResponse {
|
|
182
|
+
id: string;
|
|
183
|
+
signingKey: {
|
|
184
|
+
publicKey: string;
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
type WalletMetadata = GetWalletResponse & {
|
|
188
|
+
boundToEvmNetwork: boolean;
|
|
189
|
+
};
|
|
190
|
+
|
|
130
191
|
/**
|
|
131
192
|
* Types for WebAuthn provider abstraction
|
|
132
193
|
*/
|
|
194
|
+
interface WebAuthnAssertion {
|
|
195
|
+
kind: 'Fido2';
|
|
196
|
+
credentialAssertion: {
|
|
197
|
+
credId: string;
|
|
198
|
+
clientData: string;
|
|
199
|
+
authenticatorData: string;
|
|
200
|
+
signature: string;
|
|
201
|
+
userHandle?: string;
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
interface WebAuthnAttestation {
|
|
205
|
+
id: string;
|
|
206
|
+
clientDataJSON: string;
|
|
207
|
+
attestationObject: string;
|
|
208
|
+
}
|
|
209
|
+
interface WebAuthnCredential {
|
|
210
|
+
id: string;
|
|
211
|
+
transports?: AuthenticatorTransport[];
|
|
212
|
+
}
|
|
213
|
+
interface WebAuthnSignChallenge {
|
|
214
|
+
challenge: string;
|
|
215
|
+
challengeIdentifier?: string;
|
|
216
|
+
allowCredentials?: {
|
|
217
|
+
webauthn?: WebAuthnCredential[];
|
|
218
|
+
key?: any[];
|
|
219
|
+
};
|
|
220
|
+
rpId?: string;
|
|
221
|
+
userVerification?: UserVerificationRequirement;
|
|
222
|
+
timeout?: number;
|
|
223
|
+
[key: string]: any;
|
|
224
|
+
}
|
|
225
|
+
interface WebAuthnCreateChallenge {
|
|
226
|
+
challenge: string;
|
|
227
|
+
user: {
|
|
228
|
+
id: string;
|
|
229
|
+
name: string;
|
|
230
|
+
displayName: string;
|
|
231
|
+
};
|
|
232
|
+
rp: {
|
|
233
|
+
id: string;
|
|
234
|
+
name: string;
|
|
235
|
+
};
|
|
236
|
+
pubKeyCredParams: {
|
|
237
|
+
type: "public-key";
|
|
238
|
+
alg: number;
|
|
239
|
+
}[];
|
|
240
|
+
authenticatorSelection?: AuthenticatorSelectionCriteria;
|
|
241
|
+
attestation?: AttestationConveyancePreference;
|
|
242
|
+
timeout?: number;
|
|
243
|
+
excludeCredentials?: {
|
|
244
|
+
id: string;
|
|
245
|
+
type: "public-key";
|
|
246
|
+
transports?: AuthenticatorTransport[];
|
|
247
|
+
}[];
|
|
248
|
+
[key: string]: any;
|
|
249
|
+
}
|
|
133
250
|
interface WebAuthnProvider {
|
|
134
|
-
create(challenge:
|
|
135
|
-
sign(challenge:
|
|
251
|
+
create(challenge: WebAuthnCreateChallenge): Promise<WebAuthnAttestation>;
|
|
252
|
+
sign(challenge: WebAuthnSignChallenge): Promise<WebAuthnAssertion>;
|
|
136
253
|
}
|
|
137
254
|
interface WebAuthnConfig {
|
|
138
255
|
relyingParty: {
|
|
@@ -142,61 +259,6 @@ interface WebAuthnConfig {
|
|
|
142
259
|
};
|
|
143
260
|
}
|
|
144
261
|
|
|
145
|
-
/**
|
|
146
|
-
* Key service response types and interfaces
|
|
147
|
-
*/
|
|
148
|
-
/**
|
|
149
|
-
* Signature response from key signing operations
|
|
150
|
-
*/
|
|
151
|
-
interface SignResponse {
|
|
152
|
-
id: string;
|
|
153
|
-
keyId: string;
|
|
154
|
-
requester: {
|
|
155
|
-
userId: string;
|
|
156
|
-
appId: string;
|
|
157
|
-
};
|
|
158
|
-
requestBody: {
|
|
159
|
-
hash: string;
|
|
160
|
-
kind: "Hash";
|
|
161
|
-
};
|
|
162
|
-
status: "Signed";
|
|
163
|
-
signature: {
|
|
164
|
-
r: string;
|
|
165
|
-
s: string;
|
|
166
|
-
v: number;
|
|
167
|
-
encoded: string;
|
|
168
|
-
};
|
|
169
|
-
network: "KeyECDSA";
|
|
170
|
-
dateRequested: string;
|
|
171
|
-
dateSigned: string;
|
|
172
|
-
walletId: string;
|
|
173
|
-
}
|
|
174
|
-
/**
|
|
175
|
-
* Authentication response from login/register operations
|
|
176
|
-
*/
|
|
177
|
-
interface AuthResponse {
|
|
178
|
-
token: string;
|
|
179
|
-
message?: string;
|
|
180
|
-
status?: number;
|
|
181
|
-
}
|
|
182
|
-
/**
|
|
183
|
-
* Registration challenge response
|
|
184
|
-
*/
|
|
185
|
-
interface RegistrationChallenge {
|
|
186
|
-
temporaryAuthenticationToken: string;
|
|
187
|
-
challenge: any;
|
|
188
|
-
status?: number;
|
|
189
|
-
message?: string;
|
|
190
|
-
}
|
|
191
|
-
/**
|
|
192
|
-
* Registration completion response
|
|
193
|
-
*/
|
|
194
|
-
interface RegistrationResult {
|
|
195
|
-
token: string;
|
|
196
|
-
walletId?: string;
|
|
197
|
-
status?: number;
|
|
198
|
-
message?: string;
|
|
199
|
-
}
|
|
200
262
|
/**
|
|
201
263
|
* Individual wallet item
|
|
202
264
|
*/
|
|
@@ -221,162 +283,6 @@ interface TypedDataSigningRequest {
|
|
|
221
283
|
* Generic signing request
|
|
222
284
|
*/
|
|
223
285
|
type SigningRequest = HashSigningRequest | TypedDataSigningRequest;
|
|
224
|
-
/**
|
|
225
|
-
* Signing challenge response
|
|
226
|
-
*/
|
|
227
|
-
interface SigningChallenge {
|
|
228
|
-
requestBody: any;
|
|
229
|
-
challenge: {
|
|
230
|
-
challengeIdentifier: string;
|
|
231
|
-
[key: string]: any;
|
|
232
|
-
};
|
|
233
|
-
status?: number;
|
|
234
|
-
message?: string;
|
|
235
|
-
}
|
|
236
|
-
/**
|
|
237
|
-
* User credentials for authentication
|
|
238
|
-
*/
|
|
239
|
-
interface UserCredentials {
|
|
240
|
-
username: string;
|
|
241
|
-
appId?: string;
|
|
242
|
-
}
|
|
243
|
-
/**
|
|
244
|
-
* Relying party configuration for WebAuthn
|
|
245
|
-
*/
|
|
246
|
-
interface RelyingPartyConfig {
|
|
247
|
-
id: string;
|
|
248
|
-
name: string;
|
|
249
|
-
origin?: string;
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
/**
|
|
253
|
-
* Type definitions for the new PERS Signer API v1
|
|
254
|
-
* Based on API_MIGRATION_REFERENCE.md - Updated for wrapped responses
|
|
255
|
-
*/
|
|
256
|
-
interface SignerApiResponse<T = unknown> {
|
|
257
|
-
success: boolean;
|
|
258
|
-
data?: T;
|
|
259
|
-
}
|
|
260
|
-
interface SignerApiError {
|
|
261
|
-
status: number;
|
|
262
|
-
error: string;
|
|
263
|
-
message: string;
|
|
264
|
-
request_id: string;
|
|
265
|
-
timestamp: string;
|
|
266
|
-
suggestion?: {
|
|
267
|
-
action: string;
|
|
268
|
-
text: string;
|
|
269
|
-
endpoint: string;
|
|
270
|
-
};
|
|
271
|
-
}
|
|
272
|
-
interface LoginRequest {
|
|
273
|
-
authToken: string;
|
|
274
|
-
}
|
|
275
|
-
interface JWTLoginResponse {
|
|
276
|
-
success: true;
|
|
277
|
-
access_token: string;
|
|
278
|
-
token_type: "Bearer";
|
|
279
|
-
expires_in: number;
|
|
280
|
-
user: {
|
|
281
|
-
id: string;
|
|
282
|
-
username: string;
|
|
283
|
-
org_id: string;
|
|
284
|
-
};
|
|
285
|
-
provider: string;
|
|
286
|
-
}
|
|
287
|
-
interface WrappedProviderResponse {
|
|
288
|
-
success: true;
|
|
289
|
-
data: unknown;
|
|
290
|
-
}
|
|
291
|
-
type LoginResponse = JWTLoginResponse | WrappedProviderResponse;
|
|
292
|
-
interface VerifyTokenRequest {
|
|
293
|
-
token: string;
|
|
294
|
-
}
|
|
295
|
-
interface VerifyTokenResponse {
|
|
296
|
-
valid: boolean;
|
|
297
|
-
provider: string;
|
|
298
|
-
claims: {
|
|
299
|
-
sub: string;
|
|
300
|
-
iss: string;
|
|
301
|
-
aud: string;
|
|
302
|
-
exp: number;
|
|
303
|
-
iat: number;
|
|
304
|
-
user_id: string;
|
|
305
|
-
username: string;
|
|
306
|
-
org_id: string;
|
|
307
|
-
provider: string;
|
|
308
|
-
permissions: unknown;
|
|
309
|
-
};
|
|
310
|
-
tenantId: string;
|
|
311
|
-
}
|
|
312
|
-
interface InitRegistrationRequest {
|
|
313
|
-
authToken: string;
|
|
314
|
-
}
|
|
315
|
-
interface InitRegistrationResponse {
|
|
316
|
-
success: true;
|
|
317
|
-
data: {
|
|
318
|
-
challenge?: string;
|
|
319
|
-
temporaryAuthenticationToken?: string;
|
|
320
|
-
user?: object;
|
|
321
|
-
[key: string]: unknown;
|
|
322
|
-
};
|
|
323
|
-
}
|
|
324
|
-
type CompleteRegistrationResponse = JWTLoginResponse | WrappedProviderResponse;
|
|
325
|
-
interface ListWalletsRequest {
|
|
326
|
-
}
|
|
327
|
-
interface ListWalletsResponse {
|
|
328
|
-
success: true;
|
|
329
|
-
data: {
|
|
330
|
-
wallets?: Array<unknown>;
|
|
331
|
-
[key: string]: unknown;
|
|
332
|
-
};
|
|
333
|
-
}
|
|
334
|
-
interface InitSignatureRequest {
|
|
335
|
-
walletId: string;
|
|
336
|
-
request: unknown;
|
|
337
|
-
}
|
|
338
|
-
interface InitSignatureResponse {
|
|
339
|
-
success: true;
|
|
340
|
-
data: {
|
|
341
|
-
requestBody: unknown;
|
|
342
|
-
challenge: unknown;
|
|
343
|
-
[key: string]: unknown;
|
|
344
|
-
};
|
|
345
|
-
}
|
|
346
|
-
interface CompleteSignatureRequest {
|
|
347
|
-
walletId: string;
|
|
348
|
-
requestBody: unknown;
|
|
349
|
-
signedChallenge: unknown;
|
|
350
|
-
}
|
|
351
|
-
interface CompleteSignatureResponse {
|
|
352
|
-
success: true;
|
|
353
|
-
data: {
|
|
354
|
-
signature?: {
|
|
355
|
-
r: string;
|
|
356
|
-
s: string;
|
|
357
|
-
recid: number;
|
|
358
|
-
encoded: string;
|
|
359
|
-
} | string;
|
|
360
|
-
transaction?: unknown;
|
|
361
|
-
dateRequested?: string;
|
|
362
|
-
dateSigned?: string;
|
|
363
|
-
id?: string;
|
|
364
|
-
keyId?: string;
|
|
365
|
-
network?: string;
|
|
366
|
-
requestBody?: {
|
|
367
|
-
kind?: 'Eip712' | 'Hash' | string;
|
|
368
|
-
blockchainKind?: string;
|
|
369
|
-
[key: string]: unknown;
|
|
370
|
-
};
|
|
371
|
-
requester?: unknown;
|
|
372
|
-
status?: string;
|
|
373
|
-
walletId?: string;
|
|
374
|
-
[key: string]: unknown;
|
|
375
|
-
};
|
|
376
|
-
}
|
|
377
|
-
interface HealthCheckResponse {
|
|
378
|
-
success: boolean;
|
|
379
|
-
}
|
|
380
286
|
|
|
381
287
|
/**
|
|
382
288
|
* Signing service for cryptographic operations
|
|
@@ -426,10 +332,6 @@ declare class SigningService {
|
|
|
426
332
|
* Combined transaction status type that includes both PERS and additional statuses
|
|
427
333
|
*/
|
|
428
334
|
type CombinedTransactionStatus = TransactionStatus;
|
|
429
|
-
/**
|
|
430
|
-
* Transaction statuses that allow signing
|
|
431
|
-
*/
|
|
432
|
-
declare const SIGNABLE_STATUSES: readonly [TransactionStatus.PENDING_SIGNATURE, TransactionStatus.CREATED];
|
|
433
335
|
/**
|
|
434
336
|
* Transaction status information for UI display
|
|
435
337
|
*/
|
|
@@ -482,28 +384,6 @@ interface TransactionSigningParams {
|
|
|
482
384
|
returnUrl?: string;
|
|
483
385
|
}
|
|
484
386
|
|
|
485
|
-
/**
|
|
486
|
-
* Wallet list response from WalletService
|
|
487
|
-
*/
|
|
488
|
-
interface WalletListResponse {
|
|
489
|
-
items: WalletItem[];
|
|
490
|
-
}
|
|
491
|
-
/**
|
|
492
|
-
* Individual wallet item from wallet list - compatible with KeyWallet constructor
|
|
493
|
-
*/
|
|
494
|
-
interface WalletItem {
|
|
495
|
-
id: string;
|
|
496
|
-
address: string;
|
|
497
|
-
network: string;
|
|
498
|
-
status: string;
|
|
499
|
-
signingKey?: unknown;
|
|
500
|
-
dateCreated?: string;
|
|
501
|
-
custodial?: boolean;
|
|
502
|
-
tags?: string[];
|
|
503
|
-
boundToEvmNetwork?: boolean;
|
|
504
|
-
[key: string]: unknown;
|
|
505
|
-
}
|
|
506
|
-
|
|
507
387
|
/**
|
|
508
388
|
* Error codes for transaction signing operations
|
|
509
389
|
*/
|
|
@@ -530,6 +410,43 @@ interface TransactionSigningError extends Error {
|
|
|
530
410
|
originalError?: unknown;
|
|
531
411
|
}
|
|
532
412
|
|
|
413
|
+
/**
|
|
414
|
+
* Signing status types for type-safe status updates
|
|
415
|
+
* Using const pattern instead of enum for better bundling compatibility
|
|
416
|
+
*/
|
|
417
|
+
declare const SigningStatus: {
|
|
418
|
+
readonly INITIALIZING: "initializing";
|
|
419
|
+
readonly AUTHENTICATING: "authenticating";
|
|
420
|
+
readonly PREPARING: "preparing";
|
|
421
|
+
readonly SIGNING: "signing";
|
|
422
|
+
readonly SUBMITTING: "submitting";
|
|
423
|
+
readonly COMPLETED: "completed";
|
|
424
|
+
readonly ERROR: "error";
|
|
425
|
+
readonly EXPIRED: "expired";
|
|
426
|
+
};
|
|
427
|
+
/**
|
|
428
|
+
* Type for signing status values
|
|
429
|
+
*/
|
|
430
|
+
type SigningStatus = typeof SigningStatus[keyof typeof SigningStatus];
|
|
431
|
+
/**
|
|
432
|
+
* Status update data interface
|
|
433
|
+
*/
|
|
434
|
+
interface StatusUpdateData {
|
|
435
|
+
transactionId?: string;
|
|
436
|
+
transactionHash?: string;
|
|
437
|
+
error?: string;
|
|
438
|
+
[key: string]: any;
|
|
439
|
+
}
|
|
440
|
+
/**
|
|
441
|
+
* Status update callback interface for tracking transaction progress
|
|
442
|
+
*
|
|
443
|
+
* @interface StatusCallback
|
|
444
|
+
* @property {function} onStatusUpdate - Callback function that receives type-safe status updates
|
|
445
|
+
*/
|
|
446
|
+
interface StatusCallback {
|
|
447
|
+
onStatusUpdate?: (status: SigningStatus, message: string, data?: StatusUpdateData) => void;
|
|
448
|
+
}
|
|
449
|
+
|
|
533
450
|
/**
|
|
534
451
|
* Central type definitions for the blockchain signer shared library
|
|
535
452
|
* Single source of truth for all type exports
|
|
@@ -544,31 +461,12 @@ interface AuthenticatedUser {
|
|
|
544
461
|
persAccessToken: string;
|
|
545
462
|
expiresAt: number;
|
|
546
463
|
}
|
|
547
|
-
/**
|
|
548
|
-
* Error types for service operations
|
|
549
|
-
*/
|
|
550
|
-
interface ServiceError {
|
|
551
|
-
code: string;
|
|
552
|
-
message: string;
|
|
553
|
-
details?: any;
|
|
554
|
-
timestamp: Date;
|
|
555
|
-
}
|
|
556
|
-
|
|
557
|
-
interface GetWalletResponse {
|
|
558
|
-
id: string;
|
|
559
|
-
signingKey: {
|
|
560
|
-
publicKey: string;
|
|
561
|
-
};
|
|
562
|
-
}
|
|
563
464
|
|
|
564
465
|
type WalletOptions = {
|
|
565
466
|
wallet: WalletMetadata;
|
|
566
467
|
authToken: string;
|
|
567
468
|
signingService: SigningService;
|
|
568
469
|
};
|
|
569
|
-
type WalletMetadata = GetWalletResponse & {
|
|
570
|
-
boundToEvmNetwork: boolean;
|
|
571
|
-
};
|
|
572
470
|
declare class KeyWallet extends AbstractSigner {
|
|
573
471
|
private options;
|
|
574
472
|
private address?;
|
|
@@ -629,12 +527,14 @@ declare class KeyWallet extends AbstractSigner {
|
|
|
629
527
|
* @property {WebAuthnProvider} webAuthnProvider - WebAuthn provider for secure authentication
|
|
630
528
|
* @property {string} [apiUrl] - Custom API base URL (defaults to production)
|
|
631
529
|
* @property {string} [relyingPartyName] - WebAuthn relying party name for authentication
|
|
530
|
+
* @property {StatusCallback} [globalStatusCallback] - Optional global status callback for all operations
|
|
632
531
|
*/
|
|
633
532
|
interface ExtendedPersSignerConfig {
|
|
634
533
|
ethersProviderUrl?: string;
|
|
635
534
|
webAuthnProvider: WebAuthnProvider;
|
|
636
535
|
apiUrl?: string;
|
|
637
536
|
relyingPartyName?: string;
|
|
537
|
+
globalStatusCallback?: StatusCallback;
|
|
638
538
|
}
|
|
639
539
|
interface PersSignerConfig extends Omit<ExtendedPersSignerConfig, 'webAuthnProvider'> {
|
|
640
540
|
}
|
|
@@ -664,6 +564,11 @@ declare class PersSignerSDK {
|
|
|
664
564
|
* @throws {Error} If required configuration is missing
|
|
665
565
|
*/
|
|
666
566
|
constructor(config: ExtendedPersSignerConfig);
|
|
567
|
+
/**
|
|
568
|
+
* Helper method to trigger both global and method-specific status callbacks
|
|
569
|
+
* @private
|
|
570
|
+
*/
|
|
571
|
+
private triggerStatusUpdate;
|
|
667
572
|
/**
|
|
668
573
|
* Authenticate user and cache session for 5 minutes
|
|
669
574
|
*
|
|
@@ -671,20 +576,23 @@ declare class PersSignerSDK {
|
|
|
671
576
|
* and caches the authenticated user session to avoid repeated authentication.
|
|
672
577
|
*
|
|
673
578
|
* @param {string} jwtToken - JWT token containing user identifier and tenant info
|
|
579
|
+
* @param {StatusCallback} [statusCallback] - Optional callback for status updates
|
|
674
580
|
* @returns {Promise<AuthenticatedUser>} Authenticated user with access tokens
|
|
675
581
|
* @throws {Error} If JWT is invalid, expired, or authentication fails
|
|
676
582
|
*
|
|
677
583
|
* @example
|
|
678
584
|
* ```typescript
|
|
679
585
|
* try {
|
|
680
|
-
* const user = await sdk.loginUser(jwtToken
|
|
586
|
+
* const user = await sdk.loginUser(jwtToken, {
|
|
587
|
+
* onStatusUpdate: (status, message) => console.log(`${status}: ${message}`)
|
|
588
|
+
* });
|
|
681
589
|
* console.log('Authenticated:', user.identifier);
|
|
682
590
|
* } catch (error) {
|
|
683
591
|
* console.error('Authentication failed:', error.message);
|
|
684
592
|
* }
|
|
685
593
|
* ```
|
|
686
594
|
*/
|
|
687
|
-
loginUser(jwtToken: string): Promise<AuthenticatedUser>;
|
|
595
|
+
loginUser(jwtToken: string, statusCallback?: StatusCallback): Promise<AuthenticatedUser>;
|
|
688
596
|
/**
|
|
689
597
|
* Sign a PERS transaction (legacy compatibility method)
|
|
690
598
|
*
|
|
@@ -693,13 +601,16 @@ declare class PersSignerSDK {
|
|
|
693
601
|
* maintained for backward compatibility.
|
|
694
602
|
*
|
|
695
603
|
* @param {string} jwtToken - JWT token containing transaction ID and user info
|
|
604
|
+
* @param {StatusCallback} [statusCallback] - Optional callback for status updates
|
|
696
605
|
* @returns {Promise<TransactionSigningResult>} Signing result with signature and metadata
|
|
697
606
|
* @throws {Error} If authentication fails, transaction ID missing, or signing fails
|
|
698
607
|
*
|
|
699
608
|
* @example
|
|
700
609
|
* ```typescript
|
|
701
610
|
* try {
|
|
702
|
-
* const result = await sdk.signPersTransaction(jwtToken
|
|
611
|
+
* const result = await sdk.signPersTransaction(jwtToken, {
|
|
612
|
+
* onStatusUpdate: (status, message) => console.log(`${status}: ${message}`)
|
|
613
|
+
* });
|
|
703
614
|
* if (result.success) {
|
|
704
615
|
* console.log('Transaction signed:', result.signature);
|
|
705
616
|
* }
|
|
@@ -708,7 +619,7 @@ declare class PersSignerSDK {
|
|
|
708
619
|
* }
|
|
709
620
|
* ```
|
|
710
621
|
*/
|
|
711
|
-
signPersTransaction(jwtToken: string): Promise<TransactionSigningResult>;
|
|
622
|
+
signPersTransaction(jwtToken: string, statusCallback?: StatusCallback): Promise<TransactionSigningResult>;
|
|
712
623
|
/**
|
|
713
624
|
* Sign a transaction with provided signing data
|
|
714
625
|
*
|
|
@@ -717,17 +628,20 @@ declare class PersSignerSDK {
|
|
|
717
628
|
*
|
|
718
629
|
* @param {CounterfactualWalletTransactionResponse | LegacyTransaction} signingData - Transaction data to sign
|
|
719
630
|
* @param {string} jwtToken - JWT token containing transaction ID and user info
|
|
631
|
+
* @param {StatusCallback} [statusCallback] - Optional callback for status updates
|
|
720
632
|
* @returns {Promise<TransactionSigningResult>} Signing result with signature and metadata
|
|
721
633
|
* @throws {Error} If authentication fails, transaction ID missing, or signing fails
|
|
722
634
|
*
|
|
723
635
|
* @example
|
|
724
636
|
* ```typescript
|
|
725
637
|
* const signingData = await getTransactionData(transactionId);
|
|
726
|
-
* const result = await sdk.signTransaction(signingData, jwtToken
|
|
638
|
+
* const result = await sdk.signTransaction(signingData, jwtToken, {
|
|
639
|
+
* onStatusUpdate: (status, message) => console.log(`${status}: ${message}`)
|
|
640
|
+
* });
|
|
727
641
|
* console.log('Signed transaction:', result.signature);
|
|
728
642
|
* ```
|
|
729
643
|
*/
|
|
730
|
-
signTransaction(signingData: CounterfactualWalletTransactionResponse$1 | LegacyTransaction, jwtToken: string): Promise<TransactionSigningResult>;
|
|
644
|
+
signTransaction(signingData: CounterfactualWalletTransactionResponse$1 | LegacyTransaction, jwtToken: string, statusCallback?: StatusCallback): Promise<TransactionSigningResult>;
|
|
731
645
|
/**
|
|
732
646
|
* Complete transaction flow: sign and submit in one call
|
|
733
647
|
*
|
|
@@ -736,13 +650,18 @@ declare class PersSignerSDK {
|
|
|
736
650
|
* transaction lifecycle automatically.
|
|
737
651
|
*
|
|
738
652
|
* @param {string} jwtToken - JWT token containing transaction ID and user info
|
|
653
|
+
* @param {StatusCallback} [statusCallback] - Optional callback for status updates
|
|
739
654
|
* @returns {Promise<SubmissionResult>} Submission result with transaction hash and status
|
|
740
655
|
* @throws {Error} If authentication, signing, or submission fails
|
|
741
656
|
*
|
|
742
657
|
* @example
|
|
743
658
|
* ```typescript
|
|
744
659
|
* try {
|
|
745
|
-
* const result = await sdk.signAndSubmitPersTransaction(jwtToken
|
|
660
|
+
* const result = await sdk.signAndSubmitPersTransaction(jwtToken, {
|
|
661
|
+
* onStatusUpdate: (status, message) => {
|
|
662
|
+
* console.log(`Status: ${status} - ${message}`);
|
|
663
|
+
* }
|
|
664
|
+
* });
|
|
746
665
|
* if (result.success) {
|
|
747
666
|
* console.log('Transaction completed:', result.transactionHash);
|
|
748
667
|
* if (result.shouldRedirect) {
|
|
@@ -754,7 +673,7 @@ declare class PersSignerSDK {
|
|
|
754
673
|
* }
|
|
755
674
|
* ```
|
|
756
675
|
*/
|
|
757
|
-
signAndSubmitPersTransaction(jwtToken: string): Promise<SubmissionResult>;
|
|
676
|
+
signAndSubmitPersTransaction(jwtToken: string, statusCallback?: StatusCallback): Promise<SubmissionResult>;
|
|
758
677
|
/**
|
|
759
678
|
* Submit a signed transaction to the blockchain
|
|
760
679
|
*
|
|
@@ -764,17 +683,20 @@ declare class PersSignerSDK {
|
|
|
764
683
|
*
|
|
765
684
|
* @param {TransactionSigningResult} signingResult - Result from a successful transaction signing
|
|
766
685
|
* @param {string} jwtToken - JWT token containing tenant and user info
|
|
686
|
+
* @param {StatusCallback} [statusCallback] - Optional callback for status updates
|
|
767
687
|
* @returns {Promise<SubmissionResult>} Submission result with transaction hash and status
|
|
768
688
|
* @throws {Error} If signing result is invalid, JWT is missing tenantId, or submission fails
|
|
769
689
|
*
|
|
770
690
|
* @example
|
|
771
691
|
* ```typescript
|
|
772
692
|
* const signedTx = await sdk.signPersTransaction(jwtToken);
|
|
773
|
-
* const result = await sdk.submitTransaction(signedTx, jwtToken
|
|
693
|
+
* const result = await sdk.submitTransaction(signedTx, jwtToken, {
|
|
694
|
+
* onStatusUpdate: (status, message) => console.log(`${status}: ${message}`)
|
|
695
|
+
* });
|
|
774
696
|
* console.log('Transaction submitted:', result.transactionHash);
|
|
775
697
|
* ```
|
|
776
698
|
*/
|
|
777
|
-
submitTransaction(signingResult: TransactionSigningResult, jwtToken: string): Promise<SubmissionResult>;
|
|
699
|
+
submitTransaction(signingResult: TransactionSigningResult, jwtToken: string, statusCallback?: StatusCallback): Promise<SubmissionResult>;
|
|
778
700
|
/**
|
|
779
701
|
* Clear user authentication cache
|
|
780
702
|
*
|
|
@@ -873,11 +795,9 @@ declare class TransactionErrorHandler {
|
|
|
873
795
|
error?: {
|
|
874
796
|
code?: string;
|
|
875
797
|
message?: string;
|
|
876
|
-
developerMessage?: string;
|
|
877
798
|
};
|
|
878
799
|
code?: string;
|
|
879
800
|
message?: string;
|
|
880
|
-
developerMessage?: string;
|
|
881
801
|
}, transactionId: string): never;
|
|
882
802
|
/**
|
|
883
803
|
* Process PERS API errors and handle TRANSACTION_NOT_PENDING cases
|
|
@@ -1043,7 +963,6 @@ declare function getHttpClient(): HttpClient;
|
|
|
1043
963
|
*/
|
|
1044
964
|
declare class AuthenticationService {
|
|
1045
965
|
private signerToken;
|
|
1046
|
-
private config;
|
|
1047
966
|
private webAuthnProvider;
|
|
1048
967
|
constructor(config: ExtendedPersSignerConfig);
|
|
1049
968
|
/**
|
|
@@ -1059,11 +978,11 @@ declare class AuthenticationService {
|
|
|
1059
978
|
*/
|
|
1060
979
|
verifyToken(token: string): Promise<VerifyTokenResponse>;
|
|
1061
980
|
/**
|
|
1062
|
-
*
|
|
1063
|
-
* @param persToken - PERS JWT token
|
|
1064
|
-
* @returns Promise resolving to
|
|
981
|
+
* Register user with unified flow
|
|
982
|
+
* @param persToken - PERS JWT token
|
|
983
|
+
* @returns Promise resolving to authenticated user data
|
|
1065
984
|
*/
|
|
1066
|
-
|
|
985
|
+
registerUser(persToken: string): Promise<JWTLoginResponse>;
|
|
1067
986
|
/**
|
|
1068
987
|
* Get current signer token
|
|
1069
988
|
* @returns The current signer JWT token
|
|
@@ -1074,14 +993,6 @@ declare class AuthenticationService {
|
|
|
1074
993
|
* @param token - Signer JWT token
|
|
1075
994
|
*/
|
|
1076
995
|
setSignerToken(token: string): void;
|
|
1077
|
-
/**
|
|
1078
|
-
* Complete registration with WebAuthn challenge data (v1 API format)
|
|
1079
|
-
* @param tmpAuthToken - Temporary auth token from init registration (temporaryAuthenticationToken)
|
|
1080
|
-
* @param signedChallenge - WebAuthn credential response (will be restructured for backend)
|
|
1081
|
-
* @param persToken - PERS JWT token (authToken)
|
|
1082
|
-
* @returns Promise resolving to registration result
|
|
1083
|
-
*/
|
|
1084
|
-
completeRegistrationWithChallenge(tmpAuthToken: string | null, signedChallenge: any, persToken: string): Promise<JWTLoginResponse | unknown>;
|
|
1085
996
|
/**
|
|
1086
997
|
* Combined authentication flow - handles both login and registration
|
|
1087
998
|
* @param identifier - User identifier (email/userId)
|
|
@@ -1094,7 +1005,8 @@ declare class AuthenticationService {
|
|
|
1094
1005
|
}
|
|
1095
1006
|
|
|
1096
1007
|
/**
|
|
1097
|
-
* Browser-specific WebAuthn provider using
|
|
1008
|
+
* Browser-specific WebAuthn provider using native browser APIs
|
|
1009
|
+
* Fully agnostic implementation without external SDK dependencies
|
|
1098
1010
|
*/
|
|
1099
1011
|
|
|
1100
1012
|
/**
|
|
@@ -1104,14 +1016,53 @@ declare function getBrowserWebAuthnProvider(): Promise<WebAuthnProvider>;
|
|
|
1104
1016
|
|
|
1105
1017
|
/**
|
|
1106
1018
|
* Browser-specific entry point for the PERS Signer SDK
|
|
1107
|
-
*
|
|
1019
|
+
*
|
|
1020
|
+
* This module provides browser-optimized SDK functionality with automatic WebAuthn provider setup.
|
|
1021
|
+
* Use this entry point for all browser-based applications (React, Vue, Angular, etc.).
|
|
1022
|
+
*
|
|
1023
|
+
* @example
|
|
1024
|
+
* ```typescript
|
|
1025
|
+
* import { createPersSignerSDK } from '@explorins/pers-signer/browser';
|
|
1026
|
+
*
|
|
1027
|
+
* // Simple initialization - WebAuthn provider is handled automatically
|
|
1028
|
+
* const sdk = await createPersSignerSDK({
|
|
1029
|
+
* ethersProviderUrl: 'https://mainnet.infura.io/v3/YOUR_KEY'
|
|
1030
|
+
* });
|
|
1031
|
+
*
|
|
1032
|
+
* // Complete transaction flow
|
|
1033
|
+
* const result = await sdk.signAndSubmitPersTransaction(jwtToken);
|
|
1034
|
+
* if (result.success) {
|
|
1035
|
+
* console.log('Transaction completed:', result.transactionHash);
|
|
1036
|
+
* }
|
|
1037
|
+
* ```
|
|
1108
1038
|
*/
|
|
1109
1039
|
|
|
1110
1040
|
/**
|
|
1111
1041
|
* Create a new PersSignerSDK instance with browser WebAuthn provider
|
|
1112
|
-
*
|
|
1042
|
+
*
|
|
1043
|
+
* This is the recommended way to initialize the SDK in browser environments.
|
|
1044
|
+
* The WebAuthn provider is automatically configured for browser usage.
|
|
1045
|
+
*
|
|
1046
|
+
* @param config - SDK configuration object
|
|
1047
|
+
* @param config.ethersProviderUrl - Optional custom Ethereum RPC provider URL
|
|
1048
|
+
* @param config.apiUrl - Optional custom API base URL (defaults to production)
|
|
1049
|
+
* @param config.relyingPartyName - Optional WebAuthn relying party name
|
|
1050
|
+
* @param config.globalStatusCallback - Optional global status callback for all operations
|
|
1051
|
+
* @returns Promise resolving to configured PersSignerSDK instance
|
|
1052
|
+
*
|
|
1053
|
+
* @example
|
|
1054
|
+
* ```typescript
|
|
1055
|
+
* import { createPersSignerSDK } from '@explorins/pers-signer/browser';
|
|
1056
|
+
*
|
|
1057
|
+
* const sdk = await createPersSignerSDK({
|
|
1058
|
+
* ethersProviderUrl: 'https://mainnet.infura.io/v3/YOUR_KEY'
|
|
1059
|
+
* });
|
|
1060
|
+
*
|
|
1061
|
+
* // Use the SDK
|
|
1062
|
+
* const result = await sdk.signAndSubmitPersTransaction(jwtToken);
|
|
1063
|
+
* ```
|
|
1113
1064
|
*/
|
|
1114
1065
|
declare function createPersSignerSDK(config: PersSignerConfig): Promise<PersSignerSDK>;
|
|
1115
1066
|
|
|
1116
|
-
export { AuthenticationService, FetchHttpClient, KeyWallet, PersService, PersSignerSDK, ReactNativeConfigProvider,
|
|
1117
|
-
export type {
|
|
1067
|
+
export { AuthenticationService, FetchHttpClient, KeyWallet, PersService, PersSignerSDK, ReactNativeConfigProvider, SigningService, SigningStatus, StaticConfigProvider, TransactionErrorHandler, TransactionSigningService, TransactionSubmissionHandler, TransactionValidator, WalletService, WebAuthnCoordinator, WebConfigProvider, createPersSignerSDK, getBrowserWebAuthnProvider, getConfigProvider, getHttpClient, getServiceConfig, getBrowserWebAuthnProvider as getWebAuthnProvider, setConfigProvider, setHttpClient };
|
|
1068
|
+
export type { AuthenticatedUser, ConfigProvider, HttpClient, HttpRequestOptions, HttpResponse, PersSignerConfig, PlatformConfig, StatusCallback, StatusUpdateData, SubmissionResult, TransactionSigningResult, WebAuthnConfig, WebAuthnProvider };
|