@getpara/core-sdk 1.12.0 → 2.0.0-alpha.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/ParaCore.js +936 -974
- package/dist/cjs/constants.js +7 -1
- package/dist/cjs/index.js +15 -9
- package/dist/cjs/types/coreApi.js +74 -0
- package/dist/cjs/types/events.js +1 -0
- package/dist/cjs/types/index.js +4 -2
- package/dist/cjs/types/{params.js → methods.js} +2 -2
- package/dist/cjs/utils/autobind.js +41 -0
- package/dist/cjs/utils/formatting.js +0 -12
- package/dist/cjs/utils/index.js +10 -0
- package/dist/cjs/utils/json.js +37 -0
- package/dist/cjs/utils/listeners.js +2 -11
- package/dist/cjs/utils/phone.js +61 -0
- package/dist/cjs/utils/types.js +29 -0
- package/dist/cjs/utils/url.js +34 -2
- package/dist/cjs/utils/wallet.js +30 -17
- package/dist/esm/ParaCore.js +952 -979
- package/dist/esm/constants.js +5 -1
- package/dist/esm/index.js +12 -9
- package/dist/esm/types/coreApi.js +52 -0
- package/dist/esm/types/events.js +1 -0
- package/dist/esm/types/index.js +2 -1
- package/dist/esm/utils/autobind.js +19 -0
- package/dist/esm/utils/formatting.js +0 -10
- package/dist/esm/utils/index.js +5 -0
- package/dist/esm/utils/json.js +15 -0
- package/dist/esm/utils/listeners.js +2 -11
- package/dist/esm/utils/phone.js +28 -0
- package/dist/esm/utils/types.js +7 -0
- package/dist/esm/utils/url.js +15 -2
- package/dist/esm/utils/wallet.js +27 -16
- package/dist/types/ParaCore.d.ts +100 -391
- package/dist/types/PlatformUtils.d.ts +3 -3
- package/dist/types/constants.d.ts +2 -0
- package/dist/types/external/userManagementClient.d.ts +1 -1
- package/dist/types/index.d.ts +5 -3
- package/dist/types/types/config.d.ts +4 -24
- package/dist/types/types/coreApi.d.ts +475 -0
- package/dist/types/types/events.d.ts +4 -1
- package/dist/types/types/index.d.ts +2 -1
- package/dist/types/types/methods.d.ts +148 -0
- package/dist/types/types/onRamps.d.ts +3 -3
- package/dist/types/types/wallet.d.ts +4 -4
- package/dist/types/utils/autobind.d.ts +1 -0
- package/dist/types/utils/formatting.d.ts +2 -4
- package/dist/types/utils/index.d.ts +5 -0
- package/dist/types/utils/json.d.ts +1 -0
- package/dist/types/utils/onRamps.d.ts +3 -3
- package/dist/types/utils/phone.d.ts +7 -0
- package/dist/types/utils/types.d.ts +2 -0
- package/dist/types/utils/url.d.ts +2 -1
- package/dist/types/utils/wallet.d.ts +9 -7
- package/package.json +4 -3
- package/dist/types/types/params.d.ts +0 -73
- /package/dist/esm/types/{params.js → methods.js} +0 -0
package/dist/esm/ParaCore.js
CHANGED
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
__spreadProps,
|
|
9
9
|
__spreadValues
|
|
10
10
|
} from "./chunk-7B52C2XE.js";
|
|
11
|
-
var
|
|
11
|
+
var _authInfo, _partner, _ParaCore_instances, assertPartner_fn, guestWalletIds_get, guestWalletIdsArray_get, toAuthInfo_fn, setAuthInfo_fn, getPartner_fn, createPregenWallet_fn, _isCreateGuestWalletsPending, prepareAuthState_fn, prepareLogin_fn, prepareLoginState_fn, prepareSignUpState_fn;
|
|
12
12
|
import { Buffer as NodeBuffer } from "buffer";
|
|
13
13
|
if (typeof global !== "undefined") {
|
|
14
14
|
global.Buffer = global.Buffer || NodeBuffer;
|
|
@@ -23,12 +23,17 @@ import {
|
|
|
23
23
|
AuthMethod,
|
|
24
24
|
PublicKeyStatus,
|
|
25
25
|
PublicKeyType,
|
|
26
|
-
WalletType,
|
|
27
|
-
WalletScheme,
|
|
28
|
-
OAuthMethod,
|
|
29
26
|
extractWalletRef,
|
|
30
27
|
PasswordStatus,
|
|
31
|
-
extractAuthInfo
|
|
28
|
+
extractAuthInfo,
|
|
29
|
+
isEmail,
|
|
30
|
+
isPhone,
|
|
31
|
+
isFarcaster,
|
|
32
|
+
isTelegram,
|
|
33
|
+
toPregenTypeAndId,
|
|
34
|
+
toPregenIds,
|
|
35
|
+
isExternalWallet,
|
|
36
|
+
WALLET_TYPES
|
|
32
37
|
} from "@getpara/user-management-client";
|
|
33
38
|
import forge from "node-forge";
|
|
34
39
|
const { pki, jsbn } = forge;
|
|
@@ -41,9 +46,10 @@ import {
|
|
|
41
46
|
PopupType,
|
|
42
47
|
ParaEvent
|
|
43
48
|
} from "./types/index.js";
|
|
44
|
-
import * as transmissionUtils from "./transmission/transmissionUtils.js";
|
|
45
49
|
import { sendRecoveryForShare } from "./shares/recovery.js";
|
|
46
50
|
import {
|
|
51
|
+
autoBind,
|
|
52
|
+
formatPhoneNumber,
|
|
47
53
|
constructUrl,
|
|
48
54
|
dispatchEvent,
|
|
49
55
|
entityToWallet,
|
|
@@ -54,15 +60,18 @@ import {
|
|
|
54
60
|
getSchemes,
|
|
55
61
|
isPregenIdentifierMatch,
|
|
56
62
|
isWalletSupported,
|
|
63
|
+
jsonParse,
|
|
57
64
|
migrateWallet,
|
|
58
65
|
newUuid,
|
|
59
|
-
|
|
66
|
+
setupListeners,
|
|
67
|
+
supportedWalletTypesEq,
|
|
60
68
|
truncateAddress,
|
|
61
|
-
WalletSchemeTypeMap
|
|
69
|
+
WalletSchemeTypeMap,
|
|
70
|
+
shortenUrl,
|
|
71
|
+
isServerAuthState
|
|
62
72
|
} from "./utils/index.js";
|
|
63
|
-
import { TransactionReviewDenied,
|
|
73
|
+
import { TransactionReviewDenied, TransactionReviewTimeout } from "./errors.js";
|
|
64
74
|
import * as constants from "./constants.js";
|
|
65
|
-
import { setupListeners } from "./utils/listeners.js";
|
|
66
75
|
const _ParaCore = class _ParaCore {
|
|
67
76
|
/**
|
|
68
77
|
* Constructs a new `ParaCore` instance.
|
|
@@ -73,6 +82,9 @@ const _ParaCore = class _ParaCore {
|
|
|
73
82
|
*/
|
|
74
83
|
constructor(env, apiKey, opts) {
|
|
75
84
|
__privateAdd(this, _ParaCore_instances);
|
|
85
|
+
__privateAdd(this, _authInfo);
|
|
86
|
+
this.isNativePasskey = false;
|
|
87
|
+
__privateAdd(this, _partner);
|
|
76
88
|
this.isAwaitingAccountCreation = false;
|
|
77
89
|
this.isAwaitingLogin = false;
|
|
78
90
|
this.isAwaitingFarcaster = false;
|
|
@@ -81,14 +93,19 @@ const _ParaCore = class _ParaCore {
|
|
|
81
93
|
* 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.
|
|
82
94
|
*/
|
|
83
95
|
this.currentWalletIds = {};
|
|
84
|
-
|
|
85
|
-
|
|
96
|
+
/**
|
|
97
|
+
* Wallets associated with the `ParaCore` instance.
|
|
98
|
+
*/
|
|
99
|
+
this.externalWallets = {};
|
|
86
100
|
this.localStorageGetItem = (key) => {
|
|
87
101
|
return this.platformUtils.localStorage.get(key);
|
|
88
102
|
};
|
|
89
103
|
this.localStorageSetItem = (key, value) => {
|
|
90
104
|
return this.platformUtils.localStorage.set(key, value);
|
|
91
105
|
};
|
|
106
|
+
this.localStorageRemoveItem = (key) => {
|
|
107
|
+
return this.platformUtils.localStorage.removeItem(key);
|
|
108
|
+
};
|
|
92
109
|
this.sessionStorageGetItem = (key) => {
|
|
93
110
|
return this.platformUtils.sessionStorage.get(key);
|
|
94
111
|
};
|
|
@@ -145,38 +162,41 @@ const _ParaCore = class _ParaCore {
|
|
|
145
162
|
}
|
|
146
163
|
};
|
|
147
164
|
this.initializeFromStorage = () => {
|
|
148
|
-
this.
|
|
149
|
-
this.
|
|
150
|
-
this.updatePhoneFromStorage();
|
|
165
|
+
this.updateExternalWalletsFromStorage();
|
|
166
|
+
this.updateAuthInfoFromStorage();
|
|
151
167
|
this.updateUserIdFromStorage();
|
|
152
|
-
this.updateTelegramUserIdFromStorage();
|
|
153
168
|
this.updateWalletsFromStorage();
|
|
154
169
|
this.updateWalletIdsFromStorage();
|
|
155
170
|
this.updateSessionCookieFromStorage();
|
|
156
171
|
this.updateLoginEncryptionKeyPairFromStorage();
|
|
157
|
-
this.updateExternalWalletsFromStorage();
|
|
158
172
|
};
|
|
159
|
-
this.
|
|
160
|
-
|
|
173
|
+
this.updateAuthInfoFromStorage = () => {
|
|
174
|
+
var _a;
|
|
175
|
+
const storageAuthInfo = this.localStorageGetItem(constants.LOCAL_STORAGE_AUTH_INFO) || void 0;
|
|
176
|
+
let authInfo = jsonParse(storageAuthInfo);
|
|
177
|
+
if (!authInfo) {
|
|
178
|
+
const authParams = {
|
|
179
|
+
email: this.localStorageGetItem(constants.LOCAL_STORAGE_EMAIL) || void 0,
|
|
180
|
+
phone: this.localStorageGetItem(constants.LOCAL_STORAGE_PHONE) || void 0,
|
|
181
|
+
countryCode: this.localStorageGetItem(constants.LOCAL_STORAGE_COUNTRY_CODE) || void 0,
|
|
182
|
+
farcasterUsername: this.localStorageGetItem(constants.LOCAL_STORAGE_FARCASTER_USERNAME) || void 0,
|
|
183
|
+
telegramUserId: this.localStorageGetItem(constants.LOCAL_STORAGE_TELEGRAM_USER_ID) || void 0,
|
|
184
|
+
// Using id here since we store the bech32 address for cosmos in the address field of the wallet
|
|
185
|
+
externalWalletAddress: ((_a = this.externalWalletWithParaAuth) == null ? void 0 : _a.id) || void 0
|
|
186
|
+
};
|
|
187
|
+
authInfo = __privateMethod(this, _ParaCore_instances, toAuthInfo_fn).call(this, authParams);
|
|
188
|
+
}
|
|
189
|
+
__privateSet(this, _authInfo, authInfo);
|
|
161
190
|
};
|
|
162
191
|
this.updateUserIdFromStorage = () => {
|
|
163
192
|
this.userId = this.localStorageGetItem(constants.LOCAL_STORAGE_USER_ID) || void 0;
|
|
164
193
|
};
|
|
165
|
-
this.updatePhoneFromStorage = () => {
|
|
166
|
-
this.phone = this.localStorageGetItem(constants.LOCAL_STORAGE_PHONE) || void 0;
|
|
167
|
-
};
|
|
168
|
-
this.updateCountryCodeFromStorage = () => {
|
|
169
|
-
this.countryCode = this.localStorageGetItem(constants.LOCAL_STORAGE_COUNTRY_CODE) || void 0;
|
|
170
|
-
};
|
|
171
|
-
this.updateEmailFromStorage = () => {
|
|
172
|
-
this.email = this.localStorageGetItem(constants.LOCAL_STORAGE_EMAIL) || void 0;
|
|
173
|
-
};
|
|
174
194
|
this.updateWalletsFromStorage = () => __async(this, null, function* () {
|
|
175
195
|
var _a;
|
|
176
196
|
const _currentWalletIds = (_a = this.localStorageGetItem(constants.LOCAL_STORAGE_CURRENT_WALLET_IDS)) != null ? _a : void 0;
|
|
177
197
|
const currentWalletIds = [void 0, null, "undefined"].includes(_currentWalletIds) ? {} : (() => {
|
|
178
198
|
const fromJson = JSON.parse(_currentWalletIds);
|
|
179
|
-
return Array.isArray(fromJson) ?
|
|
199
|
+
return Array.isArray(fromJson) ? WALLET_TYPES.reduce((acc, type) => {
|
|
180
200
|
const wallet = Object.values(this.wallets).find(
|
|
181
201
|
(w) => fromJson.includes(w.id) && WalletSchemeTypeMap[w.scheme][type]
|
|
182
202
|
);
|
|
@@ -200,9 +220,9 @@ const _ParaCore = class _ParaCore {
|
|
|
200
220
|
this.updateWalletIdsFromStorage = () => {
|
|
201
221
|
var _a;
|
|
202
222
|
const _currentWalletIds = (_a = this.localStorageGetItem(constants.LOCAL_STORAGE_CURRENT_WALLET_IDS)) != null ? _a : void 0;
|
|
203
|
-
const currentWalletIds = [void 0, null, "undefined"].includes(_currentWalletIds) ? {} : (() => {
|
|
223
|
+
const currentWalletIds = [void 0, null, "undefined", "null"].includes(_currentWalletIds) ? {} : (() => {
|
|
204
224
|
const fromJson = JSON.parse(_currentWalletIds);
|
|
205
|
-
return Array.isArray(fromJson) ?
|
|
225
|
+
return Array.isArray(fromJson) ? WALLET_TYPES.reduce((acc, type) => {
|
|
206
226
|
const wallet = Object.values(this.wallets).find(
|
|
207
227
|
(w) => fromJson.includes(w.id) && WalletSchemeTypeMap[w.scheme][type]
|
|
208
228
|
);
|
|
@@ -237,12 +257,16 @@ const _ParaCore = class _ParaCore {
|
|
|
237
257
|
* @deprecated alias for `createWalletPerType`
|
|
238
258
|
**/
|
|
239
259
|
this.createWalletPerMissingType = this.createWalletPerType;
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
260
|
+
__privateAdd(this, _isCreateGuestWalletsPending, false);
|
|
261
|
+
this.getWalletBalance = (_0) => __async(this, [_0], function* ({
|
|
262
|
+
walletId,
|
|
263
|
+
rpcUrl
|
|
264
|
+
}) {
|
|
265
|
+
return (yield this.ctx.client.getWalletBalance({ walletId, rpcUrl })).balance;
|
|
245
266
|
});
|
|
267
|
+
if (!apiKey) {
|
|
268
|
+
throw new Error("A Para API key is required.");
|
|
269
|
+
}
|
|
246
270
|
if (!opts) opts = {};
|
|
247
271
|
let isE2E = false;
|
|
248
272
|
if (env === "E2E") {
|
|
@@ -301,49 +325,27 @@ const _ParaCore = class _ParaCore {
|
|
|
301
325
|
useDKLS: opts.useDKLSForCreation || !opts.offloadMPCComputationURL,
|
|
302
326
|
disableWebSockets: !!opts.disableWebSockets,
|
|
303
327
|
wasmOverride: opts.wasmOverride,
|
|
304
|
-
cosmosPrefix: this.cosmosPrefix,
|
|
305
328
|
isE2E
|
|
306
329
|
};
|
|
307
330
|
if (opts.offloadMPCComputationURL) {
|
|
308
331
|
this.ctx.mpcComputationClient = mpcComputationClient.initClient(opts.offloadMPCComputationURL, opts.disableWorkers);
|
|
309
332
|
}
|
|
310
|
-
try {
|
|
311
|
-
__privateSet(this, _supportedWalletTypes, opts.supportedWalletTypes ? (() => {
|
|
312
|
-
if (Object.values(opts.supportedWalletTypes).every(
|
|
313
|
-
(config) => !!config && typeof config === "object" && config.optional
|
|
314
|
-
)) {
|
|
315
|
-
throw new Error("at least one wallet type must be non-optional");
|
|
316
|
-
}
|
|
317
|
-
if (!Object.keys(opts.supportedWalletTypes).every((type) => Object.values(WalletType).includes(type))) {
|
|
318
|
-
throw new Error("unsupported wallet type");
|
|
319
|
-
}
|
|
320
|
-
__privateSet(this, _supportedWalletTypesOpt, opts.supportedWalletTypes);
|
|
321
|
-
return Object.entries(opts.supportedWalletTypes).reduce((acc, [key, value]) => {
|
|
322
|
-
var _a;
|
|
323
|
-
if (!value) {
|
|
324
|
-
return acc;
|
|
325
|
-
}
|
|
326
|
-
if (key === WalletType.COSMOS && typeof value === "object" && !!value.prefix) {
|
|
327
|
-
this.cosmosPrefix = value.prefix;
|
|
328
|
-
}
|
|
329
|
-
return [...acc, { type: key, optional: value === true ? false : (_a = value.optional) != null ? _a : false }];
|
|
330
|
-
}, []);
|
|
331
|
-
})() : void 0);
|
|
332
|
-
} catch (e) {
|
|
333
|
-
__privateSet(this, _supportedWalletTypes, void 0);
|
|
334
|
-
}
|
|
335
333
|
if (!this.platformUtils.isSyncStorage || opts.useStorageOverrides) {
|
|
336
334
|
return;
|
|
337
335
|
}
|
|
338
336
|
this.initializeFromStorage();
|
|
339
337
|
setupListeners.bind(this)();
|
|
338
|
+
autoBind(this);
|
|
340
339
|
if (env !== Environment.PROD) {
|
|
341
340
|
this.wrapMethodsWithErrorTracking([
|
|
342
|
-
"
|
|
343
|
-
"
|
|
344
|
-
"
|
|
345
|
-
"
|
|
346
|
-
"
|
|
341
|
+
"signUpOrLogIn",
|
|
342
|
+
"verifyNewAccount",
|
|
343
|
+
"waitForLogin",
|
|
344
|
+
"waitForSignup",
|
|
345
|
+
"waitForWalletCreation",
|
|
346
|
+
"verifyOAuth",
|
|
347
|
+
"verifyTelegram",
|
|
348
|
+
"verifyFarcaster",
|
|
347
349
|
"createPregenWallet",
|
|
348
350
|
"claimPregenWallets",
|
|
349
351
|
"signMessage",
|
|
@@ -351,35 +353,75 @@ const _ParaCore = class _ParaCore {
|
|
|
351
353
|
]);
|
|
352
354
|
}
|
|
353
355
|
}
|
|
354
|
-
get
|
|
355
|
-
return
|
|
356
|
+
get authInfo() {
|
|
357
|
+
return __privateGet(this, _authInfo);
|
|
356
358
|
}
|
|
357
|
-
get
|
|
358
|
-
|
|
359
|
+
get email() {
|
|
360
|
+
var _a;
|
|
361
|
+
return isEmail((_a = __privateGet(this, _authInfo)) == null ? void 0 : _a.auth) ? __privateGet(this, _authInfo).auth.email : void 0;
|
|
359
362
|
}
|
|
360
|
-
get
|
|
361
|
-
|
|
363
|
+
get phone() {
|
|
364
|
+
var _a;
|
|
365
|
+
return isPhone((_a = __privateGet(this, _authInfo)) == null ? void 0 : _a.auth) ? __privateGet(this, _authInfo).auth.phone : void 0;
|
|
362
366
|
}
|
|
363
|
-
get
|
|
364
|
-
|
|
367
|
+
get farcasterUsername() {
|
|
368
|
+
var _a;
|
|
369
|
+
return isFarcaster((_a = __privateGet(this, _authInfo)) == null ? void 0 : _a.auth) ? __privateGet(this, _authInfo).auth.farcasterUsername : void 0;
|
|
370
|
+
}
|
|
371
|
+
get telegramUserId() {
|
|
372
|
+
var _a;
|
|
373
|
+
return isTelegram((_a = __privateGet(this, _authInfo)) == null ? void 0 : _a.auth) ? __privateGet(this, _authInfo).auth.telegramUserId : void 0;
|
|
365
374
|
}
|
|
366
375
|
get externalWalletWithParaAuth() {
|
|
367
376
|
const externalWallets = Object.values(this.externalWallets);
|
|
368
377
|
return externalWallets.find((w) => w.isExternalWithParaAuth);
|
|
369
378
|
}
|
|
379
|
+
get externalWalletConnectionType() {
|
|
380
|
+
if (this.isExternalWalletAuth) {
|
|
381
|
+
return "AUTHENTICATED";
|
|
382
|
+
} else if (!!Object.keys(this.externalWallets).length) {
|
|
383
|
+
return "CONNECTION_ONLY";
|
|
384
|
+
}
|
|
385
|
+
return "NONE";
|
|
386
|
+
}
|
|
387
|
+
get isEmail() {
|
|
388
|
+
var _a;
|
|
389
|
+
return isEmail((_a = this.authInfo) == null ? void 0 : _a.auth);
|
|
390
|
+
}
|
|
391
|
+
get isPhone() {
|
|
392
|
+
var _a;
|
|
393
|
+
return isPhone((_a = this.authInfo) == null ? void 0 : _a.auth);
|
|
394
|
+
}
|
|
395
|
+
get isFarcaster() {
|
|
396
|
+
var _a;
|
|
397
|
+
return isFarcaster((_a = this.authInfo) == null ? void 0 : _a.auth);
|
|
398
|
+
}
|
|
399
|
+
get isTelegram() {
|
|
400
|
+
var _a;
|
|
401
|
+
return isTelegram((_a = this.authInfo) == null ? void 0 : _a.auth);
|
|
402
|
+
}
|
|
370
403
|
get isExternalWalletAuth() {
|
|
371
|
-
|
|
404
|
+
var _a;
|
|
405
|
+
return isExternalWallet((_a = __privateGet(this, _authInfo)) == null ? void 0 : _a.auth);
|
|
406
|
+
}
|
|
407
|
+
get partnerId() {
|
|
408
|
+
var _a;
|
|
409
|
+
return (_a = __privateGet(this, _partner)) == null ? void 0 : _a.id;
|
|
372
410
|
}
|
|
373
411
|
get currentWalletIdsArray() {
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
412
|
+
var _a, _b;
|
|
413
|
+
return ((_b = (_a = __privateGet(this, _partner)) == null ? void 0 : _a.supportedWalletTypes) != null ? _b : Object.keys(this.currentWalletIds).map((type) => ({ type }))).reduce(
|
|
414
|
+
(acc, { type }) => {
|
|
415
|
+
var _a2;
|
|
416
|
+
return [
|
|
417
|
+
...acc,
|
|
418
|
+
...((_a2 = this.currentWalletIds[type]) != null ? _a2 : []).map((id) => {
|
|
419
|
+
return [id, type];
|
|
420
|
+
})
|
|
421
|
+
];
|
|
422
|
+
},
|
|
423
|
+
[]
|
|
424
|
+
);
|
|
383
425
|
}
|
|
384
426
|
get currentWalletIdsUnique() {
|
|
385
427
|
return [...new Set(Object.values(this.currentWalletIds).flat())];
|
|
@@ -404,17 +446,23 @@ const _ParaCore = class _ParaCore {
|
|
|
404
446
|
* Whether the instance has multiple wallets connected.
|
|
405
447
|
*/
|
|
406
448
|
get isMultiWallet() {
|
|
407
|
-
return this.currentWalletIdsArray.length > 1;
|
|
449
|
+
return this.currentWalletIdsArray.length > 1 || __privateGet(this, _ParaCore_instances, guestWalletIdsArray_get).length > 1;
|
|
408
450
|
}
|
|
409
451
|
get isNoWalletConfig() {
|
|
410
|
-
|
|
452
|
+
var _a;
|
|
453
|
+
return !!((_a = __privateGet(this, _partner)) == null ? void 0 : _a.supportedWalletTypes) && __privateGet(this, _partner).supportedWalletTypes.length === 0;
|
|
411
454
|
}
|
|
412
455
|
get supportedWalletTypes() {
|
|
456
|
+
var _a, _b;
|
|
457
|
+
return (_b = (_a = __privateGet(this, _partner)) == null ? void 0 : _a.supportedWalletTypes) != null ? _b : [];
|
|
458
|
+
}
|
|
459
|
+
get cosmosPrefix() {
|
|
413
460
|
var _a;
|
|
414
|
-
return (_a = __privateGet(this,
|
|
461
|
+
return (_a = __privateGet(this, _partner)) == null ? void 0 : _a.cosmosPrefix;
|
|
415
462
|
}
|
|
416
463
|
get isWalletTypeEnabled() {
|
|
417
|
-
|
|
464
|
+
var _a;
|
|
465
|
+
return (((_a = __privateGet(this, _partner)) == null ? void 0 : _a.supportedWalletTypes) || []).reduce((acc, { type }) => {
|
|
418
466
|
return __spreadProps(__spreadValues({}, acc), { [type]: true });
|
|
419
467
|
}, {});
|
|
420
468
|
}
|
|
@@ -463,7 +511,7 @@ const _ParaCore = class _ParaCore {
|
|
|
463
511
|
}
|
|
464
512
|
isWalletSupported(wallet) {
|
|
465
513
|
var _a, _b;
|
|
466
|
-
return !
|
|
514
|
+
return !((_a = __privateGet(this, _partner)) == null ? void 0 : _a.supportedWalletTypes) || isWalletSupported((_b = __privateGet(this, _partner).supportedWalletTypes.map(({ type }) => type)) != null ? _b : [], wallet);
|
|
467
515
|
}
|
|
468
516
|
isWalletOwned(wallet) {
|
|
469
517
|
return this.isWalletSupported(wallet) && !(wallet == null ? void 0 : wallet.pregenIdentifier) && !(wallet == null ? void 0 : wallet.pregenIdentifierType) && !!this.userId && (wallet == null ? void 0 : wallet.userId) === this.userId;
|
|
@@ -479,7 +527,7 @@ const _ParaCore = class _ParaCore {
|
|
|
479
527
|
));
|
|
480
528
|
}
|
|
481
529
|
isWalletUsable(walletId, { type: types, scheme: schemes, forbidPregen = false } = {}, throwError = false) {
|
|
482
|
-
var _a;
|
|
530
|
+
var _a, _b;
|
|
483
531
|
let error;
|
|
484
532
|
if ((_a = this.externalWallets) == null ? void 0 : _a[walletId]) {
|
|
485
533
|
return true;
|
|
@@ -494,10 +542,10 @@ const _ParaCore = class _ParaCore {
|
|
|
494
542
|
} else if (!isOwned && !isUnclaimed) {
|
|
495
543
|
error = `wallet with id ${wallet == null ? void 0 : wallet.id} is not owned by the current user`;
|
|
496
544
|
} else if (!this.isWalletSupported(wallet)) {
|
|
497
|
-
error = `wallet with id ${wallet
|
|
545
|
+
error = `wallet with id ${wallet.id} and type ${wallet.type} is not supported, supported types are: ${(((_b = __privateGet(this, _partner)) == null ? void 0 : _b.supportedWalletTypes) || []).map(({ type }) => type).join(", ")}`;
|
|
498
546
|
} else if (types && (!getEquivalentTypes(types).includes(wallet == null ? void 0 : wallet.type) || isOwned && !types.some((type) => {
|
|
499
|
-
var _a2,
|
|
500
|
-
return (
|
|
547
|
+
var _a2, _b2;
|
|
548
|
+
return (_b2 = (_a2 = this.currentWalletIds) == null ? void 0 : _a2[type]) == null ? void 0 : _b2.includes(walletId);
|
|
501
549
|
}))) {
|
|
502
550
|
error = `wallet with id ${wallet == null ? void 0 : wallet.id} and type ${wallet == null ? void 0 : wallet.type} cannot be selected`;
|
|
503
551
|
} else if (schemes && !schemes.includes(wallet == null ? void 0 : wallet.scheme)) {
|
|
@@ -517,14 +565,17 @@ const _ParaCore = class _ParaCore {
|
|
|
517
565
|
* @param {string} walletId the ID of the wallet address to display.
|
|
518
566
|
* @param {object} options additional options for formatting the address.
|
|
519
567
|
* @param {boolean} options.truncate whether to truncate the address.
|
|
520
|
-
* @param {
|
|
568
|
+
* @param {TWalletType} options.addressType the type of address to display.
|
|
521
569
|
* @returns the formatted address
|
|
522
570
|
*/
|
|
523
571
|
getDisplayAddress(walletId, options = {}) {
|
|
524
|
-
var _a, _b;
|
|
572
|
+
var _a, _b, _c, _d;
|
|
525
573
|
if (this.externalWallets[walletId]) {
|
|
526
574
|
const wallet2 = this.externalWallets[walletId];
|
|
527
|
-
return options.truncate ? truncateAddress(wallet2.address, wallet2.type, {
|
|
575
|
+
return options.truncate ? truncateAddress(wallet2.address, wallet2.type, {
|
|
576
|
+
prefix: (_a = __privateGet(this, _partner)) == null ? void 0 : _a.cosmosPrefix,
|
|
577
|
+
targetLength: options.targetLength
|
|
578
|
+
}) : wallet2.address;
|
|
528
579
|
}
|
|
529
580
|
const wallet = this.findWallet(walletId, options.addressType);
|
|
530
581
|
if (!wallet) {
|
|
@@ -533,8 +584,8 @@ const _ParaCore = class _ParaCore {
|
|
|
533
584
|
let str;
|
|
534
585
|
let prefix;
|
|
535
586
|
switch (wallet.type) {
|
|
536
|
-
case
|
|
537
|
-
prefix = (
|
|
587
|
+
case "COSMOS":
|
|
588
|
+
prefix = (_d = (_c = options.cosmosPrefix) != null ? _c : (_b = __privateGet(this, _partner)) == null ? void 0 : _b.cosmosPrefix) != null ? _d : "cosmos";
|
|
538
589
|
str = getCosmosAddress(wallet.publicKey, prefix);
|
|
539
590
|
break;
|
|
540
591
|
default:
|
|
@@ -567,8 +618,24 @@ const _ParaCore = class _ParaCore {
|
|
|
567
618
|
}
|
|
568
619
|
constructPortalUrl(_0) {
|
|
569
620
|
return __async(this, arguments, function* (type, opts = {}) {
|
|
570
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m
|
|
571
|
-
const
|
|
621
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
622
|
+
const [isCreate, isLogin, isOnRamp] = [
|
|
623
|
+
["createAuth", "createPassword"].includes(type),
|
|
624
|
+
["loginAuth", "loginPassword"].includes(type),
|
|
625
|
+
type === "onRamp"
|
|
626
|
+
];
|
|
627
|
+
if (isCreate || isLogin) {
|
|
628
|
+
this.assertIsAuthSet();
|
|
629
|
+
}
|
|
630
|
+
let sessionId = opts.sessionId;
|
|
631
|
+
if ((isLogin || isOnRamp) && !sessionId) {
|
|
632
|
+
const session = yield this.touchSession(true);
|
|
633
|
+
sessionId = session.sessionId;
|
|
634
|
+
}
|
|
635
|
+
if (!this.loginEncryptionKeyPair) {
|
|
636
|
+
yield this.setLoginEncryptionKeyPair();
|
|
637
|
+
}
|
|
638
|
+
const base = type === "onRamp" ? getPortalBaseURL(this.ctx) : yield this.getPortalURL();
|
|
572
639
|
let path;
|
|
573
640
|
switch (type) {
|
|
574
641
|
case "createPassword": {
|
|
@@ -599,61 +666,50 @@ const _ParaCore = class _ParaCore {
|
|
|
599
666
|
throw new Error(`invalid URL type ${type}`);
|
|
600
667
|
}
|
|
601
668
|
}
|
|
602
|
-
const
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
const partner = opts.partnerId ? (_a = (yield this.ctx.client.getPartner(opts.partnerId)).data) == null ? void 0 : _a.partner : void 0;
|
|
669
|
+
const partner = yield __privateMethod(this, _ParaCore_instances, assertPartner_fn).call(this);
|
|
670
|
+
const thisDevice = (_a = opts.thisDevice) != null ? _a : {
|
|
671
|
+
encryptionKey: getPublicKeyHex(this.loginEncryptionKeyPair),
|
|
672
|
+
sessionId
|
|
673
|
+
};
|
|
608
674
|
const params = __spreadValues(__spreadValues(__spreadValues(__spreadValues({
|
|
609
675
|
apiKey: this.ctx.apiKey,
|
|
610
|
-
partnerId:
|
|
611
|
-
portalFont: ((_b = opts.
|
|
612
|
-
portalBorderRadius: ((_d = opts.
|
|
613
|
-
portalThemeMode: ((_f = opts.
|
|
614
|
-
portalAccentColor: ((_h = opts.
|
|
615
|
-
portalForegroundColor: ((_j = opts.
|
|
616
|
-
portalBackgroundColor: ((_l = opts.
|
|
676
|
+
partnerId: partner.id,
|
|
677
|
+
portalFont: ((_b = opts.portalTheme) == null ? void 0 : _b.font) || (partner == null ? void 0 : partner.font) || ((_c = this.portalTheme) == null ? void 0 : _c.font),
|
|
678
|
+
portalBorderRadius: ((_d = opts.portalTheme) == null ? void 0 : _d.borderRadius) || ((_e = this.portalTheme) == null ? void 0 : _e.borderRadius),
|
|
679
|
+
portalThemeMode: ((_f = opts.portalTheme) == null ? void 0 : _f.mode) || (partner == null ? void 0 : partner.themeMode) || ((_g = this.portalTheme) == null ? void 0 : _g.mode),
|
|
680
|
+
portalAccentColor: ((_h = opts.portalTheme) == null ? void 0 : _h.accentColor) || (partner == null ? void 0 : partner.accentColor) || ((_i = this.portalTheme) == null ? void 0 : _i.accentColor),
|
|
681
|
+
portalForegroundColor: ((_j = opts.portalTheme) == null ? void 0 : _j.foregroundColor) || (partner == null ? void 0 : partner.foregroundColor) || ((_k = this.portalTheme) == null ? void 0 : _k.foregroundColor),
|
|
682
|
+
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),
|
|
617
683
|
portalPrimaryButtonColor: this.portalPrimaryButtonColor,
|
|
618
684
|
portalTextColor: this.portalTextColor,
|
|
619
685
|
portalPrimaryButtonTextColor: this.portalPrimaryButtonTextColor,
|
|
620
|
-
isForNewDevice: opts.isForNewDevice ? opts.isForNewDevice.toString() : void 0
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
686
|
+
isForNewDevice: opts.isForNewDevice ? opts.isForNewDevice.toString() : void 0
|
|
687
|
+
}, isCreate || isLogin ? { authInfo: JSON.stringify(this.authInfo) } : {}), isOnRamp ? { sessionId } : {}), isLogin ? __spreadProps(__spreadValues({
|
|
688
|
+
sessionId: thisDevice.sessionId,
|
|
689
|
+
encryptionKey: thisDevice.encryptionKey
|
|
690
|
+
}, opts.newDevice ? {
|
|
691
|
+
newDeviceSessionLookupId: opts.newDevice.sessionId,
|
|
692
|
+
newDeviceEncryptionKey: opts.newDevice.encryptionKey
|
|
693
|
+
} : {}), {
|
|
694
|
+
pregenIds: JSON.stringify(this.pregenIds)
|
|
695
|
+
}) : {}), opts.params || {});
|
|
696
|
+
const url = constructUrl({ base, path, params });
|
|
697
|
+
if (opts.shorten) {
|
|
698
|
+
return shortenUrl(this.ctx, url);
|
|
699
|
+
}
|
|
700
|
+
return url;
|
|
634
701
|
});
|
|
635
702
|
}
|
|
636
703
|
touchSession(regenerate = false) {
|
|
637
704
|
return __async(this, null, function* () {
|
|
638
|
-
|
|
639
|
-
this.
|
|
640
|
-
|
|
705
|
+
var _a, _b, _c;
|
|
706
|
+
const session = yield this.ctx.client.touchSession(regenerate);
|
|
707
|
+
if (!__privateGet(this, _partner) || ((_a = __privateGet(this, _partner)) == null ? void 0 : _a.id) !== session.partnerId || !supportedWalletTypesEq(((_b = __privateGet(this, _partner)) == null ? void 0 : _b.supportedWalletTypes) || [], session.supportedWalletTypes) || (((_c = __privateGet(this, _partner)) == null ? void 0 : _c.cosmosPrefix) || "cosmos") !== session.cosmosPrefix) {
|
|
708
|
+
yield __privateMethod(this, _ParaCore_instances, getPartner_fn).call(this, session.partnerId);
|
|
709
|
+
}
|
|
710
|
+
return session;
|
|
641
711
|
});
|
|
642
712
|
}
|
|
643
|
-
setSupportedWalletTypes(supportedWalletTypes, cosmosPrefix) {
|
|
644
|
-
if (supportedWalletTypes && !__privateGet(this, _supportedWalletTypes)) {
|
|
645
|
-
__privateSet(this, _supportedWalletTypes, supportedWalletTypes);
|
|
646
|
-
Object.keys(this.currentWalletIds).forEach((type) => {
|
|
647
|
-
var _a;
|
|
648
|
-
if (!((_a = __privateGet(this, _supportedWalletTypes)) == null ? void 0 : _a.some(({ type: supportedType }) => supportedType === type))) {
|
|
649
|
-
delete this.currentWalletIds[type];
|
|
650
|
-
}
|
|
651
|
-
});
|
|
652
|
-
}
|
|
653
|
-
if (cosmosPrefix && !this.cosmosPrefix) {
|
|
654
|
-
this.cosmosPrefix = cosmosPrefix;
|
|
655
|
-
}
|
|
656
|
-
}
|
|
657
713
|
getVerificationEmailProps() {
|
|
658
714
|
return {
|
|
659
715
|
brandColor: this.emailPrimaryColor,
|
|
@@ -683,12 +739,26 @@ const _ParaCore = class _ParaCore {
|
|
|
683
739
|
*/
|
|
684
740
|
init() {
|
|
685
741
|
return __async(this, null, function* () {
|
|
686
|
-
var _a;
|
|
687
|
-
this.email = (yield this.localStorageGetItem(constants.LOCAL_STORAGE_EMAIL)) || void 0;
|
|
688
|
-
this.countryCode = (yield this.localStorageGetItem(constants.LOCAL_STORAGE_COUNTRY_CODE)) || void 0;
|
|
689
|
-
this.phone = (yield this.localStorageGetItem(constants.LOCAL_STORAGE_PHONE)) || void 0;
|
|
742
|
+
var _a, _b;
|
|
690
743
|
this.userId = (yield this.localStorageGetItem(constants.LOCAL_STORAGE_USER_ID)) || void 0;
|
|
691
|
-
|
|
744
|
+
const storageAuthInfo = (yield this.localStorageGetItem(constants.LOCAL_STORAGE_AUTH_INFO)) || void 0;
|
|
745
|
+
const stringExternalWallets = yield this.localStorageGetItem(constants.LOCAL_STORAGE_EXTERNAL_WALLETS);
|
|
746
|
+
const _externalWallets = JSON.parse(stringExternalWallets || "{}");
|
|
747
|
+
yield this.setExternalWallets(_externalWallets);
|
|
748
|
+
let authInfo = jsonParse(storageAuthInfo);
|
|
749
|
+
if (!authInfo) {
|
|
750
|
+
const authParams = {
|
|
751
|
+
email: (yield this.localStorageGetItem(constants.LOCAL_STORAGE_EMAIL)) || void 0,
|
|
752
|
+
phone: (yield this.localStorageGetItem(constants.LOCAL_STORAGE_PHONE)) || void 0,
|
|
753
|
+
countryCode: (yield this.localStorageGetItem(constants.LOCAL_STORAGE_COUNTRY_CODE)) || void 0,
|
|
754
|
+
farcasterUsername: (yield this.localStorageGetItem(constants.LOCAL_STORAGE_FARCASTER_USERNAME)) || void 0,
|
|
755
|
+
telegramUserId: (yield this.localStorageGetItem(constants.LOCAL_STORAGE_TELEGRAM_USER_ID)) || void 0,
|
|
756
|
+
// Using id here since we store the bech32 address for cosmos in the address field of the wallet
|
|
757
|
+
externalWalletAddress: ((_a = this.externalWalletWithParaAuth) == null ? void 0 : _a.id) || void 0
|
|
758
|
+
};
|
|
759
|
+
authInfo = __privateMethod(this, _ParaCore_instances, toAuthInfo_fn).call(this, authParams);
|
|
760
|
+
}
|
|
761
|
+
__privateSet(this, _authInfo, authInfo);
|
|
692
762
|
const stringWallets = this.platformUtils.secureStorage ? yield this.platformUtils.secureStorage.get(constants.LOCAL_STORAGE_WALLETS) : yield this.localStorageGetItem(constants.LOCAL_STORAGE_WALLETS);
|
|
693
763
|
const _wallets = JSON.parse(stringWallets || "{}");
|
|
694
764
|
const stringEd25519Wallets = this.platformUtils.secureStorage ? yield this.platformUtils.secureStorage.get(constants.LOCAL_STORAGE_ED25519_WALLETS) : yield this.localStorageGetItem(constants.LOCAL_STORAGE_ED25519_WALLETS);
|
|
@@ -701,10 +771,10 @@ const _ParaCore = class _ParaCore {
|
|
|
701
771
|
return __spreadValues(__spreadValues({}, res), !res[key] ? { [key]: migrateWallet(_ed25519Wallets[key]) } : {});
|
|
702
772
|
}, {}));
|
|
703
773
|
yield this.setWallets(wallets);
|
|
704
|
-
const _currentWalletIds = (
|
|
774
|
+
const _currentWalletIds = (_b = yield this.localStorageGetItem(constants.LOCAL_STORAGE_CURRENT_WALLET_IDS)) != null ? _b : void 0;
|
|
705
775
|
const currentWalletIds = [void 0, null, "undefined", "null"].includes(_currentWalletIds) ? {} : (() => {
|
|
706
776
|
const fromJson = JSON.parse(_currentWalletIds);
|
|
707
|
-
return Array.isArray(fromJson) ?
|
|
777
|
+
return Array.isArray(fromJson) ? WALLET_TYPES.reduce((acc, type) => {
|
|
708
778
|
const wallet = Object.values(this.wallets).find(
|
|
709
779
|
(w) => fromJson.includes(w.id) && WalletSchemeTypeMap[w.scheme][type]
|
|
710
780
|
);
|
|
@@ -720,21 +790,42 @@ const _ParaCore = class _ParaCore {
|
|
|
720
790
|
if (loginEncryptionKey && loginEncryptionKey !== "undefined") {
|
|
721
791
|
this.loginEncryptionKeyPair = this.convertEncryptionKeyPair(JSON.parse(loginEncryptionKey));
|
|
722
792
|
}
|
|
723
|
-
const stringExternalWallets = yield this.localStorageGetItem(constants.LOCAL_STORAGE_EXTERNAL_WALLETS);
|
|
724
|
-
const _externalWallets = JSON.parse(stringExternalWallets || "{}");
|
|
725
|
-
yield this.setExternalWallets(_externalWallets);
|
|
726
793
|
setupListeners.bind(this)();
|
|
727
794
|
yield this.touchSession();
|
|
728
795
|
});
|
|
729
796
|
}
|
|
797
|
+
setAuth(_0) {
|
|
798
|
+
return __async(this, arguments, function* (auth, { extras = {}, userId } = {}) {
|
|
799
|
+
const authInfo = __spreadValues(__spreadValues({}, extractAuthInfo(auth, { isRequired: true })), extras || {});
|
|
800
|
+
yield __privateMethod(this, _ParaCore_instances, setAuthInfo_fn).call(this, authInfo);
|
|
801
|
+
if (!!userId) {
|
|
802
|
+
yield this.setUserId(userId);
|
|
803
|
+
}
|
|
804
|
+
return __privateGet(this, _authInfo);
|
|
805
|
+
});
|
|
806
|
+
}
|
|
807
|
+
assertUserId() {
|
|
808
|
+
if (!this.userId) {
|
|
809
|
+
throw new Error("no userId is set");
|
|
810
|
+
}
|
|
811
|
+
return this.userId;
|
|
812
|
+
}
|
|
813
|
+
assertIsAuthSet(allowed) {
|
|
814
|
+
if (!__privateGet(this, _authInfo)) {
|
|
815
|
+
throw new Error("auth is not set");
|
|
816
|
+
}
|
|
817
|
+
if (allowed && !allowed.includes(__privateGet(this, _authInfo).authType)) {
|
|
818
|
+
throw new Error(`invalid auth type, expected ${allowed.join(", ")}`);
|
|
819
|
+
}
|
|
820
|
+
return __privateGet(this, _authInfo);
|
|
821
|
+
}
|
|
730
822
|
/**
|
|
731
823
|
* Sets the email associated with the `ParaCore` instance.
|
|
732
824
|
* @param email - Email to set.
|
|
733
825
|
*/
|
|
734
826
|
setEmail(email) {
|
|
735
827
|
return __async(this, null, function* () {
|
|
736
|
-
this.email
|
|
737
|
-
yield this.localStorageSetItem(constants.LOCAL_STORAGE_EMAIL, email);
|
|
828
|
+
yield this.setAuth({ email });
|
|
738
829
|
});
|
|
739
830
|
}
|
|
740
831
|
/**
|
|
@@ -743,8 +834,7 @@ const _ParaCore = class _ParaCore {
|
|
|
743
834
|
*/
|
|
744
835
|
setTelegramUserId(telegramUserId) {
|
|
745
836
|
return __async(this, null, function* () {
|
|
746
|
-
this.telegramUserId
|
|
747
|
-
yield this.localStorageSetItem(constants.LOCAL_STORAGE_TELEGRAM_USER_ID, telegramUserId);
|
|
837
|
+
yield this.setAuth({ telegramUserId });
|
|
748
838
|
});
|
|
749
839
|
}
|
|
750
840
|
/**
|
|
@@ -754,10 +844,7 @@ const _ParaCore = class _ParaCore {
|
|
|
754
844
|
*/
|
|
755
845
|
setPhoneNumber(phone, countryCode) {
|
|
756
846
|
return __async(this, null, function* () {
|
|
757
|
-
this.phone
|
|
758
|
-
this.countryCode = countryCode;
|
|
759
|
-
yield this.localStorageSetItem(constants.LOCAL_STORAGE_PHONE, phone);
|
|
760
|
-
yield this.localStorageSetItem(constants.LOCAL_STORAGE_COUNTRY_CODE, countryCode);
|
|
847
|
+
yield this.setAuth({ phone: formatPhoneNumber(phone, countryCode) });
|
|
761
848
|
});
|
|
762
849
|
}
|
|
763
850
|
/**
|
|
@@ -766,8 +853,7 @@ const _ParaCore = class _ParaCore {
|
|
|
766
853
|
*/
|
|
767
854
|
setFarcasterUsername(farcasterUsername) {
|
|
768
855
|
return __async(this, null, function* () {
|
|
769
|
-
this.farcasterUsername
|
|
770
|
-
yield this.localStorageSetItem(constants.LOCAL_STORAGE_FARCASTER_USERNAME, farcasterUsername);
|
|
856
|
+
yield this.setAuth({ farcasterUsername });
|
|
771
857
|
});
|
|
772
858
|
}
|
|
773
859
|
/**
|
|
@@ -852,6 +938,9 @@ const _ParaCore = class _ParaCore {
|
|
|
852
938
|
getUserId() {
|
|
853
939
|
return this.userId;
|
|
854
940
|
}
|
|
941
|
+
getAuthInfo() {
|
|
942
|
+
return this.authInfo;
|
|
943
|
+
}
|
|
855
944
|
/**
|
|
856
945
|
* Gets the email associated with the `ParaCore` instance.
|
|
857
946
|
* @returns - email associated with the `ParaCore` instance.
|
|
@@ -859,22 +948,12 @@ const _ParaCore = class _ParaCore {
|
|
|
859
948
|
getEmail() {
|
|
860
949
|
return this.email;
|
|
861
950
|
}
|
|
862
|
-
/**
|
|
863
|
-
* Gets the phone object associated with the `ParaCore` instance.
|
|
864
|
-
* @returns - phone object with phone number and country code associated with the `ParaCore` instance.
|
|
865
|
-
*/
|
|
866
|
-
getPhone() {
|
|
867
|
-
return { phone: this.phone, countryCode: this.countryCode };
|
|
868
|
-
}
|
|
869
951
|
/**
|
|
870
952
|
* Gets the formatted phone number associated with the `ParaCore` instance.
|
|
871
953
|
* @returns - formatted phone number associated with the `ParaCore` instance.
|
|
872
954
|
*/
|
|
873
955
|
getPhoneNumber() {
|
|
874
|
-
|
|
875
|
-
return void 0;
|
|
876
|
-
}
|
|
877
|
-
return normalizePhoneNumber(this.countryCode, this.phone);
|
|
956
|
+
return this.phone;
|
|
878
957
|
}
|
|
879
958
|
/**
|
|
880
959
|
* Gets the farcaster username associated with the `ParaCore` instance.
|
|
@@ -913,9 +992,7 @@ const _ParaCore = class _ParaCore {
|
|
|
913
992
|
if (!(yield this.isSessionActive()) || !this.userId) {
|
|
914
993
|
throw new Error("no signed-in user");
|
|
915
994
|
}
|
|
916
|
-
const {
|
|
917
|
-
data: { partnerId }
|
|
918
|
-
} = yield this.touchSession();
|
|
995
|
+
const { partnerId } = yield this.touchSession();
|
|
919
996
|
const { accountMetadata } = yield this.ctx.client.getAccountMetadata(this.userId, partnerId);
|
|
920
997
|
return accountMetadata;
|
|
921
998
|
});
|
|
@@ -973,8 +1050,10 @@ const _ParaCore = class _ParaCore {
|
|
|
973
1050
|
}
|
|
974
1051
|
findWallet(idOrAddress, overrideType, filter = {}) {
|
|
975
1052
|
var _a, _c, _d;
|
|
976
|
-
if (!this.isExternalWalletAuth
|
|
977
|
-
|
|
1053
|
+
if (!this.isExternalWalletAuth) {
|
|
1054
|
+
if (!idOrAddress && Object.keys(this.externalWallets).length > 0) {
|
|
1055
|
+
return Object.values(this.externalWallets)[0];
|
|
1056
|
+
}
|
|
978
1057
|
}
|
|
979
1058
|
if ((_a = this.externalWallets) == null ? void 0 : _a[idOrAddress]) {
|
|
980
1059
|
return this.externalWallets[idOrAddress];
|
|
@@ -985,7 +1064,7 @@ const _ParaCore = class _ParaCore {
|
|
|
985
1064
|
const _b = this.wallets[walletId], { signer: _signer } = _b, wallet = __objRest(_b, ["signer"]);
|
|
986
1065
|
const type = (_d = overrideType != null ? overrideType : (_c = this.currentWalletIdsArray.find(([id]) => id === walletId)) == null ? void 0 : _c[1]) != null ? _d : wallet.type;
|
|
987
1066
|
return __spreadProps(__spreadValues({}, wallet), {
|
|
988
|
-
type
|
|
1067
|
+
type
|
|
989
1068
|
});
|
|
990
1069
|
}
|
|
991
1070
|
} catch (e) {
|
|
@@ -995,7 +1074,7 @@ const _ParaCore = class _ParaCore {
|
|
|
995
1074
|
get availableWallets() {
|
|
996
1075
|
var _a;
|
|
997
1076
|
return [
|
|
998
|
-
...this.currentWalletIdsArray.map(([address, type]) => [address, type, false]).map(([id, type]) => {
|
|
1077
|
+
...[...this.currentWalletIdsArray, ...__privateGet(this, _ParaCore_instances, guestWalletIdsArray_get)].map(([address, type]) => [address, type, false]).map(([id, type]) => {
|
|
999
1078
|
const wallet = this.findWallet(id, type);
|
|
1000
1079
|
if (!wallet) return null;
|
|
1001
1080
|
return {
|
|
@@ -1021,10 +1100,8 @@ const _ParaCore = class _ParaCore {
|
|
|
1021
1100
|
}
|
|
1022
1101
|
assertIsValidWalletType(type, walletTypes) {
|
|
1023
1102
|
return __async(this, null, function* () {
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
}
|
|
1027
|
-
if (!type || !Object.values(WalletType).includes(type) || !(walletTypes != null ? walletTypes : this.supportedWalletTypes.map(({ type: type2 }) => type2)).includes(type)) {
|
|
1103
|
+
const { supportedWalletTypes } = yield __privateMethod(this, _ParaCore_instances, assertPartner_fn).call(this);
|
|
1104
|
+
if (!type || !WALLET_TYPES.includes(type) || !(walletTypes != null ? walletTypes : supportedWalletTypes.map(({ type: type2 }) => type2)).includes(type)) {
|
|
1028
1105
|
throw new Error(`wallet type ${type} is not supported`);
|
|
1029
1106
|
}
|
|
1030
1107
|
return type;
|
|
@@ -1032,33 +1109,29 @@ const _ParaCore = class _ParaCore {
|
|
|
1032
1109
|
}
|
|
1033
1110
|
getMissingTypes() {
|
|
1034
1111
|
return __async(this, null, function* () {
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
}
|
|
1038
|
-
return this.supportedWalletTypes.filter(
|
|
1112
|
+
const { supportedWalletTypes } = yield __privateMethod(this, _ParaCore_instances, assertPartner_fn).call(this);
|
|
1113
|
+
return supportedWalletTypes.filter(
|
|
1039
1114
|
({ type: t, optional }) => !optional && Object.values(this.wallets).every((w) => !this.isWalletOwned(w) || !WalletSchemeTypeMap[w.scheme][t])
|
|
1040
1115
|
).map(({ type }) => type);
|
|
1041
1116
|
});
|
|
1042
1117
|
}
|
|
1043
1118
|
getTypesToCreate(types) {
|
|
1044
1119
|
return __async(this, null, function* () {
|
|
1045
|
-
|
|
1046
|
-
yield this.touchSession();
|
|
1047
|
-
}
|
|
1120
|
+
const { supportedWalletTypes } = yield __privateMethod(this, _ParaCore_instances, assertPartner_fn).call(this);
|
|
1048
1121
|
return getSchemes(types != null ? types : yield this.getMissingTypes()).map((scheme) => {
|
|
1049
1122
|
switch (scheme) {
|
|
1050
|
-
case
|
|
1051
|
-
return
|
|
1123
|
+
case "ED25519":
|
|
1124
|
+
return "SOLANA";
|
|
1052
1125
|
default:
|
|
1053
|
-
return
|
|
1126
|
+
return supportedWalletTypes.some(({ type, optional }) => type === "COSMOS" && !optional) ? "COSMOS" : "EVM";
|
|
1054
1127
|
}
|
|
1055
1128
|
});
|
|
1056
1129
|
});
|
|
1057
1130
|
}
|
|
1058
|
-
getPartnerURL(
|
|
1131
|
+
getPartnerURL() {
|
|
1059
1132
|
return __async(this, null, function* () {
|
|
1060
|
-
const
|
|
1061
|
-
return
|
|
1133
|
+
const { portalUrl } = yield __privateMethod(this, _ParaCore_instances, assertPartner_fn).call(this);
|
|
1134
|
+
return portalUrl;
|
|
1062
1135
|
});
|
|
1063
1136
|
}
|
|
1064
1137
|
/**
|
|
@@ -1066,75 +1139,9 @@ const _ParaCore = class _ParaCore {
|
|
|
1066
1139
|
* @param partnerId: string - id of the partner to get the portal URL for
|
|
1067
1140
|
* @returns - portal URL
|
|
1068
1141
|
*/
|
|
1069
|
-
getPortalURL(
|
|
1142
|
+
getPortalURL() {
|
|
1070
1143
|
return __async(this, null, function* () {
|
|
1071
|
-
return
|
|
1072
|
-
});
|
|
1073
|
-
}
|
|
1074
|
-
getWebAuthURLForCreate(_a) {
|
|
1075
|
-
return __async(this, null, function* () {
|
|
1076
|
-
var _b = _a, {
|
|
1077
|
-
webAuthId
|
|
1078
|
-
} = _b, options = __objRest(_b, [
|
|
1079
|
-
"webAuthId"
|
|
1080
|
-
]);
|
|
1081
|
-
return this.constructPortalUrl("createAuth", __spreadProps(__spreadValues({}, options), { pathId: webAuthId }));
|
|
1082
|
-
});
|
|
1083
|
-
}
|
|
1084
|
-
getPasswordURLForCreate(_c) {
|
|
1085
|
-
return __async(this, null, function* () {
|
|
1086
|
-
var _d = _c, {
|
|
1087
|
-
passwordId
|
|
1088
|
-
} = _d, options = __objRest(_d, [
|
|
1089
|
-
"passwordId"
|
|
1090
|
-
]);
|
|
1091
|
-
return this.constructPortalUrl("createPassword", __spreadProps(__spreadValues({}, options), {
|
|
1092
|
-
pathId: passwordId
|
|
1093
|
-
}));
|
|
1094
|
-
});
|
|
1095
|
-
}
|
|
1096
|
-
getShortUrl(compressedUrl) {
|
|
1097
|
-
return constructUrl({
|
|
1098
|
-
base: getPortalBaseURL(this.ctx),
|
|
1099
|
-
path: `/short/${compressedUrl}`
|
|
1100
|
-
});
|
|
1101
|
-
}
|
|
1102
|
-
shortenLoginLink(link) {
|
|
1103
|
-
return __async(this, null, function* () {
|
|
1104
|
-
const url = yield transmissionUtils.upload(link, this.ctx.client);
|
|
1105
|
-
return this.getShortUrl(url);
|
|
1106
|
-
});
|
|
1107
|
-
}
|
|
1108
|
-
/**
|
|
1109
|
-
* Generates a URL for registering a new WebAuth passkey.
|
|
1110
|
-
* @param {GetWebAuthUrlForLoginParams} opts the options object
|
|
1111
|
-
* @returns - the URL for creating a new passkey
|
|
1112
|
-
*/
|
|
1113
|
-
getWebAuthURLForLogin(opts) {
|
|
1114
|
-
return __async(this, null, function* () {
|
|
1115
|
-
return this.constructPortalUrl("loginAuth", opts);
|
|
1116
|
-
});
|
|
1117
|
-
}
|
|
1118
|
-
/**
|
|
1119
|
-
* Generates a URL for registering a new user password.
|
|
1120
|
-
* @param {GetWebAuthUrlForLoginParams} opts the options object
|
|
1121
|
-
* @returns - the URL for creating a new password
|
|
1122
|
-
*/
|
|
1123
|
-
getPasswordURLForLogin(opts) {
|
|
1124
|
-
return __async(this, null, function* () {
|
|
1125
|
-
return this.constructPortalUrl("loginPassword", opts);
|
|
1126
|
-
});
|
|
1127
|
-
}
|
|
1128
|
-
/**
|
|
1129
|
-
* Generates a URL for registering a new WebAuth passkey for a phone number.
|
|
1130
|
-
* @param {Omit<GetWebAuthUrlForLoginParams, 'authType'>} opts the options object
|
|
1131
|
-
* @returns - web auth url
|
|
1132
|
-
*/
|
|
1133
|
-
getWebAuthURLForLoginForPhone(opts) {
|
|
1134
|
-
return __async(this, null, function* () {
|
|
1135
|
-
return this.constructPortalUrl("loginAuth", __spreadValues({
|
|
1136
|
-
authType: "phone"
|
|
1137
|
-
}, opts));
|
|
1144
|
+
return (yield this.getPartnerURL()) || getPortalBaseURL(this.ctx);
|
|
1138
1145
|
});
|
|
1139
1146
|
}
|
|
1140
1147
|
/**
|
|
@@ -1149,7 +1156,7 @@ const _ParaCore = class _ParaCore {
|
|
|
1149
1156
|
if (!wallet) {
|
|
1150
1157
|
throw new Error("wallet not found");
|
|
1151
1158
|
}
|
|
1152
|
-
if (wallet.scheme !==
|
|
1159
|
+
if (wallet.scheme !== "DKLS") {
|
|
1153
1160
|
throw new Error("invalid wallet scheme");
|
|
1154
1161
|
}
|
|
1155
1162
|
return yield this.platformUtils.getPrivateKey(
|
|
@@ -1196,131 +1203,52 @@ const _ParaCore = class _ParaCore {
|
|
|
1196
1203
|
yield this.setWallets(this.wallets);
|
|
1197
1204
|
});
|
|
1198
1205
|
}
|
|
1199
|
-
/**
|
|
1200
|
-
* Checks if a user exists for an email address.
|
|
1201
|
-
* @param {Object} opts the options object
|
|
1202
|
-
* @param {string} opts.email the email to check.
|
|
1203
|
-
* @returns true if user exists, false otherwise.
|
|
1204
|
-
*/
|
|
1205
|
-
checkIfUserExists(_0) {
|
|
1206
|
-
return __async(this, arguments, function* ({ email }) {
|
|
1207
|
-
const res = yield this.ctx.client.checkUserExists({ email });
|
|
1208
|
-
return res.data.exists;
|
|
1209
|
-
});
|
|
1210
|
-
}
|
|
1211
|
-
/**
|
|
1212
|
-
* Checks if a user exists for a phone number.
|
|
1213
|
-
* @param {Object} opts the options object
|
|
1214
|
-
* @param {string} opts.phone - phone number to check.
|
|
1215
|
-
* @param {string} opts.countryCode - the country code.
|
|
1216
|
-
* @returns true if user exists, false otherwise.
|
|
1217
|
-
*/
|
|
1218
|
-
checkIfUserExistsByPhone(_0) {
|
|
1219
|
-
return __async(this, arguments, function* ({ phone, countryCode }) {
|
|
1220
|
-
const res = yield this.ctx.client.checkUserExists({ phone, countryCode });
|
|
1221
|
-
return res.data.exists;
|
|
1222
|
-
});
|
|
1223
|
-
}
|
|
1224
|
-
/**
|
|
1225
|
-
* Creates a new user.
|
|
1226
|
-
* @param {Object} opts the options object
|
|
1227
|
-
* @param {string} opts.email the email to use.
|
|
1228
|
-
*/
|
|
1229
|
-
createUser(_0) {
|
|
1230
|
-
return __async(this, arguments, function* ({ email }) {
|
|
1231
|
-
this.requireApiKey();
|
|
1232
|
-
yield this.setEmail(email);
|
|
1233
|
-
const { userId } = yield this.ctx.client.createUser(__spreadValues({
|
|
1234
|
-
email: this.email
|
|
1235
|
-
}, this.getVerificationEmailProps()));
|
|
1236
|
-
yield this.setUserId(userId);
|
|
1237
|
-
});
|
|
1238
|
-
}
|
|
1239
|
-
/**
|
|
1240
|
-
* Creates a new user with a phone number.
|
|
1241
|
-
* @param {Object} opts the options object
|
|
1242
|
-
* @param {string} opts.phone - the phone number to use for creating the user.
|
|
1243
|
-
* @param {string} opts.countryCode - the country code to use for creating the user.
|
|
1244
|
-
*/
|
|
1245
|
-
createUserByPhone(_0) {
|
|
1246
|
-
return __async(this, arguments, function* ({ phone, countryCode }) {
|
|
1247
|
-
this.requireApiKey();
|
|
1248
|
-
yield this.setPhoneNumber(phone, countryCode);
|
|
1249
|
-
const { userId } = yield this.ctx.client.createUser({
|
|
1250
|
-
phone: this.phone,
|
|
1251
|
-
countryCode: this.countryCode
|
|
1252
|
-
});
|
|
1253
|
-
yield this.setUserId(userId);
|
|
1254
|
-
});
|
|
1255
|
-
}
|
|
1256
1206
|
/**
|
|
1257
1207
|
* Logs in or creates a new user using an external wallet address.
|
|
1258
1208
|
* @param {Object} opts the options object
|
|
1259
1209
|
* @param {string} opts.address the external wallet address to use for identification.
|
|
1260
|
-
* @param {
|
|
1210
|
+
* @param {TWalletType} opts.type type of external wallet to use for identification.
|
|
1261
1211
|
* @param {string} opts.provider the name of the provider for the external wallet.
|
|
1262
1212
|
*/
|
|
1263
|
-
|
|
1213
|
+
loginExternalWallet(_a) {
|
|
1264
1214
|
return __async(this, null, function* () {
|
|
1215
|
+
var _b = _a, {
|
|
1216
|
+
externalWallet
|
|
1217
|
+
} = _b, urlOptions = __objRest(_b, [
|
|
1218
|
+
"externalWallet"
|
|
1219
|
+
]);
|
|
1265
1220
|
if (this.externalWalletConnectionOnly) {
|
|
1266
|
-
|
|
1267
|
-
yield this.setExternalWallet(
|
|
1221
|
+
externalWallet.withFullParaAuth = false;
|
|
1222
|
+
yield this.setExternalWallet(externalWallet);
|
|
1268
1223
|
return Promise.resolve({
|
|
1269
1224
|
userId: constants.EXTERNAL_WALLET_CONNECTION_ONLY_USER_ID
|
|
1270
1225
|
});
|
|
1271
1226
|
}
|
|
1272
1227
|
this.requireApiKey();
|
|
1273
|
-
const
|
|
1274
|
-
|
|
1275
|
-
type: wallet.type,
|
|
1276
|
-
externalWalletProvider: wallet.provider,
|
|
1277
|
-
// If the wallet isn't using full Para auth we want to track the login here
|
|
1278
|
-
shouldTrackUser: !wallet.withFullParaAuth
|
|
1279
|
-
});
|
|
1280
|
-
yield this.setExternalWallet(wallet);
|
|
1281
|
-
yield this.setUserId(res.userId);
|
|
1282
|
-
return res;
|
|
1283
|
-
});
|
|
1284
|
-
}
|
|
1285
|
-
/**
|
|
1286
|
-
* Returns whether or not the user is connected with only an external wallet, not an external wallet with Para auth.
|
|
1287
|
-
*/
|
|
1288
|
-
isUsingExternalWallet() {
|
|
1289
|
-
return !this.isExternalWalletAuth && !!Object.keys(this.externalWallets).length;
|
|
1290
|
-
}
|
|
1291
|
-
/**
|
|
1292
|
-
* Passes the email code obtained from the user for verification.
|
|
1293
|
-
* @param {Object} opts the options object
|
|
1294
|
-
* @param {string} verificationCode the six-digit code to check
|
|
1295
|
-
* @returns {string} the web auth url for creating a new credential
|
|
1296
|
-
*/
|
|
1297
|
-
verifyEmail(_0) {
|
|
1298
|
-
return __async(this, arguments, function* ({ verificationCode }) {
|
|
1299
|
-
yield this.ctx.client.verifyEmail(this.userId, { verificationCode });
|
|
1300
|
-
return this.getSetUpBiometricsURL();
|
|
1228
|
+
const serverAuthState = yield this.ctx.client.loginExternalWallet({ externalWallet });
|
|
1229
|
+
return __privateMethod(this, _ParaCore_instances, prepareAuthState_fn).call(this, serverAuthState, urlOptions);
|
|
1301
1230
|
});
|
|
1302
1231
|
}
|
|
1303
|
-
verifyExternalWallet(
|
|
1304
|
-
return __async(this,
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
return this.getSetUpBiometricsURLForPhone();
|
|
1232
|
+
verifyExternalWallet(_c) {
|
|
1233
|
+
return __async(this, null, function* () {
|
|
1234
|
+
var _d = _c, {
|
|
1235
|
+
externalWallet,
|
|
1236
|
+
signedMessage,
|
|
1237
|
+
cosmosPublicKeyHex,
|
|
1238
|
+
cosmosSigner
|
|
1239
|
+
} = _d, urlOptions = __objRest(_d, [
|
|
1240
|
+
"externalWallet",
|
|
1241
|
+
"signedMessage",
|
|
1242
|
+
"cosmosPublicKeyHex",
|
|
1243
|
+
"cosmosSigner"
|
|
1244
|
+
]);
|
|
1245
|
+
const serverAuthState = yield this.ctx.client.verifyExternalWallet(this.userId, {
|
|
1246
|
+
externalWallet,
|
|
1247
|
+
signedMessage,
|
|
1248
|
+
cosmosPublicKeyHex,
|
|
1249
|
+
cosmosSigner
|
|
1250
|
+
});
|
|
1251
|
+
return __privateMethod(this, _ParaCore_instances, prepareAuthState_fn).call(this, serverAuthState, urlOptions);
|
|
1324
1252
|
});
|
|
1325
1253
|
}
|
|
1326
1254
|
/**
|
|
@@ -1329,18 +1257,19 @@ const _ParaCore = class _ParaCore {
|
|
|
1329
1257
|
* @param authResponse - the response JSON object received from the Telegram widget.
|
|
1330
1258
|
* @returns `{ isValid: boolean; telegramUserId?: string; userId?: string; isNewUser?: boolean; supportedAuthMethods?: AuthMethod[]; biometricHints?: BiometricLocationHint[] }`
|
|
1331
1259
|
*/
|
|
1332
|
-
verifyTelegram(
|
|
1260
|
+
verifyTelegram(_e) {
|
|
1333
1261
|
return __async(this, null, function* () {
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1262
|
+
var _f = _e, {
|
|
1263
|
+
telegramAuthResponse
|
|
1264
|
+
} = _f, urlOptions = __objRest(_f, [
|
|
1265
|
+
"telegramAuthResponse"
|
|
1266
|
+
]);
|
|
1267
|
+
try {
|
|
1268
|
+
const serverAuthState = yield this.ctx.client.verifyTelegram(telegramAuthResponse);
|
|
1269
|
+
return __privateMethod(this, _ParaCore_instances, prepareAuthState_fn).call(this, serverAuthState, urlOptions);
|
|
1270
|
+
} catch (e) {
|
|
1271
|
+
throw new Error(e.message);
|
|
1342
1272
|
}
|
|
1343
|
-
return res;
|
|
1344
1273
|
});
|
|
1345
1274
|
}
|
|
1346
1275
|
/**
|
|
@@ -1350,32 +1279,9 @@ const _ParaCore = class _ParaCore {
|
|
|
1350
1279
|
* @param {string} opts.verificationCode the verification code to received via 2FA.
|
|
1351
1280
|
* @returns {Object} `{ address, initiatedAt, status, userId, walletId }`
|
|
1352
1281
|
*/
|
|
1353
|
-
|
|
1354
|
-
return __async(this, arguments, function* ({
|
|
1355
|
-
const res = yield this.ctx.client.verify2FA(
|
|
1356
|
-
return {
|
|
1357
|
-
initiatedAt: res.data.initiatedAt,
|
|
1358
|
-
status: res.data.status,
|
|
1359
|
-
userId: res.data.userId,
|
|
1360
|
-
wallets: res.data.wallets
|
|
1361
|
-
};
|
|
1362
|
-
});
|
|
1363
|
-
}
|
|
1364
|
-
/**
|
|
1365
|
-
* Performs 2FA verification.
|
|
1366
|
-
* @param {Object} opts the options object
|
|
1367
|
-
* @param {string} opts.phone the phone number
|
|
1368
|
-
* @param {string} opts.countryCode - the country code
|
|
1369
|
-
* @param {string} opts.verificationCode - verification code to received via 2FA.
|
|
1370
|
-
* @returns {Object} `{ address, initiatedAt, status, userId, walletId }`
|
|
1371
|
-
*/
|
|
1372
|
-
verify2FAForPhone(_0) {
|
|
1373
|
-
return __async(this, arguments, function* ({
|
|
1374
|
-
phone,
|
|
1375
|
-
countryCode,
|
|
1376
|
-
verificationCode
|
|
1377
|
-
}) {
|
|
1378
|
-
const res = yield this.ctx.client.verify2FAForPhone(phone, countryCode, verificationCode);
|
|
1282
|
+
verify2fa(_0) {
|
|
1283
|
+
return __async(this, arguments, function* ({ auth, verificationCode }) {
|
|
1284
|
+
const res = yield this.ctx.client.verify2FA(auth, verificationCode);
|
|
1379
1285
|
return {
|
|
1380
1286
|
initiatedAt: res.data.initiatedAt,
|
|
1381
1287
|
status: res.data.status,
|
|
@@ -1388,12 +1294,11 @@ const _ParaCore = class _ParaCore {
|
|
|
1388
1294
|
* Sets up two-factor authentication for the current user.
|
|
1389
1295
|
* @returns {string} uri - uri to use for setting up 2FA
|
|
1390
1296
|
* */
|
|
1391
|
-
|
|
1297
|
+
setup2fa() {
|
|
1392
1298
|
return __async(this, null, function* () {
|
|
1393
|
-
const
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
};
|
|
1299
|
+
const userId = this.assertUserId();
|
|
1300
|
+
const res = yield this.ctx.client.setup2FA(userId);
|
|
1301
|
+
return res;
|
|
1397
1302
|
});
|
|
1398
1303
|
}
|
|
1399
1304
|
/**
|
|
@@ -1401,24 +1306,10 @@ const _ParaCore = class _ParaCore {
|
|
|
1401
1306
|
* @param {Object} opts the options object
|
|
1402
1307
|
* @param {string} opts.verificationCode - the verification code received via 2FA.
|
|
1403
1308
|
*/
|
|
1404
|
-
|
|
1309
|
+
enable2fa(_0) {
|
|
1405
1310
|
return __async(this, arguments, function* ({ verificationCode }) {
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
}
|
|
1409
|
-
/**
|
|
1410
|
-
* Determines if 2FA has been set up.
|
|
1411
|
-
* @returns {Object} `{ isSetup: boolean }` - true if 2FA is setup, false otherwise
|
|
1412
|
-
*/
|
|
1413
|
-
check2FAStatus() {
|
|
1414
|
-
return __async(this, null, function* () {
|
|
1415
|
-
if (!this.userId) {
|
|
1416
|
-
return { isSetup: false };
|
|
1417
|
-
}
|
|
1418
|
-
const res = yield this.ctx.client.check2FAStatus(this.userId);
|
|
1419
|
-
return {
|
|
1420
|
-
isSetup: res.data.isSetup
|
|
1421
|
-
};
|
|
1311
|
+
const userId = this.assertUserId();
|
|
1312
|
+
yield this.ctx.client.enable2FA(userId, verificationCode);
|
|
1422
1313
|
});
|
|
1423
1314
|
}
|
|
1424
1315
|
/**
|
|
@@ -1431,99 +1322,17 @@ const _ParaCore = class _ParaCore {
|
|
|
1431
1322
|
}, this.getVerificationEmailProps()));
|
|
1432
1323
|
});
|
|
1433
1324
|
}
|
|
1434
|
-
/**
|
|
1435
|
-
* Resend a verification SMS for the current user.
|
|
1436
|
-
*/
|
|
1437
|
-
resendVerificationCodeByPhone() {
|
|
1438
|
-
return __async(this, null, function* () {
|
|
1439
|
-
yield this.ctx.client.resendVerificationCodeByPhone({
|
|
1440
|
-
userId: this.userId
|
|
1441
|
-
});
|
|
1442
|
-
});
|
|
1443
|
-
}
|
|
1444
|
-
/**
|
|
1445
|
-
* Returns a URL for setting up a new WebAuth passkey.
|
|
1446
|
-
* @param {Object} opts the options object
|
|
1447
|
-
* @param {string} opts.authType - the auth type to use
|
|
1448
|
-
* @param {boolean} opts.isForNewDevice whether the passkey is for a new device of an existing user
|
|
1449
|
-
* @returns {string} the URL
|
|
1450
|
-
*/
|
|
1451
|
-
getSetUpBiometricsURL() {
|
|
1452
|
-
return __async(this, arguments, function* ({
|
|
1453
|
-
authType = "email",
|
|
1454
|
-
isForNewDevice = false
|
|
1455
|
-
} = {}) {
|
|
1456
|
-
const res = yield this.ctx.client.addSessionPublicKey(this.userId, {
|
|
1457
|
-
status: PublicKeyStatus.PENDING,
|
|
1458
|
-
type: PublicKeyType.WEB
|
|
1459
|
-
});
|
|
1460
|
-
return this.getWebAuthURLForCreate({
|
|
1461
|
-
authType,
|
|
1462
|
-
isForNewDevice,
|
|
1463
|
-
webAuthId: res.data.id,
|
|
1464
|
-
partnerId: res.data.partnerId
|
|
1465
|
-
});
|
|
1466
|
-
});
|
|
1467
|
-
}
|
|
1468
|
-
/**
|
|
1469
|
-
* Returns a URL for setting up a new WebAuth passkey for a phone number.
|
|
1470
|
-
* @param {Object} opts the options object
|
|
1471
|
-
* @param {boolean} opts.isForNewDevice whether the passkey is for a new device of an existing user
|
|
1472
|
-
* @returns {string} the URL
|
|
1473
|
-
*/
|
|
1474
|
-
getSetUpBiometricsURLForPhone() {
|
|
1475
|
-
return __async(this, arguments, function* ({
|
|
1476
|
-
isForNewDevice = false
|
|
1477
|
-
} = {}) {
|
|
1478
|
-
const res = yield this.ctx.client.addSessionPublicKey(this.userId, {
|
|
1479
|
-
status: PublicKeyStatus.PENDING,
|
|
1480
|
-
type: PublicKeyType.WEB
|
|
1481
|
-
});
|
|
1482
|
-
return this.getWebAuthURLForCreate({
|
|
1483
|
-
authType: "phone",
|
|
1484
|
-
isForNewDevice,
|
|
1485
|
-
webAuthId: res.data.id,
|
|
1486
|
-
partnerId: res.data.partnerId
|
|
1487
|
-
});
|
|
1488
|
-
});
|
|
1489
|
-
}
|
|
1490
|
-
/**
|
|
1491
|
-
* Returns a URL for setting up a new password.
|
|
1492
|
-
* @param {Object} opts the options object
|
|
1493
|
-
* @param {string} opts.authType - the auth type to use
|
|
1494
|
-
* @param {boolean} opts.isForNewDevice whether the passkey is for a new device of an existing user
|
|
1495
|
-
* @param {Theme} [opts.theme] the portal theme to use in place of the partner's default
|
|
1496
|
-
* @returns {string} the URL
|
|
1497
|
-
*/
|
|
1498
|
-
getSetupPasswordURL() {
|
|
1499
|
-
return __async(this, arguments, function* ({
|
|
1500
|
-
authType = "email",
|
|
1501
|
-
isForNewDevice = false,
|
|
1502
|
-
theme
|
|
1503
|
-
} = {}) {
|
|
1504
|
-
const res = yield this.ctx.client.addSessionPasswordPublicKey(this.userId, {
|
|
1505
|
-
status: PasswordStatus.PENDING
|
|
1506
|
-
});
|
|
1507
|
-
return this.getPasswordURLForCreate({
|
|
1508
|
-
authType,
|
|
1509
|
-
isForNewDevice,
|
|
1510
|
-
passwordId: res.data.id,
|
|
1511
|
-
partnerId: res.data.partnerId,
|
|
1512
|
-
theme
|
|
1513
|
-
});
|
|
1514
|
-
});
|
|
1515
|
-
}
|
|
1516
1325
|
/**
|
|
1517
1326
|
* Checks if the current session is active.
|
|
1518
1327
|
* @returns `true` if active, `false` otherwise
|
|
1519
1328
|
*/
|
|
1520
1329
|
isSessionActive() {
|
|
1521
1330
|
return __async(this, null, function* () {
|
|
1522
|
-
if (this.
|
|
1331
|
+
if (this.externalWalletConnectionType === "CONNECTION_ONLY") {
|
|
1523
1332
|
return true;
|
|
1524
1333
|
}
|
|
1525
|
-
const
|
|
1526
|
-
return !!
|
|
1334
|
+
const { isAuthenticated } = yield this.touchSession();
|
|
1335
|
+
return !!isAuthenticated;
|
|
1527
1336
|
});
|
|
1528
1337
|
}
|
|
1529
1338
|
/**
|
|
@@ -1532,201 +1341,102 @@ const _ParaCore = class _ParaCore {
|
|
|
1532
1341
|
**/
|
|
1533
1342
|
isFullyLoggedIn() {
|
|
1534
1343
|
return __async(this, null, function* () {
|
|
1535
|
-
if (this.
|
|
1536
|
-
return true;
|
|
1537
|
-
}
|
|
1538
|
-
if (this.isGuestMode) {
|
|
1344
|
+
if (this.externalWalletConnectionType === "CONNECTION_ONLY") {
|
|
1539
1345
|
return true;
|
|
1540
1346
|
}
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
});
|
|
1544
|
-
}
|
|
1545
|
-
get isGuestMode() {
|
|
1546
|
-
return !this.userId && this.currentWalletIdsArray.length > 0 && this.currentWalletIdsArray.every(([id]) => !!this.wallets[id] && this.wallets[id].pregenIdentifierType === "GUEST_ID");
|
|
1547
|
-
}
|
|
1548
|
-
supportedAuthMethods(auth) {
|
|
1549
|
-
return __async(this, null, function* () {
|
|
1550
|
-
const { supportedAuthMethods } = yield this.ctx.client.getSupportedAuthMethods(auth);
|
|
1551
|
-
const authMethods = /* @__PURE__ */ new Set();
|
|
1552
|
-
for (const type of supportedAuthMethods) {
|
|
1553
|
-
switch (type) {
|
|
1554
|
-
case "PASSWORD":
|
|
1555
|
-
authMethods.add(AuthMethod.PASSWORD);
|
|
1556
|
-
break;
|
|
1557
|
-
case "BIOMETRIC":
|
|
1558
|
-
authMethods.add(AuthMethod.PASSKEY);
|
|
1559
|
-
break;
|
|
1560
|
-
}
|
|
1561
|
-
}
|
|
1562
|
-
return authMethods;
|
|
1563
|
-
});
|
|
1564
|
-
}
|
|
1565
|
-
/**
|
|
1566
|
-
* Get hints associated with the users stored biometrics.
|
|
1567
|
-
* @returns Array containing useragents and AAGuids for stored biometrics
|
|
1568
|
-
*/
|
|
1569
|
-
getUserBiometricLocationHints() {
|
|
1570
|
-
return __async(this, null, function* () {
|
|
1571
|
-
var _a;
|
|
1572
|
-
if (!this.email && !this.phone && !this.farcasterUsername && !this.telegramUserId && !this.isExternalWalletAuth) {
|
|
1573
|
-
throw new Error(
|
|
1574
|
-
"one of email, phone, farcaster username, telegram user id or external wallet with Para auth are required to get biometric location hints"
|
|
1575
|
-
);
|
|
1576
|
-
}
|
|
1577
|
-
return yield this.ctx.client.getBiometricLocationHints({
|
|
1578
|
-
email: this.email,
|
|
1579
|
-
phone: this.phone,
|
|
1580
|
-
countryCode: this.countryCode,
|
|
1581
|
-
farcasterUsername: this.farcasterUsername,
|
|
1582
|
-
telegramUserId: this.telegramUserId,
|
|
1583
|
-
// Using id here since we store the bech32 address for cosmos in the address field of the wallet
|
|
1584
|
-
externalWalletAddress: (_a = this.externalWalletWithParaAuth) == null ? void 0 : _a.id
|
|
1585
|
-
});
|
|
1586
|
-
});
|
|
1587
|
-
}
|
|
1588
|
-
setAuth(auth) {
|
|
1589
|
-
return __async(this, null, function* () {
|
|
1590
|
-
const authInfo = extractAuthInfo(auth);
|
|
1591
|
-
if (!authInfo) {
|
|
1592
|
-
return void 0;
|
|
1593
|
-
}
|
|
1594
|
-
switch (authInfo.authType) {
|
|
1595
|
-
case "email":
|
|
1596
|
-
yield this.setEmail(authInfo.identifier);
|
|
1597
|
-
break;
|
|
1598
|
-
case "phone":
|
|
1599
|
-
yield this.setPhoneNumber(authInfo.auth.phone, authInfo.auth.countryCode);
|
|
1600
|
-
break;
|
|
1601
|
-
case "farcaster":
|
|
1602
|
-
yield this.setFarcasterUsername(authInfo.identifier);
|
|
1603
|
-
break;
|
|
1604
|
-
case "telegram":
|
|
1605
|
-
yield this.setTelegramUserId(authInfo.identifier);
|
|
1606
|
-
break;
|
|
1607
|
-
}
|
|
1608
|
-
return authInfo;
|
|
1609
|
-
});
|
|
1610
|
-
}
|
|
1611
|
-
/**
|
|
1612
|
-
* Initiates a login.
|
|
1613
|
-
* @param {Object} opts the options object
|
|
1614
|
-
* @param {String} opts.email - the email to login with
|
|
1615
|
-
* @param {boolean} opts.useShortURL - whether to shorten the link
|
|
1616
|
-
* @returns - the WebAuth URL for logging in
|
|
1617
|
-
**/
|
|
1618
|
-
initiateUserLogin(_e) {
|
|
1619
|
-
return __async(this, null, function* () {
|
|
1620
|
-
var _f = _e, { useShortUrl = false } = _f, auth = __objRest(_f, ["useShortUrl"]);
|
|
1621
|
-
const authInfo = yield this.setAuth(auth);
|
|
1622
|
-
if (!authInfo) {
|
|
1623
|
-
return;
|
|
1624
|
-
}
|
|
1625
|
-
const res = yield this.touchSession(true);
|
|
1626
|
-
if (!this.loginEncryptionKeyPair) {
|
|
1627
|
-
yield this.setLoginEncryptionKeyPair();
|
|
1628
|
-
}
|
|
1629
|
-
const webAuthLoginURL = yield this.getWebAuthURLForLogin({
|
|
1630
|
-
authType: authInfo.authType,
|
|
1631
|
-
sessionId: res.data.sessionId,
|
|
1632
|
-
partnerId: res.data.partnerId,
|
|
1633
|
-
loginEncryptionPublicKey: getPublicKeyHex(this.loginEncryptionKeyPair)
|
|
1634
|
-
});
|
|
1635
|
-
if (!useShortUrl) {
|
|
1636
|
-
return webAuthLoginURL;
|
|
1347
|
+
if (this.isGuestMode) {
|
|
1348
|
+
return true;
|
|
1637
1349
|
}
|
|
1638
|
-
|
|
1350
|
+
const isSessionActive = yield this.isSessionActive();
|
|
1351
|
+
return isSessionActive && (this.isNoWalletConfig || this.currentWalletIdsArray.length > 0 && this.currentWalletIdsArray.reduce((acc, [id]) => acc && !!this.wallets[id], true));
|
|
1639
1352
|
});
|
|
1640
1353
|
}
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
initiateUserLoginV2(auth) {
|
|
1647
|
-
return __async(this, null, function* () {
|
|
1648
|
-
const authInfo = yield this.setAuth(auth);
|
|
1649
|
-
if (!authInfo) {
|
|
1650
|
-
return;
|
|
1354
|
+
get isGuestMode() {
|
|
1355
|
+
return __privateGet(this, _ParaCore_instances, guestWalletIdsArray_get).length > 0 && Object.values(this.wallets).every(
|
|
1356
|
+
({ userId, partnerId }) => {
|
|
1357
|
+
var _a;
|
|
1358
|
+
return partnerId === ((_a = __privateGet(this, _partner)) == null ? void 0 : _a.id) && (!userId || userId !== this.userId);
|
|
1651
1359
|
}
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1360
|
+
);
|
|
1361
|
+
}
|
|
1362
|
+
supportedAuthMethods(auth) {
|
|
1363
|
+
return __async(this, null, function* () {
|
|
1364
|
+
const { supportedAuthMethods } = yield this.ctx.client.getSupportedAuthMethods(auth);
|
|
1365
|
+
const authMethods = /* @__PURE__ */ new Set();
|
|
1366
|
+
for (const type of supportedAuthMethods) {
|
|
1367
|
+
switch (type) {
|
|
1368
|
+
case "PASSWORD":
|
|
1369
|
+
authMethods.add(AuthMethod.PASSWORD);
|
|
1370
|
+
break;
|
|
1371
|
+
case "BIOMETRIC":
|
|
1372
|
+
authMethods.add(AuthMethod.PASSKEY);
|
|
1373
|
+
break;
|
|
1374
|
+
}
|
|
1655
1375
|
}
|
|
1656
|
-
return
|
|
1376
|
+
return authMethods;
|
|
1657
1377
|
});
|
|
1658
1378
|
}
|
|
1659
1379
|
/**
|
|
1660
|
-
*
|
|
1661
|
-
* @
|
|
1662
|
-
* @
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
* @returns - the WebAuth URL for logging in
|
|
1666
|
-
**/
|
|
1667
|
-
initiateUserLoginForPhone(_g) {
|
|
1380
|
+
* Get hints associated with the users stored biometrics.
|
|
1381
|
+
* @deprecated
|
|
1382
|
+
* @returns Array containing useragents and AAGuids for stored biometrics
|
|
1383
|
+
*/
|
|
1384
|
+
getUserBiometricLocationHints() {
|
|
1668
1385
|
return __async(this, null, function* () {
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
} = _h, auth = __objRest(_h, [
|
|
1672
|
-
"useShortUrl"
|
|
1673
|
-
]);
|
|
1674
|
-
yield this.setAuth(auth);
|
|
1675
|
-
const res = yield this.touchSession(true);
|
|
1676
|
-
if (!this.loginEncryptionKeyPair) {
|
|
1677
|
-
yield this.setLoginEncryptionKeyPair();
|
|
1678
|
-
}
|
|
1679
|
-
const webAuthLoginURL = yield this.getWebAuthURLForLoginForPhone({
|
|
1680
|
-
sessionId: res.data.sessionId,
|
|
1681
|
-
loginEncryptionPublicKey: getPublicKeyHex(this.loginEncryptionKeyPair),
|
|
1682
|
-
partnerId: res.data.partnerId
|
|
1683
|
-
});
|
|
1684
|
-
if (!useShortUrl) {
|
|
1685
|
-
return webAuthLoginURL;
|
|
1686
|
-
}
|
|
1687
|
-
return this.shortenLoginLink(webAuthLoginURL);
|
|
1386
|
+
const { auth } = this.assertIsAuthSet();
|
|
1387
|
+
return yield this.ctx.client.getBiometricLocationHints(auth);
|
|
1688
1388
|
});
|
|
1689
1389
|
}
|
|
1690
1390
|
/**
|
|
1691
1391
|
* Waits for the session to be active.
|
|
1692
1392
|
**/
|
|
1693
|
-
|
|
1694
|
-
return __async(this, arguments, function* ({
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
yield
|
|
1703
|
-
if (
|
|
1704
|
-
this.
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1393
|
+
waitForSignup(_0) {
|
|
1394
|
+
return __async(this, arguments, function* ({
|
|
1395
|
+
isCanceled = () => false,
|
|
1396
|
+
onCancel,
|
|
1397
|
+
onPoll
|
|
1398
|
+
}) {
|
|
1399
|
+
const startedAt = Date.now();
|
|
1400
|
+
return new Promise((resolve, reject) => {
|
|
1401
|
+
(() => __async(this, null, function* () {
|
|
1402
|
+
yield this.touchSession();
|
|
1403
|
+
if (!this.isExternalWalletAuth) {
|
|
1404
|
+
this.externalWallets = {};
|
|
1405
|
+
}
|
|
1406
|
+
while (true) {
|
|
1407
|
+
try {
|
|
1408
|
+
if (isCanceled() || Date.now() - startedAt > constants.POLLING_TIMEOUT_MS) {
|
|
1409
|
+
onCancel == null ? void 0 : onCancel();
|
|
1410
|
+
dispatchEvent(ParaEvent.ACCOUNT_CREATION_EVENT, false, "failed to sign up user");
|
|
1411
|
+
return reject("canceled");
|
|
1412
|
+
}
|
|
1413
|
+
yield new Promise((_resolve) => setTimeout(_resolve, constants.POLLING_INTERVAL_MS));
|
|
1414
|
+
if (yield this.isSessionActive()) {
|
|
1415
|
+
dispatchEvent(ParaEvent.ACCOUNT_CREATION_EVENT, true);
|
|
1416
|
+
return resolve(true);
|
|
1417
|
+
}
|
|
1418
|
+
onPoll == null ? void 0 : onPoll();
|
|
1419
|
+
} catch (err) {
|
|
1420
|
+
console.error(err);
|
|
1421
|
+
onPoll == null ? void 0 : onPoll();
|
|
1711
1422
|
}
|
|
1712
1423
|
}
|
|
1713
|
-
}
|
|
1714
|
-
|
|
1715
|
-
}
|
|
1716
|
-
}
|
|
1717
|
-
return false;
|
|
1424
|
+
}))();
|
|
1425
|
+
});
|
|
1718
1426
|
});
|
|
1719
1427
|
}
|
|
1720
|
-
|
|
1428
|
+
waitForWalletCreation() {
|
|
1721
1429
|
return __async(this, arguments, function* ({
|
|
1722
|
-
|
|
1430
|
+
isCanceled = () => false,
|
|
1431
|
+
onCancel
|
|
1723
1432
|
} = {}) {
|
|
1724
|
-
yield this.
|
|
1433
|
+
yield this.waitForSignup({ isCanceled, onCancel });
|
|
1434
|
+
const { supportedWalletTypes } = yield __privateMethod(this, _ParaCore_instances, assertPartner_fn).call(this);
|
|
1725
1435
|
const pregenWallets = yield this.getPregenWallets();
|
|
1726
1436
|
let recoverySecret, walletIds = {};
|
|
1727
1437
|
if (pregenWallets.length > 0) {
|
|
1728
1438
|
recoverySecret = yield this.claimPregenWallets();
|
|
1729
|
-
walletIds =
|
|
1439
|
+
walletIds = supportedWalletTypes.reduce((acc, { type }) => {
|
|
1730
1440
|
var _a;
|
|
1731
1441
|
return __spreadProps(__spreadValues({}, acc), {
|
|
1732
1442
|
[type]: [(_a = pregenWallets.find((w) => !!WalletSchemeTypeMap[w.scheme][type])) == null ? void 0 : _a.id]
|
|
@@ -1746,14 +1456,12 @@ const _ParaCore = class _ParaCore {
|
|
|
1746
1456
|
* You can create a QR code with this URI that works with Farcaster's mobile app.
|
|
1747
1457
|
* @return {string} the Farcaster connect URI
|
|
1748
1458
|
*/
|
|
1749
|
-
|
|
1459
|
+
getFarcasterConnectUri() {
|
|
1750
1460
|
return __async(this, null, function* () {
|
|
1751
|
-
yield this.logout();
|
|
1752
|
-
yield this.touchSession(true);
|
|
1753
1461
|
const {
|
|
1754
|
-
data: { connect_uri }
|
|
1462
|
+
data: { connect_uri: connectUri }
|
|
1755
1463
|
} = yield this.ctx.client.initializeFarcasterLogin();
|
|
1756
|
-
return
|
|
1464
|
+
return connectUri;
|
|
1757
1465
|
});
|
|
1758
1466
|
}
|
|
1759
1467
|
/**
|
|
@@ -1761,40 +1469,60 @@ const _ParaCore = class _ParaCore {
|
|
|
1761
1469
|
* If successful, this returns the user's Farcaster username and profile picture and indicates whether the user already exists.
|
|
1762
1470
|
* @return {Object} `{userExists: boolean; username: string; pfpUrl?: string | null }` - the user's information and whether the user already exists.
|
|
1763
1471
|
*/
|
|
1764
|
-
|
|
1472
|
+
verifyFarcaster(_g) {
|
|
1765
1473
|
return __async(this, null, function* () {
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1474
|
+
var _h = _g, {
|
|
1475
|
+
isCanceled = () => false,
|
|
1476
|
+
onConnectUri,
|
|
1477
|
+
onCancel,
|
|
1478
|
+
onPoll
|
|
1479
|
+
} = _h, urlOptions = __objRest(_h, [
|
|
1480
|
+
"isCanceled",
|
|
1481
|
+
"onConnectUri",
|
|
1482
|
+
"onCancel",
|
|
1483
|
+
"onPoll"
|
|
1484
|
+
]);
|
|
1485
|
+
if (onConnectUri) {
|
|
1486
|
+
const connectUri = yield this.getFarcasterConnectUri();
|
|
1487
|
+
onConnectUri(connectUri);
|
|
1488
|
+
}
|
|
1489
|
+
return new Promise((resolve, reject) => {
|
|
1490
|
+
(() => __async(this, null, function* () {
|
|
1491
|
+
const startedAt = Date.now();
|
|
1492
|
+
while (true) {
|
|
1493
|
+
try {
|
|
1494
|
+
if (isCanceled() || Date.now() - startedAt > constants.POLLING_TIMEOUT_MS) {
|
|
1495
|
+
onCancel == null ? void 0 : onCancel();
|
|
1496
|
+
return reject("canceled");
|
|
1497
|
+
}
|
|
1498
|
+
yield new Promise((_resolve) => setTimeout(_resolve, constants.POLLING_INTERVAL_MS));
|
|
1499
|
+
const serverAuthState = yield this.ctx.client.getFarcasterAuthStatus();
|
|
1500
|
+
if (isServerAuthState(serverAuthState)) {
|
|
1501
|
+
const authState = yield __privateMethod(this, _ParaCore_instances, prepareAuthState_fn).call(this, serverAuthState, urlOptions);
|
|
1502
|
+
return resolve(authState);
|
|
1503
|
+
}
|
|
1504
|
+
onPoll == null ? void 0 : onPoll();
|
|
1505
|
+
} catch (e) {
|
|
1506
|
+
console.error(e);
|
|
1507
|
+
return reject(e);
|
|
1508
|
+
}
|
|
1780
1509
|
}
|
|
1781
|
-
}
|
|
1782
|
-
|
|
1783
|
-
this.isAwaitingFarcaster = false;
|
|
1784
|
-
}
|
|
1785
|
-
}
|
|
1510
|
+
}))();
|
|
1511
|
+
});
|
|
1786
1512
|
});
|
|
1787
1513
|
}
|
|
1788
1514
|
/**
|
|
1789
1515
|
* Generates a URL for the user to log in with OAuth using a desire method.
|
|
1790
1516
|
*
|
|
1791
1517
|
* @param {Object} opts the options object
|
|
1792
|
-
* @param {
|
|
1518
|
+
* @param {TOAuthMethod} opts.method the third-party service to use for OAuth.
|
|
1793
1519
|
* @param {string} [opts.deeplinkUrl] the deeplink to redirect to after the OAuth flow. This is for mobile only.
|
|
1794
1520
|
* @returns {string} the URL for the user to log in with OAuth.
|
|
1795
1521
|
*/
|
|
1796
|
-
|
|
1797
|
-
return __async(this,
|
|
1522
|
+
getOAuthUrl(_i) {
|
|
1523
|
+
return __async(this, null, function* () {
|
|
1524
|
+
var _j = _i, { method, deeplinkUrl } = _j, params = __objRest(_j, ["method", "deeplinkUrl"]);
|
|
1525
|
+
var _a;
|
|
1798
1526
|
if (deeplinkUrl) {
|
|
1799
1527
|
try {
|
|
1800
1528
|
new URL(deeplinkUrl);
|
|
@@ -1802,14 +1530,13 @@ const _ParaCore = class _ParaCore {
|
|
|
1802
1530
|
throw new Error("Invalid deeplink URL");
|
|
1803
1531
|
}
|
|
1804
1532
|
}
|
|
1805
|
-
yield this.
|
|
1806
|
-
const res = yield this.touchSession(true);
|
|
1533
|
+
const sessionLookupId = (_a = params.sessionLookupId) != null ? _a : yield __privateMethod(this, _ParaCore_instances, prepareLogin_fn).call(this);
|
|
1807
1534
|
return constructUrl({
|
|
1808
|
-
base:
|
|
1809
|
-
path: `/auth/${method
|
|
1535
|
+
base: getBaseOAuthUrl(this.ctx.env),
|
|
1536
|
+
path: `/auth/${method}`,
|
|
1810
1537
|
params: {
|
|
1811
1538
|
apiKey: this.ctx.apiKey,
|
|
1812
|
-
sessionLookupId
|
|
1539
|
+
sessionLookupId,
|
|
1813
1540
|
deeplinkUrl
|
|
1814
1541
|
}
|
|
1815
1542
|
});
|
|
@@ -1823,37 +1550,54 @@ const _ParaCore = class _ParaCore {
|
|
|
1823
1550
|
* @param {Window} [opts.popupWindow] the popup window being used for login.
|
|
1824
1551
|
* @return {Object} `{ email?: string; isError?: boolean; userExists: boolean; }` the result data
|
|
1825
1552
|
*/
|
|
1826
|
-
|
|
1827
|
-
return __async(this,
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1553
|
+
verifyOAuth(_k) {
|
|
1554
|
+
return __async(this, null, function* () {
|
|
1555
|
+
var _l = _k, {
|
|
1556
|
+
method,
|
|
1557
|
+
deeplinkUrl,
|
|
1558
|
+
isCanceled = () => false,
|
|
1559
|
+
onCancel,
|
|
1560
|
+
onPoll,
|
|
1561
|
+
onOAuthUrl
|
|
1562
|
+
} = _l, urlOptions = __objRest(_l, [
|
|
1563
|
+
"method",
|
|
1564
|
+
"deeplinkUrl",
|
|
1565
|
+
"isCanceled",
|
|
1566
|
+
"onCancel",
|
|
1567
|
+
"onPoll",
|
|
1568
|
+
"onOAuthUrl"
|
|
1569
|
+
]);
|
|
1570
|
+
let sessionLookupId;
|
|
1571
|
+
if (onOAuthUrl) {
|
|
1572
|
+
sessionLookupId = yield __privateMethod(this, _ParaCore_instances, prepareLogin_fn).call(this);
|
|
1573
|
+
const oAuthUrl = yield this.getOAuthUrl({ method, deeplinkUrl, sessionLookupId });
|
|
1574
|
+
onOAuthUrl(oAuthUrl);
|
|
1575
|
+
} else {
|
|
1576
|
+
({ sessionLookupId } = yield this.touchSession());
|
|
1577
|
+
}
|
|
1578
|
+
const startedAt = Date.now();
|
|
1579
|
+
return new Promise((resolve, reject) => {
|
|
1580
|
+
(() => __async(this, null, function* () {
|
|
1581
|
+
while (true) {
|
|
1582
|
+
try {
|
|
1583
|
+
if (isCanceled() || Date.now() - startedAt > constants.POLLING_TIMEOUT_MS) {
|
|
1584
|
+
onCancel == null ? void 0 : onCancel();
|
|
1585
|
+
return reject("canceled");
|
|
1841
1586
|
}
|
|
1842
|
-
yield
|
|
1843
|
-
yield this.
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1587
|
+
yield new Promise((_resolve) => setTimeout(_resolve, constants.POLLING_INTERVAL_MS));
|
|
1588
|
+
const serverAuthState = yield this.ctx.client.verifyOAuth();
|
|
1589
|
+
if (isServerAuthState(serverAuthState)) {
|
|
1590
|
+
const authState = yield __privateMethod(this, _ParaCore_instances, prepareAuthState_fn).call(this, serverAuthState, __spreadProps(__spreadValues({}, urlOptions), { sessionLookupId }));
|
|
1591
|
+
return resolve(authState);
|
|
1592
|
+
}
|
|
1593
|
+
onPoll == null ? void 0 : onPoll();
|
|
1594
|
+
} catch (err) {
|
|
1595
|
+
console.error(err);
|
|
1596
|
+
onPoll == null ? void 0 : onPoll();
|
|
1850
1597
|
}
|
|
1851
1598
|
}
|
|
1852
|
-
}
|
|
1853
|
-
|
|
1854
|
-
}
|
|
1855
|
-
}
|
|
1856
|
-
return { userExists: false };
|
|
1599
|
+
}))();
|
|
1600
|
+
});
|
|
1857
1601
|
});
|
|
1858
1602
|
}
|
|
1859
1603
|
/**
|
|
@@ -1864,60 +1608,61 @@ const _ParaCore = class _ParaCore {
|
|
|
1864
1608
|
* @param {boolean} [opts.skipSessionRefresh] whether to skip refreshing the session.
|
|
1865
1609
|
* @returns {Object} `{ isComplete: boolean; isError: boolean; needsWallet: boolean; partnerId: string; }` the result data
|
|
1866
1610
|
**/
|
|
1867
|
-
|
|
1611
|
+
waitForLogin() {
|
|
1868
1612
|
return __async(this, arguments, function* ({
|
|
1869
|
-
|
|
1613
|
+
isCanceled = () => false,
|
|
1614
|
+
onCancel,
|
|
1615
|
+
onPoll,
|
|
1870
1616
|
skipSessionRefresh = false
|
|
1871
1617
|
} = {}) {
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
this
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
try {
|
|
1879
|
-
yield new Promise((resolve) => setTimeout(resolve, constants.POLLING_INTERVAL_MS));
|
|
1880
|
-
if (!(yield this.isSessionActive())) {
|
|
1881
|
-
if (popupWindow == null ? void 0 : popupWindow.closed) {
|
|
1882
|
-
const resp2 = { isComplete: false, isError: true };
|
|
1883
|
-
dispatchEvent(ParaEvent.LOGIN_EVENT, resp2, "failed to setup user");
|
|
1884
|
-
return resp2;
|
|
1885
|
-
}
|
|
1886
|
-
continue;
|
|
1618
|
+
const startedAt = Date.now();
|
|
1619
|
+
return new Promise((resolve, reject) => {
|
|
1620
|
+
(() => __async(this, null, function* () {
|
|
1621
|
+
var _a;
|
|
1622
|
+
if (!this.isExternalWalletAuth) {
|
|
1623
|
+
this.externalWallets = {};
|
|
1887
1624
|
}
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1625
|
+
while (true) {
|
|
1626
|
+
if (isCanceled() || Date.now() - startedAt > constants.POLLING_TIMEOUT_MS) {
|
|
1627
|
+
dispatchEvent(ParaEvent.LOGIN_EVENT, { isComplete: false }, "failed to setup user");
|
|
1628
|
+
onCancel == null ? void 0 : onCancel();
|
|
1629
|
+
return reject("canceled");
|
|
1630
|
+
}
|
|
1631
|
+
yield new Promise((resolve2) => setTimeout(resolve2, constants.POLLING_INTERVAL_MS));
|
|
1632
|
+
try {
|
|
1633
|
+
let session = yield this.touchSession();
|
|
1634
|
+
if (!session.isAuthenticated) {
|
|
1635
|
+
onPoll == null ? void 0 : onPoll();
|
|
1897
1636
|
continue;
|
|
1898
1637
|
}
|
|
1638
|
+
session = yield this.userSetupAfterLogin();
|
|
1639
|
+
const needsWallet = (_a = session.needsWallet) != null ? _a : false;
|
|
1640
|
+
if (!needsWallet) {
|
|
1641
|
+
if (this.currentWalletIdsArray.length === 0) {
|
|
1642
|
+
onPoll == null ? void 0 : onPoll();
|
|
1643
|
+
continue;
|
|
1644
|
+
}
|
|
1645
|
+
}
|
|
1646
|
+
const fetchedWallets = yield this.fetchWallets();
|
|
1647
|
+
const tempSharesRes = yield this.getTransmissionKeyShares();
|
|
1648
|
+
if (tempSharesRes.data.temporaryShares.length === fetchedWallets.length) {
|
|
1649
|
+
yield this.setupAfterLogin({ temporaryShares: tempSharesRes.data.temporaryShares, skipSessionRefresh });
|
|
1650
|
+
yield this.claimPregenWallets();
|
|
1651
|
+
const resp = {
|
|
1652
|
+
needsWallet: needsWallet || Object.values(this.wallets).length === 0,
|
|
1653
|
+
partnerId: session.partnerId
|
|
1654
|
+
};
|
|
1655
|
+
dispatchEvent(ParaEvent.LOGIN_EVENT, resp);
|
|
1656
|
+
return resolve(resp);
|
|
1657
|
+
}
|
|
1658
|
+
onPoll == null ? void 0 : onPoll();
|
|
1659
|
+
} catch (err) {
|
|
1660
|
+
console.error(err);
|
|
1661
|
+
onPoll == null ? void 0 : onPoll();
|
|
1899
1662
|
}
|
|
1900
1663
|
}
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
if (tempSharesRes.data.temporaryShares.length === fetchedWallets.length) {
|
|
1904
|
-
yield this.setupAfterLogin({ temporaryShares: tempSharesRes.data.temporaryShares, skipSessionRefresh });
|
|
1905
|
-
yield this.claimPregenWallets();
|
|
1906
|
-
const resp2 = {
|
|
1907
|
-
isComplete: true,
|
|
1908
|
-
needsWallet: needsWallet || Object.values(this.wallets).length === 0,
|
|
1909
|
-
partnerId: postLoginData.data.partnerId
|
|
1910
|
-
};
|
|
1911
|
-
dispatchEvent(ParaEvent.LOGIN_EVENT, resp2);
|
|
1912
|
-
return resp2;
|
|
1913
|
-
}
|
|
1914
|
-
} catch (err) {
|
|
1915
|
-
console.error(err);
|
|
1916
|
-
}
|
|
1917
|
-
}
|
|
1918
|
-
const resp = { isComplete: false };
|
|
1919
|
-
dispatchEvent(ParaEvent.LOGIN_EVENT, resp, "exitted login without setting up user");
|
|
1920
|
-
return resp;
|
|
1664
|
+
}))();
|
|
1665
|
+
});
|
|
1921
1666
|
});
|
|
1922
1667
|
}
|
|
1923
1668
|
/**
|
|
@@ -1929,14 +1674,15 @@ const _ParaCore = class _ParaCore {
|
|
|
1929
1674
|
* @returns a URL for the user to reauthenticate.
|
|
1930
1675
|
**/
|
|
1931
1676
|
refreshSession() {
|
|
1932
|
-
return __async(this, arguments, function* ({
|
|
1933
|
-
|
|
1677
|
+
return __async(this, arguments, function* ({
|
|
1678
|
+
shouldOpenPopup = false
|
|
1679
|
+
} = {}) {
|
|
1680
|
+
const { sessionId } = yield this.touchSession(true);
|
|
1934
1681
|
if (!this.loginEncryptionKeyPair) {
|
|
1935
1682
|
yield this.setLoginEncryptionKeyPair();
|
|
1936
1683
|
}
|
|
1937
|
-
const link = yield this.
|
|
1938
|
-
sessionId
|
|
1939
|
-
loginEncryptionPublicKey: getPublicKeyHex(this.loginEncryptionKeyPair)
|
|
1684
|
+
const link = yield this.getLoginUrl({
|
|
1685
|
+
sessionId
|
|
1940
1686
|
});
|
|
1941
1687
|
if (shouldOpenPopup) {
|
|
1942
1688
|
this.platformUtils.openPopup(link);
|
|
@@ -1950,13 +1696,13 @@ const _ParaCore = class _ParaCore {
|
|
|
1950
1696
|
**/
|
|
1951
1697
|
userSetupAfterLogin() {
|
|
1952
1698
|
return __async(this, null, function* () {
|
|
1953
|
-
const
|
|
1954
|
-
yield this.setUserId(
|
|
1955
|
-
if (
|
|
1956
|
-
yield this.setCurrentWalletIds(
|
|
1957
|
-
sessionLookupId: this.isPortal() ?
|
|
1699
|
+
const session = yield this.touchSession();
|
|
1700
|
+
yield this.setUserId(session.userId);
|
|
1701
|
+
if (session.currentWalletIds && session.currentWalletIds !== this.currentWalletIds)
|
|
1702
|
+
yield this.setCurrentWalletIds(session.currentWalletIds, {
|
|
1703
|
+
sessionLookupId: this.isPortal() ? session.sessionLookupId : void 0
|
|
1958
1704
|
});
|
|
1959
|
-
return
|
|
1705
|
+
return session;
|
|
1960
1706
|
});
|
|
1961
1707
|
}
|
|
1962
1708
|
/**
|
|
@@ -1967,8 +1713,8 @@ const _ParaCore = class _ParaCore {
|
|
|
1967
1713
|
**/
|
|
1968
1714
|
getTransmissionKeyShares() {
|
|
1969
1715
|
return __async(this, arguments, function* ({ isForNewDevice = false } = {}) {
|
|
1970
|
-
const
|
|
1971
|
-
const sessionLookupId = isForNewDevice ? `${
|
|
1716
|
+
const session = yield this.touchSession();
|
|
1717
|
+
const sessionLookupId = isForNewDevice ? `${session.sessionLookupId}-new-device` : session.sessionLookupId;
|
|
1972
1718
|
return this.ctx.client.getTransmissionKeyshares(this.userId, sessionLookupId);
|
|
1973
1719
|
});
|
|
1974
1720
|
}
|
|
@@ -2095,7 +1841,7 @@ const _ParaCore = class _ParaCore {
|
|
|
2095
1841
|
*
|
|
2096
1842
|
* @param {Object} [opts] the options object.
|
|
2097
1843
|
* @param {boolean} [opts.skipDistribute] if `true`, the wallets' recovery share will not be distributed.
|
|
2098
|
-
* @param {
|
|
1844
|
+
* @param {TWalletType[]} [opts.types] the types of wallets to create.
|
|
2099
1845
|
* @returns {Object} the wallets created, their ids, and the recovery secret.
|
|
2100
1846
|
**/
|
|
2101
1847
|
createWalletPerType() {
|
|
@@ -2166,7 +1912,7 @@ const _ParaCore = class _ParaCore {
|
|
|
2166
1912
|
/**
|
|
2167
1913
|
* Creates a new wallet.
|
|
2168
1914
|
* @param {Object} opts the options object.
|
|
2169
|
-
* @param {
|
|
1915
|
+
* @param {TWalletType} opts.type the type of wallet to create.
|
|
2170
1916
|
* @param {boolean} opts.skipDistribute - if true, recovery share will not be distributed.
|
|
2171
1917
|
* @returns {[Wallet, string | null]} `[wallet, recoveryShare]` - the wallet object and the new recovery share.
|
|
2172
1918
|
**/
|
|
@@ -2177,14 +1923,15 @@ const _ParaCore = class _ParaCore {
|
|
|
2177
1923
|
} = {}) {
|
|
2178
1924
|
var _a, _b;
|
|
2179
1925
|
this.requireApiKey();
|
|
1926
|
+
const { supportedWalletTypes } = yield __privateMethod(this, _ParaCore_instances, assertPartner_fn).call(this);
|
|
2180
1927
|
const walletType = yield this.assertIsValidWalletType(
|
|
2181
|
-
_type != null ? _type : (_a =
|
|
1928
|
+
_type != null ? _type : (_a = supportedWalletTypes.find(({ optional }) => !optional)) == null ? void 0 : _a.type
|
|
2182
1929
|
);
|
|
2183
1930
|
let signer;
|
|
2184
1931
|
let wallet;
|
|
2185
1932
|
let keygenRes;
|
|
2186
1933
|
switch (walletType) {
|
|
2187
|
-
case
|
|
1934
|
+
case "SOLANA": {
|
|
2188
1935
|
keygenRes = yield this.platformUtils.ed25519Keygen(
|
|
2189
1936
|
this.ctx,
|
|
2190
1937
|
this.userId,
|
|
@@ -2210,7 +1957,7 @@ const _ParaCore = class _ParaCore {
|
|
|
2210
1957
|
this.wallets[walletId] = {
|
|
2211
1958
|
id: walletId,
|
|
2212
1959
|
signer,
|
|
2213
|
-
scheme: walletType ===
|
|
1960
|
+
scheme: walletType === "SOLANA" ? "ED25519" : "DKLS",
|
|
2214
1961
|
type: walletType
|
|
2215
1962
|
};
|
|
2216
1963
|
wallet = this.wallets[walletId];
|
|
@@ -2227,7 +1974,7 @@ const _ParaCore = class _ParaCore {
|
|
|
2227
1974
|
});
|
|
2228
1975
|
}
|
|
2229
1976
|
yield this.setCurrentWalletIds(__spreadProps(__spreadValues({}, this.currentWalletIds), {
|
|
2230
|
-
[walletType]: [...(_b = this.currentWalletIds[walletType]) != null ? _b : [], walletId]
|
|
1977
|
+
[walletType]: [.../* @__PURE__ */ new Set([...(_b = this.currentWalletIds[walletType]) != null ? _b : [], walletId])]
|
|
2231
1978
|
}));
|
|
2232
1979
|
const walletNoSigner = __spreadValues({}, wallet);
|
|
2233
1980
|
delete walletNoSigner.signer;
|
|
@@ -2238,15 +1985,6 @@ const _ParaCore = class _ParaCore {
|
|
|
2238
1985
|
return [wallet, recoveryShare];
|
|
2239
1986
|
});
|
|
2240
1987
|
}
|
|
2241
|
-
/**
|
|
2242
|
-
* Creates a new pregenerated wallet.
|
|
2243
|
-
*
|
|
2244
|
-
* @param {Object} opts the options object.
|
|
2245
|
-
* @param {string} opts.pregenIdentifier the identifier associated with the new wallet.
|
|
2246
|
-
* @param {TPregenIdentifierType} [opts.pregenIdentifierType] the identifier type. Defaults to `EMAIL`.
|
|
2247
|
-
* @param {WalletType} [opts.type] the type of wallet to create. Defaults to the first non-optional type in the instance's `supportedWalletTypes` array.
|
|
2248
|
-
* @returns {Wallet} the created wallet.
|
|
2249
|
-
**/
|
|
2250
1988
|
createPregenWallet(opts) {
|
|
2251
1989
|
return __async(this, null, function* () {
|
|
2252
1990
|
return yield __privateMethod(this, _ParaCore_instances, createPregenWallet_fn).call(this, opts);
|
|
@@ -2259,18 +1997,17 @@ const _ParaCore = class _ParaCore {
|
|
|
2259
1997
|
* @param {Object} opts the options object.
|
|
2260
1998
|
* @param {string} opts.pregenIdentifier the identifier to associate each wallet with.
|
|
2261
1999
|
* @param {TPregenIdentifierType} opts.pregenIdentifierType - either `'EMAIL'` or `'PHONE'`.
|
|
2262
|
-
* @param {
|
|
2000
|
+
* @param {TWalletType[]} [opts.types] the wallet types to create. Defaults to any types the instance supports that are not already present.
|
|
2263
2001
|
* @returns {Wallet[]} an array containing the created wallets.
|
|
2264
2002
|
**/
|
|
2265
2003
|
createPregenWalletPerType(_0) {
|
|
2266
2004
|
return __async(this, arguments, function* ({
|
|
2267
2005
|
types,
|
|
2268
|
-
|
|
2269
|
-
pregenIdentifierType = "EMAIL"
|
|
2006
|
+
pregenId
|
|
2270
2007
|
}) {
|
|
2271
2008
|
const wallets = [];
|
|
2272
2009
|
for (const type of yield this.getTypesToCreate(types)) {
|
|
2273
|
-
const wallet = yield
|
|
2010
|
+
const wallet = yield this.createPregenWallet({ type, pregenId });
|
|
2274
2011
|
wallets.push(wallet);
|
|
2275
2012
|
}
|
|
2276
2013
|
return wallets;
|
|
@@ -2278,7 +2015,6 @@ const _ParaCore = class _ParaCore {
|
|
|
2278
2015
|
}
|
|
2279
2016
|
/**
|
|
2280
2017
|
* Claims a pregenerated wallet.
|
|
2281
|
-
*
|
|
2282
2018
|
* @param {Object} opts the options object.
|
|
2283
2019
|
* @param {string} opts.pregenIdentifier string the identifier of the user claiming the wallet
|
|
2284
2020
|
* @param {TPregenIdentifierType} opts.pregenIdentifierType type of the identifier of the user claiming the wallet
|
|
@@ -2286,12 +2022,11 @@ const _ParaCore = class _ParaCore {
|
|
|
2286
2022
|
**/
|
|
2287
2023
|
claimPregenWallets() {
|
|
2288
2024
|
return __async(this, arguments, function* ({
|
|
2289
|
-
|
|
2290
|
-
pregenIdentifierType = !!pregenIdentifier ? "EMAIL" : void 0
|
|
2025
|
+
pregenId
|
|
2291
2026
|
} = {}) {
|
|
2292
2027
|
var _a;
|
|
2293
2028
|
this.requireApiKey();
|
|
2294
|
-
const pregenWallets =
|
|
2029
|
+
const pregenWallets = pregenId ? yield this.getPregenWallets({ pregenId }) : yield this.getPregenWallets();
|
|
2295
2030
|
if (pregenWallets.length === 0) {
|
|
2296
2031
|
return void 0;
|
|
2297
2032
|
}
|
|
@@ -2309,7 +2044,7 @@ const _ParaCore = class _ParaCore {
|
|
|
2309
2044
|
for (const walletId of walletIds) {
|
|
2310
2045
|
const wallet = this.wallets[walletId];
|
|
2311
2046
|
let refreshedShare;
|
|
2312
|
-
if (wallet.scheme ===
|
|
2047
|
+
if (wallet.scheme === "ED25519") {
|
|
2313
2048
|
const distributeRes = yield distributeNewShare({
|
|
2314
2049
|
ctx: this.ctx,
|
|
2315
2050
|
userId: this.userId,
|
|
@@ -2360,10 +2095,10 @@ const _ParaCore = class _ParaCore {
|
|
|
2360
2095
|
updatePregenWalletIdentifier(_0) {
|
|
2361
2096
|
return __async(this, arguments, function* ({
|
|
2362
2097
|
walletId,
|
|
2363
|
-
|
|
2364
|
-
newPregenIdentifierType
|
|
2098
|
+
newPregenId
|
|
2365
2099
|
}) {
|
|
2366
2100
|
this.requireApiKey();
|
|
2101
|
+
const [newPregenIdentifierType, newPregenIdentifier] = toPregenTypeAndId(newPregenId);
|
|
2367
2102
|
yield this.ctx.client.updatePregenWallet(walletId, {
|
|
2368
2103
|
pregenIdentifier: newPregenIdentifier,
|
|
2369
2104
|
pregenIdentifierType: newPregenIdentifierType
|
|
@@ -2385,13 +2120,13 @@ const _ParaCore = class _ParaCore {
|
|
|
2385
2120
|
* @returns {boolean} whether the pregen wallet exists
|
|
2386
2121
|
**/
|
|
2387
2122
|
hasPregenWallet(_0) {
|
|
2388
|
-
return __async(this, arguments, function* ({
|
|
2389
|
-
pregenIdentifier,
|
|
2390
|
-
pregenIdentifierType
|
|
2391
|
-
}) {
|
|
2123
|
+
return __async(this, arguments, function* ({ pregenId }) {
|
|
2392
2124
|
this.requireApiKey();
|
|
2393
|
-
const
|
|
2394
|
-
const
|
|
2125
|
+
const [pregenIdentifierType, pregenIdentifier] = toPregenTypeAndId(pregenId);
|
|
2126
|
+
const wallets = yield this.getPregenWallets({ pregenId });
|
|
2127
|
+
const wallet = wallets.find(
|
|
2128
|
+
(w) => w.pregenIdentifier === pregenIdentifier && w.pregenIdentifierType === pregenIdentifierType
|
|
2129
|
+
);
|
|
2395
2130
|
if (!wallet) {
|
|
2396
2131
|
return false;
|
|
2397
2132
|
}
|
|
@@ -2406,13 +2141,10 @@ const _ParaCore = class _ParaCore {
|
|
|
2406
2141
|
* @returns {Promise<WalletEntity[]>} the array of found wallets
|
|
2407
2142
|
**/
|
|
2408
2143
|
getPregenWallets() {
|
|
2409
|
-
return __async(this, arguments, function* ({
|
|
2410
|
-
pregenIdentifier,
|
|
2411
|
-
pregenIdentifierType = !!pregenIdentifier ? "EMAIL" : void 0
|
|
2412
|
-
} = {}) {
|
|
2144
|
+
return __async(this, arguments, function* ({ pregenId } = {}) {
|
|
2413
2145
|
this.requireApiKey();
|
|
2414
2146
|
const res = yield this.ctx.client.getPregenWallets(
|
|
2415
|
-
|
|
2147
|
+
pregenId ? toPregenIds(pregenId) : this.pregenIds,
|
|
2416
2148
|
this.isPortal(),
|
|
2417
2149
|
this.userId
|
|
2418
2150
|
);
|
|
@@ -2420,21 +2152,37 @@ const _ParaCore = class _ParaCore {
|
|
|
2420
2152
|
});
|
|
2421
2153
|
}
|
|
2422
2154
|
createGuestWallets() {
|
|
2423
|
-
return __async(this,
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
wallets
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2155
|
+
return __async(this, null, function* () {
|
|
2156
|
+
let error;
|
|
2157
|
+
if (__privateGet(this, _isCreateGuestWalletsPending)) {
|
|
2158
|
+
error = new Error("Guest wallets creation already in progress");
|
|
2159
|
+
dispatchEvent(ParaEvent.GUEST_WALLETS_CREATED, null, error.message);
|
|
2160
|
+
throw error;
|
|
2161
|
+
}
|
|
2162
|
+
if (this.isGuestMode) {
|
|
2163
|
+
error = new Error("Guest wallets already created");
|
|
2164
|
+
dispatchEvent(ParaEvent.GUEST_WALLETS_CREATED, null, error.message);
|
|
2165
|
+
throw error;
|
|
2166
|
+
}
|
|
2167
|
+
try {
|
|
2168
|
+
__privateSet(this, _isCreateGuestWalletsPending, true);
|
|
2169
|
+
const { supportedWalletTypes } = yield __privateMethod(this, _ParaCore_instances, assertPartner_fn).call(this);
|
|
2170
|
+
const wallets = [];
|
|
2171
|
+
const guestId = newUuid();
|
|
2172
|
+
for (const type of yield this.getTypesToCreate(
|
|
2173
|
+
supportedWalletTypes.filter(({ optional }) => !optional).map(({ type: type2 }) => type2)
|
|
2174
|
+
)) {
|
|
2175
|
+
const wallet = yield __privateMethod(this, _ParaCore_instances, createPregenWallet_fn).call(this, { type, pregenId: { guestId } });
|
|
2176
|
+
wallets.push(wallet);
|
|
2177
|
+
}
|
|
2178
|
+
dispatchEvent(ParaEvent.GUEST_WALLETS_CREATED, wallets);
|
|
2179
|
+
__privateSet(this, _isCreateGuestWalletsPending, false);
|
|
2180
|
+
return wallets;
|
|
2181
|
+
} catch (e) {
|
|
2182
|
+
dispatchEvent(ParaEvent.GUEST_WALLETS_CREATED, null, error == null ? void 0 : error.message);
|
|
2183
|
+
__privateSet(this, _isCreateGuestWalletsPending, false);
|
|
2184
|
+
throw error;
|
|
2435
2185
|
}
|
|
2436
|
-
yield this.setCurrentWalletIds(currentWalletIds);
|
|
2437
|
-
return wallets;
|
|
2438
2186
|
});
|
|
2439
2187
|
}
|
|
2440
2188
|
encodeWalletBase64(wallet) {
|
|
@@ -2472,9 +2220,7 @@ const _ParaCore = class _ParaCore {
|
|
|
2472
2220
|
}
|
|
2473
2221
|
getTransactionReviewUrl(transactionId, timeoutMs) {
|
|
2474
2222
|
return __async(this, null, function* () {
|
|
2475
|
-
const res = yield this.touchSession();
|
|
2476
2223
|
return this.constructPortalUrl("txReview", {
|
|
2477
|
-
partnerId: res.data.partnerId,
|
|
2478
2224
|
pathId: transactionId,
|
|
2479
2225
|
params: {
|
|
2480
2226
|
email: this.email,
|
|
@@ -2483,21 +2229,20 @@ const _ParaCore = class _ParaCore {
|
|
|
2483
2229
|
});
|
|
2484
2230
|
});
|
|
2485
2231
|
}
|
|
2486
|
-
getOnRampTransactionUrl(
|
|
2232
|
+
getOnRampTransactionUrl(_m) {
|
|
2487
2233
|
return __async(this, null, function* () {
|
|
2488
|
-
var
|
|
2234
|
+
var _n = _m, {
|
|
2489
2235
|
purchaseId,
|
|
2490
2236
|
providerKey
|
|
2491
|
-
} =
|
|
2237
|
+
} = _n, walletParams = __objRest(_n, [
|
|
2492
2238
|
"purchaseId",
|
|
2493
2239
|
"providerKey"
|
|
2494
2240
|
]);
|
|
2495
|
-
const
|
|
2241
|
+
const { sessionId } = yield this.touchSession();
|
|
2496
2242
|
const [key, identifier] = extractWalletRef(walletParams);
|
|
2497
2243
|
return this.constructPortalUrl("onRamp", {
|
|
2498
|
-
partnerId: res.data.partnerId,
|
|
2499
2244
|
pathId: purchaseId,
|
|
2500
|
-
sessionId
|
|
2245
|
+
sessionId,
|
|
2501
2246
|
params: {
|
|
2502
2247
|
[key]: identifier,
|
|
2503
2248
|
providerKey,
|
|
@@ -2522,7 +2267,10 @@ const _ParaCore = class _ParaCore {
|
|
|
2522
2267
|
walletId,
|
|
2523
2268
|
messageBase64,
|
|
2524
2269
|
timeoutMs = 3e4,
|
|
2525
|
-
cosmosSignDocBase64
|
|
2270
|
+
cosmosSignDocBase64,
|
|
2271
|
+
isCanceled = () => false,
|
|
2272
|
+
onCancel,
|
|
2273
|
+
onPoll
|
|
2526
2274
|
}) {
|
|
2527
2275
|
this.assertIsValidWalletId(walletId);
|
|
2528
2276
|
const wallet = this.wallets[walletId];
|
|
@@ -2541,11 +2289,12 @@ const _ParaCore = class _ParaCore {
|
|
|
2541
2289
|
dispatchEvent(ParaEvent.SIGN_MESSAGE_EVENT, signRes);
|
|
2542
2290
|
return signRes;
|
|
2543
2291
|
}
|
|
2544
|
-
yield new Promise((resolve) => setTimeout(resolve, constants.POLLING_INTERVAL_MS));
|
|
2545
2292
|
while (true) {
|
|
2546
|
-
if (Date.now() - timeStart > timeoutMs) {
|
|
2293
|
+
if (isCanceled() || Date.now() - timeStart > timeoutMs) {
|
|
2294
|
+
onCancel == null ? void 0 : onCancel();
|
|
2547
2295
|
break;
|
|
2548
2296
|
}
|
|
2297
|
+
yield new Promise((resolve) => setTimeout(resolve, constants.POLLING_INTERVAL_MS));
|
|
2549
2298
|
try {
|
|
2550
2299
|
yield this.ctx.client.getPendingTransaction(this.userId, signRes.pendingTransactionId);
|
|
2551
2300
|
} catch (err) {
|
|
@@ -2555,7 +2304,8 @@ const _ParaCore = class _ParaCore {
|
|
|
2555
2304
|
}
|
|
2556
2305
|
signRes = yield this.signMessageInner({ wallet, signerId, messageBase64, cosmosSignDocBase64 });
|
|
2557
2306
|
if (signRes.pendingTransactionId) {
|
|
2558
|
-
|
|
2307
|
+
onPoll == null ? void 0 : onPoll();
|
|
2308
|
+
continue;
|
|
2559
2309
|
} else {
|
|
2560
2310
|
break;
|
|
2561
2311
|
}
|
|
@@ -2581,7 +2331,7 @@ const _ParaCore = class _ParaCore {
|
|
|
2581
2331
|
}) {
|
|
2582
2332
|
let signRes;
|
|
2583
2333
|
switch (wallet.scheme) {
|
|
2584
|
-
case
|
|
2334
|
+
case "ED25519":
|
|
2585
2335
|
signRes = yield this.platformUtils.ed25519Sign(
|
|
2586
2336
|
this.ctx,
|
|
2587
2337
|
signerId,
|
|
@@ -2599,7 +2349,7 @@ const _ParaCore = class _ParaCore {
|
|
|
2599
2349
|
wallet.signer,
|
|
2600
2350
|
messageBase64,
|
|
2601
2351
|
this.retrieveSessionCookie(),
|
|
2602
|
-
wallet.scheme ===
|
|
2352
|
+
wallet.scheme === "DKLS",
|
|
2603
2353
|
cosmosSignDocBase64
|
|
2604
2354
|
);
|
|
2605
2355
|
break;
|
|
@@ -2620,7 +2370,10 @@ const _ParaCore = class _ParaCore {
|
|
|
2620
2370
|
walletId,
|
|
2621
2371
|
rlpEncodedTxBase64,
|
|
2622
2372
|
chainId,
|
|
2623
|
-
timeoutMs = 3e4
|
|
2373
|
+
timeoutMs = 3e4,
|
|
2374
|
+
isCanceled = () => false,
|
|
2375
|
+
onCancel,
|
|
2376
|
+
onPoll
|
|
2624
2377
|
}) {
|
|
2625
2378
|
this.assertIsValidWalletId(walletId);
|
|
2626
2379
|
const wallet = this.wallets[walletId];
|
|
@@ -2636,7 +2389,7 @@ const _ParaCore = class _ParaCore {
|
|
|
2636
2389
|
rlpEncodedTxBase64,
|
|
2637
2390
|
chainId,
|
|
2638
2391
|
this.retrieveSessionCookie(),
|
|
2639
|
-
wallet.scheme ===
|
|
2392
|
+
wallet.scheme === "DKLS"
|
|
2640
2393
|
);
|
|
2641
2394
|
let timeStart = Date.now();
|
|
2642
2395
|
if (signRes.pendingTransactionId) {
|
|
@@ -2648,11 +2401,12 @@ const _ParaCore = class _ParaCore {
|
|
|
2648
2401
|
dispatchEvent(ParaEvent.SIGN_TRANSACTION_EVENT, signRes);
|
|
2649
2402
|
return signRes;
|
|
2650
2403
|
}
|
|
2651
|
-
yield new Promise((resolve) => setTimeout(resolve, constants.POLLING_INTERVAL_MS));
|
|
2652
2404
|
while (true) {
|
|
2653
|
-
if (Date.now() - timeStart > timeoutMs) {
|
|
2405
|
+
if (isCanceled() || Date.now() - timeStart > timeoutMs) {
|
|
2406
|
+
onCancel == null ? void 0 : onCancel();
|
|
2654
2407
|
break;
|
|
2655
2408
|
}
|
|
2409
|
+
yield new Promise((resolve) => setTimeout(resolve, constants.POLLING_INTERVAL_MS));
|
|
2656
2410
|
try {
|
|
2657
2411
|
yield this.ctx.client.getPendingTransaction(this.userId, signRes.pendingTransactionId);
|
|
2658
2412
|
} catch (err) {
|
|
@@ -2668,10 +2422,11 @@ const _ParaCore = class _ParaCore {
|
|
|
2668
2422
|
rlpEncodedTxBase64,
|
|
2669
2423
|
chainId,
|
|
2670
2424
|
this.retrieveSessionCookie(),
|
|
2671
|
-
wallet.scheme ===
|
|
2425
|
+
wallet.scheme === "DKLS"
|
|
2672
2426
|
);
|
|
2673
2427
|
if (signRes.pendingTransactionId) {
|
|
2674
|
-
|
|
2428
|
+
onPoll == null ? void 0 : onPoll();
|
|
2429
|
+
continue;
|
|
2675
2430
|
} else {
|
|
2676
2431
|
break;
|
|
2677
2432
|
}
|
|
@@ -2688,44 +2443,6 @@ const _ParaCore = class _ParaCore {
|
|
|
2688
2443
|
return signRes;
|
|
2689
2444
|
});
|
|
2690
2445
|
}
|
|
2691
|
-
/**
|
|
2692
|
-
* @deprecated
|
|
2693
|
-
* Sends a transaction.
|
|
2694
|
-
* @param walletId - id of the wallet to send the transaction from.
|
|
2695
|
-
* @param rlpEncodedTxBase64 - rlp encoded tx as base64 string
|
|
2696
|
-
* @param chainId - chain id of the chain the transaction is being sent on.
|
|
2697
|
-
**/
|
|
2698
|
-
sendTransaction(_0) {
|
|
2699
|
-
return __async(this, arguments, function* ({
|
|
2700
|
-
walletId,
|
|
2701
|
-
rlpEncodedTxBase64,
|
|
2702
|
-
chainId
|
|
2703
|
-
}) {
|
|
2704
|
-
this.assertIsValidWalletId(walletId);
|
|
2705
|
-
const wallet = this.wallets[walletId];
|
|
2706
|
-
const signRes = yield this.platformUtils.sendTransaction(
|
|
2707
|
-
this.ctx,
|
|
2708
|
-
this.userId,
|
|
2709
|
-
walletId,
|
|
2710
|
-
this.wallets[walletId].signer,
|
|
2711
|
-
rlpEncodedTxBase64,
|
|
2712
|
-
chainId,
|
|
2713
|
-
this.retrieveSessionCookie(),
|
|
2714
|
-
wallet.scheme === WalletScheme.DKLS
|
|
2715
|
-
);
|
|
2716
|
-
if (signRes.pendingTransactionId) {
|
|
2717
|
-
this.platformUtils.openPopup(
|
|
2718
|
-
yield this.getTransactionReviewUrl(signRes.pendingTransactionId),
|
|
2719
|
-
{ type: PopupType.SIGN_TRANSACTION_REVIEW }
|
|
2720
|
-
);
|
|
2721
|
-
const error = new TransactionReviewError(
|
|
2722
|
-
yield this.getTransactionReviewUrl(signRes.pendingTransactionId)
|
|
2723
|
-
);
|
|
2724
|
-
throw error;
|
|
2725
|
-
}
|
|
2726
|
-
return signRes;
|
|
2727
|
-
});
|
|
2728
|
-
}
|
|
2729
2446
|
isProviderModalDisabled() {
|
|
2730
2447
|
return !!this.disableProviderModal;
|
|
2731
2448
|
}
|
|
@@ -2775,17 +2492,13 @@ const _ParaCore = class _ParaCore {
|
|
|
2775
2492
|
* @param {boolean} excludeSigners - whether or not to exclude the signer from the exported wallets.
|
|
2776
2493
|
* @returns {string} the serialized session
|
|
2777
2494
|
*/
|
|
2778
|
-
exportSession({ excludeSigners } = {}) {
|
|
2495
|
+
exportSession({ excludeSigners = false } = {}) {
|
|
2779
2496
|
const sessionInfo = {
|
|
2780
|
-
|
|
2497
|
+
authInfo: __privateGet(this, _authInfo),
|
|
2781
2498
|
userId: this.userId,
|
|
2782
2499
|
wallets: structuredClone(this.wallets),
|
|
2783
2500
|
currentWalletIds: this.currentWalletIds,
|
|
2784
|
-
sessionCookie: this.
|
|
2785
|
-
phone: this.phone,
|
|
2786
|
-
countryCode: this.countryCode,
|
|
2787
|
-
telegramUserId: this.telegramUserId,
|
|
2788
|
-
farcasterUsername: this.farcasterUsername,
|
|
2501
|
+
sessionCookie: this.retrieveSessionCookie(),
|
|
2789
2502
|
externalWallets: this.externalWallets
|
|
2790
2503
|
};
|
|
2791
2504
|
if (excludeSigners) {
|
|
@@ -2801,12 +2514,11 @@ const _ParaCore = class _ParaCore {
|
|
|
2801
2514
|
*/
|
|
2802
2515
|
importSession(serializedInstanceBase64) {
|
|
2803
2516
|
return __async(this, null, function* () {
|
|
2804
|
-
var _a;
|
|
2517
|
+
var _a, _b;
|
|
2805
2518
|
const serializedInstance = Buffer.from(serializedInstanceBase64, "base64").toString("utf8");
|
|
2806
|
-
const sessionInfo =
|
|
2807
|
-
|
|
2808
|
-
yield this.
|
|
2809
|
-
yield this.setFarcasterUsername(sessionInfo.farcasterUsername);
|
|
2519
|
+
const sessionInfo = jsonParse(serializedInstance);
|
|
2520
|
+
const authInfo = (_a = sessionInfo.authInfo) != null ? _a : __privateMethod(this, _ParaCore_instances, toAuthInfo_fn).call(this, sessionInfo);
|
|
2521
|
+
yield __privateMethod(this, _ParaCore_instances, setAuthInfo_fn).call(this, authInfo);
|
|
2810
2522
|
yield this.setUserId(sessionInfo.userId);
|
|
2811
2523
|
yield this.setWallets(sessionInfo.wallets);
|
|
2812
2524
|
yield this.setExternalWallets(sessionInfo.externalWallets || {});
|
|
@@ -2821,42 +2533,23 @@ const _ParaCore = class _ParaCore {
|
|
|
2821
2533
|
const currentWalletIds = {};
|
|
2822
2534
|
for (const walletId of Object.keys(sessionInfo.wallets)) {
|
|
2823
2535
|
currentWalletIds[sessionInfo.wallets[walletId].type] = [
|
|
2824
|
-
...(
|
|
2536
|
+
...(_b = currentWalletIds[sessionInfo.wallets[walletId].type]) != null ? _b : [],
|
|
2825
2537
|
walletId
|
|
2826
2538
|
];
|
|
2827
2539
|
}
|
|
2828
2540
|
yield this.setCurrentWalletIds(currentWalletIds);
|
|
2829
2541
|
}
|
|
2830
2542
|
this.persistSessionCookie(sessionInfo.sessionCookie);
|
|
2831
|
-
yield this.setPhoneNumber(sessionInfo.phone, sessionInfo.countryCode);
|
|
2832
2543
|
});
|
|
2833
2544
|
}
|
|
2834
|
-
exitAccountCreation() {
|
|
2835
|
-
this.isAwaitingAccountCreation = false;
|
|
2836
|
-
}
|
|
2837
|
-
exitLogin() {
|
|
2838
|
-
this.isAwaitingLogin = false;
|
|
2839
|
-
}
|
|
2840
|
-
exitFarcaster() {
|
|
2841
|
-
this.isAwaitingFarcaster = false;
|
|
2842
|
-
}
|
|
2843
|
-
exitOAuth() {
|
|
2844
|
-
this.isAwaitingOAuth = false;
|
|
2845
|
-
}
|
|
2846
|
-
exitLoops() {
|
|
2847
|
-
this.exitAccountCreation();
|
|
2848
|
-
this.exitLogin();
|
|
2849
|
-
this.exitFarcaster();
|
|
2850
|
-
this.exitOAuth();
|
|
2851
|
-
}
|
|
2852
2545
|
/**
|
|
2853
2546
|
* Retrieves a token to verify the current session.
|
|
2854
2547
|
* @returns {Promise<string>} the ID
|
|
2855
2548
|
**/
|
|
2856
2549
|
getVerificationToken() {
|
|
2857
2550
|
return __async(this, null, function* () {
|
|
2858
|
-
const {
|
|
2859
|
-
return
|
|
2551
|
+
const { sessionLookupId } = yield this.touchSession();
|
|
2552
|
+
return sessionLookupId;
|
|
2860
2553
|
});
|
|
2861
2554
|
}
|
|
2862
2555
|
/**
|
|
@@ -2881,22 +2574,18 @@ const _ParaCore = class _ParaCore {
|
|
|
2881
2574
|
this.currentWalletIds = {};
|
|
2882
2575
|
this.externalWallets = {};
|
|
2883
2576
|
this.loginEncryptionKeyPair = void 0;
|
|
2884
|
-
this
|
|
2885
|
-
this.telegramUserId = void 0;
|
|
2886
|
-
this.phone = void 0;
|
|
2887
|
-
this.countryCode = void 0;
|
|
2577
|
+
__privateSet(this, _authInfo, void 0);
|
|
2888
2578
|
this.userId = void 0;
|
|
2889
2579
|
this.sessionCookie = void 0;
|
|
2890
2580
|
dispatchEvent(ParaEvent.LOGOUT_EVENT, null);
|
|
2891
2581
|
});
|
|
2892
2582
|
}
|
|
2583
|
+
/** @deprecated */
|
|
2893
2584
|
getSupportedCreateAuthMethods() {
|
|
2894
2585
|
return __async(this, null, function* () {
|
|
2895
|
-
const
|
|
2896
|
-
const partnerId = res.data.partnerId;
|
|
2897
|
-
const partnerRes = yield this.ctx.client.getPartner(partnerId);
|
|
2586
|
+
const partner = yield __privateMethod(this, _ParaCore_instances, assertPartner_fn).call(this);
|
|
2898
2587
|
let supportedAuthMethods = /* @__PURE__ */ new Set();
|
|
2899
|
-
for (const authMethod of
|
|
2588
|
+
for (const authMethod of partner.supportedAuthMethods) {
|
|
2900
2589
|
supportedAuthMethods.add(AuthMethod[authMethod]);
|
|
2901
2590
|
}
|
|
2902
2591
|
return supportedAuthMethods;
|
|
@@ -2908,6 +2597,7 @@ const _ParaCore = class _ParaCore {
|
|
|
2908
2597
|
* Doesn't work for all types of logging.
|
|
2909
2598
|
**/
|
|
2910
2599
|
toString() {
|
|
2600
|
+
var _a, _b, _c;
|
|
2911
2601
|
const redactedWallets = Object.keys(this.wallets).reduce(
|
|
2912
2602
|
(acc, walletId) => __spreadProps(__spreadValues({}, acc), {
|
|
2913
2603
|
[walletId]: __spreadProps(__spreadValues({}, this.wallets[walletId]), {
|
|
@@ -2925,16 +2615,15 @@ const _ParaCore = class _ParaCore {
|
|
|
2925
2615
|
{}
|
|
2926
2616
|
);
|
|
2927
2617
|
const obj = {
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
telegramUserId: this.telegramUserId,
|
|
2934
|
-
farcasterUsername: this.farcasterUsername,
|
|
2618
|
+
partnerId: (_a = __privateGet(this, _partner)) == null ? void 0 : _a.id,
|
|
2619
|
+
supportedWalletTypes: (_b = __privateGet(this, _partner)) == null ? void 0 : _b.supportedWalletTypes,
|
|
2620
|
+
cosmosPrefix: (_c = __privateGet(this, _partner)) == null ? void 0 : _c.cosmosPrefix,
|
|
2621
|
+
authInfo: __privateGet(this, _authInfo),
|
|
2622
|
+
isGuestMode: this.isGuestMode,
|
|
2935
2623
|
userId: this.userId,
|
|
2936
2624
|
pregenIds: this.pregenIds,
|
|
2937
2625
|
currentWalletIds: this.currentWalletIds,
|
|
2626
|
+
guestWalletIds: __privateGet(this, _ParaCore_instances, guestWalletIds_get),
|
|
2938
2627
|
wallets: redactedWallets,
|
|
2939
2628
|
externalWallets: redactedExternalWallets,
|
|
2940
2629
|
loginEncryptionKeyPair: this.loginEncryptionKeyPair ? "[REDACTED]" : void 0,
|
|
@@ -2951,25 +2640,201 @@ const _ParaCore = class _ParaCore {
|
|
|
2951
2640
|
};
|
|
2952
2641
|
return `Para ${JSON.stringify(obj, null, 2)}`;
|
|
2953
2642
|
}
|
|
2643
|
+
getNewCredentialAndUrl() {
|
|
2644
|
+
return __async(this, arguments, function* ({
|
|
2645
|
+
authMethod = "PASSKEY",
|
|
2646
|
+
isForNewDevice = false,
|
|
2647
|
+
portalTheme,
|
|
2648
|
+
shorten = false
|
|
2649
|
+
} = {}) {
|
|
2650
|
+
this.assertIsAuthSet();
|
|
2651
|
+
let credentialId, urlType;
|
|
2652
|
+
switch (authMethod) {
|
|
2653
|
+
case "PASSKEY":
|
|
2654
|
+
({
|
|
2655
|
+
data: { id: credentialId }
|
|
2656
|
+
} = yield this.ctx.client.addSessionPublicKey(this.userId, {
|
|
2657
|
+
status: PublicKeyStatus.PENDING,
|
|
2658
|
+
type: PublicKeyType.WEB
|
|
2659
|
+
}));
|
|
2660
|
+
urlType = "createAuth";
|
|
2661
|
+
break;
|
|
2662
|
+
case "PASSWORD":
|
|
2663
|
+
({
|
|
2664
|
+
data: { id: credentialId }
|
|
2665
|
+
} = yield this.ctx.client.addSessionPasswordPublicKey(this.userId, {
|
|
2666
|
+
status: PasswordStatus.PENDING
|
|
2667
|
+
}));
|
|
2668
|
+
urlType = "createPassword";
|
|
2669
|
+
break;
|
|
2670
|
+
}
|
|
2671
|
+
const url = this.isNativePasskey && urlType === "createAuth" ? void 0 : yield this.constructPortalUrl(urlType, {
|
|
2672
|
+
isForNewDevice,
|
|
2673
|
+
pathId: credentialId,
|
|
2674
|
+
portalTheme,
|
|
2675
|
+
shorten
|
|
2676
|
+
});
|
|
2677
|
+
return __spreadValues({ credentialId }, url ? { url } : {});
|
|
2678
|
+
});
|
|
2679
|
+
}
|
|
2680
|
+
/**
|
|
2681
|
+
* Returns a Para Portal URL for logging in with a WebAuth passkey or a password.
|
|
2682
|
+
* @param {Object} opts the options object
|
|
2683
|
+
* @param {String} opts.auth - the user auth to sign up or log in with, in the form ` { email: string } | { phone: `+${number}` } `
|
|
2684
|
+
* @param {boolean} opts.useShortUrls - whether to shorten the generated portal URLs
|
|
2685
|
+
* @param {Theme} opts.portalTheme the Para Portal theme to apply to the password creation URL, if other than the default theme
|
|
2686
|
+
* @returns {SignUpOrLogInResponse} an object in the form of either: `{ stage: 'verify' }` or `{ stage: 'login'; passkeyUrl?: string; passwordUrl?: string; biometricHints?: BiometricLocationHint[] }`
|
|
2687
|
+
*/
|
|
2688
|
+
getLoginUrl(_0) {
|
|
2689
|
+
return __async(this, arguments, function* ({
|
|
2690
|
+
authMethod = "PASSKEY",
|
|
2691
|
+
shorten = false,
|
|
2692
|
+
portalTheme,
|
|
2693
|
+
sessionId
|
|
2694
|
+
}) {
|
|
2695
|
+
if (!sessionId) {
|
|
2696
|
+
sessionId = (yield this.touchSession()).sessionLookupId;
|
|
2697
|
+
}
|
|
2698
|
+
this.assertIsAuthSet();
|
|
2699
|
+
let urlType;
|
|
2700
|
+
switch (authMethod) {
|
|
2701
|
+
case "PASSKEY":
|
|
2702
|
+
urlType = "loginAuth";
|
|
2703
|
+
break;
|
|
2704
|
+
case "PASSWORD":
|
|
2705
|
+
urlType = "loginPassword";
|
|
2706
|
+
break;
|
|
2707
|
+
default:
|
|
2708
|
+
throw new Error(`invalid authentication method: '${authMethod}'`);
|
|
2709
|
+
}
|
|
2710
|
+
return this.constructPortalUrl(urlType, {
|
|
2711
|
+
sessionId,
|
|
2712
|
+
shorten,
|
|
2713
|
+
portalTheme
|
|
2714
|
+
});
|
|
2715
|
+
});
|
|
2716
|
+
}
|
|
2717
|
+
signUpOrLogIn(_o) {
|
|
2718
|
+
return __async(this, null, function* () {
|
|
2719
|
+
var _p = _o, { auth } = _p, urlOptions = __objRest(_p, ["auth"]);
|
|
2720
|
+
const serverAuthState = yield this.ctx.client.signUpOrLogIn(__spreadValues(__spreadValues({}, auth), this.getVerificationEmailProps()));
|
|
2721
|
+
return __privateMethod(this, _ParaCore_instances, prepareAuthState_fn).call(this, serverAuthState, urlOptions);
|
|
2722
|
+
});
|
|
2723
|
+
}
|
|
2724
|
+
verifyNewAccount(_q) {
|
|
2725
|
+
return __async(this, null, function* () {
|
|
2726
|
+
var _r = _q, {
|
|
2727
|
+
verificationCode
|
|
2728
|
+
} = _r, urlOptions = __objRest(_r, [
|
|
2729
|
+
"verificationCode"
|
|
2730
|
+
]);
|
|
2731
|
+
this.assertIsAuthSet(["email", "phone"]);
|
|
2732
|
+
const userId = this.assertUserId();
|
|
2733
|
+
const serverAuthState = yield this.ctx.client.verifyNewAccount(userId, {
|
|
2734
|
+
verificationCode
|
|
2735
|
+
});
|
|
2736
|
+
return __privateMethod(this, _ParaCore_instances, prepareAuthState_fn).call(this, serverAuthState, urlOptions);
|
|
2737
|
+
});
|
|
2738
|
+
}
|
|
2954
2739
|
};
|
|
2955
|
-
|
|
2956
|
-
|
|
2740
|
+
_authInfo = new WeakMap();
|
|
2741
|
+
_partner = new WeakMap();
|
|
2957
2742
|
_ParaCore_instances = new WeakSet();
|
|
2743
|
+
assertPartner_fn = function() {
|
|
2744
|
+
return __async(this, null, function* () {
|
|
2745
|
+
var _a, _b;
|
|
2746
|
+
if (!__privateGet(this, _partner)) {
|
|
2747
|
+
yield this.touchSession();
|
|
2748
|
+
}
|
|
2749
|
+
if (((_a = __privateGet(this, _partner)) == null ? void 0 : _a.cosmosPrefix) && this.ctx.cosmosPrefix !== __privateGet(this, _partner).cosmosPrefix) {
|
|
2750
|
+
this.ctx.cosmosPrefix = (_b = __privateGet(this, _partner)) == null ? void 0 : _b.cosmosPrefix;
|
|
2751
|
+
}
|
|
2752
|
+
return __privateGet(this, _partner);
|
|
2753
|
+
});
|
|
2754
|
+
};
|
|
2755
|
+
guestWalletIds_get = function() {
|
|
2756
|
+
var _a, _b, _c;
|
|
2757
|
+
if (!((_a = __privateGet(this, _partner)) == null ? void 0 : _a.supportedWalletTypes)) {
|
|
2758
|
+
return {};
|
|
2759
|
+
}
|
|
2760
|
+
const guestId = (_c = (_b = this.pregenIds) == null ? void 0 : _b.GUEST_ID) == null ? void 0 : _c[0];
|
|
2761
|
+
return !!guestId ? Object.entries(this.wallets).reduce((acc, [id, wallet]) => {
|
|
2762
|
+
if (wallet.isPregen && !wallet.userId && wallet.pregenIdentifierType === "GUEST_ID" && wallet.pregenIdentifier === guestId) {
|
|
2763
|
+
return __spreadValues(__spreadValues({}, acc), getEquivalentTypes(wallet.type).filter((type) => __privateGet(this, _partner).supportedWalletTypes.some((entry) => entry.type === type)).reduce((acc2, eqType) => {
|
|
2764
|
+
var _a2;
|
|
2765
|
+
return __spreadProps(__spreadValues({}, acc2), { [eqType]: [.../* @__PURE__ */ new Set([...(_a2 = acc2[eqType]) != null ? _a2 : [], id])] });
|
|
2766
|
+
}, {}));
|
|
2767
|
+
}
|
|
2768
|
+
return acc;
|
|
2769
|
+
}, {}) : {};
|
|
2770
|
+
};
|
|
2771
|
+
guestWalletIdsArray_get = function() {
|
|
2772
|
+
return Object.entries(__privateGet(this, _ParaCore_instances, guestWalletIds_get)).reduce((acc, [type, ids]) => {
|
|
2773
|
+
return [...acc, ...ids.map((id) => [id, type])];
|
|
2774
|
+
}, []);
|
|
2775
|
+
};
|
|
2776
|
+
toAuthInfo_fn = function({
|
|
2777
|
+
email,
|
|
2778
|
+
phone,
|
|
2779
|
+
countryCode,
|
|
2780
|
+
farcasterUsername,
|
|
2781
|
+
telegramUserId,
|
|
2782
|
+
externalWalletAddress
|
|
2783
|
+
}) {
|
|
2784
|
+
let auth;
|
|
2785
|
+
switch (true) {
|
|
2786
|
+
case !!email:
|
|
2787
|
+
auth = { email };
|
|
2788
|
+
break;
|
|
2789
|
+
case !!phone:
|
|
2790
|
+
{
|
|
2791
|
+
const validPhone = formatPhoneNumber(phone, countryCode);
|
|
2792
|
+
if (validPhone) auth = { phone: formatPhoneNumber(phone, countryCode) };
|
|
2793
|
+
}
|
|
2794
|
+
break;
|
|
2795
|
+
case !!farcasterUsername:
|
|
2796
|
+
auth = { farcasterUsername };
|
|
2797
|
+
break;
|
|
2798
|
+
case !!telegramUserId:
|
|
2799
|
+
auth = { telegramUserId };
|
|
2800
|
+
break;
|
|
2801
|
+
case !!externalWalletAddress:
|
|
2802
|
+
auth = { externalWalletAddress };
|
|
2803
|
+
break;
|
|
2804
|
+
}
|
|
2805
|
+
return extractAuthInfo(auth);
|
|
2806
|
+
};
|
|
2807
|
+
setAuthInfo_fn = function(authInfo) {
|
|
2808
|
+
return __async(this, null, function* () {
|
|
2809
|
+
__privateSet(this, _authInfo, authInfo);
|
|
2810
|
+
yield this.localStorageSetItem(constants.LOCAL_STORAGE_AUTH_INFO, JSON.stringify(authInfo));
|
|
2811
|
+
yield this.localStorageRemoveItem(constants.LOCAL_STORAGE_EMAIL);
|
|
2812
|
+
yield this.localStorageRemoveItem(constants.LOCAL_STORAGE_PHONE);
|
|
2813
|
+
yield this.localStorageRemoveItem(constants.LOCAL_STORAGE_COUNTRY_CODE);
|
|
2814
|
+
yield this.localStorageRemoveItem(constants.LOCAL_STORAGE_FARCASTER_USERNAME);
|
|
2815
|
+
yield this.localStorageRemoveItem(constants.LOCAL_STORAGE_TELEGRAM_USER_ID);
|
|
2816
|
+
});
|
|
2817
|
+
};
|
|
2818
|
+
getPartner_fn = function(partnerId) {
|
|
2819
|
+
return __async(this, null, function* () {
|
|
2820
|
+
const res = yield this.ctx.client.getPartner(partnerId);
|
|
2821
|
+
__privateSet(this, _partner, res.data.partner);
|
|
2822
|
+
return __privateGet(this, _partner);
|
|
2823
|
+
});
|
|
2824
|
+
};
|
|
2958
2825
|
createPregenWallet_fn = function(opts) {
|
|
2959
2826
|
return __async(this, null, function* () {
|
|
2960
2827
|
var _a, _b;
|
|
2961
|
-
const {
|
|
2962
|
-
|
|
2963
|
-
pregenIdentifier,
|
|
2964
|
-
pregenIdentifierType = "EMAIL"
|
|
2965
|
-
} = opts;
|
|
2828
|
+
const { supportedWalletTypes } = yield __privateMethod(this, _ParaCore_instances, assertPartner_fn).call(this);
|
|
2829
|
+
const { type: _type = (_a = supportedWalletTypes.find(({ optional }) => !optional)) == null ? void 0 : _a.type, pregenId } = opts;
|
|
2966
2830
|
this.requireApiKey();
|
|
2967
2831
|
const walletType = yield this.assertIsValidWalletType(
|
|
2968
|
-
_type != null ? _type : (_b =
|
|
2832
|
+
_type != null ? _type : (_b = supportedWalletTypes.find(({ optional }) => !optional)) == null ? void 0 : _b.type
|
|
2969
2833
|
);
|
|
2834
|
+
const [pregenIdentifierType, pregenIdentifier] = toPregenTypeAndId(pregenId);
|
|
2970
2835
|
let keygenRes;
|
|
2971
2836
|
switch (walletType) {
|
|
2972
|
-
case
|
|
2837
|
+
case "SOLANA":
|
|
2973
2838
|
keygenRes = yield this.platformUtils.ed25519PreKeygen(
|
|
2974
2839
|
this.ctx,
|
|
2975
2840
|
pregenIdentifier,
|
|
@@ -2993,7 +2858,7 @@ createPregenWallet_fn = function(opts) {
|
|
|
2993
2858
|
this.wallets[walletId] = {
|
|
2994
2859
|
id: walletId,
|
|
2995
2860
|
signer,
|
|
2996
|
-
scheme: walletType ===
|
|
2861
|
+
scheme: walletType === "SOLANA" ? "ED25519" : "DKLS",
|
|
2997
2862
|
type: walletType,
|
|
2998
2863
|
isPregen: true,
|
|
2999
2864
|
pregenIdentifier,
|
|
@@ -3004,6 +2869,114 @@ createPregenWallet_fn = function(opts) {
|
|
|
3004
2869
|
return this.wallets[walletId];
|
|
3005
2870
|
});
|
|
3006
2871
|
};
|
|
2872
|
+
_isCreateGuestWalletsPending = new WeakMap();
|
|
2873
|
+
prepareAuthState_fn = function(_0) {
|
|
2874
|
+
return __async(this, arguments, function* (serverAuthState, opts = {}) {
|
|
2875
|
+
if (!opts.sessionLookupId && serverAuthState.stage === "login") {
|
|
2876
|
+
opts.sessionLookupId = yield __privateMethod(this, _ParaCore_instances, prepareLogin_fn).call(this);
|
|
2877
|
+
}
|
|
2878
|
+
const { auth, externalWallet, userId, displayName, pfpUrl, username } = serverAuthState;
|
|
2879
|
+
const authInfo = __spreadValues(__spreadValues({}, extractAuthInfo(auth, { isRequired: true })), Object.fromEntries(
|
|
2880
|
+
Object.entries({
|
|
2881
|
+
displayName,
|
|
2882
|
+
pfpUrl,
|
|
2883
|
+
username,
|
|
2884
|
+
externalWallet
|
|
2885
|
+
}).filter(([_, v]) => !!v)
|
|
2886
|
+
));
|
|
2887
|
+
yield __privateMethod(this, _ParaCore_instances, setAuthInfo_fn).call(this, authInfo);
|
|
2888
|
+
yield this.assertIsAuthSet();
|
|
2889
|
+
if (!!externalWallet) {
|
|
2890
|
+
yield this.setExternalWallet(externalWallet);
|
|
2891
|
+
}
|
|
2892
|
+
if (!!userId) {
|
|
2893
|
+
yield this.setUserId(userId);
|
|
2894
|
+
}
|
|
2895
|
+
let authState;
|
|
2896
|
+
switch (serverAuthState.stage) {
|
|
2897
|
+
case "verify":
|
|
2898
|
+
authState = serverAuthState;
|
|
2899
|
+
break;
|
|
2900
|
+
case "login":
|
|
2901
|
+
authState = yield __privateMethod(this, _ParaCore_instances, prepareLoginState_fn).call(this, serverAuthState, __spreadProps(__spreadValues({}, opts), { sessionLookupId: opts.sessionLookupId }));
|
|
2902
|
+
break;
|
|
2903
|
+
case "signup":
|
|
2904
|
+
authState = yield __privateMethod(this, _ParaCore_instances, prepareSignUpState_fn).call(this, serverAuthState, opts);
|
|
2905
|
+
break;
|
|
2906
|
+
}
|
|
2907
|
+
return authState;
|
|
2908
|
+
});
|
|
2909
|
+
};
|
|
2910
|
+
prepareLogin_fn = function() {
|
|
2911
|
+
return __async(this, null, function* () {
|
|
2912
|
+
yield this.logout();
|
|
2913
|
+
const { sessionLookupId } = yield this.touchSession(true);
|
|
2914
|
+
if (!this.loginEncryptionKeyPair) {
|
|
2915
|
+
yield this.setLoginEncryptionKeyPair();
|
|
2916
|
+
}
|
|
2917
|
+
return sessionLookupId;
|
|
2918
|
+
});
|
|
2919
|
+
};
|
|
2920
|
+
prepareLoginState_fn = function(_0, _1) {
|
|
2921
|
+
return __async(this, arguments, function* (loginState, {
|
|
2922
|
+
useShortUrls: shorten = false,
|
|
2923
|
+
portalTheme,
|
|
2924
|
+
sessionLookupId
|
|
2925
|
+
}) {
|
|
2926
|
+
const _a = loginState, { loginAuthMethods } = _a, authState = __objRest(_a, ["loginAuthMethods"]);
|
|
2927
|
+
return __spreadValues(__spreadValues(__spreadValues({}, authState), !this.isNativePasskey && loginAuthMethods.includes(AuthMethod.PASSKEY) ? {
|
|
2928
|
+
passkeyUrl: yield this.getLoginUrl({ sessionId: sessionLookupId, shorten, portalTheme }),
|
|
2929
|
+
passkeyKnownDeviceUrl: yield this.constructPortalUrl("loginAuth", {
|
|
2930
|
+
sessionId: sessionLookupId,
|
|
2931
|
+
newDevice: {
|
|
2932
|
+
sessionId: sessionLookupId,
|
|
2933
|
+
encryptionKey: getPublicKeyHex(this.loginEncryptionKeyPair)
|
|
2934
|
+
},
|
|
2935
|
+
shorten,
|
|
2936
|
+
portalTheme
|
|
2937
|
+
})
|
|
2938
|
+
} : {}), loginAuthMethods.includes(AuthMethod.PASSWORD) ? {
|
|
2939
|
+
passwordUrl: yield this.constructPortalUrl("loginPassword", {
|
|
2940
|
+
sessionId: sessionLookupId,
|
|
2941
|
+
shorten,
|
|
2942
|
+
portalTheme
|
|
2943
|
+
})
|
|
2944
|
+
} : {});
|
|
2945
|
+
});
|
|
2946
|
+
};
|
|
2947
|
+
prepareSignUpState_fn = function(_0, _1) {
|
|
2948
|
+
return __async(this, arguments, function* (serverSignupState, { useShortUrls: shorten = false, portalTheme }) {
|
|
2949
|
+
const _a = serverSignupState, { signupAuthMethods } = _a, authState = __objRest(_a, ["signupAuthMethods"]);
|
|
2950
|
+
const [isPasskey, isPassword] = [
|
|
2951
|
+
signupAuthMethods.includes(AuthMethod.PASSKEY),
|
|
2952
|
+
signupAuthMethods.includes(AuthMethod.PASSWORD)
|
|
2953
|
+
];
|
|
2954
|
+
if (!isPasskey && !isPassword) {
|
|
2955
|
+
throw new Error(
|
|
2956
|
+
"No supported authentication methods found. Please ensure you have enabled either WebAuth passkeys or passwords in your Developer Portal settings."
|
|
2957
|
+
);
|
|
2958
|
+
}
|
|
2959
|
+
const signupState = authState;
|
|
2960
|
+
if (isPasskey) {
|
|
2961
|
+
const { url: passkeyUrl, credentialId: passkeyId } = yield this.getNewCredentialAndUrl({
|
|
2962
|
+
authMethod: "PASSKEY",
|
|
2963
|
+
shorten
|
|
2964
|
+
});
|
|
2965
|
+
if (passkeyUrl) signupState.passkeyUrl = passkeyUrl;
|
|
2966
|
+
signupState.passkeyId = passkeyId;
|
|
2967
|
+
}
|
|
2968
|
+
if (isPassword) {
|
|
2969
|
+
const { url: passwordUrl, credentialId: passwordId } = yield this.getNewCredentialAndUrl({
|
|
2970
|
+
authMethod: "PASSWORD",
|
|
2971
|
+
portalTheme,
|
|
2972
|
+
shorten
|
|
2973
|
+
});
|
|
2974
|
+
signupState.passwordUrl = passwordUrl;
|
|
2975
|
+
signupState.passwordId = passwordId;
|
|
2976
|
+
}
|
|
2977
|
+
return signupState;
|
|
2978
|
+
});
|
|
2979
|
+
};
|
|
3007
2980
|
_ParaCore.version = constants.PARA_CORE_VERSION;
|
|
3008
2981
|
let ParaCore = _ParaCore;
|
|
3009
2982
|
export {
|