mirror of
https://github.com/bitwarden/browser
synced 2025-12-27 21:53:25 +00:00
[EC-598] feat: fully wokring non-discoverable implementation
This commit is contained in:
@@ -60,6 +60,8 @@ export class CipherData {
|
||||
switch (this.type) {
|
||||
case CipherType.Login:
|
||||
this.login = new LoginData(response.login);
|
||||
this.fido2Key =
|
||||
response.fido2Key != undefined ? new Fido2KeyData(response.fido2Key) : undefined;
|
||||
break;
|
||||
case CipherType.SecureNote:
|
||||
this.secureNote = new SecureNoteData(response.secureNote);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { LoginApi } from "../../../models/api/login.api";
|
||||
import { Fido2KeyData } from "../../../webauthn/models/data/fido2-key.data";
|
||||
|
||||
import { LoginUriData } from "./login-uri.data";
|
||||
|
||||
@@ -9,6 +10,7 @@ export class LoginData {
|
||||
passwordRevisionDate: string;
|
||||
totp: string;
|
||||
autofillOnPageLoad: boolean;
|
||||
fido2Key?: Fido2KeyData;
|
||||
|
||||
constructor(data?: LoginApi) {
|
||||
if (data == null) {
|
||||
@@ -24,5 +26,9 @@ export class LoginData {
|
||||
if (data.uris) {
|
||||
this.uris = data.uris.map((u) => new LoginUriData(u));
|
||||
}
|
||||
|
||||
if (data.fido2Key) {
|
||||
this.fido2Key = new Fido2KeyData(data.fido2Key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ import { Jsonify } from "type-fest";
|
||||
import Domain from "../../../models/domain/domain-base";
|
||||
import { EncString } from "../../../models/domain/enc-string";
|
||||
import { SymmetricCryptoKey } from "../../../models/domain/symmetric-crypto-key";
|
||||
import { Fido2Key } from "../../../webauthn/models/domain/fido2-key";
|
||||
import { LoginData } from "../data/login.data";
|
||||
import { LoginView } from "../view/login.view";
|
||||
|
||||
@@ -15,6 +16,7 @@ export class Login extends Domain {
|
||||
passwordRevisionDate?: Date;
|
||||
totp: EncString;
|
||||
autofillOnPageLoad: boolean;
|
||||
fido2Key: Fido2Key;
|
||||
|
||||
constructor(obj?: LoginData) {
|
||||
super();
|
||||
@@ -42,6 +44,10 @@ export class Login extends Domain {
|
||||
this.uris.push(new LoginUri(u));
|
||||
});
|
||||
}
|
||||
|
||||
if (obj.fido2Key) {
|
||||
this.fido2Key = new Fido2Key(obj.fido2Key);
|
||||
}
|
||||
}
|
||||
|
||||
async decrypt(orgId: string, encKey?: SymmetricCryptoKey): Promise<LoginView> {
|
||||
@@ -64,6 +70,10 @@ export class Login extends Domain {
|
||||
}
|
||||
}
|
||||
|
||||
if (this.fido2Key != null) {
|
||||
view.fido2Key = await this.fido2Key.decrypt(orgId, encKey);
|
||||
}
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
@@ -85,6 +95,10 @@ export class Login extends Domain {
|
||||
});
|
||||
}
|
||||
|
||||
if (this.fido2Key != null) {
|
||||
l.fido2Key = this.fido2Key.toFido2KeyData();
|
||||
}
|
||||
|
||||
return l;
|
||||
}
|
||||
|
||||
@@ -99,13 +113,15 @@ export class Login extends Domain {
|
||||
const passwordRevisionDate =
|
||||
obj.passwordRevisionDate == null ? null : new Date(obj.passwordRevisionDate);
|
||||
const uris = obj.uris?.map((uri: any) => LoginUri.fromJSON(uri));
|
||||
const fido2Key = obj.fido2Key == null ? null : Fido2Key.fromJSON(obj.fido2Key);
|
||||
|
||||
return Object.assign(new Login(), obj, {
|
||||
username,
|
||||
password,
|
||||
totp,
|
||||
passwordRevisionDate: passwordRevisionDate,
|
||||
uris: uris,
|
||||
passwordRevisionDate,
|
||||
uris,
|
||||
fido2Key,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,6 +63,44 @@ export class CipherRequest {
|
||||
return uri;
|
||||
});
|
||||
}
|
||||
|
||||
if (cipher.login.fido2Key != null) {
|
||||
this.login.fido2Key = new Fido2KeyApi();
|
||||
this.login.fido2Key.nonDiscoverableId =
|
||||
cipher.login.fido2Key.nonDiscoverableId != null
|
||||
? cipher.login.fido2Key.nonDiscoverableId.encryptedString
|
||||
: null;
|
||||
this.login.fido2Key.keyType =
|
||||
cipher.login.fido2Key.keyType != null
|
||||
? (cipher.login.fido2Key.keyType.encryptedString as "public-key")
|
||||
: null;
|
||||
this.login.fido2Key.keyAlgorithm =
|
||||
cipher.login.fido2Key.keyAlgorithm != null
|
||||
? (cipher.login.fido2Key.keyAlgorithm.encryptedString as "ECDSA")
|
||||
: null;
|
||||
this.login.fido2Key.keyCurve =
|
||||
cipher.login.fido2Key.keyCurve != null
|
||||
? (cipher.login.fido2Key.keyCurve.encryptedString as "P-256")
|
||||
: null;
|
||||
this.login.fido2Key.keyValue =
|
||||
cipher.login.fido2Key.keyValue != null
|
||||
? cipher.login.fido2Key.keyValue.encryptedString
|
||||
: null;
|
||||
this.login.fido2Key.rpId =
|
||||
cipher.login.fido2Key.rpId != null ? cipher.login.fido2Key.rpId.encryptedString : null;
|
||||
this.login.fido2Key.rpName =
|
||||
cipher.login.fido2Key.rpName != null
|
||||
? cipher.login.fido2Key.rpName.encryptedString
|
||||
: null;
|
||||
this.login.fido2Key.userHandle =
|
||||
cipher.login.fido2Key.userHandle != null
|
||||
? cipher.login.fido2Key.userHandle.encryptedString
|
||||
: null;
|
||||
this.login.fido2Key.userName =
|
||||
cipher.login.fido2Key.userName != null
|
||||
? cipher.login.fido2Key.userName.encryptedString
|
||||
: null;
|
||||
}
|
||||
break;
|
||||
case CipherType.SecureNote:
|
||||
this.secureNote = new SecureNoteApi();
|
||||
|
||||
@@ -3,6 +3,7 @@ import { Jsonify } from "type-fest";
|
||||
import { LoginLinkedId as LinkedId } from "../../../enums/linkedIdType";
|
||||
import { linkedFieldOption } from "../../../misc/linkedFieldOption.decorator";
|
||||
import { Utils } from "../../../misc/utils";
|
||||
import { Fido2KeyView } from "../../../webauthn/models/view/fido2-key.view";
|
||||
import { Login } from "../domain/login";
|
||||
|
||||
import { ItemView } from "./item.view";
|
||||
@@ -18,6 +19,7 @@ export class LoginView extends ItemView {
|
||||
totp: string = null;
|
||||
uris: LoginUriView[] = null;
|
||||
autofillOnPageLoad: boolean = null;
|
||||
fido2Key?: Fido2KeyView;
|
||||
|
||||
constructor(l?: Login) {
|
||||
super();
|
||||
@@ -67,10 +69,12 @@ export class LoginView extends ItemView {
|
||||
const passwordRevisionDate =
|
||||
obj.passwordRevisionDate == null ? null : new Date(obj.passwordRevisionDate);
|
||||
const uris = obj.uris?.map((uri: any) => LoginUriView.fromJSON(uri));
|
||||
const fido2Key = obj.fido2Key == null ? null : Fido2KeyView.fromJSON(obj.fido2Key);
|
||||
|
||||
return Object.assign(new LoginView(), obj, {
|
||||
passwordRevisionDate: passwordRevisionDate,
|
||||
uris: uris,
|
||||
uris,
|
||||
fido2Key,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1117,6 +1117,27 @@ export class CipherService implements CipherServiceAbstraction {
|
||||
cipher.login.uris.push(loginUri);
|
||||
}
|
||||
}
|
||||
|
||||
if (model.login.fido2Key != null) {
|
||||
cipher.login.fido2Key = new Fido2Key();
|
||||
await this.encryptObjProperty(
|
||||
model.login.fido2Key,
|
||||
cipher.login.fido2Key,
|
||||
{
|
||||
nonDiscoverableId: null,
|
||||
keyType: null,
|
||||
keyAlgorithm: null,
|
||||
keyCurve: null,
|
||||
keyValue: null,
|
||||
rpId: null,
|
||||
rpName: null,
|
||||
userHandle: null,
|
||||
userName: null,
|
||||
origin: null,
|
||||
},
|
||||
key
|
||||
);
|
||||
}
|
||||
return;
|
||||
case CipherType.SecureNote:
|
||||
cipher.secureNote = new SecureNote();
|
||||
|
||||
Reference in New Issue
Block a user