-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.js
31 lines (25 loc) · 908 Bytes
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
const { generateOtp, sendOtp, encryptOtp, decryptOtp, validateOtp } = require('./index.js');
async function test() {
try {
const testEmail = '[email protected]';
const otp = generateOtp(6, { upperCaseAlphabets: true, specialChars: true });
console.log(`Generated OTP: ${otp}`);
const encryptedOtp = encryptOtp(otp);
console.log(`Encrypted OTP: ${encryptedOtp}`);
const decryptedOtp = decryptOtp(encryptedOtp);
console.log(`Decrypted OTP: ${decryptedOtp}`);
if (validateOtp(otp, decryptedOtp)) {
console.log('OTP validation successful!');
} else {
console.log('OTP validation failed!');
}
await sendOtp(testEmail, otp, {
attachments: [{ filename: 'test.txt', content: 'Test attachment' }],
embedImages: true
});
console.log('OTP sent successfully!');
} catch (error) {
console.error('Error:', error);
}
}
test();