Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PM-15584] Fix autoprompt safari process reload #12352

Merged
merged 143 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
143 commits
Select commit Hold shift + click to select a range
a3c1e06
Move ownership of biometrics to key-management
quexten Aug 30, 2024
a3be922
Move biometrics ipc ownership to km
quexten Aug 30, 2024
2f63ffa
Move further files to km; split off preload / ipc to km
quexten Aug 30, 2024
9ad0a73
Fix linting
quexten Aug 30, 2024
d75aa3e
Fix linting
quexten Aug 30, 2024
91fd69c
Fix tests
quexten Sep 2, 2024
efee7f7
Extract biometric messaging service
quexten Sep 3, 2024
44e8927
Fix tests
quexten Sep 3, 2024
0f8763d
Merge branch 'main' into km/pm-8836/move-biometrics-to-km-ownership
quexten Sep 4, 2024
1a9dfbc
Merge branch 'km/pm-8836/move-biometrics-to-km-ownership' into km/pm-โ€ฆ
quexten Sep 4, 2024
672099c
Update .github/CODEOWNERS
quexten Sep 4, 2024
8661112
Update .github/CODEOWNERS
quexten Sep 4, 2024
77c53f7
Change ownership of native messaging to key-management
quexten Sep 4, 2024
86faebb
Merge branch 'km/pm-8836/move-biometrics-to-km-ownership' into km/pm-โ€ฆ
quexten Sep 4, 2024
be028b7
Initial refactor
quexten Sep 9, 2024
3c4ddab
Initial refactor
quexten Sep 9, 2024
3edcdd6
Continued refactor
quexten Sep 10, 2024
9f583e9
Continued refactor
quexten Sep 10, 2024
e276b5e
Add message for when biometric unlock is not configured in desktop app
quexten Sep 10, 2024
ddb7e62
Clean up lock component
quexten Sep 11, 2024
489f07c
Clean up lock component html
quexten Sep 11, 2024
1255e64
Merge branch 'main' into km/pm-8836/move-biometrics-to-km-ownership
quexten Sep 11, 2024
2490409
Merge branch 'km/pm-8836/move-biometrics-to-km-ownership' into km/pm-โ€ฆ
quexten Sep 11, 2024
5a8dd36
Fix build
quexten Sep 13, 2024
995376c
Fix status for windows and linux
quexten Sep 13, 2024
62f65aa
Continue refactor
quexten Sep 15, 2024
68e7f2f
Refactor browser
quexten Sep 15, 2024
ea03746
Fix unlock on extensions and add message enums
quexten Sep 16, 2024
8144973
Implement safari and fix setup
quexten Sep 16, 2024
66b971b
Fix cli and web
quexten Sep 16, 2024
1d9215b
Make tests pass
quexten Sep 16, 2024
8dbf7b0
Add backward compatibility
quexten Sep 17, 2024
49843cf
Fix version incompatibility
quexten Sep 17, 2024
b506837
Clean up auto-bio-prompt on desktop
quexten Sep 18, 2024
edf94af
Fix biometric auto prompt on browser
quexten Sep 18, 2024
d9b2ca7
Fix tests
quexten Sep 18, 2024
20a986e
Remove logging
quexten Sep 18, 2024
9703970
Add null in return type of unlockwithbiometricsforuser
quexten Sep 18, 2024
d931552
Move biometrics to libs/key-management
quexten Sep 22, 2024
1cf0603
Add README to capital whitelist
quexten Sep 22, 2024
1d23d2b
Update package-lock.json
quexten Sep 22, 2024
c2e4ea2
Move km to key-management
quexten Sep 22, 2024
7d65374
Move km to key-management
quexten Sep 22, 2024
42a72e5
Merge branch 'main' into km/pm-8836/move-biometrics-to-km-ownership
quexten Sep 22, 2024
97e8772
Fix build for cli
quexten Sep 22, 2024
2235bb5
Import fixes
quexten Sep 22, 2024
aadefb4
Apply prettier fix
quexten Sep 22, 2024
dd5d411
Fix test
quexten Sep 22, 2024
2c01786
Import fixes
quexten Sep 22, 2024
f688e59
Import fixes
quexten Sep 22, 2024
9df20f1
Update libs/key-management/README.md
quexten Sep 23, 2024
0fd36e1
Update libs/key-management/package.json
quexten Sep 23, 2024
9c2acc7
Update lock file
quexten Sep 23, 2024
92e0413
Change imports to top level km package
quexten Sep 23, 2024
a07f4a5
Change import order
quexten Sep 23, 2024
cdd8e86
Fix cli build
quexten Sep 23, 2024
453a604
Remove debug logging
quexten Sep 23, 2024
51a709a
Fix user not showing in "notenabledinconnecteddesktopapp" helptext
quexten Sep 23, 2024
6767f23
Document autoprompt and enable it on manual account switch
quexten Sep 23, 2024
990115d
Fix build
quexten Sep 23, 2024
2f89be0
Merge branch 'km/pm-8836/move-biometrics-to-km-ownership' into km/pm-โ€ฆ
quexten Sep 23, 2024
b6203b7
Fix unlock on windows
quexten Sep 26, 2024
01b1c81
Rename duckduckgo message handler service
quexten Sep 27, 2024
d0d317b
Merge branch 'main' into km/pm-9823/extract-biometric-messaging-service
quexten Oct 2, 2024
c708661
Merge branch 'main' into km/pm-9823/extract-biometric-messaging-service
quexten Oct 2, 2024
94807c7
Fix merge conflicts
quexten Oct 2, 2024
d74580d
Fix codeowners
quexten Oct 2, 2024
4127afb
Fix biometric message handler naming
quexten Oct 2, 2024
30e0b5c
Update codeowners for renamed message handler service
quexten Oct 2, 2024
5e740f9
Merge branch 'main' into km/pm-9823/extract-biometric-messaging-service
quexten Oct 22, 2024
2f5a49d
Merge branch 'km/pm-9823/extract-biometric-messaging-service' into kmโ€ฆ
quexten Oct 22, 2024
9c2a855
Fix cli build error
quexten Oct 22, 2024
bc30d90
Fix browser build errors
quexten Oct 22, 2024
1f2266b
Fix tests and update lock components
quexten Oct 22, 2024
42cbf13
Fix linking
quexten Oct 22, 2024
359e6c7
Fix build error
quexten Oct 22, 2024
576185b
Fix build error
quexten Oct 22, 2024
296545d
Fix build error
quexten Oct 22, 2024
587cc35
Fix build error
quexten Oct 22, 2024
8d29f3e
Fix logging message
quexten Oct 23, 2024
fccf533
Merge branch 'main' into km/pm-9823/extract-biometric-messaging-service
quexten Oct 23, 2024
c64526c
Merge branch 'main' into km/pm-9823/extract-biometric-messaging-service
quexten Nov 5, 2024
a53aadc
Merge branch 'main' into km/pm-9823/extract-biometric-messaging-service
quexten Nov 5, 2024
539a485
Merge changes
quexten Nov 5, 2024
6492fc1
Fix conflicts
quexten Nov 5, 2024
ad1b75b
Add jsdoc to biometric status enum
quexten Nov 5, 2024
2f8a05d
Add jsdoc to biometric commands
quexten Nov 5, 2024
4751c75
Merge changes
quexten Nov 5, 2024
397c572
Remove unused initialization code
quexten Nov 5, 2024
422aebd
Fix incorrectly checked setup-required status in desktop settings comโ€ฆ
quexten Nov 5, 2024
9bb038e
Extract process reload when required
quexten Nov 5, 2024
b1d2762
Remvoe cryptoservice reference
quexten Nov 5, 2024
f69603f
Merge branch 'main' into km/pm-9823/extract-biometric-messaging-service
quexten Nov 5, 2024
f4daca1
Merge branch 'km/pm-9823/extract-biometric-messaging-service' into kmโ€ฆ
quexten Nov 5, 2024
915bc4f
Remove commented out tests
quexten Nov 5, 2024
0d185a9
Improve tests
quexten Nov 5, 2024
1624c4f
Fix build
quexten Nov 5, 2024
a4bb0a9
Fix tests
quexten Nov 5, 2024
e375f4b
Fix biometric unlock
quexten Nov 6, 2024
525bcfd
Fix errors from prior merge
quexten Nov 6, 2024
a15131f
Re-add tests
quexten Nov 6, 2024
281e7c6
Update lock component tests
quexten Nov 6, 2024
390b9cd
Add tests for process reload for biometric ipc unlock
quexten Nov 6, 2024
ccc4166
Merge branch 'main' into km/pm-10741/refactor-biometrics
quexten Nov 25, 2024
0f6ece8
Merge branch 'main' into km/pm-10741/refactor-biometrics
quexten Nov 26, 2024
7ed44d8
Fix autoprompt happening when it should not
quexten Nov 26, 2024
1bef741
Fix lock v2
quexten Nov 26, 2024
6c02282
Fix lint
quexten Nov 26, 2024
05d64bb
Merge branch 'main' into km/pm-10741/refactor-biometrics
quexten Dec 2, 2024
fd80fc5
Merge branch 'main' into km/pm-10741/refactor-biometrics
quexten Dec 2, 2024
7235c34
Update apps/browser/src/auth/popup/settings/account-security.componenโ€ฆ
quexten Dec 3, 2024
4eca9ba
Update apps/desktop/src/app/accounts/settings.component.ts
quexten Dec 3, 2024
50d22c6
Update apps/desktop/src/key-management/biometrics/main-biometrics.serโ€ฆ
quexten Dec 3, 2024
3082b99
Update libs/key-management/src/biometrics/biometric.service.ts
quexten Dec 3, 2024
7214e2c
Update libs/key-management/src/biometrics/biometrics-status.ts
quexten Dec 3, 2024
5fab0e7
Update apps/browser/src/background/nativeMessaging.background.ts
quexten Dec 3, 2024
b582fa3
Update apps/desktop/src/key-management/biometrics/main-biometrics.serโ€ฆ
quexten Dec 3, 2024
8dd9336
Cleanup
quexten Dec 3, 2024
88d2c5c
Merge branch 'main' into km/pm-10741/refactor-biometrics
quexten Dec 3, 2024
bcfaee3
Remove unavailabilityReason from UI
quexten Dec 9, 2024
526ea0f
Merge branch 'main' into km/pm-10741/refactor-biometrics
quexten Dec 9, 2024
02e3b31
Merge branch 'main' into km/pm-10741/refactor-biometrics
quexten Dec 9, 2024
dbd8945
Merge branch 'main' into km/pm-10741/refactor-biometrics
quexten Dec 10, 2024
0d4e30b
Merge branch 'km/pm-10741/refactor-biometrics' of github.com:bitwardeโ€ฆ
quexten Dec 10, 2024
40f15b9
Fix autoprompt safari process reload
quexten Dec 11, 2024
0e56334
Merge branch 'main' into km/pm-10741/refactor-biometrics
quexten Dec 12, 2024
e54427c
Apply changes according to feedback
quexten Dec 16, 2024
26983e7
Adjust PR according to feedback
quexten Dec 16, 2024
b851d1b
Address feedback
quexten Dec 16, 2024
41f641f
Fix account settings biometrics setting
quexten Dec 23, 2024
af2ecc0
Merge branch 'main' into km/pm-10741/refactor-biometrics
quexten Dec 23, 2024
e0610f6
Merge branch 'km/pm-10741/refactor-biometrics' into km/pm-15584/fix-sโ€ฆ
quexten Dec 23, 2024
6807cad
Fix build
quexten Dec 24, 2024
9d5758e
Cleanup
quexten Dec 24, 2024
8f89180
Merge branch 'km/pm-10741/refactor-biometrics' into km/pm-15584/fix-sโ€ฆ
quexten Dec 24, 2024
f197bf2
Fix incorrect merge
quexten Dec 24, 2024
c36793b
Merge branch 'km/pm-15584/fix-safari-biometrics' of github.com:bitwarโ€ฆ
quexten Dec 24, 2024
1fd97a8
Allow disabling biometrics in browser while desktop app is disconnected
quexten Dec 24, 2024
7a77cf7
Merge branch 'main' into km/pm-10741/refactor-biometrics
quexten Jan 6, 2025
90bee20
Merge branch 'km/pm-10741/refactor-biometrics' into km/pm-15584/fix-sโ€ฆ
quexten Jan 6, 2025
e85ad5f
Merge branch 'main' into km/pm-15584/fix-safari-biometrics
quexten Jan 9, 2025
d69e96a
Merge branch 'km/pm-15584/fix-safari-biometrics' of github.com:bitwarโ€ฆ
quexten Jan 9, 2025
b3a31d2
Merge branch 'main' into km/pm-15584/fix-safari-biometrics
quexten Jan 9, 2025
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: 3 additions & 0 deletions apps/browser/src/popup/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
ToastOptions,
ToastService,
} from "@bitwarden/components";
import { BiometricStateService } from "@bitwarden/key-management";

