@getpara/core-sdk 1.0.2 → 1.2.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.
- package/dist/cjs/ParaCore.js +140 -224
- package/dist/cjs/constants.js +20 -0
- package/dist/cjs/cryptography/utils.js +2 -2
- package/dist/cjs/external/userManagementClient.js +14 -14
- package/dist/cjs/index.js +28 -12
- package/dist/cjs/types/config.js +22 -0
- package/dist/cjs/types/index.js +11 -2
- package/dist/cjs/types/onRamps.js +10 -0
- package/dist/cjs/types/recovery.js +12 -0
- package/dist/cjs/types/wallet.js +9 -0
- package/dist/cjs/utils/events.js +9 -0
- package/dist/cjs/utils/{formattingUtils.js → formatting.js} +11 -1
- package/dist/cjs/utils/index.js +22 -0
- package/dist/cjs/utils/onRamps.js +36 -0
- package/dist/cjs/utils/url.js +74 -0
- package/dist/cjs/utils/wallet.js +74 -0
- package/dist/esm/ParaCore.js +89 -166
- package/dist/esm/constants.js +17 -0
- package/dist/esm/cryptography/utils.js +1 -1
- package/dist/esm/external/userManagementClient.js +1 -1
- package/dist/esm/index.js +12 -8
- package/dist/esm/types/config.js +19 -0
- package/dist/esm/types/index.js +6 -2
- package/dist/esm/types/onRamps.js +7 -0
- package/dist/esm/types/recovery.js +9 -0
- package/dist/esm/types/wallet.js +6 -0
- package/dist/esm/utils/events.js +5 -0
- package/dist/esm/utils/{formattingUtils.js → formatting.js} +8 -0
- package/dist/esm/utils/index.js +6 -0
- package/dist/esm/utils/onRamps.js +30 -0
- package/dist/esm/utils/url.js +66 -0
- package/dist/esm/utils/wallet.js +64 -0
- package/dist/types/ParaCore.d.ts +12 -168
- package/dist/types/PlatformUtils.d.ts +1 -3
- package/dist/types/constants.d.ts +17 -0
- package/dist/types/cryptography/utils.d.ts +1 -1
- package/dist/types/external/userManagementClient.d.ts +1 -1
- package/dist/types/index.d.ts +12 -10
- package/dist/types/shares/recovery.d.ts +1 -1
- package/dist/types/shares/shareDistribution.d.ts +1 -1
- package/dist/types/types/config.d.ts +162 -0
- package/dist/types/types/events.d.ts +10 -10
- package/dist/types/types/index.d.ts +6 -2
- package/dist/types/types/onRamps.d.ts +10 -0
- package/dist/types/types/recovery.d.ts +7 -0
- package/dist/types/types/wallet.d.ts +39 -0
- package/dist/types/utils/events.d.ts +2 -0
- package/dist/types/utils/{formattingUtils.d.ts → formatting.d.ts} +3 -1
- package/dist/types/utils/index.d.ts +6 -0
- package/dist/types/utils/onRamps.d.ts +12 -0
- package/dist/types/utils/url.d.ts +15 -0
- package/dist/types/utils/wallet.d.ts +10 -0
- package/package.json +3 -3
- package/dist/cjs/definitions.js +0 -153
- package/dist/cjs/types/walletTypes.js +0 -2
- package/dist/esm/definitions.js +0 -140
- package/dist/esm/types/walletTypes.js +0 -1
- package/dist/types/definitions.d.ts +0 -86
- package/dist/types/types/walletTypes.d.ts +0 -11
- /package/dist/cjs/types/{popupTypes.js → popup.js} +0 -0
- /package/dist/cjs/utils/{pollingUtils.js → polling.js} +0 -0
- /package/dist/esm/types/{popupTypes.js → popup.js} +0 -0
- /package/dist/esm/utils/{pollingUtils.js → polling.js} +0 -0
- /package/dist/types/types/{popupTypes.d.ts → popup.d.ts} +0 -0
- /package/dist/types/utils/{pollingUtils.d.ts → polling.d.ts} +0 -0
package/dist/esm/ParaCore.js
CHANGED
|
@@ -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
|
|
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
|
-
|
|
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 =
|
|
663
|
-
|
|
664
|
-
this.
|
|
665
|
-
this.
|
|
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;
|
|
@@ -1691,9 +1600,10 @@ export class ParaCore {
|
|
|
1691
1600
|
*
|
|
1692
1601
|
* @param {Object} opts the options object
|
|
1693
1602
|
* @param {OAuthMethod} opts.method the third-party service to use for OAuth.
|
|
1603
|
+
* @param {string} [opts.deeplinkUrl] the deeplink to redirect to after the OAuth flow. This is for mobile only.
|
|
1694
1604
|
* @returns {string} the URL for the user to log in with OAuth.
|
|
1695
1605
|
*/
|
|
1696
|
-
getOAuthURL({ method }) {
|
|
1606
|
+
getOAuthURL({ method, deeplinkUrl }) {
|
|
1697
1607
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1698
1608
|
yield this.logout();
|
|
1699
1609
|
const res = yield this.touchSession(true);
|
|
@@ -1703,6 +1613,7 @@ export class ParaCore {
|
|
|
1703
1613
|
params: {
|
|
1704
1614
|
apiKey: this.ctx.apiKey,
|
|
1705
1615
|
sessionLookupId: res.data.sessionLookupId,
|
|
1616
|
+
deeplinkUrl,
|
|
1706
1617
|
},
|
|
1707
1618
|
});
|
|
1708
1619
|
});
|
|
@@ -1723,7 +1634,7 @@ export class ParaCore {
|
|
|
1723
1634
|
if (popupWindow === null || popupWindow === void 0 ? void 0 : popupWindow.closed) {
|
|
1724
1635
|
return { isError: true, userExists: false };
|
|
1725
1636
|
}
|
|
1726
|
-
yield new Promise(resolve => setTimeout(resolve, POLLING_INTERVAL_MS));
|
|
1637
|
+
yield new Promise(resolve => setTimeout(resolve, constants.POLLING_INTERVAL_MS));
|
|
1727
1638
|
if (this.isAwaitingOAuth) {
|
|
1728
1639
|
const res = yield this.touchSession();
|
|
1729
1640
|
if (res.data.userId) {
|
|
@@ -1763,7 +1674,7 @@ export class ParaCore {
|
|
|
1763
1674
|
this.isAwaitingLogin = true;
|
|
1764
1675
|
while (this.isAwaitingLogin) {
|
|
1765
1676
|
try {
|
|
1766
|
-
yield new Promise(resolve => setTimeout(resolve, POLLING_INTERVAL_MS));
|
|
1677
|
+
yield new Promise(resolve => setTimeout(resolve, constants.POLLING_INTERVAL_MS));
|
|
1767
1678
|
if (!(yield this.isSessionActive())) {
|
|
1768
1679
|
if (popupWindow === null || popupWindow === void 0 ? void 0 : popupWindow.closed) {
|
|
1769
1680
|
const resp = { isComplete: false, isError: true };
|
|
@@ -1935,7 +1846,7 @@ export class ParaCore {
|
|
|
1935
1846
|
if (wallet && wallet.address) {
|
|
1936
1847
|
return;
|
|
1937
1848
|
}
|
|
1938
|
-
yield new Promise(resolve => setTimeout(resolve, SHORT_POLLING_INTERVAL_MS));
|
|
1849
|
+
yield new Promise(resolve => setTimeout(resolve, constants.SHORT_POLLING_INTERVAL_MS));
|
|
1939
1850
|
}
|
|
1940
1851
|
catch (err) {
|
|
1941
1852
|
// want to continue polling on error
|
|
@@ -1967,7 +1878,7 @@ export class ParaCore {
|
|
|
1967
1878
|
if (wallet && wallet.address) {
|
|
1968
1879
|
return;
|
|
1969
1880
|
}
|
|
1970
|
-
yield new Promise(resolve => setTimeout(resolve, SHORT_POLLING_INTERVAL_MS));
|
|
1881
|
+
yield new Promise(resolve => setTimeout(resolve, constants.SHORT_POLLING_INTERVAL_MS));
|
|
1971
1882
|
}
|
|
1972
1883
|
catch (err) {
|
|
1973
1884
|
// want to continue polling on error
|
|
@@ -2360,7 +2271,7 @@ export class ParaCore {
|
|
|
2360
2271
|
dispatchEvent(ParaEvent.SIGN_MESSAGE_EVENT, signRes);
|
|
2361
2272
|
return signRes;
|
|
2362
2273
|
}
|
|
2363
|
-
yield new Promise(resolve => setTimeout(resolve, POLLING_INTERVAL_MS));
|
|
2274
|
+
yield new Promise(resolve => setTimeout(resolve, constants.POLLING_INTERVAL_MS));
|
|
2364
2275
|
while (true) {
|
|
2365
2276
|
if (Date.now() - timeStart > timeoutMs) {
|
|
2366
2277
|
break;
|
|
@@ -2375,7 +2286,7 @@ export class ParaCore {
|
|
|
2375
2286
|
}
|
|
2376
2287
|
signRes = yield this.signMessageInner({ wallet, signerId, messageBase64, cosmosSignDocBase64 });
|
|
2377
2288
|
if (signRes.pendingTransactionId) {
|
|
2378
|
-
yield new Promise(resolve => setTimeout(resolve, POLLING_INTERVAL_MS));
|
|
2289
|
+
yield new Promise(resolve => setTimeout(resolve, constants.POLLING_INTERVAL_MS));
|
|
2379
2290
|
}
|
|
2380
2291
|
else {
|
|
2381
2292
|
break;
|
|
@@ -2429,7 +2340,7 @@ export class ParaCore {
|
|
|
2429
2340
|
dispatchEvent(ParaEvent.SIGN_TRANSACTION_EVENT, signRes);
|
|
2430
2341
|
return signRes;
|
|
2431
2342
|
}
|
|
2432
|
-
yield new Promise(resolve => setTimeout(resolve, POLLING_INTERVAL_MS));
|
|
2343
|
+
yield new Promise(resolve => setTimeout(resolve, constants.POLLING_INTERVAL_MS));
|
|
2433
2344
|
while (true) {
|
|
2434
2345
|
if (Date.now() - timeStart > timeoutMs) {
|
|
2435
2346
|
break;
|
|
@@ -2444,7 +2355,7 @@ export class ParaCore {
|
|
|
2444
2355
|
}
|
|
2445
2356
|
signRes = yield this.platformUtils.signTransaction(this.ctx, signerId, walletId, this.wallets[walletId].signer, rlpEncodedTxBase64, chainId, this.retrieveSessionCookie(), wallet.scheme === WalletScheme.DKLS);
|
|
2446
2357
|
if (signRes.pendingTransactionId) {
|
|
2447
|
-
yield new Promise(resolve => setTimeout(resolve, POLLING_INTERVAL_MS));
|
|
2358
|
+
yield new Promise(resolve => setTimeout(resolve, constants.POLLING_INTERVAL_MS));
|
|
2448
2359
|
}
|
|
2449
2360
|
else {
|
|
2450
2361
|
break;
|
|
@@ -2529,6 +2440,8 @@ export class ParaCore {
|
|
|
2529
2440
|
sessionCookie: this.sessionCookie,
|
|
2530
2441
|
phone: this.phone,
|
|
2531
2442
|
countryCode: this.countryCode,
|
|
2443
|
+
telegramUserId: this.telegramUserId,
|
|
2444
|
+
farcasterUsername: this.farcasterUsername,
|
|
2532
2445
|
};
|
|
2533
2446
|
return Buffer.from(JSON.stringify(sessionInfo)).toString('base64');
|
|
2534
2447
|
}
|
|
@@ -2584,6 +2497,16 @@ export class ParaCore {
|
|
|
2584
2497
|
this.exitFarcaster();
|
|
2585
2498
|
this.exitOAuth();
|
|
2586
2499
|
}
|
|
2500
|
+
/**
|
|
2501
|
+
* Retrieves a token to verify the current session.
|
|
2502
|
+
* @returns {Promise<string>} the ID
|
|
2503
|
+
**/
|
|
2504
|
+
getVerificationToken() {
|
|
2505
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2506
|
+
const { data } = yield this.touchSession();
|
|
2507
|
+
return data.sessionLookupId;
|
|
2508
|
+
});
|
|
2509
|
+
}
|
|
2587
2510
|
/**
|
|
2588
2511
|
* Logs the user out.
|
|
2589
2512
|
* @param {Object} opts the options object.
|
|
@@ -2664,4 +2587,4 @@ export class ParaCore {
|
|
|
2664
2587
|
}
|
|
2665
2588
|
}
|
|
2666
2589
|
_ParaCore_supportedWalletTypes = new WeakMap(), _ParaCore_supportedWalletTypesOpt = new WeakMap();
|
|
2667
|
-
ParaCore.version = PARA_CORE_VERSION;
|
|
2590
|
+
ParaCore.version = constants.PARA_CORE_VERSION;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export const PARA_CORE_VERSION = '1.2.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 '../
|
|
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
|
package/dist/esm/index.js
CHANGED
|
@@ -1,19 +1,23 @@
|
|
|
1
|
-
import { ParaCore
|
|
2
|
-
export { AuthMethod, EmailTheme, WalletType, WalletScheme, OnRampPurchaseType, OAuthMethod, NON_ED25519, PREGEN_IDENTIFIER_TYPES, } from '@getpara/user-management-client';
|
|
3
|
-
export
|
|
4
|
-
export * from './types/
|
|
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/
|
|
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 = {}));
|
package/dist/esm/types/index.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
export * from './
|
|
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 './
|
|
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,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 = {}));
|