1
0
mirror of https://github.com/bitwarden/browser synced 2025-01-01 20:57:53 +01:00

shallow copy credentials in strategies that store them (#7047)

- add warnings about dead objects in firefox
This commit is contained in:
Jake Fink 2023-11-30 16:09:52 -05:00 committed by GitHub
parent 0b9a2775f0
commit cf6ed0d8a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 2 deletions

View File

@ -58,7 +58,9 @@ export class AuthRequestLoginStrategy extends LoginStrategy {
}
override async logIn(credentials: AuthRequestLoginCredentials) {
this.authRequestCredentials = credentials;
// NOTE: To avoid DeadObject references on Firefox, do not set the credentials object directly
// Use deep copy in future if objects are added that were created in popup
this.authRequestCredentials = { ...credentials };
this.tokenRequest = new PasswordTokenRequest(
credentials.email,

View File

@ -61,7 +61,9 @@ export class WebAuthnLoginStrategy extends LoginStrategy {
}
async logIn(credentials: WebAuthnLoginCredentials) {
this.credentials = credentials;
// NOTE: To avoid DeadObject references on Firefox, do not set the credentials object directly
// Use deep copy in future if objects are added that were created in popup
this.credentials = { ...credentials };
this.tokenRequest = new WebAuthnLoginTokenRequest(
credentials.token,

View File

@ -208,6 +208,8 @@ export class AuthService implements AuthServiceAbstraction {
break;
}
// Note: Do not set the credentials object directly on the strategy. They are
// created in the popup and can cause DeadObject references on Firefox.
const result = await strategy.logIn(credentials as any);
if (result?.requiresTwoFactor) {