@metamask-previews/profile-sync-controller 32.1.1-preview-d3f9964be → 32.1.1-preview-a2f6118d2

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.
Files changed (74) hide show
  1. package/CHANGELOG.md +0 -3
  2. package/dist/controllers/authentication/AuthenticationController-method-action-types.d.ts +1 -38
  3. package/dist/controllers/authentication/AuthenticationController-method-action-types.d.ts.map +1 -1
  4. package/dist/controllers/authentication/AuthenticationController-method-action-types.js.map +1 -1
  5. package/dist/controllers/authentication/AuthenticationController.d.ts +2 -38
  6. package/dist/controllers/authentication/AuthenticationController.d.ts.map +1 -1
  7. package/dist/controllers/authentication/AuthenticationController.js +7 -185
  8. package/dist/controllers/authentication/AuthenticationController.js.map +1 -1
  9. package/dist/controllers/authentication/index.d.ts +1 -1
  10. package/dist/controllers/authentication/index.d.ts.map +1 -1
  11. package/dist/controllers/authentication/index.js.map +1 -1
  12. package/dist/controllers/authentication/mocks/mockResponses.d.ts +0 -5
  13. package/dist/controllers/authentication/mocks/mockResponses.d.ts.map +1 -1
  14. package/dist/controllers/authentication/mocks/mockResponses.js +1 -26
  15. package/dist/controllers/authentication/mocks/mockResponses.js.map +1 -1
  16. package/dist/controllers/user-storage/UserStorageController.d.ts.map +1 -1
  17. package/dist/controllers/user-storage/UserStorageController.js +5 -6
  18. package/dist/controllers/user-storage/UserStorageController.js.map +1 -1
  19. package/dist/sdk/authentication-jwt-bearer/flow-srp.d.ts +1 -56
  20. package/dist/sdk/authentication-jwt-bearer/flow-srp.d.ts.map +1 -1
  21. package/dist/sdk/authentication-jwt-bearer/flow-srp.js +1 -119
  22. package/dist/sdk/authentication-jwt-bearer/flow-srp.js.map +1 -1
  23. package/dist/sdk/authentication.d.ts +6 -15
  24. package/dist/sdk/authentication.d.ts.map +1 -1
  25. package/dist/sdk/authentication.js +0 -24
  26. package/dist/sdk/authentication.js.map +1 -1
  27. package/dist/sdk/constants.d.ts +0 -2
  28. package/dist/sdk/constants.d.ts.map +1 -1
  29. package/dist/sdk/constants.js +0 -2
  30. package/dist/sdk/constants.js.map +1 -1
  31. package/dist/sdk/errors.d.ts +0 -91
  32. package/dist/sdk/errors.d.ts.map +1 -1
  33. package/dist/sdk/errors.js +0 -161
  34. package/dist/sdk/errors.js.map +1 -1
  35. package/dist/sdk/index.d.ts +0 -3
  36. package/dist/sdk/index.d.ts.map +1 -1
  37. package/dist/sdk/index.js +0 -1
  38. package/dist/sdk/index.js.map +1 -1
  39. package/dist/sdk/mocks/auth.d.ts +0 -63
  40. package/dist/sdk/mocks/auth.d.ts.map +1 -1
  41. package/dist/sdk/mocks/auth.js +0 -90
  42. package/dist/sdk/mocks/auth.js.map +1 -1
  43. package/dist/sdk/utils/validate-login-response.d.ts.map +1 -1
  44. package/dist/sdk/utils/validate-login-response.js +7 -5
  45. package/dist/sdk/utils/validate-login-response.js.map +1 -1
  46. package/dist/shared/utils/entropy-source.d.ts +12 -3
  47. package/dist/shared/utils/entropy-source.d.ts.map +1 -1
  48. package/dist/shared/utils/entropy-source.js +17 -4
  49. package/dist/shared/utils/entropy-source.js.map +1 -1
  50. package/package.json +1 -4
  51. package/dist/sdk/authentication-jwt-bearer/mfa/schemas.d.ts +0 -691
  52. package/dist/sdk/authentication-jwt-bearer/mfa/schemas.d.ts.map +0 -1
  53. package/dist/sdk/authentication-jwt-bearer/mfa/schemas.js +0 -265
  54. package/dist/sdk/authentication-jwt-bearer/mfa/schemas.js.map +0 -1
  55. package/dist/sdk/authentication-jwt-bearer/mfa/services.d.ts +0 -104
  56. package/dist/sdk/authentication-jwt-bearer/mfa/services.d.ts.map +0 -1
  57. package/dist/sdk/authentication-jwt-bearer/mfa/services.js +0 -363
  58. package/dist/sdk/authentication-jwt-bearer/mfa/services.js.map +0 -1
  59. package/dist/sdk/authentication-jwt-bearer/mfa/types.d.ts +0 -125
  60. package/dist/sdk/authentication-jwt-bearer/mfa/types.d.ts.map +0 -1
  61. package/dist/sdk/authentication-jwt-bearer/mfa/types.js +0 -3
  62. package/dist/sdk/authentication-jwt-bearer/mfa/types.js.map +0 -1
  63. package/dist/sdk/utils/as-record.d.ts +0 -10
  64. package/dist/sdk/utils/as-record.d.ts.map +0 -1
  65. package/dist/sdk/utils/as-record.js +0 -14
  66. package/dist/sdk/utils/as-record.js.map +0 -1
  67. package/dist/sdk/utils/jwt.d.ts +0 -13
  68. package/dist/sdk/utils/jwt.d.ts.map +0 -1
  69. package/dist/sdk/utils/jwt.js +0 -21
  70. package/dist/sdk/utils/jwt.js.map +0 -1
  71. package/dist/sdk/utils/to-error-message.d.ts +0 -8
  72. package/dist/sdk/utils/to-error-message.d.ts.map +0 -1
  73. package/dist/sdk/utils/to-error-message.js +0 -10
  74. package/dist/sdk/utils/to-error-message.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -9,9 +9,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
9
9
 
10
10
  ### Added
11
11
 
