@getpara/core-sdk 1.0.1 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/ParaCore.js +132 -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 +82 -167
- 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 +4 -167
- 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;
|
|
@@ -220,11 +127,17 @@ export class ParaCore {
|
|
|
220
127
|
};
|
|
221
128
|
}
|
|
222
129
|
isPortal(envOverride) {
|
|
223
|
-
|
|
130
|
+
var _a;
|
|
131
|
+
if (typeof window === 'undefined')
|
|
132
|
+
return false;
|
|
133
|
+
return (!!((_a = window.location) === null || _a === void 0 ? void 0 : _a.host) &&
|
|
224
134
|
getPortalBaseURL(envOverride ? { env: envOverride } : this.ctx).includes(window.location.host));
|
|
225
135
|
}
|
|
226
136
|
isParaConnect() {
|
|
227
|
-
|
|
137
|
+
var _a;
|
|
138
|
+
if (typeof window === 'undefined')
|
|
139
|
+
return false;
|
|
140
|
+
return !!((_a = window.location) === null || _a === void 0 ? void 0 : _a.host) && getParaConnectBaseUrl(this.ctx).includes(window.location.host);
|
|
228
141
|
}
|
|
229
142
|
requireApiKey() {
|
|
230
143
|
if (!this.ctx.apiKey) {
|
|
@@ -443,10 +356,10 @@ export class ParaCore {
|
|
|
443
356
|
*/
|
|
444
357
|
this.clearStorage = (type = 'all') => __awaiter(this, void 0, void 0, function* () {
|
|
445
358
|
const isAll = type === 'all';
|
|
446
|
-
(isAll || type === 'local') && this.platformUtils.localStorage.clear(PREFIX);
|
|
447
|
-
(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);
|
|
448
361
|
if ((isAll || type === 'secure') && this.platformUtils.secureStorage) {
|
|
449
|
-
this.platformUtils.secureStorage.clear(PREFIX);
|
|
362
|
+
this.platformUtils.secureStorage.clear(constants.PREFIX);
|
|
450
363
|
}
|
|
451
364
|
});
|
|
452
365
|
/**
|
|
@@ -489,7 +402,7 @@ export class ParaCore {
|
|
|
489
402
|
}
|
|
490
403
|
this.persistSessionCookie = (cookie) => {
|
|
491
404
|
this.sessionCookie = cookie;
|
|
492
|
-
(opts.useSessionStorage ? this.sessionStorageSetItem : this.localStorageSetItem)(LOCAL_STORAGE_SESSION_COOKIE, cookie);
|
|
405
|
+
(opts.useSessionStorage ? this.sessionStorageSetItem : this.localStorageSetItem)(constants.LOCAL_STORAGE_SESSION_COOKIE, cookie);
|
|
493
406
|
};
|
|
494
407
|
this.ctx = {
|
|
495
408
|
env,
|
|
@@ -546,18 +459,18 @@ export class ParaCore {
|
|
|
546
459
|
if (!this.platformUtils.isSyncStorage || opts.useStorageOverrides) {
|
|
547
460
|
return;
|
|
548
461
|
}
|
|
549
|
-
this.email = this.localStorageGetItem(LOCAL_STORAGE_EMAIL) || undefined;
|
|
550
|
-
this.countryCode = this.localStorageGetItem(LOCAL_STORAGE_COUNTRY_CODE) || undefined;
|
|
551
|
-
this.phone = this.localStorageGetItem(LOCAL_STORAGE_PHONE) || undefined;
|
|
552
|
-
this.userId = this.localStorageGetItem(LOCAL_STORAGE_USER_ID) || undefined;
|
|
553
|
-
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;
|
|
554
467
|
const stringWallets = this.platformUtils.secureStorage
|
|
555
|
-
? this.platformUtils.secureStorage.get(LOCAL_STORAGE_WALLETS)
|
|
556
|
-
: this.localStorageGetItem(LOCAL_STORAGE_WALLETS);
|
|
468
|
+
? this.platformUtils.secureStorage.get(constants.LOCAL_STORAGE_WALLETS)
|
|
469
|
+
: this.localStorageGetItem(constants.LOCAL_STORAGE_WALLETS);
|
|
557
470
|
const _wallets = JSON.parse(stringWallets || '{}');
|
|
558
471
|
const stringEd25519Wallets = this.platformUtils.secureStorage
|
|
559
|
-
? this.platformUtils.secureStorage.get(LOCAL_STORAGE_ED25519_WALLETS)
|
|
560
|
-
: this.localStorageGetItem(LOCAL_STORAGE_ED25519_WALLETS);
|
|
472
|
+
? this.platformUtils.secureStorage.get(constants.LOCAL_STORAGE_ED25519_WALLETS)
|
|
473
|
+
: this.localStorageGetItem(constants.LOCAL_STORAGE_ED25519_WALLETS);
|
|
561
474
|
const _ed25519Wallets = JSON.parse(stringEd25519Wallets || '{}');
|
|
562
475
|
const wallets = Object.assign(Object.assign({}, Object.keys(_wallets).reduce((res, key) => {
|
|
563
476
|
return Object.assign(Object.assign({}, res), { [key]: migrateWallet(_wallets[key]) });
|
|
@@ -566,7 +479,7 @@ export class ParaCore {
|
|
|
566
479
|
}, {}));
|
|
567
480
|
this.setWallets(wallets);
|
|
568
481
|
// TODO: Improve not great check
|
|
569
|
-
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;
|
|
570
483
|
const currentWalletIds = [undefined, null, 'undefined'].includes(_currentWalletIds)
|
|
571
484
|
? {}
|
|
572
485
|
: (() => {
|
|
@@ -581,22 +494,22 @@ export class ParaCore {
|
|
|
581
494
|
this.setCurrentWalletIds(currentWalletIds);
|
|
582
495
|
// TODO: remove sessionStorageGetItem call once new version is being consumed
|
|
583
496
|
this.sessionCookie =
|
|
584
|
-
this.localStorageGetItem(LOCAL_STORAGE_SESSION_COOKIE) ||
|
|
585
|
-
this.sessionStorageGetItem(LOCAL_STORAGE_SESSION_COOKIE) ||
|
|
497
|
+
this.localStorageGetItem(constants.LOCAL_STORAGE_SESSION_COOKIE) ||
|
|
498
|
+
this.sessionStorageGetItem(constants.LOCAL_STORAGE_SESSION_COOKIE) ||
|
|
586
499
|
undefined;
|
|
587
500
|
// In case currentWalletIds was missing from storage
|
|
588
501
|
if (Object.values(this.wallets).filter(w => this.isWalletOwned(w)).length > 0 &&
|
|
589
502
|
this.currentWalletIdsArray.length === 0) {
|
|
590
503
|
this.findWalletId(undefined, { forbidPregen: true });
|
|
591
504
|
}
|
|
592
|
-
const loginEncryptionKey = this.sessionStorageGetItem(SESSION_STORAGE_LOGIN_ENCRYPTION_KEY_PAIR);
|
|
505
|
+
const loginEncryptionKey = this.sessionStorageGetItem(constants.SESSION_STORAGE_LOGIN_ENCRYPTION_KEY_PAIR);
|
|
593
506
|
if (loginEncryptionKey && loginEncryptionKey !== 'undefined') {
|
|
594
507
|
this.loginEncryptionKeyPair = this.convertEncryptionKeyPair(JSON.parse(loginEncryptionKey));
|
|
595
508
|
}
|
|
596
|
-
const stringExternalWallets = this.localStorageGetItem(LOCAL_STORAGE_EXTERNAL_WALLETS);
|
|
509
|
+
const stringExternalWallets = this.localStorageGetItem(constants.LOCAL_STORAGE_EXTERNAL_WALLETS);
|
|
597
510
|
const _externalWallets = JSON.parse(stringExternalWallets || '{}');
|
|
598
511
|
this.setExternalWallets(_externalWallets);
|
|
599
|
-
const _currentExternalWalletAddresses = this.localStorageGetItem(LOCAL_STORAGE_CURRENT_EXTERNAL_WALLET_ADDRESSES) || undefined;
|
|
512
|
+
const _currentExternalWalletAddresses = this.localStorageGetItem(constants.LOCAL_STORAGE_CURRENT_EXTERNAL_WALLET_ADDRESSES) || undefined;
|
|
600
513
|
this.currentExternalWalletAddresses = _currentExternalWalletAddresses
|
|
601
514
|
? JSON.parse(_currentExternalWalletAddresses)
|
|
602
515
|
: undefined;
|
|
@@ -652,18 +565,20 @@ export class ParaCore {
|
|
|
652
565
|
init() {
|
|
653
566
|
var _a;
|
|
654
567
|
return __awaiter(this, void 0, void 0, function* () {
|
|
655
|
-
this.email = (yield this.localStorageGetItem(LOCAL_STORAGE_EMAIL)) || undefined;
|
|
656
|
-
this.countryCode =
|
|
657
|
-
|
|
658
|
-
this.
|
|
659
|
-
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;
|
|
660
575
|
const stringWallets = this.platformUtils.secureStorage
|
|
661
|
-
? yield this.platformUtils.secureStorage.get(LOCAL_STORAGE_WALLETS)
|
|
662
|
-
: yield this.localStorageGetItem(LOCAL_STORAGE_WALLETS);
|
|
576
|
+
? yield this.platformUtils.secureStorage.get(constants.LOCAL_STORAGE_WALLETS)
|
|
577
|
+
: yield this.localStorageGetItem(constants.LOCAL_STORAGE_WALLETS);
|
|
663
578
|
const _wallets = JSON.parse(stringWallets || '{}');
|
|
664
579
|
const stringEd25519Wallets = this.platformUtils.secureStorage
|
|
665
|
-
? yield this.platformUtils.secureStorage.get(LOCAL_STORAGE_ED25519_WALLETS)
|
|
666
|
-
: 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);
|
|
667
582
|
const _ed25519Wallets = JSON.parse(stringEd25519Wallets || '{}');
|
|
668
583
|
const wallets = Object.assign(Object.assign({}, Object.keys(_wallets).reduce((res, key) => {
|
|
669
584
|
return Object.assign(Object.assign({}, res), { [key]: migrateWallet(_wallets[key]) });
|
|
@@ -672,7 +587,7 @@ export class ParaCore {
|
|
|
672
587
|
}, {}));
|
|
673
588
|
yield this.setWallets(wallets);
|
|
674
589
|
// TODO: Improve not great check
|
|
675
|
-
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;
|
|
676
591
|
const currentWalletIds = [undefined, null, 'undefined', 'null'].includes(_currentWalletIds)
|
|
677
592
|
? {}
|
|
678
593
|
: (() => {
|
|
@@ -687,22 +602,22 @@ export class ParaCore {
|
|
|
687
602
|
yield this.setCurrentWalletIds(currentWalletIds);
|
|
688
603
|
// TODO: remove sessionStorageGetItem call once new version is being consumed
|
|
689
604
|
this.sessionCookie =
|
|
690
|
-
(yield this.localStorageGetItem(LOCAL_STORAGE_SESSION_COOKIE)) ||
|
|
691
|
-
(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)) ||
|
|
692
607
|
undefined;
|
|
693
608
|
// In case currentWalletIds was missing from storage
|
|
694
609
|
if (Object.values(this.wallets).filter(w => this.isWalletOwned(w)).length > 0 &&
|
|
695
610
|
this.currentWalletIdsArray.length === 0) {
|
|
696
611
|
this.findWalletId(undefined, { forbidPregen: true });
|
|
697
612
|
}
|
|
698
|
-
const loginEncryptionKey = (yield this.sessionStorageGetItem(SESSION_STORAGE_LOGIN_ENCRYPTION_KEY_PAIR));
|
|
613
|
+
const loginEncryptionKey = (yield this.sessionStorageGetItem(constants.SESSION_STORAGE_LOGIN_ENCRYPTION_KEY_PAIR));
|
|
699
614
|
if (loginEncryptionKey && loginEncryptionKey !== 'undefined') {
|
|
700
615
|
this.loginEncryptionKeyPair = this.convertEncryptionKeyPair(JSON.parse(loginEncryptionKey));
|
|
701
616
|
}
|
|
702
|
-
const stringExternalWallets = yield this.localStorageGetItem(LOCAL_STORAGE_EXTERNAL_WALLETS);
|
|
617
|
+
const stringExternalWallets = yield this.localStorageGetItem(constants.LOCAL_STORAGE_EXTERNAL_WALLETS);
|
|
703
618
|
const _externalWallets = JSON.parse(stringExternalWallets || '{}');
|
|
704
619
|
yield this.setExternalWallets(_externalWallets);
|
|
705
|
-
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;
|
|
706
621
|
this.currentExternalWalletAddresses = _currentExternalWalletAddresses
|
|
707
622
|
? JSON.parse(_currentExternalWalletAddresses)
|
|
708
623
|
: undefined;
|
|
@@ -716,7 +631,7 @@ export class ParaCore {
|
|
|
716
631
|
setEmail(email) {
|
|
717
632
|
return __awaiter(this, void 0, void 0, function* () {
|
|
718
633
|
this.email = email;
|
|
719
|
-
yield this.localStorageSetItem(LOCAL_STORAGE_EMAIL, email);
|
|
634
|
+
yield this.localStorageSetItem(constants.LOCAL_STORAGE_EMAIL, email);
|
|
720
635
|
});
|
|
721
636
|
}
|
|
722
637
|
/**
|
|
@@ -726,7 +641,7 @@ export class ParaCore {
|
|
|
726
641
|
setTelegramUserId(telegramUserId) {
|
|
727
642
|
return __awaiter(this, void 0, void 0, function* () {
|
|
728
643
|
this.telegramUserId = telegramUserId;
|
|
729
|
-
yield this.localStorageSetItem(LOCAL_STORAGE_TELEGRAM_USER_ID, telegramUserId);
|
|
644
|
+
yield this.localStorageSetItem(constants.LOCAL_STORAGE_TELEGRAM_USER_ID, telegramUserId);
|
|
730
645
|
});
|
|
731
646
|
}
|
|
732
647
|
/**
|
|
@@ -738,8 +653,8 @@ export class ParaCore {
|
|
|
738
653
|
return __awaiter(this, void 0, void 0, function* () {
|
|
739
654
|
this.phone = phone;
|
|
740
655
|
this.countryCode = countryCode;
|
|
741
|
-
yield this.localStorageSetItem(LOCAL_STORAGE_PHONE, phone);
|
|
742
|
-
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);
|
|
743
658
|
});
|
|
744
659
|
}
|
|
745
660
|
/**
|
|
@@ -749,7 +664,7 @@ export class ParaCore {
|
|
|
749
664
|
setFarcasterUsername(farcasterUsername) {
|
|
750
665
|
return __awaiter(this, void 0, void 0, function* () {
|
|
751
666
|
this.farcasterUsername = farcasterUsername;
|
|
752
|
-
yield this.localStorageSetItem(LOCAL_STORAGE_FARCASTER_USERNAME, farcasterUsername);
|
|
667
|
+
yield this.localStorageSetItem(constants.LOCAL_STORAGE_FARCASTER_USERNAME, farcasterUsername);
|
|
753
668
|
});
|
|
754
669
|
}
|
|
755
670
|
/**
|
|
@@ -783,7 +698,7 @@ export class ParaCore {
|
|
|
783
698
|
setUserId(userId) {
|
|
784
699
|
return __awaiter(this, void 0, void 0, function* () {
|
|
785
700
|
this.userId = userId;
|
|
786
|
-
yield this.localStorageSetItem(LOCAL_STORAGE_USER_ID, userId);
|
|
701
|
+
yield this.localStorageSetItem(constants.LOCAL_STORAGE_USER_ID, userId);
|
|
787
702
|
});
|
|
788
703
|
}
|
|
789
704
|
/**
|
|
@@ -794,10 +709,10 @@ export class ParaCore {
|
|
|
794
709
|
return __awaiter(this, void 0, void 0, function* () {
|
|
795
710
|
this.wallets = wallets;
|
|
796
711
|
if (this.platformUtils.secureStorage) {
|
|
797
|
-
yield this.platformUtils.secureStorage.set(LOCAL_STORAGE_WALLETS, JSON.stringify(wallets));
|
|
712
|
+
yield this.platformUtils.secureStorage.set(constants.LOCAL_STORAGE_WALLETS, JSON.stringify(wallets));
|
|
798
713
|
return;
|
|
799
714
|
}
|
|
800
|
-
yield this.localStorageSetItem(LOCAL_STORAGE_WALLETS, JSON.stringify(wallets));
|
|
715
|
+
yield this.localStorageSetItem(constants.LOCAL_STORAGE_WALLETS, JSON.stringify(wallets));
|
|
801
716
|
});
|
|
802
717
|
}
|
|
803
718
|
/**
|
|
@@ -807,13 +722,13 @@ export class ParaCore {
|
|
|
807
722
|
setExternalWallets(externalWallets) {
|
|
808
723
|
return __awaiter(this, void 0, void 0, function* () {
|
|
809
724
|
this.externalWallets = externalWallets;
|
|
810
|
-
yield this.localStorageSetItem(LOCAL_STORAGE_EXTERNAL_WALLETS, JSON.stringify(externalWallets));
|
|
725
|
+
yield this.localStorageSetItem(constants.LOCAL_STORAGE_EXTERNAL_WALLETS, JSON.stringify(externalWallets));
|
|
811
726
|
});
|
|
812
727
|
}
|
|
813
728
|
setCurrentExternalWalletAddresses(currentExternalWalletAddresses) {
|
|
814
729
|
return __awaiter(this, void 0, void 0, function* () {
|
|
815
730
|
this.currentExternalWalletAddresses = currentExternalWalletAddresses;
|
|
816
|
-
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));
|
|
817
732
|
});
|
|
818
733
|
}
|
|
819
734
|
/**
|
|
@@ -826,13 +741,13 @@ export class ParaCore {
|
|
|
826
741
|
keyPair = yield getAsymmetricKeyPair(this.ctx);
|
|
827
742
|
}
|
|
828
743
|
this.loginEncryptionKeyPair = keyPair;
|
|
829
|
-
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));
|
|
830
745
|
});
|
|
831
746
|
}
|
|
832
747
|
deleteLoginEncryptionKeyPair() {
|
|
833
748
|
return __awaiter(this, void 0, void 0, function* () {
|
|
834
749
|
this.loginEncryptionKeyPair = undefined;
|
|
835
|
-
yield this.sessionStorageRemoveItem(SESSION_STORAGE_LOGIN_ENCRYPTION_KEY_PAIR);
|
|
750
|
+
yield this.sessionStorageRemoveItem(constants.SESSION_STORAGE_LOGIN_ENCRYPTION_KEY_PAIR);
|
|
836
751
|
});
|
|
837
752
|
}
|
|
838
753
|
/**
|
|
@@ -876,7 +791,7 @@ export class ParaCore {
|
|
|
876
791
|
setCurrentWalletIds(currentWalletIds, { needsWallet = false, sessionLookupId, newDeviceSessionLookupId, } = {}) {
|
|
877
792
|
return __awaiter(this, void 0, void 0, function* () {
|
|
878
793
|
this.currentWalletIds = currentWalletIds;
|
|
879
|
-
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));
|
|
880
795
|
if (sessionLookupId) {
|
|
881
796
|
yield this.ctx.client.setCurrentWalletIds(this.getUserId(), this.currentWalletIds, needsWallet, sessionLookupId, newDeviceSessionLookupId);
|
|
882
797
|
}
|
|
@@ -1601,7 +1516,7 @@ export class ParaCore {
|
|
|
1601
1516
|
this.isAwaitingAccountCreation = true;
|
|
1602
1517
|
while (this.isAwaitingAccountCreation) {
|
|
1603
1518
|
try {
|
|
1604
|
-
yield new Promise(resolve => setTimeout(resolve, POLLING_INTERVAL_MS));
|
|
1519
|
+
yield new Promise(resolve => setTimeout(resolve, constants.POLLING_INTERVAL_MS));
|
|
1605
1520
|
if (yield this.isSessionActive()) {
|
|
1606
1521
|
this.isAwaitingAccountCreation = false;
|
|
1607
1522
|
dispatchEvent(ParaEvent.ACCOUNT_CREATION_EVENT, true);
|
|
@@ -1660,7 +1575,7 @@ export class ParaCore {
|
|
|
1660
1575
|
this.isAwaitingFarcaster = true;
|
|
1661
1576
|
while (this.isAwaitingFarcaster) {
|
|
1662
1577
|
try {
|
|
1663
|
-
yield new Promise(resolve => setTimeout(resolve, POLLING_INTERVAL_MS));
|
|
1578
|
+
yield new Promise(resolve => setTimeout(resolve, constants.POLLING_INTERVAL_MS));
|
|
1664
1579
|
const res = yield this.ctx.client.getFarcasterAuthStatus();
|
|
1665
1580
|
if (res.data.state === 'completed') {
|
|
1666
1581
|
const { userId, userExists, username, pfpUrl } = res.data;
|
|
@@ -1717,7 +1632,7 @@ export class ParaCore {
|
|
|
1717
1632
|
if (popupWindow === null || popupWindow === void 0 ? void 0 : popupWindow.closed) {
|
|
1718
1633
|
return { isError: true, userExists: false };
|
|
1719
1634
|
}
|
|
1720
|
-
yield new Promise(resolve => setTimeout(resolve, POLLING_INTERVAL_MS));
|
|
1635
|
+
yield new Promise(resolve => setTimeout(resolve, constants.POLLING_INTERVAL_MS));
|
|
1721
1636
|
if (this.isAwaitingOAuth) {
|
|
1722
1637
|
const res = yield this.touchSession();
|
|
1723
1638
|
if (res.data.userId) {
|
|
@@ -1757,7 +1672,7 @@ export class ParaCore {
|
|
|
1757
1672
|
this.isAwaitingLogin = true;
|
|
1758
1673
|
while (this.isAwaitingLogin) {
|
|
1759
1674
|
try {
|
|
1760
|
-
yield new Promise(resolve => setTimeout(resolve, POLLING_INTERVAL_MS));
|
|
1675
|
+
yield new Promise(resolve => setTimeout(resolve, constants.POLLING_INTERVAL_MS));
|
|
1761
1676
|
if (!(yield this.isSessionActive())) {
|
|
1762
1677
|
if (popupWindow === null || popupWindow === void 0 ? void 0 : popupWindow.closed) {
|
|
1763
1678
|
const resp = { isComplete: false, isError: true };
|
|
@@ -1929,7 +1844,7 @@ export class ParaCore {
|
|
|
1929
1844
|
if (wallet && wallet.address) {
|
|
1930
1845
|
return;
|
|
1931
1846
|
}
|
|
1932
|
-
yield new Promise(resolve => setTimeout(resolve, SHORT_POLLING_INTERVAL_MS));
|
|
1847
|
+
yield new Promise(resolve => setTimeout(resolve, constants.SHORT_POLLING_INTERVAL_MS));
|
|
1933
1848
|
}
|
|
1934
1849
|
catch (err) {
|
|
1935
1850
|
// want to continue polling on error
|
|
@@ -1961,7 +1876,7 @@ export class ParaCore {
|
|
|
1961
1876
|
if (wallet && wallet.address) {
|
|
1962
1877
|
return;
|
|
1963
1878
|
}
|
|
1964
|
-
yield new Promise(resolve => setTimeout(resolve, SHORT_POLLING_INTERVAL_MS));
|
|
1879
|
+
yield new Promise(resolve => setTimeout(resolve, constants.SHORT_POLLING_INTERVAL_MS));
|
|
1965
1880
|
}
|
|
1966
1881
|
catch (err) {
|
|
1967
1882
|
// want to continue polling on error
|
|
@@ -2354,7 +2269,7 @@ export class ParaCore {
|
|
|
2354
2269
|
dispatchEvent(ParaEvent.SIGN_MESSAGE_EVENT, signRes);
|
|
2355
2270
|
return signRes;
|
|
2356
2271
|
}
|
|
2357
|
-
yield new Promise(resolve => setTimeout(resolve, POLLING_INTERVAL_MS));
|
|
2272
|
+
yield new Promise(resolve => setTimeout(resolve, constants.POLLING_INTERVAL_MS));
|
|
2358
2273
|
while (true) {
|
|
2359
2274
|
if (Date.now() - timeStart > timeoutMs) {
|
|
2360
2275
|
break;
|
|
@@ -2369,7 +2284,7 @@ export class ParaCore {
|
|
|
2369
2284
|
}
|
|
2370
2285
|
signRes = yield this.signMessageInner({ wallet, signerId, messageBase64, cosmosSignDocBase64 });
|
|
2371
2286
|
if (signRes.pendingTransactionId) {
|
|
2372
|
-
yield new Promise(resolve => setTimeout(resolve, POLLING_INTERVAL_MS));
|
|
2287
|
+
yield new Promise(resolve => setTimeout(resolve, constants.POLLING_INTERVAL_MS));
|
|
2373
2288
|
}
|
|
2374
2289
|
else {
|
|
2375
2290
|
break;
|
|
@@ -2423,7 +2338,7 @@ export class ParaCore {
|
|
|
2423
2338
|
dispatchEvent(ParaEvent.SIGN_TRANSACTION_EVENT, signRes);
|
|
2424
2339
|
return signRes;
|
|
2425
2340
|
}
|
|
2426
|
-
yield new Promise(resolve => setTimeout(resolve, POLLING_INTERVAL_MS));
|
|
2341
|
+
yield new Promise(resolve => setTimeout(resolve, constants.POLLING_INTERVAL_MS));
|
|
2427
2342
|
while (true) {
|
|
2428
2343
|
if (Date.now() - timeStart > timeoutMs) {
|
|
2429
2344
|
break;
|
|
@@ -2438,7 +2353,7 @@ export class ParaCore {
|
|
|
2438
2353
|
}
|
|
2439
2354
|
signRes = yield this.platformUtils.signTransaction(this.ctx, signerId, walletId, this.wallets[walletId].signer, rlpEncodedTxBase64, chainId, this.retrieveSessionCookie(), wallet.scheme === WalletScheme.DKLS);
|
|
2440
2355
|
if (signRes.pendingTransactionId) {
|
|
2441
|
-
yield new Promise(resolve => setTimeout(resolve, POLLING_INTERVAL_MS));
|
|
2356
|
+
yield new Promise(resolve => setTimeout(resolve, constants.POLLING_INTERVAL_MS));
|
|
2442
2357
|
}
|
|
2443
2358
|
else {
|
|
2444
2359
|
break;
|
|
@@ -2658,4 +2573,4 @@ export class ParaCore {
|
|
|
2658
2573
|
}
|
|
2659
2574
|
}
|
|
2660
2575
|
_ParaCore_supportedWalletTypes = new WeakMap(), _ParaCore_supportedWalletTypesOpt = new WeakMap();
|
|
2661
|
-
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 '../
|
|
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 = {}));
|