@getpara/core-sdk 2.0.0-alpha.63 → 2.0.0-alpha.65

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.
@@ -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-alpha.63";
46
+ const PARA_CORE_VERSION = "2.0.0-alpha.65";
47
47
  const PREFIX = "@CAPSULE/";
48
48
  const PARA_PREFIX = "@PARA/";
49
49
  const LOCAL_STORAGE_AUTH_INFO = `${PREFIX}authInfo`;
package/dist/cjs/index.js CHANGED
@@ -37,6 +37,8 @@ __export(src_exports, {
37
37
  EmailTheme: () => import_user_management_client.EmailTheme,
38
38
  KeyContainer: () => import_KeyContainer.KeyContainer,
39
39
  LINKED_ACCOUNT_TYPES: () => import_user_management_client.LINKED_ACCOUNT_TYPES,
40
+ LOCAL_STORAGE_CURRENT_WALLET_IDS: () => import_constants.LOCAL_STORAGE_CURRENT_WALLET_IDS,
41
+ LOCAL_STORAGE_WALLETS: () => import_constants.LOCAL_STORAGE_WALLETS,
40
42
  NON_ED25519: () => import_user_management_client.NON_ED25519,
41
43
  Network: () => import_user_management_client.Network,
42
44
  OAUTH_METHODS: () => import_user_management_client.OAUTH_METHODS,
@@ -85,6 +87,7 @@ __export(src_exports, {
85
87
  getSHA256HashHex: () => import_utils2.getSHA256HashHex,
86
88
  hashPasswordWithSalt: () => import_utils2.hashPasswordWithSalt,
87
89
  initClient: () => import_userManagementClient.initClient,
90
+ isPortal: () => import_utils.isPortal,
88
91
  isWalletSupported: () => import_wallet.isWalletSupported,
89
92
  mpcComputationClient: () => mpcComputationClient,
90
93
  paraVersion: () => paraVersion,
@@ -130,6 +133,8 @@ var src_default = import_ParaCore.ParaCore;
130
133
  EmailTheme,
131
134
  KeyContainer,
132
135
  LINKED_ACCOUNT_TYPES,
136
+ LOCAL_STORAGE_CURRENT_WALLET_IDS,
137
+ LOCAL_STORAGE_WALLETS,
133
138
  NON_ED25519,
134
139
  Network,
135
140
  OAUTH_METHODS,
@@ -177,6 +182,7 @@ var src_default = import_ParaCore.ParaCore;
177
182
  getSHA256HashHex,
178
183
  hashPasswordWithSalt,
179
184
  initClient,
185
+ isPortal,
180
186
  isWalletSupported,
181
187
  mpcComputationClient,
182
188
  paraVersion,
@@ -54,15 +54,16 @@ module.exports = __toCommonJS(transmissionUtils_exports);
54
54
  var import_ecies = require("@celo/utils/lib/ecies.js");
55
55
  var import_buffer = require("buffer");
56
56
  var eutil = __toESM(require("@ethereumjs/util"));
57
- var import_crypto = require("crypto");
58
57
  function upload(message, userManagementClient) {
59
58
  return __async(this, null, function* () {
60
59
  let secret;
61
60
  let publicKeyUint8Array;
62
61
  while (true) {
63
62
  try {
64
- secret = (0, import_crypto.randomBytes)(32).toString("hex");
65
- publicKeyUint8Array = eutil.privateToPublic(import_buffer.Buffer.from(secret, "hex"));
63
+ const privateKeyUint8Array = new Uint8Array(32);
64
+ crypto.getRandomValues(privateKeyUint8Array);
65
+ secret = import_buffer.Buffer.from(privateKeyUint8Array).toString("hex");
66
+ publicKeyUint8Array = eutil.privateToPublic(privateKeyUint8Array);
66
67
  break;
67
68
  } catch (e) {
68
69
  continue;
@@ -70,7 +70,9 @@ const PARA_CORE_METHODS = [
70
70
  "getWalletBalance",
71
71
  "issueJwt",
72
72
  "getLinkedAccounts",
73
- "accountLinkInProgress"
73
+ "accountLinkInProgress",
74
+ "addCredential",
75
+ "exportPrivateKey"
74
76
  ];
75
77
  const PARA_INTERNAL_METHODS = [
76
78
  "linkAccount",
@@ -82,7 +84,8 @@ const PARA_INTERNAL_METHODS = [
82
84
  "verifyExternalWalletLink",
83
85
  "accountLinkInProgress",
84
86
  "prepareLogin",
85
- "sendLoginCode"
87
+ "sendLoginCode",
88
+ "supportedUserAuthMethods"
86
89
  ];
87
90
  // Annotate the CommonJS export names for ESM import in node:
88
91
  0 && (module.exports = {
@@ -27,6 +27,7 @@ var PopupType = /* @__PURE__ */ ((PopupType2) => {
27
27
  PopupType2["CREATE_PASSKEY"] = "CREATE_PASSKEY";
28
28
  PopupType2["OAUTH"] = "OAUTH";
29
29
  PopupType2["ON_RAMP_TRANSACTION"] = "ON_RAMP_TRANSACTION";
30
+ PopupType2["EXPORT_PRIVATE_KEY"] = "EXPORT_PRIVATE_KEY";
30
31
  return PopupType2;
31
32
  })(PopupType || {});
32
33
  // Annotate the CommonJS export names for ESM import in node:
@@ -26,6 +26,7 @@ __reExport(utils_exports, require("./polling.js"), module.exports);
26
26
  __reExport(utils_exports, require("./types.js"), module.exports);
27
27
  __reExport(utils_exports, require("./url.js"), module.exports);
28
28
  __reExport(utils_exports, require("./wallet.js"), module.exports);
29
+ __reExport(utils_exports, require("./window.js"), module.exports);
29
30
  // Annotate the CommonJS export names for ESM import in node:
30
31
  0 && (module.exports = {
31
32
  ...require("./autobind.js"),
@@ -39,5 +40,6 @@ __reExport(utils_exports, require("./wallet.js"), module.exports);
39
40
  ...require("./polling.js"),
40
41
  ...require("./types.js"),
41
42
  ...require("./url.js"),
42
- ...require("./wallet.js")
43
+ ...require("./wallet.js"),
44
+ ...require("./window.js")
43
45
  });
@@ -45,6 +45,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
45
45
  var wallet_exports = {};
46
46
  __export(wallet_exports, {
47
47
  WalletSchemeTypeMap: () => WalletSchemeTypeMap,
48
+ currentWalletIdsEq: () => currentWalletIdsEq,
48
49
  entityToWallet: () => entityToWallet,
49
50
  getEquivalentTypes: () => getEquivalentTypes,
50
51
  getSchemes: () => getSchemes,
@@ -146,9 +147,23 @@ function mergeCurrentWalletIds(original, additional) {
146
147
  function newUuid() {
147
148
  return uuid.v4();
148
149
  }
150
+ function currentWalletIdsEq(a, b) {
151
+ if (!a && !b) return true;
152
+ if (!a || !b) return false;
153
+ const aKeys = Object.keys(a);
154
+ const bKeys = Object.keys(b);
155
+ if (aKeys.length !== bKeys.length) return false;
156
+ return aKeys.every((key) => {
157
+ var _a, _b;
158
+ const aIds = ((_a = a[key]) == null ? void 0 : _a.sort()) || [];
159
+ const bIds = ((_b = b[key]) == null ? void 0 : _b.sort()) || [];
160
+ return aIds.length === bIds.length && aIds.every((id, index) => id === bIds[index]);
161
+ });
162
+ }
149
163
  // Annotate the CommonJS export names for ESM import in node:
150
164
  0 && (module.exports = {
151
165
  WalletSchemeTypeMap,
166
+ currentWalletIdsEq,
152
167
  entityToWallet,
153
168
  getEquivalentTypes,
154
169
  getSchemes,
@@ -0,0 +1,38 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var window_exports = {};
19
+ __export(window_exports, {
20
+ isPortal: () => isPortal
21
+ });
22
+ module.exports = __toCommonJS(window_exports);
23
+ var import_url = require("./url.js");
24
+ function isPortal(ctx, env) {
25
+ var _a, _b;
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");
28
+ const isOnPortalDomain = (0, import_url.getPortalBaseURL)(env ? { env } : ctx).includes(normalizedUrl);
29
+ if (!isOnPortalDomain) return false;
30
+ const isInIframe = window.parent !== window && !window.opener;
31
+ const isInPopup = window.opener && window.parent === window;
32
+ const isDirectAccess = window.parent === window && !window.opener;
33
+ return isInIframe || isInPopup || isDirectAccess;
34
+ }
35
+ // Annotate the CommonJS export names for ESM import in node:
36
+ 0 && (module.exports = {
37
+ isPortal
38
+ });