@getpara/core-sdk 0.2.0 → 0.2.1

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.
@@ -73,7 +73,7 @@ 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
- const PARA_CORE_VERSION = '0.1.0';
76
+ const PARA_CORE_VERSION = '0.2.1';
77
77
  function dispatchEvent(type, data, error) {
78
78
  typeof window !== 'undefined' &&
79
79
  !!window.dispatchEvent &&
@@ -1719,7 +1719,7 @@ class ParaCore {
1719
1719
  yield this.logout();
1720
1720
  const res = yield this.touchSession(true);
1721
1721
  return constructUrl({
1722
- base: method === user_management_client_1.OAuthMethod.TELEGRAM ? (0, definitions_js_1.getPortalBaseURL)(this.ctx, true) : (0, userManagementClient_js_1.getBaseUrl)(this.ctx.env),
1722
+ 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
1723
  path: `/auth/${method.toLowerCase()}`,
1724
1724
  params: {
1725
1725
  apiKey: this.ctx.apiKey,
@@ -1751,7 +1751,7 @@ class ParaCore {
1751
1751
  const { userId, email } = res.data;
1752
1752
  yield this.setUserId(userId);
1753
1753
  yield this.setEmail(email);
1754
- const userExists = yield this.checkIfUserExists(email);
1754
+ const userExists = yield this.checkIfUserExists({ email });
1755
1755
  this.isAwaitingOAuth = false;
1756
1756
  return {
1757
1757
  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:
@@ -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 { getBaseUrl, initClient } from './external/userManagementClient.js';
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,7 @@ 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
- const PARA_CORE_VERSION = '0.1.0';
47
+ const PARA_CORE_VERSION = '0.2.1';
48
48
  function dispatchEvent(type, data, error) {
49
49
  typeof window !== 'undefined' &&
50
50
  !!window.dispatchEvent &&
@@ -1683,7 +1683,7 @@ export class ParaCore {
1683
1683
  yield this.logout();
1684
1684
  const res = yield this.touchSession(true);
1685
1685
  return constructUrl({
1686
- base: method === OAuthMethod.TELEGRAM ? getPortalBaseURL(this.ctx, true) : getBaseUrl(this.ctx.env),
1686
+ base: method === OAuthMethod.TELEGRAM ? getPortalBaseURL(this.ctx, true) : getBaseOAuthUrl(this.ctx.env),
1687
1687
  path: `/auth/${method.toLowerCase()}`,
1688
1688
  params: {
1689
1689
  apiKey: this.ctx.apiKey,
@@ -1715,7 +1715,7 @@ export class ParaCore {
1715
1715
  const { userId, email } = res.data;
1716
1716
  yield this.setUserId(userId);
1717
1717
  yield this.setEmail(email);
1718
- const userExists = yield this.checkIfUserExists(email);
1718
+ const userExists = yield this.checkIfUserExists({ email });
1719
1719
  this.isAwaitingOAuth = false;
1720
1720
  return {
1721
1721
  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.0",
3
+ "version": "0.2.1",
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": "9e28f35ede16f3627aeb5baebdf26dae03fa4dcf"
43
+ "gitHead": "dd8c9463981f7dd563f6c925c370c7054ca74adf"
44
44
  }