@getpara/core-sdk 1.0.1 → 1.1.0

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 (65) hide show
  1. package/dist/cjs/ParaCore.js +132 -224
  2. package/dist/cjs/constants.js +20 -0
  3. package/dist/cjs/cryptography/utils.js +2 -2
  4. package/dist/cjs/external/userManagementClient.js +14 -14
  5. package/dist/cjs/index.js +28 -12
  6. package/dist/cjs/types/config.js +22 -0
  7. package/dist/cjs/types/index.js +11 -2
  8. package/dist/cjs/types/onRamps.js +10 -0
  9. package/dist/cjs/types/recovery.js +12 -0
  10. package/dist/cjs/types/wallet.js +9 -0
  11. package/dist/cjs/utils/events.js +9 -0
  12. package/dist/cjs/utils/{formattingUtils.js → formatting.js} +11 -1
  13. package/dist/cjs/utils/index.js +22 -0
  14. package/dist/cjs/utils/onRamps.js +36 -0
  15. package/dist/cjs/utils/url.js +74 -0
  16. package/dist/cjs/utils/wallet.js +74 -0
  17. package/dist/esm/ParaCore.js +82 -167
  18. package/dist/esm/constants.js +17 -0
  19. package/dist/esm/cryptography/utils.js +1 -1
  20. package/dist/esm/external/userManagementClient.js +1 -1
  21. package/dist/esm/index.js +12 -8
  22. package/dist/esm/types/config.js +19 -0
  23. package/dist/esm/types/index.js +6 -2
  24. package/dist/esm/types/onRamps.js +7 -0
  25. package/dist/esm/types/recovery.js +9 -0
  26. package/dist/esm/types/wallet.js +6 -0
  27. package/dist/esm/utils/events.js +5 -0
  28. package/dist/esm/utils/{formattingUtils.js → formatting.js} +8 -0
  29. package/dist/esm/utils/index.js +6 -0
  30. package/dist/esm/utils/onRamps.js +30 -0
  31. package/dist/esm/utils/url.js +66 -0
  32. package/dist/esm/utils/wallet.js +64 -0
  33. package/dist/types/ParaCore.d.ts +4 -167
  34. package/dist/types/PlatformUtils.d.ts +1 -3
  35. package/dist/types/constants.d.ts +17 -0
  36. package/dist/types/cryptography/utils.d.ts +1 -1
  37. package/dist/types/external/userManagementClient.d.ts +1 -1
  38. package/dist/types/index.d.ts +12 -10
  39. package/dist/types/shares/recovery.d.ts +1 -1
  40. package/dist/types/shares/shareDistribution.d.ts +1 -1
  41. package/dist/types/types/config.d.ts +162 -0
  42. package/dist/types/types/events.d.ts +10 -10
  43. package/dist/types/types/index.d.ts +6 -2
  44. package/dist/types/types/onRamps.d.ts +10 -0
  45. package/dist/types/types/recovery.d.ts +7 -0
  46. package/dist/types/types/wallet.d.ts +39 -0
  47. package/dist/types/utils/events.d.ts +2 -0
  48. package/dist/types/utils/{formattingUtils.d.ts → formatting.d.ts} +3 -1
  49. package/dist/types/utils/index.d.ts +6 -0
  50. package/dist/types/utils/onRamps.d.ts +12 -0
  51. package/dist/types/utils/url.d.ts +15 -0
  52. package/dist/types/utils/wallet.d.ts +10 -0
  53. package/package.json +3 -3
  54. package/dist/cjs/definitions.js +0 -153
  55. package/dist/cjs/types/walletTypes.js +0 -2
  56. package/dist/esm/definitions.js +0 -140
  57. package/dist/esm/types/walletTypes.js +0 -1
  58. package/dist/types/definitions.d.ts +0 -86
  59. package/dist/types/types/walletTypes.d.ts +0 -11
  60. /package/dist/cjs/types/{popupTypes.js → popup.js} +0 -0
  61. /package/dist/cjs/utils/{pollingUtils.js → polling.js} +0 -0
  62. /package/dist/esm/types/{popupTypes.js → popup.js} +0 -0
  63. /package/dist/esm/utils/{pollingUtils.js → polling.js} +0 -0
  64. /package/dist/types/types/{popupTypes.d.ts → popup.d.ts} +0 -0
  65. /package/dist/types/utils/{pollingUtils.d.ts → polling.d.ts} +0 -0
@@ -58,132 +58,32 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
58
58
  };
59
59
  var _ParaCore_supportedWalletTypes, _ParaCore_supportedWalletTypesOpt;
60
60
  Object.defineProperty(exports, "__esModule", { value: true });
61
- exports.ParaCore = exports.isCosmosRequired = exports.getEquivalentTypes = exports.getWalletTypes = exports.isWalletSupported = exports.normalizePhoneNumber = exports.stringToPhoneNumber = exports.PREFIX = exports.PregenIdentifierType = exports.RecoveryStatus = exports.entityToWallet = void 0;
61
+ exports.ParaCore = void 0;
62
+ const buffer_1 = require("buffer");
63
+ if (typeof global !== 'undefined') {
64
+ global.Buffer = global.Buffer || buffer_1.Buffer;
65
+ }
66
+ else if (typeof window !== 'undefined') {
67
+ window.Buffer = window.Buffer || buffer_1.Buffer;
68
+ window.global = window.global || window;
69
+ }
70
+ else {
71
+ self.Buffer = self.Buffer || buffer_1.Buffer;
72
+ self.global = self.global || self;
73
+ }
62
74
  const user_management_client_1 = require("@getpara/user-management-client");
63
75
  const node_forge_1 = __importDefault(require("node-forge"));
64
76
  const { pki, jsbn } = node_forge_1.default;
65
77
  const utils_js_1 = require("./cryptography/utils.js");
66
- const definitions_js_1 = require("./definitions.js");
67
78
  const userManagementClient_js_1 = require("./external/userManagementClient.js");
68
79
  const mpcComputationClient = __importStar(require("./external/mpcComputationClient.js"));
69
80
  const shareDistribution_js_1 = require("./shares/shareDistribution.js");
70
81
  const index_js_1 = require("./types/index.js");
71
82
  const transmissionUtils = __importStar(require("./transmission/transmissionUtils.js"));
72
83
  const recovery_js_1 = require("./shares/recovery.js");
73
- const libphonenumber_js_1 = __importDefault(require("libphonenumber-js"));
74
- const formattingUtils_js_1 = require("./utils/formattingUtils.js");
84
+ const index_js_2 = require("./utils/index.js");
75
85
  const errors_js_1 = require("./errors.js");
