Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('throws InvalidVerification when using a corrupt verification key', async () => {
const badKeys = [
corruptVerificationKey(verificationKey, 'privateSignatureKey', 4), // corrupt private part
corruptVerificationKey(verificationKey, 'privateSignatureKey', 60), // corrupt public part
corruptVerificationKey(verificationKey, 'privateEncryptionKey', 4), // does not match the one used at registration
];
for (let i = 0; i < badKeys.length; i++) {
const badKey = badKeys[i];
await expect(bobPhone.verifyIdentity({ verificationKey: badKey }), `bad verification key #${i}`).to.be.rejectedWith(errors.InvalidVerification);
}
});
});
it('throws when verifying provisional identity with wrong verification code', async () => {
await expect(aliceLaptop.verifyProvisionalIdentity({ email, verificationCode: 'wrongCode' })).to.be.rejectedWith(errors.InvalidVerification);
});
it('should fail to register an email verification method if the verification code is wrong', async () => {
const verificationCode = await appHelper.getWrongVerificationCode('john@doe.com');
await expect(bobLaptop.registerIdentity({ email: 'elton@doe.com', verificationCode })).to.be.rejectedWith(errors.InvalidVerification);
});