@getpara/core-sdk 1.12.0 → 2.0.0-alpha.11

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 (55) hide show
  1. package/dist/cjs/ParaCore.js +942 -975
  2. package/dist/cjs/constants.js +7 -1
  3. package/dist/cjs/index.js +15 -3
  4. package/dist/cjs/types/coreApi.js +74 -0
  5. package/dist/cjs/types/events.js +1 -0
  6. package/dist/cjs/types/index.js +4 -2
  7. package/dist/cjs/types/{params.js → methods.js} +2 -2
  8. package/dist/cjs/utils/autobind.js +41 -0
  9. package/dist/cjs/utils/formatting.js +0 -12
  10. package/dist/cjs/utils/index.js +10 -0
  11. package/dist/cjs/utils/json.js +37 -0
  12. package/dist/cjs/utils/listeners.js +2 -11
  13. package/dist/cjs/utils/phone.js +73 -0
  14. package/dist/cjs/utils/types.js +29 -0
  15. package/dist/cjs/utils/url.js +34 -2
  16. package/dist/cjs/utils/wallet.js +30 -17
  17. package/dist/esm/ParaCore.js +959 -980
  18. package/dist/esm/constants.js +5 -1
  19. package/dist/esm/index.js +12 -3
  20. package/dist/esm/types/coreApi.js +52 -0
  21. package/dist/esm/types/events.js +1 -0
  22. package/dist/esm/types/index.js +2 -1
  23. package/dist/esm/utils/autobind.js +19 -0
  24. package/dist/esm/utils/formatting.js +0 -10
  25. package/dist/esm/utils/index.js +5 -0
  26. package/dist/esm/utils/json.js +15 -0
  27. package/dist/esm/utils/listeners.js +2 -11
  28. package/dist/esm/utils/phone.js +39 -0
  29. package/dist/esm/utils/types.js +7 -0
  30. package/dist/esm/utils/url.js +15 -2
  31. package/dist/esm/utils/wallet.js +27 -16
  32. package/dist/types/ParaCore.d.ts +100 -391
  33. package/dist/types/PlatformUtils.d.ts +3 -3
  34. package/dist/types/constants.d.ts +2 -0
  35. package/dist/types/external/userManagementClient.d.ts +1 -1
  36. package/dist/types/index.d.ts +5 -3
  37. package/dist/types/types/config.d.ts +4 -24
  38. package/dist/types/types/coreApi.d.ts +475 -0
  39. package/dist/types/types/events.d.ts +4 -1
  40. package/dist/types/types/index.d.ts +2 -1
  41. package/dist/types/types/methods.d.ts +148 -0
  42. package/dist/types/types/onRamps.d.ts +3 -3
  43. package/dist/types/types/wallet.d.ts +4 -4
  44. package/dist/types/utils/autobind.d.ts +1 -0
  45. package/dist/types/utils/formatting.d.ts +2 -4
  46. package/dist/types/utils/index.d.ts +5 -0
  47. package/dist/types/utils/json.d.ts +1 -0
  48. package/dist/types/utils/onRamps.d.ts +3 -3
  49. package/dist/types/utils/phone.d.ts +11 -0
  50. package/dist/types/utils/types.d.ts +2 -0
  51. package/dist/types/utils/url.d.ts +2 -1
  52. package/dist/types/utils/wallet.d.ts +9 -7
  53. package/package.json +4 -3
  54. package/dist/types/types/params.d.ts +0 -73
  55. /package/dist/esm/types/{params.js → methods.js} +0 -0
@@ -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 = "1.12.0";
42
+ const PARA_CORE_VERSION = "2.0.0-alpha.10";
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,6 +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
+ OAUTH_METHODS: () => import_user_management_client.OAUTH_METHODS,
36
37
  OAuthMethod: () => import_user_management_client.OAuthMethod,
37
38
  OnRampAsset: () => import_user_management_client.OnRampAsset,
38
39
  OnRampMethod: () => import_types.OnRampMethod,
