@getpara/core-sdk 1.12.0 → 2.0.0-alpha.5
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 +936 -974
- package/dist/cjs/constants.js +7 -1
- package/dist/cjs/index.js +15 -9
- package/dist/cjs/types/coreApi.js +74 -0
- package/dist/cjs/types/events.js +1 -0
- package/dist/cjs/types/index.js +4 -2
- package/dist/cjs/types/{params.js → methods.js} +2 -2
- package/dist/cjs/utils/autobind.js +41 -0
- package/dist/cjs/utils/formatting.js +0 -12
- package/dist/cjs/utils/index.js +10 -0
- package/dist/cjs/utils/json.js +37 -0
- package/dist/cjs/utils/listeners.js +2 -11
- package/dist/cjs/utils/phone.js +61 -0
- package/dist/cjs/utils/types.js +29 -0
- package/dist/cjs/utils/url.js +34 -2
- package/dist/cjs/utils/wallet.js +30 -17
- package/dist/esm/ParaCore.js +952 -979
- package/dist/esm/constants.js +5 -1
- package/dist/esm/index.js +12 -9
- package/dist/esm/types/coreApi.js +52 -0
- package/dist/esm/types/events.js +1 -0
- package/dist/esm/types/index.js +2 -1
- package/dist/esm/utils/autobind.js +19 -0
- package/dist/esm/utils/formatting.js +0 -10
- package/dist/esm/utils/index.js +5 -0
- package/dist/esm/utils/json.js +15 -0
- package/dist/esm/utils/listeners.js +2 -11
- package/dist/esm/utils/phone.js +28 -0
- package/dist/esm/utils/types.js +7 -0
- package/dist/esm/utils/url.js +15 -2
- package/dist/esm/utils/wallet.js +27 -16
- package/dist/types/ParaCore.d.ts +100 -391
- package/dist/types/PlatformUtils.d.ts +3 -3
- package/dist/types/constants.d.ts +2 -0
- package/dist/types/external/userManagementClient.d.ts +1 -1
- package/dist/types/index.d.ts +5 -3
- package/dist/types/types/config.d.ts +4 -24
- package/dist/types/types/coreApi.d.ts +475 -0
- package/dist/types/types/events.d.ts +4 -1
- package/dist/types/types/index.d.ts +2 -1
- package/dist/types/types/methods.d.ts +148 -0
- package/dist/types/types/onRamps.d.ts +3 -3
- package/dist/types/types/wallet.d.ts +4 -4
- package/dist/types/utils/autobind.d.ts +1 -0
- package/dist/types/utils/formatting.d.ts +2 -4
- package/dist/types/utils/index.d.ts +5 -0
- package/dist/types/utils/json.d.ts +1 -0
- package/dist/types/utils/onRamps.d.ts +3 -3
- package/dist/types/utils/phone.d.ts +7 -0
- package/dist/types/utils/types.d.ts +2 -0
- package/dist/types/utils/url.d.ts +2 -1
- package/dist/types/utils/wallet.d.ts +9 -7
- package/package.json +4 -3
- package/dist/types/types/params.d.ts +0 -73
- /package/dist/esm/types/{params.js → methods.js} +0 -0
package/dist/cjs/ParaCore.js
CHANGED
|
@@ -95,13 +95,11 @@ var import_userManagementClient = require("./external/userManagementClient.js");
|
|
|
95
95
|
var mpcComputationClient = __toESM(require("./external/mpcComputationClient.js"));
|
|
96
96
|
var import_shareDistribution = require("./shares/shareDistribution.js");
|
|
97
97
|
var import_types = require("./types/index.js");
|
|
98
|
-
var transmissionUtils = __toESM(require("./transmission/transmissionUtils.js"));
|
|
99
98
|
var import_recovery = require("./shares/recovery.js");
|
|
100
99
|
var import_utils2 = require("./utils/index.js");
|
|
101
100
|
var import_errors = require("./errors.js");
|
|
102
101
|
var constants = __toESM(require("./constants.js"));
|
|
103
|
-
var
|
|
104
|
-
var _supportedWalletTypes, _supportedWalletTypesOpt, _ParaCore_instances, createPregenWallet_fn;
|
|
102
|
+
var _authInfo, _partner, _ParaCore_instances, assertPartner_fn, guestWalletIds_get, guestWalletIdsArray_get, toAuthInfo_fn, setAuthInfo_fn, getPartner_fn, createPregenWallet_fn, _isCreateGuestWalletsPending, prepareAuthState_fn, prepareLogin_fn, prepareLoginState_fn, prepareSignUpState_fn;
|
|
105
103
|
if (typeof global !== "undefined") {
|
|
106
104
|
global.Buffer = global.Buffer || import_buffer.Buffer;
|
|
107
105
|
} else if (typeof window !== "undefined") {
|
|
@@ -122,6 +120,9 @@ const _ParaCore = class _ParaCore {
|
|
|
122
120
|
*/
|
|
123
121
|
constructor(env, apiKey, opts) {
|
|
124
122
|
__privateAdd(this, _ParaCore_instances);
|
|
123
|
+
__privateAdd(this, _authInfo);
|
|
124
|
+
this.isNativePasskey = false;
|
|
125
|
+
__privateAdd(this, _partner);
|
|
125
126
|
this.isAwaitingAccountCreation = false;
|
|
126
127
|
this.isAwaitingLogin = false;
|
|
127
128
|
this.isAwaitingFarcaster = false;
|
|
@@ -130,14 +131,19 @@ const _ParaCore = class _ParaCore {
|
|
|
130
131
|
* The IDs of the currently active wallets, for each supported wallet type. Any signer integrations will default to the first viable wallet ID in this dictionary.
|
|
131
132
|
*/
|
|
132
133
|
this.currentWalletIds = {};
|
|
133
|
-
|
|
134
|
-
|
|
134
|
+
/**
|
|
135
|
+
* Wallets associated with the `ParaCore` instance.
|
|
136
|
+
*/
|
|
137
|
+
this.externalWallets = {};
|
|
135
138
|
this.localStorageGetItem = (key) => {
|
|
136
139
|
return this.platformUtils.localStorage.get(key);
|
|
137
140
|
};
|
|
138
141
|
this.localStorageSetItem = (key, value) => {
|
|
139
142
|
return this.platformUtils.localStorage.set(key, value);
|
|
140
143
|
};
|
|
144
|
+
this.localStorageRemoveItem = (key) => {
|
|
145
|
+
return this.platformUtils.localStorage.removeItem(key);
|
|
146
|
+
};
|
|
141
147
|
this.sessionStorageGetItem = (key) => {
|
|
142
148
|
return this.platformUtils.sessionStorage.get(key);
|
|
143
149
|
};
|
|
@@ -194,38 +200,41 @@ const _ParaCore = class _ParaCore {
|
|
|
194
200
|
}
|
|
195
201
|
};
|
|
196
202
|
this.initializeFromStorage = () => {
|
|
197
|
-
this.
|
|
198
|
-
this.
|
|
199
|
-
this.updatePhoneFromStorage();
|
|
203
|
+
this.updateExternalWalletsFromStorage();
|
|
204
|
+
this.updateAuthInfoFromStorage();
|
|
200
205
|
this.updateUserIdFromStorage();
|
|
201
|
-
this.updateTelegramUserIdFromStorage();
|
|
202
206
|
this.updateWalletsFromStorage();
|
|
203
207
|
this.updateWalletIdsFromStorage();
|
|
204
208
|
this.updateSessionCookieFromStorage();
|
|
205
209
|
this.updateLoginEncryptionKeyPairFromStorage();
|
|
206
|
-
this.updateExternalWalletsFromStorage();
|
|
207
210
|
};
|
|
208
|
-
this.
|
|
209
|
-
|
|
211
|
+
this.updateAuthInfoFromStorage = () => {
|
|
212
|
+
var _a;
|
|
213
|
+
const storageAuthInfo = this.localStorageGetItem(constants.LOCAL_STORAGE_AUTH_INFO) || void 0;
|
|
214
|
+
let authInfo = (0, import_utils2.jsonParse)(storageAuthInfo);
|
|
215
|
+
if (!authInfo) {
|
|
216
|
+
const authParams = {
|
|
217
|
+
email: this.localStorageGetItem(constants.LOCAL_STORAGE_EMAIL) || void 0,
|
|
218
|
+
phone: this.localStorageGetItem(constants.LOCAL_STORAGE_PHONE) || void 0,
|
|
219
|
+
countryCode: this.localStorageGetItem(constants.LOCAL_STORAGE_COUNTRY_CODE) || void 0,
|
|
220
|
+
farcasterUsername: this.localStorageGetItem(constants.LOCAL_STORAGE_FARCASTER_USERNAME) || void 0,
|
|
221
|
+
telegramUserId: this.localStorageGetItem(constants.LOCAL_STORAGE_TELEGRAM_USER_ID) || void 0,
|
|
222
|
+
// Using id here since we store the bech32 address for cosmos in the address field of the wallet
|
|
223
|
+
externalWalletAddress: ((_a = this.externalWalletWithParaAuth) == null ? void 0 : _a.id) || void 0
|
|
224
|
+
};
|
|
225
|
+
authInfo = __privateMethod(this, _ParaCore_instances, toAuthInfo_fn).call(this, authParams);
|
|
226
|
+
}
|
|
227
|
+
__privateSet(this, _authInfo, authInfo);
|
|
210
228
|
};
|
|
211
229
|
this.updateUserIdFromStorage = () => {
|
|
212
230
|
this.userId = this.localStorageGetItem(constants.LOCAL_STORAGE_USER_ID) || void 0;
|
|
213
231
|
};
|
|
214
|
-
this.updatePhoneFromStorage = () => {
|
|
215
|
-
this.phone = this.localStorageGetItem(constants.LOCAL_STORAGE_PHONE) || void 0;
|
|
216
|
-
};
|
|
217
|
-
this.updateCountryCodeFromStorage = () => {
|
|
218
|
-
this.countryCode = this.localStorageGetItem(constants.LOCAL_STORAGE_COUNTRY_CODE) || void 0;
|
|
219
|
-
};
|
|
220
|
-
this.updateEmailFromStorage = () => {
|
|
221
|
-
this.email = this.localStorageGetItem(constants.LOCAL_STORAGE_EMAIL) || void 0;
|
|
222
|
-
};
|
|
223
232
|
this.updateWalletsFromStorage = () => __async(this, null, function* () {
|
|
224
233
|
var _a;
|
|
225
234
|
const _currentWalletIds = (_a = this.localStorageGetItem(constants.LOCAL_STORAGE_CURRENT_WALLET_IDS)) != null ? _a : void 0;
|
|
226
235
|
const currentWalletIds = [void 0, null, "undefined"].includes(_currentWalletIds) ? {} : (() => {
|
|
227
236
|
const fromJson = JSON.parse(_currentWalletIds);
|
|
228
|
-
return Array.isArray(fromJson) ?
|
|
237
|
+
return Array.isArray(fromJson) ? import_user_management_client.WALLET_TYPES.reduce((acc, type) => {
|
|
229
238
|
const wallet = Object.values(this.wallets).find(
|
|
230
239
|
(w) => fromJson.includes(w.id) && import_utils2.WalletSchemeTypeMap[w.scheme][type]
|
|
231
240
|
);
|
|
@@ -249,9 +258,9 @@ const _ParaCore = class _ParaCore {
|
|
|
249
258
|
this.updateWalletIdsFromStorage = () => {
|
|
250
259
|
var _a;
|
|
251
260
|
const _currentWalletIds = (_a = this.localStorageGetItem(constants.LOCAL_STORAGE_CURRENT_WALLET_IDS)) != null ? _a : void 0;
|
|
252
|
-
const currentWalletIds = [void 0, null, "undefined"].includes(_currentWalletIds) ? {} : (() => {
|
|
261
|
+
const currentWalletIds = [void 0, null, "undefined", "null"].includes(_currentWalletIds) ? {} : (() => {
|
|
253
262
|
const fromJson = JSON.parse(_currentWalletIds);
|
|
254
|
-
return Array.isArray(fromJson) ?
|
|
263
|
+
return Array.isArray(fromJson) ? import_user_management_client.WALLET_TYPES.reduce((acc, type) => {
|
|
255
264
|
const wallet = Object.values(this.wallets).find(
|
|
256
265
|
(w) => fromJson.includes(w.id) && import_utils2.WalletSchemeTypeMap[w.scheme][type]
|
|
257
266
|
);
|
|
@@ -286,12 +295,16 @@ const _ParaCore = class _ParaCore {
|
|
|
286
295
|
* @deprecated alias for `createWalletPerType`
|
|
287
296
|
**/
|
|
288
297
|
this.createWalletPerMissingType = this.createWalletPerType;
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
298
|
+
__privateAdd(this, _isCreateGuestWalletsPending, false);
|
|
299
|
+
this.getWalletBalance = (_0) => __async(this, [_0], function* ({
|
|
300
|
+
walletId,
|
|
301
|
+
rpcUrl
|
|
302
|
+
}) {
|
|
303
|
+
return (yield this.ctx.client.getWalletBalance({ walletId, rpcUrl })).balance;
|
|
294
304
|
});
|
|
305
|
+
if (!apiKey) {
|
|
306
|
+
throw new Error("A Para API key is required.");
|
|
307
|
+
}
|
|
295
308
|
if (!opts) opts = {};
|
|
296
309
|
let isE2E = false;
|
|
297
310
|
if (env === "E2E") {
|
|
@@ -350,49 +363,27 @@ const _ParaCore = class _ParaCore {
|
|
|
350
363
|
useDKLS: opts.useDKLSForCreation || !opts.offloadMPCComputationURL,
|
|
351
364
|
disableWebSockets: !!opts.disableWebSockets,
|
|
352
365
|
wasmOverride: opts.wasmOverride,
|
|
353
|
-
cosmosPrefix: this.cosmosPrefix,
|
|
354
366
|
isE2E
|
|
355
367
|
};
|
|
356
368
|
if (opts.offloadMPCComputationURL) {
|
|
357
369
|
this.ctx.mpcComputationClient = mpcComputationClient.initClient(opts.offloadMPCComputationURL, opts.disableWorkers);
|
|
358
370
|
}
|
|
359
|
-
try {
|
|
360
|
-
__privateSet(this, _supportedWalletTypes, opts.supportedWalletTypes ? (() => {
|
|
361
|
-
if (Object.values(opts.supportedWalletTypes).every(
|
|
362
|
-
(config) => !!config && typeof config === "object" && config.optional
|
|
363
|
-
)) {
|
|
364
|
-
throw new Error("at least one wallet type must be non-optional");
|
|
365
|
-
}
|
|
366
|
-
if (!Object.keys(opts.supportedWalletTypes).every((type) => Object.values(import_user_management_client.WalletType).includes(type))) {
|
|
367
|
-
throw new Error("unsupported wallet type");
|
|
368
|
-
}
|
|
369
|
-
__privateSet(this, _supportedWalletTypesOpt, opts.supportedWalletTypes);
|
|
370
|
-
return Object.entries(opts.supportedWalletTypes).reduce((acc, [key, value]) => {
|
|
371
|
-
var _a;
|
|
372
|
-
if (!value) {
|
|
373
|
-
return acc;
|
|
374
|
-
}
|
|
375
|
-
if (key === import_user_management_client.WalletType.COSMOS && typeof value === "object" && !!value.prefix) {
|
|
376
|
-
this.cosmosPrefix = value.prefix;
|
|
377
|
-
}
|
|
378
|
-
return [...acc, { type: key, optional: value === true ? false : (_a = value.optional) != null ? _a : false }];
|
|
379
|
-
}, []);
|
|
380
|
-
})() : void 0);
|
|
381
|
-
} catch (e) {
|
|
382
|
-
__privateSet(this, _supportedWalletTypes, void 0);
|
|
383
|
-
}
|
|
384
371
|
if (!this.platformUtils.isSyncStorage || opts.useStorageOverrides) {
|
|
385
372
|
return;
|
|
386
373
|
}
|
|
387
374
|
this.initializeFromStorage();
|
|
388
|
-
|
|
375
|
+
import_utils2.setupListeners.bind(this)();
|
|
376
|
+
(0, import_utils2.autoBind)(this);
|
|
389
377
|
if (env !== import_types.Environment.PROD) {
|
|
390
378
|
this.wrapMethodsWithErrorTracking([
|
|
391
|
-
"
|
|
392
|
-
"
|
|
393
|
-
"
|
|
394
|
-
"
|
|
395
|
-
"
|
|
379
|
+
"signUpOrLogIn",
|
|
380
|
+
"verifyNewAccount",
|
|
381
|
+
"waitForLogin",
|
|
382
|
+
"waitForSignup",
|
|
383
|
+
"waitForWalletCreation",
|
|
384
|
+
"verifyOAuth",
|
|
385
|
+
"verifyTelegram",
|
|
386
|
+
"verifyFarcaster",
|
|
396
387
|
"createPregenWallet",
|
|
397
388
|
"claimPregenWallets",
|
|
398
389
|
"signMessage",
|
|
@@ -400,35 +391,75 @@ const _ParaCore = class _ParaCore {
|
|
|
400
391
|
]);
|
|
401
392
|
}
|
|
402
393
|
}
|
|
403
|
-
get
|
|
404
|
-
return
|
|
394
|
+
get authInfo() {
|
|
395
|
+
return __privateGet(this, _authInfo);
|
|
405
396
|
}
|
|
406
|
-
get
|
|
407
|
-
|
|
397
|
+
get email() {
|
|
398
|
+
var _a;
|
|
399
|
+
return (0, import_user_management_client.isEmail)((_a = __privateGet(this, _authInfo)) == null ? void 0 : _a.auth) ? __privateGet(this, _authInfo).auth.email : void 0;
|
|
408
400
|
}
|
|
409
|
-
get
|
|
410
|
-
|
|
401
|
+
get phone() {
|
|
402
|
+
var _a;
|
|
403
|
+
return (0, import_user_management_client.isPhone)((_a = __privateGet(this, _authInfo)) == null ? void 0 : _a.auth) ? __privateGet(this, _authInfo).auth.phone : void 0;
|
|
411
404
|
}
|
|
412
|
-
get
|
|
413
|
-
|
|
405
|
+
get farcasterUsername() {
|
|
406
|
+
var _a;
|
|
407
|
+
return (0, import_user_management_client.isFarcaster)((_a = __privateGet(this, _authInfo)) == null ? void 0 : _a.auth) ? __privateGet(this, _authInfo).auth.farcasterUsername : void 0;
|
|
408
|
+
}
|
|
409
|
+
get telegramUserId() {
|
|
410
|
+
var _a;
|
|
411
|
+
return (0, import_user_management_client.isTelegram)((_a = __privateGet(this, _authInfo)) == null ? void 0 : _a.auth) ? __privateGet(this, _authInfo).auth.telegramUserId : void 0;
|
|
414
412
|
}
|
|
415
413
|
get externalWalletWithParaAuth() {
|
|
416
414
|
const externalWallets = Object.values(this.externalWallets);
|
|
417
415
|
return externalWallets.find((w) => w.isExternalWithParaAuth);
|
|
418
416
|
}
|
|
417
|
+
get externalWalletConnectionType() {
|
|
418
|
+
if (this.isExternalWalletAuth) {
|
|
419
|
+
return "AUTHENTICATED";
|
|
420
|
+
} else if (!!Object.keys(this.externalWallets).length) {
|
|
421
|
+
return "CONNECTION_ONLY";
|
|
422
|
+
}
|
|
423
|
+
return "NONE";
|
|
424
|
+
}
|
|
425
|
+
get isEmail() {
|
|
426
|
+
var _a;
|
|
427
|
+
return (0, import_user_management_client.isEmail)((_a = this.authInfo) == null ? void 0 : _a.auth);
|
|
428
|
+
}
|
|
429
|
+
get isPhone() {
|
|
430
|
+
var _a;
|
|
431
|
+
return (0, import_user_management_client.isPhone)((_a = this.authInfo) == null ? void 0 : _a.auth);
|
|
432
|
+
}
|
|
433
|
+
get isFarcaster() {
|
|
434
|
+
var _a;
|
|
435
|
+
return (0, import_user_management_client.isFarcaster)((_a = this.authInfo) == null ? void 0 : _a.auth);
|
|
436
|
+
}
|
|
437
|
+
get isTelegram() {
|
|
438
|
+
var _a;
|
|
439
|
+
return (0, import_user_management_client.isTelegram)((_a = this.authInfo) == null ? void 0 : _a.auth);
|
|
440
|
+
}
|
|
419
441
|
get isExternalWalletAuth() {
|
|
420
|
-
|
|
442
|
+
var _a;
|
|
443
|
+
return (0, import_user_management_client.isExternalWallet)((_a = __privateGet(this, _authInfo)) == null ? void 0 : _a.auth);
|
|
444
|
+
}
|
|
445
|
+
get partnerId() {
|
|
446
|
+
var _a;
|
|
447
|
+
return (_a = __privateGet(this, _partner)) == null ? void 0 : _a.id;
|
|
421
448
|
}
|
|
422
449
|
get currentWalletIdsArray() {
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
450
|
+
var _a, _b;
|
|
451
|
+
return ((_b = (_a = __privateGet(this, _partner)) == null ? void 0 : _a.supportedWalletTypes) != null ? _b : Object.keys(this.currentWalletIds).map((type) => ({ type }))).reduce(
|
|
452
|
+
(acc, { type }) => {
|
|
453
|
+
var _a2;
|
|
454
|
+
return [
|
|
455
|
+
...acc,
|
|
456
|
+
...((_a2 = this.currentWalletIds[type]) != null ? _a2 : []).map((id) => {
|
|
457
|
+
return [id, type];
|
|
458
|
+
})
|
|
459
|
+
];
|
|
460
|
+
},
|
|
461
|
+
[]
|
|
462
|
+
);
|
|
432
463
|
}
|
|
433
464
|
get currentWalletIdsUnique() {
|
|
434
465
|
return [...new Set(Object.values(this.currentWalletIds).flat())];
|
|
@@ -453,17 +484,23 @@ const _ParaCore = class _ParaCore {
|
|
|
453
484
|
* Whether the instance has multiple wallets connected.
|
|
454
485
|
*/
|
|
455
486
|
get isMultiWallet() {
|
|
456
|
-
return this.currentWalletIdsArray.length > 1;
|
|
487
|
+
return this.currentWalletIdsArray.length > 1 || __privateGet(this, _ParaCore_instances, guestWalletIdsArray_get).length > 1;
|
|
457
488
|
}
|
|
458
489
|
get isNoWalletConfig() {
|
|
459
|
-
|
|
490
|
+
var _a;
|
|
491
|
+
return !!((_a = __privateGet(this, _partner)) == null ? void 0 : _a.supportedWalletTypes) && __privateGet(this, _partner).supportedWalletTypes.length === 0;
|
|
460
492
|
}
|
|
461
493
|
get supportedWalletTypes() {
|
|
494
|
+
var _a, _b;
|
|
495
|
+
return (_b = (_a = __privateGet(this, _partner)) == null ? void 0 : _a.supportedWalletTypes) != null ? _b : [];
|
|
496
|
+
}
|
|
497
|
+
get cosmosPrefix() {
|
|
462
498
|
var _a;
|
|
463
|
-
return (_a = __privateGet(this,
|
|
499
|
+
return (_a = __privateGet(this, _partner)) == null ? void 0 : _a.cosmosPrefix;
|
|
464
500
|
}
|
|
465
501
|
get isWalletTypeEnabled() {
|
|
466
|
-
|
|
502
|
+
var _a;
|
|
503
|
+
return (((_a = __privateGet(this, _partner)) == null ? void 0 : _a.supportedWalletTypes) || []).reduce((acc, { type }) => {
|
|
467
504
|
return __spreadProps(__spreadValues({}, acc), { [type]: true });
|
|
468
505
|
}, {});
|
|
469
506
|
}
|
|
@@ -512,7 +549,7 @@ const _ParaCore = class _ParaCore {
|
|
|
512
549
|
}
|
|
513
550
|
isWalletSupported(wallet) {
|
|
514
551
|
var _a, _b;
|
|
515
|
-
return !__privateGet(this,
|
|
552
|
+
return !((_a = __privateGet(this, _partner)) == null ? void 0 : _a.supportedWalletTypes) || (0, import_utils2.isWalletSupported)((_b = __privateGet(this, _partner).supportedWalletTypes.map(({ type }) => type)) != null ? _b : [], wallet);
|
|
516
553
|
}
|
|
517
554
|
isWalletOwned(wallet) {
|
|
518
555
|
return this.isWalletSupported(wallet) && !(wallet == null ? void 0 : wallet.pregenIdentifier) && !(wallet == null ? void 0 : wallet.pregenIdentifierType) && !!this.userId && (wallet == null ? void 0 : wallet.userId) === this.userId;
|
|
@@ -528,7 +565,7 @@ const _ParaCore = class _ParaCore {
|
|
|
528
565
|
));
|
|
529
566
|
}
|
|
530
567
|
isWalletUsable(walletId, { type: types, scheme: schemes, forbidPregen = false } = {}, throwError = false) {
|
|
531
|
-
var _a;
|
|
568
|
+
var _a, _b;
|
|
532
569
|
let error;
|
|
533
570
|
if ((_a = this.externalWallets) == null ? void 0 : _a[walletId]) {
|
|
534
571
|
return true;
|
|
@@ -543,10 +580,10 @@ const _ParaCore = class _ParaCore {
|
|
|
543
580
|
} else if (!isOwned && !isUnclaimed) {
|
|
544
581
|
error = `wallet with id ${wallet == null ? void 0 : wallet.id} is not owned by the current user`;
|
|
545
582
|
} else if (!this.isWalletSupported(wallet)) {
|
|
546
|
-
error = `wallet with id ${wallet
|
|
583
|
+
error = `wallet with id ${wallet.id} and type ${wallet.type} is not supported, supported types are: ${(((_b = __privateGet(this, _partner)) == null ? void 0 : _b.supportedWalletTypes) || []).map(({ type }) => type).join(", ")}`;
|
|
547
584
|
} else if (types && (!(0, import_utils2.getEquivalentTypes)(types).includes(wallet == null ? void 0 : wallet.type) || isOwned && !types.some((type) => {
|
|
548
|
-
var _a2,
|
|
549
|
-
return (
|
|
585
|
+
var _a2, _b2;
|
|
586
|
+
return (_b2 = (_a2 = this.currentWalletIds) == null ? void 0 : _a2[type]) == null ? void 0 : _b2.includes(walletId);
|
|
550
587
|
}))) {
|
|
551
588
|
error = `wallet with id ${wallet == null ? void 0 : wallet.id} and type ${wallet == null ? void 0 : wallet.type} cannot be selected`;
|
|
552
589
|
} else if (schemes && !schemes.includes(wallet == null ? void 0 : wallet.scheme)) {
|
|
@@ -566,14 +603,17 @@ const _ParaCore = class _ParaCore {
|
|
|
566
603
|
* @param {string} walletId the ID of the wallet address to display.
|
|
567
604
|
* @param {object} options additional options for formatting the address.
|
|
568
605
|
* @param {boolean} options.truncate whether to truncate the address.
|
|
569
|
-
* @param {
|
|
606
|
+
* @param {TWalletType} options.addressType the type of address to display.
|
|
570
607
|
* @returns the formatted address
|
|
571
608
|
*/
|
|
572
609
|
getDisplayAddress(walletId, options = {}) {
|
|
573
|
-
var _a, _b;
|
|
610
|
+
var _a, _b, _c, _d;
|
|
574
611
|
if (this.externalWallets[walletId]) {
|
|
575
612
|
const wallet2 = this.externalWallets[walletId];
|
|
576
|
-
return options.truncate ? (0, import_utils2.truncateAddress)(wallet2.address, wallet2.type, {
|
|
613
|
+
return options.truncate ? (0, import_utils2.truncateAddress)(wallet2.address, wallet2.type, {
|
|
614
|
+
prefix: (_a = __privateGet(this, _partner)) == null ? void 0 : _a.cosmosPrefix,
|
|
615
|
+
targetLength: options.targetLength
|
|
616
|
+
}) : wallet2.address;
|
|
577
617
|
}
|
|
578
618
|
const wallet = this.findWallet(walletId, options.addressType);
|
|
579
619
|
if (!wallet) {
|
|
@@ -582,8 +622,8 @@ const _ParaCore = class _ParaCore {
|
|
|
582
622
|
let str;
|
|
583
623
|
let prefix;
|
|
584
624
|
switch (wallet.type) {
|
|
585
|
-
case
|
|
586
|
-
prefix = (
|
|
625
|
+
case "COSMOS":
|
|
626
|
+
prefix = (_d = (_c = options.cosmosPrefix) != null ? _c : (_b = __privateGet(this, _partner)) == null ? void 0 : _b.cosmosPrefix) != null ? _d : "cosmos";
|
|
587
627
|
str = (0, import_utils2.getCosmosAddress)(wallet.publicKey, prefix);
|
|
588
628
|
break;
|
|
589
629
|
default:
|
|
@@ -616,8 +656,24 @@ const _ParaCore = class _ParaCore {
|
|
|
616
656
|
}
|
|
617
657
|
constructPortalUrl(_0) {
|
|
618
658
|
return __async(this, arguments, function* (type, opts = {}) {
|
|
619
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m
|
|
620
|
-
const
|
|
659
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
660
|
+
const [isCreate, isLogin, isOnRamp] = [
|
|
661
|
+
["createAuth", "createPassword"].includes(type),
|
|
662
|
+
["loginAuth", "loginPassword"].includes(type),
|
|
663
|
+
type === "onRamp"
|
|
664
|
+
];
|
|
665
|
+
if (isCreate || isLogin) {
|
|
666
|
+
this.assertIsAuthSet();
|
|
667
|
+
}
|
|
668
|
+
let sessionId = opts.sessionId;
|
|
669
|
+
if ((isLogin || isOnRamp) && !sessionId) {
|
|
670
|
+
const session = yield this.touchSession(true);
|
|
671
|
+
sessionId = session.sessionId;
|
|
672
|
+
}
|
|
673
|
+
if (!this.loginEncryptionKeyPair) {
|
|
674
|
+
yield this.setLoginEncryptionKeyPair();
|
|
675
|
+
}
|
|
676
|
+
const base = type === "onRamp" ? (0, import_utils2.getPortalBaseURL)(this.ctx) : yield this.getPortalURL();
|
|
621
677
|
let path;
|
|
622
678
|
switch (type) {
|
|
623
679
|
case "createPassword": {
|
|
@@ -648,61 +704,50 @@ const _ParaCore = class _ParaCore {
|
|
|
648
704
|
throw new Error(`invalid URL type ${type}`);
|
|
649
705
|
}
|
|
650
706
|
}
|
|
651
|
-
const
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
const partner = opts.partnerId ? (_a = (yield this.ctx.client.getPartner(opts.partnerId)).data) == null ? void 0 : _a.partner : void 0;
|
|
707
|
+
const partner = yield __privateMethod(this, _ParaCore_instances, assertPartner_fn).call(this);
|
|
708
|
+
const thisDevice = (_a = opts.thisDevice) != null ? _a : {
|
|
709
|
+
encryptionKey: (0, import_utils.getPublicKeyHex)(this.loginEncryptionKeyPair),
|
|
710
|
+
sessionId
|
|
711
|
+
};
|
|
657
712
|
const params = __spreadValues(__spreadValues(__spreadValues(__spreadValues({
|
|
658
713
|
apiKey: this.ctx.apiKey,
|
|
659
|
-
partnerId:
|
|
660
|
-
portalFont: ((_b = opts.
|
|
661
|
-
portalBorderRadius: ((_d = opts.
|
|
662
|
-
portalThemeMode: ((_f = opts.
|
|
663
|
-
portalAccentColor: ((_h = opts.
|
|
664
|
-
portalForegroundColor: ((_j = opts.
|
|
665
|
-
portalBackgroundColor: ((_l = opts.
|
|
714
|
+
partnerId: partner.id,
|
|
715
|
+
portalFont: ((_b = opts.portalTheme) == null ? void 0 : _b.font) || (partner == null ? void 0 : partner.font) || ((_c = this.portalTheme) == null ? void 0 : _c.font),
|
|
716
|
+
portalBorderRadius: ((_d = opts.portalTheme) == null ? void 0 : _d.borderRadius) || ((_e = this.portalTheme) == null ? void 0 : _e.borderRadius),
|
|
717
|
+
portalThemeMode: ((_f = opts.portalTheme) == null ? void 0 : _f.mode) || (partner == null ? void 0 : partner.themeMode) || ((_g = this.portalTheme) == null ? void 0 : _g.mode),
|
|
718
|
+
portalAccentColor: ((_h = opts.portalTheme) == null ? void 0 : _h.accentColor) || (partner == null ? void 0 : partner.accentColor) || ((_i = this.portalTheme) == null ? void 0 : _i.accentColor),
|
|
719
|
+
portalForegroundColor: ((_j = opts.portalTheme) == null ? void 0 : _j.foregroundColor) || (partner == null ? void 0 : partner.foregroundColor) || ((_k = this.portalTheme) == null ? void 0 : _k.foregroundColor),
|
|
720
|
+
portalBackgroundColor: ((_l = opts.portalTheme) == null ? void 0 : _l.backgroundColor) || (partner == null ? void 0 : partner.backgroundColor) || this.portalBackgroundColor || ((_m = this.portalTheme) == null ? void 0 : _m.backgroundColor),
|
|
666
721
|
portalPrimaryButtonColor: this.portalPrimaryButtonColor,
|
|
667
722
|
portalTextColor: this.portalTextColor,
|
|
668
723
|
portalPrimaryButtonTextColor: this.portalPrimaryButtonTextColor,
|
|
669
|
-
isForNewDevice: opts.isForNewDevice ? opts.isForNewDevice.toString() : void 0
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
724
|
+
isForNewDevice: opts.isForNewDevice ? opts.isForNewDevice.toString() : void 0
|
|
725
|
+
}, isCreate || isLogin ? { authInfo: JSON.stringify(this.authInfo) } : {}), isOnRamp ? { sessionId } : {}), isLogin ? __spreadProps(__spreadValues({
|
|
726
|
+
sessionId: thisDevice.sessionId,
|
|
727
|
+
encryptionKey: thisDevice.encryptionKey
|
|
728
|
+
}, opts.newDevice ? {
|
|
729
|
+
newDeviceSessionLookupId: opts.newDevice.sessionId,
|
|
730
|
+
newDeviceEncryptionKey: opts.newDevice.encryptionKey
|
|
731
|
+
} : {}), {
|
|
732
|
+
pregenIds: JSON.stringify(this.pregenIds)
|
|
733
|
+
}) : {}), opts.params || {});
|
|
734
|
+
const url = (0, import_utils2.constructUrl)({ base, path, params });
|
|
735
|
+
if (opts.shorten) {
|
|
736
|
+
return (0, import_utils2.shortenUrl)(this.ctx, url);
|
|
737
|
+
}
|
|
738
|
+
return url;
|
|
683
739
|
});
|
|
684
740
|
}
|
|
685
741
|
touchSession(regenerate = false) {
|
|
686
742
|
return __async(this, null, function* () {
|
|
687
|
-
|
|
688
|
-
this.
|
|
689
|
-
|
|
743
|
+
var _a, _b, _c;
|
|
744
|
+
const session = yield this.ctx.client.touchSession(regenerate);
|
|
745
|
+
if (!__privateGet(this, _partner) || ((_a = __privateGet(this, _partner)) == null ? void 0 : _a.id) !== session.partnerId || !(0, import_utils2.supportedWalletTypesEq)(((_b = __privateGet(this, _partner)) == null ? void 0 : _b.supportedWalletTypes) || [], session.supportedWalletTypes) || (((_c = __privateGet(this, _partner)) == null ? void 0 : _c.cosmosPrefix) || "cosmos") !== session.cosmosPrefix) {
|
|
746
|
+
yield __privateMethod(this, _ParaCore_instances, getPartner_fn).call(this, session.partnerId);
|
|
747
|
+
}
|
|
748
|
+
return session;
|
|
690
749
|
});
|
|
691
750
|
}
|
|
692
|
-
setSupportedWalletTypes(supportedWalletTypes, cosmosPrefix) {
|
|
693
|
-
if (supportedWalletTypes && !__privateGet(this, _supportedWalletTypes)) {
|
|
694
|
-
__privateSet(this, _supportedWalletTypes, supportedWalletTypes);
|
|
695
|
-
Object.keys(this.currentWalletIds).forEach((type) => {
|
|
696
|
-
var _a;
|
|
697
|
-
if (!((_a = __privateGet(this, _supportedWalletTypes)) == null ? void 0 : _a.some(({ type: supportedType }) => supportedType === type))) {
|
|
698
|
-
delete this.currentWalletIds[type];
|
|
699
|
-
}
|
|
700
|
-
});
|
|
701
|
-
}
|
|
702
|
-
if (cosmosPrefix && !this.cosmosPrefix) {
|
|
703
|
-
this.cosmosPrefix = cosmosPrefix;
|
|
704
|
-
}
|
|
705
|
-
}
|
|
706
751
|
getVerificationEmailProps() {
|
|
707
752
|
return {
|
|
708
753
|
brandColor: this.emailPrimaryColor,
|
|
@@ -732,12 +777,26 @@ const _ParaCore = class _ParaCore {
|
|
|
732
777
|
*/
|
|
733
778
|
init() {
|
|
734
779
|
return __async(this, null, function* () {
|
|
735
|
-
var _a;
|
|
736
|
-
this.email = (yield this.localStorageGetItem(constants.LOCAL_STORAGE_EMAIL)) || void 0;
|
|
737
|
-
this.countryCode = (yield this.localStorageGetItem(constants.LOCAL_STORAGE_COUNTRY_CODE)) || void 0;
|
|
738
|
-
this.phone = (yield this.localStorageGetItem(constants.LOCAL_STORAGE_PHONE)) || void 0;
|
|
780
|
+
var _a, _b;
|
|
739
781
|
this.userId = (yield this.localStorageGetItem(constants.LOCAL_STORAGE_USER_ID)) || void 0;
|
|
740
|
-
|
|
782
|
+
const storageAuthInfo = (yield this.localStorageGetItem(constants.LOCAL_STORAGE_AUTH_INFO)) || void 0;
|
|
783
|
+
const stringExternalWallets = yield this.localStorageGetItem(constants.LOCAL_STORAGE_EXTERNAL_WALLETS);
|
|
784
|
+
const _externalWallets = JSON.parse(stringExternalWallets || "{}");
|
|
785
|
+
yield this.setExternalWallets(_externalWallets);
|
|
786
|
+
let authInfo = (0, import_utils2.jsonParse)(storageAuthInfo);
|
|
787
|
+
if (!authInfo) {
|
|
788
|
+
const authParams = {
|
|
789
|
+
email: (yield this.localStorageGetItem(constants.LOCAL_STORAGE_EMAIL)) || void 0,
|
|
790
|
+
phone: (yield this.localStorageGetItem(constants.LOCAL_STORAGE_PHONE)) || void 0,
|
|
791
|
+
countryCode: (yield this.localStorageGetItem(constants.LOCAL_STORAGE_COUNTRY_CODE)) || void 0,
|
|
792
|
+
farcasterUsername: (yield this.localStorageGetItem(constants.LOCAL_STORAGE_FARCASTER_USERNAME)) || void 0,
|
|
793
|
+
telegramUserId: (yield this.localStorageGetItem(constants.LOCAL_STORAGE_TELEGRAM_USER_ID)) || void 0,
|
|
794
|
+
// Using id here since we store the bech32 address for cosmos in the address field of the wallet
|
|
795
|
+
externalWalletAddress: ((_a = this.externalWalletWithParaAuth) == null ? void 0 : _a.id) || void 0
|
|
796
|
+
};
|
|
797
|
+
authInfo = __privateMethod(this, _ParaCore_instances, toAuthInfo_fn).call(this, authParams);
|
|
798
|
+
}
|
|
799
|
+
__privateSet(this, _authInfo, authInfo);
|
|
741
800
|
const stringWallets = this.platformUtils.secureStorage ? yield this.platformUtils.secureStorage.get(constants.LOCAL_STORAGE_WALLETS) : yield this.localStorageGetItem(constants.LOCAL_STORAGE_WALLETS);
|
|
742
801
|
const _wallets = JSON.parse(stringWallets || "{}");
|
|
743
802
|
const stringEd25519Wallets = this.platformUtils.secureStorage ? yield this.platformUtils.secureStorage.get(constants.LOCAL_STORAGE_ED25519_WALLETS) : yield this.localStorageGetItem(constants.LOCAL_STORAGE_ED25519_WALLETS);
|
|
@@ -750,10 +809,10 @@ const _ParaCore = class _ParaCore {
|
|
|
750
809
|
return __spreadValues(__spreadValues({}, res), !res[key] ? { [key]: (0, import_utils2.migrateWallet)(_ed25519Wallets[key]) } : {});
|
|
751
810
|
}, {}));
|
|
752
811
|
yield this.setWallets(wallets);
|
|
753
|
-
const _currentWalletIds = (
|
|
812
|
+
const _currentWalletIds = (_b = yield this.localStorageGetItem(constants.LOCAL_STORAGE_CURRENT_WALLET_IDS)) != null ? _b : void 0;
|
|
754
813
|
const currentWalletIds = [void 0, null, "undefined", "null"].includes(_currentWalletIds) ? {} : (() => {
|
|
755
814
|
const fromJson = JSON.parse(_currentWalletIds);
|
|
756
|
-
return Array.isArray(fromJson) ?
|
|
815
|
+
return Array.isArray(fromJson) ? import_user_management_client.WALLET_TYPES.reduce((acc, type) => {
|
|
757
816
|
const wallet = Object.values(this.wallets).find(
|
|
758
817
|
(w) => fromJson.includes(w.id) && import_utils2.WalletSchemeTypeMap[w.scheme][type]
|
|
759
818
|
);
|
|
@@ -769,21 +828,42 @@ const _ParaCore = class _ParaCore {
|
|
|
769
828
|
if (loginEncryptionKey && loginEncryptionKey !== "undefined") {
|
|
770
829
|
this.loginEncryptionKeyPair = this.convertEncryptionKeyPair(JSON.parse(loginEncryptionKey));
|
|
771
830
|
}
|
|
772
|
-
|
|
773
|
-
const _externalWallets = JSON.parse(stringExternalWallets || "{}");
|
|
774
|
-
yield this.setExternalWallets(_externalWallets);
|
|
775
|
-
import_listeners.setupListeners.bind(this)();
|
|
831
|
+
import_utils2.setupListeners.bind(this)();
|
|
776
832
|
yield this.touchSession();
|
|
777
833
|
});
|
|
778
834
|
}
|
|
835
|
+
setAuth(_0) {
|
|
836
|
+
return __async(this, arguments, function* (auth, { extras = {}, userId } = {}) {
|
|
837
|
+
const authInfo = __spreadValues(__spreadValues({}, (0, import_user_management_client.extractAuthInfo)(auth, { isRequired: true })), extras || {});
|
|
838
|
+
yield __privateMethod(this, _ParaCore_instances, setAuthInfo_fn).call(this, authInfo);
|
|
839
|
+
if (!!userId) {
|
|
840
|
+
yield this.setUserId(userId);
|
|
841
|
+
}
|
|
842
|
+
return __privateGet(this, _authInfo);
|
|
843
|
+
});
|
|
844
|
+
}
|
|
845
|
+
assertUserId() {
|
|
846
|
+
if (!this.userId) {
|
|
847
|
+
throw new Error("no userId is set");
|
|
848
|
+
}
|
|
849
|
+
return this.userId;
|
|
850
|
+
}
|
|
851
|
+
assertIsAuthSet(allowed) {
|
|
852
|
+
if (!__privateGet(this, _authInfo)) {
|
|
853
|
+
throw new Error("auth is not set");
|
|
854
|
+
}
|
|
855
|
+
if (allowed && !allowed.includes(__privateGet(this, _authInfo).authType)) {
|
|
856
|
+
throw new Error(`invalid auth type, expected ${allowed.join(", ")}`);
|
|
857
|
+
}
|
|
858
|
+
return __privateGet(this, _authInfo);
|
|
859
|
+
}
|
|
779
860
|
/**
|
|
780
861
|
* Sets the email associated with the `ParaCore` instance.
|
|
781
862
|
* @param email - Email to set.
|
|
782
863
|
*/
|
|
783
864
|
setEmail(email) {
|
|
784
865
|
return __async(this, null, function* () {
|
|
785
|
-
this.email
|
|
786
|
-
yield this.localStorageSetItem(constants.LOCAL_STORAGE_EMAIL, email);
|
|
866
|
+
yield this.setAuth({ email });
|
|
787
867
|
});
|
|
788
868
|
}
|
|
789
869
|
/**
|
|
@@ -792,8 +872,7 @@ const _ParaCore = class _ParaCore {
|
|
|
792
872
|
*/
|
|
793
873
|
setTelegramUserId(telegramUserId) {
|
|
794
874
|
return __async(this, null, function* () {
|
|
795
|
-
this.telegramUserId
|
|
796
|
-
yield this.localStorageSetItem(constants.LOCAL_STORAGE_TELEGRAM_USER_ID, telegramUserId);
|
|
875
|
+
yield this.setAuth({ telegramUserId });
|
|
797
876
|
});
|
|
798
877
|
}
|
|
799
878
|
/**
|
|
@@ -803,10 +882,7 @@ const _ParaCore = class _ParaCore {
|
|
|
803
882
|
*/
|
|
804
883
|
setPhoneNumber(phone, countryCode) {
|
|
805
884
|
return __async(this, null, function* () {
|
|
806
|
-
this.phone
|
|
807
|
-
this.countryCode = countryCode;
|
|
808
|
-
yield this.localStorageSetItem(constants.LOCAL_STORAGE_PHONE, phone);
|
|
809
|
-
yield this.localStorageSetItem(constants.LOCAL_STORAGE_COUNTRY_CODE, countryCode);
|
|
885
|
+
yield this.setAuth({ phone: (0, import_utils2.formatPhoneNumber)(phone, countryCode) });
|
|
810
886
|
});
|
|
811
887
|
}
|
|
812
888
|
/**
|
|
@@ -815,8 +891,7 @@ const _ParaCore = class _ParaCore {
|
|
|
815
891
|
*/
|
|
816
892
|
setFarcasterUsername(farcasterUsername) {
|
|
817
893
|
return __async(this, null, function* () {
|
|
818
|
-
this.farcasterUsername
|
|
819
|
-
yield this.localStorageSetItem(constants.LOCAL_STORAGE_FARCASTER_USERNAME, farcasterUsername);
|
|
894
|
+
yield this.setAuth({ farcasterUsername });
|
|
820
895
|
});
|
|
821
896
|
}
|
|
822
897
|
/**
|
|
@@ -901,6 +976,9 @@ const _ParaCore = class _ParaCore {
|
|
|
901
976
|
getUserId() {
|
|
902
977
|
return this.userId;
|
|
903
978
|
}
|
|
979
|
+
getAuthInfo() {
|
|
980
|
+
return this.authInfo;
|
|
981
|
+
}
|
|
904
982
|
/**
|
|
905
983
|
* Gets the email associated with the `ParaCore` instance.
|
|
906
984
|
* @returns - email associated with the `ParaCore` instance.
|
|
@@ -908,22 +986,12 @@ const _ParaCore = class _ParaCore {
|
|
|
908
986
|
getEmail() {
|
|
909
987
|
return this.email;
|
|
910
988
|
}
|
|
911
|
-
/**
|
|
912
|
-
* Gets the phone object associated with the `ParaCore` instance.
|
|
913
|
-
* @returns - phone object with phone number and country code associated with the `ParaCore` instance.
|
|
914
|
-
*/
|
|
915
|
-
getPhone() {
|
|
916
|
-
return { phone: this.phone, countryCode: this.countryCode };
|
|
917
|
-
}
|
|
918
989
|
/**
|
|
919
990
|
* Gets the formatted phone number associated with the `ParaCore` instance.
|
|
920
991
|
* @returns - formatted phone number associated with the `ParaCore` instance.
|
|
921
992
|
*/
|
|
922
993
|
getPhoneNumber() {
|
|
923
|
-
|
|
924
|
-
return void 0;
|
|
925
|
-
}
|
|
926
|
-
return (0, import_utils2.normalizePhoneNumber)(this.countryCode, this.phone);
|
|
994
|
+
return this.phone;
|
|
927
995
|
}
|
|
928
996
|
/**
|
|
929
997
|
* Gets the farcaster username associated with the `ParaCore` instance.
|
|
@@ -962,9 +1030,7 @@ const _ParaCore = class _ParaCore {
|
|
|
962
1030
|
if (!(yield this.isSessionActive()) || !this.userId) {
|
|
963
1031
|
throw new Error("no signed-in user");
|
|
964
1032
|
}
|
|
965
|
-
const {
|
|
966
|
-
data: { partnerId }
|
|
967
|
-
} = yield this.touchSession();
|
|
1033
|
+
const { partnerId } = yield this.touchSession();
|
|
968
1034
|
const { accountMetadata } = yield this.ctx.client.getAccountMetadata(this.userId, partnerId);
|
|
969
1035
|
return accountMetadata;
|
|
970
1036
|
});
|
|
@@ -1022,8 +1088,10 @@ const _ParaCore = class _ParaCore {
|
|
|
1022
1088
|
}
|
|
1023
1089
|
findWallet(idOrAddress, overrideType, filter = {}) {
|
|
1024
1090
|
var _a, _c, _d;
|
|
1025
|
-
if (!this.isExternalWalletAuth
|
|
1026
|
-
|
|
1091
|
+
if (!this.isExternalWalletAuth) {
|
|
1092
|
+
if (!idOrAddress && Object.keys(this.externalWallets).length > 0) {
|
|
1093
|
+
return Object.values(this.externalWallets)[0];
|
|
1094
|
+
}
|
|
1027
1095
|
}
|
|
1028
1096
|
if ((_a = this.externalWallets) == null ? void 0 : _a[idOrAddress]) {
|
|
1029
1097
|
return this.externalWallets[idOrAddress];
|
|
@@ -1034,7 +1102,7 @@ const _ParaCore = class _ParaCore {
|
|
|
1034
1102
|
const _b = this.wallets[walletId], { signer: _signer } = _b, wallet = __objRest(_b, ["signer"]);
|
|
1035
1103
|
const type = (_d = overrideType != null ? overrideType : (_c = this.currentWalletIdsArray.find(([id]) => id === walletId)) == null ? void 0 : _c[1]) != null ? _d : wallet.type;
|
|
1036
1104
|
return __spreadProps(__spreadValues({}, wallet), {
|
|
1037
|
-
type
|
|
1105
|
+
type
|
|
1038
1106
|
});
|
|
1039
1107
|
}
|
|
1040
1108
|
} catch (e) {
|
|
@@ -1044,7 +1112,7 @@ const _ParaCore = class _ParaCore {
|
|
|
1044
1112
|
get availableWallets() {
|
|
1045
1113
|
var _a;
|
|
1046
1114
|
return [
|
|
1047
|
-
...this.currentWalletIdsArray.map(([address, type]) => [address, type, false]).map(([id, type]) => {
|
|
1115
|
+
...[...this.currentWalletIdsArray, ...__privateGet(this, _ParaCore_instances, guestWalletIdsArray_get)].map(([address, type]) => [address, type, false]).map(([id, type]) => {
|
|
1048
1116
|
const wallet = this.findWallet(id, type);
|
|
1049
1117
|
if (!wallet) return null;
|
|
1050
1118
|
return {
|
|
@@ -1070,10 +1138,8 @@ const _ParaCore = class _ParaCore {
|
|
|
1070
1138
|
}
|
|
1071
1139
|
assertIsValidWalletType(type, walletTypes) {
|
|
1072
1140
|
return __async(this, null, function* () {
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
}
|
|
1076
|
-
if (!type || !Object.values(import_user_management_client.WalletType).includes(type) || !(walletTypes != null ? walletTypes : this.supportedWalletTypes.map(({ type: type2 }) => type2)).includes(type)) {
|
|
1141
|
+
const { supportedWalletTypes } = yield __privateMethod(this, _ParaCore_instances, assertPartner_fn).call(this);
|
|
1142
|
+
if (!type || !import_user_management_client.WALLET_TYPES.includes(type) || !(walletTypes != null ? walletTypes : supportedWalletTypes.map(({ type: type2 }) => type2)).includes(type)) {
|
|
1077
1143
|
throw new Error(`wallet type ${type} is not supported`);
|
|
1078
1144
|
}
|
|
1079
1145
|
return type;
|
|
@@ -1081,33 +1147,29 @@ const _ParaCore = class _ParaCore {
|
|
|
1081
1147
|
}
|
|
1082
1148
|
getMissingTypes() {
|
|
1083
1149
|
return __async(this, null, function* () {
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
}
|
|
1087
|
-
return this.supportedWalletTypes.filter(
|
|
1150
|
+
const { supportedWalletTypes } = yield __privateMethod(this, _ParaCore_instances, assertPartner_fn).call(this);
|
|
1151
|
+
return supportedWalletTypes.filter(
|
|
1088
1152
|
({ type: t, optional }) => !optional && Object.values(this.wallets).every((w) => !this.isWalletOwned(w) || !import_utils2.WalletSchemeTypeMap[w.scheme][t])
|
|
1089
1153
|
).map(({ type }) => type);
|
|
1090
1154
|
});
|
|
1091
1155
|
}
|
|
1092
1156
|
getTypesToCreate(types) {
|
|
1093
1157
|
return __async(this, null, function* () {
|
|
1094
|
-
|
|
1095
|
-
yield this.touchSession();
|
|
1096
|
-
}
|
|
1158
|
+
const { supportedWalletTypes } = yield __privateMethod(this, _ParaCore_instances, assertPartner_fn).call(this);
|
|
1097
1159
|
return (0, import_utils2.getSchemes)(types != null ? types : yield this.getMissingTypes()).map((scheme) => {
|
|
1098
1160
|
switch (scheme) {
|
|
1099
|
-
case
|
|
1100
|
-
return
|
|
1161
|
+
case "ED25519":
|
|
1162
|
+
return "SOLANA";
|
|
1101
1163
|
default:
|
|
1102
|
-
return
|
|
1164
|
+
return supportedWalletTypes.some(({ type, optional }) => type === "COSMOS" && !optional) ? "COSMOS" : "EVM";
|
|
1103
1165
|
}
|
|
1104
1166
|
});
|
|
1105
1167
|
});
|
|
1106
1168
|
}
|
|
1107
|
-
getPartnerURL(
|
|
1169
|
+
getPartnerURL() {
|
|
1108
1170
|
return __async(this, null, function* () {
|
|
1109
|
-
const
|
|
1110
|
-
return
|
|
1171
|
+
const { portalUrl } = yield __privateMethod(this, _ParaCore_instances, assertPartner_fn).call(this);
|
|
1172
|
+
return portalUrl;
|
|
1111
1173
|
});
|
|
1112
1174
|
}
|
|
1113
1175
|
/**
|
|
@@ -1115,75 +1177,9 @@ const _ParaCore = class _ParaCore {
|
|
|
1115
1177
|
* @param partnerId: string - id of the partner to get the portal URL for
|
|
1116
1178
|
* @returns - portal URL
|
|
1117
1179
|
*/
|
|
1118
|
-
getPortalURL(
|
|
1180
|
+
getPortalURL() {
|
|
1119
1181
|
return __async(this, null, function* () {
|
|
1120
|
-
return
|
|
1121
|
-
});
|
|
1122
|
-
}
|
|
1123
|
-
getWebAuthURLForCreate(_a) {
|
|
1124
|
-
return __async(this, null, function* () {
|
|
1125
|
-
var _b = _a, {
|
|
1126
|
-
webAuthId
|
|
1127
|
-
} = _b, options = __objRest(_b, [
|
|
1128
|
-
"webAuthId"
|
|
1129
|
-
]);
|
|
1130
|
-
return this.constructPortalUrl("createAuth", __spreadProps(__spreadValues({}, options), { pathId: webAuthId }));
|
|
1131
|
-
});
|
|
1132
|
-
}
|
|
1133
|
-
getPasswordURLForCreate(_c) {
|
|
1134
|
-
return __async(this, null, function* () {
|
|
1135
|
-
var _d = _c, {
|
|
1136
|
-
passwordId
|
|
1137
|
-
} = _d, options = __objRest(_d, [
|
|
1138
|
-
"passwordId"
|
|
1139
|
-
]);
|
|
1140
|
-
return this.constructPortalUrl("createPassword", __spreadProps(__spreadValues({}, options), {
|
|
1141
|
-
pathId: passwordId
|
|
1142
|
-
}));
|
|
1143
|
-
});
|
|
1144
|
-
}
|
|
1145
|
-
getShortUrl(compressedUrl) {
|
|
1146
|
-
return (0, import_utils2.constructUrl)({
|
|
1147
|
-
base: (0, import_utils2.getPortalBaseURL)(this.ctx),
|
|
1148
|
-
path: `/short/${compressedUrl}`
|
|
1149
|
-
});
|
|
1150
|
-
}
|
|
1151
|
-
shortenLoginLink(link) {
|
|
1152
|
-
return __async(this, null, function* () {
|
|
1153
|
-
const url = yield transmissionUtils.upload(link, this.ctx.client);
|
|
1154
|
-
return this.getShortUrl(url);
|
|
1155
|
-
});
|
|
1156
|
-
}
|
|
1157
|
-
/**
|
|
1158
|
-
* Generates a URL for registering a new WebAuth passkey.
|
|
1159
|
-
* @param {GetWebAuthUrlForLoginParams} opts the options object
|
|
1160
|
-
* @returns - the URL for creating a new passkey
|
|
1161
|
-
*/
|
|
1162
|
-
getWebAuthURLForLogin(opts) {
|
|
1163
|
-
return __async(this, null, function* () {
|
|
1164
|
-
return this.constructPortalUrl("loginAuth", opts);
|
|
1165
|
-
});
|
|
1166
|
-
}
|
|
1167
|
-
/**
|
|
1168
|
-
* Generates a URL for registering a new user password.
|
|
1169
|
-
* @param {GetWebAuthUrlForLoginParams} opts the options object
|
|
1170
|
-
* @returns - the URL for creating a new password
|
|
1171
|
-
*/
|
|
1172
|
-
getPasswordURLForLogin(opts) {
|
|
1173
|
-
return __async(this, null, function* () {
|
|
1174
|
-
return this.constructPortalUrl("loginPassword", opts);
|
|
1175
|
-
});
|
|
1176
|
-
}
|
|
1177
|
-
/**
|
|
1178
|
-
* Generates a URL for registering a new WebAuth passkey for a phone number.
|
|
1179
|
-
* @param {Omit<GetWebAuthUrlForLoginParams, 'authType'>} opts the options object
|
|
1180
|
-
* @returns - web auth url
|
|
1181
|
-
*/
|
|
1182
|
-
getWebAuthURLForLoginForPhone(opts) {
|
|
1183
|
-
return __async(this, null, function* () {
|
|
1184
|
-
return this.constructPortalUrl("loginAuth", __spreadValues({
|
|
1185
|
-
authType: "phone"
|
|
1186
|
-
}, opts));
|
|
1182
|
+
return (yield this.getPartnerURL()) || (0, import_utils2.getPortalBaseURL)(this.ctx);
|
|
1187
1183
|
});
|
|
1188
1184
|
}
|
|
1189
1185
|
/**
|
|
@@ -1198,7 +1194,7 @@ const _ParaCore = class _ParaCore {
|
|
|
1198
1194
|
if (!wallet) {
|
|
1199
1195
|
throw new Error("wallet not found");
|
|
1200
1196
|
}
|
|
1201
|
-
if (wallet.scheme !==
|
|
1197
|
+
if (wallet.scheme !== "DKLS") {
|
|
1202
1198
|
throw new Error("invalid wallet scheme");
|
|
1203
1199
|
}
|
|
1204
1200
|
return yield this.platformUtils.getPrivateKey(
|
|
@@ -1245,131 +1241,52 @@ const _ParaCore = class _ParaCore {
|
|
|
1245
1241
|
yield this.setWallets(this.wallets);
|
|
1246
1242
|
});
|
|
1247
1243
|
}
|
|
1248
|
-
/**
|
|
1249
|
-
* Checks if a user exists for an email address.
|
|
1250
|
-
* @param {Object} opts the options object
|
|
1251
|
-
* @param {string} opts.email the email to check.
|
|
1252
|
-
* @returns true if user exists, false otherwise.
|
|
1253
|
-
*/
|
|
1254
|
-
checkIfUserExists(_0) {
|
|
1255
|
-
return __async(this, arguments, function* ({ email }) {
|
|
1256
|
-
const res = yield this.ctx.client.checkUserExists({ email });
|
|
1257
|
-
return res.data.exists;
|
|
1258
|
-
});
|
|
1259
|
-
}
|
|
1260
|
-
/**
|
|
1261
|
-
* Checks if a user exists for a phone number.
|
|
1262
|
-
* @param {Object} opts the options object
|
|
1263
|
-
* @param {string} opts.phone - phone number to check.
|
|
1264
|
-
* @param {string} opts.countryCode - the country code.
|
|
1265
|
-
* @returns true if user exists, false otherwise.
|
|
1266
|
-
*/
|
|
1267
|
-
checkIfUserExistsByPhone(_0) {
|
|
1268
|
-
return __async(this, arguments, function* ({ phone, countryCode }) {
|
|
1269
|
-
const res = yield this.ctx.client.checkUserExists({ phone, countryCode });
|
|
1270
|
-
return res.data.exists;
|
|
1271
|
-
});
|
|
1272
|
-
}
|
|
1273
|
-
/**
|
|
1274
|
-
* Creates a new user.
|
|
1275
|
-
* @param {Object} opts the options object
|
|
1276
|
-
* @param {string} opts.email the email to use.
|
|
1277
|
-
*/
|
|
1278
|
-
createUser(_0) {
|
|
1279
|
-
return __async(this, arguments, function* ({ email }) {
|
|
1280
|
-
this.requireApiKey();
|
|
1281
|
-
yield this.setEmail(email);
|
|
1282
|
-
const { userId } = yield this.ctx.client.createUser(__spreadValues({
|
|
1283
|
-
email: this.email
|
|
1284
|
-
}, this.getVerificationEmailProps()));
|
|
1285
|
-
yield this.setUserId(userId);
|
|
1286
|
-
});
|
|
1287
|
-
}
|
|
1288
|
-
/**
|
|
1289
|
-
* Creates a new user with a phone number.
|
|
1290
|
-
* @param {Object} opts the options object
|
|
1291
|
-
* @param {string} opts.phone - the phone number to use for creating the user.
|
|
1292
|
-
* @param {string} opts.countryCode - the country code to use for creating the user.
|
|
1293
|
-
*/
|
|
1294
|
-
createUserByPhone(_0) {
|
|
1295
|
-
return __async(this, arguments, function* ({ phone, countryCode }) {
|
|
1296
|
-
this.requireApiKey();
|
|
1297
|
-
yield this.setPhoneNumber(phone, countryCode);
|
|
1298
|
-
const { userId } = yield this.ctx.client.createUser({
|
|
1299
|
-
phone: this.phone,
|
|
1300
|
-
countryCode: this.countryCode
|
|
1301
|
-
});
|
|
1302
|
-
yield this.setUserId(userId);
|
|
1303
|
-
});
|
|
1304
|
-
}
|
|
1305
1244
|
/**
|
|
1306
1245
|
* Logs in or creates a new user using an external wallet address.
|
|
1307
1246
|
* @param {Object} opts the options object
|
|
1308
1247
|
* @param {string} opts.address the external wallet address to use for identification.
|
|
1309
|
-
* @param {
|
|
1248
|
+
* @param {TWalletType} opts.type type of external wallet to use for identification.
|
|
1310
1249
|
* @param {string} opts.provider the name of the provider for the external wallet.
|
|
1311
1250
|
*/
|
|
1312
|
-
|
|
1251
|
+
loginExternalWallet(_a) {
|
|
1313
1252
|
return __async(this, null, function* () {
|
|
1253
|
+
var _b = _a, {
|
|
1254
|
+
externalWallet
|
|
1255
|
+
} = _b, urlOptions = __objRest(_b, [
|
|
1256
|
+
"externalWallet"
|
|
1257
|
+
]);
|
|
1314
1258
|
if (this.externalWalletConnectionOnly) {
|
|
1315
|
-
|
|
1316
|
-
yield this.setExternalWallet(
|
|
1259
|
+
externalWallet.withFullParaAuth = false;
|
|
1260
|
+
yield this.setExternalWallet(externalWallet);
|
|
1317
1261
|
return Promise.resolve({
|
|
1318
1262
|
userId: constants.EXTERNAL_WALLET_CONNECTION_ONLY_USER_ID
|
|
1319
1263
|
});
|
|
1320
1264
|
}
|
|
1321
1265
|
this.requireApiKey();
|
|
1322
|
-
const
|
|
1323
|
-
|
|
1324
|
-
type: wallet.type,
|
|
1325
|
-
externalWalletProvider: wallet.provider,
|
|
1326
|
-
// If the wallet isn't using full Para auth we want to track the login here
|
|
1327
|
-
shouldTrackUser: !wallet.withFullParaAuth
|
|
1328
|
-
});
|
|
1329
|
-
yield this.setExternalWallet(wallet);
|
|
1330
|
-
yield this.setUserId(res.userId);
|
|
1331
|
-
return res;
|
|
1332
|
-
});
|
|
1333
|
-
}
|
|
1334
|
-
/**
|
|
1335
|
-
* Returns whether or not the user is connected with only an external wallet, not an external wallet with Para auth.
|
|
1336
|
-
*/
|
|
1337
|
-
isUsingExternalWallet() {
|
|
1338
|
-
return !this.isExternalWalletAuth && !!Object.keys(this.externalWallets).length;
|
|
1339
|
-
}
|
|
1340
|
-
/**
|
|
1341
|
-
* Passes the email code obtained from the user for verification.
|
|
1342
|
-
* @param {Object} opts the options object
|
|
1343
|
-
* @param {string} verificationCode the six-digit code to check
|
|
1344
|
-
* @returns {string} the web auth url for creating a new credential
|
|
1345
|
-
*/
|
|
1346
|
-
verifyEmail(_0) {
|
|
1347
|
-
return __async(this, arguments, function* ({ verificationCode }) {
|
|
1348
|
-
yield this.ctx.client.verifyEmail(this.userId, { verificationCode });
|
|
1349
|
-
return this.getSetUpBiometricsURL();
|
|
1266
|
+
const serverAuthState = yield this.ctx.client.loginExternalWallet({ externalWallet });
|
|
1267
|
+
return __privateMethod(this, _ParaCore_instances, prepareAuthState_fn).call(this, serverAuthState, urlOptions);
|
|
1350
1268
|
});
|
|
1351
1269
|
}
|
|
1352
|
-
verifyExternalWallet(
|
|
1353
|
-
return __async(this,
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
return this.getSetUpBiometricsURLForPhone();
|
|
1270
|
+
verifyExternalWallet(_c) {
|
|
1271
|
+
return __async(this, null, function* () {
|
|
1272
|
+
var _d = _c, {
|
|
1273
|
+
externalWallet,
|
|
1274
|
+
signedMessage,
|
|
1275
|
+
cosmosPublicKeyHex,
|
|
1276
|
+
cosmosSigner
|
|
1277
|
+
} = _d, urlOptions = __objRest(_d, [
|
|
1278
|
+
"externalWallet",
|
|
1279
|
+
"signedMessage",
|
|
1280
|
+
"cosmosPublicKeyHex",
|
|
1281
|
+
"cosmosSigner"
|
|
1282
|
+
]);
|
|
1283
|
+
const serverAuthState = yield this.ctx.client.verifyExternalWallet(this.userId, {
|
|
1284
|
+
externalWallet,
|
|
1285
|
+
signedMessage,
|
|
1286
|
+
cosmosPublicKeyHex,
|
|
1287
|
+
cosmosSigner
|
|
1288
|
+
});
|
|
1289
|
+
return __privateMethod(this, _ParaCore_instances, prepareAuthState_fn).call(this, serverAuthState, urlOptions);
|
|
1373
1290
|
});
|
|
1374
1291
|
}
|
|
1375
1292
|
/**
|
|
@@ -1378,18 +1295,19 @@ const _ParaCore = class _ParaCore {
|
|
|
1378
1295
|
* @param authResponse - the response JSON object received from the Telegram widget.
|
|
1379
1296
|
* @returns `{ isValid: boolean; telegramUserId?: string; userId?: string; isNewUser?: boolean; supportedAuthMethods?: AuthMethod[]; biometricHints?: BiometricLocationHint[] }`
|
|
1380
1297
|
*/
|
|
1381
|
-
verifyTelegram(
|
|
1298
|
+
verifyTelegram(_e) {
|
|
1382
1299
|
return __async(this, null, function* () {
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1300
|
+
var _f = _e, {
|
|
1301
|
+
telegramAuthResponse
|
|
1302
|
+
} = _f, urlOptions = __objRest(_f, [
|
|
1303
|
+
"telegramAuthResponse"
|
|
1304
|
+
]);
|
|
1305
|
+
try {
|
|
1306
|
+
const serverAuthState = yield this.ctx.client.verifyTelegram(telegramAuthResponse);
|
|
1307
|
+
return __privateMethod(this, _ParaCore_instances, prepareAuthState_fn).call(this, serverAuthState, urlOptions);
|
|
1308
|
+
} catch (e) {
|
|
1309
|
+
throw new Error(e.message);
|
|
1391
1310
|
}
|
|
1392
|
-
return res;
|
|
1393
1311
|
});
|
|
1394
1312
|
}
|
|
1395
1313
|
/**
|
|
@@ -1399,32 +1317,9 @@ const _ParaCore = class _ParaCore {
|
|
|
1399
1317
|
* @param {string} opts.verificationCode the verification code to received via 2FA.
|
|
1400
1318
|
* @returns {Object} `{ address, initiatedAt, status, userId, walletId }`
|
|
1401
1319
|
*/
|
|
1402
|
-
|
|
1403
|
-
return __async(this, arguments, function* ({
|
|
1404
|
-
const res = yield this.ctx.client.verify2FA(
|
|
1405
|
-
return {
|
|
1406
|
-
initiatedAt: res.data.initiatedAt,
|
|
1407
|
-
status: res.data.status,
|
|
1408
|
-
userId: res.data.userId,
|
|
1409
|
-
wallets: res.data.wallets
|
|
1410
|
-
};
|
|
1411
|
-
});
|
|
1412
|
-
}
|
|
1413
|
-
/**
|
|
1414
|
-
* Performs 2FA verification.
|
|
1415
|
-
* @param {Object} opts the options object
|
|
1416
|
-
* @param {string} opts.phone the phone number
|
|
1417
|
-
* @param {string} opts.countryCode - the country code
|
|
1418
|
-
* @param {string} opts.verificationCode - verification code to received via 2FA.
|
|
1419
|
-
* @returns {Object} `{ address, initiatedAt, status, userId, walletId }`
|
|
1420
|
-
*/
|
|
1421
|
-
verify2FAForPhone(_0) {
|
|
1422
|
-
return __async(this, arguments, function* ({
|
|
1423
|
-
phone,
|
|
1424
|
-
countryCode,
|
|
1425
|
-
verificationCode
|
|
1426
|
-
}) {
|
|
1427
|
-
const res = yield this.ctx.client.verify2FAForPhone(phone, countryCode, verificationCode);
|
|
1320
|
+
verify2fa(_0) {
|
|
1321
|
+
return __async(this, arguments, function* ({ auth, verificationCode }) {
|
|
1322
|
+
const res = yield this.ctx.client.verify2FA(auth, verificationCode);
|
|
1428
1323
|
return {
|
|
1429
1324
|
initiatedAt: res.data.initiatedAt,
|
|
1430
1325
|
status: res.data.status,
|
|
@@ -1437,12 +1332,11 @@ const _ParaCore = class _ParaCore {
|
|
|
1437
1332
|
* Sets up two-factor authentication for the current user.
|
|
1438
1333
|
* @returns {string} uri - uri to use for setting up 2FA
|
|
1439
1334
|
* */
|
|
1440
|
-
|
|
1335
|
+
setup2fa() {
|
|
1441
1336
|
return __async(this, null, function* () {
|
|
1442
|
-
const
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
};
|
|
1337
|
+
const userId = this.assertUserId();
|
|
1338
|
+
const res = yield this.ctx.client.setup2FA(userId);
|
|
1339
|
+
return res;
|
|
1446
1340
|
});
|
|
1447
1341
|
}
|
|
1448
1342
|
/**
|
|
@@ -1450,24 +1344,10 @@ const _ParaCore = class _ParaCore {
|
|
|
1450
1344
|
* @param {Object} opts the options object
|
|
1451
1345
|
* @param {string} opts.verificationCode - the verification code received via 2FA.
|
|
1452
1346
|
*/
|
|
1453
|
-
|
|
1347
|
+
enable2fa(_0) {
|
|
1454
1348
|
return __async(this, arguments, function* ({ verificationCode }) {
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
}
|
|
1458
|
-
/**
|
|
1459
|
-
* Determines if 2FA has been set up.
|
|
1460
|
-
* @returns {Object} `{ isSetup: boolean }` - true if 2FA is setup, false otherwise
|
|
1461
|
-
*/
|
|
1462
|
-
check2FAStatus() {
|
|
1463
|
-
return __async(this, null, function* () {
|
|
1464
|
-
if (!this.userId) {
|
|
1465
|
-
return { isSetup: false };
|
|
1466
|
-
}
|
|
1467
|
-
const res = yield this.ctx.client.check2FAStatus(this.userId);
|
|
1468
|
-
return {
|
|
1469
|
-
isSetup: res.data.isSetup
|
|
1470
|
-
};
|
|
1349
|
+
const userId = this.assertUserId();
|
|
1350
|
+
yield this.ctx.client.enable2FA(userId, verificationCode);
|
|
1471
1351
|
});
|
|
1472
1352
|
}
|
|
1473
1353
|
/**
|
|
@@ -1480,99 +1360,17 @@ const _ParaCore = class _ParaCore {
|
|
|
1480
1360
|
}, this.getVerificationEmailProps()));
|
|
1481
1361
|
});
|
|
1482
1362
|
}
|
|
1483
|
-
/**
|
|
1484
|
-
* Resend a verification SMS for the current user.
|
|
1485
|
-
*/
|
|
1486
|
-
resendVerificationCodeByPhone() {
|
|
1487
|
-
return __async(this, null, function* () {
|
|
1488
|
-
yield this.ctx.client.resendVerificationCodeByPhone({
|
|
1489
|
-
userId: this.userId
|
|
1490
|
-
});
|
|
1491
|
-
});
|
|
1492
|
-
}
|
|
1493
|
-
/**
|
|
1494
|
-
* Returns a URL for setting up a new WebAuth passkey.
|
|
1495
|
-
* @param {Object} opts the options object
|
|
1496
|
-
* @param {string} opts.authType - the auth type to use
|
|
1497
|
-
* @param {boolean} opts.isForNewDevice whether the passkey is for a new device of an existing user
|
|
1498
|
-
* @returns {string} the URL
|
|
1499
|
-
*/
|
|
1500
|
-
getSetUpBiometricsURL() {
|
|
1501
|
-
return __async(this, arguments, function* ({
|
|
1502
|
-
authType = "email",
|
|
1503
|
-
isForNewDevice = false
|
|
1504
|
-
} = {}) {
|
|
1505
|
-
const res = yield this.ctx.client.addSessionPublicKey(this.userId, {
|
|
1506
|
-
status: import_user_management_client.PublicKeyStatus.PENDING,
|
|
1507
|
-
type: import_user_management_client.PublicKeyType.WEB
|
|
1508
|
-
});
|
|
1509
|
-
return this.getWebAuthURLForCreate({
|
|
1510
|
-
authType,
|
|
1511
|
-
isForNewDevice,
|
|
1512
|
-
webAuthId: res.data.id,
|
|
1513
|
-
partnerId: res.data.partnerId
|
|
1514
|
-
});
|
|
1515
|
-
});
|
|
1516
|
-
}
|
|
1517
|
-
/**
|
|
1518
|
-
* Returns a URL for setting up a new WebAuth passkey for a phone number.
|
|
1519
|
-
* @param {Object} opts the options object
|
|
1520
|
-
* @param {boolean} opts.isForNewDevice whether the passkey is for a new device of an existing user
|
|
1521
|
-
* @returns {string} the URL
|
|
1522
|
-
*/
|
|
1523
|
-
getSetUpBiometricsURLForPhone() {
|
|
1524
|
-
return __async(this, arguments, function* ({
|
|
1525
|
-
isForNewDevice = false
|
|
1526
|
-
} = {}) {
|
|
1527
|
-
const res = yield this.ctx.client.addSessionPublicKey(this.userId, {
|
|
1528
|
-
status: import_user_management_client.PublicKeyStatus.PENDING,
|
|
1529
|
-
type: import_user_management_client.PublicKeyType.WEB
|
|
1530
|
-
});
|
|
1531
|
-
return this.getWebAuthURLForCreate({
|
|
1532
|
-
authType: "phone",
|
|
1533
|
-
isForNewDevice,
|
|
1534
|
-
webAuthId: res.data.id,
|
|
1535
|
-
partnerId: res.data.partnerId
|
|
1536
|
-
});
|
|
1537
|
-
});
|
|
1538
|
-
}
|
|
1539
|
-
/**
|
|
1540
|
-
* Returns a URL for setting up a new password.
|
|
1541
|
-
* @param {Object} opts the options object
|
|
1542
|
-
* @param {string} opts.authType - the auth type to use
|
|
1543
|
-
* @param {boolean} opts.isForNewDevice whether the passkey is for a new device of an existing user
|
|
1544
|
-
* @param {Theme} [opts.theme] the portal theme to use in place of the partner's default
|
|
1545
|
-
* @returns {string} the URL
|
|
1546
|
-
*/
|
|
1547
|
-
getSetupPasswordURL() {
|
|
1548
|
-
return __async(this, arguments, function* ({
|
|
1549
|
-
authType = "email",
|
|
1550
|
-
isForNewDevice = false,
|
|
1551
|
-
theme
|
|
1552
|
-
} = {}) {
|
|
1553
|
-
const res = yield this.ctx.client.addSessionPasswordPublicKey(this.userId, {
|
|
1554
|
-
status: import_user_management_client.PasswordStatus.PENDING
|
|
1555
|
-
});
|
|
1556
|
-
return this.getPasswordURLForCreate({
|
|
1557
|
-
authType,
|
|
1558
|
-
isForNewDevice,
|
|
1559
|
-
passwordId: res.data.id,
|
|
1560
|
-
partnerId: res.data.partnerId,
|
|
1561
|
-
theme
|
|
1562
|
-
});
|
|
1563
|
-
});
|
|
1564
|
-
}
|
|
1565
1363
|
/**
|
|
1566
1364
|
* Checks if the current session is active.
|
|
1567
1365
|
* @returns `true` if active, `false` otherwise
|
|
1568
1366
|
*/
|
|
1569
1367
|
isSessionActive() {
|
|
1570
1368
|
return __async(this, null, function* () {
|
|
1571
|
-
if (this.
|
|
1369
|
+
if (this.externalWalletConnectionType === "CONNECTION_ONLY") {
|
|
1572
1370
|
return true;
|
|
1573
1371
|
}
|
|
1574
|
-
const
|
|
1575
|
-
return !!
|
|
1372
|
+
const { isAuthenticated } = yield this.touchSession();
|
|
1373
|
+
return !!isAuthenticated;
|
|
1576
1374
|
});
|
|
1577
1375
|
}
|
|
1578
1376
|
/**
|
|
@@ -1581,201 +1379,102 @@ const _ParaCore = class _ParaCore {
|
|
|
1581
1379
|
**/
|
|
1582
1380
|
isFullyLoggedIn() {
|
|
1583
1381
|
return __async(this, null, function* () {
|
|
1584
|
-
if (this.
|
|
1585
|
-
return true;
|
|
1586
|
-
}
|
|
1587
|
-
if (this.isGuestMode) {
|
|
1382
|
+
if (this.externalWalletConnectionType === "CONNECTION_ONLY") {
|
|
1588
1383
|
return true;
|
|
1589
1384
|
}
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
});
|
|
1593
|
-
}
|
|
1594
|
-
get isGuestMode() {
|
|
1595
|
-
return !this.userId && this.currentWalletIdsArray.length > 0 && this.currentWalletIdsArray.every(([id]) => !!this.wallets[id] && this.wallets[id].pregenIdentifierType === "GUEST_ID");
|
|
1596
|
-
}
|
|
1597
|
-
supportedAuthMethods(auth) {
|
|
1598
|
-
return __async(this, null, function* () {
|
|
1599
|
-
const { supportedAuthMethods } = yield this.ctx.client.getSupportedAuthMethods(auth);
|
|
1600
|
-
const authMethods = /* @__PURE__ */ new Set();
|
|
1601
|
-
for (const type of supportedAuthMethods) {
|
|
1602
|
-
switch (type) {
|
|
1603
|
-
case "PASSWORD":
|
|
1604
|
-
authMethods.add(import_user_management_client.AuthMethod.PASSWORD);
|
|
1605
|
-
break;
|
|
1606
|
-
case "BIOMETRIC":
|
|
1607
|
-
authMethods.add(import_user_management_client.AuthMethod.PASSKEY);
|
|
1608
|
-
break;
|
|
1609
|
-
}
|
|
1610
|
-
}
|
|
1611
|
-
return authMethods;
|
|
1612
|
-
});
|
|
1613
|
-
}
|
|
1614
|
-
/**
|
|
1615
|
-
* Get hints associated with the users stored biometrics.
|
|
1616
|
-
* @returns Array containing useragents and AAGuids for stored biometrics
|
|
1617
|
-
*/
|
|
1618
|
-
getUserBiometricLocationHints() {
|
|
1619
|
-
return __async(this, null, function* () {
|
|
1620
|
-
var _a;
|
|
1621
|
-
if (!this.email && !this.phone && !this.farcasterUsername && !this.telegramUserId && !this.isExternalWalletAuth) {
|
|
1622
|
-
throw new Error(
|
|
1623
|
-
"one of email, phone, farcaster username, telegram user id or external wallet with Para auth are required to get biometric location hints"
|
|
1624
|
-
);
|
|
1625
|
-
}
|
|
1626
|
-
return yield this.ctx.client.getBiometricLocationHints({
|
|
1627
|
-
email: this.email,
|
|
1628
|
-
phone: this.phone,
|
|
1629
|
-
countryCode: this.countryCode,
|
|
1630
|
-
farcasterUsername: this.farcasterUsername,
|
|
1631
|
-
telegramUserId: this.telegramUserId,
|
|
1632
|
-
// Using id here since we store the bech32 address for cosmos in the address field of the wallet
|
|
1633
|
-
externalWalletAddress: (_a = this.externalWalletWithParaAuth) == null ? void 0 : _a.id
|
|
1634
|
-
});
|
|
1635
|
-
});
|
|
1636
|
-
}
|
|
1637
|
-
setAuth(auth) {
|
|
1638
|
-
return __async(this, null, function* () {
|
|
1639
|
-
const authInfo = (0, import_user_management_client.extractAuthInfo)(auth);
|
|
1640
|
-
if (!authInfo) {
|
|
1641
|
-
return void 0;
|
|
1642
|
-
}
|
|
1643
|
-
switch (authInfo.authType) {
|
|
1644
|
-
case "email":
|
|
1645
|
-
yield this.setEmail(authInfo.identifier);
|
|
1646
|
-
break;
|
|
1647
|
-
case "phone":
|
|
1648
|
-
yield this.setPhoneNumber(authInfo.auth.phone, authInfo.auth.countryCode);
|
|
1649
|
-
break;
|
|
1650
|
-
case "farcaster":
|
|
1651
|
-
yield this.setFarcasterUsername(authInfo.identifier);
|
|
1652
|
-
break;
|
|
1653
|
-
case "telegram":
|
|
1654
|
-
yield this.setTelegramUserId(authInfo.identifier);
|
|
1655
|
-
break;
|
|
1656
|
-
}
|
|
1657
|
-
return authInfo;
|
|
1658
|
-
});
|
|
1659
|
-
}
|
|
1660
|
-
/**
|
|
1661
|
-
* Initiates a login.
|
|
1662
|
-
* @param {Object} opts the options object
|
|
1663
|
-
* @param {String} opts.email - the email to login with
|
|
1664
|
-
* @param {boolean} opts.useShortURL - whether to shorten the link
|
|
1665
|
-
* @returns - the WebAuth URL for logging in
|
|
1666
|
-
**/
|
|
1667
|
-
initiateUserLogin(_e) {
|
|
1668
|
-
return __async(this, null, function* () {
|
|
1669
|
-
var _f = _e, { useShortUrl = false } = _f, auth = __objRest(_f, ["useShortUrl"]);
|
|
1670
|
-
const authInfo = yield this.setAuth(auth);
|
|
1671
|
-
if (!authInfo) {
|
|
1672
|
-
return;
|
|
1673
|
-
}
|
|
1674
|
-
const res = yield this.touchSession(true);
|
|
1675
|
-
if (!this.loginEncryptionKeyPair) {
|
|
1676
|
-
yield this.setLoginEncryptionKeyPair();
|
|
1677
|
-
}
|
|
1678
|
-
const webAuthLoginURL = yield this.getWebAuthURLForLogin({
|
|
1679
|
-
authType: authInfo.authType,
|
|
1680
|
-
sessionId: res.data.sessionId,
|
|
1681
|
-
partnerId: res.data.partnerId,
|
|
1682
|
-
loginEncryptionPublicKey: (0, import_utils.getPublicKeyHex)(this.loginEncryptionKeyPair)
|
|
1683
|
-
});
|
|
1684
|
-
if (!useShortUrl) {
|
|
1685
|
-
return webAuthLoginURL;
|
|
1385
|
+
if (this.isGuestMode) {
|
|
1386
|
+
return true;
|
|
1686
1387
|
}
|
|
1687
|
-
|
|
1388
|
+
const isSessionActive = yield this.isSessionActive();
|
|
1389
|
+
return isSessionActive && (this.isNoWalletConfig || this.currentWalletIdsArray.length > 0 && this.currentWalletIdsArray.reduce((acc, [id]) => acc && !!this.wallets[id], true));
|
|
1688
1390
|
});
|
|
1689
1391
|
}
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
initiateUserLoginV2(auth) {
|
|
1696
|
-
return __async(this, null, function* () {
|
|
1697
|
-
const authInfo = yield this.setAuth(auth);
|
|
1698
|
-
if (!authInfo) {
|
|
1699
|
-
return;
|
|
1392
|
+
get isGuestMode() {
|
|
1393
|
+
return __privateGet(this, _ParaCore_instances, guestWalletIdsArray_get).length > 0 && Object.values(this.wallets).every(
|
|
1394
|
+
({ userId, partnerId }) => {
|
|
1395
|
+
var _a;
|
|
1396
|
+
return partnerId === ((_a = __privateGet(this, _partner)) == null ? void 0 : _a.id) && (!userId || userId !== this.userId);
|
|
1700
1397
|
}
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1398
|
+
);
|
|
1399
|
+
}
|
|
1400
|
+
supportedAuthMethods(auth) {
|
|
1401
|
+
return __async(this, null, function* () {
|
|
1402
|
+
const { supportedAuthMethods } = yield this.ctx.client.getSupportedAuthMethods(auth);
|
|
1403
|
+
const authMethods = /* @__PURE__ */ new Set();
|
|
1404
|
+
for (const type of supportedAuthMethods) {
|
|
1405
|
+
switch (type) {
|
|
1406
|
+
case "PASSWORD":
|
|
1407
|
+
authMethods.add(import_user_management_client.AuthMethod.PASSWORD);
|
|
1408
|
+
break;
|
|
1409
|
+
case "BIOMETRIC":
|
|
1410
|
+
authMethods.add(import_user_management_client.AuthMethod.PASSKEY);
|
|
1411
|
+
break;
|
|
1412
|
+
}
|
|
1704
1413
|
}
|
|
1705
|
-
return
|
|
1414
|
+
return authMethods;
|
|
1706
1415
|
});
|
|
1707
1416
|
}
|
|
1708
1417
|
/**
|
|
1709
|
-
*
|
|
1710
|
-
* @
|
|
1711
|
-
* @
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
* @returns - the WebAuth URL for logging in
|
|
1715
|
-
**/
|
|
1716
|
-
initiateUserLoginForPhone(_g) {
|
|
1418
|
+
* Get hints associated with the users stored biometrics.
|
|
1419
|
+
* @deprecated
|
|
1420
|
+
* @returns Array containing useragents and AAGuids for stored biometrics
|
|
1421
|
+
*/
|
|
1422
|
+
getUserBiometricLocationHints() {
|
|
1717
1423
|
return __async(this, null, function* () {
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
} = _h, auth = __objRest(_h, [
|
|
1721
|
-
"useShortUrl"
|
|
1722
|
-
]);
|
|
1723
|
-
yield this.setAuth(auth);
|
|
1724
|
-
const res = yield this.touchSession(true);
|
|
1725
|
-
if (!this.loginEncryptionKeyPair) {
|
|
1726
|
-
yield this.setLoginEncryptionKeyPair();
|
|
1727
|
-
}
|
|
1728
|
-
const webAuthLoginURL = yield this.getWebAuthURLForLoginForPhone({
|
|
1729
|
-
sessionId: res.data.sessionId,
|
|
1730
|
-
loginEncryptionPublicKey: (0, import_utils.getPublicKeyHex)(this.loginEncryptionKeyPair),
|
|
1731
|
-
partnerId: res.data.partnerId
|
|
1732
|
-
});
|
|
1733
|
-
if (!useShortUrl) {
|
|
1734
|
-
return webAuthLoginURL;
|
|
1735
|
-
}
|
|
1736
|
-
return this.shortenLoginLink(webAuthLoginURL);
|
|
1424
|
+
const { auth } = this.assertIsAuthSet();
|
|
1425
|
+
return yield this.ctx.client.getBiometricLocationHints(auth);
|
|
1737
1426
|
});
|
|
1738
1427
|
}
|
|
1739
1428
|
/**
|
|
1740
1429
|
* Waits for the session to be active.
|
|
1741
1430
|
**/
|
|
1742
|
-
|
|
1743
|
-
return __async(this, arguments, function* ({
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
yield
|
|
1752
|
-
if (
|
|
1753
|
-
this.
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1431
|
+
waitForSignup(_0) {
|
|
1432
|
+
return __async(this, arguments, function* ({
|
|
1433
|
+
isCanceled = () => false,
|
|
1434
|
+
onCancel,
|
|
1435
|
+
onPoll
|
|
1436
|
+
}) {
|
|
1437
|
+
const startedAt = Date.now();
|
|
1438
|
+
return new Promise((resolve, reject) => {
|
|
1439
|
+
(() => __async(this, null, function* () {
|
|
1440
|
+
yield this.touchSession();
|
|
1441
|
+
if (!this.isExternalWalletAuth) {
|
|
1442
|
+
this.externalWallets = {};
|
|
1443
|
+
}
|
|
1444
|
+
while (true) {
|
|
1445
|
+
try {
|
|
1446
|
+
if (isCanceled() || Date.now() - startedAt > constants.POLLING_TIMEOUT_MS) {
|
|
1447
|
+
onCancel == null ? void 0 : onCancel();
|
|
1448
|
+
(0, import_utils2.dispatchEvent)(import_types.ParaEvent.ACCOUNT_CREATION_EVENT, false, "failed to sign up user");
|
|
1449
|
+
return reject("canceled");
|
|
1450
|
+
}
|
|
1451
|
+
yield new Promise((_resolve) => setTimeout(_resolve, constants.POLLING_INTERVAL_MS));
|
|
1452
|
+
if (yield this.isSessionActive()) {
|
|
1453
|
+
(0, import_utils2.dispatchEvent)(import_types.ParaEvent.ACCOUNT_CREATION_EVENT, true);
|
|
1454
|
+
return resolve(true);
|
|
1455
|
+
}
|
|
1456
|
+
onPoll == null ? void 0 : onPoll();
|
|
1457
|
+
} catch (err) {
|
|
1458
|
+
console.error(err);
|
|
1459
|
+
onPoll == null ? void 0 : onPoll();
|
|
1760
1460
|
}
|
|
1761
1461
|
}
|
|
1762
|
-
}
|
|
1763
|
-
|
|
1764
|
-
}
|
|
1765
|
-
}
|
|
1766
|
-
return false;
|
|
1462
|
+
}))();
|
|
1463
|
+
});
|
|
1767
1464
|
});
|
|
1768
1465
|
}
|
|
1769
|
-
|
|
1466
|
+
waitForWalletCreation() {
|
|
1770
1467
|
return __async(this, arguments, function* ({
|
|
1771
|
-
|
|
1468
|
+
isCanceled = () => false,
|
|
1469
|
+
onCancel
|
|
1772
1470
|
} = {}) {
|
|
1773
|
-
yield this.
|
|
1471
|
+
yield this.waitForSignup({ isCanceled, onCancel });
|
|
1472
|
+
const { supportedWalletTypes } = yield __privateMethod(this, _ParaCore_instances, assertPartner_fn).call(this);
|
|
1774
1473
|
const pregenWallets = yield this.getPregenWallets();
|
|
1775
1474
|
let recoverySecret, walletIds = {};
|
|
1776
1475
|
if (pregenWallets.length > 0) {
|
|
1777
1476
|
recoverySecret = yield this.claimPregenWallets();
|
|
1778
|
-
walletIds =
|
|
1477
|
+
walletIds = supportedWalletTypes.reduce((acc, { type }) => {
|
|
1779
1478
|
var _a;
|
|
1780
1479
|
return __spreadProps(__spreadValues({}, acc), {
|
|
1781
1480
|
[type]: [(_a = pregenWallets.find((w) => !!import_utils2.WalletSchemeTypeMap[w.scheme][type])) == null ? void 0 : _a.id]
|
|
@@ -1795,14 +1494,12 @@ const _ParaCore = class _ParaCore {
|
|
|
1795
1494
|
* You can create a QR code with this URI that works with Farcaster's mobile app.
|
|
1796
1495
|
* @return {string} the Farcaster connect URI
|
|
1797
1496
|
*/
|
|
1798
|
-
|
|
1497
|
+
getFarcasterConnectUri() {
|
|
1799
1498
|
return __async(this, null, function* () {
|
|
1800
|
-
yield this.logout();
|
|
1801
|
-
yield this.touchSession(true);
|
|
1802
1499
|
const {
|
|
1803
|
-
data: { connect_uri }
|
|
1500
|
+
data: { connect_uri: connectUri }
|
|
1804
1501
|
} = yield this.ctx.client.initializeFarcasterLogin();
|
|
1805
|
-
return
|
|
1502
|
+
return connectUri;
|
|
1806
1503
|
});
|
|
1807
1504
|
}
|
|
1808
1505
|
/**
|
|
@@ -1810,40 +1507,60 @@ const _ParaCore = class _ParaCore {
|
|
|
1810
1507
|
* If successful, this returns the user's Farcaster username and profile picture and indicates whether the user already exists.
|
|
1811
1508
|
* @return {Object} `{userExists: boolean; username: string; pfpUrl?: string | null }` - the user's information and whether the user already exists.
|
|
1812
1509
|
*/
|
|
1813
|
-
|
|
1510
|
+
verifyFarcaster(_g) {
|
|
1814
1511
|
return __async(this, null, function* () {
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1512
|
+
var _h = _g, {
|
|
1513
|
+
isCanceled = () => false,
|
|
1514
|
+
onConnectUri,
|
|
1515
|
+
onCancel,
|
|
1516
|
+
onPoll
|
|
1517
|
+
} = _h, urlOptions = __objRest(_h, [
|
|
1518
|
+
"isCanceled",
|
|
1519
|
+
"onConnectUri",
|
|
1520
|
+
"onCancel",
|
|
1521
|
+
"onPoll"
|
|
1522
|
+
]);
|
|
1523
|
+
if (onConnectUri) {
|
|
1524
|
+
const connectUri = yield this.getFarcasterConnectUri();
|
|
1525
|
+
onConnectUri(connectUri);
|
|
1526
|
+
}
|
|
1527
|
+
return new Promise((resolve, reject) => {
|
|
1528
|
+
(() => __async(this, null, function* () {
|
|
1529
|
+
const startedAt = Date.now();
|
|
1530
|
+
while (true) {
|
|
1531
|
+
try {
|
|
1532
|
+
if (isCanceled() || Date.now() - startedAt > constants.POLLING_TIMEOUT_MS) {
|
|
1533
|
+
onCancel == null ? void 0 : onCancel();
|
|
1534
|
+
return reject("canceled");
|
|
1535
|
+
}
|
|
1536
|
+
yield new Promise((_resolve) => setTimeout(_resolve, constants.POLLING_INTERVAL_MS));
|
|
1537
|
+
const serverAuthState = yield this.ctx.client.getFarcasterAuthStatus();
|
|
1538
|
+
if ((0, import_utils2.isServerAuthState)(serverAuthState)) {
|
|
1539
|
+
const authState = yield __privateMethod(this, _ParaCore_instances, prepareAuthState_fn).call(this, serverAuthState, urlOptions);
|
|
1540
|
+
return resolve(authState);
|
|
1541
|
+
}
|
|
1542
|
+
onPoll == null ? void 0 : onPoll();
|
|
1543
|
+
} catch (e) {
|
|
1544
|
+
console.error(e);
|
|
1545
|
+
return reject(e);
|
|
1546
|
+
}
|
|
1829
1547
|
}
|
|
1830
|
-
}
|
|
1831
|
-
|
|
1832
|
-
this.isAwaitingFarcaster = false;
|
|
1833
|
-
}
|
|
1834
|
-
}
|
|
1548
|
+
}))();
|
|
1549
|
+
});
|
|
1835
1550
|
});
|
|
1836
1551
|
}
|
|
1837
1552
|
/**
|
|
1838
1553
|
* Generates a URL for the user to log in with OAuth using a desire method.
|
|
1839
1554
|
*
|
|
1840
1555
|
* @param {Object} opts the options object
|
|
1841
|
-
* @param {
|
|
1556
|
+
* @param {TOAuthMethod} opts.method the third-party service to use for OAuth.
|
|
1842
1557
|
* @param {string} [opts.deeplinkUrl] the deeplink to redirect to after the OAuth flow. This is for mobile only.
|
|
1843
1558
|
* @returns {string} the URL for the user to log in with OAuth.
|
|
1844
1559
|
*/
|
|
1845
|
-
|
|
1846
|
-
return __async(this,
|
|
1560
|
+
getOAuthUrl(_i) {
|
|
1561
|
+
return __async(this, null, function* () {
|
|
1562
|
+
var _j = _i, { method, deeplinkUrl } = _j, params = __objRest(_j, ["method", "deeplinkUrl"]);
|
|
1563
|
+
var _a;
|
|
1847
1564
|
if (deeplinkUrl) {
|
|
1848
1565
|
try {
|
|
1849
1566
|
new URL(deeplinkUrl);
|
|
@@ -1851,14 +1568,13 @@ const _ParaCore = class _ParaCore {
|
|
|
1851
1568
|
throw new Error("Invalid deeplink URL");
|
|
1852
1569
|
}
|
|
1853
1570
|
}
|
|
1854
|
-
yield this.
|
|
1855
|
-
const res = yield this.touchSession(true);
|
|
1571
|
+
const sessionLookupId = (_a = params.sessionLookupId) != null ? _a : yield __privateMethod(this, _ParaCore_instances, prepareLogin_fn).call(this);
|
|
1856
1572
|
return (0, import_utils2.constructUrl)({
|
|
1857
|
-
base:
|
|
1858
|
-
path: `/auth/${method
|
|
1573
|
+
base: (0, import_userManagementClient.getBaseOAuthUrl)(this.ctx.env),
|
|
1574
|
+
path: `/auth/${method}`,
|
|
1859
1575
|
params: {
|
|
1860
1576
|
apiKey: this.ctx.apiKey,
|
|
1861
|
-
sessionLookupId
|
|
1577
|
+
sessionLookupId,
|
|
1862
1578
|
deeplinkUrl
|
|
1863
1579
|
}
|
|
1864
1580
|
});
|
|
@@ -1872,37 +1588,54 @@ const _ParaCore = class _ParaCore {
|
|
|
1872
1588
|
* @param {Window} [opts.popupWindow] the popup window being used for login.
|
|
1873
1589
|
* @return {Object} `{ email?: string; isError?: boolean; userExists: boolean; }` the result data
|
|
1874
1590
|
*/
|
|
1875
|
-
|
|
1876
|
-
return __async(this,
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1591
|
+
verifyOAuth(_k) {
|
|
1592
|
+
return __async(this, null, function* () {
|
|
1593
|
+
var _l = _k, {
|
|
1594
|
+
method,
|
|
1595
|
+
deeplinkUrl,
|
|
1596
|
+
isCanceled = () => false,
|
|
1597
|
+
onCancel,
|
|
1598
|
+
onPoll,
|
|
1599
|
+
onOAuthUrl
|
|
1600
|
+
} = _l, urlOptions = __objRest(_l, [
|
|
1601
|
+
"method",
|
|
1602
|
+
"deeplinkUrl",
|
|
1603
|
+
"isCanceled",
|
|
1604
|
+
"onCancel",
|
|
1605
|
+
"onPoll",
|
|
1606
|
+
"onOAuthUrl"
|
|
1607
|
+
]);
|
|
1608
|
+
let sessionLookupId;
|
|
1609
|
+
if (onOAuthUrl) {
|
|
1610
|
+
sessionLookupId = yield __privateMethod(this, _ParaCore_instances, prepareLogin_fn).call(this);
|
|
1611
|
+
const oAuthUrl = yield this.getOAuthUrl({ method, deeplinkUrl, sessionLookupId });
|
|
1612
|
+
onOAuthUrl(oAuthUrl);
|
|
1613
|
+
} else {
|
|
1614
|
+
({ sessionLookupId } = yield this.touchSession());
|
|
1615
|
+
}
|
|
1616
|
+
const startedAt = Date.now();
|
|
1617
|
+
return new Promise((resolve, reject) => {
|
|
1618
|
+
(() => __async(this, null, function* () {
|
|
1619
|
+
while (true) {
|
|
1620
|
+
try {
|
|
1621
|
+
if (isCanceled() || Date.now() - startedAt > constants.POLLING_TIMEOUT_MS) {
|
|
1622
|
+
onCancel == null ? void 0 : onCancel();
|
|
1623
|
+
return reject("canceled");
|
|
1890
1624
|
}
|
|
1891
|
-
yield
|
|
1892
|
-
yield this.
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1625
|
+
yield new Promise((_resolve) => setTimeout(_resolve, constants.POLLING_INTERVAL_MS));
|
|
1626
|
+
const serverAuthState = yield this.ctx.client.verifyOAuth();
|
|
1627
|
+
if ((0, import_utils2.isServerAuthState)(serverAuthState)) {
|
|
1628
|
+
const authState = yield __privateMethod(this, _ParaCore_instances, prepareAuthState_fn).call(this, serverAuthState, __spreadProps(__spreadValues({}, urlOptions), { sessionLookupId }));
|
|
1629
|
+
return resolve(authState);
|
|
1630
|
+
}
|
|
1631
|
+
onPoll == null ? void 0 : onPoll();
|
|
1632
|
+
} catch (err) {
|
|
1633
|
+
console.error(err);
|
|
1634
|
+
onPoll == null ? void 0 : onPoll();
|
|
1899
1635
|
}
|
|
1900
1636
|
}
|
|
1901
|
-
}
|
|
1902
|
-
|
|
1903
|
-
}
|
|
1904
|
-
}
|
|
1905
|
-
return { userExists: false };
|
|
1637
|
+
}))();
|
|
1638
|
+
});
|
|
1906
1639
|
});
|
|
1907
1640
|
}
|
|
1908
1641
|
/**
|
|
@@ -1913,60 +1646,61 @@ const _ParaCore = class _ParaCore {
|
|
|
1913
1646
|
* @param {boolean} [opts.skipSessionRefresh] whether to skip refreshing the session.
|
|
1914
1647
|
* @returns {Object} `{ isComplete: boolean; isError: boolean; needsWallet: boolean; partnerId: string; }` the result data
|
|
1915
1648
|
**/
|
|
1916
|
-
|
|
1649
|
+
waitForLogin() {
|
|
1917
1650
|
return __async(this, arguments, function* ({
|
|
1918
|
-
|
|
1651
|
+
isCanceled = () => false,
|
|
1652
|
+
onCancel,
|
|
1653
|
+
onPoll,
|
|
1919
1654
|
skipSessionRefresh = false
|
|
1920
1655
|
} = {}) {
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
this
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
try {
|
|
1928
|
-
yield new Promise((resolve) => setTimeout(resolve, constants.POLLING_INTERVAL_MS));
|
|
1929
|
-
if (!(yield this.isSessionActive())) {
|
|
1930
|
-
if (popupWindow == null ? void 0 : popupWindow.closed) {
|
|
1931
|
-
const resp2 = { isComplete: false, isError: true };
|
|
1932
|
-
(0, import_utils2.dispatchEvent)(import_types.ParaEvent.LOGIN_EVENT, resp2, "failed to setup user");
|
|
1933
|
-
return resp2;
|
|
1934
|
-
}
|
|
1935
|
-
continue;
|
|
1656
|
+
const startedAt = Date.now();
|
|
1657
|
+
return new Promise((resolve, reject) => {
|
|
1658
|
+
(() => __async(this, null, function* () {
|
|
1659
|
+
var _a;
|
|
1660
|
+
if (!this.isExternalWalletAuth) {
|
|
1661
|
+
this.externalWallets = {};
|
|
1936
1662
|
}
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1663
|
+
while (true) {
|
|
1664
|
+
if (isCanceled() || Date.now() - startedAt > constants.POLLING_TIMEOUT_MS) {
|
|
1665
|
+
(0, import_utils2.dispatchEvent)(import_types.ParaEvent.LOGIN_EVENT, { isComplete: false }, "failed to setup user");
|
|
1666
|
+
onCancel == null ? void 0 : onCancel();
|
|
1667
|
+
return reject("canceled");
|
|
1668
|
+
}
|
|
1669
|
+
yield new Promise((resolve2) => setTimeout(resolve2, constants.POLLING_INTERVAL_MS));
|
|
1670
|
+
try {
|
|
1671
|
+
let session = yield this.touchSession();
|
|
1672
|
+
if (!session.isAuthenticated) {
|
|
1673
|
+
onPoll == null ? void 0 : onPoll();
|
|
1946
1674
|
continue;
|
|
1947
1675
|
}
|
|
1676
|
+
session = yield this.userSetupAfterLogin();
|
|
1677
|
+
const needsWallet = (_a = session.needsWallet) != null ? _a : false;
|
|
1678
|
+
if (!needsWallet) {
|
|
1679
|
+
if (this.currentWalletIdsArray.length === 0) {
|
|
1680
|
+
onPoll == null ? void 0 : onPoll();
|
|
1681
|
+
continue;
|
|
1682
|
+
}
|
|
1683
|
+
}
|
|
1684
|
+
const fetchedWallets = yield this.fetchWallets();
|
|
1685
|
+
const tempSharesRes = yield this.getTransmissionKeyShares();
|
|
1686
|
+
if (tempSharesRes.data.temporaryShares.length === fetchedWallets.length) {
|
|
1687
|
+
yield this.setupAfterLogin({ temporaryShares: tempSharesRes.data.temporaryShares, skipSessionRefresh });
|
|
1688
|
+
yield this.claimPregenWallets();
|
|
1689
|
+
const resp = {
|
|
1690
|
+
needsWallet: needsWallet || Object.values(this.wallets).length === 0,
|
|
1691
|
+
partnerId: session.partnerId
|
|
1692
|
+
};
|
|
1693
|
+
(0, import_utils2.dispatchEvent)(import_types.ParaEvent.LOGIN_EVENT, resp);
|
|
1694
|
+
return resolve(resp);
|
|
1695
|
+
}
|
|
1696
|
+
onPoll == null ? void 0 : onPoll();
|
|
1697
|
+
} catch (err) {
|
|
1698
|
+
console.error(err);
|
|
1699
|
+
onPoll == null ? void 0 : onPoll();
|
|
1948
1700
|
}
|
|
1949
1701
|
}
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
if (tempSharesRes.data.temporaryShares.length === fetchedWallets.length) {
|
|
1953
|
-
yield this.setupAfterLogin({ temporaryShares: tempSharesRes.data.temporaryShares, skipSessionRefresh });
|
|
1954
|
-
yield this.claimPregenWallets();
|
|
1955
|
-
const resp2 = {
|
|
1956
|
-
isComplete: true,
|
|
1957
|
-
needsWallet: needsWallet || Object.values(this.wallets).length === 0,
|
|
1958
|
-
partnerId: postLoginData.data.partnerId
|
|
1959
|
-
};
|
|
1960
|
-
(0, import_utils2.dispatchEvent)(import_types.ParaEvent.LOGIN_EVENT, resp2);
|
|
1961
|
-
return resp2;
|
|
1962
|
-
}
|
|
1963
|
-
} catch (err) {
|
|
1964
|
-
console.error(err);
|
|
1965
|
-
}
|
|
1966
|
-
}
|
|
1967
|
-
const resp = { isComplete: false };
|
|
1968
|
-
(0, import_utils2.dispatchEvent)(import_types.ParaEvent.LOGIN_EVENT, resp, "exitted login without setting up user");
|
|
1969
|
-
return resp;
|
|
1702
|
+
}))();
|
|
1703
|
+
});
|
|
1970
1704
|
});
|
|
1971
1705
|
}
|
|
1972
1706
|
/**
|
|
@@ -1978,14 +1712,15 @@ const _ParaCore = class _ParaCore {
|
|
|
1978
1712
|
* @returns a URL for the user to reauthenticate.
|
|
1979
1713
|
**/
|
|
1980
1714
|
refreshSession() {
|
|
1981
|
-
return __async(this, arguments, function* ({
|
|
1982
|
-
|
|
1715
|
+
return __async(this, arguments, function* ({
|
|
1716
|
+
shouldOpenPopup = false
|
|
1717
|
+
} = {}) {
|
|
1718
|
+
const { sessionId } = yield this.touchSession(true);
|
|
1983
1719
|
if (!this.loginEncryptionKeyPair) {
|
|
1984
1720
|
yield this.setLoginEncryptionKeyPair();
|
|
1985
1721
|
}
|
|
1986
|
-
const link = yield this.
|
|
1987
|
-
sessionId
|
|
1988
|
-
loginEncryptionPublicKey: (0, import_utils.getPublicKeyHex)(this.loginEncryptionKeyPair)
|
|
1722
|
+
const link = yield this.getLoginUrl({
|
|
1723
|
+
sessionId
|
|
1989
1724
|
});
|
|
1990
1725
|
if (shouldOpenPopup) {
|
|
1991
1726
|
this.platformUtils.openPopup(link);
|
|
@@ -1999,13 +1734,13 @@ const _ParaCore = class _ParaCore {
|
|
|
1999
1734
|
**/
|
|
2000
1735
|
userSetupAfterLogin() {
|
|
2001
1736
|
return __async(this, null, function* () {
|
|
2002
|
-
const
|
|
2003
|
-
yield this.setUserId(
|
|
2004
|
-
if (
|
|
2005
|
-
yield this.setCurrentWalletIds(
|
|
2006
|
-
sessionLookupId: this.isPortal() ?
|
|
1737
|
+
const session = yield this.touchSession();
|
|
1738
|
+
yield this.setUserId(session.userId);
|
|
1739
|
+
if (session.currentWalletIds && session.currentWalletIds !== this.currentWalletIds)
|
|
1740
|
+
yield this.setCurrentWalletIds(session.currentWalletIds, {
|
|
1741
|
+
sessionLookupId: this.isPortal() ? session.sessionLookupId : void 0
|
|
2007
1742
|
});
|
|
2008
|
-
return
|
|
1743
|
+
return session;
|
|
2009
1744
|
});
|
|
2010
1745
|
}
|
|
2011
1746
|
/**
|
|
@@ -2016,8 +1751,8 @@ const _ParaCore = class _ParaCore {
|
|
|
2016
1751
|
**/
|
|
2017
1752
|
getTransmissionKeyShares() {
|
|
2018
1753
|
return __async(this, arguments, function* ({ isForNewDevice = false } = {}) {
|
|
2019
|
-
const
|
|
2020
|
-
const sessionLookupId = isForNewDevice ? `${
|
|
1754
|
+
const session = yield this.touchSession();
|
|
1755
|
+
const sessionLookupId = isForNewDevice ? `${session.sessionLookupId}-new-device` : session.sessionLookupId;
|
|
2021
1756
|
return this.ctx.client.getTransmissionKeyshares(this.userId, sessionLookupId);
|
|
2022
1757
|
});
|
|
2023
1758
|
}
|
|
@@ -2144,7 +1879,7 @@ const _ParaCore = class _ParaCore {
|
|
|
2144
1879
|
*
|
|
2145
1880
|
* @param {Object} [opts] the options object.
|
|
2146
1881
|
* @param {boolean} [opts.skipDistribute] if `true`, the wallets' recovery share will not be distributed.
|
|
2147
|
-
* @param {
|
|
1882
|
+
* @param {TWalletType[]} [opts.types] the types of wallets to create.
|
|
2148
1883
|
* @returns {Object} the wallets created, their ids, and the recovery secret.
|
|
2149
1884
|
**/
|
|
2150
1885
|
createWalletPerType() {
|
|
@@ -2215,7 +1950,7 @@ const _ParaCore = class _ParaCore {
|
|
|
2215
1950
|
/**
|
|
2216
1951
|
* Creates a new wallet.
|
|
2217
1952
|
* @param {Object} opts the options object.
|
|
2218
|
-
* @param {
|
|
1953
|
+
* @param {TWalletType} opts.type the type of wallet to create.
|
|
2219
1954
|
* @param {boolean} opts.skipDistribute - if true, recovery share will not be distributed.
|
|
2220
1955
|
* @returns {[Wallet, string | null]} `[wallet, recoveryShare]` - the wallet object and the new recovery share.
|
|
2221
1956
|
**/
|
|
@@ -2226,14 +1961,15 @@ const _ParaCore = class _ParaCore {
|
|
|
2226
1961
|
} = {}) {
|
|
2227
1962
|
var _a, _b;
|
|
2228
1963
|
this.requireApiKey();
|
|
1964
|
+
const { supportedWalletTypes } = yield __privateMethod(this, _ParaCore_instances, assertPartner_fn).call(this);
|
|
2229
1965
|
const walletType = yield this.assertIsValidWalletType(
|
|
2230
|
-
_type != null ? _type : (_a =
|
|
1966
|
+
_type != null ? _type : (_a = supportedWalletTypes.find(({ optional }) => !optional)) == null ? void 0 : _a.type
|
|
2231
1967
|
);
|
|
2232
1968
|
let signer;
|
|
2233
1969
|
let wallet;
|
|
2234
1970
|
let keygenRes;
|
|
2235
1971
|
switch (walletType) {
|
|
2236
|
-
case
|
|
1972
|
+
case "SOLANA": {
|
|
2237
1973
|
keygenRes = yield this.platformUtils.ed25519Keygen(
|
|
2238
1974
|
this.ctx,
|
|
2239
1975
|
this.userId,
|
|
@@ -2259,7 +1995,7 @@ const _ParaCore = class _ParaCore {
|
|
|
2259
1995
|
this.wallets[walletId] = {
|
|
2260
1996
|
id: walletId,
|
|
2261
1997
|
signer,
|
|
2262
|
-
scheme: walletType ===
|
|
1998
|
+
scheme: walletType === "SOLANA" ? "ED25519" : "DKLS",
|
|
2263
1999
|
type: walletType
|
|
2264
2000
|
};
|
|
2265
2001
|
wallet = this.wallets[walletId];
|
|
@@ -2276,7 +2012,7 @@ const _ParaCore = class _ParaCore {
|
|
|
2276
2012
|
});
|
|
2277
2013
|
}
|
|
2278
2014
|
yield this.setCurrentWalletIds(__spreadProps(__spreadValues({}, this.currentWalletIds), {
|
|
2279
|
-
[walletType]: [...(_b = this.currentWalletIds[walletType]) != null ? _b : [], walletId]
|
|
2015
|
+
[walletType]: [.../* @__PURE__ */ new Set([...(_b = this.currentWalletIds[walletType]) != null ? _b : [], walletId])]
|
|
2280
2016
|
}));
|
|
2281
2017
|
const walletNoSigner = __spreadValues({}, wallet);
|
|
2282
2018
|
delete walletNoSigner.signer;
|
|
@@ -2287,15 +2023,6 @@ const _ParaCore = class _ParaCore {
|
|
|
2287
2023
|
return [wallet, recoveryShare];
|
|
2288
2024
|
});
|
|
2289
2025
|
}
|
|
2290
|
-
/**
|
|
2291
|
-
* Creates a new pregenerated wallet.
|
|
2292
|
-
*
|
|
2293
|
-
* @param {Object} opts the options object.
|
|
2294
|
-
* @param {string} opts.pregenIdentifier the identifier associated with the new wallet.
|
|
2295
|
-
* @param {TPregenIdentifierType} [opts.pregenIdentifierType] the identifier type. Defaults to `EMAIL`.
|
|
2296
|
-
* @param {WalletType} [opts.type] the type of wallet to create. Defaults to the first non-optional type in the instance's `supportedWalletTypes` array.
|
|
2297
|
-
* @returns {Wallet} the created wallet.
|
|
2298
|
-
**/
|
|
2299
2026
|
createPregenWallet(opts) {
|
|
2300
2027
|
return __async(this, null, function* () {
|
|
2301
2028
|
return yield __privateMethod(this, _ParaCore_instances, createPregenWallet_fn).call(this, opts);
|
|
@@ -2308,18 +2035,17 @@ const _ParaCore = class _ParaCore {
|
|
|
2308
2035
|
* @param {Object} opts the options object.
|
|
2309
2036
|
* @param {string} opts.pregenIdentifier the identifier to associate each wallet with.
|
|
2310
2037
|
* @param {TPregenIdentifierType} opts.pregenIdentifierType - either `'EMAIL'` or `'PHONE'`.
|
|
2311
|
-
* @param {
|
|
2038
|
+
* @param {TWalletType[]} [opts.types] the wallet types to create. Defaults to any types the instance supports that are not already present.
|
|
2312
2039
|
* @returns {Wallet[]} an array containing the created wallets.
|
|
2313
2040
|
**/
|
|
2314
2041
|
createPregenWalletPerType(_0) {
|
|
2315
2042
|
return __async(this, arguments, function* ({
|
|
2316
2043
|
types,
|
|
2317
|
-
|
|
2318
|
-
pregenIdentifierType = "EMAIL"
|
|
2044
|
+
pregenId
|
|
2319
2045
|
}) {
|
|
2320
2046
|
const wallets = [];
|
|
2321
2047
|
for (const type of yield this.getTypesToCreate(types)) {
|
|
2322
|
-
const wallet = yield
|
|
2048
|
+
const wallet = yield this.createPregenWallet({ type, pregenId });
|
|
2323
2049
|
wallets.push(wallet);
|
|
2324
2050
|
}
|
|
2325
2051
|
return wallets;
|
|
@@ -2327,7 +2053,6 @@ const _ParaCore = class _ParaCore {
|
|
|
2327
2053
|
}
|
|
2328
2054
|
/**
|
|
2329
2055
|
* Claims a pregenerated wallet.
|
|
2330
|
-
*
|
|
2331
2056
|
* @param {Object} opts the options object.
|
|
2332
2057
|
* @param {string} opts.pregenIdentifier string the identifier of the user claiming the wallet
|
|
2333
2058
|
* @param {TPregenIdentifierType} opts.pregenIdentifierType type of the identifier of the user claiming the wallet
|
|
@@ -2335,12 +2060,11 @@ const _ParaCore = class _ParaCore {
|
|
|
2335
2060
|
**/
|
|
2336
2061
|
claimPregenWallets() {
|
|
2337
2062
|
return __async(this, arguments, function* ({
|
|
2338
|
-
|
|
2339
|
-
pregenIdentifierType = !!pregenIdentifier ? "EMAIL" : void 0
|
|
2063
|
+
pregenId
|
|
2340
2064
|
} = {}) {
|
|
2341
2065
|
var _a;
|
|
2342
2066
|
this.requireApiKey();
|
|
2343
|
-
const pregenWallets =
|
|
2067
|
+
const pregenWallets = pregenId ? yield this.getPregenWallets({ pregenId }) : yield this.getPregenWallets();
|
|
2344
2068
|
if (pregenWallets.length === 0) {
|
|
2345
2069
|
return void 0;
|
|
2346
2070
|
}
|
|
@@ -2358,7 +2082,7 @@ const _ParaCore = class _ParaCore {
|
|
|
2358
2082
|
for (const walletId of walletIds) {
|
|
2359
2083
|
const wallet = this.wallets[walletId];
|
|
2360
2084
|
let refreshedShare;
|
|
2361
|
-
if (wallet.scheme ===
|
|
2085
|
+
if (wallet.scheme === "ED25519") {
|
|
2362
2086
|
const distributeRes = yield (0, import_shareDistribution.distributeNewShare)({
|
|
2363
2087
|
ctx: this.ctx,
|
|
2364
2088
|
userId: this.userId,
|
|
@@ -2409,10 +2133,10 @@ const _ParaCore = class _ParaCore {
|
|
|
2409
2133
|
updatePregenWalletIdentifier(_0) {
|
|
2410
2134
|
return __async(this, arguments, function* ({
|
|
2411
2135
|
walletId,
|
|
2412
|
-
|
|
2413
|
-
newPregenIdentifierType
|
|
2136
|
+
newPregenId
|
|
2414
2137
|
}) {
|
|
2415
2138
|
this.requireApiKey();
|
|
2139
|
+
const [newPregenIdentifierType, newPregenIdentifier] = (0, import_user_management_client.toPregenTypeAndId)(newPregenId);
|
|
2416
2140
|
yield this.ctx.client.updatePregenWallet(walletId, {
|
|
2417
2141
|
pregenIdentifier: newPregenIdentifier,
|
|
2418
2142
|
pregenIdentifierType: newPregenIdentifierType
|
|
@@ -2434,13 +2158,13 @@ const _ParaCore = class _ParaCore {
|
|
|
2434
2158
|
* @returns {boolean} whether the pregen wallet exists
|
|
2435
2159
|
**/
|
|
2436
2160
|
hasPregenWallet(_0) {
|
|
2437
|
-
return __async(this, arguments, function* ({
|
|
2438
|
-
pregenIdentifier,
|
|
2439
|
-
pregenIdentifierType
|
|
2440
|
-
}) {
|
|
2161
|
+
return __async(this, arguments, function* ({ pregenId }) {
|
|
2441
2162
|
this.requireApiKey();
|
|
2442
|
-
const
|
|
2443
|
-
const
|
|
2163
|
+
const [pregenIdentifierType, pregenIdentifier] = (0, import_user_management_client.toPregenTypeAndId)(pregenId);
|
|
2164
|
+
const wallets = yield this.getPregenWallets({ pregenId });
|
|
2165
|
+
const wallet = wallets.find(
|
|
2166
|
+
(w) => w.pregenIdentifier === pregenIdentifier && w.pregenIdentifierType === pregenIdentifierType
|
|
2167
|
+
);
|
|
2444
2168
|
if (!wallet) {
|
|
2445
2169
|
return false;
|
|
2446
2170
|
}
|
|
@@ -2455,13 +2179,10 @@ const _ParaCore = class _ParaCore {
|
|
|
2455
2179
|
* @returns {Promise<WalletEntity[]>} the array of found wallets
|
|
2456
2180
|
**/
|
|
2457
2181
|
getPregenWallets() {
|
|
2458
|
-
return __async(this, arguments, function* ({
|
|
2459
|
-
pregenIdentifier,
|
|
2460
|
-
pregenIdentifierType = !!pregenIdentifier ? "EMAIL" : void 0
|
|
2461
|
-
} = {}) {
|
|
2182
|
+
return __async(this, arguments, function* ({ pregenId } = {}) {
|
|
2462
2183
|
this.requireApiKey();
|
|
2463
2184
|
const res = yield this.ctx.client.getPregenWallets(
|
|
2464
|
-
|
|
2185
|
+
pregenId ? (0, import_user_management_client.toPregenIds)(pregenId) : this.pregenIds,
|
|
2465
2186
|
this.isPortal(),
|
|
2466
2187
|
this.userId
|
|
2467
2188
|
);
|
|
@@ -2469,21 +2190,37 @@ const _ParaCore = class _ParaCore {
|
|
|
2469
2190
|
});
|
|
2470
2191
|
}
|
|
2471
2192
|
createGuestWallets() {
|
|
2472
|
-
return __async(this,
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
wallets
|
|
2481
|
-
(0, import_utils2.
|
|
2482
|
-
|
|
2483
|
-
|
|
2193
|
+
return __async(this, null, function* () {
|
|
2194
|
+
let error;
|
|
2195
|
+
if (__privateGet(this, _isCreateGuestWalletsPending)) {
|
|
2196
|
+
error = new Error("Guest wallets creation already in progress");
|
|
2197
|
+
(0, import_utils2.dispatchEvent)(import_types.ParaEvent.GUEST_WALLETS_CREATED, null, error.message);
|
|
2198
|
+
throw error;
|
|
2199
|
+
}
|
|
2200
|
+
if (this.isGuestMode) {
|
|
2201
|
+
error = new Error("Guest wallets already created");
|
|
2202
|
+
(0, import_utils2.dispatchEvent)(import_types.ParaEvent.GUEST_WALLETS_CREATED, null, error.message);
|
|
2203
|
+
throw error;
|
|
2204
|
+
}
|
|
2205
|
+
try {
|
|
2206
|
+
__privateSet(this, _isCreateGuestWalletsPending, true);
|
|
2207
|
+
const { supportedWalletTypes } = yield __privateMethod(this, _ParaCore_instances, assertPartner_fn).call(this);
|
|
2208
|
+
const wallets = [];
|
|
2209
|
+
const guestId = (0, import_utils2.newUuid)();
|
|
2210
|
+
for (const type of yield this.getTypesToCreate(
|
|
2211
|
+
supportedWalletTypes.filter(({ optional }) => !optional).map(({ type: type2 }) => type2)
|
|
2212
|
+
)) {
|
|
2213
|
+
const wallet = yield __privateMethod(this, _ParaCore_instances, createPregenWallet_fn).call(this, { type, pregenId: { guestId } });
|
|
2214
|
+
wallets.push(wallet);
|
|
2215
|
+
}
|
|
2216
|
+
(0, import_utils2.dispatchEvent)(import_types.ParaEvent.GUEST_WALLETS_CREATED, wallets);
|
|
2217
|
+
__privateSet(this, _isCreateGuestWalletsPending, false);
|
|
2218
|
+
return wallets;
|
|
2219
|
+
} catch (e) {
|
|
2220
|
+
(0, import_utils2.dispatchEvent)(import_types.ParaEvent.GUEST_WALLETS_CREATED, null, error == null ? void 0 : error.message);
|
|
2221
|
+
__privateSet(this, _isCreateGuestWalletsPending, false);
|
|
2222
|
+
throw error;
|
|
2484
2223
|
}
|
|
2485
|
-
yield this.setCurrentWalletIds(currentWalletIds);
|
|
2486
|
-
return wallets;
|
|
2487
2224
|
});
|
|
2488
2225
|
}
|
|
2489
2226
|
encodeWalletBase64(wallet) {
|
|
@@ -2521,9 +2258,7 @@ const _ParaCore = class _ParaCore {
|
|
|
2521
2258
|
}
|
|
2522
2259
|
getTransactionReviewUrl(transactionId, timeoutMs) {
|
|
2523
2260
|
return __async(this, null, function* () {
|
|
2524
|
-
const res = yield this.touchSession();
|
|
2525
2261
|
return this.constructPortalUrl("txReview", {
|
|
2526
|
-
partnerId: res.data.partnerId,
|
|
2527
2262
|
pathId: transactionId,
|
|
2528
2263
|
params: {
|
|
2529
2264
|
email: this.email,
|
|
@@ -2532,21 +2267,20 @@ const _ParaCore = class _ParaCore {
|
|
|
2532
2267
|
});
|
|
2533
2268
|
});
|
|
2534
2269
|
}
|
|
2535
|
-
getOnRampTransactionUrl(
|
|
2270
|
+
getOnRampTransactionUrl(_m) {
|
|
2536
2271
|
return __async(this, null, function* () {
|
|
2537
|
-
var
|
|
2272
|
+
var _n = _m, {
|
|
2538
2273
|
purchaseId,
|
|
2539
2274
|
providerKey
|
|
2540
|
-
} =
|
|
2275
|
+
} = _n, walletParams = __objRest(_n, [
|
|
2541
2276
|
"purchaseId",
|
|
2542
2277
|
"providerKey"
|
|
2543
2278
|
]);
|
|
2544
|
-
const
|
|
2279
|
+
const { sessionId } = yield this.touchSession();
|
|
2545
2280
|
const [key, identifier] = (0, import_user_management_client.extractWalletRef)(walletParams);
|
|
2546
2281
|
return this.constructPortalUrl("onRamp", {
|
|
2547
|
-
partnerId: res.data.partnerId,
|
|
2548
2282
|
pathId: purchaseId,
|
|
2549
|
-
sessionId
|
|
2283
|
+
sessionId,
|
|
2550
2284
|
params: {
|
|
2551
2285
|
[key]: identifier,
|
|
2552
2286
|
providerKey,
|
|
@@ -2571,7 +2305,10 @@ const _ParaCore = class _ParaCore {
|
|
|
2571
2305
|
walletId,
|
|
2572
2306
|
messageBase64,
|
|
2573
2307
|
timeoutMs = 3e4,
|
|
2574
|
-
cosmosSignDocBase64
|
|
2308
|
+
cosmosSignDocBase64,
|
|
2309
|
+
isCanceled = () => false,
|
|
2310
|
+
onCancel,
|
|
2311
|
+
onPoll
|
|
2575
2312
|
}) {
|
|
2576
2313
|
this.assertIsValidWalletId(walletId);
|
|
2577
2314
|
const wallet = this.wallets[walletId];
|
|
@@ -2590,11 +2327,12 @@ const _ParaCore = class _ParaCore {
|
|
|
2590
2327
|
(0, import_utils2.dispatchEvent)(import_types.ParaEvent.SIGN_MESSAGE_EVENT, signRes);
|
|
2591
2328
|
return signRes;
|
|
2592
2329
|
}
|
|
2593
|
-
yield new Promise((resolve) => setTimeout(resolve, constants.POLLING_INTERVAL_MS));
|
|
2594
2330
|
while (true) {
|
|
2595
|
-
if (Date.now() - timeStart > timeoutMs) {
|
|
2331
|
+
if (isCanceled() || Date.now() - timeStart > timeoutMs) {
|
|
2332
|
+
onCancel == null ? void 0 : onCancel();
|
|
2596
2333
|
break;
|
|
2597
2334
|
}
|
|
2335
|
+
yield new Promise((resolve) => setTimeout(resolve, constants.POLLING_INTERVAL_MS));
|
|
2598
2336
|
try {
|
|
2599
2337
|
yield this.ctx.client.getPendingTransaction(this.userId, signRes.pendingTransactionId);
|
|
2600
2338
|
} catch (err) {
|
|
@@ -2604,7 +2342,8 @@ const _ParaCore = class _ParaCore {
|
|
|
2604
2342
|
}
|
|
2605
2343
|
signRes = yield this.signMessageInner({ wallet, signerId, messageBase64, cosmosSignDocBase64 });
|
|
2606
2344
|
if (signRes.pendingTransactionId) {
|
|
2607
|
-
|
|
2345
|
+
onPoll == null ? void 0 : onPoll();
|
|
2346
|
+
continue;
|
|
2608
2347
|
} else {
|
|
2609
2348
|
break;
|
|
2610
2349
|
}
|
|
@@ -2630,7 +2369,7 @@ const _ParaCore = class _ParaCore {
|
|
|
2630
2369
|
}) {
|
|
2631
2370
|
let signRes;
|
|
2632
2371
|
switch (wallet.scheme) {
|
|
2633
|
-
case
|
|
2372
|
+
case "ED25519":
|
|
2634
2373
|
signRes = yield this.platformUtils.ed25519Sign(
|
|
2635
2374
|
this.ctx,
|
|
2636
2375
|
signerId,
|
|
@@ -2648,7 +2387,7 @@ const _ParaCore = class _ParaCore {
|
|
|
2648
2387
|
wallet.signer,
|
|
2649
2388
|
messageBase64,
|
|
2650
2389
|
this.retrieveSessionCookie(),
|
|
2651
|
-
wallet.scheme ===
|
|
2390
|
+
wallet.scheme === "DKLS",
|
|
2652
2391
|
cosmosSignDocBase64
|
|
2653
2392
|
);
|
|
2654
2393
|
break;
|
|
@@ -2669,7 +2408,10 @@ const _ParaCore = class _ParaCore {
|
|
|
2669
2408
|
walletId,
|
|
2670
2409
|
rlpEncodedTxBase64,
|
|
2671
2410
|
chainId,
|
|
2672
|
-
timeoutMs = 3e4
|
|
2411
|
+
timeoutMs = 3e4,
|
|
2412
|
+
isCanceled = () => false,
|
|
2413
|
+
onCancel,
|
|
2414
|
+
onPoll
|
|
2673
2415
|
}) {
|
|
2674
2416
|
this.assertIsValidWalletId(walletId);
|
|
2675
2417
|
const wallet = this.wallets[walletId];
|
|
@@ -2685,7 +2427,7 @@ const _ParaCore = class _ParaCore {
|
|
|
2685
2427
|
rlpEncodedTxBase64,
|
|
2686
2428
|
chainId,
|
|
2687
2429
|
this.retrieveSessionCookie(),
|
|
2688
|
-
wallet.scheme ===
|
|
2430
|
+
wallet.scheme === "DKLS"
|
|
2689
2431
|
);
|
|
2690
2432
|
let timeStart = Date.now();
|
|
2691
2433
|
if (signRes.pendingTransactionId) {
|
|
@@ -2697,11 +2439,12 @@ const _ParaCore = class _ParaCore {
|
|
|
2697
2439
|
(0, import_utils2.dispatchEvent)(import_types.ParaEvent.SIGN_TRANSACTION_EVENT, signRes);
|
|
2698
2440
|
return signRes;
|
|
2699
2441
|
}
|
|
2700
|
-
yield new Promise((resolve) => setTimeout(resolve, constants.POLLING_INTERVAL_MS));
|
|
2701
2442
|
while (true) {
|
|
2702
|
-
if (Date.now() - timeStart > timeoutMs) {
|
|
2443
|
+
if (isCanceled() || Date.now() - timeStart > timeoutMs) {
|
|
2444
|
+
onCancel == null ? void 0 : onCancel();
|
|
2703
2445
|
break;
|
|
2704
2446
|
}
|
|
2447
|
+
yield new Promise((resolve) => setTimeout(resolve, constants.POLLING_INTERVAL_MS));
|
|
2705
2448
|
try {
|
|
2706
2449
|
yield this.ctx.client.getPendingTransaction(this.userId, signRes.pendingTransactionId);
|
|
2707
2450
|
} catch (err) {
|
|
@@ -2717,10 +2460,11 @@ const _ParaCore = class _ParaCore {
|
|
|
2717
2460
|
rlpEncodedTxBase64,
|
|
2718
2461
|
chainId,
|
|
2719
2462
|
this.retrieveSessionCookie(),
|
|
2720
|
-
wallet.scheme ===
|
|
2463
|
+
wallet.scheme === "DKLS"
|
|
2721
2464
|
);
|
|
2722
2465
|
if (signRes.pendingTransactionId) {
|
|
2723
|
-
|
|
2466
|
+
onPoll == null ? void 0 : onPoll();
|
|
2467
|
+
continue;
|
|
2724
2468
|
} else {
|
|
2725
2469
|
break;
|
|
2726
2470
|
}
|
|
@@ -2737,44 +2481,6 @@ const _ParaCore = class _ParaCore {
|
|
|
2737
2481
|
return signRes;
|
|
2738
2482
|
});
|
|
2739
2483
|
}
|
|
2740
|
-
/**
|
|
2741
|
-
* @deprecated
|
|
2742
|
-
* Sends a transaction.
|
|
2743
|
-
* @param walletId - id of the wallet to send the transaction from.
|
|
2744
|
-
* @param rlpEncodedTxBase64 - rlp encoded tx as base64 string
|
|
2745
|
-
* @param chainId - chain id of the chain the transaction is being sent on.
|
|
2746
|
-
**/
|
|
2747
|
-
sendTransaction(_0) {
|
|
2748
|
-
return __async(this, arguments, function* ({
|
|
2749
|
-
walletId,
|
|
2750
|
-
rlpEncodedTxBase64,
|
|
2751
|
-
chainId
|
|
2752
|
-
}) {
|
|
2753
|
-
this.assertIsValidWalletId(walletId);
|
|
2754
|
-
const wallet = this.wallets[walletId];
|
|
2755
|
-
const signRes = yield this.platformUtils.sendTransaction(
|
|
2756
|
-
this.ctx,
|
|
2757
|
-
this.userId,
|
|
2758
|
-
walletId,
|
|
2759
|
-
this.wallets[walletId].signer,
|
|
2760
|
-
rlpEncodedTxBase64,
|
|
2761
|
-
chainId,
|
|
2762
|
-
this.retrieveSessionCookie(),
|
|
2763
|
-
wallet.scheme === import_user_management_client.WalletScheme.DKLS
|
|
2764
|
-
);
|
|
2765
|
-
if (signRes.pendingTransactionId) {
|
|
2766
|
-
this.platformUtils.openPopup(
|
|
2767
|
-
yield this.getTransactionReviewUrl(signRes.pendingTransactionId),
|
|
2768
|
-
{ type: import_types.PopupType.SIGN_TRANSACTION_REVIEW }
|
|
2769
|
-
);
|
|
2770
|
-
const error = new import_errors.TransactionReviewError(
|
|
2771
|
-
yield this.getTransactionReviewUrl(signRes.pendingTransactionId)
|
|
2772
|
-
);
|
|
2773
|
-
throw error;
|
|
2774
|
-
}
|
|
2775
|
-
return signRes;
|
|
2776
|
-
});
|
|
2777
|
-
}
|
|
2778
2484
|
isProviderModalDisabled() {
|
|
2779
2485
|
return !!this.disableProviderModal;
|
|
2780
2486
|
}
|
|
@@ -2824,17 +2530,13 @@ const _ParaCore = class _ParaCore {
|
|
|
2824
2530
|
* @param {boolean} excludeSigners - whether or not to exclude the signer from the exported wallets.
|
|
2825
2531
|
* @returns {string} the serialized session
|
|
2826
2532
|
*/
|
|
2827
|
-
exportSession({ excludeSigners } = {}) {
|
|
2533
|
+
exportSession({ excludeSigners = false } = {}) {
|
|
2828
2534
|
const sessionInfo = {
|
|
2829
|
-
|
|
2535
|
+
authInfo: __privateGet(this, _authInfo),
|
|
2830
2536
|
userId: this.userId,
|
|
2831
2537
|
wallets: structuredClone(this.wallets),
|
|
2832
2538
|
currentWalletIds: this.currentWalletIds,
|
|
2833
|
-
sessionCookie: this.
|
|
2834
|
-
phone: this.phone,
|
|
2835
|
-
countryCode: this.countryCode,
|
|
2836
|
-
telegramUserId: this.telegramUserId,
|
|
2837
|
-
farcasterUsername: this.farcasterUsername,
|
|
2539
|
+
sessionCookie: this.retrieveSessionCookie(),
|
|
2838
2540
|
externalWallets: this.externalWallets
|
|
2839
2541
|
};
|
|
2840
2542
|
if (excludeSigners) {
|
|
@@ -2850,12 +2552,11 @@ const _ParaCore = class _ParaCore {
|
|
|
2850
2552
|
*/
|
|
2851
2553
|
importSession(serializedInstanceBase64) {
|
|
2852
2554
|
return __async(this, null, function* () {
|
|
2853
|
-
var _a;
|
|
2555
|
+
var _a, _b;
|
|
2854
2556
|
const serializedInstance = Buffer.from(serializedInstanceBase64, "base64").toString("utf8");
|
|
2855
|
-
const sessionInfo =
|
|
2856
|
-
|
|
2857
|
-
yield this.
|
|
2858
|
-
yield this.setFarcasterUsername(sessionInfo.farcasterUsername);
|
|
2557
|
+
const sessionInfo = (0, import_utils2.jsonParse)(serializedInstance);
|
|
2558
|
+
const authInfo = (_a = sessionInfo.authInfo) != null ? _a : __privateMethod(this, _ParaCore_instances, toAuthInfo_fn).call(this, sessionInfo);
|
|
2559
|
+
yield __privateMethod(this, _ParaCore_instances, setAuthInfo_fn).call(this, authInfo);
|
|
2859
2560
|
yield this.setUserId(sessionInfo.userId);
|
|
2860
2561
|
yield this.setWallets(sessionInfo.wallets);
|
|
2861
2562
|
yield this.setExternalWallets(sessionInfo.externalWallets || {});
|
|
@@ -2870,42 +2571,23 @@ const _ParaCore = class _ParaCore {
|
|
|
2870
2571
|
const currentWalletIds = {};
|
|
2871
2572
|
for (const walletId of Object.keys(sessionInfo.wallets)) {
|
|
2872
2573
|
currentWalletIds[sessionInfo.wallets[walletId].type] = [
|
|
2873
|
-
...(
|
|
2574
|
+
...(_b = currentWalletIds[sessionInfo.wallets[walletId].type]) != null ? _b : [],
|
|
2874
2575
|
walletId
|
|
2875
2576
|
];
|
|
2876
2577
|
}
|
|
2877
2578
|
yield this.setCurrentWalletIds(currentWalletIds);
|
|
2878
2579
|
}
|
|
2879
2580
|
this.persistSessionCookie(sessionInfo.sessionCookie);
|
|
2880
|
-
yield this.setPhoneNumber(sessionInfo.phone, sessionInfo.countryCode);
|
|
2881
2581
|
});
|
|
2882
2582
|
}
|
|
2883
|
-
exitAccountCreation() {
|
|
2884
|
-
this.isAwaitingAccountCreation = false;
|
|
2885
|
-
}
|
|
2886
|
-
exitLogin() {
|
|
2887
|
-
this.isAwaitingLogin = false;
|
|
2888
|
-
}
|
|
2889
|
-
exitFarcaster() {
|
|
2890
|
-
this.isAwaitingFarcaster = false;
|
|
2891
|
-
}
|
|
2892
|
-
exitOAuth() {
|
|
2893
|
-
this.isAwaitingOAuth = false;
|
|
2894
|
-
}
|
|
2895
|
-
exitLoops() {
|
|
2896
|
-
this.exitAccountCreation();
|
|
2897
|
-
this.exitLogin();
|
|
2898
|
-
this.exitFarcaster();
|
|
2899
|
-
this.exitOAuth();
|
|
2900
|
-
}
|
|
2901
2583
|
/**
|
|
2902
2584
|
* Retrieves a token to verify the current session.
|
|
2903
2585
|
* @returns {Promise<string>} the ID
|
|
2904
2586
|
**/
|
|
2905
2587
|
getVerificationToken() {
|
|
2906
2588
|
return __async(this, null, function* () {
|
|
2907
|
-
const {
|
|
2908
|
-
return
|
|
2589
|
+
const { sessionLookupId } = yield this.touchSession();
|
|
2590
|
+
return sessionLookupId;
|
|
2909
2591
|
});
|
|
2910
2592
|
}
|
|
2911
2593
|
/**
|
|
@@ -2930,22 +2612,18 @@ const _ParaCore = class _ParaCore {
|
|
|
2930
2612
|
this.currentWalletIds = {};
|
|
2931
2613
|
this.externalWallets = {};
|
|
2932
2614
|
this.loginEncryptionKeyPair = void 0;
|
|
2933
|
-
this
|
|
2934
|
-
this.telegramUserId = void 0;
|
|
2935
|
-
this.phone = void 0;
|
|
2936
|
-
this.countryCode = void 0;
|
|
2615
|
+
__privateSet(this, _authInfo, void 0);
|
|
2937
2616
|
this.userId = void 0;
|
|
2938
2617
|
this.sessionCookie = void 0;
|
|
2939
2618
|
(0, import_utils2.dispatchEvent)(import_types.ParaEvent.LOGOUT_EVENT, null);
|
|
2940
2619
|
});
|
|
2941
2620
|
}
|
|
2621
|
+
/** @deprecated */
|
|
2942
2622
|
getSupportedCreateAuthMethods() {
|
|
2943
2623
|
return __async(this, null, function* () {
|
|
2944
|
-
const
|
|
2945
|
-
const partnerId = res.data.partnerId;
|
|
2946
|
-
const partnerRes = yield this.ctx.client.getPartner(partnerId);
|
|
2624
|
+
const partner = yield __privateMethod(this, _ParaCore_instances, assertPartner_fn).call(this);
|
|
2947
2625
|
let supportedAuthMethods = /* @__PURE__ */ new Set();
|
|
2948
|
-
for (const authMethod of
|
|
2626
|
+
for (const authMethod of partner.supportedAuthMethods) {
|
|
2949
2627
|
supportedAuthMethods.add(import_user_management_client.AuthMethod[authMethod]);
|
|
2950
2628
|
}
|
|
2951
2629
|
return supportedAuthMethods;
|
|
@@ -2957,6 +2635,7 @@ const _ParaCore = class _ParaCore {
|
|
|
2957
2635
|
* Doesn't work for all types of logging.
|
|
2958
2636
|
**/
|
|
2959
2637
|
toString() {
|
|
2638
|
+
var _a, _b, _c;
|
|
2960
2639
|
const redactedWallets = Object.keys(this.wallets).reduce(
|
|
2961
2640
|
(acc, walletId) => __spreadProps(__spreadValues({}, acc), {
|
|
2962
2641
|
[walletId]: __spreadProps(__spreadValues({}, this.wallets[walletId]), {
|
|
@@ -2974,16 +2653,15 @@ const _ParaCore = class _ParaCore {
|
|
|
2974
2653
|
{}
|
|
2975
2654
|
);
|
|
2976
2655
|
const obj = {
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
telegramUserId: this.telegramUserId,
|
|
2983
|
-
farcasterUsername: this.farcasterUsername,
|
|
2656
|
+
partnerId: (_a = __privateGet(this, _partner)) == null ? void 0 : _a.id,
|
|
2657
|
+
supportedWalletTypes: (_b = __privateGet(this, _partner)) == null ? void 0 : _b.supportedWalletTypes,
|
|
2658
|
+
cosmosPrefix: (_c = __privateGet(this, _partner)) == null ? void 0 : _c.cosmosPrefix,
|
|
2659
|
+
authInfo: __privateGet(this, _authInfo),
|
|
2660
|
+
isGuestMode: this.isGuestMode,
|
|
2984
2661
|
userId: this.userId,
|
|
2985
2662
|
pregenIds: this.pregenIds,
|
|
2986
2663
|
currentWalletIds: this.currentWalletIds,
|
|
2664
|
+
guestWalletIds: __privateGet(this, _ParaCore_instances, guestWalletIds_get),
|
|
2987
2665
|
wallets: redactedWallets,
|
|
2988
2666
|
externalWallets: redactedExternalWallets,
|
|
2989
2667
|
loginEncryptionKeyPair: this.loginEncryptionKeyPair ? "[REDACTED]" : void 0,
|
|
@@ -3000,25 +2678,201 @@ const _ParaCore = class _ParaCore {
|
|
|
3000
2678
|
};
|
|
3001
2679
|
return `Para ${JSON.stringify(obj, null, 2)}`;
|
|
3002
2680
|
}
|
|
2681
|
+
getNewCredentialAndUrl() {
|
|
2682
|
+
return __async(this, arguments, function* ({
|
|
2683
|
+
authMethod = "PASSKEY",
|
|
2684
|
+
isForNewDevice = false,
|
|
2685
|
+
portalTheme,
|
|
2686
|
+
shorten = false
|
|
2687
|
+
} = {}) {
|
|
2688
|
+
this.assertIsAuthSet();
|
|
2689
|
+
let credentialId, urlType;
|
|
2690
|
+
switch (authMethod) {
|
|
2691
|
+
case "PASSKEY":
|
|
2692
|
+
({
|
|
2693
|
+
data: { id: credentialId }
|
|
2694
|
+
} = yield this.ctx.client.addSessionPublicKey(this.userId, {
|
|
2695
|
+
status: import_user_management_client.PublicKeyStatus.PENDING,
|
|
2696
|
+
type: import_user_management_client.PublicKeyType.WEB
|
|
2697
|
+
}));
|
|
2698
|
+
urlType = "createAuth";
|
|
2699
|
+
break;
|
|
2700
|
+
case "PASSWORD":
|
|
2701
|
+
({
|
|
2702
|
+
data: { id: credentialId }
|
|
2703
|
+
} = yield this.ctx.client.addSessionPasswordPublicKey(this.userId, {
|
|
2704
|
+
status: import_user_management_client.PasswordStatus.PENDING
|
|
2705
|
+
}));
|
|
2706
|
+
urlType = "createPassword";
|
|
2707
|
+
break;
|
|
2708
|
+
}
|
|
2709
|
+
const url = this.isNativePasskey && urlType === "createAuth" ? void 0 : yield this.constructPortalUrl(urlType, {
|
|
2710
|
+
isForNewDevice,
|
|
2711
|
+
pathId: credentialId,
|
|
2712
|
+
portalTheme,
|
|
2713
|
+
shorten
|
|
2714
|
+
});
|
|
2715
|
+
return __spreadValues({ credentialId }, url ? { url } : {});
|
|
2716
|
+
});
|
|
2717
|
+
}
|
|
2718
|
+
/**
|
|
2719
|
+
* Returns a Para Portal URL for logging in with a WebAuth passkey or a password.
|
|
2720
|
+
* @param {Object} opts the options object
|
|
2721
|
+
* @param {String} opts.auth - the user auth to sign up or log in with, in the form ` { email: string } | { phone: `+${number}` } `
|
|
2722
|
+
* @param {boolean} opts.useShortUrls - whether to shorten the generated portal URLs
|
|
2723
|
+
* @param {Theme} opts.portalTheme the Para Portal theme to apply to the password creation URL, if other than the default theme
|
|
2724
|
+
* @returns {SignUpOrLogInResponse} an object in the form of either: `{ stage: 'verify' }` or `{ stage: 'login'; passkeyUrl?: string; passwordUrl?: string; biometricHints?: BiometricLocationHint[] }`
|
|
2725
|
+
*/
|
|
2726
|
+
getLoginUrl(_0) {
|
|
2727
|
+
return __async(this, arguments, function* ({
|
|
2728
|
+
authMethod = "PASSKEY",
|
|
2729
|
+
shorten = false,
|
|
2730
|
+
portalTheme,
|
|
2731
|
+
sessionId
|
|
2732
|
+
}) {
|
|
2733
|
+
if (!sessionId) {
|
|
2734
|
+
sessionId = (yield this.touchSession()).sessionLookupId;
|
|
2735
|
+
}
|
|
2736
|
+
this.assertIsAuthSet();
|
|
2737
|
+
let urlType;
|
|
2738
|
+
switch (authMethod) {
|
|
2739
|
+
case "PASSKEY":
|
|
2740
|
+
urlType = "loginAuth";
|
|
2741
|
+
break;
|
|
2742
|
+
case "PASSWORD":
|
|
2743
|
+
urlType = "loginPassword";
|
|
2744
|
+
break;
|
|
2745
|
+
default:
|
|
2746
|
+
throw new Error(`invalid authentication method: '${authMethod}'`);
|
|
2747
|
+
}
|
|
2748
|
+
return this.constructPortalUrl(urlType, {
|
|
2749
|
+
sessionId,
|
|
2750
|
+
shorten,
|
|
2751
|
+
portalTheme
|
|
2752
|
+
});
|
|
2753
|
+
});
|
|
2754
|
+
}
|
|
2755
|
+
signUpOrLogIn(_o) {
|
|
2756
|
+
return __async(this, null, function* () {
|
|
2757
|
+
var _p = _o, { auth } = _p, urlOptions = __objRest(_p, ["auth"]);
|
|
2758
|
+
const serverAuthState = yield this.ctx.client.signUpOrLogIn(__spreadValues(__spreadValues({}, auth), this.getVerificationEmailProps()));
|
|
2759
|
+
return __privateMethod(this, _ParaCore_instances, prepareAuthState_fn).call(this, serverAuthState, urlOptions);
|
|
2760
|
+
});
|
|
2761
|
+
}
|
|
2762
|
+
verifyNewAccount(_q) {
|
|
2763
|
+
return __async(this, null, function* () {
|
|
2764
|
+
var _r = _q, {
|
|
2765
|
+
verificationCode
|
|
2766
|
+
} = _r, urlOptions = __objRest(_r, [
|
|
2767
|
+
"verificationCode"
|
|
2768
|
+
]);
|
|
2769
|
+
this.assertIsAuthSet(["email", "phone"]);
|
|
2770
|
+
const userId = this.assertUserId();
|
|
2771
|
+
const serverAuthState = yield this.ctx.client.verifyNewAccount(userId, {
|
|
2772
|
+
verificationCode
|
|
2773
|
+
});
|
|
2774
|
+
return __privateMethod(this, _ParaCore_instances, prepareAuthState_fn).call(this, serverAuthState, urlOptions);
|
|
2775
|
+
});
|
|
2776
|
+
}
|
|
3003
2777
|
};
|
|
3004
|
-
|
|
3005
|
-
|
|
2778
|
+
_authInfo = new WeakMap();
|
|
2779
|
+
_partner = new WeakMap();
|
|
3006
2780
|
_ParaCore_instances = new WeakSet();
|
|
2781
|
+
assertPartner_fn = function() {
|
|
2782
|
+
return __async(this, null, function* () {
|
|
2783
|
+
var _a, _b;
|
|
2784
|
+
if (!__privateGet(this, _partner)) {
|
|
2785
|
+
yield this.touchSession();
|
|
2786
|
+
}
|
|
2787
|
+
if (((_a = __privateGet(this, _partner)) == null ? void 0 : _a.cosmosPrefix) && this.ctx.cosmosPrefix !== __privateGet(this, _partner).cosmosPrefix) {
|
|
2788
|
+
this.ctx.cosmosPrefix = (_b = __privateGet(this, _partner)) == null ? void 0 : _b.cosmosPrefix;
|
|
2789
|
+
}
|
|
2790
|
+
return __privateGet(this, _partner);
|
|
2791
|
+
});
|
|
2792
|
+
};
|
|
2793
|
+
guestWalletIds_get = function() {
|
|
2794
|
+
var _a, _b, _c;
|
|
2795
|
+
if (!((_a = __privateGet(this, _partner)) == null ? void 0 : _a.supportedWalletTypes)) {
|
|
2796
|
+
return {};
|
|
2797
|
+
}
|
|
2798
|
+
const guestId = (_c = (_b = this.pregenIds) == null ? void 0 : _b.GUEST_ID) == null ? void 0 : _c[0];
|
|
2799
|
+
return !!guestId ? Object.entries(this.wallets).reduce((acc, [id, wallet]) => {
|
|
2800
|
+
if (wallet.isPregen && !wallet.userId && wallet.pregenIdentifierType === "GUEST_ID" && wallet.pregenIdentifier === guestId) {
|
|
2801
|
+
return __spreadValues(__spreadValues({}, acc), (0, import_utils2.getEquivalentTypes)(wallet.type).filter((type) => __privateGet(this, _partner).supportedWalletTypes.some((entry) => entry.type === type)).reduce((acc2, eqType) => {
|
|
2802
|
+
var _a2;
|
|
2803
|
+
return __spreadProps(__spreadValues({}, acc2), { [eqType]: [.../* @__PURE__ */ new Set([...(_a2 = acc2[eqType]) != null ? _a2 : [], id])] });
|
|
2804
|
+
}, {}));
|
|
2805
|
+
}
|
|
2806
|
+
return acc;
|
|
2807
|
+
}, {}) : {};
|
|
2808
|
+
};
|
|
2809
|
+
guestWalletIdsArray_get = function() {
|
|
2810
|
+
return Object.entries(__privateGet(this, _ParaCore_instances, guestWalletIds_get)).reduce((acc, [type, ids]) => {
|
|
2811
|
+
return [...acc, ...ids.map((id) => [id, type])];
|
|
2812
|
+
}, []);
|
|
2813
|
+
};
|
|
2814
|
+
toAuthInfo_fn = function({
|
|
2815
|
+
email,
|
|
2816
|
+
phone,
|
|
2817
|
+
countryCode,
|
|
2818
|
+
farcasterUsername,
|
|
2819
|
+
telegramUserId,
|
|
2820
|
+
externalWalletAddress
|
|
2821
|
+
}) {
|
|
2822
|
+
let auth;
|
|
2823
|
+
switch (true) {
|
|
2824
|
+
case !!email:
|
|
2825
|
+
auth = { email };
|
|
2826
|
+
break;
|
|
2827
|
+
case !!phone:
|
|
2828
|
+
{
|
|
2829
|
+
const validPhone = (0, import_utils2.formatPhoneNumber)(phone, countryCode);
|
|
2830
|
+
if (validPhone) auth = { phone: (0, import_utils2.formatPhoneNumber)(phone, countryCode) };
|
|
2831
|
+
}
|
|
2832
|
+
break;
|
|
2833
|
+
case !!farcasterUsername:
|
|
2834
|
+
auth = { farcasterUsername };
|
|
2835
|
+
break;
|
|
2836
|
+
case !!telegramUserId:
|
|
2837
|
+
auth = { telegramUserId };
|
|
2838
|
+
break;
|
|
2839
|
+
case !!externalWalletAddress:
|
|
2840
|
+
auth = { externalWalletAddress };
|
|
2841
|
+
break;
|
|
2842
|
+
}
|
|
2843
|
+
return (0, import_user_management_client.extractAuthInfo)(auth);
|
|
2844
|
+
};
|
|
2845
|
+
setAuthInfo_fn = function(authInfo) {
|
|
2846
|
+
return __async(this, null, function* () {
|
|
2847
|
+
__privateSet(this, _authInfo, authInfo);
|
|
2848
|
+
yield this.localStorageSetItem(constants.LOCAL_STORAGE_AUTH_INFO, JSON.stringify(authInfo));
|
|
2849
|
+
yield this.localStorageRemoveItem(constants.LOCAL_STORAGE_EMAIL);
|
|
2850
|
+
yield this.localStorageRemoveItem(constants.LOCAL_STORAGE_PHONE);
|
|
2851
|
+
yield this.localStorageRemoveItem(constants.LOCAL_STORAGE_COUNTRY_CODE);
|
|
2852
|
+
yield this.localStorageRemoveItem(constants.LOCAL_STORAGE_FARCASTER_USERNAME);
|
|
2853
|
+
yield this.localStorageRemoveItem(constants.LOCAL_STORAGE_TELEGRAM_USER_ID);
|
|
2854
|
+
});
|
|
2855
|
+
};
|
|
2856
|
+
getPartner_fn = function(partnerId) {
|
|
2857
|
+
return __async(this, null, function* () {
|
|
2858
|
+
const res = yield this.ctx.client.getPartner(partnerId);
|
|
2859
|
+
__privateSet(this, _partner, res.data.partner);
|
|
2860
|
+
return __privateGet(this, _partner);
|
|
2861
|
+
});
|
|
2862
|
+
};
|
|
3007
2863
|
createPregenWallet_fn = function(opts) {
|
|
3008
2864
|
return __async(this, null, function* () {
|
|
3009
2865
|
var _a, _b;
|
|
3010
|
-
const {
|
|
3011
|
-
|
|
3012
|
-
pregenIdentifier,
|
|
3013
|
-
pregenIdentifierType = "EMAIL"
|
|
3014
|
-
} = opts;
|
|
2866
|
+
const { supportedWalletTypes } = yield __privateMethod(this, _ParaCore_instances, assertPartner_fn).call(this);
|
|
2867
|
+
const { type: _type = (_a = supportedWalletTypes.find(({ optional }) => !optional)) == null ? void 0 : _a.type, pregenId } = opts;
|
|
3015
2868
|
this.requireApiKey();
|
|
3016
2869
|
const walletType = yield this.assertIsValidWalletType(
|
|
3017
|
-
_type != null ? _type : (_b =
|
|
2870
|
+
_type != null ? _type : (_b = supportedWalletTypes.find(({ optional }) => !optional)) == null ? void 0 : _b.type
|
|
3018
2871
|
);
|
|
2872
|
+
const [pregenIdentifierType, pregenIdentifier] = (0, import_user_management_client.toPregenTypeAndId)(pregenId);
|
|
3019
2873
|
let keygenRes;
|
|
3020
2874
|
switch (walletType) {
|
|
3021
|
-
case
|
|
2875
|
+
case "SOLANA":
|
|
3022
2876
|
keygenRes = yield this.platformUtils.ed25519PreKeygen(
|
|
3023
2877
|
this.ctx,
|
|
3024
2878
|
pregenIdentifier,
|
|
@@ -3042,7 +2896,7 @@ createPregenWallet_fn = function(opts) {
|
|
|
3042
2896
|
this.wallets[walletId] = {
|
|
3043
2897
|
id: walletId,
|
|
3044
2898
|
signer,
|
|
3045
|
-
scheme: walletType ===
|
|
2899
|
+
scheme: walletType === "SOLANA" ? "ED25519" : "DKLS",
|
|
3046
2900
|
type: walletType,
|
|
3047
2901
|
isPregen: true,
|
|
3048
2902
|
pregenIdentifier,
|
|
@@ -3053,6 +2907,114 @@ createPregenWallet_fn = function(opts) {
|
|
|
3053
2907
|
return this.wallets[walletId];
|
|
3054
2908
|
});
|
|
3055
2909
|
};
|
|
2910
|
+
_isCreateGuestWalletsPending = new WeakMap();
|
|
2911
|
+
prepareAuthState_fn = function(_0) {
|
|
2912
|
+
return __async(this, arguments, function* (serverAuthState, opts = {}) {
|
|
2913
|
+
if (!opts.sessionLookupId && serverAuthState.stage === "login") {
|
|
2914
|
+
opts.sessionLookupId = yield __privateMethod(this, _ParaCore_instances, prepareLogin_fn).call(this);
|
|
2915
|
+
}
|
|
2916
|
+
const { auth, externalWallet, userId, displayName, pfpUrl, username } = serverAuthState;
|
|
2917
|
+
const authInfo = __spreadValues(__spreadValues({}, (0, import_user_management_client.extractAuthInfo)(auth, { isRequired: true })), Object.fromEntries(
|
|
2918
|
+
Object.entries({
|
|
2919
|
+
displayName,
|
|
2920
|
+
pfpUrl,
|
|
2921
|
+
username,
|
|
2922
|
+
externalWallet
|
|
2923
|
+
}).filter(([_, v]) => !!v)
|
|
2924
|
+
));
|
|
2925
|
+
yield __privateMethod(this, _ParaCore_instances, setAuthInfo_fn).call(this, authInfo);
|
|
2926
|
+
yield this.assertIsAuthSet();
|
|
2927
|
+
if (!!externalWallet) {
|
|
2928
|
+
yield this.setExternalWallet(externalWallet);
|
|
2929
|
+
}
|
|
2930
|
+
if (!!userId) {
|
|
2931
|
+
yield this.setUserId(userId);
|
|
2932
|
+
}
|
|
2933
|
+
let authState;
|
|
2934
|
+
switch (serverAuthState.stage) {
|
|
2935
|
+
case "verify":
|
|
2936
|
+
authState = serverAuthState;
|
|
2937
|
+
break;
|
|
2938
|
+
case "login":
|
|
2939
|
+
authState = yield __privateMethod(this, _ParaCore_instances, prepareLoginState_fn).call(this, serverAuthState, __spreadProps(__spreadValues({}, opts), { sessionLookupId: opts.sessionLookupId }));
|
|
2940
|
+
break;
|
|
2941
|
+
case "signup":
|
|
2942
|
+
authState = yield __privateMethod(this, _ParaCore_instances, prepareSignUpState_fn).call(this, serverAuthState, opts);
|
|
2943
|
+
break;
|
|
2944
|
+
}
|
|
2945
|
+
return authState;
|
|
2946
|
+
});
|
|
2947
|
+
};
|
|
2948
|
+
prepareLogin_fn = function() {
|
|
2949
|
+
return __async(this, null, function* () {
|
|
2950
|
+
yield this.logout();
|
|
2951
|
+
const { sessionLookupId } = yield this.touchSession(true);
|
|
2952
|
+
if (!this.loginEncryptionKeyPair) {
|
|
2953
|
+
yield this.setLoginEncryptionKeyPair();
|
|
2954
|
+
}
|
|
2955
|
+
return sessionLookupId;
|
|
2956
|
+
});
|
|
2957
|
+
};
|
|
2958
|
+
prepareLoginState_fn = function(_0, _1) {
|
|
2959
|
+
return __async(this, arguments, function* (loginState, {
|
|
2960
|
+
useShortUrls: shorten = false,
|
|
2961
|
+
portalTheme,
|
|
2962
|
+
sessionLookupId
|
|
2963
|
+
}) {
|
|
2964
|
+
const _a = loginState, { loginAuthMethods } = _a, authState = __objRest(_a, ["loginAuthMethods"]);
|
|
2965
|
+
return __spreadValues(__spreadValues(__spreadValues({}, authState), !this.isNativePasskey && loginAuthMethods.includes(import_user_management_client.AuthMethod.PASSKEY) ? {
|
|
2966
|
+
passkeyUrl: yield this.getLoginUrl({ sessionId: sessionLookupId, shorten, portalTheme }),
|
|
2967
|
+
passkeyKnownDeviceUrl: yield this.constructPortalUrl("loginAuth", {
|
|
2968
|
+
sessionId: sessionLookupId,
|
|
2969
|
+
newDevice: {
|
|
2970
|
+
sessionId: sessionLookupId,
|
|
2971
|
+
encryptionKey: (0, import_utils.getPublicKeyHex)(this.loginEncryptionKeyPair)
|
|
2972
|
+
},
|
|
2973
|
+
shorten,
|
|
2974
|
+
portalTheme
|
|
2975
|
+
})
|
|
2976
|
+
} : {}), loginAuthMethods.includes(import_user_management_client.AuthMethod.PASSWORD) ? {
|
|
2977
|
+
passwordUrl: yield this.constructPortalUrl("loginPassword", {
|
|
2978
|
+
sessionId: sessionLookupId,
|
|
2979
|
+
shorten,
|
|
2980
|
+
portalTheme
|
|
2981
|
+
})
|
|
2982
|
+
} : {});
|
|
2983
|
+
});
|
|
2984
|
+
};
|
|
2985
|
+
prepareSignUpState_fn = function(_0, _1) {
|
|
2986
|
+
return __async(this, arguments, function* (serverSignupState, { useShortUrls: shorten = false, portalTheme }) {
|
|
2987
|
+
const _a = serverSignupState, { signupAuthMethods } = _a, authState = __objRest(_a, ["signupAuthMethods"]);
|
|
2988
|
+
const [isPasskey, isPassword] = [
|
|
2989
|
+
signupAuthMethods.includes(import_user_management_client.AuthMethod.PASSKEY),
|
|
2990
|
+
signupAuthMethods.includes(import_user_management_client.AuthMethod.PASSWORD)
|
|
2991
|
+
];
|
|
2992
|
+
if (!isPasskey && !isPassword) {
|
|
2993
|
+
throw new Error(
|
|
2994
|
+
"No supported authentication methods found. Please ensure you have enabled either WebAuth passkeys or passwords in your Developer Portal settings."
|
|
2995
|
+
);
|
|
2996
|
+
}
|
|
2997
|
+
const signupState = authState;
|
|
2998
|
+
if (isPasskey) {
|
|
2999
|
+
const { url: passkeyUrl, credentialId: passkeyId } = yield this.getNewCredentialAndUrl({
|
|
3000
|
+
authMethod: "PASSKEY",
|
|
3001
|
+
shorten
|
|
3002
|
+
});
|
|
3003
|
+
if (passkeyUrl) signupState.passkeyUrl = passkeyUrl;
|
|
3004
|
+
signupState.passkeyId = passkeyId;
|
|
3005
|
+
}
|
|
3006
|
+
if (isPassword) {
|
|
3007
|
+
const { url: passwordUrl, credentialId: passwordId } = yield this.getNewCredentialAndUrl({
|
|
3008
|
+
authMethod: "PASSWORD",
|
|
3009
|
+
portalTheme,
|
|
3010
|
+
shorten
|
|
3011
|
+
});
|
|
3012
|
+
signupState.passwordUrl = passwordUrl;
|
|
3013
|
+
signupState.passwordId = passwordId;
|
|
3014
|
+
}
|
|
3015
|
+
return signupState;
|
|
3016
|
+
});
|
|
3017
|
+
};
|
|
3056
3018
|
_ParaCore.version = constants.PARA_CORE_VERSION;
|
|
3057
3019
|
let ParaCore = _ParaCore;
|
|
3058
3020
|
// Annotate the CommonJS export names for ESM import in node:
|