@metamask-previews/seedless-onboarding-controller 1.0.0-preview-3c8bcc82 → 2.0.0-preview-d9822daf
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 +11 -1
- package/dist/SeedlessOnboardingController.cjs +47 -48
- package/dist/SeedlessOnboardingController.cjs.map +1 -1
- package/dist/SeedlessOnboardingController.d.cts +2 -1
- package/dist/SeedlessOnboardingController.d.cts.map +1 -1
- package/dist/SeedlessOnboardingController.d.mts +2 -1
- package/dist/SeedlessOnboardingController.d.mts.map +1 -1
- package/dist/SeedlessOnboardingController.mjs +47 -48
- package/dist/SeedlessOnboardingController.mjs.map +1 -1
- package/dist/constants.cjs +2 -0
- package/dist/constants.cjs.map +1 -1
- package/dist/constants.d.cts +2 -0
- package/dist/constants.d.cts.map +1 -1
- package/dist/constants.d.mts +2 -0
- package/dist/constants.d.mts.map +1 -1
- package/dist/constants.mjs +2 -0
- package/dist/constants.mjs.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [2.0.0]
|
|
11
|
+
|
|
10
12
|
### Added
|
|
11
13
|
|
|
12
14
|
- Added `PrivateKey sync` feature to the controller ([#5948](https://github.com/MetaMask/core/pull/5948)).
|
|
@@ -20,6 +22,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
20
22
|
- updated `updateBackupMetadataState` method param with `{ keyringId?: string; data: Uint8Array; type: SecretType }`. Previously , `{ keyringId: string; seedPhrase: Uint8Array }`.
|
|
21
23
|
- Added `submitGlobalPassword`. ([#5995](https://github.com/MetaMask/core/pull/5995))
|
|
22
24
|
- Added `storeKeyringEncryptionKey` and `loadKeyringEncryptionKey`. ([#5995](https://github.com/MetaMask/core/pull/5995))
|
|
25
|
+
- Added validations in `fetchAllSecretData`. ([#6047](https://github.com/MetaMask/core/pull/6047))
|
|
26
|
+
- Throwing `NoSecretDataFound` error when the client receives the empty secret data from the metadata store.
|
|
27
|
+
- Throwing `InvalidPrimarySecretDataType` error when the first secret data backup is not a `Mnemonic`. First backup must always be a `Mnemonic`
|
|
28
|
+
since generating a new mnemonic (SRP) is the only way to create a new wallet for a Social Login user.
|
|
23
29
|
|
|
24
30
|
### Changed
|
|
25
31
|
|
|
@@ -33,6 +39,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
33
39
|
- removed parameter `oldPassword`
|
|
34
40
|
- no longer verifying old password
|
|
35
41
|
- explicitly requring unlocked controller
|
|
42
|
+
- **BREAKING** Changed data structure of return values from `fetchAllSecretData`. ([#6047](https://github.com/MetaMask/core/pull/6047))
|
|
43
|
+
- Now returns `SecretMetadata[]` object instead of `Record<SecretType, Uint8Array[]>`
|
|
44
|
+
- Bump `@metamask/utils` from `^11.2.0` to `^11.4.2` ([#6054](https://github.com/MetaMask/core/pull/6054))
|
|
36
45
|
|
|
37
46
|
### Removed
|
|
38
47
|
|
|
@@ -63,5 +72,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
63
72
|
- `checkIsPasswordOutdated`: Check if the password is current device is outdated, i.e. user changed password in another device.
|
|
64
73
|
- `clearState`: Reset the state of the controller to the defaults.
|
|
65
74
|
|
|
66
|
-
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/seedless-onboarding-controller@
|
|
75
|
+
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/seedless-onboarding-controller@2.0.0...HEAD
|
|
76
|
+
[2.0.0]: https://github.com/MetaMask/core/compare/@metamask/seedless-onboarding-controller@1.0.0...@metamask/seedless-onboarding-controller@2.0.0
|
|
67
77
|
[1.0.0]: https://github.com/MetaMask/core/releases/tag/@metamask/seedless-onboarding-controller@1.0.0
|
|
@@ -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_setUnlocked, _SeedlessOnboardingController_persistOprfKey, _SeedlessOnboardingController_persistAuthPubKey, _SeedlessOnboardingController_storeKeyringEncryptionKey, _SeedlessOnboardingController_loadKeyringEncryptionKey, _SeedlessOnboardingController_loadSeedlessEncryptionKey, _SeedlessOnboardingController_recoverAuthPubKey, _SeedlessOnboardingController_recoverEncKey, _SeedlessOnboardingController_changeEncryptionKey, _SeedlessOnboardingController_encryptAndStoreSecretData, _SeedlessOnboardingController_unlockVaultAndGetBackupEncKey, _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_assertIsValidVaultData, _SeedlessOnboardingController_isTokenExpiredError, _SeedlessOnboardingController_executeWithTokenRefresh;
|
|
13
|
+
var _SeedlessOnboardingController_instances, _SeedlessOnboardingController_vaultEncryptor, _SeedlessOnboardingController_controllerOperationMutex, _SeedlessOnboardingController_vaultOperationMutex, _SeedlessOnboardingController_refreshJWTToken, _SeedlessOnboardingController_revokeRefreshToken, _SeedlessOnboardingController_isUnlocked, _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_unlockVaultAndGetBackupEncKey, _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_assertIsValidVaultData, _SeedlessOnboardingController_isTokenExpiredError, _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");
|
|
@@ -255,9 +255,6 @@ class SeedlessOnboardingController extends base_controller_1.BaseController {
|
|
|
255
255
|
rawToprfPwEncryptionKey: pwEncKey,
|
|
256
256
|
rawToprfAuthKeyPair: authKeyPair,
|
|
257
257
|
});
|
|
258
|
-
__classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_persistAuthPubKey).call(this, {
|
|
259
|
-
authPubKey: authKeyPair.pk,
|
|
260
|
-
});
|
|
261
258
|
};
|
|
262
259
|
await __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_executeWithTokenRefresh).call(this, performKeyCreationAndBackup, 'createToprfKeyAndBackupSeedPhrase');
|
|
263
260
|
});
|
|
@@ -322,40 +319,20 @@ class SeedlessOnboardingController extends base_controller_1.BaseController {
|
|
|
322
319
|
pwEncKey = keysFromVault.toprfPwEncryptionKey;
|
|
323
320
|
authKeyPair = keysFromVault.toprfAuthKeyPair;
|
|
324
321
|
}
|
|
325
|
-
|
|
326
|
-
const
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
password,
|
|
335
|
-
rawToprfEncryptionKey: encKey,
|
|
336
|
-
rawToprfPwEncryptionKey: pwEncKey,
|
|
337
|
-
rawToprfAuthKeyPair: authKeyPair,
|
|
338
|
-
});
|
|
339
|
-
__classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_persistAuthPubKey).call(this, {
|
|
340
|
-
authPubKey: authKeyPair.pk,
|
|
341
|
-
});
|
|
342
|
-
}
|
|
343
|
-
const result = {
|
|
344
|
-
mnemonic: [],
|
|
345
|
-
privateKey: [],
|
|
346
|
-
};
|
|
347
|
-
const secrets = SecretMetadata_1.SecretMetadata.parseSecretsFromMetadataStore(secretData);
|
|
348
|
-
secrets.forEach((secret) => {
|
|
349
|
-
result[secret.type].push(secret.data);
|
|
322
|
+
const performFetch = async () => {
|
|
323
|
+
const secrets = await __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_fetchAllSecretDataFromMetadataStore).call(this, encKey, authKeyPair);
|
|
324
|
+
if (password) {
|
|
325
|
+
// if password is provided, we need to create a new vault with the auth data. (supposedly the user is trying to rehydrate the wallet)
|
|
326
|
+
await __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_createNewVaultWithAuthData).call(this, {
|
|
327
|
+
password,
|
|
328
|
+
rawToprfEncryptionKey: encKey,
|
|
329
|
+
rawToprfPwEncryptionKey: pwEncKey,
|
|
330
|
+
rawToprfAuthKeyPair: authKeyPair,
|
|
350
331
|
});
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
catch (error) {
|
|
356
|
-
log('Error fetching secret data', error);
|
|
357
|
-
throw new Error(constants_1.SeedlessOnboardingControllerErrorMessage.FailedToFetchSecretMetadata);
|
|
358
|
-
}
|
|
332
|
+
}
|
|
333
|
+
return secrets;
|
|
334
|
+
};
|
|
335
|
+
return await __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_executeWithTokenRefresh).call(this, performFetch, 'fetchAllSecretData');
|
|
359
336
|
});
|
|
360
337
|
}
|
|
361
338
|
/**
|
|
@@ -396,9 +373,6 @@ class SeedlessOnboardingController extends base_controller_1.BaseController {
|
|
|
396
373
|
rawToprfPwEncryptionKey: newPwEncKey,
|
|
397
374
|
rawToprfAuthKeyPair: newAuthKeyPair,
|
|
398
375
|
});
|
|
399
|
-
__classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_persistAuthPubKey).call(this, {
|
|
400
|
-
authPubKey: newAuthKeyPair.pk,
|
|
401
|
-
});
|
|
402
376
|
__classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_resetPasswordOutdatedCache).call(this);
|
|
403
377
|
// store the keyring encryption key if it exists
|
|
404
378
|
if (keyringEncryptionKey) {
|
|
@@ -512,10 +486,6 @@ class SeedlessOnboardingController extends base_controller_1.BaseController {
|
|
|
512
486
|
rawToprfPwEncryptionKey: pwEncKey,
|
|
513
487
|
rawToprfAuthKeyPair: authKeyPair,
|
|
514
488
|
});
|
|
515
|
-
// persist the latest global password authPubKey
|
|
516
|
-
__classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_persistAuthPubKey).call(this, {
|
|
517
|
-
authPubKey: authKeyPair.pk,
|
|
518
|
-
});
|
|
519
489
|
__classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_resetPasswordOutdatedCache).call(this);
|
|
520
490
|
};
|
|
521
491
|
return await __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_executeWithTokenRefresh).call(this, doSyncPassword, 'syncLatestGlobalPassword');
|
|
@@ -820,9 +790,9 @@ async function _SeedlessOnboardingController_loadSeedlessEncryptionKey(encKey) {
|
|
|
820
790
|
* @throws RecoveryError - If failed to recover the encryption key.
|
|
821
791
|
*/
|
|
822
792
|
async function _SeedlessOnboardingController_recoverEncKey(password) {
|
|
793
|
+
__classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_assertIsAuthenticatedUser).call(this, this.state);
|
|
794
|
+
const { authConnectionId, groupedAuthConnectionId, userId } = this.state;
|
|
823
795
|
try {
|
|
824
|
-
__classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_assertIsAuthenticatedUser).call(this, this.state);
|
|
825
|
-
const { authConnectionId, groupedAuthConnectionId, userId } = this.state;
|
|
826
796
|
const recoverEncKeyResult = await this.toprfClient.recoverEncKey({
|
|
827
797
|
nodeAuthTokens: this.state.nodeAuthTokens,
|
|
828
798
|
password,
|
|
@@ -833,14 +803,39 @@ async function _SeedlessOnboardingController_recoverEncKey(password) {
|
|
|
833
803
|
return recoverEncKeyResult;
|
|
834
804
|
}
|
|
835
805
|
catch (error) {
|
|
836
|
-
console.log('error', error);
|
|
837
|
-
console.log('isTokenExpiredError', __classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_isTokenExpiredError).call(this, error));
|
|
838
806
|
// throw token expired error for token refresh handler
|
|
839
807
|
if (__classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_isTokenExpiredError).call(this, error)) {
|
|
840
808
|
throw error;
|
|
841
809
|
}
|
|
842
810
|
throw errors_1.RecoveryError.getInstance(error);
|
|
843
811
|
}
|
|
812
|
+
}, _SeedlessOnboardingController_fetchAllSecretDataFromMetadataStore = async function _SeedlessOnboardingController_fetchAllSecretDataFromMetadataStore(encKey, authKeyPair) {
|
|
813
|
+
let secretData = [];
|
|
814
|
+
try {
|
|
815
|
+
// fetch and decrypt the secret data from the metadata store
|
|
816
|
+
secretData = await this.toprfClient.fetchAllSecretDataItems({
|
|
817
|
+
decKey: encKey,
|
|
818
|
+
authKeyPair,
|
|
819
|
+
});
|
|
820
|
+
}
|
|
821
|
+
catch (error) {
|
|
822
|
+
log('Error fetching secret data', error);
|
|
823
|
+
if (__classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_isTokenExpiredError).call(this, error)) {
|
|
824
|
+
throw error;
|
|
825
|
+
}
|
|
826
|
+
throw new Error(constants_1.SeedlessOnboardingControllerErrorMessage.FailedToFetchSecretMetadata);
|
|
827
|
+
}
|
|
828
|
+
// user must have at least one secret data
|
|
829
|
+
if (secretData?.length > 0) {
|
|
830
|
+
const secrets = SecretMetadata_1.SecretMetadata.parseSecretsFromMetadataStore(secretData);
|
|
831
|
+
// validate the primary secret data is a mnemonic (SRP)
|
|
832
|
+
const primarySecret = secrets[0];
|
|
833
|
+
if (primarySecret.type !== constants_1.SecretType.Mnemonic) {
|
|
834
|
+
throw new Error(constants_1.SeedlessOnboardingControllerErrorMessage.InvalidPrimarySecretDataType);
|
|
835
|
+
}
|
|
836
|
+
return secrets;
|
|
837
|
+
}
|
|
838
|
+
throw new Error(constants_1.SeedlessOnboardingControllerErrorMessage.NoSecretDataFound);
|
|
844
839
|
}, _SeedlessOnboardingController_changeEncryptionKey =
|
|
845
840
|
/**
|
|
846
841
|
* Update the encryption key with new password and update the Metadata Store with new encryption key.
|
|
@@ -1070,6 +1065,10 @@ async function _SeedlessOnboardingController_createNewVaultWithAuthData({ passwo
|
|
|
1070
1065
|
serializedVaultData,
|
|
1071
1066
|
pwEncKey: rawToprfPwEncryptionKey,
|
|
1072
1067
|
});
|
|
1068
|
+
// update the authPubKey in the state
|
|
1069
|
+
__classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_persistAuthPubKey).call(this, {
|
|
1070
|
+
authPubKey: rawToprfAuthKeyPair.pk,
|
|
1071
|
+
});
|
|
1073
1072
|
}, _SeedlessOnboardingController_updateVault =
|
|
1074
1073
|
/**
|
|
1075
1074
|
* Encrypt and update the vault with the given authentication data.
|