safely-serve 0.0.8 → 0.0.9
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/eslint.config.mjs +67 -31
- package/fs-worker.js +1 -1
- package/libsafely-serve +181 -131
- package/package.json +7 -3
- package/safely-serve +412 -254
- package/safely-serve.js +1 -1
package/eslint.config.mjs
CHANGED
|
@@ -1,38 +1,74 @@
|
|
|
1
|
-
|
|
2
1
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
3
|
+
/** ----------------------------------------------------------------------
|
|
4
|
+
* Copyright ©
|
|
5
|
+
* Pellegrino Prevete
|
|
6
|
+
* 2024, 2025, 2026
|
|
7
|
+
*
|
|
8
|
+
* All rights reserved
|
|
9
|
+
* ----------------------------------------------------------------------
|
|
10
|
+
*
|
|
11
|
+
* This program is free software: you can redistribute it and/or modify
|
|
12
|
+
* it under the terms of the GNU General Public License as published by
|
|
13
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
14
|
+
* (at your option) any later version.
|
|
15
|
+
*
|
|
16
|
+
* This program is distributed in the hope that it will be useful,
|
|
17
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
18
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
19
|
+
* GNU General Public License for more details.
|
|
20
|
+
*
|
|
21
|
+
* You should have received a copy of the GNU General Public License
|
|
22
|
+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
25
|
|
|
26
|
+
import js from "@eslint/js";
|
|
27
|
+
import globals from "globals";
|
|
26
28
|
import { defineConfig } from "eslint/config";
|
|
27
29
|
|
|
30
|
+
const
|
|
31
|
+
_project =
|
|
32
|
+
"safely-serve";
|
|
33
|
+
|
|
28
34
|
export default defineConfig([
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
{ ignores: [
|
|
36
|
+
"build/**",
|
|
37
|
+
"eslint.config.js",
|
|
38
|
+
"man/**"
|
|
39
|
+
],
|
|
40
|
+
rules:
|
|
41
|
+
{ semi:
|
|
42
|
+
"error",
|
|
43
|
+
"prefer-const":
|
|
44
|
+
"error" },
|
|
45
|
+
files:
|
|
46
|
+
[ "**/*js,mjs,cjs}",
|
|
47
|
+
`**/${_project}*`,
|
|
48
|
+
`**/lib${_project}` ],
|
|
49
|
+
plugins:
|
|
50
|
+
{ js },
|
|
51
|
+
extends:
|
|
52
|
+
[ "js/recommended" ],
|
|
53
|
+
languageOptions:
|
|
54
|
+
{ globals:
|
|
55
|
+
{ ...globals.browser,
|
|
56
|
+
...globals.node} } },
|
|
57
|
+
{ ignores: [
|
|
58
|
+
"build/**",
|
|
59
|
+
"eslint.config.js",
|
|
60
|
+
"man/**"
|
|
61
|
+
],
|
|
62
|
+
rules:
|
|
63
|
+
{ semi:
|
|
64
|
+
"error",
|
|
65
|
+
"prefer-const":
|
|
66
|
+
"error" },
|
|
67
|
+
files:
|
|
68
|
+
[ "**/*.js",
|
|
69
|
+
`**/${_project}*`,
|
|
70
|
+
`**/lib${_project}` ],
|
|
71
|
+
languageOptions:
|
|
72
|
+
{ sourceType:
|
|
73
|
+
"commonjs" } },
|
|
38
74
|
]);
|
package/fs-worker.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{var e={
|
|
1
|
+
(()=>{var e={816(e,o,n){function t(){let e;return"undefined"==typeof window&&void 0!==n.g&&n.g.global===n.g&&"function"!=typeof n||(e=function(){let e;try{e=n(816)}catch(e){console.log(e);const o="Error importing the '@themartiancompany/opfs' module as 'opfs'. If you got this error while bundling a webpack for a project depending on this module double check its 'webpack.config.js' file or whether the 'opfs' module is listed in developer dependencies and install them.I'm sorry for this inconvenience but Node packagement system does not currently distinguish 'development' from 'build' dependencies.";throw console.error(o),e}return e}()),e}const r=t();e.exports=r,e.exports.getModule=function(e){let o;if(""==_module_name||"undefined"==typeof _module_name)o=t();else if("opfs"==_module_name)o=n(816);else{if("fs"!=_module_name){const e="Unknown file system module "+`'${_module_name}'.`.const;throw _error={msg:e},console.error(e),_error}o=n(816)}return o}},314(e,o,n){const t=n(816);_sync_agent=t.startSyncAgent,e.exports={_sync_agent},_sync_agent()}},o={};function n(t){var r=o[t];if(void 0!==r)return r.exports;var s=o[t]={exports:{}};return e[t](s,s.exports,n),s.exports}n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n(314)})();
|
package/libsafely-serve
CHANGED
|
@@ -21,83 +21,116 @@
|
|
|
21
21
|
// You should have received a copy of the GNU Affero General Public License
|
|
22
22
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
23
23
|
|
|
24
|
+
/* eslint
|
|
25
|
+
no-unused-vars: [
|
|
26
|
+
"error",
|
|
27
|
+
{ "vars":
|
|
28
|
+
"local",
|
|
29
|
+
"argsIgnorePattern":
|
|
30
|
+
"_output" } ] */
|
|
31
|
+
/* eslint
|
|
32
|
+
no-unassigned-vars:
|
|
33
|
+
"off" */
|
|
34
|
+
|
|
24
35
|
const
|
|
25
36
|
{ spawn } =
|
|
26
37
|
require(
|
|
27
38
|
"node:child_process");
|
|
28
|
-
|
|
29
|
-
|
|
39
|
+
/* global
|
|
40
|
+
_spawn */
|
|
41
|
+
const
|
|
42
|
+
_spawn =
|
|
43
|
+
spawn;
|
|
30
44
|
const
|
|
31
45
|
_cert_tools_module =
|
|
32
46
|
require(
|
|
33
47
|
'cert-tools');
|
|
34
|
-
|
|
35
|
-
|
|
48
|
+
/* global
|
|
49
|
+
_cert_gen */
|
|
50
|
+
const
|
|
51
|
+
_cert_gen =
|
|
52
|
+
_cert_tools_module._cert_gen;
|
|
36
53
|
const
|
|
37
54
|
_sha_module =
|
|
38
55
|
require(
|
|
39
56
|
'js-sha256');
|
|
40
|
-
|
|
41
|
-
|
|
57
|
+
/* global
|
|
58
|
+
_sha256 */
|
|
59
|
+
const
|
|
60
|
+
_sha256 =
|
|
61
|
+
_sha_module.sha256;
|
|
42
62
|
const
|
|
43
63
|
_libcrash =
|
|
44
64
|
require(
|
|
45
65
|
'crash-js');
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
66
|
+
/* global
|
|
67
|
+
_dirname */
|
|
68
|
+
const
|
|
69
|
+
_dirname =
|
|
70
|
+
_libcrash._dirname;
|
|
71
|
+
/* global
|
|
72
|
+
_file_exists */
|
|
73
|
+
const
|
|
74
|
+
_file_exists =
|
|
75
|
+
_libcrash._file_exists;
|
|
76
|
+
/* global
|
|
77
|
+
_mkdir */
|
|
78
|
+
const
|
|
79
|
+
_mkdir =
|
|
80
|
+
_libcrash._mkdir;
|
|
81
|
+
/* global
|
|
82
|
+
_msg_info */
|
|
83
|
+
const
|
|
84
|
+
_msg_info =
|
|
85
|
+
_libcrash._msg_info;
|
|
58
86
|
|
|
59
87
|
function
|
|
60
88
|
_path_encode(
|
|
61
89
|
_path) {
|
|
62
|
-
|
|
63
|
-
_string
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
_path + "\n");
|
|
90
|
+
const
|
|
91
|
+
_string =
|
|
92
|
+
_sha256(
|
|
93
|
+
_path + "\n");
|
|
67
94
|
return _string;
|
|
68
95
|
}
|
|
69
96
|
|
|
70
97
|
function
|
|
71
98
|
_serve_close_callback_get(
|
|
72
99
|
_output) {
|
|
73
|
-
|
|
74
|
-
_close_callback
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
100
|
+
const
|
|
101
|
+
_close_callback =
|
|
102
|
+
function(
|
|
103
|
+
_code) {
|
|
104
|
+
let
|
|
105
|
+
_msg;
|
|
106
|
+
_msg =
|
|
107
|
+
`Exit code: ${_code}`;
|
|
108
|
+
console.log(
|
|
109
|
+
_msg);
|
|
110
|
+
_msg =
|
|
111
|
+
`Output: ${_output}`;
|
|
112
|
+
console.log(
|
|
113
|
+
_msg);
|
|
114
|
+
};
|
|
83
115
|
return _close_callback;
|
|
84
116
|
}
|
|
85
117
|
|
|
86
118
|
function
|
|
87
119
|
_serve_data_callback_get(
|
|
88
120
|
_output) {
|
|
89
|
-
|
|
90
|
-
_data_callback
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
_data
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
121
|
+
const
|
|
122
|
+
_data_callback =
|
|
123
|
+
function(
|
|
124
|
+
_data) {
|
|
125
|
+
_data =
|
|
126
|
+
_data.toString();
|
|
127
|
+
console.log(
|
|
128
|
+
_data);
|
|
129
|
+
/* global
|
|
130
|
+
_output */
|
|
131
|
+
_output +=
|
|
132
|
+
_data;
|
|
133
|
+
};
|
|
101
134
|
return _data_callback;
|
|
102
135
|
}
|
|
103
136
|
|
|
@@ -120,10 +153,11 @@ function
|
|
|
120
153
|
_ssl_pass,
|
|
121
154
|
_port_switching_disabled) {
|
|
122
155
|
let
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
156
|
+
_uri;
|
|
157
|
+
const
|
|
158
|
+
_cmd_args = [
|
|
159
|
+
"serve"
|
|
160
|
+
];
|
|
127
161
|
for ( _uri of _listen_uris ) {
|
|
128
162
|
_cmd_args.push(
|
|
129
163
|
"-l",
|
|
@@ -174,21 +208,26 @@ function
|
|
|
174
208
|
"--no-port-switching");
|
|
175
209
|
}
|
|
176
210
|
if ( _ssl_cert != "" ) {
|
|
211
|
+
/* global
|
|
212
|
+
ssl_cert */
|
|
177
213
|
_cmd_args.push(
|
|
178
214
|
"--ssl-cert",
|
|
179
215
|
ssl_cert);
|
|
180
216
|
}
|
|
181
217
|
if ( _ssl_key != "" ) {
|
|
218
|
+
/* global
|
|
219
|
+
ssl_key */
|
|
182
220
|
_cmd_args.push(
|
|
183
221
|
"--ssl-key",
|
|
184
222
|
ssl_key);
|
|
185
223
|
}
|
|
186
224
|
if ( _ssl_pass != "" ) {
|
|
225
|
+
/* global
|
|
226
|
+
ssl_pass */
|
|
187
227
|
_cmd_args.push(
|
|
188
228
|
"--ssl-pass",
|
|
189
229
|
ssl_pass);
|
|
190
230
|
}
|
|
191
|
-
|
|
192
231
|
}
|
|
193
232
|
|
|
194
233
|
function
|
|
@@ -210,44 +249,45 @@ function
|
|
|
210
249
|
_ssl_pass,
|
|
211
250
|
_port_switching_disabled) {
|
|
212
251
|
let
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
252
|
+
_output;
|
|
253
|
+
const
|
|
254
|
+
_cmd =
|
|
255
|
+
"npx";
|
|
256
|
+
const
|
|
257
|
+
_cmd_args =
|
|
258
|
+
_npx_cmdline_get(
|
|
259
|
+
_target_directory,
|
|
260
|
+
_listen_uris,
|
|
261
|
+
_target_port,
|
|
262
|
+
_index_redirect,
|
|
263
|
+
_debug_enabled,
|
|
264
|
+
_config_file,
|
|
265
|
+
_logging_disabled,
|
|
266
|
+
_cors_enabled,
|
|
267
|
+
_clipboard_disabled,
|
|
268
|
+
_compression_disabled,
|
|
269
|
+
_etag_disabled,
|
|
270
|
+
_symlinks_enabled,
|
|
271
|
+
_ssl_cert,
|
|
272
|
+
_ssl_key,
|
|
273
|
+
_ssl_pass,
|
|
274
|
+
_port_switching_disabled);
|
|
275
|
+
const
|
|
276
|
+
_serve_process =
|
|
277
|
+
_spawn(
|
|
278
|
+
_cmd,
|
|
279
|
+
_cmd_args);
|
|
280
|
+
const
|
|
281
|
+
_serve_data_callback =
|
|
282
|
+
_serve_data_callback_get(
|
|
283
|
+
_output);
|
|
245
284
|
_serve_process.stdout.on(
|
|
246
285
|
'data',
|
|
247
286
|
_serve_data_callback);
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
287
|
+
const
|
|
288
|
+
_serve_close_callback =
|
|
289
|
+
_serve_close_callback_get(
|
|
290
|
+
_output);
|
|
251
291
|
_serve_process.stdout.on(
|
|
252
292
|
'close',
|
|
253
293
|
_serve_close_callback);
|
|
@@ -283,62 +323,72 @@ async function
|
|
|
283
323
|
_organization_name,
|
|
284
324
|
_organization_unit) {
|
|
285
325
|
let
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
_mkdir_opts,
|
|
289
|
-
_serve_opts;
|
|
326
|
+
_cert_gen_opts_str,
|
|
327
|
+
_msg;
|
|
290
328
|
if ( ! _file_exists(
|
|
291
329
|
_ssl_cert) &&
|
|
292
330
|
_cert_new == "y" ) {
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
331
|
+
const
|
|
332
|
+
_mkdir_opts =
|
|
333
|
+
{ "recursive":
|
|
334
|
+
true,
|
|
335
|
+
"mode":
|
|
336
|
+
"0700" };
|
|
337
|
+
const
|
|
338
|
+
_mkdir_args = [
|
|
339
|
+
_dirname(
|
|
340
|
+
_ssl_cert),
|
|
341
|
+
_mkdir_opts
|
|
342
|
+
];
|
|
303
343
|
_mkdir.apply(
|
|
304
344
|
null,
|
|
305
345
|
_mkdir_args);
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
346
|
+
const
|
|
347
|
+
_cert_gen_opts = [
|
|
348
|
+
_ssl_key,
|
|
349
|
+
_keys_length,
|
|
350
|
+
_serial_number,
|
|
351
|
+
_validity_min,
|
|
352
|
+
_validity_max,
|
|
353
|
+
_domain_name,
|
|
354
|
+
_country_name,
|
|
355
|
+
_state_name,
|
|
356
|
+
_locality_name,
|
|
357
|
+
_organization_name,
|
|
358
|
+
_organization_unit,
|
|
359
|
+
_ssl_cert
|
|
360
|
+
];
|
|
361
|
+
_cert_gen_opts_str =
|
|
362
|
+
" ".join(
|
|
363
|
+
_cert_gen_opts);
|
|
364
|
+
_msg =
|
|
365
|
+
`Running 'cert-gen' ` +
|
|
366
|
+
`options '${_cert_gen_opts_str}'.`;
|
|
367
|
+
_msg_info(
|
|
368
|
+
_msg);
|
|
320
369
|
await _cert_gen.apply(
|
|
321
370
|
null,
|
|
322
371
|
_cert_gen_opts);
|
|
323
372
|
}
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
373
|
+
const
|
|
374
|
+
_serve_opts = [
|
|
375
|
+
_target_directory,
|
|
376
|
+
_listen_uris,
|
|
377
|
+
_target_port,
|
|
378
|
+
_index_redirect,
|
|
379
|
+
_debug_enabled,
|
|
380
|
+
_config_file,
|
|
381
|
+
_logging_disabled,
|
|
382
|
+
_cors_enabled,
|
|
383
|
+
_clipboard_disabled,
|
|
384
|
+
_compression_disabled,
|
|
385
|
+
_etag_disabled,
|
|
386
|
+
_symlinks_enabled,
|
|
387
|
+
_ssl_cert,
|
|
388
|
+
_ssl_key,
|
|
389
|
+
_ssl_pass,
|
|
390
|
+
_port_switching_disabled
|
|
391
|
+
];
|
|
342
392
|
_serve.apply(
|
|
343
393
|
null,
|
|
344
394
|
_serve_opts);
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name":
|
|
3
3
|
"safely-serve",
|
|
4
4
|
"version":
|
|
5
|
-
"0.0.
|
|
5
|
+
"0.0.9",
|
|
6
6
|
"description":
|
|
7
7
|
"Serve extension which auto-generates self-signed OpenSSL certificates' at runtime",
|
|
8
8
|
"funding": {
|
|
@@ -62,7 +62,11 @@
|
|
|
62
62
|
"crash-js-webpack":
|
|
63
63
|
"^0.0.3",
|
|
64
64
|
"eslint":
|
|
65
|
-
"^
|
|
65
|
+
"^10.0.0",
|
|
66
|
+
"globals":
|
|
67
|
+
"^17.3.0",
|
|
68
|
+
"@eslint/js":
|
|
69
|
+
"^10.0.1",
|
|
66
70
|
"webpack":
|
|
67
71
|
"^5.102.1",
|
|
68
72
|
"webpack-cli":
|
|
@@ -70,7 +74,7 @@
|
|
|
70
74
|
},
|
|
71
75
|
"dependencies": {
|
|
72
76
|
"crash-js":
|
|
73
|
-
"^0.1.
|
|
77
|
+
"^0.1.72",
|
|
74
78
|
"cert-tools":
|
|
75
79
|
"^0.0.7",
|
|
76
80
|
"js-sha256":
|