@getpara/core-sdk 2.0.0-alpha.7 → 2.0.0-alpha.71

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.
Files changed (66) hide show
  1. package/dist/cjs/ParaCore.js +1516 -382
  2. package/dist/cjs/constants.js +13 -1
  3. package/dist/cjs/index.js +35 -3
  4. package/dist/cjs/shares/KeyContainer.js +3 -3
  5. package/dist/cjs/shares/enclave.js +266 -0
  6. package/dist/cjs/shares/shareDistribution.js +16 -1
  7. package/dist/cjs/transmission/transmissionUtils.js +4 -3
  8. package/dist/cjs/types/{theme.js → assets.js} +2 -2
  9. package/dist/cjs/types/{onRamps.js → auth.js} +12 -12
  10. package/dist/cjs/types/coreApi.js +23 -3
  11. package/dist/cjs/types/events.js +2 -0
  12. package/dist/cjs/types/index.js +2 -21
  13. package/dist/cjs/types/popup.js +1 -0
  14. package/dist/cjs/utils/config.js +108 -0
  15. package/dist/cjs/utils/formatting.js +4 -0
  16. package/dist/cjs/utils/index.js +5 -1
  17. package/dist/cjs/utils/onRamps.js +2 -3
  18. package/dist/cjs/utils/wallet.js +18 -0
  19. package/dist/cjs/{types/recovery.js → utils/window.js} +17 -13
  20. package/dist/esm/ParaCore.js +1525 -388
  21. package/dist/esm/constants.js +9 -1
  22. package/dist/esm/index.js +36 -5
  23. package/dist/esm/shares/KeyContainer.js +3 -3
  24. package/dist/esm/shares/enclave.js +226 -0
  25. package/dist/esm/shares/shareDistribution.js +16 -1
  26. package/dist/esm/transmission/transmissionUtils.js +4 -3
  27. package/dist/esm/types/auth.js +11 -0
  28. package/dist/esm/types/coreApi.js +21 -2
  29. package/dist/esm/types/events.js +2 -0
  30. package/dist/esm/types/index.js +1 -16
  31. package/dist/esm/types/popup.js +1 -0
  32. package/dist/esm/utils/config.js +86 -0
  33. package/dist/esm/utils/formatting.js +2 -0
  34. package/dist/esm/utils/index.js +2 -0
  35. package/dist/esm/utils/onRamps.js +2 -3
  36. package/dist/esm/utils/wallet.js +17 -0
  37. package/dist/esm/utils/window.js +16 -0
  38. package/dist/types/ParaCore.d.ts +142 -57
  39. package/dist/types/PlatformUtils.d.ts +2 -3
  40. package/dist/types/constants.d.ts +18 -14
  41. package/dist/types/index.d.ts +6 -4
  42. package/dist/types/shares/KeyContainer.d.ts +0 -2
  43. package/dist/types/shares/enclave.d.ts +81 -0
  44. package/dist/types/shares/shareDistribution.d.ts +4 -2
  45. package/dist/types/types/assets.d.ts +14 -0
  46. package/dist/types/types/auth.d.ts +16 -0
  47. package/dist/types/types/config.d.ts +11 -2
  48. package/dist/types/types/coreApi.d.ts +133 -37
  49. package/dist/types/types/events.d.ts +7 -2
  50. package/dist/types/types/index.d.ts +1 -4
  51. package/dist/types/types/methods.d.ts +94 -15
  52. package/dist/types/types/popup.d.ts +2 -1
  53. package/dist/types/types/wallet.d.ts +11 -4
  54. package/dist/types/utils/config.d.ts +7 -0
  55. package/dist/types/utils/formatting.d.ts +2 -0
  56. package/dist/types/utils/index.d.ts +2 -0
  57. package/dist/types/utils/onRamps.d.ts +9 -10
  58. package/dist/types/utils/wallet.d.ts +1 -0
  59. package/dist/types/utils/window.d.ts +2 -0
  60. package/package.json +23 -23
  61. package/dist/esm/types/onRamps.js +0 -11
  62. package/dist/esm/types/recovery.js +0 -12
  63. package/dist/types/types/onRamps.d.ts +0 -10
  64. package/dist/types/types/recovery.d.ts +0 -7
  65. package/dist/types/types/theme.d.ts +0 -12
  66. /package/dist/esm/types/{theme.js → assets.js} +0 -0
