safely-serve 0.0.11 → 0.0.12

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 CHANGED
@@ -68,9 +68,7 @@ export default defineConfig([
68
68
  "prefer-const":
69
69
  "error" },
70
70
  files:
71
- [ "**/*.js",
72
- `**/${_project}*`,
73
- `**/lib${_project}` ],
71
+ [ "**/*.{js,cjs}" ],
74
72
  languageOptions:
75
73
  { sourceType:
76
74
  "commonjs" } },
package/libsafely-serve CHANGED
@@ -37,9 +37,38 @@
37
37
  no-unassigned-vars:
38
38
  "off" */
39
39
 
40
+ const
41
+ _libcrash =
42
+ await import(
43
+ "libcrash-js");
44
+ /* global
45
+ _dirname */
46
+ const
47
+ _dirname =
48
+ _libcrash._dirname;
49
+ /* global
50
+ _file_exists */
51
+ const
52
+ _file_exists =
53
+ _libcrash._file_exists;
54
+ /* global
55
+ _mkdir */
56
+ const
57
+ _mkdir =
58
+ _libcrash._mkdir;
59
+ /* global
60
+ _msg_info */
61
+ const
62
+ _msg_info =
63
+ _libcrash._msg_info;
64
+ /* global
65
+ _require */
66
+ const
67
+ _require =
68
+ _libcrash._require;
40
69
  const
41
70
  { spawn } =
