@getpara/core-sdk 2.0.0 → 2.2.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.
@@ -807,7 +807,8 @@ const _ParaCore = class _ParaCore {
807
807
  if (!this.loginEncryptionKeyPair) {
808
808
  yield this.setLoginEncryptionKeyPair();
809
809
  }
810
- const base = type === "onRamp" || isTelegramLogin ? (0, import_utils2.getPortalBaseURL)(this.ctx, isTelegramLogin) : yield this.getPortalURL();
810
+ const shouldUseLegacyPortalUrl = opts.useLegacyUrl || !!opts.addNewCredentialPasskeyId || type === "loginAuth";
811
+ const base = type === "onRamp" || isTelegramLogin ? (0, import_utils2.getPortalBaseURL)(this.ctx, isTelegramLogin, false, shouldUseLegacyPortalUrl) : yield this.getPortalURL(shouldUseLegacyPortalUrl);
811
812
  let path;
812
813
  switch (type) {
813
814
  case "createPassword": {
@@ -946,7 +947,7 @@ const _ParaCore = class _ParaCore {
946
947
  } : {});
947
948
  const url = (0, import_utils2.constructUrl)({ base, path, params });
948
949
  if (opts.shorten) {
949
- return (0, import_utils2.shortenUrl)(this.ctx, url);
950
+ return yield (0, import_utils2.shortenUrl)(this.ctx, url, shouldUseLegacyPortalUrl);
950
951
  }
951
952
  return url;
952
953
  });
@@ -1561,9 +1562,9 @@ Need help? Visit: https://docs.getpara.com or contact support
1561
1562
  * @param partnerId: string - id of the partner to get the portal URL for
1562
1563
  * @returns - portal URL
1563
1564
  */
