Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/profile-sync-controller/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Resolve HD entropy source IDs from `KeyringController` instead of the message-signing snap (`getBearerToken` primary ID, `performSignIn` SRP enumeration) ([#9794](https://github.com/MetaMask/core/pull/9794))
- Bump `@metamask/keyring-controller` from `^27.1.0` to `^27.1.1` ([#9791](https://github.com/MetaMask/core/pull/9791))
- Add `@metamask/key-tree` and `@noble/curves`; remove unused `@metamask/snaps-controllers`, `@metamask/snaps-sdk`, and `@metamask/snaps-utils` dependencies ([#9824](https://github.com/MetaMask/core/pull/9824))
- Bump `@metamask/utils` from `^11.11.0` to `^11.12.0` ([#10076](https://github.com/MetaMask/core/pull/10076))
- Bump `@metamask/utils` from `^11.11.0` to `^11.12.0` ([#10076](10076))
- `AuthenticationControllerMessenger` does not require `KeyringController:unlock` or `KeyringController:lock` events anymore ([#0000](https://github.com/MetaMask/core/pull/0000))

## [29.0.0]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
} from '@metamask/base-controller';
import type {
KeyringControllerGetStateAction,
KeyringControllerLockEvent,

Check failure on line 9 in packages/profile-sync-controller/src/controllers/authentication/AuthenticationController.ts

View workflow job for this annotation

GitHub Actions / Lint, build, and test / Lint (lint:eslint) (24.x)

'KeyringControllerLockEvent' is defined but never used
KeyringControllerUnlockEvent,

Check failure on line 10 in packages/profile-sync-controller/src/controllers/authentication/AuthenticationController.ts

View workflow job for this annotation

GitHub Actions / Lint, build, and test / Lint (lint:eslint) (24.x)

'KeyringControllerUnlockEvent' is defined but never used
KeyringControllerWithKeyringV2UnsafeAction,
} from '@metamask/keyring-controller';
import type { Messenger } from '@metamask/messenger';
Expand Down Expand Up @@ -159,7 +159,7 @@
| KeyringControllerWithKeyringV2UnsafeAction
| SeedlessOnboardingControllerGetStateAction;

type AllowedEvents = KeyringControllerLockEvent | KeyringControllerUnlockEvent;
type AllowedEvents = never;

// Messenger
export type AuthenticationControllerMessenger = Messenger<
Expand All @@ -185,28 +185,11 @@
env: Env.PRD,
};

#isUnlocked = false;

// Bumped by `requestProfilePairing`. `performSignIn` snapshots this
// before its first await; if it changes mid-flight we must NOT clear
// `needsProfilePairing` (the rearm signal wins).
#profilePairingRequestEpoch = 0;

readonly #keyringController = {
setupLockedStateSubscriptions: () => {
const { isUnlocked } = this.messenger.call('KeyringController:getState');
this.#isUnlocked = isUnlocked;

this.messenger.subscribe('KeyringController:unlock', () => {
this.#isUnlocked = true;
});

this.messenger.subscribe('KeyringController:lock', () => {
this.#isUnlocked = false;
});
},
};

constructor({
messenger,
state,
Expand Down Expand Up @@ -261,8 +244,6 @@
},
);

this.#keyringController.setupLockedStateSubscriptions();

this.messenger.registerMethodActionHandlers(
this,
MESSENGER_EXPOSED_METHODS,
Expand Down Expand Up @@ -301,7 +282,8 @@
}

#assertIsUnlocked(methodName: string): void {
if (!this.#isUnlocked) {
const { isUnlocked } = this.messenger.call('KeyringController:getState');
if (!isUnlocked) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Locked-wallet test still uses events

Medium Severity

#assertIsUnlocked now reads isUnlocked from KeyringController:getState, but the performSignIn locked-wallet test still publishes KeyringController:lock and KeyringController:unlock while the getState mock stays isUnlocked: true. Sign-in therefore succeeds after lock, so the test fails and no longer covers the locked path.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit fe8ba53. Configure here.

throw new Error(`${methodName} - unable to proceed, wallet is locked`);
}
}
Expand Down
Loading