ayiin 1.0.17 → 1.0.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +49 -0
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -1 +1,50 @@
|
|
|
1
|
+
import nodemailer from 'nodemailer';
|
|
2
|
+
|
|
3
|
+
|
|
1
4
|
declare module 'ayiin';
|
|
5
|
+
|
|
6
|
+
declare class Ayiin {
|
|
7
|
+
constructor(
|
|
8
|
+
email: string,
|
|
9
|
+
password: string
|
|
10
|
+
) {
|
|
11
|
+
this.email = email;
|
|
12
|
+
this.password = password;
|
|
13
|
+
this.array = [];
|
|
14
|
+
this.object = {};
|
|
15
|
+
this.mail = nodemailer.createTransport({
|
|
16
|
+
service: 'gmail',
|
|
17
|
+
host: "smtp.gmail.com",
|
|
18
|
+
port: 587,
|
|
19
|
+
auth: {
|
|
20
|
+
user: this.email,
|
|
21
|
+
pass: this.password
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
sendEmail(toEmail: string, subject: string, textHtml: string) {
|
|
27
|
+
let mailOptions = {
|
|
28
|
+
from: this.email,
|
|
29
|
+
to: toEmail,
|
|
30
|
+
subject: subject,
|
|
31
|
+
html: textHtml
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
this.mail.sendMail(mailOptions, (err, info) => {
|
|
35
|
+
if (err) {
|
|
36
|
+
console.log({ error: err });
|
|
37
|
+
}
|
|
38
|
+
console.log('Email sent: ' + info.response);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
generateOtp(length: number) {
|
|
43
|
+
var chars = '0123456789';
|
|
44
|
+
var result = '';
|
|
45
|
+
for (var i = length; i > 0; --i) result += chars[Math.floor(Math.random() * chars.length)];
|
|
46
|
+
return result;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export default Ayiin;
|