@getpara/core-sdk 3.5.1 → 3.7.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 (76) hide show
  1. package/dist/cjs/ParaCore.js +11 -4
  2. package/dist/cjs/constants.js +1 -1
  3. package/dist/cjs/cryptography/utils.js +2 -2
  4. package/dist/cjs/external/localDevUrlOverrides.js +50 -0
  5. package/dist/cjs/external/userManagementClient.js +11 -21
  6. package/dist/cjs/index.js +15 -15
  7. package/dist/cjs/services/PollingService.js +11 -0
  8. package/dist/cjs/services/PortalUrlService.js +1 -1
  9. package/dist/cjs/services/WalletService.js +19 -4
  10. package/dist/cjs/state/actors/authenticateWithEmailOrPhone.js +1 -1
  11. package/dist/cjs/state/actors/authenticateWithExternalWallet.js +1 -1
  12. package/dist/cjs/state/actors/authenticateWithFarcaster.js +1 -1
  13. package/dist/cjs/state/actors/authenticateWithFarcasterLegacy.js +1 -1
  14. package/dist/cjs/state/actors/authenticateWithTelegram.js +1 -1
  15. package/dist/cjs/state/actors/authenticateWithTelegramLegacy.js +1 -1
  16. package/dist/cjs/state/actors/checkUserState.js +1 -1
  17. package/dist/cjs/state/actors/claimWallets.js +1 -1
  18. package/dist/cjs/state/actors/connectExternalConnectors.js +1 -1
  19. package/dist/cjs/state/actors/connectExternalWallet.js +1 -1
  20. package/dist/cjs/state/actors/createGuestWallets.js +1 -1
  21. package/dist/cjs/state/actors/createWallets.js +1 -1
  22. package/dist/cjs/state/actors/processAuthentication.js +1 -1
  23. package/dist/cjs/state/actors/setupAfterLogin.js +1 -1
  24. package/dist/cjs/state/actors/setupPara.js +1 -1
  25. package/dist/cjs/state/actors/signExternalWalletVerification.js +1 -1
  26. package/dist/cjs/state/actors/switchExternalWallet.js +1 -1
  27. package/dist/cjs/state/actors/verifyExternalWallet.js +1 -1
  28. package/dist/cjs/state/actors/verifyNewAccount.js +1 -1
  29. package/dist/cjs/state/actors/waitForExternalWalletProviders.js +1 -1
  30. package/dist/cjs/state/machines/authStateMachine.js +14 -7
  31. package/dist/cjs/state/machines/coreStateMachine.js +1 -1
  32. package/dist/cjs/state/machines/walletStateMachine.js +1 -1
  33. package/dist/cjs/telemetry/tracer.js +1 -1
  34. package/dist/cjs/utils/url.js +5 -2
  35. package/dist/esm/ParaCore.js +11 -4
  36. package/dist/esm/constants.js +1 -1
  37. package/dist/esm/cryptography/utils.js +2 -2
  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/PollingService.js +11 -0
  42. package/dist/esm/services/PortalUrlService.js +1 -1
  43. package/dist/esm/services/WalletService.js +19 -4
  44. package/dist/esm/state/actors/authenticateWithEmailOrPhone.js +1 -1
  45. package/dist/esm/state/actors/authenticateWithExternalWallet.js +1 -1
  46. package/dist/esm/state/actors/authenticateWithFarcaster.js +1 -1
  47. package/dist/esm/state/actors/authenticateWithFarcasterLegacy.js +1 -1
  48. package/dist/esm/state/actors/authenticateWithTelegram.js +1 -1
  49. package/dist/esm/state/actors/authenticateWithTelegramLegacy.js +1 -1
  50. package/dist/esm/state/actors/checkUserState.js +1 -1
  51. package/dist/esm/state/actors/claimWallets.js +1 -1
  52. package/dist/esm/state/actors/connectExternalConnectors.js +1 -1
  53. package/dist/esm/state/actors/connectExternalWallet.js +1 -1
  54. package/dist/esm/state/actors/createGuestWallets.js +1 -1
  55. package/dist/esm/state/actors/createWallets.js +1 -1
  56. package/dist/esm/state/actors/processAuthentication.js +1 -1
  57. package/dist/esm/state/actors/setupAfterLogin.js +1 -1
  58. package/dist/esm/state/actors/setupPara.js +1 -1
  59. package/dist/esm/state/actors/signExternalWalletVerification.js +1 -1
  60. package/dist/esm/state/actors/switchExternalWallet.js +1 -1
  61. package/dist/esm/state/actors/verifyExternalWallet.js +1 -1
  62. package/dist/esm/state/actors/verifyNewAccount.js +1 -1
  63. package/dist/esm/state/actors/waitForExternalWalletProviders.js +1 -1
  64. package/dist/esm/state/machines/authStateMachine.js +14 -7
  65. package/dist/esm/state/machines/coreStateMachine.js +1 -1
  66. package/dist/esm/state/machines/walletStateMachine.js +1 -1
  67. package/dist/esm/telemetry/tracer.js +1 -1
  68. package/dist/esm/utils/url.js +4 -2
  69. package/dist/types/external/localDevUrlOverrides.d.ts +4 -0
  70. package/dist/types/external/userManagementClient.d.ts +5 -4
  71. package/dist/types/services/types/PollingServiceTypes.d.ts +9 -0
  72. package/dist/types/state/machines/authStateMachine.d.ts +2 -0
  73. package/dist/types/state/machines/coreStateMachine.d.ts +12 -0
  74. package/dist/types/types/config.d.ts +2 -0
  75. package/dist/types/utils/url.d.ts +1 -0
  76. package/package.json +14 -14
