@getpara/core-sdk 1.12.0 → 2.0.0-alpha.5
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 +936 -974
- package/dist/cjs/constants.js +7 -1
- package/dist/cjs/index.js +15 -9
- package/dist/cjs/types/coreApi.js +74 -0
- package/dist/cjs/types/events.js +1 -0
- package/dist/cjs/types/index.js +4 -2
- package/dist/cjs/types/{params.js → methods.js} +2 -2
- package/dist/cjs/utils/autobind.js +41 -0
- package/dist/cjs/utils/formatting.js +0 -12
- package/dist/cjs/utils/index.js +10 -0
- package/dist/cjs/utils/json.js +37 -0
- package/dist/cjs/utils/listeners.js +2 -11
- package/dist/cjs/utils/phone.js +61 -0
- package/dist/cjs/utils/types.js +29 -0
- package/dist/cjs/utils/url.js +34 -2
- package/dist/cjs/utils/wallet.js +30 -17
- package/dist/esm/ParaCore.js +952 -979
- package/dist/esm/constants.js +5 -1
- package/dist/esm/index.js +12 -9
- package/dist/esm/types/coreApi.js +52 -0
- package/dist/esm/types/events.js +1 -0
- package/dist/esm/types/index.js +2 -1
- package/dist/esm/utils/autobind.js +19 -0
- package/dist/esm/utils/formatting.js +0 -10
- package/dist/esm/utils/index.js +5 -0
- package/dist/esm/utils/json.js +15 -0
- package/dist/esm/utils/listeners.js +2 -11
- package/dist/esm/utils/phone.js +28 -0
- package/dist/esm/utils/types.js +7 -0
- package/dist/esm/utils/url.js +15 -2
- package/dist/esm/utils/wallet.js +27 -16
- package/dist/types/ParaCore.d.ts +100 -391
- package/dist/types/PlatformUtils.d.ts +3 -3
- package/dist/types/constants.d.ts +2 -0
- package/dist/types/external/userManagementClient.d.ts +1 -1
- package/dist/types/index.d.ts +5 -3
- package/dist/types/types/config.d.ts +4 -24
- package/dist/types/types/coreApi.d.ts +475 -0
- package/dist/types/types/events.d.ts +4 -1
- package/dist/types/types/index.d.ts +2 -1
- package/dist/types/types/methods.d.ts +148 -0
- package/dist/types/types/onRamps.d.ts +3 -3
- package/dist/types/types/wallet.d.ts +4 -4
- package/dist/types/utils/autobind.d.ts +1 -0
- package/dist/types/utils/formatting.d.ts +2 -4
- package/dist/types/utils/index.d.ts +5 -0
- package/dist/types/utils/json.d.ts +1 -0
- package/dist/types/utils/onRamps.d.ts +3 -3
- 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 +9 -7
- package/package.json +4 -3
- package/dist/types/types/params.d.ts +0 -73
- /package/dist/esm/types/{params.js → methods.js} +0 -0
package/dist/cjs/constants.js
CHANGED
|
@@ -18,6 +18,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
18
18
|
var constants_exports = {};
|
|
19
19
|
__export(constants_exports, {
|
|
20
20
|
EXTERNAL_WALLET_CONNECTION_ONLY_USER_ID: () => EXTERNAL_WALLET_CONNECTION_ONLY_USER_ID,
|
|
21
|
+
LOCAL_STORAGE_AUTH_INFO: () => LOCAL_STORAGE_AUTH_INFO,
|
|
21
22
|
LOCAL_STORAGE_COUNTRY_CODE: () => LOCAL_STORAGE_COUNTRY_CODE,
|
|
22
23
|
LOCAL_STORAGE_CURRENT_WALLET_IDS: () => LOCAL_STORAGE_CURRENT_WALLET_IDS,
|
|
23
24
|
LOCAL_STORAGE_ED25519_WALLETS: () => LOCAL_STORAGE_ED25519_WALLETS,
|
|
@@ -32,13 +33,15 @@ __export(constants_exports, {
|
|
|
32
33
|
LOCAL_STORAGE_WALLETS: () => LOCAL_STORAGE_WALLETS,
|
|
33
34
|
PARA_CORE_VERSION: () => PARA_CORE_VERSION,
|
|
34
35
|
POLLING_INTERVAL_MS: () => POLLING_INTERVAL_MS,
|
|
36
|
+
POLLING_TIMEOUT_MS: () => POLLING_TIMEOUT_MS,
|
|
35
37
|
PREFIX: () => PREFIX,
|
|
36
38
|
SESSION_STORAGE_LOGIN_ENCRYPTION_KEY_PAIR: () => SESSION_STORAGE_LOGIN_ENCRYPTION_KEY_PAIR,
|
|
37
39
|
SHORT_POLLING_INTERVAL_MS: () => SHORT_POLLING_INTERVAL_MS
|
|
38
40
|
});
|
|
39
41
|
module.exports = __toCommonJS(constants_exports);
|
|
40
|
-
const PARA_CORE_VERSION = "
|
|
42
|
+
const PARA_CORE_VERSION = "2.0.0-alpha.3";
|
|
41
43
|
const PREFIX = "@CAPSULE/";
|
|
44
|
+
const LOCAL_STORAGE_AUTH_INFO = `${PREFIX}authInfo`;
|
|
42
45
|
const LOCAL_STORAGE_EMAIL = `${PREFIX}e-mail`;
|
|
43
46
|
const LOCAL_STORAGE_PHONE = `${PREFIX}phone`;
|
|
44
47
|
const LOCAL_STORAGE_COUNTRY_CODE = `${PREFIX}countryCode`;
|
|
@@ -54,10 +57,12 @@ const LOCAL_STORAGE_SESSION_COOKIE = `${PREFIX}sessionCookie`;
|
|
|
54
57
|
const SESSION_STORAGE_LOGIN_ENCRYPTION_KEY_PAIR = `${PREFIX}loginEncryptionKeyPair`;
|
|
55
58
|
const POLLING_INTERVAL_MS = 2e3;
|
|
56
59
|
const SHORT_POLLING_INTERVAL_MS = 1e3;
|
|
60
|
+
const POLLING_TIMEOUT_MS = 3e5;
|
|
57
61
|
const EXTERNAL_WALLET_CONNECTION_ONLY_USER_ID = "EXTERNAL_WALLET_CONNECTION_ONLY";
|
|
58
62
|
// Annotate the CommonJS export names for ESM import in node:
|
|
59
63
|
0 && (module.exports = {
|
|
60
64
|
EXTERNAL_WALLET_CONNECTION_ONLY_USER_ID,
|
|
65
|
+
LOCAL_STORAGE_AUTH_INFO,
|
|
61
66
|
LOCAL_STORAGE_COUNTRY_CODE,
|
|
62
67
|
LOCAL_STORAGE_CURRENT_WALLET_IDS,
|
|
63
68
|
LOCAL_STORAGE_ED25519_WALLETS,
|
|
@@ -72,6 +77,7 @@ const EXTERNAL_WALLET_CONNECTION_ONLY_USER_ID = "EXTERNAL_WALLET_CONNECTION_ONLY
|
|
|
72
77
|
LOCAL_STORAGE_WALLETS,
|
|
73
78
|
PARA_CORE_VERSION,
|
|
74
79
|
POLLING_INTERVAL_MS,
|
|
80
|
+
POLLING_TIMEOUT_MS,
|
|
75
81
|
PREFIX,
|
|
76
82
|
SESSION_STORAGE_LOGIN_ENCRYPTION_KEY_PAIR,
|
|
77
83
|
SHORT_POLLING_INTERVAL_MS
|
package/dist/cjs/index.js
CHANGED
|
@@ -33,7 +33,7 @@ __export(src_exports, {
|
|
|
33
33
|
KeyContainer: () => import_KeyContainer.KeyContainer,
|
|
34
34
|
NON_ED25519: () => import_user_management_client.NON_ED25519,
|
|
35
35
|
Network: () => import_user_management_client.Network,
|
|
36
|
-
|
|
36
|
+
OAUTH_METHODS: () => import_user_management_client.OAUTH_METHODS,
|
|
37
37
|
OnRampAsset: () => import_user_management_client.OnRampAsset,
|
|
38
38
|
OnRampMethod: () => import_types.OnRampMethod,
|
|
39
39
|
OnRampProvider: () => import_user_management_client.OnRampProvider,
|
|
@@ -44,8 +44,9 @@ __export(src_exports, {
|
|
|
44
44
|
PregenIdentifierType: () => import_types.PregenIdentifierType,
|
|
45
45
|
RecoveryStatus: () => import_types.RecoveryStatus,
|
|
46
46
|
STORAGE_PREFIX: () => import_constants.PREFIX,
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
WALLET_SCHEMES: () => import_user_management_client.WALLET_SCHEMES,
|
|
48
|
+
WALLET_TYPES: () => import_user_management_client.WALLET_TYPES,
|
|
49
|
+
constructUrl: () => import_utils.constructUrl,
|
|
49
50
|
decryptPrivateKey: () => import_utils2.decryptPrivateKey,
|
|
50
51
|
decryptPrivateKeyAndDecryptShare: () => import_utils2.decryptPrivateKeyAndDecryptShare,
|
|
51
52
|
decryptPrivateKeyWithPassword: () => import_utils2.decryptPrivateKeyWithPassword,
|
|
@@ -75,7 +76,7 @@ __export(src_exports, {
|
|
|
75
76
|
mpcComputationClient: () => mpcComputationClient,
|
|
76
77
|
paraVersion: () => paraVersion,
|
|
77
78
|
publicKeyFromHex: () => import_utils2.publicKeyFromHex,
|
|
78
|
-
|
|
79
|
+
shortenUrl: () => import_utils.shortenUrl,
|
|
79
80
|
toAssetInfoArray: () => import_onRamps.toAssetInfoArray,
|
|
80
81
|
transmissionUtilsRetrieve: () => import_transmissionUtils.retrieve
|
|
81
82
|
});
|
|
@@ -83,6 +84,7 @@ module.exports = __toCommonJS(src_exports);
|
|
|
83
84
|
var import_ParaCore = require("./ParaCore.js");
|
|
84
85
|
var import_user_management_client = require("@getpara/user-management-client");
|
|
85
86
|
var import_types = require("./types/index.js");
|
|
87
|
+
__reExport(src_exports, require("./types/coreApi.js"), module.exports);
|
|
86
88
|
__reExport(src_exports, require("./types/events.js"), module.exports);
|
|
87
89
|
__reExport(src_exports, require("./types/config.js"), module.exports);
|
|
88
90
|
var import_utils = require("./utils/index.js");
|
|
@@ -96,6 +98,7 @@ __reExport(src_exports, require("./external/userManagementClient.js"), module.ex
|
|
|
96
98
|
__reExport(src_exports, require("./errors.js"), module.exports);
|
|
97
99
|
__reExport(src_exports, require("./utils/formatting.js"), module.exports);
|
|
98
100
|
__reExport(src_exports, require("./utils/polling.js"), module.exports);
|
|
101
|
+
__reExport(src_exports, require("./utils/phone.js"), module.exports);
|
|
99
102
|
var import_wallet = require("./utils/wallet.js");
|
|
100
103
|
var import_onRamps = require("./utils/onRamps.js");
|
|
101
104
|
var import_url = require("./utils/url.js");
|
|
@@ -109,7 +112,7 @@ var src_default = import_ParaCore.ParaCore;
|
|
|
109
112
|
KeyContainer,
|
|
110
113
|
NON_ED25519,
|
|
111
114
|
Network,
|
|
112
|
-
|
|
115
|
+
OAUTH_METHODS,
|
|
113
116
|
OnRampAsset,
|
|
114
117
|
OnRampMethod,
|
|
115
118
|
OnRampProvider,
|
|
@@ -120,8 +123,9 @@ var src_default = import_ParaCore.ParaCore;
|
|
|
120
123
|
PregenIdentifierType,
|
|
121
124
|
RecoveryStatus,
|
|
122
125
|
STORAGE_PREFIX,
|
|
123
|
-
|
|
124
|
-
|
|
126
|
+
WALLET_SCHEMES,
|
|
127
|
+
WALLET_TYPES,
|
|
128
|
+
constructUrl,
|
|
125
129
|
decryptPrivateKey,
|
|
126
130
|
decryptPrivateKeyAndDecryptShare,
|
|
127
131
|
decryptPrivateKeyWithPassword,
|
|
@@ -150,13 +154,15 @@ var src_default = import_ParaCore.ParaCore;
|
|
|
150
154
|
mpcComputationClient,
|
|
151
155
|
paraVersion,
|
|
152
156
|
publicKeyFromHex,
|
|
153
|
-
|
|
157
|
+
shortenUrl,
|
|
154
158
|
toAssetInfoArray,
|
|
155
159
|
transmissionUtilsRetrieve,
|
|
160
|
+
...require("./types/coreApi.js"),
|
|
156
161
|
...require("./types/events.js"),
|
|
157
162
|
...require("./types/config.js"),
|
|
158
163
|
...require("./external/userManagementClient.js"),
|
|
159
164
|
...require("./errors.js"),
|
|
160
165
|
...require("./utils/formatting.js"),
|
|
161
|
-
...require("./utils/polling.js")
|
|
166
|
+
...require("./utils/polling.js"),
|
|
167
|
+
...require("./utils/phone.js")
|
|
162
168
|
});
|
|
@@ -0,0 +1,74 @@
|
|
|
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 coreApi_exports = {};
|
|
19
|
+
__export(coreApi_exports, {
|
|
20
|
+
PARA_CORE_METHODS: () => PARA_CORE_METHODS
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(coreApi_exports);
|
|
23
|
+
const PARA_CORE_METHODS = [
|
|
24
|
+
"getAuthInfo",
|
|
25
|
+
"signUpOrLogIn",
|
|
26
|
+
"verifyNewAccount",
|
|
27
|
+
"waitForLogin",
|
|
28
|
+
"waitForSignup",
|
|
29
|
+
"waitForWalletCreation",
|
|
30
|
+
"getOAuthUrl",
|
|
31
|
+
"verifyOAuth",
|
|
32
|
+
"getFarcasterConnectUri",
|
|
33
|
+
"verifyFarcaster",
|
|
34
|
+
"verifyTelegram",
|
|
35
|
+
"resendVerificationCode",
|
|
36
|
+
"loginExternalWallet",
|
|
37
|
+
"verifyExternalWallet",
|
|
38
|
+
"setup2fa",
|
|
39
|
+
"enable2fa",
|
|
40
|
+
"verify2fa",
|
|
41
|
+
"logout",
|
|
42
|
+
"clearStorage",
|
|
43
|
+
"isSessionActive",
|
|
44
|
+
"isFullyLoggedIn",
|
|
45
|
+
"refreshSession",
|
|
46
|
+
"keepSessionAlive",
|
|
47
|
+
"exportSession",
|
|
48
|
+
"importSession",
|
|
49
|
+
"getVerificationToken",
|
|
50
|
+
"getWallets",
|
|
51
|
+
"getWalletsByType",
|
|
52
|
+
"fetchWallets",
|
|
53
|
+
"createWallet",
|
|
54
|
+
"createWalletPerType",
|
|
55
|
+
"getPregenWallets",
|
|
56
|
+
"hasPregenWallet",
|
|
57
|
+
"updatePregenWalletIdentifier",
|
|
58
|
+
"createPregenWallet",
|
|
59
|
+
"createPregenWalletPerType",
|
|
60
|
+
"claimPregenWallets",
|
|
61
|
+
"createGuestWallets",
|
|
62
|
+
"distributeNewWalletShare",
|
|
63
|
+
"getUserShare",
|
|
64
|
+
"setUserShare",
|
|
65
|
+
"refreshShare",
|
|
66
|
+
"signMessage",
|
|
67
|
+
"signTransaction",
|
|
68
|
+
"initiateOnRampTransaction",
|
|
69
|
+
"getWalletBalance"
|
|
70
|
+
];
|
|
71
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
72
|
+
0 && (module.exports = {
|
|
73
|
+
PARA_CORE_METHODS
|
|
74
|
+
});
|
package/dist/cjs/types/events.js
CHANGED
|
@@ -32,6 +32,7 @@ var ParaEvent = ((ParaEvent2) => {
|
|
|
32
32
|
ParaEvent2["WALLETS_CHANGE_EVENT"] = `${EVENT_PREFIX}WalletsChange`;
|
|
33
33
|
ParaEvent2["WALLET_CREATED"] = `${EVENT_PREFIX}WalletCreated`;
|
|
34
34
|
ParaEvent2["PREGEN_WALLET_CLAIMED"] = `${EVENT_PREFIX}PregenWalletClaimed`;
|
|
35
|
+
ParaEvent2["GUEST_WALLETS_CREATED"] = `${EVENT_PREFIX}GuestWalletsCreated`;
|
|
35
36
|
return ParaEvent2;
|
|
36
37
|
})(ParaEvent || {});
|
|
37
38
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/cjs/types/index.js
CHANGED
|
@@ -25,8 +25,9 @@ __export(types_exports, {
|
|
|
25
25
|
});
|
|
26
26
|
module.exports = __toCommonJS(types_exports);
|
|
27
27
|
__reExport(types_exports, require("./config.js"), module.exports);
|
|
28
|
+
__reExport(types_exports, require("./coreApi.js"), module.exports);
|
|
28
29
|
__reExport(types_exports, require("./wallet.js"), module.exports);
|
|
29
|
-
__reExport(types_exports, require("./
|
|
30
|
+
__reExport(types_exports, require("./methods.js"), module.exports);
|
|
30
31
|
__reExport(types_exports, require("./theme.js"), module.exports);
|
|
31
32
|
__reExport(types_exports, require("./onRamps.js"), module.exports);
|
|
32
33
|
__reExport(types_exports, require("./popup.js"), module.exports);
|
|
@@ -40,8 +41,9 @@ var import_user_management_client = require("@getpara/user-management-client");
|
|
|
40
41
|
OnRampProvider,
|
|
41
42
|
OnRampPurchaseStatus,
|
|
42
43
|
...require("./config.js"),
|
|
44
|
+
...require("./coreApi.js"),
|
|
43
45
|
...require("./wallet.js"),
|
|
44
|
-
...require("./
|
|
46
|
+
...require("./methods.js"),
|
|
45
47
|
...require("./theme.js"),
|
|
46
48
|
...require("./onRamps.js"),
|
|
47
49
|
...require("./popup.js"),
|
|
@@ -11,5 +11,5 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
11
11
|
return to;
|
|
12
12
|
};
|
|
13
13
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
14
|
-
var
|
|
15
|
-
module.exports = __toCommonJS(
|
|
14
|
+
var methods_exports = {};
|
|
15
|
+
module.exports = __toCommonJS(methods_exports);
|
|
@@ -0,0 +1,41 @@
|
|
|
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 autobind_exports = {};
|
|
19
|
+
__export(autobind_exports, {
|
|
20
|
+
autoBind: () => autoBind
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(autobind_exports);
|
|
23
|
+
function autoBind(instance) {
|
|
24
|
+
let proto = instance;
|
|
25
|
+
while (proto && proto !== Object.prototype) {
|
|
26
|
+
for (const key of Object.getOwnPropertyNames(proto)) {
|
|
27
|
+
const value = instance[key];
|
|
28
|
+
if (typeof value === "function" && key !== "constructor") {
|
|
29
|
+
try {
|
|
30
|
+
instance[key] = value.bind(instance);
|
|
31
|
+
} catch (e) {
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
proto = Object.getPrototypeOf(proto);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
39
|
+
0 && (module.exports = {
|
|
40
|
+
autoBind
|
|
41
|
+
});
|
|
@@ -33,8 +33,6 @@ __export(formatting_exports, {
|
|
|
33
33
|
hexToDecimal: () => hexToDecimal,
|
|
34
34
|
hexToSignature: () => hexToSignature,
|
|
35
35
|
hexToUint8Array: () => hexToUint8Array,
|
|
36
|
-
normalizePhoneNumber: () => normalizePhoneNumber,
|
|
37
|
-
stringToPhoneNumber: () => stringToPhoneNumber,
|
|
38
36
|
truncateAddress: () => truncateAddress
|
|
39
37
|
});
|
|
40
38
|
module.exports = __toCommonJS(formatting_exports);
|
|
@@ -42,7 +40,6 @@ var import_encoding = require("@cosmjs/encoding");
|
|
|
42
40
|
var import_sha256 = require("@noble/hashes/sha256");
|
|
43
41
|
var import_ripemd160 = require("@noble/hashes/ripemd160");
|
|
44
42
|
var import_elliptic = __toESM(require("elliptic"));
|
|
45
|
-
var import_libphonenumber_js = __toESM(require("libphonenumber-js"));
|
|
46
43
|
const secp256k1 = new import_elliptic.default.ec("secp256k1");
|
|
47
44
|
function hexStringToBase64(hexString) {
|
|
48
45
|
if (hexString.substring(0, 2) === "0x") {
|
|
@@ -103,13 +100,6 @@ function truncateAddress(str, addressType, {
|
|
|
103
100
|
const margin = targetLength !== void 0 ? (targetLength - minimum) / 2 : 4;
|
|
104
101
|
return `${str.slice(0, minimum + margin)}...${str.slice(-1 * margin)}`;
|
|
105
102
|
}
|
|
106
|
-
function stringToPhoneNumber(str) {
|
|
107
|
-
var _a;
|
|
108
|
-
return (_a = (0, import_libphonenumber_js.default)(str)) == null ? void 0 : _a.formatInternational().replace(/[^\d+]/g, "");
|
|
109
|
-
}
|
|
110
|
-
function normalizePhoneNumber(countryCode, number) {
|
|
111
|
-
return stringToPhoneNumber(`${countryCode[0] !== "+" ? "+" : ""}${countryCode}${number}`);
|
|
112
|
-
}
|
|
113
103
|
// Annotate the CommonJS export names for ESM import in node:
|
|
114
104
|
0 && (module.exports = {
|
|
115
105
|
decimalToHex,
|
|
@@ -118,7 +108,5 @@ function normalizePhoneNumber(countryCode, number) {
|
|
|
118
108
|
hexToDecimal,
|
|
119
109
|
hexToSignature,
|
|
120
110
|
hexToUint8Array,
|
|
121
|
-
normalizePhoneNumber,
|
|
122
|
-
stringToPhoneNumber,
|
|
123
111
|
truncateAddress
|
|
124
112
|
});
|
package/dist/cjs/utils/index.js
CHANGED
|
@@ -14,18 +14,28 @@ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "defau
|
|
|
14
14
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
15
|
var utils_exports = {};
|
|
16
16
|
module.exports = __toCommonJS(utils_exports);
|
|
17
|
+
__reExport(utils_exports, require("./autobind.js"), module.exports);
|
|
17
18
|
__reExport(utils_exports, require("./events.js"), module.exports);
|
|
18
19
|
__reExport(utils_exports, require("./formatting.js"), module.exports);
|
|
20
|
+
__reExport(utils_exports, require("./json.js"), module.exports);
|
|
21
|
+
__reExport(utils_exports, require("./listeners.js"), module.exports);
|
|
19
22
|
__reExport(utils_exports, require("./onRamps.js"), module.exports);
|
|
23
|
+
__reExport(utils_exports, require("./phone.js"), module.exports);
|
|
20
24
|
__reExport(utils_exports, require("./polling.js"), module.exports);
|
|
25
|
+
__reExport(utils_exports, require("./types.js"), module.exports);
|
|
21
26
|
__reExport(utils_exports, require("./url.js"), module.exports);
|
|
22
27
|
__reExport(utils_exports, require("./wallet.js"), module.exports);
|
|
23
28
|
// Annotate the CommonJS export names for ESM import in node:
|
|
24
29
|
0 && (module.exports = {
|
|
30
|
+
...require("./autobind.js"),
|
|
25
31
|
...require("./events.js"),
|
|
26
32
|
...require("./formatting.js"),
|
|
33
|
+
...require("./json.js"),
|
|
34
|
+
...require("./listeners.js"),
|
|
27
35
|
...require("./onRamps.js"),
|
|
36
|
+
...require("./phone.js"),
|
|
28
37
|
...require("./polling.js"),
|
|
38
|
+
...require("./types.js"),
|
|
29
39
|
...require("./url.js"),
|
|
30
40
|
...require("./wallet.js")
|
|
31
41
|
});
|
|
@@ -0,0 +1,37 @@
|
|
|
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 json_exports = {};
|
|
19
|
+
__export(json_exports, {
|
|
20
|
+
jsonParse: () => jsonParse
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(json_exports);
|
|
23
|
+
function jsonParse(data, validate) {
|
|
24
|
+
try {
|
|
25
|
+
const res = JSON.parse(data);
|
|
26
|
+
if (validate && !validate(res)) {
|
|
27
|
+
return void 0;
|
|
28
|
+
}
|
|
29
|
+
return res;
|
|
30
|
+
} catch (e) {
|
|
31
|
+
return void 0;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
35
|
+
0 && (module.exports = {
|
|
36
|
+
jsonParse
|
|
37
|
+
});
|
|
@@ -51,21 +51,12 @@ function storageListener(e) {
|
|
|
51
51
|
if (e.key === constants.LOCAL_STORAGE_WALLETS || e.key === constants.LOCAL_STORAGE_ED25519_WALLETS) {
|
|
52
52
|
this.updateWalletsFromStorage();
|
|
53
53
|
}
|
|
54
|
-
if (e.key === constants.
|
|
55
|
-
this.
|
|
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();
|
|
54
|
+
if (e.key === constants.LOCAL_STORAGE_AUTH_INFO) {
|
|
55
|
+
this.updateAuthInfoFromStorage();
|
|
62
56
|
}
|
|
63
57
|
if (e.key === constants.LOCAL_STORAGE_USER_ID) {
|
|
64
58
|
this.updateUserIdFromStorage();
|
|
65
59
|
}
|
|
66
|
-
if (e.key === constants.LOCAL_STORAGE_TELEGRAM_USER_ID) {
|
|
67
|
-
this.updateTelegramUserIdFromStorage();
|
|
68
|
-
}
|
|
69
60
|
}
|
|
70
61
|
function setupListeners() {
|
|
71
62
|
if (typeof window !== "undefined" && window.addEventListener && window.location) {
|
|
@@ -0,0 +1,61 @@
|
|
|
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 phone_exports = {};
|
|
29
|
+
__export(phone_exports, {
|
|
30
|
+
displayPhoneNumber: () => displayPhoneNumber,
|
|
31
|
+
formatPhoneNumber: () => formatPhoneNumber
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(phone_exports);
|
|
34
|
+
var import_libphonenumber_js = __toESM(require("libphonenumber-js"));
|
|
35
|
+
function formatPhoneNumber(phone, countryCode, { forDisplay = false } = {}) {
|
|
36
|
+
phone = phone.toString();
|
|
37
|
+
countryCode = countryCode == null ? void 0 : countryCode.toString();
|
|
38
|
+
let sanitizedNumber, parsedNumber;
|
|
39
|
+
if (!!countryCode) {
|
|
40
|
+
sanitizedNumber = phone.replace(/\D/g, "");
|
|
41
|
+
if (/^\+\d+$/.test(countryCode)) {
|
|
42
|
+
countryCode = countryCode.slice(1);
|
|
43
|
+
}
|
|
44
|
+
parsedNumber = (0, import_libphonenumber_js.default)(sanitizedNumber, { defaultCallingCode: countryCode });
|
|
45
|
+
} else {
|
|
46
|
+
sanitizedNumber = `+${phone.replace(/\D/g, "")}`;
|
|
47
|
+
parsedNumber = (0, import_libphonenumber_js.default)(sanitizedNumber);
|
|
48
|
+
}
|
|
49
|
+
if (parsedNumber == null ? void 0 : parsedNumber.isValid()) {
|
|
50
|
+
return forDisplay ? parsedNumber.formatInternational() : parsedNumber.formatInternational().replace(/[^\d+]/g, "");
|
|
51
|
+
}
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
function displayPhoneNumber(phone, countryCode) {
|
|
55
|
+
return formatPhoneNumber(phone, countryCode, { forDisplay: true });
|
|
56
|
+
}
|
|
57
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
58
|
+
0 && (module.exports = {
|
|
59
|
+
displayPhoneNumber,
|
|
60
|
+
formatPhoneNumber
|
|
61
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
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 types_exports = {};
|
|
19
|
+
__export(types_exports, {
|
|
20
|
+
isServerAuthState: () => isServerAuthState
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(types_exports);
|
|
23
|
+
function isServerAuthState(obj) {
|
|
24
|
+
return "stage" in obj;
|
|
25
|
+
}
|
|
26
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
27
|
+
0 && (module.exports = {
|
|
28
|
+
isServerAuthState
|
|
29
|
+
});
|
package/dist/cjs/utils/url.js
CHANGED
|
@@ -15,15 +15,37 @@ 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 __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
|
+
};
|
|
18
38
|
var url_exports = {};
|
|
19
39
|
__export(url_exports, {
|
|
20
40
|
constructUrl: () => constructUrl,
|
|
21
41
|
getParaConnectBaseUrl: () => getParaConnectBaseUrl,
|
|
22
42
|
getParaConnectDomain: () => getParaConnectDomain,
|
|
23
43
|
getPortalBaseURL: () => getPortalBaseURL,
|
|
24
|
-
getPortalDomain: () => getPortalDomain
|
|
44
|
+
getPortalDomain: () => getPortalDomain,
|
|
45
|
+
shortenUrl: () => shortenUrl
|
|
25
46
|
});
|
|
26
47
|
module.exports = __toCommonJS(url_exports);
|
|
48
|
+
var import_transmissionUtils = require("../transmission/transmissionUtils.js");
|
|
27
49
|
var import_types = require("../types/index.js");
|
|
28
50
|
function getPortalDomain(env, isE2E) {
|
|
29
51
|
if (isE2E) {
|
|
@@ -93,11 +115,21 @@ function constructUrl({
|
|
|
93
115
|
});
|
|
94
116
|
return url.toString();
|
|
95
117
|
}
|
|
118
|
+
function shortenUrl(ctx, url) {
|
|
119
|
+
return __async(this, null, function* () {
|
|
120
|
+
const compressedUrl = yield (0, import_transmissionUtils.upload)(url, ctx.client);
|
|
121
|
+
return constructUrl({
|
|
122
|
+
base: getPortalBaseURL(ctx),
|
|
123
|
+
path: `/short/${compressedUrl}`
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
}
|
|
96
127
|
// Annotate the CommonJS export names for ESM import in node:
|
|
97
128
|
0 && (module.exports = {
|
|
98
129
|
constructUrl,
|
|
99
130
|
getParaConnectBaseUrl,
|
|
100
131
|
getParaConnectDomain,
|
|
101
132
|
getPortalBaseURL,
|
|
102
|
-
getPortalDomain
|
|
133
|
+
getPortalDomain,
|
|
134
|
+
shortenUrl
|
|
103
135
|
});
|
package/dist/cjs/utils/wallet.js
CHANGED
|
@@ -51,24 +51,25 @@ __export(wallet_exports, {
|
|
|
51
51
|
getWalletTypes: () => getWalletTypes,
|
|
52
52
|
isPregenIdentifierMatch: () => isPregenIdentifierMatch,
|
|
53
53
|
isWalletSupported: () => isWalletSupported,
|
|
54
|
+
mergeCurrentWalletIds: () => mergeCurrentWalletIds,
|
|
54
55
|
migrateWallet: () => migrateWallet,
|
|
55
|
-
newUuid: () => newUuid
|
|
56
|
+
newUuid: () => newUuid,
|
|
57
|
+
supportedWalletTypesEq: () => supportedWalletTypesEq
|
|
56
58
|
});
|
|
57
59
|
module.exports = __toCommonJS(wallet_exports);
|
|
58
60
|
var uuid = __toESM(require("uuid"));
|
|
59
|
-
var
|
|
60
|
-
var import_formatting = require("./formatting.js");
|
|
61
|
+
var import_phone = require("./phone.js");
|
|
61
62
|
const WalletSchemeTypeMap = {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
DKLS: {
|
|
64
|
+
EVM: true,
|
|
65
|
+
COSMOS: true
|
|
65
66
|
},
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
CGGMP: {
|
|
68
|
+
EVM: true,
|
|
69
|
+
COSMOS: true
|
|
69
70
|
},
|
|
70
|
-
|
|
71
|
-
|
|
71
|
+
ED25519: {
|
|
72
|
+
SOLANA: true
|
|
72
73
|
}
|
|
73
74
|
};
|
|
74
75
|
function isPregenIdentifierMatch(a, b, type) {
|
|
@@ -79,7 +80,7 @@ function isPregenIdentifierMatch(a, b, type) {
|
|
|
79
80
|
case "EMAIL":
|
|
80
81
|
return a.toLowerCase() === b.toLowerCase();
|
|
81
82
|
case "PHONE":
|
|
82
|
-
return (0,
|
|
83
|
+
return (0, import_phone.formatPhoneNumber)(a) === (0, import_phone.formatPhoneNumber)(b);
|
|
83
84
|
case "CUSTOM_ID":
|
|
84
85
|
return a === b;
|
|
85
86
|
default:
|
|
@@ -94,7 +95,7 @@ function isWalletSupported(types, wallet) {
|
|
|
94
95
|
}
|
|
95
96
|
function getSchemes(types) {
|
|
96
97
|
return Object.keys(WalletSchemeTypeMap).filter((scheme) => {
|
|
97
|
-
if (scheme ===
|
|
98
|
+
if (scheme === "CGGMP") {
|
|
98
99
|
return false;
|
|
99
100
|
}
|
|
100
101
|
return (Array.isArray(types) ? types : Object.keys(types)).some((type) => WalletSchemeTypeMap[scheme][type]);
|
|
@@ -110,7 +111,7 @@ function getWalletTypes(schemes) {
|
|
|
110
111
|
];
|
|
111
112
|
}
|
|
112
113
|
function getEquivalentTypes(types) {
|
|
113
|
-
return getWalletTypes(getSchemes(
|
|
114
|
+
return getWalletTypes(getSchemes(Array.isArray(types) ? types : [types]));
|
|
114
115
|
}
|
|
115
116
|
function entityToWallet(w) {
|
|
116
117
|
return __spreadProps(__spreadValues({}, w), {
|
|
@@ -122,13 +123,23 @@ function entityToWallet(w) {
|
|
|
122
123
|
function migrateWallet(obj) {
|
|
123
124
|
if (["USER", "PREGEN"].includes(obj.type)) {
|
|
124
125
|
obj.isPregen = obj.type === "PREGEN";
|
|
125
|
-
obj.type = obj.scheme ===
|
|
126
|
+
obj.type = obj.scheme === "ED25519" ? "SOLANA" : "EVM";
|
|
126
127
|
}
|
|
127
128
|
if (!!obj.scheme && !obj.type) {
|
|
128
|
-
obj.type = obj.scheme ===
|
|
129
|
+
obj.type = obj.scheme === "ED25519" ? "SOLANA" : "EVM";
|
|
129
130
|
}
|
|
130
131
|
return obj;
|
|
131
132
|
}
|
|
133
|
+
function supportedWalletTypesEq(a, b) {
|
|
134
|
+
return a.length === b.length && a.every(({ type, optional }, index) => b[index].type === type && b[index].optional === optional);
|
|
135
|
+
}
|
|
136
|
+
function mergeCurrentWalletIds(original, additional) {
|
|
137
|
+
return [.../* @__PURE__ */ new Set([...Object.keys(original), ...Object.keys(additional)])].reduce((acc, key) => {
|
|
138
|
+
return __spreadProps(__spreadValues({}, acc), {
|
|
139
|
+
[key]: [.../* @__PURE__ */ new Set([...original[key] || [], ...additional[key] || []])]
|
|
140
|
+
});
|
|
141
|
+
}, {});
|
|
142
|
+
}
|
|
132
143
|
function newUuid() {
|
|
133
144
|
return uuid.v4();
|
|
134
145
|
}
|
|
@@ -141,6 +152,8 @@ function newUuid() {
|
|
|
141
152
|
getWalletTypes,
|
|
142
153
|
isPregenIdentifierMatch,
|
|
143
154
|
isWalletSupported,
|
|
155
|
+
mergeCurrentWalletIds,
|
|
144
156
|
migrateWallet,
|
|
145
|
-
newUuid
|
|
157
|
+
newUuid,
|
|
158
|
+
supportedWalletTypesEq
|
|
146
159
|
});
|