@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/cjs/ParaCore.js
CHANGED
|
@@ -58,132 +58,32 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
58
58
|
};
|
|
59
59
|
var _ParaCore_supportedWalletTypes, _ParaCore_supportedWalletTypesOpt;
|
|
60
60
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
61
|
-
exports.ParaCore =
|
|
61
|
+
exports.ParaCore = void 0;
|
|
62
|
+
const buffer_1 = require("buffer");
|
|
63
|
+
if (typeof global !== 'undefined') {
|
|
64
|
+
global.Buffer = global.Buffer || buffer_1.Buffer;
|
|
65
|
+
}
|
|
66
|
+
else if (typeof window !== 'undefined') {
|
|
67
|
+
window.Buffer = window.Buffer || buffer_1.Buffer;
|
|
68
|
+
window.global = window.global || window;
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
self.Buffer = self.Buffer || buffer_1.Buffer;
|
|
72
|
+
self.global = self.global || self;
|
|
73
|
+
}
|
|
62
74
|
const user_management_client_1 = require("@getpara/user-management-client");
|
|
63
75
|
const node_forge_1 = __importDefault(require("node-forge"));
|
|
64
76
|
const { pki, jsbn } = node_forge_1.default;
|
|
65
77
|
const utils_js_1 = require("./cryptography/utils.js");
|
|
66
|
-
const definitions_js_1 = require("./definitions.js");
|
|
67
78
|
const userManagementClient_js_1 = require("./external/userManagementClient.js");
|
|
68
79
|
const mpcComputationClient = __importStar(require("./external/mpcComputationClient.js"));
|
|
69
80
|
const shareDistribution_js_1 = require("./shares/shareDistribution.js");
|
|
70
81
|
const index_js_1 = require("./types/index.js");
|
|
71
82
|
const transmissionUtils = __importStar(require("./transmission/transmissionUtils.js"));
|
|
72
83
|
const recovery_js_1 = require("./shares/recovery.js");
|
|
73
|
-
const
|
|
74
|
-
const formattingUtils_js_1 = require("./utils/formattingUtils.js");
|
|
84
|
+
const index_js_2 = require("./utils/index.js");
|
|
75
85
|
const errors_js_1 = require("./errors.js");
|
|
76
|
-
const
|
|
77
|
-
function dispatchEvent(type, data, error) {
|
|
78
|
-
typeof window !== 'undefined' &&
|
|
79
|
-
!!window.dispatchEvent &&
|
|
80
|
-
window.dispatchEvent(new CustomEvent(type, { detail: Object.assign({ data }, (error && { error: new Error(error) })) }));
|
|
81
|
-
}
|
|
82
|
-
function isPregenIdentifierMatch(a, b, type) {
|
|
83
|
-
if (!a || !b) {
|
|
84
|
-
return false;
|
|
85
|
-
}
|
|
86
|
-
switch (type) {
|
|
87
|
-
case 'EMAIL':
|
|
88
|
-
return a.toLowerCase() === b.toLowerCase();
|
|
89
|
-
case 'PHONE':
|
|
90
|
-
return stringToPhoneNumber(a) === stringToPhoneNumber(b);
|
|
91
|
-
case 'CUSTOM_ID':
|
|
92
|
-
return a === b;
|
|
93
|
-
default:
|
|
94
|
-
return a.replace(/^@/g, '').toLowerCase() === b.replace(/^@/g, '').toLowerCase();
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
function entityToWallet(w) {
|
|
98
|
-
return Object.assign(Object.assign({}, w), { scheme: w.scheme, type: w.type, pregenIdentifierType: w.pregenIdentifierType });
|
|
99
|
-
}
|
|
100
|
-
exports.entityToWallet = entityToWallet;
|
|
101
|
-
function migrateWallet(obj) {
|
|
102
|
-
if (['USER', 'PREGEN'].includes(obj.type)) {
|
|
103
|
-
obj.isPregen = obj.type === 'PREGEN';
|
|
104
|
-
obj.type = obj.scheme === user_management_client_1.WalletScheme.ED25519 ? user_management_client_1.WalletType.SOLANA : user_management_client_1.WalletType.EVM;
|
|
105
|
-
}
|
|
106
|
-
if (!!obj.scheme && !obj.type) {
|
|
107
|
-
obj.type = obj.scheme === user_management_client_1.WalletScheme.ED25519 ? user_management_client_1.WalletType.SOLANA : user_management_client_1.WalletType.EVM;
|
|
108
|
-
}
|
|
109
|
-
return obj;
|
|
110
|
-
}
|
|
111
|
-
// Make sure to keep this in sync with capsule-org/src/entities/recoveryAttemptEntity.ts
|
|
112
|
-
var RecoveryStatus;
|
|
113
|
-
(function (RecoveryStatus) {
|
|
114
|
-
RecoveryStatus["INITIATED"] = "INITIATED";
|
|
115
|
-
RecoveryStatus["READY"] = "READY";
|
|
116
|
-
RecoveryStatus["EXPIRED"] = "EXPIRED";
|
|
117
|
-
RecoveryStatus["FINISHED"] = "FINISHED";
|
|
118
|
-
RecoveryStatus["CANCELLED"] = "CANCELLED";
|
|
119
|
-
})(RecoveryStatus || (exports.RecoveryStatus = RecoveryStatus = {}));
|
|
120
|
-
/** @deprecated */
|
|
121
|
-
var PregenIdentifierType;
|
|
122
|
-
(function (PregenIdentifierType) {
|
|
123
|
-
PregenIdentifierType["EMAIL"] = "EMAIL";
|
|
124
|
-
PregenIdentifierType["PHONE"] = "PHONE";
|
|
125
|
-
})(PregenIdentifierType || (exports.PregenIdentifierType = PregenIdentifierType = {}));
|
|
126
|
-
exports.PREFIX = '@CAPSULE/';
|
|
127
|
-
const LOCAL_STORAGE_EMAIL = `${exports.PREFIX}e-mail`;
|
|
128
|
-
const LOCAL_STORAGE_PHONE = `${exports.PREFIX}phone`;
|
|
129
|
-
const LOCAL_STORAGE_COUNTRY_CODE = `${exports.PREFIX}countryCode`;
|
|
130
|
-
const LOCAL_STORAGE_FARCASTER_USERNAME = `${exports.PREFIX}farcasterUsername`;
|
|
131
|
-
const LOCAL_STORAGE_TELEGRAM_USER_ID = `${exports.PREFIX}telegramUserId`;
|
|
132
|
-
const LOCAL_STORAGE_USER_ID = `${exports.PREFIX}userId`;
|
|
133
|
-
const LOCAL_STORAGE_ED25519_WALLETS = `${exports.PREFIX}ed25519Wallets`;
|
|
134
|
-
const LOCAL_STORAGE_WALLETS = `${exports.PREFIX}wallets`;
|
|
135
|
-
const LOCAL_STORAGE_EXTERNAL_WALLETS = `${exports.PREFIX}externalWallets`;
|
|
136
|
-
const LOCAL_STORAGE_CURRENT_WALLET_IDS = `${exports.PREFIX}currentWalletIds`;
|
|
137
|
-
const LOCAL_STORAGE_CURRENT_EXTERNAL_WALLET_ADDRESSES = `${exports.PREFIX}currentExternalWalletAddresses`;
|
|
138
|
-
const LOCAL_STORAGE_SESSION_COOKIE = `${exports.PREFIX}sessionCookie`;
|
|
139
|
-
const SESSION_STORAGE_LOGIN_ENCRYPTION_KEY_PAIR = `${exports.PREFIX}loginEncryptionKeyPair`;
|
|
140
|
-
const POLLING_INTERVAL_MS = 2000;
|
|
141
|
-
const SHORT_POLLING_INTERVAL_MS = 1000;
|
|
142
|
-
function stringToPhoneNumber(str) {
|
|
143
|
-
var _a;
|
|
144
|
-
return (_a = (0, libphonenumber_js_1.default)(str)) === null || _a === void 0 ? void 0 : _a.formatInternational().replace(/[^\d+]/g, '');
|
|
145
|
-
}
|
|
146
|
-
exports.stringToPhoneNumber = stringToPhoneNumber;
|
|
147
|
-
function normalizePhoneNumber(countryCode, number) {
|
|
148
|
-
return stringToPhoneNumber(`${countryCode[0] !== '+' ? '+' : ''}${countryCode}${number}`);
|
|
149
|
-
}
|
|
150
|
-
exports.normalizePhoneNumber = normalizePhoneNumber;
|
|
151
|
-
function isWalletSupported(types, wallet) {
|
|
152
|
-
return types.some((walletType) => !!definitions_js_1.WalletSchemeTypeMap[wallet.scheme][walletType]);
|
|
153
|
-
}
|
|
154
|
-
exports.isWalletSupported = isWalletSupported;
|
|
155
|
-
function getSchemes(types) {
|
|
156
|
-
return Object.keys(definitions_js_1.WalletSchemeTypeMap).filter(scheme => {
|
|
157
|
-
if (scheme === user_management_client_1.WalletScheme.CGGMP) {
|
|
158
|
-
return false;
|
|
159
|
-
}
|
|
160
|
-
return (Array.isArray(types) ? types : Object.keys(types)).some(type => definitions_js_1.WalletSchemeTypeMap[scheme][type]);
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
function getWalletTypes(schemes) {
|
|
164
|
-
return [
|
|
165
|
-
...new Set(schemes.reduce((acc, scheme) => {
|
|
166
|
-
return [...acc, ...Object.keys(definitions_js_1.WalletSchemeTypeMap[scheme]).filter(type => definitions_js_1.WalletSchemeTypeMap[scheme][type])];
|
|
167
|
-
}, [])),
|
|
168
|
-
];
|
|
169
|
-
}
|
|
170
|
-
exports.getWalletTypes = getWalletTypes;
|
|
171
|
-
function getEquivalentTypes(types) {
|
|
172
|
-
return getWalletTypes(getSchemes((Array.isArray(types) ? types : [types]).map(t => user_management_client_1.WalletType[t])));
|
|
173
|
-
}
|
|
174
|
-
exports.getEquivalentTypes = getEquivalentTypes;
|
|
175
|
-
function isCosmosRequired(supportedWalletTypes) {
|
|
176
|
-
return supportedWalletTypes.some(({ type, optional }) => type === user_management_client_1.WalletType.COSMOS && !optional);
|
|
177
|
-
}
|
|
178
|
-
exports.isCosmosRequired = isCosmosRequired;
|
|
179
|
-
function constructUrl({ base, path, params = {}, }) {
|
|
180
|
-
const url = new URL(path, base);
|
|
181
|
-
Object.entries(params).forEach(([key, value]) => {
|
|
182
|
-
if (!!value && value !== 'undefined' && value !== 'null')
|
|
183
|
-
url.searchParams.set(key, value.toString());
|
|
184
|
-
});
|
|
185
|
-
return url.toString();
|
|
186
|
-
}
|
|
86
|
+
const constants = __importStar(require("./constants.js"));
|
|
187
87
|
class ParaCore {
|
|
188
88
|
get isEmail() {
|
|
189
89
|
return !!this.email && !this.phone && !this.countryCode && !this.farcasterUsername && !this.telegramUserId;
|
|
@@ -260,13 +160,13 @@ class ParaCore {
|
|
|
260
160
|
if (typeof window === 'undefined')
|
|
261
161
|
return false;
|
|
262
162
|
return (!!((_a = window.location) === null || _a === void 0 ? void 0 : _a.host) &&
|
|
263
|
-
(0,
|
|
163
|
+
(0, index_js_2.getPortalBaseURL)(envOverride ? { env: envOverride } : this.ctx).includes(window.location.host));
|
|
264
164
|
}
|
|
265
165
|
isParaConnect() {
|
|
266
166
|
var _a;
|
|
267
167
|
if (typeof window === 'undefined')
|
|
268
168
|
return false;
|
|
269
|
-
return !!((_a = window.location) === null || _a === void 0 ? void 0 : _a.host) && (0,
|
|
169
|
+
return !!((_a = window.location) === null || _a === void 0 ? void 0 : _a.host) && (0, index_js_2.getParaConnectBaseUrl)(this.ctx).includes(window.location.host);
|
|
270
170
|
}
|
|
271
171
|
requireApiKey() {
|
|
272
172
|
if (!this.ctx.apiKey) {
|
|
@@ -276,7 +176,7 @@ class ParaCore {
|
|
|
276
176
|
}
|
|
277
177
|
isWalletSupported(wallet) {
|
|
278
178
|
var _a;
|
|
279
|
-
return !__classPrivateFieldGet(this, _ParaCore_supportedWalletTypes, "f") || isWalletSupported((_a = this.supportedWalletTypes.map(({ type }) => type)) !== null && _a !== void 0 ? _a : [], wallet);
|
|
179
|
+
return !__classPrivateFieldGet(this, _ParaCore_supportedWalletTypes, "f") || (0, index_js_2.isWalletSupported)((_a = this.supportedWalletTypes.map(({ type }) => type)) !== null && _a !== void 0 ? _a : [], wallet);
|
|
280
180
|
}
|
|
281
181
|
isWalletOwned(wallet) {
|
|
282
182
|
return (this.isWalletSupported(wallet) &&
|
|
@@ -293,7 +193,7 @@ class ParaCore {
|
|
|
293
193
|
return (this.isWalletSupported(wallet) &&
|
|
294
194
|
this.isPregenWalletUnclaimed(wallet) &&
|
|
295
195
|
(!['EMAIL', 'PHONE', 'TELEGRAM'].includes(wallet.pregenIdentifierType) ||
|
|
296
|
-
isPregenIdentifierMatch(wallet.pregenIdentifierType === 'EMAIL'
|
|
196
|
+
(0, index_js_2.isPregenIdentifierMatch)(wallet.pregenIdentifierType === 'EMAIL'
|
|
297
197
|
? this.email
|
|
298
198
|
: wallet.pregenIdentifierType === 'TELEGRAM'
|
|
299
199
|
? this.telegramUserId
|
|
@@ -317,7 +217,7 @@ class ParaCore {
|
|
|
317
217
|
error = `wallet with id ${wallet.id} and type ${wallet.type} is not supported, supported types are: ${this.supportedWalletTypes.map(({ type }) => type).join(', ')}`;
|
|
318
218
|
}
|
|
319
219
|
else if (types &&
|
|
320
|
-
(!getEquivalentTypes(types).includes(wallet.type) ||
|
|
220
|
+
(!(0, index_js_2.getEquivalentTypes)(types).includes(wallet.type) ||
|
|
321
221
|
(isOwned && !types.some(type => { var _a; return ((_a = this.currentWalletIds[type]) !== null && _a !== void 0 ? _a : []).includes(walletId); })))) {
|
|
322
222
|
error = `wallet with id ${wallet.id} and type ${wallet.type} cannot be selected`;
|
|
323
223
|
}
|
|
@@ -345,7 +245,7 @@ class ParaCore {
|
|
|
345
245
|
var _a;
|
|
346
246
|
if (this.externalWallets[walletId]) {
|
|
347
247
|
const wallet = this.externalWallets[walletId];
|
|
348
|
-
return options.truncate ? (0,
|
|
248
|
+
return options.truncate ? (0, index_js_2.truncateAddress)(wallet.address, wallet.type, { prefix: this.cosmosPrefix }) : wallet.address;
|
|
349
249
|
}
|
|
350
250
|
const wallet = this.findWallet(walletId, options.addressType);
|
|
351
251
|
if (!wallet) {
|
|
@@ -354,13 +254,13 @@ class ParaCore {
|
|
|
354
254
|
let str;
|
|
355
255
|
switch (wallet.type) {
|
|
356
256
|
case user_management_client_1.WalletType.COSMOS:
|
|
357
|
-
str = (0,
|
|
257
|
+
str = (0, index_js_2.getCosmosAddress)(wallet.publicKey, (_a = this.cosmosPrefix) !== null && _a !== void 0 ? _a : 'cosmos');
|
|
358
258
|
break;
|
|
359
259
|
default:
|
|
360
260
|
str = wallet.address;
|
|
361
261
|
break;
|
|
362
262
|
}
|
|
363
|
-
return options.truncate ? (0,
|
|
263
|
+
return options.truncate ? (0, index_js_2.truncateAddress)(str, wallet.type, { prefix: this.cosmosPrefix }) : str;
|
|
364
264
|
}
|
|
365
265
|
/**
|
|
366
266
|
* Returns a unique hash for a wallet suitable for use as an identicon seed.
|
|
@@ -386,7 +286,7 @@ class ParaCore {
|
|
|
386
286
|
constructPortalUrl(type, opts = {}) {
|
|
387
287
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
388
288
|
return __awaiter(this, void 0, void 0, function* () {
|
|
389
|
-
const base = type === 'onRamp' ? (0,
|
|
289
|
+
const base = type === 'onRamp' ? (0, index_js_2.getPortalBaseURL)(this.ctx) : yield this.getPortalURL(opts.partnerId);
|
|
390
290
|
let path;
|
|
391
291
|
switch (type) {
|
|
392
292
|
case 'createPassword': {
|
|
@@ -439,7 +339,7 @@ class ParaCore {
|
|
|
439
339
|
pfpUrl: opts.pfpUrl,
|
|
440
340
|
}
|
|
441
341
|
: {})), (opts.params || {}));
|
|
442
|
-
return constructUrl({ base, path, params });
|
|
342
|
+
return (0, index_js_2.constructUrl)({ base, path, params });
|
|
443
343
|
});
|
|
444
344
|
}
|
|
445
345
|
/**
|
|
@@ -485,10 +385,10 @@ class ParaCore {
|
|
|
485
385
|
*/
|
|
486
386
|
this.clearStorage = (type = 'all') => __awaiter(this, void 0, void 0, function* () {
|
|
487
387
|
const isAll = type === 'all';
|
|
488
|
-
(isAll || type === 'local') && this.platformUtils.localStorage.clear(
|
|
489
|
-
(isAll || type === 'session') && this.platformUtils.sessionStorage.clear(
|
|
388
|
+
(isAll || type === 'local') && this.platformUtils.localStorage.clear(constants.PREFIX);
|
|
389
|
+
(isAll || type === 'session') && this.platformUtils.sessionStorage.clear(constants.PREFIX);
|
|
490
390
|
if ((isAll || type === 'secure') && this.platformUtils.secureStorage) {
|
|
491
|
-
this.platformUtils.secureStorage.clear(
|
|
391
|
+
this.platformUtils.secureStorage.clear(constants.PREFIX);
|
|
492
392
|
}
|
|
493
393
|
});
|
|
494
394
|
/**
|
|
@@ -531,7 +431,7 @@ class ParaCore {
|
|
|
531
431
|
}
|
|
532
432
|
this.persistSessionCookie = (cookie) => {
|
|
533
433
|
this.sessionCookie = cookie;
|
|
534
|
-
(opts.useSessionStorage ? this.sessionStorageSetItem : this.localStorageSetItem)(LOCAL_STORAGE_SESSION_COOKIE, cookie);
|
|
434
|
+
(opts.useSessionStorage ? this.sessionStorageSetItem : this.localStorageSetItem)(constants.LOCAL_STORAGE_SESSION_COOKIE, cookie);
|
|
535
435
|
};
|
|
536
436
|
this.ctx = {
|
|
537
437
|
env,
|
|
@@ -588,34 +488,34 @@ class ParaCore {
|
|
|
588
488
|
if (!this.platformUtils.isSyncStorage || opts.useStorageOverrides) {
|
|
589
489
|
return;
|
|
590
490
|
}
|
|
591
|
-
this.email = this.localStorageGetItem(LOCAL_STORAGE_EMAIL) || undefined;
|
|
592
|
-
this.countryCode = this.localStorageGetItem(LOCAL_STORAGE_COUNTRY_CODE) || undefined;
|
|
593
|
-
this.phone = this.localStorageGetItem(LOCAL_STORAGE_PHONE) || undefined;
|
|
594
|
-
this.userId = this.localStorageGetItem(LOCAL_STORAGE_USER_ID) || undefined;
|
|
595
|
-
this.telegramUserId = this.localStorageGetItem(LOCAL_STORAGE_TELEGRAM_USER_ID) || undefined;
|
|
491
|
+
this.email = this.localStorageGetItem(constants.LOCAL_STORAGE_EMAIL) || undefined;
|
|
492
|
+
this.countryCode = this.localStorageGetItem(constants.LOCAL_STORAGE_COUNTRY_CODE) || undefined;
|
|
493
|
+
this.phone = this.localStorageGetItem(constants.LOCAL_STORAGE_PHONE) || undefined;
|
|
494
|
+
this.userId = this.localStorageGetItem(constants.LOCAL_STORAGE_USER_ID) || undefined;
|
|
495
|
+
this.telegramUserId = this.localStorageGetItem(constants.LOCAL_STORAGE_TELEGRAM_USER_ID) || undefined;
|
|
596
496
|
const stringWallets = this.platformUtils.secureStorage
|
|
597
|
-
? this.platformUtils.secureStorage.get(LOCAL_STORAGE_WALLETS)
|
|
598
|
-
: this.localStorageGetItem(LOCAL_STORAGE_WALLETS);
|
|
497
|
+
? this.platformUtils.secureStorage.get(constants.LOCAL_STORAGE_WALLETS)
|
|
498
|
+
: this.localStorageGetItem(constants.LOCAL_STORAGE_WALLETS);
|
|
599
499
|
const _wallets = JSON.parse(stringWallets || '{}');
|
|
600
500
|
const stringEd25519Wallets = this.platformUtils.secureStorage
|
|
601
|
-
? this.platformUtils.secureStorage.get(LOCAL_STORAGE_ED25519_WALLETS)
|
|
602
|
-
: this.localStorageGetItem(LOCAL_STORAGE_ED25519_WALLETS);
|
|
501
|
+
? this.platformUtils.secureStorage.get(constants.LOCAL_STORAGE_ED25519_WALLETS)
|
|
502
|
+
: this.localStorageGetItem(constants.LOCAL_STORAGE_ED25519_WALLETS);
|
|
603
503
|
const _ed25519Wallets = JSON.parse(stringEd25519Wallets || '{}');
|
|
604
504
|
const wallets = Object.assign(Object.assign({}, Object.keys(_wallets).reduce((res, key) => {
|
|
605
|
-
return Object.assign(Object.assign({}, res), { [key]: migrateWallet(_wallets[key]) });
|
|
505
|
+
return Object.assign(Object.assign({}, res), { [key]: (0, index_js_2.migrateWallet)(_wallets[key]) });
|
|
606
506
|
}, {})), Object.keys(_ed25519Wallets).reduce((res, key) => {
|
|
607
|
-
return Object.assign(Object.assign({}, res), (!res[key] ? { [key]: migrateWallet(_ed25519Wallets[key]) } : {}));
|
|
507
|
+
return Object.assign(Object.assign({}, res), (!res[key] ? { [key]: (0, index_js_2.migrateWallet)(_ed25519Wallets[key]) } : {}));
|
|
608
508
|
}, {}));
|
|
609
509
|
this.setWallets(wallets);
|
|
610
510
|
// TODO: Improve not great check
|
|
611
|
-
const _currentWalletIds = (_a = this.localStorageGetItem(LOCAL_STORAGE_CURRENT_WALLET_IDS)) !== null && _a !== void 0 ? _a : undefined;
|
|
511
|
+
const _currentWalletIds = (_a = this.localStorageGetItem(constants.LOCAL_STORAGE_CURRENT_WALLET_IDS)) !== null && _a !== void 0 ? _a : undefined;
|
|
612
512
|
const currentWalletIds = [undefined, null, 'undefined'].includes(_currentWalletIds)
|
|
613
513
|
? {}
|
|
614
514
|
: (() => {
|
|
615
515
|
const fromJson = JSON.parse(_currentWalletIds);
|
|
616
516
|
return Array.isArray(fromJson)
|
|
617
517
|
? Object.keys(user_management_client_1.WalletType).reduce((acc, type) => {
|
|
618
|
-
const wallet = Object.values(this.wallets).find(w => fromJson.includes(w.id) &&
|
|
518
|
+
const wallet = Object.values(this.wallets).find(w => fromJson.includes(w.id) && index_js_2.WalletSchemeTypeMap[w.scheme][type]);
|
|
619
519
|
return Object.assign(Object.assign({}, acc), (wallet && !acc[type] ? { [type]: [wallet.id] } : {}));
|
|
620
520
|
}, {})
|
|
621
521
|
: fromJson;
|
|
@@ -623,22 +523,22 @@ class ParaCore {
|
|
|
623
523
|
this.setCurrentWalletIds(currentWalletIds);
|
|
624
524
|
// TODO: remove sessionStorageGetItem call once new version is being consumed
|
|
625
525
|
this.sessionCookie =
|
|
626
|
-
this.localStorageGetItem(LOCAL_STORAGE_SESSION_COOKIE) ||
|
|
627
|
-
this.sessionStorageGetItem(LOCAL_STORAGE_SESSION_COOKIE) ||
|
|
526
|
+
this.localStorageGetItem(constants.LOCAL_STORAGE_SESSION_COOKIE) ||
|
|
527
|
+
this.sessionStorageGetItem(constants.LOCAL_STORAGE_SESSION_COOKIE) ||
|
|
628
528
|
undefined;
|
|
629
529
|
// In case currentWalletIds was missing from storage
|
|
630
530
|
if (Object.values(this.wallets).filter(w => this.isWalletOwned(w)).length > 0 &&
|
|
631
531
|
this.currentWalletIdsArray.length === 0) {
|
|
632
532
|
this.findWalletId(undefined, { forbidPregen: true });
|
|
633
533
|
}
|
|
634
|
-
const loginEncryptionKey = this.sessionStorageGetItem(SESSION_STORAGE_LOGIN_ENCRYPTION_KEY_PAIR);
|
|
534
|
+
const loginEncryptionKey = this.sessionStorageGetItem(constants.SESSION_STORAGE_LOGIN_ENCRYPTION_KEY_PAIR);
|
|
635
535
|
if (loginEncryptionKey && loginEncryptionKey !== 'undefined') {
|
|
636
536
|
this.loginEncryptionKeyPair = this.convertEncryptionKeyPair(JSON.parse(loginEncryptionKey));
|
|
637
537
|
}
|
|
638
|
-
const stringExternalWallets = this.localStorageGetItem(LOCAL_STORAGE_EXTERNAL_WALLETS);
|
|
538
|
+
const stringExternalWallets = this.localStorageGetItem(constants.LOCAL_STORAGE_EXTERNAL_WALLETS);
|
|
639
539
|
const _externalWallets = JSON.parse(stringExternalWallets || '{}');
|
|
640
540
|
this.setExternalWallets(_externalWallets);
|
|
641
|
-
const _currentExternalWalletAddresses = this.localStorageGetItem(LOCAL_STORAGE_CURRENT_EXTERNAL_WALLET_ADDRESSES) || undefined;
|
|
541
|
+
const _currentExternalWalletAddresses = this.localStorageGetItem(constants.LOCAL_STORAGE_CURRENT_EXTERNAL_WALLET_ADDRESSES) || undefined;
|
|
642
542
|
this.currentExternalWalletAddresses = _currentExternalWalletAddresses
|
|
643
543
|
? JSON.parse(_currentExternalWalletAddresses)
|
|
644
544
|
: undefined;
|
|
@@ -694,34 +594,36 @@ class ParaCore {
|
|
|
694
594
|
init() {
|
|
695
595
|
var _a;
|
|
696
596
|
return __awaiter(this, void 0, void 0, function* () {
|
|
697
|
-
this.email = (yield this.localStorageGetItem(LOCAL_STORAGE_EMAIL)) || undefined;
|
|
698
|
-
this.countryCode =
|
|
699
|
-
|
|
700
|
-
this.
|
|
701
|
-
this.
|
|
597
|
+
this.email = (yield this.localStorageGetItem(constants.LOCAL_STORAGE_EMAIL)) || undefined;
|
|
598
|
+
this.countryCode =
|
|
599
|
+
(yield this.localStorageGetItem(constants.LOCAL_STORAGE_COUNTRY_CODE)) || undefined;
|
|
600
|
+
this.phone = (yield this.localStorageGetItem(constants.LOCAL_STORAGE_PHONE)) || undefined;
|
|
601
|
+
this.userId = (yield this.localStorageGetItem(constants.LOCAL_STORAGE_USER_ID)) || undefined;
|
|
602
|
+
this.telegramUserId =
|
|
603
|
+
(yield this.localStorageGetItem(constants.LOCAL_STORAGE_TELEGRAM_USER_ID)) || undefined;
|
|
702
604
|
const stringWallets = this.platformUtils.secureStorage
|
|
703
|
-
? yield this.platformUtils.secureStorage.get(LOCAL_STORAGE_WALLETS)
|
|
704
|
-
: yield this.localStorageGetItem(LOCAL_STORAGE_WALLETS);
|
|
605
|
+
? yield this.platformUtils.secureStorage.get(constants.LOCAL_STORAGE_WALLETS)
|
|
606
|
+
: yield this.localStorageGetItem(constants.LOCAL_STORAGE_WALLETS);
|
|
705
607
|
const _wallets = JSON.parse(stringWallets || '{}');
|
|
706
608
|
const stringEd25519Wallets = this.platformUtils.secureStorage
|
|
707
|
-
? yield this.platformUtils.secureStorage.get(LOCAL_STORAGE_ED25519_WALLETS)
|
|
708
|
-
: yield this.localStorageGetItem(LOCAL_STORAGE_ED25519_WALLETS);
|
|
609
|
+
? yield this.platformUtils.secureStorage.get(constants.LOCAL_STORAGE_ED25519_WALLETS)
|
|
610
|
+
: yield this.localStorageGetItem(constants.LOCAL_STORAGE_ED25519_WALLETS);
|
|
709
611
|
const _ed25519Wallets = JSON.parse(stringEd25519Wallets || '{}');
|
|
710
612
|
const wallets = Object.assign(Object.assign({}, Object.keys(_wallets).reduce((res, key) => {
|
|
711
|
-
return Object.assign(Object.assign({}, res), { [key]: migrateWallet(_wallets[key]) });
|
|
613
|
+
return Object.assign(Object.assign({}, res), { [key]: (0, index_js_2.migrateWallet)(_wallets[key]) });
|
|
712
614
|
}, {})), Object.keys(_ed25519Wallets).reduce((res, key) => {
|
|
713
|
-
return Object.assign(Object.assign({}, res), (!res[key] ? { [key]: migrateWallet(_ed25519Wallets[key]) } : {}));
|
|
615
|
+
return Object.assign(Object.assign({}, res), (!res[key] ? { [key]: (0, index_js_2.migrateWallet)(_ed25519Wallets[key]) } : {}));
|
|
714
616
|
}, {}));
|
|
715
617
|
yield this.setWallets(wallets);
|
|
716
618
|
// TODO: Improve not great check
|
|
717
|
-
const _currentWalletIds = (_a = (yield this.localStorageGetItem(LOCAL_STORAGE_CURRENT_WALLET_IDS))) !== null && _a !== void 0 ? _a : undefined;
|
|
619
|
+
const _currentWalletIds = (_a = (yield this.localStorageGetItem(constants.LOCAL_STORAGE_CURRENT_WALLET_IDS))) !== null && _a !== void 0 ? _a : undefined;
|
|
718
620
|
const currentWalletIds = [undefined, null, 'undefined', 'null'].includes(_currentWalletIds)
|
|
719
621
|
? {}
|
|
720
622
|
: (() => {
|
|
721
623
|
const fromJson = JSON.parse(_currentWalletIds);
|
|
722
624
|
return Array.isArray(fromJson)
|
|
723
625
|
? Object.keys(user_management_client_1.WalletType).reduce((acc, type) => {
|
|
724
|
-
const wallet = Object.values(this.wallets).find(w => fromJson.includes(w.id) &&
|
|
626
|
+
const wallet = Object.values(this.wallets).find(w => fromJson.includes(w.id) && index_js_2.WalletSchemeTypeMap[w.scheme][type]);
|
|
725
627
|
return Object.assign(Object.assign({}, acc), (wallet && !acc[type] ? { [type]: [wallet.id] } : {}));
|
|
726
628
|
}, {})
|
|
727
629
|
: fromJson;
|
|
@@ -729,22 +631,22 @@ class ParaCore {
|
|
|
729
631
|
yield this.setCurrentWalletIds(currentWalletIds);
|
|
730
632
|
// TODO: remove sessionStorageGetItem call once new version is being consumed
|
|
731
633
|
this.sessionCookie =
|
|
732
|
-
(yield this.localStorageGetItem(LOCAL_STORAGE_SESSION_COOKIE)) ||
|
|
733
|
-
(yield this.sessionStorageGetItem(LOCAL_STORAGE_SESSION_COOKIE)) ||
|
|
634
|
+
(yield this.localStorageGetItem(constants.LOCAL_STORAGE_SESSION_COOKIE)) ||
|
|
635
|
+
(yield this.sessionStorageGetItem(constants.LOCAL_STORAGE_SESSION_COOKIE)) ||
|
|
734
636
|
undefined;
|
|
735
637
|
// In case currentWalletIds was missing from storage
|
|
736
638
|
if (Object.values(this.wallets).filter(w => this.isWalletOwned(w)).length > 0 &&
|
|
737
639
|
this.currentWalletIdsArray.length === 0) {
|
|
738
640
|
this.findWalletId(undefined, { forbidPregen: true });
|
|
739
641
|
}
|
|
740
|
-
const loginEncryptionKey = (yield this.sessionStorageGetItem(SESSION_STORAGE_LOGIN_ENCRYPTION_KEY_PAIR));
|
|
642
|
+
const loginEncryptionKey = (yield this.sessionStorageGetItem(constants.SESSION_STORAGE_LOGIN_ENCRYPTION_KEY_PAIR));
|
|
741
643
|
if (loginEncryptionKey && loginEncryptionKey !== 'undefined') {
|
|
742
644
|
this.loginEncryptionKeyPair = this.convertEncryptionKeyPair(JSON.parse(loginEncryptionKey));
|
|
743
645
|
}
|
|
744
|
-
const stringExternalWallets = yield this.localStorageGetItem(LOCAL_STORAGE_EXTERNAL_WALLETS);
|
|
646
|
+
const stringExternalWallets = yield this.localStorageGetItem(constants.LOCAL_STORAGE_EXTERNAL_WALLETS);
|
|
745
647
|
const _externalWallets = JSON.parse(stringExternalWallets || '{}');
|
|
746
648
|
yield this.setExternalWallets(_externalWallets);
|
|
747
|
-
const _currentExternalWalletAddresses = (yield this.localStorageGetItem(LOCAL_STORAGE_CURRENT_EXTERNAL_WALLET_ADDRESSES)) || undefined;
|
|
649
|
+
const _currentExternalWalletAddresses = (yield this.localStorageGetItem(constants.LOCAL_STORAGE_CURRENT_EXTERNAL_WALLET_ADDRESSES)) || undefined;
|
|
748
650
|
this.currentExternalWalletAddresses = _currentExternalWalletAddresses
|
|
749
651
|
? JSON.parse(_currentExternalWalletAddresses)
|
|
750
652
|
: undefined;
|
|
@@ -758,7 +660,7 @@ class ParaCore {
|
|
|
758
660
|
setEmail(email) {
|
|
759
661
|
return __awaiter(this, void 0, void 0, function* () {
|
|
760
662
|
this.email = email;
|
|
761
|
-
yield this.localStorageSetItem(LOCAL_STORAGE_EMAIL, email);
|
|
663
|
+
yield this.localStorageSetItem(constants.LOCAL_STORAGE_EMAIL, email);
|
|
762
664
|
});
|
|
763
665
|
}
|
|
764
666
|
/**
|
|
@@ -768,7 +670,7 @@ class ParaCore {
|
|
|
768
670
|
setTelegramUserId(telegramUserId) {
|
|
769
671
|
return __awaiter(this, void 0, void 0, function* () {
|
|
770
672
|
this.telegramUserId = telegramUserId;
|
|
771
|
-
yield this.localStorageSetItem(LOCAL_STORAGE_TELEGRAM_USER_ID, telegramUserId);
|
|
673
|
+
yield this.localStorageSetItem(constants.LOCAL_STORAGE_TELEGRAM_USER_ID, telegramUserId);
|
|
772
674
|
});
|
|
773
675
|
}
|
|
774
676
|
/**
|
|
@@ -780,8 +682,8 @@ class ParaCore {
|
|
|
780
682
|
return __awaiter(this, void 0, void 0, function* () {
|
|
781
683
|
this.phone = phone;
|
|
782
684
|
this.countryCode = countryCode;
|
|
783
|
-
yield this.localStorageSetItem(LOCAL_STORAGE_PHONE, phone);
|
|
784
|
-
yield this.localStorageSetItem(LOCAL_STORAGE_COUNTRY_CODE, countryCode);
|
|
685
|
+
yield this.localStorageSetItem(constants.LOCAL_STORAGE_PHONE, phone);
|
|
686
|
+
yield this.localStorageSetItem(constants.LOCAL_STORAGE_COUNTRY_CODE, countryCode);
|
|
785
687
|
});
|
|
786
688
|
}
|
|
787
689
|
/**
|
|
@@ -791,7 +693,7 @@ class ParaCore {
|
|
|
791
693
|
setFarcasterUsername(farcasterUsername) {
|
|
792
694
|
return __awaiter(this, void 0, void 0, function* () {
|
|
793
695
|
this.farcasterUsername = farcasterUsername;
|
|
794
|
-
yield this.localStorageSetItem(LOCAL_STORAGE_FARCASTER_USERNAME, farcasterUsername);
|
|
696
|
+
yield this.localStorageSetItem(constants.LOCAL_STORAGE_FARCASTER_USERNAME, farcasterUsername);
|
|
795
697
|
});
|
|
796
698
|
}
|
|
797
699
|
/**
|
|
@@ -815,7 +717,7 @@ class ParaCore {
|
|
|
815
717
|
this.currentExternalWalletAddresses = [address];
|
|
816
718
|
this.setCurrentExternalWalletAddresses(this.currentExternalWalletAddresses);
|
|
817
719
|
this.setExternalWallets(this.externalWallets);
|
|
818
|
-
dispatchEvent(index_js_1.ParaEvent.EXTERNAL_WALLET_CHANGE_EVENT, null);
|
|
720
|
+
(0, index_js_2.dispatchEvent)(index_js_1.ParaEvent.EXTERNAL_WALLET_CHANGE_EVENT, null);
|
|
819
721
|
});
|
|
820
722
|
}
|
|
821
723
|
/**
|
|
@@ -825,7 +727,7 @@ class ParaCore {
|
|
|
825
727
|
setUserId(userId) {
|
|
826
728
|
return __awaiter(this, void 0, void 0, function* () {
|
|
827
729
|
this.userId = userId;
|
|
828
|
-
yield this.localStorageSetItem(LOCAL_STORAGE_USER_ID, userId);
|
|
730
|
+
yield this.localStorageSetItem(constants.LOCAL_STORAGE_USER_ID, userId);
|
|
829
731
|
});
|
|
830
732
|
}
|
|
831
733
|
/**
|
|
@@ -836,10 +738,10 @@ class ParaCore {
|
|
|
836
738
|
return __awaiter(this, void 0, void 0, function* () {
|
|
837
739
|
this.wallets = wallets;
|
|
838
740
|
if (this.platformUtils.secureStorage) {
|
|
839
|
-
yield this.platformUtils.secureStorage.set(LOCAL_STORAGE_WALLETS, JSON.stringify(wallets));
|
|
741
|
+
yield this.platformUtils.secureStorage.set(constants.LOCAL_STORAGE_WALLETS, JSON.stringify(wallets));
|
|
840
742
|
return;
|
|
841
743
|
}
|
|
842
|
-
yield this.localStorageSetItem(LOCAL_STORAGE_WALLETS, JSON.stringify(wallets));
|
|
744
|
+
yield this.localStorageSetItem(constants.LOCAL_STORAGE_WALLETS, JSON.stringify(wallets));
|
|
843
745
|
});
|
|
844
746
|
}
|
|
845
747
|
/**
|
|
@@ -849,13 +751,13 @@ class ParaCore {
|
|
|
849
751
|
setExternalWallets(externalWallets) {
|
|
850
752
|
return __awaiter(this, void 0, void 0, function* () {
|
|
851
753
|
this.externalWallets = externalWallets;
|
|
852
|
-
yield this.localStorageSetItem(LOCAL_STORAGE_EXTERNAL_WALLETS, JSON.stringify(externalWallets));
|
|
754
|
+
yield this.localStorageSetItem(constants.LOCAL_STORAGE_EXTERNAL_WALLETS, JSON.stringify(externalWallets));
|
|
853
755
|
});
|
|
854
756
|
}
|
|
855
757
|
setCurrentExternalWalletAddresses(currentExternalWalletAddresses) {
|
|
856
758
|
return __awaiter(this, void 0, void 0, function* () {
|
|
857
759
|
this.currentExternalWalletAddresses = currentExternalWalletAddresses;
|
|
858
|
-
yield this.localStorageSetItem(LOCAL_STORAGE_CURRENT_EXTERNAL_WALLET_ADDRESSES, JSON.stringify(currentExternalWalletAddresses));
|
|
760
|
+
yield this.localStorageSetItem(constants.LOCAL_STORAGE_CURRENT_EXTERNAL_WALLET_ADDRESSES, JSON.stringify(currentExternalWalletAddresses));
|
|
859
761
|
});
|
|
860
762
|
}
|
|
861
763
|
/**
|
|
@@ -868,13 +770,13 @@ class ParaCore {
|
|
|
868
770
|
keyPair = yield (0, utils_js_1.getAsymmetricKeyPair)(this.ctx);
|
|
869
771
|
}
|
|
870
772
|
this.loginEncryptionKeyPair = keyPair;
|
|
871
|
-
yield this.sessionStorageSetItem(SESSION_STORAGE_LOGIN_ENCRYPTION_KEY_PAIR, JSON.stringify(keyPair));
|
|
773
|
+
yield this.sessionStorageSetItem(constants.SESSION_STORAGE_LOGIN_ENCRYPTION_KEY_PAIR, JSON.stringify(keyPair));
|
|
872
774
|
});
|
|
873
775
|
}
|
|
874
776
|
deleteLoginEncryptionKeyPair() {
|
|
875
777
|
return __awaiter(this, void 0, void 0, function* () {
|
|
876
778
|
this.loginEncryptionKeyPair = undefined;
|
|
877
|
-
yield this.sessionStorageRemoveItem(SESSION_STORAGE_LOGIN_ENCRYPTION_KEY_PAIR);
|
|
779
|
+
yield this.sessionStorageRemoveItem(constants.SESSION_STORAGE_LOGIN_ENCRYPTION_KEY_PAIR);
|
|
878
780
|
});
|
|
879
781
|
}
|
|
880
782
|
/**
|
|
@@ -906,7 +808,7 @@ class ParaCore {
|
|
|
906
808
|
if (!this.phone || !this.countryCode) {
|
|
907
809
|
return undefined;
|
|
908
810
|
}
|
|
909
|
-
return normalizePhoneNumber(this.countryCode, this.phone);
|
|
811
|
+
return (0, index_js_2.normalizePhoneNumber)(this.countryCode, this.phone);
|
|
910
812
|
}
|
|
911
813
|
/**
|
|
912
814
|
* Gets the farcaster username associated with the `ParaCore` instance.
|
|
@@ -918,11 +820,11 @@ class ParaCore {
|
|
|
918
820
|
setCurrentWalletIds(currentWalletIds, { needsWallet = false, sessionLookupId, newDeviceSessionLookupId, } = {}) {
|
|
919
821
|
return __awaiter(this, void 0, void 0, function* () {
|
|
920
822
|
this.currentWalletIds = currentWalletIds;
|
|
921
|
-
yield this.localStorageSetItem(LOCAL_STORAGE_CURRENT_WALLET_IDS, JSON.stringify(this.currentWalletIds));
|
|
823
|
+
yield this.localStorageSetItem(constants.LOCAL_STORAGE_CURRENT_WALLET_IDS, JSON.stringify(this.currentWalletIds));
|
|
922
824
|
if (sessionLookupId) {
|
|
923
825
|
yield this.ctx.client.setCurrentWalletIds(this.getUserId(), this.currentWalletIds, needsWallet, sessionLookupId, newDeviceSessionLookupId);
|
|
924
826
|
}
|
|
925
|
-
dispatchEvent(index_js_1.ParaEvent.WALLETS_CHANGE_EVENT, null);
|
|
827
|
+
(0, index_js_2.dispatchEvent)(index_js_1.ParaEvent.WALLETS_CHANGE_EVENT, null);
|
|
926
828
|
});
|
|
927
829
|
}
|
|
928
830
|
/**
|
|
@@ -1045,7 +947,7 @@ class ParaCore {
|
|
|
1045
947
|
yield this.touchSession();
|
|
1046
948
|
}
|
|
1047
949
|
return (this.supportedWalletTypes
|
|
1048
|
-
.filter(({ type: t, optional }) => !optional && Object.values(this.wallets).every(w => !this.isWalletOwned(w) || !
|
|
950
|
+
.filter(({ type: t, optional }) => !optional && Object.values(this.wallets).every(w => !this.isWalletOwned(w) || !index_js_2.WalletSchemeTypeMap[w.scheme][t]))
|
|
1049
951
|
.map(({ type }) => type));
|
|
1050
952
|
});
|
|
1051
953
|
}
|
|
@@ -1054,7 +956,7 @@ class ParaCore {
|
|
|
1054
956
|
if (!__classPrivateFieldGet(this, _ParaCore_supportedWalletTypes, "f")) {
|
|
1055
957
|
yield this.touchSession();
|
|
1056
958
|
}
|
|
1057
|
-
return getSchemes(types !== null && types !== void 0 ? types : (yield this.getMissingTypes())).map(scheme => {
|
|
959
|
+
return (0, index_js_2.getSchemes)(types !== null && types !== void 0 ? types : (yield this.getMissingTypes())).map(scheme => {
|
|
1058
960
|
switch (scheme) {
|
|
1059
961
|
case user_management_client_1.WalletScheme.ED25519:
|
|
1060
962
|
return user_management_client_1.WalletType.SOLANA;
|
|
@@ -1079,7 +981,7 @@ class ParaCore {
|
|
|
1079
981
|
*/
|
|
1080
982
|
getPortalURL(partnerId) {
|
|
1081
983
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1082
|
-
return (partnerId && (yield this.getPartnerURL(partnerId))) || (0,
|
|
984
|
+
return (partnerId && (yield this.getPartnerURL(partnerId))) || (0, index_js_2.getPortalBaseURL)(this.ctx);
|
|
1083
985
|
});
|
|
1084
986
|
}
|
|
1085
987
|
getWebAuthURLForCreate(_a) {
|
|
@@ -1095,8 +997,8 @@ class ParaCore {
|
|
|
1095
997
|
});
|
|
1096
998
|
}
|
|
1097
999
|
getShortUrl(compressedUrl) {
|
|
1098
|
-
return constructUrl({
|
|
1099
|
-
base: (0,
|
|
1000
|
+
return (0, index_js_2.constructUrl)({
|
|
1001
|
+
base: (0, index_js_2.getPortalBaseURL)(this.ctx),
|
|
1100
1002
|
path: `/short/${compressedUrl}`,
|
|
1101
1003
|
});
|
|
1102
1004
|
}
|
|
@@ -1165,7 +1067,7 @@ class ParaCore {
|
|
|
1165
1067
|
? this.ctx.client.getAllWallets(this.userId)
|
|
1166
1068
|
: this.ctx.client.getWallets(this.userId, true));
|
|
1167
1069
|
return res.data.wallets.filter(wallet => !!wallet.address &&
|
|
1168
|
-
(this.isParaConnect() || (!this.isParaConnect() && this.isWalletSupported(entityToWallet(wallet)))));
|
|
1070
|
+
(this.isParaConnect() || (!this.isParaConnect() && this.isWalletSupported((0, index_js_2.entityToWallet)(wallet)))));
|
|
1169
1071
|
});
|
|
1170
1072
|
}
|
|
1171
1073
|
populateWalletAddresses() {
|
|
@@ -1174,7 +1076,7 @@ class ParaCore {
|
|
|
1174
1076
|
const wallets = res.data.wallets;
|
|
1175
1077
|
wallets.forEach(entity => {
|
|
1176
1078
|
if (this.wallets[entity.id]) {
|
|
1177
|
-
this.wallets[entity.id] = Object.assign(Object.assign({}, entityToWallet(entity)), this.wallets[entity.id]);
|
|
1079
|
+
this.wallets[entity.id] = Object.assign(Object.assign({}, (0, index_js_2.entityToWallet)(entity)), this.wallets[entity.id]);
|
|
1178
1080
|
}
|
|
1179
1081
|
});
|
|
1180
1082
|
yield this.setWallets(this.wallets);
|
|
@@ -1185,7 +1087,7 @@ class ParaCore {
|
|
|
1185
1087
|
const res = yield this.getPregenWallets();
|
|
1186
1088
|
res.forEach(entity => {
|
|
1187
1089
|
if (this.wallets[entity.id]) {
|
|
1188
|
-
this.wallets[entity.id] = Object.assign(Object.assign({}, entityToWallet(entity)), this.wallets[entity.id]);
|
|
1090
|
+
this.wallets[entity.id] = Object.assign(Object.assign({}, (0, index_js_2.entityToWallet)(entity)), this.wallets[entity.id]);
|
|
1189
1091
|
}
|
|
1190
1092
|
});
|
|
1191
1093
|
yield this.setWallets(this.wallets);
|
|
@@ -1643,10 +1545,10 @@ class ParaCore {
|
|
|
1643
1545
|
this.isAwaitingAccountCreation = true;
|
|
1644
1546
|
while (this.isAwaitingAccountCreation) {
|
|
1645
1547
|
try {
|
|
1646
|
-
yield new Promise(resolve => setTimeout(resolve, POLLING_INTERVAL_MS));
|
|
1548
|
+
yield new Promise(resolve => setTimeout(resolve, constants.POLLING_INTERVAL_MS));
|
|
1647
1549
|
if (yield this.isSessionActive()) {
|
|
1648
1550
|
this.isAwaitingAccountCreation = false;
|
|
1649
|
-
dispatchEvent(index_js_1.ParaEvent.ACCOUNT_CREATION_EVENT, true);
|
|
1551
|
+
(0, index_js_2.dispatchEvent)(index_js_1.ParaEvent.ACCOUNT_CREATION_EVENT, true);
|
|
1650
1552
|
return true;
|
|
1651
1553
|
}
|
|
1652
1554
|
}
|
|
@@ -1667,7 +1569,7 @@ class ParaCore {
|
|
|
1667
1569
|
recoverySecret = yield this.claimPregenWallets();
|
|
1668
1570
|
walletIds = this.supportedWalletTypes.reduce((acc, { type }) => {
|
|
1669
1571
|
var _a;
|
|
1670
|
-
return Object.assign(Object.assign({}, acc), { [type]: [(_a = pregenWallets.find(w => !!
|
|
1572
|
+
return Object.assign(Object.assign({}, acc), { [type]: [(_a = pregenWallets.find(w => !!index_js_2.WalletSchemeTypeMap[w.scheme][type])) === null || _a === void 0 ? void 0 : _a.id] });
|
|
1671
1573
|
}, {});
|
|
1672
1574
|
}
|
|
1673
1575
|
// After claiming any pregen wallets, create wallets for the remaining missing types
|
|
@@ -1675,7 +1577,7 @@ class ParaCore {
|
|
|
1675
1577
|
recoverySecret = recoverySecret !== null && recoverySecret !== void 0 ? recoverySecret : created.recoverySecret;
|
|
1676
1578
|
walletIds = Object.assign(Object.assign({}, walletIds), created.walletIds);
|
|
1677
1579
|
const resp = { walletIds, recoverySecret };
|
|
1678
|
-
dispatchEvent(index_js_1.ParaEvent.ACCOUNT_SETUP_EVENT, resp);
|
|
1580
|
+
(0, index_js_2.dispatchEvent)(index_js_1.ParaEvent.ACCOUNT_SETUP_EVENT, resp);
|
|
1679
1581
|
return resp;
|
|
1680
1582
|
});
|
|
1681
1583
|
}
|
|
@@ -1702,7 +1604,7 @@ class ParaCore {
|
|
|
1702
1604
|
this.isAwaitingFarcaster = true;
|
|
1703
1605
|
while (this.isAwaitingFarcaster) {
|
|
1704
1606
|
try {
|
|
1705
|
-
yield new Promise(resolve => setTimeout(resolve, POLLING_INTERVAL_MS));
|
|
1607
|
+
yield new Promise(resolve => setTimeout(resolve, constants.POLLING_INTERVAL_MS));
|
|
1706
1608
|
const res = yield this.ctx.client.getFarcasterAuthStatus();
|
|
1707
1609
|
if (res.data.state === 'completed') {
|
|
1708
1610
|
const { userId, userExists, username, pfpUrl } = res.data;
|
|
@@ -1727,18 +1629,20 @@ class ParaCore {
|
|
|
1727
1629
|
*
|
|
1728
1630
|
* @param {Object} opts the options object
|
|
1729
1631
|
* @param {OAuthMethod} opts.method the third-party service to use for OAuth.
|
|
1632
|
+
* @param {string} [opts.deeplinkUrl] the deeplink to redirect to after the OAuth flow. This is for mobile only.
|
|
1730
1633
|
* @returns {string} the URL for the user to log in with OAuth.
|
|
1731
1634
|
*/
|
|
1732
|
-
getOAuthURL({ method }) {
|
|
1635
|
+
getOAuthURL({ method, deeplinkUrl }) {
|
|
1733
1636
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1734
1637
|
yield this.logout();
|
|
1735
1638
|
const res = yield this.touchSession(true);
|
|
1736
|
-
return constructUrl({
|
|
1737
|
-
base: method === user_management_client_1.OAuthMethod.TELEGRAM ? (0,
|
|
1639
|
+
return (0, index_js_2.constructUrl)({
|
|
1640
|
+
base: method === user_management_client_1.OAuthMethod.TELEGRAM ? (0, index_js_2.getPortalBaseURL)(this.ctx, true) : (0, userManagementClient_js_1.getBaseOAuthUrl)(this.ctx.env),
|
|
1738
1641
|
path: `/auth/${method.toLowerCase()}`,
|
|
1739
1642
|
params: {
|
|
1740
1643
|
apiKey: this.ctx.apiKey,
|
|
1741
1644
|
sessionLookupId: res.data.sessionLookupId,
|
|
1645
|
+
deeplinkUrl,
|
|
1742
1646
|
},
|
|
1743
1647
|
});
|
|
1744
1648
|
});
|
|
@@ -1759,7 +1663,7 @@ class ParaCore {
|
|
|
1759
1663
|
if (popupWindow === null || popupWindow === void 0 ? void 0 : popupWindow.closed) {
|
|
1760
1664
|
return { isError: true, userExists: false };
|
|
1761
1665
|
}
|
|
1762
|
-
yield new Promise(resolve => setTimeout(resolve, POLLING_INTERVAL_MS));
|
|
1666
|
+
yield new Promise(resolve => setTimeout(resolve, constants.POLLING_INTERVAL_MS));
|
|
1763
1667
|
if (this.isAwaitingOAuth) {
|
|
1764
1668
|
const res = yield this.touchSession();
|
|
1765
1669
|
if (res.data.userId) {
|
|
@@ -1799,11 +1703,11 @@ class ParaCore {
|
|
|
1799
1703
|
this.isAwaitingLogin = true;
|
|
1800
1704
|
while (this.isAwaitingLogin) {
|
|
1801
1705
|
try {
|
|
1802
|
-
yield new Promise(resolve => setTimeout(resolve, POLLING_INTERVAL_MS));
|
|
1706
|
+
yield new Promise(resolve => setTimeout(resolve, constants.POLLING_INTERVAL_MS));
|
|
1803
1707
|
if (!(yield this.isSessionActive())) {
|
|
1804
1708
|
if (popupWindow === null || popupWindow === void 0 ? void 0 : popupWindow.closed) {
|
|
1805
1709
|
const resp = { isComplete: false, isError: true };
|
|
1806
|
-
dispatchEvent(index_js_1.ParaEvent.LOGIN_EVENT, resp, 'failed to setup user');
|
|
1710
|
+
(0, index_js_2.dispatchEvent)(index_js_1.ParaEvent.LOGIN_EVENT, resp, 'failed to setup user');
|
|
1807
1711
|
return resp;
|
|
1808
1712
|
}
|
|
1809
1713
|
continue;
|
|
@@ -1814,7 +1718,7 @@ class ParaCore {
|
|
|
1814
1718
|
if (this.currentWalletIdsArray.length === 0) {
|
|
1815
1719
|
if (popupWindow === null || popupWindow === void 0 ? void 0 : popupWindow.closed) {
|
|
1816
1720
|
const resp = { isComplete: false, isError: true };
|
|
1817
|
-
dispatchEvent(index_js_1.ParaEvent.LOGIN_EVENT, resp, 'failed to setup user');
|
|
1721
|
+
(0, index_js_2.dispatchEvent)(index_js_1.ParaEvent.LOGIN_EVENT, resp, 'failed to setup user');
|
|
1818
1722
|
return resp;
|
|
1819
1723
|
}
|
|
1820
1724
|
else {
|
|
@@ -1834,7 +1738,7 @@ class ParaCore {
|
|
|
1834
1738
|
needsWallet: needsWallet || Object.values(this.wallets).length === 0,
|
|
1835
1739
|
partnerId: postLoginData.data.partnerId,
|
|
1836
1740
|
};
|
|
1837
|
-
dispatchEvent(index_js_1.ParaEvent.LOGIN_EVENT, resp);
|
|
1741
|
+
(0, index_js_2.dispatchEvent)(index_js_1.ParaEvent.LOGIN_EVENT, resp);
|
|
1838
1742
|
return resp;
|
|
1839
1743
|
}
|
|
1840
1744
|
}
|
|
@@ -1844,7 +1748,7 @@ class ParaCore {
|
|
|
1844
1748
|
}
|
|
1845
1749
|
}
|
|
1846
1750
|
const resp = { isComplete: false };
|
|
1847
|
-
dispatchEvent(index_js_1.ParaEvent.LOGIN_EVENT, resp, 'exitted login without setting up user');
|
|
1751
|
+
(0, index_js_2.dispatchEvent)(index_js_1.ParaEvent.LOGIN_EVENT, resp, 'exitted login without setting up user');
|
|
1848
1752
|
return resp;
|
|
1849
1753
|
});
|
|
1850
1754
|
}
|
|
@@ -1971,7 +1875,7 @@ class ParaCore {
|
|
|
1971
1875
|
if (wallet && wallet.address) {
|
|
1972
1876
|
return;
|
|
1973
1877
|
}
|
|
1974
|
-
yield new Promise(resolve => setTimeout(resolve, SHORT_POLLING_INTERVAL_MS));
|
|
1878
|
+
yield new Promise(resolve => setTimeout(resolve, constants.SHORT_POLLING_INTERVAL_MS));
|
|
1975
1879
|
}
|
|
1976
1880
|
catch (err) {
|
|
1977
1881
|
// want to continue polling on error
|
|
@@ -2003,7 +1907,7 @@ class ParaCore {
|
|
|
2003
1907
|
if (wallet && wallet.address) {
|
|
2004
1908
|
return;
|
|
2005
1909
|
}
|
|
2006
|
-
yield new Promise(resolve => setTimeout(resolve, SHORT_POLLING_INTERVAL_MS));
|
|
1910
|
+
yield new Promise(resolve => setTimeout(resolve, constants.SHORT_POLLING_INTERVAL_MS));
|
|
2007
1911
|
}
|
|
2008
1912
|
catch (err) {
|
|
2009
1913
|
// want to continue polling on error
|
|
@@ -2032,7 +1936,7 @@ class ParaCore {
|
|
|
2032
1936
|
for (const type of yield this.getTypesToCreate(types)) {
|
|
2033
1937
|
const [wallet, recoveryShare] = yield this.createWallet({ type, skipDistribute });
|
|
2034
1938
|
wallets.push(wallet);
|
|
2035
|
-
getEquivalentTypes(type)
|
|
1939
|
+
(0, index_js_2.getEquivalentTypes)(type)
|
|
2036
1940
|
.filter(t => !!this.isWalletTypeEnabled[t])
|
|
2037
1941
|
.forEach(t => {
|
|
2038
1942
|
walletIds[t] = [wallet.id];
|
|
@@ -2121,7 +2025,7 @@ class ParaCore {
|
|
|
2121
2025
|
yield this.setCurrentWalletIds(Object.assign(Object.assign({}, this.currentWalletIds), { [walletType]: [...((_b = this.currentWalletIds[walletType]) !== null && _b !== void 0 ? _b : []), walletId] }));
|
|
2122
2026
|
const walletNoSigner = Object.assign({}, wallet);
|
|
2123
2027
|
delete walletNoSigner.signer;
|
|
2124
|
-
dispatchEvent(index_js_1.ParaEvent.WALLET_CREATED, {
|
|
2028
|
+
(0, index_js_2.dispatchEvent)(index_js_1.ParaEvent.WALLET_CREATED, {
|
|
2125
2029
|
wallet: walletNoSigner,
|
|
2126
2030
|
recoverySecret: recoveryShare,
|
|
2127
2031
|
});
|
|
@@ -2241,7 +2145,7 @@ class ParaCore {
|
|
|
2241
2145
|
this.wallets[wallet.id] = Object.assign(Object.assign({}, this.wallets[wallet.id]), { signer: (_a = refreshedShare === null || refreshedShare === void 0 ? void 0 : refreshedShare.signer) !== null && _a !== void 0 ? _a : wallet.signer, userId: this.userId, pregenIdentifier: undefined, pregenIdentifierType: undefined });
|
|
2242
2146
|
const walletNoSigner = Object.assign({}, this.wallets[wallet.id]);
|
|
2243
2147
|
delete walletNoSigner.signer;
|
|
2244
|
-
dispatchEvent(index_js_1.ParaEvent.PREGEN_WALLET_CLAIMED, {
|
|
2148
|
+
(0, index_js_2.dispatchEvent)(index_js_1.ParaEvent.PREGEN_WALLET_CLAIMED, {
|
|
2245
2149
|
wallet: walletNoSigner,
|
|
2246
2150
|
recoverySecret: newRecoverySecret,
|
|
2247
2151
|
});
|
|
@@ -2300,7 +2204,7 @@ class ParaCore {
|
|
|
2300
2204
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2301
2205
|
this.requireApiKey();
|
|
2302
2206
|
const res = yield this.ctx.client.getPregenWallets(pregenIdentifier && pregenIdentifierType ? { [pregenIdentifierType]: [pregenIdentifier] } : this.pregenIds, this.isPortal(), this.userId);
|
|
2303
|
-
return res.wallets.filter(w => this.isWalletSupported(entityToWallet(w)));
|
|
2207
|
+
return res.wallets.filter(w => this.isWalletSupported((0, index_js_2.entityToWallet)(w)));
|
|
2304
2208
|
});
|
|
2305
2209
|
}
|
|
2306
2210
|
encodeWalletBase64(wallet) {
|
|
@@ -2332,7 +2236,7 @@ class ParaCore {
|
|
|
2332
2236
|
const base64WalletsSplit = base64Wallets.split('-');
|
|
2333
2237
|
for (const base64Wallet of base64WalletsSplit) {
|
|
2334
2238
|
const walletJson = Buffer.from(base64Wallet, 'base64').toString();
|
|
2335
|
-
const wallet = migrateWallet(JSON.parse(walletJson));
|
|
2239
|
+
const wallet = (0, index_js_2.migrateWallet)(JSON.parse(walletJson));
|
|
2336
2240
|
this.wallets[wallet.id] = wallet;
|
|
2337
2241
|
yield this.setWallets(this.wallets);
|
|
2338
2242
|
}
|
|
@@ -2393,10 +2297,10 @@ class ParaCore {
|
|
|
2393
2297
|
this.platformUtils.openPopup(yield this.getTransactionReviewUrl(signRes.pendingTransactionId, timeoutMs), { type: cosmosSignDocBase64 ? index_js_1.PopupType.SIGN_TRANSACTION_REVIEW : index_js_1.PopupType.SIGN_MESSAGE_REVIEW });
|
|
2394
2298
|
}
|
|
2395
2299
|
else {
|
|
2396
|
-
dispatchEvent(index_js_1.ParaEvent.SIGN_MESSAGE_EVENT, signRes);
|
|
2300
|
+
(0, index_js_2.dispatchEvent)(index_js_1.ParaEvent.SIGN_MESSAGE_EVENT, signRes);
|
|
2397
2301
|
return signRes;
|
|
2398
2302
|
}
|
|
2399
|
-
yield new Promise(resolve => setTimeout(resolve, POLLING_INTERVAL_MS));
|
|
2303
|
+
yield new Promise(resolve => setTimeout(resolve, constants.POLLING_INTERVAL_MS));
|
|
2400
2304
|
while (true) {
|
|
2401
2305
|
if (Date.now() - timeStart > timeoutMs) {
|
|
2402
2306
|
break;
|
|
@@ -2406,12 +2310,12 @@ class ParaCore {
|
|
|
2406
2310
|
}
|
|
2407
2311
|
catch (err) {
|
|
2408
2312
|
const error = new errors_js_1.TransactionReviewDenied();
|
|
2409
|
-
dispatchEvent(index_js_1.ParaEvent.SIGN_MESSAGE_EVENT, signRes, error.message);
|
|
2313
|
+
(0, index_js_2.dispatchEvent)(index_js_1.ParaEvent.SIGN_MESSAGE_EVENT, signRes, error.message);
|
|
2410
2314
|
throw error;
|
|
2411
2315
|
}
|
|
2412
2316
|
signRes = yield this.signMessageInner({ wallet, signerId, messageBase64, cosmosSignDocBase64 });
|
|
2413
2317
|
if (signRes.pendingTransactionId) {
|
|
2414
|
-
yield new Promise(resolve => setTimeout(resolve, POLLING_INTERVAL_MS));
|
|
2318
|
+
yield new Promise(resolve => setTimeout(resolve, constants.POLLING_INTERVAL_MS));
|
|
2415
2319
|
}
|
|
2416
2320
|
else {
|
|
2417
2321
|
break;
|
|
@@ -2419,10 +2323,10 @@ class ParaCore {
|
|
|
2419
2323
|
}
|
|
2420
2324
|
if (signRes.pendingTransactionId) {
|
|
2421
2325
|
const error = new errors_js_1.TransactionReviewTimeout(yield this.getTransactionReviewUrl(signRes.pendingTransactionId), signRes.pendingTransactionId);
|
|
2422
|
-
dispatchEvent(index_js_1.ParaEvent.SIGN_MESSAGE_EVENT, signRes, error.message);
|
|
2326
|
+
(0, index_js_2.dispatchEvent)(index_js_1.ParaEvent.SIGN_MESSAGE_EVENT, signRes, error.message);
|
|
2423
2327
|
throw error;
|
|
2424
2328
|
}
|
|
2425
|
-
dispatchEvent(index_js_1.ParaEvent.SIGN_MESSAGE_EVENT, signRes);
|
|
2329
|
+
(0, index_js_2.dispatchEvent)(index_js_1.ParaEvent.SIGN_MESSAGE_EVENT, signRes);
|
|
2426
2330
|
return signRes;
|
|
2427
2331
|
});
|
|
2428
2332
|
}
|
|
@@ -2462,10 +2366,10 @@ class ParaCore {
|
|
|
2462
2366
|
this.platformUtils.openPopup(yield this.getTransactionReviewUrl(signRes.pendingTransactionId, timeoutMs), { type: index_js_1.PopupType.SIGN_TRANSACTION_REVIEW });
|
|
2463
2367
|
}
|
|
2464
2368
|
else {
|
|
2465
|
-
dispatchEvent(index_js_1.ParaEvent.SIGN_TRANSACTION_EVENT, signRes);
|
|
2369
|
+
(0, index_js_2.dispatchEvent)(index_js_1.ParaEvent.SIGN_TRANSACTION_EVENT, signRes);
|
|
2466
2370
|
return signRes;
|
|
2467
2371
|
}
|
|
2468
|
-
yield new Promise(resolve => setTimeout(resolve, POLLING_INTERVAL_MS));
|
|
2372
|
+
yield new Promise(resolve => setTimeout(resolve, constants.POLLING_INTERVAL_MS));
|
|
2469
2373
|
while (true) {
|
|
2470
2374
|
if (Date.now() - timeStart > timeoutMs) {
|
|
2471
2375
|
break;
|
|
@@ -2475,12 +2379,12 @@ class ParaCore {
|
|
|
2475
2379
|
}
|
|
2476
2380
|
catch (err) {
|
|
2477
2381
|
const error = new errors_js_1.TransactionReviewDenied();
|
|
2478
|
-
dispatchEvent(index_js_1.ParaEvent.SIGN_TRANSACTION_EVENT, signRes, error.message);
|
|
2382
|
+
(0, index_js_2.dispatchEvent)(index_js_1.ParaEvent.SIGN_TRANSACTION_EVENT, signRes, error.message);
|
|
2479
2383
|
throw error;
|
|
2480
2384
|
}
|
|
2481
2385
|
signRes = yield this.platformUtils.signTransaction(this.ctx, signerId, walletId, this.wallets[walletId].signer, rlpEncodedTxBase64, chainId, this.retrieveSessionCookie(), wallet.scheme === user_management_client_1.WalletScheme.DKLS);
|
|
2482
2386
|
if (signRes.pendingTransactionId) {
|
|
2483
|
-
yield new Promise(resolve => setTimeout(resolve, POLLING_INTERVAL_MS));
|
|
2387
|
+
yield new Promise(resolve => setTimeout(resolve, constants.POLLING_INTERVAL_MS));
|
|
2484
2388
|
}
|
|
2485
2389
|
else {
|
|
2486
2390
|
break;
|
|
@@ -2488,10 +2392,10 @@ class ParaCore {
|
|
|
2488
2392
|
}
|
|
2489
2393
|
if (signRes.pendingTransactionId) {
|
|
2490
2394
|
const error = new errors_js_1.TransactionReviewTimeout(yield this.getTransactionReviewUrl(signRes.pendingTransactionId), signRes.pendingTransactionId);
|
|
2491
|
-
dispatchEvent(index_js_1.ParaEvent.SIGN_TRANSACTION_EVENT, signRes, error.message);
|
|
2395
|
+
(0, index_js_2.dispatchEvent)(index_js_1.ParaEvent.SIGN_TRANSACTION_EVENT, signRes, error.message);
|
|
2492
2396
|
throw error;
|
|
2493
2397
|
}
|
|
2494
|
-
dispatchEvent(index_js_1.ParaEvent.SIGN_TRANSACTION_EVENT, signRes);
|
|
2398
|
+
(0, index_js_2.dispatchEvent)(index_js_1.ParaEvent.SIGN_TRANSACTION_EVENT, signRes);
|
|
2495
2399
|
return signRes;
|
|
2496
2400
|
});
|
|
2497
2401
|
}
|
|
@@ -2565,6 +2469,8 @@ class ParaCore {
|
|
|
2565
2469
|
sessionCookie: this.sessionCookie,
|
|
2566
2470
|
phone: this.phone,
|
|
2567
2471
|
countryCode: this.countryCode,
|
|
2472
|
+
telegramUserId: this.telegramUserId,
|
|
2473
|
+
farcasterUsername: this.farcasterUsername,
|
|
2568
2474
|
};
|
|
2569
2475
|
return Buffer.from(JSON.stringify(sessionInfo)).toString('base64');
|
|
2570
2476
|
}
|
|
@@ -2620,6 +2526,16 @@ class ParaCore {
|
|
|
2620
2526
|
this.exitFarcaster();
|
|
2621
2527
|
this.exitOAuth();
|
|
2622
2528
|
}
|
|
2529
|
+
/**
|
|
2530
|
+
* Retrieves a token to verify the current session.
|
|
2531
|
+
* @returns {Promise<string>} the ID
|
|
2532
|
+
**/
|
|
2533
|
+
getVerificationToken() {
|
|
2534
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2535
|
+
const { data } = yield this.touchSession();
|
|
2536
|
+
return data.sessionLookupId;
|
|
2537
|
+
});
|
|
2538
|
+
}
|
|
2623
2539
|
/**
|
|
2624
2540
|
* Logs the user out.
|
|
2625
2541
|
* @param {Object} opts the options object.
|
|
@@ -2650,7 +2566,7 @@ class ParaCore {
|
|
|
2650
2566
|
this.countryCode = undefined;
|
|
2651
2567
|
this.userId = undefined;
|
|
2652
2568
|
this.sessionCookie = undefined;
|
|
2653
|
-
dispatchEvent(index_js_1.ParaEvent.LOGOUT_EVENT, null);
|
|
2569
|
+
(0, index_js_2.dispatchEvent)(index_js_1.ParaEvent.LOGOUT_EVENT, null);
|
|
2654
2570
|
});
|
|
2655
2571
|
}
|
|
2656
2572
|
getSupportedCreateAuthMethods() {
|
|
@@ -2701,4 +2617,4 @@ class ParaCore {
|
|
|
2701
2617
|
}
|
|
2702
2618
|
exports.ParaCore = ParaCore;
|
|
2703
2619
|
_ParaCore_supportedWalletTypes = new WeakMap(), _ParaCore_supportedWalletTypesOpt = new WeakMap();
|
|
2704
|
-
ParaCore.version = PARA_CORE_VERSION;
|
|
2620
|
+
ParaCore.version = constants.PARA_CORE_VERSION;
|