1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-21 18:53:29 +00:00

[PM-25682] Migrate CipherView and subviews to be TS strict compliant (#16463)

* [PM-25682] Remove ts-strict-ignore from Vault view models and update types to be strict

* [PM-25682] Ignore ViewEncryptableKeys error for old decrypt methods

* [PM-25682] Add null/undefined as possible types for isNull* and other helpers that include null checks internally

* [PM-25682] Use patchValue instead of setValue which does not support undefined values

* [PM-25682] Add type assertions and other misc. null checks where necessary

* [PM-25682] Fix importers specs

* [PM-25682] Cleanup card view/details

* [PM-25682] Fix cipher view hasAttachment helper

* [PM-25682] Cleanup unecessary null assignments in notification.background.spec.ts

* [PM-25682] Ensure linkedId is undefined instead of null

* [PM-25682] Cleanup misc typing errors

* [PM-25682] Make the CipherId required

* [PM-25682] Undo CipherId assertions

* [PM-25682] Undo brand initial value change

* [PM-25682] Update SshKeyView

* [PM-25682] Add constructor to Fido2CredentialView

* [PM-25682] Prettier

* [PM-25682] Fix strict type warnings after merge with main

* [PM-25682] Cleanup cipher view spec

* [PM-25682] Cleanup new type warnings after merge

* [PM-25682] Undo removed eslint-disable-next-line comment

* [PM-25682] Fix flaky test

* [PM-25682] Use satisfies instead of as for Fido2CredentialAutofillView
This commit is contained in:
Shane Melton
2025-10-07 08:40:57 -07:00
committed by GitHub
parent 2127f71f5d
commit 9f0a565241
54 changed files with 424 additions and 503 deletions

View File

@@ -40,7 +40,7 @@ export function getTrimmedCipherUris(cipher: CipherView): string[] {
const uniqueDomains = new Set<string>();
uris.forEach((u: { uri: string }) => {
uris.forEach((u: { uri: string | undefined }) => {
const domain = Utils.getDomain(u.uri) ?? u.uri;
uniqueDomains.add(domain);
});

View File

@@ -29,7 +29,7 @@ export class PasswordHealthService {
filter((cipher) => this.isValidCipher(cipher)),
mergeMap((cipher) =>
this.auditService
.passwordLeaked(cipher.login.password)
.passwordLeaked(cipher.login.password!)
.then((exposedCount) => ({ cipher, exposedCount })),
),
// [FIXME] ExposedDetails is can still return a null
@@ -74,11 +74,11 @@ export class PasswordHealthService {
// Check the username
const userInput = this.isUserNameNotEmpty(cipher)
? this.extractUsernameParts(cipher.login.username)
? this.extractUsernameParts(cipher.login.username!)
: undefined;
const { score } = this.passwordStrengthService.getPasswordStrength(
cipher.login.password,
cipher.login.password!,
undefined, // No email available in this context
userInput,
);

View File

@@ -436,13 +436,13 @@ export class RiskInsightsReportService {
const weakPassword = this.passwordHealthService.findWeakPasswordDetails(cipher);
// Looping over all ciphers needs to happen first to determine reused passwords over all ciphers.
// Store in the set and evaluate later
if (passwordUseMap.has(cipher.login.password)) {
if (passwordUseMap.has(cipher.login.password!)) {
passwordUseMap.set(
cipher.login.password,
(passwordUseMap.get(cipher.login.password) || 0) + 1,
cipher.login.password!,
(passwordUseMap.get(cipher.login.password!) || 0) + 1,
);
} else {
passwordUseMap.set(cipher.login.password, 1);
passwordUseMap.set(cipher.login.password!, 1);
}
const exposedPassword = exposedDetails.find((x) => x?.cipherId === cipher.id);
@@ -466,7 +466,7 @@ export class RiskInsightsReportService {
// loop for reused passwords
cipherHealthReports.forEach((detail) => {
detail.reusedPasswordCount = passwordUseMap.get(detail.login.password) ?? 0;
detail.reusedPasswordCount = passwordUseMap.get(detail.login.password!) ?? 0;
});
return cipherHealthReports;
}
@@ -514,7 +514,7 @@ export class RiskInsightsReportService {
private _buildPasswordUseMap(ciphers: CipherView[]): Map<string, number> {
const passwordUseMap = new Map<string, number>();
ciphers.forEach((cipher) => {
const password = cipher.login.password;
const password = cipher.login.password!;
passwordUseMap.set(password, (passwordUseMap.get(password) || 0) + 1);
});
return passwordUseMap;
@@ -686,7 +686,7 @@ export class RiskInsightsReportService {
healthData: {
weakPasswordDetail: this.passwordHealthService.findWeakPasswordDetails(cipher),
exposedPasswordDetail: exposedPassword,
reusedPasswordCount: passwordUseMap.get(cipher.login.password) ?? 0,
reusedPasswordCount: passwordUseMap.get(cipher.login.password!) ?? 0,
},
applications: getTrimmedCipherUris(cipher),
} as CipherHealthReport;