Check warning on line 24 in apps/browser/src/popup/app.component.ts

View check run for this annotation

Codecov / codecov/patch

apps/browser/src/popup/app.component.ts#L24

Added line #L24 was not covered by tests

import { PopupCompactModeService } from "../platform/popup/layout/popup-compact-mode.service";
import { PopupViewCacheService } from "../platform/popup/view-cache/popup-view-cache.service";
Expand Down Expand Up @@ -64,6 +65,7 @@
private toastService: ToastService,
private accountService: AccountService,
private animationControlService: AnimationControlService,
private biometricStateService: BiometricStateService,

Check warning on line 68 in apps/browser/src/popup/app.component.ts

View check run for this annotation

Codecov / codecov/patch

apps/browser/src/popup/app.component.ts#L68

Added line #L68 was not covered by tests
) {}

async ngOnInit() {
Expand Down Expand Up @@ -134,6 +136,7 @@
} else if (msg.command === "reloadProcess") {
if (this.platformUtilsService.isSafari()) {
window.setTimeout(() => {
this.biometricStateService.updateLastProcessReload();

Check warning on line 139 in apps/browser/src/popup/app.component.ts

View check run for this annotation

Codecov / codecov/patch

apps/browser/src/popup/app.component.ts#L139

Added line #L139 was not covered by tests
window.location.reload();
}, 2000);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@
[ClientType.Browser]: "/tabs/current",
};

/// The minimum amount of time to wait after a process reload for a biometrics auto prompt to be possible
/// Fixes safari autoprompt behavior
const AUTOPROMPT_BIOMETRICS_PROCESS_RELOAD_DELAY = 5000;

Check warning on line 75 in libs/key-management/src/angular/lock/components/lock.component.ts

View check run for this annotation

Codecov / codecov/patch

libs/key-management/src/angular/lock/components/lock.component.ts#L75

Added line #L75 was not covered by tests
@Component({
selector: "bit-lock",
templateUrl: "lock.component.html",
Expand Down Expand Up @@ -304,7 +307,13 @@
(await this.biometricService.getShouldAutopromptNow())
) {
await this.biometricService.setShouldAutopromptNow(false);
await this.unlockViaBiometrics();
if (
(await this.biometricStateService.getLastProcessReload()) == null ||
Date.now() - (await this.biometricStateService.getLastProcessReload()).getTime() >
AUTOPROMPT_BIOMETRICS_PROCESS_RELOAD_DELAY
) {
await this.unlockViaBiometrics();

Check warning on line 315 in libs/key-management/src/angular/lock/components/lock.component.ts

View check run for this annotation

Codecov / codecov/patch

libs/key-management/src/angular/lock/components/lock.component.ts#L315

Added line #L315 was not covered by tests
}
}
}
}
Expand Down
18 changes: 18 additions & 0 deletions libs/key-management/src/biometrics/biometric-state.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
PROMPT_AUTOMATICALLY,
PROMPT_CANCELLED,
FINGERPRINT_VALIDATED,
LAST_PROCESS_RELOAD,
} from "./biometric.state";

