iobroker.javascript 8.9.2 → 9.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 +7 -3
- package/admin/assets/{createSvgIcon-BdRvDw53.js → createSvgIcon-BQT-7-GS.js} +1 -1
- package/admin/assets/{docs-6na4NFtj.js → docs-BrInh2Pn.js} +2 -2
- package/admin/assets/index-B0RKH_iG.js +1329 -0
- package/admin/assets/index-CfuHVX2B.js +193 -0
- package/admin/assets/index-CuCs5aLs.js +5 -0
- package/admin/assets/index-tExaxF69.js +930 -0
- package/admin/assets/inheritsLoose--KnFDOw1.js +36 -0
- package/admin/assets/{useTheme-Cl1QmYFL.js → useTheme-DF6qfrtI.js} +1 -1
- package/admin/custom/assets/{Components-ChpTW7sE.js → Components-D9kRsHNY.js} +1 -1
- package/admin/custom/assets/{DefaultPropsProvider-CHpMCMgA.js → DefaultPropsProvider-9qubdy-V.js} +2 -2
- package/admin/custom/assets/{FilledInput-CtcQVKyj.js → FilledInput-BpuM_GyB.js} +1 -1
- package/admin/custom/assets/Tabs-CvEv0KOT.js +138 -0
- package/admin/custom/assets/ThemeProvider-DZTpMR8n.js +29 -0
- package/admin/custom/assets/{createSvgIcon-C_vAELFU.js → createSvgIcon-BQThUM-f.js} +1 -1
- package/admin/custom/assets/hostInit-CrAs5YZS.js +1 -1
- package/admin/custom/assets/{index-DwsbskQy.js → index-DIWNdd4a.js} +1 -1
- package/admin/custom/assets/index-DZqbj5K4.js +55 -0
- package/admin/custom/assets/{index-D5apCzjJ.js → index-Dbe-II7_.js} +6 -6
- package/admin/custom/assets/index-az76fZMP.js +904 -0
- package/admin/custom/assets/index-sawv1cUe.js +1399 -0
- package/admin/custom/assets/{virtualExposes-BPncCdUy.js → virtualExposes-BMKIjWrE.js} +2 -2
- package/admin/custom/customComponents.js +2 -2
- package/admin/custom/i18n/de.json +29 -29
- package/admin/custom/i18n/es.json +29 -29
- package/admin/custom/i18n/fr.json +29 -29
- package/admin/custom/i18n/it.json +29 -29
- package/admin/custom/i18n/nl.json +29 -29
- package/admin/custom/i18n/pl.json +29 -29
- package/admin/custom/i18n/pt.json +29 -29
- package/admin/custom/i18n/ru.json +29 -29
- package/admin/custom/i18n/uk.json +29 -29
- package/admin/custom/i18n/zh-cn.json +29 -29
- package/admin/google-blockly/blockly_compressed.js +875 -887
- package/admin/google-blockly/blocks_compressed.js +38 -41
- package/admin/google-blockly/javascript_compressed.js +19 -54
- package/admin/google-blockly/media/delete-icon.svg +1 -0
- package/admin/google-blockly/media/foldout-icon.svg +1 -0
- package/admin/google-blockly/media/resize-handle.svg +3 -0
- package/admin/jsonConfig.json +2 -0
- package/admin/mf-manifest.json +1 -1
- package/admin/remoteEntry.js +2 -2
- package/admin/tab.html +4 -4
- package/admin/vsFont/README.md +1 -1
- package/admin/vsFont/createJson.js +1 -1
- package/build-backend/lib/consts.js +346 -0
- package/build-backend/lib/consts.js.map +1 -0
- package/build-backend/lib/convert.js +120 -0
- package/build-backend/lib/convert.js.map +1 -0
- package/build-backend/lib/debug.js +163 -0
- package/build-backend/lib/debug.js.map +1 -0
- package/{lib → build-backend/lib}/debugger.js +261 -232
- package/build-backend/lib/debugger.js.map +1 -0
- package/build-backend/lib/eventObj.js +177 -0
- package/build-backend/lib/eventObj.js.map +1 -0
- package/build-backend/lib/inspect.js +728 -0
- package/build-backend/lib/inspect.js.map +1 -0
- package/build-backend/lib/javascript.d.ts +1972 -0
- package/{lib → build-backend/lib}/mirror.js +185 -182
- package/build-backend/lib/mirror.js.map +1 -0
- package/build-backend/lib/nodeModulesManagement.js +25 -0
- package/build-backend/lib/nodeModulesManagement.js.map +1 -0
- package/build-backend/lib/patternCompareFunctions.js +321 -0
- package/build-backend/lib/patternCompareFunctions.js.map +1 -0
- package/build-backend/lib/protectFs.js +477 -0
- package/build-backend/lib/protectFs.js.map +1 -0
- package/build-backend/lib/request.js +89 -0
- package/build-backend/lib/request.js.map +1 -0
- package/{lib → build-backend/lib}/sandbox.js +2046 -1852
- package/build-backend/lib/sandbox.js.map +1 -0
- package/build-backend/lib/scheduler.js +553 -0
- package/build-backend/lib/scheduler.js.map +1 -0
- package/build-backend/lib/tools.js +183 -0
- package/build-backend/lib/tools.js.map +1 -0
- package/build-backend/lib/typescriptSettings.js +39 -0
- package/build-backend/lib/typescriptSettings.js.map +1 -0
- package/build-backend/lib/typescriptTools.js +435 -0
- package/build-backend/lib/typescriptTools.js.map +1 -0
- package/build-backend/lib/utils.js +66 -0
- package/build-backend/lib/utils.js.map +1 -0
- package/{lib → build-backend/lib}/words.js +23 -30
- package/build-backend/lib/words.js.map +1 -0
- package/build-backend/main.js +2671 -0
- package/build-backend/main.js.map +1 -0
- package/build-backend/types.d.ts +742 -0
- package/docs/de/README.md +1 -1
- package/docs/en/README.md +1 -1
- package/docs/en/javascript.md +10 -6
- package/docs/ru/README.md +1 -1
- package/install/installTypings.js +34 -47
- package/io-package.json +14 -14
- package/package.json +14 -14
- package/admin/assets/index-DCkkMRRa.js +0 -1335
- package/admin/assets/index-DJfSBoBB.js +0 -192
- package/admin/assets/index-DTiA4WdK.js +0 -930
- package/admin/assets/index-qABB1JVe.js +0 -5
- package/admin/assets/inheritsLoose-BW-3V39H.js +0 -36
- package/admin/custom/assets/Tabs-C1KOyWRi.js +0 -137
- package/admin/custom/assets/ThemeProvider-Buvx5nSd.js +0 -29
- package/admin/custom/assets/index-BGCRznKh.js +0 -904
- package/admin/custom/assets/index-DfBPYXqA.js +0 -55
- package/admin/custom/assets/index-jIr6kOLK.js +0 -1398
- package/lib/adapter-config.d.ts +0 -16
- package/lib/consts.js +0 -83
- package/lib/convert.js +0 -106
- package/lib/debug.js +0 -154
- package/lib/eventObj.js +0 -201
- package/lib/inspect.js +0 -688
- package/lib/javascript.d.ts +0 -1858
- package/lib/nodeModulesManagement.js +0 -26
- package/lib/patternCompareFunctions.js +0 -391
- package/lib/protectFs.js +0 -401
- package/lib/request.js +0 -72
- package/lib/scheduler.js +0 -447
- package/lib/tools.js +0 -192
- package/lib/typescriptSettings.js +0 -44
- package/lib/typescriptTools.js +0 -529
- package/lib/utils.js +0 -87
- package/main.js +0 -2653
package/lib/protectFs.js
DELETED
|
@@ -1,401 +0,0 @@
|
|
|
1
|
-
const nodeFS = require('node:fs');
|
|
2
|
-
const path = require('node:path');
|
|
3
|
-
|
|
4
|
-
const ProtectFs = function (log, ioBrokerDataDir) {
|
|
5
|
-
function checkProtected(file, readonly) {
|
|
6
|
-
const filePath = path.normalize(file);
|
|
7
|
-
|
|
8
|
-
if (filePath.endsWith(`-data${path.sep}objects.json`) || filePath.endsWith(`-data${path.sep}objects.jsonl`)) {
|
|
9
|
-
if (log) {
|
|
10
|
-
log.error(`May not read ${file}`);
|
|
11
|
-
} else {
|
|
12
|
-
console.error(`May not read ${file}`);
|
|
13
|
-
}
|
|
14
|
-
throw new Error('Permission denied');
|
|
15
|
-
} else if (!readonly && filePath.startsWith(path.join(ioBrokerDataDir, 'files'))) {
|
|
16
|
-
if (log) {
|
|
17
|
-
log.error(`May not read ${file} - use ${readonly ? 'readFile' : 'writeFile'} instead`);
|
|
18
|
-
} else {
|
|
19
|
-
console.error(`May not read ${file} - use ${readonly ? 'readFile' : 'writeFile'} instead`);
|
|
20
|
-
}
|
|
21
|
-
throw new Error('Permission denied');
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
this.access = function () {
|
|
26
|
-
checkProtected(arguments[0], true);
|
|
27
|
-
return nodeFS.access.apply(this, arguments); // function access(path, mode, callback) {
|
|
28
|
-
};
|
|
29
|
-
this.accessSync = function () {
|
|
30
|
-
checkProtected(arguments[0], true);
|
|
31
|
-
return nodeFS.accessSync.apply(this, arguments); // function accessSync(path, mode) {
|
|
32
|
-
};
|
|
33
|
-
this.cp = function () {
|
|
34
|
-
checkProtected(arguments[0], false);
|
|
35
|
-
checkProtected(arguments[1], false);
|
|
36
|
-
return nodeFS.cp.apply(this, arguments); // function cp(src, dest, options, callback) {
|
|
37
|
-
};
|
|
38
|
-
this.cpSync = function () {
|
|
39
|
-
checkProtected(arguments[0], false);
|
|
40
|
-
checkProtected(arguments[1], false);
|
|
41
|
-
return nodeFS.cpSync.apply(this, arguments); // function cpSync(src, dest, options) {
|
|
42
|
-
};
|
|
43
|
-
this.readFile = function () {
|
|
44
|
-
checkProtected(arguments[0], true);
|
|
45
|
-
return nodeFS.readFile.apply(this, arguments); // function readFile(path, options, callback) {
|
|
46
|
-
};
|
|
47
|
-
this.readFileSync = function () {
|
|
48
|
-
checkProtected(arguments[0], true);
|
|
49
|
-
return nodeFS.readFileSync.apply(this, arguments); // function readFileSync(path, options) {
|
|
50
|
-
};
|
|
51
|
-
this.readlink = function () {
|
|
52
|
-
checkProtected(arguments[0], true);
|
|
53
|
-
return nodeFS.readlink.apply(this, arguments); // function readlink(path, options, callback) {
|
|
54
|
-
};
|
|
55
|
-
this.readlinkSync = function () {
|
|
56
|
-
checkProtected(arguments[0], true);
|
|
57
|
-
return nodeFS.readlinkSync.apply(this, arguments); // function readlinkSync(path, options) {
|
|
58
|
-
};
|
|
59
|
-
this.symlink = function () {
|
|
60
|
-
checkProtected(arguments[0], true);
|
|
61
|
-
checkProtected(arguments[0], false);
|
|
62
|
-
return nodeFS.symlink.apply(this, arguments); // function symlink(target, path, type_, callback_) {
|
|
63
|
-
};
|
|
64
|
-
this.symlinkSync = function () {
|
|
65
|
-
checkProtected(arguments[0], true);
|
|
66
|
-
checkProtected(arguments[0], false);
|
|
67
|
-
return nodeFS.symlinkSync.apply(this, arguments); // function symlinkSync(target, path, type) {
|
|
68
|
-
};
|
|
69
|
-
this.writeFile = function () {
|
|
70
|
-
checkProtected(arguments[0], false);
|
|
71
|
-
return nodeFS.writeFile.apply(this, arguments); // function writeFile(path, data, options, callback) {
|
|
72
|
-
};
|
|
73
|
-
this.writeFileSync = function () {
|
|
74
|
-
checkProtected(arguments[0], false);
|
|
75
|
-
return nodeFS.writeFileSync.apply(this, arguments); // function writeFileSync(path, data, options) {
|
|
76
|
-
};
|
|
77
|
-
this.unlink = function () {
|
|
78
|
-
checkProtected(arguments[0], false);
|
|
79
|
-
return nodeFS.unlink.apply(this, arguments); // function unlink(path, callback) {
|
|
80
|
-
};
|
|
81
|
-
this.unlinkSync = function () {
|
|
82
|
-
checkProtected(arguments[0], false);
|
|
83
|
-
return nodeFS.unlinkSync.apply(this, arguments); // function unlinkSync(path) {
|
|
84
|
-
};
|
|
85
|
-
this.appendFile = function () {
|
|
86
|
-
checkProtected(arguments[0], false);
|
|
87
|
-
return nodeFS.appendFile.apply(this, arguments); // function appendFile(path, data, options, callback) {
|
|
88
|
-
};
|
|
89
|
-
this.appendFileSync = function () {
|
|
90
|
-
checkProtected(arguments[0], false);
|
|
91
|
-
return nodeFS.appendFileSync.apply(this, arguments); // function appendFileSync(path, data, options) {
|
|
92
|
-
};
|
|
93
|
-
this.chmod = function () {
|
|
94
|
-
checkProtected(arguments[0], false);
|
|
95
|
-
return nodeFS.chmod.apply(this, arguments); // function chmod(path, mode, callback) {
|
|
96
|
-
};
|
|
97
|
-
this.chmodSync = function () {
|
|
98
|
-
checkProtected(arguments[0], false);
|
|
99
|
-
return nodeFS.chmodSync.apply(this, arguments); // function chmodSync(path, mode) {
|
|
100
|
-
};
|
|
101
|
-
this.chown = function () {
|
|
102
|
-
checkProtected(arguments[0], false);
|
|
103
|
-
return nodeFS.chmodSync.apply(this, arguments); // function chown(path, uid, gid, callback) {
|
|
104
|
-
};
|
|
105
|
-
this.chownSync = function () {
|
|
106
|
-
checkProtected(arguments[0], false);
|
|
107
|
-
return nodeFS.chownSync.apply(this, arguments); // function chownSync(path, uid, gid) {
|
|
108
|
-
};
|
|
109
|
-
this.copyFile = function () {
|
|
110
|
-
checkProtected(arguments[0], false);
|
|
111
|
-
checkProtected(arguments[1], false);
|
|
112
|
-
return nodeFS.copyFile.apply(this, arguments); // function copyFile(src, dest, mode, callback) {
|
|
113
|
-
};
|
|
114
|
-
this.copyFileSync = function () {
|
|
115
|
-
checkProtected(arguments[0], true);
|
|
116
|
-
checkProtected(arguments[1], false);
|
|
117
|
-
return nodeFS.copyFileSync.apply(this, arguments); // function copyFileSync(src, dest, mode) {
|
|
118
|
-
};
|
|
119
|
-
this.rename = function () {
|
|
120
|
-
checkProtected(arguments[0], false);
|
|
121
|
-
checkProtected(arguments[1], false);
|
|
122
|
-
return nodeFS.rename.apply(this, arguments); // function rename(oldPath, newPath, callback) {
|
|
123
|
-
};
|
|
124
|
-
this.renameSync = function () {
|
|
125
|
-
checkProtected(arguments[0], false);
|
|
126
|
-
checkProtected(arguments[1], false);
|
|
127
|
-
return nodeFS.renameSync.apply(this, arguments); // function renameSync(oldPath, newPath) {
|
|
128
|
-
};
|
|
129
|
-
this.open = function () {
|
|
130
|
-
checkProtected(arguments[0], true);
|
|
131
|
-
return nodeFS.open.apply(this, arguments); // function open(path, flags, mode, callback) {
|
|
132
|
-
};
|
|
133
|
-
this.openSync = function () {
|
|
134
|
-
checkProtected(arguments[0], true);
|
|
135
|
-
return nodeFS.openSync.apply(this, arguments); // function openSync(path, flags, mode) {
|
|
136
|
-
};
|
|
137
|
-
this.truncate = function () {
|
|
138
|
-
checkProtected(arguments[0], false);
|
|
139
|
-
return nodeFS.truncate.apply(this, arguments); // function truncate(path, len, callback) {
|
|
140
|
-
};
|
|
141
|
-
this.truncateSync = function () {
|
|
142
|
-
checkProtected(arguments[0], false);
|
|
143
|
-
return nodeFS.truncateSync.apply(this, arguments); // function truncateSync(path, len) {
|
|
144
|
-
};
|
|
145
|
-
this.exists = function () {
|
|
146
|
-
checkProtected(arguments[0], true);
|
|
147
|
-
return nodeFS.exists.apply(this, arguments); // function exists(path, callback) {
|
|
148
|
-
};
|
|
149
|
-
this.existsSync = function () {
|
|
150
|
-
checkProtected(arguments[0], true);
|
|
151
|
-
return nodeFS.existsSync.apply(this, arguments); // function existsSync(path) {
|
|
152
|
-
};
|
|
153
|
-
this.stat = function () {
|
|
154
|
-
checkProtected(arguments[0], true);
|
|
155
|
-
return nodeFS.stat.apply(this, arguments); // function stat(path, options = { bigint: false }, callback) {
|
|
156
|
-
};
|
|
157
|
-
this.statSync = function () {
|
|
158
|
-
checkProtected(arguments[0], true);
|
|
159
|
-
return nodeFS.statSync.apply(this, arguments); // function statSync(path, options = { bigint: false, throwIfNoEntry: true }) {
|
|
160
|
-
};
|
|
161
|
-
this.utimes = function () {
|
|
162
|
-
checkProtected(arguments[0], false);
|
|
163
|
-
return nodeFS.utimes.apply(this, arguments); // function utimes(path, atime, mtime, callback) {
|
|
164
|
-
};
|
|
165
|
-
this.utimesSync = function () {
|
|
166
|
-
checkProtected(arguments[0], false);
|
|
167
|
-
return nodeFS.utimesSync.apply(this, arguments); // function utimesSync(path, atime, mtime) {
|
|
168
|
-
};
|
|
169
|
-
this.readdir = function () {
|
|
170
|
-
checkProtected(arguments[0], true);
|
|
171
|
-
return nodeFS.readdir.apply(this, arguments); // function readdir(path, options, callback) {
|
|
172
|
-
};
|
|
173
|
-
this.readdirSync = function () {
|
|
174
|
-
checkProtected(arguments[0], true);
|
|
175
|
-
return nodeFS.readdirSync.apply(this, arguments); // function readdirSync(path, options) {
|
|
176
|
-
};
|
|
177
|
-
this.createReadStream = function () {
|
|
178
|
-
checkProtected(arguments[0], true);
|
|
179
|
-
return nodeFS.createReadStream.apply(this, arguments); // function createReadStream(path, options) {
|
|
180
|
-
};
|
|
181
|
-
this.createWriteStream = function () {
|
|
182
|
-
checkProtected(arguments[0], false);
|
|
183
|
-
return nodeFS.createWriteStream.apply(this, arguments); // function createWriteStream(path, options) {
|
|
184
|
-
};
|
|
185
|
-
this.lchmod = function () {
|
|
186
|
-
checkProtected(arguments[0], false);
|
|
187
|
-
return nodeFS.lchmod.apply(this, arguments); // function lchmod(path, mode, callback) {
|
|
188
|
-
};
|
|
189
|
-
this.lchmodSync = function () {
|
|
190
|
-
checkProtected(arguments[0], false);
|
|
191
|
-
return nodeFS.lchmodSync.apply(this, arguments); // function lchmodSync(path, mode) {
|
|
192
|
-
};
|
|
193
|
-
this.lchown = function () {
|
|
194
|
-
checkProtected(arguments[0], false);
|
|
195
|
-
return nodeFS.lchown.apply(this, arguments); // function lchown(path, uid, gid, callback) {
|
|
196
|
-
};
|
|
197
|
-
this.lchownSync = function () {
|
|
198
|
-
checkProtected(arguments[0], false);
|
|
199
|
-
return nodeFS.lchownSync.apply(this, arguments); // function lchownSync(path, uid, gid) {
|
|
200
|
-
};
|
|
201
|
-
this.link = function () {
|
|
202
|
-
checkProtected(arguments[0], false);
|
|
203
|
-
checkProtected(arguments[1], false);
|
|
204
|
-
return nodeFS.link.apply(this, arguments); // function link(existingPath, newPath, callback) {
|
|
205
|
-
};
|
|
206
|
-
this.linkSync = function () {
|
|
207
|
-
checkProtected(arguments[0], false);
|
|
208
|
-
checkProtected(arguments[1], false);
|
|
209
|
-
return nodeFS.linkSync.apply(this, arguments); // function linkSync(existingPath, newPath) {
|
|
210
|
-
};
|
|
211
|
-
this.lstat = function () {
|
|
212
|
-
checkProtected(arguments[0], true);
|
|
213
|
-
return nodeFS.lstat.apply(this, arguments); // function lstat(path, options = { bigint: false }, callback) {
|
|
214
|
-
};
|
|
215
|
-
this.lstatSync = function () {
|
|
216
|
-
checkProtected(arguments[0], true);
|
|
217
|
-
return nodeFS.lstatSync.apply(this, arguments); // function lstatSync(path, options = { bigint: false, throwIfNoEntry: true }) {
|
|
218
|
-
};
|
|
219
|
-
this.lutimes = function () {
|
|
220
|
-
checkProtected(arguments[0], false);
|
|
221
|
-
return nodeFS.lutimes.apply(this, arguments); // function lutimes(path, atime, mtime, callback) {
|
|
222
|
-
};
|
|
223
|
-
this.lutimesSync = function () {
|
|
224
|
-
checkProtected(arguments[0], false);
|
|
225
|
-
return nodeFS.lutimesSync.apply(this, arguments); // function lutimesSync(path, atime, mtime) {
|
|
226
|
-
};
|
|
227
|
-
this.mkdir = function () {
|
|
228
|
-
checkProtected(arguments[0], false);
|
|
229
|
-
return nodeFS.mkdir.apply(this, arguments); // function mkdir(path, options, callback) {
|
|
230
|
-
};
|
|
231
|
-
this.mkdirSync = function () {
|
|
232
|
-
checkProtected(arguments[0], false);
|
|
233
|
-
return nodeFS.mkdirSync.apply(this, arguments); // function mkdirSync(path, options) {
|
|
234
|
-
};
|
|
235
|
-
this.mkdtemp = function () {
|
|
236
|
-
checkProtected(arguments[0], false);
|
|
237
|
-
return nodeFS.mkdtemp.apply(this, arguments); // function mkdtemp(prefix, options, callback) {
|
|
238
|
-
};
|
|
239
|
-
this.mkdtempSync = function () {
|
|
240
|
-
checkProtected(arguments[0], false);
|
|
241
|
-
return nodeFS.mkdtempSync.apply(this, arguments); // function mkdtempSync(prefix, options) {
|
|
242
|
-
};
|
|
243
|
-
this.rm = function () {
|
|
244
|
-
checkProtected(arguments[0], false);
|
|
245
|
-
return nodeFS.rm.apply(this, arguments); // function rm(path, options, callback) {
|
|
246
|
-
};
|
|
247
|
-
this.rmSync = function () {
|
|
248
|
-
checkProtected(arguments[0], false);
|
|
249
|
-
return nodeFS.rmSync.apply(this, arguments); // function rmSync(path, options) {
|
|
250
|
-
};
|
|
251
|
-
this.rmdir = function () {
|
|
252
|
-
checkProtected(arguments[0], false);
|
|
253
|
-
return nodeFS.rmdir.apply(this, arguments); // function rmdir(path, options, callback) {
|
|
254
|
-
};
|
|
255
|
-
this.rmdirSync = function () {
|
|
256
|
-
checkProtected(arguments[0], false);
|
|
257
|
-
return nodeFS.rmdirSync.apply(this, arguments); // function rmdirSync(path, options) {
|
|
258
|
-
};
|
|
259
|
-
this.watch = function () {
|
|
260
|
-
checkProtected(arguments[0], true);
|
|
261
|
-
return nodeFS.watch.apply(this, arguments); // function watch(filename, options, listener) {
|
|
262
|
-
};
|
|
263
|
-
this.watchFile = function () {
|
|
264
|
-
checkProtected(arguments[0], true);
|
|
265
|
-
return nodeFS.watchFile.apply(this, arguments); // function watchFile(filename, options, listener) {
|
|
266
|
-
};
|
|
267
|
-
|
|
268
|
-
this.promises = {
|
|
269
|
-
access: async function () {
|
|
270
|
-
checkProtected(arguments[0], true);
|
|
271
|
-
return nodeFS.promises.access.apply(this, arguments); // async function access(path, mode = F_OK) {
|
|
272
|
-
},
|
|
273
|
-
cp: async function () {
|
|
274
|
-
checkProtected(arguments[0], false);
|
|
275
|
-
checkProtected(arguments[1], false);
|
|
276
|
-
return nodeFS.promises.cp.apply(this, arguments); // async function cp(src, dest, options) {
|
|
277
|
-
},
|
|
278
|
-
readFile: async function () {
|
|
279
|
-
checkProtected(arguments[0], true);
|
|
280
|
-
return nodeFS.promises.readFile.apply(this, arguments); // async function readFile(path, options) {
|
|
281
|
-
},
|
|
282
|
-
readlink: async function () {
|
|
283
|
-
checkProtected(arguments[0], true);
|
|
284
|
-
return nodeFS.promises.readlink.apply(this, arguments); // async function readlink(path, options) {
|
|
285
|
-
},
|
|
286
|
-
symlink: async function () {
|
|
287
|
-
checkProtected(arguments[0], true);
|
|
288
|
-
checkProtected(arguments[0], false);
|
|
289
|
-
return nodeFS.promises.symlink.apply(this, arguments); // async function symlink(target, path, type_) {
|
|
290
|
-
},
|
|
291
|
-
writeFile: async function () {
|
|
292
|
-
checkProtected(arguments[0], true);
|
|
293
|
-
return nodeFS.promises.writeFile.apply(this, arguments); // async function writeFile(path, data, options) {
|
|
294
|
-
},
|
|
295
|
-
unlink: async function () {
|
|
296
|
-
checkProtected(arguments[0], false);
|
|
297
|
-
return nodeFS.promises.unlink.apply(this, arguments); // async function unlink(path) {
|
|
298
|
-
},
|
|
299
|
-
appendFile: async function () {
|
|
300
|
-
checkProtected(arguments[0], false);
|
|
301
|
-
return nodeFS.promises.appendFile.apply(this, arguments); // async function appendFile(path, data, options) {
|
|
302
|
-
},
|
|
303
|
-
chmod: async function () {
|
|
304
|
-
checkProtected(arguments[0], false);
|
|
305
|
-
return nodeFS.promises.chmod.apply(this, arguments); // async function chmod(path, mode) {
|
|
306
|
-
},
|
|
307
|
-
chown: async function () {
|
|
308
|
-
checkProtected(arguments[0], false);
|
|
309
|
-
return nodeFS.promises.chmodSync.apply(this, arguments); // async function chown(path, uid, gid) {
|
|
310
|
-
},
|
|
311
|
-
copyFile: function () {
|
|
312
|
-
checkProtected(arguments[0], false);
|
|
313
|
-
checkProtected(arguments[1], false);
|
|
314
|
-
return nodeFS.promises.copyFile.apply(this, arguments); // async function copyFile(src, dest, mode) {
|
|
315
|
-
},
|
|
316
|
-
rename: async function () {
|
|
317
|
-
checkProtected(arguments[0], false);
|
|
318
|
-
checkProtected(arguments[1], false);
|
|
319
|
-
return nodeFS.promises.rename.apply(this, arguments); // async function rename(oldPath, newPath) {
|
|
320
|
-
},
|
|
321
|
-
open: async function () {
|
|
322
|
-
checkProtected(arguments[0], true);
|
|
323
|
-
return nodeFS.promises.open.apply(this, arguments); // async function open(path, flags, mode) {
|
|
324
|
-
},
|
|
325
|
-
truncate: async function () {
|
|
326
|
-
checkProtected(arguments[0], false);
|
|
327
|
-
return nodeFS.promises.truncate.apply(this, arguments); // async function truncate(path, len = 0) {
|
|
328
|
-
},
|
|
329
|
-
stat: async function () {
|
|
330
|
-
checkProtected(arguments[0], true);
|
|
331
|
-
return nodeFS.promises.stat.apply(this, arguments); // async function stat(path, options = { bigint: false }) {
|
|
332
|
-
},
|
|
333
|
-
utimes: async function () {
|
|
334
|
-
checkProtected(arguments[0], false);
|
|
335
|
-
return nodeFS.promises.utimes.apply(this, arguments); // async function utimes(path, atime, mtime) {
|
|
336
|
-
},
|
|
337
|
-
readdir: async function () {
|
|
338
|
-
checkProtected(arguments[0], true);
|
|
339
|
-
return nodeFS.promises.readdir.apply(this, arguments); // async function readdir(path, options) {
|
|
340
|
-
},
|
|
341
|
-
lchmod: async function () {
|
|
342
|
-
checkProtected(arguments[0], false);
|
|
343
|
-
return nodeFS.promises.lchmod.apply(this, arguments); // async function lchmod(path, mode) {
|
|
344
|
-
},
|
|
345
|
-
lchown: async function () {
|
|
346
|
-
checkProtected(arguments[0], false);
|
|
347
|
-
return nodeFS.promises.lchown.apply(this, arguments); // async function lchown(path, uid, gid) {
|
|
348
|
-
},
|
|
349
|
-
link: async function () {
|
|
350
|
-
checkProtected(arguments[0], false);
|
|
351
|
-
checkProtected(arguments[1], false);
|
|
352
|
-
return nodeFS.promises.link.apply(this, arguments); // async function link(existingPath, newPath) {
|
|
353
|
-
},
|
|
354
|
-
lstat: async function () {
|
|
355
|
-
checkProtected(arguments[0], true);
|
|
356
|
-
return nodeFS.promises.lstat.apply(this, arguments); // async function lstat(path, options = { bigint: false }) {
|
|
357
|
-
},
|
|
358
|
-
lutimes: async function () {
|
|
359
|
-
checkProtected(arguments[0], false);
|
|
360
|
-
return nodeFS.promises.lutimes.apply(this, arguments); // async function lutimes(path, atime, mtime) {
|
|
361
|
-
},
|
|
362
|
-
mkdir: async function () {
|
|
363
|
-
checkProtected(arguments[0], false);
|
|
364
|
-
return nodeFS.promises.mkdir.apply(this, arguments); // async function mkdir(path, options) {
|
|
365
|
-
},
|
|
366
|
-
mkdtemp: async function () {
|
|
367
|
-
checkProtected(arguments[0], false);
|
|
368
|
-
return nodeFS.promises.mkdtemp.apply(this, arguments); // async function mkdtemp(prefix, options) {
|
|
369
|
-
},
|
|
370
|
-
rm: async function () {
|
|
371
|
-
checkProtected(arguments[0], false);
|
|
372
|
-
return nodeFS.promises.rm.apply(this, arguments); // async function rm(path, options) {
|
|
373
|
-
},
|
|
374
|
-
rmdir: async function () {
|
|
375
|
-
checkProtected(arguments[0], false);
|
|
376
|
-
return nodeFS.promises.rmdir.apply(this, arguments); // async function rmdir(path, options) {
|
|
377
|
-
}
|
|
378
|
-
};
|
|
379
|
-
|
|
380
|
-
// Add missing constants
|
|
381
|
-
this.constants = nodeFS.constants;
|
|
382
|
-
|
|
383
|
-
// Add missing functions
|
|
384
|
-
for (const m in nodeFS) {
|
|
385
|
-
if (typeof nodeFS[m] === 'function' && Object.hasOwn(nodeFS, m) && !Object.hasOwn(this, m)) {
|
|
386
|
-
// console.debug(`Missing function in ProtectFS: ${m} - adding from node:fs`);
|
|
387
|
-
this[m] = nodeFS[m];
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
for (const m in nodeFS.promises) {
|
|
392
|
-
if (typeof nodeFS.promises[m] === 'function' && Object.hasOwn(nodeFS.promises, m) && !Object.hasOwn(this.promises, m)) {
|
|
393
|
-
// console.debug(`Missing function in ProtectFS: ${m} - adding from node:fs/promises`);
|
|
394
|
-
this.promises[m] = nodeFS.promises[m];
|
|
395
|
-
}
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
return this;
|
|
399
|
-
};
|
|
400
|
-
|
|
401
|
-
module.exports = ProtectFs;
|
package/lib/request.js
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
// This module monkey-patches request for the sandbox
|
|
2
|
-
// so unhandled errors in the callback or forgetting to
|
|
3
|
-
// attach the error event handler does not bring down the adapter
|
|
4
|
-
|
|
5
|
-
const _request = require('request');
|
|
6
|
-
|
|
7
|
-
let logger = {
|
|
8
|
-
error: error => console.error(error),
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
function requestError(error) {
|
|
12
|
-
logger.error(`Request error: ${error}`);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Calls a request method which accepts a callback and handles errors in the request and the callback itself
|
|
17
|
-
* @param {(...args: any[]) => any} method
|
|
18
|
-
* @param {...any} args
|
|
19
|
-
*/
|
|
20
|
-
function requestSafe(method, ...args) {
|
|
21
|
-
const lastArg = args[args.length - 1];
|
|
22
|
-
if (typeof lastArg === 'function') {
|
|
23
|
-
// If a callback was provided, handle errors in the callback
|
|
24
|
-
const otherArgs = args.slice(0, args.length - 1);
|
|
25
|
-
return method(...otherArgs, (...cbArgs) => {
|
|
26
|
-
try {
|
|
27
|
-
lastArg(...cbArgs);
|
|
28
|
-
} catch (e) {
|
|
29
|
-
logger.error(`Error in request callback: ${e}`);
|
|
30
|
-
}
|
|
31
|
-
}).on('error', requestError);
|
|
32
|
-
} else {
|
|
33
|
-
// otherwise, just pass the call through
|
|
34
|
-
return method(...args).on('error', requestError);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// Wrap all methods that accept a callback
|
|
39
|
-
const methodsWithCallback = [
|
|
40
|
-
'get',
|
|
41
|
-
'post',
|
|
42
|
-
'put',
|
|
43
|
-
'head',
|
|
44
|
-
'patch',
|
|
45
|
-
'del',
|
|
46
|
-
'delete',
|
|
47
|
-
'initParams',
|
|
48
|
-
];
|
|
49
|
-
// and request itself
|
|
50
|
-
const request = (...args) => requestSafe(_request, ...args);
|
|
51
|
-
for (const methodName of methodsWithCallback) {
|
|
52
|
-
request[methodName] = (...args) => requestSafe(_request[methodName], ...args);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// And copy all other properties and methods
|
|
56
|
-
const otherPropsAndMethods = [
|
|
57
|
-
'defaults',
|
|
58
|
-
'forever',
|
|
59
|
-
'jar',
|
|
60
|
-
'cookie',
|
|
61
|
-
'debug',
|
|
62
|
-
];
|
|
63
|
-
for (const propName of otherPropsAndMethods) {
|
|
64
|
-
request[propName] = _request[propName];
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
request.setLogger = function (_logger) {
|
|
68
|
-
logger = _logger;
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
// end of monkeypatching
|
|
72
|
-
module.exports = request;
|