@@ -44,8 +45,11 @@ __export(src_exports, {
44
45
  PregenIdentifierType: () => import_types.PregenIdentifierType,
45
46
  RecoveryStatus: () => import_types.RecoveryStatus,
46
47
  STORAGE_PREFIX: () => import_constants.PREFIX,
48
+ WALLET_SCHEMES: () => import_user_management_client.WALLET_SCHEMES,
49
+ WALLET_TYPES: () => import_user_management_client.WALLET_TYPES,
47
50
  WalletScheme: () => import_user_management_client.WalletScheme,
48
51
  WalletType: () => import_user_management_client.WalletType,
52
+ constructUrl: () => import_utils.constructUrl,
49
53
  decryptPrivateKey: () => import_utils2.decryptPrivateKey,
50
54
  decryptPrivateKeyAndDecryptShare: () => import_utils2.decryptPrivateKeyAndDecryptShare,
51
55
  decryptPrivateKeyWithPassword: () => import_utils2.decryptPrivateKeyWithPassword,
@@ -75,7 +79,7 @@ __export(src_exports, {
75
79
  mpcComputationClient: () => mpcComputationClient,
76
80
  paraVersion: () => paraVersion,
77
81
  publicKeyFromHex: () => import_utils2.publicKeyFromHex,
78
- stringToPhoneNumber: () => import_utils.stringToPhoneNumber,
82
+ shortenUrl: () => import_utils.shortenUrl,
79
83
  toAssetInfoArray: () => import_onRamps.toAssetInfoArray,
80
84
  transmissionUtilsRetrieve: () => import_transmissionUtils.retrieve
81
85
  });
@@ -83,6 +87,7 @@ module.exports = __toCommonJS(src_exports);
83
87
  var import_ParaCore = require("./ParaCore.js");
84
88
  var import_user_management_client = require("@getpara/user-management-client");
85
89
  var import_types = require("./types/index.js");
90
+ __reExport(src_exports, require("./types/coreApi.js"), module.exports);
86
91
  __reExport(src_exports, require("./types/events.js"), module.exports);
87
92
  __reExport(src_exports, require("./types/config.js"), module.exports);
88
93
  var import_utils = require("./utils/index.js");
@@ -96,6 +101,7 @@ __reExport(src_exports, require("./external/userManagementClient.js"), module.ex
96
101
  __reExport(src_exports, require("./errors.js"), module.exports);
97
102
  __reExport(src_exports, require("./utils/formatting.js"), module.exports);
98
103
  __reExport(src_exports, require("./utils/polling.js"), module.exports);
104
+ __reExport(src_exports, require("./utils/phone.js"), module.exports);
99
105
  var import_wallet = require("./utils/wallet.js");
100
106
  var import_onRamps = require("./utils/onRamps.js");
101
107
  var import_url = require("./utils/url.js");
@@ -109,6 +115,7 @@ var src_default = import_ParaCore.ParaCore;
109
115
  KeyContainer,
110
116
  NON_ED25519,
111
117
  Network,
118
+ OAUTH_METHODS,
112
119
  OAuthMethod,
113
120
  OnRampAsset,
114
121
  OnRampMethod,
@@ -120,8 +127,11 @@ var src_default = import_ParaCore.ParaCore;
120
127
  PregenIdentifierType,
121
128
  RecoveryStatus,
122
129
  STORAGE_PREFIX,
130
+ WALLET_SCHEMES,
131
+ WALLET_TYPES,
123
132
  WalletScheme,
124
133
  WalletType,
134
+ constructUrl,
125
135
  decryptPrivateKey,
126
136
  decryptPrivateKeyAndDecryptShare,
127
137
  decryptPrivateKeyWithPassword,
@@ -150,13 +160,15 @@ var src_default = import_ParaCore.ParaCore;
150
160
  mpcComputationClient,
151
161
  paraVersion,
152
162
  publicKeyFromHex,
153
- stringToPhoneNumber,
163
+ shortenUrl,
154
164
  toAssetInfoArray,
155
165
  transmissionUtilsRetrieve,
166
+ ...require("./types/coreApi.js"),
156
167
  ...require("./types/events.js"),
157
168
  ...require("./types/config.js"),
158
169
  ...require("./external/userManagementClient.js"),
159
170
  ...require("./errors.js"),
160
171
  ...require("./utils/formatting.js"),
161
- ...require("./utils/polling.js")
172
+ ...require("./utils/polling.js"),
173
+ ...require("./utils/phone.js")
162
174
  });
@@ -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
+ });
@@ -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:
@@ -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("./params.js"), module.exports);
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("./params.js"),
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 params_exports = {};
15
- module.exports = __toCommonJS(params_exports);
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
  });
@@ -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.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();
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,73 @@
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
+ splitPhoneNumber: () => splitPhoneNumber
33
+ });
34
+ module.exports = __toCommonJS(phone_exports);
35
+ var import_libphonenumber_js = __toESM(require("libphonenumber-js"));
36
+ function formatPhoneNumber(phone, countryCode, { forDisplay = false } = {}) {
37
+ phone = phone.toString();
38
+ countryCode = countryCode == null ? void 0 : countryCode.toString();
39
+ let sanitizedNumber, parsedNumber;
40
+ if (!!countryCode) {
41
+ sanitizedNumber = phone.replace(/\D/g, "");
42
+ if (/^\+\d+$/.test(countryCode)) {
43
+ countryCode = countryCode.slice(1);
44
+ }
45
+ parsedNumber = (0, import_libphonenumber_js.default)(sanitizedNumber, { defaultCallingCode: countryCode });
46
+ } else {
47
+ sanitizedNumber = `+${phone.replace(/\D/g, "")}`;
48
+ parsedNumber = (0, import_libphonenumber_js.default)(sanitizedNumber);
49
+ }
50
+ if (parsedNumber == null ? void 0 : parsedNumber.isValid()) {
51
+ return forDisplay ? parsedNumber.formatInternational() : parsedNumber.formatInternational().replace(/[^\d+]/g, "");
52
+ }
53
+ return null;
54
+ }
55
+ function displayPhoneNumber(phone, countryCode) {
56
+ return formatPhoneNumber(phone, countryCode, { forDisplay: true });
57
+ }
58
+ function splitPhoneNumber(phone) {
59
+ const parsedNumber = (0, import_libphonenumber_js.default)(phone);
60
+ if (parsedNumber == null ? void 0 : parsedNumber.isValid()) {
61
+ return {
62
+ phone: parsedNumber.nationalNumber.replace(/\D/g, ""),
63
+ countryCode: `+${parsedNumber.countryCallingCode}`
64
+ };
65
+ }
66
+ throw new Error("Invalid phone number");
67
+ }
68
+ // Annotate the CommonJS export names for ESM import in node:
69
+ 0 && (module.exports = {
70
+ displayPhoneNumber,
71
+ formatPhoneNumber,
72
+ splitPhoneNumber
73
+ });
@@ -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
+ });
@@ -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
  });