@@ -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) => {
@@ -364,6 +364,11 @@ function createAuthStateMachine(paraCoreInterface) {
364
364
  return (_b = (_a = event.data).onCancel) == null ? void 0 : _b.call(_a);
365
365
  },
366
366
  isCanceled: event.data.isCanceled || (() => false),
367
+ // verify-oauth buffers success server-side, so closing the in-app browser
368
+ // right after authenticating (Apple's Face ID confirm is near-instant) can
369
+ // land as "cancel" for a login that already succeeded — re-check once
370
+ // before giving up (ENG-6993).
371
+ graceCheckOnCancel: true,
367
372
  id: "authenticatingOauth"
368
373
  };
369
374
  }
@@ -649,7 +654,7 @@ function createAuthStateMachine(paraCoreInterface) {
649
654
  var _a;
650
655
  let farcasterAuthState = null;
651
656
  return {
652
- checkCondition: () => __async(this, null, function* () {
657
+ checkCondition: () => __async(null, null, function* () {
653
658
  try {
654
659
  const result = yield paraCoreInterface.pollingService.waitForFarcasterAuth({
655
660
  onSuccess: (serverAuthState) => {
@@ -921,7 +926,7 @@ function createAuthStateMachine(paraCoreInterface) {
921
926
  var _a;
922
927
  let resolvedAuthState = null;
923
928
  return {
924
- checkCondition: () => __async(this, null, function* () {
929
+ checkCondition: () => __async(null, null, function* () {
925
930
  try {
926
931
  const result = yield paraCoreInterface.pollingService.waitForOAuth({
927
932
  onSuccess: (serverAuthState) => {
@@ -942,6 +947,8 @@ function createAuthStateMachine(paraCoreInterface) {
942
947
  return (_b = (_a2 = context.pollingCallbacks) == null ? void 0 : _a2.onCancel) == null ? void 0 : _b.call(_a2);
943
948
  },
944
949
  isCanceled: ((_a = context.pollingCallbacks) == null ? void 0 : _a.isCanceled) || (() => false),
950
+ // Same cancel-races-completion window as authenticating_oauth (ENG-6993).
951
+ graceCheckOnCancel: true,
945
952
  id: "resolving2fa"
946
953
  };
947
954
  },
@@ -1113,7 +1120,7 @@ function createAuthStateMachine(paraCoreInterface) {
1113
1120
  input: ({ context }) => {
1114
1121
  var _a;
1115
1122
  return {
1116
- init: () => __async(this, null, function* () {
1123
+ init: () => __async(null, null, function* () {
1117
1124
  try {
1118
1125
  yield paraCoreInterface.sessionManagementService.touchSession();
1119
1126
  if (!paraCoreInterface.authService.isExternalWalletAuth) {
@@ -1124,7 +1131,7 @@ function createAuthStateMachine(paraCoreInterface) {
1124
1131
  throw new Error(`Session touch failed: ${(0, import_stateErrorHelpers.extractErrorMessage)(error, "Unknown error")}`);
1125
1132
  }
1126
1133
  }),
1127
- checkCondition: () => __async(this, null, function* () {
1134
+ checkCondition: () => __async(null, null, function* () {
1128
1135
  try {
1129
1136
  return yield paraCoreInterface.pollingService.waitForSession();
1130
1137
  } 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,
@@ -226,7 +228,7 @@ const _ParaCore = class _ParaCore {
226
228
  const uxTargetId = typeof entry === "string" ? void 0 : entry.uxTargetId;
227
229
  const original = this[methodName];
228
230
  if (typeof original === "function") {
229
- this[methodName] = (...args) => {
231
+ this[methodName] = ((...args) => {
230
232
  var _a;
231
233
  const attrs = __spreadValues(__spreadProps(__spreadValues({
232
234
  "para.platform": this.platformUtils.sdkType
@@ -249,7 +251,7 @@ const _ParaCore = class _ParaCore {
249
251
  }),
250
252
  attrs
251
253
  ).catch((err) => this.trackError(methodName, err));
252
- };
254
+ });
253
255
  }
254
256
  }
255
257
  };
@@ -482,6 +484,7 @@ const _ParaCore = class _ParaCore {
482
484
  const rawPlatform = (_a = opts.hostPlatform) != null ? _a : this.platformUtils.sdkType;
483
485
  this.clientType = normalizePlatform(rawPlatform);
484
486
  const requestAgents = (_c = (_b = this.platformUtils).getRequestAgents) == null ? void 0 : _c.call(_b);
487
+ const apiBaseUrlOverride = getDevApiBaseUrlOverride();
485
488
  const client = initClient({
486
489
  env,
487
490
  version: _ParaCore.version,
@@ -494,7 +497,8 @@ const _ParaCore = class _ParaCore {
494
497
  retrieveSessionCookie: this.retrieveSessionCookie,
495
498
  persistSessionCookie: this.persistSessionCookie,
496
499
  httpAgent: requestAgents == null ? void 0 : requestAgents.httpAgent,
497
- httpsAgent: requestAgents == null ? void 0 : requestAgents.httpsAgent
500
+ httpsAgent: requestAgents == null ? void 0 : requestAgents.httpsAgent,
501
+ apiBaseUrlOverride
498
502
  });
499
503
  const enclaveClient = new EnclaveClient({
500
504
  userManagementClient: client,
@@ -508,6 +512,9 @@ const _ParaCore = class _ParaCore {
508
512
  apiKey,
509
513
  client,
510
514
  enclaveClient,
515
+ apiBaseUrlOverride,
516
+ portalUrlOverride: getGlobalPortalUrlOverride(),
517
+ mpcNetworkUrlOverride: getDevMPCNetworkUrlOverride(),
511
518
  disableWorkers: opts.disableWorkers,
512
519
  offloadMPCComputationURL: opts.offloadMPCComputationURL,
513
520
  useLocalFiles: opts.useLocalFiles,
@@ -1540,7 +1547,7 @@ const _ParaCore = class _ParaCore {
1540
1547
  const telemetry = res.data.partner.telemetry;
1541
1548
  if ((telemetry == null ? void 0 : telemetry.enabled) && this.ctx.env) {
1542
1549
  void initTelemetry({
1543
- tunnelUrl: `${getBaseUrl(this.ctx.env)}telemetry`,
1550
+ tunnelUrl: `${getBaseUrl(this.ctx.env, "http", this.ctx.apiBaseUrlOverride)}telemetry`,
1544
1551
  sampleRate: telemetry.sample_rate,
1545
1552
  sdkType: this.platformUtils.sdkType,
1546
1553
  clientType: this.clientType,
@@ -1,5 +1,5 @@
1
1
  import "./chunk-7B52C2XE.js";
2
- const PARA_CORE_VERSION = "3.5.1";
2
+ const PARA_CORE_VERSION = "3.7.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,
@@ -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,
@@ -71,6 +71,7 @@ class PollingService {
71
71
  onPoll,
72
72
  onCancel,
73
73
  isCanceled,
74
+ graceCheckOnCancel = false,
74
75
  id = "genericPolling"
75
76
  } = config;
76
77
  return wrapWithSpan(
@@ -108,6 +109,16 @@ class PollingService {
108
109
  }
109
110
  while (pollCount < maxPolls) {
110
111
  if (isOperationCanceled()) {
112
+ if (graceCheckOnCancel) {
113
+ try {
114
+ const { finished, data } = yield checkCondition();
115
+ if (finished) {
116
+ cleanup();
117
+ return finalize({ type: "COMPLETE", data });
118
+ }
119
+ } catch (e) {
120
+ }
121
+ }
111
122
  cleanup();
112
123
  onCancel == null ? void 0 : onCancel();
113
124
  return finalize({ type: "CANCEL" });
@@ -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,
@@ -272,16 +272,31 @@ class WalletService {
272
272
  (id) => this.wallets[id].type === type && __privateGet(this, _pregenWalletService).isPregenWalletClaimable(this.wallets[id])
273
273
  );
274
274
  [...walletIds, ...pregenWalletIds].forEach((id) => {
275
- if (address.toLowerCase() === this.getDisplayAddress(id, { addressType: type }).toLowerCase()) {
275
+ var _a;
276
+ if (address.toLowerCase() === ((_a = this.getDisplayAddress(id, { addressType: type })) == null ? void 0 : _a.toLowerCase())) {
276
277
  wallet = this.wallets[id];
277
278
  }
278
279
  });
279
280
  });
280
- if (!wallet) {
281
+ if (wallet) {
282
+ this.assertIsValidWalletId(wallet.id, filter);
283
+ return wallet;
284
+ }
285
+ const target = address.toLowerCase();
286
+ const fallbackWallet = target ? Object.values(this.wallets).find(
287
+ (w) => !!w.type && this.isWalletUsable(w.id, __spreadProps(__spreadValues({}, filter), { type: void 0 })) && (!(filter == null ? void 0 : filter.type) || getEquivalentTypes(filter.type).includes(w.type)) && (!w.pregenIdentifier || __privateGet(this, _pregenWalletService).isPregenWalletClaimable(w)) && getEquivalentTypes(w.type).some((type) => {
288
+ var _a;
289
+ try {
290
+ return ((_a = this.getDisplayAddress(w.id, { addressType: type })) == null ? void 0 : _a.toLowerCase()) === target;
291
+ } catch (e) {
292
+ return false;
293
+ }
294
+ })
295
+ ) : void 0;
296
+ if (!fallbackWallet) {
281
297
  throw new Error(`wallet with address ${address} not found`);
282
298
  }
283
- this.assertIsValidWalletId(wallet.id, filter);
284
- return wallet;
299
+ return fallbackWallet;
285
300
  };
286
301
  this.findWallet = (idOrAddress, overrideType, filter = {}) => {
287
302
  var _a, _c, _d;
@@ -2,7 +2,7 @@ import {
2
2
  __async
3
3
  } from "../../chunk-7B52C2XE.js";
4
4
  import { fromPromise } from "xstate";
5
- const createAuthenticateWithEmailOrPhoneActor = (authService) => fromPromise((params) => __async(void 0, null, function* () {
5
+ const createAuthenticateWithEmailOrPhoneActor = (authService) => fromPromise((params) => __async(null, null, function* () {
6
6
  return yield authService.performSignUpOrLogIn(params.input);
7
7
  }));
8
8
  export {
@@ -2,7 +2,7 @@ import {
2
2
  __async
3
3
  } from "../../chunk-7B52C2XE.js";
4
4
  import { fromPromise } from "xstate";
5
- const createAuthenticateWithExternalWalletActor = (authService) => fromPromise((params) => __async(void 0, null, function* () {
5
+ const createAuthenticateWithExternalWalletActor = (authService) => fromPromise((params) => __async(null, null, function* () {
6
6
  return yield authService.performLoginExternalWallet(params.input);
7
7
  }));
8
8
  export {
@@ -2,7 +2,7 @@ import {
2
2
  __async
3
3
  } from "../../chunk-7B52C2XE.js";
4
4
  import { fromPromise } from "xstate";
5
- const createAuthenticateWithFarcasterActor = (pollingService) => fromPromise((params) => __async(void 0, null, function* () {
5
+ const createAuthenticateWithFarcasterActor = (pollingService) => fromPromise((params) => __async(null, null, function* () {
6
6
  return yield pollingService.waitForFarcasterEvent(params.input);
7
7
  }));
8
8
  export {
@@ -2,7 +2,7 @@ import {
2
2
  __async
3
3
  } from "../../chunk-7B52C2XE.js";
4
4
  import { fromPromise } from "xstate";
5
- const createAuthenticateWithFarcasterLegacyActor = (authService) => fromPromise((params) => __async(void 0, null, function* () {
5
+ const createAuthenticateWithFarcasterLegacyActor = (authService) => fromPromise((params) => __async(null, null, function* () {
6
6
  return yield authService.performVerifyFarcaster(params.input);
7
7
  }));
8
8
  export {
@@ -2,7 +2,7 @@ import {
2
2
  __async
3
3
  } from "../../chunk-7B52C2XE.js";
4
4
  import { fromPromise } from "xstate";
5
- const createAuthenticateWithTelegramActor = (pollingService) => fromPromise((params) => __async(void 0, null, function* () {
5
+ const createAuthenticateWithTelegramActor = (pollingService) => fromPromise((params) => __async(null, null, function* () {
6
6
  return yield pollingService.waitForTelegramEvent(params.input);
7
7
  }));
8
8
  export {
@@ -2,7 +2,7 @@ import {
2
2
  __async
3
3
  } from "../../chunk-7B52C2XE.js";
4
4
  import { fromPromise } from "xstate";
5
- const createAuthenticateWithTelegramLegacyActor = (authService) => fromPromise((params) => __async(void 0, null, function* () {
5
+ const createAuthenticateWithTelegramLegacyActor = (authService) => fromPromise((params) => __async(null, null, function* () {
6
6
  return yield authService.performVerifyTelegram(params.input);
7
7
  }));
8
8
  export {
@@ -2,7 +2,7 @@ import {
2
2
  __async
3
3
  } from "../../chunk-7B52C2XE.js";
4
4
  import { fromPromise } from "xstate";
5
- const createCheckUserStateActor = (paraCoreInterface) => fromPromise(() => __async(void 0, null, function* () {
5
+ const createCheckUserStateActor = (paraCoreInterface) => fromPromise(() => __async(null, null, function* () {
6
6
  const isAuthenticated = yield paraCoreInterface.sessionManagementService.isSessionActive();
7
7
  const isFullyLoggedIn = yield paraCoreInterface.sessionManagementService.isFullyLoggedIn();
8
8
  const isGuestMode = paraCoreInterface.pregenWalletService.isGuestMode;
@@ -4,7 +4,7 @@ import {
4
4
  import { fromPromise } from "xstate";
5
5
  import { retryDelay, sleep } from "../../utils/retryBackoff.js";
6
6
  const createClaimWalletsActor = (pregenWalletService) => fromPromise(
7
- (_0) => __async(void 0, [_0], function* ({ input }) {
7
+ (_0) => __async(null, [_0], function* ({ input }) {
8
8
  var _a;
9
9
  const retryCount = (_a = input == null ? void 0 : input.retryCount) != null ? _a : 0;
10
10
  if (retryCount > 0) yield sleep(retryDelay(retryCount));
@@ -3,7 +3,7 @@ import {
3
3
  } from "../../chunk-7B52C2XE.js";
4
4
  import { fromPromise } from "xstate";
5
5
  import { retryDelay, sleep } from "../../utils/retryBackoff.js";
6
- const createConnectParaConnectorsActor = (externalWalletService) => fromPromise((_0) => __async(void 0, [_0], function* ({ input }) {
6
+ const createConnectParaConnectorsActor = (externalWalletService) => fromPromise((_0) => __async(null, [_0], function* ({ input }) {
7
7
  var _a;
8
8
  const retryCount = (_a = input == null ? void 0 : input.retryCount) != null ? _a : 0;
9
9
  if (retryCount > 0) yield sleep(retryDelay(retryCount));
@@ -2,7 +2,7 @@ import {
2
2
  __async
3
3
  } from "../../chunk-7B52C2XE.js";
4
4
  import { fromPromise } from "xstate";
5
- const createConnectExternalWalletActor = (externalWalletService) => fromPromise((params) => __async(void 0, null, function* () {
5
+ const createConnectExternalWalletActor = (externalWalletService) => fromPromise((params) => __async(null, null, function* () {
6
6
  return yield externalWalletService.performConnectExternalWallet(params.input);
7
7
  }));
8
8
  export {
@@ -2,7 +2,7 @@ import {
2
2
  __async
3
3
  } from "../../chunk-7B52C2XE.js";
4
4
  import { fromPromise } from "xstate";
5
- const createCreateGuestWalletsActor = (pregenWalletService) => fromPromise(() => __async(void 0, null, function* () {
5
+ const createCreateGuestWalletsActor = (pregenWalletService) => fromPromise(() => __async(null, null, function* () {
6
6
  return yield pregenWalletService.performCreateGuestWallets();
7
7
  }));
8
8
  export {
@@ -4,7 +4,7 @@ import {
4
4
  } from "../../chunk-7B52C2XE.js";
5
5
  import { fromPromise } from "xstate";
6
6
  import { retryDelay, sleep } from "../../utils/retryBackoff.js";
7
- const createCreateWalletsActor = (walletService) => fromPromise((_0) => __async(void 0, [_0], function* ({ input }) {
7
+ const createCreateWalletsActor = (walletService) => fromPromise((_0) => __async(null, [_0], function* ({ input }) {
8
8
  var _a;
9
9
  const retryCount = (_a = input == null ? void 0 : input.retryCount) != null ? _a : 0;
10
10
  if (retryCount > 0) yield sleep(retryDelay(retryCount));
@@ -2,7 +2,7 @@ import {
2
2
  __async
3
3
  } from "../../chunk-7B52C2XE.js";
4
4
  import { fromPromise } from "xstate";
5
- const createProcessAuthenticationActor = (authService) => fromPromise((params) => __async(void 0, null, function* () {
5
+ const createProcessAuthenticationActor = (authService) => fromPromise((params) => __async(null, null, function* () {
6
6
  return yield authService.prepareAuthState(params.input.authState, params.input.opts);
7
7
  }));
8
8
  export {
@@ -3,7 +3,7 @@ import {
3
3
  } from "../../chunk-7B52C2XE.js";
4
4
  import { fromPromise } from "xstate";
5
5
  const createSetupAfterLoginActor = (paraCoreInterface) => fromPromise(
6
- (_0) => __async(void 0, [_0], function* ({ input: { temporaryShares, skipSessionRefresh } }) {
6
+ (_0) => __async(null, [_0], function* ({ input: { temporaryShares, skipSessionRefresh } }) {
7
7
  yield paraCoreInterface.setupAfterLogin({ temporaryShares, skipSessionRefresh });
8
8
  })
9
9
  );
@@ -2,7 +2,7 @@ import {
2
2
  __async
3
3
  } from "../../chunk-7B52C2XE.js";
4
4
  import { fromPromise } from "xstate";
5
- const createSetupParaActor = (paraCoreInterface) => fromPromise(() => __async(void 0, null, function* () {
5
+ const createSetupParaActor = (paraCoreInterface) => fromPromise(() => __async(null, null, function* () {
6
6
  const eagerPartnerLoad = paraCoreInterface.isPortal() ? Promise.resolve() : paraCoreInterface.sessionManagementService.touchSession().catch((e) => {
7
7
  paraCoreInterface.devLog("setupPara: eager partner load via touchSession failed; will retry lazily", e);
8
8
  });
@@ -5,7 +5,7 @@ import {
5
5
  } from "../../chunk-7B52C2XE.js";
6
6
  import { fromPromise } from "xstate";
7
7
  const createSignExternalWalletVerificationActor = (externalWalletService) => fromPromise(
8
- (params) => __async(void 0, null, function* () {
8
+ (params) => __async(null, null, function* () {
9
9
  const _a = yield externalWalletService.signMessage(params.input), { signature } = _a, rest = __objRest(_a, ["signature"]);
10
10
  return __spreadValues({ externalWallet: params.input.externalWallet, signedMessage: signature }, rest);
11
11
  })
@@ -2,7 +2,7 @@ import {
2
2
  __async
3
3
  } from "../../chunk-7B52C2XE.js";
4
4
  import { fromPromise } from "xstate";
5
- const createSwitchExternalWalletActor = (externalWalletService) => fromPromise((params) => __async(void 0, null, function* () {
5
+ const createSwitchExternalWalletActor = (externalWalletService) => fromPromise((params) => __async(null, null, function* () {
6
6
  return yield externalWalletService.performSwitchExternalWallet(params.input);
7
7
  }));
8
8
  export {
@@ -2,7 +2,7 @@ import {
2
2
  __async
3
3
  } from "../../chunk-7B52C2XE.js";
4
4
  import { fromPromise } from "xstate";
5
- const createVerifyExternalWalletActor = (authService) => fromPromise((params) => __async(void 0, null, function* () {
5
+ const createVerifyExternalWalletActor = (authService) => fromPromise((params) => __async(null, null, function* () {
6
6
  return yield authService.performVerifyExternalWallet(params.input);
7
7
  }));
8
8
  export {
@@ -2,7 +2,7 @@ import {
2
2
  __async
3
3
  } from "../../chunk-7B52C2XE.js";
4
4
  import { fromPromise } from "xstate";
5
- const createVerifyNewAccountActor = (authService) => fromPromise((params) => __async(void 0, null, function* () {
5
+ const createVerifyNewAccountActor = (authService) => fromPromise((params) => __async(null, null, function* () {
6
6
  return yield authService.performVerifyNewAccount(params.input);
7
7
  }));
8
8
  export {
@@ -2,7 +2,7 @@ import {
2
2
  __async
3
3
  } from "../../chunk-7B52C2XE.js";
4
4
  import { fromPromise } from "xstate";
5
- const createWaitForExternalWalletProvidersActor = (stateMachineInterface) => fromPromise(() => __async(void 0, null, function* () {
5
+ const createWaitForExternalWalletProvidersActor = (stateMachineInterface) => fromPromise(() => __async(null, null, function* () {
6
6
  return yield stateMachineInterface.externalWalletService.waitForProvidersLoading();
7
7
  }));
8
8
  export {