@getpara/core-sdk 3.5.0 → 3.6.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.
Files changed (73) hide show
  1. package/dist/cjs/ParaCore.js +78 -39
  2. package/dist/cjs/constants.js +1 -1
  3. package/dist/cjs/cryptography/utils.js +2 -2
  4. package/dist/cjs/errors.js +12 -0
  5. package/dist/cjs/external/localDevUrlOverrides.js +50 -0
  6. package/dist/cjs/external/userManagementClient.js +11 -21
  7. package/dist/cjs/index.js +15 -15
  8. package/dist/cjs/services/PortalUrlService.js +1 -1
  9. package/dist/cjs/state/actors/authenticateWithEmailOrPhone.js +1 -1
  10. package/dist/cjs/state/actors/authenticateWithExternalWallet.js +1 -1
  11. package/dist/cjs/state/actors/authenticateWithFarcaster.js +1 -1
  12. package/dist/cjs/state/actors/authenticateWithFarcasterLegacy.js +1 -1
  13. package/dist/cjs/state/actors/authenticateWithTelegram.js +1 -1
  14. package/dist/cjs/state/actors/authenticateWithTelegramLegacy.js +1 -1
  15. package/dist/cjs/state/actors/checkUserState.js +1 -1
  16. package/dist/cjs/state/actors/claimWallets.js +1 -1
  17. package/dist/cjs/state/actors/connectExternalConnectors.js +1 -1
  18. package/dist/cjs/state/actors/connectExternalWallet.js +1 -1
  19. package/dist/cjs/state/actors/createGuestWallets.js +1 -1
  20. package/dist/cjs/state/actors/createWallets.js +1 -1
  21. package/dist/cjs/state/actors/processAuthentication.js +1 -1
  22. package/dist/cjs/state/actors/setupAfterLogin.js +1 -1
  23. package/dist/cjs/state/actors/setupPara.js +1 -1
  24. package/dist/cjs/state/actors/signExternalWalletVerification.js +1 -1
  25. package/dist/cjs/state/actors/switchExternalWallet.js +1 -1
  26. package/dist/cjs/state/actors/verifyExternalWallet.js +1 -1
  27. package/dist/cjs/state/actors/verifyNewAccount.js +1 -1
  28. package/dist/cjs/state/actors/waitForExternalWalletProviders.js +1 -1
  29. package/dist/cjs/state/machines/authStateMachine.js +7 -7
  30. package/dist/cjs/state/machines/coreStateMachine.js +1 -1
  31. package/dist/cjs/state/machines/walletStateMachine.js +1 -1
  32. package/dist/cjs/telemetry/tracer.js +1 -1
  33. package/dist/cjs/utils/url.js +5 -2
  34. package/dist/esm/ParaCore.js +79 -40
  35. package/dist/esm/constants.js +1 -1
  36. package/dist/esm/cryptography/utils.js +2 -2
  37. package/dist/esm/errors.js +11 -0
  38. package/dist/esm/external/localDevUrlOverrides.js +27 -0
  39. package/dist/esm/external/userManagementClient.js +11 -21
  40. package/dist/esm/index.js +2 -2
  41. package/dist/esm/services/PortalUrlService.js +1 -1
  42. package/dist/esm/state/actors/authenticateWithEmailOrPhone.js +1 -1
  43. package/dist/esm/state/actors/authenticateWithExternalWallet.js +1 -1
  44. package/dist/esm/state/actors/authenticateWithFarcaster.js +1 -1
  45. package/dist/esm/state/actors/authenticateWithFarcasterLegacy.js +1 -1
  46. package/dist/esm/state/actors/authenticateWithTelegram.js +1 -1
  47. package/dist/esm/state/actors/authenticateWithTelegramLegacy.js +1 -1
  48. package/dist/esm/state/actors/checkUserState.js +1 -1
  49. package/dist/esm/state/actors/claimWallets.js +1 -1
  50. package/dist/esm/state/actors/connectExternalConnectors.js +1 -1
  51. package/dist/esm/state/actors/connectExternalWallet.js +1 -1
  52. package/dist/esm/state/actors/createGuestWallets.js +1 -1
  53. package/dist/esm/state/actors/createWallets.js +1 -1
  54. package/dist/esm/state/actors/processAuthentication.js +1 -1
  55. package/dist/esm/state/actors/setupAfterLogin.js +1 -1
  56. package/dist/esm/state/actors/setupPara.js +1 -1
  57. package/dist/esm/state/actors/signExternalWalletVerification.js +1 -1
  58. package/dist/esm/state/actors/switchExternalWallet.js +1 -1
  59. package/dist/esm/state/actors/verifyExternalWallet.js +1 -1
  60. package/dist/esm/state/actors/verifyNewAccount.js +1 -1
  61. package/dist/esm/state/actors/waitForExternalWalletProviders.js +1 -1
  62. package/dist/esm/state/machines/authStateMachine.js +7 -7
  63. package/dist/esm/state/machines/coreStateMachine.js +1 -1
  64. package/dist/esm/state/machines/walletStateMachine.js +1 -1
  65. package/dist/esm/telemetry/tracer.js +1 -1
  66. package/dist/esm/utils/url.js +4 -2
  67. package/dist/types/ParaCore.d.ts +1 -0
  68. package/dist/types/errors.d.ts +13 -0
  69. package/dist/types/external/localDevUrlOverrides.d.ts +4 -0
  70. package/dist/types/external/userManagementClient.d.ts +5 -4
  71. package/dist/types/types/config.d.ts +2 -0
  72. package/dist/types/utils/url.d.ts +1 -0
  73. package/package.json +4 -4
@@ -41,7 +41,7 @@ __export(processAuthentication_exports, {
41
41
  });
