@getpara/core-sdk 1.0.2 → 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 +125 -223
  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 +74 -165
  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.2';
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;
@@ -260,13 +160,13 @@ class ParaCore {
260
160
  if (typeof window === 'undefined')
261
161
  return false;
262
162
  return (!!((_a = window.location) === null || _a === void 0 ? void 0 : _a.host) &&
263
- (0, definitions_js_1.getPortalBaseURL)(envOverride ? { env: envOverride } : this.ctx).includes(window.location.host));
163
+ (0, index_js_2.getPortalBaseURL)(envOverride ? { env: envOverride } : this.ctx).includes(window.location.host));
264
164
  }
265
165
  isParaConnect() {
266
166
  var _a;
267
167
  if (typeof window === 'undefined')
268
168
  return false;
269
- return !!((_a = window.location) === null || _a === void 0 ? void 0 : _a.host) && (0, definitions_js_1.getParaConnectBaseUrl)(this.ctx).includes(window.location.host);
169
+ return !!((_a = window.location) === null || _a === void 0 ? void 0 : _a.host) && (0, index_js_2.getParaConnectBaseUrl)(this.ctx).includes(window.location.host);
270
170
  }
271
171
  requireApiKey() {
272
172
  if (!this.ctx.apiKey) {
@@ -276,7 +176,7 @@ class ParaCore {
276
176
  }
277
177
  isWalletSupported(wallet) {
278
178
  var _a;
279
- 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);
280
180
  }
281
181
  isWalletOwned(wallet) {
282
182
  return (this.isWalletSupported(wallet) &&
@@ -293,7 +193,7 @@ class ParaCore {
293
193
  return (this.isWalletSupported(wallet) &&
294
194
  this.isPregenWalletUnclaimed(wallet) &&
295
195
  (!['EMAIL', 'PHONE', 'TELEGRAM'].includes(wallet.pregenIdentifierType) ||
296
- isPregenIdentifierMatch(wallet.pregenIdentifierType === 'EMAIL'
196
+ (0, index_js_2.isPregenIdentifierMatch)(wallet.pregenIdentifierType === 'EMAIL'
297
197
  ? this.email
298
198
  : wallet.pregenIdentifierType === 'TELEGRAM'
299
199
  ? this.telegramUserId
@@ -317,7 +217,7 @@ class ParaCore {
317
217
  error = `wallet with id ${wallet.id} and type ${wallet.type} is not supported, supported types are: ${this.supportedWalletTypes.map(({ type }) => type).join(', ')}`;
318
218
  }
319
219
  else if (types &&
320
- (!getEquivalentTypes(types).includes(wallet.type) ||
220
+ (!(0, index_js_2.getEquivalentTypes)(types).includes(wallet.type) ||
321
221
  (isOwned && !types.some(type => { var _a; return ((_a = this.currentWalletIds[type]) !== null && _a !== void 0 ? _a : []).includes(walletId); })))) {
322
222
  error = `wallet with id ${wallet.id} and type ${wallet.type} cannot be selected`;
323
223
  }
@@ -345,7 +245,7 @@ class ParaCore {
345
245
  var _a;
346
246
  if (this.externalWallets[walletId]) {
347
247
  const wallet = this.externalWallets[walletId];
348
- 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;
349
249
  }
350
250
  const wallet = this.findWallet(walletId, options.addressType);
351
251
  if (!wallet) {
@@ -354,13 +254,13 @@ class ParaCore {
354
254
  let str;
355
255
  switch (wallet.type) {
356
256
  case user_management_client_1.WalletType.COSMOS:
357
- 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');
358
258
  break;
359
259
  default:
360
260
  str = wallet.address;
361
261
  break;
362
262
  }
363
- 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;
364
264
  }
365
265
  /**
366
266
  * Returns a unique hash for a wallet suitable for use as an identicon seed.
@@ -386,7 +286,7 @@ class ParaCore {
386
286
  constructPortalUrl(type, opts = {}) {
387
287
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
388
288
  return __awaiter(this, void 0, void 0, function* () {
389
- 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);
390
290
  let path;
391
291
  switch (type) {
392
292
  case 'createPassword': {
@@ -439,7 +339,7 @@ class ParaCore {
439
339
  pfpUrl: opts.pfpUrl,
440
340
  }
441
341
  : {})), (opts.params || {}));
442
- return constructUrl({ base, path, params });
342
+ return (0, index_js_2.constructUrl)({ base, path, params });
443
343
  });
444
344
  }
445
345
  /**
@@ -485,10 +385,10 @@ class ParaCore {
485
385
  */
486
386
  this.clearStorage = (type = 'all') => __awaiter(this, void 0, void 0, function* () {
487
387
  const isAll = type === 'all';
488
- (isAll || type === 'local') && this.platformUtils.localStorage.clear(exports.PREFIX);
489
- (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);
490
390
  if ((isAll || type === 'secure') && this.platformUtils.secureStorage) {
491
- this.platformUtils.secureStorage.clear(exports.PREFIX);
391
+ this.platformUtils.secureStorage.clear(constants.PREFIX);
492
392
  }
493
393
  });
494
394
  /**
@@ -531,7 +431,7 @@ class ParaCore {
531
431
  }
532
432
  this.persistSessionCookie = (cookie) => {
533
433
  this.sessionCookie = cookie;
534
- (opts.useSessionStorage ? this.sessionStorageSetItem : this.localStorageSetItem)(LOCAL_STORAGE_SESSION_COOKIE, cookie);
434
+ (opts.useSessionStorage ? this.sessionStorageSetItem : this.localStorageSetItem)(constants.LOCAL_STORAGE_SESSION_COOKIE, cookie);
535
435
  };
536
436
  this.ctx = {
537
437
  env,
@@ -588,34 +488,34 @@ class ParaCore {
588
488
  if (!this.platformUtils.isSyncStorage || opts.useStorageOverrides) {
589
489
  return;
590
490
  }
591
- this.email = this.localStorageGetItem(LOCAL_STORAGE_EMAIL) || undefined;
592
- this.countryCode = this.localStorageGetItem(LOCAL_STORAGE_COUNTRY_CODE) || undefined;
593
- this.phone = this.localStorageGetItem(LOCAL_STORAGE_PHONE) || undefined;
594
- this.userId = this.localStorageGetItem(LOCAL_STORAGE_USER_ID) || undefined;
595
- 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;
596
496
  const stringWallets = this.platformUtils.secureStorage
597
- ? this.platformUtils.secureStorage.get(LOCAL_STORAGE_WALLETS)
598
- : this.localStorageGetItem(LOCAL_STORAGE_WALLETS);
497
+ ? this.platformUtils.secureStorage.get(constants.LOCAL_STORAGE_WALLETS)
498
+ : this.localStorageGetItem(constants.LOCAL_STORAGE_WALLETS);
599
499
  const _wallets = JSON.parse(stringWallets || '{}');
600
500
  const stringEd25519Wallets = this.platformUtils.secureStorage
601
- ? this.platformUtils.secureStorage.get(LOCAL_STORAGE_ED25519_WALLETS)
602
- : this.localStorageGetItem(LOCAL_STORAGE_ED25519_WALLETS);
501
+ ? this.platformUtils.secureStorage.get(constants.LOCAL_STORAGE_ED25519_WALLETS)
502
+ : this.localStorageGetItem(constants.LOCAL_STORAGE_ED25519_WALLETS);
603
503
  const _ed25519Wallets = JSON.parse(stringEd25519Wallets || '{}');
604
504
  const wallets = Object.assign(Object.assign({}, Object.keys(_wallets).reduce((res, key) => {
605
- 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]) });
606
506
  }, {})), Object.keys(_ed25519Wallets).reduce((res, key) => {
607
- 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]) } : {}));
608
508
  }, {}));
609
509
  this.setWallets(wallets);
610
510
  // TODO: Improve not great check
611
- 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;
612
512
  const currentWalletIds = [undefined, null, 'undefined'].includes(_currentWalletIds)
613
513
  ? {}
614
514
  : (() => {
615
515
  const fromJson = JSON.parse(_currentWalletIds);
616
516
  return Array.isArray(fromJson)
617
517
  ? Object.keys(user_management_client_1.WalletType).reduce((acc, type) => {
618
- 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]);
619
519
  return Object.assign(Object.assign({}, acc), (wallet && !acc[type] ? { [type]: [wallet.id] } : {}));
620
520
  }, {})
621
521
  : fromJson;
@@ -623,22 +523,22 @@ class ParaCore {
623
523
  this.setCurrentWalletIds(currentWalletIds);
624
524
  // TODO: remove sessionStorageGetItem call once new version is being consumed
625
525
  this.sessionCookie =
626
- this.localStorageGetItem(LOCAL_STORAGE_SESSION_COOKIE) ||
627
- this.sessionStorageGetItem(LOCAL_STORAGE_SESSION_COOKIE) ||
526
+ this.localStorageGetItem(constants.LOCAL_STORAGE_SESSION_COOKIE) ||
527
+ this.sessionStorageGetItem(constants.LOCAL_STORAGE_SESSION_COOKIE) ||
628
528
  undefined;
629
529
  // In case currentWalletIds was missing from storage
630
530
  if (Object.values(this.wallets).filter(w => this.isWalletOwned(w)).length > 0 &&
631
531
  this.currentWalletIdsArray.length === 0) {
632
532
  this.findWalletId(undefined, { forbidPregen: true });
633
533
  }
634
- const loginEncryptionKey = this.sessionStorageGetItem(SESSION_STORAGE_LOGIN_ENCRYPTION_KEY_PAIR);
534
+ const loginEncryptionKey = this.sessionStorageGetItem(constants.SESSION_STORAGE_LOGIN_ENCRYPTION_KEY_PAIR);
635
535
  if (loginEncryptionKey && loginEncryptionKey !== 'undefined') {
636
536
  this.loginEncryptionKeyPair = this.convertEncryptionKeyPair(JSON.parse(loginEncryptionKey));
637
537
  }
638
- const stringExternalWallets = this.localStorageGetItem(LOCAL_STORAGE_EXTERNAL_WALLETS);
538
+ const stringExternalWallets = this.localStorageGetItem(constants.LOCAL_STORAGE_EXTERNAL_WALLETS);
639
539
  const _externalWallets = JSON.parse(stringExternalWallets || '{}');
640
540
  this.setExternalWallets(_externalWallets);
641
- const _currentExternalWalletAddresses = this.localStorageGetItem(LOCAL_STORAGE_CURRENT_EXTERNAL_WALLET_ADDRESSES) || undefined;
541
+ const _currentExternalWalletAddresses = this.localStorageGetItem(constants.LOCAL_STORAGE_CURRENT_EXTERNAL_WALLET_ADDRESSES) || undefined;
642
542
  this.currentExternalWalletAddresses = _currentExternalWalletAddresses
643
543
  ? JSON.parse(_currentExternalWalletAddresses)
644
544
  : undefined;
@@ -694,34 +594,36 @@ class ParaCore {
694
594
  init() {
695
595
  var _a;
696
596
  return __awaiter(this, void 0, void 0, function* () {
697
- this.email = (yield this.localStorageGetItem(LOCAL_STORAGE_EMAIL)) || undefined;
698
- this.countryCode = (yield this.localStorageGetItem(LOCAL_STORAGE_COUNTRY_CODE)) || undefined;
699
- this.phone = (yield this.localStorageGetItem(LOCAL_STORAGE_PHONE)) || undefined;
700
- this.userId = (yield this.localStorageGetItem(LOCAL_STORAGE_USER_ID)) || undefined;
701
- 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;
702
604
  const stringWallets = this.platformUtils.secureStorage
703
- ? yield this.platformUtils.secureStorage.get(LOCAL_STORAGE_WALLETS)
704
- : yield this.localStorageGetItem(LOCAL_STORAGE_WALLETS);
605
+ ? yield this.platformUtils.secureStorage.get(constants.LOCAL_STORAGE_WALLETS)
606
+ : yield this.localStorageGetItem(constants.LOCAL_STORAGE_WALLETS);
705
607
  const _wallets = JSON.parse(stringWallets || '{}');
706
608
  const stringEd25519Wallets = this.platformUtils.secureStorage
707
- ? yield this.platformUtils.secureStorage.get(LOCAL_STORAGE_ED25519_WALLETS)
708
- : 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);
709
611
  const _ed25519Wallets = JSON.parse(stringEd25519Wallets || '{}');
710
612
  const wallets = Object.assign(Object.assign({}, Object.keys(_wallets).reduce((res, key) => {
711
- 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]) });
712
614
  }, {})), Object.keys(_ed25519Wallets).reduce((res, key) => {
713
- 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]) } : {}));
714
616
  }, {}));
715
617
  yield this.setWallets(wallets);
716
618
  // TODO: Improve not great check
717
- 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;
718
620
  const currentWalletIds = [undefined, null, 'undefined', 'null'].includes(_currentWalletIds)
719
621
  ? {}
720
622
  : (() => {
721
623
  const fromJson = JSON.parse(_currentWalletIds);
722
624
  return Array.isArray(fromJson)
723
625
  ? Object.keys(user_management_client_1.WalletType).reduce((acc, type) => {
724
- 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]);
725
627
  return Object.assign(Object.assign({}, acc), (wallet && !acc[type] ? { [type]: [wallet.id] } : {}));
726
628
  }, {})
727
629
  : fromJson;
@@ -729,22 +631,22 @@ class ParaCore {
729
631
  yield this.setCurrentWalletIds(currentWalletIds);
730
632
  // TODO: remove sessionStorageGetItem call once new version is being consumed
731
633
  this.sessionCookie =
732
- (yield this.localStorageGetItem(LOCAL_STORAGE_SESSION_COOKIE)) ||
733
- (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)) ||
734
636
  undefined;
735
637
  // In case currentWalletIds was missing from storage
736
638
  if (Object.values(this.wallets).filter(w => this.isWalletOwned(w)).length > 0 &&
737
639
  this.currentWalletIdsArray.length === 0) {
738
640
  this.findWalletId(undefined, { forbidPregen: true });
739
641
  }
740
- const loginEncryptionKey = (yield this.sessionStorageGetItem(SESSION_STORAGE_LOGIN_ENCRYPTION_KEY_PAIR));
642
+ const loginEncryptionKey = (yield this.sessionStorageGetItem(constants.SESSION_STORAGE_LOGIN_ENCRYPTION_KEY_PAIR));
741
643
  if (loginEncryptionKey && loginEncryptionKey !== 'undefined') {
742
644
  this.loginEncryptionKeyPair = this.convertEncryptionKeyPair(JSON.parse(loginEncryptionKey));
743
645
  }
744
- const stringExternalWallets = yield this.localStorageGetItem(LOCAL_STORAGE_EXTERNAL_WALLETS);
646
+ const stringExternalWallets = yield this.localStorageGetItem(constants.LOCAL_STORAGE_EXTERNAL_WALLETS);
745
647
  const _externalWallets = JSON.parse(stringExternalWallets || '{}');
746
648
  yield this.setExternalWallets(_externalWallets);
747
- 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;
748
650
  this.currentExternalWalletAddresses = _currentExternalWalletAddresses
749
651
  ? JSON.parse(_currentExternalWalletAddresses)
750
652
  : undefined;
@@ -758,7 +660,7 @@ class ParaCore {
758
660
  setEmail(email) {
759
661
  return __awaiter(this, void 0, void 0, function* () {
760
662
  this.email = email;
761
- yield this.localStorageSetItem(LOCAL_STORAGE_EMAIL, email);
663
+ yield this.localStorageSetItem(constants.LOCAL_STORAGE_EMAIL, email);
762
664
  });
763
665
  }
764
666
  /**
@@ -768,7 +670,7 @@ class ParaCore {
768
670
  setTelegramUserId(telegramUserId) {
769
671
  return __awaiter(this, void 0, void 0, function* () {
770
672
  this.telegramUserId = telegramUserId;
771
- yield this.localStorageSetItem(LOCAL_STORAGE_TELEGRAM_USER_ID, telegramUserId);
673
+ yield this.localStorageSetItem(constants.LOCAL_STORAGE_TELEGRAM_USER_ID, telegramUserId);
772
674
  });
773
675
  }
774
676
  /**
@@ -780,8 +682,8 @@ class ParaCore {
780
682
  return __awaiter(this, void 0, void 0, function* () {
781
683
  this.phone = phone;
782
684
  this.countryCode = countryCode;
783
- yield this.localStorageSetItem(LOCAL_STORAGE_PHONE, phone);
784
- 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);
785
687
  });
786
688
  }
787
689
  /**
@@ -791,7 +693,7 @@ class ParaCore {
791
693
  setFarcasterUsername(farcasterUsername) {
792
694
  return __awaiter(this, void 0, void 0, function* () {
793
695
  this.farcasterUsername = farcasterUsername;
794
- yield this.localStorageSetItem(LOCAL_STORAGE_FARCASTER_USERNAME, farcasterUsername);
696
+ yield this.localStorageSetItem(constants.LOCAL_STORAGE_FARCASTER_USERNAME, farcasterUsername);
795
697
  });
796
698
  }
797
699
  /**
@@ -815,7 +717,7 @@ class ParaCore {
815
717
  this.currentExternalWalletAddresses = [address];
816
718
  this.setCurrentExternalWalletAddresses(this.currentExternalWalletAddresses);
817
719
  this.setExternalWallets(this.externalWallets);
818
- 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);
819
721
  });
820
722
  }
821
723
  /**
@@ -825,7 +727,7 @@ class ParaCore {
825
727
  setUserId(userId) {
826
728
  return __awaiter(this, void 0, void 0, function* () {
827
729
  this.userId = userId;
828
- yield this.localStorageSetItem(LOCAL_STORAGE_USER_ID, userId);
730
+ yield this.localStorageSetItem(constants.LOCAL_STORAGE_USER_ID, userId);
829
731
  });
830
732
  }
831
733
  /**
@@ -836,10 +738,10 @@ class ParaCore {
836
738
  return __awaiter(this, void 0, void 0, function* () {
837
739
  this.wallets = wallets;
838
740
  if (this.platformUtils.secureStorage) {
839
- yield this.platformUtils.secureStorage.set(LOCAL_STORAGE_WALLETS, JSON.stringify(wallets));
741
+ yield this.platformUtils.secureStorage.set(constants.LOCAL_STORAGE_WALLETS, JSON.stringify(wallets));
840
742
  return;
841
743
  }
842
- yield this.localStorageSetItem(LOCAL_STORAGE_WALLETS, JSON.stringify(wallets));
744
+ yield this.localStorageSetItem(constants.LOCAL_STORAGE_WALLETS, JSON.stringify(wallets));
843
745
  });
844
746
  }
845
747
  /**
@@ -849,13 +751,13 @@ class ParaCore {
849
751
  setExternalWallets(externalWallets) {
850
752
  return __awaiter(this, void 0, void 0, function* () {
851
753
  this.externalWallets = externalWallets;
852
- yield this.localStorageSetItem(LOCAL_STORAGE_EXTERNAL_WALLETS, JSON.stringify(externalWallets));
754
+ yield this.localStorageSetItem(constants.LOCAL_STORAGE_EXTERNAL_WALLETS, JSON.stringify(externalWallets));
853
755
  });
854
756
  }
855
757
  setCurrentExternalWalletAddresses(currentExternalWalletAddresses) {
856
758
  return __awaiter(this, void 0, void 0, function* () {
857
759
  this.currentExternalWalletAddresses = currentExternalWalletAddresses;
858
- 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));
859
761
  });
860
762
  }
861
763
  /**
@@ -868,13 +770,13 @@ class ParaCore {
868
770
  keyPair = yield (0, utils_js_1.getAsymmetricKeyPair)(this.ctx);
869
771
  }
870
772
  this.loginEncryptionKeyPair = keyPair;
871
- 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));
872
774
  });
873
775
  }
874
776
  deleteLoginEncryptionKeyPair() {
875
777
  return __awaiter(this, void 0, void 0, function* () {
876
778
  this.loginEncryptionKeyPair = undefined;
877
- yield this.sessionStorageRemoveItem(SESSION_STORAGE_LOGIN_ENCRYPTION_KEY_PAIR);
779
+ yield this.sessionStorageRemoveItem(constants.SESSION_STORAGE_LOGIN_ENCRYPTION_KEY_PAIR);
878
780
  });
879
781
  }
880
782
  /**
@@ -906,7 +808,7 @@ class ParaCore {
906
808
  if (!this.phone || !this.countryCode) {
907
809
  return undefined;
908
810
  }
909
- return normalizePhoneNumber(this.countryCode, this.phone);
811
+ return (0, index_js_2.normalizePhoneNumber)(this.countryCode, this.phone);
910
812
  }
911
813
  /**
912
814
  * Gets the farcaster username associated with the `ParaCore` instance.
@@ -918,11 +820,11 @@ class ParaCore {
918
820
  setCurrentWalletIds(currentWalletIds, { needsWallet = false, sessionLookupId, newDeviceSessionLookupId, } = {}) {
919
821
  return __awaiter(this, void 0, void 0, function* () {
920
822
  this.currentWalletIds = currentWalletIds;
921
- 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));
922
824
  if (sessionLookupId) {
923
825
  yield this.ctx.client.setCurrentWalletIds(this.getUserId(), this.currentWalletIds, needsWallet, sessionLookupId, newDeviceSessionLookupId);
924
826
  }
925
- dispatchEvent(index_js_1.ParaEvent.WALLETS_CHANGE_EVENT, null);
827
+ (0, index_js_2.dispatchEvent)(index_js_1.ParaEvent.WALLETS_CHANGE_EVENT, null);
926
828
  });
927
829
  }
928
830
  /**
@@ -1045,7 +947,7 @@ class ParaCore {
1045
947
  yield this.touchSession();
1046
948
  }
1047
949
  return (this.supportedWalletTypes
1048
- .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]))
1049
951
  .map(({ type }) => type));
1050
952
  });
1051
953
  }
@@ -1054,7 +956,7 @@ class ParaCore {
1054
956
  if (!__classPrivateFieldGet(this, _ParaCore_supportedWalletTypes, "f")) {
1055
957
  yield this.touchSession();
1056
958
  }
1057
- 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 => {
1058
960
  switch (scheme) {
1059
961
  case user_management_client_1.WalletScheme.ED25519:
1060
962
  return user_management_client_1.WalletType.SOLANA;
@@ -1079,7 +981,7 @@ class ParaCore {
1079
981
  */
1080
982
  getPortalURL(partnerId) {
1081
983
  return __awaiter(this, void 0, void 0, function* () {
1082
- 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);
1083
985
  });
1084
986
  }
1085
987
  getWebAuthURLForCreate(_a) {
@@ -1095,8 +997,8 @@ class ParaCore {
1095
997
  });
1096
998
  }
1097
999
  getShortUrl(compressedUrl) {
1098
- return constructUrl({
1099
- base: (0, definitions_js_1.getPortalBaseURL)(this.ctx),
1000
+ return (0, index_js_2.constructUrl)({
1001
+ base: (0, index_js_2.getPortalBaseURL)(this.ctx),
1100
1002
  path: `/short/${compressedUrl}`,
1101
1003
  });
1102
1004
  }
@@ -1165,7 +1067,7 @@ class ParaCore {
1165
1067
  ? this.ctx.client.getAllWallets(this.userId)
1166
1068
  : this.ctx.client.getWallets(this.userId, true));
1167
1069
  return res.data.wallets.filter(wallet => !!wallet.address &&
1168
- (this.isParaConnect() || (!this.isParaConnect() && this.isWalletSupported(entityToWallet(wallet)))));
1070
+ (this.isParaConnect() || (!this.isParaConnect() && this.isWalletSupported((0, index_js_2.entityToWallet)(wallet)))));
1169
1071
  });
1170
1072
  }
1171
1073
  populateWalletAddresses() {
@@ -1174,7 +1076,7 @@ class ParaCore {
1174
1076
  const wallets = res.data.wallets;
1175
1077
  wallets.forEach(entity => {
1176
1078
  if (this.wallets[entity.id]) {
1177
- 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]);
1178
1080
  }
1179
1081
  });
1180
1082
  yield this.setWallets(this.wallets);
@@ -1185,7 +1087,7 @@ class ParaCore {
1185
1087
  const res = yield this.getPregenWallets();
1186
1088
  res.forEach(entity => {
1187
1089
  if (this.wallets[entity.id]) {
1188
- 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]);
1189
1091
  }
1190
1092
  });
1191
1093
  yield this.setWallets(this.wallets);
@@ -1643,10 +1545,10 @@ class ParaCore {
1643
1545
  this.isAwaitingAccountCreation = true;
1644
1546
  while (this.isAwaitingAccountCreation) {
1645
1547
  try {
1646
- yield new Promise(resolve => setTimeout(resolve, POLLING_INTERVAL_MS));
1548
+ yield new Promise(resolve => setTimeout(resolve, constants.POLLING_INTERVAL_MS));
1647
1549
  if (yield this.isSessionActive()) {
1648
1550
  this.isAwaitingAccountCreation = false;
1649
- dispatchEvent(index_js_1.ParaEvent.ACCOUNT_CREATION_EVENT, true);
1551
+ (0, index_js_2.dispatchEvent)(index_js_1.ParaEvent.ACCOUNT_CREATION_EVENT, true);
1650
1552
  return true;
1651
1553
  }
1652
1554
  }
@@ -1667,7 +1569,7 @@ class ParaCore {
1667
1569
  recoverySecret = yield this.claimPregenWallets();
1668
1570
  walletIds = this.supportedWalletTypes.reduce((acc, { type }) => {
1669
1571
  var _a;
1670
- 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] });
1671
1573
  }, {});
1672
1574
  }
1673
1575
  // After claiming any pregen wallets, create wallets for the remaining missing types
@@ -1675,7 +1577,7 @@ class ParaCore {
1675
1577
  recoverySecret = recoverySecret !== null && recoverySecret !== void 0 ? recoverySecret : created.recoverySecret;
1676
1578
  walletIds = Object.assign(Object.assign({}, walletIds), created.walletIds);
1677
1579
  const resp = { walletIds, recoverySecret };
1678
- dispatchEvent(index_js_1.ParaEvent.ACCOUNT_SETUP_EVENT, resp);
1580
+ (0, index_js_2.dispatchEvent)(index_js_1.ParaEvent.ACCOUNT_SETUP_EVENT, resp);
1679
1581
  return resp;
1680
1582
  });
1681
1583
  }
@@ -1702,7 +1604,7 @@ class ParaCore {
1702
1604
  this.isAwaitingFarcaster = true;
1703
1605
  while (this.isAwaitingFarcaster) {
1704
1606
  try {
1705
- yield new Promise(resolve => setTimeout(resolve, POLLING_INTERVAL_MS));
1607
+ yield new Promise(resolve => setTimeout(resolve, constants.POLLING_INTERVAL_MS));
1706
1608
  const res = yield this.ctx.client.getFarcasterAuthStatus();
1707
1609
  if (res.data.state === 'completed') {
1708
1610
  const { userId, userExists, username, pfpUrl } = res.data;
@@ -1733,8 +1635,8 @@ class ParaCore {
1733
1635
  return __awaiter(this, void 0, void 0, function* () {
1734
1636
  yield this.logout();
1735
1637
  const res = yield this.touchSession(true);
1736
- return constructUrl({
1737
- 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),
1738
1640
  path: `/auth/${method.toLowerCase()}`,
1739
1641
  params: {
1740
1642
  apiKey: this.ctx.apiKey,
@@ -1759,7 +1661,7 @@ class ParaCore {
1759
1661
  if (popupWindow === null || popupWindow === void 0 ? void 0 : popupWindow.closed) {
1760
1662
  return { isError: true, userExists: false };
1761
1663
  }
1762
- yield new Promise(resolve => setTimeout(resolve, POLLING_INTERVAL_MS));
1664
+ yield new Promise(resolve => setTimeout(resolve, constants.POLLING_INTERVAL_MS));
1763
1665
  if (this.isAwaitingOAuth) {
1764
1666
  const res = yield this.touchSession();
1765
1667
  if (res.data.userId) {
@@ -1799,11 +1701,11 @@ class ParaCore {
1799
1701
  this.isAwaitingLogin = true;
1800
1702
  while (this.isAwaitingLogin) {
1801
1703
  try {
1802
- yield new Promise(resolve => setTimeout(resolve, POLLING_INTERVAL_MS));
1704
+ yield new Promise(resolve => setTimeout(resolve, constants.POLLING_INTERVAL_MS));
1803
1705
  if (!(yield this.isSessionActive())) {
1804
1706
  if (popupWindow === null || popupWindow === void 0 ? void 0 : popupWindow.closed) {
1805
1707
  const resp = { isComplete: false, isError: true };
1806
- 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');
1807
1709
  return resp;
1808
1710
  }
1809
1711
  continue;
@@ -1814,7 +1716,7 @@ class ParaCore {
1814
1716
  if (this.currentWalletIdsArray.length === 0) {
1815
1717
  if (popupWindow === null || popupWindow === void 0 ? void 0 : popupWindow.closed) {
1816
1718
  const resp = { isComplete: false, isError: true };
1817
- 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');
1818
1720
  return resp;
1819
1721
  }
1820
1722
  else {
@@ -1834,7 +1736,7 @@ class ParaCore {
1834
1736
  needsWallet: needsWallet || Object.values(this.wallets).length === 0,
1835
1737
  partnerId: postLoginData.data.partnerId,
1836
1738
  };
1837
- dispatchEvent(index_js_1.ParaEvent.LOGIN_EVENT, resp);
1739
+ (0, index_js_2.dispatchEvent)(index_js_1.ParaEvent.LOGIN_EVENT, resp);
1838
1740
  return resp;
1839
1741
  }
1840
1742
  }
@@ -1844,7 +1746,7 @@ class ParaCore {
1844
1746
  }
1845
1747
  }
1846
1748
  const resp = { isComplete: false };
1847
- 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');
1848
1750
  return resp;
1849
1751
  });
1850
1752
  }
@@ -1971,7 +1873,7 @@ class ParaCore {
1971
1873
  if (wallet && wallet.address) {
1972
1874
  return;
1973
1875
  }
1974
- yield new Promise(resolve => setTimeout(resolve, SHORT_POLLING_INTERVAL_MS));
1876
+ yield new Promise(resolve => setTimeout(resolve, constants.SHORT_POLLING_INTERVAL_MS));
1975
1877
  }
1976
1878
  catch (err) {
1977
1879
  // want to continue polling on error
@@ -2003,7 +1905,7 @@ class ParaCore {
2003
1905
  if (wallet && wallet.address) {
2004
1906
  return;
2005
1907
  }
2006
- yield new Promise(resolve => setTimeout(resolve, SHORT_POLLING_INTERVAL_MS));
1908
+ yield new Promise(resolve => setTimeout(resolve, constants.SHORT_POLLING_INTERVAL_MS));
2007
1909
  }
2008
1910
  catch (err) {
2009
1911
  // want to continue polling on error
@@ -2032,7 +1934,7 @@ class ParaCore {
2032
1934
  for (const type of yield this.getTypesToCreate(types)) {
2033
1935
  const [wallet, recoveryShare] = yield this.createWallet({ type, skipDistribute });
2034
1936
  wallets.push(wallet);
2035
- getEquivalentTypes(type)
1937
+ (0, index_js_2.getEquivalentTypes)(type)
2036
1938
  .filter(t => !!this.isWalletTypeEnabled[t])
2037
1939
  .forEach(t => {
2038
1940
  walletIds[t] = [wallet.id];
@@ -2121,7 +2023,7 @@ class ParaCore {
2121
2023
  yield this.setCurrentWalletIds(Object.assign(Object.assign({}, this.currentWalletIds), { [walletType]: [...((_b = this.currentWalletIds[walletType]) !== null && _b !== void 0 ? _b : []), walletId] }));
2122
2024
  const walletNoSigner = Object.assign({}, wallet);
2123
2025
  delete walletNoSigner.signer;
2124
- dispatchEvent(index_js_1.ParaEvent.WALLET_CREATED, {
2026
+ (0, index_js_2.dispatchEvent)(index_js_1.ParaEvent.WALLET_CREATED, {
2125
2027
  wallet: walletNoSigner,
2126
2028
  recoverySecret: recoveryShare,
2127
2029
  });
@@ -2241,7 +2143,7 @@ class ParaCore {
2241
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 });
2242
2144
  const walletNoSigner = Object.assign({}, this.wallets[wallet.id]);
2243
2145
  delete walletNoSigner.signer;
2244
- dispatchEvent(index_js_1.ParaEvent.PREGEN_WALLET_CLAIMED, {
2146
+ (0, index_js_2.dispatchEvent)(index_js_1.ParaEvent.PREGEN_WALLET_CLAIMED, {
2245
2147
  wallet: walletNoSigner,
2246
2148
  recoverySecret: newRecoverySecret,
2247
2149
  });
@@ -2300,7 +2202,7 @@ class ParaCore {
2300
2202
  return __awaiter(this, void 0, void 0, function* () {
2301
2203
  this.requireApiKey();
2302
2204
  const res = yield this.ctx.client.getPregenWallets(pregenIdentifier && pregenIdentifierType ? { [pregenIdentifierType]: [pregenIdentifier] } : this.pregenIds, this.isPortal(), this.userId);
2303
- return res.wallets.filter(w => this.isWalletSupported(entityToWallet(w)));
2205
+ return res.wallets.filter(w => this.isWalletSupported((0, index_js_2.entityToWallet)(w)));
2304
2206
  });
2305
2207
  }
2306
2208
  encodeWalletBase64(wallet) {
@@ -2332,7 +2234,7 @@ class ParaCore {
2332
2234
  const base64WalletsSplit = base64Wallets.split('-');
2333
2235
  for (const base64Wallet of base64WalletsSplit) {
2334
2236
  const walletJson = Buffer.from(base64Wallet, 'base64').toString();
2335
- const wallet = migrateWallet(JSON.parse(walletJson));
2237
+ const wallet = (0, index_js_2.migrateWallet)(JSON.parse(walletJson));
2336
2238
  this.wallets[wallet.id] = wallet;
2337
2239
  yield this.setWallets(this.wallets);
2338
2240
  }
@@ -2393,10 +2295,10 @@ class ParaCore {
2393
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 });
2394
2296
  }
2395
2297
  else {
2396
- dispatchEvent(index_js_1.ParaEvent.SIGN_MESSAGE_EVENT, signRes);
2298
+ (0, index_js_2.dispatchEvent)(index_js_1.ParaEvent.SIGN_MESSAGE_EVENT, signRes);
2397
2299
  return signRes;
2398
2300
  }
2399
- yield new Promise(resolve => setTimeout(resolve, POLLING_INTERVAL_MS));
2301
+ yield new Promise(resolve => setTimeout(resolve, constants.POLLING_INTERVAL_MS));
2400
2302
  while (true) {
2401
2303
  if (Date.now() - timeStart > timeoutMs) {
2402
2304
  break;
@@ -2406,12 +2308,12 @@ class ParaCore {
2406
2308
  }
2407
2309
  catch (err) {
2408
2310
  const error = new errors_js_1.TransactionReviewDenied();
2409
- 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);
2410
2312
  throw error;
2411
2313
  }
2412
2314
  signRes = yield this.signMessageInner({ wallet, signerId, messageBase64, cosmosSignDocBase64 });
2413
2315
  if (signRes.pendingTransactionId) {
2414
- yield new Promise(resolve => setTimeout(resolve, POLLING_INTERVAL_MS));
2316
+ yield new Promise(resolve => setTimeout(resolve, constants.POLLING_INTERVAL_MS));
2415
2317
  }
2416
2318
  else {
2417
2319
  break;
@@ -2419,10 +2321,10 @@ class ParaCore {
2419
2321
  }
2420
2322
  if (signRes.pendingTransactionId) {
2421
2323
  const error = new errors_js_1.TransactionReviewTimeout(yield this.getTransactionReviewUrl(signRes.pendingTransactionId), signRes.pendingTransactionId);
2422
- 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);
2423
2325
  throw error;
2424
2326
  }
2425
- dispatchEvent(index_js_1.ParaEvent.SIGN_MESSAGE_EVENT, signRes);
2327
+ (0, index_js_2.dispatchEvent)(index_js_1.ParaEvent.SIGN_MESSAGE_EVENT, signRes);
2426
2328
  return signRes;
2427
2329
  });
2428
2330
  }
@@ -2462,10 +2364,10 @@ class ParaCore {
2462
2364
  this.platformUtils.openPopup(yield this.getTransactionReviewUrl(signRes.pendingTransactionId, timeoutMs), { type: index_js_1.PopupType.SIGN_TRANSACTION_REVIEW });
2463
2365
  }
2464
2366
  else {
2465
- dispatchEvent(index_js_1.ParaEvent.SIGN_TRANSACTION_EVENT, signRes);
2367
+ (0, index_js_2.dispatchEvent)(index_js_1.ParaEvent.SIGN_TRANSACTION_EVENT, signRes);
2466
2368
  return signRes;
2467
2369
  }
2468
- yield new Promise(resolve => setTimeout(resolve, POLLING_INTERVAL_MS));
2370
+ yield new Promise(resolve => setTimeout(resolve, constants.POLLING_INTERVAL_MS));
2469
2371
  while (true) {
2470
2372
  if (Date.now() - timeStart > timeoutMs) {
2471
2373
  break;
@@ -2475,12 +2377,12 @@ class ParaCore {
2475
2377
  }
2476
2378
  catch (err) {
2477
2379
  const error = new errors_js_1.TransactionReviewDenied();
2478
- 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);
2479
2381
  throw error;
2480
2382
  }
2481
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);
2482
2384
  if (signRes.pendingTransactionId) {
2483
- yield new Promise(resolve => setTimeout(resolve, POLLING_INTERVAL_MS));
2385
+ yield new Promise(resolve => setTimeout(resolve, constants.POLLING_INTERVAL_MS));
2484
2386
  }
2485
2387
  else {
2486
2388
  break;
@@ -2488,10 +2390,10 @@ class ParaCore {
2488
2390
  }
2489
2391
  if (signRes.pendingTransactionId) {
2490
2392
  const error = new errors_js_1.TransactionReviewTimeout(yield this.getTransactionReviewUrl(signRes.pendingTransactionId), signRes.pendingTransactionId);
2491
- 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);
2492
2394
  throw error;
2493
2395
  }
2494
- dispatchEvent(index_js_1.ParaEvent.SIGN_TRANSACTION_EVENT, signRes);
2396
+ (0, index_js_2.dispatchEvent)(index_js_1.ParaEvent.SIGN_TRANSACTION_EVENT, signRes);
2495
2397
  return signRes;
2496
2398
  });
2497
2399
  }
@@ -2650,7 +2552,7 @@ class ParaCore {
2650
2552
  this.countryCode = undefined;
2651
2553
  this.userId = undefined;
2652
2554
  this.sessionCookie = undefined;
2653
- dispatchEvent(index_js_1.ParaEvent.LOGOUT_EVENT, null);
2555
+ (0, index_js_2.dispatchEvent)(index_js_1.ParaEvent.LOGOUT_EVENT, null);
2654
2556
  });
2655
2557
  }
2656
2558
  getSupportedCreateAuthMethods() {
@@ -2701,4 +2603,4 @@ class ParaCore {
2701
2603
  }
2702
2604
  exports.ParaCore = ParaCore;
2703
2605
  _ParaCore_supportedWalletTypes = new WeakMap(), _ParaCore_supportedWalletTypesOpt = new WeakMap();
2704
- ParaCore.version = PARA_CORE_VERSION;
2606
+ ParaCore.version = constants.PARA_CORE_VERSION;