42
- require(
71
+ await _require(
43
72
  "node:child_process");
44
73
  /* global
45
74
  _spawn */
@@ -48,7 +77,7 @@ const
48
77
  spawn;
49
78
  const
50
79
  _cert_tools_module =
51
- require(
80
+ await _require(
52
81
  'cert-tools');
53
82
  /* global
54
83
  _cert_gen */
@@ -57,37 +86,13 @@ const
57
86
  _cert_tools_module._cert_gen;
58
87
  const
59
88
  _sha_module =
60
- require(
89
+ await _require(
61
90
  'js-sha256');
62
91
  /* global
63
92
  _sha256 */
64
93
  const
65
94
  _sha256 =
66
95
  _sha_module.sha256;
67
- const
68
- _libcrash =
69
- require(
70
- 'crash-js');
71
- /* global
72
- _dirname */
73
- const
74
- _dirname =
75
- _libcrash._dirname;
76
- /* global
77
- _file_exists */
78
- const
79
- _file_exists =
80
- _libcrash._file_exists;
81
- /* global
82
- _mkdir */
83
- const
84
- _mkdir =
85
- _libcrash._mkdir;
86
- /* global
87
- _msg_info */
88
- const
89
- _msg_info =
90
- _libcrash._msg_info;
91
96
 
92
97
  function
93
98
  _path_encode(
@@ -399,11 +404,17 @@ async function
399
404
  _serve_opts);
400
405
  }
401
406
 
402
- module.exports = {
403
- _path_encode:
404
- _path_encode,
405
- _safely_serve:
406
- _safely_serve,
407
- _serve:
408
- _serve
407
+ export {
408
+ _path_encode,
409
+ _safely_serve,
410
+ _serve
409
411
  };
412
+
413
+ // module.exports = {
414
+ // _path_encode:
415
+ // _path_encode,
416
+ // _safely_serve:
417
+ // _safely_serve,
418
+ // _serve:
419
+ // _serve
420
+ // };
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name":
3
3
  "safely-serve",
4
4
  "version":
5
- "0.0.11",
5
+ "0.0.12",
6
6
  "description":
7
7
  "Serve extension which auto-generates self-signed OpenSSL certificates' at runtime",
8
8
  "funding": {
@@ -58,7 +58,7 @@
58
58
  },
59
59
  "devDependencies": {
60
60
  "crash-js-webpack":
61
- "^0.0.45",
61
+ "^0.0.50",
62
62
  "eslint":
63
63
  "^10.3.0",
64
64
  "globals":
@@ -71,10 +71,10 @@
71
71
  "^7.2.2"
72
72
  },
73
73
  "dependencies": {
74
- "crash-js":
75
- "^0.1111.1111111111111111",
74
+ "libcrash-js":
75
+ "npm:crash-js@^0.111111111111.1111111111111111",
76
76
  "cert-tools":
77
- "^0.0.12",
77
+ "^0.0.13",
78
78
  "js-sha256":
79
79
  "^0.11.1",
80
80
  "os":
@@ -83,7 +83,7 @@
83
83
  "^14.2.6"
84
84
  },
85
85
  "type":
86
- "commonjs",
86
+ "module",
87
87
  "main":
88
88
  "libsafely-serve",
89
89
  "bin":
package/safely-serve CHANGED
@@ -38,21 +38,32 @@
38
38
  "_input_args_check" } ] */
39
39
 
40
40
  const
41
- _os =
42
- require(
43
- "os");
44
- const
45
- _homedir =
46
- _os.homedir;
41
+ _libcrash_module =
42
+ await import(
43
+ "libcrash-js");
47
44
  const
48
45
  _libcrash =
49
- require(
50
- 'crash-js');
46
+ _libcrash_module.default;
51
47
  /* global
52
48
  _cmdline_check */
53
49
  const
54
50
  _cmdline_check =
55
51
  _libcrash._cmdline_check;
52
+ /* global
53
+ _echo */
54
+ const
55
+ _echo =
56
+ _libcrash._echo;
57
+ /* global
58
+ _exit */
59
+ const
60
+ _exit =
61
+ _libcrash._exit;
62
+ /* global
63
+ _homedir_get */
64
+ const
65
+ _homedir_get =
66
+ _libcrash._homedir_get;
56
67
  /* global
57
68
  _msg_info */
58
69
  const
@@ -63,21 +74,26 @@ const
63
74
  const
64
75
  _msg_error =
65
76
  _libcrash._msg_error;
77
+ /* global
78
+ _override_set */
79
+ const
80
+ _override_set =
81
+ _libcrash._override_set;
66
82
  /* global
67
83
  _path_join */
68
84
  const
69
85
  _path_join =
70
86
  _libcrash._path_join;
71
- /* global
72
- _process_exit */
73
- const
74
- _process_exit =
75
- _libcrash._process_exit;
76
87
  /* global
77
88
  _pwd */
78
89
  const
79
90
  _pwd =
80
91
  _libcrash._pwd;
92
+ /* global
93
+ _require */
94
+ const
95
+ _require =
96
+ _libcrash._require;
81
97
  /* global
82
98
  _argv_url_get */
83
99
  const
@@ -88,9 +104,10 @@ const
88
104
  const
89
105
  _yargv_get =
90
106
  _libcrash._yargv_get;
107
+
91
108
  const
92
109
  _libsafely_serve_module =
93
- require(
110
+ await _require(
94
111
  "./libsafely-serve");
95
112
  /* global
96
113
  _path_encode */
@@ -268,11 +285,24 @@ function
268
285
  }
269
286
 
270
287
  function
271
- _cache_dir_auto_detect() {
272
- return _homedir() +
273
- `/.cache/${app_name}`;
288
+ _cache_dir_get() {
289
+ const
290
+ _home =
291
+ _homedir_get();
292
+ const
293
+ _cache_dir =
294
+ _path_join( [
295
+ _home,
296
+ ".cache",
297
+ app_name
298
+ ]);
299
+ return _cache_dir;
274
300
  }
275
301
 
302
+ const
303
+ _cache_dir_auto_detect =
304
+ _cache_dir_get;
305
+
276
306
  function
277
307
  _work_dir_get(
278
308
  _target_directory) {
@@ -316,94 +346,106 @@ function
316
346
  }
317
347
  }
318
348
 
349
+ function
350
+ _validity_auto_detect() {
351
+ const
352
+ _validity_min =
353
+ new Date();
354
+ const
355
+ _validity_max =
356
+ validity_min;
357
+ _validity_max.setFullYear(
358
+ _validity_min.getFullYear() +
359
+ 1);
360
+ _override_set(
361
+ "validity",
362
+ "min",
363
+ _validity_min);
364
+ _override_set(
365
+ "validity",
366
+ "max",
367
+ _validity_max);
368
+ }
369
+
370
+
319
371
  function
320
372
  _overrides_set() {
321
373
  cache_dir =
322
374
  _cache_dir_auto_detect();
323
- if ( target_directory == "" ) {
324
- target_directory =
325
- _pwd();
326
- }
327
- if ( target_port == "" ) {
328
- target_port =
329
- "3000";
330
- }
331
- if ( index_redirect == "" ) {
332
- index_redirect =
333
- "y";
334
- }
335
- if ( logging_disabled == "" ) {
336
- logging_disabled =
337
- "n";
338
- }
339
- if ( cors_enabled == "" ) {
340
- cors_enabled =
341
- "n";
342
- }
343
- if ( clipboard_disabled == "" ) {
344
- clipboard_disabled =
345
- "n";
346
- }
347
- if ( compression_disabled == "" ) {
348
- compression_disabled =
349
- "n";
350
- }
351
- if ( etag_disabled == "" ) {
352
- etag_disabled =
353
- "n";
354
- }
355
- if ( symlinks_enabled == "" ) {
356
- symlinks_enabled =
357
- "n";
358
- }
375
+ _override_set(
376
+ "target",
377
+ "directory",
378
+ _pwd());
379
+ _override_set(
380
+ "target",
381
+ "port",
382
+ "3000");
383
+ _override_set(
384
+ "index",
385
+ "redirect",
386
+ "y");
387
+ _override_set(
388
+ "logging",
389
+ "disabled",
390
+ "n");
391
+ _override_set(
392
+ "cors",
393
+ "enabled",
394
+ "n");
395
+ _override_set(
396
+ "clipboard",
397
+ "disabled",
398
+ "n");
399
+ _override_set(
400
+ "compression",
401
+ "disabled",
402
+ "n");
403
+ _override_set(
404
+ "etag",
405
+ "disabled",
406
+ "n");
407
+ _override_set(
408
+ "symlink",
409
+ "enabled",
410
+ "n");
359
411
  _ssl_config_auto_detect();
360
- if ( port_switching_disabled == "" ) {
361
- port_switching_disabled =
362
- "n";
363
- }
364
- if ( keys_length == "" ) {
365
- keys_length =
366
- "4096";
367
- }
368
- if ( validity_min == "" ) {
369
- validity_min =
370
- new Date();
371
- }
372
- if ( validity_max == "" ) {
373
- validity_max =
374
- new Date();
375
- validity_max.setFullYear(
376
- validity_min.getFullYear() +
377
- 1);
378
- }
379
- if ( serial_number == "" ) {
380
- serial_number =
381
- "01";
382
- }
383
- if ( domain_name == "" ) {
384
- domain_name =
385
- "localhost";
386
- }
387
- if ( country_name == "" ) {
388
- country_name =
389
- "LP";
390
- }
391
- if ( state_name == "" ) {
392
- state_name =
393
- "Nananapoli";
394
- }
395
- if ( locality_name == "" ) {
396
- locality_name =
397
- "Pollena Trocchia";
398
- }
399
- if ( organization_name == "" ) {
400
- organization_name =
401
- "The Martian Company";
402
- }
403
- if ( organization_unit == "" ) {
404
- organization_unit =
405
- "Index Development Team";
406
- }
412
+ _override_set(
413
+ "port_switching",
414
+ "disabled",
415
+ "n");
416
+ _override_set(
417
+ "keys",
418
+ "length",
419
+ "4096");
420
+ _validity_auto_detect();
421
+ _override_set(
422
+ "serial",
423
+ "number",
424
+ "01");
425
+ _override_set(
426
+ "domain",
427
+ "name",
428
+ "localhost");
429
+ _override_set(
430
+ "country",
431
+ "name",
432
+ "LP");
433
+ _override_set(
434
+ "state",
435
+ "name",
436
+ "Nananapoli");
437
+ _override_set(
438
+ "locality",
439
+ "name",
440
+ "Pollena Trocchia");
441
+ _override_set(
442
+ "organization",
443
+ "name",
444
+ "The Martian Company");
445
+ _override_set(
446
+ "organization",
447
+ "name",
448
+ "Index Development Team");
407
449
  }
408
450
 
409
451
  function
@@ -551,10 +593,10 @@ function
551
593
  "",
552
594
  ];
553
595
  for ( _line of _text ) {
554
- console.log(
596
+ _echo(
555
597
  _line);
556
598
  }
557
- _process_exit(
599
+ _exit(
558
600
  _exit_code);
559
601
  }
560
602