42
42
  module.exports = __toCommonJS(processAuthentication_exports);
43
43
  var import_xstate = require("xstate");
44
- const createProcessAuthenticationActor = (authService) => (0, import_xstate.fromPromise)((params) => __async(void 0, null, function* () {
44
+ const createProcessAuthenticationActor = (authService) => (0, import_xstate.fromPromise)((params) => __async(null, null, function* () {
45
45
  return yield authService.prepareAuthState(params.input.authState, params.input.opts);
46
46
  }));
47
47
  // Annotate the CommonJS export names for ESM import in node:
@@ -42,7 +42,7 @@ __export(setupAfterLogin_exports, {
42
42
  module.exports = __toCommonJS(setupAfterLogin_exports);
43
43
  var import_xstate = require("xstate");
44
44
  const createSetupAfterLoginActor = (paraCoreInterface) => (0, import_xstate.fromPromise)(
45
- (_0) => __async(void 0, [_0], function* ({ input: { temporaryShares, skipSessionRefresh } }) {
45
+ (_0) => __async(null, [_0], function* ({ input: { temporaryShares, skipSessionRefresh } }) {
46
46
  yield paraCoreInterface.setupAfterLogin({ temporaryShares, skipSessionRefresh });
47
47
  })
48
48
  );
@@ -41,7 +41,7 @@ __export(setupPara_exports, {
41
41
  });
42
42
  module.exports = __toCommonJS(setupPara_exports);
43
43
  var import_xstate = require("xstate");
44
- const createSetupParaActor = (paraCoreInterface) => (0, import_xstate.fromPromise)(() => __async(void 0, null, function* () {
44
+ const createSetupParaActor = (paraCoreInterface) => (0, import_xstate.fromPromise)(() => __async(null, null, function* () {
45
45
  const eagerPartnerLoad = paraCoreInterface.isPortal() ? Promise.resolve() : paraCoreInterface.sessionManagementService.touchSession().catch((e) => {
46
46
  paraCoreInterface.devLog("setupPara: eager partner load via touchSession failed; will retry lazily", e);
47
47
  });
@@ -68,7 +68,7 @@ __export(signExternalWalletVerification_exports, {
68
68
  module.exports = __toCommonJS(signExternalWalletVerification_exports);
69
69
  var import_xstate = require("xstate");
70
70
  const createSignExternalWalletVerificationActor = (externalWalletService) => (0, import_xstate.fromPromise)(
71
- (params) => __async(void 0, null, function* () {
71
+ (params) => __async(null, null, function* () {
72
72
  const _a = yield externalWalletService.signMessage(params.input), { signature } = _a, rest = __objRest(_a, ["signature"]);
73
73
  return __spreadValues({ externalWallet: params.input.externalWallet, signedMessage: signature }, rest);
74
74
  })
@@ -41,7 +41,7 @@ __export(switchExternalWallet_exports, {
41
41
  });
42
42
  module.exports = __toCommonJS(switchExternalWallet_exports);
43
43
  var import_xstate = require("xstate");
44
- const createSwitchExternalWalletActor = (externalWalletService) => (0, import_xstate.fromPromise)((params) => __async(void 0, null, function* () {
44
+ const createSwitchExternalWalletActor = (externalWalletService) => (0, import_xstate.fromPromise)((params) => __async(null, null, function* () {
45
45
  return yield externalWalletService.performSwitchExternalWallet(params.input);
46
46
  }));
47
47
  // Annotate the CommonJS export names for ESM import in node:
@@ -41,7 +41,7 @@ __export(verifyExternalWallet_exports, {
41
41
  });
42
42
  module.exports = __toCommonJS(verifyExternalWallet_exports);
43
43
  var import_xstate = require("xstate");
44
- const createVerifyExternalWalletActor = (authService) => (0, import_xstate.fromPromise)((params) => __async(void 0, null, function* () {
44
+ const createVerifyExternalWalletActor = (authService) => (0, import_xstate.fromPromise)((params) => __async(null, null, function* () {
45
45
  return yield authService.performVerifyExternalWallet(params.input);
46
46
  }));
47
47
  // Annotate the CommonJS export names for ESM import in node:
@@ -41,7 +41,7 @@ __export(verifyNewAccount_exports, {
41
41
  });
42
42
  module.exports = __toCommonJS(verifyNewAccount_exports);
43
43
  var import_xstate = require("xstate");
44
- const createVerifyNewAccountActor = (authService) => (0, import_xstate.fromPromise)((params) => __async(void 0, null, function* () {
44
+ const createVerifyNewAccountActor = (authService) => (0, import_xstate.fromPromise)((params) => __async(null, null, function* () {
45
45
  return yield authService.performVerifyNewAccount(params.input);
46
46
  }));
47
47
  // Annotate the CommonJS export names for ESM import in node:
@@ -41,7 +41,7 @@ __export(waitForExternalWalletProviders_exports, {
41
41
  });
42
42
  module.exports = __toCommonJS(waitForExternalWalletProviders_exports);
43
43
  var import_xstate = require("xstate");
44
- const createWaitForExternalWalletProvidersActor = (stateMachineInterface) => (0, import_xstate.fromPromise)(() => __async(void 0, null, function* () {
44
+ const createWaitForExternalWalletProvidersActor = (stateMachineInterface) => (0, import_xstate.fromPromise)(() => __async(null, null, function* () {
45
45
  return yield stateMachineInterface.externalWalletService.waitForProvidersLoading();
46
46
  }));
47
47
  // Annotate the CommonJS export names for ESM import in node:
@@ -98,7 +98,7 @@ function createAuthStateMachine(paraCoreInterface) {
98
98
  connectExternalWallet: (0, import_connectExternalWallet.createConnectExternalWalletActor)(paraCoreInterface.externalWalletService),
99
99
  signExternalWalletVerification: (0, import_signExternalWalletVerification.createSignExternalWalletVerificationActor)(paraCoreInterface.externalWalletService),
100
100
  switchExternalWallet: (0, import_switchExternalWallet.createSwitchExternalWalletActor)(paraCoreInterface.externalWalletService),
101
- logoutActor: (0, import_xstate.fromPromise)(() => __async(this, null, function* () {
101
+ logoutActor: (0, import_xstate.fromPromise)(() => __async(null, null, function* () {
102
102
  yield paraCoreInterface.logout({ skipStateReset: true });
103
103
  }))
104
104
  },
@@ -321,7 +321,7 @@ function createAuthStateMachine(paraCoreInterface) {
321
321
  let oauthSessionLookupId;
322
322
  let oauthAuthState = null;
323
323
  return {
324
- init: () => __async(this, null, function* () {
324
+ init: () => __async(null, null, function* () {
325
325
  try {
326
326
  const { sessionLookupId } = yield paraCoreInterface.pollingService.initOAuthPolling({
327
327
  onOAuthPopup,
@@ -336,7 +336,7 @@ function createAuthStateMachine(paraCoreInterface) {
336
336
  throw new Error(`OAuth initialization failed: ${(0, import_stateErrorHelpers.extractErrorMessage)(error, "Unknown error")}`);
337
337
  }
338
338
  }),
339
- checkCondition: () => __async(this, null, function* () {
339
+ checkCondition: () => __async(null, null, function* () {
340
340
  try {
341
341
  const result = yield paraCoreInterface.pollingService.waitForOAuth({
342
342
  onSuccess: (serverAuthState) => {
@@ -649,7 +649,7 @@ function createAuthStateMachine(paraCoreInterface) {
649
649
  var _a;
650
650
  let farcasterAuthState = null;
651
651
  return {
652
- checkCondition: () => __async(this, null, function* () {
652
+ checkCondition: () => __async(null, null, function* () {
653
653
  try {
654
654
  const result = yield paraCoreInterface.pollingService.waitForFarcasterAuth({
655
655
  onSuccess: (serverAuthState) => {
@@ -921,7 +921,7 @@ function createAuthStateMachine(paraCoreInterface) {
921
921
  var _a;
922
922
  let resolvedAuthState = null;
923
923
  return {
924
- checkCondition: () => __async(this, null, function* () {
924
+ checkCondition: () => __async(null, null, function* () {
925
925
  try {
926
926
  const result = yield paraCoreInterface.pollingService.waitForOAuth({
927
927
  onSuccess: (serverAuthState) => {
@@ -1113,7 +1113,7 @@ function createAuthStateMachine(paraCoreInterface) {
1113
1113
  input: ({ context }) => {
1114
1114
  var _a;
1115
1115
  return {
1116
- init: () => __async(this, null, function* () {
1116
+ init: () => __async(null, null, function* () {
1117
1117
  try {
1118
1118
  yield paraCoreInterface.sessionManagementService.touchSession();
1119
1119
  if (!paraCoreInterface.authService.isExternalWalletAuth) {
@@ -1124,7 +1124,7 @@ function createAuthStateMachine(paraCoreInterface) {
1124
1124
  throw new Error(`Session touch failed: ${(0, import_stateErrorHelpers.extractErrorMessage)(error, "Unknown error")}`);
1125
1125
  }
1126
1126
  }),
1127
- checkCondition: () => __async(this, null, function* () {
1127
+ checkCondition: () => __async(null, null, function* () {
1128
1128
  try {
1129
1129
  return yield paraCoreInterface.pollingService.waitForSession();
1130
1130
  } catch (error) {
@@ -57,7 +57,7 @@ function createCoreStateMachine(paraCoreInterface) {
57
57
  waitForExternalWalletProviders: (0, import_waitForExternalWalletProviders.createWaitForExternalWalletProvidersActor)(paraCoreInterface),
58
58
  authMachine: (0, import_authStateMachine.createAuthStateMachine)(paraCoreInterface),
59
59
  walletMachine: (0, import_walletStateMachine.createWalletStateMachine)(paraCoreInterface),
60
- logoutPara: (0, import_xstate.fromPromise)(() => __async(this, null, function* () {
60
+ logoutPara: (0, import_xstate.fromPromise)(() => __async(null, null, function* () {
61
61
  yield paraCoreInterface.logout();
62
62
  }))
63
63
  },
@@ -337,7 +337,7 @@ function createWalletStateMachine(paraCoreInterface) {
337
337
  input: ({ context, self }) => {
338
338
  var _a;
339
339
  return {
340
- checkCondition: () => __async(this, null, function* () {
340
+ checkCondition: () => __async(null, null, function* () {
341
341
  try {
342
342
  return yield paraCoreInterface.pollingService.waitForWallets({ parent: self })();
343
343
  } catch (error) {
@@ -69,7 +69,7 @@ function wrapWithSpan(name, fn, attributes) {
69
69
  const parentCtx = activeSpan ? active : (_b = (_a = (0, import_modalSession.getModalSessionContext)()) != null ? _a : defaultParentContext) != null ? _b : active;
70
70
  return import_api.context.with(
71
71
  parentCtx,
72
- () => getTracer().startActiveSpan(name, { attributes }, (span) => __async(this, null, function* () {
72
+ () => getTracer().startActiveSpan(name, { attributes }, (span) => __async(null, null, function* () {
73
73
  try {
74
74
  const result = yield fn(span);
75
75
  return result;
@@ -38,6 +38,7 @@ var __async = (__this, __arguments, generator) => {
38
38
  var url_exports = {};
39
39
  __export(url_exports, {
40
40
  constructUrl: () => constructUrl,
41
+ getGlobalPortalUrlOverride: () => getGlobalPortalUrlOverride,
41
42
  getParaConnectBaseUrl: () => getParaConnectBaseUrl,
42
43
  getParaConnectDomain: () => getParaConnectDomain,
43
44
  getPortalBaseURL: () => getPortalBaseURL,
@@ -48,7 +49,8 @@ module.exports = __toCommonJS(url_exports);
48
49
  var import_transmissionUtils = require("../transmission/transmissionUtils.js");
49
50
  var import_types = require("../types/index.js");
50
51
  function getGlobalPortalUrlOverride() {
51
- const override = typeof globalThis !== "undefined" ? globalThis.__PARA_PORTAL_URL_OVERRIDE__ : void 0;
52
+ var _a;
53
+ const override = (_a = typeof globalThis !== "undefined" ? globalThis.__PARA_PORTAL_URL_OVERRIDE__ : void 0) != null ? _a : typeof process !== "undefined" ? process.env.PARA_PORTAL_URL : void 0;
52
54
  return typeof override === "string" && override ? override : void 0;
53
55
  }
54
56
  function getPortalDomain(env, isE2E, isLegacy) {
@@ -71,7 +73,7 @@ function getPortalDomain(env, isE2E, isLegacy) {
71
73
  }
72
74
  function getPortalBaseURL({ env, isE2E, portalUrlOverride }, useLocalIp, isForWasm, isLegacy) {
73
75
  const resolvedPortalUrlOverride = portalUrlOverride != null ? portalUrlOverride : getGlobalPortalUrlOverride();
74
- if (resolvedPortalUrlOverride && !isForWasm) {
76
+ if (resolvedPortalUrlOverride) {
75
77
  return new URL(resolvedPortalUrlOverride).origin;
76
78
  }
77
79
  if (isE2E) {
@@ -136,6 +138,7 @@ function shortenUrl(ctx, url, isLegacy) {
136
138
  // Annotate the CommonJS export names for ESM import in node:
137
139
  0 && (module.exports = {
138
140
  constructUrl,
141
+ getGlobalPortalUrlOverride,
139
142
  getParaConnectBaseUrl,
140
143
  getParaConnectDomain,
141
144
  getPortalBaseURL,
@@ -30,7 +30,9 @@ import forge from "node-forge";
30
30
  const { pki, jsbn } = forge;
31
31
  import { decryptWithPrivateKey, getAsymmetricKeyPair } from "./cryptography/utils.js";
32
32
  import { getBaseUrl, initClient, normalizePlatform } from "./external/userManagementClient.js";
33
+ import { getDevApiBaseUrlOverride, getDevMPCNetworkUrlOverride } from "./external/localDevUrlOverrides.js";
33
34
  import * as mpcComputationClient from "./external/mpcComputationClient.js";
35
+ import { getGlobalPortalUrlOverride } from "./utils/url.js";
34
36
  import {
35
37
  Environment,
36
38
  PopupType,
@@ -54,7 +56,7 @@ import {
54
56
  import { waitForAuthStateChange } from "./utils/stateListener.js";
55
57
  import { warnOnce } from "./utils/deprecation.js";
56
58
  import { assertConfigAllowed } from "./utils/partnerConfigGating.js";
57
- import { TransactionReviewDenied, TransactionReviewTimeout } from "./errors.js";
59
+ import { SigningResultError, TransactionReviewDenied, TransactionReviewTimeout } from "./errors.js";
58
60
  import * as constants from "./constants.js";
59
61
  import { EnclaveClient } from "./shares/enclave.js";
60
62
  import { AuthService } from "./services/AuthService.js";
@@ -69,6 +71,24 @@ import { wrapWithSpan } from "./telemetry/tracer.js";
69
71
  import { setCurrentUserId } from "./telemetry/uxStateSpanProcessor.js";
70
72
  import { initTelemetry } from "./telemetry/init.js";
71
73
  import { recordActionOnSpan } from "./telemetry/uxAction.js";
74
+ const DEFAULT_SIGNING_RESULT_ERROR_MESSAGE = "Signing failed before a signature was produced.";
75
+ function getPendingTransactionId(signRes) {
76
+ return typeof signRes.pendingTransactionId === "string" && signRes.pendingTransactionId.length > 0 ? signRes.pendingTransactionId : void 0;
77
+ }
78
+ function requireSuccessfulSignatureResult(signRes) {
79
+ if (typeof signRes.signature === "string" && signRes.signature.length > 0) {
80
+ return { signature: signRes.signature };
81
+ }
82
+ throw new SigningResultError(
83
+ typeof signRes.message === "string" && signRes.message.length > 0 ? signRes.message : DEFAULT_SIGNING_RESULT_ERROR_MESSAGE,
84
+ {
85
+ code: signRes.code,
86
+ status: signRes.status,
87
+ responseURL: signRes.responseURL,
88
+ data: signRes.data
89
+ }
90
+ );
91
+ }
72
92
  const _ParaCore = class _ParaCore {
73
93
  constructor(envOrApiKey, apiKeyOrOpts, opts) {
74
94
  __privateAdd(this, _ParaCore_instances);
@@ -208,7 +228,7 @@ const _ParaCore = class _ParaCore {
208
228
  const uxTargetId = typeof entry === "string" ? void 0 : entry.uxTargetId;
209
229
  const original = this[methodName];
210
230
  if (typeof original === "function") {
211
- this[methodName] = (...args) => {
231
+ this[methodName] = ((...args) => {
212
232
  var _a;
213
233
  const attrs = __spreadValues(__spreadProps(__spreadValues({
214
234
  "para.platform": this.platformUtils.sdkType
@@ -231,7 +251,7 @@ const _ParaCore = class _ParaCore {
231
251
  }),
232
252
  attrs
233
253
  ).catch((err) => this.trackError(methodName, err));
234
- };
254
+ });
235
255
  }
236
256
  }
237
257
  };
@@ -464,6 +484,7 @@ const _ParaCore = class _ParaCore {
464
484
  const rawPlatform = (_a = opts.hostPlatform) != null ? _a : this.platformUtils.sdkType;
465
485
  this.clientType = normalizePlatform(rawPlatform);
466
486
  const requestAgents = (_c = (_b = this.platformUtils).getRequestAgents) == null ? void 0 : _c.call(_b);
487
+ const apiBaseUrlOverride = getDevApiBaseUrlOverride();
467
488
  const client = initClient({
468
489
  env,
469
490
  version: _ParaCore.version,
@@ -476,7 +497,8 @@ const _ParaCore = class _ParaCore {
476
497
  retrieveSessionCookie: this.retrieveSessionCookie,
477
498
  persistSessionCookie: this.persistSessionCookie,
478
499
  httpAgent: requestAgents == null ? void 0 : requestAgents.httpAgent,
479
- httpsAgent: requestAgents == null ? void 0 : requestAgents.httpsAgent
500
+ httpsAgent: requestAgents == null ? void 0 : requestAgents.httpsAgent,
501
+ apiBaseUrlOverride
480
502
  });
481
503
  const enclaveClient = new EnclaveClient({
482
504
  userManagementClient: client,
@@ -490,6 +512,9 @@ const _ParaCore = class _ParaCore {
490
512
  apiKey,
491
513
  client,
492
514
  enclaveClient,
515
+ apiBaseUrlOverride,
516
+ portalUrlOverride: getGlobalPortalUrlOverride(),
517
+ mpcNetworkUrlOverride: getDevMPCNetworkUrlOverride(),
493
518
  disableWorkers: opts.disableWorkers,
494
519
  offloadMPCComputationURL: opts.offloadMPCComputationURL,
495
520
  useLocalFiles: opts.useLocalFiles,
@@ -1522,7 +1547,7 @@ const _ParaCore = class _ParaCore {
1522
1547
  const telemetry = res.data.partner.telemetry;
1523
1548
  if ((telemetry == null ? void 0 : telemetry.enabled) && this.ctx.env) {
1524
1549
  void initTelemetry({
1525
- tunnelUrl: `${getBaseUrl(this.ctx.env)}telemetry`,
1550
+ tunnelUrl: `${getBaseUrl(this.ctx.env, "http", this.ctx.apiBaseUrlOverride)}telemetry`,
1526
1551
  sampleRate: telemetry.sample_rate,
1527
1552
  sdkType: this.platformUtils.sdkType,
1528
1553
  clientType: this.clientType,
@@ -2362,6 +2387,14 @@ const _ParaCore = class _ParaCore {
2362
2387
  return result.url;
2363
2388
  });
2364
2389
  }
2390
+ getDeniedSignatureResultWithUrl(pendingTransactionId) {
2391
+ return __async(this, null, function* () {
2392
+ return {
2393
+ pendingTransactionId,
2394
+ transactionReviewUrl: yield this.getTransactionReviewUrl(pendingTransactionId)
2395
+ };
2396
+ });
2397
+ }
2365
2398
  getOnRampTransactionUrl(_0) {
2366
2399
  return __async(this, arguments, function* ({
2367
2400
  purchaseId
@@ -2424,11 +2457,9 @@ const _ParaCore = class _ParaCore {
2424
2457
  );
2425
2458
  let timeStart = Date.now();
2426
2459
  const effectiveTimeoutMs = Math.max(timeoutMs, constants.TRANSACTION_REVIEW_TIMEOUT_MS);
2427
- if (signRes.pendingTransactionId) {
2428
- const reviewUrl = yield this.getTransactionReviewUrl(
2429
- signRes.pendingTransactionId,
2430
- effectiveTimeoutMs
2431
- );
2460
+ let pendingTransactionId = getPendingTransactionId(signRes);
2461
+ if (pendingTransactionId) {
2462
+ const reviewUrl = yield this.getTransactionReviewUrl(pendingTransactionId, effectiveTimeoutMs);
2432
2463
  if (onTransactionReviewUrl) {
2433
2464
  onTransactionReviewUrl(reviewUrl);
2434
2465
  } else {
@@ -2437,8 +2468,9 @@ const _ParaCore = class _ParaCore {
2437
2468
  });
2438
2469
  }
2439
2470
  } else {
2440
- dispatchEvent(ParaEvent.SIGN_MESSAGE_EVENT, signRes);
2441
- return signRes;
2471
+ const successfulSignRes2 = requireSuccessfulSignatureResult(signRes);
2472
+ dispatchEvent(ParaEvent.SIGN_MESSAGE_EVENT, successfulSignRes2);
2473
+ return successfulSignRes2;
2442
2474
  }
2443
2475
  while (true) {
2444
2476
  if (isCanceled() || Date.now() - timeStart > effectiveTimeoutMs) {
@@ -2452,15 +2484,19 @@ const _ParaCore = class _ParaCore {
2452
2484
  "tx.review.poll",
2453
2485
  (span) => __async(this, null, function* () {
2454
2486
  var _a;
2455
- const res = (_a = (yield this.ctx.client.getPendingTransaction(this.userId, signRes.pendingTransactionId)).data) == null ? void 0 : _a.pendingTransaction;
2487
+ const res = (_a = (yield this.ctx.client.getPendingTransaction(this.userId, pendingTransactionId)).data) == null ? void 0 : _a.pendingTransaction;
2456
2488
  span.setAttribute("polling.status", (res == null ? void 0 : res.approvedAt) ? "approved" : "pending");
2457
2489
  return res;
2458
2490
  }),
2459
- { "pending_transaction.id": signRes.pendingTransactionId }
2491
+ { "pending_transaction.id": pendingTransactionId }
2460
2492
  );
2461
2493
  } catch (e) {
2462
2494
  const error = new TransactionReviewDenied();
2463
- dispatchEvent(ParaEvent.SIGN_MESSAGE_EVENT, signRes, error.message);
2495
+ dispatchEvent(
2496
+ ParaEvent.SIGN_MESSAGE_EVENT,
2497
+ yield this.getDeniedSignatureResultWithUrl(pendingTransactionId),
2498
+ error.message
2499
+ );
2464
2500
  throw error;
2465
2501
  }
2466
2502
  if (!(pendingTransaction == null ? void 0 : pendingTransaction.approvedAt)) {
@@ -2475,16 +2511,16 @@ const _ParaCore = class _ParaCore {
2475
2511
  break;
2476
2512
  }
2477
2513
  }
2478
- if (signRes.pendingTransactionId) {
2479
- const error = new TransactionReviewTimeout(
2480
- yield this.getTransactionReviewUrl(signRes.pendingTransactionId),
2481
- signRes.pendingTransactionId
2482
- );
2483
- dispatchEvent(ParaEvent.SIGN_MESSAGE_EVENT, signRes, error.message);
2514
+ pendingTransactionId = getPendingTransactionId(signRes);
2515
+ if (pendingTransactionId) {
2516
+ const deniedSignRes = yield this.getDeniedSignatureResultWithUrl(pendingTransactionId);
2517
+ const error = new TransactionReviewTimeout(deniedSignRes.transactionReviewUrl, pendingTransactionId);
2518
+ dispatchEvent(ParaEvent.SIGN_MESSAGE_EVENT, deniedSignRes, error.message);
2484
2519
  throw error;
2485
2520
  }
2486
- dispatchEvent(ParaEvent.SIGN_MESSAGE_EVENT, signRes);
2487
- return signRes;
2521
+ const successfulSignRes = requireSuccessfulSignatureResult(signRes);
2522
+ dispatchEvent(ParaEvent.SIGN_MESSAGE_EVENT, successfulSignRes);
2523
+ return successfulSignRes;
2488
2524
  });
2489
2525
  }
2490
2526
  signMessageInner(_0) {
@@ -2563,19 +2599,18 @@ const _ParaCore = class _ParaCore {
2563
2599
  );
2564
2600
  let timeStart = Date.now();
2565
2601
  const effectiveTimeoutMs = Math.max(timeoutMs, constants.TRANSACTION_REVIEW_TIMEOUT_MS);
2566
- if (signRes.pendingTransactionId) {
2567
- const reviewUrl = yield this.getTransactionReviewUrl(
2568
- signRes.pendingTransactionId,
2569
- effectiveTimeoutMs
2570
- );
2602
+ let pendingTransactionId = getPendingTransactionId(signRes);
2603
+ if (pendingTransactionId) {
2604
+ const reviewUrl = yield this.getTransactionReviewUrl(pendingTransactionId, effectiveTimeoutMs);
2571
2605
  if (onTransactionReviewUrl) {
2572
2606
  onTransactionReviewUrl(reviewUrl);
2573
2607
  } else {
2574
2608
  yield this.platformUtils.openPopup(reviewUrl, { type: PopupType.SIGN_TRANSACTION_REVIEW });
2575
2609
  }
2576
2610
  } else {
2577
- dispatchEvent(ParaEvent.SIGN_TRANSACTION_EVENT, signRes);
2578
- return signRes;
2611
+ const successfulSignRes2 = requireSuccessfulSignatureResult(signRes);
2612
+ dispatchEvent(ParaEvent.SIGN_TRANSACTION_EVENT, successfulSignRes2);
2613
+ return successfulSignRes2;
2579
2614
  }
2580
2615
  while (true) {
2581
2616
  if (isCanceled() || Date.now() - timeStart > effectiveTimeoutMs) {
@@ -2583,7 +2618,7 @@ const _ParaCore = class _ParaCore {
2583
2618
  break;
2584
2619
  }
2585
2620
  yield new Promise((resolve) => setTimeout(resolve, constants.POLLING_INTERVAL_MS));
2586
- const pendingTxId = signRes.pendingTransactionId;
2621
+ const pendingTxId = pendingTransactionId;
2587
2622
  let pendingTransaction;
2588
2623
  try {
2589
2624
  pendingTransaction = yield wrapWithSpan(
@@ -2598,7 +2633,11 @@ const _ParaCore = class _ParaCore {
2598
2633
  );
2599
2634
  } catch (e) {
2600
2635
  const error = new TransactionReviewDenied();
2601
- dispatchEvent(ParaEvent.SIGN_TRANSACTION_EVENT, signRes, error.message);
2636
+ dispatchEvent(
2637
+ ParaEvent.SIGN_TRANSACTION_EVENT,
2638
+ yield this.getDeniedSignatureResultWithUrl(pendingTxId),
2639
+ error.message
2640
+ );
2602
2641
  throw error;
2603
2642
  }
2604
2643
  if (!(pendingTransaction == null ? void 0 : pendingTransaction.approvedAt)) {
@@ -2622,16 +2661,16 @@ const _ParaCore = class _ParaCore {
2622
2661
  break;
2623
2662
  }
2624
2663
  }
2625
- if (signRes.pendingTransactionId) {
2626
- const error = new TransactionReviewTimeout(
2627
- yield this.getTransactionReviewUrl(signRes.pendingTransactionId),
2628
- signRes.pendingTransactionId
2629
- );
2630
- dispatchEvent(ParaEvent.SIGN_TRANSACTION_EVENT, signRes, error.message);
2664
+ pendingTransactionId = getPendingTransactionId(signRes);
2665
+ if (pendingTransactionId) {
2666
+ const deniedSignRes = yield this.getDeniedSignatureResultWithUrl(pendingTransactionId);
2667
+ const error = new TransactionReviewTimeout(deniedSignRes.transactionReviewUrl, pendingTransactionId);
2668
+ dispatchEvent(ParaEvent.SIGN_TRANSACTION_EVENT, deniedSignRes, error.message);
2631
2669
  throw error;
2632
2670
  }
2633
- dispatchEvent(ParaEvent.SIGN_TRANSACTION_EVENT, signRes);
2634
- return signRes;
2671
+ const successfulSignRes = requireSuccessfulSignatureResult(signRes);
2672
+ dispatchEvent(ParaEvent.SIGN_TRANSACTION_EVENT, successfulSignRes);
2673
+ return successfulSignRes;
2635
2674
  });
2636
2675
  }
2637
2676
  isProviderModalDisabled() {
@@ -1,5 +1,5 @@
1
1
  import "./chunk-7B52C2XE.js";
2
- const PARA_CORE_VERSION = "3.5.0";
2
+ const PARA_CORE_VERSION = "3.6.0";
3
3
  const PREFIX = "@CAPSULE/";
4
4
  const PARA_PREFIX = "@PARA/";
5
5
  const LOCAL_STORAGE_AUTH_INFO = `${PREFIX}authInfo`;
@@ -94,7 +94,7 @@ function getAsymmetricKeyPair(ctx, seedValue) {
94
94
  if (!ctx.disableWorkers) {
95
95
  options.workLoad = 100;
96
96
  options.workers = seedValue ? 1 : -1;
97
- const workerBlob = yield wrapWithSpan("worker.load_prime", () => __async(this, null, function* () {
97
+ const workerBlob = yield wrapWithSpan("worker.load_prime", () => __async(null, null, function* () {
98
98
  const workerRes = yield fetch(`${getPortalBaseURL(ctx)}/static/js/prime.worker.min.js`);
99
99
  return new Blob([yield workerRes.text()], { type: "application/javascript" });
100
100
  }));
@@ -156,7 +156,7 @@ function decryptWithDerivedPrivateKey(_0, _1) {
156
156
  function getDerivedPrivateKeyAndDecrypt(ctx, seedValue, encryptedShares) {
157
157
  return __async(this, null, function* () {
158
158
  return Promise.all(
159
- encryptedShares.map((share) => __async(this, null, function* () {
159
+ encryptedShares.map((share) => __async(null, null, function* () {
160
160
  return {
161
161
  walletId: share.walletId,
162
162
  walletScheme: share.walletScheme,
@@ -20,6 +20,16 @@ class TransactionReviewTimeout extends Error {
20
20
  this.pendingTransactionId = pendingTransactionId;
21
21
  }
22
22
  }
23
+ class SigningResultError extends Error {
24
+ constructor(message, options = {}) {
25
+ super(message);
26
+ this.name = "SigningResultError";
27
+ this.code = options.code;
28
+ this.status = options.status;
29
+ this.responseURL = options.responseURL;
30
+ this.data = options.data;
31
+ }
32
+ }
23
33
  class PartnerConfigError extends Error {
24
34
  constructor(code, message, detail) {
25
35
  super(message);
@@ -30,6 +40,7 @@ class PartnerConfigError extends Error {
30
40
  }
31
41
  export {
32
42
  PartnerConfigError,
43
+ SigningResultError,
33
44
  TransactionReviewDenied,
34
45
  TransactionReviewError,
35
46
  TransactionReviewTimeout
@@ -0,0 +1,27 @@
1
+ import "../chunk-7B52C2XE.js";
2
+ function getLocalDevUrlOverride(explicitOverride, globalKey, envKey) {
3
+ var _a;
4
+ const override = (_a = explicitOverride != null ? explicitOverride : typeof globalThis !== "undefined" ? globalThis[globalKey] : void 0) != null ? _a : typeof process !== "undefined" ? process.env[envKey] : void 0;
5
+ return typeof override === "string" && override ? override : void 0;
6
+ }
7
+ function normalizeDevUrlOverride(override, scheme) {
8
+ const url = new URL(override);
9
+ url.protocol = `${scheme}${url.protocol.endsWith("s:") ? "s" : ""}:`;
10
+ return url.href;
11
+ }
12
+ function getDevApiBaseUrlOverride(apiBaseUrlOverride, scheme = "http") {
13
+ const override = getLocalDevUrlOverride(apiBaseUrlOverride, "__PARA_API_BASE_URL_OVERRIDE__", "PARA_API_BASE_URL");
14
+ return override ? normalizeDevUrlOverride(override, scheme) : void 0;
15
+ }
16
+ function getDevMPCNetworkUrlOverride(mpcNetworkUrlOverride, useWebsocket) {
17
+ const override = getLocalDevUrlOverride(
18
+ mpcNetworkUrlOverride,
19
+ "__PARA_MPC_NETWORK_URL_OVERRIDE__",
20
+ "PARA_MPC_NETWORK_URL"
21
+ );
22
+ return override ? normalizeDevUrlOverride(override, useWebsocket ? "ws" : "http").replace(/\/+$/, "") : void 0;
23
+ }
24
+ export {
25
+ getDevApiBaseUrlOverride,
26
+ getDevMPCNetworkUrlOverride
27
+ };
@@ -1,24 +1,12 @@
1
1
  import "../chunk-7B52C2XE.js";
2
2
  import Client from "@getpara/user-management-client";
3
3
  import { Environment } from "../types/index.js";
4
- function getDevApiBaseUrlOverride(scheme = "http") {
5
- const override = typeof globalThis !== "undefined" ? globalThis.__PARA_API_BASE_URL_OVERRIDE__ : void 0;
6
- if (!override || typeof override !== "string") {
7
- return void 0;
8
- }
9
- const url = new URL(override);
10
- if (scheme === "ws") {
11
- url.protocol = url.protocol === "https:" || url.protocol === "wss:" ? "wss:" : "ws:";
12
- } else {
13
- url.protocol = url.protocol === "wss:" || url.protocol === "https:" ? "https:" : "http:";
14
- }
15
- return url.toString();
16
- }
17
- function getBaseOAuthUrl(env) {
4
+ import { getDevApiBaseUrlOverride, getDevMPCNetworkUrlOverride } from "./localDevUrlOverrides.js";
5
+ function getBaseOAuthUrl(env, apiBaseUrlOverride) {
18
6
  var _a;
19
7
  switch (env) {
20
8
  case Environment.DEV:
21
- return (_a = getDevApiBaseUrlOverride()) != null ? _a : "http://localhost:8080/";
9
+ return (_a = getDevApiBaseUrlOverride(apiBaseUrlOverride)) != null ? _a : "http://localhost:8080/";
22
10
  case Environment.SANDBOX:
23
11
  return "https://api.sandbox.usecapsule.com/";
24
12
  case Environment.BETA:
@@ -29,11 +17,11 @@ function getBaseOAuthUrl(env) {
29
17
  throw new Error(`unsupported env: ${env}`);
30
18
  }
31
19
  }
32
- function getBaseUrl(env, scheme = "http") {
20
+ function getBaseUrl(env, scheme = "http", apiBaseUrlOverride) {
33
21
  var _a;
34
22
  switch (env) {
35
23
  case Environment.DEV:
36
- return (_a = getDevApiBaseUrlOverride(scheme)) != null ? _a : `${scheme}://localhost:8080/`;
24
+ return (_a = getDevApiBaseUrlOverride(apiBaseUrlOverride, scheme)) != null ? _a : `${scheme}://localhost:8080/`;
37
25
  case Environment.SANDBOX:
38
26
  return `${scheme}s://api.sandbox.getpara.com/`;
39
27
  case Environment.BETA:
@@ -44,11 +32,12 @@ function getBaseUrl(env, scheme = "http") {
44
32
  throw new Error(`unsupported env: ${env}`);
45
33
  }
46
34
  }
47
- function getBaseMPCNetworkUrl(env, useWebsocket) {
35
+ function getBaseMPCNetworkUrl(env, useWebsocket, mpcNetworkUrlOverride) {
36
+ var _a;
48
37
  const prefix = useWebsocket ? "ws" : "http";
49
38
  switch (env) {
50
39
  case Environment.DEV:
51
- return `${prefix}://localhost:3000`;
40
+ return (_a = getDevMPCNetworkUrlOverride(mpcNetworkUrlOverride, useWebsocket)) != null ? _a : `${prefix}://localhost:3000`;
52
41
  case Environment.SANDBOX:
53
42
  return `${prefix}s://mpc-network.sandbox.getpara.com`;
54
43
  case Environment.BETA:
@@ -91,10 +80,11 @@ function initClient({
91
80
  persistSessionCookie,
92
81
  staticTraceContext,
93
82
  httpAgent,
94
- httpsAgent
83
+ httpsAgent,
84
+ apiBaseUrlOverride
95
85
  }) {
96
86
  return new Client({
97
- userManagementHost: getBaseUrl(env),
87
+ userManagementHost: getBaseUrl(env, "http", apiBaseUrlOverride),
98
88
  version: [Environment.DEV, Environment.SANDBOX].includes(env) ? "dev" : version,
99
89
  apiKey,
100
90
  partnerId,
package/dist/esm/index.js CHANGED
@@ -111,7 +111,7 @@ import { setCurrentUserId } from "./telemetry/uxStateSpanProcessor.js";
111
111
  import { recordActionOnSpan } from "./telemetry/uxAction.js";
112
112
  import { startModalSession, endModalSession, getModalSessionContext } from "./telemetry/modalSession.js";
113
113
  const paraVersion = ParaCore.version;
114
- var src_default = ParaCore;
114
+ var index_default = ParaCore;
115
115
  export {
116
116
  AccountLinkError,
117
117
  AuthLayout,
@@ -155,7 +155,7 @@ export {
155
155
  decryptPrivateKeyWithPassword,
156
156
  decryptWithKeyPair,
157
157
  decryptWithPrivateKey,
158
- src_default as default,
158
+ index_default as default,
159
159
  dispatchEvent,
160
160
  distributeNewShare,
161
161
  encodeConfigParams,
@@ -396,7 +396,7 @@ class PortalUrlService {
396
396
  })).then((r) => r.url) : Promise.resolve(false)
397
397
  ]);
398
398
  return constructUrl({
399
- base: getBaseOAuthUrl(__privateGet(this, _paraCoreInterface).ctx.env),
399
+ base: getBaseOAuthUrl(__privateGet(this, _paraCoreInterface).ctx.env, __privateGet(this, _paraCoreInterface).ctx.apiBaseUrlOverride),
400
400
  path: `/auth/${method.toLowerCase()}`,
401
401
  params: __spreadValues(__spreadValues({
402
402
  apiKey: __privateGet(this, _paraCoreInterface).ctx.apiKey,