@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
@@ -30,124 +30,31 @@ var __rest = (this && this.__rest) || function (s, e) {
30
30
  return t;
31
31
  };
32
32
  var _ParaCore_supportedWalletTypes, _ParaCore_supportedWalletTypesOpt;
33
+ import { Buffer as NodeBuffer } from 'buffer';
34
+ if (typeof global !== 'undefined') {
35
+ global.Buffer = global.Buffer || NodeBuffer;
36
+ }
37
+ else if (typeof window !== 'undefined') {
38
+ window.Buffer = window.Buffer || NodeBuffer;
39
+ window.global = window.global || window;
40
+ }
41
+ else {
42
+ self.Buffer = self.Buffer || NodeBuffer;
43
+ self.global = self.global || self;
44
+ }
33
45
  import { AuthMethod, PublicKeyStatus, PublicKeyType, WalletType, WalletScheme, OAuthMethod, extractWalletRef, PasswordStatus, extractAuthInfo, } from '@getpara/user-management-client';
34
46
  import forge from 'node-forge';
35
47
  const { pki, jsbn } = forge;
36
48
  import { decryptWithPrivateKey, getAsymmetricKeyPair, getPublicKeyHex } from './cryptography/utils.js';
37
- import { WalletSchemeTypeMap, getPortalBaseURL, getParaConnectBaseUrl, } from './definitions.js';
38
49
  import { getBaseOAuthUrl, initClient } from './external/userManagementClient.js';
39
50
  import * as mpcComputationClient from './external/mpcComputationClient.js';
40
51
  import { distributeNewShare } from './shares/shareDistribution.js';
41
52
  import { PopupType, ParaEvent, } from './types/index.js';
42
53
  import * as transmissionUtils from './transmission/transmissionUtils.js';
43
54
  import { sendRecoveryForShare } from './shares/recovery.js';
44
- import parsePhoneNumberFromString from 'libphonenumber-js';
45
- import { getCosmosAddress, truncateAddress } from './utils/formattingUtils.js';
55
+ import { constructUrl, dispatchEvent, entityToWallet, getCosmosAddress, getEquivalentTypes, getParaConnectBaseUrl, getPortalBaseURL, getSchemes, isPregenIdentifierMatch, isWalletSupported, migrateWallet, normalizePhoneNumber, truncateAddress, WalletSchemeTypeMap, } from './utils/index.js';
46
56
  import { TransactionReviewDenied, TransactionReviewError, TransactionReviewTimeout } from './errors.js';
