PM-7392 - Don't re-invent the wheel and simply use existing isSerializedEncString static method.

This commit is contained in:
Jared Snider 2024-05-03 11:31:42 -04:00
parent 6456670c2f
commit e9d2f3fec9
No known key found for this signature in database
GPG Key ID: A149DDD612516286
2 changed files with 3 additions and 17 deletions

View File

@ -102,7 +102,7 @@ export class EncString implements Encrypted {
}
}
static parseEncryptedString(encryptedString: string): {
private static parseEncryptedString(encryptedString: string): {
encType: EncryptionType;
encPieces: string[];
} {

View File

@ -2,7 +2,7 @@ import { Utils } from "../../../platform/misc/utils";
import { CryptoFunctionService } from "../../abstractions/crypto-function.service";
import { EncryptService } from "../../abstractions/encrypt.service";
import { LogService } from "../../abstractions/log.service";
import { EXPECTED_NUM_PARTS_BY_ENCRYPTION_TYPE, EncryptionType } from "../../enums";
import { EncryptionType } from "../../enums";
import { Decryptable } from "../../interfaces/decryptable.interface";
import { Encrypted } from "../../interfaces/encrypted";
import { InitializerMetadata } from "../../interfaces/initializer-metadata.interface";
@ -68,21 +68,7 @@ export class EncryptServiceImplementation implements EncryptService {
return false;
}
const parsedEncString = EncString.parseEncryptedString(value);
if (
parsedEncString == null ||
parsedEncString.encType === null ||
parsedEncString.encPieces == null
) {
return false;
}
// check if the number of parts in the parsed enc pieces matches the expected number of parts for the encryption type
return (
parsedEncString.encPieces.length ===
EXPECTED_NUM_PARTS_BY_ENCRYPTION_TYPE[parsedEncString.encType]
);
return EncString.isSerializedEncString(value);
}
async decryptToUtf8(encString: EncString, key: SymmetricCryptoKey): Promise<string> {