export abstract class BiometricStateService {
Expand Down Expand Up @@ -106,6 +107,10 @@
*/
abstract setFingerprintValidated(validated: boolean): Promise<void>;

abstract updateLastProcessReload(): Promise<void>;

abstract getLastProcessReload(): Promise<Date>;

abstract logout(userId: UserId): Promise<void>;
}

Expand All @@ -117,13 +122,15 @@
private promptCancelledState: GlobalState<Record<UserId, boolean>>;
private promptAutomaticallyState: ActiveUserState<boolean>;
private fingerprintValidatedState: GlobalState<boolean>;
private lastProcessReloadState: GlobalState<Date>;
biometricUnlockEnabled$: Observable<boolean>;
encryptedClientKeyHalf$: Observable<EncString | undefined>;
requirePasswordOnStart$: Observable<boolean>;
dismissedRequirePasswordOnStartCallout$: Observable<boolean>;
promptCancelled$: Observable<boolean>;
promptAutomatically$: Observable<boolean>;
fingerprintValidated$: Observable<boolean>;
lastProcessReload$: Observable<Date>;

constructor(private stateProvider: StateProvider) {
this.biometricUnlockEnabledState = this.stateProvider.getActive(BIOMETRIC_UNLOCK_ENABLED);
Expand Down Expand Up @@ -159,6 +166,9 @@

this.fingerprintValidatedState = this.stateProvider.getGlobal(FINGERPRINT_VALIDATED);
this.fingerprintValidated$ = this.fingerprintValidatedState.state$.pipe(map(Boolean));

this.lastProcessReloadState = this.stateProvider.getGlobal(LAST_PROCESS_RELOAD);
this.lastProcessReload$ = this.lastProcessReloadState.state$;
}

