@getpara/core-sdk 2.0.0-fc.2 → 2.0.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 +1111 -316
- 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/wallet.js +18 -0
- package/dist/cjs/{types/onRamps.js → utils/window.js} +17 -12
- package/dist/esm/ParaCore.js +1115 -320
- 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/wallet.js +17 -0
- package/dist/esm/utils/window.js +16 -0
- package/dist/types/ParaCore.d.ts +90 -19
- 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 +56 -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/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,55 @@ 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 base = type === "onRamp" ||
|
|
810
|
+
const base = type === "onRamp" || isTelegramLogin ? (0, import_utils2.getPortalBaseURL)(this.ctx, isTelegramLogin) : yield this.getPortalURL();
|
|
690
811
|
let path;
|
|
691
812
|
switch (type) {
|
|
692
813
|
case "createPassword": {
|
|
693
814
|
path = `/web/users/${this.userId}/passwords/${opts.pathId}`;
|
|
694
815
|
break;
|
|
695
816
|
}
|
|
817
|
+
case "createPIN": {
|
|
818
|
+
path = `/web/users/${this.userId}/pin/${opts.pathId}`;
|
|
819
|
+
break;
|
|
820
|
+
}
|
|
696
821
|
case "createAuth": {
|
|
697
822
|
path = `/web/users/${this.userId}/biometrics/${opts.pathId}`;
|
|
698
823
|
break;
|
|
@@ -705,18 +830,62 @@ const _ParaCore = class _ParaCore {
|
|
|
705
830
|
path = "/web/biometrics/login";
|
|
706
831
|
break;
|
|
707
832
|
}
|
|
833
|
+
case "loginPIN": {
|
|
834
|
+
path = "/web/pin/login";
|
|
835
|
+
break;
|
|
836
|
+
}
|
|
708
837
|
case "txReview": {
|
|
709
838
|
path = `/web/users/${this.userId}/transaction-review/${opts.pathId}`;
|
|
710
839
|
break;
|
|
711
840
|
}
|
|
712
841
|
case "onRamp": {
|
|
713
|
-
path = `/web/users/${this.userId}/on-ramp-transaction/${opts.pathId}`;
|
|
842
|
+
path = `/web/users/${this.userId}/on-ramp-transaction/v2/${opts.pathId}`;
|
|
843
|
+
break;
|
|
844
|
+
}
|
|
845
|
+
case "telegramLoginVerify": {
|
|
846
|
+
path = `/auth/telegram/verify`;
|
|
714
847
|
break;
|
|
715
848
|
}
|
|
716
849
|
case "telegramLogin": {
|
|
717
850
|
path = `/auth/telegram`;
|
|
718
851
|
break;
|
|
719
852
|
}
|
|
853
|
+
case "oAuth": {
|
|
854
|
+
path = `/auth/${opts.oAuthMethod.toLowerCase()}`;
|
|
855
|
+
break;
|
|
856
|
+
}
|
|
857
|
+
case "oAuthCallback": {
|
|
858
|
+
path = `/auth/${opts.oAuthMethod.toLowerCase()}/callback`;
|
|
859
|
+
break;
|
|
860
|
+
}
|
|
861
|
+
case "loginOTP": {
|
|
862
|
+
path = "/auth/otp";
|
|
863
|
+
break;
|
|
864
|
+
}
|
|
865
|
+
case "loginFarcaster": {
|
|
866
|
+
path = "/auth/farcaster";
|
|
867
|
+
break;
|
|
868
|
+
}
|
|
869
|
+
case "switchWallets": {
|
|
870
|
+
path = `/auth/wallets`;
|
|
871
|
+
break;
|
|
872
|
+
}
|
|
873
|
+
case "addNewCredential": {
|
|
874
|
+
path = "/auth/add-new-credential";
|
|
875
|
+
break;
|
|
876
|
+
}
|
|
877
|
+
case "exportPrivateKey": {
|
|
878
|
+
path = `/web/users/${this.userId}/private-key/${opts.pathId}`;
|
|
879
|
+
break;
|
|
880
|
+
}
|
|
881
|
+
case "loginExternalWallet": {
|
|
882
|
+
path = "/auth/external-wallet";
|
|
883
|
+
break;
|
|
884
|
+
}
|
|
885
|
+
case "connectExternalWallet": {
|
|
886
|
+
path = "/auth/connect-external-wallet";
|
|
887
|
+
break;
|
|
888
|
+
}
|
|
720
889
|
default: {
|
|
721
890
|
throw new Error(`invalid URL type ${type}`);
|
|
722
891
|
}
|
|
@@ -735,25 +904,28 @@ const _ParaCore = class _ParaCore {
|
|
|
735
904
|
encryptionKey: (0, import_utils.getPublicKeyHex)(this.loginEncryptionKeyPair),
|
|
736
905
|
sessionId
|
|
737
906
|
};
|
|
738
|
-
const params = __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({
|
|
907
|
+
const params = __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadProps(__spreadValues({
|
|
739
908
|
apiKey: this.ctx.apiKey,
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
909
|
+
origin: typeof window !== "undefined" ? window.location.origin : void 0,
|
|
910
|
+
partnerId: partner == null ? void 0 : partner.id
|
|
911
|
+
}, typeof window !== "undefined" && ((_b = window.location) == null ? void 0 : _b.origin) ? { origin: window.location.origin } : {}), {
|
|
912
|
+
portalFont: ((_c = opts.portalTheme) == null ? void 0 : _c.font) || ((_d = this.portalTheme) == null ? void 0 : _d.font) || (partner == null ? void 0 : partner.font),
|
|
913
|
+
portalBorderRadius: ((_e = opts.portalTheme) == null ? void 0 : _e.borderRadius) || ((_f = this.portalTheme) == null ? void 0 : _f.borderRadius),
|
|
914
|
+
portalThemeMode: ((_g = opts.portalTheme) == null ? void 0 : _g.mode) || ((_h = this.portalTheme) == null ? void 0 : _h.mode) || (partner == null ? void 0 : partner.themeMode),
|
|
915
|
+
portalAccentColor: ((_i = opts.portalTheme) == null ? void 0 : _i.accentColor) || ((_j = this.portalTheme) == null ? void 0 : _j.accentColor) || (partner == null ? void 0 : partner.accentColor),
|
|
916
|
+
portalForegroundColor: ((_k = opts.portalTheme) == null ? void 0 : _k.foregroundColor) || ((_l = this.portalTheme) == null ? void 0 : _l.foregroundColor) || (partner == null ? void 0 : partner.foregroundColor),
|
|
917
|
+
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
918
|
portalPrimaryButtonColor: this.portalPrimaryButtonColor,
|
|
748
919
|
portalTextColor: this.portalTextColor,
|
|
749
920
|
portalPrimaryButtonTextColor: this.portalPrimaryButtonTextColor,
|
|
750
921
|
isForNewDevice: opts.isForNewDevice ? opts.isForNewDevice.toString() : void 0
|
|
751
|
-
}, isCreate || isLogin ? __spreadProps(__spreadValues({
|
|
922
|
+
}), this.authInfo && (isCreate || isLogin || isAddNewCredential || isOAuthCallback || isSwitchWallets || isExportPrivateKey) ? __spreadProps(__spreadValues({
|
|
752
923
|
authInfo: JSON.stringify(this.authInfo)
|
|
753
924
|
}, (0, import_user_management_client.isPhone)(this.authInfo.auth) ? (0, import_utils2.splitPhoneNumber)(this.authInfo.auth.phone) : this.authInfo.auth), {
|
|
754
925
|
pfpUrl: this.authInfo.pfpUrl,
|
|
755
|
-
displayName: this.authInfo.displayName
|
|
756
|
-
|
|
926
|
+
displayName: this.authInfo.displayName,
|
|
927
|
+
userId: this.userId
|
|
928
|
+
}) : {}), isOnRamp ? { email: this.email } : {}), isLogin || isOAuth || isOAuthCallback || isTelegramLogin || isFarcasterLogin || isAddNewCredential ? __spreadProps(__spreadValues({
|
|
757
929
|
sessionId: thisDevice.sessionId,
|
|
758
930
|
encryptionKey: thisDevice.encryptionKey
|
|
759
931
|
}, opts.newDevice ? {
|
|
@@ -761,7 +933,17 @@ const _ParaCore = class _ParaCore {
|
|
|
761
933
|
newDeviceEncryptionKey: opts.newDevice.encryptionKey
|
|
762
934
|
} : {}), {
|
|
763
935
|
pregenIds: JSON.stringify(this.pregenIds)
|
|
764
|
-
}) : {}),
|
|
936
|
+
}) : {}), isOAuth || isOAuthCallback || isFarcasterLogin ? {
|
|
937
|
+
appScheme: opts.appScheme
|
|
938
|
+
} : {}), 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() }), {
|
|
939
|
+
addNewCredentialPasskeyId: opts.addNewCredentialPasskeyId,
|
|
940
|
+
addNewCredentialPasswordId: opts.addNewCredentialPasswordId
|
|
941
|
+
}) : {}), isLogin && {
|
|
942
|
+
// Prior versions won't have this param which will skip the upgrade prompt
|
|
943
|
+
isBasicLoginUpgradeVersion: "true"
|
|
944
|
+
}), isExportPrivateKey ? {
|
|
945
|
+
sessionId: thisDevice.sessionId
|
|
946
|
+
} : {});
|
|
765
947
|
const url = (0, import_utils2.constructUrl)({ base, path, params });
|
|
766
948
|
if (opts.shorten) {
|
|
767
949
|
return (0, import_utils2.shortenUrl)(this.ctx, url);
|
|
@@ -769,15 +951,75 @@ const _ParaCore = class _ParaCore {
|
|
|
769
951
|
return url;
|
|
770
952
|
});
|
|
771
953
|
}
|
|
954
|
+
static resolveEnvironment(env, apiKey) {
|
|
955
|
+
var _a;
|
|
956
|
+
if (!apiKey) {
|
|
957
|
+
throw new Error("A Para API key is required.");
|
|
958
|
+
}
|
|
959
|
+
if (apiKey.includes("_")) {
|
|
960
|
+
const validEnvironmentPrefixes = Object.values(import_types.Environment);
|
|
961
|
+
const envPrefix = (_a = apiKey.split("_")[0]) == null ? void 0 : _a.toUpperCase();
|
|
962
|
+
const hasValidPrefix = validEnvironmentPrefixes.some((envValue) => envValue === envPrefix);
|
|
963
|
+
if (!hasValidPrefix) {
|
|
964
|
+
throw new Error(`Invalid API key environment prefix.`);
|
|
965
|
+
}
|
|
966
|
+
return envPrefix;
|
|
967
|
+
}
|
|
968
|
+
if (!env) {
|
|
969
|
+
throw new Error("Environment parameter is required.");
|
|
970
|
+
}
|
|
971
|
+
return env;
|
|
972
|
+
}
|
|
772
973
|
touchSession(regenerate = false) {
|
|
773
974
|
return __async(this, null, function* () {
|
|
774
|
-
var _a, _b, _c;
|
|
975
|
+
var _a, _b, _c, _d, _e;
|
|
976
|
+
if (!this.isWorkerInitialized) {
|
|
977
|
+
this.initializeWorker();
|
|
978
|
+
}
|
|
775
979
|
if (!this.isReady) {
|
|
776
980
|
yield this.ready();
|
|
777
981
|
}
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
yield
|
|
982
|
+
let session;
|
|
983
|
+
try {
|
|
984
|
+
session = yield this.ctx.client.touchSession(regenerate);
|
|
985
|
+
} catch (error) {
|
|
986
|
+
this.handleTouchSessionError(error);
|
|
987
|
+
throw error;
|
|
988
|
+
}
|
|
989
|
+
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) {
|
|
990
|
+
if (!session.partnerId && !this.isPortal()) {
|
|
991
|
+
this.displayModalError(
|
|
992
|
+
`Invalid API Key. Please ensure you have a valid API key for the current environment: ${(_d = this.ctx.env) == null ? void 0 : _d.toUpperCase()}.`
|
|
993
|
+
);
|
|
994
|
+
console.error(`
|
|
995
|
+
\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
|
|
996
|
+
\u{1F6A8} PARA SDK CONFIGURATION ERROR \u{1F6A8}
|
|
997
|
+
|
|
998
|
+
INVALID API KEY FOR CONFIGURED ENVIRONMENT
|
|
999
|
+
|
|
1000
|
+
Your API key does not match the configured environment. This usually means:
|
|
1001
|
+
|
|
1002
|
+
1. You're using a production API key with a development environment
|
|
1003
|
+
2. You're using a development API key with a production environment
|
|
1004
|
+
3. Your API key is invalid or has been regenerated
|
|
1005
|
+
|
|
1006
|
+
SOLUTION:
|
|
1007
|
+
\u2022 Verify your API key at: https://developer.getpara.com
|
|
1008
|
+
\u2022 If your API key doesn't contain an environment prefix, ensure your API key is the correct key for your target environment
|
|
1009
|
+
|
|
1010
|
+
Current Environment: ${this.ctx.env}
|
|
1011
|
+
API Key Prefix: ${((_e = this.ctx.apiKey) == null ? void 0 : _e.split("_")[0].toUpperCase()) || "None"}
|
|
1012
|
+
|
|
1013
|
+
Need help? Visit: https://docs.getpara.com or contact support
|
|
1014
|
+
\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
|
|
1015
|
+
`);
|
|
1016
|
+
throw new Error("Invalid API Key.");
|
|
1017
|
+
} else {
|
|
1018
|
+
yield __privateMethod(this, _ParaCore_instances, getPartner_fn).call(this, session.partnerId);
|
|
1019
|
+
}
|
|
1020
|
+
}
|
|
1021
|
+
if (session.currentWalletIds && !(0, import_utils2.currentWalletIdsEq)(session.currentWalletIds, this.currentWalletIds)) {
|
|
1022
|
+
yield this.setCurrentWalletIds(session.currentWalletIds);
|
|
781
1023
|
}
|
|
782
1024
|
return session;
|
|
783
1025
|
});
|
|
@@ -876,8 +1118,35 @@ const _ParaCore = class _ParaCore {
|
|
|
876
1118
|
return __privateGet(this, _authInfo);
|
|
877
1119
|
});
|
|
878
1120
|
}
|
|
879
|
-
|
|
880
|
-
|
|
1121
|
+
/**
|
|
1122
|
+
* Display an error message in the modal (if available)
|
|
1123
|
+
* @internal
|
|
1124
|
+
*/
|
|
1125
|
+
displayModalError(error) {
|
|
1126
|
+
if (this.ctx.env !== import_types.Environment.PROD) {
|
|
1127
|
+
this.setModalError(error);
|
|
1128
|
+
}
|
|
1129
|
+
}
|
|
1130
|
+
/**
|
|
1131
|
+
* Handle specific touchSession errors with user-friendly messages
|
|
1132
|
+
* @private
|
|
1133
|
+
*/
|
|
1134
|
+
handleTouchSessionError(error) {
|
|
1135
|
+
const errorStr = String(error);
|
|
1136
|
+
const errorMessage = error instanceof Error ? error.message : "";
|
|
1137
|
+
if (errorStr.includes("blocked by CORS policy") && errorStr.includes("Access-Control-Allow-Origin")) {
|
|
1138
|
+
this.displayModalError("Request rate limit reached. Please wait a couple of minutes and try again.");
|
|
1139
|
+
return;
|
|
1140
|
+
}
|
|
1141
|
+
if (error.status === 403 && errorMessage.includes("origin not authorized")) {
|
|
1142
|
+
this.displayModalError(
|
|
1143
|
+
"The current origin is not allowed. Update your allowed origins in the Para developer portal to allow the current origin."
|
|
1144
|
+
);
|
|
1145
|
+
return;
|
|
1146
|
+
}
|
|
1147
|
+
}
|
|
1148
|
+
assertUserId({ allowGuestMode = false } = {}) {
|
|
1149
|
+
if (!this.userId || !allowGuestMode && this.isGuestMode) {
|
|
881
1150
|
throw new Error("no userId is set");
|
|
882
1151
|
}
|
|
883
1152
|
return this.userId;
|
|
@@ -935,11 +1204,59 @@ const _ParaCore = class _ParaCore {
|
|
|
935
1204
|
*/
|
|
936
1205
|
setExternalWallet(externalWallet) {
|
|
937
1206
|
return __async(this, null, function* () {
|
|
1207
|
+
const { id: partnerId, supportedWalletTypes } = yield __privateMethod(this, _ParaCore_instances, assertPartner_fn).call(this);
|
|
938
1208
|
this.externalWallets = (Array.isArray(externalWallet) ? externalWallet : [externalWallet]).reduce(
|
|
1209
|
+
(acc, {
|
|
1210
|
+
partnerId: wPartnerId,
|
|
1211
|
+
address,
|
|
1212
|
+
type,
|
|
1213
|
+
provider,
|
|
1214
|
+
providerId,
|
|
1215
|
+
addressBech32,
|
|
1216
|
+
withFullParaAuth,
|
|
1217
|
+
isConnectionOnly,
|
|
1218
|
+
withVerification
|
|
1219
|
+
}) => {
|
|
1220
|
+
if (partnerId === wPartnerId && supportedWalletTypes.some(({ type: supportedType }) => supportedType === type)) {
|
|
1221
|
+
return __spreadProps(__spreadValues({}, acc), {
|
|
1222
|
+
[address]: {
|
|
1223
|
+
id: address,
|
|
1224
|
+
partnerId,
|
|
1225
|
+
address: addressBech32 != null ? addressBech32 : address,
|
|
1226
|
+
type,
|
|
1227
|
+
name: provider,
|
|
1228
|
+
isExternal: true,
|
|
1229
|
+
isExternalWithParaAuth: withFullParaAuth,
|
|
1230
|
+
externalProviderId: providerId,
|
|
1231
|
+
signer: "",
|
|
1232
|
+
isExternalConnectionOnly: isConnectionOnly,
|
|
1233
|
+
isExternalWithVerification: withVerification
|
|
1234
|
+
}
|
|
1235
|
+
});
|
|
1236
|
+
}
|
|
1237
|
+
return acc;
|
|
1238
|
+
},
|
|
1239
|
+
{}
|
|
1240
|
+
), this.setExternalWallets(this.externalWallets);
|
|
1241
|
+
(0, import_utils2.dispatchEvent)(import_types.ParaEvent.EXTERNAL_WALLET_CHANGE_EVENT, null);
|
|
1242
|
+
});
|
|
1243
|
+
}
|
|
1244
|
+
addExternalWallets(externalWallets) {
|
|
1245
|
+
return __async(this, null, function* () {
|
|
1246
|
+
const { id: partnerId, supportedWalletTypes } = yield __privateMethod(this, _ParaCore_instances, assertPartner_fn).call(this);
|
|
1247
|
+
this.externalWallets = __spreadValues(__spreadValues({}, Object.entries(this.externalWallets).reduce((acc, [address, wallet]) => {
|
|
1248
|
+
if (partnerId === wallet.partnerId && supportedWalletTypes.some(({ type }) => type === wallet.type)) {
|
|
1249
|
+
return __spreadProps(__spreadValues({}, acc), {
|
|
1250
|
+
[address]: wallet
|
|
1251
|
+
});
|
|
1252
|
+
}
|
|
1253
|
+
return acc;
|
|
1254
|
+
}, {})), externalWallets.reduce(
|
|
939
1255
|
(acc, { address, type, provider, providerId, addressBech32, withFullParaAuth, isConnectionOnly, withVerification }) => {
|
|
940
1256
|
return __spreadProps(__spreadValues({}, acc), {
|
|
941
1257
|
[address]: {
|
|
942
1258
|
id: address,
|
|
1259
|
+
partnerId,
|
|
943
1260
|
address: addressBech32 != null ? addressBech32 : address,
|
|
944
1261
|
type,
|
|
945
1262
|
name: provider,
|
|
@@ -953,7 +1270,7 @@ const _ParaCore = class _ParaCore {
|
|
|
953
1270
|
});
|
|
954
1271
|
},
|
|
955
1272
|
{}
|
|
956
|
-
);
|
|
1273
|
+
));
|
|
957
1274
|
this.setExternalWallets(this.externalWallets);
|
|
958
1275
|
(0, import_utils2.dispatchEvent)(import_types.ParaEvent.EXTERNAL_WALLET_CHANGE_EVENT, null);
|
|
959
1276
|
});
|
|
@@ -984,12 +1301,16 @@ const _ParaCore = class _ParaCore {
|
|
|
984
1301
|
}
|
|
985
1302
|
/**
|
|
986
1303
|
* Sets the external wallets associated with the `ParaCore` instance.
|
|
987
|
-
* @param externalWallets - External wallets to set.
|
|
1304
|
+
* @param externalWallets - External wallets to set, or a function that modifies the current wallets.
|
|
988
1305
|
*/
|
|
989
1306
|
setExternalWallets(externalWallets) {
|
|
990
1307
|
return __async(this, null, function* () {
|
|
991
|
-
|
|
992
|
-
|
|
1308
|
+
if (typeof externalWallets === "function") {
|
|
1309
|
+
this.externalWallets = externalWallets(this.externalWallets);
|
|
1310
|
+
} else {
|
|
1311
|
+
this.externalWallets = externalWallets;
|
|
1312
|
+
}
|
|
1313
|
+
yield this.localStorageSetItem(constants.LOCAL_STORAGE_EXTERNAL_WALLETS, JSON.stringify(this.externalWallets));
|
|
993
1314
|
});
|
|
994
1315
|
}
|
|
995
1316
|
/**
|
|
@@ -1158,14 +1479,27 @@ const _ParaCore = class _ParaCore {
|
|
|
1158
1479
|
...[...this.currentWalletIdsArray, ...__privateGet(this, _ParaCore_instances, guestWalletIdsArray_get)].map(([address, type]) => [address, type, false]).map(([id, type]) => {
|
|
1159
1480
|
const wallet = this.findWallet(id, type);
|
|
1160
1481
|
if (!wallet) return null;
|
|
1482
|
+
const name = wallet.name;
|
|
1483
|
+
const address = this.getDisplayAddress(id, { addressType: type });
|
|
1484
|
+
const addressShort = this.getDisplayAddress(id, { addressType: type, truncate: true });
|
|
1161
1485
|
return {
|
|
1162
1486
|
id: wallet.id,
|
|
1487
|
+
partner: wallet.partner,
|
|
1163
1488
|
type,
|
|
1164
|
-
address
|
|
1165
|
-
name
|
|
1489
|
+
address,
|
|
1490
|
+
name,
|
|
1491
|
+
addressShort,
|
|
1492
|
+
displayName: name != null ? name : addressShort,
|
|
1493
|
+
ensName: wallet.ensName,
|
|
1494
|
+
ensAvatar: wallet.ensAvatar
|
|
1166
1495
|
};
|
|
1167
1496
|
}).filter((obj) => obj !== null),
|
|
1168
|
-
...Object.values((_a = this.externalWallets) != null ? _a : {})
|
|
1497
|
+
...Object.values((_a = this.externalWallets) != null ? _a : {}).map((wallet) => {
|
|
1498
|
+
return __spreadProps(__spreadValues({}, wallet), {
|
|
1499
|
+
addressShort: (0, import_utils2.truncateAddress)(wallet.address, wallet.type, { prefix: this.cosmosPrefix }),
|
|
1500
|
+
displayName: wallet.externalProviderId
|
|
1501
|
+
});
|
|
1502
|
+
})
|
|
1169
1503
|
];
|
|
1170
1504
|
}
|
|
1171
1505
|
/**
|
|
@@ -1264,13 +1598,13 @@ const _ParaCore = class _ParaCore {
|
|
|
1264
1598
|
return __async(this, null, function* () {
|
|
1265
1599
|
const res = yield this.isPortal() || this.isParaConnect() ? this.ctx.client.getAllWallets(this.userId) : this.ctx.client.getWallets(this.userId, true);
|
|
1266
1600
|
return res.data.wallets.filter(
|
|
1267
|
-
(wallet) => !!wallet.address && (this.isParaConnect() || !this.isParaConnect() && this.isWalletSupported((0, import_utils2.entityToWallet)(wallet)))
|
|
1601
|
+
(wallet) => !!wallet.address && wallet.sharesPersisted && (this.isParaConnect() || !this.isParaConnect() && this.isWalletSupported((0, import_utils2.entityToWallet)(wallet)))
|
|
1268
1602
|
);
|
|
1269
1603
|
});
|
|
1270
1604
|
}
|
|
1271
1605
|
populateWalletAddresses() {
|
|
1272
1606
|
return __async(this, null, function* () {
|
|
1273
|
-
const res = yield this.ctx.client.getWallets(this.userId, true);
|
|
1607
|
+
const res = yield (this.isPortal() ? this.ctx.client.getAllWallets : this.ctx.client.getWallets)(this.userId, true);
|
|
1274
1608
|
const wallets = res.data.wallets;
|
|
1275
1609
|
wallets.forEach((entity) => {
|
|
1276
1610
|
if (this.wallets[entity.id]) {
|
|
@@ -1301,13 +1635,28 @@ const _ParaCore = class _ParaCore {
|
|
|
1301
1635
|
loginExternalWallet(_a) {
|
|
1302
1636
|
return __async(this, null, function* () {
|
|
1303
1637
|
var _b = _a, {
|
|
1304
|
-
externalWallet
|
|
1638
|
+
externalWallet,
|
|
1639
|
+
chainId,
|
|
1640
|
+
uri
|
|
1305
1641
|
} = _b, urlOptions = __objRest(_b, [
|
|
1306
|
-
"externalWallet"
|
|
1642
|
+
"externalWallet",
|
|
1643
|
+
"chainId",
|
|
1644
|
+
"uri"
|
|
1307
1645
|
]);
|
|
1308
1646
|
const externalWallets = Array.isArray(externalWallet) ? externalWallet : [externalWallet];
|
|
1647
|
+
try {
|
|
1648
|
+
yield this.ctx.client.trackExternalWalletConnections({
|
|
1649
|
+
wallets: externalWallets.map((wallet) => ({
|
|
1650
|
+
address: wallet.address,
|
|
1651
|
+
type: wallet.type,
|
|
1652
|
+
provider: wallet.provider
|
|
1653
|
+
}))
|
|
1654
|
+
});
|
|
1655
|
+
} catch (err) {
|
|
1656
|
+
console.error("Error tracking external wallet connections:", err);
|
|
1657
|
+
}
|
|
1309
1658
|
if (this.externalWalletConnectionOnly || externalWallets.every((wallet) => wallet.isConnectionOnly)) {
|
|
1310
|
-
yield this.
|
|
1659
|
+
yield this.addExternalWallets(
|
|
1311
1660
|
externalWallets.map((wallet) => __spreadProps(__spreadValues({}, wallet), {
|
|
1312
1661
|
withFullParaAuth: false
|
|
1313
1662
|
}))
|
|
@@ -1322,33 +1671,47 @@ const _ParaCore = class _ParaCore {
|
|
|
1322
1671
|
);
|
|
1323
1672
|
}
|
|
1324
1673
|
this.requireApiKey();
|
|
1325
|
-
const serverAuthState = yield this.ctx.client.loginExternalWallet({ externalWallet });
|
|
1674
|
+
const serverAuthState = yield this.ctx.client.loginExternalWallet({ externalWallet, chainId, uri });
|
|
1326
1675
|
if (!externalWallet.withFullParaAuth && externalWallet.withVerification) {
|
|
1327
1676
|
yield this.touchSession(true);
|
|
1328
1677
|
}
|
|
1678
|
+
if (externalWallet.withFullParaAuth) {
|
|
1679
|
+
yield this.ctx.client.sessionAddPortalVerification();
|
|
1680
|
+
}
|
|
1329
1681
|
return __privateMethod(this, _ParaCore_instances, prepareAuthState_fn).call(this, serverAuthState, urlOptions);
|
|
1330
1682
|
});
|
|
1331
1683
|
}
|
|
1332
|
-
verifyExternalWallet(
|
|
1684
|
+
verifyExternalWallet(params) {
|
|
1333
1685
|
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
|
-
|
|
1686
|
+
var _c;
|
|
1687
|
+
let serverAuthState;
|
|
1688
|
+
let urlOptions;
|
|
1689
|
+
if ("serverAuthState" in params && params.serverAuthState !== void 0) {
|
|
1690
|
+
const _a = params, { serverAuthState: optsServerAuthState } = _a, rest = __objRest(_a, ["serverAuthState"]);
|
|
1691
|
+
serverAuthState = optsServerAuthState;
|
|
1692
|
+
urlOptions = rest;
|
|
1693
|
+
} else if ("externalWallet" in params) {
|
|
1694
|
+
const _b = params, { externalWallet, signedMessage, cosmosPublicKeyHex, cosmosSigner } = _b, rest = __objRest(_b, ["externalWallet", "signedMessage", "cosmosPublicKeyHex", "cosmosSigner"]);
|
|
1695
|
+
const _serverAuthState = yield this.ctx.client.verifyExternalWallet(this.userId, {
|
|
1696
|
+
externalWallet,
|
|
1697
|
+
signedMessage,
|
|
1698
|
+
cosmosPublicKeyHex,
|
|
1699
|
+
cosmosSigner
|
|
1700
|
+
});
|
|
1701
|
+
serverAuthState = _serverAuthState;
|
|
1702
|
+
urlOptions = rest;
|
|
1703
|
+
}
|
|
1704
|
+
if (serverAuthState.stage === "login" && ((_c = serverAuthState.loginAuthMethods) == null ? void 0 : _c.includes(import_user_management_client.AuthMethod.PIN))) {
|
|
1705
|
+
const { sessionLookupId } = yield this.touchSession();
|
|
1706
|
+
return yield __privateMethod(this, _ParaCore_instances, prepareLoginState_fn).call(this, serverAuthState, __spreadProps(__spreadValues({}, urlOptions), { sessionLookupId }));
|
|
1707
|
+
}
|
|
1708
|
+
let state;
|
|
1709
|
+
try {
|
|
1710
|
+
state = yield __privateMethod(this, _ParaCore_instances, prepareAuthState_fn).call(this, serverAuthState, urlOptions);
|
|
1711
|
+
} catch (err) {
|
|
1712
|
+
console.error("Error prepping state:", err);
|
|
1713
|
+
}
|
|
1714
|
+
return state;
|
|
1352
1715
|
});
|
|
1353
1716
|
}
|
|
1354
1717
|
verifyExternalWalletLink(opts) {
|
|
@@ -1364,28 +1727,38 @@ const _ParaCore = class _ParaCore {
|
|
|
1364
1727
|
return accounts;
|
|
1365
1728
|
});
|
|
1366
1729
|
}
|
|
1730
|
+
// TELEGRAM
|
|
1367
1731
|
/**
|
|
1368
1732
|
* Validates the response received from an attempted Telegram login for authenticity, then
|
|
1369
1733
|
* creates or retrieves the corresponding Para user and prepares the Para instance to sign in with that user.
|
|
1370
1734
|
* @param authResponse - the response JSON object received from the Telegram widget.
|
|
1371
1735
|
* @returns `{ isValid: boolean; telegramUserId?: string; userId?: string; isNewUser?: boolean; supportedAuthMethods?: AuthMethod[]; biometricHints?: BiometricLocationHint[] }`
|
|
1372
1736
|
*/
|
|
1373
|
-
verifyTelegramProcess(
|
|
1737
|
+
verifyTelegramProcess(_c) {
|
|
1374
1738
|
return __async(this, null, function* () {
|
|
1375
|
-
var
|
|
1739
|
+
var _d = _c, {
|
|
1740
|
+
serverAuthState: optsServerAuthState,
|
|
1376
1741
|
telegramAuthResponse,
|
|
1377
1742
|
isLinkAccount
|
|
1378
|
-
} =
|
|
1743
|
+
} = _d, urlOptions = __objRest(_d, [
|
|
1744
|
+
"serverAuthState",
|
|
1379
1745
|
"telegramAuthResponse",
|
|
1380
1746
|
"isLinkAccount"
|
|
1381
1747
|
]);
|
|
1382
1748
|
try {
|
|
1383
1749
|
switch (isLinkAccount) {
|
|
1384
1750
|
case false: {
|
|
1385
|
-
|
|
1386
|
-
|
|
1751
|
+
if (!optsServerAuthState && !telegramAuthResponse) {
|
|
1752
|
+
throw new Error("one of serverAuthState or telegramAuthResponse are required for verifying telegram");
|
|
1753
|
+
}
|
|
1754
|
+
const serverAuthState = optsServerAuthState != null ? optsServerAuthState : yield this.ctx.client.verifyTelegram({ authObject: telegramAuthResponse });
|
|
1755
|
+
const { sessionLookupId } = yield this.touchSession();
|
|
1756
|
+
return __privateMethod(this, _ParaCore_instances, prepareAuthState_fn).call(this, serverAuthState, __spreadProps(__spreadValues({}, urlOptions), { sessionLookupId }));
|
|
1387
1757
|
}
|
|
1388
1758
|
case true: {
|
|
1759
|
+
if (!telegramAuthResponse) {
|
|
1760
|
+
throw new Error("telegramAuthResponse is required for verifying telegram link");
|
|
1761
|
+
}
|
|
1389
1762
|
const accountLinkInProgress = yield __privateMethod(this, _ParaCore_instances, assertIsLinkingAccountOrStart_fn).call(this, "TELEGRAM");
|
|
1390
1763
|
const accounts = yield this.verifyLink({
|
|
1391
1764
|
accountLinkInProgress,
|
|
@@ -1395,7 +1768,8 @@ const _ParaCore = class _ParaCore {
|
|
|
1395
1768
|
}
|
|
1396
1769
|
}
|
|
1397
1770
|
} catch (e) {
|
|
1398
|
-
|
|
1771
|
+
const errorMessage = e instanceof Error ? e.message : e ? String(e) : "Unknown error occurred";
|
|
1772
|
+
throw new Error(errorMessage);
|
|
1399
1773
|
}
|
|
1400
1774
|
});
|
|
1401
1775
|
}
|
|
@@ -1459,6 +1833,7 @@ const _ParaCore = class _ParaCore {
|
|
|
1459
1833
|
let type, linkedAccountId;
|
|
1460
1834
|
switch (reason) {
|
|
1461
1835
|
case "SIGNUP":
|
|
1836
|
+
case "LOGIN":
|
|
1462
1837
|
{
|
|
1463
1838
|
const authInfo = this.assertIsAuthSet(["email", "phone"]);
|
|
1464
1839
|
type = authInfo.authType.toUpperCase();
|
|
@@ -1472,7 +1847,7 @@ const _ParaCore = class _ParaCore {
|
|
|
1472
1847
|
}
|
|
1473
1848
|
break;
|
|
1474
1849
|
}
|
|
1475
|
-
const userId = this.assertUserId();
|
|
1850
|
+
const userId = this.assertUserId({ allowGuestMode: true });
|
|
1476
1851
|
if (type !== "EMAIL" && type !== "PHONE") {
|
|
1477
1852
|
throw new Error("invalid auth type for verification code");
|
|
1478
1853
|
}
|
|
@@ -1510,6 +1885,9 @@ const _ParaCore = class _ParaCore {
|
|
|
1510
1885
|
isFullyLoggedIn() {
|
|
1511
1886
|
return __async(this, null, function* () {
|
|
1512
1887
|
if (this.externalWalletConnectionType === "CONNECTION_ONLY") {
|
|
1888
|
+
if (!this.isReady) {
|
|
1889
|
+
yield this.ready();
|
|
1890
|
+
}
|
|
1513
1891
|
return true;
|
|
1514
1892
|
}
|
|
1515
1893
|
if (this.isGuestMode) {
|
|
@@ -1519,17 +1897,45 @@ const _ParaCore = class _ParaCore {
|
|
|
1519
1897
|
if (this.externalWalletConnectionType === "VERIFICATION") {
|
|
1520
1898
|
return isSessionActive;
|
|
1521
1899
|
}
|
|
1522
|
-
|
|
1900
|
+
if (this.isSwitchingWallets) {
|
|
1901
|
+
return isSessionActive;
|
|
1902
|
+
}
|
|
1903
|
+
if (!isSessionActive) {
|
|
1904
|
+
return false;
|
|
1905
|
+
}
|
|
1906
|
+
if (this.isNoWalletConfig) {
|
|
1907
|
+
return true;
|
|
1908
|
+
}
|
|
1909
|
+
const { supportedWalletTypes } = yield __privateMethod(this, _ParaCore_instances, assertPartner_fn).call(this);
|
|
1910
|
+
const requiredWalletTypes = supportedWalletTypes.filter(({ optional }) => !optional);
|
|
1911
|
+
for (const { type } of requiredWalletTypes) {
|
|
1912
|
+
const hasWalletForType = this.currentWalletIdsArray.some(([walletId, walletType]) => {
|
|
1913
|
+
try {
|
|
1914
|
+
const wallet = this.wallets[walletId];
|
|
1915
|
+
return wallet && walletType === type && typeof wallet.address === "string";
|
|
1916
|
+
} catch (e) {
|
|
1917
|
+
return false;
|
|
1918
|
+
}
|
|
1919
|
+
});
|
|
1920
|
+
if (!hasWalletForType) {
|
|
1921
|
+
return false;
|
|
1922
|
+
}
|
|
1923
|
+
}
|
|
1924
|
+
return true;
|
|
1523
1925
|
});
|
|
1524
1926
|
}
|
|
1525
1927
|
get isGuestMode() {
|
|
1526
1928
|
return __privateGet(this, _ParaCore_instances, guestWalletIdsArray_get).length > 0 && Object.values(this.wallets).every(
|
|
1527
1929
|
({ userId, partnerId }) => {
|
|
1528
1930
|
var _a;
|
|
1529
|
-
return partnerId === ((_a =
|
|
1931
|
+
return partnerId === ((_a = this.partner) == null ? void 0 : _a.id) && (!userId || userId !== this.userId);
|
|
1530
1932
|
}
|
|
1531
1933
|
);
|
|
1532
1934
|
}
|
|
1935
|
+
/**
|
|
1936
|
+
* Get the auth methods available to an existing user
|
|
1937
|
+
* @deprecated Use supportedUserAuthMethods instead
|
|
1938
|
+
*/
|
|
1533
1939
|
supportedAuthMethods(auth) {
|
|
1534
1940
|
return __async(this, null, function* () {
|
|
1535
1941
|
const { supportedAuthMethods } = yield this.ctx.client.getSupportedAuthMethods(auth);
|
|
@@ -1547,6 +1953,37 @@ const _ParaCore = class _ParaCore {
|
|
|
1547
1953
|
return authMethods;
|
|
1548
1954
|
});
|
|
1549
1955
|
}
|
|
1956
|
+
/**
|
|
1957
|
+
* Get the auth methods available to an existing user
|
|
1958
|
+
*/
|
|
1959
|
+
supportedUserAuthMethods() {
|
|
1960
|
+
return __async(this, null, function* () {
|
|
1961
|
+
yield this.assertIsAuthSet();
|
|
1962
|
+
const { supportedAuthMethods, hasPasswordWithoutPIN } = yield this.ctx.client.getSupportedAuthMethodsV2(
|
|
1963
|
+
this.authInfo.auth
|
|
1964
|
+
);
|
|
1965
|
+
const authMethods = /* @__PURE__ */ new Set();
|
|
1966
|
+
for (const type of supportedAuthMethods) {
|
|
1967
|
+
switch (type) {
|
|
1968
|
+
case "PASSWORD":
|
|
1969
|
+
if (hasPasswordWithoutPIN) {
|
|
1970
|
+
authMethods.add(import_user_management_client.AuthMethod.PASSWORD);
|
|
1971
|
+
}
|
|
1972
|
+
break;
|
|
1973
|
+
case "PASSKEY":
|
|
1974
|
+
authMethods.add(import_user_management_client.AuthMethod.PASSKEY);
|
|
1975
|
+
break;
|
|
1976
|
+
case "PIN":
|
|
1977
|
+
authMethods.add(import_user_management_client.AuthMethod.PIN);
|
|
1978
|
+
break;
|
|
1979
|
+
case "BASIC_LOGIN":
|
|
1980
|
+
authMethods.add(import_user_management_client.AuthMethod.BASIC_LOGIN);
|
|
1981
|
+
break;
|
|
1982
|
+
}
|
|
1983
|
+
}
|
|
1984
|
+
return authMethods;
|
|
1985
|
+
});
|
|
1986
|
+
}
|
|
1550
1987
|
/**
|
|
1551
1988
|
* Get hints associated with the users stored biometrics.
|
|
1552
1989
|
* @deprecated
|
|
@@ -1633,26 +2070,33 @@ const _ParaCore = class _ParaCore {
|
|
|
1633
2070
|
return connectUri;
|
|
1634
2071
|
});
|
|
1635
2072
|
}
|
|
2073
|
+
// FARCASTER
|
|
1636
2074
|
/**
|
|
1637
2075
|
* Awaits the response from a user's attempt to log in with Farcaster.
|
|
1638
2076
|
* If successful, this returns the user's Farcaster username and profile picture and indicates whether the user already exists.
|
|
1639
2077
|
* @return {Object} `{userExists: boolean; username: string; pfpUrl?: string | null }` - the user's information and whether the user already exists.
|
|
1640
2078
|
*/
|
|
1641
|
-
verifyFarcasterProcess(
|
|
2079
|
+
verifyFarcasterProcess(_e) {
|
|
1642
2080
|
return __async(this, null, function* () {
|
|
1643
|
-
var
|
|
2081
|
+
var _f = _e, {
|
|
1644
2082
|
isCanceled = () => false,
|
|
1645
2083
|
onConnectUri,
|
|
1646
2084
|
onCancel,
|
|
1647
2085
|
onPoll,
|
|
1648
|
-
isLinkAccount
|
|
1649
|
-
|
|
2086
|
+
isLinkAccount,
|
|
2087
|
+
serverAuthState: optsServerAuthState
|
|
2088
|
+
} = _f, urlOptions = __objRest(_f, [
|
|
1650
2089
|
"isCanceled",
|
|
1651
2090
|
"onConnectUri",
|
|
1652
2091
|
"onCancel",
|
|
1653
2092
|
"onPoll",
|
|
1654
|
-
"isLinkAccount"
|
|
2093
|
+
"isLinkAccount",
|
|
2094
|
+
"serverAuthState"
|
|
1655
2095
|
]);
|
|
2096
|
+
if (optsServerAuthState) {
|
|
2097
|
+
const authState = yield __privateMethod(this, _ParaCore_instances, prepareAuthState_fn).call(this, optsServerAuthState, urlOptions);
|
|
2098
|
+
return authState;
|
|
2099
|
+
}
|
|
1656
2100
|
let accountLinkInProgress;
|
|
1657
2101
|
if (isLinkAccount) {
|
|
1658
2102
|
accountLinkInProgress = yield __privateMethod(this, _ParaCore_instances, assertIsLinkingAccountOrStart_fn).call(this, "FARCASTER");
|
|
@@ -1714,7 +2158,9 @@ const _ParaCore = class _ParaCore {
|
|
|
1714
2158
|
}
|
|
1715
2159
|
getOAuthUrl(opts) {
|
|
1716
2160
|
return __async(this, null, function* () {
|
|
1717
|
-
|
|
2161
|
+
var _a;
|
|
2162
|
+
const sessionLookupId = (_a = opts.sessionLookupId) != null ? _a : yield this.prepareLogin();
|
|
2163
|
+
return __privateMethod(this, _ParaCore_instances, getOAuthUrl_fn).call(this, __spreadProps(__spreadValues({}, opts), { sessionLookupId }));
|
|
1718
2164
|
});
|
|
1719
2165
|
}
|
|
1720
2166
|
/**
|
|
@@ -1725,35 +2171,54 @@ const _ParaCore = class _ParaCore {
|
|
|
1725
2171
|
* @param {Window} [opts.popupWindow] the popup window being used for login.
|
|
1726
2172
|
* @return {Object} `{ email?: string; isError?: boolean; userExists: boolean; }` the result data
|
|
1727
2173
|
*/
|
|
1728
|
-
verifyOAuthProcess(
|
|
2174
|
+
verifyOAuthProcess(_g) {
|
|
1729
2175
|
return __async(this, null, function* () {
|
|
1730
|
-
var
|
|
2176
|
+
var _h = _g, {
|
|
1731
2177
|
method,
|
|
1732
2178
|
appScheme,
|
|
1733
2179
|
isCanceled = () => false,
|
|
1734
2180
|
onCancel,
|
|
1735
2181
|
onPoll,
|
|
1736
2182
|
onOAuthUrl,
|
|
2183
|
+
onOAuthPopup,
|
|
1737
2184
|
isLinkAccount
|
|
1738
|
-
} =
|
|
2185
|
+
} = _h, urlOptions = __objRest(_h, [
|
|
1739
2186
|
"method",
|
|
1740
2187
|
"appScheme",
|
|
1741
2188
|
"isCanceled",
|
|
1742
2189
|
"onCancel",
|
|
1743
2190
|
"onPoll",
|
|
1744
2191
|
"onOAuthUrl",
|
|
2192
|
+
"onOAuthPopup",
|
|
1745
2193
|
"isLinkAccount"
|
|
1746
2194
|
]);
|
|
2195
|
+
if (onOAuthPopup) {
|
|
2196
|
+
try {
|
|
2197
|
+
this.popupWindow = yield this.platformUtils.openPopup("about:blank", { type: import_types.PopupType.OAUTH });
|
|
2198
|
+
} catch (error) {
|
|
2199
|
+
throw new Error(`Failed to open OAuth popup: ${error}`);
|
|
2200
|
+
}
|
|
2201
|
+
}
|
|
1747
2202
|
let sessionLookupId, accountLinkInProgress;
|
|
1748
|
-
if (onOAuthUrl) {
|
|
2203
|
+
if (onOAuthUrl || onOAuthPopup) {
|
|
1749
2204
|
if (isLinkAccount) {
|
|
1750
2205
|
accountLinkInProgress = yield __privateMethod(this, _ParaCore_instances, assertIsLinkingAccountOrStart_fn).call(this, method);
|
|
1751
2206
|
sessionLookupId = (yield this.touchSession()).sessionLookupId;
|
|
1752
2207
|
} else {
|
|
1753
|
-
sessionLookupId = yield
|
|
2208
|
+
sessionLookupId = yield this.prepareLogin();
|
|
1754
2209
|
}
|
|
1755
2210
|
const oAuthUrl = yield __privateMethod(this, _ParaCore_instances, getOAuthUrl_fn).call(this, { method, appScheme, sessionLookupId, accountLinkInProgress });
|
|
1756
|
-
|
|
2211
|
+
switch (true) {
|
|
2212
|
+
case !!onOAuthUrl: {
|
|
2213
|
+
onOAuthUrl(oAuthUrl);
|
|
2214
|
+
break;
|
|
2215
|
+
}
|
|
2216
|
+
case (!!onOAuthPopup && !!this.popupWindow): {
|
|
2217
|
+
this.popupWindow.location.href = oAuthUrl;
|
|
2218
|
+
onOAuthPopup(this.popupWindow);
|
|
2219
|
+
break;
|
|
2220
|
+
}
|
|
2221
|
+
}
|
|
1757
2222
|
} else {
|
|
1758
2223
|
({ sessionLookupId } = yield this.touchSession());
|
|
1759
2224
|
}
|
|
@@ -1812,61 +2277,26 @@ const _ParaCore = class _ParaCore {
|
|
|
1812
2277
|
* @param {boolean} [opts.skipSessionRefresh] whether to skip refreshing the session.
|
|
1813
2278
|
* @returns {Object} `{ isComplete: boolean; isError: boolean; needsWallet: boolean; partnerId: string; }` the result data
|
|
1814
2279
|
**/
|
|
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
|
-
});
|
|
2280
|
+
waitForLogin(args) {
|
|
2281
|
+
return __async(this, null, function* () {
|
|
2282
|
+
return yield __privateMethod(this, _ParaCore_instances, waitForLoginProcess_fn).call(this, args);
|
|
2283
|
+
});
|
|
2284
|
+
}
|
|
2285
|
+
waitForWalletSwitching(args) {
|
|
2286
|
+
return __async(this, null, function* () {
|
|
2287
|
+
return yield __privateMethod(this, _ParaCore_instances, waitForLoginProcess_fn).call(this, __spreadProps(__spreadValues({}, args), { isSwitchingWallets: true }));
|
|
2288
|
+
});
|
|
2289
|
+
}
|
|
2290
|
+
/**
|
|
2291
|
+
* Gets the switch wallets URL for wallet selection.
|
|
2292
|
+
* The authMethod is automatically included in the URL if available.
|
|
2293
|
+
*
|
|
2294
|
+
* @returns {Promise<{ url: string; authMethod: TAuthMethod }>} The switch wallets URL and authMethod
|
|
2295
|
+
*/
|
|
2296
|
+
getSwitchWalletsUrl() {
|
|
2297
|
+
return __async(this, null, function* () {
|
|
2298
|
+
const url = yield this.constructPortalUrl("switchWallets");
|
|
2299
|
+
return url;
|
|
1870
2300
|
});
|
|
1871
2301
|
}
|
|
1872
2302
|
/**
|
|
@@ -1889,7 +2319,7 @@ const _ParaCore = class _ParaCore {
|
|
|
1889
2319
|
sessionId
|
|
1890
2320
|
});
|
|
1891
2321
|
if (shouldOpenPopup) {
|
|
1892
|
-
this.platformUtils.openPopup(link);
|
|
2322
|
+
yield this.platformUtils.openPopup(link);
|
|
1893
2323
|
}
|
|
1894
2324
|
return link;
|
|
1895
2325
|
});
|
|
@@ -1980,7 +2410,9 @@ const _ParaCore = class _ParaCore {
|
|
|
1980
2410
|
userId: this.userId,
|
|
1981
2411
|
walletId,
|
|
1982
2412
|
userShare: userSigner,
|
|
1983
|
-
emailProps: this.getBackupKitEmailProps()
|
|
2413
|
+
emailProps: this.getBackupKitEmailProps(),
|
|
2414
|
+
isEnclaveUser: this.isEnclaveUser,
|
|
2415
|
+
walletScheme: this.wallets[walletId].scheme
|
|
1984
2416
|
});
|
|
1985
2417
|
return recoveryShare;
|
|
1986
2418
|
});
|
|
@@ -1994,7 +2426,7 @@ const _ParaCore = class _ParaCore {
|
|
|
1994
2426
|
break;
|
|
1995
2427
|
}
|
|
1996
2428
|
++maxPolls;
|
|
1997
|
-
const res = yield this.ctx.client.getWallets(this.userId);
|
|
2429
|
+
const res = yield (this.isPortal() ? this.ctx.client.getAllWallets : this.ctx.client.getWallets)(this.userId);
|
|
1998
2430
|
const wallet = res.data.wallets.find((w) => w.id === walletId);
|
|
1999
2431
|
if (wallet && wallet.address) {
|
|
2000
2432
|
return;
|
|
@@ -2108,7 +2540,9 @@ const _ParaCore = class _ParaCore {
|
|
|
2108
2540
|
ignoreRedistributingBackupEncryptedShare: !redistributeBackupEncryptedShares,
|
|
2109
2541
|
emailProps: this.getBackupKitEmailProps(),
|
|
2110
2542
|
partnerId: newPartnerId,
|
|
2111
|
-
protocolId
|
|
2543
|
+
protocolId,
|
|
2544
|
+
isEnclaveUser: this.isEnclaveUser,
|
|
2545
|
+
walletScheme: this.wallets[walletId].scheme
|
|
2112
2546
|
});
|
|
2113
2547
|
return { signer, recoverySecret, protocolId };
|
|
2114
2548
|
});
|
|
@@ -2157,26 +2591,29 @@ const _ParaCore = class _ParaCore {
|
|
|
2157
2591
|
}
|
|
2158
2592
|
}
|
|
2159
2593
|
const walletId = keygenRes.walletId;
|
|
2594
|
+
const walletScheme = walletType === "SOLANA" ? "ED25519" : "DKLS";
|
|
2160
2595
|
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();
|
|
2596
|
+
yield this.waitForWalletAddress(walletId);
|
|
2170
2597
|
let recoveryShare = null;
|
|
2171
2598
|
if (!skipDistribute) {
|
|
2172
2599
|
recoveryShare = yield (0, import_shareDistribution.distributeNewShare)({
|
|
2173
2600
|
ctx: this.ctx,
|
|
2174
2601
|
userId: this.userId,
|
|
2175
|
-
walletId
|
|
2602
|
+
walletId,
|
|
2176
2603
|
userShare: signer,
|
|
2177
|
-
emailProps: this.getBackupKitEmailProps()
|
|
2604
|
+
emailProps: this.getBackupKitEmailProps(),
|
|
2605
|
+
isEnclaveUser: this.isEnclaveUser,
|
|
2606
|
+
walletScheme
|
|
2178
2607
|
});
|
|
2179
2608
|
}
|
|
2609
|
+
this.wallets[walletId] = {
|
|
2610
|
+
id: walletId,
|
|
2611
|
+
signer,
|
|
2612
|
+
scheme: walletScheme,
|
|
2613
|
+
type: walletType
|
|
2614
|
+
};
|
|
2615
|
+
wallet = this.wallets[walletId];
|
|
2616
|
+
yield this.populateWalletAddresses();
|
|
2180
2617
|
yield this.setCurrentWalletIds(__spreadProps(__spreadValues({}, this.currentWalletIds), {
|
|
2181
2618
|
[walletType]: [.../* @__PURE__ */ new Set([...(_b = this.currentWalletIds[walletType]) != null ? _b : [], walletId])]
|
|
2182
2619
|
}));
|
|
@@ -2255,7 +2692,9 @@ const _ParaCore = class _ParaCore {
|
|
|
2255
2692
|
walletId: wallet.id,
|
|
2256
2693
|
userShare: this.wallets[wallet.id].signer,
|
|
2257
2694
|
emailProps: this.getBackupKitEmailProps(),
|
|
2258
|
-
partnerId: wallet.partnerId
|
|
2695
|
+
partnerId: wallet.partnerId,
|
|
2696
|
+
isEnclaveUser: this.isEnclaveUser,
|
|
2697
|
+
walletScheme: wallet.scheme
|
|
2259
2698
|
});
|
|
2260
2699
|
if (distributeRes.length > 0) {
|
|
2261
2700
|
newRecoverySecret = distributeRes;
|
|
@@ -2382,10 +2821,10 @@ const _ParaCore = class _ParaCore {
|
|
|
2382
2821
|
(0, import_utils2.dispatchEvent)(import_types.ParaEvent.GUEST_WALLETS_CREATED, wallets);
|
|
2383
2822
|
__privateSet(this, _isCreateGuestWalletsPending, false);
|
|
2384
2823
|
return wallets;
|
|
2385
|
-
} catch (
|
|
2386
|
-
(0, import_utils2.dispatchEvent)(import_types.ParaEvent.GUEST_WALLETS_CREATED, null,
|
|
2824
|
+
} catch (error2) {
|
|
2825
|
+
(0, import_utils2.dispatchEvent)(import_types.ParaEvent.GUEST_WALLETS_CREATED, null, error2 == null ? void 0 : error2.message);
|
|
2387
2826
|
__privateSet(this, _isCreateGuestWalletsPending, false);
|
|
2388
|
-
throw
|
|
2827
|
+
throw error2;
|
|
2389
2828
|
}
|
|
2390
2829
|
});
|
|
2391
2830
|
}
|
|
@@ -2433,25 +2872,12 @@ const _ParaCore = class _ParaCore {
|
|
|
2433
2872
|
});
|
|
2434
2873
|
});
|
|
2435
2874
|
}
|
|
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);
|
|
2875
|
+
getOnRampTransactionUrl(_0) {
|
|
2876
|
+
return __async(this, arguments, function* ({
|
|
2877
|
+
purchaseId
|
|
2878
|
+
}) {
|
|
2447
2879
|
return this.constructPortalUrl("onRamp", {
|
|
2448
|
-
pathId: purchaseId
|
|
2449
|
-
sessionId,
|
|
2450
|
-
params: {
|
|
2451
|
-
[key]: identifier,
|
|
2452
|
-
providerKey,
|
|
2453
|
-
currentWalletIds: JSON.stringify(this.currentWalletIds)
|
|
2454
|
-
}
|
|
2880
|
+
pathId: purchaseId
|
|
2455
2881
|
});
|
|
2456
2882
|
});
|
|
2457
2883
|
}
|
|
@@ -2476,6 +2902,7 @@ const _ParaCore = class _ParaCore {
|
|
|
2476
2902
|
onCancel,
|
|
2477
2903
|
onPoll
|
|
2478
2904
|
}) {
|
|
2905
|
+
var _a;
|
|
2479
2906
|
this.assertIsValidWalletId(walletId);
|
|
2480
2907
|
const wallet = this.wallets[walletId];
|
|
2481
2908
|
let signerId = this.userId;
|
|
@@ -2485,7 +2912,7 @@ const _ParaCore = class _ParaCore {
|
|
|
2485
2912
|
let signRes = yield this.signMessageInner({ wallet, signerId, messageBase64, cosmosSignDocBase64 });
|
|
2486
2913
|
let timeStart = Date.now();
|
|
2487
2914
|
if (signRes.pendingTransactionId) {
|
|
2488
|
-
this.platformUtils.openPopup(
|
|
2915
|
+
yield this.platformUtils.openPopup(
|
|
2489
2916
|
yield this.getTransactionReviewUrl(signRes.pendingTransactionId, timeoutMs),
|
|
2490
2917
|
{ type: cosmosSignDocBase64 ? import_types.PopupType.SIGN_TRANSACTION_REVIEW : import_types.PopupType.SIGN_MESSAGE_REVIEW }
|
|
2491
2918
|
);
|
|
@@ -2499,18 +2926,19 @@ const _ParaCore = class _ParaCore {
|
|
|
2499
2926
|
break;
|
|
2500
2927
|
}
|
|
2501
2928
|
yield new Promise((resolve) => setTimeout(resolve, constants.POLLING_INTERVAL_MS));
|
|
2929
|
+
let pendingTransaction;
|
|
2502
2930
|
try {
|
|
2503
|
-
yield this.ctx.client.getPendingTransaction(this.userId, signRes.pendingTransactionId);
|
|
2504
|
-
} catch (
|
|
2931
|
+
pendingTransaction = (_a = (yield this.ctx.client.getPendingTransaction(this.userId, signRes.pendingTransactionId)).data) == null ? void 0 : _a.pendingTransaction;
|
|
2932
|
+
} catch (e) {
|
|
2505
2933
|
const error = new import_errors.TransactionReviewDenied();
|
|
2506
2934
|
(0, import_utils2.dispatchEvent)(import_types.ParaEvent.SIGN_MESSAGE_EVENT, signRes, error.message);
|
|
2507
2935
|
throw error;
|
|
2508
2936
|
}
|
|
2509
|
-
|
|
2510
|
-
if (signRes.pendingTransactionId) {
|
|
2937
|
+
if (!(pendingTransaction == null ? void 0 : pendingTransaction.approvedAt)) {
|
|
2511
2938
|
onPoll == null ? void 0 : onPoll();
|
|
2512
2939
|
continue;
|
|
2513
2940
|
} else {
|
|
2941
|
+
signRes = yield this.signMessageInner({ wallet, signerId, messageBase64, cosmosSignDocBase64 });
|
|
2514
2942
|
break;
|
|
2515
2943
|
}
|
|
2516
2944
|
}
|
|
@@ -2579,6 +3007,7 @@ const _ParaCore = class _ParaCore {
|
|
|
2579
3007
|
onCancel,
|
|
2580
3008
|
onPoll
|
|
2581
3009
|
}) {
|
|
3010
|
+
var _a;
|
|
2582
3011
|
this.assertIsValidWalletId(walletId);
|
|
2583
3012
|
const wallet = this.wallets[walletId];
|
|
2584
3013
|
let signerId = this.userId;
|
|
@@ -2597,7 +3026,7 @@ const _ParaCore = class _ParaCore {
|
|
|
2597
3026
|
);
|
|
2598
3027
|
let timeStart = Date.now();
|
|
2599
3028
|
if (signRes.pendingTransactionId) {
|
|
2600
|
-
this.platformUtils.openPopup(
|
|
3029
|
+
yield this.platformUtils.openPopup(
|
|
2601
3030
|
yield this.getTransactionReviewUrl(signRes.pendingTransactionId, timeoutMs),
|
|
2602
3031
|
{ type: import_types.PopupType.SIGN_TRANSACTION_REVIEW }
|
|
2603
3032
|
);
|
|
@@ -2611,27 +3040,28 @@ const _ParaCore = class _ParaCore {
|
|
|
2611
3040
|
break;
|
|
2612
3041
|
}
|
|
2613
3042
|
yield new Promise((resolve) => setTimeout(resolve, constants.POLLING_INTERVAL_MS));
|
|
3043
|
+
let pendingTransaction;
|
|
2614
3044
|
try {
|
|
2615
|
-
yield this.ctx.client.getPendingTransaction(this.userId, signRes.pendingTransactionId);
|
|
2616
|
-
} catch (
|
|
3045
|
+
pendingTransaction = (_a = (yield this.ctx.client.getPendingTransaction(this.userId, signRes.pendingTransactionId)).data) == null ? void 0 : _a.pendingTransaction;
|
|
3046
|
+
} catch (e) {
|
|
2617
3047
|
const error = new import_errors.TransactionReviewDenied();
|
|
2618
3048
|
(0, import_utils2.dispatchEvent)(import_types.ParaEvent.SIGN_TRANSACTION_EVENT, signRes, error.message);
|
|
2619
3049
|
throw error;
|
|
2620
3050
|
}
|
|
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) {
|
|
3051
|
+
if (!(pendingTransaction == null ? void 0 : pendingTransaction.approvedAt)) {
|
|
2632
3052
|
onPoll == null ? void 0 : onPoll();
|
|
2633
3053
|
continue;
|
|
2634
3054
|
} else {
|
|
3055
|
+
signRes = yield this.platformUtils.signTransaction(
|
|
3056
|
+
this.ctx,
|
|
3057
|
+
signerId,
|
|
3058
|
+
walletId,
|
|
3059
|
+
this.wallets[walletId].signer,
|
|
3060
|
+
rlpEncodedTxBase64,
|
|
3061
|
+
chainId,
|
|
3062
|
+
this.retrieveSessionCookie(),
|
|
3063
|
+
wallet.scheme === "DKLS"
|
|
3064
|
+
);
|
|
2635
3065
|
break;
|
|
2636
3066
|
}
|
|
2637
3067
|
}
|
|
@@ -2673,7 +3103,8 @@ const _ParaCore = class _ParaCore {
|
|
|
2673
3103
|
providerKey: onRampPurchase.providerKey
|
|
2674
3104
|
}, walletParams));
|
|
2675
3105
|
if (shouldOpenPopup) {
|
|
2676
|
-
this.platformUtils.openPopup(portalUrl, { type: import_types.PopupType.ON_RAMP_TRANSACTION });
|
|
3106
|
+
const onRampWindow = yield this.platformUtils.openPopup(portalUrl, { type: import_types.PopupType.ON_RAMP_TRANSACTION });
|
|
3107
|
+
this.onRampPopup = { window: onRampWindow, onRampPurchase };
|
|
2677
3108
|
}
|
|
2678
3109
|
return { onRampPurchase, portalUrl };
|
|
2679
3110
|
});
|
|
@@ -2686,7 +3117,7 @@ const _ParaCore = class _ParaCore {
|
|
|
2686
3117
|
try {
|
|
2687
3118
|
yield this.ctx.client.keepSessionAlive(this.userId);
|
|
2688
3119
|
return true;
|
|
2689
|
-
} catch (
|
|
3120
|
+
} catch (e) {
|
|
2690
3121
|
return false;
|
|
2691
3122
|
}
|
|
2692
3123
|
});
|
|
@@ -2758,8 +3189,16 @@ const _ParaCore = class _ParaCore {
|
|
|
2758
3189
|
}
|
|
2759
3190
|
issueJwt() {
|
|
2760
3191
|
return __async(this, arguments, function* ({ keyIndex = 0 } = {}) {
|
|
2761
|
-
|
|
2762
|
-
|
|
3192
|
+
try {
|
|
3193
|
+
return yield this.ctx.client.issueJwt({ keyIndex });
|
|
3194
|
+
} catch (error) {
|
|
3195
|
+
if (error.status === 403 || error.status === 401) {
|
|
3196
|
+
const errorMessage = "The user needs to be logged in to issue a JWT. Please log in and try again.";
|
|
3197
|
+
this.displayModalError(errorMessage);
|
|
3198
|
+
console.warn(errorMessage);
|
|
3199
|
+
}
|
|
3200
|
+
throw error;
|
|
3201
|
+
}
|
|
2763
3202
|
});
|
|
2764
3203
|
}
|
|
2765
3204
|
/**
|
|
@@ -2769,6 +3208,7 @@ const _ParaCore = class _ParaCore {
|
|
|
2769
3208
|
**/
|
|
2770
3209
|
logout() {
|
|
2771
3210
|
return __async(this, arguments, function* ({ clearPregenWallets = false } = {}) {
|
|
3211
|
+
const shouldDispatchLogoutEvent = yield this.isSessionActive();
|
|
2772
3212
|
yield this.ctx.client.logout();
|
|
2773
3213
|
yield this.clearStorage();
|
|
2774
3214
|
if (!clearPregenWallets) {
|
|
@@ -2788,7 +3228,9 @@ const _ParaCore = class _ParaCore {
|
|
|
2788
3228
|
this.accountLinkInProgress = void 0;
|
|
2789
3229
|
this.userId = void 0;
|
|
2790
3230
|
this.sessionCookie = void 0;
|
|
2791
|
-
(
|
|
3231
|
+
if (shouldDispatchLogoutEvent) {
|
|
3232
|
+
(0, import_utils2.dispatchEvent)(import_types.ParaEvent.LOGOUT_EVENT, null);
|
|
3233
|
+
}
|
|
2792
3234
|
});
|
|
2793
3235
|
}
|
|
2794
3236
|
get toStringAdditions() {
|
|
@@ -2818,9 +3260,9 @@ const _ParaCore = class _ParaCore {
|
|
|
2818
3260
|
{}
|
|
2819
3261
|
);
|
|
2820
3262
|
const obj = __spreadProps(__spreadValues({
|
|
2821
|
-
partnerId: (_a =
|
|
2822
|
-
supportedWalletTypes: (_b =
|
|
2823
|
-
cosmosPrefix: (_c =
|
|
3263
|
+
partnerId: (_a = this.partner) == null ? void 0 : _a.id,
|
|
3264
|
+
supportedWalletTypes: (_b = this.partner) == null ? void 0 : _b.supportedWalletTypes,
|
|
3265
|
+
cosmosPrefix: (_c = this.partner) == null ? void 0 : _c.cosmosPrefix,
|
|
2824
3266
|
authInfo: __privateGet(this, _authInfo),
|
|
2825
3267
|
isGuestMode: this.isGuestMode,
|
|
2826
3268
|
userId: this.userId,
|
|
@@ -2852,43 +3294,88 @@ const _ParaCore = class _ParaCore {
|
|
|
2852
3294
|
}
|
|
2853
3295
|
getNewCredentialAndUrl() {
|
|
2854
3296
|
return __async(this, arguments, function* ({
|
|
2855
|
-
authMethod
|
|
3297
|
+
authMethod: optsAuthMethod,
|
|
2856
3298
|
isForNewDevice = false,
|
|
2857
3299
|
portalTheme,
|
|
2858
3300
|
shorten = false
|
|
2859
3301
|
} = {}) {
|
|
3302
|
+
const userAuthMethods = yield this.supportedUserAuthMethods();
|
|
3303
|
+
const isEnclaveUser = userAuthMethods.has(import_user_management_client.AuthMethod.BASIC_LOGIN);
|
|
3304
|
+
const isAddingBasicLogin = optsAuthMethod === "BASIC_LOGIN";
|
|
3305
|
+
if (isEnclaveUser && isAddingBasicLogin) {
|
|
3306
|
+
throw new Error("That user is already using basic login");
|
|
3307
|
+
}
|
|
3308
|
+
if (isEnclaveUser || isAddingBasicLogin) {
|
|
3309
|
+
isForNewDevice = true;
|
|
3310
|
+
}
|
|
3311
|
+
const authMethods = optsAuthMethod ? [optsAuthMethod] : isForNewDevice ? ["PASSKEY", "PIN", "PASSWORD"] : ["PASSKEY"];
|
|
2860
3312
|
this.assertIsAuthSet();
|
|
2861
|
-
let
|
|
2862
|
-
|
|
2863
|
-
|
|
3313
|
+
let passkeyId, passwordId, urlType, credentialId;
|
|
3314
|
+
if (!isAddingBasicLogin) {
|
|
3315
|
+
const canAddPasswordOrPIN = !userAuthMethods.has(import_user_management_client.AuthMethod.PASSWORD) && !userAuthMethods.has(import_user_management_client.AuthMethod.PIN);
|
|
3316
|
+
if (authMethods.includes("PASSKEY") && (yield this.isPasskeySupported())) {
|
|
2864
3317
|
({
|
|
2865
|
-
data: { id:
|
|
3318
|
+
data: { id: passkeyId }
|
|
2866
3319
|
} = yield this.ctx.client.addSessionPublicKey(this.userId, {
|
|
2867
|
-
status: import_user_management_client.
|
|
3320
|
+
status: import_user_management_client.AuthMethodStatus.PENDING,
|
|
2868
3321
|
type: import_user_management_client.PublicKeyType.WEB
|
|
2869
3322
|
}));
|
|
2870
3323
|
urlType = "createAuth";
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
({
|
|
2874
|
-
|
|
2875
|
-
}
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
3324
|
+
}
|
|
3325
|
+
if (authMethods.includes("PASSWORD")) {
|
|
3326
|
+
if (!canAddPasswordOrPIN) {
|
|
3327
|
+
if (optsAuthMethod === "PASSWORD") throw new Error("A user cannot have more than one password or PIN.");
|
|
3328
|
+
} else {
|
|
3329
|
+
({
|
|
3330
|
+
data: { id: passwordId }
|
|
3331
|
+
} = yield this.ctx.client.addSessionPasswordPublicKey(this.userId, {
|
|
3332
|
+
status: import_user_management_client.AuthMethodStatus.PENDING
|
|
3333
|
+
}));
|
|
3334
|
+
urlType = "createPassword";
|
|
3335
|
+
}
|
|
3336
|
+
}
|
|
3337
|
+
if (authMethods.includes("PIN")) {
|
|
3338
|
+
if (!canAddPasswordOrPIN) {
|
|
3339
|
+
if (optsAuthMethod === "PIN") throw new Error("A user cannot have more than one password or PIN.");
|
|
3340
|
+
} else {
|
|
3341
|
+
({
|
|
3342
|
+
data: { id: passwordId }
|
|
3343
|
+
} = yield this.ctx.client.addSessionPasswordPublicKey(this.userId, {
|
|
3344
|
+
status: import_user_management_client.AuthMethodStatus.PENDING
|
|
3345
|
+
}));
|
|
3346
|
+
urlType = "createPIN";
|
|
3347
|
+
}
|
|
3348
|
+
}
|
|
3349
|
+
credentialId = passkeyId != null ? passkeyId : passwordId;
|
|
3350
|
+
if (this.isNativePasskey && authMethods.includes("PASSKEY")) {
|
|
3351
|
+
return { credentialId };
|
|
3352
|
+
}
|
|
2880
3353
|
}
|
|
2881
|
-
const
|
|
3354
|
+
const { sessionId } = yield this.touchSession();
|
|
3355
|
+
const url = (isForNewDevice || urlType) && (yield this.constructPortalUrl(isForNewDevice ? "addNewCredential" : urlType, {
|
|
2882
3356
|
isForNewDevice,
|
|
2883
3357
|
pathId: credentialId,
|
|
2884
3358
|
portalTheme,
|
|
2885
|
-
shorten
|
|
2886
|
-
|
|
3359
|
+
shorten,
|
|
3360
|
+
sessionId: isForNewDevice ? sessionId : void 0,
|
|
3361
|
+
addNewCredentialType: optsAuthMethod,
|
|
3362
|
+
addNewCredentialPasskeyId: passkeyId,
|
|
3363
|
+
addNewCredentialPasswordId: passwordId
|
|
3364
|
+
}));
|
|
2887
3365
|
return __spreadValues({ credentialId }, url ? { url } : {});
|
|
2888
3366
|
});
|
|
2889
3367
|
}
|
|
3368
|
+
addCredential(_0) {
|
|
3369
|
+
return __async(this, arguments, function* ({ authMethod }) {
|
|
3370
|
+
if (authMethod === "PASSKEY" && !(yield this.isPasskeySupported())) {
|
|
3371
|
+
throw new Error("Passkeys are not supported.");
|
|
3372
|
+
}
|
|
3373
|
+
const { url } = yield this.getNewCredentialAndUrl({ isForNewDevice: true, authMethod });
|
|
3374
|
+
return url;
|
|
3375
|
+
});
|
|
3376
|
+
}
|
|
2890
3377
|
/**
|
|
2891
|
-
* Returns a Para Portal URL for logging in with a WebAuth passkey or
|
|
3378
|
+
* Returns a Para Portal URL for logging in with a WebAuth passkey, password, PIN or OTP.
|
|
2892
3379
|
* @param {Object} opts the options object
|
|
2893
3380
|
* @param {String} opts.auth - the user auth to sign up or log in with, in the form ` { email: string } | { phone: `+${number}` } `
|
|
2894
3381
|
* @param {boolean} opts.useShortUrls - whether to shorten the generated portal URLs
|
|
@@ -2914,6 +3401,12 @@ const _ParaCore = class _ParaCore {
|
|
|
2914
3401
|
case "PASSWORD":
|
|
2915
3402
|
urlType = "loginPassword";
|
|
2916
3403
|
break;
|
|
3404
|
+
case "PIN":
|
|
3405
|
+
urlType = "loginPIN";
|
|
3406
|
+
break;
|
|
3407
|
+
case "BASIC_LOGIN":
|
|
3408
|
+
urlType = this.authInfo.authType === "externalWallet" ? "loginExternalWallet" : "loginOTP";
|
|
3409
|
+
break;
|
|
2917
3410
|
default:
|
|
2918
3411
|
throw new Error(`invalid authentication method: '${authMethod}'`);
|
|
2919
3412
|
}
|
|
@@ -2924,10 +3417,30 @@ const _ParaCore = class _ParaCore {
|
|
|
2924
3417
|
});
|
|
2925
3418
|
});
|
|
2926
3419
|
}
|
|
2927
|
-
|
|
3420
|
+
prepareLogin() {
|
|
3421
|
+
return __async(this, null, function* () {
|
|
3422
|
+
yield this.logout();
|
|
3423
|
+
const { sessionLookupId } = yield this.touchSession(true);
|
|
3424
|
+
if (!this.loginEncryptionKeyPair) {
|
|
3425
|
+
yield this.setLoginEncryptionKeyPair();
|
|
3426
|
+
}
|
|
3427
|
+
return sessionLookupId;
|
|
3428
|
+
});
|
|
3429
|
+
}
|
|
3430
|
+
signUpOrLogIn(_i) {
|
|
2928
3431
|
return __async(this, null, function* () {
|
|
2929
|
-
var
|
|
2930
|
-
|
|
3432
|
+
var _j = _i, { auth } = _j, urlOptions = __objRest(_j, ["auth"]);
|
|
3433
|
+
let serverAuthState;
|
|
3434
|
+
try {
|
|
3435
|
+
serverAuthState = yield this.ctx.client.signUpOrLogIn(__spreadValues(__spreadValues({}, auth), this.getVerificationEmailProps()));
|
|
3436
|
+
} catch (error) {
|
|
3437
|
+
if (error.message.includes("max beta users reached")) {
|
|
3438
|
+
this.displayModalError(
|
|
3439
|
+
`50 user limit reached. [Go to Production.](https://docs.getpara.com/v2/general/checklist#go-live-checklist)`
|
|
3440
|
+
);
|
|
3441
|
+
}
|
|
3442
|
+
throw error;
|
|
3443
|
+
}
|
|
2931
3444
|
const authInfo = serverAuthState.auth;
|
|
2932
3445
|
if (this.fetchPregenWalletsOverride && (0, import_user_management_client.isPregenAuth)(authInfo)) {
|
|
2933
3446
|
const { userShare } = yield this.fetchPregenWalletsOverride({ pregenId: authInfo });
|
|
@@ -2935,21 +3448,25 @@ const _ParaCore = class _ParaCore {
|
|
|
2935
3448
|
yield this.setUserShare(userShare);
|
|
2936
3449
|
}
|
|
2937
3450
|
}
|
|
2938
|
-
return __privateMethod(this, _ParaCore_instances, prepareAuthState_fn).call(this, serverAuthState, urlOptions);
|
|
3451
|
+
return __privateMethod(this, _ParaCore_instances, prepareAuthState_fn).call(this, serverAuthState, __spreadValues({}, urlOptions));
|
|
2939
3452
|
});
|
|
2940
3453
|
}
|
|
2941
|
-
verifyNewAccount(
|
|
3454
|
+
verifyNewAccount(_k) {
|
|
2942
3455
|
return __async(this, null, function* () {
|
|
2943
|
-
var
|
|
3456
|
+
var _l = _k, {
|
|
2944
3457
|
verificationCode
|
|
2945
|
-
} =
|
|
3458
|
+
} = _l, urlOptions = __objRest(_l, [
|
|
2946
3459
|
"verificationCode"
|
|
2947
3460
|
]);
|
|
2948
3461
|
this.assertIsAuthSet(["email", "phone"]);
|
|
2949
|
-
const userId = this.assertUserId();
|
|
2950
|
-
const serverAuthState = yield this.ctx.client.
|
|
3462
|
+
const userId = this.assertUserId({ allowGuestMode: true });
|
|
3463
|
+
const serverAuthState = yield this.ctx.client.verifyAccount(userId, {
|
|
2951
3464
|
verificationCode
|
|
2952
3465
|
});
|
|
3466
|
+
if (serverAuthState.stage === "login" || serverAuthState.stage === "done") {
|
|
3467
|
+
throw new Error("Account already exists.");
|
|
3468
|
+
}
|
|
3469
|
+
yield this.touchSession(true);
|
|
2953
3470
|
return __privateMethod(this, _ParaCore_instances, prepareAuthState_fn).call(this, serverAuthState, urlOptions);
|
|
2954
3471
|
});
|
|
2955
3472
|
}
|
|
@@ -2997,7 +3514,7 @@ const _ParaCore = class _ParaCore {
|
|
|
2997
3514
|
}
|
|
2998
3515
|
break;
|
|
2999
3516
|
default:
|
|
3000
|
-
throw new Error("Invalid parameters for linking account, must pass `auth` or `type` or `externalWallet");
|
|
3517
|
+
throw new Error("Invalid parameters for linking account, must pass `auth` or `type` or `externalWallet`");
|
|
3001
3518
|
}
|
|
3002
3519
|
if (!isPermitted) {
|
|
3003
3520
|
throw new Error(`Account linking for type '${type}' is not supported by the current API key configuration`);
|
|
@@ -3036,10 +3553,10 @@ const _ParaCore = class _ParaCore {
|
|
|
3036
3553
|
});
|
|
3037
3554
|
}
|
|
3038
3555
|
verifyLink() {
|
|
3039
|
-
return __async(this, arguments, function* (
|
|
3040
|
-
var
|
|
3556
|
+
return __async(this, arguments, function* (_m = {}) {
|
|
3557
|
+
var _n = _m, {
|
|
3041
3558
|
accountLinkInProgress = __privateMethod(this, _ParaCore_instances, assertIsLinkingAccount_fn).call(this)
|
|
3042
|
-
} =
|
|
3559
|
+
} = _n, opts = __objRest(_n, [
|
|
3043
3560
|
"accountLinkInProgress"
|
|
3044
3561
|
]);
|
|
3045
3562
|
try {
|
|
@@ -3068,31 +3585,80 @@ const _ParaCore = class _ParaCore {
|
|
|
3068
3585
|
return accounts;
|
|
3069
3586
|
});
|
|
3070
3587
|
}
|
|
3588
|
+
getProfileBalance() {
|
|
3589
|
+
return __async(this, arguments, function* ({ config, refetch = false } = {}) {
|
|
3590
|
+
const { balance } = yield this.ctx.client.getProfileBalance({
|
|
3591
|
+
config,
|
|
3592
|
+
wallets: this.availableWallets.filter(({ type }) => type !== "COSMOS").map(({ type, address }) => ({ type, address })),
|
|
3593
|
+
refetch
|
|
3594
|
+
});
|
|
3595
|
+
return balance;
|
|
3596
|
+
});
|
|
3597
|
+
}
|
|
3598
|
+
sendLoginCode() {
|
|
3599
|
+
return __async(this, null, function* () {
|
|
3600
|
+
const { userId } = yield this.ctx.client.sendLoginVerificationCode(this.authInfo);
|
|
3601
|
+
this.setUserId(userId);
|
|
3602
|
+
});
|
|
3603
|
+
}
|
|
3604
|
+
exportPrivateKey() {
|
|
3605
|
+
return __async(this, arguments, function* (args = {}) {
|
|
3606
|
+
let walletId = args == null ? void 0 : args.walletId;
|
|
3607
|
+
if (!(args == null ? void 0 : args.walletId)) {
|
|
3608
|
+
walletId = this.findWalletId(void 0, { forbidPregen: true, scheme: ["DKLS"] });
|
|
3609
|
+
}
|
|
3610
|
+
const wallet = this.wallets[walletId];
|
|
3611
|
+
if (this.externalWallets[walletId]) {
|
|
3612
|
+
throw new Error("Cannot export private key for an external wallet");
|
|
3613
|
+
}
|
|
3614
|
+
if (!wallet || !wallet.signer) {
|
|
3615
|
+
throw new Error("Wallet not found with id: " + walletId);
|
|
3616
|
+
}
|
|
3617
|
+
if (wallet.scheme !== "DKLS") {
|
|
3618
|
+
throw new Error("Cannot export private key for a Solana wallet");
|
|
3619
|
+
}
|
|
3620
|
+
if (wallet.isPregen && !!wallet.pregenIdentifier && wallet.pregenIdentifierType !== "GUEST_ID") {
|
|
3621
|
+
throw new Error("Cannot export private key for a pregenerated wallet");
|
|
3622
|
+
}
|
|
3623
|
+
if (args.shouldOpenPopup) {
|
|
3624
|
+
this.popupWindow = yield this.platformUtils.openPopup("about:blank", { type: import_types.PopupType.EXPORT_PRIVATE_KEY });
|
|
3625
|
+
}
|
|
3626
|
+
const exportPrivateKeyUrl = yield this.constructPortalUrl("exportPrivateKey", {
|
|
3627
|
+
pathId: walletId
|
|
3628
|
+
});
|
|
3629
|
+
if (args.shouldOpenPopup) {
|
|
3630
|
+
this.popupWindow.location.href = exportPrivateKeyUrl;
|
|
3631
|
+
}
|
|
3632
|
+
return {
|
|
3633
|
+
url: exportPrivateKeyUrl,
|
|
3634
|
+
popupWindow: this.popupWindow
|
|
3635
|
+
};
|
|
3636
|
+
});
|
|
3637
|
+
}
|
|
3071
3638
|
};
|
|
3072
3639
|
_authInfo = new WeakMap();
|
|
3073
|
-
_partner = new WeakMap();
|
|
3074
3640
|
_ParaCore_instances = new WeakSet();
|
|
3075
3641
|
assertPartner_fn = function() {
|
|
3076
3642
|
return __async(this, null, function* () {
|
|
3077
3643
|
var _a, _b;
|
|
3078
|
-
if (!
|
|
3644
|
+
if (!this.partner) {
|
|
3079
3645
|
yield this.touchSession();
|
|
3080
3646
|
}
|
|
3081
|
-
if (((_a =
|
|
3082
|
-
this.ctx.cosmosPrefix = (_b =
|
|
3647
|
+
if (((_a = this.partner) == null ? void 0 : _a.cosmosPrefix) && this.ctx.cosmosPrefix !== this.partner.cosmosPrefix) {
|
|
3648
|
+
this.ctx.cosmosPrefix = (_b = this.partner) == null ? void 0 : _b.cosmosPrefix;
|
|
3083
3649
|
}
|
|
3084
|
-
return
|
|
3650
|
+
return this.partner;
|
|
3085
3651
|
});
|
|
3086
3652
|
};
|
|
3087
3653
|
guestWalletIds_get = function() {
|
|
3088
3654
|
var _a, _b, _c;
|
|
3089
|
-
if (!((_a =
|
|
3655
|
+
if (!((_a = this.partner) == null ? void 0 : _a.supportedWalletTypes)) {
|
|
3090
3656
|
return {};
|
|
3091
3657
|
}
|
|
3092
3658
|
const guestId = (_c = (_b = this.pregenIds) == null ? void 0 : _b.GUEST_ID) == null ? void 0 : _c[0];
|
|
3093
3659
|
return !!guestId ? Object.entries(this.wallets).reduce((acc, [id, wallet]) => {
|
|
3094
3660
|
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) =>
|
|
3661
|
+
return __spreadValues(__spreadValues({}, acc), (0, import_utils2.getEquivalentTypes)(wallet.type).filter((type) => this.partner.supportedWalletTypes.some((entry) => entry.type === type)).reduce((acc2, eqType) => {
|
|
3096
3662
|
var _a2;
|
|
3097
3663
|
return __spreadProps(__spreadValues({}, acc2), { [eqType]: [.../* @__PURE__ */ new Set([...(_a2 = acc2[eqType]) != null ? _a2 : [], id])] });
|
|
3098
3664
|
}, {}));
|
|
@@ -3153,8 +3719,8 @@ getPartner_fn = function(partnerId) {
|
|
|
3153
3719
|
return void 0;
|
|
3154
3720
|
}
|
|
3155
3721
|
const res = yield this.ctx.client.getPartner(partnerId);
|
|
3156
|
-
|
|
3157
|
-
return
|
|
3722
|
+
this.partner = res.data.partner;
|
|
3723
|
+
return this.partner;
|
|
3158
3724
|
});
|
|
3159
3725
|
};
|
|
3160
3726
|
assertIsLinkingAccount_fn = function(types) {
|
|
@@ -3176,29 +3742,208 @@ assertIsLinkingAccountOrStart_fn = function(type) {
|
|
|
3176
3742
|
return yield this.linkAccount({ type });
|
|
3177
3743
|
});
|
|
3178
3744
|
};
|
|
3179
|
-
getOAuthUrl_fn = function(
|
|
3180
|
-
return __async(this,
|
|
3181
|
-
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3745
|
+
getOAuthUrl_fn = function(_0) {
|
|
3746
|
+
return __async(this, arguments, function* ({
|
|
3747
|
+
method,
|
|
3748
|
+
appScheme,
|
|
3749
|
+
accountLinkInProgress,
|
|
3750
|
+
sessionLookupId,
|
|
3751
|
+
encryptionKey,
|
|
3752
|
+
portalCallbackParams
|
|
3753
|
+
}) {
|
|
3754
|
+
if (!accountLinkInProgress && !this.isPortal()) {
|
|
3755
|
+
return yield this.constructPortalUrl("oAuth", { sessionId: sessionLookupId, oAuthMethod: method, appScheme });
|
|
3756
|
+
}
|
|
3757
|
+
let portalSessionLookupId;
|
|
3758
|
+
if (this.isPortal()) {
|
|
3759
|
+
portalSessionLookupId = (yield this.touchSession(true)).sessionLookupId;
|
|
3760
|
+
}
|
|
3192
3761
|
return (0, import_utils2.constructUrl)({
|
|
3193
3762
|
base: (0, import_userManagementClient.getBaseOAuthUrl)(this.ctx.env),
|
|
3194
|
-
path: `/auth/${method}`,
|
|
3195
|
-
params: __spreadValues({
|
|
3763
|
+
path: `/auth/${method.toLowerCase()}`,
|
|
3764
|
+
params: __spreadProps(__spreadValues({
|
|
3196
3765
|
apiKey: this.ctx.apiKey,
|
|
3766
|
+
origin: typeof window !== "undefined" ? window.location.origin : void 0,
|
|
3197
3767
|
sessionLookupId,
|
|
3768
|
+
portalSessionLookupId,
|
|
3198
3769
|
appScheme
|
|
3199
3770
|
}, accountLinkInProgress ? {
|
|
3200
3771
|
linkedAccountId: this.accountLinkInProgress.id
|
|
3201
|
-
} : {})
|
|
3772
|
+
} : {}), {
|
|
3773
|
+
callback: !accountLinkInProgress && (yield this.constructPortalUrl("oAuthCallback", __spreadValues({
|
|
3774
|
+
sessionId: sessionLookupId,
|
|
3775
|
+
oAuthMethod: method,
|
|
3776
|
+
appScheme,
|
|
3777
|
+
thisDevice: {
|
|
3778
|
+
sessionId: sessionLookupId,
|
|
3779
|
+
encryptionKey
|
|
3780
|
+
}
|
|
3781
|
+
}, this.isPortal() && { params: portalCallbackParams })))
|
|
3782
|
+
})
|
|
3783
|
+
});
|
|
3784
|
+
});
|
|
3785
|
+
};
|
|
3786
|
+
waitForLoginProcess_fn = function() {
|
|
3787
|
+
return __async(this, arguments, function* ({
|
|
3788
|
+
isCanceled = () => false,
|
|
3789
|
+
onCancel,
|
|
3790
|
+
onPoll,
|
|
3791
|
+
skipSessionRefresh = false,
|
|
3792
|
+
isSwitchingWallets = false
|
|
3793
|
+
} = {}) {
|
|
3794
|
+
this.devLog("[waitForLoginProcess] Starting", {
|
|
3795
|
+
isSwitchingWallets,
|
|
3796
|
+
skipSessionRefresh,
|
|
3797
|
+
isExternalWalletAuth: this.isExternalWalletAuth
|
|
3798
|
+
});
|
|
3799
|
+
const startedAt = Date.now();
|
|
3800
|
+
let originalCurrentWalletIdsHash;
|
|
3801
|
+
if (isSwitchingWallets) {
|
|
3802
|
+
this.devLog("[waitForLoginProcess] Wallet switching mode enabled");
|
|
3803
|
+
this.isSwitchingWallets = true;
|
|
3804
|
+
const session = yield this.touchSession();
|
|
3805
|
+
originalCurrentWalletIdsHash = session.currentWalletIdsHash;
|
|
3806
|
+
this.devLog("[waitForLoginProcess] Original wallet IDs hash", { originalCurrentWalletIdsHash });
|
|
3807
|
+
}
|
|
3808
|
+
return new Promise((resolve, reject) => {
|
|
3809
|
+
(() => __async(this, null, function* () {
|
|
3810
|
+
var _a;
|
|
3811
|
+
if (!this.isExternalWalletAuth && !isSwitchingWallets) {
|
|
3812
|
+
this.devLog("[waitForLoginProcess] Clearing external wallets");
|
|
3813
|
+
this.externalWallets = {};
|
|
3814
|
+
}
|
|
3815
|
+
let pollCount = 0;
|
|
3816
|
+
while (true) {
|
|
3817
|
+
pollCount++;
|
|
3818
|
+
this.devLog("[waitForLoginProcess] Poll iteration", {
|
|
3819
|
+
pollCount,
|
|
3820
|
+
elapsedMs: Date.now() - startedAt
|
|
3821
|
+
});
|
|
3822
|
+
if (isCanceled() || Date.now() - startedAt > constants.POLLING_TIMEOUT_MS) {
|
|
3823
|
+
this.devLog("[waitForLoginProcess] Canceled or timed out", {
|
|
3824
|
+
wasCanceled: isCanceled(),
|
|
3825
|
+
timedOut: Date.now() - startedAt > constants.POLLING_TIMEOUT_MS,
|
|
3826
|
+
elapsedMs: Date.now() - startedAt
|
|
3827
|
+
});
|
|
3828
|
+
if (isSwitchingWallets) {
|
|
3829
|
+
this.isSwitchingWallets = false;
|
|
3830
|
+
} else {
|
|
3831
|
+
(0, import_utils2.dispatchEvent)(import_types.ParaEvent.LOGIN_EVENT, { isComplete: false }, "failed to setup user");
|
|
3832
|
+
}
|
|
3833
|
+
onCancel == null ? void 0 : onCancel();
|
|
3834
|
+
return reject("canceled");
|
|
3835
|
+
}
|
|
3836
|
+
yield new Promise((resolve2) => setTimeout(resolve2, constants.POLLING_INTERVAL_MS));
|
|
3837
|
+
try {
|
|
3838
|
+
this.devLog("[waitForLoginProcess] Touching session");
|
|
3839
|
+
let session = yield this.touchSession();
|
|
3840
|
+
this.devLog("[waitForLoginProcess] Session state", {
|
|
3841
|
+
isAuthenticated: session.isAuthenticated,
|
|
3842
|
+
currentWalletIdsHash: session.currentWalletIdsHash,
|
|
3843
|
+
needsWallet: session.needsWallet
|
|
3844
|
+
});
|
|
3845
|
+
const shouldContinuePolling = isSwitchingWallets ? originalCurrentWalletIdsHash === session.currentWalletIdsHash : !session.isAuthenticated;
|
|
3846
|
+
this.devLog("[waitForLoginProcess] Should continue polling", {
|
|
3847
|
+
shouldContinuePolling,
|
|
3848
|
+
isSwitchingWallets,
|
|
3849
|
+
originalCurrentWalletIdsHash,
|
|
3850
|
+
sessionCurrentWalletIdsHash: session.currentWalletIdsHash,
|
|
3851
|
+
isAuthenticated: session.isAuthenticated
|
|
3852
|
+
});
|
|
3853
|
+
if (shouldContinuePolling) {
|
|
3854
|
+
onPoll == null ? void 0 : onPoll();
|
|
3855
|
+
continue;
|
|
3856
|
+
}
|
|
3857
|
+
this.devLog("[waitForLoginProcess] Authentication check passed, setting up user");
|
|
3858
|
+
session = yield this.userSetupAfterLogin();
|
|
3859
|
+
const needsWallet = (_a = session.needsWallet) != null ? _a : false;
|
|
3860
|
+
this.devLog("[waitForLoginProcess] User setup complete", { needsWallet });
|
|
3861
|
+
if (isSwitchingWallets) {
|
|
3862
|
+
const isWalletSwitchingComplete = originalCurrentWalletIdsHash !== session.currentWalletIdsHash;
|
|
3863
|
+
this.devLog("[waitForLoginProcess] Wallet switching check", {
|
|
3864
|
+
isWalletSwitchingComplete,
|
|
3865
|
+
originalHash: originalCurrentWalletIdsHash,
|
|
3866
|
+
sessionHash: session.currentWalletIdsHash
|
|
3867
|
+
});
|
|
3868
|
+
if (!isWalletSwitchingComplete) {
|
|
3869
|
+
onPoll == null ? void 0 : onPoll();
|
|
3870
|
+
continue;
|
|
3871
|
+
}
|
|
3872
|
+
} else if (!needsWallet) {
|
|
3873
|
+
this.devLog("[waitForLoginProcess] Checking wallet IDs", {
|
|
3874
|
+
currentWalletIdsArrayLength: this.currentWalletIdsArray.length
|
|
3875
|
+
});
|
|
3876
|
+
if (this.currentWalletIdsArray.length === 0) {
|
|
3877
|
+
this.devLog("[waitForLoginProcess] No wallet IDs yet, continuing to poll");
|
|
3878
|
+
onPoll == null ? void 0 : onPoll();
|
|
3879
|
+
continue;
|
|
3880
|
+
}
|
|
3881
|
+
}
|
|
3882
|
+
this.devLog("[waitForLoginProcess] Getting transmission key shares");
|
|
3883
|
+
const tempSharesRes = yield this.getTransmissionKeyShares();
|
|
3884
|
+
this.devLog("[waitForLoginProcess] Transmission shares received", {
|
|
3885
|
+
shareCount: tempSharesRes.data.temporaryShares.length,
|
|
3886
|
+
shares: tempSharesRes.data.temporaryShares.map((s) => ({
|
|
3887
|
+
walletId: s.walletId,
|
|
3888
|
+
walletScheme: s.walletScheme
|
|
3889
|
+
}))
|
|
3890
|
+
});
|
|
3891
|
+
let hasSharesForCurrentWallets;
|
|
3892
|
+
if (!isSwitchingWallets && !this.isPortal()) {
|
|
3893
|
+
this.devLog("[waitForLoginProcess] Fetching wallets");
|
|
3894
|
+
const fetchedWallets = yield this.fetchWallets();
|
|
3895
|
+
this.devLog("[waitForLoginProcess] Wallets fetched", {
|
|
3896
|
+
walletCount: fetchedWallets.length,
|
|
3897
|
+
wallets: fetchedWallets.map((w) => ({ id: w.id, type: w.type, scheme: w.scheme }))
|
|
3898
|
+
});
|
|
3899
|
+
hasSharesForCurrentWallets = tempSharesRes.data.temporaryShares.length === fetchedWallets.length;
|
|
3900
|
+
} else {
|
|
3901
|
+
hasSharesForCurrentWallets = this.currentWalletIdsArray.every(([walletId]) => {
|
|
3902
|
+
return tempSharesRes.data.temporaryShares.some((share) => share.walletId === walletId);
|
|
3903
|
+
});
|
|
3904
|
+
}
|
|
3905
|
+
this.devLog("[waitForLoginProcess] Checking shares for current wallets", {
|
|
3906
|
+
hasSharesForCurrentWallets,
|
|
3907
|
+
currentWalletIdsArray: this.currentWalletIdsArray,
|
|
3908
|
+
shares: tempSharesRes.data.temporaryShares.map((s) => ({
|
|
3909
|
+
walletId: s.walletId,
|
|
3910
|
+
walletScheme: s.walletScheme
|
|
3911
|
+
}))
|
|
3912
|
+
});
|
|
3913
|
+
if (hasSharesForCurrentWallets) {
|
|
3914
|
+
this.devLog("[waitForLoginProcess] Setting up after login");
|
|
3915
|
+
yield this.setupAfterLogin({ temporaryShares: tempSharesRes.data.temporaryShares, skipSessionRefresh });
|
|
3916
|
+
this.devLog("[waitForLoginProcess] Setup after login complete");
|
|
3917
|
+
this.devLog("[waitForLoginProcess] Claiming pregen wallets");
|
|
3918
|
+
yield this.claimPregenWallets();
|
|
3919
|
+
this.devLog("[waitForLoginProcess] Pregen wallets claimed");
|
|
3920
|
+
const resp = {
|
|
3921
|
+
needsWallet: needsWallet || Object.values(this.wallets).length === 0,
|
|
3922
|
+
partnerId: session.partnerId
|
|
3923
|
+
};
|
|
3924
|
+
this.devLog("[waitForLoginProcess] Login process complete", {
|
|
3925
|
+
needsWallet: resp.needsWallet,
|
|
3926
|
+
partnerId: resp.partnerId,
|
|
3927
|
+
walletCount: Object.values(this.wallets).length,
|
|
3928
|
+
isSwitchingWallets
|
|
3929
|
+
});
|
|
3930
|
+
if (isSwitchingWallets) {
|
|
3931
|
+
this.devLog("[waitForLoginProcess] Clearing wallet switching state");
|
|
3932
|
+
this.isSwitchingWallets = false;
|
|
3933
|
+
} else {
|
|
3934
|
+
this.devLog("[waitForLoginProcess] Dispatching LOGIN_EVENT");
|
|
3935
|
+
(0, import_utils2.dispatchEvent)(import_types.ParaEvent.LOGIN_EVENT, resp);
|
|
3936
|
+
}
|
|
3937
|
+
return resolve(resp);
|
|
3938
|
+
}
|
|
3939
|
+
this.devLog("[waitForLoginProcess] Not all shares available yet, continuing to poll");
|
|
3940
|
+
onPoll == null ? void 0 : onPoll();
|
|
3941
|
+
} catch (err) {
|
|
3942
|
+
console.error("[waitForLoginProcess] Error during polling iteration", err);
|
|
3943
|
+
onPoll == null ? void 0 : onPoll();
|
|
3944
|
+
}
|
|
3945
|
+
}
|
|
3946
|
+
}))();
|
|
3202
3947
|
});
|
|
3203
3948
|
});
|
|
3204
3949
|
};
|
|
@@ -3252,8 +3997,9 @@ createPregenWallet_fn = function(opts) {
|
|
|
3252
3997
|
_isCreateGuestWalletsPending = new WeakMap();
|
|
3253
3998
|
prepareAuthState_fn = function(_0) {
|
|
3254
3999
|
return __async(this, arguments, function* (serverAuthState, opts = {}) {
|
|
3255
|
-
|
|
3256
|
-
|
|
4000
|
+
var _a, _b;
|
|
4001
|
+
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))))) {
|
|
4002
|
+
opts.sessionLookupId = yield this.prepareLogin();
|
|
3257
4003
|
}
|
|
3258
4004
|
const { auth, externalWallet, userId, displayName, pfpUrl, username } = serverAuthState;
|
|
3259
4005
|
const authInfo = __spreadValues(__spreadValues({}, (0, import_user_management_client.extractAuthInfo)(auth, { isRequired: true })), Object.fromEntries(
|
|
@@ -3274,8 +4020,14 @@ prepareAuthState_fn = function(_0) {
|
|
|
3274
4020
|
}
|
|
3275
4021
|
let authState;
|
|
3276
4022
|
switch (serverAuthState.stage) {
|
|
4023
|
+
case "done": {
|
|
4024
|
+
authState = yield __privateMethod(this, _ParaCore_instances, prepareDoneState_fn).call(this, serverAuthState);
|
|
4025
|
+
break;
|
|
4026
|
+
}
|
|
3277
4027
|
case "verify":
|
|
3278
|
-
authState = serverAuthState
|
|
4028
|
+
authState = yield __privateMethod(this, _ParaCore_instances, prepareVerificationState_fn).call(this, serverAuthState, __spreadProps(__spreadValues({}, opts), {
|
|
4029
|
+
sessionLookupId: opts.sessionLookupId
|
|
4030
|
+
}));
|
|
3279
4031
|
break;
|
|
3280
4032
|
case "login":
|
|
3281
4033
|
if (externalWallet && !(externalWallet == null ? void 0 : externalWallet.withFullParaAuth)) {
|
|
@@ -3295,14 +4047,36 @@ prepareAuthState_fn = function(_0) {
|
|
|
3295
4047
|
return authState;
|
|
3296
4048
|
});
|
|
3297
4049
|
};
|
|
3298
|
-
|
|
4050
|
+
prepareDoneState_fn = function(doneState) {
|
|
3299
4051
|
return __async(this, null, function* () {
|
|
3300
|
-
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
|
|
4052
|
+
let isSLOPossible = doneState.authMethods.includes(import_user_management_client.AuthMethod.BASIC_LOGIN);
|
|
4053
|
+
this.isEnclaveUser = isSLOPossible;
|
|
4054
|
+
return doneState;
|
|
4055
|
+
});
|
|
4056
|
+
};
|
|
4057
|
+
prepareVerificationState_fn = function(_0, _1) {
|
|
4058
|
+
return __async(this, arguments, function* (verifyState, {
|
|
4059
|
+
useShortUrls: shorten = false,
|
|
4060
|
+
portalTheme,
|
|
4061
|
+
sessionLookupId
|
|
4062
|
+
}) {
|
|
4063
|
+
var _a;
|
|
4064
|
+
let isSLOPossible = false;
|
|
4065
|
+
if (verifyState.nextStage === "login") {
|
|
4066
|
+
isSLOPossible = verifyState.loginAuthMethods.includes(import_user_management_client.AuthMethod.BASIC_LOGIN);
|
|
4067
|
+
} else if (verifyState.nextStage === "signup") {
|
|
4068
|
+
isSLOPossible = verifyState.signupAuthMethods.includes(import_user_management_client.AuthMethod.BASIC_LOGIN);
|
|
3304
4069
|
}
|
|
3305
|
-
|
|
4070
|
+
this.isEnclaveUser = isSLOPossible;
|
|
4071
|
+
const isExternalWalletFullAuth = (_a = verifyState.externalWallet) == null ? void 0 : _a.withFullParaAuth;
|
|
4072
|
+
return __spreadValues(__spreadValues({}, verifyState), isSLOPossible || isExternalWalletFullAuth ? {
|
|
4073
|
+
loginUrl: yield this.getLoginUrl({
|
|
4074
|
+
authMethod: import_user_management_client.AuthMethod.BASIC_LOGIN,
|
|
4075
|
+
sessionId: sessionLookupId,
|
|
4076
|
+
shorten,
|
|
4077
|
+
portalTheme
|
|
4078
|
+
})
|
|
4079
|
+
} : {});
|
|
3306
4080
|
});
|
|
3307
4081
|
};
|
|
3308
4082
|
prepareLoginState_fn = function(_0, _1) {
|
|
@@ -3311,10 +4085,11 @@ prepareLoginState_fn = function(_0, _1) {
|
|
|
3311
4085
|
portalTheme,
|
|
3312
4086
|
sessionLookupId
|
|
3313
4087
|
}) {
|
|
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
|
|
4088
|
+
const _a = loginState, { loginAuthMethods = [], hasPasswordWithoutPIN } = _a, authState = __objRest(_a, ["loginAuthMethods", "hasPasswordWithoutPIN"]);
|
|
4089
|
+
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);
|
|
4090
|
+
return __spreadValues(__spreadValues(__spreadValues(__spreadProps(__spreadValues({}, authState), {
|
|
4091
|
+
isPasskeySupported,
|
|
4092
|
+
loginAuthMethods
|
|
3318
4093
|
}), isPasskeyPossible ? {
|
|
3319
4094
|
passkeyUrl: yield this.getLoginUrl({ sessionId: sessionLookupId, shorten, portalTheme }),
|
|
3320
4095
|
passkeyKnownDeviceUrl: yield this.constructPortalUrl("loginAuth", {
|
|
@@ -3333,23 +4108,34 @@ prepareLoginState_fn = function(_0, _1) {
|
|
|
3333
4108
|
portalTheme,
|
|
3334
4109
|
params: { isEmbedded: `${!loginState.isWalletSelectionNeeded}` }
|
|
3335
4110
|
})
|
|
4111
|
+
} : {}), isPINPossible ? {
|
|
4112
|
+
pinUrl: yield this.constructPortalUrl("loginPIN", {
|
|
4113
|
+
sessionId: sessionLookupId,
|
|
4114
|
+
shorten,
|
|
4115
|
+
portalTheme,
|
|
4116
|
+
params: { isEmbedded: `${!loginState.isWalletSelectionNeeded}` }
|
|
4117
|
+
})
|
|
3336
4118
|
} : {});
|
|
3337
4119
|
});
|
|
3338
4120
|
};
|
|
3339
4121
|
prepareSignUpState_fn = function(_0, _1) {
|
|
3340
4122
|
return __async(this, arguments, function* (serverSignupState, { useShortUrls: shorten = false, portalTheme }) {
|
|
3341
|
-
const _a = serverSignupState, { signupAuthMethods } = _a, authState = __objRest(_a, ["signupAuthMethods"]);
|
|
4123
|
+
const _a = serverSignupState, { signupAuthMethods = [] } = _a, authState = __objRest(_a, ["signupAuthMethods"]);
|
|
3342
4124
|
const isPasskeySupported = yield this.isPasskeySupported();
|
|
3343
|
-
const [isPasskey, isPassword] = [
|
|
4125
|
+
const [isPasskey, isPassword, isPIN] = [
|
|
3344
4126
|
signupAuthMethods.includes(import_user_management_client.AuthMethod.PASSKEY),
|
|
3345
|
-
signupAuthMethods.includes(import_user_management_client.AuthMethod.PASSWORD) || !isPasskeySupported
|
|
4127
|
+
signupAuthMethods.includes(import_user_management_client.AuthMethod.PASSWORD) || !isPasskeySupported,
|
|
4128
|
+
signupAuthMethods.includes(import_user_management_client.AuthMethod.PIN)
|
|
3346
4129
|
];
|
|
3347
|
-
if (!isPasskey && !isPassword) {
|
|
4130
|
+
if (!isPasskey && !isPassword && !isPIN) {
|
|
3348
4131
|
throw new Error(
|
|
3349
|
-
"No supported authentication methods found. Please ensure you have enabled either WebAuth passkeys or
|
|
4132
|
+
"No supported authentication methods found. Please ensure you have enabled either WebAuth passkeys, passwords or PINs in your Developer Portal settings."
|
|
3350
4133
|
);
|
|
3351
4134
|
}
|
|
3352
|
-
const signupState = __spreadProps(__spreadValues({}, authState), {
|
|
4135
|
+
const signupState = __spreadProps(__spreadValues({}, authState), {
|
|
4136
|
+
isPasskeySupported,
|
|
4137
|
+
signupAuthMethods
|
|
4138
|
+
});
|
|
3353
4139
|
if (isPasskey) {
|
|
3354
4140
|
const { url: passkeyUrl, credentialId: passkeyId } = yield this.getNewCredentialAndUrl({
|
|
3355
4141
|
authMethod: "PASSKEY",
|
|
@@ -3367,6 +4153,15 @@ prepareSignUpState_fn = function(_0, _1) {
|
|
|
3367
4153
|
signupState.passwordUrl = passwordUrl;
|
|
3368
4154
|
signupState.passwordId = passwordId;
|
|
3369
4155
|
}
|
|
4156
|
+
if (isPIN) {
|
|
4157
|
+
const { url: pinUrl, credentialId: pinId } = yield this.getNewCredentialAndUrl({
|
|
4158
|
+
authMethod: "PIN",
|
|
4159
|
+
portalTheme,
|
|
4160
|
+
shorten
|
|
4161
|
+
});
|
|
4162
|
+
signupState.pinUrl = pinUrl;
|
|
4163
|
+
signupState.pinId = pinId;
|
|
4164
|
+
}
|
|
3370
4165
|
return signupState;
|
|
3371
4166
|
});
|
|
3372
4167
|
};
|