@explorins/pers-signer 1.0.16 → 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 +48 -40
- package/dist/browser.cjs.js.map +1 -1
- package/dist/browser.d.ts +382 -325
- package/dist/browser.esm.js +41 -41
- package/dist/browser.esm.js.map +1 -1
- package/dist/index.cjs.js +48 -40
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +309 -292
- package/dist/index.esm.js +41 -41
- package/dist/index.esm.js.map +1 -1
- package/dist/react-native.cjs.js +48 -40
- package/dist/react-native.cjs.js.map +1 -1
- package/dist/react-native.d.ts +382 -325
- package/dist/react-native.esm.js +41 -41
- package/dist/react-native.esm.js.map +1 -1
- package/package.json +1 -1
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);
|
|
@@ -1737,7 +1739,7 @@ class PersSignerSDK {
|
|
|
1737
1739
|
/**
|
|
1738
1740
|
* Initialize the PERS Signer SDK
|
|
1739
1741
|
*
|
|
1740
|
-
* @param {
|
|
1742
|
+
* @param {ExtendedPersSignerConfig} config - SDK configuration object
|
|
1741
1743
|
* @throws {Error} If required configuration is missing
|
|
1742
1744
|
*/
|
|
1743
1745
|
constructor(config) {
|
|
@@ -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 || this.config.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);
|