1
0
mirror of https://github.com/bitwarden/browser synced 2026-02-10 21:50:15 +00:00

update cipher handling

This commit is contained in:
Evan Bassler
2025-02-18 08:24:44 -06:00
parent 8b74787e84
commit 4d1d635c76
4 changed files with 18 additions and 17 deletions

View File

@@ -160,6 +160,7 @@ export class DesktopFido2UserInterfaceSession implements Fido2UserInterfaceSessi
}
async getRpId(): Promise<string> {
console.log("getRpId");
return lastValueFrom(
this.rpId.pipe(
filter((id) => id != null),
@@ -215,6 +216,7 @@ export class DesktopFido2UserInterfaceSession implements Fido2UserInterfaceSessi
userVerification,
rpId,
);
this.rpId.next(rpId);
try {
await this.showUi("/passkey-create");
@@ -262,7 +264,6 @@ export class DesktopFido2UserInterfaceSession implements Fido2UserInterfaceSessi
*/
async createCipher({ credentialName, userName, rpId }: NewCredentialParams): Promise<Cipher> {
// Store the passkey on a new cipher to avoid replacing something important
this.rpId.next(rpId);
const cipher = new CipherView();
cipher.name = credentialName;

View File

@@ -62,21 +62,30 @@ export class Fido2CreateComponent implements OnInit {
) {}
async ngOnInit() {
console.log("fido2 create component");
this.session = this.fido2UserInterfaceService.getCurrentSession();
console.log(this.session, "session");
const rpid = await this.session.getRpId();
const equivalentDomains = await firstValueFrom(
this.domainSettingsService.getUrlEquivalentDomains(rpid),
);
console.log(rpid, "webdomain stuff");
this.cipherService
.getPasskeyCiphersForUrl(rpid)
.getAllDecrypted()
.then((ciphers) => {
const relevantCiphers = ciphers.filter(
(cipher) =>
cipher.login.matchesUri(rpid, equivalentDomains) &&
(!cipher.login.fido2Credentials || cipher.login.fido2Credentials.length === 0),
);
console.log(ciphers, "ciphers from url");
const relevantCiphers = ciphers.filter((cipher) => {
if (!cipher.login) {
return false;
}
return (
cipher.login.uri === rpid &&
(!cipher.login.fido2Credentials || cipher.login.fido2Credentials.length === 0)
);
});
this.ciphersSubject.next(relevantCiphers);
})
.catch(() => {

View File

@@ -46,7 +46,6 @@ export abstract class CipherService implements UserKeyRotationDataProvider<Ciphe
defaultMatch?: UriMatchStrategySetting,
) => Promise<CipherView[]>;
getAllDecryptedForIds: (ids: string[]) => Promise<CipherView[]>;
getPasskeyCiphersForUrl: (url: string) => Promise<CipherView[]>;
getPasskeyCiphers: () => Promise<CipherView[]>;
filterCiphersForUrl: (
ciphers: CipherView[],

View File

@@ -1637,14 +1637,6 @@ export class CipherService implements CipherServiceAbstraction {
}
}
async getPasskeyCiphersForUrl(url: string): Promise<CipherView[]> {
let ciphers = await this.getAllDecryptedForUrl(url);
if (!ciphers) {
return null;
}
ciphers = ciphers.filter((cipher) => cipher.login.fido2Credentials?.length);
return ciphers;
}
async getPasskeyCiphers(): Promise<CipherView[]> {
let ciphers = await this.getAllDecrypted();
if (!ciphers) {