@getpara/core-sdk 0.2.0 → 0.2.2
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
CHANGED
|
@@ -73,7 +73,8 @@ const recovery_js_1 = require("./shares/recovery.js");
|
|
|
73
73
|
const libphonenumber_js_1 = __importDefault(require("libphonenumber-js"));
|
|
74
74
|
const formattingUtils_js_1 = require("./utils/formattingUtils.js");
|
|
75
75
|
const errors_js_1 = require("./errors.js");
|
|
76
|
-
|
|
76
|
+
// TODO: update backend to use @getpara/core-sdk version
|
|
77
|
+
const PARA_CORE_VERSION = '2.20.0'; // '0.2.2';
|
|
77
78
|
function dispatchEvent(type, data, error) {
|
|
78
79
|
typeof window !== 'undefined' &&
|
|
79
80
|
!!window.dispatchEvent &&
|
|
@@ -1719,7 +1720,7 @@ class ParaCore {
|
|
|
1719
1720
|
yield this.logout();
|
|
1720
1721
|
const res = yield this.touchSession(true);
|
|
1721
1722
|
return constructUrl({
|
|
1722
|
-
base: method === user_management_client_1.OAuthMethod.TELEGRAM ? (0, definitions_js_1.getPortalBaseURL)(this.ctx, true) : (0, userManagementClient_js_1.
|
|
1723
|
+
base: method === user_management_client_1.OAuthMethod.TELEGRAM ? (0, definitions_js_1.getPortalBaseURL)(this.ctx, true) : (0, userManagementClient_js_1.getBaseOAuthUrl)(this.ctx.env),
|
|
1723
1724
|
path: `/auth/${method.toLowerCase()}`,
|
|
1724
1725
|
params: {
|
|
1725
1726
|
apiKey: this.ctx.apiKey,
|
|
@@ -1751,7 +1752,7 @@ class ParaCore {
|
|
|
1751
1752
|
const { userId, email } = res.data;
|
|
1752
1753
|
yield this.setUserId(userId);
|
|
1753
1754
|
yield this.setEmail(email);
|
|
1754
|
-
const userExists = yield this.checkIfUserExists(email);
|
|
1755
|
+
const userExists = yield this.checkIfUserExists({ email });
|
|
1755
1756
|
this.isAwaitingOAuth = false;
|
|
1756
1757
|
return {
|
|
1757
1758
|
userExists,
|
|
@@ -3,9 +3,24 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.initClient = exports.getBaseMPCNetworkUrl = exports.getBaseUrl = void 0;
|
|
6
|
+
exports.initClient = exports.getBaseMPCNetworkUrl = exports.getBaseUrl = exports.getBaseOAuthUrl = void 0;
|
|
7
7
|
const user_management_client_1 = __importDefault(require("@getpara/user-management-client"));
|
|
8
8
|
const definitions_js_1 = require("../definitions.js");
|
|
9
|
+
function getBaseOAuthUrl(env) {
|
|
10
|
+
switch (env) {
|
|
11
|
+
case definitions_js_1.Environment.DEV:
|
|
12
|
+
return 'http://localhost:8080/';
|
|
13
|
+
case definitions_js_1.Environment.SANDBOX:
|
|
14
|
+
return 'https://api.sandbox.usecapsule.com/';
|
|
15
|
+
case definitions_js_1.Environment.BETA:
|
|
16
|
+
return 'https://api.beta.usecapsule.com/';
|
|
17
|
+
case definitions_js_1.Environment.PROD:
|
|
18
|
+
return 'https://api.usecapsule.com/';
|
|
19
|
+
default:
|
|
20
|
+
throw new Error(`unsupported env: ${env}`);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.getBaseOAuthUrl = getBaseOAuthUrl;
|
|
9
24
|
function getBaseUrl(env) {
|
|
10
25
|
switch (env) {
|
|
11
26
|
case definitions_js_1.Environment.DEV:
|
package/dist/esm/ParaCore.js
CHANGED
|
@@ -35,7 +35,7 @@ import forge from 'node-forge';
|
|
|
35
35
|
const { pki, jsbn } = forge;
|
|
36
36
|
import { decryptWithPrivateKey, getAsymmetricKeyPair, getPublicKeyHex } from './cryptography/utils.js';
|
|
37
37
|
import { WalletSchemeTypeMap, getPortalBaseURL, getParaConnectBaseUrl, } from './definitions.js';
|
|
38
|
-
import {
|
|
38
|
+
import { getBaseOAuthUrl, initClient } from './external/userManagementClient.js';
|
|
39
39
|
import * as mpcComputationClient from './external/mpcComputationClient.js';
|
|
40
40
|
import { distributeNewShare } from './shares/shareDistribution.js';
|
|
41
41
|
import { PopupType, ParaEvent, } from './types/index.js';
|
|
@@ -44,7 +44,8 @@ import { sendRecoveryForShare } from './shares/recovery.js';
|
|
|
44
44
|
import parsePhoneNumberFromString from 'libphonenumber-js';
|
|
45
45
|
import { getCosmosAddress, truncateAddress } from './utils/formattingUtils.js';
|
|
46
46
|
import { TransactionReviewDenied, TransactionReviewError, TransactionReviewTimeout } from './errors.js';
|
|
47
|
-
|
|
47
|
+
// TODO: update backend to use @getpara/core-sdk version
|
|
48
|
+
const PARA_CORE_VERSION = '2.20.0'; // '0.2.2';
|
|
48
49
|
function dispatchEvent(type, data, error) {
|
|
49
50
|
typeof window !== 'undefined' &&
|
|
50
51
|
!!window.dispatchEvent &&
|
|
@@ -1683,7 +1684,7 @@ export class ParaCore {
|
|
|
1683
1684
|
yield this.logout();
|
|
1684
1685
|
const res = yield this.touchSession(true);
|
|
1685
1686
|
return constructUrl({
|
|
1686
|
-
base: method === OAuthMethod.TELEGRAM ? getPortalBaseURL(this.ctx, true) :
|
|
1687
|
+
base: method === OAuthMethod.TELEGRAM ? getPortalBaseURL(this.ctx, true) : getBaseOAuthUrl(this.ctx.env),
|
|
1687
1688
|
path: `/auth/${method.toLowerCase()}`,
|
|
1688
1689
|
params: {
|
|
1689
1690
|
apiKey: this.ctx.apiKey,
|
|
@@ -1715,7 +1716,7 @@ export class ParaCore {
|
|
|
1715
1716
|
const { userId, email } = res.data;
|
|
1716
1717
|
yield this.setUserId(userId);
|
|
1717
1718
|
yield this.setEmail(email);
|
|
1718
|
-
const userExists = yield this.checkIfUserExists(email);
|
|
1719
|
+
const userExists = yield this.checkIfUserExists({ email });
|
|
1719
1720
|
this.isAwaitingOAuth = false;
|
|
1720
1721
|
return {
|
|
1721
1722
|
userExists,
|
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
import Client from '@getpara/user-management-client';
|
|
2
2
|
import { Environment } from '../definitions.js';
|
|
3
|
+
export function getBaseOAuthUrl(env) {
|
|
4
|
+
switch (env) {
|
|
5
|
+
case Environment.DEV:
|
|
6
|
+
return 'http://localhost:8080/';
|
|
7
|
+
case Environment.SANDBOX:
|
|
8
|
+
return 'https://api.sandbox.usecapsule.com/';
|
|
9
|
+
case Environment.BETA:
|
|
10
|
+
return 'https://api.beta.usecapsule.com/';
|
|
11
|
+
case Environment.PROD:
|
|
12
|
+
return 'https://api.usecapsule.com/';
|
|
13
|
+
default:
|
|
14
|
+
throw new Error(`unsupported env: ${env}`);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
3
17
|
export function getBaseUrl(env) {
|
|
4
18
|
switch (env) {
|
|
5
19
|
case Environment.DEV:
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import Client from '@getpara/user-management-client';
|
|
2
2
|
import { Environment } from '../definitions.js';
|
|
3
|
+
export declare function getBaseOAuthUrl(env: Environment): string;
|
|
3
4
|
export declare function getBaseUrl(env: Environment): string;
|
|
4
5
|
export declare function getBaseMPCNetworkUrl(env: Environment, useWebsocket?: boolean): string;
|
|
5
6
|
export declare function initClient({ env, version, apiKey, partnerId, useFetchAdapter, retrieveSessionCookie, persistSessionCookie, }: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getpara/core-sdk",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"types": "dist/types/index.d.ts",
|
|
@@ -40,5 +40,5 @@
|
|
|
40
40
|
"types": "./dist/types/index.d.ts"
|
|
41
41
|
}
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "89c777434a4854d895d96246fa2443a40b1c071d"
|
|
44
44
|
}
|