76
- const PARA_CORE_VERSION = '1.0.1';
77
- function dispatchEvent(type, data, error) {
78
- typeof window !== 'undefined' &&
79
- !!window.dispatchEvent &&
80
- window.dispatchEvent(new CustomEvent(type, { detail: Object.assign({ data }, (error && { error: new Error(error) })) }));
81
- }
82
- function isPregenIdentifierMatch(a, b, type) {
83
- if (!a || !b) {
84
- return false;
85
- }
86
- switch (type) {
87
- case 'EMAIL':
88
- return a.toLowerCase() === b.toLowerCase();
89
- case 'PHONE':
90
- return stringToPhoneNumber(a) === stringToPhoneNumber(b);
91
- case 'CUSTOM_ID':
92
- return a === b;
93
- default:
94
- return a.replace(/^@/g, '').toLowerCase() === b.replace(/^@/g, '').toLowerCase();
95
- }
96
- }
97
- function entityToWallet(w) {
98
- return Object.assign(Object.assign({}, w), { scheme: w.scheme, type: w.type, pregenIdentifierType: w.pregenIdentifierType });
99
- }
100
- exports.entityToWallet = entityToWallet;
101
- function migrateWallet(obj) {
102
- if (['USER', 'PREGEN'].includes(obj.type)) {
103
- obj.isPregen = obj.type === 'PREGEN';
104
- obj.type = obj.scheme === user_management_client_1.WalletScheme.ED25519 ? user_management_client_1.WalletType.SOLANA : user_management_client_1.WalletType.EVM;
105
- }
106
- if (!!obj.scheme && !obj.type) {
107
- obj.type = obj.scheme === user_management_client_1.WalletScheme.ED25519 ? user_management_client_1.WalletType.SOLANA : user_management_client_1.WalletType.EVM;
108
- }
109
- return obj;
110
- }
111
- // Make sure to keep this in sync with capsule-org/src/entities/recoveryAttemptEntity.ts
112
- var RecoveryStatus;
113
- (function (RecoveryStatus) {
114
- RecoveryStatus["INITIATED"] = "INITIATED";
115
- RecoveryStatus["READY"] = "READY";
116
- RecoveryStatus["EXPIRED"] = "EXPIRED";
117
- RecoveryStatus["FINISHED"] = "FINISHED";
118
- RecoveryStatus["CANCELLED"] = "CANCELLED";
119
- })(RecoveryStatus || (exports.RecoveryStatus = RecoveryStatus = {}));
120
- /** @deprecated */
121
- var PregenIdentifierType;
122
- (function (PregenIdentifierType) {
123
- PregenIdentifierType["EMAIL"] = "EMAIL";
124
- PregenIdentifierType["PHONE"] = "PHONE";
125
- })(PregenIdentifierType || (exports.PregenIdentifierType = PregenIdentifierType = {}));
126
- exports.PREFIX = '@CAPSULE/';
127
- const LOCAL_STORAGE_EMAIL = `${exports.PREFIX}e-mail`;
128
- const LOCAL_STORAGE_PHONE = `${exports.PREFIX}phone`;
129
- const LOCAL_STORAGE_COUNTRY_CODE = `${exports.PREFIX}countryCode`;
130
- const LOCAL_STORAGE_FARCASTER_USERNAME = `${exports.PREFIX}farcasterUsername`;
131
- const LOCAL_STORAGE_TELEGRAM_USER_ID = `${exports.PREFIX}telegramUserId`;
132
- const LOCAL_STORAGE_USER_ID = `${exports.PREFIX}userId`;
133
- const LOCAL_STORAGE_ED25519_WALLETS = `${exports.PREFIX}ed25519Wallets`;
134
- const LOCAL_STORAGE_WALLETS = `${exports.PREFIX}wallets`;
135
- const LOCAL_STORAGE_EXTERNAL_WALLETS = `${exports.PREFIX}externalWallets`;
136
- const LOCAL_STORAGE_CURRENT_WALLET_IDS = `${exports.PREFIX}currentWalletIds`;
137
- const LOCAL_STORAGE_CURRENT_EXTERNAL_WALLET_ADDRESSES = `${exports.PREFIX}currentExternalWalletAddresses`;
138
- const LOCAL_STORAGE_SESSION_COOKIE = `${exports.PREFIX}sessionCookie`;
139
- const SESSION_STORAGE_LOGIN_ENCRYPTION_KEY_PAIR = `${exports.PREFIX}loginEncryptionKeyPair`;
140
- const POLLING_INTERVAL_MS = 2000;
141
- const SHORT_POLLING_INTERVAL_MS = 1000;
142
- function stringToPhoneNumber(str) {
143
- var _a;
144
- return (_a = (0, libphonenumber_js_1.default)(str)) === null || _a === void 0 ? void 0 : _a.formatInternational().replace(/[^\d+]/g, '');
145
- }
146
- exports.stringToPhoneNumber = stringToPhoneNumber;
147
- function normalizePhoneNumber(countryCode, number) {
148
- return stringToPhoneNumber(`${countryCode[0] !== '+' ? '+' : ''}${countryCode}${number}`);
149
- }
150
- exports.normalizePhoneNumber = normalizePhoneNumber;
151
- function isWalletSupported(types, wallet) {
152
- return types.some((walletType) => !!definitions_js_1.WalletSchemeTypeMap[wallet.scheme][walletType]);
153
- }
154
- exports.isWalletSupported = isWalletSupported;
155
- function getSchemes(types) {
156
- return Object.keys(definitions_js_1.WalletSchemeTypeMap).filter(scheme => {
157
- if (scheme === user_management_client_1.WalletScheme.CGGMP) {
158
- return false;
159
- }
160
- return (Array.isArray(types) ? types : Object.keys(types)).some(type => definitions_js_1.WalletSchemeTypeMap[scheme][type]);
161
- });
162
- }
163
- function getWalletTypes(schemes) {
164
- return [
165
- ...new Set(schemes.reduce((acc, scheme) => {
166
- return [...acc, ...Object.keys(definitions_js_1.WalletSchemeTypeMap[scheme]).filter(type => definitions_js_1.WalletSchemeTypeMap[scheme][type])];
167
- }, [])),
168
- ];
169
- }
170
- exports.getWalletTypes = getWalletTypes;
171
- function getEquivalentTypes(types) {
172
- return getWalletTypes(getSchemes((Array.isArray(types) ? types : [types]).map(t => user_management_client_1.WalletType[t])));
173
- }
174
- exports.getEquivalentTypes = getEquivalentTypes;
175
- function isCosmosRequired(supportedWalletTypes) {
176
- return supportedWalletTypes.some(({ type, optional }) => type === user_management_client_1.WalletType.COSMOS && !optional);
177
- }
178
- exports.isCosmosRequired = isCosmosRequired;
179
- function constructUrl({ base, path, params = {}, }) {
180
- const url = new URL(path, base);
181
- Object.entries(params).forEach(([key, value]) => {
182
- if (!!value && value !== 'undefined' && value !== 'null')
183
- url.searchParams.set(key, value.toString());
184
- });
185
- return url.toString();
186
- }
86
+ const constants = __importStar(require("./constants.js"));
187
87
  class ParaCore {
188
88
  get isEmail() {
189
89
  return !!this.email && !this.phone && !this.countryCode && !this.farcasterUsername && !this.telegramUserId;
@@ -256,11 +156,17 @@ class ParaCore {
256
156
  };
257
157
  }
258
158
  isPortal(envOverride) {
259
- return (typeof window !== 'undefined' &&
260
- (0, definitions_js_1.getPortalBaseURL)(envOverride ? { env: envOverride } : this.ctx).includes(window.location.host));
159
+ var _a;
160
+ if (typeof window === 'undefined')
161
+ return false;
162
+ return (!!((_a = window.location) === null || _a === void 0 ? void 0 : _a.host) &&
163
+ (0, index_js_2.getPortalBaseURL)(envOverride ? { env: envOverride } : this.ctx).includes(window.location.host));
261
164
  }
262
165
  isParaConnect() {
263
- return typeof window !== 'undefined' && (0, definitions_js_1.getParaConnectBaseUrl)(this.ctx).includes(window.location.host);
166
+ var _a;
167
+ if (typeof window === 'undefined')
168
+ return false;
169
+ return !!((_a = window.location) === null || _a === void 0 ? void 0 : _a.host) && (0, index_js_2.getParaConnectBaseUrl)(this.ctx).includes(window.location.host);
264
170
  }
265
171
  requireApiKey() {
266
172
  if (!this.ctx.apiKey) {
@@ -270,7 +176,7 @@ class ParaCore {
270
176
  }
271
177
  isWalletSupported(wallet) {
272
178
  var _a;
273
- return !__classPrivateFieldGet(this, _ParaCore_supportedWalletTypes, "f") || isWalletSupported((_a = this.supportedWalletTypes.map(({ type }) => type)) !== null && _a !== void 0 ? _a : [], wallet);
179
+ return !__classPrivateFieldGet(this, _ParaCore_supportedWalletTypes, "f") || (0, index_js_2.isWalletSupported)((_a = this.supportedWalletTypes.map(({ type }) => type)) !== null && _a !== void 0 ? _a : [], wallet);
274
180
  }
275
181
  isWalletOwned(wallet) {
276
182
  return (this.isWalletSupported(wallet) &&
@@ -287,7 +193,7 @@ class ParaCore {
287
193
  return (this.isWalletSupported(wallet) &&
288
194
  this.isPregenWalletUnclaimed(wallet) &&
289
195
  (!['EMAIL', 'PHONE', 'TELEGRAM'].includes(wallet.pregenIdentifierType) ||
290
- isPregenIdentifierMatch(wallet.pregenIdentifierType === 'EMAIL'
196
+ (0, index_js_2.isPregenIdentifierMatch)(wallet.pregenIdentifierType === 'EMAIL'
291
197
  ? this.email
292
198
  : wallet.pregenIdentifierType === 'TELEGRAM'
293
199
  ? this.telegramUserId
@@ -311,7 +217,7 @@ class ParaCore {
311
217
  error = `wallet with id ${wallet.id} and type ${wallet.type} is not supported, supported types are: ${this.supportedWalletTypes.map(({ type }) => type).join(', ')}`;
312
218
  }
313
219
  else if (types &&
314
- (!getEquivalentTypes(types).includes(wallet.type) ||
220
+ (!(0, index_js_2.getEquivalentTypes)(types).includes(wallet.type) ||
315
221
  (isOwned && !types.some(type => { var _a; return ((_a = this.currentWalletIds[type]) !== null && _a !== void 0 ? _a : []).includes(walletId); })))) {
316
222
  error = `wallet with id ${wallet.id} and type ${wallet.type} cannot be selected`;
317
223
  }
@@ -339,7 +245,7 @@ class ParaCore {
339
245
  var _a;
340
246
  if (this.externalWallets[walletId]) {
341
247
  const wallet = this.externalWallets[walletId];
342
- return options.truncate ? (0, formattingUtils_js_1.truncateAddress)(wallet.address, wallet.type, { prefix: this.cosmosPrefix }) : wallet.address;
248
+ return options.truncate ? (0, index_js_2.truncateAddress)(wallet.address, wallet.type, { prefix: this.cosmosPrefix }) : wallet.address;
343
249
  }
344
250
  const wallet = this.findWallet(walletId, options.addressType);
345
251
  if (!wallet) {
@@ -348,13 +254,13 @@ class ParaCore {
348
254
  let str;
349
255
  switch (wallet.type) {
350
256
  case user_management_client_1.WalletType.COSMOS:
351
- str = (0, formattingUtils_js_1.getCosmosAddress)(wallet.publicKey, (_a = this.cosmosPrefix) !== null && _a !== void 0 ? _a : 'cosmos');
257
+ str = (0, index_js_2.getCosmosAddress)(wallet.publicKey, (_a = this.cosmosPrefix) !== null && _a !== void 0 ? _a : 'cosmos');
352
258
  break;
353
259
  default:
354
260
  str = wallet.address;
355
261
  break;
356
262
  }
357
- return options.truncate ? (0, formattingUtils_js_1.truncateAddress)(str, wallet.type, { prefix: this.cosmosPrefix }) : str;
263
+ return options.truncate ? (0, index_js_2.truncateAddress)(str, wallet.type, { prefix: this.cosmosPrefix }) : str;
358
264
  }
359
265
  /**
360
266
  * Returns a unique hash for a wallet suitable for use as an identicon seed.
@@ -380,7 +286,7 @@ class ParaCore {
380
286
  constructPortalUrl(type, opts = {}) {
381
287
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
382
288
  return __awaiter(this, void 0, void 0, function* () {
383
- const base = type === 'onRamp' ? (0, definitions_js_1.getPortalBaseURL)(this.ctx) : yield this.getPortalURL(opts.partnerId);
289
+ const base = type === 'onRamp' ? (0, index_js_2.getPortalBaseURL)(this.ctx) : yield this.getPortalURL(opts.partnerId);
384
290
  let path;
385
291
  switch (type) {
386
292
  case 'createPassword': {
@@ -433,7 +339,7 @@ class ParaCore {
433
339
  pfpUrl: opts.pfpUrl,
434
340
  }
435
341
  : {})), (opts.params || {}));
436
- return constructUrl({ base, path, params });
342
+ return (0, index_js_2.constructUrl)({ base, path, params });
437
343
  });
438
344
  }
439
345
  /**
@@ -479,10 +385,10 @@ class ParaCore {
479
385
  */
480
386
  this.clearStorage = (type = 'all') => __awaiter(this, void 0, void 0, function* () {
481
387
  const isAll = type === 'all';
482
- (isAll || type === 'local') && this.platformUtils.localStorage.clear(exports.PREFIX);
483
- (isAll || type === 'session') && this.platformUtils.sessionStorage.clear(exports.PREFIX);
388
+ (isAll || type === 'local') && this.platformUtils.localStorage.clear(constants.PREFIX);
389
+ (isAll || type === 'session') && this.platformUtils.sessionStorage.clear(constants.PREFIX);
484
390
  if ((isAll || type === 'secure') && this.platformUtils.secureStorage) {
485
- this.platformUtils.secureStorage.clear(exports.PREFIX);
391
+ this.platformUtils.secureStorage.clear(constants.PREFIX);
486
392
  }
487
393
  });
488
394
  /**
@@ -525,7 +431,7 @@ class ParaCore {
525
431
  }
526
432
  this.persistSessionCookie = (cookie) => {
527
433
  this.sessionCookie = cookie;
528
- (opts.useSessionStorage ? this.sessionStorageSetItem : this.localStorageSetItem)(LOCAL_STORAGE_SESSION_COOKIE, cookie);
434
+ (opts.useSessionStorage ? this.sessionStorageSetItem : this.localStorageSetItem)(constants.LOCAL_STORAGE_SESSION_COOKIE, cookie);
529
435
  };
530
436
  this.ctx = {
531
437
  env,
@@ -582,34 +488,34 @@ class ParaCore {
582
488
  if (!this.platformUtils.isSyncStorage || opts.useStorageOverrides) {
583
489
  return;
584
490
  }
585
- this.email = this.localStorageGetItem(LOCAL_STORAGE_EMAIL) || undefined;
586
- this.countryCode = this.localStorageGetItem(LOCAL_STORAGE_COUNTRY_CODE) || undefined;
587
- this.phone = this.localStorageGetItem(LOCAL_STORAGE_PHONE) || undefined;
588
- this.userId = this.localStorageGetItem(LOCAL_STORAGE_USER_ID) || undefined;
589
- this.telegramUserId = this.localStorageGetItem(LOCAL_STORAGE_TELEGRAM_USER_ID) || undefined;
491
+ this.email = this.localStorageGetItem(constants.LOCAL_STORAGE_EMAIL) || undefined;
492
+ this.countryCode = this.localStorageGetItem(constants.LOCAL_STORAGE_COUNTRY_CODE) || undefined;
493
+ this.phone = this.localStorageGetItem(constants.LOCAL_STORAGE_PHONE) || undefined;
494
+ this.userId = this.localStorageGetItem(constants.LOCAL_STORAGE_USER_ID) || undefined;
495
+ this.telegramUserId = this.localStorageGetItem(constants.LOCAL_STORAGE_TELEGRAM_USER_ID) || undefined;
590
496
  const stringWallets = this.platformUtils.secureStorage
591
- ? this.platformUtils.secureStorage.get(LOCAL_STORAGE_WALLETS)
592
- : this.localStorageGetItem(LOCAL_STORAGE_WALLETS);
497
+ ? this.platformUtils.secureStorage.get(constants.LOCAL_STORAGE_WALLETS)
498
+ : this.localStorageGetItem(constants.LOCAL_STORAGE_WALLETS);
593
499
  const _wallets = JSON.parse(stringWallets || '{}');
594
500
  const stringEd25519Wallets = this.platformUtils.secureStorage
595
- ? this.platformUtils.secureStorage.get(LOCAL_STORAGE_ED25519_WALLETS)
596
- : this.localStorageGetItem(LOCAL_STORAGE_ED25519_WALLETS);
501
+ ? this.platformUtils.secureStorage.get(constants.LOCAL_STORAGE_ED25519_WALLETS)
502
+ : this.localStorageGetItem(constants.LOCAL_STORAGE_ED25519_WALLETS);
597
503
  const _ed25519Wallets = JSON.parse(stringEd25519Wallets || '{}');
598
504
  const wallets = Object.assign(Object.assign({}, Object.keys(_wallets).reduce((res, key) => {
599
- return Object.assign(Object.assign({}, res), { [key]: migrateWallet(_wallets[key]) });
505
+ return Object.assign(Object.assign({}, res), { [key]: (0, index_js_2.migrateWallet)(_wallets[key]) });
600
506
  }, {})), Object.keys(_ed25519Wallets).reduce((res, key) => {
601
- return Object.assign(Object.assign({}, res), (!res[key] ? { [key]: migrateWallet(_ed25519Wallets[key]) } : {}));
507
+ return Object.assign(Object.assign({}, res), (!res[key] ? { [key]: (0, index_js_2.migrateWallet)(_ed25519Wallets[key]) } : {}));
602
508
  }, {}));
603
509
  this.setWallets(wallets);
604
510
  // TODO: Improve not great check
605
- const _currentWalletIds = (_a = this.localStorageGetItem(LOCAL_STORAGE_CURRENT_WALLET_IDS)) !== null && _a !== void 0 ? _a : undefined;
511
+ const _currentWalletIds = (_a = this.localStorageGetItem(constants.LOCAL_STORAGE_CURRENT_WALLET_IDS)) !== null && _a !== void 0 ? _a : undefined;
606
512
  const currentWalletIds = [undefined, null, 'undefined'].includes(_currentWalletIds)
607
513
  ? {}
608
514
  : (() => {
609
515
  const fromJson = JSON.parse(_currentWalletIds);
610
516
  return Array.isArray(fromJson)
611
517
  ? Object.keys(user_management_client_1.WalletType).reduce((acc, type) => {
612
- const wallet = Object.values(this.wallets).find(w => fromJson.includes(w.id) && definitions_js_1.WalletSchemeTypeMap[w.scheme][type]);
518
+ const wallet = Object.values(this.wallets).find(w => fromJson.includes(w.id) && index_js_2.WalletSchemeTypeMap[w.scheme][type]);
613
519
  return Object.assign(Object.assign({}, acc), (wallet && !acc[type] ? { [type]: [wallet.id] } : {}));
614
520
  }, {})
615
521
  : fromJson;
@@ -617,22 +523,22 @@ class ParaCore {
617
523
  this.setCurrentWalletIds(currentWalletIds);
618
524
  // TODO: remove sessionStorageGetItem call once new version is being consumed
619
525
  this.sessionCookie =
620
- this.localStorageGetItem(LOCAL_STORAGE_SESSION_COOKIE) ||
621
- this.sessionStorageGetItem(LOCAL_STORAGE_SESSION_COOKIE) ||
526
+ this.localStorageGetItem(constants.LOCAL_STORAGE_SESSION_COOKIE) ||
527
+ this.sessionStorageGetItem(constants.LOCAL_STORAGE_SESSION_COOKIE) ||
622
528
  undefined;
623
529
  // In case currentWalletIds was missing from storage
624
530
  if (Object.values(this.wallets).filter(w => this.isWalletOwned(w)).length > 0 &&
625
531
  this.currentWalletIdsArray.length === 0) {
626
532
  this.findWalletId(undefined, { forbidPregen: true });
627
533
  }
628
- const loginEncryptionKey = this.sessionStorageGetItem(SESSION_STORAGE_LOGIN_ENCRYPTION_KEY_PAIR);
534
+ const loginEncryptionKey = this.sessionStorageGetItem(constants.SESSION_STORAGE_LOGIN_ENCRYPTION_KEY_PAIR);
629
535
  if (loginEncryptionKey && loginEncryptionKey !== 'undefined') {
630
536
  this.loginEncryptionKeyPair = this.convertEncryptionKeyPair(JSON.parse(loginEncryptionKey));
631
537
  }
632
- const stringExternalWallets = this.localStorageGetItem(LOCAL_STORAGE_EXTERNAL_WALLETS);
538
+ const stringExternalWallets = this.localStorageGetItem(constants.LOCAL_STORAGE_EXTERNAL_WALLETS);
633
539
  const _externalWallets = JSON.parse(stringExternalWallets || '{}');
634
540
  this.setExternalWallets(_externalWallets);
635
- const _currentExternalWalletAddresses = this.localStorageGetItem(LOCAL_STORAGE_CURRENT_EXTERNAL_WALLET_ADDRESSES) || undefined;
541
+ const _currentExternalWalletAddresses = this.localStorageGetItem(constants.LOCAL_STORAGE_CURRENT_EXTERNAL_WALLET_ADDRESSES) || undefined;
636
542
  this.currentExternalWalletAddresses = _currentExternalWalletAddresses
637
543
  ? JSON.parse(_currentExternalWalletAddresses)
638
544
  : undefined;
@@ -688,34 +594,36 @@ class ParaCore {
688
594
  init() {
689
595
  var _a;
690
596
  return __awaiter(this, void 0, void 0, function* () {
691
- this.email = (yield this.localStorageGetItem(LOCAL_STORAGE_EMAIL)) || undefined;
692
- this.countryCode = (yield this.localStorageGetItem(LOCAL_STORAGE_COUNTRY_CODE)) || undefined;
693
- this.phone = (yield this.localStorageGetItem(LOCAL_STORAGE_PHONE)) || undefined;
694
- this.userId = (yield this.localStorageGetItem(LOCAL_STORAGE_USER_ID)) || undefined;
695
- this.telegramUserId = (yield this.localStorageGetItem(LOCAL_STORAGE_TELEGRAM_USER_ID)) || undefined;
597
+ this.email = (yield this.localStorageGetItem(constants.LOCAL_STORAGE_EMAIL)) || undefined;
598
+ this.countryCode =
599
+ (yield this.localStorageGetItem(constants.LOCAL_STORAGE_COUNTRY_CODE)) || undefined;
600
+ this.phone = (yield this.localStorageGetItem(constants.LOCAL_STORAGE_PHONE)) || undefined;
601
+ this.userId = (yield this.localStorageGetItem(constants.LOCAL_STORAGE_USER_ID)) || undefined;
602
+ this.telegramUserId =
603
+ (yield this.localStorageGetItem(constants.LOCAL_STORAGE_TELEGRAM_USER_ID)) || undefined;
696
604
  const stringWallets = this.platformUtils.secureStorage
697
- ? yield this.platformUtils.secureStorage.get(LOCAL_STORAGE_WALLETS)
698
- : yield this.localStorageGetItem(LOCAL_STORAGE_WALLETS);
605
+ ? yield this.platformUtils.secureStorage.get(constants.LOCAL_STORAGE_WALLETS)
606
+ : yield this.localStorageGetItem(constants.LOCAL_STORAGE_WALLETS);
699
607
  const _wallets = JSON.parse(stringWallets || '{}');
700
608
  const stringEd25519Wallets = this.platformUtils.secureStorage
701
- ? yield this.platformUtils.secureStorage.get(LOCAL_STORAGE_ED25519_WALLETS)
702
- : yield this.localStorageGetItem(LOCAL_STORAGE_ED25519_WALLETS);
609
+ ? yield this.platformUtils.secureStorage.get(constants.LOCAL_STORAGE_ED25519_WALLETS)
610
+ : yield this.localStorageGetItem(constants.LOCAL_STORAGE_ED25519_WALLETS);
703
611
  const _ed25519Wallets = JSON.parse(stringEd25519Wallets || '{}');
704
612
  const wallets = Object.assign(Object.assign({}, Object.keys(_wallets).reduce((res, key) => {
705
- return Object.assign(Object.assign({}, res), { [key]: migrateWallet(_wallets[key]) });
613
+ return Object.assign(Object.assign({}, res), { [key]: (0, index_js_2.migrateWallet)(_wallets[key]) });
706
614
  }, {})), Object.keys(_ed25519Wallets).reduce((res, key) => {
707
- return Object.assign(Object.assign({}, res), (!res[key] ? { [key]: migrateWallet(_ed25519Wallets[key]) } : {}));
615
+ return Object.assign(Object.assign({}, res), (!res[key] ? { [key]: (0, index_js_2.migrateWallet)(_ed25519Wallets[key]) } : {}));
708
616
  }, {}));
709
617
  yield this.setWallets(wallets);
710
618
  // TODO: Improve not great check
711
- const _currentWalletIds = (_a = (yield this.localStorageGetItem(LOCAL_STORAGE_CURRENT_WALLET_IDS))) !== null && _a !== void 0 ? _a : undefined;
619
+ const _currentWalletIds = (_a = (yield this.localStorageGetItem(constants.LOCAL_STORAGE_CURRENT_WALLET_IDS))) !== null && _a !== void 0 ? _a : undefined;
712
620
  const currentWalletIds = [undefined, null, 'undefined', 'null'].includes(_currentWalletIds)
713
621
  ? {}
714
622
  : (() => {
715
623
  const fromJson = JSON.parse(_currentWalletIds);
716
624
  return Array.isArray(fromJson)
717
625
  ? Object.keys(user_management_client_1.WalletType).reduce((acc, type) => {
718
- const wallet = Object.values(this.wallets).find(w => fromJson.includes(w.id) && definitions_js_1.WalletSchemeTypeMap[w.scheme][type]);
626
+ const wallet = Object.values(this.wallets).find(w => fromJson.includes(w.id) && index_js_2.WalletSchemeTypeMap[w.scheme][type]);
719
627
  return Object.assign(Object.assign({}, acc), (wallet && !acc[type] ? { [type]: [wallet.id] } : {}));
720
628
  }, {})
721
629
  : fromJson;
@@ -723,22 +631,22 @@ class ParaCore {
723
631
  yield this.setCurrentWalletIds(currentWalletIds);
724
632
  // TODO: remove sessionStorageGetItem call once new version is being consumed
725
633
  this.sessionCookie =
726
- (yield this.localStorageGetItem(LOCAL_STORAGE_SESSION_COOKIE)) ||
727
- (yield this.sessionStorageGetItem(LOCAL_STORAGE_SESSION_COOKIE)) ||
634
+ (yield this.localStorageGetItem(constants.LOCAL_STORAGE_SESSION_COOKIE)) ||
635
+ (yield this.sessionStorageGetItem(constants.LOCAL_STORAGE_SESSION_COOKIE)) ||
728
636
  undefined;
729
637
  // In case currentWalletIds was missing from storage
730
638
  if (Object.values(this.wallets).filter(w => this.isWalletOwned(w)).length > 0 &&
731
639
  this.currentWalletIdsArray.length === 0) {
732
640
  this.findWalletId(undefined, { forbidPregen: true });
733
641
  }
734
- const loginEncryptionKey = (yield this.sessionStorageGetItem(SESSION_STORAGE_LOGIN_ENCRYPTION_KEY_PAIR));
642
+ const loginEncryptionKey = (yield this.sessionStorageGetItem(constants.SESSION_STORAGE_LOGIN_ENCRYPTION_KEY_PAIR));
735
643
  if (loginEncryptionKey && loginEncryptionKey !== 'undefined') {
736
644
  this.loginEncryptionKeyPair = this.convertEncryptionKeyPair(JSON.parse(loginEncryptionKey));
737
645
  }
738
- const stringExternalWallets = yield this.localStorageGetItem(LOCAL_STORAGE_EXTERNAL_WALLETS);
646
+ const stringExternalWallets = yield this.localStorageGetItem(constants.LOCAL_STORAGE_EXTERNAL_WALLETS);
739
647
  const _externalWallets = JSON.parse(stringExternalWallets || '{}');
740
648
  yield this.setExternalWallets(_externalWallets);
741
- const _currentExternalWalletAddresses = (yield this.localStorageGetItem(LOCAL_STORAGE_CURRENT_EXTERNAL_WALLET_ADDRESSES)) || undefined;
649
+ const _currentExternalWalletAddresses = (yield this.localStorageGetItem(constants.LOCAL_STORAGE_CURRENT_EXTERNAL_WALLET_ADDRESSES)) || undefined;
742
650
  this.currentExternalWalletAddresses = _currentExternalWalletAddresses
743
651
  ? JSON.parse(_currentExternalWalletAddresses)
744
652
  : undefined;
@@ -752,7 +660,7 @@ class ParaCore {
752
660
  setEmail(email) {
753
661
  return __awaiter(this, void 0, void 0, function* () {
754
662
  this.email = email;
755
- yield this.localStorageSetItem(LOCAL_STORAGE_EMAIL, email);
663
+ yield this.localStorageSetItem(constants.LOCAL_STORAGE_EMAIL, email);
756
664
  });
757
665
  }
758
666
  /**
@@ -762,7 +670,7 @@ class ParaCore {
762
670
  setTelegramUserId(telegramUserId) {
763
671
  return __awaiter(this, void 0, void 0, function* () {
764
672
  this.telegramUserId = telegramUserId;
765
- yield this.localStorageSetItem(LOCAL_STORAGE_TELEGRAM_USER_ID, telegramUserId);
673
+ yield this.localStorageSetItem(constants.LOCAL_STORAGE_TELEGRAM_USER_ID, telegramUserId);
766
674
  });
767
675
  }
768
676
  /**
@@ -774,8 +682,8 @@ class ParaCore {
774
682
  return __awaiter(this, void 0, void 0, function* () {
775
683
  this.phone = phone;
776
684
  this.countryCode = countryCode;
777
- yield this.localStorageSetItem(LOCAL_STORAGE_PHONE, phone);
778
- yield this.localStorageSetItem(LOCAL_STORAGE_COUNTRY_CODE, countryCode);
685
+ yield this.localStorageSetItem(constants.LOCAL_STORAGE_PHONE, phone);
686
+ yield this.localStorageSetItem(constants.LOCAL_STORAGE_COUNTRY_CODE, countryCode);
779
687
  });
780
688
  }
781
689
  /**
@@ -785,7 +693,7 @@ class ParaCore {
785
693
  setFarcasterUsername(farcasterUsername) {
786
694
  return __awaiter(this, void 0, void 0, function* () {
787
695
  this.farcasterUsername = farcasterUsername;
788
- yield this.localStorageSetItem(LOCAL_STORAGE_FARCASTER_USERNAME, farcasterUsername);
696
+ yield this.localStorageSetItem(constants.LOCAL_STORAGE_FARCASTER_USERNAME, farcasterUsername);
789
697
  });
790
698
  }
791
699
  /**
@@ -809,7 +717,7 @@ class ParaCore {
809
717
  this.currentExternalWalletAddresses = [address];
810
718
  this.setCurrentExternalWalletAddresses(this.currentExternalWalletAddresses);
811
719
  this.setExternalWallets(this.externalWallets);
812
- dispatchEvent(index_js_1.ParaEvent.EXTERNAL_WALLET_CHANGE_EVENT, null);
720
+ (0, index_js_2.dispatchEvent)(index_js_1.ParaEvent.EXTERNAL_WALLET_CHANGE_EVENT, null);
813
721
  });
814
722
  }
815
723
  /**
@@ -819,7 +727,7 @@ class ParaCore {
819
727
  setUserId(userId) {
820
728
  return __awaiter(this, void 0, void 0, function* () {
821
729
  this.userId = userId;
822
- yield this.localStorageSetItem(LOCAL_STORAGE_USER_ID, userId);
730
+ yield this.localStorageSetItem(constants.LOCAL_STORAGE_USER_ID, userId);
823
731
  });
824
732
  }
825
733
  /**
@@ -830,10 +738,10 @@ class ParaCore {
830
738
  return __awaiter(this, void 0, void 0, function* () {
831
739
  this.wallets = wallets;
832
740
  if (this.platformUtils.secureStorage) {
833
- yield this.platformUtils.secureStorage.set(LOCAL_STORAGE_WALLETS, JSON.stringify(wallets));
741
+ yield this.platformUtils.secureStorage.set(constants.LOCAL_STORAGE_WALLETS, JSON.stringify(wallets));
834
742
  return;
835
743
  }
836
- yield this.localStorageSetItem(LOCAL_STORAGE_WALLETS, JSON.stringify(wallets));
744
+ yield this.localStorageSetItem(constants.LOCAL_STORAGE_WALLETS, JSON.stringify(wallets));
837
745
  });
838
746
  }
839
747
  /**
@@ -843,13 +751,13 @@ class ParaCore {
843
751
  setExternalWallets(externalWallets) {
844
752
  return __awaiter(this, void 0, void 0, function* () {
845
753
  this.externalWallets = externalWallets;
846
- yield this.localStorageSetItem(LOCAL_STORAGE_EXTERNAL_WALLETS, JSON.stringify(externalWallets));
754
+ yield this.localStorageSetItem(constants.LOCAL_STORAGE_EXTERNAL_WALLETS, JSON.stringify(externalWallets));
847
755
  });
848
756
  }
849
757
  setCurrentExternalWalletAddresses(currentExternalWalletAddresses) {
850
758
  return __awaiter(this, void 0, void 0, function* () {
851
759
  this.currentExternalWalletAddresses = currentExternalWalletAddresses;
852
- yield this.localStorageSetItem(LOCAL_STORAGE_CURRENT_EXTERNAL_WALLET_ADDRESSES, JSON.stringify(currentExternalWalletAddresses));
760
+ yield this.localStorageSetItem(constants.LOCAL_STORAGE_CURRENT_EXTERNAL_WALLET_ADDRESSES, JSON.stringify(currentExternalWalletAddresses));
853
761
  });
854
762
  }
855
763
  /**
@@ -862,13 +770,13 @@ class ParaCore {
862
770
  keyPair = yield (0, utils_js_1.getAsymmetricKeyPair)(this.ctx);
863
771
  }
864
772
  this.loginEncryptionKeyPair = keyPair;
865
- yield this.sessionStorageSetItem(SESSION_STORAGE_LOGIN_ENCRYPTION_KEY_PAIR, JSON.stringify(keyPair));
773
+ yield this.sessionStorageSetItem(constants.SESSION_STORAGE_LOGIN_ENCRYPTION_KEY_PAIR, JSON.stringify(keyPair));
866
774
  });
867
775
  }
868
776
  deleteLoginEncryptionKeyPair() {
869
777
  return __awaiter(this, void 0, void 0, function* () {
870
778
  this.loginEncryptionKeyPair = undefined;
871
- yield this.sessionStorageRemoveItem(SESSION_STORAGE_LOGIN_ENCRYPTION_KEY_PAIR);
779
+ yield this.sessionStorageRemoveItem(constants.SESSION_STORAGE_LOGIN_ENCRYPTION_KEY_PAIR);
872
780
  });
873
781
  }
874
782
  /**
@@ -900,7 +808,7 @@ class ParaCore {
900
808
  if (!this.phone || !this.countryCode) {
901
809
  return undefined;
902
810
  }
903
- return normalizePhoneNumber(this.countryCode, this.phone);
811
+ return (0, index_js_2.normalizePhoneNumber)(this.countryCode, this.phone);
904
812
  }
905
813
  /**
906
814
  * Gets the farcaster username associated with the `ParaCore` instance.
@@ -912,11 +820,11 @@ class ParaCore {
912
820
  setCurrentWalletIds(currentWalletIds, { needsWallet = false, sessionLookupId, newDeviceSessionLookupId, } = {}) {
913
821
  return __awaiter(this, void 0, void 0, function* () {
914
822
  this.currentWalletIds = currentWalletIds;
915
- yield this.localStorageSetItem(LOCAL_STORAGE_CURRENT_WALLET_IDS, JSON.stringify(this.currentWalletIds));
823
+ yield this.localStorageSetItem(constants.LOCAL_STORAGE_CURRENT_WALLET_IDS, JSON.stringify(this.currentWalletIds));
916
824
  if (sessionLookupId) {
917
825
  yield this.ctx.client.setCurrentWalletIds(this.getUserId(), this.currentWalletIds, needsWallet, sessionLookupId, newDeviceSessionLookupId);
918
826
  }
919
- dispatchEvent(index_js_1.ParaEvent.WALLETS_CHANGE_EVENT, null);
827
+ (0, index_js_2.dispatchEvent)(index_js_1.ParaEvent.WALLETS_CHANGE_EVENT, null);
920
828
  });
921
829
  }
922
830
  /**
@@ -1039,7 +947,7 @@ class ParaCore {
1039
947
  yield this.touchSession();
1040
948
  }
1041
949
  return (this.supportedWalletTypes
1042
- .filter(({ type: t, optional }) => !optional && Object.values(this.wallets).every(w => !this.isWalletOwned(w) || !definitions_js_1.WalletSchemeTypeMap[w.scheme][t]))
950
+ .filter(({ type: t, optional }) => !optional && Object.values(this.wallets).every(w => !this.isWalletOwned(w) || !index_js_2.WalletSchemeTypeMap[w.scheme][t]))
1043
951
  .map(({ type }) => type));
1044
952
  });
1045
953
  }
@@ -1048,7 +956,7 @@ class ParaCore {
1048
956
  if (!__classPrivateFieldGet(this, _ParaCore_supportedWalletTypes, "f")) {
1049
957
  yield this.touchSession();
1050
958
  }
1051
- return getSchemes(types !== null && types !== void 0 ? types : (yield this.getMissingTypes())).map(scheme => {
959
+ return (0, index_js_2.getSchemes)(types !== null && types !== void 0 ? types : (yield this.getMissingTypes())).map(scheme => {
1052
960
  switch (scheme) {
1053
961
  case user_management_client_1.WalletScheme.ED25519:
1054
962
  return user_management_client_1.WalletType.SOLANA;
@@ -1073,7 +981,7 @@ class ParaCore {
1073
981
  */
1074
982
  getPortalURL(partnerId) {
1075
983
  return __awaiter(this, void 0, void 0, function* () {
1076
- return (partnerId && (yield this.getPartnerURL(partnerId))) || (0, definitions_js_1.getPortalBaseURL)(this.ctx);
984
+ return (partnerId && (yield this.getPartnerURL(partnerId))) || (0, index_js_2.getPortalBaseURL)(this.ctx);
1077
985
  });
1078
986
  }
1079
987
  getWebAuthURLForCreate(_a) {
@@ -1089,8 +997,8 @@ class ParaCore {
1089
997
  });
1090
998
  }
1091
999
  getShortUrl(compressedUrl) {
1092
- return constructUrl({
1093
- base: (0, definitions_js_1.getPortalBaseURL)(this.ctx),
1000
+ return (0, index_js_2.constructUrl)({
1001
+ base: (0, index_js_2.getPortalBaseURL)(this.ctx),
1094
1002
  path: `/short/${compressedUrl}`,
1095
1003
  });
1096
1004
  }
@@ -1159,7 +1067,7 @@ class ParaCore {
1159
1067
  ? this.ctx.client.getAllWallets(this.userId)
1160
1068
  : this.ctx.client.getWallets(this.userId, true));
1161
1069
  return res.data.wallets.filter(wallet => !!wallet.address &&
1162
- (this.isParaConnect() || (!this.isParaConnect() && this.isWalletSupported(entityToWallet(wallet)))));
1070
+ (this.isParaConnect() || (!this.isParaConnect() && this.isWalletSupported((0, index_js_2.entityToWallet)(wallet)))));
1163
1071
  });
1164
1072
  }
1165
1073
  populateWalletAddresses() {
@@ -1168,7 +1076,7 @@ class ParaCore {
1168
1076
  const wallets = res.data.wallets;
1169
1077
  wallets.forEach(entity => {
1170
1078
  if (this.wallets[entity.id]) {
1171
- this.wallets[entity.id] = Object.assign(Object.assign({}, entityToWallet(entity)), this.wallets[entity.id]);
1079
+ this.wallets[entity.id] = Object.assign(Object.assign({}, (0, index_js_2.entityToWallet)(entity)), this.wallets[entity.id]);
1172
1080
  }
1173
1081
  });
1174
1082
  yield this.setWallets(this.wallets);
@@ -1179,7 +1087,7 @@ class ParaCore {
1179
1087
  const res = yield this.getPregenWallets();
1180
1088
  res.forEach(entity => {
1181
1089
  if (this.wallets[entity.id]) {
1182
- this.wallets[entity.id] = Object.assign(Object.assign({}, entityToWallet(entity)), this.wallets[entity.id]);
1090
+ this.wallets[entity.id] = Object.assign(Object.assign({}, (0, index_js_2.entityToWallet)(entity)), this.wallets[entity.id]);
1183
1091
  }
1184
1092
  });
1185
1093
  yield this.setWallets(this.wallets);
@@ -1637,10 +1545,10 @@ class ParaCore {
1637
1545
  this.isAwaitingAccountCreation = true;
1638
1546
  while (this.isAwaitingAccountCreation) {
1639
1547
  try {
1640
- yield new Promise(resolve => setTimeout(resolve, POLLING_INTERVAL_MS));
1548
+ yield new Promise(resolve => setTimeout(resolve, constants.POLLING_INTERVAL_MS));
1641
1549
  if (yield this.isSessionActive()) {
1642
1550
  this.isAwaitingAccountCreation = false;
1643
- dispatchEvent(index_js_1.ParaEvent.ACCOUNT_CREATION_EVENT, true);
1551
+ (0, index_js_2.dispatchEvent)(index_js_1.ParaEvent.ACCOUNT_CREATION_EVENT, true);
1644
1552
  return true;
1645
1553
  }
1646
1554
  }
@@ -1661,7 +1569,7 @@ class ParaCore {
1661
1569
  recoverySecret = yield this.claimPregenWallets();
1662
1570
  walletIds = this.supportedWalletTypes.reduce((acc, { type }) => {
1663
1571
  var _a;
1664
- return Object.assign(Object.assign({}, acc), { [type]: [(_a = pregenWallets.find(w => !!definitions_js_1.WalletSchemeTypeMap[w.scheme][type])) === null || _a === void 0 ? void 0 : _a.id] });
1572
+ return Object.assign(Object.assign({}, acc), { [type]: [(_a = pregenWallets.find(w => !!index_js_2.WalletSchemeTypeMap[w.scheme][type])) === null || _a === void 0 ? void 0 : _a.id] });
1665
1573
  }, {});
1666
1574
  }
1667
1575
  // After claiming any pregen wallets, create wallets for the remaining missing types
@@ -1669,7 +1577,7 @@ class ParaCore {
1669
1577
  recoverySecret = recoverySecret !== null && recoverySecret !== void 0 ? recoverySecret : created.recoverySecret;
1670
1578
  walletIds = Object.assign(Object.assign({}, walletIds), created.walletIds);
1671
1579
  const resp = { walletIds, recoverySecret };
1672
- dispatchEvent(index_js_1.ParaEvent.ACCOUNT_SETUP_EVENT, resp);
1580
+ (0, index_js_2.dispatchEvent)(index_js_1.ParaEvent.ACCOUNT_SETUP_EVENT, resp);
1673
1581
  return resp;
1674
1582
  });
1675
1583
  }
@@ -1696,7 +1604,7 @@ class ParaCore {
1696
1604
  this.isAwaitingFarcaster = true;
1697
1605
  while (this.isAwaitingFarcaster) {
1698
1606
  try {
1699
- yield new Promise(resolve => setTimeout(resolve, POLLING_INTERVAL_MS));
1607
+ yield new Promise(resolve => setTimeout(resolve, constants.POLLING_INTERVAL_MS));
1700
1608
  const res = yield this.ctx.client.getFarcasterAuthStatus();
1701
1609
  if (res.data.state === 'completed') {
1702
1610
  const { userId, userExists, username, pfpUrl } = res.data;
@@ -1727,8 +1635,8 @@ class ParaCore {
1727
1635
  return __awaiter(this, void 0, void 0, function* () {
1728
1636
  yield this.logout();
1729
1637
  const res = yield this.touchSession(true);
1730
- return constructUrl({
1731
- base: method === user_management_client_1.OAuthMethod.TELEGRAM ? (0, definitions_js_1.getPortalBaseURL)(this.ctx, true) : (0, userManagementClient_js_1.getBaseOAuthUrl)(this.ctx.env),
1638
+ return (0, index_js_2.constructUrl)({
1639
+ base: method === user_management_client_1.OAuthMethod.TELEGRAM ? (0, index_js_2.getPortalBaseURL)(this.ctx, true) : (0, userManagementClient_js_1.getBaseOAuthUrl)(this.ctx.env),
1732
1640
  path: `/auth/${method.toLowerCase()}`,
1733
1641
  params: {
1734
1642
  apiKey: this.ctx.apiKey,
@@ -1753,7 +1661,7 @@ class ParaCore {
1753
1661
  if (popupWindow === null || popupWindow === void 0 ? void 0 : popupWindow.closed) {
1754
1662
  return { isError: true, userExists: false };
1755
1663
  }
1756
- yield new Promise(resolve => setTimeout(resolve, POLLING_INTERVAL_MS));
1664
+ yield new Promise(resolve => setTimeout(resolve, constants.POLLING_INTERVAL_MS));
1757
1665
  if (this.isAwaitingOAuth) {
1758
1666
  const res = yield this.touchSession();
1759
1667
  if (res.data.userId) {
@@ -1793,11 +1701,11 @@ class ParaCore {
1793
1701
  this.isAwaitingLogin = true;
1794
1702
  while (this.isAwaitingLogin) {
1795
1703
  try {
1796
- yield new Promise(resolve => setTimeout(resolve, POLLING_INTERVAL_MS));
1704
+ yield new Promise(resolve => setTimeout(resolve, constants.POLLING_INTERVAL_MS));
1797
1705
  if (!(yield this.isSessionActive())) {
1798
1706
  if (popupWindow === null || popupWindow === void 0 ? void 0 : popupWindow.closed) {
1799
1707
  const resp = { isComplete: false, isError: true };
1800
- dispatchEvent(index_js_1.ParaEvent.LOGIN_EVENT, resp, 'failed to setup user');
1708
+ (0, index_js_2.dispatchEvent)(index_js_1.ParaEvent.LOGIN_EVENT, resp, 'failed to setup user');
1801
1709
  return resp;
1802
1710
  }
1803
1711
  continue;
@@ -1808,7 +1716,7 @@ class ParaCore {
1808
1716
  if (this.currentWalletIdsArray.length === 0) {
1809
1717
  if (popupWindow === null || popupWindow === void 0 ? void 0 : popupWindow.closed) {
1810
1718
  const resp = { isComplete: false, isError: true };
1811
- dispatchEvent(index_js_1.ParaEvent.LOGIN_EVENT, resp, 'failed to setup user');
1719
+ (0, index_js_2.dispatchEvent)(index_js_1.ParaEvent.LOGIN_EVENT, resp, 'failed to setup user');
1812
1720
  return resp;
1813
1721
  }
1814
1722
  else {
@@ -1828,7 +1736,7 @@ class ParaCore {
1828
1736
  needsWallet: needsWallet || Object.values(this.wallets).length === 0,
1829
1737
  partnerId: postLoginData.data.partnerId,
1830
1738
  };
1831
- dispatchEvent(index_js_1.ParaEvent.LOGIN_EVENT, resp);
1739
+ (0, index_js_2.dispatchEvent)(index_js_1.ParaEvent.LOGIN_EVENT, resp);
1832
1740
  return resp;
1833
1741
  }
1834
1742
  }
@@ -1838,7 +1746,7 @@ class ParaCore {
1838
1746
  }
1839
1747
  }
1840
1748
  const resp = { isComplete: false };
1841
- dispatchEvent(index_js_1.ParaEvent.LOGIN_EVENT, resp, 'exitted login without setting up user');
1749
+ (0, index_js_2.dispatchEvent)(index_js_1.ParaEvent.LOGIN_EVENT, resp, 'exitted login without setting up user');
1842
1750
  return resp;
1843
1751
  });
1844
1752
  }
@@ -1965,7 +1873,7 @@ class ParaCore {
1965
1873
  if (wallet && wallet.address) {
1966
1874
  return;
1967
1875
  }
1968
- yield new Promise(resolve => setTimeout(resolve, SHORT_POLLING_INTERVAL_MS));
1876
+ yield new Promise(resolve => setTimeout(resolve, constants.SHORT_POLLING_INTERVAL_MS));
1969
1877
  }
1970
1878
  catch (err) {
1971
1879
  // want to continue polling on error
@@ -1997,7 +1905,7 @@ class ParaCore {
1997
1905
  if (wallet && wallet.address) {
1998
1906
  return;
1999
1907
  }
2000
- yield new Promise(resolve => setTimeout(resolve, SHORT_POLLING_INTERVAL_MS));
1908
+ yield new Promise(resolve => setTimeout(resolve, constants.SHORT_POLLING_INTERVAL_MS));
2001
1909
  }
2002
1910
  catch (err) {
2003
1911
  // want to continue polling on error
@@ -2026,7 +1934,7 @@ class ParaCore {
2026
1934
  for (const type of yield this.getTypesToCreate(types)) {
2027
1935
  const [wallet, recoveryShare] = yield this.createWallet({ type, skipDistribute });
2028
1936
  wallets.push(wallet);
2029
- getEquivalentTypes(type)
1937
+ (0, index_js_2.getEquivalentTypes)(type)
2030
1938
  .filter(t => !!this.isWalletTypeEnabled[t])
2031
1939
  .forEach(t => {
2032
1940
  walletIds[t] = [wallet.id];
@@ -2115,7 +2023,7 @@ class ParaCore {
2115
2023
  yield this.setCurrentWalletIds(Object.assign(Object.assign({}, this.currentWalletIds), { [walletType]: [...((_b = this.currentWalletIds[walletType]) !== null && _b !== void 0 ? _b : []), walletId] }));
2116
2024
  const walletNoSigner = Object.assign({}, wallet);
2117
2025
  delete walletNoSigner.signer;
2118
- dispatchEvent(index_js_1.ParaEvent.WALLET_CREATED, {
2026
+ (0, index_js_2.dispatchEvent)(index_js_1.ParaEvent.WALLET_CREATED, {
2119
2027
  wallet: walletNoSigner,
2120
2028
  recoverySecret: recoveryShare,
2121
2029
  });
@@ -2235,7 +2143,7 @@ class ParaCore {
2235
2143
  this.wallets[wallet.id] = Object.assign(Object.assign({}, this.wallets[wallet.id]), { signer: (_a = refreshedShare === null || refreshedShare === void 0 ? void 0 : refreshedShare.signer) !== null && _a !== void 0 ? _a : wallet.signer, userId: this.userId, pregenIdentifier: undefined, pregenIdentifierType: undefined });
2236
2144
  const walletNoSigner = Object.assign({}, this.wallets[wallet.id]);
2237
2145
  delete walletNoSigner.signer;
2238
- dispatchEvent(index_js_1.ParaEvent.PREGEN_WALLET_CLAIMED, {
2146
+ (0, index_js_2.dispatchEvent)(index_js_1.ParaEvent.PREGEN_WALLET_CLAIMED, {
2239
2147
  wallet: walletNoSigner,
2240
2148
  recoverySecret: newRecoverySecret,
2241
2149
  });
@@ -2294,7 +2202,7 @@ class ParaCore {
2294
2202
  return __awaiter(this, void 0, void 0, function* () {
2295
2203
  this.requireApiKey();
2296
2204
  const res = yield this.ctx.client.getPregenWallets(pregenIdentifier && pregenIdentifierType ? { [pregenIdentifierType]: [pregenIdentifier] } : this.pregenIds, this.isPortal(), this.userId);
2297
- return res.wallets.filter(w => this.isWalletSupported(entityToWallet(w)));
2205
+ return res.wallets.filter(w => this.isWalletSupported((0, index_js_2.entityToWallet)(w)));
2298
2206
  });
2299
2207
  }
2300
2208
  encodeWalletBase64(wallet) {
@@ -2326,7 +2234,7 @@ class ParaCore {
2326
2234
  const base64WalletsSplit = base64Wallets.split('-');
2327
2235
  for (const base64Wallet of base64WalletsSplit) {
2328
2236
  const walletJson = Buffer.from(base64Wallet, 'base64').toString();
2329
- const wallet = migrateWallet(JSON.parse(walletJson));
2237
+ const wallet = (0, index_js_2.migrateWallet)(JSON.parse(walletJson));
2330
2238
  this.wallets[wallet.id] = wallet;
2331
2239
  yield this.setWallets(this.wallets);
2332
2240
  }
@@ -2387,10 +2295,10 @@ class ParaCore {
2387
2295
  this.platformUtils.openPopup(yield this.getTransactionReviewUrl(signRes.pendingTransactionId, timeoutMs), { type: cosmosSignDocBase64 ? index_js_1.PopupType.SIGN_TRANSACTION_REVIEW : index_js_1.PopupType.SIGN_MESSAGE_REVIEW });
2388
2296
  }
2389
2297
  else {
2390
- dispatchEvent(index_js_1.ParaEvent.SIGN_MESSAGE_EVENT, signRes);
2298
+ (0, index_js_2.dispatchEvent)(index_js_1.ParaEvent.SIGN_MESSAGE_EVENT, signRes);
2391
2299
  return signRes;
2392
2300
  }
2393
- yield new Promise(resolve => setTimeout(resolve, POLLING_INTERVAL_MS));
2301
+ yield new Promise(resolve => setTimeout(resolve, constants.POLLING_INTERVAL_MS));
2394
2302
  while (true) {
2395
2303
  if (Date.now() - timeStart > timeoutMs) {
2396
2304
  break;
@@ -2400,12 +2308,12 @@ class ParaCore {
2400
2308
  }
2401
2309
  catch (err) {
2402
2310
  const error = new errors_js_1.TransactionReviewDenied();
2403
- dispatchEvent(index_js_1.ParaEvent.SIGN_MESSAGE_EVENT, signRes, error.message);
2311
+ (0, index_js_2.dispatchEvent)(index_js_1.ParaEvent.SIGN_MESSAGE_EVENT, signRes, error.message);
2404
2312
  throw error;
2405
2313
  }
2406
2314
  signRes = yield this.signMessageInner({ wallet, signerId, messageBase64, cosmosSignDocBase64 });
2407
2315
  if (signRes.pendingTransactionId) {
2408
- yield new Promise(resolve => setTimeout(resolve, POLLING_INTERVAL_MS));
2316
+ yield new Promise(resolve => setTimeout(resolve, constants.POLLING_INTERVAL_MS));
2409
2317
  }
2410
2318
  else {
2411
2319
  break;
@@ -2413,10 +2321,10 @@ class ParaCore {
2413
2321
  }
2414
2322
  if (signRes.pendingTransactionId) {
2415
2323
  const error = new errors_js_1.TransactionReviewTimeout(yield this.getTransactionReviewUrl(signRes.pendingTransactionId), signRes.pendingTransactionId);
2416
- dispatchEvent(index_js_1.ParaEvent.SIGN_MESSAGE_EVENT, signRes, error.message);
2324
+ (0, index_js_2.dispatchEvent)(index_js_1.ParaEvent.SIGN_MESSAGE_EVENT, signRes, error.message);
2417
2325
  throw error;
2418
2326
  }
2419
- dispatchEvent(index_js_1.ParaEvent.SIGN_MESSAGE_EVENT, signRes);
2327
+ (0, index_js_2.dispatchEvent)(index_js_1.ParaEvent.SIGN_MESSAGE_EVENT, signRes);
2420
2328
  return signRes;
2421
2329
  });
2422
2330
  }
@@ -2456,10 +2364,10 @@ class ParaCore {
2456
2364
  this.platformUtils.openPopup(yield this.getTransactionReviewUrl(signRes.pendingTransactionId, timeoutMs), { type: index_js_1.PopupType.SIGN_TRANSACTION_REVIEW });
2457
2365
  }
2458
2366
  else {
2459
- dispatchEvent(index_js_1.ParaEvent.SIGN_TRANSACTION_EVENT, signRes);
2367
+ (0, index_js_2.dispatchEvent)(index_js_1.ParaEvent.SIGN_TRANSACTION_EVENT, signRes);
2460
2368
  return signRes;
2461
2369
  }
2462
- yield new Promise(resolve => setTimeout(resolve, POLLING_INTERVAL_MS));
2370
+ yield new Promise(resolve => setTimeout(resolve, constants.POLLING_INTERVAL_MS));
2463
2371
  while (true) {
2464
2372
  if (Date.now() - timeStart > timeoutMs) {
2465
2373
  break;
@@ -2469,12 +2377,12 @@ class ParaCore {
2469
2377
  }
2470
2378
  catch (err) {
2471
2379
  const error = new errors_js_1.TransactionReviewDenied();
2472
- dispatchEvent(index_js_1.ParaEvent.SIGN_TRANSACTION_EVENT, signRes, error.message);
2380
+ (0, index_js_2.dispatchEvent)(index_js_1.ParaEvent.SIGN_TRANSACTION_EVENT, signRes, error.message);
2473
2381
  throw error;
2474
2382
  }
2475
2383
  signRes = yield this.platformUtils.signTransaction(this.ctx, signerId, walletId, this.wallets[walletId].signer, rlpEncodedTxBase64, chainId, this.retrieveSessionCookie(), wallet.scheme === user_management_client_1.WalletScheme.DKLS);
2476
2384
  if (signRes.pendingTransactionId) {
2477
- yield new Promise(resolve => setTimeout(resolve, POLLING_INTERVAL_MS));
2385
+ yield new Promise(resolve => setTimeout(resolve, constants.POLLING_INTERVAL_MS));
2478
2386
  }
2479
2387
  else {
2480
2388
  break;
@@ -2482,10 +2390,10 @@ class ParaCore {
2482
2390
  }
2483
2391
  if (signRes.pendingTransactionId) {
2484
2392
  const error = new errors_js_1.TransactionReviewTimeout(yield this.getTransactionReviewUrl(signRes.pendingTransactionId), signRes.pendingTransactionId);
2485
- dispatchEvent(index_js_1.ParaEvent.SIGN_TRANSACTION_EVENT, signRes, error.message);
2393
+ (0, index_js_2.dispatchEvent)(index_js_1.ParaEvent.SIGN_TRANSACTION_EVENT, signRes, error.message);
2486
2394
  throw error;
2487
2395
  }
2488
- dispatchEvent(index_js_1.ParaEvent.SIGN_TRANSACTION_EVENT, signRes);
2396
+ (0, index_js_2.dispatchEvent)(index_js_1.ParaEvent.SIGN_TRANSACTION_EVENT, signRes);
2489
2397
  return signRes;
2490
2398
  });
2491
2399
  }
@@ -2644,7 +2552,7 @@ class ParaCore {
2644
2552
  this.countryCode = undefined;
2645
2553
  this.userId = undefined;
2646
2554
  this.sessionCookie = undefined;
2647
- dispatchEvent(index_js_1.ParaEvent.LOGOUT_EVENT, null);
2555
+ (0, index_js_2.dispatchEvent)(index_js_1.ParaEvent.LOGOUT_EVENT, null);
2648
2556
  });
2649
2557
  }
2650
2558
  getSupportedCreateAuthMethods() {
@@ -2695,4 +2603,4 @@ class ParaCore {
2695
2603
  }
2696
2604
  exports.ParaCore = ParaCore;
2697
2605
  _ParaCore_supportedWalletTypes = new WeakMap(), _ParaCore_supportedWalletTypesOpt = new WeakMap();
2698
- ParaCore.version = PARA_CORE_VERSION;
2606
+ ParaCore.version = constants.PARA_CORE_VERSION;