1564
- getPortalURL() {
1565
+ getPortalURL(isLegacy) {
1565
1566
  return __async(this, null, function* () {
1566
- return (yield this.getPartnerURL()) || (0, import_utils2.getPortalBaseURL)(this.ctx);
1567
+ return (yield this.getPartnerURL()) || (0, import_utils2.getPortalBaseURL)(this.ctx, false, false, isLegacy);
1567
1568
  });
1568
1569
  }
1569
1570
  /**
@@ -3778,7 +3779,11 @@ getOAuthUrl_fn = function(_0) {
3778
3779
  sessionId: sessionLookupId,
3779
3780
  encryptionKey
3780
3781
  }
3781
- }, this.isPortal() && { params: portalCallbackParams })))
3782
+ }, this.isPortal() && {
3783
+ params: portalCallbackParams,
3784
+ // Build callback for legacy portal if needed
3785
+ useLegacyUrl: typeof window !== "undefined" ? window.location.host.includes("usecapsule") : false
3786
+ })))
3782
3787
  })
3783
3788
  });
3784
3789
  });
@@ -43,7 +43,7 @@ __export(constants_exports, {
43
43
  SHORT_POLLING_INTERVAL_MS: () => SHORT_POLLING_INTERVAL_MS
44
44
  });
45
45
  module.exports = __toCommonJS(constants_exports);
46
- const PARA_CORE_VERSION = "2.0.0";
46
+ const PARA_CORE_VERSION = "2.2.0";
47
47
  const PREFIX = "@CAPSULE/";
48
48
  const PARA_PREFIX = "@PARA/";
49
49
  const LOCAL_STORAGE_AUTH_INFO = `${PREFIX}authInfo`;
@@ -40,14 +40,6 @@ function validateBalancesConfig(obj) {
40
40
  if (!validateCustomAsset(asset)) {
41
41
  return false;
42
42
  }
43
- const hasPriceUrl = typeof asset.priceUrl === "string" && asset.priceUrl.trim();
44
- const hasPrice = asset.price && typeof asset.price === "object" && typeof asset.price.value === "number" && asset.price.value > 0 && typeof asset.price.currency === "string" && asset.price.currency.trim();
45
- if (!hasPriceUrl && !hasPrice) {
46
- return false;
47
- }
48
- if (hasPriceUrl && hasPrice) {
49
- return false;
50
- }
51
43
  }
52
44
  }
53
45
  return true;
@@ -47,31 +47,32 @@ __export(url_exports, {
47
47
  module.exports = __toCommonJS(url_exports);
48
48
  var import_transmissionUtils = require("../transmission/transmissionUtils.js");
49
49
  var import_types = require("../types/index.js");
50
- function getPortalDomain(env, isE2E) {
50
+ function getPortalDomain(env, isE2E, isLegacy) {
51
51
  if (isE2E) {
52
52
  return `localhost`;
53
53
  }
54
+ const domainRoot = isLegacy ? "usecapsule" : "getpara";
54
55
  switch (env) {
55
56
  case import_types.Environment.DEV:
56
57
  return "localhost";
57
58
  case import_types.Environment.SANDBOX:
58
- return "app.sandbox.usecapsule.com";
59
+ return `app.sandbox.${domainRoot}.com`;
59
60
  case import_types.Environment.BETA:
60
- return "app.beta.usecapsule.com";
61
+ return `app.beta.${domainRoot}.com`;
61
62
  case import_types.Environment.PROD:
62
- return "app.usecapsule.com";
63
+ return `app.${domainRoot}.com`;
63
64
  default:
64
65
  throw new Error(`env: ${env} not supported`);
65
66
  }
66
67
  }
67
- function getPortalBaseURL({ env, isE2E }, useLocalIp, isForWasm) {
68
+ function getPortalBaseURL({ env, isE2E }, useLocalIp, isForWasm, isLegacy) {
68
69
  if (isE2E) {
69
70
  if (isForWasm) {
70
- return `https://app.sandbox.usecapsule.com`;
71
+ return `https://app.sandbox.getpara.com`;
71
72
  }
72
73
  return `http://localhost:3003`;
73
74
  }
74
- const domain = getPortalDomain(env);
75
+ const domain = getPortalDomain(env, false, isLegacy);
75
76
  if (env === import_types.Environment.DEV) {
76
77
  if (useLocalIp) {
77
78
  return `http://127.0.0.1:3003`;
@@ -115,11 +116,11 @@ function constructUrl({
115
116
  });
116
117
  return url.toString();
117
118
  }
118
- function shortenUrl(ctx, url) {
119
+ function shortenUrl(ctx, url, isLegacy) {
119
120
  return __async(this, null, function* () {
120
121
  const compressedUrl = yield (0, import_transmissionUtils.upload)(url, ctx.client);
121
122
  return constructUrl({
122
- base: getPortalBaseURL(ctx),
123
+ base: getPortalBaseURL(ctx, false, false, isLegacy),
123
124
  path: `/short/${compressedUrl}`
124
125
  });
125
126
  });
@@ -24,7 +24,7 @@ var import_url = require("./url.js");
24
24
  function isPortal(ctx, env) {
25
25
  var _a, _b;
26
26
  if (typeof window === "undefined") return false;
27
- const normalizedUrl = (_b = (_a = window.location) == null ? void 0 : _a.host) == null ? void 0 : _b.replace("getpara", "usecapsule");
27
+ const normalizedUrl = (_b = (_a = window.location) == null ? void 0 : _a.host) == null ? void 0 : _b.replace("usecapsule", "getpara");
28
28
  const isOnPortalDomain = (0, import_url.getPortalBaseURL)(env ? { env } : ctx).includes(normalizedUrl);
29
29
  if (!isOnPortalDomain) return false;
30
30
  const isInIframe = window.parent !== window && !window.opener;
@@ -773,7 +773,8 @@ const _ParaCore = class _ParaCore {
773
773
  if (!this.loginEncryptionKeyPair) {
774
774
  yield this.setLoginEncryptionKeyPair();
775
775
  }
776
- const base = type === "onRamp" || isTelegramLogin ? getPortalBaseURL(this.ctx, isTelegramLogin) : yield this.getPortalURL();
776
+ const shouldUseLegacyPortalUrl = opts.useLegacyUrl || !!opts.addNewCredentialPasskeyId || type === "loginAuth";
777
+ const base = type === "onRamp" || isTelegramLogin ? getPortalBaseURL(this.ctx, isTelegramLogin, false, shouldUseLegacyPortalUrl) : yield this.getPortalURL(shouldUseLegacyPortalUrl);
777
778
  let path;
778
779
  switch (type) {
779
780
  case "createPassword": {
@@ -912,7 +913,7 @@ const _ParaCore = class _ParaCore {
912
913
  } : {});
913
914
  const url = constructUrl({ base, path, params });
914
915
  if (opts.shorten) {
915
- return shortenUrl(this.ctx, url);
916
+ return yield shortenUrl(this.ctx, url, shouldUseLegacyPortalUrl);
916
917
  }
917
918
  return url;
918
919
  });
@@ -1527,9 +1528,9 @@ Need help? Visit: https://docs.getpara.com or contact support
1527
1528
  * @param partnerId: string - id of the partner to get the portal URL for
1528
1529
  * @returns - portal URL
1529
1530
  */
1530
- getPortalURL() {
1531
+ getPortalURL(isLegacy) {
1531
1532
  return __async(this, null, function* () {
1532
- return (yield this.getPartnerURL()) || getPortalBaseURL(this.ctx);
1533
+ return (yield this.getPartnerURL()) || getPortalBaseURL(this.ctx, false, false, isLegacy);
1533
1534
  });
1534
1535
  }
1535
1536
  /**
@@ -3744,7 +3745,11 @@ getOAuthUrl_fn = function(_0) {
3744
3745
  sessionId: sessionLookupId,
3745
3746
  encryptionKey
3746
3747
  }
3747
- }, this.isPortal() && { params: portalCallbackParams })))
3748
+ }, this.isPortal() && {
3749
+ params: portalCallbackParams,
3750
+ // Build callback for legacy portal if needed
3751
+ useLegacyUrl: typeof window !== "undefined" ? window.location.host.includes("usecapsule") : false
3752
+ })))
3748
3753
  })
3749
3754
  });
3750
3755
  });
@@ -1,5 +1,5 @@
1
1
  import "./chunk-7B52C2XE.js";
2
- const PARA_CORE_VERSION = "2.0.0";
2
+ const PARA_CORE_VERSION = "2.2.0";
3
3
  const PREFIX = "@CAPSULE/";
4
4
  const PARA_PREFIX = "@PARA/";
5
5
  const LOCAL_STORAGE_AUTH_INFO = `${PREFIX}authInfo`;
@@ -19,14 +19,6 @@ function validateBalancesConfig(obj) {
19
19
  if (!validateCustomAsset(asset)) {
20
20
  return false;
21
21
  }
22
- const hasPriceUrl = typeof asset.priceUrl === "string" && asset.priceUrl.trim();
23
- const hasPrice = asset.price && typeof asset.price === "object" && typeof asset.price.value === "number" && asset.price.value > 0 && typeof asset.price.currency === "string" && asset.price.currency.trim();
24
- if (!hasPriceUrl && !hasPrice) {
25
- return false;
26
- }
27
- if (hasPriceUrl && hasPrice) {
28
- return false;
29
- }
30
22
  }
31
23
  }
32
24
  return true;
@@ -3,31 +3,32 @@ import {
3
3
  } from "../chunk-7B52C2XE.js";
4
4
  import { upload } from "../transmission/transmissionUtils.js";
5
5
  import { Environment } from "../types/index.js";
6
- function getPortalDomain(env, isE2E) {
6
+ function getPortalDomain(env, isE2E, isLegacy) {
7
7
  if (isE2E) {
8
8
  return `localhost`;
9
9
  }
10
+ const domainRoot = isLegacy ? "usecapsule" : "getpara";
10
11
  switch (env) {
11
12
  case Environment.DEV:
12
13
  return "localhost";
13
14
  case Environment.SANDBOX:
14
- return "app.sandbox.usecapsule.com";
15
+ return `app.sandbox.${domainRoot}.com`;
15
16
  case Environment.BETA:
16
- return "app.beta.usecapsule.com";
17
+ return `app.beta.${domainRoot}.com`;
17
18
  case Environment.PROD:
18
- return "app.usecapsule.com";
19
+ return `app.${domainRoot}.com`;
19
20
  default:
20
21
  throw new Error(`env: ${env} not supported`);
21
22
  }
22
23
  }
23
- function getPortalBaseURL({ env, isE2E }, useLocalIp, isForWasm) {
24
+ function getPortalBaseURL({ env, isE2E }, useLocalIp, isForWasm, isLegacy) {
24
25
  if (isE2E) {
25
26
  if (isForWasm) {
26
- return `https://app.sandbox.usecapsule.com`;
27
+ return `https://app.sandbox.getpara.com`;
27
28
  }
28
29
  return `http://localhost:3003`;
29
30
  }
30
- const domain = getPortalDomain(env);
31
+ const domain = getPortalDomain(env, false, isLegacy);
31
32
  if (env === Environment.DEV) {
32
33
  if (useLocalIp) {
33
34
  return `http://127.0.0.1:3003`;
@@ -71,11 +72,11 @@ function constructUrl({
71
72
  });
72
73
  return url.toString();
73
74
  }
74
- function shortenUrl(ctx, url) {
75
+ function shortenUrl(ctx, url, isLegacy) {
75
76
  return __async(this, null, function* () {
76
77
  const compressedUrl = yield upload(url, ctx.client);
77
78
  return constructUrl({
78
- base: getPortalBaseURL(ctx),
79
+ base: getPortalBaseURL(ctx, false, false, isLegacy),
79
80
  path: `/short/${compressedUrl}`
80
81
  });
81
82
  });
@@ -3,7 +3,7 @@ import { getPortalBaseURL } from "./url.js";
3
3
  function isPortal(ctx, env) {
4
4
  var _a, _b;
5
5
  if (typeof window === "undefined") return false;
6
- const normalizedUrl = (_b = (_a = window.location) == null ? void 0 : _a.host) == null ? void 0 : _b.replace("getpara", "usecapsule");
6
+ const normalizedUrl = (_b = (_a = window.location) == null ? void 0 : _a.host) == null ? void 0 : _b.replace("usecapsule", "getpara");
7
7
  const isOnPortalDomain = getPortalBaseURL(env ? { env } : ctx).includes(normalizedUrl);
8
8
  if (!isOnPortalDomain) return false;
9
9
  const isInIframe = window.parent !== window && !window.opener;
@@ -370,7 +370,7 @@ export declare abstract class ParaCore implements CoreInterface {
370
370
  * @param partnerId: string - id of the partner to get the portal URL for
371
371
  * @returns - portal URL
372
372
  */
373
- protected getPortalURL(): Promise<string>;
373
+ protected getPortalURL(isLegacy?: boolean): Promise<string>;
374
374
  /**
375
375
  * Gets the private key for the given wallet.
376
376
  * @param {string } [walletId] id of the wallet to get the private key for. Will default to the first wallet if not provided.
@@ -29,6 +29,7 @@ export type PortalUrlOptions = {
29
29
  addNewCredentialType?: TAuthMethod;
30
30
  addNewCredentialPasswordId?: string;
31
31
  addNewCredentialPasskeyId?: string;
32
+ useLegacyUrl?: boolean;
32
33
  };
33
34
  export type WithAuthMethod = {
34
35
  /**
@@ -1,9 +1,9 @@
1
1
  import { Ctx, Environment } from '../types/index.js';
2
- export declare function getPortalDomain(env: Environment, isE2E?: boolean): "localhost" | "app.sandbox.usecapsule.com" | "app.beta.usecapsule.com" | "app.usecapsule.com";
2
+ export declare function getPortalDomain(env: Environment, isE2E?: boolean, isLegacy?: boolean): string;
3
3
  export declare function getPortalBaseURL({ env, isE2E }: {
4
4
  env: Environment;
5
5
  isE2E?: boolean;
6
- }, useLocalIp?: boolean, isForWasm?: boolean): string;
6
+ }, useLocalIp?: boolean, isForWasm?: boolean, isLegacy?: boolean): string;
7
7
  export declare function getParaConnectDomain(env: Environment): "localhost" | "connect.sandbox.getpara.com" | "connect.beta.getpara.com" | "connect.getpara.com";
8
8
  export declare function getParaConnectBaseUrl({ env }: {
9
9
  env: Environment;
@@ -13,4 +13,4 @@ export declare function constructUrl({ base, path, params, }: {
13
13
  path: string;
14
14
  params?: Record<string, string | undefined | null>;
15
15
  }): string;
16
- export declare function shortenUrl(ctx: Ctx, url: string): Promise<string>;
16
+ export declare function shortenUrl(ctx: Ctx, url: string, isLegacy?: boolean): Promise<string>;
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@getpara/core-sdk",
3
- "version": "2.0.0",
3
+ "version": "2.2.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.0.0",
8
+ "@getpara/user-management-client": "2.2.0",
9
9
  "@noble/hashes": "^1.5.0",
10
10
  "base64url": "^3.0.1",
11
11
  "libphonenumber-js": "^1.11.7",
@@ -27,7 +27,7 @@
27
27
  "dist",
28
28
  "package.json"
29
29
  ],
30
- "gitHead": "a64b6aa9b3c481a2d955022f621e495fb55e549e",
30
+ "gitHead": "51765cf39b1667e0283b3906a8f8ef91e447e347",
31
31
  "main": "dist/cjs/index.js",
32
32
  "module": "dist/esm/index.js",
33
33
  "scripts": {