@getpara/core-sdk 2.0.0-fc.3 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/ParaCore.js +1119 -319
- package/dist/cjs/constants.js +10 -1
- package/dist/cjs/index.js +23 -3
- package/dist/cjs/shares/KeyContainer.js +3 -3
- package/dist/cjs/shares/enclave.js +287 -0
- package/dist/cjs/shares/shareDistribution.js +16 -1
- package/dist/cjs/transmission/transmissionUtils.js +4 -3
- package/dist/cjs/types/{theme.js → assets.js} +2 -2
- package/dist/cjs/types/coreApi.js +7 -2
- package/dist/cjs/types/events.js +2 -0
- package/dist/cjs/types/index.js +0 -21
- package/dist/cjs/types/popup.js +1 -0
- package/dist/cjs/utils/config.js +108 -0
- package/dist/cjs/utils/index.js +5 -1
- package/dist/cjs/utils/onRamps.js +2 -3
- package/dist/cjs/utils/url.js +10 -9
- package/dist/cjs/utils/wallet.js +18 -0
- package/dist/cjs/{types/onRamps.js → utils/window.js} +17 -12
- package/dist/esm/ParaCore.js +1123 -323
- package/dist/esm/constants.js +7 -1
- package/dist/esm/index.js +24 -5
- package/dist/esm/shares/KeyContainer.js +3 -3
- package/dist/esm/shares/enclave.js +247 -0
- package/dist/esm/shares/shareDistribution.js +16 -1
- package/dist/esm/transmission/transmissionUtils.js +4 -3
- package/dist/esm/types/coreApi.js +7 -2
- package/dist/esm/types/events.js +2 -0
- package/dist/esm/types/index.js +0 -16
- package/dist/esm/types/popup.js +1 -0
- package/dist/esm/utils/config.js +86 -0
- package/dist/esm/utils/index.js +2 -0
- package/dist/esm/utils/onRamps.js +2 -3
- package/dist/esm/utils/url.js +10 -9
- package/dist/esm/utils/wallet.js +17 -0
- package/dist/esm/utils/window.js +16 -0
- package/dist/types/ParaCore.d.ts +91 -20
- package/dist/types/PlatformUtils.d.ts +2 -1
- package/dist/types/constants.d.ts +3 -0
- package/dist/types/index.d.ts +6 -4
- package/dist/types/shares/enclave.d.ts +83 -0
- package/dist/types/shares/shareDistribution.d.ts +4 -2
- package/dist/types/types/assets.d.ts +14 -0
- package/dist/types/types/config.d.ts +3 -2
- package/dist/types/types/coreApi.d.ts +47 -7
- package/dist/types/types/events.d.ts +7 -2
- package/dist/types/types/index.d.ts +0 -4
- package/dist/types/types/methods.d.ts +57 -12
- package/dist/types/types/popup.d.ts +2 -1
- package/dist/types/types/wallet.d.ts +8 -4
- package/dist/types/utils/config.d.ts +7 -0
- package/dist/types/utils/index.d.ts +2 -0
- package/dist/types/utils/onRamps.d.ts +9 -10
- package/dist/types/utils/url.d.ts +3 -3
- package/dist/types/utils/wallet.d.ts +1 -0
- package/dist/types/utils/window.d.ts +2 -0
- package/package.json +3 -3
- package/dist/cjs/types/recovery.js +0 -34
- package/dist/esm/types/onRamps.js +0 -11
- package/dist/esm/types/recovery.js +0 -12
- package/dist/types/types/onRamps.d.ts +0 -10
- package/dist/types/types/recovery.d.ts +0 -7
- package/dist/types/types/theme.d.ts +0 -12
- /package/dist/esm/types/{theme.js → assets.js} +0 -0
package/dist/cjs/ParaCore.js
CHANGED
|
@@ -99,7 +99,8 @@ var import_recovery = require("./shares/recovery.js");
|
|
|
99
99
|
var import_utils2 = require("./utils/index.js");
|
|
100
100
|
var import_errors = require("./errors.js");
|
|
101
101
|
var constants = __toESM(require("./constants.js"));
|
|
102
|
-
var
|
|
102
|
+
var import_enclave = require("./shares/enclave.js");
|
|
103
|
+
var _authInfo, _ParaCore_instances, assertPartner_fn, guestWalletIds_get, guestWalletIdsArray_get, toAuthInfo_fn, setAuthInfo_fn, getPartner_fn, assertIsLinkingAccount_fn, assertIsLinkingAccountOrStart_fn, getOAuthUrl_fn, waitForLoginProcess_fn, createPregenWallet_fn, _isCreateGuestWalletsPending, prepareAuthState_fn, prepareDoneState_fn, prepareVerificationState_fn, prepareLoginState_fn, prepareSignUpState_fn;
|
|
103
104
|
if (typeof global !== "undefined") {
|
|
104
105
|
global.Buffer = global.Buffer || import_buffer.Buffer;
|
|
105
106
|
} else if (typeof window !== "undefined") {
|
|
@@ -111,24 +112,20 @@ if (typeof global !== "undefined") {
|
|
|
111
112
|
}
|
|
112
113
|
const { pki, jsbn } = import_node_forge.default;
|
|
113
114
|
const _ParaCore = class _ParaCore {
|
|
114
|
-
|
|
115
|
-
* Constructs a new `ParaCore` instance.
|
|
116
|
-
* @param env - `Environment` to use.
|
|
117
|
-
* @param apiKey - API key to use.
|
|
118
|
-
* @param opts - Additional constructor options; see `ConstructorOpts`.
|
|
119
|
-
* @returns - A new ParaCore instance.
|
|
120
|
-
*/
|
|
121
|
-
constructor(env, apiKey, opts) {
|
|
115
|
+
constructor(envOrApiKey, apiKeyOrOpts, opts) {
|
|
122
116
|
__privateAdd(this, _ParaCore_instances);
|
|
117
|
+
this.popupWindow = null;
|
|
123
118
|
__privateAdd(this, _authInfo);
|
|
119
|
+
this.isSwitchingWallets = false;
|
|
124
120
|
this.isNativePasskey = false;
|
|
125
121
|
this.isReady = false;
|
|
126
|
-
__privateAdd(this, _partner);
|
|
127
122
|
this.accountLinkInProgress = void 0;
|
|
123
|
+
this.isEnclaveUser = false;
|
|
128
124
|
this.isAwaitingAccountCreation = false;
|
|
129
125
|
this.isAwaitingLogin = false;
|
|
130
126
|
this.isAwaitingFarcaster = false;
|
|
131
127
|
this.isAwaitingOAuth = false;
|
|
128
|
+
this.isWorkerInitialized = false;
|
|
132
129
|
/**
|
|
133
130
|
* 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.
|
|
134
131
|
*/
|
|
@@ -137,20 +134,34 @@ const _ParaCore = class _ParaCore {
|
|
|
137
134
|
* Wallets associated with the `ParaCore` instance.
|
|
138
135
|
*/
|
|
139
136
|
this.externalWallets = {};
|
|
137
|
+
this.onRampPopup = void 0;
|
|
138
|
+
this.nonPersistedStorageKeys = [];
|
|
140
139
|
this.localStorageGetItem = (key) => {
|
|
141
|
-
|
|
140
|
+
var _a;
|
|
141
|
+
if (!((_a = this.nonPersistedStorageKeys) != null ? _a : []).includes(key)) {
|
|
142
|
+
return this.platformUtils.localStorage.get(key);
|
|
143
|
+
}
|
|
142
144
|
};
|
|
143
145
|
this.localStorageSetItem = (key, value) => {
|
|
144
|
-
|
|
146
|
+
var _a;
|
|
147
|
+
if (!((_a = this.nonPersistedStorageKeys) != null ? _a : []).includes(key)) {
|
|
148
|
+
return this.platformUtils.localStorage.set(key, value);
|
|
149
|
+
}
|
|
145
150
|
};
|
|
146
151
|
this.localStorageRemoveItem = (key) => {
|
|
147
152
|
return this.platformUtils.localStorage.removeItem(key);
|
|
148
153
|
};
|
|
149
154
|
this.sessionStorageGetItem = (key) => {
|
|
150
|
-
|
|
155
|
+
var _a;
|
|
156
|
+
if (!((_a = this.nonPersistedStorageKeys) != null ? _a : []).includes(key)) {
|
|
157
|
+
return this.platformUtils.sessionStorage.get(key);
|
|
158
|
+
}
|
|
151
159
|
};
|
|
152
160
|
this.sessionStorageSetItem = (key, value) => {
|
|
153
|
-
|
|
161
|
+
var _a;
|
|
162
|
+
if (!((_a = this.nonPersistedStorageKeys) != null ? _a : []).includes(key)) {
|
|
163
|
+
return this.platformUtils.sessionStorage.set(key, value);
|
|
164
|
+
}
|
|
154
165
|
};
|
|
155
166
|
this.sessionStorageRemoveItem = (key) => {
|
|
156
167
|
return this.platformUtils.sessionStorage.removeItem(key);
|
|
@@ -158,16 +169,29 @@ const _ParaCore = class _ParaCore {
|
|
|
158
169
|
this.retrieveSessionCookie = () => {
|
|
159
170
|
return this.sessionCookie;
|
|
160
171
|
};
|
|
172
|
+
this.retrieveEnclaveJwt = () => {
|
|
173
|
+
return this.enclaveJwt;
|
|
174
|
+
};
|
|
175
|
+
this.retrieveEnclaveRefreshJwt = () => {
|
|
176
|
+
return this.enclaveRefreshJwt;
|
|
177
|
+
};
|
|
161
178
|
/**
|
|
162
179
|
* Remove all local storage and prefixed session storage.
|
|
163
180
|
* @param {'local' | 'session' | 'secure' | 'all'} type - Type of storage to clear. Defaults to 'all'.
|
|
164
181
|
*/
|
|
165
182
|
this.clearStorage = (type = "all") => __async(this, null, function* () {
|
|
166
183
|
const isAll = type === "all";
|
|
167
|
-
(isAll || type === "local")
|
|
168
|
-
|
|
184
|
+
if (isAll || type === "local") {
|
|
185
|
+
this.platformUtils.localStorage.clear(constants.PREFIX);
|
|
186
|
+
this.platformUtils.localStorage.clear(constants.PARA_PREFIX);
|
|
187
|
+
}
|
|
188
|
+
if (isAll || type === "session") {
|
|
189
|
+
this.platformUtils.sessionStorage.clear(constants.PREFIX);
|
|
190
|
+
this.platformUtils.sessionStorage.clear(constants.PARA_PREFIX);
|
|
191
|
+
}
|
|
169
192
|
if ((isAll || type === "secure") && this.platformUtils.secureStorage) {
|
|
170
193
|
this.platformUtils.secureStorage.clear(constants.PREFIX);
|
|
194
|
+
this.platformUtils.secureStorage.clear(constants.PARA_PREFIX);
|
|
171
195
|
}
|
|
172
196
|
});
|
|
173
197
|
this.trackError = (methodName, err) => __async(this, null, function* () {
|
|
@@ -209,6 +233,7 @@ const _ParaCore = class _ParaCore {
|
|
|
209
233
|
this.updateWalletIdsFromStorage();
|
|
210
234
|
this.updateSessionCookieFromStorage();
|
|
211
235
|
this.updateLoginEncryptionKeyPairFromStorage();
|
|
236
|
+
this.updateEnclaveJwtFromStorage();
|
|
212
237
|
};
|
|
213
238
|
this.updateAuthInfoFromStorage = () => {
|
|
214
239
|
var _a;
|
|
@@ -228,6 +253,10 @@ const _ParaCore = class _ParaCore {
|
|
|
228
253
|
}
|
|
229
254
|
__privateSet(this, _authInfo, authInfo);
|
|
230
255
|
};
|
|
256
|
+
this.updateEnclaveJwtFromStorage = () => {
|
|
257
|
+
this.enclaveJwt = this.localStorageGetItem(constants.LOCAL_STORAGE_ENCLAVE_JWT) || this.sessionStorageGetItem(constants.LOCAL_STORAGE_ENCLAVE_JWT) || void 0;
|
|
258
|
+
this.enclaveRefreshJwt = this.localStorageGetItem(constants.LOCAL_STORAGE_ENCLAVE_REFRESH_JWT) || this.sessionStorageGetItem(constants.LOCAL_STORAGE_ENCLAVE_REFRESH_JWT) || void 0;
|
|
259
|
+
};
|
|
231
260
|
this.updateUserIdFromStorage = () => {
|
|
232
261
|
this.userId = this.localStorageGetItem(constants.LOCAL_STORAGE_USER_ID) || void 0;
|
|
233
262
|
};
|
|
@@ -288,6 +317,16 @@ const _ParaCore = class _ParaCore {
|
|
|
288
317
|
const _externalWallets = JSON.parse(stringExternalWallets || "{}");
|
|
289
318
|
this.setExternalWallets(_externalWallets);
|
|
290
319
|
};
|
|
320
|
+
this.initializeWorker = () => __async(this, null, function* () {
|
|
321
|
+
if (!this.isWorkerInitialized && !this.ctx.disableWebSockets && !this.ctx.disableWorkers && !this.isPortal()) {
|
|
322
|
+
try {
|
|
323
|
+
this.isWorkerInitialized = true;
|
|
324
|
+
yield this.platformUtils.initializeWorker(this.ctx);
|
|
325
|
+
} catch (e) {
|
|
326
|
+
this.devLog("error initializing worker:", e);
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
});
|
|
291
330
|
/**
|
|
292
331
|
* Creates several new wallets with the desired types. If no types are provided, this method
|
|
293
332
|
* will create one for each of the non-optional types specified in the instance's `supportedWalletTypes`
|
|
@@ -304,8 +343,29 @@ const _ParaCore = class _ParaCore {
|
|
|
304
343
|
}) {
|
|
305
344
|
return (yield this.ctx.client.getWalletBalance({ walletId, rpcUrl })).balance;
|
|
306
345
|
});
|
|
307
|
-
|
|
308
|
-
|
|
346
|
+
let env, apiKey;
|
|
347
|
+
const actualArgs = Array.from(arguments).filter((arg) => arg !== void 0);
|
|
348
|
+
const actualArgumentCount = actualArgs.length;
|
|
349
|
+
if (actualArgumentCount === 1) {
|
|
350
|
+
if (Object.values(import_types.Environment).includes(envOrApiKey)) {
|
|
351
|
+
throw new Error("A Para API key is required.");
|
|
352
|
+
}
|
|
353
|
+
env = _ParaCore.resolveEnvironment(void 0, actualArgs[0]);
|
|
354
|
+
apiKey = actualArgs[0];
|
|
355
|
+
opts = void 0;
|
|
356
|
+
} else if (actualArgumentCount === 2) {
|
|
357
|
+
if (typeof apiKeyOrOpts === "object" && apiKeyOrOpts !== null) {
|
|
358
|
+
env = _ParaCore.resolveEnvironment(void 0, envOrApiKey);
|
|
359
|
+
apiKey = envOrApiKey;
|
|
360
|
+
opts = apiKeyOrOpts;
|
|
361
|
+
} else {
|
|
362
|
+
env = _ParaCore.resolveEnvironment(envOrApiKey, apiKeyOrOpts);
|
|
363
|
+
apiKey = apiKeyOrOpts;
|
|
364
|
+
opts = void 0;
|
|
365
|
+
}
|
|
366
|
+
} else {
|
|
367
|
+
env = _ParaCore.resolveEnvironment(envOrApiKey, apiKeyOrOpts);
|
|
368
|
+
apiKey = apiKeyOrOpts;
|
|
309
369
|
}
|
|
310
370
|
if (!opts) opts = {};
|
|
311
371
|
let isE2E = false;
|
|
@@ -348,18 +408,41 @@ const _ParaCore = class _ParaCore {
|
|
|
348
408
|
cookie
|
|
349
409
|
);
|
|
350
410
|
};
|
|
411
|
+
this.persistEnclaveJwt = (jwt) => {
|
|
412
|
+
this.enclaveJwt = jwt;
|
|
413
|
+
(opts.useSessionStorage ? this.sessionStorageSetItem : this.localStorageSetItem)(
|
|
414
|
+
constants.LOCAL_STORAGE_ENCLAVE_JWT,
|
|
415
|
+
jwt
|
|
416
|
+
);
|
|
417
|
+
};
|
|
418
|
+
this.persistEnclaveRefreshJwt = (refreshJwt) => {
|
|
419
|
+
this.enclaveRefreshJwt = refreshJwt;
|
|
420
|
+
(opts.useSessionStorage ? this.sessionStorageSetItem : this.localStorageSetItem)(
|
|
421
|
+
constants.LOCAL_STORAGE_ENCLAVE_REFRESH_JWT,
|
|
422
|
+
refreshJwt
|
|
423
|
+
);
|
|
424
|
+
};
|
|
425
|
+
const client = (0, import_userManagementClient.initClient)({
|
|
426
|
+
env,
|
|
427
|
+
version: _ParaCore.version,
|
|
428
|
+
apiKey,
|
|
429
|
+
partnerId: this.isPortal(env) ? opts.portalPartnerId : void 0,
|
|
430
|
+
useFetchAdapter: !!opts.disableWorkers,
|
|
431
|
+
retrieveSessionCookie: this.retrieveSessionCookie,
|
|
432
|
+
persistSessionCookie: this.persistSessionCookie
|
|
433
|
+
});
|
|
434
|
+
const enclaveClient = new import_enclave.EnclaveClient({
|
|
435
|
+
userManagementClient: client,
|
|
436
|
+
retrieveJwt: this.retrieveEnclaveJwt,
|
|
437
|
+
persistJwt: this.persistEnclaveJwt,
|
|
438
|
+
retrieveRefreshJwt: this.retrieveEnclaveRefreshJwt,
|
|
439
|
+
persistRefreshJwt: this.persistEnclaveRefreshJwt
|
|
440
|
+
});
|
|
351
441
|
this.ctx = {
|
|
352
442
|
env,
|
|
353
443
|
apiKey,
|
|
354
|
-
client
|
|
355
|
-
|
|
356
|
-
version: _ParaCore.version,
|
|
357
|
-
apiKey,
|
|
358
|
-
partnerId: this.isPortal(env) ? opts.portalPartnerId : void 0,
|
|
359
|
-
useFetchAdapter: !!opts.disableWorkers,
|
|
360
|
-
retrieveSessionCookie: this.retrieveSessionCookie,
|
|
361
|
-
persistSessionCookie: this.persistSessionCookie
|
|
362
|
-
}),
|
|
444
|
+
client,
|
|
445
|
+
enclaveClient,
|
|
363
446
|
disableWorkers: opts.disableWorkers,
|
|
364
447
|
offloadMPCComputationURL: opts.offloadMPCComputationURL,
|
|
365
448
|
useLocalFiles: opts.useLocalFiles,
|
|
@@ -394,6 +477,9 @@ const _ParaCore = class _ParaCore {
|
|
|
394
477
|
]);
|
|
395
478
|
}
|
|
396
479
|
}
|
|
480
|
+
setModalError(_error) {
|
|
481
|
+
return;
|
|
482
|
+
}
|
|
397
483
|
get authInfo() {
|
|
398
484
|
return __privateGet(this, _authInfo);
|
|
399
485
|
}
|
|
@@ -423,7 +509,12 @@ const _ParaCore = class _ParaCore {
|
|
|
423
509
|
} else if (this.isExternalWalletWithVerification) {
|
|
424
510
|
return "VERIFICATION";
|
|
425
511
|
} else if (!!Object.keys(this.externalWallets).length) {
|
|
426
|
-
|
|
512
|
+
const hasEmbeddedWallets = Object.keys(this.wallets).some((id) => !this.wallets[id].isExternal);
|
|
513
|
+
if (hasEmbeddedWallets) {
|
|
514
|
+
return "NONE";
|
|
515
|
+
} else {
|
|
516
|
+
return "CONNECTION_ONLY";
|
|
517
|
+
}
|
|
427
518
|
}
|
|
428
519
|
return "NONE";
|
|
429
520
|
}
|
|
@@ -453,11 +544,19 @@ const _ParaCore = class _ParaCore {
|
|
|
453
544
|
}
|
|
454
545
|
get partnerId() {
|
|
455
546
|
var _a;
|
|
456
|
-
return (_a =
|
|
547
|
+
return (_a = this.partner) == null ? void 0 : _a.id;
|
|
548
|
+
}
|
|
549
|
+
get partnerName() {
|
|
550
|
+
var _a;
|
|
551
|
+
return (_a = this.partner) == null ? void 0 : _a.displayName;
|
|
552
|
+
}
|
|
553
|
+
get partnerLogo() {
|
|
554
|
+
var _a;
|
|
555
|
+
return (_a = this.partner) == null ? void 0 : _a.logoUrl;
|
|
457
556
|
}
|
|
458
557
|
get currentWalletIdsArray() {
|
|
459
558
|
var _a, _b;
|
|
460
|
-
return ((_b = (_a =
|
|
559
|
+
return ((_b = (_a = this.partner) == null ? void 0 : _a.supportedWalletTypes) != null ? _b : Object.keys(this.currentWalletIds).map((type) => ({ type }))).reduce(
|
|
461
560
|
(acc, { type }) => {
|
|
462
561
|
var _a2;
|
|
463
562
|
return [
|
|
@@ -497,23 +596,23 @@ const _ParaCore = class _ParaCore {
|
|
|
497
596
|
}
|
|
498
597
|
get isNoWalletConfig() {
|
|
499
598
|
var _a;
|
|
500
|
-
return !!((_a =
|
|
599
|
+
return !!((_a = this.partner) == null ? void 0 : _a.supportedWalletTypes) && this.partner.supportedWalletTypes.length === 0;
|
|
501
600
|
}
|
|
502
601
|
get supportedWalletTypes() {
|
|
503
602
|
var _a, _b;
|
|
504
|
-
return (_b = (_a =
|
|
603
|
+
return (_b = (_a = this.partner) == null ? void 0 : _a.supportedWalletTypes) != null ? _b : [];
|
|
505
604
|
}
|
|
506
605
|
get cosmosPrefix() {
|
|
507
606
|
var _a;
|
|
508
|
-
return (_a =
|
|
607
|
+
return (_a = this.partner) == null ? void 0 : _a.cosmosPrefix;
|
|
509
608
|
}
|
|
510
609
|
get supportedAccountLinks() {
|
|
511
610
|
var _a, _b;
|
|
512
|
-
return (_b = (_a =
|
|
611
|
+
return (_b = (_a = this.partner) == null ? void 0 : _a.supportedAccountLinks) != null ? _b : [...import_user_management_client.LINKED_ACCOUNT_TYPES];
|
|
513
612
|
}
|
|
514
613
|
get isWalletTypeEnabled() {
|
|
515
614
|
var _a;
|
|
516
|
-
return (((_a =
|
|
615
|
+
return (((_a = this.partner) == null ? void 0 : _a.supportedWalletTypes) || []).reduce((acc, { type }) => {
|
|
517
616
|
return __spreadProps(__spreadValues({}, acc), { [type]: true });
|
|
518
617
|
}, {});
|
|
519
618
|
}
|
|
@@ -543,9 +642,7 @@ const _ParaCore = class _ParaCore {
|
|
|
543
642
|
};
|
|
544
643
|
}
|
|
545
644
|
isPortal(envOverride) {
|
|
546
|
-
|
|
547
|
-
if (typeof window === "undefined") return false;
|
|
548
|
-
return !!((_a = window.location) == null ? void 0 : _a.host) && (0, import_utils2.getPortalBaseURL)(envOverride ? { env: envOverride } : this.ctx).includes(window.location.host);
|
|
645
|
+
return (0, import_utils2.isPortal)(this.ctx, envOverride);
|
|
549
646
|
}
|
|
550
647
|
isParaConnect() {
|
|
551
648
|
var _a;
|
|
@@ -562,7 +659,7 @@ const _ParaCore = class _ParaCore {
|
|
|
562
659
|
}
|
|
563
660
|
isWalletSupported(wallet) {
|
|
564
661
|
var _a, _b;
|
|
565
|
-
return !((_a =
|
|
662
|
+
return !((_a = this.partner) == null ? void 0 : _a.supportedWalletTypes) || (0, import_utils2.isWalletSupported)((_b = this.partner.supportedWalletTypes.map(({ type }) => type)) != null ? _b : [], wallet);
|
|
566
663
|
}
|
|
567
664
|
isWalletOwned(wallet) {
|
|
568
665
|
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;
|
|
@@ -593,7 +690,7 @@ const _ParaCore = class _ParaCore {
|
|
|
593
690
|
} else if (!isOwned && !isUnclaimed) {
|
|
594
691
|
error = `wallet with id ${wallet == null ? void 0 : wallet.id} is not owned by the current user`;
|
|
595
692
|
} else if (!this.isWalletSupported(wallet)) {
|
|
596
|
-
error = `wallet with id ${wallet.id} and type ${wallet.type} is not supported, supported types are: ${(((_b =
|
|
693
|
+
error = `wallet with id ${wallet.id} and type ${wallet.type} is not supported, supported types are: ${(((_b = this.partner) == null ? void 0 : _b.supportedWalletTypes) || []).map(({ type }) => type).join(", ")}`;
|
|
597
694
|
} else if (types && (!(0, import_utils2.getEquivalentTypes)(types).includes(wallet == null ? void 0 : wallet.type) || isOwned && !types.some((type) => {
|
|
598
695
|
var _a2, _b2;
|
|
599
696
|
return (_b2 = (_a2 = this.currentWalletIds) == null ? void 0 : _a2[type]) == null ? void 0 : _b2.includes(walletId);
|
|
@@ -611,6 +708,9 @@ const _ParaCore = class _ParaCore {
|
|
|
611
708
|
}
|
|
612
709
|
return true;
|
|
613
710
|
}
|
|
711
|
+
truncateAddress(...args) {
|
|
712
|
+
return (0, import_utils2.truncateAddress)(args[0], args[1], __spreadValues({ prefix: this.cosmosPrefix }, args[2] || {}));
|
|
713
|
+
}
|
|
614
714
|
/**
|
|
615
715
|
* Returns the formatted address for the desired wallet ID, depending on your app settings.
|
|
616
716
|
* @param {string} walletId the ID of the wallet address to display.
|
|
@@ -624,7 +724,7 @@ const _ParaCore = class _ParaCore {
|
|
|
624
724
|
if (this.externalWallets[walletId]) {
|
|
625
725
|
const wallet2 = this.externalWallets[walletId];
|
|
626
726
|
return options.truncate ? (0, import_utils2.truncateAddress)(wallet2.address, wallet2.type, {
|
|
627
|
-
prefix: (_a =
|
|
727
|
+
prefix: (_a = this.partner) == null ? void 0 : _a.cosmosPrefix,
|
|
628
728
|
targetLength: options.targetLength
|
|
629
729
|
}) : wallet2.address;
|
|
630
730
|
}
|
|
@@ -636,7 +736,7 @@ const _ParaCore = class _ParaCore {
|
|
|
636
736
|
let prefix;
|
|
637
737
|
switch (wallet.type) {
|
|
638
738
|
case "COSMOS":
|
|
639
|
-
prefix = (_d = (_c = options.cosmosPrefix) != null ? _c : (_b =
|
|
739
|
+
prefix = (_d = (_c = options.cosmosPrefix) != null ? _c : (_b = this.partner) == null ? void 0 : _b.cosmosPrefix) != null ? _d : "cosmos";
|
|
640
740
|
str = (0, import_utils2.getCosmosAddress)(wallet.publicKey, prefix);
|
|
641
741
|
break;
|
|
642
742
|
default:
|
|
@@ -669,30 +769,56 @@ const _ParaCore = class _ParaCore {
|
|
|
669
769
|
}
|
|
670
770
|
constructPortalUrl(_0) {
|
|
671
771
|
return __async(this, arguments, function* (type, opts = {}) {
|
|
672
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
673
|
-
const [
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
772
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
773
|
+
const [
|
|
774
|
+
isCreate,
|
|
775
|
+
isLogin,
|
|
776
|
+
isOnRamp,
|
|
777
|
+
isOAuth,
|
|
778
|
+
isOAuthCallback,
|
|
779
|
+
isTelegramLogin,
|
|
780
|
+
isFarcasterLogin,
|
|
781
|
+
isAddNewCredential,
|
|
782
|
+
isSwitchWallets,
|
|
783
|
+
isExportPrivateKey
|
|
784
|
+
] = [
|
|
785
|
+
["createAuth", "createPassword", "createPIN"].includes(type),
|
|
786
|
+
["loginAuth", "loginPassword", "loginPIN", "loginOTP", "switchWallets", "loginExternalWallet"].includes(type),
|
|
787
|
+
type === "onRamp",
|
|
788
|
+
type === "oAuth",
|
|
789
|
+
type === "oAuthCallback",
|
|
790
|
+
["telegramLogin", "telegramLoginVerify"].includes(type),
|
|
791
|
+
type === "loginFarcaster",
|
|
792
|
+
type === "addNewCredential",
|
|
793
|
+
type === "switchWallets",
|
|
794
|
+
type === "exportPrivateKey"
|
|
677
795
|
];
|
|
796
|
+
if (isOAuth && !opts.oAuthMethod) {
|
|
797
|
+
throw new Error("oAuthMethod is required for oAuth portal URLs");
|
|
798
|
+
}
|
|
678
799
|
if (isCreate || isLogin) {
|
|
679
800
|
this.assertIsAuthSet();
|
|
680
801
|
}
|
|
681
802
|
let sessionId = opts.sessionId;
|
|
682
|
-
if ((isLogin || isOnRamp) && !sessionId) {
|
|
803
|
+
if ((isLogin || isOnRamp || isTelegramLogin || isFarcasterLogin || isExportPrivateKey) && !sessionId) {
|
|
683
804
|
const session = yield this.touchSession(true);
|
|
684
805
|
sessionId = session.sessionId;
|
|
685
806
|
}
|
|
686
807
|
if (!this.loginEncryptionKeyPair) {
|
|
687
808
|
yield this.setLoginEncryptionKeyPair();
|
|
688
809
|
}
|
|
689
|
-
const
|
|
810
|
+
const shouldUseLegacyPortalUrl = opts.useLegacyUrl || !!opts.addNewCredentialPasskeyId || type === "loginAuth";
|
|
811
|
+
const base = type === "onRamp" || isTelegramLogin ? (0, import_utils2.getPortalBaseURL)(this.ctx, isTelegramLogin, false, shouldUseLegacyPortalUrl) : yield this.getPortalURL(shouldUseLegacyPortalUrl);
|
|
690
812
|
let path;
|
|
691
813
|
switch (type) {
|
|
692
814
|
case "createPassword": {
|
|
693
815
|
path = `/web/users/${this.userId}/passwords/${opts.pathId}`;
|
|
694
816
|
break;
|
|
695
817
|
}
|
|
818
|
+
case "createPIN": {
|
|
819
|
+
path = `/web/users/${this.userId}/pin/${opts.pathId}`;
|
|
820
|
+
break;
|
|
821
|
+
}
|
|
696
822
|
case "createAuth": {
|
|
697
823
|
path = `/web/users/${this.userId}/biometrics/${opts.pathId}`;
|
|
698
824
|
break;
|
|
@@ -705,18 +831,62 @@ const _ParaCore = class _ParaCore {
|
|
|
705
831
|
path = "/web/biometrics/login";
|
|
706
832
|
break;
|
|
707
833
|
}
|
|
834
|
+
case "loginPIN": {
|
|
835
|
+
path = "/web/pin/login";
|
|
836
|
+
break;
|
|
837
|
+
}
|
|
708
838
|
case "txReview": {
|
|
709
839
|
path = `/web/users/${this.userId}/transaction-review/${opts.pathId}`;
|
|
710
840
|
break;
|
|
711
841
|
}
|
|
712
842
|
case "onRamp": {
|
|
713
|
-
path = `/web/users/${this.userId}/on-ramp-transaction/${opts.pathId}`;
|
|
843
|
+
path = `/web/users/${this.userId}/on-ramp-transaction/v2/${opts.pathId}`;
|
|
844
|
+
break;
|
|
845
|
+
}
|
|
846
|
+
case "telegramLoginVerify": {
|
|
847
|
+
path = `/auth/telegram/verify`;
|
|
714
848
|
break;
|
|
715
849
|
}
|
|
716
850
|
case "telegramLogin": {
|
|
717
851
|
path = `/auth/telegram`;
|
|
718
852
|
break;
|
|
719
853
|
}
|
|
854
|
+
case "oAuth": {
|
|
855
|
+
path = `/auth/${opts.oAuthMethod.toLowerCase()}`;
|
|
856
|
+
break;
|
|
857
|
+
}
|
|
858
|
+
case "oAuthCallback": {
|
|
859
|
+
path = `/auth/${opts.oAuthMethod.toLowerCase()}/callback`;
|
|
860
|
+
break;
|
|
861
|
+
}
|
|
862
|
+
case "loginOTP": {
|
|
863
|
+
path = "/auth/otp";
|
|
864
|
+
break;
|
|
865
|
+
}
|
|
866
|
+
case "loginFarcaster": {
|
|
867
|
+
path = "/auth/farcaster";
|
|
868
|
+
break;
|
|
869
|
+
}
|
|
870
|
+
case "switchWallets": {
|
|
871
|
+
path = `/auth/wallets`;
|
|
872
|
+
break;
|
|
873
|
+
}
|
|
874
|
+
case "addNewCredential": {
|
|
875
|
+
path = "/auth/add-new-credential";
|
|
876
|
+
break;
|
|
877
|
+
}
|
|
878
|
+
case "exportPrivateKey": {
|
|
879
|
+
path = `/web/users/${this.userId}/private-key/${opts.pathId}`;
|
|
880
|
+
break;
|
|
881
|
+
}
|
|
882
|
+
case "loginExternalWallet": {
|
|
883
|
+
path = "/auth/external-wallet";
|
|
884
|
+
break;
|
|
885
|
+
}
|
|
886
|
+
case "connectExternalWallet": {
|
|
887
|
+
path = "/auth/connect-external-wallet";
|
|
888
|
+
break;
|
|
889
|
+
}
|
|
720
890
|
default: {
|
|
721
891
|
throw new Error(`invalid URL type ${type}`);
|
|
722
892
|
}
|
|
@@ -735,25 +905,28 @@ const _ParaCore = class _ParaCore {
|
|
|
735
905
|
encryptionKey: (0, import_utils.getPublicKeyHex)(this.loginEncryptionKeyPair),
|
|
736
906
|
sessionId
|
|
737
907
|
};
|
|
738
|
-
const params = __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({
|
|
908
|
+
const params = __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadProps(__spreadValues({
|
|
739
909
|
apiKey: this.ctx.apiKey,
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
910
|
+
origin: typeof window !== "undefined" ? window.location.origin : void 0,
|
|
911
|
+
partnerId: partner == null ? void 0 : partner.id
|
|
912
|
+
}, typeof window !== "undefined" && ((_b = window.location) == null ? void 0 : _b.origin) ? { origin: window.location.origin } : {}), {
|
|
913
|
+
portalFont: ((_c = opts.portalTheme) == null ? void 0 : _c.font) || ((_d = this.portalTheme) == null ? void 0 : _d.font) || (partner == null ? void 0 : partner.font),
|
|
914
|
+
portalBorderRadius: ((_e = opts.portalTheme) == null ? void 0 : _e.borderRadius) || ((_f = this.portalTheme) == null ? void 0 : _f.borderRadius),
|
|
915
|
+
portalThemeMode: ((_g = opts.portalTheme) == null ? void 0 : _g.mode) || ((_h = this.portalTheme) == null ? void 0 : _h.mode) || (partner == null ? void 0 : partner.themeMode),
|
|
916
|
+
portalAccentColor: ((_i = opts.portalTheme) == null ? void 0 : _i.accentColor) || ((_j = this.portalTheme) == null ? void 0 : _j.accentColor) || (partner == null ? void 0 : partner.accentColor),
|
|
917
|
+
portalForegroundColor: ((_k = opts.portalTheme) == null ? void 0 : _k.foregroundColor) || ((_l = this.portalTheme) == null ? void 0 : _l.foregroundColor) || (partner == null ? void 0 : partner.foregroundColor),
|
|
918
|
+
portalBackgroundColor: ((_m = opts.portalTheme) == null ? void 0 : _m.backgroundColor) || ((_n = this.portalTheme) == null ? void 0 : _n.backgroundColor) || (partner == null ? void 0 : partner.backgroundColor) || this.portalBackgroundColor,
|
|
747
919
|
portalPrimaryButtonColor: this.portalPrimaryButtonColor,
|
|
748
920
|
portalTextColor: this.portalTextColor,
|
|
749
921
|
portalPrimaryButtonTextColor: this.portalPrimaryButtonTextColor,
|
|
750
922
|
isForNewDevice: opts.isForNewDevice ? opts.isForNewDevice.toString() : void 0
|
|
751
|
-
}, isCreate || isLogin ? __spreadProps(__spreadValues({
|
|
923
|
+
}), this.authInfo && (isCreate || isLogin || isAddNewCredential || isOAuthCallback || isSwitchWallets || isExportPrivateKey) ? __spreadProps(__spreadValues({
|
|
752
924
|
authInfo: JSON.stringify(this.authInfo)
|
|
753
925
|
}, (0, import_user_management_client.isPhone)(this.authInfo.auth) ? (0, import_utils2.splitPhoneNumber)(this.authInfo.auth.phone) : this.authInfo.auth), {
|
|
754
926
|
pfpUrl: this.authInfo.pfpUrl,
|
|
755
|
-
displayName: this.authInfo.displayName
|
|
756
|
-
|
|
927
|
+
displayName: this.authInfo.displayName,
|
|
928
|
+
userId: this.userId
|
|
929
|
+
}) : {}), isOnRamp ? { email: this.email } : {}), isLogin || isOAuth || isOAuthCallback || isTelegramLogin || isFarcasterLogin || isAddNewCredential ? __spreadProps(__spreadValues({
|
|
757
930
|
sessionId: thisDevice.sessionId,
|
|
758
931
|
encryptionKey: thisDevice.encryptionKey
|
|
759
932
|
}, opts.newDevice ? {
|
|
@@ -761,23 +934,93 @@ const _ParaCore = class _ParaCore {
|
|
|
761
934
|
newDeviceEncryptionKey: opts.newDevice.encryptionKey
|
|
762
935
|
} : {}), {
|
|
763
936
|
pregenIds: JSON.stringify(this.pregenIds)
|
|
764
|
-
}) : {}),
|
|
937
|
+
}) : {}), isOAuth || isOAuthCallback || isFarcasterLogin ? {
|
|
938
|
+
appScheme: opts.appScheme
|
|
939
|
+
} : {}), isTelegramLogin ? { isEmbed: "true" } : {}), isSwitchWallets ? __spreadValues(__spreadValues({}, this.currentWalletIds ? { currentWalletIds: JSON.stringify(this.currentWalletIds) } : {}), this.userId ? { userId: this.userId } : {}) : {}), opts.params || {}), isAddNewCredential ? __spreadProps(__spreadValues({}, opts.addNewCredentialType && { addNewCredentialType: opts.addNewCredentialType.toString() }), {
|
|
940
|
+
addNewCredentialPasskeyId: opts.addNewCredentialPasskeyId,
|
|
941
|
+
addNewCredentialPasswordId: opts.addNewCredentialPasswordId
|
|
942
|
+
}) : {}), isLogin && {
|
|
943
|
+
// Prior versions won't have this param which will skip the upgrade prompt
|
|
944
|
+
isBasicLoginUpgradeVersion: "true"
|
|
945
|
+
}), isExportPrivateKey ? {
|
|
946
|
+
sessionId: thisDevice.sessionId
|
|
947
|
+
} : {});
|
|
765
948
|
const url = (0, import_utils2.constructUrl)({ base, path, params });
|
|
766
949
|
if (opts.shorten) {
|
|
767
|
-
return (0, import_utils2.shortenUrl)(this.ctx, url);
|
|
950
|
+
return yield (0, import_utils2.shortenUrl)(this.ctx, url, shouldUseLegacyPortalUrl);
|
|
768
951
|
}
|
|
769
952
|
return url;
|
|
770
953
|
});
|
|
771
954
|
}
|
|
955
|
+
static resolveEnvironment(env, apiKey) {
|
|
956
|
+
var _a;
|
|
957
|
+
if (!apiKey) {
|
|
958
|
+
throw new Error("A Para API key is required.");
|
|
959
|
+
}
|
|
960
|
+
if (apiKey.includes("_")) {
|
|
961
|
+
const validEnvironmentPrefixes = Object.values(import_types.Environment);
|
|
962
|
+
const envPrefix = (_a = apiKey.split("_")[0]) == null ? void 0 : _a.toUpperCase();
|
|
963
|
+
const hasValidPrefix = validEnvironmentPrefixes.some((envValue) => envValue === envPrefix);
|
|
964
|
+
if (!hasValidPrefix) {
|
|
965
|
+
throw new Error(`Invalid API key environment prefix.`);
|
|
966
|
+
}
|
|
967
|
+
return envPrefix;
|
|
968
|
+
}
|
|
969
|
+
if (!env) {
|
|
970
|
+
throw new Error("Environment parameter is required.");
|
|
971
|
+
}
|
|
972
|
+
return env;
|
|
973
|
+
}
|
|
772
974
|
touchSession(regenerate = false) {
|
|
773
975
|
return __async(this, null, function* () {
|
|
774
|
-
var _a, _b, _c;
|
|
976
|
+
var _a, _b, _c, _d, _e;
|
|
977
|
+
if (!this.isWorkerInitialized) {
|
|
978
|
+
this.initializeWorker();
|
|
979
|
+
}
|
|
775
980
|
if (!this.isReady) {
|
|
776
981
|
yield this.ready();
|
|
777
982
|
}
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
yield
|
|
983
|
+
let session;
|
|
984
|
+
try {
|
|
985
|
+
session = yield this.ctx.client.touchSession(regenerate);
|
|
986
|
+
} catch (error) {
|
|
987
|
+
this.handleTouchSessionError(error);
|
|
988
|
+
throw error;
|
|
989
|
+
}
|
|
990
|
+
if (!this.partner || ((_a = this.partner) == null ? void 0 : _a.id) !== session.partnerId || !(0, import_utils2.supportedWalletTypesEq)(((_b = this.partner) == null ? void 0 : _b.supportedWalletTypes) || [], session.supportedWalletTypes) || (((_c = this.partner) == null ? void 0 : _c.cosmosPrefix) || "cosmos") !== session.cosmosPrefix) {
|
|
991
|
+
if (!session.partnerId && !this.isPortal()) {
|
|
992
|
+
this.displayModalError(
|
|
993
|
+
`Invalid API Key. Please ensure you have a valid API key for the current environment: ${(_d = this.ctx.env) == null ? void 0 : _d.toUpperCase()}.`
|
|
994
|
+
);
|
|
995
|
+
console.error(`
|
|
996
|
+
\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501
|
|
997
|
+
\u{1F6A8} PARA SDK CONFIGURATION ERROR \u{1F6A8}
|
|
998
|
+
|
|
999
|
+
INVALID API KEY FOR CONFIGURED ENVIRONMENT
|
|
1000
|
+
|
|
1001
|
+
Your API key does not match the configured environment. This usually means:
|
|
1002
|
+
|
|
1003
|
+
1. You're using a production API key with a development environment
|
|
1004
|
+
2. You're using a development API key with a production environment
|
|
1005
|
+
3. Your API key is invalid or has been regenerated
|
|
1006
|
+
|
|
1007
|
+
SOLUTION:
|
|
1008
|
+
\u2022 Verify your API key at: https://developer.getpara.com
|
|
1009
|
+
\u2022 If your API key doesn't contain an environment prefix, ensure your API key is the correct key for your target environment
|
|
1010
|
+
|
|
1011
|
+
Current Environment: ${this.ctx.env}
|
|
1012
|
+
API Key Prefix: ${((_e = this.ctx.apiKey) == null ? void 0 : _e.split("_")[0].toUpperCase()) || "None"}
|
|
1013
|
+
|
|
1014
|
+
Need help? Visit: https://docs.getpara.com or contact support
|
|
1015
|
+
\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501
|
|
1016
|
+
`);
|
|
1017
|
+
throw new Error("Invalid API Key.");
|
|
1018
|
+
} else {
|
|
1019
|
+
yield __privateMethod(this, _ParaCore_instances, getPartner_fn).call(this, session.partnerId);
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
if (session.currentWalletIds && !(0, import_utils2.currentWalletIdsEq)(session.currentWalletIds, this.currentWalletIds)) {
|
|
1023
|
+
yield this.setCurrentWalletIds(session.currentWalletIds);
|
|
781
1024
|
}
|
|
782
1025
|
return session;
|
|
783
1026
|
});
|
|
@@ -876,8 +1119,35 @@ const _ParaCore = class _ParaCore {
|
|
|
876
1119
|
return __privateGet(this, _authInfo);
|
|
877
1120
|
});
|
|
878
1121
|
}
|
|
879
|
-
|
|
880
|
-
|
|
1122
|
+
/**
|
|
1123
|
+
* Display an error message in the modal (if available)
|
|
1124
|
+
* @internal
|
|
1125
|
+
*/
|
|
1126
|
+
displayModalError(error) {
|
|
1127
|
+
if (this.ctx.env !== import_types.Environment.PROD) {
|
|
1128
|
+
this.setModalError(error);
|
|
1129
|
+
}
|
|
1130
|
+
}
|
|
1131
|
+
/**
|
|
1132
|
+
* Handle specific touchSession errors with user-friendly messages
|
|
1133
|
+
* @private
|
|
1134
|
+
*/
|
|
1135
|
+
handleTouchSessionError(error) {
|
|
1136
|
+
const errorStr = String(error);
|
|
1137
|
+
const errorMessage = error instanceof Error ? error.message : "";
|
|
1138
|
+
if (errorStr.includes("blocked by CORS policy") && errorStr.includes("Access-Control-Allow-Origin")) {
|
|
1139
|
+
this.displayModalError("Request rate limit reached. Please wait a couple of minutes and try again.");
|
|
1140
|
+
return;
|
|
1141
|
+
}
|
|
1142
|
+
if (error.status === 403 && errorMessage.includes("origin not authorized")) {
|
|
1143
|
+
this.displayModalError(
|
|
1144
|
+
"The current origin is not allowed. Update your allowed origins in the Para developer portal to allow the current origin."
|
|
1145
|
+
);
|
|
1146
|
+
return;
|
|
1147
|
+
}
|
|
1148
|
+
}
|
|
1149
|
+
assertUserId({ allowGuestMode = false } = {}) {
|
|
1150
|
+
if (!this.userId || !allowGuestMode && this.isGuestMode) {
|
|
881
1151
|
throw new Error("no userId is set");
|
|
882
1152
|
}
|
|
883
1153
|
return this.userId;
|
|
@@ -935,11 +1205,59 @@ const _ParaCore = class _ParaCore {
|
|
|
935
1205
|
*/
|
|
936
1206
|
setExternalWallet(externalWallet) {
|
|
937
1207
|
return __async(this, null, function* () {
|
|
1208
|
+
const { id: partnerId, supportedWalletTypes } = yield __privateMethod(this, _ParaCore_instances, assertPartner_fn).call(this);
|
|
938
1209
|
this.externalWallets = (Array.isArray(externalWallet) ? externalWallet : [externalWallet]).reduce(
|
|
1210
|
+
(acc, {
|
|
1211
|
+
partnerId: wPartnerId,
|
|
1212
|
+
address,
|
|
1213
|
+
type,
|
|
1214
|
+
provider,
|
|
1215
|
+
providerId,
|
|
1216
|
+
addressBech32,
|
|
1217
|
+
withFullParaAuth,
|
|
1218
|
+
isConnectionOnly,
|
|
1219
|
+
withVerification
|
|
1220
|
+
}) => {
|
|
1221
|
+
if (partnerId === wPartnerId && supportedWalletTypes.some(({ type: supportedType }) => supportedType === type)) {
|
|
1222
|
+
return __spreadProps(__spreadValues({}, acc), {
|
|
1223
|
+
[address]: {
|
|
1224
|
+
id: address,
|
|
1225
|
+
partnerId,
|
|
1226
|
+
address: addressBech32 != null ? addressBech32 : address,
|
|
1227
|
+
type,
|
|
1228
|
+
name: provider,
|
|
1229
|
+
isExternal: true,
|
|
1230
|
+
isExternalWithParaAuth: withFullParaAuth,
|
|
1231
|
+
externalProviderId: providerId,
|
|
1232
|
+
signer: "",
|
|
1233
|
+
isExternalConnectionOnly: isConnectionOnly,
|
|
1234
|
+
isExternalWithVerification: withVerification
|
|
1235
|
+
}
|
|
1236
|
+
});
|
|
1237
|
+
}
|
|
1238
|
+
return acc;
|
|
1239
|
+
},
|
|
1240
|
+
{}
|
|
1241
|
+
), this.setExternalWallets(this.externalWallets);
|
|
1242
|
+
(0, import_utils2.dispatchEvent)(import_types.ParaEvent.EXTERNAL_WALLET_CHANGE_EVENT, null);
|
|
1243
|
+
});
|
|
1244
|
+
}
|
|
1245
|
+
addExternalWallets(externalWallets) {
|
|
1246
|
+
return __async(this, null, function* () {
|
|
1247
|
+
const { id: partnerId, supportedWalletTypes } = yield __privateMethod(this, _ParaCore_instances, assertPartner_fn).call(this);
|
|
1248
|
+
this.externalWallets = __spreadValues(__spreadValues({}, Object.entries(this.externalWallets).reduce((acc, [address, wallet]) => {
|
|
1249
|
+
if (partnerId === wallet.partnerId && supportedWalletTypes.some(({ type }) => type === wallet.type)) {
|
|
1250
|
+
return __spreadProps(__spreadValues({}, acc), {
|
|
1251
|
+
[address]: wallet
|
|
1252
|
+
});
|
|
1253
|
+
}
|
|
1254
|
+
return acc;
|
|
1255
|
+
}, {})), externalWallets.reduce(
|
|
939
1256
|
(acc, { address, type, provider, providerId, addressBech32, withFullParaAuth, isConnectionOnly, withVerification }) => {
|
|
940
1257
|
return __spreadProps(__spreadValues({}, acc), {
|
|
941
1258
|
[address]: {
|
|
942
1259
|
id: address,
|
|
1260
|
+
partnerId,
|
|
943
1261
|
address: addressBech32 != null ? addressBech32 : address,
|
|
944
1262
|
type,
|
|
945
1263
|
name: provider,
|
|
@@ -953,7 +1271,7 @@ const _ParaCore = class _ParaCore {
|
|
|
953
1271
|
});
|
|
954
1272
|
},
|
|
955
1273
|
{}
|
|
956
|
-
);
|
|
1274
|
+
));
|
|
957
1275
|
this.setExternalWallets(this.externalWallets);
|
|
958
1276
|
(0, import_utils2.dispatchEvent)(import_types.ParaEvent.EXTERNAL_WALLET_CHANGE_EVENT, null);
|
|
959
1277
|
});
|
|
@@ -984,12 +1302,16 @@ const _ParaCore = class _ParaCore {
|
|
|
984
1302
|
}
|
|
985
1303
|
/**
|
|
986
1304
|
* Sets the external wallets associated with the `ParaCore` instance.
|
|
987
|
-
* @param externalWallets - External wallets to set.
|
|
1305
|
+
* @param externalWallets - External wallets to set, or a function that modifies the current wallets.
|
|
988
1306
|
*/
|
|
989
1307
|
setExternalWallets(externalWallets) {
|
|
990
1308
|
return __async(this, null, function* () {
|
|
991
|
-
|
|
992
|
-
|
|
1309
|
+
if (typeof externalWallets === "function") {
|
|
1310
|
+
this.externalWallets = externalWallets(this.externalWallets);
|
|
1311
|
+
} else {
|
|
1312
|
+
this.externalWallets = externalWallets;
|
|
1313
|
+
}
|
|
1314
|
+
yield this.localStorageSetItem(constants.LOCAL_STORAGE_EXTERNAL_WALLETS, JSON.stringify(this.externalWallets));
|
|
993
1315
|
});
|
|
994
1316
|
}
|
|
995
1317
|
/**
|
|
@@ -1158,14 +1480,27 @@ const _ParaCore = class _ParaCore {
|
|
|
1158
1480
|
...[...this.currentWalletIdsArray, ...__privateGet(this, _ParaCore_instances, guestWalletIdsArray_get)].map(([address, type]) => [address, type, false]).map(([id, type]) => {
|
|
1159
1481
|
const wallet = this.findWallet(id, type);
|
|
1160
1482
|
if (!wallet) return null;
|
|
1483
|
+
const name = wallet.name;
|
|
1484
|
+
const address = this.getDisplayAddress(id, { addressType: type });
|
|
1485
|
+
const addressShort = this.getDisplayAddress(id, { addressType: type, truncate: true });
|
|
1161
1486
|
return {
|
|
1162
1487
|
id: wallet.id,
|
|
1488
|
+
partner: wallet.partner,
|
|
1163
1489
|
type,
|
|
1164
|
-
address
|
|
1165
|
-
name
|
|
1490
|
+
address,
|
|
1491
|
+
name,
|
|
1492
|
+
addressShort,
|
|
1493
|
+
displayName: name != null ? name : addressShort,
|
|
1494
|
+
ensName: wallet.ensName,
|
|
1495
|
+
ensAvatar: wallet.ensAvatar
|
|
1166
1496
|
};
|
|
1167
1497
|
}).filter((obj) => obj !== null),
|
|
1168
|
-
...Object.values((_a = this.externalWallets) != null ? _a : {})
|
|
1498
|
+
...Object.values((_a = this.externalWallets) != null ? _a : {}).map((wallet) => {
|
|
1499
|
+
return __spreadProps(__spreadValues({}, wallet), {
|
|
1500
|
+
addressShort: (0, import_utils2.truncateAddress)(wallet.address, wallet.type, { prefix: this.cosmosPrefix }),
|
|
1501
|
+
displayName: wallet.externalProviderId
|
|
1502
|
+
});
|
|
1503
|
+
})
|
|
1169
1504
|
];
|
|
1170
1505
|
}
|
|
1171
1506
|
/**
|
|
@@ -1227,9 +1562,9 @@ const _ParaCore = class _ParaCore {
|
|
|
1227
1562
|
* @param partnerId: string - id of the partner to get the portal URL for
|
|
1228
1563
|
* @returns - portal URL
|
|
1229
1564
|
*/
|
|
1230
|
-
getPortalURL() {
|
|
1565
|
+
getPortalURL(isLegacy) {
|
|
1231
1566
|
return __async(this, null, function* () {
|
|
1232
|
-
return (yield this.getPartnerURL()) || (0, import_utils2.getPortalBaseURL)(this.ctx);
|
|
1567
|
+
return (yield this.getPartnerURL()) || (0, import_utils2.getPortalBaseURL)(this.ctx, false, false, isLegacy);
|
|
1233
1568
|
});
|
|
1234
1569
|
}
|
|
1235
1570
|
/**
|
|
@@ -1264,13 +1599,13 @@ const _ParaCore = class _ParaCore {
|
|
|
1264
1599
|
return __async(this, null, function* () {
|
|
1265
1600
|
const res = yield this.isPortal() || this.isParaConnect() ? this.ctx.client.getAllWallets(this.userId) : this.ctx.client.getWallets(this.userId, true);
|
|
1266
1601
|
return res.data.wallets.filter(
|
|
1267
|
-
(wallet) => !!wallet.address && (this.isParaConnect() || !this.isParaConnect() && this.isWalletSupported((0, import_utils2.entityToWallet)(wallet)))
|
|
1602
|
+
(wallet) => !!wallet.address && wallet.sharesPersisted && (this.isParaConnect() || !this.isParaConnect() && this.isWalletSupported((0, import_utils2.entityToWallet)(wallet)))
|
|
1268
1603
|
);
|
|
1269
1604
|
});
|
|
1270
1605
|
}
|
|
1271
1606
|
populateWalletAddresses() {
|
|
1272
1607
|
return __async(this, null, function* () {
|
|
1273
|
-
const res = yield this.ctx.client.getWallets(this.userId, true);
|
|
1608
|
+
const res = yield (this.isPortal() ? this.ctx.client.getAllWallets : this.ctx.client.getWallets)(this.userId, true);
|
|
1274
1609
|
const wallets = res.data.wallets;
|
|
1275
1610
|
wallets.forEach((entity) => {
|
|
1276
1611
|
if (this.wallets[entity.id]) {
|
|
@@ -1301,13 +1636,28 @@ const _ParaCore = class _ParaCore {
|
|
|
1301
1636
|
loginExternalWallet(_a) {
|
|
1302
1637
|
return __async(this, null, function* () {
|
|
1303
1638
|
var _b = _a, {
|
|
1304
|
-
externalWallet
|
|
1639
|
+
externalWallet,
|
|
1640
|
+
chainId,
|
|
1641
|
+
uri
|
|
1305
1642
|
} = _b, urlOptions = __objRest(_b, [
|
|
1306
|
-
"externalWallet"
|
|
1643
|
+
"externalWallet",
|
|
1644
|
+
"chainId",
|
|
1645
|
+
"uri"
|
|
1307
1646
|
]);
|
|
1308
1647
|
const externalWallets = Array.isArray(externalWallet) ? externalWallet : [externalWallet];
|
|
1648
|
+
try {
|
|
1649
|
+
yield this.ctx.client.trackExternalWalletConnections({
|
|
1650
|
+
wallets: externalWallets.map((wallet) => ({
|
|
1651
|
+
address: wallet.address,
|
|
1652
|
+
type: wallet.type,
|
|
1653
|
+
provider: wallet.provider
|
|
1654
|
+
}))
|
|
1655
|
+
});
|
|
1656
|
+
} catch (err) {
|
|
1657
|
+
console.error("Error tracking external wallet connections:", err);
|
|
1658
|
+
}
|
|
1309
1659
|
if (this.externalWalletConnectionOnly || externalWallets.every((wallet) => wallet.isConnectionOnly)) {
|
|
1310
|
-
yield this.
|
|
1660
|
+
yield this.addExternalWallets(
|
|
1311
1661
|
externalWallets.map((wallet) => __spreadProps(__spreadValues({}, wallet), {
|
|
1312
1662
|
withFullParaAuth: false
|
|
1313
1663
|
}))
|
|
@@ -1322,33 +1672,47 @@ const _ParaCore = class _ParaCore {
|
|
|
1322
1672
|
);
|
|
1323
1673
|
}
|
|
1324
1674
|
this.requireApiKey();
|
|
1325
|
-
const serverAuthState = yield this.ctx.client.loginExternalWallet({ externalWallet });
|
|
1675
|
+
const serverAuthState = yield this.ctx.client.loginExternalWallet({ externalWallet, chainId, uri });
|
|
1326
1676
|
if (!externalWallet.withFullParaAuth && externalWallet.withVerification) {
|
|
1327
1677
|
yield this.touchSession(true);
|
|
1328
1678
|
}
|
|
1679
|
+
if (externalWallet.withFullParaAuth) {
|
|
1680
|
+
yield this.ctx.client.sessionAddPortalVerification();
|
|
1681
|
+
}
|
|
1329
1682
|
return __privateMethod(this, _ParaCore_instances, prepareAuthState_fn).call(this, serverAuthState, urlOptions);
|
|
1330
1683
|
});
|
|
1331
1684
|
}
|
|
1332
|
-
verifyExternalWallet(
|
|
1685
|
+
verifyExternalWallet(params) {
|
|
1333
1686
|
return __async(this, null, function* () {
|
|
1334
|
-
var
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
"cosmosPublicKeyHex",
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1687
|
+
var _c;
|
|
1688
|
+
let serverAuthState;
|
|
1689
|
+
let urlOptions;
|
|
1690
|
+
if ("serverAuthState" in params && params.serverAuthState !== void 0) {
|
|
1691
|
+
const _a = params, { serverAuthState: optsServerAuthState } = _a, rest = __objRest(_a, ["serverAuthState"]);
|
|
1692
|
+
serverAuthState = optsServerAuthState;
|
|
1693
|
+
urlOptions = rest;
|
|
1694
|
+
} else if ("externalWallet" in params) {
|
|
1695
|
+
const _b = params, { externalWallet, signedMessage, cosmosPublicKeyHex, cosmosSigner } = _b, rest = __objRest(_b, ["externalWallet", "signedMessage", "cosmosPublicKeyHex", "cosmosSigner"]);
|
|
1696
|
+
const _serverAuthState = yield this.ctx.client.verifyExternalWallet(this.userId, {
|
|
1697
|
+
externalWallet,
|
|
1698
|
+
signedMessage,
|
|
1699
|
+
cosmosPublicKeyHex,
|
|
1700
|
+
cosmosSigner
|
|
1701
|
+
});
|
|
1702
|
+
serverAuthState = _serverAuthState;
|
|
1703
|
+
urlOptions = rest;
|
|
1704
|
+
}
|
|
1705
|
+
if (serverAuthState.stage === "login" && ((_c = serverAuthState.loginAuthMethods) == null ? void 0 : _c.includes(import_user_management_client.AuthMethod.PIN))) {
|
|
1706
|
+
const { sessionLookupId } = yield this.touchSession();
|
|
1707
|
+
return yield __privateMethod(this, _ParaCore_instances, prepareLoginState_fn).call(this, serverAuthState, __spreadProps(__spreadValues({}, urlOptions), { sessionLookupId }));
|
|
1708
|
+
}
|
|
1709
|
+
let state;
|
|
1710
|
+
try {
|
|
1711
|
+
state = yield __privateMethod(this, _ParaCore_instances, prepareAuthState_fn).call(this, serverAuthState, urlOptions);
|
|
1712
|
+
} catch (err) {
|
|
1713
|
+
console.error("Error prepping state:", err);
|
|
1714
|
+
}
|
|
1715
|
+
return state;
|
|
1352
1716
|
});
|
|
1353
1717
|
}
|
|
1354
1718
|
verifyExternalWalletLink(opts) {
|
|
@@ -1364,28 +1728,38 @@ const _ParaCore = class _ParaCore {
|
|
|
1364
1728
|
return accounts;
|
|
1365
1729
|
});
|
|
1366
1730
|
}
|
|
1731
|
+
// TELEGRAM
|
|
1367
1732
|
/**
|
|
1368
1733
|
* Validates the response received from an attempted Telegram login for authenticity, then
|
|
1369
1734
|
* creates or retrieves the corresponding Para user and prepares the Para instance to sign in with that user.
|
|
1370
1735
|
* @param authResponse - the response JSON object received from the Telegram widget.
|
|
1371
1736
|
* @returns `{ isValid: boolean; telegramUserId?: string; userId?: string; isNewUser?: boolean; supportedAuthMethods?: AuthMethod[]; biometricHints?: BiometricLocationHint[] }`
|
|
1372
1737
|
*/
|
|
1373
|
-
verifyTelegramProcess(
|
|
1738
|
+
verifyTelegramProcess(_c) {
|
|
1374
1739
|
return __async(this, null, function* () {
|
|
1375
|
-
var
|
|
1740
|
+
var _d = _c, {
|
|
1741
|
+
serverAuthState: optsServerAuthState,
|
|
1376
1742
|
telegramAuthResponse,
|
|
1377
1743
|
isLinkAccount
|
|
1378
|
-
} =
|
|
1744
|
+
} = _d, urlOptions = __objRest(_d, [
|
|
1745
|
+
"serverAuthState",
|
|
1379
1746
|
"telegramAuthResponse",
|
|
1380
1747
|
"isLinkAccount"
|
|
1381
1748
|
]);
|
|
1382
1749
|
try {
|
|
1383
1750
|
switch (isLinkAccount) {
|
|
1384
1751
|
case false: {
|
|
1385
|
-
|
|
1386
|
-
|
|
1752
|
+
if (!optsServerAuthState && !telegramAuthResponse) {
|
|
1753
|
+
throw new Error("one of serverAuthState or telegramAuthResponse are required for verifying telegram");
|
|
1754
|
+
}
|
|
1755
|
+
const serverAuthState = optsServerAuthState != null ? optsServerAuthState : yield this.ctx.client.verifyTelegram({ authObject: telegramAuthResponse });
|
|
1756
|
+
const { sessionLookupId } = yield this.touchSession();
|
|
1757
|
+
return __privateMethod(this, _ParaCore_instances, prepareAuthState_fn).call(this, serverAuthState, __spreadProps(__spreadValues({}, urlOptions), { sessionLookupId }));
|
|
1387
1758
|
}
|
|
1388
1759
|
case true: {
|
|
1760
|
+
if (!telegramAuthResponse) {
|
|
1761
|
+
throw new Error("telegramAuthResponse is required for verifying telegram link");
|
|
1762
|
+
}
|
|
1389
1763
|
const accountLinkInProgress = yield __privateMethod(this, _ParaCore_instances, assertIsLinkingAccountOrStart_fn).call(this, "TELEGRAM");
|
|
1390
1764
|
const accounts = yield this.verifyLink({
|
|
1391
1765
|
accountLinkInProgress,
|
|
@@ -1395,7 +1769,8 @@ const _ParaCore = class _ParaCore {
|
|
|
1395
1769
|
}
|
|
1396
1770
|
}
|
|
1397
1771
|
} catch (e) {
|
|
1398
|
-
|
|
1772
|
+
const errorMessage = e instanceof Error ? e.message : e ? String(e) : "Unknown error occurred";
|
|
1773
|
+
throw new Error(errorMessage);
|
|
1399
1774
|
}
|
|
1400
1775
|
});
|
|
1401
1776
|
}
|
|
@@ -1459,6 +1834,7 @@ const _ParaCore = class _ParaCore {
|
|
|
1459
1834
|
let type, linkedAccountId;
|
|
1460
1835
|
switch (reason) {
|
|
1461
1836
|
case "SIGNUP":
|
|
1837
|
+
case "LOGIN":
|
|
1462
1838
|
{
|
|
1463
1839
|
const authInfo = this.assertIsAuthSet(["email", "phone"]);
|
|
1464
1840
|
type = authInfo.authType.toUpperCase();
|
|
@@ -1472,7 +1848,7 @@ const _ParaCore = class _ParaCore {
|
|
|
1472
1848
|
}
|
|
1473
1849
|
break;
|
|
1474
1850
|
}
|
|
1475
|
-
const userId = this.assertUserId();
|
|
1851
|
+
const userId = this.assertUserId({ allowGuestMode: true });
|
|
1476
1852
|
if (type !== "EMAIL" && type !== "PHONE") {
|
|
1477
1853
|
throw new Error("invalid auth type for verification code");
|
|
1478
1854
|
}
|
|
@@ -1510,6 +1886,9 @@ const _ParaCore = class _ParaCore {
|
|
|
1510
1886
|
isFullyLoggedIn() {
|
|
1511
1887
|
return __async(this, null, function* () {
|
|
1512
1888
|
if (this.externalWalletConnectionType === "CONNECTION_ONLY") {
|
|
1889
|
+
if (!this.isReady) {
|
|
1890
|
+
yield this.ready();
|
|
1891
|
+
}
|
|
1513
1892
|
return true;
|
|
1514
1893
|
}
|
|
1515
1894
|
if (this.isGuestMode) {
|
|
@@ -1519,17 +1898,45 @@ const _ParaCore = class _ParaCore {
|
|
|
1519
1898
|
if (this.externalWalletConnectionType === "VERIFICATION") {
|
|
1520
1899
|
return isSessionActive;
|
|
1521
1900
|
}
|
|
1522
|
-
|
|
1901
|
+
if (this.isSwitchingWallets) {
|
|
1902
|
+
return isSessionActive;
|
|
1903
|
+
}
|
|
1904
|
+
if (!isSessionActive) {
|
|
1905
|
+
return false;
|
|
1906
|
+
}
|
|
1907
|
+
if (this.isNoWalletConfig) {
|
|
1908
|
+
return true;
|
|
1909
|
+
}
|
|
1910
|
+
const { supportedWalletTypes } = yield __privateMethod(this, _ParaCore_instances, assertPartner_fn).call(this);
|
|
1911
|
+
const requiredWalletTypes = supportedWalletTypes.filter(({ optional }) => !optional);
|
|
1912
|
+
for (const { type } of requiredWalletTypes) {
|
|
1913
|
+
const hasWalletForType = this.currentWalletIdsArray.some(([walletId, walletType]) => {
|
|
1914
|
+
try {
|
|
1915
|
+
const wallet = this.wallets[walletId];
|
|
1916
|
+
return wallet && walletType === type && typeof wallet.address === "string";
|
|
1917
|
+
} catch (e) {
|
|
1918
|
+
return false;
|
|
1919
|
+
}
|
|
1920
|
+
});
|
|
1921
|
+
if (!hasWalletForType) {
|
|
1922
|
+
return false;
|
|
1923
|
+
}
|
|
1924
|
+
}
|
|
1925
|
+
return true;
|
|
1523
1926
|
});
|
|
1524
1927
|
}
|
|
1525
1928
|
get isGuestMode() {
|
|
1526
1929
|
return __privateGet(this, _ParaCore_instances, guestWalletIdsArray_get).length > 0 && Object.values(this.wallets).every(
|
|
1527
1930
|
({ userId, partnerId }) => {
|
|
1528
1931
|
var _a;
|
|
1529
|
-
return partnerId === ((_a =
|
|
1932
|
+
return partnerId === ((_a = this.partner) == null ? void 0 : _a.id) && (!userId || userId !== this.userId);
|
|
1530
1933
|
}
|
|
1531
1934
|
);
|
|
1532
1935
|
}
|
|
1936
|
+
/**
|
|
1937
|
+
* Get the auth methods available to an existing user
|
|
1938
|
+
* @deprecated Use supportedUserAuthMethods instead
|
|
1939
|
+
*/
|
|
1533
1940
|
supportedAuthMethods(auth) {
|
|
1534
1941
|
return __async(this, null, function* () {
|
|
1535
1942
|
const { supportedAuthMethods } = yield this.ctx.client.getSupportedAuthMethods(auth);
|
|
@@ -1547,6 +1954,37 @@ const _ParaCore = class _ParaCore {
|
|
|
1547
1954
|
return authMethods;
|
|
1548
1955
|
});
|
|
1549
1956
|
}
|
|
1957
|
+
/**
|
|
1958
|
+
* Get the auth methods available to an existing user
|
|
1959
|
+
*/
|
|
1960
|
+
supportedUserAuthMethods() {
|
|
1961
|
+
return __async(this, null, function* () {
|
|
1962
|
+
yield this.assertIsAuthSet();
|
|
1963
|
+
const { supportedAuthMethods, hasPasswordWithoutPIN } = yield this.ctx.client.getSupportedAuthMethodsV2(
|
|
1964
|
+
this.authInfo.auth
|
|
1965
|
+
);
|
|
1966
|
+
const authMethods = /* @__PURE__ */ new Set();
|
|
1967
|
+
for (const type of supportedAuthMethods) {
|
|
1968
|
+
switch (type) {
|
|
1969
|
+
case "PASSWORD":
|
|
1970
|
+
if (hasPasswordWithoutPIN) {
|
|
1971
|
+
authMethods.add(import_user_management_client.AuthMethod.PASSWORD);
|
|
1972
|
+
}
|
|
1973
|
+
break;
|
|
1974
|
+
case "PASSKEY":
|
|
1975
|
+
authMethods.add(import_user_management_client.AuthMethod.PASSKEY);
|
|
1976
|
+
break;
|
|
1977
|
+
case "PIN":
|
|
1978
|
+
authMethods.add(import_user_management_client.AuthMethod.PIN);
|
|
1979
|
+
break;
|
|
1980
|
+
case "BASIC_LOGIN":
|
|
1981
|
+
authMethods.add(import_user_management_client.AuthMethod.BASIC_LOGIN);
|
|
1982
|
+
break;
|
|
1983
|
+
}
|
|
1984
|
+
}
|
|
1985
|
+
return authMethods;
|
|
1986
|
+
});
|
|
1987
|
+
}
|
|
1550
1988
|
/**
|
|
1551
1989
|
* Get hints associated with the users stored biometrics.
|
|
1552
1990
|
* @deprecated
|
|
@@ -1633,26 +2071,33 @@ const _ParaCore = class _ParaCore {
|
|
|
1633
2071
|
return connectUri;
|
|
1634
2072
|
});
|
|
1635
2073
|
}
|
|
2074
|
+
// FARCASTER
|
|
1636
2075
|
/**
|
|
1637
2076
|
* Awaits the response from a user's attempt to log in with Farcaster.
|
|
1638
2077
|
* If successful, this returns the user's Farcaster username and profile picture and indicates whether the user already exists.
|
|
1639
2078
|
* @return {Object} `{userExists: boolean; username: string; pfpUrl?: string | null }` - the user's information and whether the user already exists.
|
|
1640
2079
|
*/
|
|
1641
|
-
verifyFarcasterProcess(
|
|
2080
|
+
verifyFarcasterProcess(_e) {
|
|
1642
2081
|
return __async(this, null, function* () {
|
|
1643
|
-
var
|
|
2082
|
+
var _f = _e, {
|
|
1644
2083
|
isCanceled = () => false,
|
|
1645
2084
|
onConnectUri,
|
|
1646
2085
|
onCancel,
|
|
1647
2086
|
onPoll,
|
|
1648
|
-
isLinkAccount
|
|
1649
|
-
|
|
2087
|
+
isLinkAccount,
|
|
2088
|
+
serverAuthState: optsServerAuthState
|
|
2089
|
+
} = _f, urlOptions = __objRest(_f, [
|
|
1650
2090
|
"isCanceled",
|
|
1651
2091
|
"onConnectUri",
|
|
1652
2092
|
"onCancel",
|
|
1653
2093
|
"onPoll",
|
|
1654
|
-
"isLinkAccount"
|
|
2094
|
+
"isLinkAccount",
|
|
2095
|
+
"serverAuthState"
|
|
1655
2096
|
]);
|
|
2097
|
+
if (optsServerAuthState) {
|
|
2098
|
+
const authState = yield __privateMethod(this, _ParaCore_instances, prepareAuthState_fn).call(this, optsServerAuthState, urlOptions);
|
|
2099
|
+
return authState;
|
|
2100
|
+
}
|
|
1656
2101
|
let accountLinkInProgress;
|
|
1657
2102
|
if (isLinkAccount) {
|
|
1658
2103
|
accountLinkInProgress = yield __privateMethod(this, _ParaCore_instances, assertIsLinkingAccountOrStart_fn).call(this, "FARCASTER");
|
|
@@ -1714,7 +2159,9 @@ const _ParaCore = class _ParaCore {
|
|
|
1714
2159
|
}
|
|
1715
2160
|
getOAuthUrl(opts) {
|
|
1716
2161
|
return __async(this, null, function* () {
|
|
1717
|
-
|
|
2162
|
+
var _a;
|
|
2163
|
+
const sessionLookupId = (_a = opts.sessionLookupId) != null ? _a : yield this.prepareLogin();
|
|
2164
|
+
return __privateMethod(this, _ParaCore_instances, getOAuthUrl_fn).call(this, __spreadProps(__spreadValues({}, opts), { sessionLookupId }));
|
|
1718
2165
|
});
|
|
1719
2166
|
}
|
|
1720
2167
|
/**
|
|
@@ -1725,35 +2172,54 @@ const _ParaCore = class _ParaCore {
|
|
|
1725
2172
|
* @param {Window} [opts.popupWindow] the popup window being used for login.
|
|
1726
2173
|
* @return {Object} `{ email?: string; isError?: boolean; userExists: boolean; }` the result data
|
|
1727
2174
|
*/
|
|
1728
|
-
verifyOAuthProcess(
|
|
2175
|
+
verifyOAuthProcess(_g) {
|
|
1729
2176
|
return __async(this, null, function* () {
|
|
1730
|
-
var
|
|
2177
|
+
var _h = _g, {
|
|
1731
2178
|
method,
|
|
1732
2179
|
appScheme,
|
|
1733
2180
|
isCanceled = () => false,
|
|
1734
2181
|
onCancel,
|
|
1735
2182
|
onPoll,
|
|
1736
2183
|
onOAuthUrl,
|
|
2184
|
+
onOAuthPopup,
|
|
1737
2185
|
isLinkAccount
|
|
1738
|
-
} =
|
|
2186
|
+
} = _h, urlOptions = __objRest(_h, [
|
|
1739
2187
|
"method",
|
|
1740
2188
|
"appScheme",
|
|
1741
2189
|
"isCanceled",
|
|
1742
2190
|
"onCancel",
|
|
1743
2191
|
"onPoll",
|
|
1744
2192
|
"onOAuthUrl",
|
|
2193
|
+
"onOAuthPopup",
|
|
1745
2194
|
"isLinkAccount"
|
|
1746
2195
|
]);
|
|
2196
|
+
if (onOAuthPopup) {
|
|
2197
|
+
try {
|
|
2198
|
+
this.popupWindow = yield this.platformUtils.openPopup("about:blank", { type: import_types.PopupType.OAUTH });
|
|
2199
|
+
} catch (error) {
|
|
2200
|
+
throw new Error(`Failed to open OAuth popup: ${error}`);
|
|
2201
|
+
}
|
|
2202
|
+
}
|
|
1747
2203
|
let sessionLookupId, accountLinkInProgress;
|
|
1748
|
-
if (onOAuthUrl) {
|
|
2204
|
+
if (onOAuthUrl || onOAuthPopup) {
|
|
1749
2205
|
if (isLinkAccount) {
|
|
1750
2206
|
accountLinkInProgress = yield __privateMethod(this, _ParaCore_instances, assertIsLinkingAccountOrStart_fn).call(this, method);
|
|
1751
2207
|
sessionLookupId = (yield this.touchSession()).sessionLookupId;
|
|
1752
2208
|
} else {
|
|
1753
|
-
sessionLookupId = yield
|
|
2209
|
+
sessionLookupId = yield this.prepareLogin();
|
|
1754
2210
|
}
|
|
1755
2211
|
const oAuthUrl = yield __privateMethod(this, _ParaCore_instances, getOAuthUrl_fn).call(this, { method, appScheme, sessionLookupId, accountLinkInProgress });
|
|
1756
|
-
|
|
2212
|
+
switch (true) {
|
|
2213
|
+
case !!onOAuthUrl: {
|
|
2214
|
+
onOAuthUrl(oAuthUrl);
|
|
2215
|
+
break;
|
|
2216
|
+
}
|
|
2217
|
+
case (!!onOAuthPopup && !!this.popupWindow): {
|
|
2218
|
+
this.popupWindow.location.href = oAuthUrl;
|
|
2219
|
+
onOAuthPopup(this.popupWindow);
|
|
2220
|
+
break;
|
|
2221
|
+
}
|
|
2222
|
+
}
|
|
1757
2223
|
} else {
|
|
1758
2224
|
({ sessionLookupId } = yield this.touchSession());
|
|
1759
2225
|
}
|
|
@@ -1812,61 +2278,26 @@ const _ParaCore = class _ParaCore {
|
|
|
1812
2278
|
* @param {boolean} [opts.skipSessionRefresh] whether to skip refreshing the session.
|
|
1813
2279
|
* @returns {Object} `{ isComplete: boolean; isError: boolean; needsWallet: boolean; partnerId: string; }` the result data
|
|
1814
2280
|
**/
|
|
1815
|
-
waitForLogin() {
|
|
1816
|
-
return __async(this,
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
yield new Promise((resolve2) => setTimeout(resolve2, constants.POLLING_INTERVAL_MS));
|
|
1836
|
-
try {
|
|
1837
|
-
let session = yield this.touchSession();
|
|
1838
|
-
if (!session.isAuthenticated) {
|
|
1839
|
-
onPoll == null ? void 0 : onPoll();
|
|
1840
|
-
continue;
|
|
1841
|
-
}
|
|
1842
|
-
session = yield this.userSetupAfterLogin();
|
|
1843
|
-
const needsWallet = (_a = session.needsWallet) != null ? _a : false;
|
|
1844
|
-
if (!needsWallet) {
|
|
1845
|
-
if (this.currentWalletIdsArray.length === 0) {
|
|
1846
|
-
onPoll == null ? void 0 : onPoll();
|
|
1847
|
-
continue;
|
|
1848
|
-
}
|
|
1849
|
-
}
|
|
1850
|
-
const fetchedWallets = yield this.fetchWallets();
|
|
1851
|
-
const tempSharesRes = yield this.getTransmissionKeyShares();
|
|
1852
|
-
if (tempSharesRes.data.temporaryShares.length === fetchedWallets.length) {
|
|
1853
|
-
yield this.setupAfterLogin({ temporaryShares: tempSharesRes.data.temporaryShares, skipSessionRefresh });
|
|
1854
|
-
yield this.claimPregenWallets();
|
|
1855
|
-
const resp = {
|
|
1856
|
-
needsWallet: needsWallet || Object.values(this.wallets).length === 0,
|
|
1857
|
-
partnerId: session.partnerId
|
|
1858
|
-
};
|
|
1859
|
-
(0, import_utils2.dispatchEvent)(import_types.ParaEvent.LOGIN_EVENT, resp);
|
|
1860
|
-
return resolve(resp);
|
|
1861
|
-
}
|
|
1862
|
-
onPoll == null ? void 0 : onPoll();
|
|
1863
|
-
} catch (err) {
|
|
1864
|
-
console.error(err);
|
|
1865
|
-
onPoll == null ? void 0 : onPoll();
|
|
1866
|
-
}
|
|
1867
|
-
}
|
|
1868
|
-
}))();
|
|
1869
|
-
});
|
|
2281
|
+
waitForLogin(args) {
|
|
2282
|
+
return __async(this, null, function* () {
|
|
2283
|
+
return yield __privateMethod(this, _ParaCore_instances, waitForLoginProcess_fn).call(this, args);
|
|
2284
|
+
});
|
|
2285
|
+
}
|
|
2286
|
+
waitForWalletSwitching(args) {
|
|
2287
|
+
return __async(this, null, function* () {
|
|
2288
|
+
return yield __privateMethod(this, _ParaCore_instances, waitForLoginProcess_fn).call(this, __spreadProps(__spreadValues({}, args), { isSwitchingWallets: true }));
|
|
2289
|
+
});
|
|
2290
|
+
}
|
|
2291
|
+
/**
|
|
2292
|
+
* Gets the switch wallets URL for wallet selection.
|
|
2293
|
+
* The authMethod is automatically included in the URL if available.
|
|
2294
|
+
*
|
|
2295
|
+
* @returns {Promise<{ url: string; authMethod: TAuthMethod }>} The switch wallets URL and authMethod
|
|
2296
|
+
*/
|
|
2297
|
+
getSwitchWalletsUrl() {
|
|
2298
|
+
return __async(this, null, function* () {
|
|
2299
|
+
const url = yield this.constructPortalUrl("switchWallets");
|
|
2300
|
+
return url;
|
|
1870
2301
|
});
|
|
1871
2302
|
}
|
|
1872
2303
|
/**
|
|
@@ -1889,7 +2320,7 @@ const _ParaCore = class _ParaCore {
|
|
|
1889
2320
|
sessionId
|
|
1890
2321
|
});
|
|
1891
2322
|
if (shouldOpenPopup) {
|
|
1892
|
-
this.platformUtils.openPopup(link);
|
|
2323
|
+
yield this.platformUtils.openPopup(link);
|
|
1893
2324
|
}
|
|
1894
2325
|
return link;
|
|
1895
2326
|
});
|
|
@@ -1980,7 +2411,9 @@ const _ParaCore = class _ParaCore {
|
|
|
1980
2411
|
userId: this.userId,
|
|
1981
2412
|
walletId,
|
|
1982
2413
|
userShare: userSigner,
|
|
1983
|
-
emailProps: this.getBackupKitEmailProps()
|
|
2414
|
+
emailProps: this.getBackupKitEmailProps(),
|
|
2415
|
+
isEnclaveUser: this.isEnclaveUser,
|
|
2416
|
+
walletScheme: this.wallets[walletId].scheme
|
|
1984
2417
|
});
|
|
1985
2418
|
return recoveryShare;
|
|
1986
2419
|
});
|
|
@@ -1994,7 +2427,7 @@ const _ParaCore = class _ParaCore {
|
|
|
1994
2427
|
break;
|
|
1995
2428
|
}
|
|
1996
2429
|
++maxPolls;
|
|
1997
|
-
const res = yield this.ctx.client.getWallets(this.userId);
|
|
2430
|
+
const res = yield (this.isPortal() ? this.ctx.client.getAllWallets : this.ctx.client.getWallets)(this.userId);
|
|
1998
2431
|
const wallet = res.data.wallets.find((w) => w.id === walletId);
|
|
1999
2432
|
if (wallet && wallet.address) {
|
|
2000
2433
|
return;
|
|
@@ -2108,7 +2541,9 @@ const _ParaCore = class _ParaCore {
|
|
|
2108
2541
|
ignoreRedistributingBackupEncryptedShare: !redistributeBackupEncryptedShares,
|
|
2109
2542
|
emailProps: this.getBackupKitEmailProps(),
|
|
2110
2543
|
partnerId: newPartnerId,
|
|
2111
|
-
protocolId
|
|
2544
|
+
protocolId,
|
|
2545
|
+
isEnclaveUser: this.isEnclaveUser,
|
|
2546
|
+
walletScheme: this.wallets[walletId].scheme
|
|
2112
2547
|
});
|
|
2113
2548
|
return { signer, recoverySecret, protocolId };
|
|
2114
2549
|
});
|
|
@@ -2157,26 +2592,29 @@ const _ParaCore = class _ParaCore {
|
|
|
2157
2592
|
}
|
|
2158
2593
|
}
|
|
2159
2594
|
const walletId = keygenRes.walletId;
|
|
2595
|
+
const walletScheme = walletType === "SOLANA" ? "ED25519" : "DKLS";
|
|
2160
2596
|
signer = keygenRes.signer;
|
|
2161
|
-
this.
|
|
2162
|
-
id: walletId,
|
|
2163
|
-
signer,
|
|
2164
|
-
scheme: walletType === "SOLANA" ? "ED25519" : "DKLS",
|
|
2165
|
-
type: walletType
|
|
2166
|
-
};
|
|
2167
|
-
wallet = this.wallets[walletId];
|
|
2168
|
-
yield this.waitForWalletAddress(wallet.id);
|
|
2169
|
-
yield this.populateWalletAddresses();
|
|
2597
|
+
yield this.waitForWalletAddress(walletId);
|
|
2170
2598
|
let recoveryShare = null;
|
|
2171
2599
|
if (!skipDistribute) {
|
|
2172
2600
|
recoveryShare = yield (0, import_shareDistribution.distributeNewShare)({
|
|
2173
2601
|
ctx: this.ctx,
|
|
2174
2602
|
userId: this.userId,
|
|
2175
|
-
walletId
|
|
2603
|
+
walletId,
|
|
2176
2604
|
userShare: signer,
|
|
2177
|
-
emailProps: this.getBackupKitEmailProps()
|
|
2605
|
+
emailProps: this.getBackupKitEmailProps(),
|
|
2606
|
+
isEnclaveUser: this.isEnclaveUser,
|
|
2607
|
+
walletScheme
|
|
2178
2608
|
});
|
|
2179
2609
|
}
|
|
2610
|
+
this.wallets[walletId] = {
|
|
2611
|
+
id: walletId,
|
|
2612
|
+
signer,
|
|
2613
|
+
scheme: walletScheme,
|
|
2614
|
+
type: walletType
|
|
2615
|
+
};
|
|
2616
|
+
wallet = this.wallets[walletId];
|
|
2617
|
+
yield this.populateWalletAddresses();
|
|
2180
2618
|
yield this.setCurrentWalletIds(__spreadProps(__spreadValues({}, this.currentWalletIds), {
|
|
2181
2619
|
[walletType]: [.../* @__PURE__ */ new Set([...(_b = this.currentWalletIds[walletType]) != null ? _b : [], walletId])]
|
|
2182
2620
|
}));
|
|
@@ -2255,7 +2693,9 @@ const _ParaCore = class _ParaCore {
|
|
|
2255
2693
|
walletId: wallet.id,
|
|
2256
2694
|
userShare: this.wallets[wallet.id].signer,
|
|
2257
2695
|
emailProps: this.getBackupKitEmailProps(),
|
|
2258
|
-
partnerId: wallet.partnerId
|
|
2696
|
+
partnerId: wallet.partnerId,
|
|
2697
|
+
isEnclaveUser: this.isEnclaveUser,
|
|
2698
|
+
walletScheme: wallet.scheme
|
|
2259
2699
|
});
|
|
2260
2700
|
if (distributeRes.length > 0) {
|
|
2261
2701
|
newRecoverySecret = distributeRes;
|
|
@@ -2382,10 +2822,10 @@ const _ParaCore = class _ParaCore {
|
|
|
2382
2822
|
(0, import_utils2.dispatchEvent)(import_types.ParaEvent.GUEST_WALLETS_CREATED, wallets);
|
|
2383
2823
|
__privateSet(this, _isCreateGuestWalletsPending, false);
|
|
2384
2824
|
return wallets;
|
|
2385
|
-
} catch (
|
|
2386
|
-
(0, import_utils2.dispatchEvent)(import_types.ParaEvent.GUEST_WALLETS_CREATED, null,
|
|
2825
|
+
} catch (error2) {
|
|
2826
|
+
(0, import_utils2.dispatchEvent)(import_types.ParaEvent.GUEST_WALLETS_CREATED, null, error2 == null ? void 0 : error2.message);
|
|
2387
2827
|
__privateSet(this, _isCreateGuestWalletsPending, false);
|
|
2388
|
-
throw
|
|
2828
|
+
throw error2;
|
|
2389
2829
|
}
|
|
2390
2830
|
});
|
|
2391
2831
|
}
|
|
@@ -2433,25 +2873,12 @@ const _ParaCore = class _ParaCore {
|
|
|
2433
2873
|
});
|
|
2434
2874
|
});
|
|
2435
2875
|
}
|
|
2436
|
-
getOnRampTransactionUrl(
|
|
2437
|
-
return __async(this,
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
providerKey
|
|
2441
|
-
} = _n, walletParams = __objRest(_n, [
|
|
2442
|
-
"purchaseId",
|
|
2443
|
-
"providerKey"
|
|
2444
|
-
]);
|
|
2445
|
-
const { sessionId } = yield this.touchSession();
|
|
2446
|
-
const [key, identifier] = (0, import_user_management_client.extractWalletRef)(walletParams);
|
|
2876
|
+
getOnRampTransactionUrl(_0) {
|
|
2877
|
+
return __async(this, arguments, function* ({
|
|
2878
|
+
purchaseId
|
|
2879
|
+
}) {
|
|
2447
2880
|
return this.constructPortalUrl("onRamp", {
|
|
2448
|
-
pathId: purchaseId
|
|
2449
|
-
sessionId,
|
|
2450
|
-
params: {
|
|
2451
|
-
[key]: identifier,
|
|
2452
|
-
providerKey,
|
|
2453
|
-
currentWalletIds: JSON.stringify(this.currentWalletIds)
|
|
2454
|
-
}
|
|
2881
|
+
pathId: purchaseId
|
|
2455
2882
|
});
|
|
2456
2883
|
});
|
|
2457
2884
|
}
|
|
@@ -2476,6 +2903,7 @@ const _ParaCore = class _ParaCore {
|
|
|
2476
2903
|
onCancel,
|
|
2477
2904
|
onPoll
|
|
2478
2905
|
}) {
|
|
2906
|
+
var _a;
|
|
2479
2907
|
this.assertIsValidWalletId(walletId);
|
|
2480
2908
|
const wallet = this.wallets[walletId];
|
|
2481
2909
|
let signerId = this.userId;
|
|
@@ -2485,7 +2913,7 @@ const _ParaCore = class _ParaCore {
|
|
|
2485
2913
|
let signRes = yield this.signMessageInner({ wallet, signerId, messageBase64, cosmosSignDocBase64 });
|
|
2486
2914
|
let timeStart = Date.now();
|
|
2487
2915
|
if (signRes.pendingTransactionId) {
|
|
2488
|
-
this.platformUtils.openPopup(
|
|
2916
|
+
yield this.platformUtils.openPopup(
|
|
2489
2917
|
yield this.getTransactionReviewUrl(signRes.pendingTransactionId, timeoutMs),
|
|
2490
2918
|
{ type: cosmosSignDocBase64 ? import_types.PopupType.SIGN_TRANSACTION_REVIEW : import_types.PopupType.SIGN_MESSAGE_REVIEW }
|
|
2491
2919
|
);
|
|
@@ -2499,18 +2927,19 @@ const _ParaCore = class _ParaCore {
|
|
|
2499
2927
|
break;
|
|
2500
2928
|
}
|
|
2501
2929
|
yield new Promise((resolve) => setTimeout(resolve, constants.POLLING_INTERVAL_MS));
|
|
2930
|
+
let pendingTransaction;
|
|
2502
2931
|
try {
|
|
2503
|
-
yield this.ctx.client.getPendingTransaction(this.userId, signRes.pendingTransactionId);
|
|
2504
|
-
} catch (
|
|
2932
|
+
pendingTransaction = (_a = (yield this.ctx.client.getPendingTransaction(this.userId, signRes.pendingTransactionId)).data) == null ? void 0 : _a.pendingTransaction;
|
|
2933
|
+
} catch (e) {
|
|
2505
2934
|
const error = new import_errors.TransactionReviewDenied();
|
|
2506
2935
|
(0, import_utils2.dispatchEvent)(import_types.ParaEvent.SIGN_MESSAGE_EVENT, signRes, error.message);
|
|
2507
2936
|
throw error;
|
|
2508
2937
|
}
|
|
2509
|
-
|
|
2510
|
-
if (signRes.pendingTransactionId) {
|
|
2938
|
+
if (!(pendingTransaction == null ? void 0 : pendingTransaction.approvedAt)) {
|
|
2511
2939
|
onPoll == null ? void 0 : onPoll();
|
|
2512
2940
|
continue;
|
|
2513
2941
|
} else {
|
|
2942
|
+
signRes = yield this.signMessageInner({ wallet, signerId, messageBase64, cosmosSignDocBase64 });
|
|
2514
2943
|
break;
|
|
2515
2944
|
}
|
|
2516
2945
|
}
|
|
@@ -2579,6 +3008,7 @@ const _ParaCore = class _ParaCore {
|
|
|
2579
3008
|
onCancel,
|
|
2580
3009
|
onPoll
|
|
2581
3010
|
}) {
|
|
3011
|
+
var _a;
|
|
2582
3012
|
this.assertIsValidWalletId(walletId);
|
|
2583
3013
|
const wallet = this.wallets[walletId];
|
|
2584
3014
|
let signerId = this.userId;
|
|
@@ -2597,7 +3027,7 @@ const _ParaCore = class _ParaCore {
|
|
|
2597
3027
|
);
|
|
2598
3028
|
let timeStart = Date.now();
|
|
2599
3029
|
if (signRes.pendingTransactionId) {
|
|
2600
|
-
this.platformUtils.openPopup(
|
|
3030
|
+
yield this.platformUtils.openPopup(
|
|
2601
3031
|
yield this.getTransactionReviewUrl(signRes.pendingTransactionId, timeoutMs),
|
|
2602
3032
|
{ type: import_types.PopupType.SIGN_TRANSACTION_REVIEW }
|
|
2603
3033
|
);
|
|
@@ -2611,27 +3041,28 @@ const _ParaCore = class _ParaCore {
|
|
|
2611
3041
|
break;
|
|
2612
3042
|
}
|
|
2613
3043
|
yield new Promise((resolve) => setTimeout(resolve, constants.POLLING_INTERVAL_MS));
|
|
3044
|
+
let pendingTransaction;
|
|
2614
3045
|
try {
|
|
2615
|
-
yield this.ctx.client.getPendingTransaction(this.userId, signRes.pendingTransactionId);
|
|
2616
|
-
} catch (
|
|
3046
|
+
pendingTransaction = (_a = (yield this.ctx.client.getPendingTransaction(this.userId, signRes.pendingTransactionId)).data) == null ? void 0 : _a.pendingTransaction;
|
|
3047
|
+
} catch (e) {
|
|
2617
3048
|
const error = new import_errors.TransactionReviewDenied();
|
|
2618
3049
|
(0, import_utils2.dispatchEvent)(import_types.ParaEvent.SIGN_TRANSACTION_EVENT, signRes, error.message);
|
|
2619
3050
|
throw error;
|
|
2620
3051
|
}
|
|
2621
|
-
|
|
2622
|
-
this.ctx,
|
|
2623
|
-
signerId,
|
|
2624
|
-
walletId,
|
|
2625
|
-
this.wallets[walletId].signer,
|
|
2626
|
-
rlpEncodedTxBase64,
|
|
2627
|
-
chainId,
|
|
2628
|
-
this.retrieveSessionCookie(),
|
|
2629
|
-
wallet.scheme === "DKLS"
|
|
2630
|
-
);
|
|
2631
|
-
if (signRes.pendingTransactionId) {
|
|
3052
|
+
if (!(pendingTransaction == null ? void 0 : pendingTransaction.approvedAt)) {
|
|
2632
3053
|
onPoll == null ? void 0 : onPoll();
|
|
2633
3054
|
continue;
|
|
2634
3055
|
} else {
|
|
3056
|
+
signRes = yield this.platformUtils.signTransaction(
|
|
3057
|
+
this.ctx,
|
|
3058
|
+
signerId,
|
|
3059
|
+
walletId,
|
|
3060
|
+
this.wallets[walletId].signer,
|
|
3061
|
+
rlpEncodedTxBase64,
|
|
3062
|
+
chainId,
|
|
3063
|
+
this.retrieveSessionCookie(),
|
|
3064
|
+
wallet.scheme === "DKLS"
|
|
3065
|
+
);
|
|
2635
3066
|
break;
|
|
2636
3067
|
}
|
|
2637
3068
|
}
|
|
@@ -2673,7 +3104,8 @@ const _ParaCore = class _ParaCore {
|
|
|
2673
3104
|
providerKey: onRampPurchase.providerKey
|
|
2674
3105
|
}, walletParams));
|
|
2675
3106
|
if (shouldOpenPopup) {
|
|
2676
|
-
this.platformUtils.openPopup(portalUrl, { type: import_types.PopupType.ON_RAMP_TRANSACTION });
|
|
3107
|
+
const onRampWindow = yield this.platformUtils.openPopup(portalUrl, { type: import_types.PopupType.ON_RAMP_TRANSACTION });
|
|
3108
|
+
this.onRampPopup = { window: onRampWindow, onRampPurchase };
|
|
2677
3109
|
}
|
|
2678
3110
|
return { onRampPurchase, portalUrl };
|
|
2679
3111
|
});
|
|
@@ -2686,7 +3118,7 @@ const _ParaCore = class _ParaCore {
|
|
|
2686
3118
|
try {
|
|
2687
3119
|
yield this.ctx.client.keepSessionAlive(this.userId);
|
|
2688
3120
|
return true;
|
|
2689
|
-
} catch (
|
|
3121
|
+
} catch (e) {
|
|
2690
3122
|
return false;
|
|
2691
3123
|
}
|
|
2692
3124
|
});
|
|
@@ -2758,8 +3190,16 @@ const _ParaCore = class _ParaCore {
|
|
|
2758
3190
|
}
|
|
2759
3191
|
issueJwt() {
|
|
2760
3192
|
return __async(this, arguments, function* ({ keyIndex = 0 } = {}) {
|
|
2761
|
-
|
|
2762
|
-
|
|
3193
|
+
try {
|
|
3194
|
+
return yield this.ctx.client.issueJwt({ keyIndex });
|
|
3195
|
+
} catch (error) {
|
|
3196
|
+
if (error.status === 403 || error.status === 401) {
|
|
3197
|
+
const errorMessage = "The user needs to be logged in to issue a JWT. Please log in and try again.";
|
|
3198
|
+
this.displayModalError(errorMessage);
|
|
3199
|
+
console.warn(errorMessage);
|
|
3200
|
+
}
|
|
3201
|
+
throw error;
|
|
3202
|
+
}
|
|
2763
3203
|
});
|
|
2764
3204
|
}
|
|
2765
3205
|
/**
|
|
@@ -2769,6 +3209,7 @@ const _ParaCore = class _ParaCore {
|
|
|
2769
3209
|
**/
|
|
2770
3210
|
logout() {
|
|
2771
3211
|
return __async(this, arguments, function* ({ clearPregenWallets = false } = {}) {
|
|
3212
|
+
const shouldDispatchLogoutEvent = yield this.isSessionActive();
|
|
2772
3213
|
yield this.ctx.client.logout();
|
|
2773
3214
|
yield this.clearStorage();
|
|
2774
3215
|
if (!clearPregenWallets) {
|
|
@@ -2788,7 +3229,9 @@ const _ParaCore = class _ParaCore {
|
|
|
2788
3229
|
this.accountLinkInProgress = void 0;
|
|
2789
3230
|
this.userId = void 0;
|
|
2790
3231
|
this.sessionCookie = void 0;
|
|
2791
|
-
(
|
|
3232
|
+
if (shouldDispatchLogoutEvent) {
|
|
3233
|
+
(0, import_utils2.dispatchEvent)(import_types.ParaEvent.LOGOUT_EVENT, null);
|
|
3234
|
+
}
|
|
2792
3235
|
});
|
|
2793
3236
|
}
|
|
2794
3237
|
get toStringAdditions() {
|
|
@@ -2818,9 +3261,9 @@ const _ParaCore = class _ParaCore {
|
|
|
2818
3261
|
{}
|
|
2819
3262
|
);
|
|
2820
3263
|
const obj = __spreadProps(__spreadValues({
|
|
2821
|
-
partnerId: (_a =
|
|
2822
|
-
supportedWalletTypes: (_b =
|
|
2823
|
-
cosmosPrefix: (_c =
|
|
3264
|
+
partnerId: (_a = this.partner) == null ? void 0 : _a.id,
|
|
3265
|
+
supportedWalletTypes: (_b = this.partner) == null ? void 0 : _b.supportedWalletTypes,
|
|
3266
|
+
cosmosPrefix: (_c = this.partner) == null ? void 0 : _c.cosmosPrefix,
|
|
2824
3267
|
authInfo: __privateGet(this, _authInfo),
|
|
2825
3268
|
isGuestMode: this.isGuestMode,
|
|
2826
3269
|
userId: this.userId,
|
|
@@ -2852,43 +3295,88 @@ const _ParaCore = class _ParaCore {
|
|
|
2852
3295
|
}
|
|
2853
3296
|
getNewCredentialAndUrl() {
|
|
2854
3297
|
return __async(this, arguments, function* ({
|
|
2855
|
-
authMethod
|
|
3298
|
+
authMethod: optsAuthMethod,
|
|
2856
3299
|
isForNewDevice = false,
|
|
2857
3300
|
portalTheme,
|
|
2858
3301
|
shorten = false
|
|
2859
3302
|
} = {}) {
|
|
3303
|
+
const userAuthMethods = yield this.supportedUserAuthMethods();
|
|
3304
|
+
const isEnclaveUser = userAuthMethods.has(import_user_management_client.AuthMethod.BASIC_LOGIN);
|
|
3305
|
+
const isAddingBasicLogin = optsAuthMethod === "BASIC_LOGIN";
|
|
3306
|
+
if (isEnclaveUser && isAddingBasicLogin) {
|
|
3307
|
+
throw new Error("That user is already using basic login");
|
|
3308
|
+
}
|
|
3309
|
+
if (isEnclaveUser || isAddingBasicLogin) {
|
|
3310
|
+
isForNewDevice = true;
|
|
3311
|
+
}
|
|
3312
|
+
const authMethods = optsAuthMethod ? [optsAuthMethod] : isForNewDevice ? ["PASSKEY", "PIN", "PASSWORD"] : ["PASSKEY"];
|
|
2860
3313
|
this.assertIsAuthSet();
|
|
2861
|
-
let
|
|
2862
|
-
|
|
2863
|
-
|
|
3314
|
+
let passkeyId, passwordId, urlType, credentialId;
|
|
3315
|
+
if (!isAddingBasicLogin) {
|
|
3316
|
+
const canAddPasswordOrPIN = !userAuthMethods.has(import_user_management_client.AuthMethod.PASSWORD) && !userAuthMethods.has(import_user_management_client.AuthMethod.PIN);
|
|
3317
|
+
if (authMethods.includes("PASSKEY") && (yield this.isPasskeySupported())) {
|
|
2864
3318
|
({
|
|
2865
|
-
data: { id:
|
|
3319
|
+
data: { id: passkeyId }
|
|
2866
3320
|
} = yield this.ctx.client.addSessionPublicKey(this.userId, {
|
|
2867
|
-
status: import_user_management_client.
|
|
3321
|
+
status: import_user_management_client.AuthMethodStatus.PENDING,
|
|
2868
3322
|
type: import_user_management_client.PublicKeyType.WEB
|
|
2869
3323
|
}));
|
|
2870
3324
|
urlType = "createAuth";
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
({
|
|
2874
|
-
|
|
2875
|
-
}
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
3325
|
+
}
|
|
3326
|
+
if (authMethods.includes("PASSWORD")) {
|
|
3327
|
+
if (!canAddPasswordOrPIN) {
|
|
3328
|
+
if (optsAuthMethod === "PASSWORD") throw new Error("A user cannot have more than one password or PIN.");
|
|
3329
|
+
} else {
|
|
3330
|
+
({
|
|
3331
|
+
data: { id: passwordId }
|
|
3332
|
+
} = yield this.ctx.client.addSessionPasswordPublicKey(this.userId, {
|
|
3333
|
+
status: import_user_management_client.AuthMethodStatus.PENDING
|
|
3334
|
+
}));
|
|
3335
|
+
urlType = "createPassword";
|
|
3336
|
+
}
|
|
3337
|
+
}
|
|
3338
|
+
if (authMethods.includes("PIN")) {
|
|
3339
|
+
if (!canAddPasswordOrPIN) {
|
|
3340
|
+
if (optsAuthMethod === "PIN") throw new Error("A user cannot have more than one password or PIN.");
|
|
3341
|
+
} else {
|
|
3342
|
+
({
|
|
3343
|
+
data: { id: passwordId }
|
|
3344
|
+
} = yield this.ctx.client.addSessionPasswordPublicKey(this.userId, {
|
|
3345
|
+
status: import_user_management_client.AuthMethodStatus.PENDING
|
|
3346
|
+
}));
|
|
3347
|
+
urlType = "createPIN";
|
|
3348
|
+
}
|
|
3349
|
+
}
|
|
3350
|
+
credentialId = passkeyId != null ? passkeyId : passwordId;
|
|
3351
|
+
if (this.isNativePasskey && authMethods.includes("PASSKEY")) {
|
|
3352
|
+
return { credentialId };
|
|
3353
|
+
}
|
|
2880
3354
|
}
|
|
2881
|
-
const
|
|
3355
|
+
const { sessionId } = yield this.touchSession();
|
|
3356
|
+
const url = (isForNewDevice || urlType) && (yield this.constructPortalUrl(isForNewDevice ? "addNewCredential" : urlType, {
|
|
2882
3357
|
isForNewDevice,
|
|
2883
3358
|
pathId: credentialId,
|
|
2884
3359
|
portalTheme,
|
|
2885
|
-
shorten
|
|
2886
|
-
|
|
3360
|
+
shorten,
|
|
3361
|
+
sessionId: isForNewDevice ? sessionId : void 0,
|
|
3362
|
+
addNewCredentialType: optsAuthMethod,
|
|
3363
|
+
addNewCredentialPasskeyId: passkeyId,
|
|
3364
|
+
addNewCredentialPasswordId: passwordId
|
|
3365
|
+
}));
|
|
2887
3366
|
return __spreadValues({ credentialId }, url ? { url } : {});
|
|
2888
3367
|
});
|
|
2889
3368
|
}
|
|
3369
|
+
addCredential(_0) {
|
|
3370
|
+
return __async(this, arguments, function* ({ authMethod }) {
|
|
3371
|
+
if (authMethod === "PASSKEY" && !(yield this.isPasskeySupported())) {
|
|
3372
|
+
throw new Error("Passkeys are not supported.");
|
|
3373
|
+
}
|
|
3374
|
+
const { url } = yield this.getNewCredentialAndUrl({ isForNewDevice: true, authMethod });
|
|
3375
|
+
return url;
|
|
3376
|
+
});
|
|
3377
|
+
}
|
|
2890
3378
|
/**
|
|
2891
|
-
* Returns a Para Portal URL for logging in with a WebAuth passkey or
|
|
3379
|
+
* Returns a Para Portal URL for logging in with a WebAuth passkey, password, PIN or OTP.
|
|
2892
3380
|
* @param {Object} opts the options object
|
|
2893
3381
|
* @param {String} opts.auth - the user auth to sign up or log in with, in the form ` { email: string } | { phone: `+${number}` } `
|
|
2894
3382
|
* @param {boolean} opts.useShortUrls - whether to shorten the generated portal URLs
|
|
@@ -2914,6 +3402,12 @@ const _ParaCore = class _ParaCore {
|
|
|
2914
3402
|
case "PASSWORD":
|
|
2915
3403
|
urlType = "loginPassword";
|
|
2916
3404
|
break;
|
|
3405
|
+
case "PIN":
|
|
3406
|
+
urlType = "loginPIN";
|
|
3407
|
+
break;
|
|
3408
|
+
case "BASIC_LOGIN":
|
|
3409
|
+
urlType = this.authInfo.authType === "externalWallet" ? "loginExternalWallet" : "loginOTP";
|
|
3410
|
+
break;
|
|
2917
3411
|
default:
|
|
2918
3412
|
throw new Error(`invalid authentication method: '${authMethod}'`);
|
|
2919
3413
|
}
|
|
@@ -2924,10 +3418,30 @@ const _ParaCore = class _ParaCore {
|
|
|
2924
3418
|
});
|
|
2925
3419
|
});
|
|
2926
3420
|
}
|
|
2927
|
-
|
|
3421
|
+
prepareLogin() {
|
|
3422
|
+
return __async(this, null, function* () {
|
|
3423
|
+
yield this.logout();
|
|
3424
|
+
const { sessionLookupId } = yield this.touchSession(true);
|
|
3425
|
+
if (!this.loginEncryptionKeyPair) {
|
|
3426
|
+
yield this.setLoginEncryptionKeyPair();
|
|
3427
|
+
}
|
|
3428
|
+
return sessionLookupId;
|
|
3429
|
+
});
|
|
3430
|
+
}
|
|
3431
|
+
signUpOrLogIn(_i) {
|
|
2928
3432
|
return __async(this, null, function* () {
|
|
2929
|
-
var
|
|
2930
|
-
|
|
3433
|
+
var _j = _i, { auth } = _j, urlOptions = __objRest(_j, ["auth"]);
|
|
3434
|
+
let serverAuthState;
|
|
3435
|
+
try {
|
|
3436
|
+
serverAuthState = yield this.ctx.client.signUpOrLogIn(__spreadValues(__spreadValues({}, auth), this.getVerificationEmailProps()));
|
|
3437
|
+
} catch (error) {
|
|
3438
|
+
if (error.message.includes("max beta users reached")) {
|
|
3439
|
+
this.displayModalError(
|
|
3440
|
+
`50 user limit reached. [Go to Production.](https://docs.getpara.com/v2/general/checklist#go-live-checklist)`
|
|
3441
|
+
);
|
|
3442
|
+
}
|
|
3443
|
+
throw error;
|
|
3444
|
+
}
|
|
2931
3445
|
const authInfo = serverAuthState.auth;
|
|
2932
3446
|
if (this.fetchPregenWalletsOverride && (0, import_user_management_client.isPregenAuth)(authInfo)) {
|
|
2933
3447
|
const { userShare } = yield this.fetchPregenWalletsOverride({ pregenId: authInfo });
|
|
@@ -2935,21 +3449,25 @@ const _ParaCore = class _ParaCore {
|
|
|
2935
3449
|
yield this.setUserShare(userShare);
|
|
2936
3450
|
}
|
|
2937
3451
|
}
|
|
2938
|
-
return __privateMethod(this, _ParaCore_instances, prepareAuthState_fn).call(this, serverAuthState, urlOptions);
|
|
3452
|
+
return __privateMethod(this, _ParaCore_instances, prepareAuthState_fn).call(this, serverAuthState, __spreadValues({}, urlOptions));
|
|
2939
3453
|
});
|
|
2940
3454
|
}
|
|
2941
|
-
verifyNewAccount(
|
|
3455
|
+
verifyNewAccount(_k) {
|
|
2942
3456
|
return __async(this, null, function* () {
|
|
2943
|
-
var
|
|
3457
|
+
var _l = _k, {
|
|
2944
3458
|
verificationCode
|
|
2945
|
-
} =
|
|
3459
|
+
} = _l, urlOptions = __objRest(_l, [
|
|
2946
3460
|
"verificationCode"
|
|
2947
3461
|
]);
|
|
2948
3462
|
this.assertIsAuthSet(["email", "phone"]);
|
|
2949
|
-
const userId = this.assertUserId();
|
|
2950
|
-
const serverAuthState = yield this.ctx.client.
|
|
3463
|
+
const userId = this.assertUserId({ allowGuestMode: true });
|
|
3464
|
+
const serverAuthState = yield this.ctx.client.verifyAccount(userId, {
|
|
2951
3465
|
verificationCode
|
|
2952
3466
|
});
|
|
3467
|
+
if (serverAuthState.stage === "login" || serverAuthState.stage === "done") {
|
|
3468
|
+
throw new Error("Account already exists.");
|
|
3469
|
+
}
|
|
3470
|
+
yield this.touchSession(true);
|
|
2953
3471
|
return __privateMethod(this, _ParaCore_instances, prepareAuthState_fn).call(this, serverAuthState, urlOptions);
|
|
2954
3472
|
});
|
|
2955
3473
|
}
|
|
@@ -2997,7 +3515,7 @@ const _ParaCore = class _ParaCore {
|
|
|
2997
3515
|
}
|
|
2998
3516
|
break;
|
|
2999
3517
|
default:
|
|
3000
|
-
throw new Error("Invalid parameters for linking account, must pass `auth` or `type` or `externalWallet");
|
|
3518
|
+
throw new Error("Invalid parameters for linking account, must pass `auth` or `type` or `externalWallet`");
|
|
3001
3519
|
}
|
|
3002
3520
|
if (!isPermitted) {
|
|
3003
3521
|
throw new Error(`Account linking for type '${type}' is not supported by the current API key configuration`);
|
|
@@ -3036,10 +3554,10 @@ const _ParaCore = class _ParaCore {
|
|
|
3036
3554
|
});
|
|
3037
3555
|
}
|
|
3038
3556
|
verifyLink() {
|
|
3039
|
-
return __async(this, arguments, function* (
|
|
3040
|
-
var
|
|
3557
|
+
return __async(this, arguments, function* (_m = {}) {
|
|
3558
|
+
var _n = _m, {
|
|
3041
3559
|
accountLinkInProgress = __privateMethod(this, _ParaCore_instances, assertIsLinkingAccount_fn).call(this)
|
|
3042
|
-
} =
|
|
3560
|
+
} = _n, opts = __objRest(_n, [
|
|
3043
3561
|
"accountLinkInProgress"
|
|
3044
3562
|
]);
|
|
3045
3563
|
try {
|
|
@@ -3068,31 +3586,80 @@ const _ParaCore = class _ParaCore {
|
|
|
3068
3586
|
return accounts;
|
|
3069
3587
|
});
|
|
3070
3588
|
}
|
|
3589
|
+
getProfileBalance() {
|
|
3590
|
+
return __async(this, arguments, function* ({ config, refetch = false } = {}) {
|
|
3591
|
+
const { balance } = yield this.ctx.client.getProfileBalance({
|
|
3592
|
+
config,
|
|
3593
|
+
wallets: this.availableWallets.filter(({ type }) => type !== "COSMOS").map(({ type, address }) => ({ type, address })),
|
|
3594
|
+
refetch
|
|
3595
|
+
});
|
|
3596
|
+
return balance;
|
|
3597
|
+
});
|
|
3598
|
+
}
|
|
3599
|
+
sendLoginCode() {
|
|
3600
|
+
return __async(this, null, function* () {
|
|
3601
|
+
const { userId } = yield this.ctx.client.sendLoginVerificationCode(this.authInfo);
|
|
3602
|
+
this.setUserId(userId);
|
|
3603
|
+
});
|
|
3604
|
+
}
|
|
3605
|
+
exportPrivateKey() {
|
|
3606
|
+
return __async(this, arguments, function* (args = {}) {
|
|
3607
|
+
let walletId = args == null ? void 0 : args.walletId;
|
|
3608
|
+
if (!(args == null ? void 0 : args.walletId)) {
|
|
3609
|
+
walletId = this.findWalletId(void 0, { forbidPregen: true, scheme: ["DKLS"] });
|
|
3610
|
+
}
|
|
3611
|
+
const wallet = this.wallets[walletId];
|
|
3612
|
+
if (this.externalWallets[walletId]) {
|
|
3613
|
+
throw new Error("Cannot export private key for an external wallet");
|
|
3614
|
+
}
|
|
3615
|
+
if (!wallet || !wallet.signer) {
|
|
3616
|
+
throw new Error("Wallet not found with id: " + walletId);
|
|
3617
|
+
}
|
|
3618
|
+
if (wallet.scheme !== "DKLS") {
|
|
3619
|
+
throw new Error("Cannot export private key for a Solana wallet");
|
|
3620
|
+
}
|
|
3621
|
+
if (wallet.isPregen && !!wallet.pregenIdentifier && wallet.pregenIdentifierType !== "GUEST_ID") {
|
|
3622
|
+
throw new Error("Cannot export private key for a pregenerated wallet");
|
|
3623
|
+
}
|
|
3624
|
+
if (args.shouldOpenPopup) {
|
|
3625
|
+
this.popupWindow = yield this.platformUtils.openPopup("about:blank", { type: import_types.PopupType.EXPORT_PRIVATE_KEY });
|
|
3626
|
+
}
|
|
3627
|
+
const exportPrivateKeyUrl = yield this.constructPortalUrl("exportPrivateKey", {
|
|
3628
|
+
pathId: walletId
|
|
3629
|
+
});
|
|
3630
|
+
if (args.shouldOpenPopup) {
|
|
3631
|
+
this.popupWindow.location.href = exportPrivateKeyUrl;
|
|
3632
|
+
}
|
|
3633
|
+
return {
|
|
3634
|
+
url: exportPrivateKeyUrl,
|
|
3635
|
+
popupWindow: this.popupWindow
|
|
3636
|
+
};
|
|
3637
|
+
});
|
|
3638
|
+
}
|
|
3071
3639
|
};
|
|
3072
3640
|
_authInfo = new WeakMap();
|
|
3073
|
-
_partner = new WeakMap();
|
|
3074
3641
|
_ParaCore_instances = new WeakSet();
|
|
3075
3642
|
assertPartner_fn = function() {
|
|
3076
3643
|
return __async(this, null, function* () {
|
|
3077
3644
|
var _a, _b;
|
|
3078
|
-
if (!
|
|
3645
|
+
if (!this.partner) {
|
|
3079
3646
|
yield this.touchSession();
|
|
3080
3647
|
}
|
|
3081
|
-
if (((_a =
|
|
3082
|
-
this.ctx.cosmosPrefix = (_b =
|
|
3648
|
+
if (((_a = this.partner) == null ? void 0 : _a.cosmosPrefix) && this.ctx.cosmosPrefix !== this.partner.cosmosPrefix) {
|
|
3649
|
+
this.ctx.cosmosPrefix = (_b = this.partner) == null ? void 0 : _b.cosmosPrefix;
|
|
3083
3650
|
}
|
|
3084
|
-
return
|
|
3651
|
+
return this.partner;
|
|
3085
3652
|
});
|
|
3086
3653
|
};
|
|
3087
3654
|
guestWalletIds_get = function() {
|
|
3088
3655
|
var _a, _b, _c;
|
|
3089
|
-
if (!((_a =
|
|
3656
|
+
if (!((_a = this.partner) == null ? void 0 : _a.supportedWalletTypes)) {
|
|
3090
3657
|
return {};
|
|
3091
3658
|
}
|
|
3092
3659
|
const guestId = (_c = (_b = this.pregenIds) == null ? void 0 : _b.GUEST_ID) == null ? void 0 : _c[0];
|
|
3093
3660
|
return !!guestId ? Object.entries(this.wallets).reduce((acc, [id, wallet]) => {
|
|
3094
3661
|
if (wallet.isPregen && !wallet.userId && wallet.pregenIdentifierType === "GUEST_ID" && wallet.pregenIdentifier === guestId) {
|
|
3095
|
-
return __spreadValues(__spreadValues({}, acc), (0, import_utils2.getEquivalentTypes)(wallet.type).filter((type) =>
|
|
3662
|
+
return __spreadValues(__spreadValues({}, acc), (0, import_utils2.getEquivalentTypes)(wallet.type).filter((type) => this.partner.supportedWalletTypes.some((entry) => entry.type === type)).reduce((acc2, eqType) => {
|
|
3096
3663
|
var _a2;
|
|
3097
3664
|
return __spreadProps(__spreadValues({}, acc2), { [eqType]: [.../* @__PURE__ */ new Set([...(_a2 = acc2[eqType]) != null ? _a2 : [], id])] });
|
|
3098
3665
|
}, {}));
|
|
@@ -3153,8 +3720,8 @@ getPartner_fn = function(partnerId) {
|
|
|
3153
3720
|
return void 0;
|
|
3154
3721
|
}
|
|
3155
3722
|
const res = yield this.ctx.client.getPartner(partnerId);
|
|
3156
|
-
|
|
3157
|
-
return
|
|
3723
|
+
this.partner = res.data.partner;
|
|
3724
|
+
return this.partner;
|
|
3158
3725
|
});
|
|
3159
3726
|
};
|
|
3160
3727
|
assertIsLinkingAccount_fn = function(types) {
|
|
@@ -3176,29 +3743,212 @@ assertIsLinkingAccountOrStart_fn = function(type) {
|
|
|
3176
3743
|
return yield this.linkAccount({ type });
|
|
3177
3744
|
});
|
|
3178
3745
|
};
|
|
3179
|
-
getOAuthUrl_fn = function(
|
|
3180
|
-
return __async(this,
|
|
3181
|
-
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3746
|
+
getOAuthUrl_fn = function(_0) {
|
|
3747
|
+
return __async(this, arguments, function* ({
|
|
3748
|
+
method,
|
|
3749
|
+
appScheme,
|
|
3750
|
+
accountLinkInProgress,
|
|
3751
|
+
sessionLookupId,
|
|
3752
|
+
encryptionKey,
|
|
3753
|
+
portalCallbackParams
|
|
3754
|
+
}) {
|
|
3755
|
+
if (!accountLinkInProgress && !this.isPortal()) {
|
|
3756
|
+
return yield this.constructPortalUrl("oAuth", { sessionId: sessionLookupId, oAuthMethod: method, appScheme });
|
|
3757
|
+
}
|
|
3758
|
+
let portalSessionLookupId;
|
|
3759
|
+
if (this.isPortal()) {
|
|
3760
|
+
portalSessionLookupId = (yield this.touchSession(true)).sessionLookupId;
|
|
3761
|
+
}
|
|
3192
3762
|
return (0, import_utils2.constructUrl)({
|
|
3193
3763
|
base: (0, import_userManagementClient.getBaseOAuthUrl)(this.ctx.env),
|
|
3194
|
-
path: `/auth/${method}`,
|
|
3195
|
-
params: __spreadValues({
|
|
3764
|
+
path: `/auth/${method.toLowerCase()}`,
|
|
3765
|
+
params: __spreadProps(__spreadValues({
|
|
3196
3766
|
apiKey: this.ctx.apiKey,
|
|
3767
|
+
origin: typeof window !== "undefined" ? window.location.origin : void 0,
|
|
3197
3768
|
sessionLookupId,
|
|
3769
|
+
portalSessionLookupId,
|
|
3198
3770
|
appScheme
|
|
3199
3771
|
}, accountLinkInProgress ? {
|
|
3200
3772
|
linkedAccountId: this.accountLinkInProgress.id
|
|
3201
|
-
} : {})
|
|
3773
|
+
} : {}), {
|
|
3774
|
+
callback: !accountLinkInProgress && (yield this.constructPortalUrl("oAuthCallback", __spreadValues({
|
|
3775
|
+
sessionId: sessionLookupId,
|
|
3776
|
+
oAuthMethod: method,
|
|
3777
|
+
appScheme,
|
|
3778
|
+
thisDevice: {
|
|
3779
|
+
sessionId: sessionLookupId,
|
|
3780
|
+
encryptionKey
|
|
3781
|
+
}
|
|
3782
|
+
}, this.isPortal() && {
|
|
3783
|
+
params: portalCallbackParams,
|
|
3784
|
+
// Build callback for legacy portal if needed
|
|
3785
|
+
useLegacyUrl: typeof window !== "undefined" ? window.location.host.includes("usecapsule") : false
|
|
3786
|
+
})))
|
|
3787
|
+
})
|
|
3788
|
+
});
|
|
3789
|
+
});
|
|
3790
|
+
};
|
|
3791
|
+
waitForLoginProcess_fn = function() {
|
|
3792
|
+
return __async(this, arguments, function* ({
|
|
3793
|
+
isCanceled = () => false,
|
|
3794
|
+
onCancel,
|
|
3795
|
+
onPoll,
|
|
3796
|
+
skipSessionRefresh = false,
|
|
3797
|
+
isSwitchingWallets = false
|
|
3798
|
+
} = {}) {
|
|
3799
|
+
this.devLog("[waitForLoginProcess] Starting", {
|
|
3800
|
+
isSwitchingWallets,
|
|
3801
|
+
skipSessionRefresh,
|
|
3802
|
+
isExternalWalletAuth: this.isExternalWalletAuth
|
|
3803
|
+
});
|
|
3804
|
+
const startedAt = Date.now();
|
|
3805
|
+
let originalCurrentWalletIdsHash;
|
|
3806
|
+
if (isSwitchingWallets) {
|
|
3807
|
+
this.devLog("[waitForLoginProcess] Wallet switching mode enabled");
|
|
3808
|
+
this.isSwitchingWallets = true;
|
|
3809
|
+
const session = yield this.touchSession();
|
|
3810
|
+
originalCurrentWalletIdsHash = session.currentWalletIdsHash;
|
|
3811
|
+
this.devLog("[waitForLoginProcess] Original wallet IDs hash", { originalCurrentWalletIdsHash });
|
|
3812
|
+
}
|
|
3813
|
+
return new Promise((resolve, reject) => {
|
|
3814
|
+
(() => __async(this, null, function* () {
|
|
3815
|
+
var _a;
|
|
3816
|
+
if (!this.isExternalWalletAuth && !isSwitchingWallets) {
|
|
3817
|
+
this.devLog("[waitForLoginProcess] Clearing external wallets");
|
|
3818
|
+
this.externalWallets = {};
|
|
3819
|
+
}
|
|
3820
|
+
let pollCount = 0;
|
|
3821
|
+
while (true) {
|
|
3822
|
+
pollCount++;
|
|
3823
|
+
this.devLog("[waitForLoginProcess] Poll iteration", {
|
|
3824
|
+
pollCount,
|
|
3825
|
+
elapsedMs: Date.now() - startedAt
|
|
3826
|
+
});
|
|
3827
|
+
if (isCanceled() || Date.now() - startedAt > constants.POLLING_TIMEOUT_MS) {
|
|
3828
|
+
this.devLog("[waitForLoginProcess] Canceled or timed out", {
|
|
3829
|
+
wasCanceled: isCanceled(),
|
|
3830
|
+
timedOut: Date.now() - startedAt > constants.POLLING_TIMEOUT_MS,
|
|
3831
|
+
elapsedMs: Date.now() - startedAt
|
|
3832
|
+
});
|
|
3833
|
+
if (isSwitchingWallets) {
|
|
3834
|
+
this.isSwitchingWallets = false;
|
|
3835
|
+
} else {
|
|
3836
|
+
(0, import_utils2.dispatchEvent)(import_types.ParaEvent.LOGIN_EVENT, { isComplete: false }, "failed to setup user");
|
|
3837
|
+
}
|
|
3838
|
+
onCancel == null ? void 0 : onCancel();
|
|
3839
|
+
return reject("canceled");
|
|
3840
|
+
}
|
|
3841
|
+
yield new Promise((resolve2) => setTimeout(resolve2, constants.POLLING_INTERVAL_MS));
|
|
3842
|
+
try {
|
|
3843
|
+
this.devLog("[waitForLoginProcess] Touching session");
|
|
3844
|
+
let session = yield this.touchSession();
|
|
3845
|
+
this.devLog("[waitForLoginProcess] Session state", {
|
|
3846
|
+
isAuthenticated: session.isAuthenticated,
|
|
3847
|
+
currentWalletIdsHash: session.currentWalletIdsHash,
|
|
3848
|
+
needsWallet: session.needsWallet
|
|
3849
|
+
});
|
|
3850
|
+
const shouldContinuePolling = isSwitchingWallets ? originalCurrentWalletIdsHash === session.currentWalletIdsHash : !session.isAuthenticated;
|
|
3851
|
+
this.devLog("[waitForLoginProcess] Should continue polling", {
|
|
3852
|
+
shouldContinuePolling,
|
|
3853
|
+
isSwitchingWallets,
|
|
3854
|
+
originalCurrentWalletIdsHash,
|
|
3855
|
+
sessionCurrentWalletIdsHash: session.currentWalletIdsHash,
|
|
3856
|
+
isAuthenticated: session.isAuthenticated
|
|
3857
|
+
});
|
|
3858
|
+
if (shouldContinuePolling) {
|
|
3859
|
+
onPoll == null ? void 0 : onPoll();
|
|
3860
|
+
continue;
|
|
3861
|
+
}
|
|
3862
|
+
this.devLog("[waitForLoginProcess] Authentication check passed, setting up user");
|
|
3863
|
+
session = yield this.userSetupAfterLogin();
|
|
3864
|
+
const needsWallet = (_a = session.needsWallet) != null ? _a : false;
|
|
3865
|
+
this.devLog("[waitForLoginProcess] User setup complete", { needsWallet });
|
|
3866
|
+
if (isSwitchingWallets) {
|
|
3867
|
+
const isWalletSwitchingComplete = originalCurrentWalletIdsHash !== session.currentWalletIdsHash;
|
|
3868
|
+
this.devLog("[waitForLoginProcess] Wallet switching check", {
|
|
3869
|
+
isWalletSwitchingComplete,
|
|
3870
|
+
originalHash: originalCurrentWalletIdsHash,
|
|
3871
|
+
sessionHash: session.currentWalletIdsHash
|
|
3872
|
+
});
|
|
3873
|
+
if (!isWalletSwitchingComplete) {
|
|
3874
|
+
onPoll == null ? void 0 : onPoll();
|
|
3875
|
+
continue;
|
|
3876
|
+
}
|
|
3877
|
+
} else if (!needsWallet) {
|
|
3878
|
+
this.devLog("[waitForLoginProcess] Checking wallet IDs", {
|
|
3879
|
+
currentWalletIdsArrayLength: this.currentWalletIdsArray.length
|
|
3880
|
+
});
|
|
3881
|
+
if (this.currentWalletIdsArray.length === 0) {
|
|
3882
|
+
this.devLog("[waitForLoginProcess] No wallet IDs yet, continuing to poll");
|
|
3883
|
+
onPoll == null ? void 0 : onPoll();
|
|
3884
|
+
continue;
|
|
3885
|
+
}
|
|
3886
|
+
}
|
|
3887
|
+
this.devLog("[waitForLoginProcess] Getting transmission key shares");
|
|
3888
|
+
const tempSharesRes = yield this.getTransmissionKeyShares();
|
|
3889
|
+
this.devLog("[waitForLoginProcess] Transmission shares received", {
|
|
3890
|
+
shareCount: tempSharesRes.data.temporaryShares.length,
|
|
3891
|
+
shares: tempSharesRes.data.temporaryShares.map((s) => ({
|
|
3892
|
+
walletId: s.walletId,
|
|
3893
|
+
walletScheme: s.walletScheme
|
|
3894
|
+
}))
|
|
3895
|
+
});
|
|
3896
|
+
let hasSharesForCurrentWallets;
|
|
3897
|
+
if (!isSwitchingWallets && !this.isPortal()) {
|
|
3898
|
+
this.devLog("[waitForLoginProcess] Fetching wallets");
|
|
3899
|
+
const fetchedWallets = yield this.fetchWallets();
|
|
3900
|
+
this.devLog("[waitForLoginProcess] Wallets fetched", {
|
|
3901
|
+
walletCount: fetchedWallets.length,
|
|
3902
|
+
wallets: fetchedWallets.map((w) => ({ id: w.id, type: w.type, scheme: w.scheme }))
|
|
3903
|
+
});
|
|
3904
|
+
hasSharesForCurrentWallets = tempSharesRes.data.temporaryShares.length === fetchedWallets.length;
|
|
3905
|
+
} else {
|
|
3906
|
+
hasSharesForCurrentWallets = this.currentWalletIdsArray.every(([walletId]) => {
|
|
3907
|
+
return tempSharesRes.data.temporaryShares.some((share) => share.walletId === walletId);
|
|
3908
|
+
});
|
|
3909
|
+
}
|
|
3910
|
+
this.devLog("[waitForLoginProcess] Checking shares for current wallets", {
|
|
3911
|
+
hasSharesForCurrentWallets,
|
|
3912
|
+
currentWalletIdsArray: this.currentWalletIdsArray,
|
|
3913
|
+
shares: tempSharesRes.data.temporaryShares.map((s) => ({
|
|
3914
|
+
walletId: s.walletId,
|
|
3915
|
+
walletScheme: s.walletScheme
|
|
3916
|
+
}))
|
|
3917
|
+
});
|
|
3918
|
+
if (hasSharesForCurrentWallets) {
|
|
3919
|
+
this.devLog("[waitForLoginProcess] Setting up after login");
|
|
3920
|
+
yield this.setupAfterLogin({ temporaryShares: tempSharesRes.data.temporaryShares, skipSessionRefresh });
|
|
3921
|
+
this.devLog("[waitForLoginProcess] Setup after login complete");
|
|
3922
|
+
this.devLog("[waitForLoginProcess] Claiming pregen wallets");
|
|
3923
|
+
yield this.claimPregenWallets();
|
|
3924
|
+
this.devLog("[waitForLoginProcess] Pregen wallets claimed");
|
|
3925
|
+
const resp = {
|
|
3926
|
+
needsWallet: needsWallet || Object.values(this.wallets).length === 0,
|
|
3927
|
+
partnerId: session.partnerId
|
|
3928
|
+
};
|
|
3929
|
+
this.devLog("[waitForLoginProcess] Login process complete", {
|
|
3930
|
+
needsWallet: resp.needsWallet,
|
|
3931
|
+
partnerId: resp.partnerId,
|
|
3932
|
+
walletCount: Object.values(this.wallets).length,
|
|
3933
|
+
isSwitchingWallets
|
|
3934
|
+
});
|
|
3935
|
+
if (isSwitchingWallets) {
|
|
3936
|
+
this.devLog("[waitForLoginProcess] Clearing wallet switching state");
|
|
3937
|
+
this.isSwitchingWallets = false;
|
|
3938
|
+
} else {
|
|
3939
|
+
this.devLog("[waitForLoginProcess] Dispatching LOGIN_EVENT");
|
|
3940
|
+
(0, import_utils2.dispatchEvent)(import_types.ParaEvent.LOGIN_EVENT, resp);
|
|
3941
|
+
}
|
|
3942
|
+
return resolve(resp);
|
|
3943
|
+
}
|
|
3944
|
+
this.devLog("[waitForLoginProcess] Not all shares available yet, continuing to poll");
|
|
3945
|
+
onPoll == null ? void 0 : onPoll();
|
|
3946
|
+
} catch (err) {
|
|
3947
|
+
console.error("[waitForLoginProcess] Error during polling iteration", err);
|
|
3948
|
+
onPoll == null ? void 0 : onPoll();
|
|
3949
|
+
}
|
|
3950
|
+
}
|
|
3951
|
+
}))();
|
|
3202
3952
|
});
|
|
3203
3953
|
});
|
|
3204
3954
|
};
|
|
@@ -3252,8 +4002,9 @@ createPregenWallet_fn = function(opts) {
|
|
|
3252
4002
|
_isCreateGuestWalletsPending = new WeakMap();
|
|
3253
4003
|
prepareAuthState_fn = function(_0) {
|
|
3254
4004
|
return __async(this, arguments, function* (serverAuthState, opts = {}) {
|
|
3255
|
-
|
|
3256
|
-
|
|
4005
|
+
var _a, _b;
|
|
4006
|
+
if (!opts.sessionLookupId && serverAuthState.stage === "login" && (!serverAuthState.externalWallet || !(((_a = serverAuthState.externalWallet) == null ? void 0 : _a.withFullParaAuth) && ((_b = serverAuthState.loginAuthMethods) == null ? void 0 : _b.includes(import_user_management_client.AuthMethod.PIN))))) {
|
|
4007
|
+
opts.sessionLookupId = yield this.prepareLogin();
|
|
3257
4008
|
}
|
|
3258
4009
|
const { auth, externalWallet, userId, displayName, pfpUrl, username } = serverAuthState;
|
|
3259
4010
|
const authInfo = __spreadValues(__spreadValues({}, (0, import_user_management_client.extractAuthInfo)(auth, { isRequired: true })), Object.fromEntries(
|
|
@@ -3274,8 +4025,14 @@ prepareAuthState_fn = function(_0) {
|
|
|
3274
4025
|
}
|
|
3275
4026
|
let authState;
|
|
3276
4027
|
switch (serverAuthState.stage) {
|
|
4028
|
+
case "done": {
|
|
4029
|
+
authState = yield __privateMethod(this, _ParaCore_instances, prepareDoneState_fn).call(this, serverAuthState);
|
|
4030
|
+
break;
|
|
4031
|
+
}
|
|
3277
4032
|
case "verify":
|
|
3278
|
-
authState = serverAuthState
|
|
4033
|
+
authState = yield __privateMethod(this, _ParaCore_instances, prepareVerificationState_fn).call(this, serverAuthState, __spreadProps(__spreadValues({}, opts), {
|
|
4034
|
+
sessionLookupId: opts.sessionLookupId
|
|
4035
|
+
}));
|
|
3279
4036
|
break;
|
|
3280
4037
|
case "login":
|
|
3281
4038
|
if (externalWallet && !(externalWallet == null ? void 0 : externalWallet.withFullParaAuth)) {
|
|
@@ -3295,14 +4052,36 @@ prepareAuthState_fn = function(_0) {
|
|
|
3295
4052
|
return authState;
|
|
3296
4053
|
});
|
|
3297
4054
|
};
|
|
3298
|
-
|
|
4055
|
+
prepareDoneState_fn = function(doneState) {
|
|
3299
4056
|
return __async(this, null, function* () {
|
|
3300
|
-
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
|
|
4057
|
+
let isSLOPossible = doneState.authMethods.includes(import_user_management_client.AuthMethod.BASIC_LOGIN);
|
|
4058
|
+
this.isEnclaveUser = isSLOPossible;
|
|
4059
|
+
return doneState;
|
|
4060
|
+
});
|
|
4061
|
+
};
|
|
4062
|
+
prepareVerificationState_fn = function(_0, _1) {
|
|
4063
|
+
return __async(this, arguments, function* (verifyState, {
|
|
4064
|
+
useShortUrls: shorten = false,
|
|
4065
|
+
portalTheme,
|
|
4066
|
+
sessionLookupId
|
|
4067
|
+
}) {
|
|
4068
|
+
var _a;
|
|
4069
|
+
let isSLOPossible = false;
|
|
4070
|
+
if (verifyState.nextStage === "login") {
|
|
4071
|
+
isSLOPossible = verifyState.loginAuthMethods.includes(import_user_management_client.AuthMethod.BASIC_LOGIN);
|
|
4072
|
+
} else if (verifyState.nextStage === "signup") {
|
|
4073
|
+
isSLOPossible = verifyState.signupAuthMethods.includes(import_user_management_client.AuthMethod.BASIC_LOGIN);
|
|
3304
4074
|
}
|
|
3305
|
-
|
|
4075
|
+
this.isEnclaveUser = isSLOPossible;
|
|
4076
|
+
const isExternalWalletFullAuth = (_a = verifyState.externalWallet) == null ? void 0 : _a.withFullParaAuth;
|
|
4077
|
+
return __spreadValues(__spreadValues({}, verifyState), isSLOPossible || isExternalWalletFullAuth ? {
|
|
4078
|
+
loginUrl: yield this.getLoginUrl({
|
|
4079
|
+
authMethod: import_user_management_client.AuthMethod.BASIC_LOGIN,
|
|
4080
|
+
sessionId: sessionLookupId,
|
|
4081
|
+
shorten,
|
|
4082
|
+
portalTheme
|
|
4083
|
+
})
|
|
4084
|
+
} : {});
|
|
3306
4085
|
});
|
|
3307
4086
|
};
|
|
3308
4087
|
prepareLoginState_fn = function(_0, _1) {
|
|
@@ -3311,10 +4090,11 @@ prepareLoginState_fn = function(_0, _1) {
|
|
|
3311
4090
|
portalTheme,
|
|
3312
4091
|
sessionLookupId
|
|
3313
4092
|
}) {
|
|
3314
|
-
const _a = loginState, { loginAuthMethods } = _a, authState = __objRest(_a, ["loginAuthMethods"]);
|
|
3315
|
-
const isPasskeySupported = yield this.isPasskeySupported(), isPasskeyPossible = loginAuthMethods.includes(import_user_management_client.AuthMethod.PASSKEY) && !this.isNativePasskey, isPasswordPossible = loginAuthMethods.includes(import_user_management_client.AuthMethod.PASSWORD);
|
|
3316
|
-
return __spreadValues(__spreadValues(__spreadProps(__spreadValues({}, authState), {
|
|
3317
|
-
isPasskeySupported
|
|
4093
|
+
const _a = loginState, { loginAuthMethods = [], hasPasswordWithoutPIN } = _a, authState = __objRest(_a, ["loginAuthMethods", "hasPasswordWithoutPIN"]);
|
|
4094
|
+
const isPasskeySupported = yield this.isPasskeySupported(), isPasskeyPossible = loginAuthMethods.includes(import_user_management_client.AuthMethod.PASSKEY) && !this.isNativePasskey, isPasswordPossible = loginAuthMethods.includes(import_user_management_client.AuthMethod.PASSWORD) && hasPasswordWithoutPIN, isPINPossible = loginAuthMethods.includes(import_user_management_client.AuthMethod.PIN);
|
|
4095
|
+
return __spreadValues(__spreadValues(__spreadValues(__spreadProps(__spreadValues({}, authState), {
|
|
4096
|
+
isPasskeySupported,
|
|
4097
|
+
loginAuthMethods
|
|
3318
4098
|
}), isPasskeyPossible ? {
|
|
3319
4099
|
passkeyUrl: yield this.getLoginUrl({ sessionId: sessionLookupId, shorten, portalTheme }),
|
|
3320
4100
|
passkeyKnownDeviceUrl: yield this.constructPortalUrl("loginAuth", {
|
|
@@ -3333,23 +4113,34 @@ prepareLoginState_fn = function(_0, _1) {
|
|
|
3333
4113
|
portalTheme,
|
|
3334
4114
|
params: { isEmbedded: `${!loginState.isWalletSelectionNeeded}` }
|
|
3335
4115
|
})
|
|
4116
|
+
} : {}), isPINPossible ? {
|
|
4117
|
+
pinUrl: yield this.constructPortalUrl("loginPIN", {
|
|
4118
|
+
sessionId: sessionLookupId,
|
|
4119
|
+
shorten,
|
|
4120
|
+
portalTheme,
|
|
4121
|
+
params: { isEmbedded: `${!loginState.isWalletSelectionNeeded}` }
|
|
4122
|
+
})
|
|
3336
4123
|
} : {});
|
|
3337
4124
|
});
|
|
3338
4125
|
};
|
|
3339
4126
|
prepareSignUpState_fn = function(_0, _1) {
|
|
3340
4127
|
return __async(this, arguments, function* (serverSignupState, { useShortUrls: shorten = false, portalTheme }) {
|
|
3341
|
-
const _a = serverSignupState, { signupAuthMethods } = _a, authState = __objRest(_a, ["signupAuthMethods"]);
|
|
4128
|
+
const _a = serverSignupState, { signupAuthMethods = [] } = _a, authState = __objRest(_a, ["signupAuthMethods"]);
|
|
3342
4129
|
const isPasskeySupported = yield this.isPasskeySupported();
|
|
3343
|
-
const [isPasskey, isPassword] = [
|
|
4130
|
+
const [isPasskey, isPassword, isPIN] = [
|
|
3344
4131
|
signupAuthMethods.includes(import_user_management_client.AuthMethod.PASSKEY),
|
|
3345
|
-
signupAuthMethods.includes(import_user_management_client.AuthMethod.PASSWORD) || !isPasskeySupported
|
|
4132
|
+
signupAuthMethods.includes(import_user_management_client.AuthMethod.PASSWORD) || !isPasskeySupported,
|
|
4133
|
+
signupAuthMethods.includes(import_user_management_client.AuthMethod.PIN)
|
|
3346
4134
|
];
|
|
3347
|
-
if (!isPasskey && !isPassword) {
|
|
4135
|
+
if (!isPasskey && !isPassword && !isPIN) {
|
|
3348
4136
|
throw new Error(
|
|
3349
|
-
"No supported authentication methods found. Please ensure you have enabled either WebAuth passkeys or
|
|
4137
|
+
"No supported authentication methods found. Please ensure you have enabled either WebAuth passkeys, passwords or PINs in your Developer Portal settings."
|
|
3350
4138
|
);
|
|
3351
4139
|
}
|
|
3352
|
-
const signupState = __spreadProps(__spreadValues({}, authState), {
|
|
4140
|
+
const signupState = __spreadProps(__spreadValues({}, authState), {
|
|
4141
|
+
isPasskeySupported,
|
|
4142
|
+
signupAuthMethods
|
|
4143
|
+
});
|
|
3353
4144
|
if (isPasskey) {
|
|
3354
4145
|
const { url: passkeyUrl, credentialId: passkeyId } = yield this.getNewCredentialAndUrl({
|
|
3355
4146
|
authMethod: "PASSKEY",
|
|
@@ -3367,6 +4158,15 @@ prepareSignUpState_fn = function(_0, _1) {
|
|
|
3367
4158
|
signupState.passwordUrl = passwordUrl;
|
|
3368
4159
|
signupState.passwordId = passwordId;
|
|
3369
4160
|
}
|
|
4161
|
+
if (isPIN) {
|
|
4162
|
+
const { url: pinUrl, credentialId: pinId } = yield this.getNewCredentialAndUrl({
|
|
4163
|
+
authMethod: "PIN",
|
|
4164
|
+
portalTheme,
|
|
4165
|
+
shorten
|
|
4166
|
+
});
|
|
4167
|
+
signupState.pinUrl = pinUrl;
|
|
4168
|
+
signupState.pinId = pinId;
|
|
4169
|
+
}
|
|
3370
4170
|
return signupState;
|
|
3371
4171
|
});
|
|
3372
4172
|
};
|