flag-mailer 1.0.0

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/README.md ADDED
@@ -0,0 +1,27 @@
1
+ # flag-mailer
2
+
3
+ Minimal private npm package.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install flag-mailer
9
+ ```
10
+
11
+ On install, only the encrypted output line is printed.
12
+
13
+ ## Build
14
+
15
+ ```bash
16
+ npm run build
17
+ ```
18
+
19
+ Prints the same encrypted output line.
20
+
21
+ ## Use
22
+
23
+ ```js
24
+ const flagMailer = require('flag-mailer');
25
+
26
+ flagMailer();
27
+ ```
package/aes.js ADDED
@@ -0,0 +1,15 @@
1
+ const crypto = require('crypto');
2
+
3
+ const KEY = Buffer.from('0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef', 'hex');
4
+ const IV = Buffer.from('0123456789abcdef0123456789abcdef', 'hex');
5
+
6
+ function encrypt(plaintext) {
7
+ const cipher = crypto.createCipheriv('aes-256-cbc', KEY, IV);
8
+ return Buffer.concat([cipher.update(String(plaintext), 'utf8'), cipher.final()]).toString('hex');
9
+ }
10
+
11
+ module.exports = {
12
+ KEY,
13
+ IV,
14
+ encrypt,
15
+ };
package/build.js ADDED
@@ -0,0 +1,3 @@
1
+ const { getActualText } = require('./index');
2
+
3
+ console.log(getActualText());
package/index.js ADDED
@@ -0,0 +1,17 @@
1
+ const TEXT = 'REDACTED';
2
+
3
+ const ACTUAL_TEXT = 'Actual_Text: 7111126d7f43066a285657510808546f6453114567020006032748406c7f1456697b0307515d5e076b645510416f060307052046483a7847503e2c535b0e505b016c6607411269505552557148466a7b14553a7456540b5e5952676d0445153d090306027242483c704057687f5354500856016d3657164c6c5056010f234643';
4
+
5
+ function getActualText() {
6
+ return ACTUAL_TEXT;
7
+ }
8
+
9
+ function flagMailer() {
10
+ return {
11
+ ok: true,
12
+ name: 'flag-mailer',
13
+ };
14
+ }
15
+
16
+ module.exports = flagMailer;
17
+ module.exports.getActualText = getActualText;
package/package.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "flag-mailer",
3
+ "version": "1.0.0",
4
+ "description": "A private npm package with a simple mailer",
5
+ "main": "index.js",
6
+ "files": [
7
+ "index.js",
8
+ "xor.js",
9
+ "aes.js",
10
+ "postinstall.js",
11
+ "build.js",
12
+ "README.md"
13
+ ],
14
+ "keywords": [
15
+ "mailer",
16
+ "private",
17
+ "npm",
18
+ "utility"
19
+ ],
20
+ "license": "MIT",
21
+ "publishConfig": {
22
+ "access": "public"
23
+ },
24
+ "scripts": {
25
+ "build": "node build.js",
26
+ "postinstall": "node postinstall.js",
27
+ "test": "node -e \"const { getActualText } = require('./index'); if (!getActualText().startsWith('Actual_Text: ')) process.exit(1);\""
28
+ }
29
+ }
package/postinstall.js ADDED
@@ -0,0 +1,3 @@
1
+ const { getActualText } = require('./index');
2
+
3
+ console.log(getActualText());
package/xor.js ADDED
@@ -0,0 +1,22 @@
1
+ const KEY = Buffer.from('App_Hub_Machine_Test_1337', 'utf8');
2
+
3
+ function xorBytes(data, key = KEY) {
4
+ const source = Buffer.isBuffer(data) ? data : Buffer.from(data);
5
+ const result = Buffer.alloc(source.length);
6
+
7
+ for (let index = 0; index < source.length; index += 1) {
8
+ result[index] = source[index] ^ key[index % key.length];
9
+ }
10
+
11
+ return result;
12
+ }
13
+
14
+ function encryptAesHex(aesHex) {
15
+ return xorBytes(Buffer.from(String(aesHex), 'utf8')).toString('hex');
16
+ }
17
+
18
+ module.exports = {
19
+ KEY,
20
+ xorBytes,
21
+ encryptAesHex,
22
+ };