12
- - Add `refreshEnrolledCredentials`, `beginCredentialEnrollment` and `completeCredentialEnrollment` to `AuthenticationController`, backed by a memory-only `enrolledCredentials` state and an optional `trace` callback ([#10266](https://github.com/MetaMask/core/pull/10266))
13
- - Add passkey and email OTP enrollment, verification, credential-list, and elevated-token exchange SDK methods ([#10265](https://github.com/MetaMask/core/pull/10265))
14
- - Add validated MFA domain types and structured `MfaError` classes with a serialization-safe `mfaCode` ([#10264](https://github.com/MetaMask/core/pull/10264))
15
12
  - Add `rampsOrders` to `USER_STORAGE_FEATURE_NAMES` ([#10227](https://github.com/MetaMask/core/pull/10227))
16
13
 
17
14
  ## [32.1.1]
@@ -16,43 +16,6 @@ export type AuthenticationControllerRequestProfilePairingAction = {
16
16
  type: `AuthenticationController:requestProfilePairing`;
17
17
  handler: AuthenticationController['requestProfilePairing'];
18
18
  };
19
- /**
20
- * Refreshes credentials enrolled on the canonical profile.
21
- *
22
- * @returns The current supported credentials.
23
- */
24
- export type AuthenticationControllerRefreshEnrolledCredentialsAction = {
25
- type: `AuthenticationController:refreshEnrolledCredentials`;
26
- handler: AuthenticationController['refreshEnrolledCredentials'];
27
- };
28
- /**
29
- * Begins enrollment of a passkey or email OTP credential.
30
- *
31
- * @param request - Credential, optional email address, and trace reason.
32
- * @returns A challenge for the client-owned ceremony.
33
- */
34
- export type AuthenticationControllerBeginCredentialEnrollmentAction = {
35
- type: `AuthenticationController:beginCredentialEnrollment`;
36
- handler: AuthenticationController['beginCredentialEnrollment'];
37
- };
38
- /**
39
- * Completes credential enrollment and refreshes the credential cache.
40
- *
41
- * A cache-refresh failure does not undo successful enrollment. Email
42
- * enrollment invalidates the primary SRP session *after* refresh so the
43
- * credentials call can reuse the still-valid access token; the next token
44
- * fetch then includes the newly verified email claim. That invalidation
45
- * happens even if the session ends mid-request: the enrollment succeeded
46
- * on the server, so a token cached across a lock must not be reused
47
- * without the new claim.
48
- *
49
- * @param request - Flow identifier, platform or email proof, and trace reason.
50
- * @returns The refreshed credentials, or the existing cache if refresh fails.
51
- */
52
- export type AuthenticationControllerCompleteCredentialEnrollmentAction = {
53
- type: `AuthenticationController:completeCredentialEnrollment`;
54
- handler: AuthenticationController['completeCredentialEnrollment'];
55
- };
56
19
  export type AuthenticationControllerPerformSignOutAction = {
57
20
  type: `AuthenticationController:performSignOut`;
58
21
  handler: AuthenticationController['performSignOut'];
@@ -160,5 +123,5 @@ export type AuthenticationControllerIsSignedInAction = {
160
123
  /**
161
124
  * Union of all AuthenticationController action types.
162
125
  */
163
- export type AuthenticationControllerMethodActions = AuthenticationControllerPerformSignInAction | AuthenticationControllerRequestProfilePairingAction | AuthenticationControllerRefreshEnrolledCredentialsAction | AuthenticationControllerBeginCredentialEnrollmentAction | AuthenticationControllerCompleteCredentialEnrollmentAction | AuthenticationControllerPerformSignOutAction | AuthenticationControllerClearStateAction | AuthenticationControllerGetBearerTokenAction | AuthenticationControllerGetSessionProfileAction | AuthenticationControllerRefreshCanonicalProfileIdAction | AuthenticationControllerGetUserProfileLineageAction | AuthenticationControllerGetCustomerServiceTokenAction | AuthenticationControllerGetPartnerIdentityTokenAction | AuthenticationControllerIsSignedInAction;
126
+ export type AuthenticationControllerMethodActions = AuthenticationControllerPerformSignInAction | AuthenticationControllerRequestProfilePairingAction | AuthenticationControllerPerformSignOutAction | AuthenticationControllerClearStateAction | AuthenticationControllerGetBearerTokenAction | AuthenticationControllerGetSessionProfileAction | AuthenticationControllerRefreshCanonicalProfileIdAction | AuthenticationControllerGetUserProfileLineageAction | AuthenticationControllerGetCustomerServiceTokenAction | AuthenticationControllerGetPartnerIdentityTokenAction | AuthenticationControllerIsSignedInAction;
164
127
  //# sourceMappingURL=AuthenticationController-method-action-types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"AuthenticationController-method-action-types.d.ts","sourceRoot":"","sources":["../../../src/controllers/authentication/AuthenticationController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAE9E,MAAM,MAAM,2CAA2C,GAAG;IACxD,IAAI,EAAE,wCAAwC,CAAC;IAC/C,OAAO,EAAE,wBAAwB,CAAC,eAAe,CAAC,CAAC;CACpD,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,mDAAmD,GAAG;IAChE,IAAI,EAAE,gDAAgD,CAAC;IACvD,OAAO,EAAE,wBAAwB,CAAC,uBAAuB,CAAC,CAAC;CAC5D,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,wDAAwD,GAAG;IACrE,IAAI,EAAE,qDAAqD,CAAC;IAC5D,OAAO,EAAE,wBAAwB,CAAC,4BAA4B,CAAC,CAAC;CACjE,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,uDAAuD,GAAG;IACpE,IAAI,EAAE,oDAAoD,CAAC;IAC3D,OAAO,EAAE,wBAAwB,CAAC,2BAA2B,CAAC,CAAC;CAChE,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,0DAA0D,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,wBAAwB,CAAC,yBAAyB,CAAC,CAAC;CAC9D,CAAC;AAEF,MAAM,MAAM,wCAAwC,GAAG;IACrD,IAAI,EAAE,qCAAqC,CAAC;IAC5C,OAAO,EAAE,wBAAwB,CAAC,YAAY,CAAC,CAAC;CACjD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,qCAAqC,GAC7C,2CAA2C,GAC3C,mDAAmD,GACnD,wDAAwD,GACxD,uDAAuD,GACvD,0DAA0D,GAC1D,4CAA4C,GAC5C,wCAAwC,GACxC,4CAA4C,GAC5C,+CAA+C,GAC/C,uDAAuD,GACvD,mDAAmD,GACnD,qDAAqD,GACrD,qDAAqD,GACrD,wCAAwC,CAAC"}
1
+ {"version":3,"file":"AuthenticationController-method-action-types.d.ts","sourceRoot":"","sources":["../../../src/controllers/authentication/AuthenticationController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAE9E,MAAM,MAAM,2CAA2C,GAAG;IACxD,IAAI,EAAE,wCAAwC,CAAC;IAC/C,OAAO,EAAE,wBAAwB,CAAC,eAAe,CAAC,CAAC;CACpD,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,mDAAmD,GAAG;IAChE,IAAI,EAAE,gDAAgD,CAAC;IACvD,OAAO,EAAE,wBAAwB,CAAC,uBAAuB,CAAC,CAAC;CAC5D,CAAC;AAEF,MAAM,MAAM,4CAA4C,GAAG;IACzD,IAAI,EAAE,yCAAyC,CAAC;IAChD,OAAO,EAAE,wBAAwB,CAAC,gBAAgB,CAAC,CAAC;CACrD,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,wCAAwC,GAAG;IACrD,IAAI,EAAE,qCAAqC,CAAC;IAC5C,OAAO,EAAE,wBAAwB,CAAC,YAAY,CAAC,CAAC;CACjD,CAAC;AAEF;;;;;;;;;;GAUG;AACH,MAAM,MAAM,4CAA4C,GAAG;IACzD,IAAI,EAAE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"","sources":["../../../src/controllers/authentication/AuthenticationController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { AuthenticationController } from './AuthenticationController.js';\n\nexport type AuthenticationControllerPerformSignInAction = {\n type: `AuthenticationController:performSignIn`;\n handler: AuthenticationController['performSignIn'];\n};\n\n/**\n * Marks profile pairing as needed. Clients call this when the SRP set\n * changes (e.g. a new keyring was added) so the next auto-sign-in cycle\n * re-runs `performSignIn` and re-pairs.\n */\nexport type AuthenticationControllerRequestProfilePairingAction = {\n type: `AuthenticationController:requestProfilePairing`;\n handler: AuthenticationController['requestProfilePairing'];\n};\n\n/**\n * Refreshes credentials enrolled on the canonical profile.\n *\n * @returns The current supported credentials.\n */\nexport type AuthenticationControllerRefreshEnrolledCredentialsAction = {\n type: `AuthenticationController:refreshEnrolledCredentials`;\n handler: AuthenticationController['refreshEnrolledCredentials'];\n};\n\n/**\n * Begins enrollment of a passkey or email OTP credential.\n *\n * @param request - Credential, optional email address, and trace reason.\n * @returns A challenge for the client-owned ceremony.\n */\nexport type AuthenticationControllerBeginCredentialEnrollmentAction = {\n type: `AuthenticationController:beginCredentialEnrollment`;\n handler: AuthenticationController['beginCredentialEnrollment'];\n};\n\n/**\n * Completes credential enrollment and refreshes the credential cache.\n *\n * A cache-refresh failure does not undo successful enrollment. Email\n * enrollment invalidates the primary SRP session *after* refresh so the\n * credentials call can reuse the still-valid access token; the next token\n * fetch then includes the newly verified email claim. That invalidation\n * happens even if the session ends mid-request: the enrollment succeeded\n * on the server, so a token cached across a lock must not be reused\n * without the new claim.\n *\n * @param request - Flow identifier, platform or email proof, and trace reason.\n * @returns The refreshed credentials, or the existing cache if refresh fails.\n */\nexport type AuthenticationControllerCompleteCredentialEnrollmentAction = {\n type: `AuthenticationController:completeCredentialEnrollment`;\n handler: AuthenticationController['completeCredentialEnrollment'];\n};\n\nexport type AuthenticationControllerPerformSignOutAction = {\n type: `AuthenticationController:performSignOut`;\n handler: AuthenticationController['performSignOut'];\n};\n\n/**\n * Resets the controller to `defaultState`. Clients call this on wallet reset\n * so the next wallet starts unsigned with both pairing gates re-armed.\n */\nexport type AuthenticationControllerClearStateAction = {\n type: `AuthenticationController:clearState`;\n handler: AuthenticationController['clearState'];\n};\n\n/**\n * Returns a bearer token for the specified SRP, logging in if needed.\n *\n * When called without `entropySourceId`, returns the primary (first) SRP's\n * access token, which is effectively the canonical\n * profile's token that can be used by alias-aware consumers for cross-SRP\n * operations.\n *\n * @param entropySourceId - The entropy source ID. Omit for the primary SRP.\n * @returns The OIDC access token.\n */\nexport type AuthenticationControllerGetBearerTokenAction = {\n type: `AuthenticationController:getBearerToken`;\n handler: AuthenticationController['getBearerToken'];\n};\n\n/**\n * Returns the cached session profile, logging in if no session exists.\n *\n * The returned `canonicalProfileId` reflects the value from the most recent\n * login or pairing. In the rare event where a canonical changed because of\n * a pairing that happened on another device, the cached value may be stale\n * until the next login. For guaranteed freshness, call\n * `refreshCanonicalProfileId()` before reading `canonicalProfileId`.\n *\n * @param entropySourceId - The entropy source ID used to derive the key,\n * when multiple sources are available (Multi-SRP).\n * @returns profile for the session.\n */\nexport type AuthenticationControllerGetSessionProfileAction = {\n type: `AuthenticationController:getSessionProfile`;\n handler: AuthenticationController['getSessionProfile'];\n};\n\n/**\n * Forces a fresh retrieval of the canonical profile ID from the server\n * and propagates it to all cached SRP sessions.\n *\n * This method invalidates the primary SRP's cached session and forces a\n * re-login. Use it before operations that require a guaranteed-fresh\n * canonical (e.g. storage key derivation for Accounts ADR 0005). For\n * best-effort reads, use\n * `getSessionProfile().canonicalProfileId` instead.\n *\n * Only the primary SRP is re-logged-in regardless of how many SRPs exist —\n * the server returns the current canonical for the entire pairing group\n * from any single SRP login.\n *\n * @returns The refreshed canonical profile ID.\n */\nexport type AuthenticationControllerRefreshCanonicalProfileIdAction = {\n type: `AuthenticationController:refreshCanonicalProfileId`;\n handler: AuthenticationController['refreshCanonicalProfileId'];\n};\n\nexport type AuthenticationControllerGetUserProfileLineageAction = {\n type: `AuthenticationController:getUserProfileLineage`;\n handler: AuthenticationController['getUserProfileLineage'];\n};\n\n/**\n * Returns a Customer Service specific access token for the specified SRP,\n * logging in if needed.\n *\n * Exchanges the OIDC access token for a short-lived token scoped to the\n * customer-service audience. Customer Service tooling consumes this token to\n * identify and authenticate the user.\n *\n * @param entropySourceId - The entropy source ID. Omit for the primary SRP.\n * @returns The customer-service access token.\n */\nexport type AuthenticationControllerGetCustomerServiceTokenAction = {\n type: `AuthenticationController:getCustomerServiceToken`;\n handler: AuthenticationController['getCustomerServiceToken'];\n};\n\n/**\n * Mints a partner identity token for the specified SRP, logging in if needed.\n *\n * Calls `POST /api/v2/oidc/token` with the Hydra login bearer and returns\n * the minted `access_token`. Email on live tokens is under JWT `ext`.\n * HTTP 422 throws `EmailRequiredError` when this profile has no\n * verified email.\n *\n * @param claims - Claim names to embed. Only `email` is supported.\n * @param audience - Partner audience (`kyc` or `iron`).\n * @param entropySourceId - The entropy source ID. Omit for the primary SRP.\n * @returns The partner identity access token.\n */\nexport type AuthenticationControllerGetPartnerIdentityTokenAction = {\n type: `AuthenticationController:getPartnerIdentityToken`;\n handler: AuthenticationController['getPartnerIdentityToken'];\n};\n\nexport type AuthenticationControllerIsSignedInAction = {\n type: `AuthenticationController:isSignedIn`;\n handler: AuthenticationController['isSignedIn'];\n};\n\n/**\n * Union of all AuthenticationController action types.\n */\nexport type AuthenticationControllerMethodActions =\n | AuthenticationControllerPerformSignInAction\n | AuthenticationControllerRequestProfilePairingAction\n | AuthenticationControllerRefreshEnrolledCredentialsAction\n | AuthenticationControllerBeginCredentialEnrollmentAction\n | AuthenticationControllerCompleteCredentialEnrollmentAction\n | AuthenticationControllerPerformSignOutAction\n | AuthenticationControllerClearStateAction\n | AuthenticationControllerGetBearerTokenAction\n | AuthenticationControllerGetSessionProfileAction\n | AuthenticationControllerRefreshCanonicalProfileIdAction\n | AuthenticationControllerGetUserProfileLineageAction\n | AuthenticationControllerGetCustomerServiceTokenAction\n | AuthenticationControllerGetPartnerIdentityTokenAction\n | AuthenticationControllerIsSignedInAction;\n"]}
1
+ {"version":3,"file":"AuthenticationController-method-action-types.js","sourceRoot":"","sources":["../../../src/controllers/authentication/AuthenticationController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { AuthenticationController } from './AuthenticationController.js';\n\nexport type AuthenticationControllerPerformSignInAction = {\n type: `AuthenticationController:performSignIn`;\n handler: AuthenticationController['performSignIn'];\n};\n\n/**\n * Marks profile pairing as needed. Clients call this when the SRP set\n * changes (e.g. a new keyring was added) so the next auto-sign-in cycle\n * re-runs `performSignIn` and re-pairs.\n */\nexport type AuthenticationControllerRequestProfilePairingAction = {\n type: `AuthenticationController:requestProfilePairing`;\n handler: AuthenticationController['requestProfilePairing'];\n};\n\nexport type AuthenticationControllerPerformSignOutAction = {\n type: `AuthenticationController:performSignOut`;\n handler: AuthenticationController['performSignOut'];\n};\n\n/**\n * Resets the controller to `defaultState`. Clients call this on wallet reset\n * so the next wallet starts unsigned with both pairing gates re-armed.\n */\nexport type AuthenticationControllerClearStateAction = {\n type: `AuthenticationController:clearState`;\n handler: AuthenticationController['clearState'];\n};\n\n/**\n * Returns a bearer token for the specified SRP, logging in if needed.\n *\n * When called without `entropySourceId`, returns the primary (first) SRP's\n * access token, which is effectively the canonical\n * profile's token that can be used by alias-aware consumers for cross-SRP\n * operations.\n *\n * @param entropySourceId - The entropy source ID. Omit for the primary SRP.\n * @returns The OIDC access token.\n */\nexport type AuthenticationControllerGetBearerTokenAction = {\n type: `AuthenticationController:getBearerToken`;\n handler: AuthenticationController['getBearerToken'];\n};\n\n/**\n * Returns the cached session profile, logging in if no session exists.\n *\n * The returned `canonicalProfileId` reflects the value from the most recent\n * login or pairing. In the rare event where a canonical changed because of\n * a pairing that happened on another device, the cached value may be stale\n * until the next login. For guaranteed freshness, call\n * `refreshCanonicalProfileId()` before reading `canonicalProfileId`.\n *\n * @param entropySourceId - The entropy source ID used to derive the key,\n * when multiple sources are available (Multi-SRP).\n * @returns profile for the session.\n */\nexport type AuthenticationControllerGetSessionProfileAction = {\n type: `AuthenticationController:getSessionProfile`;\n handler: AuthenticationController['getSessionProfile'];\n};\n\n/**\n * Forces a fresh retrieval of the canonical profile ID from the server\n * and propagates it to all cached SRP sessions.\n *\n * This method invalidates the primary SRP's cached session and forces a\n * re-login. Use it before operations that require a guaranteed-fresh\n * canonical (e.g. storage key derivation for Accounts ADR 0005). For\n * best-effort reads, use\n * `getSessionProfile().canonicalProfileId` instead.\n *\n * Only the primary SRP is re-logged-in regardless of how many SRPs exist —\n * the server returns the current canonical for the entire pairing group\n * from any single SRP login.\n *\n * @returns The refreshed canonical profile ID.\n */\nexport type AuthenticationControllerRefreshCanonicalProfileIdAction = {\n type: `AuthenticationController:refreshCanonicalProfileId`;\n handler: AuthenticationController['refreshCanonicalProfileId'];\n};\n\nexport type AuthenticationControllerGetUserProfileLineageAction = {\n type: `AuthenticationController:getUserProfileLineage`;\n handler: AuthenticationController['getUserProfileLineage'];\n};\n\n/**\n * Returns a Customer Service specific access token for the specified SRP,\n * logging in if needed.\n *\n * Exchanges the OIDC access token for a short-lived token scoped to the\n * customer-service audience. Customer Service tooling consumes this token to\n * identify and authenticate the user.\n *\n * @param entropySourceId - The entropy source ID. Omit for the primary SRP.\n * @returns The customer-service access token.\n */\nexport type AuthenticationControllerGetCustomerServiceTokenAction = {\n type: `AuthenticationController:getCustomerServiceToken`;\n handler: AuthenticationController['getCustomerServiceToken'];\n};\n\n/**\n * Mints a partner identity token for the specified SRP, logging in if needed.\n *\n * Calls `POST /api/v2/oidc/token` with the Hydra login bearer and returns\n * the minted `access_token`. Email on live tokens is under JWT `ext`.\n * HTTP 422 throws `EmailRequiredError` when this profile has no\n * verified email.\n *\n * @param claims - Claim names to embed. Only `email` is supported.\n * @param audience - Partner audience (`kyc` or `iron`).\n * @param entropySourceId - The entropy source ID. Omit for the primary SRP.\n * @returns The partner identity access token.\n */\nexport type AuthenticationControllerGetPartnerIdentityTokenAction = {\n type: `AuthenticationController:getPartnerIdentityToken`;\n handler: AuthenticationController['getPartnerIdentityToken'];\n};\n\nexport type AuthenticationControllerIsSignedInAction = {\n type: `AuthenticationController:isSignedIn`;\n handler: AuthenticationController['isSignedIn'];\n};\n\n/**\n * Union of all AuthenticationController action types.\n */\nexport type AuthenticationControllerMethodActions =\n | AuthenticationControllerPerformSignInAction\n | AuthenticationControllerRequestProfilePairingAction\n | AuthenticationControllerPerformSignOutAction\n | AuthenticationControllerClearStateAction\n | AuthenticationControllerGetBearerTokenAction\n | AuthenticationControllerGetSessionProfileAction\n | AuthenticationControllerRefreshCanonicalProfileIdAction\n | AuthenticationControllerGetUserProfileLineageAction\n | AuthenticationControllerGetCustomerServiceTokenAction\n | AuthenticationControllerGetPartnerIdentityTokenAction\n | AuthenticationControllerIsSignedInAction;\n"]}
@@ -1,10 +1,9 @@
1
1
  import { BaseController } from '@metamask/base-controller';
2
2
  import type { ControllerGetStateAction, ControllerStateChangeEvent } from '@metamask/base-controller';
3
- import type { TraceCallback } from '@metamask/controller-utils';
4
3
  import type { KeyringControllerGetStateAction, KeyringControllerLockEvent, KeyringControllerUnlockEvent, KeyringControllerWithKeyringV2UnsafeAction } from '@metamask/keyring-controller';
5
4
  import type { Messenger } from '@metamask/messenger';
6
5
  import type { SeedlessOnboardingControllerGetAccessTokenAction, SeedlessOnboardingControllerGetStateAction } from '@metamask/seedless-onboarding-controller';
7
- import type { LoginResponse, ProfileAlias, UserProfile, UserProfileLineage, OidcTokenAudience, OidcTokenClaims, BeginEnrollmentRequest, CompleteEnrollmentRequest, EnrolledCredential, EnrollmentChallenge } from '../../sdk/index.js';
6
+ import type { LoginResponse, ProfileAlias, UserProfile, UserProfileLineage, OidcTokenAudience, OidcTokenClaims } from '../../sdk/index.js';
8
7
  import { Env } from '../../sdk/index.js';
9
8
  import type { MetaMetricsAuth } from '../../shared/types/services.js';
10
9
  import { AuthenticationControllerMethodActions } from './AuthenticationController-method-action-types.js';
@@ -12,12 +11,6 @@ declare const controllerName = "AuthenticationController";
12
11
  export type AuthenticationControllerState = {
13
12
  isSignedIn: boolean;
14
13
  srpSessionData?: Record<string, LoginResponse>;
15
- /**
16
- * Credentials fetched for the current profile. The controller always seeds
17
- * this to an empty array; it remains optional so partial-state selectors stay
18
- * assignable to the controller state type.
19
- */
20
- enrolledCredentials?: EnrolledCredential[];
21
14
  /**
22
15
  * Client gate for profile pairing. Defaults to `true` (fresh install /
23
16
  * upgrade), set to `false` after a successful `performSignIn` pair, set
@@ -76,7 +69,7 @@ export type AuthenticationControllerMessenger = Messenger<typeof controllerName,
76
69
  */
77
70
  export declare class AuthenticationController extends BaseController<typeof controllerName, AuthenticationControllerState, AuthenticationControllerMessenger> {
78
71
  #private;
79
- constructor({ messenger, state, config, metametrics, trace, }: {
72
+ constructor({ messenger, state, config, metametrics, }: {
80
73
  messenger: AuthenticationControllerMessenger;
81
74
  state?: AuthenticationControllerState;
82
75
  config?: Partial<ControllerConfig>;
@@ -85,7 +78,6 @@ export declare class AuthenticationController extends BaseController<typeof cont
85
78
  * do not want to tie this strictly to extension
86
79
  */
87
80
  metametrics: MetaMetricsAuth;
88
- trace?: TraceCallback;
89
81
  });
90
82
  performSignIn(): Promise<string[]>;
91
83
  /**
@@ -94,34 +86,6 @@ export declare class AuthenticationController extends BaseController<typeof cont
94
86
  * re-runs `performSignIn` and re-pairs.
95
87
  */
96
88
  requestProfilePairing(): void;
97
- /**
98
- * Refreshes credentials enrolled on the canonical profile.
99
- *
100
- * @returns The current supported credentials.
101
- */
102
- refreshEnrolledCredentials(): Promise<EnrolledCredential[]>;
103
- /**
104
- * Begins enrollment of a passkey or email OTP credential.
105
- *
106
- * @param request - Credential, optional email address, and trace reason.
107
- * @returns A challenge for the client-owned ceremony.
108
- */
109
- beginCredentialEnrollment(request: BeginEnrollmentRequest): Promise<EnrollmentChallenge>;
110
- /**
111
- * Completes credential enrollment and refreshes the credential cache.
112
- *
113
- * A cache-refresh failure does not undo successful enrollment. Email
114
- * enrollment invalidates the primary SRP session *after* refresh so the
115
- * credentials call can reuse the still-valid access token; the next token
116
- * fetch then includes the newly verified email claim. That invalidation
117
- * happens even if the session ends mid-request: the enrollment succeeded
118
- * on the server, so a token cached across a lock must not be reused
119
- * without the new claim.
120
- *
121
- * @param request - Flow identifier, platform or email proof, and trace reason.
122
- * @returns The refreshed credentials, or the existing cache if refresh fails.
123
- */
124
- completeCredentialEnrollment(request: CompleteEnrollmentRequest): Promise<EnrolledCredential[]>;
125
89
  performSignOut(): void;
126
90
  /**
127
91
  * Resets the controller to `defaultState`. Clients call this on wallet reset
@@ -1 +1 @@
1
- {"version":3,"file":"AuthenticationController.d.ts","sourceRoot":"","sources":["../../../src/controllers/authentication/AuthenticationController.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAE3B,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAEhE,OAAO,KAAK,EACV,+BAA+B,EAC/B,0BAA0B,EAC1B,4BAA4B,EAC5B,0CAA0C,EAC3C,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,KAAK,EACV,gDAAgD,EAChD,0CAA0C,EAC3C,MAAM,0CAA0C,CAAC;AAQlD,OAAO,KAAK,EAEV,aAAa,EACb,YAAY,EAGZ,WAAW,EACX,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,EACf,sBAAsB,EACtB,yBAAyB,EACzB,kBAAkB,EAClB,mBAAmB,EACpB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAGL,GAAG,EAIJ,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,E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ACU,iBAAiB,CAC5B,eAAe,CAAC,EAAE,MAAM,GACvB,OAAO,CAAC,WAAW,CAAC,CAItB;IAED;;;;;;;;;;;;;;;OAeG;IACU,yBAAyB,IAAI,OAAO,CAAC,MAAM,CAAC,CAgBxD;IAcY,qBAAqB,CAChC,eAAe,CAAC,EAAE,MAAM,GACvB,OAAO,CAAC,kBAAkB,CAAC,CAI7B;IAED;;;;;;;;;;OAUG;IACU,uBAAuB,CAClC,eAAe,CAAC,EAAE,MAAM,GACvB,OAAO,CAAC,MAAM,CAAC,CAIjB;IAED;;;;;;;;;;;;OAYG;IACU,uBAAuB,CAClC,MAAM,EAAE,eAAe,EACvB,QAAQ,EAAE,iBAAiB,EAC3B,eAAe,CAAC,EAAE,MAAM,GACvB,OAAO,CAAC,MAAM,CAAC,CAQjB;IAEM,UAAU,IAAI,OAAO,CAE3B;CA8EF"}
1
+ {"version":3,"file":"AuthenticationController.d.ts","sourceRoot":"","sources":["../../../src/controllers/authentication/AuthenticationController.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAE3B,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EACV,+BAA+B,EAC/B,0BAA0B,EAC1B,4BAA4B,EAC5B,0CAA0C,EAC3C,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,KAAK,EACV,gDAAgD,EAChD,0CAA0C,EAC3C,MAAM,0CAA0C,CAAC;AAGlD,OAAO,KAAK,EAEV,aAAa,EACb,YAAY,EAGZ,WAAW,EACX,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,EAChB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAGL,GAAG,EAGJ,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAU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AC3B,eAAe,CAAC,EAAE,MAAM,GACvB,OAAO,CAAC,MAAM,CAAC,CAQjB;IAEM,UAAU,IAAI,OAAO,CAE3B;CA8EF"}
@@ -1,14 +1,11 @@
1
1
  import { BaseController } from '@metamask/base-controller';
2
- import { selectHdKeyringEntropySourceIds } from '@metamask/keyring-controller';
3
- import { BeginEnrollmentRequestStruct, CompleteEnrollmentRequestStruct, assertValidMfaRequest, } from '../../sdk/authentication-jwt-bearer/mfa/schemas.js';
4
- import { assertMessageStartsWithMetamask, AuthType, Env, JwtBearerAuth, PairConflictError, getMfaErrorCode, } from '../../sdk/index.js';
5
- import { getPrimaryHdKeyringEntropySourceId } from '../../shared/utils/entropy-source.js';
2
+ import { assertMessageStartsWithMetamask, AuthType, Env, JwtBearerAuth, PairConflictError, } from '../../sdk/index.js';
3
+ import { getHdKeyringEntropySourceIds, getPrimaryHdKeyringEntropySourceId, } from '../../shared/utils/entropy-source.js';
6
4
  import { getHdKeyringSeed } from '../../shared/utils/hd-keyring-seed.js';
7
5
  import { getMessageSigningPublicKey, signMessageWithMessageSigningKey, } from '../../shared/utils/message-signing.js';
8
6
  const controllerName = 'AuthenticationController';
9
7
  export const defaultState = {
10
8
  isSignedIn: false,
11
- enrolledCredentials: [],
12
9
  needsProfilePairing: true,
13
10
  needsSocialPairing: true,
14
11
  };
@@ -55,17 +52,6 @@ const metadata = {
55
52
  includeInDebugSnapshot: false,
56
53
  usedInUi: true,
57
54
  },
58
- enrolledCredentials: {
59
- // Allow-list so new credential types cannot leak identifiers by default.
60
- includeInStateLogs: (credentials) => credentials?.map(({ type, status, enrolledAt }) => ({
61
- type,
62
- status,
63
- ...(enrolledAt === undefined ? {} : { enrolledAt }),
64
- })) ?? null,
65
- persist: false,
66
- includeInDebugSnapshot: false,
67
- usedInUi: true,
68
- },
69
55
  };
70
56
  const MESSENGER_EXPOSED_METHODS = [
71
57
  'performSignIn',
@@ -79,9 +65,6 @@ const MESSENGER_EXPOSED_METHODS = [
79
65
  'isSignedIn',
80
66
  'requestProfilePairing',
81
67
  'clearState',
82
- 'refreshEnrolledCredentials',
83
- 'beginCredentialEnrollment',
84
- 'completeCredentialEnrollment',
85
68
  ];
86
69
  /**
87
70
  * Controller that enables authentication for restricted endpoints.
@@ -90,24 +73,11 @@ const MESSENGER_EXPOSED_METHODS = [
90
73
  export class AuthenticationController extends BaseController {
91
74
  #metametrics;
92
75
  #auth;
93
- #trace;
94
76
  #config = {
95
77
  env: Env.PRD,
96
78
  isSocialPairingEnabled: () => false,
97
79
  };
98
80
  #isUnlocked = false;
99
- /**
100
- * Bumped whenever the authenticated session ends, so an in-flight MFA
101
- * ceremony started under the previous session cannot apply its result.
102
- */
103
- #authSessionEpoch = 0;
104
- /**
105
- * Sequence number of the most recently started credentials refresh. Only
106
- * that refresh may write the cache, so a slower, earlier request cannot
107
- * overwrite a newer list (e.g. an explicit refresh landing after an
108
- * enrollment's refresh).
109
- */
110
- #credentialsRefreshSeq = 0;
111
81
  /**
112
82
  * Bumped by `requestProfilePairing` and `clearState` so an in-flight
113
83
  * `performSignIn` can't clear `needsProfilePairing` afterwards.
@@ -121,12 +91,11 @@ export class AuthenticationController extends BaseController {
121
91
  this.#isUnlocked = true;
122
92
  });
123
93
  this.messenger.subscribe('KeyringController:lock', () => {
124
- this.#authSessionEpoch += 1;
125
94
  this.#isUnlocked = false;
126
95
  });
127
96
  },
128
97
  };
129
- constructor({ messenger, state, config, metametrics, trace, }) {
98
+ constructor({ messenger, state, config, metametrics, }) {
130
99
  super({
131
100
  messenger,
132
101
  metadata,
@@ -142,7 +111,6 @@ export class AuthenticationController extends BaseController {
142
111
  isSocialPairingEnabled: config?.isSocialPairingEnabled ?? this.#config.isSocialPairingEnabled,
143
112
  };
144
113
  this.#metametrics = metametrics;
145
- this.#trace = trace ?? ((_request, fn) => fn?.());
146
114
  this.#auth = new JwtBearerAuth({
147
115
  env: this.#config.env,
148
116
  platform: metametrics.agent,
@@ -192,19 +160,14 @@ export class AuthenticationController extends BaseController {
192
160
  throw new Error(`${methodName} - unable to proceed, wallet is locked`);
193
161
  }
194
162
  }
195
- #assertAuthSessionEpoch(epoch, methodName) {
196
- if (!this.#isUnlocked || this.#authSessionEpoch !== epoch) {
197
- throw new Error(`${methodName} - unable to proceed, the authenticated session ended`);
198
- }
199
- }
200
163
  /**
201
164
  * Reads the HD keyring entropy source IDs from KeyringController.
202
165
  *
203
166
  * @returns The HD keyring metadata IDs, primary first.
204
167
  */
205
168
  #getHdKeyringEntropySourceIds() {
206
- const keyringState = this.messenger.call('KeyringController:getState');
207
- return selectHdKeyringEntropySourceIds(keyringState);
169
+ const { keyrings } = this.messenger.call('KeyringController:getState');
170
+ return getHdKeyringEntropySourceIds(keyrings);
208
171
  }
209
172
  /**
210
173
  * Resolves the primary SRP's entropy source ID from KeyringController rather
@@ -216,8 +179,8 @@ export class AuthenticationController extends BaseController {
216
179
  * the wallet is unlocked.
217
180
  */
218
181
  #getPrimaryEntropySourceId() {
219
- const keyringState = this.messenger.call('KeyringController:getState');
220
- return getPrimaryHdKeyringEntropySourceId(keyringState);
182
+ const { keyrings } = this.messenger.call('KeyringController:getState');
183
+ return getPrimaryHdKeyringEntropySourceId(keyrings);
221
184
  }
222
185
  /**
223
186
  * Resolves the SRP login tag for `raw_message`.
@@ -527,146 +490,7 @@ export class AuthenticationController extends BaseController {
527
490
  return (this.state.srpSessionData?.[primaryEntropySourceId]?.profile
528
491
  ?.canonicalProfileId ?? null);
529
492
  }
530
- /**
531
- * Runs one MFA network step inside a trace span tagged with the caller's
532
- * operation and the credential type, recording the outcome and MFA error
533
- * code.
534
- *
535
- * @param name - Span name.
536
- * @param operation - Caller-supplied `reason.operation`.
537
- * @param credentialType - Credential type the step concerns.
538
- * @param fn - The network step.
539
- * @returns The step's result.
540
- */
541
- async #runMfaRequest(name, operation, credentialType, fn) {
542
- const data = { outcome: 'pending' };
543
- return await this.#trace({
544
- name,
545
- tags: { operation, credentialType },
546
- data,
547
- }, async () => {
548
- try {
549
- const result = await fn();
550
- data.outcome = 'success';
551
- return result;
552
- }
553
- catch (error) {
554
- data.outcome = 'error';
555
- const mfaCode = getMfaErrorCode(error);
556
- if (mfaCode) {
557
- data.mfaErrorCode = mfaCode;
558
- }
559
- throw error;
560
- }
561
- });
562
- }
563
- /**
564
- * Refreshes credentials enrolled on the canonical profile.
565
- *
566
- * @returns The current supported credentials.
567
- */
568
- async refreshEnrolledCredentials() {
569
- this.#assertIsUnlocked('refreshEnrolledCredentials');
570
- const sessionEpoch = this.#authSessionEpoch;
571
- this.#credentialsRefreshSeq += 1;
572
- const refreshSeq = this.#credentialsRefreshSeq;
573
- const primaryEntropySourceId = this.#getPrimaryEntropySourceId();
574
- const credentials = await this.#runMfaRequest('MFA Credentials Refresh', 'credentials.refresh', 'all', async () => await this.#auth.getMfaCredentials(primaryEntropySourceId));
575
- this.#assertAuthSessionEpoch(sessionEpoch, 'refreshEnrolledCredentials');
576
- // A newer refresh started while this one was in flight; its result is at
577
- // least as fresh, so defer to it rather than overwrite with older data.
578
- if (refreshSeq !== this.#credentialsRefreshSeq) {
579
- return this.#getEnrolledCredentials();
580
- }
581
- // Skip the write when nothing changed so subscribers are not woken up by
582
- // a fresh-but-identical array.
583
- if (JSON.stringify(credentials) !==
584
- JSON.stringify(this.#getEnrolledCredentials())) {
585
- this.update((state) => {
586
- state.enrolledCredentials = credentials;
587
- });
588
- }
589
- return credentials;
590
- }
591
- /**
592
- * Begins enrollment of a passkey or email OTP credential.
593
- *
594
- * @param request - Credential, optional email address, and trace reason.
595
- * @returns A challenge for the client-owned ceremony.
596
- */
597
- async beginCredentialEnrollment(request) {
598
- this.#assertIsUnlocked('beginCredentialEnrollment');
599
- const sessionEpoch = this.#authSessionEpoch;
600
- assertValidMfaRequest(request, BeginEnrollmentRequestStruct);
601
- const primaryEntropySourceId = this.#getPrimaryEntropySourceId();
602
- const challenge = await this.#runMfaRequest('MFA Enroll Begin', request.reason.operation, request.type, async () => await this.#auth.beginMfaEnrollment(request.type, {
603
- email: request.email,
604
- entropySourceId: primaryEntropySourceId,
605
- }));
606
- this.#assertAuthSessionEpoch(sessionEpoch, 'beginCredentialEnrollment');
607
- return challenge;
608
- }
609
- /**
610
- * Completes credential enrollment and refreshes the credential cache.
611
- *
612
- * A cache-refresh failure does not undo successful enrollment. Email
613
- * enrollment invalidates the primary SRP session *after* refresh so the
614
- * credentials call can reuse the still-valid access token; the next token
615
- * fetch then includes the newly verified email claim. That invalidation
616
- * happens even if the session ends mid-request: the enrollment succeeded
617
- * on the server, so a token cached across a lock must not be reused
618
- * without the new claim.
619
- *
620
- * @param request - Flow identifier, platform or email proof, and trace reason.
621
- * @returns The refreshed credentials, or the existing cache if refresh fails.
622
- */
623
- async completeCredentialEnrollment(request) {
624
- this.#assertIsUnlocked('completeCredentialEnrollment');
625
- const sessionEpoch = this.#authSessionEpoch;
626
- assertValidMfaRequest(request, CompleteEnrollmentRequestStruct);
627
- const { type } = request.proof;
628
- const primaryEntropySourceId = this.#getPrimaryEntropySourceId();
629
- await this.#runMfaRequest('MFA Enroll Complete', request.reason.operation, type, async () => await this.#auth.completeMfaEnrollment(request.flowId, request.proof, primaryEntropySourceId));
630
- try {
631
- this.#assertAuthSessionEpoch(sessionEpoch, 'completeCredentialEnrollment');
632
- }
633
- catch (error) {
634
- if (type === 'email_otp') {
635
- this.#invalidateSrpSession(primaryEntropySourceId);
636
- }
637
- throw error;
638
- }
639
- try {
640
- return await this.refreshEnrolledCredentials();
641
- }
642
- catch {
643
- return this.#getEnrolledCredentials();
644
- }
645
- finally {
646
- if (type === 'email_otp') {
647
- this.#invalidateSrpSession(primaryEntropySourceId);
648
- }
649
- }
650
- }
651
- /**
652
- * Drops the cached credential list. Callers that wipe profile state must go
653
- * through this so subscribers never keep credentials belonging to a profile
654
- * that is no longer active.
655
- */
656
- #clearEnrolledCredentials() {
657
- if (this.#getEnrolledCredentials().length === 0) {
658
- return;
659
- }
660
- this.update((state) => {
661
- state.enrolledCredentials = [];
662
- });
663
- }
664
- #getEnrolledCredentials() {
665
- return this.state.enrolledCredentials ?? [];
666
- }
667
493
  performSignOut() {
668
- this.#authSessionEpoch += 1;
669
- this.#clearEnrolledCredentials();
670
494
  this.update((state) => {
671
495
  state.isSignedIn = false;
672
496
  state.srpSessionData = undefined;
@@ -678,8 +502,6 @@ export class AuthenticationController extends BaseController {
678
502
  */
679
503
  clearState() {
680
504
  this.#profilePairingRequestEpoch += 1;
681
- this.#authSessionEpoch += 1;
682
- this.#clearEnrolledCredentials();
683
505
  this.update(() => ({ ...defaultState }));
684
506
  }
685
507
  /**