PM-7392 - Don't re-invent the wheel and simply use existing isSerializedEncString static method.
This commit is contained in:
parent
6456670c2f
commit
e9d2f3fec9
|
@ -102,7 +102,7 @@ export class EncString implements Encrypted {
|
|||
}
|
||||
}
|
||||
|
||||
static parseEncryptedString(encryptedString: string): {
|
||||
private static parseEncryptedString(encryptedString: string): {
|
||||
encType: EncryptionType;
|
||||
encPieces: string[];
|
||||
} {
|
||||
|
|
|
@ -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> {
|
||||
|
|
Loading…
Reference in New Issue