@getpara/core-sdk 2.15.0 → 2.17.0

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.
@@ -403,9 +403,8 @@ const _ParaCore = class _ParaCore {
403
403
  }
404
404
  if (!opts) opts = {};
405
405
  __privateSet(this, _debugLogsEnabled, !!opts.enableDebugLogs);
406
- let isE2E = false;
407
- if (env === "E2E") {
408
- isE2E = true;
406
+ const isE2E = env === "E2E" || envOrApiKey === "E2E";
407
+ if (isE2E && env !== import_types.Environment.SANDBOX) {
409
408
  env = import_types.Environment.SANDBOX;
410
409
  }
411
410
  this.externalWalletConnectionOnly = opts.externalWalletConnectionOnly;
@@ -2132,7 +2131,7 @@ const _ParaCore = class _ParaCore {
2132
2131
  * @param {Object} opts the options object.
2133
2132
  * @param {string} opts.walletId the id of the wallet to sign with.
2134
2133
  * @param {string} opts.messageBase64 the base64 encoding of exact message that should be signed
2135
- * @param {number} [opts.timeout] optional timeout in milliseconds. If not present, defaults to 30 seconds.
2134
+ * @param {number} [opts.timeout] optional timeout in milliseconds. If not present, defaults to 30 seconds. Extended to a minimum of 5 minutes when the transaction requires approval.
2136
2135
  * @param {string} [opts.cosmosSignDocBase64] the Cosmos `SignDoc` in base64, if applicable
2137
2136
  **/
2138
2137
  signMessage(_0) {
@@ -2154,9 +2153,10 @@ const _ParaCore = class _ParaCore {
2154
2153
  }
2155
2154
  let signRes = yield this.signMessageInner({ wallet, signerId, messageBase64, cosmosSignDocBase64 });
2156
2155
  let timeStart = Date.now();
2156
+ const effectiveTimeoutMs = Math.max(timeoutMs, constants.TRANSACTION_REVIEW_TIMEOUT_MS);
2157
2157
  if (signRes.pendingTransactionId) {
2158
2158
  yield this.platformUtils.openPopup(
2159
- yield this.getTransactionReviewUrl(signRes.pendingTransactionId, timeoutMs),
2159
+ yield this.getTransactionReviewUrl(signRes.pendingTransactionId, effectiveTimeoutMs),
2160
2160
  { type: cosmosSignDocBase64 ? import_types.PopupType.SIGN_TRANSACTION_REVIEW : import_types.PopupType.SIGN_MESSAGE_REVIEW }
2161
2161
  );
2162
2162
  } else {
@@ -2164,7 +2164,7 @@ const _ParaCore = class _ParaCore {
2164
2164
  return signRes;
2165
2165
  }
2166
2166
  while (true) {
2167
- if (isCanceled() || Date.now() - timeStart > timeoutMs) {
2167
+ if (isCanceled() || Date.now() - timeStart > effectiveTimeoutMs) {
2168
2168
  onCancel == null ? void 0 : onCancel();
2169
2169
  break;
2170
2170
  }
@@ -2238,7 +2238,7 @@ const _ParaCore = class _ParaCore {
2238
2238
  * @param {string} opts.walletId the id of the wallet to sign with.
2239
2239
  * @param {string} opts.rlpEncodedTxBase64 the transaction to sign, in RLP base64 encoding
2240
2240
  * @param {string} [opts.chainId] the EVM chain id of the chain the transaction is being sent on, if applicable
2241
- * @param {number} [opts.timeoutMs] the amount of time to wait for the user to sign the transaction, in milliseconds
2241
+ * @param {number} [opts.timeoutMs] the amount of time to wait for the user to sign the transaction, in milliseconds. Extended to a minimum of 5 minutes when the transaction requires approval.
2242
2242
  **/
2243
2243
  signTransaction(_0) {
2244
2244
  return __async(this, arguments, function* ({
@@ -2268,9 +2268,10 @@ const _ParaCore = class _ParaCore {
2268
2268
  wallet.scheme === "DKLS"
2269
2269
  );
2270
2270
  let timeStart = Date.now();
2271
+ const effectiveTimeoutMs = Math.max(timeoutMs, constants.TRANSACTION_REVIEW_TIMEOUT_MS);
2271
2272
  if (signRes.pendingTransactionId) {
2272
2273
  yield this.platformUtils.openPopup(
2273
- yield this.getTransactionReviewUrl(signRes.pendingTransactionId, timeoutMs),
2274
+ yield this.getTransactionReviewUrl(signRes.pendingTransactionId, effectiveTimeoutMs),
2274
2275
  { type: import_types.PopupType.SIGN_TRANSACTION_REVIEW }
2275
2276
  );
2276
2277
  } else {
@@ -2278,7 +2279,7 @@ const _ParaCore = class _ParaCore {
2278
2279
  return signRes;
2279
2280
  }
2280
2281
  while (true) {
2281
- if (isCanceled() || Date.now() - timeStart > timeoutMs) {
2282
+ if (isCanceled() || Date.now() - timeStart > effectiveTimeoutMs) {
2282
2283
  onCancel == null ? void 0 : onCancel();
2283
2284
  break;
2284
2285
  }
@@ -42,10 +42,11 @@ __export(constants_exports, {
42
42
  POLLING_TIMEOUT_MS: () => POLLING_TIMEOUT_MS,
43
43
  PREFIX: () => PREFIX,
44
44
  SESSION_STORAGE_LOGIN_ENCRYPTION_KEY_PAIR: () => SESSION_STORAGE_LOGIN_ENCRYPTION_KEY_PAIR,
45
- SHORT_POLLING_INTERVAL_MS: () => SHORT_POLLING_INTERVAL_MS
45
+ SHORT_POLLING_INTERVAL_MS: () => SHORT_POLLING_INTERVAL_MS,
46
+ TRANSACTION_REVIEW_TIMEOUT_MS: () => TRANSACTION_REVIEW_TIMEOUT_MS
46
47
  });
47
48
  module.exports = __toCommonJS(constants_exports);
48
- const PARA_CORE_VERSION = "2.15.0";
49
+ const PARA_CORE_VERSION = "2.16.0";
49
50
  const PREFIX = "@CAPSULE/";
50
51
  const PARA_PREFIX = "@PARA/";
51
52
  const LOCAL_STORAGE_AUTH_INFO = `${PREFIX}authInfo`;
@@ -69,6 +70,7 @@ const LOCAL_STORAGE_IS_IMPORTED_SESSION = `${PREFIX}isImportedSession`;
69
70
  const POLLING_INTERVAL_MS = 1e3;
70
71
  const SHORT_POLLING_INTERVAL_MS = 750;
71
72
  const POLLING_TIMEOUT_MS = 3e5;
73
+ const TRANSACTION_REVIEW_TIMEOUT_MS = 3e5;
72
74
  const EXTERNAL_WALLET_CONNECTION_ONLY_USER_ID = "EXTERNAL_WALLET_CONNECTION_ONLY";
73
75
  const ACCOUNT_LINK_CONFLICT = "Account already linked";
74
76
  // Annotate the CommonJS export names for ESM import in node:
@@ -98,5 +100,6 @@ const ACCOUNT_LINK_CONFLICT = "Account already linked";
98
100
  POLLING_TIMEOUT_MS,
99
101
  PREFIX,
100
102
  SESSION_STORAGE_LOGIN_ENCRYPTION_KEY_PAIR,
101
- SHORT_POLLING_INTERVAL_MS
103
+ SHORT_POLLING_INTERVAL_MS,
104
+ TRANSACTION_REVIEW_TIMEOUT_MS
102
105
  });
@@ -116,7 +116,7 @@ function encryptPrivateKey(keyPair, key) {
116
116
  const ciphertext = yield window.crypto.subtle.encrypt(
117
117
  { name: "AES-GCM", iv: CONSTANT_IV_AES },
118
118
  cryptoKey,
119
- encodedPlaintext
119
+ encodedPlaintext.buffer
120
120
  );
121
121
  return Buffer.from(ciphertext).toString("base64");
122
122
  });
@@ -299,7 +299,7 @@ function encryptPrivateKeyWithPassword(keyPair, hashedPassword) {
299
299
  const ciphertext = yield window.crypto.subtle.encrypt(
300
300
  { name: "AES-GCM", iv: CONSTANT_IV_AES },
301
301
  cryptoKey,
302
- encodedPlaintext
302
+ encodedPlaintext.buffer
303
303
  );
304
304
  return Buffer.from(ciphertext).toString("base64");
305
305
  });
@@ -105,6 +105,9 @@ class PortalUrlService {
105
105
  * @returns - portal URL
106
106
  */
107
107
  this.getPortalURL = (isLegacy) => __async(this, null, function* () {
108
+ if (__privateGet(this, _paraCoreInterface).ctx.isE2E) {
109
+ return (0, import_url.getPortalBaseURL)(__privateGet(this, _paraCoreInterface).ctx, false, false, isLegacy);
110
+ }
108
111
  return __privateGet(this, _paraCoreInterface).ctx.portalUrlOverride || (yield this.getPartnerURL()) || (0, import_url.getPortalBaseURL)(__privateGet(this, _paraCoreInterface).ctx, false, false, isLegacy);
109
112
  });
110
113
  this.constructPortalUrl = (_0, ..._1) => __async(this, [_0, ..._1], function* (type, opts = {}) {
@@ -345,9 +345,8 @@ const _ParaCore = class _ParaCore {
345
345
  }
346
346
  if (!opts) opts = {};
347
347
  __privateSet(this, _debugLogsEnabled, !!opts.enableDebugLogs);
348
- let isE2E = false;
349
- if (env === "E2E") {
350
- isE2E = true;
348
+ const isE2E = env === "E2E" || envOrApiKey === "E2E";
349
+ if (isE2E && env !== Environment.SANDBOX) {
351
350
  env = Environment.SANDBOX;
352
351
  }
353
352
  this.externalWalletConnectionOnly = opts.externalWalletConnectionOnly;
@@ -2074,7 +2073,7 @@ const _ParaCore = class _ParaCore {
2074
2073
  * @param {Object} opts the options object.
2075
2074
  * @param {string} opts.walletId the id of the wallet to sign with.
2076
2075
  * @param {string} opts.messageBase64 the base64 encoding of exact message that should be signed
2077
- * @param {number} [opts.timeout] optional timeout in milliseconds. If not present, defaults to 30 seconds.
2076
+ * @param {number} [opts.timeout] optional timeout in milliseconds. If not present, defaults to 30 seconds. Extended to a minimum of 5 minutes when the transaction requires approval.
2078
2077
  * @param {string} [opts.cosmosSignDocBase64] the Cosmos `SignDoc` in base64, if applicable
2079
2078
  **/
2080
2079
  signMessage(_0) {
@@ -2096,9 +2095,10 @@ const _ParaCore = class _ParaCore {
2096
2095
  }
2097
2096
  let signRes = yield this.signMessageInner({ wallet, signerId, messageBase64, cosmosSignDocBase64 });
2098
2097
  let timeStart = Date.now();
2098
+ const effectiveTimeoutMs = Math.max(timeoutMs, constants.TRANSACTION_REVIEW_TIMEOUT_MS);
2099
2099
  if (signRes.pendingTransactionId) {
2100
2100
  yield this.platformUtils.openPopup(
2101
- yield this.getTransactionReviewUrl(signRes.pendingTransactionId, timeoutMs),
2101
+ yield this.getTransactionReviewUrl(signRes.pendingTransactionId, effectiveTimeoutMs),
2102
2102
  { type: cosmosSignDocBase64 ? PopupType.SIGN_TRANSACTION_REVIEW : PopupType.SIGN_MESSAGE_REVIEW }
2103
2103
  );
2104
2104
  } else {
@@ -2106,7 +2106,7 @@ const _ParaCore = class _ParaCore {
2106
2106
  return signRes;
2107
2107
  }
2108
2108
  while (true) {
2109
- if (isCanceled() || Date.now() - timeStart > timeoutMs) {
2109
+ if (isCanceled() || Date.now() - timeStart > effectiveTimeoutMs) {
2110
2110
  onCancel == null ? void 0 : onCancel();
2111
2111
  break;
2112
2112
  }
@@ -2180,7 +2180,7 @@ const _ParaCore = class _ParaCore {
2180
2180
  * @param {string} opts.walletId the id of the wallet to sign with.
2181
2181
  * @param {string} opts.rlpEncodedTxBase64 the transaction to sign, in RLP base64 encoding
2182
2182
  * @param {string} [opts.chainId] the EVM chain id of the chain the transaction is being sent on, if applicable
2183
- * @param {number} [opts.timeoutMs] the amount of time to wait for the user to sign the transaction, in milliseconds
2183
+ * @param {number} [opts.timeoutMs] the amount of time to wait for the user to sign the transaction, in milliseconds. Extended to a minimum of 5 minutes when the transaction requires approval.
2184
2184
  **/
2185
2185
  signTransaction(_0) {
2186
2186
  return __async(this, arguments, function* ({
@@ -2210,9 +2210,10 @@ const _ParaCore = class _ParaCore {
2210
2210
  wallet.scheme === "DKLS"
2211
2211
  );
2212
2212
  let timeStart = Date.now();
2213
+ const effectiveTimeoutMs = Math.max(timeoutMs, constants.TRANSACTION_REVIEW_TIMEOUT_MS);
2213
2214
  if (signRes.pendingTransactionId) {
2214
2215
  yield this.platformUtils.openPopup(
2215
- yield this.getTransactionReviewUrl(signRes.pendingTransactionId, timeoutMs),
2216
+ yield this.getTransactionReviewUrl(signRes.pendingTransactionId, effectiveTimeoutMs),
2216
2217
  { type: PopupType.SIGN_TRANSACTION_REVIEW }
2217
2218
  );
2218
2219
  } else {
@@ -2220,7 +2221,7 @@ const _ParaCore = class _ParaCore {
2220
2221
  return signRes;
2221
2222
  }
2222
2223
  while (true) {
2223
- if (isCanceled() || Date.now() - timeStart > timeoutMs) {
2224
+ if (isCanceled() || Date.now() - timeStart > effectiveTimeoutMs) {
2224
2225
  onCancel == null ? void 0 : onCancel();
2225
2226
  break;
2226
2227
  }
@@ -1,5 +1,5 @@
1
1
  import "./chunk-7B52C2XE.js";
2
- const PARA_CORE_VERSION = "2.15.0";
2
+ const PARA_CORE_VERSION = "2.16.0";
3
3
  const PREFIX = "@CAPSULE/";
4
4
  const PARA_PREFIX = "@PARA/";
5
5
  const LOCAL_STORAGE_AUTH_INFO = `${PREFIX}authInfo`;
@@ -23,6 +23,7 @@ const LOCAL_STORAGE_IS_IMPORTED_SESSION = `${PREFIX}isImportedSession`;
23
23
  const POLLING_INTERVAL_MS = 1e3;
24
24
  const SHORT_POLLING_INTERVAL_MS = 750;
25
25
  const POLLING_TIMEOUT_MS = 3e5;
26
+ const TRANSACTION_REVIEW_TIMEOUT_MS = 3e5;
26
27
  const EXTERNAL_WALLET_CONNECTION_ONLY_USER_ID = "EXTERNAL_WALLET_CONNECTION_ONLY";
27
28
  const ACCOUNT_LINK_CONFLICT = "Account already linked";
28
29
  export {
@@ -51,5 +52,6 @@ export {
51
52
  POLLING_TIMEOUT_MS,
52
53
  PREFIX,
53
54
  SESSION_STORAGE_LOGIN_ENCRYPTION_KEY_PAIR,
54
- SHORT_POLLING_INTERVAL_MS
55
+ SHORT_POLLING_INTERVAL_MS,
56
+ TRANSACTION_REVIEW_TIMEOUT_MS
55
57
  };
@@ -49,7 +49,7 @@ function encryptPrivateKey(keyPair, key) {
49
49
  const ciphertext = yield window.crypto.subtle.encrypt(
50
50
  { name: "AES-GCM", iv: CONSTANT_IV_AES },
51
51
  cryptoKey,
52
- encodedPlaintext
52
+ encodedPlaintext.buffer
53
53
  );
54
54
  return Buffer.from(ciphertext).toString("base64");
55
55
  });
@@ -232,7 +232,7 @@ function encryptPrivateKeyWithPassword(keyPair, hashedPassword) {
232
232
  const ciphertext = yield window.crypto.subtle.encrypt(
233
233
  { name: "AES-GCM", iv: CONSTANT_IV_AES },
234
234
  cryptoKey,
235
- encodedPlaintext
235
+ encodedPlaintext.buffer
236
236
  );
237
237
  return Buffer.from(ciphertext).toString("base64");
238
238
  });
@@ -47,6 +47,9 @@ class PortalUrlService {
47
47
  * @returns - portal URL
48
48
  */
49
49
  this.getPortalURL = (isLegacy) => __async(this, null, function* () {
50
+ if (__privateGet(this, _paraCoreInterface).ctx.isE2E) {
51
+ return getPortalBaseURL(__privateGet(this, _paraCoreInterface).ctx, false, false, isLegacy);
52
+ }
50
53
  return __privateGet(this, _paraCoreInterface).ctx.portalUrlOverride || (yield this.getPartnerURL()) || getPortalBaseURL(__privateGet(this, _paraCoreInterface).ctx, false, false, isLegacy);
51
54
  });
52
55
  this.constructPortalUrl = (_0, ..._1) => __async(this, [_0, ..._1], function* (type, opts = {}) {
@@ -732,7 +732,7 @@ export declare abstract class ParaCore implements CoreInterface {
732
732
  * @param {Object} opts the options object.
733
733
  * @param {string} opts.walletId the id of the wallet to sign with.
734
734
  * @param {string} opts.messageBase64 the base64 encoding of exact message that should be signed
735
- * @param {number} [opts.timeout] optional timeout in milliseconds. If not present, defaults to 30 seconds.
735
+ * @param {number} [opts.timeout] optional timeout in milliseconds. If not present, defaults to 30 seconds. Extended to a minimum of 5 minutes when the transaction requires approval.
736
736
  * @param {string} [opts.cosmosSignDocBase64] the Cosmos `SignDoc` in base64, if applicable
737
737
  **/
738
738
  signMessage({ walletId, messageBase64, timeoutMs, cosmosSignDocBase64, isCanceled, onCancel, onPoll, }: CoreMethodParams<'signMessage'>): CoreMethodResponse<'signMessage'>;
@@ -743,7 +743,7 @@ export declare abstract class ParaCore implements CoreInterface {
743
743
  * @param {string} opts.walletId the id of the wallet to sign with.
744
744
  * @param {string} opts.rlpEncodedTxBase64 the transaction to sign, in RLP base64 encoding
745
745
  * @param {string} [opts.chainId] the EVM chain id of the chain the transaction is being sent on, if applicable
746
- * @param {number} [opts.timeoutMs] the amount of time to wait for the user to sign the transaction, in milliseconds
746
+ * @param {number} [opts.timeoutMs] the amount of time to wait for the user to sign the transaction, in milliseconds. Extended to a minimum of 5 minutes when the transaction requires approval.
747
747
  **/
748
748
  signTransaction({ walletId, rlpEncodedTxBase64, chainId, timeoutMs, isCanceled, onCancel, onPoll, }: CoreMethodParams<'signTransaction'>): CoreMethodResponse<'signTransaction'>;
749
749
  protected isProviderModalDisabled(): boolean;
@@ -22,5 +22,6 @@ export declare const LOCAL_STORAGE_IS_IMPORTED_SESSION = "@CAPSULE/isImportedSes
22
22
  export declare const POLLING_INTERVAL_MS = 1000;
23
23
  export declare const SHORT_POLLING_INTERVAL_MS = 750;
24
24
  export declare const POLLING_TIMEOUT_MS = 300000;
25
+ export declare const TRANSACTION_REVIEW_TIMEOUT_MS = 300000;
25
26
  export declare const EXTERNAL_WALLET_CONNECTION_ONLY_USER_ID = "EXTERNAL_WALLET_CONNECTION_ONLY";
26
27
  export declare const ACCOUNT_LINK_CONFLICT = "Account already linked";
@@ -57,6 +57,7 @@ export type SignMessageParams = PollingCallbacks & {
57
57
  messageBase64: string;
58
58
  /**
59
59
  * The duration in milliseconds to wait before the signing operation times out.
60
+ * Extended to a minimum of 5 minutes when the transaction requires approval.
60
61
  */
61
62
  timeoutMs?: number;
62
63
  /**
@@ -83,6 +84,7 @@ export type SignTransactionParams = PollingCallbacks & {
83
84
  chainId: string;
84
85
  /**
85
86
  * The duration in milliseconds to wait before the signing operation times out.
87
+ * Extended to a minimum of 5 minutes when the transaction requires approval.
86
88
  */
87
89
  timeoutMs?: number;
88
90
  /**
package/package.json CHANGED
@@ -1,13 +1,15 @@
1
1
  {
2
2
  "name": "@getpara/core-sdk",
3
- "version": "2.15.0",
3
+ "version": "2.17.0",
4
4
  "dependencies": {
5
5
  "@celo/utils": "^8.0.2",
6
6
  "@cosmjs/encoding": "^0.32.4",
7
7
  "@ethereumjs/util": "^9.1.0",
8
- "@getpara/user-management-client": "2.15.0",
8
+ "@getpara/user-management-client": "2.17.0",
9
9
  "@noble/hashes": "^1.5.0",
10
+ "axios": "^1.8.4",
10
11
  "base64url": "^3.0.1",
12
+ "elliptic": "^6.6.1",
11
13
  "libphonenumber-js": "^1.11.7",
12
14
  "node-forge": "^1.3.1",
13
15
  "uuid": "^11.1.0",
@@ -28,7 +30,7 @@
28
30
  "dist",
29
31
  "package.json"
30
32
  ],
31
- "gitHead": "9cecc178e975a44d8ed4b03f46aeb57ddcb7a152",
33
+ "gitHead": "3ed1f835b97ae720f1ac747611296e3b86f61138",
32
34
  "main": "dist/cjs/index.js",
33
35
  "module": "dist/esm/index.js",
34
36
  "scripts": {