1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-17 00:33:44 +00:00

[PM-16831] TS Strict crypto function service (#12737)

* strict types in crypto function services

* Improve aesDecrypt types
This commit is contained in:
Matt Gibson
2025-01-09 18:58:22 -05:00
committed by GitHub
parent 8cabb36c99
commit 6ef3e9a076
8 changed files with 117 additions and 67 deletions

View File

@@ -1,10 +1,13 @@
// FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore
export class DecryptParameters<T> {
export type CbcDecryptParameters<T> = {
encKey: T;
data: T;
iv: T;
macKey: T;
mac: T;
macKey?: T;
mac?: T;
macData: T;
}
};
export type EcbDecryptParameters<T> = {
encKey: T;
data: T;
};

View File

@@ -7,7 +7,7 @@ import { EncryptionType } from "../../enums";
export class SymmetricCryptoKey {
key: Uint8Array;
encKey?: Uint8Array;
encKey: Uint8Array;
macKey?: Uint8Array;
encType: EncryptionType;
@@ -48,12 +48,8 @@ export class SymmetricCryptoKey {
throw new Error("Unsupported encType/key length.");
}
if (this.key != null) {
this.keyB64 = Utils.fromBufferToB64(this.key);
}
if (this.encKey != null) {
this.encKeyB64 = Utils.fromBufferToB64(this.encKey);
}
this.keyB64 = Utils.fromBufferToB64(this.key);
this.encKeyB64 = Utils.fromBufferToB64(this.encKey);
if (this.macKey != null) {
this.macKeyB64 = Utils.fromBufferToB64(this.macKey);
}