@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/index.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
|
|
|
@@ -407,11 +407,13 @@ class AuthenticationService {
|
|
|
407
407
|
throw new Error('Registration completed but no response received');
|
|
408
408
|
}
|
|
409
409
|
}
|
|
410
|
-
|
|
411
|
-
identifier,
|
|
410
|
+
const user = {
|
|
411
|
+
identifier: identifier,
|
|
412
412
|
signerAuthToken: signerToken,
|
|
413
|
-
persAccessToken
|
|
413
|
+
persAccessToken: persAccessToken,
|
|
414
|
+
expiresAt: Date.now() + 300000 // 5 minutes
|
|
414
415
|
};
|
|
416
|
+
return user;
|
|
415
417
|
}
|
|
416
418
|
catch (error) {
|
|
417
419
|
console.error(`[PersSignerSDK] Combined authentication failed for ${identifier}:`, error);
|
|
@@ -952,6 +954,30 @@ class HealthService {
|
|
|
952
954
|
}
|
|
953
955
|
}
|
|
954
956
|
|
|
957
|
+
/**
|
|
958
|
+
* Transaction statuses that allow signing
|
|
959
|
+
*/
|
|
960
|
+
const SIGNABLE_STATUSES = [TransactionStatus.PENDING_SIGNATURE, TransactionStatus.CREATED];
|
|
961
|
+
|
|
962
|
+
/**
|
|
963
|
+
* Error codes for transaction signing operations
|
|
964
|
+
*/
|
|
965
|
+
var TransactionSigningErrorCode;
|
|
966
|
+
(function (TransactionSigningErrorCode) {
|
|
967
|
+
TransactionSigningErrorCode["INVALID_TOKENS"] = "INVALID_TOKENS";
|
|
968
|
+
TransactionSigningErrorCode["TRANSACTION_NOT_FOUND"] = "TRANSACTION_NOT_FOUND";
|
|
969
|
+
TransactionSigningErrorCode["TRANSACTION_NOT_PENDING"] = "TRANSACTION_NOT_PENDING";
|
|
970
|
+
TransactionSigningErrorCode["WALLET_NOT_AVAILABLE"] = "WALLET_NOT_AVAILABLE";
|
|
971
|
+
TransactionSigningErrorCode["WEBAUTHN_OPERATION_IN_PROGRESS"] = "WEBAUTHN_OPERATION_IN_PROGRESS";
|
|
972
|
+
TransactionSigningErrorCode["SIGNING_CANCELLED"] = "SIGNING_CANCELLED";
|
|
973
|
+
TransactionSigningErrorCode["PERS_AUTH_FAILED"] = "PERS_AUTH_FAILED";
|
|
974
|
+
TransactionSigningErrorCode["AUTH_FAILED"] = "AUTH_FAILED";
|
|
975
|
+
TransactionSigningErrorCode["TRANSACTION_NOT_READY"] = "TRANSACTION_NOT_READY";
|
|
976
|
+
TransactionSigningErrorCode["SUBMISSION_FAILED"] = "SUBMISSION_FAILED";
|
|
977
|
+
TransactionSigningErrorCode["SERVER_ERROR"] = "SERVER_ERROR";
|
|
978
|
+
TransactionSigningErrorCode["UNKNOWN_ERROR"] = "UNKNOWN_ERROR";
|
|
979
|
+
})(TransactionSigningErrorCode || (TransactionSigningErrorCode = {}));
|
|
980
|
+
|
|
955
981
|
// Adapter function to convert backend signature response to legacy format
|
|
956
982
|
const adaptSignatureResponse = (newResponse) => {
|
|
957
983
|
if (!newResponse.signature) {
|
|
@@ -1169,25 +1195,6 @@ class KeyWallet extends AbstractSigner {
|
|
|
1169
1195
|
}
|
|
1170
1196
|
}
|
|
1171
1197
|
|
|
1172
|
-
/**
|
|
1173
|
-
* Error codes for transaction signing operations
|
|
1174
|
-
*/
|
|
1175
|
-
var TransactionSigningErrorCode;
|
|
1176
|
-
(function (TransactionSigningErrorCode) {
|
|
1177
|
-
TransactionSigningErrorCode["INVALID_TOKENS"] = "INVALID_TOKENS";
|
|
1178
|
-
TransactionSigningErrorCode["TRANSACTION_NOT_FOUND"] = "TRANSACTION_NOT_FOUND";
|
|
1179
|
-
TransactionSigningErrorCode["TRANSACTION_NOT_PENDING"] = "TRANSACTION_NOT_PENDING";
|
|
1180
|
-
TransactionSigningErrorCode["WALLET_NOT_AVAILABLE"] = "WALLET_NOT_AVAILABLE";
|
|
1181
|
-
TransactionSigningErrorCode["WEBAUTHN_OPERATION_IN_PROGRESS"] = "WEBAUTHN_OPERATION_IN_PROGRESS";
|
|
1182
|
-
TransactionSigningErrorCode["SIGNING_CANCELLED"] = "SIGNING_CANCELLED";
|
|
1183
|
-
TransactionSigningErrorCode["PERS_AUTH_FAILED"] = "PERS_AUTH_FAILED";
|
|
1184
|
-
TransactionSigningErrorCode["AUTH_FAILED"] = "AUTH_FAILED";
|
|
1185
|
-
TransactionSigningErrorCode["TRANSACTION_NOT_READY"] = "TRANSACTION_NOT_READY";
|
|
1186
|
-
TransactionSigningErrorCode["SUBMISSION_FAILED"] = "SUBMISSION_FAILED";
|
|
1187
|
-
TransactionSigningErrorCode["SERVER_ERROR"] = "SERVER_ERROR";
|
|
1188
|
-
TransactionSigningErrorCode["UNKNOWN_ERROR"] = "UNKNOWN_ERROR";
|
|
1189
|
-
})(TransactionSigningErrorCode || (TransactionSigningErrorCode = {}));
|
|
1190
|
-
|
|
1191
1198
|
/**
|
|
1192
1199
|
* Handles all error-related operations for transaction signing
|
|
1193
1200
|
*/
|
|
@@ -1387,11 +1394,6 @@ class WebAuthnCoordinator {
|
|
|
1387
1394
|
}
|
|
1388
1395
|
}
|
|
1389
1396
|
|
|
1390
|
-
/**
|
|
1391
|
-
* Transaction statuses that allow signing
|
|
1392
|
-
*/
|
|
1393
|
-
const SIGNABLE_STATUSES = [TransactionStatus.PENDING_SIGNATURE, TransactionStatus.CREATED];
|
|
1394
|
-
|
|
1395
1397
|
/**
|
|
1396
1398
|
* Service for orchestrating transaction signing operations
|
|
1397
1399
|
* Handles the complete flow from transaction preparation to submission
|
|
@@ -1942,25 +1944,17 @@ class PersSignerSDK {
|
|
|
1942
1944
|
throw new Error('Invalid or expired JWT token');
|
|
1943
1945
|
}
|
|
1944
1946
|
const identifier = payload.identifierEmail || payload.email || payload.userId;
|
|
1945
|
-
const tenantId = payload.tenantId || '';
|
|
1946
1947
|
if (!identifier) {
|
|
1947
1948
|
throw new Error('JWT token missing user identifier (identifierEmail, email, or userId)');
|
|
1948
1949
|
}
|
|
1949
1950
|
// Check cache first
|
|
1950
1951
|
const cachedUser = UserCache.get(identifier);
|
|
1951
|
-
if (cachedUser &&
|
|
1952
|
+
if (cachedUser && Date.now() < cachedUser.expiresAt) {
|
|
1952
1953
|
return cachedUser;
|
|
1953
1954
|
}
|
|
1954
1955
|
try {
|
|
1955
1956
|
// Authenticate and cache
|
|
1956
|
-
const
|
|
1957
|
-
const user = {
|
|
1958
|
-
identifier: authResult.identifier,
|
|
1959
|
-
signerAuthToken: authResult.signerAuthToken,
|
|
1960
|
-
persAccessToken: authResult.persAccessToken,
|
|
1961
|
-
tenantId,
|
|
1962
|
-
expiresAt: Date.now() + 300000 // 5 minutes
|
|
1963
|
-
};
|
|
1957
|
+
const user = await this.authenticationService.combinedAuthentication(identifier, jwtToken);
|
|
1964
1958
|
UserCache.set(identifier, user);
|
|
1965
1959
|
return user;
|
|
1966
1960
|
}
|
|
@@ -2000,6 +1994,9 @@ class PersSignerSDK {
|
|
|
2000
1994
|
if (!payload?.transactionId) {
|
|
2001
1995
|
throw new Error('JWT token missing transactionId in payload');
|
|
2002
1996
|
}
|
|
1997
|
+
if (!payload.tenantId) {
|
|
1998
|
+
throw new Error('JWT token missing tenantId in payload');
|
|
1999
|
+
}
|
|
2003
2000
|
const authTokens = {
|
|
2004
2001
|
signerAuthToken: user.signerAuthToken,
|
|
2005
2002
|
persAccessToken: user.persAccessToken
|
|
@@ -2008,7 +2005,7 @@ class PersSignerSDK {
|
|
|
2008
2005
|
const persSigningData = await this.transactionSigningService.getPersSigningData({
|
|
2009
2006
|
transactionId: payload.transactionId,
|
|
2010
2007
|
authTokens,
|
|
2011
|
-
tenantId:
|
|
2008
|
+
tenantId: payload.tenantId
|
|
2012
2009
|
});
|
|
2013
2010
|
const result = await this.signTransaction(persSigningData, jwtToken);
|
|
2014
2011
|
if (!result.success) {
|
|
@@ -2050,6 +2047,9 @@ class PersSignerSDK {
|
|
|
2050
2047
|
if (!payload?.transactionId) {
|
|
2051
2048
|
throw new Error('JWT token missing transactionId in payload');
|
|
2052
2049
|
}
|
|
2050
|
+
if (!payload.tenantId) {
|
|
2051
|
+
throw new Error('JWT token missing tenantId in payload');
|
|
2052
|
+
}
|
|
2053
2053
|
const authTokens = {
|
|
2054
2054
|
signerAuthToken: user.signerAuthToken,
|
|
2055
2055
|
persAccessToken: user.persAccessToken
|
|
@@ -2057,7 +2057,7 @@ class PersSignerSDK {
|
|
|
2057
2057
|
try {
|
|
2058
2058
|
const result = await this.transactionSigningService.signTransaction({
|
|
2059
2059
|
transactionId: payload.transactionId,
|
|
2060
|
-
tenantId:
|
|
2060
|
+
tenantId: payload.tenantId,
|
|
2061
2061
|
authTokens,
|
|
2062
2062
|
ethersProviderUrl: this.config.ethersProviderUrl || ''
|
|
2063
2063
|
}, signingData);
|