@metamask-previews/mfa-recovery-controller 0.0.0-preview-e1e83cae0 → 0.0.0-preview-200ae8283

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,18 +9,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
9
9
 
10
10
  ### Added
11
11
 
12
- - Initial release of `MfaRecoveryController`, which manages MFA recovery flows and persists in-flight operations in its state ([#10022](https://github.com/MetaMask/core/pull/10022), [#11280](https://github.com/MetaMask/core/pull/11280))
12
+ - Initial release of `MfaRecoveryController`, which manages MFA recovery flows and persists in-flight operations in its state ([#10022](https://github.com/MetaMask/core/pull/10022))
13
13
  - Requires recent, request-bound AAL2 approvals for writes and reads.
14
14
  - Sends the approval's identifiers to escrows as `approvedIdentifiers` with `register` and `updateIdentifiers` mutations, and rejects payload identifiers that are not exactly among them before writing ([#10883](https://github.com/MetaMask/core/pull/10883))
15
15
  - Adds `getIdentifiers`, which returns the enrolled identifiers at the highest escrow version as `epoch` along with Auth's identifiers, for building `updateIdentifiers` calls ([#11149](https://github.com/MetaMask/core/pull/11149))
16
16
  - Passes the operation's AuthController token to `RecoveryEscrowProvider.generateChallenge`, and requires `RecoveryEscrowProvider.getIdentifiers` ([#11149](https://github.com/MetaMask/core/pull/11149))
17
- - Proves each SIWE identifier an escrow has not enrolled through `identifierAuthProvider`, including at `register`, instead of requiring it in `approvedIdentifiers`, and passes `RecoveryEscrowProvider.applyMutation` a list of identifier authorizations sharing one challenge ([#11151](https://github.com/MetaMask/core/pull/11151))
18
- - Rejects SIWE identifiers with malformed verifier fields, an invalid address or domain, or a `namespace` that is not their verifier's `domain:chainId` with `invalid_identifier` ([#11151](https://github.com/MetaMask/core/pull/11151))
19
- - Rejects duplicate identifiers with `duplicate_identifier` and more than 16 identifiers with `too_many_identifiers` ([#11151](https://github.com/MetaMask/core/pull/11151))
20
- - Clears a `writing` mutation in `abort()` and `resume()` once its approval has expired and no escrow applied it; `resume()` then throws `MutationRejectedError` ([#11151](https://github.com/MetaMask/core/pull/11151))
21
17
  - Exports `MfaRecoveryController`, `getDefaultMfaRecoveryControllerState`, and the controller's action, event, messenger, state, and options types.
22
18
  - Exports `AuthApiRecoveryAuthProvider`, `AuthApiRecoveryAuthProviderOptions` and `AuthApiRecoveryAuthProviderMessenger` for requesting approvals through `AuthenticationController:requestMfaApproval`, using the profile id from `AuthenticationController:refreshCanonicalProfileId` ([#10883](https://github.com/MetaMask/core/pull/10883))
23
- - Exports `CubistEscrowProvider` and `CubistEscrowProviderOptions` for storing recovery secrets with CubeSigner. `CubistEscrowProviderOptions` takes a `getClient` callback instead of a CubeSigner client so callers can create and refresh the session lazily ([#11280](https://github.com/MetaMask/core/pull/11280))
19
+ - Exports `CubistEscrowProvider` and `CubistEscrowProviderOptions` for storing recovery secrets with CubeSigner.
24
20
  - Exports `MfaRecoveryError`, `IncompleteMutationError`, and `MutationRejectedError`.
25
21
  - Exports `MIN_IDENTIFIERS`, `IDENTIFIER_AUTH_MODES`, and `getIdentifierAuthMode` for identifier authentication.
26
22
  - Exports types for the recovery providers (`RecoveryAuthProvider`, `RecoveryIdentifierAuthProvider`, `RecoveryEscrowProvider`) and the pending operation encryptor (`PendingOperationEncryptor`), along with the related identifier, mutation, and recovery phase types, including `GetIdentifiersResponse` and `RecoveryIdentifiers` ([#11149](https://github.com/MetaMask/core/pull/11149))
@@ -29,6 +25,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
29
25
  ### Changed
30
26
 
31
27
  - Bump `@metamask/utils` from `^12.0.0` to `^12.0.1` ([#11107](https://github.com/MetaMask/core/pull/11107))
32
- - Bump `@metamask/profile-sync-controller` from `^36.0.0` to `^36.1.1` ([#11396](https://github.com/MetaMask/core/pull/11396), [#11419](https://github.com/MetaMask/core/pull/11419))
28
+ - Bump `@metamask/profile-sync-controller` from `^36.0.0` to `^36.1.0` ([#11396](https://github.com/MetaMask/core/pull/11396))
33
29
 
34
30
  [Unreleased]: https://github.com/MetaMask/core/
package/README.md CHANGED
@@ -3,8 +3,7 @@
3
3
  Coordinates MFA recovery through injected auth and escrow providers.
4
4
 
5
5
  Pending mutations are encrypted in controller state. `resume()` completes them;
6
- `abort()` is allowed before writing, or once the write approval has expired and
7
- no escrow applied the mutation. See [Architecture](ARCHITECTURE.md).
6
+ `abort()` is allowed only before writing. See [Architecture](ARCHITECTURE.md).
8
7
 
9
8
  ## Auth API Integration
10
9
 
@@ -17,12 +16,10 @@ Without a recent MFA verification, approvals reject with `StepUpRequiredError`:
17
16
  verify, then call `resume()` or retry the read.
18
17
 
19
18
  `register` and `updateIdentifiers` send the approval's `identifiers` to each
20
- escrow as `approvedIdentifiers`; the escrow rejects non-SIWE payload
21
- identifiers outside that list. Build those from Auth's entries unchanged
22
- (verifier included): the controller rejects any other before writing, and the
23
- mutation can then be aborted. Each SIWE wallet a mutation adds is proven
24
- through `identifierAuthProvider` instead, including at `register`. Set
25
- `CubistEscrowProviderOptions.authAudience` to the escrow's
19
+ escrow as `approvedIdentifiers`; the escrow rejects payload identifiers outside
20
+ that list. Build payload identifiers from those entries unchanged (verifier
21
+ included): the controller rejects any other identifier before writing, and the
22
+ mutation can then be aborted. Set `CubistEscrowProviderOptions.authAudience` to the escrow's
26
23
  `AUTH_CONTROLLER_AUDIENCE`.
27
24
 
28
25
  Before `updateIdentifiers`, call `getIdentifiers()` (AAL1) for the enrolled
@@ -72,18 +72,14 @@ export type MfaRecoveryControllerGetIdentifiersAction = {
72
72
  handler: MfaRecoveryController['getIdentifiers'];
73
73
  };
74
74
  /**
75
- * Completes a persisted pending mutation, if any. Clears a `writing` one,
76
- * throwing `MutationRejectedError`, once its approval has expired and no
77
- * escrow applied it.
75
+ * Completes a persisted pending mutation, if any.
78
76
  */
79
77
  export type MfaRecoveryControllerResumeAction = {
80
78
  type: `MfaRecoveryController:resume`;
81
79
  handler: MfaRecoveryController['resume'];
82
80
  };
83
81
  /**
84
- * Drops `authorizing` pending. Drops `writing` pending only once its approval
85
- * has expired and no escrow applied it; otherwise finish it with
86
- * {@link resume}.
82
+ * Drops `authorizing` pending. `writing` must be finished with {@link resume}.
87
83
  */
88
84
  export type MfaRecoveryControllerAbortAction = {
89
85
  type: `MfaRecoveryController:abort`;
@@ -1 +1 @@
1
- {"version":3,"file":"MfaRecoveryController-method-action-types.d.ts","sourceRoot":"","sources":["../src/MfaRecoveryController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAExE;;;;;;GAMG;AACH,MAAM,MAAM,mCAAmC,GAAG;IAChD,IAAI,EAAE,gCAAgC,CAAC;IACvC,OAAO,EAAE,qBAAqB,CAAC,UAAU,CAAC,CAAC;CAC5C,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,+CAA+C,GAAG;IAC5D,IAAI,EAAE,4CAA4C,CAAC;IACnD,OAAO,EAAE,qBAAqB,CAAC,sBAAsB,CAAC,CAAC;CACxD,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,4CAA4C,GAAG;IACzD,IAAI,EAAE,yCAAyC,CAAC;IAChD,OAAO,EAAE,qBAAqB,CAAC,mBAAmB,CAAC,CAAC;CACrD,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,iDAAiD,GAAG;IAC9D,IAAI,EAAE,8CAA8C,CAAC;IACrD,OAAO,EAAE,qBAAqB,CAAC,wBAAwB,CAAC,CAAC;CAC1D,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,4CAA4C,GAAG;IACzD,IAAI,EAAE,yCAAyC,CAAC;IAChD,OAAO,EAAE,qBAAqB,CAAC,mBAAmB,CAAC,CAAC;CACrD,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,yCAAyC,GAAG;IACtD,IAAI,EAAE,sCAAsC,CAAC;IAC7C,OAAO,EAAE,qBAAqB,CAAC,gBAAgB,CAAC,CAAC;CAClD,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,iCAAiC,GAAG;IAC9C,IAAI,EAAE,8BAA8B,CAAC;IACrC,OAAO,EAAE,qBAAqB,CAAC,QAAQ,CAAC,CAAC;CAC1C,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,gCAAgC,GAAG;IAC7C,IAAI,EAAE,6BAA6B,CAAC;IACpC,OAAO,EAAE,qBAAqB,CAAC,OAAO,CAAC,CAAC;CACzC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,mCAAmC,GAAG;IAChD,IAAI,EAAE,gCAAgC,CAAC;IACvC,OAAO,EAAE,qBAAqB,CAAC,UAAU,CAAC,CAAC;CAC5C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,kCAAkC,GAC1C,mCAAmC,GACnC,+CAA+C,GAC/C,4CAA4C,GAC5C,iDAAiD,GACjD,4CAA4C,GAC5C,yCAAyC,GACzC,iCAAiC,GACjC,gCAAgC,GAChC,mCAAmC,CAAC"}
1
+ {"version":3,"file":"MfaRecoveryController-method-action-types.d.ts","sourceRoot":"","sources":["../src/MfaRecoveryController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAExE;;;;;;GAMG;AACH,MAAM,MAAM,mCAAmC,GAAG;IAChD,IAAI,EAAE,gCAAgC,CAAC;IACvC,OAAO,EAAE,qBAAqB,CAAC,UAAU,CAAC,CAAC;CAC5C,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,+CAA+C,GAAG;IAC5D,IAAI,EAAE,4CAA4C,CAAC;IACnD,OAAO,EAAE,qBAAqB,CAAC,sBAAsB,CAAC,CAAC;CACxD,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,4CAA4C,GAAG;IACzD,IAAI,EAAE,yCAAyC,CAAC;IAChD,OAAO,EAAE,qBAAqB,CAAC,mBAAmB,CAAC,CAAC;CACrD,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,iDAAiD,GAAG;IAC9D,IAAI,EAAE,8CAA8C,CAAC;IACrD,OAAO,EAAE,qBAAqB,CAAC,wBAAwB,CAAC,CAAC;CAC1D,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,4CAA4C,GAAG;IACzD,IAAI,EAAE,yCAAyC,CAAC;IAChD,OAAO,EAAE,qBAAqB,CAAC,mBAAmB,CAAC,CAAC;CACrD,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,yCAAyC,GAAG;IACtD,IAAI,EAAE,sCAAsC,CAAC;IAC7C,OAAO,EAAE,qBAAqB,CAAC,gBAAgB,CAAC,CAAC;CAClD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,iCAAiC,GAAG;IAC9C,IAAI,EAAE,8BAA8B,CAAC;IACrC,OAAO,EAAE,qBAAqB,CAAC,QAAQ,CAAC,CAAC;CAC1C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,gCAAgC,GAAG;IAC7C,IAAI,EAAE,6BAA6B,CAAC;IACpC,OAAO,EAAE,qBAAqB,CAAC,OAAO,CAAC,CAAC;CACzC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,mCAAmC,GAAG;IAChD,IAAI,EAAE,gCAAgC,CAAC;IACvC,OAAO,EAAE,qBAAqB,CAAC,UAAU,CAAC,CAAC;CAC5C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,kCAAkC,GAC1C,mCAAmC,GACnC,+CAA+C,GAC/C,4CAA4C,GAC5C,iDAAiD,GACjD,4CAA4C,GAC5C,yCAAyC,GACzC,iCAAiC,GACjC,gCAAgC,GAChC,mCAAmC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"MfaRecoveryController-method-action-types.js","sourceRoot":"","sources":["../src/MfaRecoveryController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { MfaRecoveryController } from './MfaRecoveryController.js';\n\n/**\n * Creates version 1 of a recovery record.\n *\n * @param recoverySecret - Secret replicated in full to every escrow.\n * @param identifiers - Ownership-approved identifier set. Must contain at\n * least two identifiers.\n */\nexport type MfaRecoveryControllerRegisterAction = {\n type: `MfaRecoveryController:register`;\n handler: MfaRecoveryController['register'];\n};\n\n/**\n * Replaces the recovery secret.\n *\n * @param identifier - Currently registered identifier used to authorize.\n * @param recoverySecret - New secret.\n * @param epoch - Current recovery version, used as `expectedVersion`.\n */\nexport type MfaRecoveryControllerUpdateRecoverySecretAction = {\n type: `MfaRecoveryController:updateRecoverySecret`;\n handler: MfaRecoveryController['updateRecoverySecret'];\n};\n\n/**\n * Replaces the complete identifier set.\n *\n * @param identifier - Currently registered identifier used to authorize.\n * @param identifiers - New identifier set. Must contain at least two\n * identifiers.\n * @param epoch - Current recovery version, used as `expectedVersion`.\n */\nexport type MfaRecoveryControllerUpdateIdentifiersAction = {\n type: `MfaRecoveryController:updateIdentifiers`;\n handler: MfaRecoveryController['updateIdentifiers'];\n};\n\n/**\n * Authenticates an identifier for a subsequent recovery-secret read.\n *\n * @param identifier - Identifier to authenticate.\n * @returns Ephemeral session data required by {@link getRecoverySecret}.\n */\nexport type MfaRecoveryControllerAuthenticateIdentifierAction = {\n type: `MfaRecoveryController:authenticateIdentifier`;\n handler: MfaRecoveryController['authenticateIdentifier'];\n};\n\n/**\n * Reads the recovery secret from available escrows and returns the highest\n * consistent version. `epoch` is the current recovery version and is required\n * by later mutations. Does not wait for a pending mutation to be repaired.\n *\n * @param session - Identifier authentication session used to authorize the\n * read.\n * @returns Recovered secret bytes and the selected epoch.\n */\nexport type MfaRecoveryControllerGetRecoverySecretAction = {\n type: `MfaRecoveryController:getRecoverySecret`;\n handler: MfaRecoveryController['getRecoverySecret'];\n};\n\n/**\n * Reads the enrolled identifiers from available escrows at the highest\n * consistent version, with Auth's current identifiers. Needs no recent MFA,\n * so a new device can build an {@link updateIdentifiers} call from it.\n *\n * @returns Enrolled identifiers, `epoch`, and Auth's identifiers.\n */\nexport type MfaRecoveryControllerGetIdentifiersAction = {\n type: `MfaRecoveryController:getIdentifiers`;\n handler: MfaRecoveryController['getIdentifiers'];\n};\n\n/**\n * Completes a persisted pending mutation, if any. Clears a `writing` one,\n * throwing `MutationRejectedError`, once its approval has expired and no\n * escrow applied it.\n */\nexport type MfaRecoveryControllerResumeAction = {\n type: `MfaRecoveryController:resume`;\n handler: MfaRecoveryController['resume'];\n};\n\n/**\n * Drops `authorizing` pending. Drops `writing` pending only once its approval\n * has expired and no escrow applied it; otherwise finish it with\n * {@link resume}.\n */\nexport type MfaRecoveryControllerAbortAction = {\n type: `MfaRecoveryController:abort`;\n handler: MfaRecoveryController['abort'];\n};\n\n/**\n * @returns Current recovery phase.\n */\nexport type MfaRecoveryControllerGetPhaseAction = {\n type: `MfaRecoveryController:getPhase`;\n handler: MfaRecoveryController['getPhase'];\n};\n\n/**\n * Union of all MfaRecoveryController action types.\n */\nexport type MfaRecoveryControllerMethodActions =\n | MfaRecoveryControllerRegisterAction\n | MfaRecoveryControllerUpdateRecoverySecretAction\n | MfaRecoveryControllerUpdateIdentifiersAction\n | MfaRecoveryControllerAuthenticateIdentifierAction\n | MfaRecoveryControllerGetRecoverySecretAction\n | MfaRecoveryControllerGetIdentifiersAction\n | MfaRecoveryControllerResumeAction\n | MfaRecoveryControllerAbortAction\n | MfaRecoveryControllerGetPhaseAction;\n"]}
1
+ {"version":3,"file":"MfaRecoveryController-method-action-types.js","sourceRoot":"","sources":["../src/MfaRecoveryController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { MfaRecoveryController } from './MfaRecoveryController.js';\n\n/**\n * Creates version 1 of a recovery record.\n *\n * @param recoverySecret - Secret replicated in full to every escrow.\n * @param identifiers - Ownership-approved identifier set. Must contain at\n * least two identifiers.\n */\nexport type MfaRecoveryControllerRegisterAction = {\n type: `MfaRecoveryController:register`;\n handler: MfaRecoveryController['register'];\n};\n\n/**\n * Replaces the recovery secret.\n *\n * @param identifier - Currently registered identifier used to authorize.\n * @param recoverySecret - New secret.\n * @param epoch - Current recovery version, used as `expectedVersion`.\n */\nexport type MfaRecoveryControllerUpdateRecoverySecretAction = {\n type: `MfaRecoveryController:updateRecoverySecret`;\n handler: MfaRecoveryController['updateRecoverySecret'];\n};\n\n/**\n * Replaces the complete identifier set.\n *\n * @param identifier - Currently registered identifier used to authorize.\n * @param identifiers - New identifier set. Must contain at least two\n * identifiers.\n * @param epoch - Current recovery version, used as `expectedVersion`.\n */\nexport type MfaRecoveryControllerUpdateIdentifiersAction = {\n type: `MfaRecoveryController:updateIdentifiers`;\n handler: MfaRecoveryController['updateIdentifiers'];\n};\n\n/**\n * Authenticates an identifier for a subsequent recovery-secret read.\n *\n * @param identifier - Identifier to authenticate.\n * @returns Ephemeral session data required by {@link getRecoverySecret}.\n */\nexport type MfaRecoveryControllerAuthenticateIdentifierAction = {\n type: `MfaRecoveryController:authenticateIdentifier`;\n handler: MfaRecoveryController['authenticateIdentifier'];\n};\n\n/**\n * Reads the recovery secret from available escrows and returns the highest\n * consistent version. `epoch` is the current recovery version and is required\n * by later mutations. Does not wait for a pending mutation to be repaired.\n *\n * @param session - Identifier authentication session used to authorize the\n * read.\n * @returns Recovered secret bytes and the selected epoch.\n */\nexport type MfaRecoveryControllerGetRecoverySecretAction = {\n type: `MfaRecoveryController:getRecoverySecret`;\n handler: MfaRecoveryController['getRecoverySecret'];\n};\n\n/**\n * Reads the enrolled identifiers from available escrows at the highest\n * consistent version, with Auth's current identifiers. Needs no recent MFA,\n * so a new device can build an {@link updateIdentifiers} call from it.\n *\n * @returns Enrolled identifiers, `epoch`, and Auth's identifiers.\n */\nexport type MfaRecoveryControllerGetIdentifiersAction = {\n type: `MfaRecoveryController:getIdentifiers`;\n handler: MfaRecoveryController['getIdentifiers'];\n};\n\n/**\n * Completes a persisted pending mutation, if any.\n */\nexport type MfaRecoveryControllerResumeAction = {\n type: `MfaRecoveryController:resume`;\n handler: MfaRecoveryController['resume'];\n};\n\n/**\n * Drops `authorizing` pending. `writing` must be finished with {@link resume}.\n */\nexport type MfaRecoveryControllerAbortAction = {\n type: `MfaRecoveryController:abort`;\n handler: MfaRecoveryController['abort'];\n};\n\n/**\n * @returns Current recovery phase.\n */\nexport type MfaRecoveryControllerGetPhaseAction = {\n type: `MfaRecoveryController:getPhase`;\n handler: MfaRecoveryController['getPhase'];\n};\n\n/**\n * Union of all MfaRecoveryController action types.\n */\nexport type MfaRecoveryControllerMethodActions =\n | MfaRecoveryControllerRegisterAction\n | MfaRecoveryControllerUpdateRecoverySecretAction\n | MfaRecoveryControllerUpdateIdentifiersAction\n | MfaRecoveryControllerAuthenticateIdentifierAction\n | MfaRecoveryControllerGetRecoverySecretAction\n | MfaRecoveryControllerGetIdentifiersAction\n | MfaRecoveryControllerResumeAction\n | MfaRecoveryControllerAbortAction\n | MfaRecoveryControllerGetPhaseAction;\n"]}
@@ -111,15 +111,11 @@ export declare class MfaRecoveryController extends BaseController<typeof CONTROL
111
111
  */
112
112
  getIdentifiers(): Promise<RecoveryIdentifiers>;
113
113
  /**
114
- * Completes a persisted pending mutation, if any. Clears a `writing` one,
115
- * throwing `MutationRejectedError`, once its approval has expired and no
116
- * escrow applied it.
114
+ * Completes a persisted pending mutation, if any.
117
115
  */
118
116
  resume(): Promise<void>;
119
117
  /**
120
- * Drops `authorizing` pending. Drops `writing` pending only once its approval
121
- * has expired and no escrow applied it; otherwise finish it with
122
- * {@link resume}.
118
+ * Drops `authorizing` pending. `writing` must be finished with {@link resume}.
123
119
  */
124
120
  abort(): Promise<void>;
125
121
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"MfaRecoveryController.d.ts","sourceRoot":"","sources":["../src/MfaRecoveryController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACxB,2BAA2B,EAE5B,MAAM,2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AC,CAgE1B;IAED;;;;;;OAMG;IACG,cAAc,IAAI,OAAO,CAAC,mBAAmB,CAAC,CAuCnD;IAED;;OAEG;IACG,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CAI5B;IAED;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAQ3B;IAED;;OAEG;IACG,QAAQ,IAAI,OAAO,CAAC,aAAa,CAAC,CAIvC;CAyXF"}
@@ -1,12 +1,12 @@
1
1
  import { BaseController } from '@metamask/base-controller';
2
- import { bytesToHex, hexToBytes, isHexAddress } from '@metamask/utils';
2
+ import { bytesToHex, hexToBytes } from '@metamask/utils';
3
3
  import { decodeAuthControllerToken } from './auth-controller-token.js';
4
4
  import { decryptFromPublic, encryptToPublic, generateWrapKey, hash, randomId, unixNow, wrapKeyId, } from './crypto.js';
5
5
  import { IncompleteMutationError, MfaRecoveryError, MutationRejectedError, } from './errors.js';
6
6
  import { isFulfilledResult, isMutationReceipt, selectHighestConsistentVersion, verifyMutationReceipt, } from './escrow-utils.js';
7
- import { authorizeEscrowsWithToken, countDistinctIdentifiers, getIdentifierAuthMode, getSiweNamespace, MAX_IDENTIFIERS, MIN_IDENTIFIERS, requestKeyBoundIdentifierToken, } from './identifier-auth.js';
7
+ import { authorizeEscrowsWithToken, countDistinctIdentifiers, getIdentifierAuthMode, MIN_IDENTIFIERS, requestKeyBoundIdentifierToken, } from './identifier-auth.js';
8
8
  import { assertValidPendingOperation, pendingPayloadHasIdentifiers, pendingPayloadHasRecoverySecret, } from './pending-operation-validation.js';
9
- import { getRecoveryPhase } from './state-machine.js';
9
+ import { assertAbortAllowed, getRecoveryPhase } from './state-machine.js';
10
10
  const CONTROLLER_NAME = 'MfaRecoveryController';
11
11
  const MESSENGER_EXPOSED_METHODS = [
12
12
  'register',
@@ -75,8 +75,8 @@ export class MfaRecoveryController extends BaseController {
75
75
  * least two identifiers.
76
76
  */
77
77
  async register(recoverySecret, identifiers) {
78
- this.#assertValidIdentifiers(identifiers);
79
- this.#assertIdentifierSet(identifiers);
78
+ this.#assertKnownIdentifierTypes(identifiers);
79
+ this.#assertMinIdentifiers(identifiers);
80
80
  await this.#mutate({
81
81
  operation: 'register',
82
82
  payload: {
@@ -95,7 +95,7 @@ export class MfaRecoveryController extends BaseController {
95
95
  * @param epoch - Current recovery version, used as `expectedVersion`.
96
96
  */
97
97
  async updateRecoverySecret(identifier, recoverySecret, epoch) {
98
- this.#assertValidIdentifiers([identifier]);
98
+ this.#assertKnownIdentifierTypes([identifier]);
99
99
  await this.#mutate({
100
100
  operation: 'updateRecoverySecret',
101
101
  payload: {
@@ -114,8 +114,8 @@ export class MfaRecoveryController extends BaseController {
114
114
  * @param epoch - Current recovery version, used as `expectedVersion`.
115
115
  */
116
116
  async updateIdentifiers(identifier, identifiers, epoch) {
117
- this.#assertValidIdentifiers([identifier, ...identifiers]);
118
- this.#assertIdentifierSet(identifiers);
117
+ this.#assertKnownIdentifierTypes([identifier, ...identifiers]);
118
+ this.#assertMinIdentifiers(identifiers);
119
119
  await this.#mutate({
120
120
  operation: 'updateIdentifiers',
121
121
  payload: { identifiers },
@@ -130,7 +130,7 @@ export class MfaRecoveryController extends BaseController {
130
130
  * @returns Ephemeral session data required by {@link getRecoverySecret}.
131
131
  */
132
132
  async authenticateIdentifier(identifier) {
133
- this.#assertValidIdentifiers([identifier]);
133
+ this.#assertKnownIdentifierTypes([identifier]);
134
134
  const requestId = randomId();
135
135
  const ephemeral = await generateWrapKey();
136
136
  const pkE = ephemeral.publicKey;
@@ -163,7 +163,7 @@ export class MfaRecoveryController extends BaseController {
163
163
  async getRecoverySecret(session) {
164
164
  return await this.#withLock(async () => {
165
165
  const { token, requestId, pkE } = session;
166
- this.#assertValidIdentifiers([token.identifier]);
166
+ this.#assertKnownIdentifierTypes([token.identifier]);
167
167
  const requestHash = await hash({
168
168
  operation: 'getRecoverySecret',
169
169
  requestId,
@@ -183,11 +183,10 @@ export class MfaRecoveryController extends BaseController {
183
183
  });
184
184
  const authorizedEscrows = await authorizeEscrowsWithToken({
185
185
  escrows: available,
186
- credentials: [session],
186
+ credential: session,
187
187
  authControllerToken: approval,
188
188
  });
189
- const results = await Promise.allSettled(authorizedEscrows.map(async ({ escrow, authorizations }) => {
190
- const [authorization] = authorizations;
189
+ const results = await Promise.allSettled(authorizedEscrows.map(async ({ escrow, authorization }) => {
191
190
  const response = await escrow.getSecret(approval, authorization, requestId, pkE);
192
191
  if (response.wrapKeyId !== (await wrapKeyId(escrow.wrapPublicKey))) {
193
192
  throw new MfaRecoveryError('Unexpected wrap key', 'wrap_key_mismatch');
@@ -219,8 +218,11 @@ export class MfaRecoveryController extends BaseController {
219
218
  if (available.length === 0) {
220
219
  throw new MfaRecoveryError('No escrow is available', 'no_available_escrow');
221
220
  }
222
- const { authIdentifiers, results } = await this.#authorizeAndReadIdentifiers(available);
223
- const responses = results
221
+ const { approval, identifiers: authIdentifiers } = await this.#authProvider.authorizeRecoveryRequest({
222
+ requestHash: await hash({ operation: 'getIdentifiers' }),
223
+ audiences: available.map((escrow) => escrow.authAudience),
224
+ });
225
+ const responses = (await Promise.allSettled(available.map(async (escrow) => await escrow.getIdentifiers(approval))))
224
226
  .filter(isFulfilledResult)
225
227
  .map((result) => result.value);
226
228
  if (responses.length === 0) {
@@ -236,9 +238,7 @@ export class MfaRecoveryController extends BaseController {
236
238
  });
237
239
  }
238
240
  /**
239
- * Completes a persisted pending mutation, if any. Clears a `writing` one,
240
- * throwing `MutationRejectedError`, once its approval has expired and no
241
- * escrow applied it.
241
+ * Completes a persisted pending mutation, if any.
242
242
  */
243
243
  async resume() {
244
244
  await this.#withLock(async () => {
@@ -246,16 +246,12 @@ export class MfaRecoveryController extends BaseController {
246
246
  });
247
247
  }
248
248
  /**
249
- * Drops `authorizing` pending. Drops `writing` pending only once its approval
250
- * has expired and no escrow applied it; otherwise finish it with
251
- * {@link resume}.
249
+ * Drops `authorizing` pending. `writing` must be finished with {@link resume}.
252
250
  */
253
251
  async abort() {
254
252
  await this.#withLock(async () => {
255
253
  const pending = await this.#loadPending();
256
- if (pending?.phase === 'writing' && !(await this.#isUnapplied(pending))) {
257
- throw new MfaRecoveryError('Cannot abort a mutation that may have been applied', 'abort_not_allowed');
258
- }
254
+ assertAbortAllowed(pending);
259
255
  if (pending) {
260
256
  await this.#clearPending();
261
257
  }
@@ -267,25 +263,6 @@ export class MfaRecoveryController extends BaseController {
267
263
  async getPhase() {
268
264
  return await this.#withLock(async () => getRecoveryPhase(await this.#loadPending()));
269
265
  }
270
- // No write can land after its approval expires, and escrow versions only
271
- // grow, so every escrow below `newVersion` means none applied it.
272
- async #isUnapplied({ mutation, authControllerToken, }) {
273
- const claims = decodeAuthControllerToken(authControllerToken);
274
- if (claims && claims.exp > this.#now()) {
275
- return false;
276
- }
277
- const { results } = await this.#authorizeAndReadIdentifiers(this.#escrows);
278
- return results.every((result) => isFulfilledResult(result) && result.value.version < mutation.newVersion);
279
- }
280
- // Read approvals need no 2FA.
281
- async #authorizeAndReadIdentifiers(escrows) {
282
- const { approval, identifiers } = await this.#authProvider.authorizeRecoveryRequest({
283
- requestHash: await hash({ operation: 'getIdentifiers' }),
284
- audiences: escrows.map((escrow) => escrow.authAudience),
285
- });
286
- const results = await Promise.allSettled(escrows.map(async (escrow) => await escrow.getIdentifiers(approval)));
287
- return { authIdentifiers: identifiers, results };
288
- }
289
266
  async #mutate(params) {
290
267
  const { operation, payload, identifier, epoch } = params;
291
268
  await this.#withLock(async () => {
@@ -348,15 +325,11 @@ export class MfaRecoveryController extends BaseController {
348
325
  });
349
326
  return;
350
327
  }
351
- // writing phase. Renewing would only prompt for MFA again.
352
- if (await this.#isUnapplied(pending)) {
353
- await this.#clearPending();
354
- throw new MutationRejectedError('No escrow applied the mutation before its approval expired');
355
- }
328
+ // writing phase
356
329
  await this.#replicateMutation(pending);
357
330
  }
358
331
  async #replicateMutation(pending) {
359
- const { mutation } = pending;
332
+ const { mutation, identifier } = pending;
360
333
  const remainingEscrows = await this.#getRemainingEscrows(pending);
361
334
  if (remainingEscrows.length === 0) {
362
335
  await this.#clearPending();
@@ -368,10 +341,21 @@ export class MfaRecoveryController extends BaseController {
368
341
  ? pending
369
342
  : { ...pending, ...(await this.#authorizeMutation(mutation)) };
370
343
  await this.#assertPending(writing);
371
- const authorizations = await this.#authorizeEscrows(writing, remainingEscrows);
344
+ const authorizedEscrows = mutation.operation === 'register'
345
+ ? null
346
+ : await this.#authorizeEscrows({
347
+ escrows: remainingEscrows,
348
+ identifier: identifier,
349
+ requestHash: mutation.requestHash,
350
+ authControllerToken: writing.authControllerToken,
351
+ });
352
+ if (authorizedEscrows !== null &&
353
+ authorizedEscrows.length !== remainingEscrows.length) {
354
+ throw new MfaRecoveryError('Unable to authorize every escrow', 'identifier_auth_failed');
355
+ }
372
356
  const payloads = await Promise.all(remainingEscrows.map(async (escrow) => this.#payloadForEscrow(writing, escrow)));
373
357
  await this.#persistPending(writing);
374
- const results = await Promise.allSettled(remainingEscrows.map((escrow, index) => escrow.applyMutation(mutation, writing.authControllerToken, authorizations[index], payloads[index], writing.approvedIdentifiers)));
358
+ const results = await Promise.allSettled(remainingEscrows.map((escrow, index) => escrow.applyMutation(mutation, writing.authControllerToken, authorizedEscrows?.[index]?.authorization ?? null, payloads[index], writing.approvedIdentifiers)));
375
359
  const { receipts, hasInvalidReceipt } = await this.#collectMutationReceipts(results, remainingEscrows, mutation, writing.receipts);
376
360
  const rejection = unanimousMutationRejection(results, writing.receipts);
377
361
  if (rejection) {
@@ -431,57 +415,18 @@ export class MfaRecoveryController extends BaseController {
431
415
  }
432
416
  return { receipts, hasInvalidReceipt };
433
417
  }
434
- /**
435
- * Proves the update's enrolled identifier and each SIWE identifier the
436
- * escrows have not enrolled, all against one challenge per escrow.
437
- *
438
- * @param writing - Writing pending mutation.
439
- * @param escrows - Escrows to authorize.
440
- * @returns Each escrow's identifier authorizations, in `escrows` order.
441
- */
442
- async #authorizeEscrows(writing, escrows) {
443
- const identifiers = [
444
- ...(writing.identifier ? [writing.identifier] : []),
445
- ...(await this.#findNewSiweIdentifiers(writing, escrows)),
446
- ];
447
- if (identifiers.length === 0) {
448
- return escrows.map(() => []);
449
- }
450
- const credentials = [];
451
- for (const identifier of identifiers) {
452
- getIdentifierAuthMode(identifier.type);
453
- credentials.push(await requestKeyBoundIdentifierToken({
454
- identifier,
455
- requestHash: writing.mutation.requestHash,
456
- identifierAuthProvider: this.#identifierAuthProvider,
457
- }));
458
- }
459
- const authorized = await authorizeEscrowsWithToken({
418
+ async #authorizeEscrows({ escrows, identifier, requestHash, authControllerToken, }) {
419
+ getIdentifierAuthMode(identifier.type);
420
+ const credential = await requestKeyBoundIdentifierToken({
421
+ identifier,
422
+ requestHash,
423
+ identifierAuthProvider: this.#identifierAuthProvider,
424
+ });
425
+ return await authorizeEscrowsWithToken({
460
426
  escrows,
461
- credentials,
462
- authControllerToken: writing.authControllerToken,
427
+ credential,
428
+ authControllerToken,
463
429
  });
464
- if (authorized.length !== escrows.length) {
465
- throw new MfaRecoveryError('Unable to authorize every escrow', 'identifier_auth_failed');
466
- }
467
- return authorized.map(({ authorizations }) => authorizations);
468
- }
469
- // SIWE identifiers some escrow has not enrolled. Escrows that already
470
- // applied the mutation replay their receipt and ignore the extra proofs.
471
- async #findNewSiweIdentifiers({ mutation, payload, authControllerToken }, escrows) {
472
- const siweIdentifiers = pendingPayloadHasIdentifiers(payload)
473
- ? payload.identifiers.filter(({ type }) => type === 'siwe')
474
- : [];
475
- if (mutation.operation === 'register' || siweIdentifiers.length === 0) {
476
- return siweIdentifiers;
477
- }
478
- const responses = await Promise.all(escrows.map((escrow) => escrow.getIdentifiers(authControllerToken)));
479
- const enrolledPerEscrow = responses.map(({ identifiers }) => identifiers);
480
- // Escrows compare SIWE addresses case-insensitively.
481
- const isEnrolledInEveryEscrow = ({ namespace, value, }) => enrolledPerEscrow.every((enrolled) => enrolled.some((other) => other.type === 'siwe' &&
482
- other.namespace === namespace &&
483
- other.value.toLowerCase() === value.toLowerCase()));
484
- return siweIdentifiers.filter((identifier) => !isEnrolledInEveryEscrow(identifier));
485
430
  }
486
431
  async #payloadForEscrow(pending, escrow) {
487
432
  const { payload } = pending;
@@ -514,27 +459,15 @@ export class MfaRecoveryController extends BaseController {
514
459
  ? [result.value.escrow]
515
460
  : []);
516
461
  }
517
- #assertValidIdentifiers(identifiers) {
462
+ #assertKnownIdentifierTypes(identifiers) {
518
463
  for (const identifier of identifiers) {
519
464
  getIdentifierAuthMode(identifier.type);
520
- if (identifier.type === 'siwe' &&
521
- (!isHexAddress(identifier.value.toLowerCase()) ||
522
- identifier.namespace !== getSiweNamespace(identifier))) {
523
- throw new MfaRecoveryError('SIWE value must be an address and namespace the verifier domain:chainId', 'invalid_identifier');
524
- }
525
465
  }
526
466
  }
527
- #assertIdentifierSet(identifiers) {
528
- const distinct = countDistinctIdentifiers(identifiers);
529
- if (distinct < MIN_IDENTIFIERS) {
467
+ #assertMinIdentifiers(identifiers) {
468
+ if (countDistinctIdentifiers(identifiers) < MIN_IDENTIFIERS) {
530
469
  throw new MfaRecoveryError(`Requires at least ${MIN_IDENTIFIERS} identifiers`, 'too_few_identifiers');
531
470
  }
532
- if (distinct !== identifiers.length) {
533
- throw new MfaRecoveryError('Duplicate identifier', 'duplicate_identifier');
534
- }
535
- if (identifiers.length > MAX_IDENTIFIERS) {
536
- throw new MfaRecoveryError(`Supports at most ${MAX_IDENTIFIERS} identifiers`, 'too_many_identifiers');
537
- }
538
471
  }
539
472
  async #wrapRecoverySecret(plaintext, wrapPublicKey) {
540
473
  const ephemeral = await generateWrapKey();