@getpara/core-sdk 2.0.0 → 2.1.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.
- package/dist/cjs/ParaCore.js +10 -5
- package/dist/cjs/constants.js +1 -1
- package/dist/cjs/utils/url.js +10 -9
- package/dist/cjs/utils/window.js +1 -1
- package/dist/esm/ParaCore.js +10 -5
- package/dist/esm/constants.js +1 -1
- package/dist/esm/utils/url.js +10 -9
- package/dist/esm/utils/window.js +1 -1
- package/dist/types/ParaCore.d.ts +1 -1
- package/dist/types/types/methods.d.ts +1 -0
- package/dist/types/utils/url.d.ts +3 -3
- package/package.json +3 -3
package/dist/cjs/ParaCore.js
CHANGED
|
@@ -807,7 +807,8 @@ const _ParaCore = class _ParaCore {
|
|
|
807
807
|
if (!this.loginEncryptionKeyPair) {
|
|
808
808
|
yield this.setLoginEncryptionKeyPair();
|
|
809
809
|
}
|
|
810
|
-
const
|
|
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() && {
|
|
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
|
});
|
package/dist/cjs/constants.js
CHANGED
|
@@ -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.
|
|
46
|
+
const PARA_CORE_VERSION = "2.1.0";
|
|
47
47
|
const PREFIX = "@CAPSULE/";
|
|
48
48
|
const PARA_PREFIX = "@PARA/";
|
|
49
49
|
const LOCAL_STORAGE_AUTH_INFO = `${PREFIX}authInfo`;
|
package/dist/cjs/utils/url.js
CHANGED
|
@@ -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
|
|
59
|
+
return `app.sandbox.${domainRoot}.com`;
|
|
59
60
|
case import_types.Environment.BETA:
|
|
60
|
-
return
|
|
61
|
+
return `app.beta.${domainRoot}.com`;
|
|
61
62
|
case import_types.Environment.PROD:
|
|
62
|
-
return
|
|
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.
|
|
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
|
});
|
package/dist/cjs/utils/window.js
CHANGED
|
@@ -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("
|
|
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;
|
package/dist/esm/ParaCore.js
CHANGED
|
@@ -773,7 +773,8 @@ const _ParaCore = class _ParaCore {
|
|
|
773
773
|
if (!this.loginEncryptionKeyPair) {
|
|
774
774
|
yield this.setLoginEncryptionKeyPair();
|
|
775
775
|
}
|
|
776
|
-
const
|
|
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() && {
|
|
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
|
});
|
package/dist/esm/constants.js
CHANGED
package/dist/esm/utils/url.js
CHANGED
|
@@ -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
|
|
15
|
+
return `app.sandbox.${domainRoot}.com`;
|
|
15
16
|
case Environment.BETA:
|
|
16
|
-
return
|
|
17
|
+
return `app.beta.${domainRoot}.com`;
|
|
17
18
|
case Environment.PROD:
|
|
18
|
-
return
|
|
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.
|
|
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
|
});
|
package/dist/esm/utils/window.js
CHANGED
|
@@ -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("
|
|
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;
|
package/dist/types/ParaCore.d.ts
CHANGED
|
@@ -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.
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Ctx, Environment } from '../types/index.js';
|
|
2
|
-
export declare function getPortalDomain(env: Environment, isE2E?: boolean):
|
|
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.
|
|
3
|
+
"version": "2.1.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.
|
|
8
|
+
"@getpara/user-management-client": "2.1.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": "
|
|
30
|
+
"gitHead": "3ae7f836324a3a2a8a57156e16304aeaf0d37b42",
|
|
31
31
|
"main": "dist/cjs/index.js",
|
|
32
32
|
"module": "dist/esm/index.js",
|
|
33
33
|
"scripts": {
|