@getpara/core-sdk 2.0.0-dev.0 → 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 +1084 -119
- package/dist/cjs/index.js.br +0 -0
- package/dist/cjs/index.js.gz +0 -0
- package/dist/esm/index.js +1083 -119
- package/dist/esm/index.js.br +0 -0
- package/dist/esm/index.js.gz +0 -0
- package/dist/types/ParaCore.d.ts +188 -81
- package/dist/types/constants.d.ts +1 -0
- package/dist/types/index.d.ts +4 -3
- package/dist/types/types/coreApi.d.ts +437 -0
- package/dist/types/types/index.d.ts +1 -0
- package/dist/types/types/methods.d.ts +133 -22
- package/dist/types/types/wallet.d.ts +1 -2
- package/dist/types/utils/index.d.ts +1 -0
- package/dist/types/utils/phone.d.ts +2 -2
- package/dist/types/utils/types.d.ts +2 -0
- package/dist/types/utils/url.d.ts +2 -1
- package/dist/types/utils/wallet.d.ts +2 -1
- package/package.json +3 -3
package/dist/cjs/index.js
CHANGED
|
@@ -99,6 +99,7 @@ __export(src_exports, {
|
|
|
99
99
|
OnRampProvider: () => import_user_management_client6.OnRampProvider,
|
|
100
100
|
OnRampPurchaseStatus: () => import_user_management_client6.OnRampPurchaseStatus,
|
|
101
101
|
OnRampPurchaseType: () => import_user_management_client6.OnRampPurchaseType,
|
|
102
|
+
PARA_CORE_METHODS: () => PARA_CORE_METHODS,
|
|
102
103
|
PREGEN_IDENTIFIER_TYPES: () => import_user_management_client6.PREGEN_IDENTIFIER_TYPES,
|
|
103
104
|
ParaEvent: () => ParaEvent,
|
|
104
105
|
PopupType: () => PopupType,
|
|
@@ -110,6 +111,7 @@ __export(src_exports, {
|
|
|
110
111
|
TransactionReviewTimeout: () => TransactionReviewTimeout,
|
|
111
112
|
WalletScheme: () => import_user_management_client6.WalletScheme,
|
|
112
113
|
WalletType: () => import_user_management_client6.WalletType,
|
|
114
|
+
constructUrl: () => constructUrl,
|
|
113
115
|
decimalToHex: () => decimalToHex,
|
|
114
116
|
decryptPrivateKey: () => decryptPrivateKey,
|
|
115
117
|
decryptPrivateKeyAndDecryptShare: () => decryptPrivateKeyAndDecryptShare,
|
|
@@ -148,6 +150,7 @@ __export(src_exports, {
|
|
|
148
150
|
mpcComputationClient: () => mpcComputationClient_exports,
|
|
149
151
|
paraVersion: () => paraVersion,
|
|
150
152
|
publicKeyFromHex: () => publicKeyFromHex,
|
|
153
|
+
shortenUrl: () => shortenUrl,
|
|
151
154
|
toAssetInfoArray: () => toAssetInfoArray,
|
|
152
155
|
transmissionUtilsRetrieve: () => retrieve,
|
|
153
156
|
truncateAddress: () => truncateAddress,
|
|
@@ -264,7 +267,7 @@ function jsonParse(data, validate) {
|
|
|
264
267
|
}
|
|
265
268
|
|
|
266
269
|
// src/constants.ts
|
|
267
|
-
var PARA_CORE_VERSION = '2.0.0-dev.
|
|
270
|
+
var PARA_CORE_VERSION = '2.0.0-dev.1';
|
|
268
271
|
var PREFIX = "@CAPSULE/";
|
|
269
272
|
var LOCAL_STORAGE_AUTH_INFO = `${PREFIX}authInfo`;
|
|
270
273
|
var LOCAL_STORAGE_EMAIL = `${PREFIX}e-mail`;
|
|
@@ -281,6 +284,7 @@ var LOCAL_STORAGE_SESSION_COOKIE = `${PREFIX}sessionCookie`;
|
|
|
281
284
|
var SESSION_STORAGE_LOGIN_ENCRYPTION_KEY_PAIR = `${PREFIX}loginEncryptionKeyPair`;
|
|
282
285
|
var POLLING_INTERVAL_MS = 2e3;
|
|
283
286
|
var SHORT_POLLING_INTERVAL_MS = 1e3;
|
|
287
|
+
var POLLING_TIMEOUT_MS = 3e5;
|
|
284
288
|
|
|
285
289
|
// src/utils/listeners.ts
|
|
286
290
|
function storageListener(e) {
|
|
@@ -355,10 +359,7 @@ function getOnRampAssets(data, {
|
|
|
355
359
|
// src/utils/phone.ts
|
|
356
360
|
var import_libphonenumber_js = __toESM(require("libphonenumber-js"));
|
|
357
361
|
function formatPhoneNumber(phone, countryCode, { forDisplay = false } = {}) {
|
|
358
|
-
|
|
359
|
-
return null;
|
|
360
|
-
}
|
|
361
|
-
phone = phone == null ? void 0 : phone.toString();
|
|
362
|
+
phone = phone.toString();
|
|
362
363
|
countryCode = countryCode == null ? void 0 : countryCode.toString();
|
|
363
364
|
let sanitizedNumber, parsedNumber;
|
|
364
365
|
if (!!countryCode) {
|
|
@@ -394,6 +395,48 @@ function waitUntilTrue(condition, timeoutMs, intervalMs) {
|
|
|
394
395
|
});
|
|
395
396
|
}
|
|
396
397
|
|
|
398
|
+
// src/utils/types.ts
|
|
399
|
+
function isServerAuthState(obj) {
|
|
400
|
+
return "stage" in obj;
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
// src/transmission/transmissionUtils.ts
|
|
404
|
+
var import_ecies = require("@celo/utils/lib/ecies.js");
|
|
405
|
+
var import_buffer = require("buffer");
|
|
406
|
+
var eutil = __toESM(require("ethereumjs-util"));
|
|
407
|
+
var import_crypto = require("crypto");
|
|
408
|
+
function upload(message, userManagementClient) {
|
|
409
|
+
return __async(this, null, function* () {
|
|
410
|
+
let secret;
|
|
411
|
+
let publicKeyUint8Array;
|
|
412
|
+
while (true) {
|
|
413
|
+
try {
|
|
414
|
+
secret = (0, import_crypto.randomBytes)(32).toString("hex");
|
|
415
|
+
publicKeyUint8Array = eutil.privateToPublic(import_buffer.Buffer.from(secret, "hex"));
|
|
416
|
+
break;
|
|
417
|
+
} catch (e) {
|
|
418
|
+
continue;
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
const pubkey = import_buffer.Buffer.from(publicKeyUint8Array);
|
|
422
|
+
const data = (0, import_ecies.Encrypt)(pubkey, import_buffer.Buffer.from(message, "ucs2")).toString("base64");
|
|
423
|
+
const {
|
|
424
|
+
data: { id }
|
|
425
|
+
} = yield userManagementClient.tempTrasmissionInit(data);
|
|
426
|
+
return encodeURIComponent(id + "|" + secret);
|
|
427
|
+
});
|
|
428
|
+
}
|
|
429
|
+
function retrieve(uriEncodedMessage, userManagementClient) {
|
|
430
|
+
return __async(this, null, function* () {
|
|
431
|
+
const [id, secret] = decodeURIComponent(uriEncodedMessage).split("|");
|
|
432
|
+
const response = yield userManagementClient.tempTrasmission(id);
|
|
433
|
+
const data = response.data.message;
|
|
434
|
+
const buf = import_buffer.Buffer.from(data, "base64");
|
|
435
|
+
const res = import_buffer.Buffer.from((0, import_ecies.Decrypt)(import_buffer.Buffer.from(secret, "hex"), buf).buffer).toString("ucs2");
|
|
436
|
+
return res;
|
|
437
|
+
});
|
|
438
|
+
}
|
|
439
|
+
|
|
397
440
|
// src/types/config.ts
|
|
398
441
|
var Environment = /* @__PURE__ */ ((Environment2) => {
|
|
399
442
|
Environment2["DEV"] = "DEV";
|
|
@@ -411,6 +454,49 @@ var EnabledFlow = /* @__PURE__ */ ((EnabledFlow2) => {
|
|
|
411
454
|
return EnabledFlow2;
|
|
412
455
|
})(EnabledFlow || {});
|
|
413
456
|
|
|
457
|
+
// src/types/coreApi.ts
|
|
458
|
+
var PARA_CORE_METHODS = [
|
|
459
|
+
"signUpOrLogInV2",
|
|
460
|
+
"verifyNewAccountV2",
|
|
461
|
+
"waitForLoginV2",
|
|
462
|
+
"waitForSignupV2",
|
|
463
|
+
"waitForWalletCreationV2",
|
|
464
|
+
"verifyOAuthV2",
|
|
465
|
+
"verifyFarcasterV2",
|
|
466
|
+
"verifyTelegramV2",
|
|
467
|
+
"resendVerificationCode",
|
|
468
|
+
"loginExternalWalletV2",
|
|
469
|
+
"verifyExternalWalletV2",
|
|
470
|
+
"setup2faV2",
|
|
471
|
+
"enable2faV2",
|
|
472
|
+
"verify2faV2",
|
|
473
|
+
"logout",
|
|
474
|
+
"clearStorage",
|
|
475
|
+
"isSessionActive",
|
|
476
|
+
"isFullyLoggedIn",
|
|
477
|
+
"refreshSession",
|
|
478
|
+
"keepSessionAlive",
|
|
479
|
+
"exportSession",
|
|
480
|
+
"importSession",
|
|
481
|
+
"getVerificationToken",
|
|
482
|
+
"fetchWallets",
|
|
483
|
+
"createWallet",
|
|
484
|
+
"createWalletPerType",
|
|
485
|
+
"getPregenWalletsV2",
|
|
486
|
+
"hasPregenWalletV2",
|
|
487
|
+
"updatePregenWalletIdentifierV2",
|
|
488
|
+
"createPregenWalletV2",
|
|
489
|
+
"createPregenWalletPerTypeV2",
|
|
490
|
+
"claimPregenWalletsV2",
|
|
491
|
+
"distributeNewWalletShare",
|
|
492
|
+
"getUserShare",
|
|
493
|
+
"setUserShare",
|
|
494
|
+
"refreshShare",
|
|
495
|
+
"signMessage",
|
|
496
|
+
"signTransaction",
|
|
497
|
+
"initiateOnRampTransaction"
|
|
498
|
+
];
|
|
499
|
+
|
|
414
500
|
// src/types/wallet.ts
|
|
415
501
|
var PregenIdentifierType = /* @__PURE__ */ ((PregenIdentifierType2) => {
|
|
416
502
|
PregenIdentifierType2["EMAIL"] = "EMAIL";
|
|
@@ -533,6 +619,15 @@ function constructUrl({
|
|
|
533
619
|
});
|
|
534
620
|
return url.toString();
|
|
535
621
|
}
|
|
622
|
+
function shortenUrl(ctx, url) {
|
|
623
|
+
return __async(this, null, function* () {
|
|
624
|
+
const compressedUrl = yield upload(url, ctx.client);
|
|
625
|
+
return constructUrl({
|
|
626
|
+
base: getPortalBaseURL(ctx),
|
|
627
|
+
path: `/short/${compressedUrl}`
|
|
628
|
+
});
|
|
629
|
+
});
|
|
630
|
+
}
|
|
536
631
|
|
|
537
632
|
// src/utils/wallet.ts
|
|
538
633
|
var import_user_management_client = require("@getpara/user-management-client");
|
|
@@ -972,8 +1067,8 @@ var import_user_management_client4 = require("@getpara/user-management-client");
|
|
|
972
1067
|
var import_user_management_client3 = require("@getpara/user-management-client");
|
|
973
1068
|
|
|
974
1069
|
// src/shares/KeyContainer.ts
|
|
975
|
-
var
|
|
976
|
-
var
|
|
1070
|
+
var import_ecies2 = require("@celo/utils/lib/ecies.js");
|
|
1071
|
+
var eutil2 = __toESM(require("ethereumjs-util"));
|
|
977
1072
|
var forge2 = __toESM(require("node-forge"));
|
|
978
1073
|
var KeyContainer = class _KeyContainer {
|
|
979
1074
|
constructor(walletId, keyshare, address) {
|
|
@@ -993,7 +1088,7 @@ var KeyContainer = class _KeyContainer {
|
|
|
993
1088
|
}
|
|
994
1089
|
}
|
|
995
1090
|
getPublicEncryptionKey() {
|
|
996
|
-
return Buffer.from(
|
|
1091
|
+
return Buffer.from(eutil2.privateToPublic(Buffer.from(this.backupDecryptionKey, "hex")));
|
|
997
1092
|
}
|
|
998
1093
|
getPublicEncryptionKeyHex() {
|
|
999
1094
|
return this.getPublicEncryptionKey().toString("hex");
|
|
@@ -1001,7 +1096,7 @@ var KeyContainer = class _KeyContainer {
|
|
|
1001
1096
|
encryptForSelf(backup) {
|
|
1002
1097
|
try {
|
|
1003
1098
|
const pubkey = this.getPublicEncryptionKey();
|
|
1004
|
-
const data = (0,
|
|
1099
|
+
const data = (0, import_ecies2.Encrypt)(pubkey, Buffer.from(backup, "ucs2")).toString("base64");
|
|
1005
1100
|
return data;
|
|
1006
1101
|
} catch (error) {
|
|
1007
1102
|
throw Error("Error encrypting backup");
|
|
@@ -1009,7 +1104,7 @@ var KeyContainer = class _KeyContainer {
|
|
|
1009
1104
|
}
|
|
1010
1105
|
static encryptWithPublicKey(publicKey, backup) {
|
|
1011
1106
|
try {
|
|
1012
|
-
const data = (0,
|
|
1107
|
+
const data = (0, import_ecies2.Encrypt)(publicKey, Buffer.from(backup, "ucs2")).toString("base64");
|
|
1013
1108
|
return data;
|
|
1014
1109
|
} catch (error) {
|
|
1015
1110
|
throw Error("Error encrypting backup");
|
|
@@ -1018,7 +1113,7 @@ var KeyContainer = class _KeyContainer {
|
|
|
1018
1113
|
decrypt(encryptedBackup) {
|
|
1019
1114
|
try {
|
|
1020
1115
|
const buf = Buffer.from(encryptedBackup, "base64");
|
|
1021
|
-
const data = (0,
|
|
1116
|
+
const data = (0, import_ecies2.Decrypt)(Buffer.from(this.backupDecryptionKey, "hex"), buf);
|
|
1022
1117
|
return Buffer.from(data.buffer).toString("ucs2");
|
|
1023
1118
|
} catch (error) {
|
|
1024
1119
|
throw Error("Error decrypting backup");
|
|
@@ -1150,43 +1245,6 @@ function distributeNewShare(_0) {
|
|
|
1150
1245
|
});
|
|
1151
1246
|
}
|
|
1152
1247
|
|
|
1153
|
-
// src/transmission/transmissionUtils.ts
|
|
1154
|
-
var import_ecies2 = require("@celo/utils/lib/ecies.js");
|
|
1155
|
-
var import_buffer = require("buffer");
|
|
1156
|
-
var eutil2 = __toESM(require("ethereumjs-util"));
|
|
1157
|
-
var import_crypto = require("crypto");
|
|
1158
|
-
function upload(message, userManagementClient) {
|
|
1159
|
-
return __async(this, null, function* () {
|
|
1160
|
-
let secret;
|
|
1161
|
-
let publicKeyUint8Array;
|
|
1162
|
-
while (true) {
|
|
1163
|
-
try {
|
|
1164
|
-
secret = (0, import_crypto.randomBytes)(32).toString("hex");
|
|
1165
|
-
publicKeyUint8Array = eutil2.privateToPublic(import_buffer.Buffer.from(secret, "hex"));
|
|
1166
|
-
break;
|
|
1167
|
-
} catch (e) {
|
|
1168
|
-
continue;
|
|
1169
|
-
}
|
|
1170
|
-
}
|
|
1171
|
-
const pubkey = import_buffer.Buffer.from(publicKeyUint8Array);
|
|
1172
|
-
const data = (0, import_ecies2.Encrypt)(pubkey, import_buffer.Buffer.from(message, "ucs2")).toString("base64");
|
|
1173
|
-
const {
|
|
1174
|
-
data: { id }
|
|
1175
|
-
} = yield userManagementClient.tempTrasmissionInit(data);
|
|
1176
|
-
return encodeURIComponent(id + "|" + secret);
|
|
1177
|
-
});
|
|
1178
|
-
}
|
|
1179
|
-
function retrieve(uriEncodedMessage, userManagementClient) {
|
|
1180
|
-
return __async(this, null, function* () {
|
|
1181
|
-
const [id, secret] = decodeURIComponent(uriEncodedMessage).split("|");
|
|
1182
|
-
const response = yield userManagementClient.tempTrasmission(id);
|
|
1183
|
-
const data = response.data.message;
|
|
1184
|
-
const buf = import_buffer.Buffer.from(data, "base64");
|
|
1185
|
-
const res = import_buffer.Buffer.from((0, import_ecies2.Decrypt)(import_buffer.Buffer.from(secret, "hex"), buf).buffer).toString("ucs2");
|
|
1186
|
-
return res;
|
|
1187
|
-
});
|
|
1188
|
-
}
|
|
1189
|
-
|
|
1190
1248
|
// src/errors.ts
|
|
1191
1249
|
var TransactionReviewError = class extends Error {
|
|
1192
1250
|
constructor(transactionReviewUrl) {
|
|
@@ -1221,7 +1279,7 @@ if (typeof global !== "undefined") {
|
|
|
1221
1279
|
self.global = self.global || self;
|
|
1222
1280
|
}
|
|
1223
1281
|
var { pki, jsbn } = import_node_forge2.default;
|
|
1224
|
-
var _authInfo, _partner, _ParaCore_instances, assertPartner_fn, toAuthInfo_fn, setAuthInfo_fn,
|
|
1282
|
+
var _authInfo, _partner, _ParaCore_instances, assertPartner_fn, toAuthInfo_fn, setAuthInfo_fn, getPartner_fn, prepareAuthState_fn, prepareLogin_fn, prepareLoginState_fn, prepareSignUpState_fn;
|
|
1225
1283
|
var _ParaCore = class _ParaCore {
|
|
1226
1284
|
/**
|
|
1227
1285
|
* Constructs a new `ParaCore` instance.
|
|
@@ -1233,6 +1291,7 @@ var _ParaCore = class _ParaCore {
|
|
|
1233
1291
|
constructor(env, apiKey, opts) {
|
|
1234
1292
|
__privateAdd(this, _ParaCore_instances);
|
|
1235
1293
|
__privateAdd(this, _authInfo);
|
|
1294
|
+
this.isNativePasskey = false;
|
|
1236
1295
|
__privateAdd(this, _partner);
|
|
1237
1296
|
this.isAwaitingAccountCreation = false;
|
|
1238
1297
|
this.isAwaitingLogin = false;
|
|
@@ -1242,6 +1301,10 @@ var _ParaCore = class _ParaCore {
|
|
|
1242
1301
|
* The IDs of the currently active wallets, for each supported wallet type. Any signer integrations will default to the first viable wallet ID in this dictionary.
|
|
1243
1302
|
*/
|
|
1244
1303
|
this.currentWalletIds = {};
|
|
1304
|
+
/**
|
|
1305
|
+
* Wallets associated with the `ParaCore` instance.
|
|
1306
|
+
*/
|
|
1307
|
+
this.externalWallets = {};
|
|
1245
1308
|
this.localStorageGetItem = (key) => {
|
|
1246
1309
|
return this.platformUtils.localStorage.get(key);
|
|
1247
1310
|
};
|
|
@@ -1696,6 +1759,91 @@ var _ParaCore = class _ParaCore {
|
|
|
1696
1759
|
var _a, _b, _c;
|
|
1697
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;
|
|
1698
1761
|
}
|
|
1762
|
+
constructPortalUrlV2(_0) {
|
|
1763
|
+
return __async(this, arguments, function* (type, opts = {}) {
|
|
1764
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
1765
|
+
const [isCreate, isLogin, isOnRamp] = [
|
|
1766
|
+
["createAuth", "createPassword"].includes(type),
|
|
1767
|
+
["loginAuth", "loginPassword"].includes(type),
|
|
1768
|
+
type === "onRamp"
|
|
1769
|
+
];
|
|
1770
|
+
let auth;
|
|
1771
|
+
if (isCreate || isLogin) {
|
|
1772
|
+
auth = this.assertIsAuthSet().auth;
|
|
1773
|
+
}
|
|
1774
|
+
let sessionId = opts.sessionId;
|
|
1775
|
+
if ((isLogin || isOnRamp) && !sessionId) {
|
|
1776
|
+
const session = yield this.touchSession(true);
|
|
1777
|
+
sessionId = session.sessionId;
|
|
1778
|
+
}
|
|
1779
|
+
if (!this.loginEncryptionKeyPair) {
|
|
1780
|
+
yield this.setLoginEncryptionKeyPair();
|
|
1781
|
+
}
|
|
1782
|
+
const base = type === "onRamp" ? getPortalBaseURL(this.ctx) : yield this.getPortalURL();
|
|
1783
|
+
let path;
|
|
1784
|
+
switch (type) {
|
|
1785
|
+
case "createPassword": {
|
|
1786
|
+
path = `/web/users/${this.userId}/passwords/${opts.pathId}`;
|
|
1787
|
+
break;
|
|
1788
|
+
}
|
|
1789
|
+
case "createAuth": {
|
|
1790
|
+
path = `/web/users/${this.userId}/biometrics/${opts.pathId}`;
|
|
1791
|
+
break;
|
|
1792
|
+
}
|
|
1793
|
+
case "loginPassword": {
|
|
1794
|
+
path = "/web/passwords/login";
|
|
1795
|
+
break;
|
|
1796
|
+
}
|
|
1797
|
+
case "loginAuth": {
|
|
1798
|
+
path = "/web/biometrics/login";
|
|
1799
|
+
break;
|
|
1800
|
+
}
|
|
1801
|
+
case "txReview": {
|
|
1802
|
+
path = `/web/users/${this.userId}/transaction-review/${opts.pathId}`;
|
|
1803
|
+
break;
|
|
1804
|
+
}
|
|
1805
|
+
case "onRamp": {
|
|
1806
|
+
path = `/web/users/${this.userId}/on-ramp-transaction/${opts.pathId}`;
|
|
1807
|
+
break;
|
|
1808
|
+
}
|
|
1809
|
+
default: {
|
|
1810
|
+
throw new Error(`invalid URL type ${type}`);
|
|
1811
|
+
}
|
|
1812
|
+
}
|
|
1813
|
+
const partner = yield __privateMethod(this, _ParaCore_instances, assertPartner_fn).call(this);
|
|
1814
|
+
const thisDevice = (_a = opts.thisDevice) != null ? _a : {
|
|
1815
|
+
encryptionKey: getPublicKeyHex(this.loginEncryptionKeyPair),
|
|
1816
|
+
sessionId
|
|
1817
|
+
};
|
|
1818
|
+
const params = __spreadValues(__spreadValues(__spreadValues(__spreadValues({
|
|
1819
|
+
apiKey: this.ctx.apiKey,
|
|
1820
|
+
partnerId: partner.id,
|
|
1821
|
+
portalFont: ((_b = opts.portalTheme) == null ? void 0 : _b.font) || (partner == null ? void 0 : partner.font) || ((_c = this.portalTheme) == null ? void 0 : _c.font),
|
|
1822
|
+
portalBorderRadius: ((_d = opts.portalTheme) == null ? void 0 : _d.borderRadius) || ((_e = this.portalTheme) == null ? void 0 : _e.borderRadius),
|
|
1823
|
+
portalThemeMode: ((_f = opts.portalTheme) == null ? void 0 : _f.mode) || (partner == null ? void 0 : partner.themeMode) || ((_g = this.portalTheme) == null ? void 0 : _g.mode),
|
|
1824
|
+
portalAccentColor: ((_h = opts.portalTheme) == null ? void 0 : _h.accentColor) || (partner == null ? void 0 : partner.accentColor) || ((_i = this.portalTheme) == null ? void 0 : _i.accentColor),
|
|
1825
|
+
portalForegroundColor: ((_j = opts.portalTheme) == null ? void 0 : _j.foregroundColor) || (partner == null ? void 0 : partner.foregroundColor) || ((_k = this.portalTheme) == null ? void 0 : _k.foregroundColor),
|
|
1826
|
+
portalBackgroundColor: ((_l = opts.portalTheme) == null ? void 0 : _l.backgroundColor) || (partner == null ? void 0 : partner.backgroundColor) || this.portalBackgroundColor || ((_m = this.portalTheme) == null ? void 0 : _m.backgroundColor),
|
|
1827
|
+
portalPrimaryButtonColor: this.portalPrimaryButtonColor,
|
|
1828
|
+
portalTextColor: this.portalTextColor,
|
|
1829
|
+
portalPrimaryButtonTextColor: this.portalPrimaryButtonTextColor,
|
|
1830
|
+
isForNewDevice: opts.isForNewDevice ? opts.isForNewDevice.toString() : void 0
|
|
1831
|
+
}, auth && (isCreate || isLogin) ? auth : {}), isOnRamp ? { sessionId } : {}), isLogin ? __spreadProps(__spreadValues({
|
|
1832
|
+
sessionId: thisDevice.sessionId,
|
|
1833
|
+
encryptionKey: thisDevice.encryptionKey
|
|
1834
|
+
}, opts.newDevice ? {
|
|
1835
|
+
newDeviceSessionLookupId: opts.newDevice.sessionId,
|
|
1836
|
+
newDeviceEncryptionKey: opts.newDevice.encryptionKey
|
|
1837
|
+
} : {}), {
|
|
1838
|
+
pregenIds: JSON.stringify(this.pregenIds)
|
|
1839
|
+
}) : {}), opts.params || {});
|
|
1840
|
+
const url = constructUrl({ base, path, params });
|
|
1841
|
+
if (opts.shorten) {
|
|
1842
|
+
return shortenUrl(this.ctx, url);
|
|
1843
|
+
}
|
|
1844
|
+
return url;
|
|
1845
|
+
});
|
|
1846
|
+
}
|
|
1699
1847
|
constructPortalUrl(_0) {
|
|
1700
1848
|
return __async(this, arguments, function* (type, opts = {}) {
|
|
1701
1849
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
@@ -1706,7 +1854,7 @@ var _ParaCore = class _ParaCore {
|
|
|
1706
1854
|
];
|
|
1707
1855
|
let auth;
|
|
1708
1856
|
if (isCreate || isLogin) {
|
|
1709
|
-
auth =
|
|
1857
|
+
auth = this.assertIsAuthSet().auth;
|
|
1710
1858
|
}
|
|
1711
1859
|
if ((isLogin || isOnRamp) && !opts.sessionId) {
|
|
1712
1860
|
opts.sessionId = (yield this.touchSession()).sessionLookupId;
|
|
@@ -1743,7 +1891,7 @@ var _ParaCore = class _ParaCore {
|
|
|
1743
1891
|
}
|
|
1744
1892
|
}
|
|
1745
1893
|
const partner = yield __privateMethod(this, _ParaCore_instances, assertPartner_fn).call(this);
|
|
1746
|
-
const params = __spreadValues(__spreadValues(__spreadValues(__spreadValues({
|
|
1894
|
+
const params = __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({
|
|
1747
1895
|
apiKey: this.ctx.apiKey,
|
|
1748
1896
|
partnerId: partner.id,
|
|
1749
1897
|
portalFont: ((_a = opts.theme) == null ? void 0 : _a.font) || (partner == null ? void 0 : partner.font) || ((_b = this.portalTheme) == null ? void 0 : _b.font),
|
|
@@ -1756,7 +1904,7 @@ var _ParaCore = class _ParaCore {
|
|
|
1756
1904
|
portalTextColor: this.portalTextColor,
|
|
1757
1905
|
portalPrimaryButtonTextColor: this.portalPrimaryButtonTextColor,
|
|
1758
1906
|
isForNewDevice: opts.isForNewDevice ? opts.isForNewDevice.toString() : void 0
|
|
1759
|
-
}, auth && (isCreate || isLogin) ? auth : {}), isLogin || isOnRamp ? { sessionId: opts.sessionId } : {}), isLogin ? {
|
|
1907
|
+
}, auth && (isCreate || isLogin) ? auth : {}), isCreate || isLogin ? { authInfo: JSON.stringify(this.authInfo) } : {}), isLogin || isOnRamp ? { sessionId: opts.sessionId } : {}), isLogin ? {
|
|
1760
1908
|
encryptionKey: opts.loginEncryptionPublicKey,
|
|
1761
1909
|
newDeviceSessionLookupId: opts.newDeviceSessionId,
|
|
1762
1910
|
newDeviceEncryptionKey: opts.newDeviceEncryptionKey,
|
|
@@ -1871,6 +2019,21 @@ var _ParaCore = class _ParaCore {
|
|
|
1871
2019
|
return __privateGet(this, _authInfo);
|
|
1872
2020
|
});
|
|
1873
2021
|
}
|
|
2022
|
+
assertUserId() {
|
|
2023
|
+
if (!this.userId) {
|
|
2024
|
+
throw new Error("no userId is set");
|
|
2025
|
+
}
|
|
2026
|
+
return this.userId;
|
|
2027
|
+
}
|
|
2028
|
+
assertIsAuthSet(allowed) {
|
|
2029
|
+
if (!__privateGet(this, _authInfo)) {
|
|
2030
|
+
throw new Error("auth is not set");
|
|
2031
|
+
}
|
|
2032
|
+
if (allowed && !allowed.includes(__privateGet(this, _authInfo).authType)) {
|
|
2033
|
+
throw new Error(`invalid auth type, expected ${allowed.join(", ")}`);
|
|
2034
|
+
}
|
|
2035
|
+
return __privateGet(this, _authInfo);
|
|
2036
|
+
}
|
|
1874
2037
|
/**
|
|
1875
2038
|
* Sets the email associated with the `ParaCore` instance.
|
|
1876
2039
|
* @param email - Email to set.
|
|
@@ -2214,6 +2377,7 @@ var _ParaCore = class _ParaCore {
|
|
|
2214
2377
|
}
|
|
2215
2378
|
/**
|
|
2216
2379
|
* Generates a URL for registering a new WebAuth passkey.
|
|
2380
|
+
* @deprecated
|
|
2217
2381
|
* @param {GetWebAuthUrlForLoginParams} opts the options object
|
|
2218
2382
|
* @returns - the URL for creating a new passkey
|
|
2219
2383
|
*/
|
|
@@ -2224,6 +2388,7 @@ var _ParaCore = class _ParaCore {
|
|
|
2224
2388
|
}
|
|
2225
2389
|
/**
|
|
2226
2390
|
* Generates a URL for registering a new user password.
|
|
2391
|
+
* @deprecated
|
|
2227
2392
|
* @param {GetWebAuthUrlForLoginParams} opts the options object
|
|
2228
2393
|
* @returns - the URL for creating a new password
|
|
2229
2394
|
*/
|
|
@@ -2234,6 +2399,7 @@ var _ParaCore = class _ParaCore {
|
|
|
2234
2399
|
}
|
|
2235
2400
|
/**
|
|
2236
2401
|
* Generates a URL for registering a new WebAuth passkey for a phone number.
|
|
2402
|
+
* @deprecated
|
|
2237
2403
|
* @param {Omit<GetWebAuthUrlForLoginParams, 'authType'>} opts the options object
|
|
2238
2404
|
* @returns - web auth url
|
|
2239
2405
|
*/
|
|
@@ -2294,7 +2460,7 @@ var _ParaCore = class _ParaCore {
|
|
|
2294
2460
|
}
|
|
2295
2461
|
populatePregenWalletAddresses() {
|
|
2296
2462
|
return __async(this, null, function* () {
|
|
2297
|
-
const res = yield this.
|
|
2463
|
+
const res = yield this.getPregenWalletsV2();
|
|
2298
2464
|
res.forEach((entity) => {
|
|
2299
2465
|
if (this.wallets[entity.id]) {
|
|
2300
2466
|
this.wallets[entity.id] = __spreadValues(__spreadValues({}, entityToWallet(entity)), this.wallets[entity.id]);
|
|
@@ -2305,6 +2471,7 @@ var _ParaCore = class _ParaCore {
|
|
|
2305
2471
|
}
|
|
2306
2472
|
/**
|
|
2307
2473
|
* Checks if a user exists for an email address.
|
|
2474
|
+
* @deprecated
|
|
2308
2475
|
* @param {Object} opts the options object
|
|
2309
2476
|
* @param {string} opts.email the email to check.
|
|
2310
2477
|
* @returns true if user exists, false otherwise.
|
|
@@ -2317,6 +2484,7 @@ var _ParaCore = class _ParaCore {
|
|
|
2317
2484
|
}
|
|
2318
2485
|
/**
|
|
2319
2486
|
* Checks if a user exists for a phone number.
|
|
2487
|
+
* @deprecated
|
|
2320
2488
|
* @param {Object} opts the options object
|
|
2321
2489
|
* @param {string} opts.phone - phone number to check.
|
|
2322
2490
|
* @param {string} opts.countryCode - the country code.
|
|
@@ -2330,6 +2498,7 @@ var _ParaCore = class _ParaCore {
|
|
|
2330
2498
|
}
|
|
2331
2499
|
/**
|
|
2332
2500
|
* Creates a new user.
|
|
2501
|
+
* @deprecated
|
|
2333
2502
|
* @param {Object} opts the options object
|
|
2334
2503
|
* @param {string} opts.email the email to use.
|
|
2335
2504
|
*/
|
|
@@ -2345,6 +2514,7 @@ var _ParaCore = class _ParaCore {
|
|
|
2345
2514
|
}
|
|
2346
2515
|
/**
|
|
2347
2516
|
* Creates a new user with a phone number.
|
|
2517
|
+
* @deprecated
|
|
2348
2518
|
* @param {Object} opts the options object
|
|
2349
2519
|
* @param {string} opts.phone - the phone number to use for creating the user.
|
|
2350
2520
|
* @param {string} opts.countryCode - the country code to use for creating the user.
|
|
@@ -2359,6 +2529,7 @@ var _ParaCore = class _ParaCore {
|
|
|
2359
2529
|
}
|
|
2360
2530
|
/**
|
|
2361
2531
|
* Logs in or creates a new user using an external wallet address.
|
|
2532
|
+
* @deprecated
|
|
2362
2533
|
* @param {Object} opts the options object
|
|
2363
2534
|
* @param {string} opts.address the external wallet address to use for identification.
|
|
2364
2535
|
* @param {WalletType} opts.type type of external wallet to use for identification.
|
|
@@ -2381,6 +2552,7 @@ var _ParaCore = class _ParaCore {
|
|
|
2381
2552
|
}
|
|
2382
2553
|
/**
|
|
2383
2554
|
* Passes the email code obtained from the user for verification.
|
|
2555
|
+
* @deprecated
|
|
2384
2556
|
* @param {Object} opts the options object
|
|
2385
2557
|
* @param {string} verificationCode the six-digit code to check
|
|
2386
2558
|
* @returns {string} the web auth url for creating a new credential
|
|
@@ -2391,6 +2563,7 @@ var _ParaCore = class _ParaCore {
|
|
|
2391
2563
|
return this.getSetUpBiometricsURL();
|
|
2392
2564
|
});
|
|
2393
2565
|
}
|
|
2566
|
+
/** @deprecated */
|
|
2394
2567
|
verifyExternalWallet(_0) {
|
|
2395
2568
|
return __async(this, arguments, function* ({
|
|
2396
2569
|
address,
|
|
@@ -2399,11 +2572,12 @@ var _ParaCore = class _ParaCore {
|
|
|
2399
2572
|
cosmosSigner
|
|
2400
2573
|
}) {
|
|
2401
2574
|
yield this.ctx.client.verifyExternalWallet(this.userId, { address, signedMessage, cosmosPublicKeyHex, cosmosSigner });
|
|
2402
|
-
return this.getSetUpBiometricsURL(
|
|
2575
|
+
return this.getSetUpBiometricsURL();
|
|
2403
2576
|
});
|
|
2404
2577
|
}
|
|
2405
2578
|
/**
|
|
2406
2579
|
* Passes the phone code obtained from the user for verification.
|
|
2580
|
+
* @deprecated
|
|
2407
2581
|
* @param {Object} opts the options object
|
|
2408
2582
|
* @param {string} verificationCode the six-digit code to check
|
|
2409
2583
|
* @returns {string} the web auth url for creating a new credential
|
|
@@ -2417,6 +2591,7 @@ var _ParaCore = class _ParaCore {
|
|
|
2417
2591
|
/**
|
|
2418
2592
|
* Validates the response received from an attempted Telegram login for authenticity, then
|
|
2419
2593
|
* creates or retrieves the corresponding Para user and prepares the Para instance to sign in with that user.
|
|
2594
|
+
* @deprecated
|
|
2420
2595
|
* @param authResponse - the response JSON object received from the Telegram widget.
|
|
2421
2596
|
* @returns `{ isValid: boolean; telegramUserId?: string; userId?: string; isNewUser?: boolean; supportedAuthMethods?: AuthMethod[]; biometricHints?: BiometricLocationHint[] }`
|
|
2422
2597
|
*/
|
|
@@ -2447,6 +2622,7 @@ var _ParaCore = class _ParaCore {
|
|
|
2447
2622
|
}
|
|
2448
2623
|
/**
|
|
2449
2624
|
* Performs 2FA verification.
|
|
2625
|
+
* @deprecated
|
|
2450
2626
|
* @param {Object} opts the options object
|
|
2451
2627
|
* @param {string} opts.email the email to use for performing a 2FA verification.
|
|
2452
2628
|
* @param {string} opts.verificationCode the verification code to received via 2FA.
|
|
@@ -2465,6 +2641,7 @@ var _ParaCore = class _ParaCore {
|
|
|
2465
2641
|
}
|
|
2466
2642
|
/**
|
|
2467
2643
|
* Performs 2FA verification.
|
|
2644
|
+
* @deprecated
|
|
2468
2645
|
* @param {Object} opts the options object
|
|
2469
2646
|
* @param {string} opts.phone the phone number
|
|
2470
2647
|
* @param {string} opts.countryCode - the country code
|
|
@@ -2487,6 +2664,7 @@ var _ParaCore = class _ParaCore {
|
|
|
2487
2664
|
}
|
|
2488
2665
|
/**
|
|
2489
2666
|
* Sets up two-factor authentication for the current user.
|
|
2667
|
+
* @deprecated
|
|
2490
2668
|
* @returns {string} uri - uri to use for setting up 2FA
|
|
2491
2669
|
* */
|
|
2492
2670
|
setup2FA() {
|
|
@@ -2499,6 +2677,7 @@ var _ParaCore = class _ParaCore {
|
|
|
2499
2677
|
}
|
|
2500
2678
|
/**
|
|
2501
2679
|
* Enables 2FA.
|
|
2680
|
+
* @deprecated
|
|
2502
2681
|
* @param {Object} opts the options object
|
|
2503
2682
|
* @param {string} opts.verificationCode - the verification code received via 2FA.
|
|
2504
2683
|
*/
|
|
@@ -2509,6 +2688,7 @@ var _ParaCore = class _ParaCore {
|
|
|
2509
2688
|
}
|
|
2510
2689
|
/**
|
|
2511
2690
|
* Determines if 2FA has been set up.
|
|
2691
|
+
* @deprecated
|
|
2512
2692
|
* @returns {Object} `{ isSetup: boolean }` - true if 2FA is setup, false otherwise
|
|
2513
2693
|
*/
|
|
2514
2694
|
check2FAStatus() {
|
|
@@ -2534,6 +2714,7 @@ var _ParaCore = class _ParaCore {
|
|
|
2534
2714
|
}
|
|
2535
2715
|
/**
|
|
2536
2716
|
* Resend a verification SMS for the current user.
|
|
2717
|
+
* @deprecated
|
|
2537
2718
|
*/
|
|
2538
2719
|
resendVerificationCodeByPhone() {
|
|
2539
2720
|
return __async(this, null, function* () {
|
|
@@ -2544,6 +2725,7 @@ var _ParaCore = class _ParaCore {
|
|
|
2544
2725
|
}
|
|
2545
2726
|
/**
|
|
2546
2727
|
* Returns a URL for setting up a new WebAuth passkey.
|
|
2728
|
+
* @deprecated
|
|
2547
2729
|
* @param {Object} opts the options object
|
|
2548
2730
|
* @param {string} opts.authType - the auth type to use
|
|
2549
2731
|
* @param {boolean} opts.isForNewDevice whether the passkey is for a new device of an existing user
|
|
@@ -2568,6 +2750,7 @@ var _ParaCore = class _ParaCore {
|
|
|
2568
2750
|
}
|
|
2569
2751
|
/**
|
|
2570
2752
|
* Returns a URL for setting up a new WebAuth passkey for a phone number.
|
|
2753
|
+
* @deprecated
|
|
2571
2754
|
* @param {Object} opts the options object
|
|
2572
2755
|
* @param {boolean} opts.isForNewDevice whether the passkey is for a new device of an existing user
|
|
2573
2756
|
* @returns {string} the URL
|
|
@@ -2590,6 +2773,7 @@ var _ParaCore = class _ParaCore {
|
|
|
2590
2773
|
}
|
|
2591
2774
|
/**
|
|
2592
2775
|
* Returns a URL for setting up a new password.
|
|
2776
|
+
* @deprecated
|
|
2593
2777
|
* @param {Object} opts the options object
|
|
2594
2778
|
* @param {string} opts.authType - the auth type to use
|
|
2595
2779
|
* @param {boolean} opts.isForNewDevice whether the passkey is for a new device of an existing user
|
|
@@ -2640,6 +2824,7 @@ var _ParaCore = class _ParaCore {
|
|
|
2640
2824
|
return isSessionActive && this.currentWalletIdsArray.length > 0 && this.currentWalletIdsArray.reduce((acc, [id]) => acc && !!this.wallets[id], true);
|
|
2641
2825
|
});
|
|
2642
2826
|
}
|
|
2827
|
+
/** @deprecated */
|
|
2643
2828
|
supportedAuthMethods(auth) {
|
|
2644
2829
|
return __async(this, null, function* () {
|
|
2645
2830
|
const { supportedAuthMethods } = yield this.ctx.client.getSupportedAuthMethods(auth);
|
|
@@ -2659,16 +2844,18 @@ var _ParaCore = class _ParaCore {
|
|
|
2659
2844
|
}
|
|
2660
2845
|
/**
|
|
2661
2846
|
* Get hints associated with the users stored biometrics.
|
|
2847
|
+
* @deprecated
|
|
2662
2848
|
* @returns Array containing useragents and AAGuids for stored biometrics
|
|
2663
2849
|
*/
|
|
2664
2850
|
getUserBiometricLocationHints() {
|
|
2665
2851
|
return __async(this, null, function* () {
|
|
2666
|
-
const auth =
|
|
2852
|
+
const { auth } = this.assertIsAuthSet();
|
|
2667
2853
|
return yield this.ctx.client.getBiometricLocationHints(auth);
|
|
2668
2854
|
});
|
|
2669
2855
|
}
|
|
2670
2856
|
/**
|
|
2671
2857
|
* Initiates a login.
|
|
2858
|
+
* @deprecated
|
|
2672
2859
|
* @param {Object} opts the options object
|
|
2673
2860
|
* @param {String} opts.email - the email to login with
|
|
2674
2861
|
* @param {boolean} opts.useShortURL - whether to shorten the link
|
|
@@ -2699,6 +2886,7 @@ var _ParaCore = class _ParaCore {
|
|
|
2699
2886
|
}
|
|
2700
2887
|
/**
|
|
2701
2888
|
* Initiates a login.
|
|
2889
|
+
* @deprecated
|
|
2702
2890
|
* @param email - the email to login with
|
|
2703
2891
|
* @returns - a set of supported auth methods for the user
|
|
2704
2892
|
**/
|
|
@@ -2720,6 +2908,7 @@ var _ParaCore = class _ParaCore {
|
|
|
2720
2908
|
}
|
|
2721
2909
|
/**
|
|
2722
2910
|
* Initiates a login.
|
|
2911
|
+
* @deprecated
|
|
2723
2912
|
* @param opts the options object
|
|
2724
2913
|
* @param opts.phone the phone number
|
|
2725
2914
|
* @param opts.countryCode the country code
|
|
@@ -2750,6 +2939,7 @@ var _ParaCore = class _ParaCore {
|
|
|
2750
2939
|
});
|
|
2751
2940
|
}
|
|
2752
2941
|
/**
|
|
2942
|
+
* @deprecated
|
|
2753
2943
|
* Waits for the session to be active.
|
|
2754
2944
|
**/
|
|
2755
2945
|
waitForAccountCreation() {
|
|
@@ -2779,13 +2969,16 @@ var _ParaCore = class _ParaCore {
|
|
|
2779
2969
|
return false;
|
|
2780
2970
|
});
|
|
2781
2971
|
}
|
|
2972
|
+
/**
|
|
2973
|
+
* @deprecated
|
|
2974
|
+
*/
|
|
2782
2975
|
waitForPasskeyAndCreateWallet() {
|
|
2783
2976
|
return __async(this, arguments, function* ({
|
|
2784
2977
|
popupWindow
|
|
2785
2978
|
} = {}) {
|
|
2786
2979
|
yield this.waitForAccountCreation({ popupWindow });
|
|
2787
2980
|
const { supportedWalletTypes } = yield __privateMethod(this, _ParaCore_instances, assertPartner_fn).call(this);
|
|
2788
|
-
const pregenWallets = yield this.
|
|
2981
|
+
const pregenWallets = yield this.getPregenWalletsV2();
|
|
2789
2982
|
let recoverySecret, walletIds = {};
|
|
2790
2983
|
if (pregenWallets.length > 0) {
|
|
2791
2984
|
recoverySecret = yield this.claimPregenWallets();
|
|
@@ -2807,6 +3000,7 @@ var _ParaCore = class _ParaCore {
|
|
|
2807
3000
|
/**
|
|
2808
3001
|
* Initiates a Farcaster login attempt and return the URI for the user to connect.
|
|
2809
3002
|
* You can create a QR code with this URI that works with Farcaster's mobile app.
|
|
3003
|
+
* @deprecated
|
|
2810
3004
|
* @return {string} the Farcaster connect URI
|
|
2811
3005
|
*/
|
|
2812
3006
|
getFarcasterConnectURL() {
|
|
@@ -2822,6 +3016,7 @@ var _ParaCore = class _ParaCore {
|
|
|
2822
3016
|
/**
|
|
2823
3017
|
* Awaits the response from a user's attempt to log in with Farcaster.
|
|
2824
3018
|
* If successful, this returns the user's Farcaster username and profile picture and indicates whether the user already exists.
|
|
3019
|
+
* @deprecated
|
|
2825
3020
|
* @return {Object} `{userExists: boolean; username: string; pfpUrl?: string | null }` - the user's information and whether the user already exists.
|
|
2826
3021
|
*/
|
|
2827
3022
|
waitForFarcasterStatus() {
|
|
@@ -2853,7 +3048,7 @@ var _ParaCore = class _ParaCore {
|
|
|
2853
3048
|
}
|
|
2854
3049
|
/**
|
|
2855
3050
|
* Generates a URL for the user to log in with OAuth using a desire method.
|
|
2856
|
-
*
|
|
3051
|
+
* @deprecated
|
|
2857
3052
|
* @param {Object} opts the options object
|
|
2858
3053
|
* @param {OAuthMethod} opts.method the third-party service to use for OAuth.
|
|
2859
3054
|
* @param {string} [opts.deeplinkUrl] the deeplink to redirect to after the OAuth flow. This is for mobile only.
|
|
@@ -2877,7 +3072,7 @@ var _ParaCore = class _ParaCore {
|
|
|
2877
3072
|
/**
|
|
2878
3073
|
* Awaits the response from a user's attempt to log in with OAuth.
|
|
2879
3074
|
* If successful, this returns the user's email address and indicates whether the user already exists.
|
|
2880
|
-
*
|
|
3075
|
+
* @deprecated
|
|
2881
3076
|
* @param {Object} opts the options object.
|
|
2882
3077
|
* @param {Window} [opts.popupWindow] the popup window being used for login.
|
|
2883
3078
|
* @return {Object} `{ email?: string; isError?: boolean; userExists: boolean; }` the result data
|
|
@@ -2915,7 +3110,7 @@ var _ParaCore = class _ParaCore {
|
|
|
2915
3110
|
}
|
|
2916
3111
|
/**
|
|
2917
3112
|
* Waits for the session to be active and sets up the user.
|
|
2918
|
-
*
|
|
3113
|
+
* @deprecated
|
|
2919
3114
|
* @param {Object} opts the options object
|
|
2920
3115
|
* @param {Window} [opts.popupWindow] the popup window being used for login.
|
|
2921
3116
|
* @param {boolean} [opts.skipSessionRefresh] whether to skip refreshing the session.
|
|
@@ -2988,7 +3183,9 @@ var _ParaCore = class _ParaCore {
|
|
|
2988
3183
|
* @returns a URL for the user to reauthenticate.
|
|
2989
3184
|
**/
|
|
2990
3185
|
refreshSession() {
|
|
2991
|
-
return __async(this, arguments, function* ({
|
|
3186
|
+
return __async(this, arguments, function* ({
|
|
3187
|
+
shouldOpenPopup = false
|
|
3188
|
+
} = {}) {
|
|
2992
3189
|
const { sessionId } = yield this.touchSession(true);
|
|
2993
3190
|
if (!this.loginEncryptionKeyPair) {
|
|
2994
3191
|
yield this.setLoginEncryptionKeyPair();
|
|
@@ -3133,7 +3330,7 @@ var _ParaCore = class _ParaCore {
|
|
|
3133
3330
|
break;
|
|
3134
3331
|
}
|
|
3135
3332
|
++maxPolls;
|
|
3136
|
-
const res = yield this.
|
|
3333
|
+
const res = yield this.getPregenWalletsV2();
|
|
3137
3334
|
const wallet = res.find((w) => w.id === walletId);
|
|
3138
3335
|
if (wallet && wallet.address) {
|
|
3139
3336
|
return;
|
|
@@ -3287,7 +3484,7 @@ var _ParaCore = class _ParaCore {
|
|
|
3287
3484
|
});
|
|
3288
3485
|
}
|
|
3289
3486
|
yield this.setCurrentWalletIds(__spreadProps(__spreadValues({}, this.currentWalletIds), {
|
|
3290
|
-
[walletType]: [...(_b = this.currentWalletIds[walletType]) != null ? _b : [], walletId]
|
|
3487
|
+
[walletType]: [.../* @__PURE__ */ new Set([...(_b = this.currentWalletIds[walletType]) != null ? _b : [], walletId])]
|
|
3291
3488
|
}));
|
|
3292
3489
|
const walletNoSigner = __spreadValues({}, wallet);
|
|
3293
3490
|
delete walletNoSigner.signer;
|
|
@@ -3300,7 +3497,7 @@ var _ParaCore = class _ParaCore {
|
|
|
3300
3497
|
}
|
|
3301
3498
|
/**
|
|
3302
3499
|
* Creates a new pregenerated wallet.
|
|
3303
|
-
*
|
|
3500
|
+
* @deprecated
|
|
3304
3501
|
* @param {Object} opts the options object.
|
|
3305
3502
|
* @param {string} opts.pregenIdentifier the identifier associated with the new wallet.
|
|
3306
3503
|
* @param {TPregenIdentifierType} [opts.pregenIdentifierType] the identifier type. Defaults to `EMAIL`.
|
|
@@ -3361,6 +3558,7 @@ var _ParaCore = class _ParaCore {
|
|
|
3361
3558
|
* Creates new pregenerated wallets for each desired type.
|
|
3362
3559
|
* If no types are provided, this method will create one for each of the non-optional types
|
|
3363
3560
|
* specified in the instance's `supportedWalletTypes` array that are not already present.
|
|
3561
|
+
* @deprecated
|
|
3364
3562
|
* @param {Object} opts the options object.
|
|
3365
3563
|
* @param {string} opts.pregenIdentifier the identifier to associate each wallet with.
|
|
3366
3564
|
* @param {TPregenIdentifierType} opts.pregenIdentifierType - either `'EMAIL'` or `'PHONE'`.
|
|
@@ -3383,7 +3581,7 @@ var _ParaCore = class _ParaCore {
|
|
|
3383
3581
|
}
|
|
3384
3582
|
/**
|
|
3385
3583
|
* Claims a pregenerated wallet.
|
|
3386
|
-
*
|
|
3584
|
+
* @deprecated
|
|
3387
3585
|
* @param {Object} opts the options object.
|
|
3388
3586
|
* @param {string} opts.pregenIdentifier string the identifier of the user claiming the wallet
|
|
3389
3587
|
* @param {TPregenIdentifierType} opts.pregenIdentifierType type of the identifier of the user claiming the wallet
|
|
@@ -3451,6 +3649,7 @@ var _ParaCore = class _ParaCore {
|
|
|
3451
3649
|
}
|
|
3452
3650
|
/**
|
|
3453
3651
|
* Updates the identifier for a pregen wallet.
|
|
3652
|
+
* @deprecated
|
|
3454
3653
|
* @param {Object} opts the options object.
|
|
3455
3654
|
* @param {string} opts.walletId the pregen wallet ID
|
|
3456
3655
|
* @param {string} opts.newPregenIdentifier the new identtifier
|
|
@@ -3478,6 +3677,7 @@ var _ParaCore = class _ParaCore {
|
|
|
3478
3677
|
}
|
|
3479
3678
|
/**
|
|
3480
3679
|
* Checks if a pregen Wallet exists for the given identifier with the current partner.
|
|
3680
|
+
* @deprecated
|
|
3481
3681
|
* @param {Object} opts the options object.
|
|
3482
3682
|
* @param {string} opts.pregenIdentifier string the identifier of the user claiming the wallet
|
|
3483
3683
|
* @param {TPregenIdentifierType} opts.pregenIdentifierType type of the string of the identifier of the user claiming the wallet
|
|
@@ -3499,6 +3699,7 @@ var _ParaCore = class _ParaCore {
|
|
|
3499
3699
|
}
|
|
3500
3700
|
/**
|
|
3501
3701
|
* Get pregen wallets for the given identifier.
|
|
3702
|
+
* @deprecated
|
|
3502
3703
|
* @param {Object} opts the options object.
|
|
3503
3704
|
* @param {string} opts.pregenIdentifier - the identifier of the user claiming the wallet
|
|
3504
3705
|
* @param {TPregenIdentifierType} opts.pregenIdentifierType - type of the identifier of the user claiming the wallet
|
|
@@ -3603,7 +3804,10 @@ var _ParaCore = class _ParaCore {
|
|
|
3603
3804
|
walletId,
|
|
3604
3805
|
messageBase64,
|
|
3605
3806
|
timeoutMs = 3e4,
|
|
3606
|
-
cosmosSignDocBase64
|
|
3807
|
+
cosmosSignDocBase64,
|
|
3808
|
+
isCanceled = () => false,
|
|
3809
|
+
onCancel,
|
|
3810
|
+
onPoll
|
|
3607
3811
|
}) {
|
|
3608
3812
|
this.assertIsValidWalletId(walletId);
|
|
3609
3813
|
const wallet = this.wallets[walletId];
|
|
@@ -3622,11 +3826,12 @@ var _ParaCore = class _ParaCore {
|
|
|
3622
3826
|
dispatchEvent(ParaEvent.SIGN_MESSAGE_EVENT, signRes);
|
|
3623
3827
|
return signRes;
|
|
3624
3828
|
}
|
|
3625
|
-
yield new Promise((resolve) => setTimeout(resolve, POLLING_INTERVAL_MS));
|
|
3626
3829
|
while (true) {
|
|
3627
|
-
if (Date.now() - timeStart > timeoutMs) {
|
|
3830
|
+
if (isCanceled() || Date.now() - timeStart > timeoutMs) {
|
|
3831
|
+
onCancel == null ? void 0 : onCancel();
|
|
3628
3832
|
break;
|
|
3629
3833
|
}
|
|
3834
|
+
yield new Promise((resolve) => setTimeout(resolve, POLLING_INTERVAL_MS));
|
|
3630
3835
|
try {
|
|
3631
3836
|
yield this.ctx.client.getPendingTransaction(this.userId, signRes.pendingTransactionId);
|
|
3632
3837
|
} catch (err) {
|
|
@@ -3636,7 +3841,8 @@ var _ParaCore = class _ParaCore {
|
|
|
3636
3841
|
}
|
|
3637
3842
|
signRes = yield this.signMessageInner({ wallet, signerId, messageBase64, cosmosSignDocBase64 });
|
|
3638
3843
|
if (signRes.pendingTransactionId) {
|
|
3639
|
-
|
|
3844
|
+
onPoll == null ? void 0 : onPoll();
|
|
3845
|
+
continue;
|
|
3640
3846
|
} else {
|
|
3641
3847
|
break;
|
|
3642
3848
|
}
|
|
@@ -3701,7 +3907,10 @@ var _ParaCore = class _ParaCore {
|
|
|
3701
3907
|
walletId,
|
|
3702
3908
|
rlpEncodedTxBase64,
|
|
3703
3909
|
chainId,
|
|
3704
|
-
timeoutMs = 3e4
|
|
3910
|
+
timeoutMs = 3e4,
|
|
3911
|
+
isCanceled = () => false,
|
|
3912
|
+
onCancel,
|
|
3913
|
+
onPoll
|
|
3705
3914
|
}) {
|
|
3706
3915
|
this.assertIsValidWalletId(walletId);
|
|
3707
3916
|
const wallet = this.wallets[walletId];
|
|
@@ -3729,11 +3938,12 @@ var _ParaCore = class _ParaCore {
|
|
|
3729
3938
|
dispatchEvent(ParaEvent.SIGN_TRANSACTION_EVENT, signRes);
|
|
3730
3939
|
return signRes;
|
|
3731
3940
|
}
|
|
3732
|
-
yield new Promise((resolve) => setTimeout(resolve, POLLING_INTERVAL_MS));
|
|
3733
3941
|
while (true) {
|
|
3734
|
-
if (Date.now() - timeStart > timeoutMs) {
|
|
3942
|
+
if (isCanceled() || Date.now() - timeStart > timeoutMs) {
|
|
3943
|
+
onCancel == null ? void 0 : onCancel();
|
|
3735
3944
|
break;
|
|
3736
3945
|
}
|
|
3946
|
+
yield new Promise((resolve) => setTimeout(resolve, POLLING_INTERVAL_MS));
|
|
3737
3947
|
try {
|
|
3738
3948
|
yield this.ctx.client.getPendingTransaction(this.userId, signRes.pendingTransactionId);
|
|
3739
3949
|
} catch (err) {
|
|
@@ -3752,7 +3962,8 @@ var _ParaCore = class _ParaCore {
|
|
|
3752
3962
|
wallet.scheme === import_user_management_client5.WalletScheme.DKLS
|
|
3753
3963
|
);
|
|
3754
3964
|
if (signRes.pendingTransactionId) {
|
|
3755
|
-
|
|
3965
|
+
onPoll == null ? void 0 : onPoll();
|
|
3966
|
+
continue;
|
|
3756
3967
|
} else {
|
|
3757
3968
|
break;
|
|
3758
3969
|
}
|
|
@@ -3900,18 +4111,33 @@ var _ParaCore = class _ParaCore {
|
|
|
3900
4111
|
this.persistSessionCookie(sessionInfo.sessionCookie);
|
|
3901
4112
|
});
|
|
3902
4113
|
}
|
|
4114
|
+
/**
|
|
4115
|
+
* @deprecated
|
|
4116
|
+
*/
|
|
3903
4117
|
exitAccountCreation() {
|
|
3904
4118
|
this.isAwaitingAccountCreation = false;
|
|
3905
4119
|
}
|
|
4120
|
+
/**
|
|
4121
|
+
* @deprecated
|
|
4122
|
+
*/
|
|
3906
4123
|
exitLogin() {
|
|
3907
4124
|
this.isAwaitingLogin = false;
|
|
3908
4125
|
}
|
|
4126
|
+
/**
|
|
4127
|
+
* @deprecated
|
|
4128
|
+
*/
|
|
3909
4129
|
exitFarcaster() {
|
|
3910
4130
|
this.isAwaitingFarcaster = false;
|
|
3911
4131
|
}
|
|
4132
|
+
/**
|
|
4133
|
+
* @deprecated
|
|
4134
|
+
*/
|
|
3912
4135
|
exitOAuth() {
|
|
3913
4136
|
this.isAwaitingOAuth = false;
|
|
3914
4137
|
}
|
|
4138
|
+
/**
|
|
4139
|
+
* @deprecated
|
|
4140
|
+
*/
|
|
3915
4141
|
exitLoops() {
|
|
3916
4142
|
this.exitAccountCreation();
|
|
3917
4143
|
this.exitLogin();
|
|
@@ -3956,6 +4182,7 @@ var _ParaCore = class _ParaCore {
|
|
|
3956
4182
|
dispatchEvent(ParaEvent.LOGOUT_EVENT, null);
|
|
3957
4183
|
});
|
|
3958
4184
|
}
|
|
4185
|
+
/** @deprecated */
|
|
3959
4186
|
getSupportedCreateAuthMethods() {
|
|
3960
4187
|
return __async(this, null, function* () {
|
|
3961
4188
|
const partner = yield __privateMethod(this, _ParaCore_instances, assertPartner_fn).call(this);
|
|
@@ -4013,45 +4240,682 @@ var _ParaCore = class _ParaCore {
|
|
|
4013
4240
|
};
|
|
4014
4241
|
return `Para ${JSON.stringify(obj, null, 2)}`;
|
|
4015
4242
|
}
|
|
4016
|
-
|
|
4017
|
-
|
|
4018
|
-
|
|
4019
|
-
|
|
4020
|
-
|
|
4021
|
-
|
|
4022
|
-
|
|
4023
|
-
|
|
4024
|
-
|
|
4025
|
-
|
|
4026
|
-
|
|
4027
|
-
|
|
4028
|
-
|
|
4029
|
-
|
|
4030
|
-
|
|
4031
|
-
|
|
4032
|
-
|
|
4033
|
-
|
|
4034
|
-
|
|
4035
|
-
|
|
4036
|
-
|
|
4037
|
-
|
|
4038
|
-
|
|
4039
|
-
}
|
|
4040
|
-
|
|
4041
|
-
|
|
4042
|
-
|
|
4043
|
-
|
|
4044
|
-
break;
|
|
4045
|
-
case !!phone:
|
|
4046
|
-
{
|
|
4047
|
-
const validPhone = formatPhoneNumber(phone, countryCode);
|
|
4048
|
-
if (validPhone) auth = { phone: formatPhoneNumber(phone, countryCode) };
|
|
4243
|
+
/** NEW METHODS */
|
|
4244
|
+
getNewCredentialAndUrl(_0) {
|
|
4245
|
+
return __async(this, arguments, function* ({
|
|
4246
|
+
authMethod = "PASSKEY",
|
|
4247
|
+
isForNewDevice = false,
|
|
4248
|
+
portalTheme,
|
|
4249
|
+
shorten = false
|
|
4250
|
+
}) {
|
|
4251
|
+
this.assertIsAuthSet();
|
|
4252
|
+
let credentialId, urlType;
|
|
4253
|
+
switch (authMethod) {
|
|
4254
|
+
case "PASSKEY":
|
|
4255
|
+
({
|
|
4256
|
+
data: { id: credentialId }
|
|
4257
|
+
} = yield this.ctx.client.addSessionPublicKey(this.userId, {
|
|
4258
|
+
status: import_user_management_client5.PublicKeyStatus.PENDING,
|
|
4259
|
+
type: import_user_management_client5.PublicKeyType.WEB
|
|
4260
|
+
}));
|
|
4261
|
+
urlType = "createAuth";
|
|
4262
|
+
break;
|
|
4263
|
+
case "PASSWORD":
|
|
4264
|
+
({
|
|
4265
|
+
data: { id: credentialId }
|
|
4266
|
+
} = yield this.ctx.client.addSessionPasswordPublicKey(this.userId, {
|
|
4267
|
+
status: import_user_management_client5.PasswordStatus.PENDING
|
|
4268
|
+
}));
|
|
4269
|
+
urlType = "createPassword";
|
|
4270
|
+
break;
|
|
4049
4271
|
}
|
|
4050
|
-
|
|
4051
|
-
|
|
4052
|
-
|
|
4053
|
-
|
|
4054
|
-
|
|
4272
|
+
const url = yield this.constructPortalUrlV2(urlType, {
|
|
4273
|
+
isForNewDevice,
|
|
4274
|
+
pathId: credentialId,
|
|
4275
|
+
portalTheme,
|
|
4276
|
+
shorten
|
|
4277
|
+
});
|
|
4278
|
+
return { credentialId, url };
|
|
4279
|
+
});
|
|
4280
|
+
}
|
|
4281
|
+
getLoginUrlV2(_0) {
|
|
4282
|
+
return __async(this, arguments, function* ({
|
|
4283
|
+
authMethod = "PASSKEY",
|
|
4284
|
+
shorten = false,
|
|
4285
|
+
portalTheme,
|
|
4286
|
+
sessionId
|
|
4287
|
+
}) {
|
|
4288
|
+
if (!sessionId) {
|
|
4289
|
+
sessionId = (yield this.touchSession()).sessionLookupId;
|
|
4290
|
+
}
|
|
4291
|
+
this.assertIsAuthSet();
|
|
4292
|
+
let urlType;
|
|
4293
|
+
switch (authMethod) {
|
|
4294
|
+
case "PASSKEY":
|
|
4295
|
+
urlType = "loginAuth";
|
|
4296
|
+
break;
|
|
4297
|
+
case "PASSWORD":
|
|
4298
|
+
urlType = "loginPassword";
|
|
4299
|
+
break;
|
|
4300
|
+
default:
|
|
4301
|
+
throw new Error(`invalid authentication method: '${authMethod}'`);
|
|
4302
|
+
}
|
|
4303
|
+
return this.constructPortalUrlV2(urlType, {
|
|
4304
|
+
sessionId,
|
|
4305
|
+
shorten,
|
|
4306
|
+
portalTheme
|
|
4307
|
+
});
|
|
4308
|
+
});
|
|
4309
|
+
}
|
|
4310
|
+
getOAuthUrlV2(_0) {
|
|
4311
|
+
return __async(this, arguments, function* ({ method, deeplinkUrl }) {
|
|
4312
|
+
yield this.logout();
|
|
4313
|
+
const { sessionLookupId } = yield this.touchSession(true);
|
|
4314
|
+
return constructUrl({
|
|
4315
|
+
base: getBaseOAuthUrl(this.ctx.env),
|
|
4316
|
+
path: `/auth/${method}`,
|
|
4317
|
+
params: {
|
|
4318
|
+
apiKey: this.ctx.apiKey,
|
|
4319
|
+
sessionLookupId,
|
|
4320
|
+
deeplinkUrl
|
|
4321
|
+
}
|
|
4322
|
+
});
|
|
4323
|
+
});
|
|
4324
|
+
}
|
|
4325
|
+
signUpOrLogInV2(_k) {
|
|
4326
|
+
return __async(this, null, function* () {
|
|
4327
|
+
var _l = _k, {
|
|
4328
|
+
auth
|
|
4329
|
+
} = _l, urlOptions = __objRest(_l, [
|
|
4330
|
+
"auth"
|
|
4331
|
+
]);
|
|
4332
|
+
const serverAuthState = yield this.ctx.client.signUpOrLogIn(__spreadValues(__spreadValues({}, auth), this.getVerificationEmailProps()));
|
|
4333
|
+
return __privateMethod(this, _ParaCore_instances, prepareAuthState_fn).call(this, serverAuthState, urlOptions);
|
|
4334
|
+
});
|
|
4335
|
+
}
|
|
4336
|
+
verifyNewAccountV2(_m) {
|
|
4337
|
+
return __async(this, null, function* () {
|
|
4338
|
+
var _n = _m, {
|
|
4339
|
+
verificationCode
|
|
4340
|
+
} = _n, urlOptions = __objRest(_n, [
|
|
4341
|
+
"verificationCode"
|
|
4342
|
+
]);
|
|
4343
|
+
this.assertIsAuthSet(["email", "phone"]);
|
|
4344
|
+
const userId = this.assertUserId();
|
|
4345
|
+
const serverAuthState = yield this.ctx.client.verifyNewAccount(userId, {
|
|
4346
|
+
verificationCode
|
|
4347
|
+
});
|
|
4348
|
+
return __privateMethod(this, _ParaCore_instances, prepareAuthState_fn).call(this, serverAuthState, urlOptions);
|
|
4349
|
+
});
|
|
4350
|
+
}
|
|
4351
|
+
verifyOAuthV2(_o) {
|
|
4352
|
+
return __async(this, null, function* () {
|
|
4353
|
+
var _p = _o, {
|
|
4354
|
+
method,
|
|
4355
|
+
deeplinkUrl,
|
|
4356
|
+
isCanceled = () => false,
|
|
4357
|
+
onCancel,
|
|
4358
|
+
onPoll,
|
|
4359
|
+
onOAuthUrl
|
|
4360
|
+
} = _p, urlOptions = __objRest(_p, [
|
|
4361
|
+
"method",
|
|
4362
|
+
"deeplinkUrl",
|
|
4363
|
+
"isCanceled",
|
|
4364
|
+
"onCancel",
|
|
4365
|
+
"onPoll",
|
|
4366
|
+
"onOAuthUrl"
|
|
4367
|
+
]);
|
|
4368
|
+
const sessionLookupId = yield __privateMethod(this, _ParaCore_instances, prepareLogin_fn).call(this);
|
|
4369
|
+
const oAuthUrl = constructUrl({
|
|
4370
|
+
base: getBaseOAuthUrl(this.ctx.env),
|
|
4371
|
+
path: `/auth/${method}`,
|
|
4372
|
+
params: {
|
|
4373
|
+
apiKey: this.ctx.apiKey,
|
|
4374
|
+
sessionLookupId,
|
|
4375
|
+
deeplinkUrl
|
|
4376
|
+
}
|
|
4377
|
+
});
|
|
4378
|
+
onOAuthUrl(oAuthUrl);
|
|
4379
|
+
const startedAt = Date.now();
|
|
4380
|
+
return new Promise((resolve, reject) => {
|
|
4381
|
+
(() => __async(this, null, function* () {
|
|
4382
|
+
while (true) {
|
|
4383
|
+
try {
|
|
4384
|
+
if (isCanceled() || Date.now() - startedAt > POLLING_TIMEOUT_MS) {
|
|
4385
|
+
onCancel == null ? void 0 : onCancel();
|
|
4386
|
+
return reject("canceled");
|
|
4387
|
+
}
|
|
4388
|
+
yield new Promise((_resolve) => setTimeout(_resolve, POLLING_INTERVAL_MS));
|
|
4389
|
+
const serverAuthState = yield this.ctx.client.verifyOAuth();
|
|
4390
|
+
if (isServerAuthState(serverAuthState)) {
|
|
4391
|
+
const authState = yield __privateMethod(this, _ParaCore_instances, prepareAuthState_fn).call(this, serverAuthState, __spreadProps(__spreadValues({}, urlOptions), { sessionLookupId }));
|
|
4392
|
+
return resolve(authState);
|
|
4393
|
+
}
|
|
4394
|
+
onPoll == null ? void 0 : onPoll();
|
|
4395
|
+
} catch (err) {
|
|
4396
|
+
console.error(err);
|
|
4397
|
+
onPoll == null ? void 0 : onPoll();
|
|
4398
|
+
}
|
|
4399
|
+
}
|
|
4400
|
+
}))();
|
|
4401
|
+
});
|
|
4402
|
+
});
|
|
4403
|
+
}
|
|
4404
|
+
verifyFarcasterV2(_q) {
|
|
4405
|
+
return __async(this, null, function* () {
|
|
4406
|
+
var _r = _q, {
|
|
4407
|
+
isCanceled = () => false,
|
|
4408
|
+
onConnectUri,
|
|
4409
|
+
onCancel,
|
|
4410
|
+
onPoll
|
|
4411
|
+
} = _r, urlOptions = __objRest(_r, [
|
|
4412
|
+
"isCanceled",
|
|
4413
|
+
"onConnectUri",
|
|
4414
|
+
"onCancel",
|
|
4415
|
+
"onPoll"
|
|
4416
|
+
]);
|
|
4417
|
+
const {
|
|
4418
|
+
data: { connect_uri: connectUri }
|
|
4419
|
+
} = yield this.ctx.client.initializeFarcasterLogin();
|
|
4420
|
+
onConnectUri(connectUri);
|
|
4421
|
+
return new Promise((resolve, reject) => {
|
|
4422
|
+
(() => __async(this, null, function* () {
|
|
4423
|
+
const startedAt = Date.now();
|
|
4424
|
+
while (true) {
|
|
4425
|
+
try {
|
|
4426
|
+
if (isCanceled() || Date.now() - startedAt > POLLING_TIMEOUT_MS) {
|
|
4427
|
+
onCancel == null ? void 0 : onCancel();
|
|
4428
|
+
return reject("canceled");
|
|
4429
|
+
}
|
|
4430
|
+
yield new Promise((_resolve) => setTimeout(_resolve, POLLING_INTERVAL_MS));
|
|
4431
|
+
const serverAuthState = yield this.ctx.client.getFarcasterAuthStatusV2();
|
|
4432
|
+
if (isServerAuthState(serverAuthState)) {
|
|
4433
|
+
const authState = yield __privateMethod(this, _ParaCore_instances, prepareAuthState_fn).call(this, serverAuthState, urlOptions);
|
|
4434
|
+
return resolve(authState);
|
|
4435
|
+
}
|
|
4436
|
+
onPoll == null ? void 0 : onPoll();
|
|
4437
|
+
} catch (e) {
|
|
4438
|
+
console.error(e);
|
|
4439
|
+
return reject(e);
|
|
4440
|
+
}
|
|
4441
|
+
}
|
|
4442
|
+
}))();
|
|
4443
|
+
});
|
|
4444
|
+
});
|
|
4445
|
+
}
|
|
4446
|
+
/**
|
|
4447
|
+
* Validates the response received from an attempted Telegram login for authenticity, then
|
|
4448
|
+
* creates or retrieves the corresponding Para user and prepares the Para instance to sign in with that user.
|
|
4449
|
+
* @param authResponse - the response JSON object received from the Telegram widget.
|
|
4450
|
+
* @returns `{ isValid: boolean; telegramUserId?: string; userId?: string; isNewUser?: boolean; supportedAuthMethods?: AuthMethod[]; biometricHints?: BiometricLocationHint[] }`
|
|
4451
|
+
*/
|
|
4452
|
+
verifyTelegramV2(_s) {
|
|
4453
|
+
return __async(this, null, function* () {
|
|
4454
|
+
var _t = _s, {
|
|
4455
|
+
telegramAuthResponse
|
|
4456
|
+
} = _t, urlOptions = __objRest(_t, [
|
|
4457
|
+
"telegramAuthResponse"
|
|
4458
|
+
]);
|
|
4459
|
+
try {
|
|
4460
|
+
const serverAuthState = yield this.ctx.client.verifyTelegramV2(telegramAuthResponse);
|
|
4461
|
+
return __privateMethod(this, _ParaCore_instances, prepareAuthState_fn).call(this, serverAuthState, urlOptions);
|
|
4462
|
+
} catch (e) {
|
|
4463
|
+
throw new Error(e.message);
|
|
4464
|
+
}
|
|
4465
|
+
});
|
|
4466
|
+
}
|
|
4467
|
+
/**
|
|
4468
|
+
* Waits for the session to be active and sets up the user.
|
|
4469
|
+
*
|
|
4470
|
+
* @param {Object} opts the options object
|
|
4471
|
+
* @param {Window} [opts.popupWindow] the popup window being used for login.
|
|
4472
|
+
* @param {boolean} [opts.skipSessionRefresh] whether to skip refreshing the session.
|
|
4473
|
+
* @returns {Object} `{ isComplete: boolean; isError: boolean; needsWallet: boolean; partnerId: string; }` the result data
|
|
4474
|
+
**/
|
|
4475
|
+
waitForLoginV2() {
|
|
4476
|
+
return __async(this, arguments, function* ({
|
|
4477
|
+
isCanceled = () => false,
|
|
4478
|
+
onCancel,
|
|
4479
|
+
onPoll,
|
|
4480
|
+
skipSessionRefresh = false
|
|
4481
|
+
} = {}) {
|
|
4482
|
+
const startedAt = Date.now();
|
|
4483
|
+
return new Promise((resolve, reject) => {
|
|
4484
|
+
(() => __async(this, null, function* () {
|
|
4485
|
+
var _a;
|
|
4486
|
+
if (!this.isExternalWalletAuth) {
|
|
4487
|
+
this.externalWallets = {};
|
|
4488
|
+
}
|
|
4489
|
+
while (true) {
|
|
4490
|
+
if (isCanceled() || Date.now() - startedAt > POLLING_TIMEOUT_MS) {
|
|
4491
|
+
dispatchEvent(ParaEvent.LOGIN_EVENT, { isComplete: false }, "failed to setup user");
|
|
4492
|
+
onCancel == null ? void 0 : onCancel();
|
|
4493
|
+
return reject("canceled");
|
|
4494
|
+
}
|
|
4495
|
+
yield new Promise((resolve2) => setTimeout(resolve2, POLLING_INTERVAL_MS));
|
|
4496
|
+
try {
|
|
4497
|
+
let session = yield this.touchSession();
|
|
4498
|
+
if (!session.isAuthenticated) {
|
|
4499
|
+
onPoll == null ? void 0 : onPoll();
|
|
4500
|
+
continue;
|
|
4501
|
+
}
|
|
4502
|
+
session = yield this.userSetupAfterLogin();
|
|
4503
|
+
const needsWallet = (_a = session.needsWallet) != null ? _a : false;
|
|
4504
|
+
if (!needsWallet) {
|
|
4505
|
+
if (this.currentWalletIdsArray.length === 0) {
|
|
4506
|
+
onPoll == null ? void 0 : onPoll();
|
|
4507
|
+
continue;
|
|
4508
|
+
}
|
|
4509
|
+
}
|
|
4510
|
+
const fetchedWallets = yield this.fetchWallets();
|
|
4511
|
+
const tempSharesRes = yield this.getTransmissionKeyShares();
|
|
4512
|
+
if (tempSharesRes.data.temporaryShares.length === fetchedWallets.length) {
|
|
4513
|
+
yield this.setupAfterLogin({ temporaryShares: tempSharesRes.data.temporaryShares, skipSessionRefresh });
|
|
4514
|
+
yield this.claimPregenWalletsV2();
|
|
4515
|
+
const resp = {
|
|
4516
|
+
needsWallet: needsWallet || Object.values(this.wallets).length === 0,
|
|
4517
|
+
partnerId: session.partnerId
|
|
4518
|
+
};
|
|
4519
|
+
dispatchEvent(ParaEvent.LOGIN_EVENT, resp);
|
|
4520
|
+
return resolve(resp);
|
|
4521
|
+
}
|
|
4522
|
+
onPoll == null ? void 0 : onPoll();
|
|
4523
|
+
} catch (err) {
|
|
4524
|
+
console.error(err);
|
|
4525
|
+
onPoll == null ? void 0 : onPoll();
|
|
4526
|
+
}
|
|
4527
|
+
}
|
|
4528
|
+
}))();
|
|
4529
|
+
});
|
|
4530
|
+
});
|
|
4531
|
+
}
|
|
4532
|
+
waitForSignupV2(_0) {
|
|
4533
|
+
return __async(this, arguments, function* ({
|
|
4534
|
+
isCanceled = () => false,
|
|
4535
|
+
onCancel,
|
|
4536
|
+
onPoll
|
|
4537
|
+
}) {
|
|
4538
|
+
const startedAt = Date.now();
|
|
4539
|
+
return new Promise((resolve, reject) => {
|
|
4540
|
+
(() => __async(this, null, function* () {
|
|
4541
|
+
yield this.touchSession();
|
|
4542
|
+
if (!this.isExternalWalletAuth) {
|
|
4543
|
+
this.externalWallets = {};
|
|
4544
|
+
}
|
|
4545
|
+
while (true) {
|
|
4546
|
+
try {
|
|
4547
|
+
if (isCanceled() || Date.now() - startedAt > POLLING_TIMEOUT_MS) {
|
|
4548
|
+
onCancel == null ? void 0 : onCancel();
|
|
4549
|
+
dispatchEvent(ParaEvent.ACCOUNT_CREATION_EVENT, false, "failed to sign up user");
|
|
4550
|
+
return reject("canceled");
|
|
4551
|
+
}
|
|
4552
|
+
yield new Promise((_resolve) => setTimeout(_resolve, POLLING_INTERVAL_MS));
|
|
4553
|
+
if (yield this.isSessionActive()) {
|
|
4554
|
+
dispatchEvent(ParaEvent.ACCOUNT_CREATION_EVENT, true);
|
|
4555
|
+
return resolve(true);
|
|
4556
|
+
}
|
|
4557
|
+
onPoll == null ? void 0 : onPoll();
|
|
4558
|
+
} catch (err) {
|
|
4559
|
+
console.error(err);
|
|
4560
|
+
onPoll == null ? void 0 : onPoll();
|
|
4561
|
+
}
|
|
4562
|
+
}
|
|
4563
|
+
}))();
|
|
4564
|
+
});
|
|
4565
|
+
});
|
|
4566
|
+
}
|
|
4567
|
+
waitForWalletCreationV2() {
|
|
4568
|
+
return __async(this, arguments, function* ({
|
|
4569
|
+
isCanceled = () => false,
|
|
4570
|
+
onCancel
|
|
4571
|
+
} = {}) {
|
|
4572
|
+
yield this.waitForSignupV2({ isCanceled, onCancel });
|
|
4573
|
+
const { supportedWalletTypes } = yield __privateMethod(this, _ParaCore_instances, assertPartner_fn).call(this);
|
|
4574
|
+
const pregenWallets = yield this.getPregenWalletsV2();
|
|
4575
|
+
let recoverySecret, walletIds = {};
|
|
4576
|
+
if (pregenWallets.length > 0) {
|
|
4577
|
+
recoverySecret = yield this.claimPregenWalletsV2();
|
|
4578
|
+
walletIds = supportedWalletTypes.reduce((acc, { type }) => {
|
|
4579
|
+
var _a;
|
|
4580
|
+
return __spreadProps(__spreadValues({}, acc), {
|
|
4581
|
+
[type]: [(_a = pregenWallets.find((w) => !!WalletSchemeTypeMap[w.scheme][type])) == null ? void 0 : _a.id]
|
|
4582
|
+
});
|
|
4583
|
+
}, {});
|
|
4584
|
+
}
|
|
4585
|
+
const created = yield this.createWalletPerType();
|
|
4586
|
+
recoverySecret = recoverySecret != null ? recoverySecret : created.recoverySecret;
|
|
4587
|
+
walletIds = __spreadValues(__spreadValues({}, walletIds), created.walletIds);
|
|
4588
|
+
const resp = { walletIds, recoverySecret };
|
|
4589
|
+
dispatchEvent(ParaEvent.ACCOUNT_SETUP_EVENT, resp);
|
|
4590
|
+
return resp;
|
|
4591
|
+
});
|
|
4592
|
+
}
|
|
4593
|
+
loginExternalWalletV2(_u) {
|
|
4594
|
+
return __async(this, null, function* () {
|
|
4595
|
+
var _v = _u, {
|
|
4596
|
+
externalWallet
|
|
4597
|
+
} = _v, urlOptions = __objRest(_v, [
|
|
4598
|
+
"externalWallet"
|
|
4599
|
+
]);
|
|
4600
|
+
this.requireApiKey();
|
|
4601
|
+
const serverAuthState = yield this.ctx.client.loginExternalWalletV2({ externalWallet });
|
|
4602
|
+
return __privateMethod(this, _ParaCore_instances, prepareAuthState_fn).call(this, serverAuthState, urlOptions);
|
|
4603
|
+
});
|
|
4604
|
+
}
|
|
4605
|
+
verifyExternalWalletV2(_w) {
|
|
4606
|
+
return __async(this, null, function* () {
|
|
4607
|
+
var _x = _w, {
|
|
4608
|
+
externalWallet,
|
|
4609
|
+
signedMessage,
|
|
4610
|
+
cosmosPublicKeyHex,
|
|
4611
|
+
cosmosSigner
|
|
4612
|
+
} = _x, urlOptions = __objRest(_x, [
|
|
4613
|
+
"externalWallet",
|
|
4614
|
+
"signedMessage",
|
|
4615
|
+
"cosmosPublicKeyHex",
|
|
4616
|
+
"cosmosSigner"
|
|
4617
|
+
]);
|
|
4618
|
+
const serverAuthState = yield this.ctx.client.verifyExternalWalletV2(this.userId, {
|
|
4619
|
+
externalWallet,
|
|
4620
|
+
signedMessage,
|
|
4621
|
+
cosmosPublicKeyHex,
|
|
4622
|
+
cosmosSigner
|
|
4623
|
+
});
|
|
4624
|
+
return __privateMethod(this, _ParaCore_instances, prepareAuthState_fn).call(this, serverAuthState, urlOptions);
|
|
4625
|
+
});
|
|
4626
|
+
}
|
|
4627
|
+
/**
|
|
4628
|
+
* Performs 2FA verification.
|
|
4629
|
+
* @param {Object} opts the options object
|
|
4630
|
+
* @param {string} opts.email the email to use for performing a 2FA verification.
|
|
4631
|
+
* @param {string} opts.verificationCode the verification code to received via 2FA.
|
|
4632
|
+
* @returns {Object} `{ address, initiatedAt, status, userId, walletId }`
|
|
4633
|
+
*/
|
|
4634
|
+
verify2faV2(_0) {
|
|
4635
|
+
return __async(this, arguments, function* ({ auth, verificationCode }) {
|
|
4636
|
+
const res = yield this.ctx.client.verify2FAV2(auth, verificationCode);
|
|
4637
|
+
return {
|
|
4638
|
+
initiatedAt: res.data.initiatedAt,
|
|
4639
|
+
status: res.data.status,
|
|
4640
|
+
userId: res.data.userId,
|
|
4641
|
+
wallets: res.data.wallets
|
|
4642
|
+
};
|
|
4643
|
+
});
|
|
4644
|
+
}
|
|
4645
|
+
/**
|
|
4646
|
+
* Sets up two-factor authentication for the current user.
|
|
4647
|
+
* @returns {string} uri - uri to use for setting up 2FA
|
|
4648
|
+
* */
|
|
4649
|
+
setup2faV2() {
|
|
4650
|
+
return __async(this, null, function* () {
|
|
4651
|
+
const userId = this.assertUserId();
|
|
4652
|
+
const res = yield this.ctx.client.setup2FAV2(userId);
|
|
4653
|
+
return res;
|
|
4654
|
+
});
|
|
4655
|
+
}
|
|
4656
|
+
/**
|
|
4657
|
+
* Enables 2FA.
|
|
4658
|
+
* @param {Object} opts the options object
|
|
4659
|
+
* @param {string} opts.verificationCode - the verification code received via 2FA.
|
|
4660
|
+
*/
|
|
4661
|
+
enable2faV2(_0) {
|
|
4662
|
+
return __async(this, arguments, function* ({ verificationCode }) {
|
|
4663
|
+
const userId = this.assertUserId();
|
|
4664
|
+
yield this.ctx.client.enable2FA(userId, verificationCode);
|
|
4665
|
+
});
|
|
4666
|
+
}
|
|
4667
|
+
/**
|
|
4668
|
+
* Creates a new pregenerated wallet.
|
|
4669
|
+
*
|
|
4670
|
+
* @param {Object} opts the options object.
|
|
4671
|
+
* @param {string} opts.pregenIdentifier the identifier associated with the new wallet.
|
|
4672
|
+
* @param {TPregenIdentifierType} [opts.pregenIdentifierType] the identifier type. Defaults to `EMAIL`.
|
|
4673
|
+
* @param {WalletType} [opts.type] the type of wallet to create. Defaults to the first non-optional type in the instance's `supportedWalletTypes` array.
|
|
4674
|
+
* @returns {Wallet} the created wallet.
|
|
4675
|
+
**/
|
|
4676
|
+
createPregenWalletV2(opts) {
|
|
4677
|
+
return __async(this, null, function* () {
|
|
4678
|
+
var _a, _b;
|
|
4679
|
+
const { supportedWalletTypes } = yield __privateMethod(this, _ParaCore_instances, assertPartner_fn).call(this);
|
|
4680
|
+
const { type: _type = (_a = supportedWalletTypes.find(({ optional }) => !optional)) == null ? void 0 : _a.type, pregenId } = opts;
|
|
4681
|
+
this.requireApiKey();
|
|
4682
|
+
const walletType = yield this.assertIsValidWalletType(
|
|
4683
|
+
_type != null ? _type : (_b = supportedWalletTypes.find(({ optional }) => !optional)) == null ? void 0 : _b.type
|
|
4684
|
+
);
|
|
4685
|
+
const [pregenIdentifierType, pregenIdentifier] = (0, import_user_management_client5.toPregenTypeAndId)(pregenId);
|
|
4686
|
+
let keygenRes;
|
|
4687
|
+
switch (walletType) {
|
|
4688
|
+
case import_user_management_client5.WalletType.SOLANA:
|
|
4689
|
+
keygenRes = yield this.platformUtils.ed25519PreKeygen(
|
|
4690
|
+
this.ctx,
|
|
4691
|
+
pregenIdentifier,
|
|
4692
|
+
pregenIdentifierType,
|
|
4693
|
+
this.retrieveSessionCookie()
|
|
4694
|
+
);
|
|
4695
|
+
break;
|
|
4696
|
+
default:
|
|
4697
|
+
keygenRes = yield this.platformUtils.preKeygen(
|
|
4698
|
+
this.ctx,
|
|
4699
|
+
void 0,
|
|
4700
|
+
pregenIdentifier,
|
|
4701
|
+
pregenIdentifierType,
|
|
4702
|
+
walletType,
|
|
4703
|
+
null,
|
|
4704
|
+
this.retrieveSessionCookie()
|
|
4705
|
+
);
|
|
4706
|
+
break;
|
|
4707
|
+
}
|
|
4708
|
+
const { signer, walletId } = keygenRes;
|
|
4709
|
+
this.wallets[walletId] = {
|
|
4710
|
+
id: walletId,
|
|
4711
|
+
signer,
|
|
4712
|
+
scheme: walletType === import_user_management_client5.WalletType.SOLANA ? import_user_management_client5.WalletScheme.ED25519 : import_user_management_client5.WalletScheme.DKLS,
|
|
4713
|
+
type: walletType,
|
|
4714
|
+
isPregen: true,
|
|
4715
|
+
pregenIdentifier,
|
|
4716
|
+
pregenIdentifierType
|
|
4717
|
+
};
|
|
4718
|
+
yield this.waitForPregenWalletAddress(walletId);
|
|
4719
|
+
yield this.populatePregenWalletAddresses();
|
|
4720
|
+
return this.wallets[walletId];
|
|
4721
|
+
});
|
|
4722
|
+
}
|
|
4723
|
+
/**
|
|
4724
|
+
* Creates new pregenerated wallets for each desired type.
|
|
4725
|
+
* If no types are provided, this method will create one for each of the non-optional types
|
|
4726
|
+
* specified in the instance's `supportedWalletTypes` array that are not already present.
|
|
4727
|
+
* @param {Object} opts the options object.
|
|
4728
|
+
* @param {string} opts.pregenIdentifier the identifier to associate each wallet with.
|
|
4729
|
+
* @param {TPregenIdentifierType} opts.pregenIdentifierType - either `'EMAIL'` or `'PHONE'`.
|
|
4730
|
+
* @param {WalletType[]} [opts.types] the wallet types to create. Defaults to any types the instance supports that are not already present.
|
|
4731
|
+
* @returns {Wallet[]} an array containing the created wallets.
|
|
4732
|
+
**/
|
|
4733
|
+
createPregenWalletPerTypeV2(_0) {
|
|
4734
|
+
return __async(this, arguments, function* ({
|
|
4735
|
+
types,
|
|
4736
|
+
pregenId
|
|
4737
|
+
}) {
|
|
4738
|
+
const wallets = [];
|
|
4739
|
+
for (const type of yield this.getTypesToCreate(types)) {
|
|
4740
|
+
const wallet = yield this.createPregenWalletV2({ type, pregenId });
|
|
4741
|
+
wallets.push(wallet);
|
|
4742
|
+
}
|
|
4743
|
+
return wallets;
|
|
4744
|
+
});
|
|
4745
|
+
}
|
|
4746
|
+
/**
|
|
4747
|
+
* Claims a pregenerated wallet.
|
|
4748
|
+
* @param {Object} opts the options object.
|
|
4749
|
+
* @param {string} opts.pregenIdentifier string the identifier of the user claiming the wallet
|
|
4750
|
+
* @param {TPregenIdentifierType} opts.pregenIdentifierType type of the identifier of the user claiming the wallet
|
|
4751
|
+
* @returns {[Wallet, string | null]} `[wallet, recoveryShare]` - the wallet object and the new recovery share.
|
|
4752
|
+
**/
|
|
4753
|
+
claimPregenWalletsV2() {
|
|
4754
|
+
return __async(this, arguments, function* ({
|
|
4755
|
+
pregenId
|
|
4756
|
+
} = {}) {
|
|
4757
|
+
var _a;
|
|
4758
|
+
this.requireApiKey();
|
|
4759
|
+
const pregenWallets = pregenId ? yield this.getPregenWalletsV2({ pregenId }) : yield this.getPregenWalletsV2();
|
|
4760
|
+
if (pregenWallets.length === 0) {
|
|
4761
|
+
return void 0;
|
|
4762
|
+
}
|
|
4763
|
+
let newRecoverySecret;
|
|
4764
|
+
const { walletIds } = yield this.ctx.client.claimPregenWallets({
|
|
4765
|
+
userId: this.userId,
|
|
4766
|
+
walletIds: pregenWallets.map((w) => w.id)
|
|
4767
|
+
});
|
|
4768
|
+
for (const walletId of walletIds) {
|
|
4769
|
+
const wallet = this.wallets[walletId];
|
|
4770
|
+
let refreshedShare;
|
|
4771
|
+
if (wallet.scheme === import_user_management_client5.WalletScheme.ED25519) {
|
|
4772
|
+
const distributeRes = yield distributeNewShare({
|
|
4773
|
+
ctx: this.ctx,
|
|
4774
|
+
userId: this.userId,
|
|
4775
|
+
walletId: wallet.id,
|
|
4776
|
+
userShare: this.wallets[wallet.id].signer,
|
|
4777
|
+
emailProps: this.getBackupKitEmailProps(),
|
|
4778
|
+
partnerId: wallet.partnerId
|
|
4779
|
+
});
|
|
4780
|
+
if (distributeRes.length > 0) {
|
|
4781
|
+
newRecoverySecret = distributeRes;
|
|
4782
|
+
}
|
|
4783
|
+
} else {
|
|
4784
|
+
refreshedShare = yield this.refreshShare({
|
|
4785
|
+
walletId: wallet.id,
|
|
4786
|
+
share: this.wallets[wallet.id].signer,
|
|
4787
|
+
oldPartnerId: wallet.partnerId,
|
|
4788
|
+
newPartnerId: wallet.partnerId,
|
|
4789
|
+
redistributeBackupEncryptedShares: true
|
|
4790
|
+
});
|
|
4791
|
+
if (refreshedShare.recoverySecret) {
|
|
4792
|
+
newRecoverySecret = refreshedShare.recoverySecret;
|
|
4793
|
+
}
|
|
4794
|
+
}
|
|
4795
|
+
this.wallets[wallet.id] = __spreadProps(__spreadValues({}, this.wallets[wallet.id]), {
|
|
4796
|
+
signer: (_a = refreshedShare == null ? void 0 : refreshedShare.signer) != null ? _a : wallet.signer,
|
|
4797
|
+
userId: this.userId,
|
|
4798
|
+
pregenIdentifier: void 0,
|
|
4799
|
+
pregenIdentifierType: void 0
|
|
4800
|
+
});
|
|
4801
|
+
const walletNoSigner = __spreadValues({}, this.wallets[wallet.id]);
|
|
4802
|
+
delete walletNoSigner.signer;
|
|
4803
|
+
dispatchEvent(ParaEvent.PREGEN_WALLET_CLAIMED, {
|
|
4804
|
+
wallet: walletNoSigner,
|
|
4805
|
+
recoverySecret: newRecoverySecret
|
|
4806
|
+
});
|
|
4807
|
+
}
|
|
4808
|
+
yield this.setWallets(this.wallets);
|
|
4809
|
+
return newRecoverySecret;
|
|
4810
|
+
});
|
|
4811
|
+
}
|
|
4812
|
+
/**
|
|
4813
|
+
* Updates the identifier for a pregen wallet.
|
|
4814
|
+
* @param {Object} opts the options object.
|
|
4815
|
+
* @param {string} opts.walletId the pregen wallet ID
|
|
4816
|
+
* @param {string} opts.newPregenIdentifier the new identtifier
|
|
4817
|
+
* @param {TPregenIdentifierType} opts.newPregenIdentifierType: the new identifier type
|
|
4818
|
+
**/
|
|
4819
|
+
updatePregenWalletIdentifierV2(_0) {
|
|
4820
|
+
return __async(this, arguments, function* ({
|
|
4821
|
+
walletId,
|
|
4822
|
+
newPregenId
|
|
4823
|
+
}) {
|
|
4824
|
+
this.requireApiKey();
|
|
4825
|
+
const [newPregenIdentifierType, newPregenIdentifier] = (0, import_user_management_client5.toPregenTypeAndId)(newPregenId);
|
|
4826
|
+
yield this.ctx.client.updatePregenWallet(walletId, {
|
|
4827
|
+
pregenIdentifier: newPregenIdentifier,
|
|
4828
|
+
pregenIdentifierType: newPregenIdentifierType
|
|
4829
|
+
});
|
|
4830
|
+
if (!!this.wallets[walletId]) {
|
|
4831
|
+
this.wallets[walletId] = __spreadProps(__spreadValues({}, this.wallets[walletId]), {
|
|
4832
|
+
pregenIdentifier: newPregenIdentifier,
|
|
4833
|
+
pregenIdentifierType: newPregenIdentifierType
|
|
4834
|
+
});
|
|
4835
|
+
yield this.setWallets(this.wallets);
|
|
4836
|
+
}
|
|
4837
|
+
});
|
|
4838
|
+
}
|
|
4839
|
+
/**
|
|
4840
|
+
* Checks if a pregen Wallet exists for the given identifier with the current partner.
|
|
4841
|
+
* @param {Object} opts the options object.
|
|
4842
|
+
* @param {string} opts.pregenIdentifier string the identifier of the user claiming the wallet
|
|
4843
|
+
* @param {TPregenIdentifierType} opts.pregenIdentifierType type of the string of the identifier of the user claiming the wallet
|
|
4844
|
+
* @returns {boolean} whether the pregen wallet exists
|
|
4845
|
+
**/
|
|
4846
|
+
hasPregenWalletV2(_0) {
|
|
4847
|
+
return __async(this, arguments, function* ({ pregenId }) {
|
|
4848
|
+
this.requireApiKey();
|
|
4849
|
+
const [pregenIdentifierType, pregenIdentifier] = (0, import_user_management_client5.toPregenTypeAndId)(pregenId);
|
|
4850
|
+
const wallets = yield this.getPregenWalletsV2({ pregenId });
|
|
4851
|
+
const wallet = wallets.find(
|
|
4852
|
+
(w) => w.pregenIdentifier === pregenIdentifier && w.pregenIdentifierType === pregenIdentifierType
|
|
4853
|
+
);
|
|
4854
|
+
if (!wallet) {
|
|
4855
|
+
return false;
|
|
4856
|
+
}
|
|
4857
|
+
return true;
|
|
4858
|
+
});
|
|
4859
|
+
}
|
|
4860
|
+
/**
|
|
4861
|
+
* Get pregen wallets for the given identifier.
|
|
4862
|
+
* @param {Object} opts the options object.
|
|
4863
|
+
* @param {string} opts.pregenIdentifier - the identifier of the user claiming the wallet
|
|
4864
|
+
* @param {TPregenIdentifierType} opts.pregenIdentifierType - type of the identifier of the user claiming the wallet
|
|
4865
|
+
* @returns {Promise<WalletEntity[]>} the array of found wallets
|
|
4866
|
+
**/
|
|
4867
|
+
getPregenWalletsV2() {
|
|
4868
|
+
return __async(this, arguments, function* ({
|
|
4869
|
+
pregenId
|
|
4870
|
+
} = {}) {
|
|
4871
|
+
this.requireApiKey();
|
|
4872
|
+
const res = yield this.ctx.client.getPregenWallets(
|
|
4873
|
+
pregenId ? (0, import_user_management_client5.toPregenIds)(pregenId) : this.pregenIds,
|
|
4874
|
+
this.isPortal(),
|
|
4875
|
+
this.userId
|
|
4876
|
+
);
|
|
4877
|
+
return res.wallets.filter((w) => this.isWalletSupported(entityToWallet(w)));
|
|
4878
|
+
});
|
|
4879
|
+
}
|
|
4880
|
+
};
|
|
4881
|
+
_authInfo = new WeakMap();
|
|
4882
|
+
_partner = new WeakMap();
|
|
4883
|
+
_ParaCore_instances = new WeakSet();
|
|
4884
|
+
assertPartner_fn = function() {
|
|
4885
|
+
return __async(this, null, function* () {
|
|
4886
|
+
var _a, _b;
|
|
4887
|
+
if (!__privateGet(this, _partner)) {
|
|
4888
|
+
yield this.touchSession();
|
|
4889
|
+
}
|
|
4890
|
+
if (((_a = __privateGet(this, _partner)) == null ? void 0 : _a.cosmosPrefix) && this.ctx.cosmosPrefix !== __privateGet(this, _partner).cosmosPrefix) {
|
|
4891
|
+
this.ctx.cosmosPrefix = (_b = __privateGet(this, _partner)) == null ? void 0 : _b.cosmosPrefix;
|
|
4892
|
+
}
|
|
4893
|
+
return __privateGet(this, _partner);
|
|
4894
|
+
});
|
|
4895
|
+
};
|
|
4896
|
+
toAuthInfo_fn = function({
|
|
4897
|
+
email,
|
|
4898
|
+
phone,
|
|
4899
|
+
countryCode,
|
|
4900
|
+
farcasterUsername,
|
|
4901
|
+
telegramUserId,
|
|
4902
|
+
externalWalletAddress
|
|
4903
|
+
}) {
|
|
4904
|
+
let auth;
|
|
4905
|
+
switch (true) {
|
|
4906
|
+
case !!email:
|
|
4907
|
+
auth = { email };
|
|
4908
|
+
break;
|
|
4909
|
+
case !!phone:
|
|
4910
|
+
{
|
|
4911
|
+
const validPhone = formatPhoneNumber(phone, countryCode);
|
|
4912
|
+
if (validPhone) auth = { phone: formatPhoneNumber(phone, countryCode) };
|
|
4913
|
+
}
|
|
4914
|
+
break;
|
|
4915
|
+
case !!farcasterUsername:
|
|
4916
|
+
auth = { farcasterUsername };
|
|
4917
|
+
break;
|
|
4918
|
+
case !!telegramUserId:
|
|
4055
4919
|
auth = { telegramUserId };
|
|
4056
4920
|
break;
|
|
4057
4921
|
case !!externalWalletAddress:
|
|
@@ -4071,15 +4935,6 @@ setAuthInfo_fn = function(authInfo) {
|
|
|
4071
4935
|
yield this.localStorageRemoveItem(LOCAL_STORAGE_TELEGRAM_USER_ID);
|
|
4072
4936
|
});
|
|
4073
4937
|
};
|
|
4074
|
-
assertIsAuthSet_fn = function(allowed) {
|
|
4075
|
-
if (!__privateGet(this, _authInfo)) {
|
|
4076
|
-
throw new Error("auth is not set");
|
|
4077
|
-
}
|
|
4078
|
-
if (allowed && !allowed.includes(__privateGet(this, _authInfo).authType)) {
|
|
4079
|
-
throw new Error(`invalid auth type, expected ${allowed.join(", ")}`);
|
|
4080
|
-
}
|
|
4081
|
-
return __privateGet(this, _authInfo).auth;
|
|
4082
|
-
};
|
|
4083
4938
|
getPartner_fn = function(partnerId) {
|
|
4084
4939
|
return __async(this, null, function* () {
|
|
4085
4940
|
const res = yield this.ctx.client.getPartner(partnerId);
|
|
@@ -4087,6 +4942,113 @@ getPartner_fn = function(partnerId) {
|
|
|
4087
4942
|
return __privateGet(this, _partner);
|
|
4088
4943
|
});
|
|
4089
4944
|
};
|
|
4945
|
+
prepareAuthState_fn = function(_0) {
|
|
4946
|
+
return __async(this, arguments, function* (serverAuthState, opts = {}) {
|
|
4947
|
+
if (!opts.sessionLookupId && serverAuthState.stage === "login") {
|
|
4948
|
+
opts.sessionLookupId = yield __privateMethod(this, _ParaCore_instances, prepareLogin_fn).call(this);
|
|
4949
|
+
}
|
|
4950
|
+
const { auth, externalWallet, userId, displayName, pfpUrl, username } = serverAuthState;
|
|
4951
|
+
const authInfo = __spreadValues(__spreadValues({}, (0, import_user_management_client5.extractAuthInfo)(auth, { isRequired: true })), Object.fromEntries(
|
|
4952
|
+
Object.entries({
|
|
4953
|
+
displayName,
|
|
4954
|
+
pfpUrl,
|
|
4955
|
+
username,
|
|
4956
|
+
externalWallet
|
|
4957
|
+
}).filter(([_, v]) => !!v)
|
|
4958
|
+
));
|
|
4959
|
+
yield __privateMethod(this, _ParaCore_instances, setAuthInfo_fn).call(this, authInfo);
|
|
4960
|
+
yield this.assertIsAuthSet();
|
|
4961
|
+
if (!!externalWallet) {
|
|
4962
|
+
yield this.setExternalWallet(externalWallet);
|
|
4963
|
+
}
|
|
4964
|
+
if (!!userId) {
|
|
4965
|
+
yield this.setUserId(userId);
|
|
4966
|
+
}
|
|
4967
|
+
let authState;
|
|
4968
|
+
switch (serverAuthState.stage) {
|
|
4969
|
+
case "verify":
|
|
4970
|
+
authState = serverAuthState;
|
|
4971
|
+
break;
|
|
4972
|
+
case "login":
|
|
4973
|
+
authState = yield __privateMethod(this, _ParaCore_instances, prepareLoginState_fn).call(this, serverAuthState, __spreadProps(__spreadValues({}, opts), { sessionLookupId: opts.sessionLookupId }));
|
|
4974
|
+
break;
|
|
4975
|
+
case "signup":
|
|
4976
|
+
authState = yield __privateMethod(this, _ParaCore_instances, prepareSignUpState_fn).call(this, serverAuthState, opts);
|
|
4977
|
+
break;
|
|
4978
|
+
}
|
|
4979
|
+
return authState;
|
|
4980
|
+
});
|
|
4981
|
+
};
|
|
4982
|
+
prepareLogin_fn = function() {
|
|
4983
|
+
return __async(this, null, function* () {
|
|
4984
|
+
yield this.logout();
|
|
4985
|
+
const { sessionLookupId } = yield this.touchSession(true);
|
|
4986
|
+
if (!this.loginEncryptionKeyPair) {
|
|
4987
|
+
yield this.setLoginEncryptionKeyPair();
|
|
4988
|
+
}
|
|
4989
|
+
return sessionLookupId;
|
|
4990
|
+
});
|
|
4991
|
+
};
|
|
4992
|
+
prepareLoginState_fn = function(_0, _1) {
|
|
4993
|
+
return __async(this, arguments, function* (loginState, {
|
|
4994
|
+
useShortUrls: shorten = false,
|
|
4995
|
+
portalTheme,
|
|
4996
|
+
sessionLookupId
|
|
4997
|
+
}) {
|
|
4998
|
+
const _a = loginState, { loginAuthMethods } = _a, authState = __objRest(_a, ["loginAuthMethods"]);
|
|
4999
|
+
return __spreadValues(__spreadValues(__spreadValues({}, authState), !this.isNativePasskey && loginAuthMethods.includes(import_user_management_client5.AuthMethod.PASSKEY) ? {
|
|
5000
|
+
passkeyUrl: yield this.getLoginUrlV2({ sessionId: sessionLookupId, shorten, portalTheme }),
|
|
5001
|
+
passkeyKnownDeviceUrl: yield this.constructPortalUrlV2("loginAuth", {
|
|
5002
|
+
sessionId: sessionLookupId,
|
|
5003
|
+
newDevice: {
|
|
5004
|
+
sessionId: sessionLookupId,
|
|
5005
|
+
encryptionKey: getPublicKeyHex(this.loginEncryptionKeyPair)
|
|
5006
|
+
},
|
|
5007
|
+
shorten,
|
|
5008
|
+
portalTheme
|
|
5009
|
+
})
|
|
5010
|
+
} : {}), loginAuthMethods.includes(import_user_management_client5.AuthMethod.PASSWORD) ? {
|
|
5011
|
+
passwordUrl: yield this.constructPortalUrlV2("loginPassword", {
|
|
5012
|
+
sessionId: sessionLookupId,
|
|
5013
|
+
shorten,
|
|
5014
|
+
portalTheme
|
|
5015
|
+
})
|
|
5016
|
+
} : {});
|
|
5017
|
+
});
|
|
5018
|
+
};
|
|
5019
|
+
prepareSignUpState_fn = function(_0, _1) {
|
|
5020
|
+
return __async(this, arguments, function* (serverSignupState, { useShortUrls: shorten = false, portalTheme }) {
|
|
5021
|
+
const _a = serverSignupState, { signupAuthMethods } = _a, authState = __objRest(_a, ["signupAuthMethods"]);
|
|
5022
|
+
const [isPasskey, isPassword] = [
|
|
5023
|
+
signupAuthMethods.includes(import_user_management_client5.AuthMethod.PASSKEY),
|
|
5024
|
+
signupAuthMethods.includes(import_user_management_client5.AuthMethod.PASSWORD)
|
|
5025
|
+
];
|
|
5026
|
+
if (!isPasskey && !isPassword) {
|
|
5027
|
+
throw new Error(
|
|
5028
|
+
"No supported authentication methods found. Please ensure you have enabled either WebAuth passkeys or passwords in your Developer Portal settings."
|
|
5029
|
+
);
|
|
5030
|
+
}
|
|
5031
|
+
const signupState = authState;
|
|
5032
|
+
if (isPasskey) {
|
|
5033
|
+
const { url: passkeyUrl, credentialId: passkeyId } = yield this.getNewCredentialAndUrl({
|
|
5034
|
+
authMethod: "PASSKEY",
|
|
5035
|
+
shorten
|
|
5036
|
+
});
|
|
5037
|
+
signupState.passkeyUrl = passkeyUrl;
|
|
5038
|
+
signupState.passkeyId = passkeyId;
|
|
5039
|
+
}
|
|
5040
|
+
if (isPassword) {
|
|
5041
|
+
const { url: passwordUrl, credentialId: passwordId } = yield this.getNewCredentialAndUrl({
|
|
5042
|
+
authMethod: "PASSWORD",
|
|
5043
|
+
portalTheme,
|
|
5044
|
+
shorten
|
|
5045
|
+
});
|
|
5046
|
+
signupState.passwordUrl = passwordUrl;
|
|
5047
|
+
signupState.passwordId = passwordId;
|
|
5048
|
+
}
|
|
5049
|
+
return signupState;
|
|
5050
|
+
});
|
|
5051
|
+
};
|
|
4090
5052
|
_ParaCore.version = PARA_CORE_VERSION;
|
|
4091
5053
|
var ParaCore = _ParaCore;
|
|
4092
5054
|
|
|
@@ -4109,6 +5071,7 @@ var src_default = ParaCore;
|
|
|
4109
5071
|
OnRampProvider,
|
|
4110
5072
|
OnRampPurchaseStatus,
|
|
4111
5073
|
OnRampPurchaseType,
|
|
5074
|
+
PARA_CORE_METHODS,
|
|
4112
5075
|
PREGEN_IDENTIFIER_TYPES,
|
|
4113
5076
|
ParaEvent,
|
|
4114
5077
|
PopupType,
|
|
@@ -4120,6 +5083,7 @@ var src_default = ParaCore;
|
|
|
4120
5083
|
TransactionReviewTimeout,
|
|
4121
5084
|
WalletScheme,
|
|
4122
5085
|
WalletType,
|
|
5086
|
+
constructUrl,
|
|
4123
5087
|
decimalToHex,
|
|
4124
5088
|
decryptPrivateKey,
|
|
4125
5089
|
decryptPrivateKeyAndDecryptShare,
|
|
@@ -4157,6 +5121,7 @@ var src_default = ParaCore;
|
|
|
4157
5121
|
mpcComputationClient,
|
|
4158
5122
|
paraVersion,
|
|
4159
5123
|
publicKeyFromHex,
|
|
5124
|
+
shortenUrl,
|
|
4160
5125
|
toAssetInfoArray,
|
|
4161
5126
|
transmissionUtilsRetrieve,
|
|
4162
5127
|
truncateAddress,
|