async setBiometricUnlockEnabled(enabled: boolean): Promise<void> {
Expand Down Expand Up @@ -270,6 +280,14 @@
async setFingerprintValidated(validated: boolean): Promise<void> {
await this.fingerprintValidatedState.update(() => validated);
}

async updateLastProcessReload(): Promise<void> {
await this.lastProcessReloadState.update(() => new Date());

Check warning on line 285 in libs/key-management/src/biometrics/biometric-state.service.ts

View check run for this annotation

Codecov / codecov/patch

libs/key-management/src/biometrics/biometric-state.service.ts#L285

Added line #L285 was not covered by tests
}

async getLastProcessReload(): Promise<Date> {
return await firstValueFrom(this.lastProcessReload$);

Check warning on line 289 in libs/key-management/src/biometrics/biometric-state.service.ts

View check run for this annotation

Codecov / codecov/patch

libs/key-management/src/biometrics/biometric-state.service.ts#L289

Added line #L289 was not covered by tests
}
}

function encryptedClientKeyHalfToEncString(
Expand Down
11 changes: 11 additions & 0 deletions libs/key-management/src/biometrics/biometric.state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,14 @@
deserializer: (obj) => obj,
},
);

/**
* Last process reload time
*/
export const LAST_PROCESS_RELOAD = new KeyDefinition<Date>(
BIOMETRIC_SETTINGS_DISK,
"lastProcessReload",
{
deserializer: (obj) => new Date(obj),

Check warning on line 106 in libs/key-management/src/biometrics/biometric.state.ts

View check run for this annotation

Codecov / codecov/patch

libs/key-management/src/biometrics/biometric.state.ts#L106

Added line #L106 was not covered by tests
},
);
Loading