@@ -2,10 +2,6 @@ var __defProp = Object.defineProperty;
2
2
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
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
5
  var __copyProps = (to, from, except, desc) => {
10
6
  if (from && typeof from === "object" || typeof from === "function") {
11
7
  for (let key of __getOwnPropNames(from))
@@ -17,36 +13,21 @@ var __copyProps = (to, from, except, desc) => {
17
13
  var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
18
14
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
15
  var types_exports = {};
20
- __export(types_exports, {
21
- Network: () => import_user_management_client.Network,
22
- OnRampAsset: () => import_user_management_client.OnRampAsset,
23
- OnRampProvider: () => import_user_management_client.OnRampProvider,
24
- OnRampPurchaseStatus: () => import_user_management_client.OnRampPurchaseStatus
25
- });
26
16
  module.exports = __toCommonJS(types_exports);
17
+ __reExport(types_exports, require("./auth.js"), module.exports);
27
18
  __reExport(types_exports, require("./config.js"), module.exports);
28
19
  __reExport(types_exports, require("./coreApi.js"), module.exports);
29
20
  __reExport(types_exports, require("./wallet.js"), module.exports);
30
21
  __reExport(types_exports, require("./methods.js"), module.exports);
31
- __reExport(types_exports, require("./theme.js"), module.exports);
32
- __reExport(types_exports, require("./onRamps.js"), module.exports);
33
22
  __reExport(types_exports, require("./popup.js"), module.exports);
34
- __reExport(types_exports, require("./recovery.js"), module.exports);
35
23
  __reExport(types_exports, require("./events.js"), module.exports);
36
- var import_user_management_client = require("@getpara/user-management-client");
37
24
  // Annotate the CommonJS export names for ESM import in node:
38
25
  0 && (module.exports = {
39
- Network,
40
- OnRampAsset,
41
- OnRampProvider,
42
- OnRampPurchaseStatus,
26
+ ...require("./auth.js"),
43
27
  ...require("./config.js"),
44
28
  ...require("./coreApi.js"),
45
29
  ...require("./wallet.js"),
46
30
  ...require("./methods.js"),
47
- ...require("./theme.js"),
48
- ...require("./onRamps.js"),
49
31
  ...require("./popup.js"),
50
- ...require("./recovery.js"),
51
32
  ...require("./events.js")
52
33
  });
@@ -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:
@@ -0,0 +1,108 @@
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 config_exports = {};
19
+ __export(config_exports, {
20
+ validateBalancesConfig: () => validateBalancesConfig
21
+ });
22
+ module.exports = __toCommonJS(config_exports);
23
+ var import_user_management_client = require("@getpara/user-management-client");
24
+ function validateBalancesConfig(obj) {
25
+ if (!obj || typeof obj !== "object") {
26
+ return false;
27
+ }
28
+ if (!obj.displayType || obj.displayType !== "AGGREGATED" && obj.displayType !== "CUSTOM_ASSET") {
29
+ return false;
30
+ }
31
+ if (obj.displayType === "AGGREGATED") {
32
+ if (obj.excludeStandardAssets !== void 0 && typeof obj.excludeStandardAssets !== "boolean") {
33
+ return false;
34
+ }
35
+ if (obj.additionalAssets !== void 0) {
36
+ if (!Array.isArray(obj.additionalAssets)) {
37
+ return false;
38
+ }
39
+ for (const asset of obj.additionalAssets) {
40
+ if (!validateCustomAsset(asset)) {
41
+ return false;
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
+ }
52
+ }
53
+ return true;
54
+ }
55
+ if (obj.displayType === "CUSTOM_ASSET") {
56
+ if (!obj.asset) {
57
+ return false;
58
+ }
59
+ if (!validateCustomAsset(obj.asset)) {
60
+ return false;
61
+ }
62
+ const hasPriceUrl = typeof obj.asset.priceUrl === "string" && obj.asset.priceUrl.trim();
63
+ const hasPrice = obj.asset.price && typeof obj.asset.price === "object" && typeof obj.asset.price.value === "number" && obj.asset.price.value > 0 && typeof obj.asset.price.currency === "string" && obj.asset.price.currency.trim();
64
+ if (hasPriceUrl && hasPrice) {
65
+ return false;
66
+ }
67
+ return true;
68
+ }
69
+ return false;
70
+ }
71
+ function validateCustomAsset(obj) {
72
+ if (!obj || typeof obj !== "object") {
73
+ return false;
74
+ }
75
+ if (typeof obj.name !== "string" || !obj.name.trim() || typeof obj.symbol !== "string" || !obj.symbol.trim()) {
76
+ return false;
77
+ }
78
+ if (!Array.isArray(obj.implementations) || obj.implementations.length === 0) {
79
+ return false;
80
+ }
81
+ for (const network of obj.implementations) {
82
+ if (!network || typeof network !== "object") {
83
+ return false;
84
+ }
85
+ if (typeof network.network === "string") {
86
+ if (!import_user_management_client.NETWORKS.includes(network.network)) {
87
+ return false;
88
+ }
89
+ if (typeof network.contractAddress !== "string" || !network.contractAddress.trim()) {
90
+ return false;
91
+ }
92
+ } else if (typeof network.network === "object") {
93
+ if (typeof network.network.name !== "string" || !network.network.name.trim() || typeof network.network.rpcUrl !== "string" || !network.network.rpcUrl.trim() || typeof network.network.evmChainId !== "string" || !network.network.evmChainId.trim()) {
94
+ return false;
95
+ }
96
+ if (network.contractAddress !== void 0 && (typeof network.contractAddress !== "string" || !network.contractAddress.trim())) {
97
+ return false;
98
+ }
99
+ } else {
100
+ return false;
101
+ }
102
+ }
103
+ return true;
104
+ }
105
+ // Annotate the CommonJS export names for ESM import in node:
106
+ 0 && (module.exports = {
107
+ validateBalancesConfig
108
+ });
@@ -27,12 +27,14 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
27
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
28
  var formatting_exports = {};
29
29
  __export(formatting_exports, {
30
+ compressPubkey: () => compressPubkey,
30
31
  decimalToHex: () => decimalToHex,
31
32
  getCosmosAddress: () => getCosmosAddress,
32
33
  hexStringToBase64: () => hexStringToBase64,
33
34
  hexToDecimal: () => hexToDecimal,
34
35
  hexToSignature: () => hexToSignature,
35
36
  hexToUint8Array: () => hexToUint8Array,
37
+ rawSecp256k1PubkeyToRawAddress: () => rawSecp256k1PubkeyToRawAddress,
36
38
  truncateAddress: () => truncateAddress
37
39
  });
38
40
  module.exports = __toCommonJS(formatting_exports);
@@ -102,11 +104,13 @@ function truncateAddress(str, addressType, {
102
104
  }
103
105
  // Annotate the CommonJS export names for ESM import in node:
104
106
  0 && (module.exports = {
107
+ compressPubkey,
105
108
  decimalToHex,
106
109
  getCosmosAddress,
107
110
  hexStringToBase64,
108
111
  hexToDecimal,
109
112
  hexToSignature,
110
113
  hexToUint8Array,
114
+ rawSecp256k1PubkeyToRawAddress,
111
115
  truncateAddress
112
116
  });
@@ -15,6 +15,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
15
15
  var utils_exports = {};
16
16
  module.exports = __toCommonJS(utils_exports);
17
17
  __reExport(utils_exports, require("./autobind.js"), module.exports);
18
+ __reExport(utils_exports, require("./config.js"), module.exports);
18
19
  __reExport(utils_exports, require("./events.js"), module.exports);
19
20
  __reExport(utils_exports, require("./formatting.js"), module.exports);
20
21
  __reExport(utils_exports, require("./json.js"), module.exports);
@@ -25,9 +26,11 @@ __reExport(utils_exports, require("./polling.js"), module.exports);
25
26
  __reExport(utils_exports, require("./types.js"), module.exports);
26
27
  __reExport(utils_exports, require("./url.js"), module.exports);
27
28
  __reExport(utils_exports, require("./wallet.js"), module.exports);
29
+ __reExport(utils_exports, require("./window.js"), module.exports);
28
30
  // Annotate the CommonJS export names for ESM import in node:
29
31
  0 && (module.exports = {
30
32
  ...require("./autobind.js"),
33
+ ...require("./config.js"),
31
34
  ...require("./events.js"),
32
35
  ...require("./formatting.js"),
33
36
  ...require("./json.js"),
@@ -37,5 +40,6 @@ __reExport(utils_exports, require("./wallet.js"), module.exports);
37
40
  ...require("./polling.js"),
38
41
  ...require("./types.js"),
39
42
  ...require("./url.js"),
40
- ...require("./wallet.js")
43
+ ...require("./wallet.js"),
44
+ ...require("./window.js")
41
45
  });
@@ -24,7 +24,6 @@ __export(onRamps_exports, {
24
24
  toAssetInfoArray: () => toAssetInfoArray
25
25
  });
26
26
  module.exports = __toCommonJS(onRamps_exports);
27
- var import_user_management_client = require("@getpara/user-management-client");
28
27
  function toAssetInfoArray(data) {
29
28
  const result = [];
30
29
  Object.keys(data).forEach((walletType) => {
@@ -76,8 +75,8 @@ function getOnRampAssets(data, {
76
75
  ];
77
76
  }
78
77
  const NETWORK_PREFIXES = {
79
- [import_user_management_client.Network.COSMOS]: "cosmos",
80
- [import_user_management_client.Network.NOBLE]: "noble"
78
+ COSMOS: "cosmos",
79
+ NOBLE: "noble"
81
80
  };
82
81
  function getNetworkPrefix(network) {
83
82
  return NETWORK_PREFIXES[network];
@@ -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,
@@ -114,7 +115,10 @@ function getEquivalentTypes(types) {
114
115
  return getWalletTypes(getSchemes(Array.isArray(types) ? types : [types]));
115
116
  }
116
117
  function entityToWallet(w) {
118
+ var _a;
117
119
  return __spreadProps(__spreadValues({}, w), {
120
+ createdAt: typeof w.createdAt === "string" ? w.createdAt : w.createdAt.toISOString(),
121
+ lastUsedAt: typeof w.lastUsedAt === "string" ? w.lastUsedAt : (_a = w.lastUsedAt) == null ? void 0 : _a.toISOString(),
118
122
  scheme: w.scheme,
119
123
  type: w.type,
120
124
  pregenIdentifierType: w.pregenIdentifierType
@@ -143,9 +147,23 @@ function mergeCurrentWalletIds(original, additional) {
143
147
  function newUuid() {
144
148
  return uuid.v4();
145
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
+ }
146
163
  // Annotate the CommonJS export names for ESM import in node:
147
164
  0 && (module.exports = {
148
165
  WalletSchemeTypeMap,
166
+ currentWalletIdsEq,
149
167
  entityToWallet,
150
168
  getEquivalentTypes,
151
169
  getSchemes,
@@ -15,20 +15,24 @@ var __copyProps = (to, from, except, desc) => {
15
15
  return to;
16
16
  };
17
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
- var recovery_exports = {};
19
- __export(recovery_exports, {
20
- RecoveryStatus: () => RecoveryStatus
18
+ var window_exports = {};
19
+ __export(window_exports, {
20
+ isPortal: () => isPortal
21
21
  });
22
- module.exports = __toCommonJS(recovery_exports);
23
- var RecoveryStatus = /* @__PURE__ */ ((RecoveryStatus2) => {
24
- RecoveryStatus2["INITIATED"] = "INITIATED";
25
- RecoveryStatus2["READY"] = "READY";
26
- RecoveryStatus2["EXPIRED"] = "EXPIRED";
27
- RecoveryStatus2["FINISHED"] = "FINISHED";
28
- RecoveryStatus2["CANCELLED"] = "CANCELLED";
29
- return RecoveryStatus2;
30
- })(RecoveryStatus || {});
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
+ }
31
35
  // Annotate the CommonJS export names for ESM import in node:
32
36
  0 && (module.exports = {
33
- RecoveryStatus
37
+ isPortal
34
38
  });