ayiin 1.0.13 → 1.0.14
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 +11 -1
- package/index.js +2 -7
- package/lib/ayiin.js +4 -27
- package/lib/core/Ayiin.js +43 -2
- package/package.json +6 -2
- package/lib/generateOtp.js +0 -18
package/index.d.ts
CHANGED
|
@@ -1 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
import Ayiin from "./lib/core/Ayiin";
|
|
2
|
+
|
|
3
|
+
export declare module 'ayiin';
|
|
4
|
+
|
|
5
|
+
/** @public */
|
|
6
|
+
export declare class Ayiin extends Ayiin {
|
|
7
|
+
/** The username for auth */
|
|
8
|
+
email?: string;
|
|
9
|
+
/** The password for auth */
|
|
10
|
+
password?: string;
|
|
11
|
+
}
|
package/index.js
CHANGED
package/lib/ayiin.js
CHANGED
|
@@ -1,30 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
* Copyright(c) 2023-2024 AyiinXd
|
|
4
|
-
* MIT Licensed
|
|
5
|
-
*/
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Module dependencies.
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
import generateOtp from "./generateOtp.js";
|
|
13
4
|
import Ayiin from "./core/Ayiin.js";
|
|
14
5
|
|
|
15
|
-
|
|
16
|
-
function
|
|
17
|
-
const context = new Ayiin(defaultConfig);
|
|
18
|
-
return context;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const defaults = { ayiinxd: 'beeehhh' };
|
|
22
|
-
|
|
23
|
-
// Create the default instance to be exported
|
|
24
|
-
const ayiin = createInstance(defaults);
|
|
25
|
-
|
|
26
|
-
// Expose generateOtp
|
|
27
|
-
ayiin.generateOtp = generateOtp;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
export default ayiin;
|
|
6
|
+
const ayiinClient = require("./core/Ayiin.js");
|
|
7
|
+
Object.defineProperty(exports, "Ayiin", { enumerable: true, get: function () { return ayiinClient.Ayiin; } });
|
package/lib/core/Ayiin.js
CHANGED
|
@@ -1,7 +1,48 @@
|
|
|
1
|
+
const nodemailer = require('nodemailer');
|
|
2
|
+
|
|
3
|
+
|
|
1
4
|
class Ayiin {
|
|
2
|
-
constructor(
|
|
3
|
-
|
|
5
|
+
constructor(
|
|
6
|
+
email,
|
|
7
|
+
password
|
|
8
|
+
) {
|
|
9
|
+
this.email = email;
|
|
10
|
+
this.password = password;
|
|
11
|
+
this.array = [];
|
|
12
|
+
this.object = {};
|
|
13
|
+
this.mail = nodemailer.createTransport({
|
|
14
|
+
service: 'gmail',
|
|
15
|
+
host: "smtp.gmail.com",
|
|
16
|
+
port: 587,
|
|
17
|
+
auth: {
|
|
18
|
+
user: this.email,
|
|
19
|
+
pass: this.password
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
sendEmail(toEmail, subject, textHtml) {
|
|
25
|
+
let mailOptions = {
|
|
26
|
+
from: this.email,
|
|
27
|
+
to: toEmail,
|
|
28
|
+
subject: subject,
|
|
29
|
+
html: textHtml
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
this.mail.sendMail(mailOptions, (err, info) => {
|
|
33
|
+
if (err) {
|
|
34
|
+
console.log({ error: err });
|
|
35
|
+
}
|
|
36
|
+
console.log('Email sent: ' + info.response);
|
|
37
|
+
});
|
|
4
38
|
}
|
|
39
|
+
|
|
40
|
+
generateOtp(length) {
|
|
41
|
+
var chars = '0123456789';
|
|
42
|
+
var result = '';
|
|
43
|
+
for (var i = length; i > 0; --i) result += chars[Math.floor(Math.random() * chars.length)];
|
|
44
|
+
return result;
|
|
45
|
+
};
|
|
5
46
|
};
|
|
6
47
|
|
|
7
48
|
|
package/package.json
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ayiin",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.14",
|
|
4
4
|
"description": "Library Pribadi Yang Gak Ada Isinya",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "AyiinXd",
|
|
7
7
|
"license": "MIT",
|
|
8
|
+
"types": "index.d.ts",
|
|
8
9
|
"directories": {
|
|
9
10
|
"lib": "lib"
|
|
10
11
|
},
|
|
11
|
-
"main": "
|
|
12
|
+
"main": "lib/ayiin.js",
|
|
12
13
|
"scripts": {
|
|
13
14
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
15
|
+
},
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"nodemailer": "^6.9.7"
|
|
14
18
|
}
|
|
15
19
|
}
|
package/lib/generateOtp.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* ayiin
|
|
3
|
-
* Copyright(c) 2023-2024 AyiinXd
|
|
4
|
-
* MIT Licensed
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* generateOtp membutuhkan argument length as number
|
|
10
|
-
* */
|
|
11
|
-
const generateOtp = (length) => {
|
|
12
|
-
var chars = '0123456789';
|
|
13
|
-
var result = '';
|
|
14
|
-
for (var i = length; i > 0; --i) result += chars[Math.floor(Math.random() * chars.length)];
|
|
15
|
-
return result;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export default generateOtp;
|