fix: return null instead of throw error on unsupported version
This commit is contained in:
parent
b982f7114c
commit
1dadf19431
|
@ -0,0 +1,16 @@
|
||||||
|
const DecryptorV4 = require("../crypto/DecryptorV4");
|
||||||
|
const jooxFactory = require("../index");
|
||||||
|
|
||||||
|
describe("package entry", () => {
|
||||||
|
it("should return null on unsupported file", () => {
|
||||||
|
const input = Buffer.from("E!99........", "utf-8");
|
||||||
|
const decryptor = jooxFactory(input, "".padStart(32, "0"));
|
||||||
|
expect(decryptor).toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should return an encryptor on v4 magic file", () => {
|
||||||
|
const input = Buffer.from("E!04........", "utf-8");
|
||||||
|
const decryptor = jooxFactory(input, "".padStart(32, "0"));
|
||||||
|
expect(decryptor).toBeInstanceOf(DecryptorV4);
|
||||||
|
});
|
||||||
|
});
|
|
@ -5,7 +5,7 @@ function jooxFactory(fileBody, seed) {
|
||||||
return new DecryptorV4(seed);
|
return new DecryptorV4(seed);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new Error("input file not supported or invalid");
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = jooxFactory;
|
module.exports = jooxFactory;
|
||||||
|
|
Loading…
Reference in New Issue