@metamask-previews/seedless-onboarding-controller 5.0.0-preview-772b5970 → 5.0.0-preview-dc6dbaa5
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/CHANGELOG.md +14 -0
- package/dist/SeedlessOnboardingController.cjs +70 -76
- package/dist/SeedlessOnboardingController.cjs.map +1 -1
- package/dist/SeedlessOnboardingController.d.cts +8 -2
- package/dist/SeedlessOnboardingController.d.cts.map +1 -1
- package/dist/SeedlessOnboardingController.d.mts +8 -2
- package/dist/SeedlessOnboardingController.d.mts.map +1 -1
- package/dist/SeedlessOnboardingController.mjs +71 -77
- package/dist/SeedlessOnboardingController.mjs.map +1 -1
- package/dist/assertions.cjs +20 -4
- package/dist/assertions.cjs.map +1 -1
- package/dist/assertions.d.cts +7 -0
- package/dist/assertions.d.cts.map +1 -1
- package/dist/assertions.d.mts +7 -0
- package/dist/assertions.d.mts.map +1 -1
- package/dist/assertions.mjs +18 -3
- package/dist/assertions.mjs.map +1 -1
- package/dist/constants.cjs +1 -0
- package/dist/constants.cjs.map +1 -1
- package/dist/constants.d.cts +2 -1
- package/dist/constants.d.cts.map +1 -1
- package/dist/constants.d.mts +2 -1
- package/dist/constants.d.mts.map +1 -1
- package/dist/constants.mjs +1 -0
- package/dist/constants.mjs.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +8 -0
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +8 -0
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- Added new public method, `checkIsSeedlessOnboardingUserAuthenticated` to validate the controller authenticate tokens state. ([#6998](https://github.com/MetaMask/core/pull/6998))
|
|
13
|
+
|
|
14
|
+
### Changed
|
|
15
|
+
|
|
16
|
+
- **BREAKING** Update `refreshToken` and `revokeToken` params as required in `Authenticate` method. ([#6998](https://github.com/MetaMask/core/pull/6998))
|
|
17
|
+
- Refactor `refreshAuthTokens` method, separately catch refreshJWTToken and authenticate errors. ([#6998](https://github.com/MetaMask/core/pull/6998))
|
|
18
|
+
- Bump `@metamask/toprf-secure-backup` package to `0.9.0`. ([#6998](https://github.com/MetaMask/core/pull/6998))
|
|
19
|
+
|
|
20
|
+
### Fixed
|
|
21
|
+
|
|
22
|
+
- Fixed `Invalid Access Token` error during rehydration. ([#6998](https://github.com/MetaMask/core/pull/6998))
|
|
23
|
+
|
|
10
24
|
## [5.0.0]
|
|
11
25
|
|
|
12
26
|
### Changed
|
|
@@ -10,7 +10,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
10
10
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
11
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
12
|
};
|
|
13
|
-
var _SeedlessOnboardingController_instances, _SeedlessOnboardingController_vaultEncryptor, _SeedlessOnboardingController_controllerOperationMutex, _SeedlessOnboardingController_vaultOperationMutex, _SeedlessOnboardingController_refreshJWTToken, _SeedlessOnboardingController_revokeRefreshToken, _SeedlessOnboardingController_renewRefreshToken, _SeedlessOnboardingController_passwordOutdatedCacheTTL, _SeedlessOnboardingController_isUnlocked, _SeedlessOnboardingController_cachedDecryptedVaultData, _SeedlessOnboardingController_submitGlobalPassword,
|
|
13
|
+
var _SeedlessOnboardingController_instances, _SeedlessOnboardingController_vaultEncryptor, _SeedlessOnboardingController_controllerOperationMutex, _SeedlessOnboardingController_vaultOperationMutex, _SeedlessOnboardingController_refreshJWTToken, _SeedlessOnboardingController_revokeRefreshToken, _SeedlessOnboardingController_renewRefreshToken, _SeedlessOnboardingController_passwordOutdatedCacheTTL, _SeedlessOnboardingController_isUnlocked, _SeedlessOnboardingController_cachedDecryptedVaultData, _SeedlessOnboardingController_submitGlobalPassword, _SeedlessOnboardingController_setUnlocked, _SeedlessOnboardingController_persistOprfKey, _SeedlessOnboardingController_persistAuthPubKey, _SeedlessOnboardingController_storeKeyringEncryptionKey, _SeedlessOnboardingController_loadKeyringEncryptionKey, _SeedlessOnboardingController_loadSeedlessEncryptionKey, _SeedlessOnboardingController_recoverAuthPubKey, _SeedlessOnboardingController_recoverEncKey, _SeedlessOnboardingController_fetchAllSecretDataFromMetadataStore, _SeedlessOnboardingController_changeEncryptionKey, _SeedlessOnboardingController_encryptAndStoreSecretData, _SeedlessOnboardingController_unlockVaultAndGetVaultData, _SeedlessOnboardingController_decryptAndParseVaultData, _SeedlessOnboardingController_withPersistedSecretMetadataBackupsState, _SeedlessOnboardingController_filterDupesAndUpdateSocialBackupsMetadata, _SeedlessOnboardingController_createNewVaultWithAuthData, _SeedlessOnboardingController_updateVault, _SeedlessOnboardingController_withControllerLock, _SeedlessOnboardingController_withVaultLock, _SeedlessOnboardingController_parseVaultData, _SeedlessOnboardingController_assertIsUnlocked, _SeedlessOnboardingController_assertIsAuthenticatedUser, _SeedlessOnboardingController_assertIsSRPBackedUpUser, _SeedlessOnboardingController_assertPasswordInSync, _SeedlessOnboardingController_resetPasswordOutdatedCache, _SeedlessOnboardingController_addRefreshTokenToRevokeList, _SeedlessOnboardingController_isAuthTokenError, _SeedlessOnboardingController_isMaxKeyChainLengthError, _SeedlessOnboardingController_executeWithTokenRefresh;
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.SeedlessOnboardingController = exports.getInitialSeedlessOnboardingControllerStateWithDefaults = void 0;
|
|
16
16
|
const auth_network_utils_1 = require("@metamask/auth-network-utils");
|
|
@@ -297,14 +297,10 @@ class SeedlessOnboardingController extends base_controller_1.BaseController {
|
|
|
297
297
|
state.authConnection = authConnection;
|
|
298
298
|
state.socialLoginEmail = socialLoginEmail;
|
|
299
299
|
state.metadataAccessToken = metadataAccessToken;
|
|
300
|
+
state.refreshToken = refreshToken;
|
|
301
|
+
// Temporarily store revoke token & access token in state for later vault creation
|
|
302
|
+
state.revokeToken = revokeToken;
|
|
300
303
|
state.accessToken = accessToken;
|
|
301
|
-
if (refreshToken) {
|
|
302
|
-
state.refreshToken = refreshToken;
|
|
303
|
-
}
|
|
304
|
-
if (revokeToken) {
|
|
305
|
-
// Temporarily store revoke token in state for later vault creation
|
|
306
|
-
state.revokeToken = revokeToken;
|
|
307
|
-
}
|
|
308
304
|
// we will check if the controller state is properly set with the authenticated user info
|
|
309
305
|
// before setting the isSeedlessOnboardingUserAuthenticated to true
|
|
310
306
|
(0, assertions_1.assertIsSeedlessOnboardingUserAuthenticated)(state);
|
|
@@ -406,26 +402,26 @@ class SeedlessOnboardingController extends base_controller_1.BaseController {
|
|
|
406
402
|
*/
|
|
407
403
|
async fetchAllSecretData(password) {
|
|
408
404
|
return await __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_withControllerLock).call(this, async () => {
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
405
|
+
return await __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_executeWithTokenRefresh).call(this, async () => {
|
|
406
|
+
// assert that the user is authenticated before fetching the secret data
|
|
407
|
+
__classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_assertIsAuthenticatedUser).call(this, this.state);
|
|
408
|
+
let encKey;
|
|
409
|
+
let pwEncKey;
|
|
410
|
+
let authKeyPair;
|
|
411
|
+
if (password) {
|
|
412
|
+
const recoverEncKeyResult = await __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_recoverEncKey).call(this, password);
|
|
413
|
+
encKey = recoverEncKeyResult.encKey;
|
|
414
|
+
pwEncKey = recoverEncKeyResult.pwEncKey;
|
|
415
|
+
authKeyPair = recoverEncKeyResult.authKeyPair;
|
|
416
|
+
}
|
|
417
|
+
else {
|
|
418
|
+
__classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_assertIsUnlocked).call(this);
|
|
419
|
+
// verify the password and unlock the vault
|
|
420
|
+
const keysFromVault = await __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_unlockVaultAndGetVaultData).call(this);
|
|
421
|
+
encKey = keysFromVault.toprfEncryptionKey;
|
|
422
|
+
pwEncKey = keysFromVault.toprfPwEncryptionKey;
|
|
423
|
+
authKeyPair = keysFromVault.toprfAuthKeyPair;
|
|
424
|
+
}
|
|
429
425
|
const secrets = await __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_fetchAllSecretDataFromMetadataStore).call(this, encKey, authKeyPair);
|
|
430
426
|
if (password) {
|
|
431
427
|
// if password is provided, we need to create a new vault with the auth data. (supposedly the user is trying to rehydrate the wallet)
|
|
@@ -437,8 +433,7 @@ class SeedlessOnboardingController extends base_controller_1.BaseController {
|
|
|
437
433
|
});
|
|
438
434
|
}
|
|
439
435
|
return secrets;
|
|
440
|
-
};
|
|
441
|
-
return await __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_executeWithTokenRefresh).call(this, performFetch, 'fetchAllSecretData');
|
|
436
|
+
}, 'fetchAllSecretData');
|
|
442
437
|
});
|
|
443
438
|
}
|
|
444
439
|
/**
|
|
@@ -634,7 +629,6 @@ class SeedlessOnboardingController extends base_controller_1.BaseController {
|
|
|
634
629
|
*/
|
|
635
630
|
async checkIsPasswordOutdated(options) {
|
|
636
631
|
const doCheckIsPasswordExpired = async () => {
|
|
637
|
-
__classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_assertIsAuthenticatedUser).call(this, this.state);
|
|
638
632
|
// cache result to reduce load on infra
|
|
639
633
|
// Check cache first unless skipCache is true
|
|
640
634
|
if (!options?.skipCache) {
|
|
@@ -647,6 +641,7 @@ class SeedlessOnboardingController extends base_controller_1.BaseController {
|
|
|
647
641
|
return passwordOutdatedCache.isExpiredPwd;
|
|
648
642
|
}
|
|
649
643
|
}
|
|
644
|
+
(0, assertions_1.assertIsAuthUserInfoValid)(this.state);
|
|
650
645
|
const { nodeAuthTokens, authConnectionId, groupedAuthConnectionId, userId, } = this.state;
|
|
651
646
|
const currentDeviceAuthPubKey = __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_recoverAuthPubKey).call(this);
|
|
652
647
|
let globalAuthPubKey = options?.globalAuthPubKey;
|
|
@@ -676,6 +671,25 @@ class SeedlessOnboardingController extends base_controller_1.BaseController {
|
|
|
676
671
|
? await doCheckIsPasswordExpired()
|
|
677
672
|
: await __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_withControllerLock).call(this, doCheckIsPasswordExpired), 'checkIsPasswordOutdated');
|
|
678
673
|
}
|
|
674
|
+
/**
|
|
675
|
+
* Check if the user is authenticated with the seedless onboarding flow by checking the token values in the state.
|
|
676
|
+
*
|
|
677
|
+
* @returns True if the user is authenticated, false otherwise.
|
|
678
|
+
*/
|
|
679
|
+
async checkIsSeedlessOnboardingUserAuthenticated() {
|
|
680
|
+
let isAuthenticated = false;
|
|
681
|
+
try {
|
|
682
|
+
(0, assertions_1.assertIsSeedlessOnboardingUserAuthenticated)(this.state);
|
|
683
|
+
isAuthenticated = true;
|
|
684
|
+
}
|
|
685
|
+
catch {
|
|
686
|
+
isAuthenticated = false;
|
|
687
|
+
}
|
|
688
|
+
this.update((state) => {
|
|
689
|
+
state.isSeedlessOnboardingUserAuthenticated = isAuthenticated;
|
|
690
|
+
});
|
|
691
|
+
return isAuthenticated;
|
|
692
|
+
}
|
|
679
693
|
/**
|
|
680
694
|
* Clears the current state of the SeedlessOnboardingController.
|
|
681
695
|
*/
|
|
@@ -715,12 +729,15 @@ class SeedlessOnboardingController extends base_controller_1.BaseController {
|
|
|
715
729
|
*/
|
|
716
730
|
async refreshAuthTokens() {
|
|
717
731
|
__classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_assertIsAuthenticatedUser).call(this, this.state);
|
|
718
|
-
const { refreshToken } = this.state;
|
|
732
|
+
const { refreshToken, revokeToken } = this.state;
|
|
733
|
+
const res = await __classPrivateFieldGet(this, _SeedlessOnboardingController_refreshJWTToken, "f").call(this, {
|
|
734
|
+
connection: this.state.authConnection,
|
|
735
|
+
refreshToken,
|
|
736
|
+
}).catch((error) => {
|
|
737
|
+
log('Error refreshing JWT tokens', error);
|
|
738
|
+
throw new Error(constants_1.SeedlessOnboardingControllerErrorMessage.FailedToRefreshJWTTokens);
|
|
739
|
+
});
|
|
719
740
|
try {
|
|
720
|
-
const res = await __classPrivateFieldGet(this, _SeedlessOnboardingController_refreshJWTToken, "f").call(this, {
|
|
721
|
-
connection: this.state.authConnection,
|
|
722
|
-
refreshToken,
|
|
723
|
-
});
|
|
724
741
|
const { idTokens, accessToken, metadataAccessToken } = res;
|
|
725
742
|
// re-authenticate with the new id tokens to set new node auth tokens
|
|
726
743
|
await this.authenticate({
|
|
@@ -731,6 +748,8 @@ class SeedlessOnboardingController extends base_controller_1.BaseController {
|
|
|
731
748
|
authConnectionId: this.state.authConnectionId,
|
|
732
749
|
groupedAuthConnectionId: this.state.groupedAuthConnectionId,
|
|
733
750
|
userId: this.state.userId,
|
|
751
|
+
refreshToken,
|
|
752
|
+
revokeToken,
|
|
734
753
|
skipLock: true,
|
|
735
754
|
});
|
|
736
755
|
}
|
|
@@ -868,9 +887,6 @@ class SeedlessOnboardingController extends base_controller_1.BaseController {
|
|
|
868
887
|
try {
|
|
869
888
|
__classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_assertIsAuthenticatedUser).call(this, this.state);
|
|
870
889
|
const { accessToken } = this.state;
|
|
871
|
-
if (!accessToken) {
|
|
872
|
-
return true; // Consider missing token as expired
|
|
873
|
-
}
|
|
874
890
|
const decodedToken = (0, utils_3.decodeJWTToken)(accessToken);
|
|
875
891
|
return decodedToken.exp < Math.floor(Date.now() / 1000);
|
|
876
892
|
}
|
|
@@ -912,7 +928,7 @@ async function _SeedlessOnboardingController_submitGlobalPassword({ targetAuthPu
|
|
|
912
928
|
__classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_setUnlocked).call(this);
|
|
913
929
|
}
|
|
914
930
|
catch (error) {
|
|
915
|
-
if (__classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m",
|
|
931
|
+
if (__classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_isAuthTokenError).call(this, error)) {
|
|
916
932
|
throw error;
|
|
917
933
|
}
|
|
918
934
|
if (__classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_isMaxKeyChainLengthError).call(this, error)) {
|
|
@@ -920,30 +936,6 @@ async function _SeedlessOnboardingController_submitGlobalPassword({ targetAuthPu
|
|
|
920
936
|
}
|
|
921
937
|
throw errors_1.PasswordSyncError.getInstance(error);
|
|
922
938
|
}
|
|
923
|
-
}, _SeedlessOnboardingController_getAccessToken =
|
|
924
|
-
/**
|
|
925
|
-
* Get the access token from the state or the vault.
|
|
926
|
-
* If the access token is not in the state, it will be retrieved from the vault by decrypting it with the password.
|
|
927
|
-
*
|
|
928
|
-
* If both the access token and the vault are not available, an error will be thrown.
|
|
929
|
-
*
|
|
930
|
-
* @param password - The optional password to unlock the vault. If not provided, the access token will be retrieved from the vault.
|
|
931
|
-
* @returns The access token.
|
|
932
|
-
*/
|
|
933
|
-
async function _SeedlessOnboardingController_getAccessToken(password) {
|
|
934
|
-
const { accessToken, vault } = this.state;
|
|
935
|
-
if (accessToken) {
|
|
936
|
-
// if the access token is in the state, return it
|
|
937
|
-
return accessToken;
|
|
938
|
-
}
|
|
939
|
-
// otherwise, check the vault availability and decrypt the access token from the vault
|
|
940
|
-
if (!vault) {
|
|
941
|
-
throw new Error(constants_1.SeedlessOnboardingControllerErrorMessage.InvalidAccessToken);
|
|
942
|
-
}
|
|
943
|
-
const { vaultData } = await __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_decryptAndParseVaultData).call(this, {
|
|
944
|
-
password,
|
|
945
|
-
});
|
|
946
|
-
return vaultData.accessToken;
|
|
947
939
|
}, _SeedlessOnboardingController_setUnlocked = function _SeedlessOnboardingController_setUnlocked() {
|
|
948
940
|
__classPrivateFieldSet(this, _SeedlessOnboardingController_isUnlocked, true, "f");
|
|
949
941
|
}, _SeedlessOnboardingController_persistOprfKey =
|
|
@@ -968,7 +960,7 @@ async function _SeedlessOnboardingController_persistOprfKey(oprfKey, authPubKey)
|
|
|
968
960
|
});
|
|
969
961
|
}
|
|
970
962
|
catch (error) {
|
|
971
|
-
if (__classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m",
|
|
963
|
+
if (__classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_isAuthTokenError).call(this, error)) {
|
|
972
964
|
throw error;
|
|
973
965
|
}
|
|
974
966
|
log('Error persisting local encryption key', error);
|
|
@@ -1032,11 +1024,11 @@ async function _SeedlessOnboardingController_loadSeedlessEncryptionKey(encKey) {
|
|
|
1032
1024
|
* @throws RecoveryError - If failed to recover the encryption key.
|
|
1033
1025
|
*/
|
|
1034
1026
|
async function _SeedlessOnboardingController_recoverEncKey(password) {
|
|
1035
|
-
|
|
1036
|
-
const { authConnectionId, groupedAuthConnectionId, userId } = this.state;
|
|
1027
|
+
(0, assertions_1.assertIsAuthUserInfoValid)(this.state);
|
|
1028
|
+
const { nodeAuthTokens, authConnectionId, groupedAuthConnectionId, userId, } = this.state;
|
|
1037
1029
|
try {
|
|
1038
1030
|
const recoverEncKeyResult = await this.toprfClient.recoverEncKey({
|
|
1039
|
-
nodeAuthTokens
|
|
1031
|
+
nodeAuthTokens,
|
|
1040
1032
|
password,
|
|
1041
1033
|
authConnectionId,
|
|
1042
1034
|
groupedAuthConnectionId,
|
|
@@ -1046,7 +1038,7 @@ async function _SeedlessOnboardingController_recoverEncKey(password) {
|
|
|
1046
1038
|
}
|
|
1047
1039
|
catch (error) {
|
|
1048
1040
|
// throw token expired error for token refresh handler
|
|
1049
|
-
if (__classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m",
|
|
1041
|
+
if (__classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_isAuthTokenError).call(this, error)) {
|
|
1050
1042
|
throw error;
|
|
1051
1043
|
}
|
|
1052
1044
|
throw errors_1.RecoveryError.getInstance(error);
|
|
@@ -1062,7 +1054,7 @@ async function _SeedlessOnboardingController_recoverEncKey(password) {
|
|
|
1062
1054
|
}
|
|
1063
1055
|
catch (error) {
|
|
1064
1056
|
log('Error fetching secret data', error);
|
|
1065
|
-
if (__classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m",
|
|
1057
|
+
if (__classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_isAuthTokenError).call(this, error)) {
|
|
1066
1058
|
throw error;
|
|
1067
1059
|
}
|
|
1068
1060
|
throw new Error(constants_1.SeedlessOnboardingControllerErrorMessage.FailedToFetchSecretMetadata);
|
|
@@ -1166,7 +1158,7 @@ async function _SeedlessOnboardingController_encryptAndStoreSecretData(params) {
|
|
|
1166
1158
|
});
|
|
1167
1159
|
}
|
|
1168
1160
|
catch (error) {
|
|
1169
|
-
if (__classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m",
|
|
1161
|
+
if (__classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_isAuthTokenError).call(this, error)) {
|
|
1170
1162
|
throw error;
|
|
1171
1163
|
}
|
|
1172
1164
|
log('Error encrypting and storing secret data backup', error);
|
|
@@ -1323,8 +1315,7 @@ async function _SeedlessOnboardingController_withPersistedSecretMetadataBackupsS
|
|
|
1323
1315
|
*/
|
|
1324
1316
|
async function _SeedlessOnboardingController_createNewVaultWithAuthData({ password, rawToprfEncryptionKey, rawToprfPwEncryptionKey, rawToprfAuthKeyPair, }) {
|
|
1325
1317
|
__classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_assertIsAuthenticatedUser).call(this, this.state);
|
|
1326
|
-
const { revokeToken } = this.state;
|
|
1327
|
-
const accessToken = await __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_getAccessToken).call(this, password);
|
|
1318
|
+
const { revokeToken, accessToken } = this.state;
|
|
1328
1319
|
const vaultData = {
|
|
1329
1320
|
toprfAuthKeyPair: rawToprfAuthKeyPair,
|
|
1330
1321
|
toprfEncryptionKey: rawToprfEncryptionKey,
|
|
@@ -1475,10 +1466,13 @@ async function _SeedlessOnboardingController_assertPasswordInSync(options) {
|
|
|
1475
1466
|
{ refreshToken, revokeToken },
|
|
1476
1467
|
];
|
|
1477
1468
|
});
|
|
1478
|
-
},
|
|
1469
|
+
}, _SeedlessOnboardingController_isAuthTokenError = function _SeedlessOnboardingController_isAuthTokenError(error) {
|
|
1479
1470
|
if (error instanceof toprf_secure_backup_1.TOPRFError) {
|
|
1471
|
+
return (
|
|
1480
1472
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison
|
|
1481
|
-
|
|
1473
|
+
error.code === toprf_secure_backup_1.TOPRFErrorCode.AuthTokenExpired ||
|
|
1474
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison
|
|
1475
|
+
error.code === toprf_secure_backup_1.TOPRFErrorCode.InvalidAuthToken);
|
|
1482
1476
|
}
|
|
1483
1477
|
return false;
|
|
1484
1478
|
}, _SeedlessOnboardingController_isMaxKeyChainLengthError = function _SeedlessOnboardingController_isMaxKeyChainLengthError(error) {
|
|
@@ -1521,7 +1515,7 @@ async function _SeedlessOnboardingController_executeWithTokenRefresh(operation,
|
|
|
1521
1515
|
}
|
|
1522
1516
|
catch (error) {
|
|
1523
1517
|
// Check if this is a token expiration error
|
|
1524
|
-
if (__classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m",
|
|
1518
|
+
if (__classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_isAuthTokenError).call(this, error)) {
|
|
1525
1519
|
log(`Token expired during ${operationName}, attempting to refresh tokens`, error);
|
|
1526
1520
|
try {
|
|
1527
1521
|
// Refresh the tokens
|