@explorins/pers-signer 1.0.17 → 1.0.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.cjs.js +47 -39
- package/dist/browser.cjs.js.map +1 -1
- package/dist/browser.d.ts +187 -131
- package/dist/browser.esm.js +40 -40
- package/dist/browser.esm.js.map +1 -1
- package/dist/index.cjs.js +47 -39
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +256 -240
- package/dist/index.esm.js +40 -40
- package/dist/index.esm.js.map +1 -1
- package/dist/react-native.cjs.js +47 -39
- package/dist/react-native.cjs.js.map +1 -1
- package/dist/react-native.d.ts +187 -131
- package/dist/react-native.esm.js +40 -40
- package/dist/react-native.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/browser.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as _explorins_web3_ts_types from '@explorins/web3-ts/types';
|
|
2
|
-
import {
|
|
3
|
-
export { AnyTransactionData } from '@explorins/web3-ts/types';
|
|
2
|
+
import { LegacyTransaction, AnyTransactionData } from '@explorins/web3-ts/types';
|
|
3
|
+
export { AnyTransactionData, BaseTransaction, CounterfactualWalletEIP712Data, EIP1559Transaction, EIP2930Transaction, EIP712TransactionData, EIP712TypedData, LegacyTransaction } from '@explorins/web3-ts/types';
|
|
4
4
|
import * as _explorins_pers_shared_browser from '@explorins/pers-shared/browser';
|
|
5
5
|
import { TenantPublicDTO, SessionAuthContextResponseDTO, TransactionFormat, TransactionRequestResponseDTO, CounterfactualWalletTransactionResponse, TransactionStatus } from '@explorins/pers-shared/browser';
|
|
6
|
-
export { TransactionFormat, TransactionRequestResponseDTO, TransactionStatus } from '@explorins/pers-shared/browser';
|
|
6
|
+
export { CampaignClaimDTO, CampaignDTO, SessionAuthResponseDTO, TRANSACTION_FORMATS, TRANSACTION_FORMAT_DESCRIPTIONS, TransactionFormat, TransactionRequestResponseDTO, TransactionStatus, TransactionSubmissionRequestDTO } from '@explorins/pers-shared/browser';
|
|
7
7
|
import { AbstractSigner, Provider, TransactionRequest, TypedDataDomain, TypedDataField } from 'ethers';
|
|
8
8
|
import { CounterfactualWalletTransactionResponse as CounterfactualWalletTransactionResponse$1 } from '@explorins/pers-shared';
|
|
9
9
|
|
|
@@ -249,6 +249,29 @@ interface RelyingPartyConfig {
|
|
|
249
249
|
origin?: string;
|
|
250
250
|
}
|
|
251
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
|
+
}
|
|
252
275
|
interface JWTLoginResponse {
|
|
253
276
|
success: true;
|
|
254
277
|
access_token: string;
|
|
@@ -261,6 +284,14 @@ interface JWTLoginResponse {
|
|
|
261
284
|
};
|
|
262
285
|
provider: string;
|
|
263
286
|
}
|
|
287
|
+
interface WrappedProviderResponse {
|
|
288
|
+
success: true;
|
|
289
|
+
data: unknown;
|
|
290
|
+
}
|
|
291
|
+
type LoginResponse = JWTLoginResponse | WrappedProviderResponse;
|
|
292
|
+
interface VerifyTokenRequest {
|
|
293
|
+
token: string;
|
|
294
|
+
}
|
|
264
295
|
interface VerifyTokenResponse {
|
|
265
296
|
valid: boolean;
|
|
266
297
|
provider: string;
|
|
@@ -278,6 +309,45 @@ interface VerifyTokenResponse {
|
|
|
278
309
|
};
|
|
279
310
|
tenantId: string;
|
|
280
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
|
+
}
|
|
281
351
|
interface CompleteSignatureResponse {
|
|
282
352
|
success: true;
|
|
283
353
|
data: {
|
|
@@ -304,6 +374,9 @@ interface CompleteSignatureResponse {
|
|
|
304
374
|
[key: string]: unknown;
|
|
305
375
|
};
|
|
306
376
|
}
|
|
377
|
+
interface HealthCheckResponse {
|
|
378
|
+
success: boolean;
|
|
379
|
+
}
|
|
307
380
|
|
|
308
381
|
/**
|
|
309
382
|
* Signing service for cryptographic operations
|
|
@@ -349,76 +422,6 @@ declare class SigningService {
|
|
|
349
422
|
signBatch(authToken: string, walletId: string, requests: SigningRequest[]): Promise<CompleteSignatureResponse['data'][]>;
|
|
350
423
|
}
|
|
351
424
|
|
|
352
|
-
/**
|
|
353
|
-
* Shared type definitions for the blockchain signer shared library
|
|
354
|
-
*/
|
|
355
|
-
|
|
356
|
-
/**
|
|
357
|
-
* Authentication types for 3-function split architecture
|
|
358
|
-
*/
|
|
359
|
-
interface AuthenticatedUser {
|
|
360
|
-
identifier: string;
|
|
361
|
-
signerAuthToken: string;
|
|
362
|
-
persAccessToken: string;
|
|
363
|
-
tenantId: string;
|
|
364
|
-
expiresAt: number;
|
|
365
|
-
}
|
|
366
|
-
/**
|
|
367
|
-
* Service configuration options
|
|
368
|
-
*/
|
|
369
|
-
interface ServiceConfig {
|
|
370
|
-
apiUrl: string;
|
|
371
|
-
environment: 'development' | 'staging' | 'production';
|
|
372
|
-
timeout?: number;
|
|
373
|
-
retryAttempts?: number;
|
|
374
|
-
}
|
|
375
|
-
/**
|
|
376
|
-
* Error types for service operations
|
|
377
|
-
*/
|
|
378
|
-
interface ServiceError {
|
|
379
|
-
code: string;
|
|
380
|
-
message: string;
|
|
381
|
-
details?: any;
|
|
382
|
-
timestamp: Date;
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
interface GetWalletResponse {
|
|
386
|
-
id: string;
|
|
387
|
-
signingKey: {
|
|
388
|
-
publicKey: string;
|
|
389
|
-
};
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
type WalletOptions = {
|
|
393
|
-
wallet: WalletMetadata;
|
|
394
|
-
authToken: string;
|
|
395
|
-
signingService: SigningService;
|
|
396
|
-
};
|
|
397
|
-
type WalletMetadata = GetWalletResponse & {
|
|
398
|
-
boundToEvmNetwork: boolean;
|
|
399
|
-
};
|
|
400
|
-
declare class KeyWallet extends AbstractSigner {
|
|
401
|
-
private options;
|
|
402
|
-
private address?;
|
|
403
|
-
private authToken;
|
|
404
|
-
private metadata;
|
|
405
|
-
private signingService;
|
|
406
|
-
constructor(options: WalletOptions, provider?: Provider | null);
|
|
407
|
-
connect(provider: Provider | null): KeyWallet;
|
|
408
|
-
getAddress(): Promise<string>;
|
|
409
|
-
private signHash;
|
|
410
|
-
signTransaction(tx: TransactionRequest): Promise<string>;
|
|
411
|
-
signMessage(message: string | Uint8Array): Promise<string>;
|
|
412
|
-
signTypedData(domain: TypedDataDomain, types: Record<string, TypedDataField[]>, value: Record<string, any>): Promise<string>;
|
|
413
|
-
/**
|
|
414
|
-
* Signs a PERS transaction based on its format
|
|
415
|
-
* Handles different transaction types: Legacy, EIP-2930, EIP-1559, and EIP-712
|
|
416
|
-
* @param transactionData - The transaction data from PERS API
|
|
417
|
-
* @returns The signature string
|
|
418
|
-
*/
|
|
419
|
-
signPersTransaction(transactionData: AnyTransactionData): Promise<string>;
|
|
420
|
-
}
|
|
421
|
-
|
|
422
425
|
/**
|
|
423
426
|
* Combined transaction status type that includes both PERS and additional statuses
|
|
424
427
|
*/
|
|
@@ -479,6 +482,115 @@ interface TransactionSigningParams {
|
|
|
479
482
|
returnUrl?: string;
|
|
480
483
|
}
|
|
481
484
|
|
|
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
|
+
/**
|
|
508
|
+
* Error codes for transaction signing operations
|
|
509
|
+
*/
|
|
510
|
+
declare enum TransactionSigningErrorCode {
|
|
511
|
+
INVALID_TOKENS = "INVALID_TOKENS",
|
|
512
|
+
TRANSACTION_NOT_FOUND = "TRANSACTION_NOT_FOUND",
|
|
513
|
+
TRANSACTION_NOT_PENDING = "TRANSACTION_NOT_PENDING",
|
|
514
|
+
WALLET_NOT_AVAILABLE = "WALLET_NOT_AVAILABLE",
|
|
515
|
+
WEBAUTHN_OPERATION_IN_PROGRESS = "WEBAUTHN_OPERATION_IN_PROGRESS",
|
|
516
|
+
SIGNING_CANCELLED = "SIGNING_CANCELLED",
|
|
517
|
+
PERS_AUTH_FAILED = "PERS_AUTH_FAILED",
|
|
518
|
+
AUTH_FAILED = "AUTH_FAILED",
|
|
519
|
+
TRANSACTION_NOT_READY = "TRANSACTION_NOT_READY",
|
|
520
|
+
SUBMISSION_FAILED = "SUBMISSION_FAILED",
|
|
521
|
+
SERVER_ERROR = "SERVER_ERROR",
|
|
522
|
+
UNKNOWN_ERROR = "UNKNOWN_ERROR"
|
|
523
|
+
}
|
|
524
|
+
/**
|
|
525
|
+
* Structured error for transaction signing operations
|
|
526
|
+
*/
|
|
527
|
+
interface TransactionSigningError extends Error {
|
|
528
|
+
code: TransactionSigningErrorCode;
|
|
529
|
+
transactionId?: string;
|
|
530
|
+
originalError?: unknown;
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
/**
|
|
534
|
+
* Central type definitions for the blockchain signer shared library
|
|
535
|
+
* Single source of truth for all type exports
|
|
536
|
+
*/
|
|
537
|
+
|
|
538
|
+
/**
|
|
539
|
+
* Authentication types for 3-function split architecture
|
|
540
|
+
*/
|
|
541
|
+
interface AuthenticatedUser {
|
|
542
|
+
identifier: string;
|
|
543
|
+
signerAuthToken: string;
|
|
544
|
+
persAccessToken: string;
|
|
545
|
+
expiresAt: number;
|
|
546
|
+
}
|
|
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
|
+
|
|
564
|
+
type WalletOptions = {
|
|
565
|
+
wallet: WalletMetadata;
|
|
566
|
+
authToken: string;
|
|
567
|
+
signingService: SigningService;
|
|
568
|
+
};
|
|
569
|
+
type WalletMetadata = GetWalletResponse & {
|
|
570
|
+
boundToEvmNetwork: boolean;
|
|
571
|
+
};
|
|
572
|
+
declare class KeyWallet extends AbstractSigner {
|
|
573
|
+
private options;
|
|
574
|
+
private address?;
|
|
575
|
+
private authToken;
|
|
576
|
+
private metadata;
|
|
577
|
+
private signingService;
|
|
578
|
+
constructor(options: WalletOptions, provider?: Provider | null);
|
|
579
|
+
connect(provider: Provider | null): KeyWallet;
|
|
580
|
+
getAddress(): Promise<string>;
|
|
581
|
+
private signHash;
|
|
582
|
+
signTransaction(tx: TransactionRequest): Promise<string>;
|
|
583
|
+
signMessage(message: string | Uint8Array): Promise<string>;
|
|
584
|
+
signTypedData(domain: TypedDataDomain, types: Record<string, TypedDataField[]>, value: Record<string, any>): Promise<string>;
|
|
585
|
+
/**
|
|
586
|
+
* Signs a PERS transaction based on its format
|
|
587
|
+
* Handles different transaction types: Legacy, EIP-2930, EIP-1559, and EIP-712
|
|
588
|
+
* @param transactionData - The transaction data from PERS API
|
|
589
|
+
* @returns The signature string
|
|
590
|
+
*/
|
|
591
|
+
signPersTransaction(transactionData: AnyTransactionData): Promise<string>;
|
|
592
|
+
}
|
|
593
|
+
|
|
482
594
|
/**
|
|
483
595
|
* PERS Blockchain Signer SDK
|
|
484
596
|
*
|
|
@@ -715,32 +827,6 @@ declare class TransactionSigningService {
|
|
|
715
827
|
signTransaction(params: TransactionSigningParams, signingData: CounterfactualWalletTransactionResponse | LegacyTransaction): Promise<TransactionSigningResult>;
|
|
716
828
|
}
|
|
717
829
|
|
|
718
|
-
/**
|
|
719
|
-
* Error codes for transaction signing operations
|
|
720
|
-
*/
|
|
721
|
-
declare enum TransactionSigningErrorCode {
|
|
722
|
-
INVALID_TOKENS = "INVALID_TOKENS",
|
|
723
|
-
TRANSACTION_NOT_FOUND = "TRANSACTION_NOT_FOUND",
|
|
724
|
-
TRANSACTION_NOT_PENDING = "TRANSACTION_NOT_PENDING",
|
|
725
|
-
WALLET_NOT_AVAILABLE = "WALLET_NOT_AVAILABLE",
|
|
726
|
-
WEBAUTHN_OPERATION_IN_PROGRESS = "WEBAUTHN_OPERATION_IN_PROGRESS",
|
|
727
|
-
SIGNING_CANCELLED = "SIGNING_CANCELLED",
|
|
728
|
-
PERS_AUTH_FAILED = "PERS_AUTH_FAILED",
|
|
729
|
-
AUTH_FAILED = "AUTH_FAILED",
|
|
730
|
-
TRANSACTION_NOT_READY = "TRANSACTION_NOT_READY",
|
|
731
|
-
SUBMISSION_FAILED = "SUBMISSION_FAILED",
|
|
732
|
-
SERVER_ERROR = "SERVER_ERROR",
|
|
733
|
-
UNKNOWN_ERROR = "UNKNOWN_ERROR"
|
|
734
|
-
}
|
|
735
|
-
/**
|
|
736
|
-
* Structured error for transaction signing operations
|
|
737
|
-
*/
|
|
738
|
-
interface TransactionSigningError extends Error {
|
|
739
|
-
code: TransactionSigningErrorCode;
|
|
740
|
-
transactionId?: string;
|
|
741
|
-
originalError?: unknown;
|
|
742
|
-
}
|
|
743
|
-
|
|
744
830
|
/**
|
|
745
831
|
* Handles all error-related operations for transaction signing
|
|
746
832
|
*/
|
|
@@ -950,36 +1036,6 @@ declare function setHttpClient(client: HttpClient): void;
|
|
|
950
1036
|
*/
|
|
951
1037
|
declare function getHttpClient(): HttpClient;
|
|
952
1038
|
|
|
953
|
-
/**
|
|
954
|
-
* Wallet list response from WalletService
|
|
955
|
-
*/
|
|
956
|
-
interface WalletListResponse {
|
|
957
|
-
items: WalletItem[];
|
|
958
|
-
}
|
|
959
|
-
/**
|
|
960
|
-
* Individual wallet item from wallet list - compatible with KeyWallet constructor
|
|
961
|
-
*/
|
|
962
|
-
interface WalletItem {
|
|
963
|
-
id: string;
|
|
964
|
-
address: string;
|
|
965
|
-
network: string;
|
|
966
|
-
status: string;
|
|
967
|
-
signingKey?: unknown;
|
|
968
|
-
dateCreated?: string;
|
|
969
|
-
custodial?: boolean;
|
|
970
|
-
tags?: string[];
|
|
971
|
-
boundToEvmNetwork?: boolean;
|
|
972
|
-
[key: string]: unknown;
|
|
973
|
-
}
|
|
974
|
-
|
|
975
|
-
/**
|
|
976
|
-
* Authenticated user with all required tokens
|
|
977
|
-
*/
|
|
978
|
-
interface SignerAuthenticatedUser {
|
|
979
|
-
identifier: string;
|
|
980
|
-
signerAuthToken: string;
|
|
981
|
-
persAccessToken: string;
|
|
982
|
-
}
|
|
983
1039
|
/**
|
|
984
1040
|
* Authentication service for user login and registration
|
|
985
1041
|
* Uses constructor-based dependency injection for WebAuthn provider
|
|
@@ -1034,7 +1090,7 @@ declare class AuthenticationService {
|
|
|
1034
1090
|
* @param relyingPartyConfig - Configuration for WebAuthn relying party
|
|
1035
1091
|
* @returns Promise resolving to authenticated user with signer token
|
|
1036
1092
|
*/
|
|
1037
|
-
combinedAuthentication(identifier: string, persAccessToken: string): Promise<
|
|
1093
|
+
combinedAuthentication(identifier: string, persAccessToken: string): Promise<AuthenticatedUser>;
|
|
1038
1094
|
}
|
|
1039
1095
|
|
|
1040
1096
|
/**
|
|
@@ -1058,4 +1114,4 @@ declare function getBrowserWebAuthnProvider(): Promise<WebAuthnProvider>;
|
|
|
1058
1114
|
declare function createPersSignerSDK(config: PersSignerConfig): Promise<PersSignerSDK>;
|
|
1059
1115
|
|
|
1060
1116
|
export { AuthenticationService, FetchHttpClient, KeyWallet, PersService, PersSignerSDK, ReactNativeConfigProvider, SIGNABLE_STATUSES, SigningService, StaticConfigProvider, TransactionErrorHandler, TransactionSigningErrorCode, TransactionSigningService, TransactionSubmissionHandler, TransactionValidator, WalletService, WebAuthnCoordinator, WebConfigProvider, createPersSignerSDK, getBrowserWebAuthnProvider, getConfigProvider, getHttpClient, getServiceConfig, getBrowserWebAuthnProvider as getWebAuthnProvider, setConfigProvider, setHttpClient };
|
|
1061
|
-
export type { AuthResponse, AuthenticatedUser, CombinedTransactionStatus, ConfigProvider, HashSigningRequest, HttpClient, HttpRequestOptions, HttpResponse, PersSignerConfig, PlatformConfig, RegistrationChallenge, RegistrationResult, RelyingPartyConfig,
|
|
1117
|
+
export type { AuthResponse, AuthenticatedUser, CombinedTransactionStatus, CompleteRegistrationResponse, CompleteSignatureRequest, CompleteSignatureResponse, ConfigProvider, HashSigningRequest, HealthCheckResponse, HttpClient, HttpRequestOptions, HttpResponse, InitRegistrationRequest, InitRegistrationResponse, InitSignatureRequest, InitSignatureResponse, ListWalletsRequest, ListWalletsResponse, LoginRequest, LoginResponse, PersSignerConfig, PlatformConfig, RegistrationChallenge, RegistrationResult, RelyingPartyConfig, ServiceError, SignResponse, SignerApiError, SignerApiResponse, SigningAuthTokens, SigningChallenge, SigningRequest, SubmissionResult, TransactionSigningError, TransactionSigningParams, TransactionSigningResult, TransactionStatusInfo, TypedDataSigningRequest, UserCredentials, VerifyTokenRequest, VerifyTokenResponse, WalletItem, WalletListResponse, WebAuthnConfig, WebAuthnProvider };
|
package/dist/browser.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TRANSACTION_FORMATS, TransactionStatus } from '@explorins/pers-shared/browser';
|
|
2
|
-
export { TransactionStatus } from '@explorins/pers-shared/browser';
|
|
2
|
+
export { TRANSACTION_FORMATS, TRANSACTION_FORMAT_DESCRIPTIONS, TransactionStatus } from '@explorins/pers-shared/browser';
|
|
3
3
|
import { AbstractSigner, computeAddress, resolveProperties, resolveAddress, getAddress, Transaction, toUtf8Bytes, keccak256, Signature, JsonRpcProvider } from 'ethers';
|
|
4
4
|
|
|
5
5
|
function _mergeNamespaces(n, m) {
|
|
@@ -564,6 +564,30 @@ PersService.currentTenantId = null;
|
|
|
564
564
|
PersService.useStaging = false;
|
|
565
565
|
PersService.TENANT_CACHE_TTL = 24 * 60 * 60 * 1000; // 24 hours - tenant configs are essentially static
|
|
566
566
|
|
|
567
|
+
/**
|
|
568
|
+
* Transaction statuses that allow signing
|
|
569
|
+
*/
|
|
570
|
+
const SIGNABLE_STATUSES = [TransactionStatus.PENDING_SIGNATURE, TransactionStatus.CREATED];
|
|
571
|
+
|
|
572
|
+
/**
|
|
573
|
+
* Error codes for transaction signing operations
|
|
574
|
+
*/
|
|
575
|
+
var TransactionSigningErrorCode;
|
|
576
|
+
(function (TransactionSigningErrorCode) {
|
|
577
|
+
TransactionSigningErrorCode["INVALID_TOKENS"] = "INVALID_TOKENS";
|
|
578
|
+
TransactionSigningErrorCode["TRANSACTION_NOT_FOUND"] = "TRANSACTION_NOT_FOUND";
|
|
579
|
+
TransactionSigningErrorCode["TRANSACTION_NOT_PENDING"] = "TRANSACTION_NOT_PENDING";
|
|
580
|
+
TransactionSigningErrorCode["WALLET_NOT_AVAILABLE"] = "WALLET_NOT_AVAILABLE";
|
|
581
|
+
TransactionSigningErrorCode["WEBAUTHN_OPERATION_IN_PROGRESS"] = "WEBAUTHN_OPERATION_IN_PROGRESS";
|
|
582
|
+
TransactionSigningErrorCode["SIGNING_CANCELLED"] = "SIGNING_CANCELLED";
|
|
583
|
+
TransactionSigningErrorCode["PERS_AUTH_FAILED"] = "PERS_AUTH_FAILED";
|
|
584
|
+
TransactionSigningErrorCode["AUTH_FAILED"] = "AUTH_FAILED";
|
|
585
|
+
TransactionSigningErrorCode["TRANSACTION_NOT_READY"] = "TRANSACTION_NOT_READY";
|
|
586
|
+
TransactionSigningErrorCode["SUBMISSION_FAILED"] = "SUBMISSION_FAILED";
|
|
587
|
+
TransactionSigningErrorCode["SERVER_ERROR"] = "SERVER_ERROR";
|
|
588
|
+
TransactionSigningErrorCode["UNKNOWN_ERROR"] = "UNKNOWN_ERROR";
|
|
589
|
+
})(TransactionSigningErrorCode || (TransactionSigningErrorCode = {}));
|
|
590
|
+
|
|
567
591
|
// Adapter function to convert backend signature response to legacy format
|
|
568
592
|
const adaptSignatureResponse = (newResponse) => {
|
|
569
593
|
if (!newResponse.signature) {
|
|
@@ -889,25 +913,6 @@ class SigningService {
|
|
|
889
913
|
}
|
|
890
914
|
}
|
|
891
915
|
|
|
892
|
-
/**
|
|
893
|
-
* Error codes for transaction signing operations
|
|
894
|
-
*/
|
|
895
|
-
var TransactionSigningErrorCode;
|
|
896
|
-
(function (TransactionSigningErrorCode) {
|
|
897
|
-
TransactionSigningErrorCode["INVALID_TOKENS"] = "INVALID_TOKENS";
|
|
898
|
-
TransactionSigningErrorCode["TRANSACTION_NOT_FOUND"] = "TRANSACTION_NOT_FOUND";
|
|
899
|
-
TransactionSigningErrorCode["TRANSACTION_NOT_PENDING"] = "TRANSACTION_NOT_PENDING";
|
|
900
|
-
TransactionSigningErrorCode["WALLET_NOT_AVAILABLE"] = "WALLET_NOT_AVAILABLE";
|
|
901
|
-
TransactionSigningErrorCode["WEBAUTHN_OPERATION_IN_PROGRESS"] = "WEBAUTHN_OPERATION_IN_PROGRESS";
|
|
902
|
-
TransactionSigningErrorCode["SIGNING_CANCELLED"] = "SIGNING_CANCELLED";
|
|
903
|
-
TransactionSigningErrorCode["PERS_AUTH_FAILED"] = "PERS_AUTH_FAILED";
|
|
904
|
-
TransactionSigningErrorCode["AUTH_FAILED"] = "AUTH_FAILED";
|
|
905
|
-
TransactionSigningErrorCode["TRANSACTION_NOT_READY"] = "TRANSACTION_NOT_READY";
|
|
906
|
-
TransactionSigningErrorCode["SUBMISSION_FAILED"] = "SUBMISSION_FAILED";
|
|
907
|
-
TransactionSigningErrorCode["SERVER_ERROR"] = "SERVER_ERROR";
|
|
908
|
-
TransactionSigningErrorCode["UNKNOWN_ERROR"] = "UNKNOWN_ERROR";
|
|
909
|
-
})(TransactionSigningErrorCode || (TransactionSigningErrorCode = {}));
|
|
910
|
-
|
|
911
916
|
/**
|
|
912
917
|
* Handles all error-related operations for transaction signing
|
|
913
918
|
*/
|
|
@@ -1107,11 +1112,6 @@ class WebAuthnCoordinator {
|
|
|
1107
1112
|
}
|
|
1108
1113
|
}
|
|
1109
1114
|
|
|
1110
|
-
/**
|
|
1111
|
-
* Transaction statuses that allow signing
|
|
1112
|
-
*/
|
|
1113
|
-
const SIGNABLE_STATUSES = [TransactionStatus.PENDING_SIGNATURE, TransactionStatus.CREATED];
|
|
1114
|
-
|
|
1115
1115
|
/**
|
|
1116
1116
|
* Service for orchestrating transaction signing operations
|
|
1117
1117
|
* Handles the complete flow from transaction preparation to submission
|
|
@@ -1568,11 +1568,13 @@ class AuthenticationService {
|
|
|
1568
1568
|
throw new Error('Registration completed but no response received');
|
|
1569
1569
|
}
|
|
1570
1570
|
}
|
|
1571
|
-
|
|
1572
|
-
identifier,
|
|
1571
|
+
const user = {
|
|
1572
|
+
identifier: identifier,
|
|
1573
1573
|
signerAuthToken: signerToken,
|
|
1574
|
-
persAccessToken
|
|
1574
|
+
persAccessToken: persAccessToken,
|
|
1575
|
+
expiresAt: Date.now() + 300000 // 5 minutes
|
|
1575
1576
|
};
|
|
1577
|
+
return user;
|
|
1576
1578
|
}
|
|
1577
1579
|
catch (error) {
|
|
1578
1580
|
console.error(`[PersSignerSDK] Combined authentication failed for ${identifier}:`, error);
|
|
@@ -1782,25 +1784,17 @@ class PersSignerSDK {
|
|
|
1782
1784
|
throw new Error('Invalid or expired JWT token');
|
|
1783
1785
|
}
|
|
1784
1786
|
const identifier = payload.identifierEmail || payload.email || payload.userId;
|
|
1785
|
-
const tenantId = payload.tenantId || '';
|
|
1786
1787
|
if (!identifier) {
|
|
1787
1788
|
throw new Error('JWT token missing user identifier (identifierEmail, email, or userId)');
|
|
1788
1789
|
}
|
|
1789
1790
|
// Check cache first
|
|
1790
1791
|
const cachedUser = UserCache.get(identifier);
|
|
1791
|
-
if (cachedUser &&
|
|
1792
|
+
if (cachedUser && Date.now() < cachedUser.expiresAt) {
|
|
1792
1793
|
return cachedUser;
|
|
1793
1794
|
}
|
|
1794
1795
|
try {
|
|
1795
1796
|
// Authenticate and cache
|
|
1796
|
-
const
|
|
1797
|
-
const user = {
|
|
1798
|
-
identifier: authResult.identifier,
|
|
1799
|
-
signerAuthToken: authResult.signerAuthToken,
|
|
1800
|
-
persAccessToken: authResult.persAccessToken,
|
|
1801
|
-
tenantId,
|
|
1802
|
-
expiresAt: Date.now() + 300000 // 5 minutes
|
|
1803
|
-
};
|
|
1797
|
+
const user = await this.authenticationService.combinedAuthentication(identifier, jwtToken);
|
|
1804
1798
|
UserCache.set(identifier, user);
|
|
1805
1799
|
return user;
|
|
1806
1800
|
}
|
|
@@ -1840,6 +1834,9 @@ class PersSignerSDK {
|
|
|
1840
1834
|
if (!payload?.transactionId) {
|
|
1841
1835
|
throw new Error('JWT token missing transactionId in payload');
|
|
1842
1836
|
}
|
|
1837
|
+
if (!payload.tenantId) {
|
|
1838
|
+
throw new Error('JWT token missing tenantId in payload');
|
|
1839
|
+
}
|
|
1843
1840
|
const authTokens = {
|
|
1844
1841
|
signerAuthToken: user.signerAuthToken,
|
|
1845
1842
|
persAccessToken: user.persAccessToken
|
|
@@ -1848,7 +1845,7 @@ class PersSignerSDK {
|
|
|
1848
1845
|
const persSigningData = await this.transactionSigningService.getPersSigningData({
|
|
1849
1846
|
transactionId: payload.transactionId,
|
|
1850
1847
|
authTokens,
|
|
1851
|
-
tenantId:
|
|
1848
|
+
tenantId: payload.tenantId
|
|
1852
1849
|
});
|
|
1853
1850
|
const result = await this.signTransaction(persSigningData, jwtToken);
|
|
1854
1851
|
if (!result.success) {
|
|
@@ -1890,6 +1887,9 @@ class PersSignerSDK {
|
|
|
1890
1887
|
if (!payload?.transactionId) {
|
|
1891
1888
|
throw new Error('JWT token missing transactionId in payload');
|
|
1892
1889
|
}
|
|
1890
|
+
if (!payload.tenantId) {
|
|
1891
|
+
throw new Error('JWT token missing tenantId in payload');
|
|
1892
|
+
}
|
|
1893
1893
|
const authTokens = {
|
|
1894
1894
|
signerAuthToken: user.signerAuthToken,
|
|
1895
1895
|
persAccessToken: user.persAccessToken
|
|
@@ -1897,7 +1897,7 @@ class PersSignerSDK {
|
|
|
1897
1897
|
try {
|
|
1898
1898
|
const result = await this.transactionSigningService.signTransaction({
|
|
1899
1899
|
transactionId: payload.transactionId,
|
|
1900
|
-
tenantId:
|
|
1900
|
+
tenantId: payload.tenantId,
|
|
1901
1901
|
authTokens,
|
|
1902
1902
|
ethersProviderUrl: this.config.ethersProviderUrl || ''
|
|
1903
1903
|
}, signingData);
|