@vandenberghinc/volt 1.1.17 → 1.1.18

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.
@@ -206,11 +206,20 @@ export declare class Server {
206
206
  add_csp(key: string, value?: null | string | string[]): void;
207
207
  remove_csp(key: string, value?: null | string): void;
208
208
  del_csp(key: string): void;
209
- generate_tls_key({ path, organization_unit, ec }: {
210
- path: string;
211
- organization_unit?: string;
209
+ generate_ssl_key({ output_path, ec, }: {
210
+ output_path: string;
212
211
  ec?: boolean;
213
212
  }): Promise<void>;
213
+ generate_csr({ output_path, key_path, name, domain, organization_unit, country_code, province, city, }: {
214
+ output_path: string;
215
+ key_path: string;
216
+ name: string;
217
+ domain: string;
218
+ organization_unit: string;
219
+ country_code: string;
220
+ province: string;
221
+ city: string;
222
+ }): Promise<void>;
214
223
  endpoint(...endpoints: (none | Endpoint | EndpointOptions | (none | EndpointOptions | Endpoint)[])[]): this;
215
224
  error_endpoint(status_code: number, endpoint: Endpoint | EndpointOptions): this;
216
225
  send_mail({ sender, recipients, subject, body, attachments, }: {
@@ -2501,27 +2501,16 @@ class Server {
2501
2501
  // ---------------------------------------------------------
2502
2502
  // TLS.
2503
2503
  // Generate a key and csr for tls.
2504
- async generate_tls_key({ path, organization_unit = "IT", ec = true }) {
2504
+ async generate_ssl_key({ output_path, ec = true, }) {
2505
2505
  // Args.
2506
- if (path == null) {
2506
+ if (output_path == null) {
2507
2507
  throw Error("Define parameter \"path\".");
2508
2508
  }
2509
- if (organization_unit == null) {
2510
- throw Error("Define parameter \"organization_unit\".");
2511
- }
2512
2509
  // Paths.
2513
- const vpath = new _vinc_1.vlib.Path(path);
2514
- const key = vpath.join("key.key");
2515
- const csr = vpath.join("csr.csr");
2516
- if (!vpath.exists()) {
2517
- vpath.mkdir_sync();
2518
- }
2510
+ const key = new _vinc_1.vlib.Path(output_path);
2519
2511
  if (key.exists()) {
2520
2512
  throw Error(`Key path "${key.str()}" already exists, remove the file manually to continue.`);
2521
2513
  }
2522
- if (csr.exists()) {
2523
- throw Error(`CSR path "${csr.str()}" already exists, remove the file manually to continue.`);
2524
- }
2525
2514
  // Generate the private key using the EC parameters file
2526
2515
  const proc = new _vinc_1.vlib.Proc();
2527
2516
  await proc.start({
@@ -2534,19 +2523,39 @@ class Server {
2534
2523
  if (proc.exit_status != 0) {
2535
2524
  throw Error(`Encountered an error while generating the private key [${proc.exit_status}]: ${proc.err}`);
2536
2525
  }
2526
+ }
2527
+ // Generate a csr for tls.
2528
+ async generate_csr({ output_path, key_path, name, domain, organization_unit, country_code, province, city, }) {
2529
+ // Args.
2530
+ if (key_path == null) {
2531
+ throw Error("Define parameter \"key_path\".");
2532
+ }
2533
+ if (organization_unit == null) {
2534
+ throw Error("Define parameter \"organization_unit\".");
2535
+ }
2536
+ // Paths.
2537
+ const key = new _vinc_1.vlib.Path(key_path);
2538
+ if (!key.exists()) {
2539
+ throw Error(`Key path "${key.str()}" already exists, remove the file manually to continue.`);
2540
+ }
2541
+ const csr = new _vinc_1.vlib.Path(output_path);
2542
+ if (csr.exists()) {
2543
+ throw Error(`CSR path "${csr.str()}" already exists, remove the file manually to continue.`);
2544
+ }
2537
2545
  // Generate the CSR using the generated private key
2546
+ const proc = new _vinc_1.vlib.Proc();
2538
2547
  await proc.start({
2539
2548
  command: "openssl",
2540
2549
  args: [
2541
2550
  "req", "-new", "-key", key.str(), "-out", csr.str(),
2542
2551
  "-subj",
2543
2552
  "\"" +
2544
- "/C=" + this.company.country_code +
2545
- "/ST=" + this.company.province +
2546
- "/L=" + this.company.city +
2547
- "/O=" + this.company.name +
2553
+ "/C=" + country_code +
2554
+ "/ST=" + province +
2555
+ "/L=" + city +
2556
+ "/O=" + name +
2548
2557
  "/OU=" + organization_unit +
2549
- "/CN=" + this.domain +
2558
+ "/CN=" + domain +
2550
2559
  "\""
2551
2560
  ],
2552
2561
  opts: { stdio: "inherit" },
@@ -206,11 +206,20 @@ export declare class Server {
206
206
  add_csp(key: string, value?: null | string | string[]): void;
207
207
  remove_csp(key: string, value?: null | string): void;
208
208
  del_csp(key: string): void;
209
- generate_tls_key({ path, organization_unit, ec }: {
210
- path: string;
211
- organization_unit?: string;
209
+ generate_ssl_key({ output_path, ec, }: {
210
+ output_path: string;
212
211
  ec?: boolean;
213
212
  }): Promise<void>;
213
+ generate_csr({ output_path, key_path, name, domain, organization_unit, country_code, province, city, }: {
214
+ output_path: string;
215
+ key_path: string;
216
+ name: string;
217
+ domain: string;
218
+ organization_unit: string;
219
+ country_code: string;
220
+ province: string;
221
+ city: string;
222
+ }): Promise<void>;
214
223
  endpoint(...endpoints: (none | Endpoint | EndpointOptions | (none | EndpointOptions | Endpoint)[])[]): this;
215
224
  error_endpoint(status_code: number, endpoint: Endpoint | EndpointOptions): this;
216
225
  send_mail({ sender, recipients, subject, body, attachments, }: {
@@ -2462,27 +2462,16 @@ export class Server {
2462
2462
  // ---------------------------------------------------------
2463
2463
  // TLS.
2464
2464
  // Generate a key and csr for tls.
2465
- async generate_tls_key({ path, organization_unit = "IT", ec = true }) {
2465
+ async generate_ssl_key({ output_path, ec = true, }) {
2466
2466
  // Args.
2467
- if (path == null) {
2467
+ if (output_path == null) {
2468
2468
  throw Error("Define parameter \"path\".");
2469
2469
  }
2470
- if (organization_unit == null) {
2471
- throw Error("Define parameter \"organization_unit\".");
2472
- }
2473
2470
  // Paths.
2474
- const vpath = new vlib.Path(path);
2475
- const key = vpath.join("key.key");
2476
- const csr = vpath.join("csr.csr");
2477
- if (!vpath.exists()) {
2478
- vpath.mkdir_sync();
2479
- }
2471
+ const key = new vlib.Path(output_path);
2480
2472
  if (key.exists()) {
2481
2473
  throw Error(`Key path "${key.str()}" already exists, remove the file manually to continue.`);
2482
2474
  }
2483
- if (csr.exists()) {
2484
- throw Error(`CSR path "${csr.str()}" already exists, remove the file manually to continue.`);
2485
- }
2486
2475
  // Generate the private key using the EC parameters file
2487
2476
  const proc = new vlib.Proc();
2488
2477
  await proc.start({
@@ -2495,19 +2484,39 @@ export class Server {
2495
2484
  if (proc.exit_status != 0) {
2496
2485
  throw Error(`Encountered an error while generating the private key [${proc.exit_status}]: ${proc.err}`);
2497
2486
  }
2487
+ }
2488
+ // Generate a csr for tls.
2489
+ async generate_csr({ output_path, key_path, name, domain, organization_unit, country_code, province, city, }) {
2490
+ // Args.
2491
+ if (key_path == null) {
2492
+ throw Error("Define parameter \"key_path\".");
2493
+ }
2494
+ if (organization_unit == null) {
2495
+ throw Error("Define parameter \"organization_unit\".");
2496
+ }
2497
+ // Paths.
2498
+ const key = new vlib.Path(key_path);
2499
+ if (!key.exists()) {
2500
+ throw Error(`Key path "${key.str()}" already exists, remove the file manually to continue.`);
2501
+ }
2502
+ const csr = new vlib.Path(output_path);
2503
+ if (csr.exists()) {
2504
+ throw Error(`CSR path "${csr.str()}" already exists, remove the file manually to continue.`);
2505
+ }
2498
2506
  // Generate the CSR using the generated private key
2507
+ const proc = new vlib.Proc();
2499
2508
  await proc.start({
2500
2509
  command: "openssl",
2501
2510
  args: [
2502
2511
  "req", "-new", "-key", key.str(), "-out", csr.str(),
2503
2512
  "-subj",
2504
2513
  "\"" +
2505
- "/C=" + this.company.country_code +
2506
- "/ST=" + this.company.province +
2507
- "/L=" + this.company.city +
2508
- "/O=" + this.company.name +
2514
+ "/C=" + country_code +
2515
+ "/ST=" + province +
2516
+ "/L=" + city +
2517
+ "/O=" + name +
2509
2518
  "/OU=" + organization_unit +
2510
- "/CN=" + this.domain +
2519
+ "/CN=" + domain +
2511
2520
  "\""
2512
2521
  ],
2513
2522
  opts: { stdio: "inherit" },
@@ -206,11 +206,20 @@ export declare class Server {
206
206
  add_csp(key: string, value?: null | string | string[]): void;
207
207
  remove_csp(key: string, value?: null | string): void;
208
208
  del_csp(key: string): void;
209
- generate_tls_key({ path, organization_unit, ec }: {
210
- path: string;
211
- organization_unit?: string;
209
+ generate_ssl_key({ output_path, ec, }: {
210
+ output_path: string;
212
211
  ec?: boolean;
213
212
  }): Promise<void>;
213
+ generate_csr({ output_path, key_path, name, domain, organization_unit, country_code, province, city, }: {
214
+ output_path: string;
215
+ key_path: string;
216
+ name: string;
217
+ domain: string;
218
+ organization_unit: string;
219
+ country_code: string;
220
+ province: string;
221
+ city: string;
222
+ }): Promise<void>;
214
223
  endpoint(...endpoints: (none | Endpoint | EndpointOptions | (none | EndpointOptions | Endpoint)[])[]): this;
215
224
  error_endpoint(status_code: number, endpoint: Endpoint | EndpointOptions): this;
216
225
  send_mail({ sender, recipients, subject, body, attachments, }: {
@@ -2462,27 +2462,16 @@ export class Server {
2462
2462
  // ---------------------------------------------------------
2463
2463
  // TLS.
2464
2464
  // Generate a key and csr for tls.
2465
- async generate_tls_key({ path, organization_unit = "IT", ec = true }) {
2465
+ async generate_ssl_key({ output_path, ec = true, }) {
2466
2466
  // Args.
2467
- if (path == null) {
2467
+ if (output_path == null) {
2468
2468
  throw Error("Define parameter \"path\".");
2469
2469
  }
2470
- if (organization_unit == null) {
2471
- throw Error("Define parameter \"organization_unit\".");
2472
- }
2473
2470
  // Paths.
2474
- const vpath = new vlib.Path(path);
2475
- const key = vpath.join("key.key");
2476
- const csr = vpath.join("csr.csr");
2477
- if (!vpath.exists()) {
2478
- vpath.mkdir_sync();
2479
- }
2471
+ const key = new vlib.Path(output_path);
2480
2472
  if (key.exists()) {
2481
2473
  throw Error(`Key path "${key.str()}" already exists, remove the file manually to continue.`);
2482
2474
  }
2483
- if (csr.exists()) {
2484
- throw Error(`CSR path "${csr.str()}" already exists, remove the file manually to continue.`);
2485
- }
2486
2475
  // Generate the private key using the EC parameters file
2487
2476
  const proc = new vlib.Proc();
2488
2477
  await proc.start({
@@ -2495,19 +2484,39 @@ export class Server {
2495
2484
  if (proc.exit_status != 0) {
2496
2485
  throw Error(`Encountered an error while generating the private key [${proc.exit_status}]: ${proc.err}`);
2497
2486
  }
2487
+ }
2488
+ // Generate a csr for tls.
2489
+ async generate_csr({ output_path, key_path, name, domain, organization_unit, country_code, province, city, }) {
2490
+ // Args.
2491
+ if (key_path == null) {
2492
+ throw Error("Define parameter \"key_path\".");
2493
+ }
2494
+ if (organization_unit == null) {
2495
+ throw Error("Define parameter \"organization_unit\".");
2496
+ }
2497
+ // Paths.
2498
+ const key = new vlib.Path(key_path);
2499
+ if (!key.exists()) {
2500
+ throw Error(`Key path "${key.str()}" already exists, remove the file manually to continue.`);
2501
+ }
2502
+ const csr = new vlib.Path(output_path);
2503
+ if (csr.exists()) {
2504
+ throw Error(`CSR path "${csr.str()}" already exists, remove the file manually to continue.`);
2505
+ }
2498
2506
  // Generate the CSR using the generated private key
2507
+ const proc = new vlib.Proc();
2499
2508
  await proc.start({
2500
2509
  command: "openssl",
2501
2510
  args: [
2502
2511
  "req", "-new", "-key", key.str(), "-out", csr.str(),
2503
2512
  "-subj",
2504
2513
  "\"" +
2505
- "/C=" + this.company.country_code +
2506
- "/ST=" + this.company.province +
2507
- "/L=" + this.company.city +
2508
- "/O=" + this.company.name +
2514
+ "/C=" + country_code +
2515
+ "/ST=" + province +
2516
+ "/L=" + city +
2517
+ "/O=" + name +
2509
2518
  "/OU=" + organization_unit +
2510
- "/CN=" + this.domain +
2519
+ "/CN=" + domain +
2511
2520
  "\""
2512
2521
  ],
2513
2522
  opts: { stdio: "inherit" },
@@ -2829,28 +2829,23 @@ export class Server {
2829
2829
  // TLS.
2830
2830
 
2831
2831
  // Generate a key and csr for tls.
2832
- async generate_tls_key({path, organization_unit = "IT", ec = true}: {path: string; organization_unit?: string; ec?: boolean}): Promise<void> {
2832
+ async generate_ssl_key({
2833
+ output_path,
2834
+ ec = true,
2835
+ }: {
2836
+ output_path: string;
2837
+ ec?: boolean;
2838
+ }): Promise<void> {
2833
2839
  // Args.
2834
- if (path == null) {
2840
+ if (output_path == null) {
2835
2841
  throw Error("Define parameter \"path\".");
2836
2842
  }
2837
- if (organization_unit == null) {
2838
- throw Error("Define parameter \"organization_unit\".");
2839
- }
2840
2843
 
2841
2844
  // Paths.
2842
- const vpath: vlib.Path = new vlib.Path(path);
2843
- const key = vpath.join("key.key");
2844
- const csr = vpath.join("csr.csr");
2845
- if (!vpath.exists()) {
2846
- vpath.mkdir_sync();
2847
- }
2845
+ const key = new vlib.Path(output_path);
2848
2846
  if (key.exists()) {
2849
2847
  throw Error(`Key path "${key.str()}" already exists, remove the file manually to continue.`);
2850
2848
  }
2851
- if (csr.exists()) {
2852
- throw Error(`CSR path "${csr.str()}" already exists, remove the file manually to continue.`);
2853
- }
2854
2849
 
2855
2850
  // Generate the private key using the EC parameters file
2856
2851
  const proc = new vlib.Proc();
@@ -2865,20 +2860,61 @@ export class Server {
2865
2860
  if (proc.exit_status != 0) {
2866
2861
  throw Error(`Encountered an error while generating the private key [${proc.exit_status}]: ${proc.err}`);
2867
2862
  }
2863
+ }
2864
+
2865
+ // Generate a csr for tls.
2866
+ async generate_csr({
2867
+ output_path,
2868
+ key_path,
2869
+ name,
2870
+ domain,
2871
+ organization_unit,
2872
+ country_code,
2873
+ province,
2874
+ city,
2875
+ }: {
2876
+ output_path: string;
2877
+ key_path: string;
2878
+ name: string,
2879
+ domain: string,
2880
+ organization_unit: string,
2881
+ country_code: string,
2882
+ province: string,
2883
+ city: string,
2884
+ }): Promise<void> {
2885
+
2886
+ // Args.
2887
+ if (key_path == null) {
2888
+ throw Error("Define parameter \"key_path\".");
2889
+ }
2890
+ if (organization_unit == null) {
2891
+ throw Error("Define parameter \"organization_unit\".");
2892
+ }
2893
+
2894
+ // Paths.
2895
+ const key = new vlib.Path(key_path);
2896
+ if (!key.exists()) {
2897
+ throw Error(`Key path "${key.str()}" already exists, remove the file manually to continue.`);
2898
+ }
2899
+ const csr = new vlib.Path(output_path);
2900
+ if (csr.exists()) {
2901
+ throw Error(`CSR path "${csr.str()}" already exists, remove the file manually to continue.`);
2902
+ }
2868
2903
 
2869
2904
  // Generate the CSR using the generated private key
2905
+ const proc = new vlib.Proc();
2870
2906
  await proc.start({
2871
2907
  command: "openssl",
2872
2908
  args: [
2873
2909
  "req", "-new", "-key", key.str(), "-out", csr.str(),
2874
- "-subj",
2910
+ "-subj",
2875
2911
  "\"" +
2876
- "/C=" + this.company.country_code +
2877
- "/ST=" + this.company.province +
2878
- "/L=" + this.company.city +
2879
- "/O=" + this.company.name +
2912
+ "/C=" + country_code +
2913
+ "/ST=" + province +
2914
+ "/L=" + city +
2915
+ "/O=" + name +
2880
2916
  "/OU=" + organization_unit +
2881
- "/CN=" + this.domain +
2917
+ "/CN=" + domain +
2882
2918
  "\""
2883
2919
  ],
2884
2920
  opts: { stdio: "inherit" },
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "author": "Daan van den Bergh",
3
3
  "name": "@vandenberghinc/volt",
4
- "version": "1.1.17",
4
+ "version": "1.1.18",
5
5
  "description": "",
6
6
  "type": "module",
7
7
  "types": "./backend/dist/esm/volt.d.ts",