@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/react-native.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
|
/**
|
|
@@ -1060,4 +1116,4 @@ declare function getReactNativeWebAuthnProvider(): Promise<WebAuthnProvider>;
|
|
|
1060
1116
|
declare function createPersSignerSDK(config: PersSignerConfig): Promise<PersSignerSDK>;
|
|
1061
1117
|
|
|
1062
1118
|
export { AuthenticationService, FetchHttpClient, KeyWallet, PersService, PersSignerSDK, ReactNativeConfigProvider, SIGNABLE_STATUSES, SigningService, StaticConfigProvider, TransactionErrorHandler, TransactionSigningErrorCode, TransactionSigningService, TransactionSubmissionHandler, TransactionValidator, WalletService, WebAuthnCoordinator, WebConfigProvider, createPersSignerSDK, getConfigProvider, getHttpClient, getServiceConfig, getReactNativeWebAuthnProvider as getWebAuthnProvider, setConfigProvider, setHttpClient };
|
|
1063
|
-
export type { AuthResponse, AuthenticatedUser, CombinedTransactionStatus, ConfigProvider, HashSigningRequest, HttpClient, HttpRequestOptions, HttpResponse, PersSignerConfig, PlatformConfig, RegistrationChallenge, RegistrationResult, RelyingPartyConfig,
|
|
1119
|
+
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/react-native.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
|
import require$$2$1, { Platform, NativeModules } from 'react-native';
|
|
5
5
|
|
|
@@ -565,6 +565,30 @@ PersService.currentTenantId = null;
|
|
|
565
565
|
PersService.useStaging = false;
|
|
566
566
|
PersService.TENANT_CACHE_TTL = 24 * 60 * 60 * 1000; // 24 hours - tenant configs are essentially static
|
|
567
567
|
|
|
568
|
+
/**
|
|
569
|
+
* Transaction statuses that allow signing
|
|
570
|
+
*/
|
|
571
|
+
const SIGNABLE_STATUSES = [TransactionStatus.PENDING_SIGNATURE, TransactionStatus.CREATED];
|
|
572
|
+
|
|
573
|
+
/**
|
|
574
|
+
* Error codes for transaction signing operations
|
|
575
|
+
*/
|
|
576
|
+
var TransactionSigningErrorCode;
|
|
577
|
+
(function (TransactionSigningErrorCode) {
|
|
578
|
+
TransactionSigningErrorCode["INVALID_TOKENS"] = "INVALID_TOKENS";
|
|
579
|
+
TransactionSigningErrorCode["TRANSACTION_NOT_FOUND"] = "TRANSACTION_NOT_FOUND";
|
|
580
|
+
TransactionSigningErrorCode["TRANSACTION_NOT_PENDING"] = "TRANSACTION_NOT_PENDING";
|
|
581
|
+
TransactionSigningErrorCode["WALLET_NOT_AVAILABLE"] = "WALLET_NOT_AVAILABLE";
|
|
582
|
+
TransactionSigningErrorCode["WEBAUTHN_OPERATION_IN_PROGRESS"] = "WEBAUTHN_OPERATION_IN_PROGRESS";
|
|
583
|
+
TransactionSigningErrorCode["SIGNING_CANCELLED"] = "SIGNING_CANCELLED";
|
|
584
|
+
TransactionSigningErrorCode["PERS_AUTH_FAILED"] = "PERS_AUTH_FAILED";
|
|
585
|
+
TransactionSigningErrorCode["AUTH_FAILED"] = "AUTH_FAILED";
|
|
586
|
+
TransactionSigningErrorCode["TRANSACTION_NOT_READY"] = "TRANSACTION_NOT_READY";
|
|
587
|
+
TransactionSigningErrorCode["SUBMISSION_FAILED"] = "SUBMISSION_FAILED";
|
|
588
|
+
TransactionSigningErrorCode["SERVER_ERROR"] = "SERVER_ERROR";
|
|
589
|
+
TransactionSigningErrorCode["UNKNOWN_ERROR"] = "UNKNOWN_ERROR";
|
|
590
|
+
})(TransactionSigningErrorCode || (TransactionSigningErrorCode = {}));
|
|
591
|
+
|
|
568
592
|
// Adapter function to convert backend signature response to legacy format
|
|
569
593
|
const adaptSignatureResponse = (newResponse) => {
|
|
570
594
|
if (!newResponse.signature) {
|
|
@@ -890,25 +914,6 @@ class SigningService {
|
|
|
890
914
|
}
|
|
891
915
|
}
|
|
892
916
|
|
|
893
|
-
/**
|
|
894
|
-
* Error codes for transaction signing operations
|
|
895
|
-
*/
|
|
896
|
-
var TransactionSigningErrorCode;
|
|
897
|
-
(function (TransactionSigningErrorCode) {
|
|
898
|
-
TransactionSigningErrorCode["INVALID_TOKENS"] = "INVALID_TOKENS";
|
|
899
|
-
TransactionSigningErrorCode["TRANSACTION_NOT_FOUND"] = "TRANSACTION_NOT_FOUND";
|
|
900
|
-
TransactionSigningErrorCode["TRANSACTION_NOT_PENDING"] = "TRANSACTION_NOT_PENDING";
|
|
901
|
-
TransactionSigningErrorCode["WALLET_NOT_AVAILABLE"] = "WALLET_NOT_AVAILABLE";
|
|
902
|
-
TransactionSigningErrorCode["WEBAUTHN_OPERATION_IN_PROGRESS"] = "WEBAUTHN_OPERATION_IN_PROGRESS";
|
|
903
|
-
TransactionSigningErrorCode["SIGNING_CANCELLED"] = "SIGNING_CANCELLED";
|
|
904
|
-
TransactionSigningErrorCode["PERS_AUTH_FAILED"] = "PERS_AUTH_FAILED";
|
|
905
|
-
TransactionSigningErrorCode["AUTH_FAILED"] = "AUTH_FAILED";
|
|
906
|
-
TransactionSigningErrorCode["TRANSACTION_NOT_READY"] = "TRANSACTION_NOT_READY";
|
|
907
|
-
TransactionSigningErrorCode["SUBMISSION_FAILED"] = "SUBMISSION_FAILED";
|
|
908
|
-
TransactionSigningErrorCode["SERVER_ERROR"] = "SERVER_ERROR";
|
|
909
|
-
TransactionSigningErrorCode["UNKNOWN_ERROR"] = "UNKNOWN_ERROR";
|
|
910
|
-
})(TransactionSigningErrorCode || (TransactionSigningErrorCode = {}));
|
|
911
|
-
|
|
912
917
|
/**
|
|
913
918
|
* Handles all error-related operations for transaction signing
|
|
914
919
|
*/
|
|
@@ -1108,11 +1113,6 @@ class WebAuthnCoordinator {
|
|
|
1108
1113
|
}
|
|
1109
1114
|
}
|
|
1110
1115
|
|
|
1111
|
-
/**
|
|
1112
|
-
* Transaction statuses that allow signing
|
|
1113
|
-
*/
|
|
1114
|
-
const SIGNABLE_STATUSES = [TransactionStatus.PENDING_SIGNATURE, TransactionStatus.CREATED];
|
|
1115
|
-
|
|
1116
1116
|
/**
|
|
1117
1117
|
* Service for orchestrating transaction signing operations
|
|
1118
1118
|
* Handles the complete flow from transaction preparation to submission
|
|
@@ -1569,11 +1569,13 @@ class AuthenticationService {
|
|
|
1569
1569
|
throw new Error('Registration completed but no response received');
|
|
1570
1570
|
}
|
|
1571
1571
|
}
|
|
1572
|
-
|
|
1573
|
-
identifier,
|
|
1572
|
+
const user = {
|
|
1573
|
+
identifier: identifier,
|
|
1574
1574
|
signerAuthToken: signerToken,
|
|
1575
|
-
persAccessToken
|
|
1575
|
+
persAccessToken: persAccessToken,
|
|
1576
|
+
expiresAt: Date.now() + 300000 // 5 minutes
|
|
1576
1577
|
};
|
|
1578
|
+
return user;
|
|
1577
1579
|
}
|
|
1578
1580
|
catch (error) {
|
|
1579
1581
|
console.error(`[PersSignerSDK] Combined authentication failed for ${identifier}:`, error);
|
|
@@ -1783,25 +1785,17 @@ class PersSignerSDK {
|
|
|
1783
1785
|
throw new Error('Invalid or expired JWT token');
|
|
1784
1786
|
}
|
|
1785
1787
|
const identifier = payload.identifierEmail || payload.email || payload.userId;
|
|
1786
|
-
const tenantId = payload.tenantId || '';
|
|
1787
1788
|
if (!identifier) {
|
|
1788
1789
|
throw new Error('JWT token missing user identifier (identifierEmail, email, or userId)');
|
|
1789
1790
|
}
|
|
1790
1791
|
// Check cache first
|
|
1791
1792
|
const cachedUser = UserCache.get(identifier);
|
|
1792
|
-
if (cachedUser &&
|
|
1793
|
+
if (cachedUser && Date.now() < cachedUser.expiresAt) {
|
|
1793
1794
|
return cachedUser;
|
|
1794
1795
|
}
|
|
1795
1796
|
try {
|
|
1796
1797
|
// Authenticate and cache
|
|
1797
|
-
const
|
|
1798
|
-
const user = {
|
|
1799
|
-
identifier: authResult.identifier,
|
|
1800
|
-
signerAuthToken: authResult.signerAuthToken,
|
|
1801
|
-
persAccessToken: authResult.persAccessToken,
|
|
1802
|
-
tenantId,
|
|
1803
|
-
expiresAt: Date.now() + 300000 // 5 minutes
|
|
1804
|
-
};
|
|
1798
|
+
const user = await this.authenticationService.combinedAuthentication(identifier, jwtToken);
|
|
1805
1799
|
UserCache.set(identifier, user);
|
|
1806
1800
|
return user;
|
|
1807
1801
|
}
|
|
@@ -1841,6 +1835,9 @@ class PersSignerSDK {
|
|
|
1841
1835
|
if (!payload?.transactionId) {
|
|
1842
1836
|
throw new Error('JWT token missing transactionId in payload');
|
|
1843
1837
|
}
|
|
1838
|
+
if (!payload.tenantId) {
|
|
1839
|
+
throw new Error('JWT token missing tenantId in payload');
|
|
1840
|
+
}
|
|
1844
1841
|
const authTokens = {
|
|
1845
1842
|
signerAuthToken: user.signerAuthToken,
|
|
1846
1843
|
persAccessToken: user.persAccessToken
|
|
@@ -1849,7 +1846,7 @@ class PersSignerSDK {
|
|
|
1849
1846
|
const persSigningData = await this.transactionSigningService.getPersSigningData({
|
|
1850
1847
|
transactionId: payload.transactionId,
|
|
1851
1848
|
authTokens,
|
|
1852
|
-
tenantId:
|
|
1849
|
+
tenantId: payload.tenantId
|
|
1853
1850
|
});
|
|
1854
1851
|
const result = await this.signTransaction(persSigningData, jwtToken);
|
|
1855
1852
|
if (!result.success) {
|
|
@@ -1891,6 +1888,9 @@ class PersSignerSDK {
|
|
|
1891
1888
|
if (!payload?.transactionId) {
|
|
1892
1889
|
throw new Error('JWT token missing transactionId in payload');
|
|
1893
1890
|
}
|
|
1891
|
+
if (!payload.tenantId) {
|
|
1892
|
+
throw new Error('JWT token missing tenantId in payload');
|
|
1893
|
+
}
|
|
1894
1894
|
const authTokens = {
|
|
1895
1895
|
signerAuthToken: user.signerAuthToken,
|
|
1896
1896
|
persAccessToken: user.persAccessToken
|
|
@@ -1898,7 +1898,7 @@ class PersSignerSDK {
|
|
|
1898
1898
|
try {
|
|
1899
1899
|
const result = await this.transactionSigningService.signTransaction({
|
|
1900
1900
|
transactionId: payload.transactionId,
|
|
1901
|
-
tenantId:
|
|
1901
|
+
tenantId: payload.tenantId,
|
|
1902
1902
|
authTokens,
|
|
1903
1903
|
ethersProviderUrl: this.config.ethersProviderUrl || ''
|
|
1904
1904
|
}, signingData);
|