1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-19 09:43:23 +00:00

merged latest EC-598, fix conflicts

This commit is contained in:
jng
2023-08-17 10:48:06 -04:00
16 changed files with 350 additions and 148 deletions

View File

@@ -8,6 +8,7 @@ import { CardExport } from "./card.export";
import { FieldExport } from "./field.export";
import { IdentityExport } from "./identity.export";
import { LoginExport } from "./login.export";
import { PasswordHistoryExport } from "./password-history.export";
import { SecureNoteExport } from "./secure-note.export";
export class CipherExport {
@@ -26,6 +27,10 @@ export class CipherExport {
req.card = null;
req.identity = null;
req.reprompt = CipherRepromptType.None;
req.passwordHistory = [];
req.creationDate = null;
req.revisionDate = null;
req.deletedDate = null;
return req;
}
@@ -63,6 +68,13 @@ export class CipherExport {
break;
}
if (req.passwordHistory != null) {
view.passwordHistory = req.passwordHistory.map((ph) => PasswordHistoryExport.toView(ph));
}
view.creationDate = req.creationDate;
view.revisionDate = req.revisionDate;
view.deletedDate = req.deletedDate;
return view;
}
@@ -96,6 +108,13 @@ export class CipherExport {
break;
}
if (req.passwordHistory != null) {
domain.passwordHistory = req.passwordHistory.map((ph) => PasswordHistoryExport.toDomain(ph));
}
domain.creationDate = req.creationDate;
domain.revisionDate = req.revisionDate;
domain.deletedDate = req.deletedDate;
return domain;
}
@@ -112,6 +131,10 @@ export class CipherExport {
card: CardExport;
identity: IdentityExport;
reprompt: CipherRepromptType;
passwordHistory: PasswordHistoryExport[] = null;
revisionDate: Date = null;
creationDate: Date = null;
deletedDate: Date = null;
// Use build method instead of ctor so that we can control order of JSON stringify for pretty print
build(o: CipherView | CipherDomain) {
@@ -152,5 +175,17 @@ export class CipherExport {
this.identity = new IdentityExport(o.identity);
break;
}
if (o.passwordHistory != null) {
if (o instanceof CipherView) {
this.passwordHistory = o.passwordHistory.map((ph) => new PasswordHistoryExport(ph));
} else {
this.passwordHistory = o.passwordHistory.map((ph) => new PasswordHistoryExport(ph));
}
}
this.creationDate = o.creationDate;
this.revisionDate = o.revisionDate;
this.deletedDate = o.deletedDate;
}
}

View File

@@ -0,0 +1,40 @@
import { EncString } from "../../platform/models/domain/enc-string";
import { Password } from "../../vault/models/domain/password";
import { PasswordHistoryView } from "../../vault/models/view/password-history.view";
export class PasswordHistoryExport {
static template(): PasswordHistoryExport {
const req = new PasswordHistoryExport();
req.password = null;
req.lastUsedDate = null;
return req;
}
static toView(req: PasswordHistoryExport, view = new PasswordHistoryView()) {
view.password = req.password;
view.lastUsedDate = req.lastUsedDate;
return view;
}
static toDomain(req: PasswordHistoryExport, domain = new Password()) {
domain.password = req.password != null ? new EncString(req.password) : null;
domain.lastUsedDate = req.lastUsedDate;
return domain;
}
password: string;
lastUsedDate: Date = null;
constructor(o?: PasswordHistoryView | Password) {
if (o == null) {
return;
}
if (o instanceof PasswordHistoryView) {
this.password = o.password;
} else {
this.password = o.password?.encryptedString;
}
this.lastUsedDate = o.lastUsedDate;
}
}

View File

@@ -11,6 +11,7 @@ export abstract class Fido2ClientService {
params: AssertCredentialParams,
abortController?: AbortController
) => Promise<AssertCredentialResult>;
isFido2FeatureEnabled: () => Promise<boolean>;
}
export interface CreateCredentialParams {

View File

@@ -34,14 +34,15 @@ export class Fido2ClientService implements Fido2ClientServiceAbstraction {
private logService?: LogService
) {}
async isFido2FeatureEnabled(): Promise<boolean> {
return await this.configService.getFeatureFlagBool(FeatureFlag.Fido2VaultCredentials);
}
async createCredential(
params: CreateCredentialParams,
abortController = new AbortController()
): Promise<CreateCredentialResult> {
// debugger;
const enableFido2VaultCredentials = await this.configService.getFeatureFlagBool(
FeatureFlag.Fido2VaultCredentials
);
const enableFido2VaultCredentials = await this.isFido2FeatureEnabled();
if (!enableFido2VaultCredentials) {
this.logService?.warning(`[Fido2Client] Fido2VaultCredential is not enabled`);
@@ -192,9 +193,7 @@ export class Fido2ClientService implements Fido2ClientServiceAbstraction {
params: AssertCredentialParams,
abortController = new AbortController()
): Promise<AssertCredentialResult> {
const enableFido2VaultCredentials = await this.configService.getFeatureFlagBool(
FeatureFlag.Fido2VaultCredentials
);
const enableFido2VaultCredentials = await this.isFido2FeatureEnabled();
if (!enableFido2VaultCredentials) {
this.logService?.warning(`[Fido2Client] Fido2VaultCredential is not enabled`);