@getpara/core-sdk 2.0.0-alpha.3 → 2.0.0-dev.1
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/index.js +1465 -420
- package/dist/cjs/index.js.br +0 -0
- package/dist/cjs/index.js.gz +0 -0
- package/dist/esm/index.js +1468 -422
- package/dist/esm/index.js.br +0 -0
- package/dist/esm/index.js.gz +0 -0
- package/dist/types/ParaCore.d.ts +414 -35
- package/dist/types/types/coreApi.d.ts +20 -20
- package/dist/types/types/methods.d.ts +49 -1
- package/package.json +3 -4
package/dist/cjs/index.js
CHANGED
|
@@ -267,7 +267,7 @@ function jsonParse(data, validate) {
|
|
|
267
267
|
}
|
|
268
268
|
|
|
269
269
|
// src/constants.ts
|
|
270
|
-
var PARA_CORE_VERSION = '2.0.0-
|
|
270
|
+
var PARA_CORE_VERSION = '2.0.0-dev.1';
|
|
271
271
|
var PREFIX = "@CAPSULE/";
|
|
272
272
|
var LOCAL_STORAGE_AUTH_INFO = `${PREFIX}authInfo`;
|
|
273
273
|
var LOCAL_STORAGE_EMAIL = `${PREFIX}e-mail`;
|
|
@@ -397,7 +397,7 @@ function waitUntilTrue(condition, timeoutMs, intervalMs) {
|
|
|
397
397
|
|
|
398
398
|
// src/utils/types.ts
|
|
399
399
|
function isServerAuthState(obj) {
|
|
400
|
-
return "stage" in obj
|
|
400
|
+
return "stage" in obj;
|
|
401
401
|
}
|
|
402
402
|
|
|
403
403
|
// src/transmission/transmissionUtils.ts
|
|
@@ -456,20 +456,20 @@ var EnabledFlow = /* @__PURE__ */ ((EnabledFlow2) => {
|
|
|
456
456
|
|
|
457
457
|
// src/types/coreApi.ts
|
|
458
458
|
var PARA_CORE_METHODS = [
|
|
459
|
-
"
|
|
460
|
-
"
|
|
461
|
-
"
|
|
462
|
-
"
|
|
463
|
-
"
|
|
464
|
-
"
|
|
465
|
-
"
|
|
466
|
-
"
|
|
459
|
+
"signUpOrLogInV2",
|
|
460
|
+
"verifyNewAccountV2",
|
|
461
|
+
"waitForLoginV2",
|
|
462
|
+
"waitForSignupV2",
|
|
463
|
+
"waitForWalletCreationV2",
|
|
464
|
+
"verifyOAuthV2",
|
|
465
|
+
"verifyFarcasterV2",
|
|
466
|
+
"verifyTelegramV2",
|
|
467
467
|
"resendVerificationCode",
|
|
468
|
-
"
|
|
469
|
-
"
|
|
470
|
-
"
|
|
471
|
-
"
|
|
472
|
-
"
|
|
468
|
+
"loginExternalWalletV2",
|
|
469
|
+
"verifyExternalWalletV2",
|
|
470
|
+
"setup2faV2",
|
|
471
|
+
"enable2faV2",
|
|
472
|
+
"verify2faV2",
|
|
473
473
|
"logout",
|
|
474
474
|
"clearStorage",
|
|
475
475
|
"isSessionActive",
|
|
@@ -482,12 +482,12 @@ var PARA_CORE_METHODS = [
|
|
|
482
482
|
"fetchWallets",
|
|
483
483
|
"createWallet",
|
|
484
484
|
"createWalletPerType",
|
|
485
|
-
"
|
|
486
|
-
"
|
|
487
|
-
"
|
|
488
|
-
"
|
|
489
|
-
"
|
|
490
|
-
"
|
|
485
|
+
"getPregenWalletsV2",
|
|
486
|
+
"hasPregenWalletV2",
|
|
487
|
+
"updatePregenWalletIdentifierV2",
|
|
488
|
+
"createPregenWalletV2",
|
|
489
|
+
"createPregenWalletPerTypeV2",
|
|
490
|
+
"claimPregenWalletsV2",
|
|
491
491
|
"distributeNewWalletShare",
|
|
492
492
|
"getUserShare",
|
|
493
493
|
"setUserShare",
|
|
@@ -525,13 +525,13 @@ var PopupType = /* @__PURE__ */ ((PopupType2) => {
|
|
|
525
525
|
})(PopupType || {});
|
|
526
526
|
|
|
527
527
|
// src/types/recovery.ts
|
|
528
|
-
var RecoveryStatus = /* @__PURE__ */ ((
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
return
|
|
528
|
+
var RecoveryStatus = /* @__PURE__ */ ((RecoveryStatus3) => {
|
|
529
|
+
RecoveryStatus3["INITIATED"] = "INITIATED";
|
|
530
|
+
RecoveryStatus3["READY"] = "READY";
|
|
531
|
+
RecoveryStatus3["EXPIRED"] = "EXPIRED";
|
|
532
|
+
RecoveryStatus3["FINISHED"] = "FINISHED";
|
|
533
|
+
RecoveryStatus3["CANCELLED"] = "CANCELLED";
|
|
534
|
+
return RecoveryStatus3;
|
|
535
535
|
})(RecoveryStatus || {});
|
|
536
536
|
|
|
537
537
|
// src/types/events.ts
|
|
@@ -1019,7 +1019,7 @@ function initClient({
|
|
|
1019
1019
|
}) {
|
|
1020
1020
|
return new import_user_management_client2.default({
|
|
1021
1021
|
userManagementHost: getBaseUrl(env),
|
|
1022
|
-
version: ["DEV" /* DEV */, "SANDBOX" /* SANDBOX */].includes(env) ? "dev
|
|
1022
|
+
version: ["DEV" /* DEV */, "SANDBOX" /* SANDBOX */].includes(env) ? "dev" : version,
|
|
1023
1023
|
apiKey,
|
|
1024
1024
|
partnerId,
|
|
1025
1025
|
opts: { useFetchAdapter },
|
|
@@ -1759,7 +1759,7 @@ var _ParaCore = class _ParaCore {
|
|
|
1759
1759
|
var _a, _b, _c;
|
|
1760
1760
|
return walletId ? (_a = this.wallets[walletId]) == null ? void 0 : _a.address : (_c = (_b = Object.values(this.wallets)) == null ? void 0 : _b[0]) == null ? void 0 : _c.address;
|
|
1761
1761
|
}
|
|
1762
|
-
|
|
1762
|
+
constructPortalUrlV2(_0) {
|
|
1763
1763
|
return __async(this, arguments, function* (type, opts = {}) {
|
|
1764
1764
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
1765
1765
|
const [isCreate, isLogin, isOnRamp] = [
|
|
@@ -1844,6 +1844,77 @@ var _ParaCore = class _ParaCore {
|
|
|
1844
1844
|
return url;
|
|
1845
1845
|
});
|
|
1846
1846
|
}
|
|
1847
|
+
constructPortalUrl(_0) {
|
|
1848
|
+
return __async(this, arguments, function* (type, opts = {}) {
|
|
1849
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
1850
|
+
const [isCreate, isLogin, isOnRamp] = [
|
|
1851
|
+
["createAuth", "createPassword"].includes(type),
|
|
1852
|
+
["loginAuth", "loginPassword"].includes(type),
|
|
1853
|
+
type === "onRamp"
|
|
1854
|
+
];
|
|
1855
|
+
let auth;
|
|
1856
|
+
if (isCreate || isLogin) {
|
|
1857
|
+
auth = this.assertIsAuthSet().auth;
|
|
1858
|
+
}
|
|
1859
|
+
if ((isLogin || isOnRamp) && !opts.sessionId) {
|
|
1860
|
+
opts.sessionId = (yield this.touchSession()).sessionLookupId;
|
|
1861
|
+
}
|
|
1862
|
+
const base = isOnRamp ? getPortalBaseURL(this.ctx) : yield this.getPortalURL();
|
|
1863
|
+
let path;
|
|
1864
|
+
switch (type) {
|
|
1865
|
+
case "createPassword": {
|
|
1866
|
+
path = `/web/users/${this.userId}/passwords/${opts.pathId}`;
|
|
1867
|
+
break;
|
|
1868
|
+
}
|
|
1869
|
+
case "createAuth": {
|
|
1870
|
+
path = `/web/users/${this.userId}/biometrics/${opts.pathId}`;
|
|
1871
|
+
break;
|
|
1872
|
+
}
|
|
1873
|
+
case "loginPassword": {
|
|
1874
|
+
path = "/web/passwords/login";
|
|
1875
|
+
break;
|
|
1876
|
+
}
|
|
1877
|
+
case "loginAuth": {
|
|
1878
|
+
path = "/web/biometrics/login";
|
|
1879
|
+
break;
|
|
1880
|
+
}
|
|
1881
|
+
case "txReview": {
|
|
1882
|
+
path = `/web/users/${this.userId}/transaction-review/${opts.pathId}`;
|
|
1883
|
+
break;
|
|
1884
|
+
}
|
|
1885
|
+
case "onRamp": {
|
|
1886
|
+
path = `/web/users/${this.userId}/on-ramp-transaction/${opts.pathId}`;
|
|
1887
|
+
break;
|
|
1888
|
+
}
|
|
1889
|
+
default: {
|
|
1890
|
+
throw new Error(`invalid URL type ${type}`);
|
|
1891
|
+
}
|
|
1892
|
+
}
|
|
1893
|
+
const partner = yield __privateMethod(this, _ParaCore_instances, assertPartner_fn).call(this);
|
|
1894
|
+
const params = __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({
|
|
1895
|
+
apiKey: this.ctx.apiKey,
|
|
1896
|
+
partnerId: partner.id,
|
|
1897
|
+
portalFont: ((_a = opts.theme) == null ? void 0 : _a.font) || (partner == null ? void 0 : partner.font) || ((_b = this.portalTheme) == null ? void 0 : _b.font),
|
|
1898
|
+
portalBorderRadius: ((_c = opts.theme) == null ? void 0 : _c.borderRadius) || ((_d = this.portalTheme) == null ? void 0 : _d.borderRadius),
|
|
1899
|
+
portalThemeMode: ((_e = opts.theme) == null ? void 0 : _e.mode) || (partner == null ? void 0 : partner.themeMode) || ((_f = this.portalTheme) == null ? void 0 : _f.mode),
|
|
1900
|
+
portalAccentColor: ((_g = opts.theme) == null ? void 0 : _g.accentColor) || (partner == null ? void 0 : partner.accentColor) || ((_h = this.portalTheme) == null ? void 0 : _h.accentColor),
|
|
1901
|
+
portalForegroundColor: ((_i = opts.theme) == null ? void 0 : _i.foregroundColor) || (partner == null ? void 0 : partner.foregroundColor) || ((_j = this.portalTheme) == null ? void 0 : _j.foregroundColor),
|
|
1902
|
+
portalBackgroundColor: ((_k = opts.theme) == null ? void 0 : _k.backgroundColor) || (partner == null ? void 0 : partner.backgroundColor) || this.portalBackgroundColor || ((_l = this.portalTheme) == null ? void 0 : _l.backgroundColor),
|
|
1903
|
+
portalPrimaryButtonColor: this.portalPrimaryButtonColor,
|
|
1904
|
+
portalTextColor: this.portalTextColor,
|
|
1905
|
+
portalPrimaryButtonTextColor: this.portalPrimaryButtonTextColor,
|
|
1906
|
+
isForNewDevice: opts.isForNewDevice ? opts.isForNewDevice.toString() : void 0
|
|
1907
|
+
}, auth && (isCreate || isLogin) ? auth : {}), isCreate || isLogin ? { authInfo: JSON.stringify(this.authInfo) } : {}), isLogin || isOnRamp ? { sessionId: opts.sessionId } : {}), isLogin ? {
|
|
1908
|
+
encryptionKey: opts.loginEncryptionPublicKey,
|
|
1909
|
+
newDeviceSessionLookupId: opts.newDeviceSessionId,
|
|
1910
|
+
newDeviceEncryptionKey: opts.newDeviceEncryptionKey,
|
|
1911
|
+
pregenIds: JSON.stringify(this.pregenIds),
|
|
1912
|
+
displayName: opts.displayName,
|
|
1913
|
+
pfpUrl: opts.pfpUrl
|
|
1914
|
+
} : {}), opts.params || {});
|
|
1915
|
+
return constructUrl({ base, path, params });
|
|
1916
|
+
});
|
|
1917
|
+
}
|
|
1847
1918
|
touchSession(regenerate = false) {
|
|
1848
1919
|
return __async(this, null, function* () {
|
|
1849
1920
|
var _a, _b, _c;
|
|
@@ -1986,7 +2057,7 @@ var _ParaCore = class _ParaCore {
|
|
|
1986
2057
|
* @param phone - Phone number to set.
|
|
1987
2058
|
* @param countryCode - Country Code to set.
|
|
1988
2059
|
*/
|
|
1989
|
-
|
|
2060
|
+
setPhoneNumber(phone, countryCode) {
|
|
1990
2061
|
return __async(this, null, function* () {
|
|
1991
2062
|
yield this.setAuth({ phone: formatPhoneNumber(phone, countryCode) });
|
|
1992
2063
|
});
|
|
@@ -2270,6 +2341,75 @@ var _ParaCore = class _ParaCore {
|
|
|
2270
2341
|
return (yield this.getPartnerURL()) || getPortalBaseURL(this.ctx);
|
|
2271
2342
|
});
|
|
2272
2343
|
}
|
|
2344
|
+
getWebAuthURLForCreate(_a) {
|
|
2345
|
+
return __async(this, null, function* () {
|
|
2346
|
+
var _b = _a, {
|
|
2347
|
+
webAuthId
|
|
2348
|
+
} = _b, options = __objRest(_b, [
|
|
2349
|
+
"webAuthId"
|
|
2350
|
+
]);
|
|
2351
|
+
return this.constructPortalUrl("createAuth", __spreadProps(__spreadValues({}, options), { pathId: webAuthId }));
|
|
2352
|
+
});
|
|
2353
|
+
}
|
|
2354
|
+
getPasswordURLForCreate(_c) {
|
|
2355
|
+
return __async(this, null, function* () {
|
|
2356
|
+
var _d = _c, {
|
|
2357
|
+
passwordId
|
|
2358
|
+
} = _d, options = __objRest(_d, [
|
|
2359
|
+
"passwordId"
|
|
2360
|
+
]);
|
|
2361
|
+
return this.constructPortalUrl("createPassword", __spreadProps(__spreadValues({}, options), {
|
|
2362
|
+
pathId: passwordId
|
|
2363
|
+
}));
|
|
2364
|
+
});
|
|
2365
|
+
}
|
|
2366
|
+
getShortUrl(compressedUrl) {
|
|
2367
|
+
return constructUrl({
|
|
2368
|
+
base: getPortalBaseURL(this.ctx),
|
|
2369
|
+
path: `/short/${compressedUrl}`
|
|
2370
|
+
});
|
|
2371
|
+
}
|
|
2372
|
+
shortenLoginLink(link) {
|
|
2373
|
+
return __async(this, null, function* () {
|
|
2374
|
+
const url = yield upload(link, this.ctx.client);
|
|
2375
|
+
return this.getShortUrl(url);
|
|
2376
|
+
});
|
|
2377
|
+
}
|
|
2378
|
+
/**
|
|
2379
|
+
* Generates a URL for registering a new WebAuth passkey.
|
|
2380
|
+
* @deprecated
|
|
2381
|
+
* @param {GetWebAuthUrlForLoginParams} opts the options object
|
|
2382
|
+
* @returns - the URL for creating a new passkey
|
|
2383
|
+
*/
|
|
2384
|
+
getWebAuthURLForLogin(opts) {
|
|
2385
|
+
return __async(this, null, function* () {
|
|
2386
|
+
return this.constructPortalUrl("loginAuth", opts);
|
|
2387
|
+
});
|
|
2388
|
+
}
|
|
2389
|
+
/**
|
|
2390
|
+
* Generates a URL for registering a new user password.
|
|
2391
|
+
* @deprecated
|
|
2392
|
+
* @param {GetWebAuthUrlForLoginParams} opts the options object
|
|
2393
|
+
* @returns - the URL for creating a new password
|
|
2394
|
+
*/
|
|
2395
|
+
getPasswordURLForLogin(opts) {
|
|
2396
|
+
return __async(this, null, function* () {
|
|
2397
|
+
return this.constructPortalUrl("loginPassword", opts);
|
|
2398
|
+
});
|
|
2399
|
+
}
|
|
2400
|
+
/**
|
|
2401
|
+
* Generates a URL for registering a new WebAuth passkey for a phone number.
|
|
2402
|
+
* @deprecated
|
|
2403
|
+
* @param {Omit<GetWebAuthUrlForLoginParams, 'authType'>} opts the options object
|
|
2404
|
+
* @returns - web auth url
|
|
2405
|
+
*/
|
|
2406
|
+
getWebAuthURLForLoginForPhone(opts) {
|
|
2407
|
+
return __async(this, null, function* () {
|
|
2408
|
+
return this.constructPortalUrl("loginAuth", __spreadValues({
|
|
2409
|
+
authType: "phone"
|
|
2410
|
+
}, opts));
|
|
2411
|
+
});
|
|
2412
|
+
}
|
|
2273
2413
|
/**
|
|
2274
2414
|
* Gets the private key for the given wallet.
|
|
2275
2415
|
* @param {string } [walletId] id of the wallet to get the private key for. Will default to the first wallet if not provided.
|
|
@@ -2320,7 +2460,7 @@ var _ParaCore = class _ParaCore {
|
|
|
2320
2460
|
}
|
|
2321
2461
|
populatePregenWalletAddresses() {
|
|
2322
2462
|
return __async(this, null, function* () {
|
|
2323
|
-
const res = yield this.
|
|
2463
|
+
const res = yield this.getPregenWalletsV2();
|
|
2324
2464
|
res.forEach((entity) => {
|
|
2325
2465
|
if (this.wallets[entity.id]) {
|
|
2326
2466
|
this.wallets[entity.id] = __spreadValues(__spreadValues({}, entityToWallet(entity)), this.wallets[entity.id]);
|
|
@@ -2330,387 +2470,1253 @@ var _ParaCore = class _ParaCore {
|
|
|
2330
2470
|
});
|
|
2331
2471
|
}
|
|
2332
2472
|
/**
|
|
2333
|
-
*
|
|
2473
|
+
* Checks if a user exists for an email address.
|
|
2474
|
+
* @deprecated
|
|
2475
|
+
* @param {Object} opts the options object
|
|
2476
|
+
* @param {string} opts.email the email to check.
|
|
2477
|
+
* @returns true if user exists, false otherwise.
|
|
2334
2478
|
*/
|
|
2335
|
-
|
|
2336
|
-
return __async(this,
|
|
2337
|
-
yield this.ctx.client.
|
|
2338
|
-
|
|
2339
|
-
}, this.getVerificationEmailProps()));
|
|
2479
|
+
checkIfUserExists(_0) {
|
|
2480
|
+
return __async(this, arguments, function* ({ email }) {
|
|
2481
|
+
const res = yield this.ctx.client.checkUserExists({ email });
|
|
2482
|
+
return res.data.exists;
|
|
2340
2483
|
});
|
|
2341
2484
|
}
|
|
2342
2485
|
/**
|
|
2343
|
-
* Checks if
|
|
2344
|
-
* @
|
|
2486
|
+
* Checks if a user exists for a phone number.
|
|
2487
|
+
* @deprecated
|
|
2488
|
+
* @param {Object} opts the options object
|
|
2489
|
+
* @param {string} opts.phone - phone number to check.
|
|
2490
|
+
* @param {string} opts.countryCode - the country code.
|
|
2491
|
+
* @returns true if user exists, false otherwise.
|
|
2345
2492
|
*/
|
|
2346
|
-
|
|
2493
|
+
checkIfUserExistsByPhone(auth) {
|
|
2347
2494
|
return __async(this, null, function* () {
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
}
|
|
2351
|
-
const { isAuthenticated } = yield this.touchSession();
|
|
2352
|
-
return !!isAuthenticated;
|
|
2495
|
+
const res = yield this.ctx.client.checkUserExists(auth);
|
|
2496
|
+
return res.data.exists;
|
|
2353
2497
|
});
|
|
2354
2498
|
}
|
|
2355
2499
|
/**
|
|
2356
|
-
*
|
|
2357
|
-
* @
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2500
|
+
* Creates a new user.
|
|
2501
|
+
* @deprecated
|
|
2502
|
+
* @param {Object} opts the options object
|
|
2503
|
+
* @param {string} opts.email the email to use.
|
|
2504
|
+
*/
|
|
2505
|
+
createUser(_0) {
|
|
2506
|
+
return __async(this, arguments, function* ({ email }) {
|
|
2507
|
+
this.requireApiKey();
|
|
2508
|
+
yield this.setEmail(email);
|
|
2509
|
+
const { userId } = yield this.ctx.client.createUser(__spreadValues({
|
|
2510
|
+
email: this.email
|
|
2511
|
+
}, this.getVerificationEmailProps()));
|
|
2512
|
+
yield this.setUserId(userId);
|
|
2366
2513
|
});
|
|
2367
2514
|
}
|
|
2368
|
-
|
|
2515
|
+
/**
|
|
2516
|
+
* Creates a new user with a phone number.
|
|
2517
|
+
* @deprecated
|
|
2518
|
+
* @param {Object} opts the options object
|
|
2519
|
+
* @param {string} opts.phone - the phone number to use for creating the user.
|
|
2520
|
+
* @param {string} opts.countryCode - the country code to use for creating the user.
|
|
2521
|
+
*/
|
|
2522
|
+
createUserByPhone(auth) {
|
|
2369
2523
|
return __async(this, null, function* () {
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
case "PASSWORD":
|
|
2375
|
-
authMethods.add(import_user_management_client5.AuthMethod.PASSWORD);
|
|
2376
|
-
break;
|
|
2377
|
-
case "BIOMETRIC":
|
|
2378
|
-
authMethods.add(import_user_management_client5.AuthMethod.PASSKEY);
|
|
2379
|
-
break;
|
|
2380
|
-
}
|
|
2381
|
-
}
|
|
2382
|
-
return authMethods;
|
|
2524
|
+
this.requireApiKey();
|
|
2525
|
+
yield this.setPhoneNumber(auth.phone);
|
|
2526
|
+
const { userId } = yield this.ctx.client.createUser(auth);
|
|
2527
|
+
yield this.setUserId(userId);
|
|
2383
2528
|
});
|
|
2384
2529
|
}
|
|
2385
2530
|
/**
|
|
2386
|
-
*
|
|
2531
|
+
* Logs in or creates a new user using an external wallet address.
|
|
2387
2532
|
* @deprecated
|
|
2388
|
-
* @
|
|
2533
|
+
* @param {Object} opts the options object
|
|
2534
|
+
* @param {string} opts.address the external wallet address to use for identification.
|
|
2535
|
+
* @param {WalletType} opts.type type of external wallet to use for identification.
|
|
2536
|
+
* @param {string} opts.provider the name of the provider for the external wallet.
|
|
2389
2537
|
*/
|
|
2390
|
-
|
|
2538
|
+
externalWalletLogin(wallet) {
|
|
2391
2539
|
return __async(this, null, function* () {
|
|
2392
|
-
|
|
2393
|
-
|
|
2540
|
+
this.requireApiKey();
|
|
2541
|
+
const res = yield this.ctx.client.externalWalletLogin({
|
|
2542
|
+
externalAddress: wallet.address,
|
|
2543
|
+
type: wallet.type,
|
|
2544
|
+
externalWalletProvider: wallet.provider,
|
|
2545
|
+
// If the wallet isn't using full Para auth we want to track the login here
|
|
2546
|
+
shouldTrackUser: !wallet.withFullParaAuth
|
|
2547
|
+
});
|
|
2548
|
+
yield this.setExternalWallet(wallet);
|
|
2549
|
+
yield this.setUserId(res.userId);
|
|
2550
|
+
return res;
|
|
2394
2551
|
});
|
|
2395
2552
|
}
|
|
2396
2553
|
/**
|
|
2397
|
-
*
|
|
2398
|
-
*
|
|
2399
|
-
*
|
|
2400
|
-
* @param {
|
|
2401
|
-
* @
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2554
|
+
* Passes the email code obtained from the user for verification.
|
|
2555
|
+
* @deprecated
|
|
2556
|
+
* @param {Object} opts the options object
|
|
2557
|
+
* @param {string} verificationCode the six-digit code to check
|
|
2558
|
+
* @returns {string} the web auth url for creating a new credential
|
|
2559
|
+
*/
|
|
2560
|
+
verifyEmail(_0) {
|
|
2561
|
+
return __async(this, arguments, function* ({ verificationCode }) {
|
|
2562
|
+
yield this.ctx.client.verifyEmail(this.userId, { verificationCode });
|
|
2563
|
+
return this.getSetUpBiometricsURL();
|
|
2564
|
+
});
|
|
2565
|
+
}
|
|
2566
|
+
/** @deprecated */
|
|
2567
|
+
verifyExternalWallet(_0) {
|
|
2405
2568
|
return __async(this, arguments, function* ({
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
}
|
|
2412
|
-
|
|
2413
|
-
sessionId
|
|
2414
|
-
});
|
|
2415
|
-
if (shouldOpenPopup) {
|
|
2416
|
-
this.platformUtils.openPopup(link);
|
|
2417
|
-
}
|
|
2418
|
-
return link;
|
|
2569
|
+
address,
|
|
2570
|
+
signedMessage,
|
|
2571
|
+
cosmosPublicKeyHex,
|
|
2572
|
+
cosmosSigner
|
|
2573
|
+
}) {
|
|
2574
|
+
yield this.ctx.client.verifyExternalWallet(this.userId, { address, signedMessage, cosmosPublicKeyHex, cosmosSigner });
|
|
2575
|
+
return this.getSetUpBiometricsURL();
|
|
2419
2576
|
});
|
|
2420
2577
|
}
|
|
2421
2578
|
/**
|
|
2422
|
-
*
|
|
2423
|
-
*
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
});
|
|
2433
|
-
return session;
|
|
2579
|
+
* Passes the phone code obtained from the user for verification.
|
|
2580
|
+
* @deprecated
|
|
2581
|
+
* @param {Object} opts the options object
|
|
2582
|
+
* @param {string} verificationCode the six-digit code to check
|
|
2583
|
+
* @returns {string} the web auth url for creating a new credential
|
|
2584
|
+
*/
|
|
2585
|
+
verifyPhone(_0) {
|
|
2586
|
+
return __async(this, arguments, function* ({ verificationCode }) {
|
|
2587
|
+
yield this.ctx.client.verifyPhone(this.userId, { verificationCode });
|
|
2588
|
+
return this.getSetUpBiometricsURLForPhone();
|
|
2434
2589
|
});
|
|
2435
2590
|
}
|
|
2436
2591
|
/**
|
|
2437
|
-
*
|
|
2438
|
-
*
|
|
2439
|
-
* @
|
|
2440
|
-
* @
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
const
|
|
2446
|
-
|
|
2592
|
+
* Validates the response received from an attempted Telegram login for authenticity, then
|
|
2593
|
+
* creates or retrieves the corresponding Para user and prepares the Para instance to sign in with that user.
|
|
2594
|
+
* @deprecated
|
|
2595
|
+
* @param authResponse - the response JSON object received from the Telegram widget.
|
|
2596
|
+
* @returns `{ isValid: boolean; telegramUserId?: string; userId?: string; isNewUser?: boolean; supportedAuthMethods?: AuthMethod[]; biometricHints?: BiometricLocationHint[] }`
|
|
2597
|
+
*/
|
|
2598
|
+
verifyTelegram(authObject) {
|
|
2599
|
+
return __async(this, null, function* () {
|
|
2600
|
+
const res = yield this.ctx.client.verifyTelegram(authObject);
|
|
2601
|
+
if (res.isValid) {
|
|
2602
|
+
const { userId, telegramUserId } = res;
|
|
2603
|
+
const { photo_url: pfpUrl, username, first_name: firstName, last_name: lastName } = authObject;
|
|
2604
|
+
yield this.setAuth(
|
|
2605
|
+
{ telegramUserId },
|
|
2606
|
+
{
|
|
2607
|
+
extras: {
|
|
2608
|
+
pfpUrl,
|
|
2609
|
+
username,
|
|
2610
|
+
displayName: firstName ? `${firstName}${lastName ? ` ${lastName}` : ""}` : username ? `@${username}` : void 0
|
|
2611
|
+
},
|
|
2612
|
+
userId
|
|
2613
|
+
}
|
|
2614
|
+
);
|
|
2615
|
+
yield this.touchSession(true);
|
|
2616
|
+
if (!this.loginEncryptionKeyPair) {
|
|
2617
|
+
yield this.setLoginEncryptionKeyPair();
|
|
2618
|
+
}
|
|
2619
|
+
}
|
|
2620
|
+
return res;
|
|
2447
2621
|
});
|
|
2448
2622
|
}
|
|
2449
2623
|
/**
|
|
2450
|
-
*
|
|
2451
|
-
* @
|
|
2452
|
-
* @param {
|
|
2453
|
-
* @param {
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
id: share.walletId,
|
|
2467
|
-
signer
|
|
2468
|
-
};
|
|
2469
|
-
});
|
|
2470
|
-
yield this.deleteLoginEncryptionKeyPair();
|
|
2471
|
-
yield this.populateWalletAddresses();
|
|
2472
|
-
yield this.touchSession(!skipSessionRefresh);
|
|
2624
|
+
* Performs 2FA verification.
|
|
2625
|
+
* @deprecated
|
|
2626
|
+
* @param {Object} opts the options object
|
|
2627
|
+
* @param {string} opts.email the email to use for performing a 2FA verification.
|
|
2628
|
+
* @param {string} opts.verificationCode the verification code to received via 2FA.
|
|
2629
|
+
* @returns {Object} `{ address, initiatedAt, status, userId, walletId }`
|
|
2630
|
+
*/
|
|
2631
|
+
verify2FA(_0) {
|
|
2632
|
+
return __async(this, arguments, function* ({ email, verificationCode }) {
|
|
2633
|
+
const res = yield this.ctx.client.verify2FA(email, verificationCode);
|
|
2634
|
+
return {
|
|
2635
|
+
initiatedAt: res.data.initiatedAt,
|
|
2636
|
+
status: res.data.status,
|
|
2637
|
+
userId: res.data.userId,
|
|
2638
|
+
wallets: res.data.wallets
|
|
2639
|
+
};
|
|
2473
2640
|
});
|
|
2474
2641
|
}
|
|
2475
2642
|
/**
|
|
2476
|
-
*
|
|
2477
|
-
* @
|
|
2478
|
-
* @param {
|
|
2479
|
-
* @param {string} opts.
|
|
2480
|
-
* @param {
|
|
2481
|
-
* @param {
|
|
2482
|
-
* @returns {
|
|
2483
|
-
|
|
2484
|
-
|
|
2643
|
+
* Performs 2FA verification.
|
|
2644
|
+
* @deprecated
|
|
2645
|
+
* @param {Object} opts the options object
|
|
2646
|
+
* @param {string} opts.phone the phone number
|
|
2647
|
+
* @param {string} opts.countryCode - the country code
|
|
2648
|
+
* @param {string} opts.verificationCode - verification code to received via 2FA.
|
|
2649
|
+
* @returns {Object} `{ address, initiatedAt, status, userId, walletId }`
|
|
2650
|
+
*/
|
|
2651
|
+
verify2FAForPhone(_0) {
|
|
2485
2652
|
return __async(this, arguments, function* ({
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
skipBiometricShareCreation = false,
|
|
2489
|
-
forceRefresh = false
|
|
2653
|
+
phone,
|
|
2654
|
+
verificationCode
|
|
2490
2655
|
}) {
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2656
|
+
const res = yield this.ctx.client.verify2FAForPhone(phone, verificationCode);
|
|
2657
|
+
return {
|
|
2658
|
+
initiatedAt: res.data.initiatedAt,
|
|
2659
|
+
status: res.data.status,
|
|
2660
|
+
userId: res.data.userId,
|
|
2661
|
+
wallets: res.data.wallets
|
|
2662
|
+
};
|
|
2663
|
+
});
|
|
2664
|
+
}
|
|
2665
|
+
/**
|
|
2666
|
+
* Sets up two-factor authentication for the current user.
|
|
2667
|
+
* @deprecated
|
|
2668
|
+
* @returns {string} uri - uri to use for setting up 2FA
|
|
2669
|
+
* */
|
|
2670
|
+
setup2FA() {
|
|
2671
|
+
return __async(this, null, function* () {
|
|
2672
|
+
const res = yield this.ctx.client.setup2FA(this.userId);
|
|
2673
|
+
return {
|
|
2674
|
+
uri: res.data.uri
|
|
2675
|
+
};
|
|
2676
|
+
});
|
|
2677
|
+
}
|
|
2678
|
+
/**
|
|
2679
|
+
* Enables 2FA.
|
|
2680
|
+
* @deprecated
|
|
2681
|
+
* @param {Object} opts the options object
|
|
2682
|
+
* @param {string} opts.verificationCode - the verification code received via 2FA.
|
|
2683
|
+
*/
|
|
2684
|
+
enable2FA(_0) {
|
|
2685
|
+
return __async(this, arguments, function* ({ verificationCode }) {
|
|
2686
|
+
yield this.ctx.client.enable2FA(this.userId, verificationCode);
|
|
2687
|
+
});
|
|
2688
|
+
}
|
|
2689
|
+
/**
|
|
2690
|
+
* Determines if 2FA has been set up.
|
|
2691
|
+
* @deprecated
|
|
2692
|
+
* @returns {Object} `{ isSetup: boolean }` - true if 2FA is setup, false otherwise
|
|
2693
|
+
*/
|
|
2694
|
+
check2FAStatus() {
|
|
2695
|
+
return __async(this, null, function* () {
|
|
2696
|
+
if (!this.userId) {
|
|
2697
|
+
return { isSetup: false };
|
|
2494
2698
|
}
|
|
2495
|
-
const
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2699
|
+
const res = yield this.ctx.client.check2FAStatus(this.userId);
|
|
2700
|
+
return {
|
|
2701
|
+
isSetup: res.data.isSetup
|
|
2702
|
+
};
|
|
2703
|
+
});
|
|
2704
|
+
}
|
|
2705
|
+
/**
|
|
2706
|
+
* Resend a verification email for the current user.
|
|
2707
|
+
*/
|
|
2708
|
+
resendVerificationCode() {
|
|
2709
|
+
return __async(this, null, function* () {
|
|
2710
|
+
yield this.ctx.client.resendVerificationCode(__spreadValues({
|
|
2711
|
+
userId: this.userId
|
|
2712
|
+
}, this.getVerificationEmailProps()));
|
|
2713
|
+
});
|
|
2714
|
+
}
|
|
2715
|
+
/**
|
|
2716
|
+
* Resend a verification SMS for the current user.
|
|
2717
|
+
* @deprecated
|
|
2718
|
+
*/
|
|
2719
|
+
resendVerificationCodeByPhone() {
|
|
2720
|
+
return __async(this, null, function* () {
|
|
2721
|
+
yield this.ctx.client.resendVerificationCodeByPhone({
|
|
2722
|
+
userId: this.userId
|
|
2508
2723
|
});
|
|
2509
|
-
return recoveryShare;
|
|
2510
2724
|
});
|
|
2511
2725
|
}
|
|
2512
|
-
|
|
2726
|
+
/**
|
|
2727
|
+
* Returns a URL for setting up a new WebAuth passkey.
|
|
2728
|
+
* @deprecated
|
|
2729
|
+
* @param {Object} opts the options object
|
|
2730
|
+
* @param {string} opts.authType - the auth type to use
|
|
2731
|
+
* @param {boolean} opts.isForNewDevice whether the passkey is for a new device of an existing user
|
|
2732
|
+
* @returns {string} the URL
|
|
2733
|
+
*/
|
|
2734
|
+
getSetUpBiometricsURL() {
|
|
2735
|
+
return __async(this, arguments, function* ({
|
|
2736
|
+
authType = "email",
|
|
2737
|
+
isForNewDevice = false
|
|
2738
|
+
} = {}) {
|
|
2739
|
+
const res = yield this.ctx.client.addSessionPublicKey(this.userId, {
|
|
2740
|
+
status: import_user_management_client5.PublicKeyStatus.PENDING,
|
|
2741
|
+
type: import_user_management_client5.PublicKeyType.WEB
|
|
2742
|
+
});
|
|
2743
|
+
return this.getWebAuthURLForCreate({
|
|
2744
|
+
authType,
|
|
2745
|
+
isForNewDevice,
|
|
2746
|
+
webAuthId: res.data.id,
|
|
2747
|
+
partnerId: res.data.partnerId
|
|
2748
|
+
});
|
|
2749
|
+
});
|
|
2750
|
+
}
|
|
2751
|
+
/**
|
|
2752
|
+
* Returns a URL for setting up a new WebAuth passkey for a phone number.
|
|
2753
|
+
* @deprecated
|
|
2754
|
+
* @param {Object} opts the options object
|
|
2755
|
+
* @param {boolean} opts.isForNewDevice whether the passkey is for a new device of an existing user
|
|
2756
|
+
* @returns {string} the URL
|
|
2757
|
+
*/
|
|
2758
|
+
getSetUpBiometricsURLForPhone() {
|
|
2759
|
+
return __async(this, arguments, function* ({
|
|
2760
|
+
isForNewDevice = false
|
|
2761
|
+
} = {}) {
|
|
2762
|
+
const res = yield this.ctx.client.addSessionPublicKey(this.userId, {
|
|
2763
|
+
status: import_user_management_client5.PublicKeyStatus.PENDING,
|
|
2764
|
+
type: import_user_management_client5.PublicKeyType.WEB
|
|
2765
|
+
});
|
|
2766
|
+
return this.getWebAuthURLForCreate({
|
|
2767
|
+
authType: "phone",
|
|
2768
|
+
isForNewDevice,
|
|
2769
|
+
webAuthId: res.data.id,
|
|
2770
|
+
partnerId: res.data.partnerId
|
|
2771
|
+
});
|
|
2772
|
+
});
|
|
2773
|
+
}
|
|
2774
|
+
/**
|
|
2775
|
+
* Returns a URL for setting up a new password.
|
|
2776
|
+
* @deprecated
|
|
2777
|
+
* @param {Object} opts the options object
|
|
2778
|
+
* @param {string} opts.authType - the auth type to use
|
|
2779
|
+
* @param {boolean} opts.isForNewDevice whether the passkey is for a new device of an existing user
|
|
2780
|
+
* @param {Theme} [opts.theme] the portal theme to use in place of the partner's default
|
|
2781
|
+
* @returns {string} the URL
|
|
2782
|
+
*/
|
|
2783
|
+
getSetupPasswordURL() {
|
|
2784
|
+
return __async(this, arguments, function* ({
|
|
2785
|
+
authType = "email",
|
|
2786
|
+
isForNewDevice = false,
|
|
2787
|
+
theme
|
|
2788
|
+
} = {}) {
|
|
2789
|
+
const res = yield this.ctx.client.addSessionPasswordPublicKey(this.userId, {
|
|
2790
|
+
status: import_user_management_client5.PasswordStatus.PENDING
|
|
2791
|
+
});
|
|
2792
|
+
return this.getPasswordURLForCreate({
|
|
2793
|
+
authType,
|
|
2794
|
+
isForNewDevice,
|
|
2795
|
+
passwordId: res.data.id,
|
|
2796
|
+
partnerId: res.data.partnerId,
|
|
2797
|
+
theme
|
|
2798
|
+
});
|
|
2799
|
+
});
|
|
2800
|
+
}
|
|
2801
|
+
/**
|
|
2802
|
+
* Checks if the current session is active.
|
|
2803
|
+
* @returns `true` if active, `false` otherwise
|
|
2804
|
+
*/
|
|
2805
|
+
isSessionActive() {
|
|
2513
2806
|
return __async(this, null, function* () {
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2807
|
+
if (this.externalWalletConnectionType === "CONNECTION_ONLY") {
|
|
2808
|
+
return true;
|
|
2809
|
+
}
|
|
2810
|
+
const { isAuthenticated } = yield this.touchSession();
|
|
2811
|
+
return !!isAuthenticated;
|
|
2812
|
+
});
|
|
2813
|
+
}
|
|
2814
|
+
/**
|
|
2815
|
+
* Checks if a session is active and a wallet exists.
|
|
2816
|
+
* @returns `true` if active, `false` otherwise
|
|
2817
|
+
**/
|
|
2818
|
+
isFullyLoggedIn() {
|
|
2819
|
+
return __async(this, null, function* () {
|
|
2820
|
+
if (this.externalWalletConnectionType === "CONNECTION_ONLY") {
|
|
2821
|
+
return true;
|
|
2822
|
+
}
|
|
2823
|
+
const isSessionActive = yield this.isSessionActive();
|
|
2824
|
+
return isSessionActive && this.currentWalletIdsArray.length > 0 && this.currentWalletIdsArray.reduce((acc, [id]) => acc && !!this.wallets[id], true);
|
|
2825
|
+
});
|
|
2826
|
+
}
|
|
2827
|
+
/** @deprecated */
|
|
2828
|
+
supportedAuthMethods(auth) {
|
|
2829
|
+
return __async(this, null, function* () {
|
|
2830
|
+
const { supportedAuthMethods } = yield this.ctx.client.getSupportedAuthMethods(auth);
|
|
2831
|
+
const authMethods = /* @__PURE__ */ new Set();
|
|
2832
|
+
for (const type of supportedAuthMethods) {
|
|
2833
|
+
switch (type) {
|
|
2834
|
+
case "PASSWORD":
|
|
2835
|
+
authMethods.add(import_user_management_client5.AuthMethod.PASSWORD);
|
|
2836
|
+
break;
|
|
2837
|
+
case "BIOMETRIC":
|
|
2838
|
+
authMethods.add(import_user_management_client5.AuthMethod.PASSKEY);
|
|
2518
2839
|
break;
|
|
2519
|
-
}
|
|
2520
|
-
++maxPolls;
|
|
2521
|
-
const res = yield this.ctx.client.getWallets(this.userId);
|
|
2522
|
-
const wallet = res.data.wallets.find((w) => w.id === walletId);
|
|
2523
|
-
if (wallet && wallet.address) {
|
|
2524
|
-
return;
|
|
2525
|
-
}
|
|
2526
|
-
yield new Promise((resolve) => setTimeout(resolve, SHORT_POLLING_INTERVAL_MS));
|
|
2527
|
-
} catch (err) {
|
|
2528
|
-
console.error(err);
|
|
2529
2840
|
}
|
|
2530
2841
|
}
|
|
2531
|
-
|
|
2842
|
+
return authMethods;
|
|
2532
2843
|
});
|
|
2533
2844
|
}
|
|
2534
2845
|
/**
|
|
2535
|
-
*
|
|
2536
|
-
*
|
|
2537
|
-
* @
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2846
|
+
* Get hints associated with the users stored biometrics.
|
|
2847
|
+
* @deprecated
|
|
2848
|
+
* @returns Array containing useragents and AAGuids for stored biometrics
|
|
2849
|
+
*/
|
|
2850
|
+
getUserBiometricLocationHints() {
|
|
2851
|
+
return __async(this, null, function* () {
|
|
2852
|
+
const { auth } = this.assertIsAuthSet();
|
|
2853
|
+
return yield this.ctx.client.getBiometricLocationHints(auth);
|
|
2854
|
+
});
|
|
2855
|
+
}
|
|
2856
|
+
/**
|
|
2857
|
+
* Initiates a login.
|
|
2858
|
+
* @deprecated
|
|
2859
|
+
* @param {Object} opts the options object
|
|
2860
|
+
* @param {String} opts.email - the email to login with
|
|
2861
|
+
* @param {boolean} opts.useShortURL - whether to shorten the link
|
|
2862
|
+
* @returns - the WebAuth URL for logging in
|
|
2541
2863
|
**/
|
|
2542
|
-
|
|
2864
|
+
initiateUserLogin(_e) {
|
|
2543
2865
|
return __async(this, null, function* () {
|
|
2544
|
-
|
|
2545
|
-
|
|
2866
|
+
var _f = _e, { useShortUrl = false } = _f, auth = __objRest(_f, ["useShortUrl"]);
|
|
2867
|
+
const authInfo = yield this.setAuth(auth);
|
|
2868
|
+
if (!authInfo) {
|
|
2869
|
+
return;
|
|
2870
|
+
}
|
|
2871
|
+
const { partnerId, sessionId } = yield this.touchSession(true);
|
|
2872
|
+
if (!this.loginEncryptionKeyPair) {
|
|
2873
|
+
yield this.setLoginEncryptionKeyPair();
|
|
2874
|
+
}
|
|
2875
|
+
const webAuthLoginURL = yield this.getWebAuthURLForLogin({
|
|
2876
|
+
authType: authInfo.authType,
|
|
2877
|
+
sessionId,
|
|
2878
|
+
partnerId,
|
|
2879
|
+
loginEncryptionPublicKey: getPublicKeyHex(this.loginEncryptionKeyPair)
|
|
2880
|
+
});
|
|
2881
|
+
if (!useShortUrl) {
|
|
2882
|
+
return webAuthLoginURL;
|
|
2883
|
+
}
|
|
2884
|
+
return this.shortenLoginLink(webAuthLoginURL);
|
|
2885
|
+
});
|
|
2886
|
+
}
|
|
2887
|
+
/**
|
|
2888
|
+
* Initiates a login.
|
|
2889
|
+
* @deprecated
|
|
2890
|
+
* @param email - the email to login with
|
|
2891
|
+
* @returns - a set of supported auth methods for the user
|
|
2892
|
+
**/
|
|
2893
|
+
initiateUserLoginV2(auth) {
|
|
2894
|
+
return __async(this, null, function* () {
|
|
2895
|
+
let authInfo = __privateGet(this, _authInfo);
|
|
2896
|
+
if (!authInfo || JSON.stringify(authInfo.auth) !== JSON.stringify(auth)) {
|
|
2897
|
+
authInfo = yield this.setAuth(auth);
|
|
2898
|
+
}
|
|
2899
|
+
if (!authInfo) {
|
|
2900
|
+
return;
|
|
2901
|
+
}
|
|
2902
|
+
yield this.touchSession(true);
|
|
2903
|
+
if (!this.loginEncryptionKeyPair) {
|
|
2904
|
+
yield this.setLoginEncryptionKeyPair();
|
|
2905
|
+
}
|
|
2906
|
+
return yield this.supportedAuthMethods(authInfo.auth);
|
|
2907
|
+
});
|
|
2908
|
+
}
|
|
2909
|
+
/**
|
|
2910
|
+
* Initiates a login.
|
|
2911
|
+
* @deprecated
|
|
2912
|
+
* @param opts the options object
|
|
2913
|
+
* @param opts.phone the phone number
|
|
2914
|
+
* @param opts.countryCode the country code
|
|
2915
|
+
* @param opts.useShortURL - whether to shorten the link
|
|
2916
|
+
* @returns - the WebAuth URL for logging in
|
|
2917
|
+
**/
|
|
2918
|
+
initiateUserLoginForPhone(_g) {
|
|
2919
|
+
return __async(this, null, function* () {
|
|
2920
|
+
var _h = _g, {
|
|
2921
|
+
useShortUrl = false
|
|
2922
|
+
} = _h, auth = __objRest(_h, [
|
|
2923
|
+
"useShortUrl"
|
|
2924
|
+
]);
|
|
2925
|
+
yield this.setAuth(auth);
|
|
2926
|
+
const { sessionId, partnerId } = yield this.touchSession(true);
|
|
2927
|
+
if (!this.loginEncryptionKeyPair) {
|
|
2928
|
+
yield this.setLoginEncryptionKeyPair();
|
|
2929
|
+
}
|
|
2930
|
+
const webAuthLoginURL = yield this.getWebAuthURLForLoginForPhone({
|
|
2931
|
+
sessionId,
|
|
2932
|
+
loginEncryptionPublicKey: getPublicKeyHex(this.loginEncryptionKeyPair),
|
|
2933
|
+
partnerId
|
|
2934
|
+
});
|
|
2935
|
+
if (!useShortUrl) {
|
|
2936
|
+
return webAuthLoginURL;
|
|
2937
|
+
}
|
|
2938
|
+
return this.shortenLoginLink(webAuthLoginURL);
|
|
2939
|
+
});
|
|
2940
|
+
}
|
|
2941
|
+
/**
|
|
2942
|
+
* @deprecated
|
|
2943
|
+
* Waits for the session to be active.
|
|
2944
|
+
**/
|
|
2945
|
+
waitForAccountCreation() {
|
|
2946
|
+
return __async(this, arguments, function* ({ popupWindow } = {}) {
|
|
2947
|
+
yield this.touchSession();
|
|
2948
|
+
if (!this.isExternalWalletAuth) {
|
|
2949
|
+
this.externalWallets = {};
|
|
2950
|
+
}
|
|
2951
|
+
this.isAwaitingAccountCreation = true;
|
|
2952
|
+
while (this.isAwaitingAccountCreation) {
|
|
2546
2953
|
try {
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2954
|
+
yield new Promise((resolve) => setTimeout(resolve, POLLING_INTERVAL_MS));
|
|
2955
|
+
if (yield this.isSessionActive()) {
|
|
2956
|
+
this.isAwaitingAccountCreation = false;
|
|
2957
|
+
dispatchEvent(ParaEvent.ACCOUNT_CREATION_EVENT, true);
|
|
2958
|
+
return true;
|
|
2959
|
+
} else {
|
|
2960
|
+
if (popupWindow == null ? void 0 : popupWindow.closed) {
|
|
2961
|
+
this.isAwaitingAccountCreation = false;
|
|
2962
|
+
return false;
|
|
2963
|
+
}
|
|
2555
2964
|
}
|
|
2556
|
-
yield new Promise((resolve) => setTimeout(resolve, SHORT_POLLING_INTERVAL_MS));
|
|
2557
2965
|
} catch (err) {
|
|
2558
2966
|
console.error(err);
|
|
2559
2967
|
}
|
|
2560
2968
|
}
|
|
2561
|
-
|
|
2969
|
+
return false;
|
|
2970
|
+
});
|
|
2971
|
+
}
|
|
2972
|
+
/**
|
|
2973
|
+
* @deprecated
|
|
2974
|
+
*/
|
|
2975
|
+
waitForPasskeyAndCreateWallet() {
|
|
2976
|
+
return __async(this, arguments, function* ({
|
|
2977
|
+
popupWindow
|
|
2978
|
+
} = {}) {
|
|
2979
|
+
yield this.waitForAccountCreation({ popupWindow });
|
|
2980
|
+
const { supportedWalletTypes } = yield __privateMethod(this, _ParaCore_instances, assertPartner_fn).call(this);
|
|
2981
|
+
const pregenWallets = yield this.getPregenWalletsV2();
|
|
2982
|
+
let recoverySecret, walletIds = {};
|
|
2983
|
+
if (pregenWallets.length > 0) {
|
|
2984
|
+
recoverySecret = yield this.claimPregenWallets();
|
|
2985
|
+
walletIds = supportedWalletTypes.reduce((acc, { type }) => {
|
|
2986
|
+
var _a;
|
|
2987
|
+
return __spreadProps(__spreadValues({}, acc), {
|
|
2988
|
+
[type]: [(_a = pregenWallets.find((w) => !!WalletSchemeTypeMap[w.scheme][type])) == null ? void 0 : _a.id]
|
|
2989
|
+
});
|
|
2990
|
+
}, {});
|
|
2991
|
+
}
|
|
2992
|
+
const created = yield this.createWalletPerType();
|
|
2993
|
+
recoverySecret = recoverySecret != null ? recoverySecret : created.recoverySecret;
|
|
2994
|
+
walletIds = __spreadValues(__spreadValues({}, walletIds), created.walletIds);
|
|
2995
|
+
const resp = { walletIds, recoverySecret };
|
|
2996
|
+
dispatchEvent(ParaEvent.ACCOUNT_SETUP_EVENT, resp);
|
|
2997
|
+
return resp;
|
|
2998
|
+
});
|
|
2999
|
+
}
|
|
3000
|
+
/**
|
|
3001
|
+
* Initiates a Farcaster login attempt and return the URI for the user to connect.
|
|
3002
|
+
* You can create a QR code with this URI that works with Farcaster's mobile app.
|
|
3003
|
+
* @deprecated
|
|
3004
|
+
* @return {string} the Farcaster connect URI
|
|
3005
|
+
*/
|
|
3006
|
+
getFarcasterConnectURL() {
|
|
3007
|
+
return __async(this, null, function* () {
|
|
3008
|
+
yield this.logout();
|
|
3009
|
+
yield this.touchSession(true);
|
|
3010
|
+
const {
|
|
3011
|
+
data: { connect_uri }
|
|
3012
|
+
} = yield this.ctx.client.initializeFarcasterLogin();
|
|
3013
|
+
return connect_uri;
|
|
3014
|
+
});
|
|
3015
|
+
}
|
|
3016
|
+
/**
|
|
3017
|
+
* Awaits the response from a user's attempt to log in with Farcaster.
|
|
3018
|
+
* If successful, this returns the user's Farcaster username and profile picture and indicates whether the user already exists.
|
|
3019
|
+
* @deprecated
|
|
3020
|
+
* @return {Object} `{userExists: boolean; username: string; pfpUrl?: string | null }` - the user's information and whether the user already exists.
|
|
3021
|
+
*/
|
|
3022
|
+
waitForFarcasterStatus() {
|
|
3023
|
+
return __async(this, null, function* () {
|
|
3024
|
+
this.isAwaitingFarcaster = true;
|
|
3025
|
+
while (this.isAwaitingFarcaster) {
|
|
3026
|
+
try {
|
|
3027
|
+
yield new Promise((resolve) => setTimeout(resolve, POLLING_INTERVAL_MS));
|
|
3028
|
+
const res = yield this.ctx.client.getFarcasterAuthStatus();
|
|
3029
|
+
if (res.data.state === "completed") {
|
|
3030
|
+
const { userId, userExists, username, pfpUrl } = res.data;
|
|
3031
|
+
yield this.setAuth(
|
|
3032
|
+
{ farcasterUsername: username },
|
|
3033
|
+
{ extras: { pfpUrl, username, displayName: username }, userId }
|
|
3034
|
+
);
|
|
3035
|
+
return {
|
|
3036
|
+
userId,
|
|
3037
|
+
userExists,
|
|
3038
|
+
username,
|
|
3039
|
+
pfpUrl
|
|
3040
|
+
};
|
|
3041
|
+
}
|
|
3042
|
+
} catch (err) {
|
|
3043
|
+
console.error(err);
|
|
3044
|
+
this.isAwaitingFarcaster = false;
|
|
3045
|
+
}
|
|
3046
|
+
}
|
|
3047
|
+
});
|
|
3048
|
+
}
|
|
3049
|
+
/**
|
|
3050
|
+
* Generates a URL for the user to log in with OAuth using a desire method.
|
|
3051
|
+
* @deprecated
|
|
3052
|
+
* @param {Object} opts the options object
|
|
3053
|
+
* @param {OAuthMethod} opts.method the third-party service to use for OAuth.
|
|
3054
|
+
* @param {string} [opts.deeplinkUrl] the deeplink to redirect to after the OAuth flow. This is for mobile only.
|
|
3055
|
+
* @returns {string} the URL for the user to log in with OAuth.
|
|
3056
|
+
*/
|
|
3057
|
+
getOAuthURL(_0) {
|
|
3058
|
+
return __async(this, arguments, function* ({ method, deeplinkUrl }) {
|
|
3059
|
+
yield this.logout();
|
|
3060
|
+
const { sessionLookupId } = yield this.touchSession(true);
|
|
3061
|
+
return constructUrl({
|
|
3062
|
+
base: method === import_user_management_client5.OAuthMethod.TELEGRAM ? getPortalBaseURL(this.ctx, true) : getBaseOAuthUrl(this.ctx.env),
|
|
3063
|
+
path: `/auth/${method.toLowerCase()}`,
|
|
3064
|
+
params: {
|
|
3065
|
+
apiKey: this.ctx.apiKey,
|
|
3066
|
+
sessionLookupId,
|
|
3067
|
+
deeplinkUrl
|
|
3068
|
+
}
|
|
3069
|
+
});
|
|
3070
|
+
});
|
|
3071
|
+
}
|
|
3072
|
+
/**
|
|
3073
|
+
* Awaits the response from a user's attempt to log in with OAuth.
|
|
3074
|
+
* If successful, this returns the user's email address and indicates whether the user already exists.
|
|
3075
|
+
* @deprecated
|
|
3076
|
+
* @param {Object} opts the options object.
|
|
3077
|
+
* @param {Window} [opts.popupWindow] the popup window being used for login.
|
|
3078
|
+
* @return {Object} `{ email?: string; isError?: boolean; userExists: boolean; }` the result data
|
|
3079
|
+
*/
|
|
3080
|
+
waitForOAuth() {
|
|
3081
|
+
return __async(this, arguments, function* ({ popupWindow } = {}) {
|
|
3082
|
+
this.isAwaitingOAuth = true;
|
|
3083
|
+
while (this.isAwaitingOAuth) {
|
|
3084
|
+
try {
|
|
3085
|
+
if (popupWindow == null ? void 0 : popupWindow.closed) {
|
|
3086
|
+
return { isError: true, userExists: false };
|
|
3087
|
+
}
|
|
3088
|
+
yield new Promise((resolve) => setTimeout(resolve, POLLING_INTERVAL_MS));
|
|
3089
|
+
if (this.isAwaitingOAuth) {
|
|
3090
|
+
const { userId, email } = yield this.touchSession();
|
|
3091
|
+
if (!!userId) {
|
|
3092
|
+
if (!this.loginEncryptionKeyPair) {
|
|
3093
|
+
yield this.setLoginEncryptionKeyPair();
|
|
3094
|
+
}
|
|
3095
|
+
yield this.setUserId(userId);
|
|
3096
|
+
yield this.setEmail(email);
|
|
3097
|
+
this.isAwaitingOAuth = false;
|
|
3098
|
+
return {
|
|
3099
|
+
userExists: true,
|
|
3100
|
+
email
|
|
3101
|
+
};
|
|
3102
|
+
}
|
|
3103
|
+
}
|
|
3104
|
+
} catch (err) {
|
|
3105
|
+
console.error(err);
|
|
3106
|
+
}
|
|
3107
|
+
}
|
|
3108
|
+
return { userExists: false };
|
|
3109
|
+
});
|
|
3110
|
+
}
|
|
3111
|
+
/**
|
|
3112
|
+
* Waits for the session to be active and sets up the user.
|
|
3113
|
+
* @deprecated
|
|
3114
|
+
* @param {Object} opts the options object
|
|
3115
|
+
* @param {Window} [opts.popupWindow] the popup window being used for login.
|
|
3116
|
+
* @param {boolean} [opts.skipSessionRefresh] whether to skip refreshing the session.
|
|
3117
|
+
* @returns {Object} `{ isComplete: boolean; isError: boolean; needsWallet: boolean; partnerId: string; }` the result data
|
|
3118
|
+
**/
|
|
3119
|
+
waitForLoginAndSetup() {
|
|
3120
|
+
return __async(this, arguments, function* ({
|
|
3121
|
+
popupWindow,
|
|
3122
|
+
skipSessionRefresh = false
|
|
3123
|
+
} = {}) {
|
|
3124
|
+
var _a;
|
|
3125
|
+
if (!this.isExternalWalletAuth) {
|
|
3126
|
+
this.externalWallets = {};
|
|
3127
|
+
}
|
|
3128
|
+
this.isAwaitingLogin = true;
|
|
3129
|
+
while (this.isAwaitingLogin) {
|
|
3130
|
+
let session;
|
|
3131
|
+
try {
|
|
3132
|
+
yield new Promise((resolve) => setTimeout(resolve, POLLING_INTERVAL_MS));
|
|
3133
|
+
session = yield this.touchSession();
|
|
3134
|
+
if (!session.isAuthenticated) {
|
|
3135
|
+
if (popupWindow == null ? void 0 : popupWindow.closed) {
|
|
3136
|
+
const resp2 = { isComplete: false, isError: true };
|
|
3137
|
+
dispatchEvent(ParaEvent.LOGIN_EVENT, resp2, "failed to setup user");
|
|
3138
|
+
return resp2;
|
|
3139
|
+
}
|
|
3140
|
+
continue;
|
|
3141
|
+
}
|
|
3142
|
+
session = yield this.userSetupAfterLogin();
|
|
3143
|
+
const needsWallet = (_a = session.needsWallet) != null ? _a : false;
|
|
3144
|
+
if (!needsWallet) {
|
|
3145
|
+
if (this.currentWalletIdsArray.length === 0) {
|
|
3146
|
+
if (popupWindow == null ? void 0 : popupWindow.closed) {
|
|
3147
|
+
const resp2 = { isComplete: false, isError: true };
|
|
3148
|
+
dispatchEvent(ParaEvent.LOGIN_EVENT, resp2, "failed to setup user");
|
|
3149
|
+
return resp2;
|
|
3150
|
+
} else {
|
|
3151
|
+
continue;
|
|
3152
|
+
}
|
|
3153
|
+
}
|
|
3154
|
+
}
|
|
3155
|
+
const fetchedWallets = yield this.fetchWallets();
|
|
3156
|
+
const tempSharesRes = yield this.getTransmissionKeyShares();
|
|
3157
|
+
if (tempSharesRes.data.temporaryShares.length === fetchedWallets.length) {
|
|
3158
|
+
yield this.setupAfterLogin({ temporaryShares: tempSharesRes.data.temporaryShares, skipSessionRefresh });
|
|
3159
|
+
yield this.claimPregenWallets();
|
|
3160
|
+
const resp2 = {
|
|
3161
|
+
isComplete: true,
|
|
3162
|
+
needsWallet: needsWallet || Object.values(this.wallets).length === 0,
|
|
3163
|
+
partnerId: session.partnerId
|
|
3164
|
+
};
|
|
3165
|
+
dispatchEvent(ParaEvent.LOGIN_EVENT, resp2);
|
|
3166
|
+
return resp2;
|
|
3167
|
+
}
|
|
3168
|
+
} catch (err) {
|
|
3169
|
+
console.error(err);
|
|
3170
|
+
}
|
|
3171
|
+
}
|
|
3172
|
+
const resp = { isComplete: false };
|
|
3173
|
+
dispatchEvent(ParaEvent.LOGIN_EVENT, resp, "exitted login without setting up user");
|
|
3174
|
+
return resp;
|
|
3175
|
+
});
|
|
3176
|
+
}
|
|
3177
|
+
/**
|
|
3178
|
+
* Updates the session with the user management server, possibly
|
|
3179
|
+
* opening a popup to refresh the session.
|
|
3180
|
+
*
|
|
3181
|
+
* @param {Object} opts the options object.
|
|
3182
|
+
* @param {boolean} [shouldOpenPopup] - if `true`, the running device will open a popup to reauthenticate the user.
|
|
3183
|
+
* @returns a URL for the user to reauthenticate.
|
|
3184
|
+
**/
|
|
3185
|
+
refreshSession() {
|
|
3186
|
+
return __async(this, arguments, function* ({
|
|
3187
|
+
shouldOpenPopup = false
|
|
3188
|
+
} = {}) {
|
|
3189
|
+
const { sessionId } = yield this.touchSession(true);
|
|
3190
|
+
if (!this.loginEncryptionKeyPair) {
|
|
3191
|
+
yield this.setLoginEncryptionKeyPair();
|
|
3192
|
+
}
|
|
3193
|
+
const link = yield this.getWebAuthURLForLogin({
|
|
3194
|
+
sessionId,
|
|
3195
|
+
loginEncryptionPublicKey: getPublicKeyHex(this.loginEncryptionKeyPair)
|
|
3196
|
+
});
|
|
3197
|
+
if (shouldOpenPopup) {
|
|
3198
|
+
this.platformUtils.openPopup(link);
|
|
3199
|
+
}
|
|
3200
|
+
return link;
|
|
3201
|
+
});
|
|
3202
|
+
}
|
|
3203
|
+
/**
|
|
3204
|
+
* Call this method after login to ensure that the user ID is set
|
|
3205
|
+
* internally.
|
|
3206
|
+
**/
|
|
3207
|
+
userSetupAfterLogin() {
|
|
3208
|
+
return __async(this, null, function* () {
|
|
3209
|
+
const session = yield this.touchSession();
|
|
3210
|
+
yield this.setUserId(session.userId);
|
|
3211
|
+
if (session.currentWalletIds && session.currentWalletIds !== this.currentWalletIds)
|
|
3212
|
+
yield this.setCurrentWalletIds(session.currentWalletIds, {
|
|
3213
|
+
sessionLookupId: this.isPortal() ? session.sessionLookupId : void 0
|
|
3214
|
+
});
|
|
3215
|
+
return session;
|
|
3216
|
+
});
|
|
3217
|
+
}
|
|
3218
|
+
/**
|
|
3219
|
+
* Get transmission shares associated with session.
|
|
3220
|
+
* @param {Object} opts the options object.
|
|
3221
|
+
* @param {boolean} opts.isForNewDevice - true if this device is registering.
|
|
3222
|
+
* @returns - transmission keyshares.
|
|
3223
|
+
**/
|
|
3224
|
+
getTransmissionKeyShares() {
|
|
3225
|
+
return __async(this, arguments, function* ({ isForNewDevice = false } = {}) {
|
|
3226
|
+
const session = yield this.touchSession();
|
|
3227
|
+
const sessionLookupId = isForNewDevice ? `${session.sessionLookupId}-new-device` : session.sessionLookupId;
|
|
3228
|
+
return this.ctx.client.getTransmissionKeyshares(this.userId, sessionLookupId);
|
|
3229
|
+
});
|
|
3230
|
+
}
|
|
3231
|
+
/**
|
|
3232
|
+
* Call this method after login to perform setup.
|
|
3233
|
+
* @param {Object} opts the options object.
|
|
3234
|
+
* @param {any[]} opts.temporaryShares optional temporary shares to use for decryption.
|
|
3235
|
+
* @param {boolean} [opts.skipSessionRefresh] - whether or not to skip refreshing the session.
|
|
3236
|
+
**/
|
|
3237
|
+
setupAfterLogin() {
|
|
3238
|
+
return __async(this, arguments, function* ({
|
|
3239
|
+
temporaryShares,
|
|
3240
|
+
skipSessionRefresh = false
|
|
3241
|
+
} = {}) {
|
|
3242
|
+
if (!temporaryShares) {
|
|
3243
|
+
temporaryShares = (yield this.getTransmissionKeyShares()).data.temporaryShares;
|
|
3244
|
+
}
|
|
3245
|
+
temporaryShares.forEach((share) => {
|
|
3246
|
+
const signer = decryptWithPrivateKey(this.loginEncryptionKeyPair.privateKey, share.encryptedShare, share.encryptedKey);
|
|
3247
|
+
this.wallets[share.walletId] = {
|
|
3248
|
+
id: share.walletId,
|
|
3249
|
+
signer
|
|
3250
|
+
};
|
|
3251
|
+
});
|
|
3252
|
+
yield this.deleteLoginEncryptionKeyPair();
|
|
3253
|
+
yield this.populateWalletAddresses();
|
|
3254
|
+
yield this.touchSession(!skipSessionRefresh);
|
|
3255
|
+
});
|
|
3256
|
+
}
|
|
3257
|
+
/**
|
|
3258
|
+
* Distributes a new wallet recovery share.
|
|
3259
|
+
* @param {Object} opts the options object.
|
|
3260
|
+
* @param {string} opts.walletId the wallet to distribute the recovery share for.
|
|
3261
|
+
* @param {string} opts.userShare optional user share generate the recovery share from. Defaults to the signer from the passed in walletId
|
|
3262
|
+
* @param {boolean} opts.skipBiometricShareCreation whether or not to skip biometric share creation. Used when regenerating recovery shares.
|
|
3263
|
+
* @param {boolean} opts.forceRefreshRecovery whether or not to force recovery secret regeneration. Used when regenerating recovery shares.
|
|
3264
|
+
* @returns {string} the recovery share.
|
|
3265
|
+
**/
|
|
3266
|
+
distributeNewWalletShare(_0) {
|
|
3267
|
+
return __async(this, arguments, function* ({
|
|
3268
|
+
walletId,
|
|
3269
|
+
userShare,
|
|
3270
|
+
skipBiometricShareCreation = false,
|
|
3271
|
+
forceRefresh = false
|
|
3272
|
+
}) {
|
|
3273
|
+
let userSigner = userShare;
|
|
3274
|
+
if (!userSigner) {
|
|
3275
|
+
userSigner = this.wallets[walletId].signer;
|
|
3276
|
+
}
|
|
3277
|
+
const recoveryShare = skipBiometricShareCreation ? yield sendRecoveryForShare({
|
|
3278
|
+
ctx: this.ctx,
|
|
3279
|
+
userId: this.userId,
|
|
3280
|
+
walletId,
|
|
3281
|
+
userSigner,
|
|
3282
|
+
emailProps: this.getBackupKitEmailProps(),
|
|
3283
|
+
forceRefresh
|
|
3284
|
+
}) : yield distributeNewShare({
|
|
3285
|
+
ctx: this.ctx,
|
|
3286
|
+
userId: this.userId,
|
|
3287
|
+
walletId,
|
|
3288
|
+
userShare: userSigner,
|
|
3289
|
+
emailProps: this.getBackupKitEmailProps()
|
|
3290
|
+
});
|
|
3291
|
+
return recoveryShare;
|
|
3292
|
+
});
|
|
3293
|
+
}
|
|
3294
|
+
waitForWalletAddress(walletId) {
|
|
3295
|
+
return __async(this, null, function* () {
|
|
3296
|
+
let maxPolls = 0;
|
|
3297
|
+
while (true) {
|
|
3298
|
+
try {
|
|
3299
|
+
if (maxPolls === 10) {
|
|
3300
|
+
break;
|
|
3301
|
+
}
|
|
3302
|
+
++maxPolls;
|
|
3303
|
+
const res = yield this.ctx.client.getWallets(this.userId);
|
|
3304
|
+
const wallet = res.data.wallets.find((w) => w.id === walletId);
|
|
3305
|
+
if (wallet && wallet.address) {
|
|
3306
|
+
return;
|
|
3307
|
+
}
|
|
3308
|
+
yield new Promise((resolve) => setTimeout(resolve, SHORT_POLLING_INTERVAL_MS));
|
|
3309
|
+
} catch (err) {
|
|
3310
|
+
console.error(err);
|
|
3311
|
+
}
|
|
3312
|
+
}
|
|
3313
|
+
throw new Error("timed out waiting for wallet address");
|
|
3314
|
+
});
|
|
3315
|
+
}
|
|
3316
|
+
/**
|
|
3317
|
+
* Waits for a pregen wallet address to be created.
|
|
3318
|
+
*
|
|
3319
|
+
* @param pregenIdentifier - the identifier of the user the pregen wallet is associated with.
|
|
3320
|
+
* @param walletId - the wallet id
|
|
3321
|
+
* @param pregenIdentifierType - the identifier type of the user the pregen wallet is associated with.
|
|
3322
|
+
* @returns - recovery share.
|
|
3323
|
+
**/
|
|
3324
|
+
waitForPregenWalletAddress(walletId) {
|
|
3325
|
+
return __async(this, null, function* () {
|
|
3326
|
+
let maxPolls = 0;
|
|
3327
|
+
while (true) {
|
|
3328
|
+
try {
|
|
3329
|
+
if (maxPolls === 10) {
|
|
3330
|
+
break;
|
|
3331
|
+
}
|
|
3332
|
+
++maxPolls;
|
|
3333
|
+
const res = yield this.getPregenWalletsV2();
|
|
3334
|
+
const wallet = res.find((w) => w.id === walletId);
|
|
3335
|
+
if (wallet && wallet.address) {
|
|
3336
|
+
return;
|
|
3337
|
+
}
|
|
3338
|
+
yield new Promise((resolve) => setTimeout(resolve, SHORT_POLLING_INTERVAL_MS));
|
|
3339
|
+
} catch (err) {
|
|
3340
|
+
console.error(err);
|
|
3341
|
+
}
|
|
3342
|
+
}
|
|
3343
|
+
throw new Error("timed out waiting for wallet address");
|
|
3344
|
+
});
|
|
3345
|
+
}
|
|
3346
|
+
/**
|
|
3347
|
+
* Creates several new wallets with the desired types. If no types are provided, this method
|
|
3348
|
+
* will create one for each of the non-optional types specified in the instance's `supportedWalletTypes`
|
|
3349
|
+
* object that are not already present. This is automatically called upon account creation to ensure that
|
|
3350
|
+
* the user has a wallet of each required type.
|
|
3351
|
+
*
|
|
3352
|
+
* @param {Object} [opts] the options object.
|
|
3353
|
+
* @param {boolean} [opts.skipDistribute] if `true`, the wallets' recovery share will not be distributed.
|
|
3354
|
+
* @param {WalletType[]} [opts.types] the types of wallets to create.
|
|
3355
|
+
* @returns {Object} the wallets created, their ids, and the recovery secret.
|
|
3356
|
+
**/
|
|
3357
|
+
createWalletPerType() {
|
|
3358
|
+
return __async(this, arguments, function* ({
|
|
3359
|
+
skipDistribute = false,
|
|
3360
|
+
types
|
|
3361
|
+
} = {}) {
|
|
3362
|
+
const wallets = [];
|
|
3363
|
+
const walletIds = {};
|
|
3364
|
+
let recoverySecret;
|
|
3365
|
+
for (const type of yield this.getTypesToCreate(types)) {
|
|
3366
|
+
const [wallet, recoveryShare] = yield this.createWallet({ type, skipDistribute });
|
|
3367
|
+
wallets.push(wallet);
|
|
3368
|
+
getEquivalentTypes(type).filter((t) => !!this.isWalletTypeEnabled[t]).forEach((t) => {
|
|
3369
|
+
walletIds[t] = [wallet.id];
|
|
3370
|
+
});
|
|
3371
|
+
if (recoveryShare) {
|
|
3372
|
+
recoverySecret = recoveryShare;
|
|
3373
|
+
}
|
|
3374
|
+
}
|
|
3375
|
+
return { wallets, walletIds, recoverySecret };
|
|
3376
|
+
});
|
|
3377
|
+
}
|
|
3378
|
+
/**
|
|
3379
|
+
* Refresh the current user share for a wallet.
|
|
3380
|
+
*
|
|
3381
|
+
* @param {Object} opts the options object.
|
|
3382
|
+
* @param {string} opts.walletId the wallet id to refresh.
|
|
3383
|
+
* @param {string} opts.share the current user share.
|
|
3384
|
+
* @param {string} [opts.oldPartnerId] the current partner id.
|
|
3385
|
+
* @param {string} [opts.newPartnerId] the new partner id to set, if any.
|
|
3386
|
+
* @param {string} [opts.keyShareProtocolId]
|
|
3387
|
+
* @param {boolean} [opts.redistributeBackupEncryptedShares] whether or not to redistribute backup encrypted shares.
|
|
3388
|
+
* @returns {Object} the new user share and recovery secret.
|
|
3389
|
+
**/
|
|
3390
|
+
refreshShare(_0) {
|
|
3391
|
+
return __async(this, arguments, function* ({
|
|
3392
|
+
walletId,
|
|
3393
|
+
share,
|
|
3394
|
+
oldPartnerId,
|
|
3395
|
+
newPartnerId,
|
|
3396
|
+
keyShareProtocolId,
|
|
3397
|
+
redistributeBackupEncryptedShares
|
|
3398
|
+
}) {
|
|
3399
|
+
const { signer, protocolId } = yield this.platformUtils.refresh(
|
|
3400
|
+
this.ctx,
|
|
3401
|
+
this.retrieveSessionCookie(),
|
|
3402
|
+
this.userId,
|
|
3403
|
+
walletId,
|
|
3404
|
+
share,
|
|
3405
|
+
oldPartnerId,
|
|
3406
|
+
newPartnerId,
|
|
3407
|
+
keyShareProtocolId
|
|
3408
|
+
);
|
|
3409
|
+
const recoverySecret = yield distributeNewShare({
|
|
3410
|
+
ctx: this.ctx,
|
|
3411
|
+
userId: this.userId,
|
|
3412
|
+
walletId,
|
|
3413
|
+
userShare: signer,
|
|
3414
|
+
ignoreRedistributingBackupEncryptedShare: !redistributeBackupEncryptedShares,
|
|
3415
|
+
emailProps: this.getBackupKitEmailProps(),
|
|
3416
|
+
partnerId: newPartnerId,
|
|
3417
|
+
protocolId
|
|
3418
|
+
});
|
|
3419
|
+
return { signer, recoverySecret, protocolId };
|
|
3420
|
+
});
|
|
3421
|
+
}
|
|
3422
|
+
/**
|
|
3423
|
+
* Creates a new wallet.
|
|
3424
|
+
* @param {Object} opts the options object.
|
|
3425
|
+
* @param {WalletType} opts.type the type of wallet to create.
|
|
3426
|
+
* @param {boolean} opts.skipDistribute - if true, recovery share will not be distributed.
|
|
3427
|
+
* @returns {[Wallet, string | null]} `[wallet, recoveryShare]` - the wallet object and the new recovery share.
|
|
3428
|
+
**/
|
|
3429
|
+
createWallet() {
|
|
3430
|
+
return __async(this, arguments, function* ({
|
|
3431
|
+
type: _type,
|
|
3432
|
+
skipDistribute = false
|
|
3433
|
+
} = {}) {
|
|
3434
|
+
var _a, _b;
|
|
3435
|
+
this.requireApiKey();
|
|
3436
|
+
const { supportedWalletTypes } = yield __privateMethod(this, _ParaCore_instances, assertPartner_fn).call(this);
|
|
3437
|
+
const walletType = yield this.assertIsValidWalletType(
|
|
3438
|
+
_type != null ? _type : (_a = supportedWalletTypes.find(({ optional }) => !optional)) == null ? void 0 : _a.type
|
|
3439
|
+
);
|
|
3440
|
+
let signer;
|
|
3441
|
+
let wallet;
|
|
3442
|
+
let keygenRes;
|
|
3443
|
+
switch (walletType) {
|
|
3444
|
+
case import_user_management_client5.WalletType.SOLANA: {
|
|
3445
|
+
keygenRes = yield this.platformUtils.ed25519Keygen(
|
|
3446
|
+
this.ctx,
|
|
3447
|
+
this.userId,
|
|
3448
|
+
this.retrieveSessionCookie(),
|
|
3449
|
+
this.getBackupKitEmailProps()
|
|
3450
|
+
);
|
|
3451
|
+
break;
|
|
3452
|
+
}
|
|
3453
|
+
default: {
|
|
3454
|
+
keygenRes = yield this.platformUtils.keygen(
|
|
3455
|
+
this.ctx,
|
|
3456
|
+
this.userId,
|
|
3457
|
+
walletType,
|
|
3458
|
+
null,
|
|
3459
|
+
this.retrieveSessionCookie(),
|
|
3460
|
+
this.getBackupKitEmailProps()
|
|
3461
|
+
);
|
|
3462
|
+
break;
|
|
3463
|
+
}
|
|
3464
|
+
}
|
|
3465
|
+
const walletId = keygenRes.walletId;
|
|
3466
|
+
signer = keygenRes.signer;
|
|
3467
|
+
this.wallets[walletId] = {
|
|
3468
|
+
id: walletId,
|
|
3469
|
+
signer,
|
|
3470
|
+
scheme: walletType === import_user_management_client5.WalletType.SOLANA ? import_user_management_client5.WalletScheme.ED25519 : import_user_management_client5.WalletScheme.DKLS,
|
|
3471
|
+
type: walletType
|
|
3472
|
+
};
|
|
3473
|
+
wallet = this.wallets[walletId];
|
|
3474
|
+
yield this.waitForWalletAddress(wallet.id);
|
|
3475
|
+
yield this.populateWalletAddresses();
|
|
3476
|
+
let recoveryShare = null;
|
|
3477
|
+
if (!skipDistribute) {
|
|
3478
|
+
recoveryShare = yield distributeNewShare({
|
|
3479
|
+
ctx: this.ctx,
|
|
3480
|
+
userId: this.userId,
|
|
3481
|
+
walletId: wallet.id,
|
|
3482
|
+
userShare: signer,
|
|
3483
|
+
emailProps: this.getBackupKitEmailProps()
|
|
3484
|
+
});
|
|
3485
|
+
}
|
|
3486
|
+
yield this.setCurrentWalletIds(__spreadProps(__spreadValues({}, this.currentWalletIds), {
|
|
3487
|
+
[walletType]: [.../* @__PURE__ */ new Set([...(_b = this.currentWalletIds[walletType]) != null ? _b : [], walletId])]
|
|
3488
|
+
}));
|
|
3489
|
+
const walletNoSigner = __spreadValues({}, wallet);
|
|
3490
|
+
delete walletNoSigner.signer;
|
|
3491
|
+
dispatchEvent(ParaEvent.WALLET_CREATED, {
|
|
3492
|
+
wallet: walletNoSigner,
|
|
3493
|
+
recoverySecret: recoveryShare
|
|
3494
|
+
});
|
|
3495
|
+
return [wallet, recoveryShare];
|
|
3496
|
+
});
|
|
3497
|
+
}
|
|
3498
|
+
/**
|
|
3499
|
+
* Creates a new pregenerated wallet.
|
|
3500
|
+
* @deprecated
|
|
3501
|
+
* @param {Object} opts the options object.
|
|
3502
|
+
* @param {string} opts.pregenIdentifier the identifier associated with the new wallet.
|
|
3503
|
+
* @param {TPregenIdentifierType} [opts.pregenIdentifierType] the identifier type. Defaults to `EMAIL`.
|
|
3504
|
+
* @param {WalletType} [opts.type] the type of wallet to create. Defaults to the first non-optional type in the instance's `supportedWalletTypes` array.
|
|
3505
|
+
* @returns {Wallet} the created wallet.
|
|
3506
|
+
**/
|
|
3507
|
+
createPregenWallet(opts) {
|
|
3508
|
+
return __async(this, null, function* () {
|
|
3509
|
+
var _a, _b;
|
|
3510
|
+
const { supportedWalletTypes } = yield __privateMethod(this, _ParaCore_instances, assertPartner_fn).call(this);
|
|
3511
|
+
const {
|
|
3512
|
+
type: _type = (_a = supportedWalletTypes.find(({ optional }) => !optional)) == null ? void 0 : _a.type,
|
|
3513
|
+
pregenIdentifier,
|
|
3514
|
+
pregenIdentifierType = "EMAIL"
|
|
3515
|
+
} = opts;
|
|
3516
|
+
this.requireApiKey();
|
|
3517
|
+
const walletType = yield this.assertIsValidWalletType(
|
|
3518
|
+
_type != null ? _type : (_b = supportedWalletTypes.find(({ optional }) => !optional)) == null ? void 0 : _b.type
|
|
3519
|
+
);
|
|
3520
|
+
let keygenRes;
|
|
3521
|
+
switch (walletType) {
|
|
3522
|
+
case import_user_management_client5.WalletType.SOLANA:
|
|
3523
|
+
keygenRes = yield this.platformUtils.ed25519PreKeygen(
|
|
3524
|
+
this.ctx,
|
|
3525
|
+
pregenIdentifier,
|
|
3526
|
+
pregenIdentifierType,
|
|
3527
|
+
this.retrieveSessionCookie()
|
|
3528
|
+
);
|
|
3529
|
+
break;
|
|
3530
|
+
default:
|
|
3531
|
+
keygenRes = yield this.platformUtils.preKeygen(
|
|
3532
|
+
this.ctx,
|
|
3533
|
+
void 0,
|
|
3534
|
+
pregenIdentifier,
|
|
3535
|
+
pregenIdentifierType,
|
|
3536
|
+
walletType,
|
|
3537
|
+
null,
|
|
3538
|
+
this.retrieveSessionCookie()
|
|
3539
|
+
);
|
|
3540
|
+
break;
|
|
3541
|
+
}
|
|
3542
|
+
const { signer, walletId } = keygenRes;
|
|
3543
|
+
this.wallets[walletId] = {
|
|
3544
|
+
id: walletId,
|
|
3545
|
+
signer,
|
|
3546
|
+
scheme: walletType === import_user_management_client5.WalletType.SOLANA ? import_user_management_client5.WalletScheme.ED25519 : import_user_management_client5.WalletScheme.DKLS,
|
|
3547
|
+
type: walletType,
|
|
3548
|
+
isPregen: true,
|
|
3549
|
+
pregenIdentifier,
|
|
3550
|
+
pregenIdentifierType
|
|
3551
|
+
};
|
|
3552
|
+
yield this.waitForPregenWalletAddress(walletId);
|
|
3553
|
+
yield this.populatePregenWalletAddresses();
|
|
3554
|
+
return this.wallets[walletId];
|
|
3555
|
+
});
|
|
3556
|
+
}
|
|
3557
|
+
/**
|
|
3558
|
+
* Creates new pregenerated wallets for each desired type.
|
|
3559
|
+
* If no types are provided, this method will create one for each of the non-optional types
|
|
3560
|
+
* specified in the instance's `supportedWalletTypes` array that are not already present.
|
|
3561
|
+
* @deprecated
|
|
3562
|
+
* @param {Object} opts the options object.
|
|
3563
|
+
* @param {string} opts.pregenIdentifier the identifier to associate each wallet with.
|
|
3564
|
+
* @param {TPregenIdentifierType} opts.pregenIdentifierType - either `'EMAIL'` or `'PHONE'`.
|
|
3565
|
+
* @param {WalletType[]} [opts.types] the wallet types to create. Defaults to any types the instance supports that are not already present.
|
|
3566
|
+
* @returns {Wallet[]} an array containing the created wallets.
|
|
3567
|
+
**/
|
|
3568
|
+
createPregenWalletPerType(_0) {
|
|
3569
|
+
return __async(this, arguments, function* ({
|
|
3570
|
+
types,
|
|
3571
|
+
pregenIdentifier,
|
|
3572
|
+
pregenIdentifierType = "EMAIL"
|
|
3573
|
+
}) {
|
|
3574
|
+
const wallets = [];
|
|
3575
|
+
for (const type of yield this.getTypesToCreate(types)) {
|
|
3576
|
+
const wallet = yield this.createPregenWallet({ type, pregenIdentifier, pregenIdentifierType });
|
|
3577
|
+
wallets.push(wallet);
|
|
3578
|
+
}
|
|
3579
|
+
return wallets;
|
|
3580
|
+
});
|
|
3581
|
+
}
|
|
3582
|
+
/**
|
|
3583
|
+
* Claims a pregenerated wallet.
|
|
3584
|
+
* @deprecated
|
|
3585
|
+
* @param {Object} opts the options object.
|
|
3586
|
+
* @param {string} opts.pregenIdentifier string the identifier of the user claiming the wallet
|
|
3587
|
+
* @param {TPregenIdentifierType} opts.pregenIdentifierType type of the identifier of the user claiming the wallet
|
|
3588
|
+
* @returns {[Wallet, string | null]} `[wallet, recoveryShare]` - the wallet object and the new recovery share.
|
|
3589
|
+
**/
|
|
3590
|
+
claimPregenWallets() {
|
|
3591
|
+
return __async(this, arguments, function* ({
|
|
3592
|
+
pregenIdentifier,
|
|
3593
|
+
pregenIdentifierType = !!pregenIdentifier ? "EMAIL" : void 0
|
|
3594
|
+
} = {}) {
|
|
3595
|
+
var _a;
|
|
3596
|
+
this.requireApiKey();
|
|
3597
|
+
const pregenWallets = pregenIdentifier && pregenIdentifierType ? yield this.getPregenWallets({ pregenIdentifier, pregenIdentifierType }) : yield this.getPregenWallets();
|
|
3598
|
+
if (pregenWallets.length === 0) {
|
|
3599
|
+
return void 0;
|
|
3600
|
+
}
|
|
3601
|
+
let newRecoverySecret;
|
|
3602
|
+
const { walletIds } = yield this.ctx.client.claimPregenWallets({
|
|
3603
|
+
userId: this.userId,
|
|
3604
|
+
walletIds: pregenWallets.map((w) => w.id)
|
|
3605
|
+
});
|
|
3606
|
+
for (const walletId of walletIds) {
|
|
3607
|
+
const wallet = this.wallets[walletId];
|
|
3608
|
+
let refreshedShare;
|
|
3609
|
+
if (wallet.scheme === import_user_management_client5.WalletScheme.ED25519) {
|
|
3610
|
+
const distributeRes = yield distributeNewShare({
|
|
3611
|
+
ctx: this.ctx,
|
|
3612
|
+
userId: this.userId,
|
|
3613
|
+
walletId: wallet.id,
|
|
3614
|
+
userShare: this.wallets[wallet.id].signer,
|
|
3615
|
+
emailProps: this.getBackupKitEmailProps(),
|
|
3616
|
+
partnerId: wallet.partnerId
|
|
3617
|
+
});
|
|
3618
|
+
if (distributeRes.length > 0) {
|
|
3619
|
+
newRecoverySecret = distributeRes;
|
|
3620
|
+
}
|
|
3621
|
+
} else {
|
|
3622
|
+
refreshedShare = yield this.refreshShare({
|
|
3623
|
+
walletId: wallet.id,
|
|
3624
|
+
share: this.wallets[wallet.id].signer,
|
|
3625
|
+
oldPartnerId: wallet.partnerId,
|
|
3626
|
+
newPartnerId: wallet.partnerId,
|
|
3627
|
+
redistributeBackupEncryptedShares: true
|
|
3628
|
+
});
|
|
3629
|
+
if (refreshedShare.recoverySecret) {
|
|
3630
|
+
newRecoverySecret = refreshedShare.recoverySecret;
|
|
3631
|
+
}
|
|
3632
|
+
}
|
|
3633
|
+
this.wallets[wallet.id] = __spreadProps(__spreadValues({}, this.wallets[wallet.id]), {
|
|
3634
|
+
signer: (_a = refreshedShare == null ? void 0 : refreshedShare.signer) != null ? _a : wallet.signer,
|
|
3635
|
+
userId: this.userId,
|
|
3636
|
+
pregenIdentifier: void 0,
|
|
3637
|
+
pregenIdentifierType: void 0
|
|
3638
|
+
});
|
|
3639
|
+
const walletNoSigner = __spreadValues({}, this.wallets[wallet.id]);
|
|
3640
|
+
delete walletNoSigner.signer;
|
|
3641
|
+
dispatchEvent(ParaEvent.PREGEN_WALLET_CLAIMED, {
|
|
3642
|
+
wallet: walletNoSigner,
|
|
3643
|
+
recoverySecret: newRecoverySecret
|
|
3644
|
+
});
|
|
3645
|
+
}
|
|
3646
|
+
yield this.setWallets(this.wallets);
|
|
3647
|
+
return newRecoverySecret;
|
|
2562
3648
|
});
|
|
2563
3649
|
}
|
|
2564
3650
|
/**
|
|
2565
|
-
*
|
|
2566
|
-
*
|
|
2567
|
-
*
|
|
2568
|
-
*
|
|
2569
|
-
*
|
|
2570
|
-
* @param {
|
|
2571
|
-
* @param {boolean} [opts.skipDistribute] if `true`, the wallets' recovery share will not be distributed.
|
|
2572
|
-
* @param {WalletType[]} [opts.types] the types of wallets to create.
|
|
2573
|
-
* @returns {Object} the wallets created, their ids, and the recovery secret.
|
|
3651
|
+
* Updates the identifier for a pregen wallet.
|
|
3652
|
+
* @deprecated
|
|
3653
|
+
* @param {Object} opts the options object.
|
|
3654
|
+
* @param {string} opts.walletId the pregen wallet ID
|
|
3655
|
+
* @param {string} opts.newPregenIdentifier the new identtifier
|
|
3656
|
+
* @param {TPregenIdentifierType} opts.newPregenIdentifierType: the new identifier type
|
|
2574
3657
|
**/
|
|
2575
|
-
|
|
3658
|
+
updatePregenWalletIdentifier(_0) {
|
|
2576
3659
|
return __async(this, arguments, function* ({
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
3660
|
+
walletId,
|
|
3661
|
+
newPregenIdentifier,
|
|
3662
|
+
newPregenIdentifierType
|
|
3663
|
+
}) {
|
|
3664
|
+
this.requireApiKey();
|
|
3665
|
+
yield this.ctx.client.updatePregenWallet(walletId, {
|
|
3666
|
+
pregenIdentifier: newPregenIdentifier,
|
|
3667
|
+
pregenIdentifierType: newPregenIdentifierType
|
|
3668
|
+
});
|
|
3669
|
+
if (!!this.wallets[walletId]) {
|
|
3670
|
+
this.wallets[walletId] = __spreadProps(__spreadValues({}, this.wallets[walletId]), {
|
|
3671
|
+
pregenIdentifier: newPregenIdentifier,
|
|
3672
|
+
pregenIdentifierType: newPregenIdentifierType
|
|
2588
3673
|
});
|
|
2589
|
-
|
|
2590
|
-
recoverySecret = recoveryShare;
|
|
2591
|
-
}
|
|
3674
|
+
yield this.setWallets(this.wallets);
|
|
2592
3675
|
}
|
|
2593
|
-
return { wallets, walletIds, recoverySecret };
|
|
2594
3676
|
});
|
|
2595
3677
|
}
|
|
2596
3678
|
/**
|
|
2597
|
-
*
|
|
2598
|
-
*
|
|
3679
|
+
* Checks if a pregen Wallet exists for the given identifier with the current partner.
|
|
3680
|
+
* @deprecated
|
|
2599
3681
|
* @param {Object} opts the options object.
|
|
2600
|
-
* @param {string} opts.
|
|
2601
|
-
* @param {
|
|
2602
|
-
* @
|
|
2603
|
-
* @param {string} [opts.newPartnerId] the new partner id to set, if any.
|
|
2604
|
-
* @param {string} [opts.keyShareProtocolId]
|
|
2605
|
-
* @param {boolean} [opts.redistributeBackupEncryptedShares] whether or not to redistribute backup encrypted shares.
|
|
2606
|
-
* @returns {Object} the new user share and recovery secret.
|
|
3682
|
+
* @param {string} opts.pregenIdentifier string the identifier of the user claiming the wallet
|
|
3683
|
+
* @param {TPregenIdentifierType} opts.pregenIdentifierType type of the string of the identifier of the user claiming the wallet
|
|
3684
|
+
* @returns {boolean} whether the pregen wallet exists
|
|
2607
3685
|
**/
|
|
2608
|
-
|
|
3686
|
+
hasPregenWallet(_0) {
|
|
2609
3687
|
return __async(this, arguments, function* ({
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
oldPartnerId,
|
|
2613
|
-
newPartnerId,
|
|
2614
|
-
keyShareProtocolId,
|
|
2615
|
-
redistributeBackupEncryptedShares
|
|
3688
|
+
pregenIdentifier,
|
|
3689
|
+
pregenIdentifierType
|
|
2616
3690
|
}) {
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
newPartnerId,
|
|
2625
|
-
keyShareProtocolId
|
|
2626
|
-
);
|
|
2627
|
-
const recoverySecret = yield distributeNewShare({
|
|
2628
|
-
ctx: this.ctx,
|
|
2629
|
-
userId: this.userId,
|
|
2630
|
-
walletId,
|
|
2631
|
-
userShare: signer,
|
|
2632
|
-
ignoreRedistributingBackupEncryptedShare: !redistributeBackupEncryptedShares,
|
|
2633
|
-
emailProps: this.getBackupKitEmailProps(),
|
|
2634
|
-
partnerId: newPartnerId,
|
|
2635
|
-
protocolId
|
|
2636
|
-
});
|
|
2637
|
-
return { signer, recoverySecret, protocolId };
|
|
3691
|
+
this.requireApiKey();
|
|
3692
|
+
const res = yield this.getPregenWallets({ pregenIdentifier, pregenIdentifierType });
|
|
3693
|
+
const wallet = res.find((w) => w.pregenIdentifier === pregenIdentifier && w.pregenIdentifierType === pregenIdentifierType);
|
|
3694
|
+
if (!wallet) {
|
|
3695
|
+
return false;
|
|
3696
|
+
}
|
|
3697
|
+
return true;
|
|
2638
3698
|
});
|
|
2639
3699
|
}
|
|
2640
3700
|
/**
|
|
2641
|
-
*
|
|
3701
|
+
* Get pregen wallets for the given identifier.
|
|
3702
|
+
* @deprecated
|
|
2642
3703
|
* @param {Object} opts the options object.
|
|
2643
|
-
* @param {
|
|
2644
|
-
* @param {
|
|
2645
|
-
* @returns {[
|
|
3704
|
+
* @param {string} opts.pregenIdentifier - the identifier of the user claiming the wallet
|
|
3705
|
+
* @param {TPregenIdentifierType} opts.pregenIdentifierType - type of the identifier of the user claiming the wallet
|
|
3706
|
+
* @returns {Promise<WalletEntity[]>} the array of found wallets
|
|
2646
3707
|
**/
|
|
2647
|
-
|
|
3708
|
+
getPregenWallets() {
|
|
2648
3709
|
return __async(this, arguments, function* ({
|
|
2649
|
-
|
|
2650
|
-
|
|
3710
|
+
pregenIdentifier,
|
|
3711
|
+
pregenIdentifierType = !!pregenIdentifier ? "EMAIL" : void 0
|
|
2651
3712
|
} = {}) {
|
|
2652
|
-
var _a, _b;
|
|
2653
3713
|
this.requireApiKey();
|
|
2654
|
-
const
|
|
2655
|
-
|
|
2656
|
-
|
|
3714
|
+
const res = yield this.ctx.client.getPregenWallets(
|
|
3715
|
+
pregenIdentifier && pregenIdentifierType ? { [pregenIdentifierType]: [pregenIdentifier] } : this.pregenIds,
|
|
3716
|
+
this.isPortal(),
|
|
3717
|
+
this.userId
|
|
2657
3718
|
);
|
|
2658
|
-
|
|
2659
|
-
let wallet;
|
|
2660
|
-
let keygenRes;
|
|
2661
|
-
switch (walletType) {
|
|
2662
|
-
case import_user_management_client5.WalletType.SOLANA: {
|
|
2663
|
-
keygenRes = yield this.platformUtils.ed25519Keygen(
|
|
2664
|
-
this.ctx,
|
|
2665
|
-
this.userId,
|
|
2666
|
-
this.retrieveSessionCookie(),
|
|
2667
|
-
this.getBackupKitEmailProps()
|
|
2668
|
-
);
|
|
2669
|
-
break;
|
|
2670
|
-
}
|
|
2671
|
-
default: {
|
|
2672
|
-
keygenRes = yield this.platformUtils.keygen(
|
|
2673
|
-
this.ctx,
|
|
2674
|
-
this.userId,
|
|
2675
|
-
walletType,
|
|
2676
|
-
null,
|
|
2677
|
-
this.retrieveSessionCookie(),
|
|
2678
|
-
this.getBackupKitEmailProps()
|
|
2679
|
-
);
|
|
2680
|
-
break;
|
|
2681
|
-
}
|
|
2682
|
-
}
|
|
2683
|
-
const walletId = keygenRes.walletId;
|
|
2684
|
-
signer = keygenRes.signer;
|
|
2685
|
-
this.wallets[walletId] = {
|
|
2686
|
-
id: walletId,
|
|
2687
|
-
signer,
|
|
2688
|
-
scheme: walletType === import_user_management_client5.WalletType.SOLANA ? import_user_management_client5.WalletScheme.ED25519 : import_user_management_client5.WalletScheme.DKLS,
|
|
2689
|
-
type: walletType
|
|
2690
|
-
};
|
|
2691
|
-
wallet = this.wallets[walletId];
|
|
2692
|
-
yield this.waitForWalletAddress(wallet.id);
|
|
2693
|
-
yield this.populateWalletAddresses();
|
|
2694
|
-
let recoveryShare = null;
|
|
2695
|
-
if (!skipDistribute) {
|
|
2696
|
-
recoveryShare = yield distributeNewShare({
|
|
2697
|
-
ctx: this.ctx,
|
|
2698
|
-
userId: this.userId,
|
|
2699
|
-
walletId: wallet.id,
|
|
2700
|
-
userShare: signer,
|
|
2701
|
-
emailProps: this.getBackupKitEmailProps()
|
|
2702
|
-
});
|
|
2703
|
-
}
|
|
2704
|
-
yield this.setCurrentWalletIds(__spreadProps(__spreadValues({}, this.currentWalletIds), {
|
|
2705
|
-
[walletType]: [.../* @__PURE__ */ new Set([...(_b = this.currentWalletIds[walletType]) != null ? _b : [], walletId])]
|
|
2706
|
-
}));
|
|
2707
|
-
const walletNoSigner = __spreadValues({}, wallet);
|
|
2708
|
-
delete walletNoSigner.signer;
|
|
2709
|
-
dispatchEvent(ParaEvent.WALLET_CREATED, {
|
|
2710
|
-
wallet: walletNoSigner,
|
|
2711
|
-
recoverySecret: recoveryShare
|
|
2712
|
-
});
|
|
2713
|
-
return [wallet, recoveryShare];
|
|
3719
|
+
return res.wallets.filter((w) => this.isWalletSupported(entityToWallet(w)));
|
|
2714
3720
|
});
|
|
2715
3721
|
}
|
|
2716
3722
|
encodeWalletBase64(wallet) {
|
|
@@ -2748,7 +3754,9 @@ var _ParaCore = class _ParaCore {
|
|
|
2748
3754
|
}
|
|
2749
3755
|
getTransactionReviewUrl(transactionId, timeoutMs) {
|
|
2750
3756
|
return __async(this, null, function* () {
|
|
3757
|
+
const { id: partnerId } = yield __privateMethod(this, _ParaCore_instances, assertPartner_fn).call(this);
|
|
2751
3758
|
return this.constructPortalUrl("txReview", {
|
|
3759
|
+
partnerId,
|
|
2752
3760
|
pathId: transactionId,
|
|
2753
3761
|
params: {
|
|
2754
3762
|
email: this.email,
|
|
@@ -2757,18 +3765,19 @@ var _ParaCore = class _ParaCore {
|
|
|
2757
3765
|
});
|
|
2758
3766
|
});
|
|
2759
3767
|
}
|
|
2760
|
-
getOnRampTransactionUrl(
|
|
3768
|
+
getOnRampTransactionUrl(_i) {
|
|
2761
3769
|
return __async(this, null, function* () {
|
|
2762
|
-
var
|
|
3770
|
+
var _j = _i, {
|
|
2763
3771
|
purchaseId,
|
|
2764
3772
|
providerKey
|
|
2765
|
-
} =
|
|
3773
|
+
} = _j, walletParams = __objRest(_j, [
|
|
2766
3774
|
"purchaseId",
|
|
2767
3775
|
"providerKey"
|
|
2768
3776
|
]);
|
|
2769
|
-
const { sessionId } = yield this.touchSession();
|
|
3777
|
+
const { partnerId, sessionId } = yield this.touchSession();
|
|
2770
3778
|
const [key, identifier] = (0, import_user_management_client5.extractWalletRef)(walletParams);
|
|
2771
3779
|
return this.constructPortalUrl("onRamp", {
|
|
3780
|
+
partnerId,
|
|
2772
3781
|
pathId: purchaseId,
|
|
2773
3782
|
sessionId,
|
|
2774
3783
|
params: {
|
|
@@ -2971,6 +3980,44 @@ var _ParaCore = class _ParaCore {
|
|
|
2971
3980
|
return signRes;
|
|
2972
3981
|
});
|
|
2973
3982
|
}
|
|
3983
|
+
/**
|
|
3984
|
+
* @deprecated
|
|
3985
|
+
* Sends a transaction.
|
|
3986
|
+
* @param walletId - id of the wallet to send the transaction from.
|
|
3987
|
+
* @param rlpEncodedTxBase64 - rlp encoded tx as base64 string
|
|
3988
|
+
* @param chainId - chain id of the chain the transaction is being sent on.
|
|
3989
|
+
**/
|
|
3990
|
+
sendTransaction(_0) {
|
|
3991
|
+
return __async(this, arguments, function* ({
|
|
3992
|
+
walletId,
|
|
3993
|
+
rlpEncodedTxBase64,
|
|
3994
|
+
chainId
|
|
3995
|
+
}) {
|
|
3996
|
+
this.assertIsValidWalletId(walletId);
|
|
3997
|
+
const wallet = this.wallets[walletId];
|
|
3998
|
+
const signRes = yield this.platformUtils.sendTransaction(
|
|
3999
|
+
this.ctx,
|
|
4000
|
+
this.userId,
|
|
4001
|
+
walletId,
|
|
4002
|
+
this.wallets[walletId].signer,
|
|
4003
|
+
rlpEncodedTxBase64,
|
|
4004
|
+
chainId,
|
|
4005
|
+
this.retrieveSessionCookie(),
|
|
4006
|
+
wallet.scheme === import_user_management_client5.WalletScheme.DKLS
|
|
4007
|
+
);
|
|
4008
|
+
if (signRes.pendingTransactionId) {
|
|
4009
|
+
this.platformUtils.openPopup(
|
|
4010
|
+
yield this.getTransactionReviewUrl(signRes.pendingTransactionId),
|
|
4011
|
+
{ type: "SIGN_TRANSACTION_REVIEW" /* SIGN_TRANSACTION_REVIEW */ }
|
|
4012
|
+
);
|
|
4013
|
+
const error = new TransactionReviewError(
|
|
4014
|
+
yield this.getTransactionReviewUrl(signRes.pendingTransactionId)
|
|
4015
|
+
);
|
|
4016
|
+
throw error;
|
|
4017
|
+
}
|
|
4018
|
+
return signRes;
|
|
4019
|
+
});
|
|
4020
|
+
}
|
|
2974
4021
|
isProviderModalDisabled() {
|
|
2975
4022
|
return !!this.disableProviderModal;
|
|
2976
4023
|
}
|
|
@@ -3067,36 +4114,36 @@ var _ParaCore = class _ParaCore {
|
|
|
3067
4114
|
/**
|
|
3068
4115
|
* @deprecated
|
|
3069
4116
|
*/
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
4117
|
+
exitAccountCreation() {
|
|
4118
|
+
this.isAwaitingAccountCreation = false;
|
|
4119
|
+
}
|
|
3073
4120
|
/**
|
|
3074
4121
|
* @deprecated
|
|
3075
4122
|
*/
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
|
|
4123
|
+
exitLogin() {
|
|
4124
|
+
this.isAwaitingLogin = false;
|
|
4125
|
+
}
|
|
3079
4126
|
/**
|
|
3080
4127
|
* @deprecated
|
|
3081
4128
|
*/
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
4129
|
+
exitFarcaster() {
|
|
4130
|
+
this.isAwaitingFarcaster = false;
|
|
4131
|
+
}
|
|
3085
4132
|
/**
|
|
3086
4133
|
* @deprecated
|
|
3087
4134
|
*/
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
4135
|
+
exitOAuth() {
|
|
4136
|
+
this.isAwaitingOAuth = false;
|
|
4137
|
+
}
|
|
3091
4138
|
/**
|
|
3092
4139
|
* @deprecated
|
|
3093
4140
|
*/
|
|
3094
|
-
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
|
|
4141
|
+
exitLoops() {
|
|
4142
|
+
this.exitAccountCreation();
|
|
4143
|
+
this.exitLogin();
|
|
4144
|
+
this.exitFarcaster();
|
|
4145
|
+
this.exitOAuth();
|
|
4146
|
+
}
|
|
3100
4147
|
/**
|
|
3101
4148
|
* Retrieves a token to verify the current session.
|
|
3102
4149
|
* @returns {Promise<string>} the ID
|
|
@@ -3194,13 +4241,13 @@ var _ParaCore = class _ParaCore {
|
|
|
3194
4241
|
return `Para ${JSON.stringify(obj, null, 2)}`;
|
|
3195
4242
|
}
|
|
3196
4243
|
/** NEW METHODS */
|
|
3197
|
-
getNewCredentialAndUrl() {
|
|
4244
|
+
getNewCredentialAndUrl(_0) {
|
|
3198
4245
|
return __async(this, arguments, function* ({
|
|
3199
4246
|
authMethod = "PASSKEY",
|
|
3200
4247
|
isForNewDevice = false,
|
|
3201
4248
|
portalTheme,
|
|
3202
4249
|
shorten = false
|
|
3203
|
-
}
|
|
4250
|
+
}) {
|
|
3204
4251
|
this.assertIsAuthSet();
|
|
3205
4252
|
let credentialId, urlType;
|
|
3206
4253
|
switch (authMethod) {
|
|
@@ -3222,7 +4269,7 @@ var _ParaCore = class _ParaCore {
|
|
|
3222
4269
|
urlType = "createPassword";
|
|
3223
4270
|
break;
|
|
3224
4271
|
}
|
|
3225
|
-
const url = yield this.
|
|
4272
|
+
const url = yield this.constructPortalUrlV2(urlType, {
|
|
3226
4273
|
isForNewDevice,
|
|
3227
4274
|
pathId: credentialId,
|
|
3228
4275
|
portalTheme,
|
|
@@ -3231,15 +4278,7 @@ var _ParaCore = class _ParaCore {
|
|
|
3231
4278
|
return { credentialId, url };
|
|
3232
4279
|
});
|
|
3233
4280
|
}
|
|
3234
|
-
|
|
3235
|
-
* Returns a Para Portal URL for logging in with a WebAuth passkey or a password.
|
|
3236
|
-
* @param {Object} opts the options object
|
|
3237
|
-
* @param {String} opts.auth - the user auth to sign up or log in with, in the form ` { email: string } | { phone: `+${number}` } `
|
|
3238
|
-
* @param {boolean} opts.useShortUrls - whether to shorten the generated portal URLs
|
|
3239
|
-
* @param {Theme} opts.portalTheme the Para Portal theme to apply to the password creation URL, if other than the default theme
|
|
3240
|
-
* @returns {SignUpOrLogInResponse} an object in the form of either: `{ stage: 'verify' }` or `{ stage: 'login'; passkeyUrl?: string; passwordUrl?: string; biometricHints?: BiometricLocationHint[] }`
|
|
3241
|
-
*/
|
|
3242
|
-
getLoginUrl(_0) {
|
|
4281
|
+
getLoginUrlV2(_0) {
|
|
3243
4282
|
return __async(this, arguments, function* ({
|
|
3244
4283
|
authMethod = "PASSKEY",
|
|
3245
4284
|
shorten = false,
|
|
@@ -3261,14 +4300,14 @@ var _ParaCore = class _ParaCore {
|
|
|
3261
4300
|
default:
|
|
3262
4301
|
throw new Error(`invalid authentication method: '${authMethod}'`);
|
|
3263
4302
|
}
|
|
3264
|
-
return this.
|
|
4303
|
+
return this.constructPortalUrlV2(urlType, {
|
|
3265
4304
|
sessionId,
|
|
3266
4305
|
shorten,
|
|
3267
4306
|
portalTheme
|
|
3268
4307
|
});
|
|
3269
4308
|
});
|
|
3270
4309
|
}
|
|
3271
|
-
|
|
4310
|
+
getOAuthUrlV2(_0) {
|
|
3272
4311
|
return __async(this, arguments, function* ({ method, deeplinkUrl }) {
|
|
3273
4312
|
yield this.logout();
|
|
3274
4313
|
const { sessionLookupId } = yield this.touchSession(true);
|
|
@@ -3283,18 +4322,22 @@ var _ParaCore = class _ParaCore {
|
|
|
3283
4322
|
});
|
|
3284
4323
|
});
|
|
3285
4324
|
}
|
|
3286
|
-
|
|
4325
|
+
signUpOrLogInV2(_k) {
|
|
3287
4326
|
return __async(this, null, function* () {
|
|
3288
|
-
var
|
|
4327
|
+
var _l = _k, {
|
|
4328
|
+
auth
|
|
4329
|
+
} = _l, urlOptions = __objRest(_l, [
|
|
4330
|
+
"auth"
|
|
4331
|
+
]);
|
|
3289
4332
|
const serverAuthState = yield this.ctx.client.signUpOrLogIn(__spreadValues(__spreadValues({}, auth), this.getVerificationEmailProps()));
|
|
3290
4333
|
return __privateMethod(this, _ParaCore_instances, prepareAuthState_fn).call(this, serverAuthState, urlOptions);
|
|
3291
4334
|
});
|
|
3292
4335
|
}
|
|
3293
|
-
|
|
4336
|
+
verifyNewAccountV2(_m) {
|
|
3294
4337
|
return __async(this, null, function* () {
|
|
3295
|
-
var
|
|
4338
|
+
var _n = _m, {
|
|
3296
4339
|
verificationCode
|
|
3297
|
-
} =
|
|
4340
|
+
} = _n, urlOptions = __objRest(_n, [
|
|
3298
4341
|
"verificationCode"
|
|
3299
4342
|
]);
|
|
3300
4343
|
this.assertIsAuthSet(["email", "phone"]);
|
|
@@ -3305,16 +4348,16 @@ var _ParaCore = class _ParaCore {
|
|
|
3305
4348
|
return __privateMethod(this, _ParaCore_instances, prepareAuthState_fn).call(this, serverAuthState, urlOptions);
|
|
3306
4349
|
});
|
|
3307
4350
|
}
|
|
3308
|
-
|
|
4351
|
+
verifyOAuthV2(_o) {
|
|
3309
4352
|
return __async(this, null, function* () {
|
|
3310
|
-
var
|
|
4353
|
+
var _p = _o, {
|
|
3311
4354
|
method,
|
|
3312
4355
|
deeplinkUrl,
|
|
3313
4356
|
isCanceled = () => false,
|
|
3314
4357
|
onCancel,
|
|
3315
4358
|
onPoll,
|
|
3316
4359
|
onOAuthUrl
|
|
3317
|
-
} =
|
|
4360
|
+
} = _p, urlOptions = __objRest(_p, [
|
|
3318
4361
|
"method",
|
|
3319
4362
|
"deeplinkUrl",
|
|
3320
4363
|
"isCanceled",
|
|
@@ -3358,14 +4401,14 @@ var _ParaCore = class _ParaCore {
|
|
|
3358
4401
|
});
|
|
3359
4402
|
});
|
|
3360
4403
|
}
|
|
3361
|
-
|
|
4404
|
+
verifyFarcasterV2(_q) {
|
|
3362
4405
|
return __async(this, null, function* () {
|
|
3363
|
-
var
|
|
4406
|
+
var _r = _q, {
|
|
3364
4407
|
isCanceled = () => false,
|
|
3365
4408
|
onConnectUri,
|
|
3366
4409
|
onCancel,
|
|
3367
4410
|
onPoll
|
|
3368
|
-
} =
|
|
4411
|
+
} = _r, urlOptions = __objRest(_r, [
|
|
3369
4412
|
"isCanceled",
|
|
3370
4413
|
"onConnectUri",
|
|
3371
4414
|
"onCancel",
|
|
@@ -3385,7 +4428,7 @@ var _ParaCore = class _ParaCore {
|
|
|
3385
4428
|
return reject("canceled");
|
|
3386
4429
|
}
|
|
3387
4430
|
yield new Promise((_resolve) => setTimeout(_resolve, POLLING_INTERVAL_MS));
|
|
3388
|
-
const serverAuthState = yield this.ctx.client.
|
|
4431
|
+
const serverAuthState = yield this.ctx.client.getFarcasterAuthStatusV2();
|
|
3389
4432
|
if (isServerAuthState(serverAuthState)) {
|
|
3390
4433
|
const authState = yield __privateMethod(this, _ParaCore_instances, prepareAuthState_fn).call(this, serverAuthState, urlOptions);
|
|
3391
4434
|
return resolve(authState);
|
|
@@ -3406,15 +4449,15 @@ var _ParaCore = class _ParaCore {
|
|
|
3406
4449
|
* @param authResponse - the response JSON object received from the Telegram widget.
|
|
3407
4450
|
* @returns `{ isValid: boolean; telegramUserId?: string; userId?: string; isNewUser?: boolean; supportedAuthMethods?: AuthMethod[]; biometricHints?: BiometricLocationHint[] }`
|
|
3408
4451
|
*/
|
|
3409
|
-
|
|
4452
|
+
verifyTelegramV2(_s) {
|
|
3410
4453
|
return __async(this, null, function* () {
|
|
3411
|
-
var
|
|
4454
|
+
var _t = _s, {
|
|
3412
4455
|
telegramAuthResponse
|
|
3413
|
-
} =
|
|
4456
|
+
} = _t, urlOptions = __objRest(_t, [
|
|
3414
4457
|
"telegramAuthResponse"
|
|
3415
4458
|
]);
|
|
3416
4459
|
try {
|
|
3417
|
-
const serverAuthState = yield this.ctx.client.
|
|
4460
|
+
const serverAuthState = yield this.ctx.client.verifyTelegramV2(telegramAuthResponse);
|
|
3418
4461
|
return __privateMethod(this, _ParaCore_instances, prepareAuthState_fn).call(this, serverAuthState, urlOptions);
|
|
3419
4462
|
} catch (e) {
|
|
3420
4463
|
throw new Error(e.message);
|
|
@@ -3429,7 +4472,7 @@ var _ParaCore = class _ParaCore {
|
|
|
3429
4472
|
* @param {boolean} [opts.skipSessionRefresh] whether to skip refreshing the session.
|
|
3430
4473
|
* @returns {Object} `{ isComplete: boolean; isError: boolean; needsWallet: boolean; partnerId: string; }` the result data
|
|
3431
4474
|
**/
|
|
3432
|
-
|
|
4475
|
+
waitForLoginV2() {
|
|
3433
4476
|
return __async(this, arguments, function* ({
|
|
3434
4477
|
isCanceled = () => false,
|
|
3435
4478
|
onCancel,
|
|
@@ -3468,7 +4511,7 @@ var _ParaCore = class _ParaCore {
|
|
|
3468
4511
|
const tempSharesRes = yield this.getTransmissionKeyShares();
|
|
3469
4512
|
if (tempSharesRes.data.temporaryShares.length === fetchedWallets.length) {
|
|
3470
4513
|
yield this.setupAfterLogin({ temporaryShares: tempSharesRes.data.temporaryShares, skipSessionRefresh });
|
|
3471
|
-
yield this.
|
|
4514
|
+
yield this.claimPregenWalletsV2();
|
|
3472
4515
|
const resp = {
|
|
3473
4516
|
needsWallet: needsWallet || Object.values(this.wallets).length === 0,
|
|
3474
4517
|
partnerId: session.partnerId
|
|
@@ -3486,7 +4529,7 @@ var _ParaCore = class _ParaCore {
|
|
|
3486
4529
|
});
|
|
3487
4530
|
});
|
|
3488
4531
|
}
|
|
3489
|
-
|
|
4532
|
+
waitForSignupV2(_0) {
|
|
3490
4533
|
return __async(this, arguments, function* ({
|
|
3491
4534
|
isCanceled = () => false,
|
|
3492
4535
|
onCancel,
|
|
@@ -3521,17 +4564,17 @@ var _ParaCore = class _ParaCore {
|
|
|
3521
4564
|
});
|
|
3522
4565
|
});
|
|
3523
4566
|
}
|
|
3524
|
-
|
|
4567
|
+
waitForWalletCreationV2() {
|
|
3525
4568
|
return __async(this, arguments, function* ({
|
|
3526
4569
|
isCanceled = () => false,
|
|
3527
4570
|
onCancel
|
|
3528
4571
|
} = {}) {
|
|
3529
|
-
yield this.
|
|
4572
|
+
yield this.waitForSignupV2({ isCanceled, onCancel });
|
|
3530
4573
|
const { supportedWalletTypes } = yield __privateMethod(this, _ParaCore_instances, assertPartner_fn).call(this);
|
|
3531
|
-
const pregenWallets = yield this.
|
|
4574
|
+
const pregenWallets = yield this.getPregenWalletsV2();
|
|
3532
4575
|
let recoverySecret, walletIds = {};
|
|
3533
4576
|
if (pregenWallets.length > 0) {
|
|
3534
|
-
recoverySecret = yield this.
|
|
4577
|
+
recoverySecret = yield this.claimPregenWalletsV2();
|
|
3535
4578
|
walletIds = supportedWalletTypes.reduce((acc, { type }) => {
|
|
3536
4579
|
var _a;
|
|
3537
4580
|
return __spreadProps(__spreadValues({}, acc), {
|
|
@@ -3547,32 +4590,32 @@ var _ParaCore = class _ParaCore {
|
|
|
3547
4590
|
return resp;
|
|
3548
4591
|
});
|
|
3549
4592
|
}
|
|
3550
|
-
|
|
4593
|
+
loginExternalWalletV2(_u) {
|
|
3551
4594
|
return __async(this, null, function* () {
|
|
3552
|
-
var
|
|
4595
|
+
var _v = _u, {
|
|
3553
4596
|
externalWallet
|
|
3554
|
-
} =
|
|
4597
|
+
} = _v, urlOptions = __objRest(_v, [
|
|
3555
4598
|
"externalWallet"
|
|
3556
4599
|
]);
|
|
3557
4600
|
this.requireApiKey();
|
|
3558
|
-
const serverAuthState = yield this.ctx.client.
|
|
4601
|
+
const serverAuthState = yield this.ctx.client.loginExternalWalletV2({ externalWallet });
|
|
3559
4602
|
return __privateMethod(this, _ParaCore_instances, prepareAuthState_fn).call(this, serverAuthState, urlOptions);
|
|
3560
4603
|
});
|
|
3561
4604
|
}
|
|
3562
|
-
|
|
4605
|
+
verifyExternalWalletV2(_w) {
|
|
3563
4606
|
return __async(this, null, function* () {
|
|
3564
|
-
var
|
|
4607
|
+
var _x = _w, {
|
|
3565
4608
|
externalWallet,
|
|
3566
4609
|
signedMessage,
|
|
3567
4610
|
cosmosPublicKeyHex,
|
|
3568
4611
|
cosmosSigner
|
|
3569
|
-
} =
|
|
4612
|
+
} = _x, urlOptions = __objRest(_x, [
|
|
3570
4613
|
"externalWallet",
|
|
3571
4614
|
"signedMessage",
|
|
3572
4615
|
"cosmosPublicKeyHex",
|
|
3573
4616
|
"cosmosSigner"
|
|
3574
4617
|
]);
|
|
3575
|
-
const serverAuthState = yield this.ctx.client.
|
|
4618
|
+
const serverAuthState = yield this.ctx.client.verifyExternalWalletV2(this.userId, {
|
|
3576
4619
|
externalWallet,
|
|
3577
4620
|
signedMessage,
|
|
3578
4621
|
cosmosPublicKeyHex,
|
|
@@ -3588,9 +4631,9 @@ var _ParaCore = class _ParaCore {
|
|
|
3588
4631
|
* @param {string} opts.verificationCode the verification code to received via 2FA.
|
|
3589
4632
|
* @returns {Object} `{ address, initiatedAt, status, userId, walletId }`
|
|
3590
4633
|
*/
|
|
3591
|
-
|
|
4634
|
+
verify2faV2(_0) {
|
|
3592
4635
|
return __async(this, arguments, function* ({ auth, verificationCode }) {
|
|
3593
|
-
const res = yield this.ctx.client.
|
|
4636
|
+
const res = yield this.ctx.client.verify2FAV2(auth, verificationCode);
|
|
3594
4637
|
return {
|
|
3595
4638
|
initiatedAt: res.data.initiatedAt,
|
|
3596
4639
|
status: res.data.status,
|
|
@@ -3603,10 +4646,10 @@ var _ParaCore = class _ParaCore {
|
|
|
3603
4646
|
* Sets up two-factor authentication for the current user.
|
|
3604
4647
|
* @returns {string} uri - uri to use for setting up 2FA
|
|
3605
4648
|
* */
|
|
3606
|
-
|
|
4649
|
+
setup2faV2() {
|
|
3607
4650
|
return __async(this, null, function* () {
|
|
3608
4651
|
const userId = this.assertUserId();
|
|
3609
|
-
const res = yield this.ctx.client.
|
|
4652
|
+
const res = yield this.ctx.client.setup2FAV2(userId);
|
|
3610
4653
|
return res;
|
|
3611
4654
|
});
|
|
3612
4655
|
}
|
|
@@ -3615,7 +4658,7 @@ var _ParaCore = class _ParaCore {
|
|
|
3615
4658
|
* @param {Object} opts the options object
|
|
3616
4659
|
* @param {string} opts.verificationCode - the verification code received via 2FA.
|
|
3617
4660
|
*/
|
|
3618
|
-
|
|
4661
|
+
enable2faV2(_0) {
|
|
3619
4662
|
return __async(this, arguments, function* ({ verificationCode }) {
|
|
3620
4663
|
const userId = this.assertUserId();
|
|
3621
4664
|
yield this.ctx.client.enable2FA(userId, verificationCode);
|
|
@@ -3630,7 +4673,7 @@ var _ParaCore = class _ParaCore {
|
|
|
3630
4673
|
* @param {WalletType} [opts.type] the type of wallet to create. Defaults to the first non-optional type in the instance's `supportedWalletTypes` array.
|
|
3631
4674
|
* @returns {Wallet} the created wallet.
|
|
3632
4675
|
**/
|
|
3633
|
-
|
|
4676
|
+
createPregenWalletV2(opts) {
|
|
3634
4677
|
return __async(this, null, function* () {
|
|
3635
4678
|
var _a, _b;
|
|
3636
4679
|
const { supportedWalletTypes } = yield __privateMethod(this, _ParaCore_instances, assertPartner_fn).call(this);
|
|
@@ -3687,14 +4730,14 @@ var _ParaCore = class _ParaCore {
|
|
|
3687
4730
|
* @param {WalletType[]} [opts.types] the wallet types to create. Defaults to any types the instance supports that are not already present.
|
|
3688
4731
|
* @returns {Wallet[]} an array containing the created wallets.
|
|
3689
4732
|
**/
|
|
3690
|
-
|
|
4733
|
+
createPregenWalletPerTypeV2(_0) {
|
|
3691
4734
|
return __async(this, arguments, function* ({
|
|
3692
4735
|
types,
|
|
3693
4736
|
pregenId
|
|
3694
4737
|
}) {
|
|
3695
4738
|
const wallets = [];
|
|
3696
4739
|
for (const type of yield this.getTypesToCreate(types)) {
|
|
3697
|
-
const wallet = yield this.
|
|
4740
|
+
const wallet = yield this.createPregenWalletV2({ type, pregenId });
|
|
3698
4741
|
wallets.push(wallet);
|
|
3699
4742
|
}
|
|
3700
4743
|
return wallets;
|
|
@@ -3707,13 +4750,13 @@ var _ParaCore = class _ParaCore {
|
|
|
3707
4750
|
* @param {TPregenIdentifierType} opts.pregenIdentifierType type of the identifier of the user claiming the wallet
|
|
3708
4751
|
* @returns {[Wallet, string | null]} `[wallet, recoveryShare]` - the wallet object and the new recovery share.
|
|
3709
4752
|
**/
|
|
3710
|
-
|
|
4753
|
+
claimPregenWalletsV2() {
|
|
3711
4754
|
return __async(this, arguments, function* ({
|
|
3712
4755
|
pregenId
|
|
3713
4756
|
} = {}) {
|
|
3714
4757
|
var _a;
|
|
3715
4758
|
this.requireApiKey();
|
|
3716
|
-
const pregenWallets = pregenId ? yield this.
|
|
4759
|
+
const pregenWallets = pregenId ? yield this.getPregenWalletsV2({ pregenId }) : yield this.getPregenWalletsV2();
|
|
3717
4760
|
if (pregenWallets.length === 0) {
|
|
3718
4761
|
return void 0;
|
|
3719
4762
|
}
|
|
@@ -3773,7 +4816,7 @@ var _ParaCore = class _ParaCore {
|
|
|
3773
4816
|
* @param {string} opts.newPregenIdentifier the new identtifier
|
|
3774
4817
|
* @param {TPregenIdentifierType} opts.newPregenIdentifierType: the new identifier type
|
|
3775
4818
|
**/
|
|
3776
|
-
|
|
4819
|
+
updatePregenWalletIdentifierV2(_0) {
|
|
3777
4820
|
return __async(this, arguments, function* ({
|
|
3778
4821
|
walletId,
|
|
3779
4822
|
newPregenId
|
|
@@ -3800,11 +4843,11 @@ var _ParaCore = class _ParaCore {
|
|
|
3800
4843
|
* @param {TPregenIdentifierType} opts.pregenIdentifierType type of the string of the identifier of the user claiming the wallet
|
|
3801
4844
|
* @returns {boolean} whether the pregen wallet exists
|
|
3802
4845
|
**/
|
|
3803
|
-
|
|
4846
|
+
hasPregenWalletV2(_0) {
|
|
3804
4847
|
return __async(this, arguments, function* ({ pregenId }) {
|
|
3805
4848
|
this.requireApiKey();
|
|
3806
4849
|
const [pregenIdentifierType, pregenIdentifier] = (0, import_user_management_client5.toPregenTypeAndId)(pregenId);
|
|
3807
|
-
const wallets = yield this.
|
|
4850
|
+
const wallets = yield this.getPregenWalletsV2({ pregenId });
|
|
3808
4851
|
const wallet = wallets.find(
|
|
3809
4852
|
(w) => w.pregenIdentifier === pregenIdentifier && w.pregenIdentifierType === pregenIdentifierType
|
|
3810
4853
|
);
|
|
@@ -3821,8 +4864,10 @@ var _ParaCore = class _ParaCore {
|
|
|
3821
4864
|
* @param {TPregenIdentifierType} opts.pregenIdentifierType - type of the identifier of the user claiming the wallet
|
|
3822
4865
|
* @returns {Promise<WalletEntity[]>} the array of found wallets
|
|
3823
4866
|
**/
|
|
3824
|
-
|
|
3825
|
-
return __async(this, arguments, function* ({
|
|
4867
|
+
getPregenWalletsV2() {
|
|
4868
|
+
return __async(this, arguments, function* ({
|
|
4869
|
+
pregenId
|
|
4870
|
+
} = {}) {
|
|
3826
4871
|
this.requireApiKey();
|
|
3827
4872
|
const res = yield this.ctx.client.getPregenWallets(
|
|
3828
4873
|
pregenId ? (0, import_user_management_client5.toPregenIds)(pregenId) : this.pregenIds,
|
|
@@ -3952,8 +4997,8 @@ prepareLoginState_fn = function(_0, _1) {
|
|
|
3952
4997
|
}) {
|
|
3953
4998
|
const _a = loginState, { loginAuthMethods } = _a, authState = __objRest(_a, ["loginAuthMethods"]);
|
|
3954
4999
|
return __spreadValues(__spreadValues(__spreadValues({}, authState), !this.isNativePasskey && loginAuthMethods.includes(import_user_management_client5.AuthMethod.PASSKEY) ? {
|
|
3955
|
-
passkeyUrl: yield this.
|
|
3956
|
-
passkeyKnownDeviceUrl: yield this.
|
|
5000
|
+
passkeyUrl: yield this.getLoginUrlV2({ sessionId: sessionLookupId, shorten, portalTheme }),
|
|
5001
|
+
passkeyKnownDeviceUrl: yield this.constructPortalUrlV2("loginAuth", {
|
|
3957
5002
|
sessionId: sessionLookupId,
|
|
3958
5003
|
newDevice: {
|
|
3959
5004
|
sessionId: sessionLookupId,
|
|
@@ -3963,7 +5008,7 @@ prepareLoginState_fn = function(_0, _1) {
|
|
|
3963
5008
|
portalTheme
|
|
3964
5009
|
})
|
|
3965
5010
|
} : {}), loginAuthMethods.includes(import_user_management_client5.AuthMethod.PASSWORD) ? {
|
|
3966
|
-
passwordUrl: yield this.
|
|
5011
|
+
passwordUrl: yield this.constructPortalUrlV2("loginPassword", {
|
|
3967
5012
|
sessionId: sessionLookupId,
|
|
3968
5013
|
shorten,
|
|
3969
5014
|
portalTheme
|