@metamask-previews/seedless-onboarding-controller 2.4.0-preview-e0bc4b4b → 2.4.0-preview-b8fffa99
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 +4 -0
- package/dist/SeedlessOnboardingController.cjs +114 -30
- package/dist/SeedlessOnboardingController.cjs.map +1 -1
- package/dist/SeedlessOnboardingController.d.cts +6 -1
- package/dist/SeedlessOnboardingController.d.cts.map +1 -1
- package/dist/SeedlessOnboardingController.d.mts +6 -1
- package/dist/SeedlessOnboardingController.d.mts.map +1 -1
- package/dist/SeedlessOnboardingController.mjs +115 -31
- package/dist/SeedlessOnboardingController.mjs.map +1 -1
- package/dist/assertions.cjs +16 -1
- 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 +14 -0
- package/dist/assertions.mjs.map +1 -1
- package/dist/constants.cjs +3 -1
- package/dist/constants.cjs.map +1 -1
- package/dist/constants.d.cts +4 -2
- package/dist/constants.d.cts.map +1 -1
- package/dist/constants.d.mts +4 -2
- package/dist/constants.d.mts.map +1 -1
- package/dist/constants.mjs +3 -1
- package/dist/constants.mjs.map +1 -1
- package/dist/index.cjs +3 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +1 -0
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -0
- package/dist/index.mjs.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +6 -0
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +6 -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,10 @@ 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 an optional parameter, `passwordOutdatedCacheTTL` to the constructor params and exported `SecretMetadata` class from the controller.([#6169](https://github.com/MetaMask/core/pull/6169))
|
|
13
|
+
|
|
10
14
|
## [2.4.0]
|
|
11
15
|
|
|
12
16
|
### Fixed
|
|
@@ -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_isUnlocked, _SeedlessOnboardingController_submitGlobalPassword, _SeedlessOnboardingController_getAccessToken, _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_withPersistedSecretMetadataBackupsState, _SeedlessOnboardingController_filterDupesAndUpdateSocialBackupsMetadata, _SeedlessOnboardingController_createNewVaultWithAuthData, _SeedlessOnboardingController_updateVault, _SeedlessOnboardingController_withControllerLock, _SeedlessOnboardingController_withVaultLock, _SeedlessOnboardingController_serializeKeyData, _SeedlessOnboardingController_parseVaultData, _SeedlessOnboardingController_assertIsUnlocked, _SeedlessOnboardingController_assertIsAuthenticatedUser, _SeedlessOnboardingController_assertIsSRPBackedUpUser, _SeedlessOnboardingController_assertPasswordInSync, _SeedlessOnboardingController_resetPasswordOutdatedCache, _SeedlessOnboardingController_revokeRefreshTokenAndUpdateState, _SeedlessOnboardingController_isTokenExpiredError, _SeedlessOnboardingController_isMaxKeyChainLengthError, _SeedlessOnboardingController_executeWithTokenRefresh;
|
|
13
|
+
var _SeedlessOnboardingController_instances, _SeedlessOnboardingController_vaultEncryptor, _SeedlessOnboardingController_controllerOperationMutex, _SeedlessOnboardingController_vaultOperationMutex, _SeedlessOnboardingController_refreshJWTToken, _SeedlessOnboardingController_revokeRefreshToken, _SeedlessOnboardingController_isUnlocked, _SeedlessOnboardingController_passwordOutdatedCacheTTL, _SeedlessOnboardingController_submitGlobalPassword, _SeedlessOnboardingController_getAccessToken, _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_withPersistedSecretMetadataBackupsState, _SeedlessOnboardingController_filterDupesAndUpdateSocialBackupsMetadata, _SeedlessOnboardingController_createNewVaultWithAuthData, _SeedlessOnboardingController_updateVault, _SeedlessOnboardingController_withControllerLock, _SeedlessOnboardingController_withVaultLock, _SeedlessOnboardingController_serializeKeyData, _SeedlessOnboardingController_parseVaultData, _SeedlessOnboardingController_assertIsUnlocked, _SeedlessOnboardingController_assertIsAuthenticatedUser, _SeedlessOnboardingController_assertIsSRPBackedUpUser, _SeedlessOnboardingController_assertPasswordInSync, _SeedlessOnboardingController_resetPasswordOutdatedCache, _SeedlessOnboardingController_revokeRefreshTokenAndUpdateState, _SeedlessOnboardingController_isTokenExpiredError, _SeedlessOnboardingController_isMaxKeyChainLengthError, _SeedlessOnboardingController_executeWithTokenRefresh;
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.SeedlessOnboardingController = exports.getDefaultSeedlessOnboardingControllerState = void 0;
|
|
16
16
|
const auth_network_utils_1 = require("@metamask/auth-network-utils");
|
|
@@ -136,8 +136,9 @@ class SeedlessOnboardingController extends base_controller_1.BaseController {
|
|
|
136
136
|
* @param options.network - The network to be used for the Seedless Onboarding flow.
|
|
137
137
|
* @param options.refreshJWTToken - A function to get a new jwt token using refresh token.
|
|
138
138
|
* @param options.revokeRefreshToken - A function to revoke the refresh token.
|
|
139
|
+
* @param options.passwordOutdatedCacheTTL - The TTL of the password outdated cache in milliseconds.,
|
|
139
140
|
*/
|
|
140
|
-
constructor({ messenger, state, encryptor, toprfKeyDeriver, network = constants_1.Web3AuthNetwork.Mainnet, refreshJWTToken, revokeRefreshToken, }) {
|
|
141
|
+
constructor({ messenger, state, encryptor, toprfKeyDeriver, network = constants_1.Web3AuthNetwork.Mainnet, refreshJWTToken, revokeRefreshToken, passwordOutdatedCacheTTL = constants_1.PASSWORD_OUTDATED_CACHE_TTL_MS, }) {
|
|
141
142
|
super({
|
|
142
143
|
name: constants_1.controllerName,
|
|
143
144
|
metadata: seedlessOnboardingMetadata,
|
|
@@ -159,6 +160,12 @@ class SeedlessOnboardingController extends base_controller_1.BaseController {
|
|
|
159
160
|
* The controller lock is synchronized with the keyring lock.
|
|
160
161
|
*/
|
|
161
162
|
_SeedlessOnboardingController_isUnlocked.set(this, false);
|
|
163
|
+
/**
|
|
164
|
+
* The TTL of the password outdated cache in milliseconds.
|
|
165
|
+
*/
|
|
166
|
+
_SeedlessOnboardingController_passwordOutdatedCacheTTL.set(this, void 0);
|
|
167
|
+
(0, assertions_1.assertIsPasswordOutdatedCacheValid)(passwordOutdatedCacheTTL);
|
|
168
|
+
__classPrivateFieldSet(this, _SeedlessOnboardingController_passwordOutdatedCacheTTL, passwordOutdatedCacheTTL, "f");
|
|
162
169
|
__classPrivateFieldSet(this, _SeedlessOnboardingController_vaultEncryptor, encryptor, "f");
|
|
163
170
|
this.toprfClient = new toprf_secure_backup_1.ToprfSecureBackup({
|
|
164
171
|
network,
|
|
@@ -391,7 +398,7 @@ class SeedlessOnboardingController extends base_controller_1.BaseController {
|
|
|
391
398
|
await this.verifyVaultPassword(oldPassword, {
|
|
392
399
|
skipLock: true, // skip lock since we already have the lock
|
|
393
400
|
});
|
|
394
|
-
await __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_assertPasswordInSync).call(this, {
|
|
401
|
+
const { latestKeyIndex } = await __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_assertPasswordInSync).call(this, {
|
|
395
402
|
skipCache: true,
|
|
396
403
|
skipLock: true, // skip lock since we already have the lock
|
|
397
404
|
});
|
|
@@ -405,6 +412,7 @@ class SeedlessOnboardingController extends base_controller_1.BaseController {
|
|
|
405
412
|
const { encKey: newEncKey, pwEncKey: newPwEncKey, authKeyPair: newAuthKeyPair, } = await __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_changeEncryptionKey).call(this, {
|
|
406
413
|
oldPassword,
|
|
407
414
|
newPassword,
|
|
415
|
+
latestKeyIndex,
|
|
408
416
|
});
|
|
409
417
|
// update and encrypt the vault with new password
|
|
410
418
|
await __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_createNewVaultWithAuthData).call(this, {
|
|
@@ -487,14 +495,27 @@ class SeedlessOnboardingController extends base_controller_1.BaseController {
|
|
|
487
495
|
return await __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_withControllerLock).call(this, async () => {
|
|
488
496
|
const { toprfEncryptionKey, toprfPwEncryptionKey, toprfAuthKeyPair, revokeToken, } = await __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_unlockVaultAndGetVaultData).call(this, password);
|
|
489
497
|
__classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_setUnlocked).call(this);
|
|
498
|
+
await __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_createNewVaultWithAuthData).call(this, {
|
|
499
|
+
password,
|
|
500
|
+
rawToprfEncryptionKey: toprfEncryptionKey,
|
|
501
|
+
rawToprfPwEncryptionKey: toprfPwEncryptionKey,
|
|
502
|
+
rawToprfAuthKeyPair: toprfAuthKeyPair,
|
|
503
|
+
});
|
|
490
504
|
if (revokeToken) {
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
505
|
+
// this call is not critical for unlocking, so we can do it in the background without await.
|
|
506
|
+
__classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_revokeRefreshTokenAndUpdateState).call(this, revokeToken)
|
|
507
|
+
.then(() => {
|
|
508
|
+
// re-creating vault to persist the new revoke token
|
|
509
|
+
// TODO: Optimize this function such that updates to vault wont require re-creating the vault.
|
|
510
|
+
return __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_createNewVaultWithAuthData).call(this, {
|
|
511
|
+
password,
|
|
512
|
+
rawToprfEncryptionKey: toprfEncryptionKey,
|
|
513
|
+
rawToprfPwEncryptionKey: toprfPwEncryptionKey,
|
|
514
|
+
rawToprfAuthKeyPair: toprfAuthKeyPair,
|
|
515
|
+
});
|
|
516
|
+
})
|
|
517
|
+
.catch((error) => {
|
|
518
|
+
log('Error revoking refresh token', error);
|
|
498
519
|
});
|
|
499
520
|
}
|
|
500
521
|
});
|
|
@@ -564,6 +585,8 @@ class SeedlessOnboardingController extends base_controller_1.BaseController {
|
|
|
564
585
|
* @description Check if the current password is outdated compare to the global password.
|
|
565
586
|
*
|
|
566
587
|
* @param options - Optional options object.
|
|
588
|
+
* @param options.globalAuthPubKey - The global auth public key to compare with the current auth public key.
|
|
589
|
+
* If not provided, the global auth public key will be fetched from the backend.
|
|
567
590
|
* @param options.skipCache - If true, bypass the cache and force a fresh check.
|
|
568
591
|
* @param options.skipLock - Whether to skip the lock acquisition. (to prevent deadlock in case the caller already acquired the lock)
|
|
569
592
|
* @returns A promise that resolves to true if the password is outdated, false otherwise.
|
|
@@ -578,19 +601,28 @@ class SeedlessOnboardingController extends base_controller_1.BaseController {
|
|
|
578
601
|
const now = Date.now();
|
|
579
602
|
const isCacheValid = passwordOutdatedCache &&
|
|
580
603
|
now - passwordOutdatedCache.timestamp <
|
|
581
|
-
|
|
604
|
+
__classPrivateFieldGet(this, _SeedlessOnboardingController_passwordOutdatedCacheTTL, "f");
|
|
582
605
|
if (isCacheValid) {
|
|
583
606
|
return passwordOutdatedCache.isExpiredPwd;
|
|
584
607
|
}
|
|
585
608
|
}
|
|
586
609
|
const { nodeAuthTokens, authConnectionId, groupedAuthConnectionId, userId, } = this.state;
|
|
587
610
|
const currentDeviceAuthPubKey = __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_recoverAuthPubKey).call(this);
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
611
|
+
let globalAuthPubKey = options?.globalAuthPubKey;
|
|
612
|
+
if (!globalAuthPubKey) {
|
|
613
|
+
const { authPubKey } = await this.toprfClient
|
|
614
|
+
.fetchAuthPubKey({
|
|
615
|
+
nodeAuthTokens,
|
|
616
|
+
authConnectionId,
|
|
617
|
+
groupedAuthConnectionId,
|
|
618
|
+
userId,
|
|
619
|
+
})
|
|
620
|
+
.catch((error) => {
|
|
621
|
+
log('Error fetching auth pub key', error);
|
|
622
|
+
throw new Error(constants_1.SeedlessOnboardingControllerErrorMessage.FailedToFetchAuthPubKey);
|
|
623
|
+
});
|
|
624
|
+
globalAuthPubKey = authPubKey;
|
|
625
|
+
}
|
|
594
626
|
// use noble lib to deserialize and compare curve point
|
|
595
627
|
const isExpiredPwd = !secp256k1_1.secp256k1.ProjectivePoint.fromHex(currentDeviceAuthPubKey).equals(secp256k1_1.secp256k1.ProjectivePoint.fromHex(globalAuthPubKey));
|
|
596
628
|
// Cache the result in state
|
|
@@ -720,7 +752,7 @@ class SeedlessOnboardingController extends base_controller_1.BaseController {
|
|
|
720
752
|
}
|
|
721
753
|
}
|
|
722
754
|
exports.SeedlessOnboardingController = SeedlessOnboardingController;
|
|
723
|
-
_SeedlessOnboardingController_vaultEncryptor = new WeakMap(), _SeedlessOnboardingController_controllerOperationMutex = new WeakMap(), _SeedlessOnboardingController_vaultOperationMutex = new WeakMap(), _SeedlessOnboardingController_refreshJWTToken = new WeakMap(), _SeedlessOnboardingController_revokeRefreshToken = new WeakMap(), _SeedlessOnboardingController_isUnlocked = new WeakMap(), _SeedlessOnboardingController_instances = new WeakSet(), _SeedlessOnboardingController_submitGlobalPassword =
|
|
755
|
+
_SeedlessOnboardingController_vaultEncryptor = new WeakMap(), _SeedlessOnboardingController_controllerOperationMutex = new WeakMap(), _SeedlessOnboardingController_vaultOperationMutex = new WeakMap(), _SeedlessOnboardingController_refreshJWTToken = new WeakMap(), _SeedlessOnboardingController_revokeRefreshToken = new WeakMap(), _SeedlessOnboardingController_isUnlocked = new WeakMap(), _SeedlessOnboardingController_passwordOutdatedCacheTTL = new WeakMap(), _SeedlessOnboardingController_instances = new WeakSet(), _SeedlessOnboardingController_submitGlobalPassword =
|
|
724
756
|
/**
|
|
725
757
|
* @description Submit the global password to the controller, verify the
|
|
726
758
|
* password validity and unlock the controller.
|
|
@@ -746,17 +778,30 @@ async function _SeedlessOnboardingController_submitGlobalPassword({ targetAuthPu
|
|
|
746
778
|
const { pwEncKey } = res;
|
|
747
779
|
const vaultKey = await __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_loadSeedlessEncryptionKey).call(this, pwEncKey);
|
|
748
780
|
// Unlock the controller
|
|
749
|
-
const { revokeToken, toprfEncryptionKey, toprfPwEncryptionKey, toprfAuthKeyPair, } = await __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_unlockVaultAndGetVaultData).call(this, undefined, vaultKey);
|
|
781
|
+
const { revokeToken, toprfEncryptionKey: latestEncKey, toprfPwEncryptionKey: latestPwEncKey, toprfAuthKeyPair: latestAuthKeyPair, } = await __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_unlockVaultAndGetVaultData).call(this, undefined, vaultKey);
|
|
750
782
|
__classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_setUnlocked).call(this);
|
|
783
|
+
await __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_createNewVaultWithAuthData).call(this, {
|
|
784
|
+
password: globalPassword,
|
|
785
|
+
rawToprfEncryptionKey: latestEncKey,
|
|
786
|
+
rawToprfPwEncryptionKey: latestPwEncKey,
|
|
787
|
+
rawToprfAuthKeyPair: latestAuthKeyPair,
|
|
788
|
+
});
|
|
751
789
|
if (revokeToken) {
|
|
752
790
|
// revoke and recyle refresh token after unlock to keep refresh token fresh, avoid malicious use of leaked refresh token
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
791
|
+
// this call is not critical for unlocking, so we can do it in the background without await.
|
|
792
|
+
__classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_revokeRefreshTokenAndUpdateState).call(this, revokeToken)
|
|
793
|
+
.then(() => {
|
|
794
|
+
// re-creating vault to persist the new revoke token.
|
|
795
|
+
// TODO: Optimize this function such that updates to vault wont require re-creating the vault.
|
|
796
|
+
return __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_createNewVaultWithAuthData).call(this, {
|
|
797
|
+
password: globalPassword,
|
|
798
|
+
rawToprfEncryptionKey: latestEncKey,
|
|
799
|
+
rawToprfPwEncryptionKey: latestPwEncKey,
|
|
800
|
+
rawToprfAuthKeyPair: latestAuthKeyPair,
|
|
801
|
+
});
|
|
802
|
+
})
|
|
803
|
+
.catch((error) => {
|
|
804
|
+
log('Error revoking refresh token', error);
|
|
760
805
|
});
|
|
761
806
|
}
|
|
762
807
|
}
|
|
@@ -932,12 +977,31 @@ async function _SeedlessOnboardingController_recoverEncKey(password) {
|
|
|
932
977
|
* @param params - The function parameters.
|
|
933
978
|
* @param params.oldPassword - The old password to verify.
|
|
934
979
|
* @param params.newPassword - The new password to update.
|
|
980
|
+
* @param params.latestKeyIndex - The key index of the latest key.
|
|
935
981
|
* @returns A promise that resolves to new encryption key and authentication key pair.
|
|
936
982
|
*/
|
|
937
|
-
async function _SeedlessOnboardingController_changeEncryptionKey({ oldPassword, newPassword, }) {
|
|
983
|
+
async function _SeedlessOnboardingController_changeEncryptionKey({ oldPassword, newPassword, latestKeyIndex, }) {
|
|
938
984
|
__classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_assertIsAuthenticatedUser).call(this, this.state);
|
|
939
985
|
const { authConnectionId, groupedAuthConnectionId, userId } = this.state;
|
|
940
|
-
|
|
986
|
+
let encKey;
|
|
987
|
+
let pwEncKey;
|
|
988
|
+
let authKeyPair;
|
|
989
|
+
let globalKeyIndex = latestKeyIndex;
|
|
990
|
+
if (!globalKeyIndex) {
|
|
991
|
+
({
|
|
992
|
+
encKey,
|
|
993
|
+
pwEncKey,
|
|
994
|
+
authKeyPair,
|
|
995
|
+
keyShareIndex: globalKeyIndex,
|
|
996
|
+
} = await __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_recoverEncKey).call(this, oldPassword));
|
|
997
|
+
}
|
|
998
|
+
else {
|
|
999
|
+
({
|
|
1000
|
+
toprfEncryptionKey: encKey,
|
|
1001
|
+
toprfPwEncryptionKey: pwEncKey,
|
|
1002
|
+
toprfAuthKeyPair: authKeyPair,
|
|
1003
|
+
} = await __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_unlockVaultAndGetVaultData).call(this, oldPassword));
|
|
1004
|
+
}
|
|
941
1005
|
const result = await this.toprfClient.changeEncKey({
|
|
942
1006
|
nodeAuthTokens: this.state.nodeAuthTokens,
|
|
943
1007
|
authConnectionId,
|
|
@@ -946,7 +1010,7 @@ async function _SeedlessOnboardingController_changeEncryptionKey({ oldPassword,
|
|
|
946
1010
|
oldEncKey: encKey,
|
|
947
1011
|
oldPwEncKey: pwEncKey,
|
|
948
1012
|
oldAuthKeyPair: authKeyPair,
|
|
949
|
-
newKeyShareIndex,
|
|
1013
|
+
newKeyShareIndex: globalKeyIndex,
|
|
950
1014
|
newPassword,
|
|
951
1015
|
});
|
|
952
1016
|
return result;
|
|
@@ -1288,13 +1352,33 @@ async function _SeedlessOnboardingController_withVaultLock(callback) {
|
|
|
1288
1352
|
* @param options - The options for asserting the password is in sync.
|
|
1289
1353
|
* @param options.skipCache - Whether to skip the cache check.
|
|
1290
1354
|
* @param options.skipLock - Whether to skip the lock acquisition. (to prevent deadlock in case the caller already acquired the lock)
|
|
1355
|
+
* @returns The global auth public key and the latest key index.
|
|
1291
1356
|
* @throws If the password is outdated.
|
|
1292
1357
|
*/
|
|
1293
1358
|
async function _SeedlessOnboardingController_assertPasswordInSync(options) {
|
|
1294
|
-
const
|
|
1359
|
+
const { nodeAuthTokens, authConnectionId, groupedAuthConnectionId, userId, } = this.state;
|
|
1360
|
+
if (!nodeAuthTokens || !authConnectionId || !userId) {
|
|
1361
|
+
throw new Error(constants_1.SeedlessOnboardingControllerErrorMessage.MissingAuthUserInfo);
|
|
1362
|
+
}
|
|
1363
|
+
const { authPubKey, keyIndex: latestKeyIndex } = await this.toprfClient
|
|
1364
|
+
.fetchAuthPubKey({
|
|
1365
|
+
nodeAuthTokens,
|
|
1366
|
+
authConnectionId,
|
|
1367
|
+
groupedAuthConnectionId,
|
|
1368
|
+
userId,
|
|
1369
|
+
})
|
|
1370
|
+
.catch((error) => {
|
|
1371
|
+
log('Error fetching auth pub key', error);
|
|
1372
|
+
throw new Error(constants_1.SeedlessOnboardingControllerErrorMessage.FailedToFetchAuthPubKey);
|
|
1373
|
+
});
|
|
1374
|
+
const isPasswordOutdated = await this.checkIsPasswordOutdated({
|
|
1375
|
+
...options,
|
|
1376
|
+
globalAuthPubKey: authPubKey,
|
|
1377
|
+
});
|
|
1295
1378
|
if (isPasswordOutdated) {
|
|
1296
1379
|
throw new Error(constants_1.SeedlessOnboardingControllerErrorMessage.OutdatedPassword);
|
|
1297
1380
|
}
|
|
1381
|
+
return { authPubKey, latestKeyIndex };
|
|
1298
1382
|
}, _SeedlessOnboardingController_resetPasswordOutdatedCache = function _SeedlessOnboardingController_resetPasswordOutdatedCache() {
|
|
1299
1383
|
this.update((state) => {
|
|
1300
1384
|
delete state.passwordOutdatedCache;
|