@metamask-previews/seedless-onboarding-controller 2.4.0-preview-fed19434 → 2.4.0-preview-e0bc4b4b
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 +0 -13
- package/dist/SeedlessOnboardingController.cjs +70 -133
- package/dist/SeedlessOnboardingController.cjs.map +1 -1
- package/dist/SeedlessOnboardingController.d.cts +14 -7
- package/dist/SeedlessOnboardingController.d.cts.map +1 -1
- package/dist/SeedlessOnboardingController.d.mts +14 -7
- package/dist/SeedlessOnboardingController.d.mts.map +1 -1
- package/dist/SeedlessOnboardingController.mjs +71 -134
- package/dist/SeedlessOnboardingController.mjs.map +1 -1
- package/dist/assertions.cjs +1 -16
- package/dist/assertions.cjs.map +1 -1
- package/dist/assertions.d.cts +0 -7
- package/dist/assertions.d.cts.map +1 -1
- package/dist/assertions.d.mts +0 -7
- package/dist/assertions.d.mts.map +1 -1
- package/dist/assertions.mjs +0 -14
- package/dist/assertions.mjs.map +1 -1
- package/dist/constants.cjs +1 -3
- package/dist/constants.cjs.map +1 -1
- package/dist/constants.d.cts +2 -4
- package/dist/constants.d.cts.map +1 -1
- package/dist/constants.d.mts +2 -4
- package/dist/constants.d.mts.map +1 -1
- package/dist/constants.mjs +1 -3
- package/dist/constants.mjs.map +1 -1
- package/dist/index.cjs +1 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +0 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +0 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +0 -1
- package/dist/index.mjs.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +0 -6
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +0 -6
- 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,19 +7,6 @@ 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
|
-
|
|
14
|
-
### Changed
|
|
15
|
-
|
|
16
|
-
- Renamed public method `submitGlobalPassword` to `submitGlobalPasswordAndSync`. ([#6180](https://github.com/MetaMask/core/pull/6180))
|
|
17
|
-
|
|
18
|
-
### Removed
|
|
19
|
-
|
|
20
|
-
- Removed `syncLatestGlobalPassword` from the Controller. ([#6180](https://github.com/MetaMask/core/pull/6180))
|
|
21
|
-
- Moved the vault syncing to the `submitGlobalPassword` method
|
|
22
|
-
|
|
23
10
|
## [2.4.0]
|
|
24
11
|
|
|
25
12
|
### 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,
|
|
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;
|
|
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,9 +136,8 @@ 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.,
|
|
140
139
|
*/
|
|
141
|
-
constructor({ messenger, state, encryptor, toprfKeyDeriver, network = constants_1.Web3AuthNetwork.Mainnet, refreshJWTToken, revokeRefreshToken,
|
|
140
|
+
constructor({ messenger, state, encryptor, toprfKeyDeriver, network = constants_1.Web3AuthNetwork.Mainnet, refreshJWTToken, revokeRefreshToken, }) {
|
|
142
141
|
super({
|
|
143
142
|
name: constants_1.controllerName,
|
|
144
143
|
metadata: seedlessOnboardingMetadata,
|
|
@@ -160,12 +159,6 @@ class SeedlessOnboardingController extends base_controller_1.BaseController {
|
|
|
160
159
|
* The controller lock is synchronized with the keyring lock.
|
|
161
160
|
*/
|
|
162
161
|
_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");
|
|
169
162
|
__classPrivateFieldSet(this, _SeedlessOnboardingController_vaultEncryptor, encryptor, "f");
|
|
170
163
|
this.toprfClient = new toprf_secure_backup_1.ToprfSecureBackup({
|
|
171
164
|
network,
|
|
@@ -398,7 +391,7 @@ class SeedlessOnboardingController extends base_controller_1.BaseController {
|
|
|
398
391
|
await this.verifyVaultPassword(oldPassword, {
|
|
399
392
|
skipLock: true, // skip lock since we already have the lock
|
|
400
393
|
});
|
|
401
|
-
|
|
394
|
+
await __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_assertPasswordInSync).call(this, {
|
|
402
395
|
skipCache: true,
|
|
403
396
|
skipLock: true, // skip lock since we already have the lock
|
|
404
397
|
});
|
|
@@ -412,7 +405,6 @@ class SeedlessOnboardingController extends base_controller_1.BaseController {
|
|
|
412
405
|
const { encKey: newEncKey, pwEncKey: newPwEncKey, authKeyPair: newAuthKeyPair, } = await __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_changeEncryptionKey).call(this, {
|
|
413
406
|
oldPassword,
|
|
414
407
|
newPassword,
|
|
415
|
-
latestKeyIndex,
|
|
416
408
|
});
|
|
417
409
|
// update and encrypt the vault with new password
|
|
418
410
|
await __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_createNewVaultWithAuthData).call(this, {
|
|
@@ -495,26 +487,14 @@ class SeedlessOnboardingController extends base_controller_1.BaseController {
|
|
|
495
487
|
return await __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_withControllerLock).call(this, async () => {
|
|
496
488
|
const { toprfEncryptionKey, toprfPwEncryptionKey, toprfAuthKeyPair, revokeToken, } = await __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_unlockVaultAndGetVaultData).call(this, password);
|
|
497
489
|
__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
|
-
});
|
|
504
490
|
if (revokeToken) {
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
rawToprfPwEncryptionKey: toprfPwEncryptionKey,
|
|
513
|
-
rawToprfAuthKeyPair: toprfAuthKeyPair,
|
|
514
|
-
});
|
|
515
|
-
})
|
|
516
|
-
.catch((error) => {
|
|
517
|
-
log('Error revoking refresh token', error);
|
|
491
|
+
await __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_revokeRefreshTokenAndUpdateState).call(this, revokeToken);
|
|
492
|
+
// re-creating vault to persist the new revoke token
|
|
493
|
+
await __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_createNewVaultWithAuthData).call(this, {
|
|
494
|
+
password,
|
|
495
|
+
rawToprfEncryptionKey: toprfEncryptionKey,
|
|
496
|
+
rawToprfPwEncryptionKey: toprfPwEncryptionKey,
|
|
497
|
+
rawToprfAuthKeyPair: toprfAuthKeyPair,
|
|
518
498
|
});
|
|
519
499
|
}
|
|
520
500
|
});
|
|
@@ -533,6 +513,33 @@ class SeedlessOnboardingController extends base_controller_1.BaseController {
|
|
|
533
513
|
});
|
|
534
514
|
__classPrivateFieldSet(this, _SeedlessOnboardingController_isUnlocked, false, "f");
|
|
535
515
|
}
|
|
516
|
+
/**
|
|
517
|
+
* Sync the latest global password to the controller.
|
|
518
|
+
* reset vault with latest globalPassword,
|
|
519
|
+
* persist the latest global password authPubKey
|
|
520
|
+
*
|
|
521
|
+
* @param params - The parameters for syncing the latest global password.
|
|
522
|
+
* @param params.globalPassword - The latest global password.
|
|
523
|
+
* @returns A promise that resolves to the success of the operation.
|
|
524
|
+
*/
|
|
525
|
+
async syncLatestGlobalPassword({ globalPassword, }) {
|
|
526
|
+
return await __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_withControllerLock).call(this, async () => {
|
|
527
|
+
__classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_assertIsUnlocked).call(this);
|
|
528
|
+
const doSyncPassword = async () => {
|
|
529
|
+
// update vault with latest globalPassword
|
|
530
|
+
const { encKey, pwEncKey, authKeyPair } = await __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_recoverEncKey).call(this, globalPassword);
|
|
531
|
+
// update and encrypt the vault with new password
|
|
532
|
+
await __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_createNewVaultWithAuthData).call(this, {
|
|
533
|
+
password: globalPassword,
|
|
534
|
+
rawToprfEncryptionKey: encKey,
|
|
535
|
+
rawToprfPwEncryptionKey: pwEncKey,
|
|
536
|
+
rawToprfAuthKeyPair: authKeyPair,
|
|
537
|
+
});
|
|
538
|
+
__classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_resetPasswordOutdatedCache).call(this);
|
|
539
|
+
};
|
|
540
|
+
return await __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_executeWithTokenRefresh).call(this, doSyncPassword, 'syncLatestGlobalPassword');
|
|
541
|
+
});
|
|
542
|
+
}
|
|
536
543
|
/**
|
|
537
544
|
* @description Unlock the controller with the latest global password.
|
|
538
545
|
*
|
|
@@ -541,24 +548,22 @@ class SeedlessOnboardingController extends base_controller_1.BaseController {
|
|
|
541
548
|
* @param params.globalPassword - The latest global password.
|
|
542
549
|
* @returns A promise that resolves to the success of the operation.
|
|
543
550
|
*/
|
|
544
|
-
async
|
|
551
|
+
async submitGlobalPassword({ globalPassword, maxKeyChainLength = 5, }) {
|
|
545
552
|
return await __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_withControllerLock).call(this, async () => {
|
|
546
553
|
return await __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_executeWithTokenRefresh).call(this, async () => {
|
|
547
554
|
const currentDeviceAuthPubKey = __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_recoverAuthPubKey).call(this);
|
|
548
|
-
await __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m",
|
|
555
|
+
await __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_submitGlobalPassword).call(this, {
|
|
549
556
|
targetAuthPubKey: currentDeviceAuthPubKey,
|
|
550
557
|
globalPassword,
|
|
551
558
|
maxKeyChainLength,
|
|
552
559
|
});
|
|
553
|
-
}, '
|
|
560
|
+
}, 'submitGlobalPassword');
|
|
554
561
|
});
|
|
555
562
|
}
|
|
556
563
|
/**
|
|
557
564
|
* @description Check if the current password is outdated compare to the global password.
|
|
558
565
|
*
|
|
559
566
|
* @param options - Optional options object.
|
|
560
|
-
* @param options.globalAuthPubKey - The global auth public key to compare with the current auth public key.
|
|
561
|
-
* If not provided, the global auth public key will be fetched from the backend.
|
|
562
567
|
* @param options.skipCache - If true, bypass the cache and force a fresh check.
|
|
563
568
|
* @param options.skipLock - Whether to skip the lock acquisition. (to prevent deadlock in case the caller already acquired the lock)
|
|
564
569
|
* @returns A promise that resolves to true if the password is outdated, false otherwise.
|
|
@@ -573,28 +578,19 @@ class SeedlessOnboardingController extends base_controller_1.BaseController {
|
|
|
573
578
|
const now = Date.now();
|
|
574
579
|
const isCacheValid = passwordOutdatedCache &&
|
|
575
580
|
now - passwordOutdatedCache.timestamp <
|
|
576
|
-
|
|
581
|
+
constants_1.PASSWORD_OUTDATED_CACHE_TTL_MS;
|
|
577
582
|
if (isCacheValid) {
|
|
578
583
|
return passwordOutdatedCache.isExpiredPwd;
|
|
579
584
|
}
|
|
580
585
|
}
|
|
581
586
|
const { nodeAuthTokens, authConnectionId, groupedAuthConnectionId, userId, } = this.state;
|
|
582
587
|
const currentDeviceAuthPubKey = __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_recoverAuthPubKey).call(this);
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
groupedAuthConnectionId,
|
|
590
|
-
userId,
|
|
591
|
-
})
|
|
592
|
-
.catch((error) => {
|
|
593
|
-
log('Error fetching auth pub key', error);
|
|
594
|
-
throw new Error(constants_1.SeedlessOnboardingControllerErrorMessage.FailedToFetchAuthPubKey);
|
|
595
|
-
});
|
|
596
|
-
globalAuthPubKey = authPubKey;
|
|
597
|
-
}
|
|
588
|
+
const { authPubKey: globalAuthPubKey } = await this.toprfClient.fetchAuthPubKey({
|
|
589
|
+
nodeAuthTokens,
|
|
590
|
+
authConnectionId,
|
|
591
|
+
groupedAuthConnectionId,
|
|
592
|
+
userId,
|
|
593
|
+
});
|
|
598
594
|
// use noble lib to deserialize and compare curve point
|
|
599
595
|
const isExpiredPwd = !secp256k1_1.secp256k1.ProjectivePoint.fromHex(currentDeviceAuthPubKey).equals(secp256k1_1.secp256k1.ProjectivePoint.fromHex(globalAuthPubKey));
|
|
600
596
|
// Cache the result in state
|
|
@@ -724,7 +720,7 @@ class SeedlessOnboardingController extends base_controller_1.BaseController {
|
|
|
724
720
|
}
|
|
725
721
|
}
|
|
726
722
|
exports.SeedlessOnboardingController = SeedlessOnboardingController;
|
|
727
|
-
_SeedlessOnboardingController_vaultEncryptor = new WeakMap(), _SeedlessOnboardingController_controllerOperationMutex = new WeakMap(), _SeedlessOnboardingController_vaultOperationMutex = new WeakMap(), _SeedlessOnboardingController_refreshJWTToken = new WeakMap(), _SeedlessOnboardingController_revokeRefreshToken = new WeakMap(), _SeedlessOnboardingController_isUnlocked = new WeakMap(),
|
|
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 =
|
|
728
724
|
/**
|
|
729
725
|
* @description Submit the global password to the controller, verify the
|
|
730
726
|
* password validity and unlock the controller.
|
|
@@ -737,52 +733,32 @@ _SeedlessOnboardingController_vaultEncryptor = new WeakMap(), _SeedlessOnboardin
|
|
|
737
733
|
* @returns A promise that resolves to the keyring encryption key
|
|
738
734
|
* corresponding to the current authPubKey in state.
|
|
739
735
|
*/
|
|
740
|
-
async function
|
|
741
|
-
const { pwEncKey:
|
|
736
|
+
async function _SeedlessOnboardingController_submitGlobalPassword({ targetAuthPubKey, globalPassword, maxKeyChainLength, }) {
|
|
737
|
+
const { pwEncKey: curPwEncKey, authKeyPair: curAuthKeyPair } = await __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_recoverEncKey).call(this, globalPassword);
|
|
742
738
|
try {
|
|
743
|
-
// Recover
|
|
744
|
-
const
|
|
739
|
+
// Recover vault encryption key.
|
|
740
|
+
const res = await this.toprfClient.recoverPwEncKey({
|
|
745
741
|
targetAuthPubKey,
|
|
746
|
-
curPwEncKey
|
|
747
|
-
curAuthKeyPair
|
|
742
|
+
curPwEncKey,
|
|
743
|
+
curAuthKeyPair,
|
|
748
744
|
maxPwChainLength: maxKeyChainLength,
|
|
749
745
|
});
|
|
750
|
-
|
|
751
|
-
const
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
]);
|
|
755
|
-
// Unlock the controller and vault
|
|
756
|
-
const { revokeToken } = await __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_unlockVaultAndGetVaultData).call(this, undefined, vaultKey);
|
|
746
|
+
const { pwEncKey } = res;
|
|
747
|
+
const vaultKey = await __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_loadSeedlessEncryptionKey).call(this, pwEncKey);
|
|
748
|
+
// Unlock the controller
|
|
749
|
+
const { revokeToken, toprfEncryptionKey, toprfPwEncryptionKey, toprfAuthKeyPair, } = await __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_unlockVaultAndGetVaultData).call(this, undefined, vaultKey);
|
|
757
750
|
__classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_setUnlocked).call(this);
|
|
758
|
-
await __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_createNewVaultWithAuthData).call(this, {
|
|
759
|
-
password: globalPassword,
|
|
760
|
-
rawToprfEncryptionKey: latestEncKey,
|
|
761
|
-
rawToprfPwEncryptionKey: latestPwEncKey,
|
|
762
|
-
rawToprfAuthKeyPair: latestAuthKeyPair,
|
|
763
|
-
});
|
|
764
751
|
if (revokeToken) {
|
|
765
|
-
//
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
rawToprfEncryptionKey: latestEncKey,
|
|
774
|
-
rawToprfPwEncryptionKey: latestPwEncKey,
|
|
775
|
-
rawToprfAuthKeyPair: latestAuthKeyPair,
|
|
776
|
-
});
|
|
777
|
-
})
|
|
778
|
-
.catch((error) => {
|
|
779
|
-
log('Error revoking refresh token', error);
|
|
752
|
+
// revoke and recyle refresh token after unlock to keep refresh token fresh, avoid malicious use of leaked refresh token
|
|
753
|
+
await __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_revokeRefreshTokenAndUpdateState).call(this, revokeToken);
|
|
754
|
+
// re-creating vault to persist the new revoke token
|
|
755
|
+
await __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_createNewVaultWithAuthData).call(this, {
|
|
756
|
+
password: globalPassword,
|
|
757
|
+
rawToprfEncryptionKey: toprfEncryptionKey,
|
|
758
|
+
rawToprfPwEncryptionKey: toprfPwEncryptionKey,
|
|
759
|
+
rawToprfAuthKeyPair: toprfAuthKeyPair,
|
|
780
760
|
});
|
|
781
761
|
}
|
|
782
|
-
// restore the current keyring encryption key with the new global password
|
|
783
|
-
await this.storeKeyringEncryptionKey(keyringEncryptionKey);
|
|
784
|
-
// reset the password outdated cache after successful global password submission and state sync
|
|
785
|
-
__classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_resetPasswordOutdatedCache).call(this);
|
|
786
762
|
}
|
|
787
763
|
catch (error) {
|
|
788
764
|
if (__classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_isTokenExpiredError).call(this, error)) {
|
|
@@ -956,31 +932,12 @@ async function _SeedlessOnboardingController_recoverEncKey(password) {
|
|
|
956
932
|
* @param params - The function parameters.
|
|
957
933
|
* @param params.oldPassword - The old password to verify.
|
|
958
934
|
* @param params.newPassword - The new password to update.
|
|
959
|
-
* @param params.latestKeyIndex - The key index of the latest key.
|
|
960
935
|
* @returns A promise that resolves to new encryption key and authentication key pair.
|
|
961
936
|
*/
|
|
962
|
-
async function _SeedlessOnboardingController_changeEncryptionKey({ oldPassword, newPassword,
|
|
937
|
+
async function _SeedlessOnboardingController_changeEncryptionKey({ oldPassword, newPassword, }) {
|
|
963
938
|
__classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_assertIsAuthenticatedUser).call(this, this.state);
|
|
964
939
|
const { authConnectionId, groupedAuthConnectionId, userId } = this.state;
|
|
965
|
-
|
|
966
|
-
let pwEncKey;
|
|
967
|
-
let authKeyPair;
|
|
968
|
-
let globalKeyIndex = latestKeyIndex;
|
|
969
|
-
if (!globalKeyIndex) {
|
|
970
|
-
({
|
|
971
|
-
encKey,
|
|
972
|
-
pwEncKey,
|
|
973
|
-
authKeyPair,
|
|
974
|
-
keyShareIndex: globalKeyIndex,
|
|
975
|
-
} = await __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_recoverEncKey).call(this, oldPassword));
|
|
976
|
-
}
|
|
977
|
-
else {
|
|
978
|
-
({
|
|
979
|
-
toprfEncryptionKey: encKey,
|
|
980
|
-
toprfPwEncryptionKey: pwEncKey,
|
|
981
|
-
toprfAuthKeyPair: authKeyPair,
|
|
982
|
-
} = await __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_unlockVaultAndGetVaultData).call(this, oldPassword));
|
|
983
|
-
}
|
|
940
|
+
const { encKey, pwEncKey, authKeyPair, keyShareIndex: newKeyShareIndex, } = await __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_recoverEncKey).call(this, oldPassword);
|
|
984
941
|
const result = await this.toprfClient.changeEncKey({
|
|
985
942
|
nodeAuthTokens: this.state.nodeAuthTokens,
|
|
986
943
|
authConnectionId,
|
|
@@ -989,7 +946,7 @@ async function _SeedlessOnboardingController_changeEncryptionKey({ oldPassword,
|
|
|
989
946
|
oldEncKey: encKey,
|
|
990
947
|
oldPwEncKey: pwEncKey,
|
|
991
948
|
oldAuthKeyPair: authKeyPair,
|
|
992
|
-
newKeyShareIndex
|
|
949
|
+
newKeyShareIndex,
|
|
993
950
|
newPassword,
|
|
994
951
|
});
|
|
995
952
|
return result;
|
|
@@ -1331,33 +1288,13 @@ async function _SeedlessOnboardingController_withVaultLock(callback) {
|
|
|
1331
1288
|
* @param options - The options for asserting the password is in sync.
|
|
1332
1289
|
* @param options.skipCache - Whether to skip the cache check.
|
|
1333
1290
|
* @param options.skipLock - Whether to skip the lock acquisition. (to prevent deadlock in case the caller already acquired the lock)
|
|
1334
|
-
* @returns The global auth public key and the latest key index.
|
|
1335
1291
|
* @throws If the password is outdated.
|
|
1336
1292
|
*/
|
|
1337
1293
|
async function _SeedlessOnboardingController_assertPasswordInSync(options) {
|
|
1338
|
-
const
|
|
1339
|
-
if (!nodeAuthTokens || !authConnectionId || !userId) {
|
|
1340
|
-
throw new Error(constants_1.SeedlessOnboardingControllerErrorMessage.MissingAuthUserInfo);
|
|
1341
|
-
}
|
|
1342
|
-
const { authPubKey, keyIndex: latestKeyIndex } = await this.toprfClient
|
|
1343
|
-
.fetchAuthPubKey({
|
|
1344
|
-
nodeAuthTokens,
|
|
1345
|
-
authConnectionId,
|
|
1346
|
-
groupedAuthConnectionId,
|
|
1347
|
-
userId,
|
|
1348
|
-
})
|
|
1349
|
-
.catch((error) => {
|
|
1350
|
-
log('Error fetching auth pub key', error);
|
|
1351
|
-
throw new Error(constants_1.SeedlessOnboardingControllerErrorMessage.FailedToFetchAuthPubKey);
|
|
1352
|
-
});
|
|
1353
|
-
const isPasswordOutdated = await this.checkIsPasswordOutdated({
|
|
1354
|
-
...options,
|
|
1355
|
-
globalAuthPubKey: authPubKey,
|
|
1356
|
-
});
|
|
1294
|
+
const isPasswordOutdated = await this.checkIsPasswordOutdated(options);
|
|
1357
1295
|
if (isPasswordOutdated) {
|
|
1358
1296
|
throw new Error(constants_1.SeedlessOnboardingControllerErrorMessage.OutdatedPassword);
|
|
1359
1297
|
}
|
|
1360
|
-
return { authPubKey, latestKeyIndex };
|
|
1361
1298
|
}, _SeedlessOnboardingController_resetPasswordOutdatedCache = function _SeedlessOnboardingController_resetPasswordOutdatedCache() {
|
|
1362
1299
|
this.update((state) => {
|
|
1363
1300
|
delete state.passwordOutdatedCache;
|