@getpara/core-sdk 1.8.0 → 2.0.0-alpha.3
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/index.js +4000 -76
- package/dist/cjs/index.js.br +0 -0
- package/dist/cjs/index.js.gz +0 -0
- package/dist/esm/index.js +3964 -53
- package/dist/esm/index.js.br +0 -0
- package/dist/esm/index.js.gz +0 -0
- package/dist/types/ParaCore.d.ts +178 -489
- package/dist/types/constants.d.ts +2 -1
- package/dist/types/external/userManagementClient.d.ts +1 -1
- package/dist/types/index.d.ts +5 -3
- package/dist/types/types/config.d.ts +1 -19
- package/dist/types/types/coreApi.d.ts +437 -0
- package/dist/types/types/index.d.ts +2 -1
- package/dist/types/types/methods.d.ts +143 -0
- package/dist/types/types/wallet.d.ts +2 -4
- package/dist/types/utils/autobind.d.ts +1 -0
- package/dist/types/utils/formatting.d.ts +0 -2
- package/dist/types/utils/index.d.ts +5 -0
- package/dist/types/utils/json.d.ts +1 -0
- package/dist/types/utils/phone.d.ts +7 -0
- package/dist/types/utils/types.d.ts +2 -0
- package/dist/types/utils/url.d.ts +2 -1
- package/dist/types/utils/wallet.d.ts +4 -2
- package/package.json +6 -5
- package/dist/cjs/ParaCore.js +0 -2964
- package/dist/cjs/PlatformUtils.js +0 -15
- package/dist/cjs/StorageUtils.js +0 -15
- package/dist/cjs/constants.js +0 -75
- package/dist/cjs/cryptography/utils.js +0 -350
- package/dist/cjs/errors.js +0 -51
- package/dist/cjs/external/mpcComputationClient.js +0 -62
- package/dist/cjs/external/userManagementClient.js +0 -106
- package/dist/cjs/package.json +0 -3
- package/dist/cjs/shares/KeyContainer.js +0 -89
- package/dist/cjs/shares/recovery.js +0 -127
- package/dist/cjs/shares/shareDistribution.js +0 -104
- package/dist/cjs/transmission/transmissionUtils.js +0 -93
- package/dist/cjs/types/config.js +0 -43
- package/dist/cjs/types/events.js +0 -40
- package/dist/cjs/types/index.js +0 -50
- package/dist/cjs/types/onRamps.js +0 -33
- package/dist/cjs/types/params.js +0 -15
- package/dist/cjs/types/popup.js +0 -35
- package/dist/cjs/types/recovery.js +0 -34
- package/dist/cjs/types/theme.js +0 -15
- package/dist/cjs/types/wallet.js +0 -31
- package/dist/cjs/utils/events.js +0 -45
- package/dist/cjs/utils/formatting.js +0 -120
- package/dist/cjs/utils/index.js +0 -31
- package/dist/cjs/utils/listeners.js +0 -80
- package/dist/cjs/utils/onRamps.js +0 -64
- package/dist/cjs/utils/polling.js +0 -58
- package/dist/cjs/utils/url.js +0 -103
- package/dist/cjs/utils/wallet.js +0 -130
- package/dist/esm/ParaCore.js +0 -2913
- package/dist/esm/PlatformUtils.js +0 -0
- package/dist/esm/StorageUtils.js +0 -0
- package/dist/esm/chunk-UICEQADR.js +0 -68
- package/dist/esm/constants.js +0 -37
- package/dist/esm/cryptography/utils.js +0 -282
- package/dist/esm/errors.js +0 -27
- package/dist/esm/external/mpcComputationClient.js +0 -30
- package/dist/esm/external/userManagementClient.js +0 -71
- package/dist/esm/package.json +0 -4
- package/dist/esm/shares/KeyContainer.js +0 -57
- package/dist/esm/shares/recovery.js +0 -74
- package/dist/esm/shares/shareDistribution.js +0 -64
- package/dist/esm/transmission/transmissionUtils.js +0 -42
- package/dist/esm/types/config.js +0 -20
- package/dist/esm/types/events.js +0 -18
- package/dist/esm/types/index.js +0 -21
- package/dist/esm/types/onRamps.js +0 -11
- package/dist/esm/types/params.js +0 -0
- package/dist/esm/types/popup.js +0 -13
- package/dist/esm/types/recovery.js +0 -12
- package/dist/esm/types/theme.js +0 -0
- package/dist/esm/types/wallet.js +0 -9
- package/dist/esm/utils/events.js +0 -11
- package/dist/esm/utils/formatting.js +0 -80
- package/dist/esm/utils/index.js +0 -6
- package/dist/esm/utils/listeners.js +0 -47
- package/dist/esm/utils/onRamps.js +0 -40
- package/dist/esm/utils/polling.js +0 -18
- package/dist/esm/utils/url.js +0 -77
- package/dist/esm/utils/wallet.js +0 -87
- package/dist/types/types/params.d.ts +0 -70
package/dist/cjs/types/theme.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __copyProps = (to, from, except, desc) => {
|
|
6
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
-
for (let key of __getOwnPropNames(from))
|
|
8
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
-
}
|
|
11
|
-
return to;
|
|
12
|
-
};
|
|
13
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
14
|
-
var theme_exports = {};
|
|
15
|
-
module.exports = __toCommonJS(theme_exports);
|
package/dist/cjs/types/wallet.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
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 wallet_exports = {};
|
|
19
|
-
__export(wallet_exports, {
|
|
20
|
-
PregenIdentifierType: () => PregenIdentifierType
|
|
21
|
-
});
|
|
22
|
-
module.exports = __toCommonJS(wallet_exports);
|
|
23
|
-
var PregenIdentifierType = /* @__PURE__ */ ((PregenIdentifierType2) => {
|
|
24
|
-
PregenIdentifierType2["EMAIL"] = "EMAIL";
|
|
25
|
-
PregenIdentifierType2["PHONE"] = "PHONE";
|
|
26
|
-
return PregenIdentifierType2;
|
|
27
|
-
})(PregenIdentifierType || {});
|
|
28
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
29
|
-
0 && (module.exports = {
|
|
30
|
-
PregenIdentifierType
|
|
31
|
-
});
|
package/dist/cjs/utils/events.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
-
var __spreadValues = (a, b) => {
|
|
9
|
-
for (var prop in b || (b = {}))
|
|
10
|
-
if (__hasOwnProp.call(b, prop))
|
|
11
|
-
__defNormalProp(a, prop, b[prop]);
|
|
12
|
-
if (__getOwnPropSymbols)
|
|
13
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
-
if (__propIsEnum.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
}
|
|
17
|
-
return a;
|
|
18
|
-
};
|
|
19
|
-
var __export = (target, all) => {
|
|
20
|
-
for (var name in all)
|
|
21
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
22
|
-
};
|
|
23
|
-
var __copyProps = (to, from, except, desc) => {
|
|
24
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
25
|
-
for (let key of __getOwnPropNames(from))
|
|
26
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
27
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
28
|
-
}
|
|
29
|
-
return to;
|
|
30
|
-
};
|
|
31
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
32
|
-
var events_exports = {};
|
|
33
|
-
__export(events_exports, {
|
|
34
|
-
dispatchEvent: () => dispatchEvent
|
|
35
|
-
});
|
|
36
|
-
module.exports = __toCommonJS(events_exports);
|
|
37
|
-
function dispatchEvent(type, data, error) {
|
|
38
|
-
typeof window !== "undefined" && !!window.dispatchEvent && window.dispatchEvent(
|
|
39
|
-
new CustomEvent(type, { detail: __spreadValues({ data }, error && { error: new Error(error) }) })
|
|
40
|
-
);
|
|
41
|
-
}
|
|
42
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
43
|
-
0 && (module.exports = {
|
|
44
|
-
dispatchEvent
|
|
45
|
-
});
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
var formatting_exports = {};
|
|
29
|
-
__export(formatting_exports, {
|
|
30
|
-
decimalToHex: () => decimalToHex,
|
|
31
|
-
getCosmosAddress: () => getCosmosAddress,
|
|
32
|
-
hexStringToBase64: () => hexStringToBase64,
|
|
33
|
-
hexToDecimal: () => hexToDecimal,
|
|
34
|
-
hexToSignature: () => hexToSignature,
|
|
35
|
-
hexToUint8Array: () => hexToUint8Array,
|
|
36
|
-
normalizePhoneNumber: () => normalizePhoneNumber,
|
|
37
|
-
stringToPhoneNumber: () => stringToPhoneNumber,
|
|
38
|
-
truncateAddress: () => truncateAddress
|
|
39
|
-
});
|
|
40
|
-
module.exports = __toCommonJS(formatting_exports);
|
|
41
|
-
var import_encoding = require("@cosmjs/encoding");
|
|
42
|
-
var import_sha256 = require("@noble/hashes/sha256");
|
|
43
|
-
var import_ripemd160 = require("@noble/hashes/ripemd160");
|
|
44
|
-
var import_elliptic = __toESM(require("elliptic"));
|
|
45
|
-
var import_libphonenumber_js = __toESM(require("libphonenumber-js"));
|
|
46
|
-
const secp256k1 = new import_elliptic.default.ec("secp256k1");
|
|
47
|
-
function hexStringToBase64(hexString) {
|
|
48
|
-
if (hexString.substring(0, 2) === "0x") {
|
|
49
|
-
hexString = hexString.substring(2);
|
|
50
|
-
}
|
|
51
|
-
return Buffer.from(hexString, "hex").toString("base64");
|
|
52
|
-
}
|
|
53
|
-
function hexToSignature(hexSig) {
|
|
54
|
-
return {
|
|
55
|
-
r: `0x${hexSig.slice(2, 66)}`,
|
|
56
|
-
s: `0x${hexSig.slice(66, 130)}`,
|
|
57
|
-
v: BigInt(hexSig.slice(130, 132))
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
function hexToUint8Array(hex) {
|
|
61
|
-
if (hex.startsWith("0x")) {
|
|
62
|
-
hex = hex.slice(2);
|
|
63
|
-
}
|
|
64
|
-
return new Uint8Array(Buffer.from(hex, "hex"));
|
|
65
|
-
}
|
|
66
|
-
function hexToDecimal(hex) {
|
|
67
|
-
if (hex.startsWith("0x")) {
|
|
68
|
-
hex = hex.slice(2);
|
|
69
|
-
}
|
|
70
|
-
return `${parseInt(hex, 16)}`;
|
|
71
|
-
}
|
|
72
|
-
function decimalToHex(decimal) {
|
|
73
|
-
return `0x${parseInt(decimal).toString(16)}`;
|
|
74
|
-
}
|
|
75
|
-
function compressPubkey(pubkey) {
|
|
76
|
-
switch (pubkey.length) {
|
|
77
|
-
case 33:
|
|
78
|
-
return pubkey;
|
|
79
|
-
case 65:
|
|
80
|
-
return Uint8Array.from(secp256k1.keyFromPublic(pubkey).getPublic(true, "array"));
|
|
81
|
-
default:
|
|
82
|
-
throw new Error("Invalid pubkey length");
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
function rawSecp256k1PubkeyToRawAddress(pubkeyData) {
|
|
86
|
-
if (pubkeyData.length !== 33) {
|
|
87
|
-
throw new Error(`Invalid Secp256k1 pubkey length (compressed): ${pubkeyData.length}`);
|
|
88
|
-
}
|
|
89
|
-
return (0, import_ripemd160.ripemd160)((0, import_sha256.sha256)(pubkeyData));
|
|
90
|
-
}
|
|
91
|
-
function getCosmosAddress(publicKey, prefix) {
|
|
92
|
-
const uncompressedPublicKey = new Uint8Array(
|
|
93
|
-
Buffer.from(publicKey.startsWith("0x") ? publicKey.slice(2) : publicKey, "hex")
|
|
94
|
-
);
|
|
95
|
-
const compressedPublicKey = compressPubkey(uncompressedPublicKey);
|
|
96
|
-
return (0, import_encoding.toBech32)(prefix, rawSecp256k1PubkeyToRawAddress(compressedPublicKey));
|
|
97
|
-
}
|
|
98
|
-
function truncateAddress(str, addressType, { prefix = addressType === "COSMOS" ? "cosmos" : void 0 } = {}) {
|
|
99
|
-
const headLength = (addressType === "COSMOS" ? prefix.length : addressType === "SOLANA" ? 0 : 2) + 4;
|
|
100
|
-
return `${str.slice(0, headLength)}...${str.slice(-4)}`;
|
|
101
|
-
}
|
|
102
|
-
function stringToPhoneNumber(str) {
|
|
103
|
-
var _a;
|
|
104
|
-
return (_a = (0, import_libphonenumber_js.default)(str)) == null ? void 0 : _a.formatInternational().replace(/[^\d+]/g, "");
|
|
105
|
-
}
|
|
106
|
-
function normalizePhoneNumber(countryCode, number) {
|
|
107
|
-
return stringToPhoneNumber(`${countryCode[0] !== "+" ? "+" : ""}${countryCode}${number}`);
|
|
108
|
-
}
|
|
109
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
110
|
-
0 && (module.exports = {
|
|
111
|
-
decimalToHex,
|
|
112
|
-
getCosmosAddress,
|
|
113
|
-
hexStringToBase64,
|
|
114
|
-
hexToDecimal,
|
|
115
|
-
hexToSignature,
|
|
116
|
-
hexToUint8Array,
|
|
117
|
-
normalizePhoneNumber,
|
|
118
|
-
stringToPhoneNumber,
|
|
119
|
-
truncateAddress
|
|
120
|
-
});
|
package/dist/cjs/utils/index.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __copyProps = (to, from, except, desc) => {
|
|
6
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
-
for (let key of __getOwnPropNames(from))
|
|
8
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
-
}
|
|
11
|
-
return to;
|
|
12
|
-
};
|
|
13
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
14
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
-
var utils_exports = {};
|
|
16
|
-
module.exports = __toCommonJS(utils_exports);
|
|
17
|
-
__reExport(utils_exports, require("./events.js"), module.exports);
|
|
18
|
-
__reExport(utils_exports, require("./formatting.js"), module.exports);
|
|
19
|
-
__reExport(utils_exports, require("./onRamps.js"), module.exports);
|
|
20
|
-
__reExport(utils_exports, require("./polling.js"), module.exports);
|
|
21
|
-
__reExport(utils_exports, require("./url.js"), module.exports);
|
|
22
|
-
__reExport(utils_exports, require("./wallet.js"), module.exports);
|
|
23
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
24
|
-
0 && (module.exports = {
|
|
25
|
-
...require("./events.js"),
|
|
26
|
-
...require("./formatting.js"),
|
|
27
|
-
...require("./onRamps.js"),
|
|
28
|
-
...require("./polling.js"),
|
|
29
|
-
...require("./url.js"),
|
|
30
|
-
...require("./wallet.js")
|
|
31
|
-
});
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
var listeners_exports = {};
|
|
29
|
-
__export(listeners_exports, {
|
|
30
|
-
setupListeners: () => setupListeners,
|
|
31
|
-
storageListener: () => storageListener
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(listeners_exports);
|
|
34
|
-
var constants = __toESM(require("../constants.js"));
|
|
35
|
-
function storageListener(e) {
|
|
36
|
-
if (!e.url.includes(window.location.origin)) {
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
if (e.key === constants.LOCAL_STORAGE_EXTERNAL_WALLETS) {
|
|
40
|
-
this.updateExternalWalletsFromStorage();
|
|
41
|
-
}
|
|
42
|
-
if (e.key === constants.SESSION_STORAGE_LOGIN_ENCRYPTION_KEY_PAIR) {
|
|
43
|
-
this.updateLoginEncryptionKeyPairFromStorage();
|
|
44
|
-
}
|
|
45
|
-
if (e.key === constants.LOCAL_STORAGE_SESSION_COOKIE) {
|
|
46
|
-
this.updateSessionCookieFromStorage();
|
|
47
|
-
}
|
|
48
|
-
if (e.key === constants.LOCAL_STORAGE_CURRENT_WALLET_IDS) {
|
|
49
|
-
this.updateWalletIdsFromStorage();
|
|
50
|
-
}
|
|
51
|
-
if (e.key === constants.LOCAL_STORAGE_WALLETS || e.key === constants.LOCAL_STORAGE_ED25519_WALLETS) {
|
|
52
|
-
this.updateWalletsFromStorage();
|
|
53
|
-
}
|
|
54
|
-
if (e.key === constants.LOCAL_STORAGE_EMAIL) {
|
|
55
|
-
this.updateEmailFromStorage();
|
|
56
|
-
}
|
|
57
|
-
if (e.key === constants.LOCAL_STORAGE_COUNTRY_CODE) {
|
|
58
|
-
this.updateCountryCodeFromStorage();
|
|
59
|
-
}
|
|
60
|
-
if (e.key === constants.LOCAL_STORAGE_PHONE) {
|
|
61
|
-
this.updatePhoneFromStorage();
|
|
62
|
-
}
|
|
63
|
-
if (e.key === constants.LOCAL_STORAGE_USER_ID) {
|
|
64
|
-
this.updateUserIdFromStorage();
|
|
65
|
-
}
|
|
66
|
-
if (e.key === constants.LOCAL_STORAGE_TELEGRAM_USER_ID) {
|
|
67
|
-
this.updateTelegramUserIdFromStorage();
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
function setupListeners() {
|
|
71
|
-
if (typeof window !== "undefined" && window.addEventListener && window.location) {
|
|
72
|
-
window.removeEventListener("storage", storageListener.bind(this));
|
|
73
|
-
window.addEventListener("storage", storageListener.bind(this));
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
77
|
-
0 && (module.exports = {
|
|
78
|
-
setupListeners,
|
|
79
|
-
storageListener
|
|
80
|
-
});
|
|
@@ -1,64 +0,0 @@
|
|
|
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 onRamps_exports = {};
|
|
19
|
-
__export(onRamps_exports, {
|
|
20
|
-
getOnRampAssets: () => getOnRampAssets,
|
|
21
|
-
getOnRampNetworks: () => getOnRampNetworks,
|
|
22
|
-
toAssetInfoArray: () => toAssetInfoArray
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(onRamps_exports);
|
|
25
|
-
function toAssetInfoArray(data) {
|
|
26
|
-
const result = [];
|
|
27
|
-
Object.keys(data).forEach((walletType) => {
|
|
28
|
-
const networks = data[walletType];
|
|
29
|
-
Object.keys(networks).forEach((network) => {
|
|
30
|
-
const assets = networks[network];
|
|
31
|
-
Object.keys(assets).forEach((asset) => {
|
|
32
|
-
const providerInfo = assets[asset];
|
|
33
|
-
result.push([walletType, network, asset, providerInfo]);
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
return result;
|
|
38
|
-
}
|
|
39
|
-
function getOnRampNetworks(data, { walletType, allowed } = {}) {
|
|
40
|
-
return [
|
|
41
|
-
...new Set(
|
|
42
|
-
toAssetInfoArray(data).filter(([type, network]) => (!walletType || type === walletType) && (!allowed || allowed.includes(network))).map(([_, network]) => network)
|
|
43
|
-
)
|
|
44
|
-
];
|
|
45
|
-
}
|
|
46
|
-
function getOnRampAssets(data, {
|
|
47
|
-
walletType,
|
|
48
|
-
network,
|
|
49
|
-
allowed
|
|
50
|
-
} = {}) {
|
|
51
|
-
return [
|
|
52
|
-
...new Set(
|
|
53
|
-
toAssetInfoArray(data).filter(
|
|
54
|
-
([t, n, a]) => (!walletType || t === walletType) && (!network || n === network) && (!Array.isArray(allowed) || allowed.includes(a))
|
|
55
|
-
).map(([, , asset]) => asset)
|
|
56
|
-
)
|
|
57
|
-
];
|
|
58
|
-
}
|
|
59
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
60
|
-
0 && (module.exports = {
|
|
61
|
-
getOnRampAssets,
|
|
62
|
-
getOnRampNetworks,
|
|
63
|
-
toAssetInfoArray
|
|
64
|
-
});
|
|
@@ -1,58 +0,0 @@
|
|
|
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 __async = (__this, __arguments, generator) => {
|
|
19
|
-
return new Promise((resolve, reject) => {
|
|
20
|
-
var fulfilled = (value) => {
|
|
21
|
-
try {
|
|
22
|
-
step(generator.next(value));
|
|
23
|
-
} catch (e) {
|
|
24
|
-
reject(e);
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
var rejected = (value) => {
|
|
28
|
-
try {
|
|
29
|
-
step(generator.throw(value));
|
|
30
|
-
} catch (e) {
|
|
31
|
-
reject(e);
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
35
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
36
|
-
});
|
|
37
|
-
};
|
|
38
|
-
var polling_exports = {};
|
|
39
|
-
__export(polling_exports, {
|
|
40
|
-
waitUntilTrue: () => waitUntilTrue
|
|
41
|
-
});
|
|
42
|
-
module.exports = __toCommonJS(polling_exports);
|
|
43
|
-
function waitUntilTrue(condition, timeoutMs, intervalMs) {
|
|
44
|
-
return __async(this, null, function* () {
|
|
45
|
-
const start = Date.now();
|
|
46
|
-
while (Date.now() - start < timeoutMs) {
|
|
47
|
-
if (yield condition()) {
|
|
48
|
-
return true;
|
|
49
|
-
}
|
|
50
|
-
yield new Promise((resolve) => setTimeout(resolve, intervalMs));
|
|
51
|
-
}
|
|
52
|
-
return false;
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
56
|
-
0 && (module.exports = {
|
|
57
|
-
waitUntilTrue
|
|
58
|
-
});
|
package/dist/cjs/utils/url.js
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
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 url_exports = {};
|
|
19
|
-
__export(url_exports, {
|
|
20
|
-
constructUrl: () => constructUrl,
|
|
21
|
-
getParaConnectBaseUrl: () => getParaConnectBaseUrl,
|
|
22
|
-
getParaConnectDomain: () => getParaConnectDomain,
|
|
23
|
-
getPortalBaseURL: () => getPortalBaseURL,
|
|
24
|
-
getPortalDomain: () => getPortalDomain
|
|
25
|
-
});
|
|
26
|
-
module.exports = __toCommonJS(url_exports);
|
|
27
|
-
var import_types = require("../types/index.js");
|
|
28
|
-
function getPortalDomain(env, isE2E) {
|
|
29
|
-
if (isE2E) {
|
|
30
|
-
return `localhost`;
|
|
31
|
-
}
|
|
32
|
-
switch (env) {
|
|
33
|
-
case import_types.Environment.DEV:
|
|
34
|
-
return "localhost";
|
|
35
|
-
case import_types.Environment.SANDBOX:
|
|
36
|
-
return "app.sandbox.usecapsule.com";
|
|
37
|
-
case import_types.Environment.BETA:
|
|
38
|
-
return "app.beta.usecapsule.com";
|
|
39
|
-
case import_types.Environment.PROD:
|
|
40
|
-
return "app.usecapsule.com";
|
|
41
|
-
default:
|
|
42
|
-
throw new Error(`env: ${env} not supported`);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
function getPortalBaseURL({ env, isE2E }, useLocalIp, isForWasm) {
|
|
46
|
-
if (isE2E) {
|
|
47
|
-
if (isForWasm) {
|
|
48
|
-
return `https://app.sandbox.usecapsule.com`;
|
|
49
|
-
}
|
|
50
|
-
return `http://localhost:3003`;
|
|
51
|
-
}
|
|
52
|
-
const domain = getPortalDomain(env);
|
|
53
|
-
if (env === import_types.Environment.DEV) {
|
|
54
|
-
if (useLocalIp) {
|
|
55
|
-
return `http://127.0.0.1:3003`;
|
|
56
|
-
}
|
|
57
|
-
return `http://${domain}:3003`;
|
|
58
|
-
}
|
|
59
|
-
return `https://${domain}`;
|
|
60
|
-
}
|
|
61
|
-
function getParaConnectDomain(env) {
|
|
62
|
-
switch (env) {
|
|
63
|
-
case import_types.Environment.DEV:
|
|
64
|
-
return "localhost";
|
|
65
|
-
case import_types.Environment.SANDBOX:
|
|
66
|
-
return "connect.sandbox.getpara.com";
|
|
67
|
-
case import_types.Environment.BETA:
|
|
68
|
-
return "connect.beta.getpara.com";
|
|
69
|
-
case import_types.Environment.PROD:
|
|
70
|
-
return "connect.getpara.com";
|
|
71
|
-
default:
|
|
72
|
-
throw new Error(`env: ${env} not supported`);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
function getParaConnectBaseUrl({ env }, useLocalIp) {
|
|
76
|
-
const domain = getParaConnectDomain(env);
|
|
77
|
-
if (env === import_types.Environment.DEV) {
|
|
78
|
-
if (useLocalIp) {
|
|
79
|
-
return `http://127.0.0.1:3008`;
|
|
80
|
-
}
|
|
81
|
-
return `http://${domain}:3008`;
|
|
82
|
-
}
|
|
83
|
-
return `https://${domain}`;
|
|
84
|
-
}
|
|
85
|
-
function constructUrl({
|
|
86
|
-
base,
|
|
87
|
-
path,
|
|
88
|
-
params = {}
|
|
89
|
-
}) {
|
|
90
|
-
const url = new URL(path, base);
|
|
91
|
-
Object.entries(params).forEach(([key, value]) => {
|
|
92
|
-
if (!!value && value !== "undefined" && value !== "null") url.searchParams.set(key, value.toString());
|
|
93
|
-
});
|
|
94
|
-
return url.toString();
|
|
95
|
-
}
|
|
96
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
97
|
-
0 && (module.exports = {
|
|
98
|
-
constructUrl,
|
|
99
|
-
getParaConnectBaseUrl,
|
|
100
|
-
getParaConnectDomain,
|
|
101
|
-
getPortalBaseURL,
|
|
102
|
-
getPortalDomain
|
|
103
|
-
});
|
package/dist/cjs/utils/wallet.js
DELETED
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defProps = Object.defineProperties;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
9
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
10
|
-
var __spreadValues = (a, b) => {
|
|
11
|
-
for (var prop in b || (b = {}))
|
|
12
|
-
if (__hasOwnProp.call(b, prop))
|
|
13
|
-
__defNormalProp(a, prop, b[prop]);
|
|
14
|
-
if (__getOwnPropSymbols)
|
|
15
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
16
|
-
if (__propIsEnum.call(b, prop))
|
|
17
|
-
__defNormalProp(a, prop, b[prop]);
|
|
18
|
-
}
|
|
19
|
-
return a;
|
|
20
|
-
};
|
|
21
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
22
|
-
var __export = (target, all) => {
|
|
23
|
-
for (var name in all)
|
|
24
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
25
|
-
};
|
|
26
|
-
var __copyProps = (to, from, except, desc) => {
|
|
27
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
28
|
-
for (let key of __getOwnPropNames(from))
|
|
29
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
30
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
31
|
-
}
|
|
32
|
-
return to;
|
|
33
|
-
};
|
|
34
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
35
|
-
var wallet_exports = {};
|
|
36
|
-
__export(wallet_exports, {
|
|
37
|
-
WalletSchemeTypeMap: () => WalletSchemeTypeMap,
|
|
38
|
-
entityToWallet: () => entityToWallet,
|
|
39
|
-
getEquivalentTypes: () => getEquivalentTypes,
|
|
40
|
-
getSchemes: () => getSchemes,
|
|
41
|
-
getWalletTypes: () => getWalletTypes,
|
|
42
|
-
isPregenIdentifierMatch: () => isPregenIdentifierMatch,
|
|
43
|
-
isWalletSupported: () => isWalletSupported,
|
|
44
|
-
migrateWallet: () => migrateWallet
|
|
45
|
-
});
|
|
46
|
-
module.exports = __toCommonJS(wallet_exports);
|
|
47
|
-
var import_user_management_client = require("@getpara/user-management-client");
|
|
48
|
-
var import_formatting = require("./formatting.js");
|
|
49
|
-
const WalletSchemeTypeMap = {
|
|
50
|
-
[import_user_management_client.WalletScheme.DKLS]: {
|
|
51
|
-
[import_user_management_client.WalletType.EVM]: true,
|
|
52
|
-
[import_user_management_client.WalletType.COSMOS]: true
|
|
53
|
-
},
|
|
54
|
-
[import_user_management_client.WalletScheme.CGGMP]: {
|
|
55
|
-
[import_user_management_client.WalletType.EVM]: true,
|
|
56
|
-
[import_user_management_client.WalletType.COSMOS]: true
|
|
57
|
-
},
|
|
58
|
-
[import_user_management_client.WalletScheme.ED25519]: {
|
|
59
|
-
[import_user_management_client.WalletType.SOLANA]: true
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
function isPregenIdentifierMatch(a, b, type) {
|
|
63
|
-
if (!a || !b) {
|
|
64
|
-
return false;
|
|
65
|
-
}
|
|
66
|
-
switch (type) {
|
|
67
|
-
case "EMAIL":
|
|
68
|
-
return a.toLowerCase() === b.toLowerCase();
|
|
69
|
-
case "PHONE":
|
|
70
|
-
return (0, import_formatting.stringToPhoneNumber)(a) === (0, import_formatting.stringToPhoneNumber)(b);
|
|
71
|
-
case "CUSTOM_ID":
|
|
72
|
-
return a === b;
|
|
73
|
-
default:
|
|
74
|
-
return a.replace(/^@/g, "").toLowerCase() === b.replace(/^@/g, "").toLowerCase();
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
function isWalletSupported(types, wallet) {
|
|
78
|
-
return types.some((walletType) => {
|
|
79
|
-
var _a;
|
|
80
|
-
return !!((_a = WalletSchemeTypeMap[wallet == null ? void 0 : wallet.scheme]) == null ? void 0 : _a[walletType]);
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
function getSchemes(types) {
|
|
84
|
-
return Object.keys(WalletSchemeTypeMap).filter((scheme) => {
|
|
85
|
-
if (scheme === import_user_management_client.WalletScheme.CGGMP) {
|
|
86
|
-
return false;
|
|
87
|
-
}
|
|
88
|
-
return (Array.isArray(types) ? types : Object.keys(types)).some((type) => WalletSchemeTypeMap[scheme][type]);
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
function getWalletTypes(schemes) {
|
|
92
|
-
return [
|
|
93
|
-
...new Set(
|
|
94
|
-
schemes.reduce((acc, scheme) => {
|
|
95
|
-
return [...acc, ...Object.keys(WalletSchemeTypeMap[scheme]).filter((type) => WalletSchemeTypeMap[scheme][type])];
|
|
96
|
-
}, [])
|
|
97
|
-
)
|
|
98
|
-
];
|
|
99
|
-
}
|
|
100
|
-
function getEquivalentTypes(types) {
|
|
101
|
-
return getWalletTypes(getSchemes((Array.isArray(types) ? types : [types]).map((t) => import_user_management_client.WalletType[t])));
|
|
102
|
-
}
|
|
103
|
-
function entityToWallet(w) {
|
|
104
|
-
return __spreadProps(__spreadValues({}, w), {
|
|
105
|
-
scheme: w.scheme,
|
|
106
|
-
type: w.type,
|
|
107
|
-
pregenIdentifierType: w.pregenIdentifierType
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
function migrateWallet(obj) {
|
|
111
|
-
if (["USER", "PREGEN"].includes(obj.type)) {
|
|
112
|
-
obj.isPregen = obj.type === "PREGEN";
|
|
113
|
-
obj.type = obj.scheme === import_user_management_client.WalletScheme.ED25519 ? import_user_management_client.WalletType.SOLANA : import_user_management_client.WalletType.EVM;
|
|
114
|
-
}
|
|
115
|
-
if (!!obj.scheme && !obj.type) {
|
|
116
|
-
obj.type = obj.scheme === import_user_management_client.WalletScheme.ED25519 ? import_user_management_client.WalletType.SOLANA : import_user_management_client.WalletType.EVM;
|
|
117
|
-
}
|
|
118
|
-
return obj;
|
|
119
|
-
}
|
|
120
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
121
|
-
0 && (module.exports = {
|
|
122
|
-
WalletSchemeTypeMap,
|
|
123
|
-
entityToWallet,
|
|
124
|
-
getEquivalentTypes,
|
|
125
|
-
getSchemes,
|
|
126
|
-
getWalletTypes,
|
|
127
|
-
isPregenIdentifierMatch,
|
|
128
|
-
isWalletSupported,
|
|
129
|
-
migrateWallet
|
|
130
|
-
});
|