@metamask-previews/seedless-onboarding-controller 7.1.0-preview-8edbf7c9d → 7.1.0-preview-c97d5b99

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 CHANGED
@@ -9,6 +9,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
9
9
 
10
10
  ### Added
11
11
 
12
+ - Add new `SeedlessOnboardingError` class for generic controller errors with support for `cause` and `details` properties ([#7660](https://github.com/MetaMask/core/pull/7660))
13
+ - Enables proper error chaining by wrapping underlying errors with additional context
14
+ - Includes `toJSON()` method for serialization in logging/transmission
15
+
16
+ ### Added
17
+
12
18
  - **BREAKING** The `encryptor` constructor param requires `encryptWithKey` method. ([#7800](https://github.com/MetaMask/core/pull/7800))
13
19
  - The method is to encrypt the vault with cached encryption key while the wallet is unlocked.
14
20
  - Added new public method, `getAccessToken`. ([#7800](https://github.com/MetaMask/core/pull/7800))
@@ -21,6 +27,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
21
27
  - Exclude All the tokens values from the state log explicitly.
22
28
  - Bump `@metamask/keyring-controller` from `^25.0.0` to `^25.1.0` ([#7713](https://github.com/MetaMask/core/pull/7713))
23
29
  - Upgrade `@metamask/utils` from `^11.8.1` to `^11.9.0` ([#7511](https://github.com/MetaMask/core/pull/7511))
30
+ - Refactor controller methods to throw `SeedlessOnboardingError` with original error as `cause` for better error tracing ([#7660](https://github.com/MetaMask/core/pull/7660))
31
+ - Affected methods: `authenticate`, `changePassword`, `#persistLocalEncryptionKey`, `#fetchAndParseSecretMetadata`, `refreshAuthTokens`
24
32
 
25
33
  ### Fixed
26
34
 
@@ -326,7 +326,9 @@ class SeedlessOnboardingController extends base_controller_1.BaseController {
326
326
  }
327
327
  catch (error) {
328
328
  log('Error authenticating user', error);
329
- throw new Error(constants_1.SeedlessOnboardingControllerErrorMessage.AuthenticationError);
329
+ throw new errors_1.SeedlessOnboardingError(constants_1.SeedlessOnboardingControllerErrorMessage.AuthenticationError, {
330
+ cause: error,
331
+ });
330
332
  }
331
333
  };
332
334
  return params.skipLock
@@ -502,7 +504,9 @@ class SeedlessOnboardingController extends base_controller_1.BaseController {
502
504
  }
503
505
  catch (error) {
504
506
  log('Error changing password', error);
505
- throw new Error(constants_1.SeedlessOnboardingControllerErrorMessage.FailedToChangePassword);
507
+ throw new errors_1.SeedlessOnboardingError(constants_1.SeedlessOnboardingControllerErrorMessage.FailedToChangePassword, {
508
+ cause: error,
509
+ });
506
510
  }
507
511
  });
508
512
  }
@@ -691,7 +695,9 @@ class SeedlessOnboardingController extends base_controller_1.BaseController {
691
695
  })
692
696
  .catch((error) => {
693
697
  log('Error fetching auth pub key', error);
694
- throw new Error(constants_1.SeedlessOnboardingControllerErrorMessage.FailedToFetchAuthPubKey);
698
+ throw new errors_1.SeedlessOnboardingError(constants_1.SeedlessOnboardingControllerErrorMessage.FailedToFetchAuthPubKey, {
699
+ cause: error,
700
+ });
695
701
  });
696
702
  globalAuthPubKey = authPubKey;
697
703
  }
@@ -772,7 +778,9 @@ class SeedlessOnboardingController extends base_controller_1.BaseController {
772
778
  refreshToken,
773
779
  }).catch((error) => {
774
780
  log('Error refreshing JWT tokens', error);
775
- throw new Error(constants_1.SeedlessOnboardingControllerErrorMessage.FailedToRefreshJWTTokens);
781
+ throw new errors_1.SeedlessOnboardingError(constants_1.SeedlessOnboardingControllerErrorMessage.FailedToRefreshJWTTokens, {
782
+ cause: error,
783
+ });
776
784
  });
777
785
  try {
778
786
  const { idTokens, accessToken, metadataAccessToken } = res;
@@ -804,7 +812,9 @@ class SeedlessOnboardingController extends base_controller_1.BaseController {
804
812
  }
805
813
  catch (error) {
806
814
  log('Error refreshing node auth tokens', error);
807
- throw new Error(constants_1.SeedlessOnboardingControllerErrorMessage.AuthenticationError);
815
+ throw new errors_1.SeedlessOnboardingError(constants_1.SeedlessOnboardingControllerErrorMessage.AuthenticationError, {
816
+ cause: error,
817
+ });
808
818
  }
809
819
  }
810
820
  /**
@@ -1046,7 +1056,9 @@ async function _SeedlessOnboardingController_persistOprfKey(oprfKey, authPubKey)
1046
1056
  throw error;
1047
1057
  }
1048
1058
  log('Error persisting local encryption key', error);
1049
- throw new Error(constants_1.SeedlessOnboardingControllerErrorMessage.FailedToPersistOprfKey);
1059
+ throw new errors_1.SeedlessOnboardingError(constants_1.SeedlessOnboardingControllerErrorMessage.FailedToPersistOprfKey, {
1060
+ cause: error,
1061
+ });
1050
1062
  }
1051
1063
  }, _SeedlessOnboardingController_persistAuthPubKey = function _SeedlessOnboardingController_persistAuthPubKey(params) {
1052
1064
  this.update((state) => {
@@ -1141,7 +1153,9 @@ async function _SeedlessOnboardingController_recoverEncKey(password) {
1141
1153
  if (__classPrivateFieldGet(this, _SeedlessOnboardingController_instances, "m", _SeedlessOnboardingController_isAuthTokenError).call(this, error)) {
1142
1154
  throw error;
1143
1155
  }
1144
- throw new Error(constants_1.SeedlessOnboardingControllerErrorMessage.FailedToFetchSecretMetadata);
1156
+ throw new errors_1.SeedlessOnboardingError(constants_1.SeedlessOnboardingControllerErrorMessage.FailedToFetchSecretMetadata, {
1157
+ cause: error,
1158
+ });
1145
1159
  }
1146
1160
  // user must have at least one secret data
1147
1161
  if (secretData?.length > 0) {
@@ -1590,7 +1604,9 @@ async function _SeedlessOnboardingController_assertPasswordInSync(options) {
1590
1604
  })
1591
1605
  .catch((error) => {
1592
1606
  log('Error fetching auth pub key', error);
1593
- throw new Error(constants_1.SeedlessOnboardingControllerErrorMessage.FailedToFetchAuthPubKey);
1607
+ throw new errors_1.SeedlessOnboardingError(constants_1.SeedlessOnboardingControllerErrorMessage.FailedToFetchAuthPubKey, {
1608
+ cause: error,
1609
+ });
1594
1610
  });
1595
1611
  const isPasswordOutdated = await this.checkIsPasswordOutdated({
1596
1612
  ...options,