47
- const PARA_CORE_VERSION = '1.0.2';
48
- function dispatchEvent(type, data, error) {
49
- typeof window !== 'undefined' &&
50
- !!window.dispatchEvent &&
51
- window.dispatchEvent(new CustomEvent(type, { detail: Object.assign({ data }, (error && { error: new Error(error) })) }));
52
- }
53
- function isPregenIdentifierMatch(a, b, type) {
54
- if (!a || !b) {
55
- return false;
56
- }
57
- switch (type) {
58
- case 'EMAIL':
59
- return a.toLowerCase() === b.toLowerCase();
60
- case 'PHONE':
61
- return stringToPhoneNumber(a) === stringToPhoneNumber(b);
62
- case 'CUSTOM_ID':
63
- return a === b;
64
- default:
65
- return a.replace(/^@/g, '').toLowerCase() === b.replace(/^@/g, '').toLowerCase();
66
- }
67
- }
68
- export function entityToWallet(w) {
69
- return Object.assign(Object.assign({}, w), { scheme: w.scheme, type: w.type, pregenIdentifierType: w.pregenIdentifierType });
70
- }
71
- function migrateWallet(obj) {
72
- if (['USER', 'PREGEN'].includes(obj.type)) {
73
- obj.isPregen = obj.type === 'PREGEN';
74
- obj.type = obj.scheme === WalletScheme.ED25519 ? WalletType.SOLANA : WalletType.EVM;
75
- }
76
- if (!!obj.scheme && !obj.type) {
77
- obj.type = obj.scheme === WalletScheme.ED25519 ? WalletType.SOLANA : WalletType.EVM;
78
- }
79
- return obj;
80
- }
81
- // Make sure to keep this in sync with capsule-org/src/entities/recoveryAttemptEntity.ts
82
- export var RecoveryStatus;
83
- (function (RecoveryStatus) {
84
- RecoveryStatus["INITIATED"] = "INITIATED";
85
- RecoveryStatus["READY"] = "READY";
86
- RecoveryStatus["EXPIRED"] = "EXPIRED";
87
- RecoveryStatus["FINISHED"] = "FINISHED";
88
- RecoveryStatus["CANCELLED"] = "CANCELLED";
89
- })(RecoveryStatus || (RecoveryStatus = {}));
90
- /** @deprecated */
91
- export var PregenIdentifierType;
92
- (function (PregenIdentifierType) {
93
- PregenIdentifierType["EMAIL"] = "EMAIL";
94
- PregenIdentifierType["PHONE"] = "PHONE";
95
- })(PregenIdentifierType || (PregenIdentifierType = {}));
96
- export const PREFIX = '@CAPSULE/';
97
- const LOCAL_STORAGE_EMAIL = `${PREFIX}e-mail`;
98
- const LOCAL_STORAGE_PHONE = `${PREFIX}phone`;
99
- const LOCAL_STORAGE_COUNTRY_CODE = `${PREFIX}countryCode`;
100
- const LOCAL_STORAGE_FARCASTER_USERNAME = `${PREFIX}farcasterUsername`;
101
- const LOCAL_STORAGE_TELEGRAM_USER_ID = `${PREFIX}telegramUserId`;
102
- const LOCAL_STORAGE_USER_ID = `${PREFIX}userId`;
103
- const LOCAL_STORAGE_ED25519_WALLETS = `${PREFIX}ed25519Wallets`;
104
- const LOCAL_STORAGE_WALLETS = `${PREFIX}wallets`;
105
- const LOCAL_STORAGE_EXTERNAL_WALLETS = `${PREFIX}externalWallets`;
106
- const LOCAL_STORAGE_CURRENT_WALLET_IDS = `${PREFIX}currentWalletIds`;
107
- const LOCAL_STORAGE_CURRENT_EXTERNAL_WALLET_ADDRESSES = `${PREFIX}currentExternalWalletAddresses`;
108
- const LOCAL_STORAGE_SESSION_COOKIE = `${PREFIX}sessionCookie`;
109
- const SESSION_STORAGE_LOGIN_ENCRYPTION_KEY_PAIR = `${PREFIX}loginEncryptionKeyPair`;
110
- const POLLING_INTERVAL_MS = 2000;
111
- const SHORT_POLLING_INTERVAL_MS = 1000;
112
- export function stringToPhoneNumber(str) {
113
- var _a;
114
- return (_a = parsePhoneNumberFromString(str)) === null || _a === void 0 ? void 0 : _a.formatInternational().replace(/[^\d+]/g, '');
115
- }
116
- export function normalizePhoneNumber(countryCode, number) {
117
- return stringToPhoneNumber(`${countryCode[0] !== '+' ? '+' : ''}${countryCode}${number}`);
118
- }
119
- export function isWalletSupported(types, wallet) {
120
- return types.some((walletType) => !!WalletSchemeTypeMap[wallet.scheme][walletType]);
121
- }
122
- function getSchemes(types) {
123
- return Object.keys(WalletSchemeTypeMap).filter(scheme => {
124
- if (scheme === WalletScheme.CGGMP) {
125
- return false;
126
- }
127
- return (Array.isArray(types) ? types : Object.keys(types)).some(type => WalletSchemeTypeMap[scheme][type]);
128
- });
129
- }
130
- export function getWalletTypes(schemes) {
131
- return [
132
- ...new Set(schemes.reduce((acc, scheme) => {
133
- return [...acc, ...Object.keys(WalletSchemeTypeMap[scheme]).filter(type => WalletSchemeTypeMap[scheme][type])];
134
- }, [])),
135
- ];
136
- }
137
- export function getEquivalentTypes(types) {
138
- return getWalletTypes(getSchemes((Array.isArray(types) ? types : [types]).map(t => WalletType[t])));
139
- }
140
- export function isCosmosRequired(supportedWalletTypes) {
141
- return supportedWalletTypes.some(({ type, optional }) => type === WalletType.COSMOS && !optional);
142
- }
143
- function constructUrl({ base, path, params = {}, }) {
144
- const url = new URL(path, base);
145
- Object.entries(params).forEach(([key, value]) => {
146
- if (!!value && value !== 'undefined' && value !== 'null')
147
- url.searchParams.set(key, value.toString());
148
- });
149
- return url.toString();
150
- }
57
+ import * as constants from './constants.js';
151
58
  export class ParaCore {
152
59
  get isEmail() {
153
60
  return !!this.email && !this.phone && !this.countryCode && !this.farcasterUsername && !this.telegramUserId;
@@ -449,10 +356,10 @@ export class ParaCore {
449
356
  */
450
357
  this.clearStorage = (type = 'all') => __awaiter(this, void 0, void 0, function* () {
451
358
  const isAll = type === 'all';
452
- (isAll || type === 'local') && this.platformUtils.localStorage.clear(PREFIX);
453
- (isAll || type === 'session') && this.platformUtils.sessionStorage.clear(PREFIX);
359
+ (isAll || type === 'local') && this.platformUtils.localStorage.clear(constants.PREFIX);
360
+ (isAll || type === 'session') && this.platformUtils.sessionStorage.clear(constants.PREFIX);
454
361
  if ((isAll || type === 'secure') && this.platformUtils.secureStorage) {
455
- this.platformUtils.secureStorage.clear(PREFIX);
362
+ this.platformUtils.secureStorage.clear(constants.PREFIX);
456
363
  }
457
364
  });
458
365
  /**
@@ -495,7 +402,7 @@ export class ParaCore {
495
402
  }
496
403
  this.persistSessionCookie = (cookie) => {
497
404
  this.sessionCookie = cookie;
498
- (opts.useSessionStorage ? this.sessionStorageSetItem : this.localStorageSetItem)(LOCAL_STORAGE_SESSION_COOKIE, cookie);
405
+ (opts.useSessionStorage ? this.sessionStorageSetItem : this.localStorageSetItem)(constants.LOCAL_STORAGE_SESSION_COOKIE, cookie);
499
406
  };
500
407
  this.ctx = {
501
408
  env,
@@ -552,18 +459,18 @@ export class ParaCore {
552
459
  if (!this.platformUtils.isSyncStorage || opts.useStorageOverrides) {
553
460
  return;
554
461
  }
555
- this.email = this.localStorageGetItem(LOCAL_STORAGE_EMAIL) || undefined;
556
- this.countryCode = this.localStorageGetItem(LOCAL_STORAGE_COUNTRY_CODE) || undefined;
557
- this.phone = this.localStorageGetItem(LOCAL_STORAGE_PHONE) || undefined;
558
- this.userId = this.localStorageGetItem(LOCAL_STORAGE_USER_ID) || undefined;
559
- this.telegramUserId = this.localStorageGetItem(LOCAL_STORAGE_TELEGRAM_USER_ID) || undefined;
462
+ this.email = this.localStorageGetItem(constants.LOCAL_STORAGE_EMAIL) || undefined;
463
+ this.countryCode = this.localStorageGetItem(constants.LOCAL_STORAGE_COUNTRY_CODE) || undefined;
464
+ this.phone = this.localStorageGetItem(constants.LOCAL_STORAGE_PHONE) || undefined;
465
+ this.userId = this.localStorageGetItem(constants.LOCAL_STORAGE_USER_ID) || undefined;
466
+ this.telegramUserId = this.localStorageGetItem(constants.LOCAL_STORAGE_TELEGRAM_USER_ID) || undefined;
560
467
  const stringWallets = this.platformUtils.secureStorage
561
- ? this.platformUtils.secureStorage.get(LOCAL_STORAGE_WALLETS)
562
- : this.localStorageGetItem(LOCAL_STORAGE_WALLETS);
468
+ ? this.platformUtils.secureStorage.get(constants.LOCAL_STORAGE_WALLETS)
469
+ : this.localStorageGetItem(constants.LOCAL_STORAGE_WALLETS);
563
470
  const _wallets = JSON.parse(stringWallets || '{}');
564
471
  const stringEd25519Wallets = this.platformUtils.secureStorage
565
- ? this.platformUtils.secureStorage.get(LOCAL_STORAGE_ED25519_WALLETS)
566
- : this.localStorageGetItem(LOCAL_STORAGE_ED25519_WALLETS);
472
+ ? this.platformUtils.secureStorage.get(constants.LOCAL_STORAGE_ED25519_WALLETS)
473
+ : this.localStorageGetItem(constants.LOCAL_STORAGE_ED25519_WALLETS);
567
474
  const _ed25519Wallets = JSON.parse(stringEd25519Wallets || '{}');
568
475
  const wallets = Object.assign(Object.assign({}, Object.keys(_wallets).reduce((res, key) => {
569
476
  return Object.assign(Object.assign({}, res), { [key]: migrateWallet(_wallets[key]) });
@@ -572,7 +479,7 @@ export class ParaCore {
572
479
  }, {}));
573
480
  this.setWallets(wallets);
574
481
  // TODO: Improve not great check
575
- const _currentWalletIds = (_a = this.localStorageGetItem(LOCAL_STORAGE_CURRENT_WALLET_IDS)) !== null && _a !== void 0 ? _a : undefined;
482
+ const _currentWalletIds = (_a = this.localStorageGetItem(constants.LOCAL_STORAGE_CURRENT_WALLET_IDS)) !== null && _a !== void 0 ? _a : undefined;
576
483
  const currentWalletIds = [undefined, null, 'undefined'].includes(_currentWalletIds)
577
484
  ? {}
578
485
  : (() => {
@@ -587,22 +494,22 @@ export class ParaCore {
587
494
  this.setCurrentWalletIds(currentWalletIds);
588
495
  // TODO: remove sessionStorageGetItem call once new version is being consumed
589
496
  this.sessionCookie =
590
- this.localStorageGetItem(LOCAL_STORAGE_SESSION_COOKIE) ||
591
- this.sessionStorageGetItem(LOCAL_STORAGE_SESSION_COOKIE) ||
497
+ this.localStorageGetItem(constants.LOCAL_STORAGE_SESSION_COOKIE) ||
498
+ this.sessionStorageGetItem(constants.LOCAL_STORAGE_SESSION_COOKIE) ||
592
499
  undefined;
593
500
  // In case currentWalletIds was missing from storage
594
501
  if (Object.values(this.wallets).filter(w => this.isWalletOwned(w)).length > 0 &&
595
502
  this.currentWalletIdsArray.length === 0) {
596
503
  this.findWalletId(undefined, { forbidPregen: true });
597
504
  }
598
- const loginEncryptionKey = this.sessionStorageGetItem(SESSION_STORAGE_LOGIN_ENCRYPTION_KEY_PAIR);
505
+ const loginEncryptionKey = this.sessionStorageGetItem(constants.SESSION_STORAGE_LOGIN_ENCRYPTION_KEY_PAIR);
599
506
  if (loginEncryptionKey && loginEncryptionKey !== 'undefined') {
600
507
  this.loginEncryptionKeyPair = this.convertEncryptionKeyPair(JSON.parse(loginEncryptionKey));
601
508
  }
602
- const stringExternalWallets = this.localStorageGetItem(LOCAL_STORAGE_EXTERNAL_WALLETS);
509
+ const stringExternalWallets = this.localStorageGetItem(constants.LOCAL_STORAGE_EXTERNAL_WALLETS);
603
510
  const _externalWallets = JSON.parse(stringExternalWallets || '{}');
604
511
  this.setExternalWallets(_externalWallets);
605
- const _currentExternalWalletAddresses = this.localStorageGetItem(LOCAL_STORAGE_CURRENT_EXTERNAL_WALLET_ADDRESSES) || undefined;
512
+ const _currentExternalWalletAddresses = this.localStorageGetItem(constants.LOCAL_STORAGE_CURRENT_EXTERNAL_WALLET_ADDRESSES) || undefined;
606
513
  this.currentExternalWalletAddresses = _currentExternalWalletAddresses
607
514
  ? JSON.parse(_currentExternalWalletAddresses)
608
515
  : undefined;
@@ -658,18 +565,20 @@ export class ParaCore {
658
565
  init() {
659
566
  var _a;
660
567
  return __awaiter(this, void 0, void 0, function* () {
661
- this.email = (yield this.localStorageGetItem(LOCAL_STORAGE_EMAIL)) || undefined;
662
- this.countryCode = (yield this.localStorageGetItem(LOCAL_STORAGE_COUNTRY_CODE)) || undefined;
663
- this.phone = (yield this.localStorageGetItem(LOCAL_STORAGE_PHONE)) || undefined;
664
- this.userId = (yield this.localStorageGetItem(LOCAL_STORAGE_USER_ID)) || undefined;
665
- this.telegramUserId = (yield this.localStorageGetItem(LOCAL_STORAGE_TELEGRAM_USER_ID)) || undefined;
568
+ this.email = (yield this.localStorageGetItem(constants.LOCAL_STORAGE_EMAIL)) || undefined;
569
+ this.countryCode =
570
+ (yield this.localStorageGetItem(constants.LOCAL_STORAGE_COUNTRY_CODE)) || undefined;
571
+ this.phone = (yield this.localStorageGetItem(constants.LOCAL_STORAGE_PHONE)) || undefined;
572
+ this.userId = (yield this.localStorageGetItem(constants.LOCAL_STORAGE_USER_ID)) || undefined;
573
+ this.telegramUserId =
574
+ (yield this.localStorageGetItem(constants.LOCAL_STORAGE_TELEGRAM_USER_ID)) || undefined;
666
575
  const stringWallets = this.platformUtils.secureStorage
667
- ? yield this.platformUtils.secureStorage.get(LOCAL_STORAGE_WALLETS)
668
- : yield this.localStorageGetItem(LOCAL_STORAGE_WALLETS);
576
+ ? yield this.platformUtils.secureStorage.get(constants.LOCAL_STORAGE_WALLETS)
577
+ : yield this.localStorageGetItem(constants.LOCAL_STORAGE_WALLETS);
669
578
  const _wallets = JSON.parse(stringWallets || '{}');
670
579
  const stringEd25519Wallets = this.platformUtils.secureStorage
671
- ? yield this.platformUtils.secureStorage.get(LOCAL_STORAGE_ED25519_WALLETS)
672
- : yield this.localStorageGetItem(LOCAL_STORAGE_ED25519_WALLETS);
580
+ ? yield this.platformUtils.secureStorage.get(constants.LOCAL_STORAGE_ED25519_WALLETS)
581
+ : yield this.localStorageGetItem(constants.LOCAL_STORAGE_ED25519_WALLETS);
673
582
  const _ed25519Wallets = JSON.parse(stringEd25519Wallets || '{}');
674
583
  const wallets = Object.assign(Object.assign({}, Object.keys(_wallets).reduce((res, key) => {
675
584
  return Object.assign(Object.assign({}, res), { [key]: migrateWallet(_wallets[key]) });
@@ -678,7 +587,7 @@ export class ParaCore {
678
587
  }, {}));
679
588
  yield this.setWallets(wallets);
680
589
  // TODO: Improve not great check
681
- const _currentWalletIds = (_a = (yield this.localStorageGetItem(LOCAL_STORAGE_CURRENT_WALLET_IDS))) !== null && _a !== void 0 ? _a : undefined;
590
+ const _currentWalletIds = (_a = (yield this.localStorageGetItem(constants.LOCAL_STORAGE_CURRENT_WALLET_IDS))) !== null && _a !== void 0 ? _a : undefined;
682
591
  const currentWalletIds = [undefined, null, 'undefined', 'null'].includes(_currentWalletIds)
683
592
  ? {}
684
593
  : (() => {
@@ -693,22 +602,22 @@ export class ParaCore {
693
602
  yield this.setCurrentWalletIds(currentWalletIds);
694
603
  // TODO: remove sessionStorageGetItem call once new version is being consumed
695
604
  this.sessionCookie =
696
- (yield this.localStorageGetItem(LOCAL_STORAGE_SESSION_COOKIE)) ||
697
- (yield this.sessionStorageGetItem(LOCAL_STORAGE_SESSION_COOKIE)) ||
605
+ (yield this.localStorageGetItem(constants.LOCAL_STORAGE_SESSION_COOKIE)) ||
606
+ (yield this.sessionStorageGetItem(constants.LOCAL_STORAGE_SESSION_COOKIE)) ||
698
607
  undefined;
699
608
  // In case currentWalletIds was missing from storage
700
609
  if (Object.values(this.wallets).filter(w => this.isWalletOwned(w)).length > 0 &&
701
610
  this.currentWalletIdsArray.length === 0) {
702
611
  this.findWalletId(undefined, { forbidPregen: true });
703
612
  }
704
- const loginEncryptionKey = (yield this.sessionStorageGetItem(SESSION_STORAGE_LOGIN_ENCRYPTION_KEY_PAIR));
613
+ const loginEncryptionKey = (yield this.sessionStorageGetItem(constants.SESSION_STORAGE_LOGIN_ENCRYPTION_KEY_PAIR));
705
614
  if (loginEncryptionKey && loginEncryptionKey !== 'undefined') {
706
615
  this.loginEncryptionKeyPair = this.convertEncryptionKeyPair(JSON.parse(loginEncryptionKey));
707
616
  }
708
- const stringExternalWallets = yield this.localStorageGetItem(LOCAL_STORAGE_EXTERNAL_WALLETS);
617
+ const stringExternalWallets = yield this.localStorageGetItem(constants.LOCAL_STORAGE_EXTERNAL_WALLETS);
709
618
  const _externalWallets = JSON.parse(stringExternalWallets || '{}');
710
619
  yield this.setExternalWallets(_externalWallets);
711
- const _currentExternalWalletAddresses = (yield this.localStorageGetItem(LOCAL_STORAGE_CURRENT_EXTERNAL_WALLET_ADDRESSES)) || undefined;
620
+ const _currentExternalWalletAddresses = (yield this.localStorageGetItem(constants.LOCAL_STORAGE_CURRENT_EXTERNAL_WALLET_ADDRESSES)) || undefined;
712
621
  this.currentExternalWalletAddresses = _currentExternalWalletAddresses
713
622
  ? JSON.parse(_currentExternalWalletAddresses)
714
623
  : undefined;
@@ -722,7 +631,7 @@ export class ParaCore {
722
631
  setEmail(email) {
723
632
  return __awaiter(this, void 0, void 0, function* () {
724
633
  this.email = email;
725
- yield this.localStorageSetItem(LOCAL_STORAGE_EMAIL, email);
634
+ yield this.localStorageSetItem(constants.LOCAL_STORAGE_EMAIL, email);
726
635
  });
727
636
  }
728
637
  /**
@@ -732,7 +641,7 @@ export class ParaCore {
732
641
  setTelegramUserId(telegramUserId) {
733
642
  return __awaiter(this, void 0, void 0, function* () {
734
643
  this.telegramUserId = telegramUserId;
735
- yield this.localStorageSetItem(LOCAL_STORAGE_TELEGRAM_USER_ID, telegramUserId);
644
+ yield this.localStorageSetItem(constants.LOCAL_STORAGE_TELEGRAM_USER_ID, telegramUserId);
736
645
  });
737
646
  }
738
647
  /**
@@ -744,8 +653,8 @@ export class ParaCore {
744
653
  return __awaiter(this, void 0, void 0, function* () {
745
654
  this.phone = phone;
746
655
  this.countryCode = countryCode;
747
- yield this.localStorageSetItem(LOCAL_STORAGE_PHONE, phone);
748
- yield this.localStorageSetItem(LOCAL_STORAGE_COUNTRY_CODE, countryCode);
656
+ yield this.localStorageSetItem(constants.LOCAL_STORAGE_PHONE, phone);
657
+ yield this.localStorageSetItem(constants.LOCAL_STORAGE_COUNTRY_CODE, countryCode);
749
658
  });
750
659
  }
751
660
  /**
@@ -755,7 +664,7 @@ export class ParaCore {
755
664
  setFarcasterUsername(farcasterUsername) {
756
665
  return __awaiter(this, void 0, void 0, function* () {
757
666
  this.farcasterUsername = farcasterUsername;
758
- yield this.localStorageSetItem(LOCAL_STORAGE_FARCASTER_USERNAME, farcasterUsername);
667
+ yield this.localStorageSetItem(constants.LOCAL_STORAGE_FARCASTER_USERNAME, farcasterUsername);
759
668
  });
760
669
  }
761
670
  /**
@@ -789,7 +698,7 @@ export class ParaCore {
789
698
  setUserId(userId) {
790
699
  return __awaiter(this, void 0, void 0, function* () {
791
700
  this.userId = userId;
792
- yield this.localStorageSetItem(LOCAL_STORAGE_USER_ID, userId);
701
+ yield this.localStorageSetItem(constants.LOCAL_STORAGE_USER_ID, userId);
793
702
  });
794
703
  }
795
704
  /**
@@ -800,10 +709,10 @@ export class ParaCore {
800
709
  return __awaiter(this, void 0, void 0, function* () {
801
710
  this.wallets = wallets;
802
711
  if (this.platformUtils.secureStorage) {
803
- yield this.platformUtils.secureStorage.set(LOCAL_STORAGE_WALLETS, JSON.stringify(wallets));
712
+ yield this.platformUtils.secureStorage.set(constants.LOCAL_STORAGE_WALLETS, JSON.stringify(wallets));
804
713
  return;
805
714
  }
806
- yield this.localStorageSetItem(LOCAL_STORAGE_WALLETS, JSON.stringify(wallets));
715
+ yield this.localStorageSetItem(constants.LOCAL_STORAGE_WALLETS, JSON.stringify(wallets));
807
716
  });
808
717
  }
809
718
  /**
@@ -813,13 +722,13 @@ export class ParaCore {
813
722
  setExternalWallets(externalWallets) {
814
723
  return __awaiter(this, void 0, void 0, function* () {
815
724
  this.externalWallets = externalWallets;
816
- yield this.localStorageSetItem(LOCAL_STORAGE_EXTERNAL_WALLETS, JSON.stringify(externalWallets));
725
+ yield this.localStorageSetItem(constants.LOCAL_STORAGE_EXTERNAL_WALLETS, JSON.stringify(externalWallets));
817
726
  });
818
727
  }
819
728
  setCurrentExternalWalletAddresses(currentExternalWalletAddresses) {
820
729
  return __awaiter(this, void 0, void 0, function* () {
821
730
  this.currentExternalWalletAddresses = currentExternalWalletAddresses;
822
- yield this.localStorageSetItem(LOCAL_STORAGE_CURRENT_EXTERNAL_WALLET_ADDRESSES, JSON.stringify(currentExternalWalletAddresses));
731
+ yield this.localStorageSetItem(constants.LOCAL_STORAGE_CURRENT_EXTERNAL_WALLET_ADDRESSES, JSON.stringify(currentExternalWalletAddresses));
823
732
  });
824
733
  }
825
734
  /**
@@ -832,13 +741,13 @@ export class ParaCore {
832
741
  keyPair = yield getAsymmetricKeyPair(this.ctx);
833
742
  }
834
743
  this.loginEncryptionKeyPair = keyPair;
835
- yield this.sessionStorageSetItem(SESSION_STORAGE_LOGIN_ENCRYPTION_KEY_PAIR, JSON.stringify(keyPair));
744
+ yield this.sessionStorageSetItem(constants.SESSION_STORAGE_LOGIN_ENCRYPTION_KEY_PAIR, JSON.stringify(keyPair));
836
745
  });
837
746
  }
838
747
  deleteLoginEncryptionKeyPair() {
839
748
  return __awaiter(this, void 0, void 0, function* () {
840
749
  this.loginEncryptionKeyPair = undefined;
841
- yield this.sessionStorageRemoveItem(SESSION_STORAGE_LOGIN_ENCRYPTION_KEY_PAIR);
750
+ yield this.sessionStorageRemoveItem(constants.SESSION_STORAGE_LOGIN_ENCRYPTION_KEY_PAIR);
842
751
  });
843
752
  }
844
753
  /**
@@ -882,7 +791,7 @@ export class ParaCore {
882
791
  setCurrentWalletIds(currentWalletIds, { needsWallet = false, sessionLookupId, newDeviceSessionLookupId, } = {}) {
883
792
  return __awaiter(this, void 0, void 0, function* () {
884
793
  this.currentWalletIds = currentWalletIds;
885
- yield this.localStorageSetItem(LOCAL_STORAGE_CURRENT_WALLET_IDS, JSON.stringify(this.currentWalletIds));
794
+ yield this.localStorageSetItem(constants.LOCAL_STORAGE_CURRENT_WALLET_IDS, JSON.stringify(this.currentWalletIds));
886
795
  if (sessionLookupId) {
887
796
  yield this.ctx.client.setCurrentWalletIds(this.getUserId(), this.currentWalletIds, needsWallet, sessionLookupId, newDeviceSessionLookupId);
888
797
  }
@@ -1607,7 +1516,7 @@ export class ParaCore {
1607
1516
  this.isAwaitingAccountCreation = true;
1608
1517
  while (this.isAwaitingAccountCreation) {
1609
1518
  try {
1610
- yield new Promise(resolve => setTimeout(resolve, POLLING_INTERVAL_MS));
1519
+ yield new Promise(resolve => setTimeout(resolve, constants.POLLING_INTERVAL_MS));
1611
1520
  if (yield this.isSessionActive()) {
1612
1521
  this.isAwaitingAccountCreation = false;
1613
1522
  dispatchEvent(ParaEvent.ACCOUNT_CREATION_EVENT, true);
@@ -1666,7 +1575,7 @@ export class ParaCore {
1666
1575
  this.isAwaitingFarcaster = true;
1667
1576
  while (this.isAwaitingFarcaster) {
1668
1577
  try {
1669
- yield new Promise(resolve => setTimeout(resolve, POLLING_INTERVAL_MS));
1578
+ yield new Promise(resolve => setTimeout(resolve, constants.POLLING_INTERVAL_MS));
1670
1579
  const res = yield this.ctx.client.getFarcasterAuthStatus();
1671
1580
  if (res.data.state === 'completed') {
1672
1581
  const { userId, userExists, username, pfpUrl } = res.data;
@@ -1723,7 +1632,7 @@ export class ParaCore {
1723
1632
  if (popupWindow === null || popupWindow === void 0 ? void 0 : popupWindow.closed) {
1724
1633
  return { isError: true, userExists: false };
1725
1634
  }
1726
- yield new Promise(resolve => setTimeout(resolve, POLLING_INTERVAL_MS));
1635
+ yield new Promise(resolve => setTimeout(resolve, constants.POLLING_INTERVAL_MS));
1727
1636
  if (this.isAwaitingOAuth) {
1728
1637
  const res = yield this.touchSession();
1729
1638
  if (res.data.userId) {
@@ -1763,7 +1672,7 @@ export class ParaCore {
1763
1672
  this.isAwaitingLogin = true;
1764
1673
  while (this.isAwaitingLogin) {
1765
1674
  try {
1766
- yield new Promise(resolve => setTimeout(resolve, POLLING_INTERVAL_MS));
1675
+ yield new Promise(resolve => setTimeout(resolve, constants.POLLING_INTERVAL_MS));
1767
1676
  if (!(yield this.isSessionActive())) {
1768
1677
  if (popupWindow === null || popupWindow === void 0 ? void 0 : popupWindow.closed) {
1769
1678
  const resp = { isComplete: false, isError: true };
@@ -1935,7 +1844,7 @@ export class ParaCore {
1935
1844
  if (wallet && wallet.address) {
1936
1845
  return;
1937
1846
  }
1938
- yield new Promise(resolve => setTimeout(resolve, SHORT_POLLING_INTERVAL_MS));
1847
+ yield new Promise(resolve => setTimeout(resolve, constants.SHORT_POLLING_INTERVAL_MS));
1939
1848
  }
1940
1849
  catch (err) {
1941
1850
  // want to continue polling on error
@@ -1967,7 +1876,7 @@ export class ParaCore {
1967
1876
  if (wallet && wallet.address) {
1968
1877
  return;
1969
1878
  }
1970
- yield new Promise(resolve => setTimeout(resolve, SHORT_POLLING_INTERVAL_MS));
1879
+ yield new Promise(resolve => setTimeout(resolve, constants.SHORT_POLLING_INTERVAL_MS));
1971
1880
  }
1972
1881
  catch (err) {
1973
1882
  // want to continue polling on error
@@ -2360,7 +2269,7 @@ export class ParaCore {
2360
2269
  dispatchEvent(ParaEvent.SIGN_MESSAGE_EVENT, signRes);
2361
2270
  return signRes;
2362
2271
  }
2363
- yield new Promise(resolve => setTimeout(resolve, POLLING_INTERVAL_MS));
2272
+ yield new Promise(resolve => setTimeout(resolve, constants.POLLING_INTERVAL_MS));
2364
2273
  while (true) {
2365
2274
  if (Date.now() - timeStart > timeoutMs) {
2366
2275
  break;
@@ -2375,7 +2284,7 @@ export class ParaCore {
2375
2284
  }
2376
2285
  signRes = yield this.signMessageInner({ wallet, signerId, messageBase64, cosmosSignDocBase64 });
2377
2286
  if (signRes.pendingTransactionId) {
2378
- yield new Promise(resolve => setTimeout(resolve, POLLING_INTERVAL_MS));
2287
+ yield new Promise(resolve => setTimeout(resolve, constants.POLLING_INTERVAL_MS));
2379
2288
  }
2380
2289
  else {
2381
2290
  break;
@@ -2429,7 +2338,7 @@ export class ParaCore {
2429
2338
  dispatchEvent(ParaEvent.SIGN_TRANSACTION_EVENT, signRes);
2430
2339
  return signRes;
2431
2340
  }
2432
- yield new Promise(resolve => setTimeout(resolve, POLLING_INTERVAL_MS));
2341
+ yield new Promise(resolve => setTimeout(resolve, constants.POLLING_INTERVAL_MS));
2433
2342
  while (true) {
2434
2343
  if (Date.now() - timeStart > timeoutMs) {
2435
2344
  break;
@@ -2444,7 +2353,7 @@ export class ParaCore {
2444
2353
  }
2445
2354
  signRes = yield this.platformUtils.signTransaction(this.ctx, signerId, walletId, this.wallets[walletId].signer, rlpEncodedTxBase64, chainId, this.retrieveSessionCookie(), wallet.scheme === WalletScheme.DKLS);
2446
2355
  if (signRes.pendingTransactionId) {
2447
- yield new Promise(resolve => setTimeout(resolve, POLLING_INTERVAL_MS));
2356
+ yield new Promise(resolve => setTimeout(resolve, constants.POLLING_INTERVAL_MS));
2448
2357
  }
2449
2358
  else {
2450
2359
  break;
@@ -2664,4 +2573,4 @@ export class ParaCore {
2664
2573
  }
2665
2574
  }
2666
2575
  _ParaCore_supportedWalletTypes = new WeakMap(), _ParaCore_supportedWalletTypesOpt = new WeakMap();
2667
- ParaCore.version = PARA_CORE_VERSION;
2576
+ ParaCore.version = constants.PARA_CORE_VERSION;
@@ -0,0 +1,17 @@
1
+ export const PARA_CORE_VERSION = '1.1.0';
2
+ export const PREFIX = '@CAPSULE/';
3
+ export const LOCAL_STORAGE_EMAIL = `${PREFIX}e-mail`;
4
+ export const LOCAL_STORAGE_PHONE = `${PREFIX}phone`;
5
+ export const LOCAL_STORAGE_COUNTRY_CODE = `${PREFIX}countryCode`;
6
+ export const LOCAL_STORAGE_FARCASTER_USERNAME = `${PREFIX}farcasterUsername`;
7
+ export const LOCAL_STORAGE_TELEGRAM_USER_ID = `${PREFIX}telegramUserId`;
8
+ export const LOCAL_STORAGE_USER_ID = `${PREFIX}userId`;
9
+ export const LOCAL_STORAGE_ED25519_WALLETS = `${PREFIX}ed25519Wallets`;
10
+ export const LOCAL_STORAGE_WALLETS = `${PREFIX}wallets`;
11
+ export const LOCAL_STORAGE_EXTERNAL_WALLETS = `${PREFIX}externalWallets`;
12
+ export const LOCAL_STORAGE_CURRENT_WALLET_IDS = `${PREFIX}currentWalletIds`;
13
+ export const LOCAL_STORAGE_CURRENT_EXTERNAL_WALLET_ADDRESSES = `${PREFIX}currentExternalWalletAddresses`;
14
+ export const LOCAL_STORAGE_SESSION_COOKIE = `${PREFIX}sessionCookie`;
15
+ export const SESSION_STORAGE_LOGIN_ENCRYPTION_KEY_PAIR = `${PREFIX}loginEncryptionKeyPair`;
16
+ export const POLLING_INTERVAL_MS = 2000;
17
+ export const SHORT_POLLING_INTERVAL_MS = 1000;
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  };
10
10
  import base64url from 'base64url';
11
11
  import forge from 'node-forge';
12
- import { getPortalBaseURL } from '../definitions.js';
12
+ import { getPortalBaseURL } from '../utils/index.js';
13
13
  const rsa = forge.pki.rsa;
14
14
  const RSA_ENCRYPTION_SCHEME = 'RSA-OAEP';
15
15
  // ivs can be constant only because every key is only ever used to encrypt one message
@@ -1,5 +1,5 @@
1
1
  import Client from '@getpara/user-management-client';
2
- import { Environment } from '../definitions.js';
2
+ import { Environment } from '../types/index.js';
3
3
  export function getBaseOAuthUrl(env) {
4
4
  switch (env) {
5
5
  case Environment.DEV:
package/dist/esm/index.js CHANGED
@@ -1,19 +1,23 @@
1
- import { ParaCore, PREFIX as STORAGE_PREFIX, PregenIdentifierType, isWalletSupported } from './ParaCore.js';
2
- export { AuthMethod, EmailTheme, WalletType, WalletScheme, OnRampPurchaseType, OAuthMethod, NON_ED25519, PREGEN_IDENTIFIER_TYPES, } from '@getpara/user-management-client';
3
- export * from './definitions.js';
4
- export * from './types/index.js';
1
+ import { ParaCore } from './ParaCore.js';
2
+ export { AuthMethod, EmailTheme, Network, WalletType, WalletScheme, OnRampAsset, OnRampPurchaseType, OnRampProvider, OnRampPurchaseStatus, OAuthMethod, NON_ED25519, PREGEN_IDENTIFIER_TYPES, } from '@getpara/user-management-client';
3
+ export { OnRampMethod, PopupType, PregenIdentifierType, RecoveryStatus, } from './types/index.js';
4
+ export * from './types/events.js';
5
+ export * from './types/config.js';
6
+ export { getPortalDomain, stringToPhoneNumber, entityToWallet } from './utils/index.js';
7
+ export { PREFIX as STORAGE_PREFIX } from './constants.js';
5
8
  export { distributeNewShare } from './shares/shareDistribution.js';
6
9
  export { KeyContainer } from './shares/KeyContainer.js';
7
- export { RecoveryStatus, stringToPhoneNumber, entityToWallet } from './ParaCore.js';
8
10
  export { getBaseUrl, initClient } from './external/userManagementClient.js';
9
11
  import * as mpcComputationClient_1 from './external/mpcComputationClient.js';
10
12
  export { mpcComputationClient_1 as mpcComputationClient };
11
13
  export { decryptWithKeyPair, decryptWithPrivateKey, getAsymmetricKeyPair, getPublicKeyHex, encryptWithDerivedPublicKey, encodePrivateKeyToPemHex, getDerivedPrivateKeyAndDecrypt, getPublicKeyFromSignature, getSHA256HashHex, encryptPrivateKey, decryptPrivateKey, decryptPrivateKeyAndDecryptShare, hashPasswordWithSalt, encryptPrivateKeyWithPassword, decryptPrivateKeyWithPassword, publicKeyFromHex, } from './cryptography/utils.js';
12
14
  export * from './external/userManagementClient.js';
13
- export * from './utils/pollingUtils.js';
14
15
  export * from './errors.js';
15
- export * from './utils/formattingUtils.js';
16
+ export * from './utils/formatting.js';
17
+ export * from './utils/polling.js';
18
+ export { isWalletSupported } from './utils/wallet.js';
19
+ export { getOnRampAssets, getOnRampNetworks, toAssetInfoArray } from './utils/onRamps.js';
20
+ export { getPortalBaseURL } from './utils/url.js';
16
21
  export { retrieve as transmissionUtilsRetrieve } from './transmission/transmissionUtils.js';
17
- export { STORAGE_PREFIX, PregenIdentifierType, isWalletSupported };
18
22
  export const paraVersion = ParaCore.version;
19
23
  export default ParaCore;
@@ -0,0 +1,19 @@
1
+ import { WalletType, } from '@getpara/user-management-client';
2
+ export var Environment;
3
+ (function (Environment) {
4
+ // Internal Environments
5
+ Environment["DEV"] = "DEV";
6
+ Environment["SANDBOX"] = "SANDBOX";
7
+ Environment["BETA"] = "BETA";
8
+ Environment["PROD"] = "PROD";
9
+ // Customer-Facing Environments
10
+ // NOTE: these resolve to the corresponding internal environments for convenience
11
+ Environment["DEVELOPMENT"] = "BETA";
12
+ Environment["PRODUCTION"] = "PROD";
13
+ })(Environment || (Environment = {}));
14
+ export var EnabledFlow;
15
+ (function (EnabledFlow) {
16
+ EnabledFlow["BUY"] = "BUY";
17
+ EnabledFlow["RECEIVE"] = "RECEIVE";
18
+ EnabledFlow["WITHDRAW"] = "WITHDRAW";
19
+ })(EnabledFlow || (EnabledFlow = {}));
@@ -1,5 +1,9 @@
1
- export * from './walletTypes.js';
1
+ export * from './config.js';
2
+ export * from './wallet.js';
2
3
  export * from './params.js';
3
4
  export * from './theme.js';
4
- export * from './popupTypes.js';
5
+ export * from './onRamps.js';
6
+ export * from './popup.js';
7
+ export * from './recovery.js';
5
8
  export * from './events.js';
9
+ export { Network, OnRampAsset, OnRampProvider, OnRampPurchaseStatus, } from '@getpara/user-management-client';
@@ -0,0 +1,7 @@
1
+ export var OnRampMethod;
2
+ (function (OnRampMethod) {
3
+ OnRampMethod["ACH"] = "ACH";
4
+ OnRampMethod["DEBIT"] = "Debit";
5
+ OnRampMethod["CREDIT"] = "Credit";
6
+ OnRampMethod["APPLE_PAY"] = "Apple Pay";
7
+ })(OnRampMethod || (OnRampMethod = {}));
@@ -0,0 +1,9 @@
1
+ // Make sure to keep this in sync with capsule-org/src/entities/recoveryAttemptEntity.ts
2
+ export var RecoveryStatus;
3
+ (function (RecoveryStatus) {
4
+ RecoveryStatus["INITIATED"] = "INITIATED";
5
+ RecoveryStatus["READY"] = "READY";
6
+ RecoveryStatus["EXPIRED"] = "EXPIRED";
7
+ RecoveryStatus["FINISHED"] = "FINISHED";
8
+ RecoveryStatus["CANCELLED"] = "CANCELLED";
9
+ })(RecoveryStatus || (RecoveryStatus = {}));
@@ -0,0 +1,6 @@
1
+ /** @deprecated */
2
+ export var PregenIdentifierType;
3
+ (function (PregenIdentifierType) {
4
+ PregenIdentifierType["EMAIL"] = "EMAIL";
5
+ PregenIdentifierType["PHONE"] = "PHONE";
6
+ })(PregenIdentifierType || (PregenIdentifierType = {}));
@@ -0,0 +1,5 @@
1
+ export function dispatchEvent(type, data, error) {
2
+ typeof window !== 'undefined' &&
3
+ !!window.dispatchEvent &&
4
+ window.dispatchEvent(new CustomEvent(type, { detail: Object.assign({ data }, (error && { error: new Error(error) })) }));
5
+ }
@@ -2,6 +2,7 @@ import { toBech32 } from '@cosmjs/encoding';
2
2
  import { sha256 } from '@noble/hashes/sha256';
3
3
  import { ripemd160 } from '@noble/hashes/ripemd160';
4
4
  import elliptic from 'elliptic';
5
+ import parsePhoneNumberFromString from 'libphonenumber-js';
5
6
  const secp256k1 = new elliptic.ec('secp256k1');
6
7
  export function hexStringToBase64(hexString) {
7
8
  if (hexString.substring(0, 2) === '0x') {
@@ -56,3 +57,10 @@ export function truncateAddress(str, addressType, { prefix = addressType === 'CO
56
57
  const headLength = (addressType === 'COSMOS' ? prefix.length : addressType === 'SOLANA' ? 0 : 2) + 4;
57
58
  return `${str.slice(0, headLength)}...${str.slice(-4)}`;
58
59
  }
60
+ export function stringToPhoneNumber(str) {
61
+ var _a;
62
+ return (_a = parsePhoneNumberFromString(str)) === null || _a === void 0 ? void 0 : _a.formatInternational().replace(/[^\d+]/g, '');
63
+ }
64
+ export function normalizePhoneNumber(countryCode, number) {
65
+ return stringToPhoneNumber(`${countryCode[0] !== '+' ? '+' : ''}${countryCode}${number}`);
66
+ }