ayiin 2.0.0 → 2.0.1
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/ayiin/methods/index.d.ts
CHANGED
|
@@ -9,15 +9,55 @@ declare class BaseMethods<C extends Crypt, M extends Mailer, T extends Tools> {
|
|
|
9
9
|
mailer: M;
|
|
10
10
|
tools: T;
|
|
11
11
|
constructor(options?: Options);
|
|
12
|
+
/**
|
|
13
|
+
* Converts an ASCII string to its corresponding Hex representation.
|
|
14
|
+
* @param {string} asciiString - The ASCII string to be converted.
|
|
15
|
+
* @returns {string} - The Hex representation of the ASCII string.
|
|
16
|
+
*/
|
|
12
17
|
asciiToHex: (asciiString: string) => string;
|
|
18
|
+
/**
|
|
19
|
+
* Converts a Hex string to its corresponding ASCII representation.
|
|
20
|
+
* @param {string} hexString - The Hex string to be converted.
|
|
21
|
+
* @returns {string} - The ASCII representation of the Hex string.
|
|
22
|
+
*/
|
|
13
23
|
hexToAscii: (hexString: string) => string;
|
|
24
|
+
/**
|
|
25
|
+
* Encrypts a plaintext message using the given key.
|
|
26
|
+
* @param {string} text - The plaintext message to be encrypted.
|
|
27
|
+
* @param {string} key - The encryption key.
|
|
28
|
+
* @returns {string} - The encrypted data in Hex format.
|
|
29
|
+
*/
|
|
14
30
|
encrypt: (text: string, key: string, bufferEncoding?: BufferEncoding) => string;
|
|
31
|
+
/**
|
|
32
|
+
* Decrypts an encrypted message using the given key.
|
|
33
|
+
* @param {string} encrypted - The encrypted data in Hex format.
|
|
34
|
+
* @param {string} key - The decryption key.
|
|
35
|
+
* @returns {string} - The decrypted plaintext message.
|
|
36
|
+
*/
|
|
15
37
|
decrypt: (text: string, key: string, bufferEncoding?: BufferEncoding) => string;
|
|
16
38
|
md5: (data: string, encoding: BinaryToTextEncoding) => string;
|
|
39
|
+
/**
|
|
40
|
+
* Send an email
|
|
41
|
+
* @param {Mail.Options} options
|
|
42
|
+
* */
|
|
17
43
|
sendMail: (options: Mail.Options) => Promise<{
|
|
18
44
|
success: boolean;
|
|
19
45
|
message: string;
|
|
20
46
|
}>;
|
|
47
|
+
/**
|
|
48
|
+
* Format money
|
|
49
|
+
* @returns {string}
|
|
50
|
+
* @memberof Tools
|
|
51
|
+
* @param {number} amount
|
|
52
|
+
* @param {"long" | "short"} [compactDisplay="long"]
|
|
53
|
+
* */
|
|
54
|
+
formatMoney: (value: number) => string;
|
|
55
|
+
/**
|
|
56
|
+
* Generate a random string
|
|
57
|
+
* @returns {string}
|
|
58
|
+
* @memberof Tools
|
|
59
|
+
* @param {number} length
|
|
60
|
+
* */
|
|
21
61
|
randomString: (length: number) => string;
|
|
22
62
|
}
|
|
23
63
|
declare class Methods extends BaseMethods<Crypt, Mailer, Tools> {
|
package/ayiin/methods/index.js
CHANGED
|
@@ -17,12 +17,52 @@ const tools_1 = __importDefault(require("./tools"));
|
|
|
17
17
|
const mailer_1 = __importDefault(require("./mailer"));
|
|
18
18
|
class BaseMethods {
|
|
19
19
|
constructor(options) {
|
|
20
|
+
/**
|
|
21
|
+
* Converts an ASCII string to its corresponding Hex representation.
|
|
22
|
+
* @param {string} asciiString - The ASCII string to be converted.
|
|
23
|
+
* @returns {string} - The Hex representation of the ASCII string.
|
|
24
|
+
*/
|
|
20
25
|
this.asciiToHex = (asciiString) => this.crypt.asciiToHex(asciiString);
|
|
26
|
+
/**
|
|
27
|
+
* Converts a Hex string to its corresponding ASCII representation.
|
|
28
|
+
* @param {string} hexString - The Hex string to be converted.
|
|
29
|
+
* @returns {string} - The ASCII representation of the Hex string.
|
|
30
|
+
*/
|
|
21
31
|
this.hexToAscii = (hexString) => this.crypt.hexToAscii(hexString);
|
|
32
|
+
/**
|
|
33
|
+
* Encrypts a plaintext message using the given key.
|
|
34
|
+
* @param {string} text - The plaintext message to be encrypted.
|
|
35
|
+
* @param {string} key - The encryption key.
|
|
36
|
+
* @returns {string} - The encrypted data in Hex format.
|
|
37
|
+
*/
|
|
22
38
|
this.encrypt = (text, key, bufferEncoding) => this.crypt.encrypt(text, key, bufferEncoding);
|
|
39
|
+
/**
|
|
40
|
+
* Decrypts an encrypted message using the given key.
|
|
41
|
+
* @param {string} encrypted - The encrypted data in Hex format.
|
|
42
|
+
* @param {string} key - The decryption key.
|
|
43
|
+
* @returns {string} - The decrypted plaintext message.
|
|
44
|
+
*/
|
|
23
45
|
this.decrypt = (text, key, bufferEncoding) => this.crypt.decrypt(text, key, bufferEncoding);
|
|
24
46
|
this.md5 = (data, encoding) => this.crypt.md5(data, encoding);
|
|
47
|
+
/**
|
|
48
|
+
* Send an email
|
|
49
|
+
* @param {Mail.Options} options
|
|
50
|
+
* */
|
|
25
51
|
this.sendMail = (options) => __awaiter(this, void 0, void 0, function* () { return yield this.mailer.sendMail(options); });
|
|
52
|
+
/**
|
|
53
|
+
* Format money
|
|
54
|
+
* @returns {string}
|
|
55
|
+
* @memberof Tools
|
|
56
|
+
* @param {number} amount
|
|
57
|
+
* @param {"long" | "short"} [compactDisplay="long"]
|
|
58
|
+
* */
|
|
59
|
+
this.formatMoney = (value) => this.tools.formatMoney(value);
|
|
60
|
+
/**
|
|
61
|
+
* Generate a random string
|
|
62
|
+
* @returns {string}
|
|
63
|
+
* @memberof Tools
|
|
64
|
+
* @param {number} length
|
|
65
|
+
* */
|
|
26
66
|
this.randomString = (length) => this.tools.randomString(length);
|
|
27
67
|
this.crypt = new crypt_1.default();
|
|
28
68
|
this.mailer = new mailer_1.default(options);
|
|
@@ -9,6 +9,10 @@ type ResponseMailer = {
|
|
|
9
9
|
declare class Mailer {
|
|
10
10
|
client?: nodemailer.Transporter<SMTPTransport.SentMessageInfo, SMTPTransport.Options>;
|
|
11
11
|
constructor(opts?: Options);
|
|
12
|
+
/**
|
|
13
|
+
* Send an email
|
|
14
|
+
* @param {Mail.Options} options
|
|
15
|
+
* */
|
|
12
16
|
sendMail: (options: Mail.Options) => Promise<ResponseMailer>;
|
|
13
17
|
}
|
|
14
18
|
export default Mailer;
|
package/ayiin/methods/mailer.js
CHANGED
|
@@ -15,6 +15,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
const nodemailer_1 = __importDefault(require("nodemailer"));
|
|
16
16
|
class Mailer {
|
|
17
17
|
constructor(opts) {
|
|
18
|
+
/**
|
|
19
|
+
* Send an email
|
|
20
|
+
* @param {Mail.Options} options
|
|
21
|
+
* */
|
|
18
22
|
this.sendMail = (options) => __awaiter(this, void 0, void 0, function* () {
|
|
19
23
|
return yield new Promise((resolve, reject) => {
|
|
20
24
|
if (!this.client) {
|
package/ayiin/methods/tools.d.ts
CHANGED
package/ayiin/methods/tools.js
CHANGED
|
@@ -2,6 +2,18 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
class Tools {
|
|
4
4
|
constructor() {
|
|
5
|
+
/**
|
|
6
|
+
* Format money
|
|
7
|
+
* @returns {string}
|
|
8
|
+
* @memberof Tools
|
|
9
|
+
* @param {number} amount
|
|
10
|
+
* */
|
|
11
|
+
this.formatMoney = (amount) => {
|
|
12
|
+
return new Intl.NumberFormat('id-ID', {
|
|
13
|
+
style: 'currency',
|
|
14
|
+
currency: 'IDR'
|
|
15
|
+
}).format(amount);
|
|
16
|
+
};
|
|
5
17
|
/**
|
|
6
18
|
* Generate a random string
|
|
7
19
|
* @returns {string}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ayiin",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "Library Pribadi Yang Gak Ada Isinya",
|
|
5
5
|
"main": "ayiin/index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"build": "yarn tsc"
|
|
8
8
|
},
|
|
9
|
-
"repository": "https://github.com/AyiinXd/
|
|
9
|
+
"repository": "https://github.com/AyiinXd/ayiin",
|
|
10
10
|
"author": {
|
|
11
11
|
"name": "AyiinXd",
|
|
12
12
|
"url": "https://github.com/AyiinXd"
|