node-opcua-pki 6.22.1 → 7.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.
Files changed (137) hide show
  1. package/bin/install_prerequisite.ts +1 -1
  2. package/bin/pki.ts +1 -1
  3. package/dist/bin/install_prerequisite.d.ts +2 -0
  4. package/dist/bin/install_prerequisite.js +6 -0
  5. package/dist/bin/install_prerequisite.js.map +1 -0
  6. package/dist/bin/pki.d.ts +2 -0
  7. package/dist/bin/pki.js +4 -0
  8. package/dist/bin/pki.js.map +1 -0
  9. package/dist/lib/ca/backends/native_ca_backend.d.ts +49 -0
  10. package/dist/lib/ca/backends/native_ca_backend.js +365 -0
  11. package/dist/lib/ca/backends/native_ca_backend.js.map +1 -0
  12. package/dist/lib/ca/backends/openssl_ca_backend.d.ts +47 -0
  13. package/dist/lib/ca/backends/openssl_ca_backend.js +398 -0
  14. package/dist/lib/ca/backends/openssl_ca_backend.js.map +1 -0
  15. package/dist/lib/ca/certificate_authority.d.ts +62 -0
  16. package/dist/lib/ca/certificate_authority.js +91 -0
  17. package/dist/lib/ca/certificate_authority.js.map +1 -0
  18. package/dist/lib/ca/core/ca_backend.d.ts +89 -0
  19. package/dist/lib/ca/core/ca_backend.js +24 -0
  20. package/dist/lib/ca/core/ca_backend.js.map +1 -0
  21. package/dist/lib/ca/core/ca_database.d.ts +91 -0
  22. package/dist/lib/ca/core/ca_database.js +267 -0
  23. package/dist/lib/ca/core/ca_database.js.map +1 -0
  24. package/dist/{core-BwqSJPHc.d.mts → lib/ca/core/certificate_authority_core.d.ts} +45 -394
  25. package/dist/lib/ca/core/certificate_authority_core.js +1300 -0
  26. package/dist/lib/ca/core/certificate_authority_core.js.map +1 -0
  27. package/dist/lib/ca/core/index.d.ts +17 -0
  28. package/dist/lib/ca/core/index.js +25 -0
  29. package/dist/lib/ca/core/index.js.map +1 -0
  30. package/dist/lib/ca/crypto_create_CA.d.ts +1 -0
  31. package/dist/lib/ca/crypto_create_CA.js +821 -0
  32. package/dist/lib/ca/crypto_create_CA.js.map +1 -0
  33. package/dist/lib/ca/index.d.ts +1 -0
  34. package/dist/lib/ca/index.js +2 -0
  35. package/dist/lib/ca/index.js.map +1 -0
  36. package/dist/lib/ca/templates/ca_config_template.cnf.d.ts +2 -0
  37. package/dist/lib/ca/templates/ca_config_template.cnf.js +170 -0
  38. package/dist/lib/ca/templates/ca_config_template.cnf.js.map +1 -0
  39. package/dist/lib/core.d.ts +33 -0
  40. package/dist/lib/core.js +56 -0
  41. package/dist/lib/core.js.map +1 -0
  42. package/dist/lib/index.d.ts +11 -0
  43. package/dist/lib/index.js +37 -0
  44. package/dist/lib/index.js.map +1 -0
  45. package/dist/lib/misc/applicationurn.d.ts +1 -0
  46. package/dist/lib/misc/applicationurn.js +40 -0
  47. package/dist/lib/misc/applicationurn.js.map +1 -0
  48. package/dist/lib/misc/hostname.d.ts +8 -0
  49. package/dist/lib/misc/hostname.js +82 -0
  50. package/dist/lib/misc/hostname.js.map +1 -0
  51. package/dist/lib/misc/subject.d.ts +2 -0
  52. package/dist/lib/misc/subject.js +2 -0
  53. package/dist/lib/misc/subject.js.map +1 -0
  54. package/dist/{index.d.ts → lib/pki/certificate_manager.d.ts} +24 -248
  55. package/dist/lib/pki/certificate_manager.js +2302 -0
  56. package/dist/lib/pki/certificate_manager.js.map +1 -0
  57. package/dist/lib/pki/templates/simple_config_template.cnf.d.ts +2 -0
  58. package/dist/lib/pki/templates/simple_config_template.cnf.js +74 -0
  59. package/dist/lib/pki/templates/simple_config_template.cnf.js.map +1 -0
  60. package/dist/lib/pki/toolbox_pfx.d.ts +127 -0
  61. package/dist/lib/pki/toolbox_pfx.js +248 -0
  62. package/dist/lib/pki/toolbox_pfx.js.map +1 -0
  63. package/dist/lib/toolbox/common.d.ts +150 -0
  64. package/dist/lib/toolbox/common.js +82 -0
  65. package/dist/lib/toolbox/common.js.map +1 -0
  66. package/dist/lib/toolbox/common2.d.ts +25 -0
  67. package/dist/lib/toolbox/common2.js +97 -0
  68. package/dist/lib/toolbox/common2.js.map +1 -0
  69. package/dist/lib/toolbox/config.d.ts +5 -0
  70. package/dist/lib/toolbox/config.js +28 -0
  71. package/dist/lib/toolbox/config.js.map +1 -0
  72. package/dist/lib/toolbox/debug.d.ts +5 -0
  73. package/dist/lib/toolbox/debug.js +35 -0
  74. package/dist/lib/toolbox/debug.js.map +1 -0
  75. package/dist/lib/toolbox/display.d.ts +4 -0
  76. package/dist/lib/toolbox/display.js +56 -0
  77. package/dist/lib/toolbox/display.js.map +1 -0
  78. package/dist/lib/toolbox/index.d.ts +5 -0
  79. package/dist/lib/toolbox/index.js +28 -0
  80. package/dist/lib/toolbox/index.js.map +1 -0
  81. package/dist/lib/toolbox/with_openssl/_create_random_file.d.ts +4 -0
  82. package/dist/lib/toolbox/with_openssl/_create_random_file.js +50 -0
  83. package/dist/lib/toolbox/with_openssl/_create_random_file.js.map +1 -0
  84. package/dist/lib/toolbox/with_openssl/_env.d.ts +58 -0
  85. package/dist/lib/toolbox/with_openssl/_env.js +126 -0
  86. package/dist/lib/toolbox/with_openssl/_env.js.map +1 -0
  87. package/dist/lib/toolbox/with_openssl/create_certificate_signing_request.d.ts +5 -0
  88. package/dist/lib/toolbox/with_openssl/create_certificate_signing_request.js +72 -0
  89. package/dist/lib/toolbox/with_openssl/create_certificate_signing_request.js.map +1 -0
  90. package/dist/lib/toolbox/with_openssl/create_private_key.d.ts +5 -0
  91. package/dist/lib/toolbox/with_openssl/create_private_key.js +92 -0
  92. package/dist/lib/toolbox/with_openssl/create_private_key.js.map +1 -0
  93. package/dist/lib/toolbox/with_openssl/create_self_signed_certificate.d.ts +5 -0
  94. package/dist/lib/toolbox/with_openssl/create_self_signed_certificate.js +135 -0
  95. package/dist/lib/toolbox/with_openssl/create_self_signed_certificate.js.map +1 -0
  96. package/dist/lib/toolbox/with_openssl/execute_openssl.d.ts +67 -0
  97. package/dist/lib/toolbox/with_openssl/execute_openssl.js +246 -0
  98. package/dist/lib/toolbox/with_openssl/execute_openssl.js.map +1 -0
  99. package/dist/lib/toolbox/with_openssl/index.d.ts +5 -0
  100. package/dist/lib/toolbox/with_openssl/index.js +30 -0
  101. package/dist/lib/toolbox/with_openssl/index.js.map +1 -0
  102. package/dist/lib/toolbox/with_openssl/install_prerequisite.d.ts +7 -0
  103. package/dist/lib/toolbox/with_openssl/install_prerequisite.js +358 -0
  104. package/dist/lib/toolbox/with_openssl/install_prerequisite.js.map +1 -0
  105. package/dist/lib/toolbox/with_openssl/toolbox.d.ts +53 -0
  106. package/dist/lib/toolbox/with_openssl/toolbox.js +190 -0
  107. package/dist/lib/toolbox/with_openssl/toolbox.js.map +1 -0
  108. package/dist/lib/toolbox/without_openssl/create_certificate_signing_request.d.ts +5 -0
  109. package/dist/lib/toolbox/without_openssl/create_certificate_signing_request.js +69 -0
  110. package/dist/lib/toolbox/without_openssl/create_certificate_signing_request.js.map +1 -0
  111. package/dist/lib/toolbox/without_openssl/create_self_signed_certificate.d.ts +3 -0
  112. package/dist/lib/toolbox/without_openssl/create_self_signed_certificate.js +78 -0
  113. package/dist/lib/toolbox/without_openssl/create_self_signed_certificate.js.map +1 -0
  114. package/dist/lib/toolbox/without_openssl/index.d.ts +2 -0
  115. package/dist/lib/toolbox/without_openssl/index.js +25 -0
  116. package/dist/lib/toolbox/without_openssl/index.js.map +1 -0
  117. package/package.json +11 -30
  118. package/dist/bin/install_prerequisite.mjs +0 -18
  119. package/dist/bin/install_prerequisite.mjs.map +0 -1
  120. package/dist/bin/pki.mjs +0 -5932
  121. package/dist/bin/pki.mjs.map +0 -1
  122. package/dist/chunk-EQ4DGI4M.mjs +0 -1917
  123. package/dist/chunk-EQ4DGI4M.mjs.map +0 -1
  124. package/dist/chunk-GCHH54PS.mjs +0 -30
  125. package/dist/chunk-GCHH54PS.mjs.map +0 -1
  126. package/dist/core-BwqSJPHc.d.ts +0 -1041
  127. package/dist/core.d.mts +0 -2
  128. package/dist/core.d.ts +0 -2
  129. package/dist/core.js +0 -1902
  130. package/dist/core.js.map +0 -1
  131. package/dist/core.mjs +0 -21
  132. package/dist/core.mjs.map +0 -1
  133. package/dist/index.d.mts +0 -1003
  134. package/dist/index.js +0 -5009
  135. package/dist/index.js.map +0 -1
  136. package/dist/index.mjs +0 -3145
  137. package/dist/index.mjs.map +0 -1
@@ -0,0 +1,150 @@
1
+ /** RSA key size in bits. */
2
+ export type KeySize = 1024 | 2048 | 3072 | 4096;
3
+ /** Hex-encoded SHA-1 certificate thumbprint. */
4
+ export type Thumbprint = string;
5
+ /** A filesystem path to a file. */
6
+ export type Filename = string;
7
+ /** Status of a certificate in the trust store. */
8
+ export type CertificateStatus = "unknown" | "trusted" | "rejected";
9
+ import type { CaSigner, CertificatePurpose, PrivateKey } from "node-opcua-crypto";
10
+ import type { SubjectOptions } from "../misc/subject.js";
11
+ /**
12
+ * @deprecated Use {@link KeySize} instead.
13
+ */
14
+ export type KeyLength = 1024 | 2048 | 3072 | 4096;
15
+ export declare function quote(str?: string): string;
16
+ /**
17
+ * Subject Alternative Name (SAN) parameters for certificate
18
+ * generation.
19
+ */
20
+ export interface ProcessAltNamesParam {
21
+ /** DNS host names to include in the SAN extension. */
22
+ dns?: string[];
23
+ /** IP addresses to include in the SAN extension. */
24
+ ip?: string[];
25
+ /** OPC UA application URI for the SAN extension. */
26
+ applicationUri?: string;
27
+ }
28
+ /**
29
+ * Options for creating a Certificate Signing Request (CSR).
30
+ */
31
+ export interface CreateCertificateSigningRequestOptions extends ProcessAltNamesParam {
32
+ /** X.500 subject for the certificate. */
33
+ subject?: SubjectOptions | string;
34
+ }
35
+ /**
36
+ * Extended CSR options that include filesystem paths and
37
+ * certificate purpose — used internally by the OpenSSL toolbox.
38
+ */
39
+ export interface CreateCertificateSigningRequestWithConfigOptions extends CreateCertificateSigningRequestOptions {
40
+ /** Root directory of the PKI store. */
41
+ rootDir: Filename;
42
+ /** Path to the OpenSSL configuration file. */
43
+ configFile: Filename;
44
+ /**
45
+ * The private key: a filesystem path to a PEM file (unencrypted;
46
+ * the historical behavior), an already-resolved in-memory
47
+ * {@link PrivateKey}, or an opaque {@link CaSigner} (HSM/KMS-held key;
48
+ * only the openssl-free toolbox supports it — openssl needs a key file)
49
+ * — see {@link CreateSelfSignCertificateWithConfigParam.privateKey}.
50
+ */
51
+ privateKey: Filename | PrivateKey | CaSigner;
52
+ /** Intended purpose of the certificate. */
53
+ purpose: CertificatePurpose;
54
+ }
55
+ /**
56
+ * Narrows the `privateKey` union of the toolbox options: a {@link CaSigner}
57
+ * is the only member that carries a `sign` method — a path is a string and
58
+ * a {@link PrivateKey} envelope has only `hidden`.
59
+ */
60
+ export declare function isOpaqueSigner(privateKey: Filename | PrivateKey | CaSigner): privateKey is CaSigner;
61
+ /**
62
+ * Validity period parameters for certificate generation.
63
+ */
64
+ export interface StartDateEndDateParam {
65
+ /** Certificate "Not Before" date. Defaults to now. */
66
+ startDate?: Date;
67
+ /** Certificate "Not After" date (computed from validity). */
68
+ endDate?: Date;
69
+ /** Number of days the certificate is valid. @defaultValue 365 */
70
+ validity?: number;
71
+ /**
72
+ * Certificate validity in milliseconds.
73
+ *
74
+ * When provided, takes precedence over {@link validity} and enables
75
+ * sub-day validity (X.509 supports second precision per RFC 5280
76
+ * §4.1.2.5; OpenSSL is invoked with `-startdate`/`-enddate` already).
77
+ *
78
+ * Typical use is short-lived certificates for demos or for renewal
79
+ * cycle testing. Existing day-based callers are unaffected.
80
+ */
81
+ validityMs?: number;
82
+ }
83
+ /**
84
+ * Parameters for creating a self-signed certificate.
85
+ */
86
+ export interface CreateSelfSignCertificateParam extends ProcessAltNamesParam, StartDateEndDateParam {
87
+ /** X.500 subject for the certificate. */
88
+ subject?: SubjectOptions | string;
89
+ }
90
+ /**
91
+ * Extended self-signed certificate options that include
92
+ * filesystem paths and purpose — used internally.
93
+ */
94
+ export interface CreateSelfSignCertificateWithConfigParam extends CreateSelfSignCertificateParam {
95
+ /** Root directory of the PKI store. */
96
+ rootDir: Filename;
97
+ /** Path to the OpenSSL configuration file. */
98
+ configFile: Filename;
99
+ /**
100
+ * The private key: a filesystem path to a PEM file (unencrypted;
101
+ * the historical behavior), an already-resolved in-memory
102
+ * {@link PrivateKey} — used when the key is passphrase-protected on
103
+ * disk, so the decrypted key material is never written back out in
104
+ * cleartext — or an opaque {@link CaSigner} (HSM/KMS-held key; only
105
+ * the openssl-free toolbox supports it — openssl needs a key file).
106
+ */
107
+ privateKey: Filename | PrivateKey | CaSigner;
108
+ /** Intended purpose of the certificate. */
109
+ purpose: CertificatePurpose;
110
+ }
111
+ /**
112
+ * A passphrase, or a function resolving one — called lazily, and at most
113
+ * once per `CertificateManager` / `CertificateAuthority` instance (the
114
+ * result is cached in memory). Never logged.
115
+ */
116
+ export type PrivateKeyPassphrase = string | (() => Promise<string>);
117
+ /**
118
+ * Sources a {@link PrivateKey} from somewhere other than the local
119
+ * filesystem (an HSM, a KMS, ...). When configured on `CertificateManager`,
120
+ * it overrides disk entirely — the on-disk `own/private/private_key.pem` is
121
+ * neither generated nor read. `CertificateAuthority` does not support a
122
+ * provider (its signing paths are openssl reading a key file); it does
123
+ * support `privateKeyPassphrase`.
124
+ */
125
+ export interface PrivateKeyProvider {
126
+ getPrivateKey(): Promise<PrivateKey>;
127
+ }
128
+ /** Resolve a {@link PrivateKeyPassphrase}, if configured. */
129
+ export declare function resolvePrivateKeyPassphrase(passphrase: PrivateKeyPassphrase | undefined): Promise<string | undefined>;
130
+ /**
131
+ * General-purpose parameters passed to CA operations such as
132
+ * {@link CertificateAuthority.signCertificateRequest} and
133
+ * {@link CertificateAuthority.revokeCertificate}.
134
+ */
135
+ export interface Params extends ProcessAltNamesParam, StartDateEndDateParam {
136
+ /** X.500 subject for the certificate. */
137
+ subject?: SubjectOptions | string;
138
+ /** Path to the private key file. */
139
+ privateKey?: string;
140
+ /** Path to the OpenSSL configuration file. */
141
+ configFile?: string;
142
+ /** Root directory of the PKI store. */
143
+ rootDir?: string;
144
+ /** Output filename for the generated certificate. */
145
+ outputFile?: string;
146
+ /** CRL revocation reason (e.g. `"keyCompromise"`). */
147
+ reason?: string;
148
+ }
149
+ export declare function adjustDate(params: StartDateEndDateParam): void;
150
+ export declare function adjustApplicationUri(params: Params): void;
@@ -0,0 +1,82 @@
1
+ // ---------------------------------------------------------------------------------------------------------------------
2
+ // node-opcua-pki
3
+ // ---------------------------------------------------------------------------------------------------------------------
4
+ // Copyright (c) 2014-2026 - Etienne Rossignon - etienne.rossignon (at) gadz.org
5
+ // Copyright (c) 2022-2026 - Sterfive.com
6
+ // ---------------------------------------------------------------------------------------------------------------------
7
+ //
8
+ // This project is licensed under the terms of the MIT license.
9
+ //
10
+ // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
11
+ // documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
12
+ // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
13
+ // permit persons to whom the Software is furnished to do so, subject to the following conditions:
14
+ //
15
+ // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
16
+ // Software.
17
+ //
18
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
19
+ // WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
20
+ // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
21
+ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ // ---------------------------------------------------------------------------------------------------------------------
23
+ import assert from "node:assert";
24
+ export function quote(str) {
25
+ return `"${str || ""}"`;
26
+ }
27
+ /**
28
+ * Narrows the `privateKey` union of the toolbox options: a {@link CaSigner}
29
+ * is the only member that carries a `sign` method — a path is a string and
30
+ * a {@link PrivateKey} envelope has only `hidden`.
31
+ */
32
+ export function isOpaqueSigner(privateKey) {
33
+ return typeof privateKey !== "string" && typeof privateKey.sign === "function";
34
+ }
35
+ /** Resolve a {@link PrivateKeyPassphrase}, if configured. */
36
+ export async function resolvePrivateKeyPassphrase(passphrase) {
37
+ if (passphrase === undefined) {
38
+ return undefined;
39
+ }
40
+ return typeof passphrase === "function" ? await passphrase() : passphrase;
41
+ }
42
+ export function adjustDate(params) {
43
+ assert(params instanceof Object);
44
+ params.startDate = params.startDate || new Date();
45
+ assert(params.startDate instanceof Date);
46
+ // Precedence: validityMs > validity (days) > default 365 days.
47
+ // When validityMs is set, compute endDate via millisecond arithmetic
48
+ // (sub-day capable). Otherwise preserve the legacy calendar-day
49
+ // arithmetic via setDate() so day-based callers remain
50
+ // bit-for-bit identical (including DST boundary handling).
51
+ if (params.validityMs !== undefined) {
52
+ if (params.validityMs <= 0) {
53
+ throw new RangeError(`validityMs must be > 0 (got ${params.validityMs})`);
54
+ }
55
+ params.endDate = new Date(params.startDate.getTime() + params.validityMs);
56
+ // Keep params.validity in sync as the ceil-rounded day count, so
57
+ // downstream code paths that read params.validity (e.g. logging,
58
+ // OpenSSL command echo) still see a sensible value.
59
+ params.validity = Math.ceil(params.validityMs / 86_400_000);
60
+ }
61
+ else {
62
+ params.validity = params.validity || 365; // one year
63
+ params.endDate = new Date(params.startDate.getTime());
64
+ params.endDate.setDate(params.startDate.getDate() + params.validity);
65
+ }
66
+ // params.endDate = x509Date(endDate);
67
+ // params.startDate = x509Date(startDate);
68
+ assert(params.endDate instanceof Date);
69
+ assert(params.startDate instanceof Date);
70
+ // // istanbul ignore next
71
+ // if (!g_config.silent) {
72
+ // warningLog(" start Date ", params.startDate.toUTCString(), x509Date(params.startDate));
73
+ // warningLog(" end Date ", params.endDate.toUTCString(), x509Date(params.endDate));
74
+ // }
75
+ }
76
+ export function adjustApplicationUri(params) {
77
+ const applicationUri = params.applicationUri || "";
78
+ if (applicationUri.length > 200) {
79
+ throw new Error(`Openssl doesn't support urn with length greater than 200${applicationUri}`);
80
+ }
81
+ }
82
+ //# sourceMappingURL=common.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.js","sourceRoot":"","sources":["../../../lib/toolbox/common.ts"],"names":[],"mappings":"AAAA,wHAAwH;AACxH,iBAAiB;AACjB,wHAAwH;AACxH,gFAAgF;AAChF,yCAAyC;AACzC,wHAAwH;AACxH,EAAE;AACF,gEAAgE;AAChE,EAAE;AACF,+GAA+G;AAC/G,sHAAsH;AACtH,kHAAkH;AAClH,mGAAmG;AACnG,EAAE;AACF,uHAAuH;AACvH,YAAY;AACZ,EAAE;AACF,uHAAuH;AACvH,wHAAwH;AACxH,mHAAmH;AACnH,mHAAmH;AACnH,wHAAwH;AACxH,OAAO,MAAM,MAAM,aAAa,CAAC;AAmBjC,MAAM,UAAU,KAAK,CAAC,GAAY;IAC9B,OAAO,IAAI,GAAG,IAAI,EAAE,GAAG,CAAC;AAC5B,CAAC;AA4CD;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,UAA4C;IACvE,OAAO,OAAO,UAAU,KAAK,QAAQ,IAAI,OAAQ,UAAuB,CAAC,IAAI,KAAK,UAAU,CAAC;AACjG,CAAC;AA0ED,6DAA6D;AAC7D,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAAC,UAA4C;IAC1F,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;QAC3B,OAAO,SAAS,CAAC;IACrB,CAAC;IACD,OAAO,OAAO,UAAU,KAAK,UAAU,CAAC,CAAC,CAAC,MAAM,UAAU,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC;AAC9E,CAAC;AAwBD,MAAM,UAAU,UAAU,CAAC,MAA6B;IACpD,MAAM,CAAC,MAAM,YAAY,MAAM,CAAC,CAAC;IACjC,MAAM,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS,IAAI,IAAI,IAAI,EAAE,CAAC;IAClD,MAAM,CAAC,MAAM,CAA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D,IAAI,cAAc,CAAC,MAAM,GAAG,GAAG,EAAE,CAAC;QAC9B,MAAM,IAAI,KAAK,CAAC,2DAA2D,cAAc,EAAE,CAAC,CAAC;IACjG,CAAC;AACL,CAAC"}
@@ -0,0 +1,25 @@
1
+ export declare function certificateFileExist(certificateFile: string): boolean;
2
+ export declare function mkdirRecursiveSync(folder: string): void;
3
+ /**
4
+ * Restrict a file or directory to owner-only access (mode 0600/0700).
5
+ *
6
+ * fs.chmod only toggles the read-only attribute on Windows and cannot express
7
+ * POSIX-style owner-only permissions, so this is a no-op there rather than a
8
+ * false sense of protection. Errors are logged, not thrown: a read-only mount
9
+ * or an unexpected ownership mismatch should not prevent the server from
10
+ * starting.
11
+ */
12
+ export declare function restrictPrivateFilePermissions(target: string, mode: 0o600 | 0o700): void;
13
+ /**
14
+ * Create (or repair) a directory intended to hold private key material,
15
+ * restricted to owner-only access. Safe to call on an existing directory
16
+ * to repair permissions left by an earlier, less restrictive version.
17
+ */
18
+ export declare function ensurePrivateDirectory(dir: string): void;
19
+ /**
20
+ * `true` if the PEM file at `filename` holds a passphrase-encrypted PKCS#8
21
+ * key (`-----BEGIN ENCRYPTED PRIVATE KEY-----`). Header check only; it does
22
+ * not validate or decrypt the key. Throws if the file cannot be read.
23
+ */
24
+ export declare function isEncryptedPrivateKeyFile(filename: string): boolean;
25
+ export declare function makePath(folderName: string, filename?: string): string;
@@ -0,0 +1,97 @@
1
+ // ---------------------------------------------------------------------------------------------------------------------
2
+ // node-opcua-pki
3
+ // ---------------------------------------------------------------------------------------------------------------------
4
+ // Copyright (c) 2014-2026 - Etienne Rossignon - etienne.rossignon (at) gadz.org
5
+ // Copyright (c) 2022-2026 - Sterfive.com
6
+ // ---------------------------------------------------------------------------------------------------------------------
7
+ //
8
+ // This project is licensed under the terms of the MIT license.
9
+ //
10
+ // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
11
+ // documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
12
+ // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
13
+ // permit persons to whom the Software is furnished to do so, subject to the following conditions:
14
+ //
15
+ // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
16
+ // Software.
17
+ //
18
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
19
+ // WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
20
+ // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
21
+ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ // ---------------------------------------------------------------------------------------------------------------------
23
+ import assert from "node:assert";
24
+ import fs from "node:fs";
25
+ import path from "node:path";
26
+ import chalk from "chalk";
27
+ import { g_config } from "./config.js";
28
+ import { debugLog, warningLog } from "./debug.js";
29
+ export function certificateFileExist(certificateFile) {
30
+ // istanbul ignore next
31
+ if (fs.existsSync(certificateFile) && !g_config.force) {
32
+ warningLog(chalk.yellow(" certificate ") + chalk.cyan(certificateFile) + chalk.yellow(" already exists => do not overwrite"));
33
+ return false;
34
+ }
35
+ return true;
36
+ }
37
+ export function mkdirRecursiveSync(folder) {
38
+ if (!fs.existsSync(folder)) {
39
+ // istanbul ignore next
40
+ debugLog(chalk.white(" .. constructing "), folder);
41
+ fs.mkdirSync(folder, { recursive: true });
42
+ }
43
+ }
44
+ /**
45
+ * Restrict a file or directory to owner-only access (mode 0600/0700).
46
+ *
47
+ * fs.chmod only toggles the read-only attribute on Windows and cannot express
48
+ * POSIX-style owner-only permissions, so this is a no-op there rather than a
49
+ * false sense of protection. Errors are logged, not thrown: a read-only mount
50
+ * or an unexpected ownership mismatch should not prevent the server from
51
+ * starting.
52
+ */
53
+ export function restrictPrivateFilePermissions(target, mode) {
54
+ // istanbul ignore if
55
+ if (process.platform === "win32") {
56
+ return;
57
+ }
58
+ try {
59
+ fs.chmodSync(target, mode);
60
+ }
61
+ catch (err) {
62
+ // istanbul ignore next
63
+ warningLog(chalk.yellow(" could not restrict permissions on "), target, err.message);
64
+ }
65
+ }
66
+ /**
67
+ * Create (or repair) a directory intended to hold private key material,
68
+ * restricted to owner-only access. Safe to call on an existing directory
69
+ * to repair permissions left by an earlier, less restrictive version.
70
+ */
71
+ export function ensurePrivateDirectory(dir) {
72
+ if (!fs.existsSync(dir)) {
73
+ fs.mkdirSync(dir, { recursive: true, mode: 0o700 });
74
+ }
75
+ restrictPrivateFilePermissions(dir, 0o700);
76
+ }
77
+ /**
78
+ * `true` if the PEM file at `filename` holds a passphrase-encrypted PKCS#8
79
+ * key (`-----BEGIN ENCRYPTED PRIVATE KEY-----`). Header check only; it does
80
+ * not validate or decrypt the key. Throws if the file cannot be read.
81
+ */
82
+ export function isEncryptedPrivateKeyFile(filename) {
83
+ return fs.readFileSync(filename, "utf-8").includes("-----BEGIN ENCRYPTED PRIVATE KEY-----");
84
+ }
85
+ export function makePath(folderName, filename) {
86
+ let s;
87
+ if (filename) {
88
+ s = path.join(path.normalize(folderName), filename);
89
+ }
90
+ else {
91
+ assert(folderName);
92
+ s = folderName;
93
+ }
94
+ s = s.replace(/\\/g, "/");
95
+ return s;
96
+ }
97
+ //# sourceMappingURL=common2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common2.js","sourceRoot":"","sources":["../../../lib/toolbox/common2.ts"],"names":[],"mappings":"AAAA,wHAAwH;AACxH,iBAAiB;AACjB,wHAAwH;AACxH,gFAAgF;AAChF,yCAAyC;AACzC,wHAAwH;AACxH,EAAE;AACF,gEAAgE;AAChE,EAAE;AACF,+GAA+G;AAC/G,sHAAsH;AACtH,kHAAkH;AAClH,mGAAmG;AACnG,EAAE;AACF,uHAAuH;AACvH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------------------------------------------------------------------------------------
2
+ // node-opcua-pki
3
+ // ---------------------------------------------------------------------------------------------------------------------
4
+ // Copyright (c) 2014-2026 - Etienne Rossignon - etienne.rossignon (at) gadz.org
5
+ // Copyright (c) 2022-2026 - Sterfive.com
6
+ // ---------------------------------------------------------------------------------------------------------------------
7
+ //
8
+ // This project is licensed under the terms of the MIT license.
9
+ //
10
+ // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
11
+ // documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
12
+ // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
13
+ // permit persons to whom the Software is furnished to do so, subject to the following conditions:
14
+ //
15
+ // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
16
+ // Software.
17
+ //
18
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
19
+ // WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
20
+ // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
21
+ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ // ---------------------------------------------------------------------------------------------------------------------
23
+ export const g_config = {
24
+ opensslVersion: "unset",
25
+ silent: process.env.VERBOSE ? !process.env.VERBOSE : true,
26
+ force: false
27
+ };
28
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../../lib/toolbox/config.ts"],"names":[],"mappings":"AAAA,wHAAwH;AACxH,iBAAiB;AACjB,wHAAwH;AACxH,gFAAgF;AAChF,yCAAyC;AACzC,wHAAwH;AACxH,EAAE;AACF,gEAAgE;AAChE,EAAE;AACF,+GAA+G;AAC/G,sHAAsH;AACtH,kHAAkH;AAClH,mGAAmG;AACnG,EAAE;AACF,uHAAuH;AACvH,YAAY;AACZ,EAAE;AACF,uHAAuH;AACvH,wHAAwH;AACxH,mHAAmH;AACnH,mHAAmH;AACnH,wHAAwH;AACxH,MAAM,CAAC,MAAM,QAAQ,GAAG;IACpB,cAAc,EAAE,OAAO;IACvB,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI;IACzD,KAAK,EAAE,KAAK;CACf,CAAC"}
@@ -0,0 +1,5 @@
1
+ export declare const doDebug: string | boolean;
2
+ export declare const displayError = true;
3
+ export declare const displayDebug: boolean;
4
+ export declare function debugLog(...args: unknown[]): void;
5
+ export declare function warningLog(...args: unknown[]): void;
@@ -0,0 +1,35 @@
1
+ // ---------------------------------------------------------------------------------------------------------------------
2
+ // node-opcua-pki
3
+ // ---------------------------------------------------------------------------------------------------------------------
4
+ // Copyright (c) 2014-2026 - Etienne Rossignon - etienne.rossignon (at) gadz.org
5
+ // Copyright (c) 2022-2026 - Sterfive.com
6
+ // ---------------------------------------------------------------------------------------------------------------------
7
+ //
8
+ // This project is licensed under the terms of the MIT license.
9
+ //
10
+ // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
11
+ // documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
12
+ // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
13
+ // permit persons to whom the Software is furnished to do so, subject to the following conditions:
14
+ //
15
+ // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
16
+ // Software.
17
+ //
18
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
19
+ // WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
20
+ // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
21
+ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ // ---------------------------------------------------------------------------------------------------------------------
23
+ export const doDebug = process.env.NODEOPCUAPKIDEBUG || false;
24
+ export const displayError = true;
25
+ export const displayDebug = !!process.env.NODEOPCUAPKIDEBUG || false;
26
+ export function debugLog(...args) {
27
+ // istanbul ignore next
28
+ if (displayDebug) {
29
+ console.log.apply(null, args);
30
+ }
31
+ }
32
+ export function warningLog(...args) {
33
+ console.log.apply(null, args);
34
+ }
35
+ //# sourceMappingURL=debug.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"debug.js","sourceRoot":"","sources":["../../../lib/toolbox/debug.ts"],"names":[],"mappings":"AAAA,wHAAwH;AACxH,iBAAiB;AACjB,wHAAwH;AACxH,gFAAgF;AAChF,yCAAyC;AACzC,wHAAwH;AACxH,EAAE;AACF,gEAAgE;AAChE,EAAE;AACF,+GAA+G;AAC/G,sHAAsH;AACtH,kHAAkH;AAClH,mGAAmG;AACnG,EAAE;AACF,uHAAuH;AACvH,YAAY;AACZ,EAAE;AACF,uHAAuH;AACvH,wHAAwH;AACxH,mHAAmH;AACnH,mHAAmH;AACnH,wHAAwH;AACxH,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,iBAAiB,IAAI,KAAK,CAAC;AAC9D,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,CAAC;AACjC,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,iBAAiB,IAAI,KAAK,CAAC;AACrE,MAAM,UAAU,QAAQ,CAAC,GAAG,IAAe;IACvC,uBAAuB;IACvB,IAAI,YAAY,EAAE,CAAC;QACf,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAClC,CAAC;AACL,CAAC;AACD,MAAM,UAAU,UAAU,CAAC,GAAG,IAAe;IACzC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AAClC,CAAC"}
@@ -0,0 +1,4 @@
1
+ export declare function displayChapter(str: string): void;
2
+ export declare function displayTitle(str: string): void;
3
+ export declare function displaySubtitle(str: string): void;
4
+ export declare function display(str: string): void;
@@ -0,0 +1,56 @@
1
+ // ---------------------------------------------------------------------------------------------------------------------
2
+ // node-opcua-pki
3
+ // ---------------------------------------------------------------------------------------------------------------------
4
+ // Copyright (c) 2014-2026 - Etienne Rossignon - etienne.rossignon (at) gadz.org
5
+ // Copyright (c) 2022-2026 - Sterfive.com
6
+ // ---------------------------------------------------------------------------------------------------------------------
7
+ //
8
+ // This project is licensed under the terms of the MIT license.
9
+ //
10
+ // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
11
+ // documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
12
+ // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
13
+ // permit persons to whom the Software is furnished to do so, subject to the following conditions:
14
+ //
15
+ // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
16
+ // Software.
17
+ //
18
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
19
+ // WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
20
+ // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
21
+ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ // ---------------------------------------------------------------------------------------------------------------------
23
+ import chalk from "chalk";
24
+ import { g_config } from "./config.js";
25
+ import { warningLog } from "./debug.js";
26
+ // istanbul ignore next
27
+ export function displayChapter(str) {
28
+ const l = " ";
29
+ warningLog(`${chalk.bgWhite(l)} `);
30
+ str = ` ${str}${l}`.substring(0, l.length);
31
+ warningLog(chalk.bgWhite.cyan(str));
32
+ warningLog(`${chalk.bgWhite(l)} `);
33
+ }
34
+ export function displayTitle(str) {
35
+ // istanbul ignore next
36
+ if (!g_config.silent) {
37
+ warningLog("");
38
+ warningLog(chalk.yellowBright(str));
39
+ warningLog(chalk.yellow(new Array(str.length + 1).join("=")), "\n");
40
+ }
41
+ }
42
+ export function displaySubtitle(str) {
43
+ // istanbul ignore next
44
+ if (!g_config.silent) {
45
+ warningLog("");
46
+ warningLog(` ${chalk.yellowBright(str)}`);
47
+ warningLog(` ${chalk.white(new Array(str.length + 1).join("-"))}`, "\n");
48
+ }
49
+ }
50
+ export function display(str) {
51
+ // istanbul ignore next
52
+ if (!g_config.silent) {
53
+ warningLog(` ${str}`);
54
+ }
55
+ }
56
+ //# sourceMappingURL=display.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"display.js","sourceRoot":"","sources":["../../../lib/toolbox/display.ts"],"names":[],"mappings":"AAAA,wHAAwH;AACxH,iBAAiB;AACjB,wHAAwH;AACxH,gFAAgF;AAChF,yCAAyC;AACzC,wHAAwH;AACxH,EAAE;AACF,gEAAgE;AAChE,EAAE;AACF,+GAA+G;AAC/G,sHAAsH;AACtH,kHAAkH;AAClH,mGAAmG;AACnG,EAAE;AACF,uHAAuH;AACvH,YAAY;AACZ,EAAE;AACF,uHAAuH;AACvH,wHAAwH;AACxH,mHAAmH;AACnH,mHAAmH;AACnH,wHAAwH;AACxH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa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AAE,EAAE,IAAI,CAAC,CAAC;IAChF,CAAC;AACL,CAAC;AACD,MAAM,UAAU,OAAO,CAAC,GAAW;IAC/B,uBAAuB;IACvB,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;QACnB,UAAU,CAAC,UAAU,GAAG,EAAE,CAAC,CAAC;IAChC,CAAC;AACL,CAAC"}
@@ -0,0 +1,5 @@
1
+ export * from "./common.js";
2
+ export * from "./common2.js";
3
+ export * from "./config.js";
4
+ export * from "./debug.js";
5
+ export * from "./display.js";
@@ -0,0 +1,28 @@
1
+ // ---------------------------------------------------------------------------------------------------------------------
2
+ // node-opcua-pki
3
+ // ---------------------------------------------------------------------------------------------------------------------
4
+ // Copyright (c) 2014-2026 - Etienne Rossignon - etienne.rossignon (at) gadz.org
5
+ // Copyright (c) 2022-2026 - Sterfive.com
6
+ // ---------------------------------------------------------------------------------------------------------------------
7
+ //
8
+ // This project is licensed under the terms of the MIT license.
9
+ //
10
+ // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
11
+ // documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
12
+ // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
13
+ // permit persons to whom the Software is furnished to do so, subject to the following conditions:
14
+ //
15
+ // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
16
+ // Software.
17
+ //
18
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
19
+ // WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
20
+ // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
21
+ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ // ---------------------------------------------------------------------------------------------------------------------
23
+ export * from "./common.js";
24
+ export * from "./common2.js";
25
+ export * from "./config.js";
26
+ export * from "./debug.js";
27
+ export * from "./display.js";
28
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../lib/toolbox/index.ts"],"names":[],"mappings":"AAAA,wHAAwH;AACxH,iBAAiB;AACjB,wHAAwH;AACxH,gFAAgF;AAChF,yCAAyC;AACzC,wHAAwH;AACxH,EAAE;AACF,gEAAgE;AAChE,EAAE;AACF,+GAA+G;AAC/G,sHAAsH;AACtH,kHAAkH;AAClH,mGAAmG;AACnG,EAAE;AACF,uHAAuH;AACvH,YAAY;AACZ,EAAE;AACF,uHAAuH;AACvH,wHAAwH;AACxH,mHAAmH;AACnH,mHAAmH;AACnH,wHAAwH;AACxH,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { type ExecuteOptions } from "./execute_openssl.js";
2
+ export declare function createRandomFile(randomFile: string, options: ExecuteOptions): Promise<void>;
3
+ export declare function createRandomFileIfNotExist(randomFile: string, options: ExecuteOptions): Promise<void>;
4
+ export declare function useRandFile(): boolean;
@@ -0,0 +1,50 @@
1
+ // ---------------------------------------------------------------------------------------------------------------------
2
+ // node-opcua-pki
3
+ // ---------------------------------------------------------------------------------------------------------------------
4
+ // Copyright (c) 2014-2026 - Etienne Rossignon - etienne.rossignon (at) gadz.org
5
+ // Copyright (c) 2022-2026 - Sterfive.com
6
+ // ---------------------------------------------------------------------------------------------------------------------
7
+ //
8
+ // This project is licensed under the terms of the MIT license.
9
+ //
10
+ // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
11
+ // documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
12
+ // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
13
+ // permit persons to whom the Software is furnished to do so, subject to the following conditions:
14
+ //
15
+ // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
16
+ // Software.
17
+ //
18
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
19
+ // WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
20
+ // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
21
+ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ // ---------------------------------------------------------------------------------------------------------------------
23
+ import fs from "node:fs";
24
+ import path from "node:path";
25
+ import { g_config } from "../config.js";
26
+ import { execute_openssl } from "./execute_openssl.js";
27
+ export async function createRandomFile(randomFile, options) {
28
+ // istanbul ignore next
29
+ if (!useRandFile()) {
30
+ return;
31
+ }
32
+ await execute_openssl(["rand", "-out", randomFile, "-hex", "256"], options);
33
+ }
34
+ export async function createRandomFileIfNotExist(randomFile, options) {
35
+ const randomFilePath = options.cwd ? path.join(options.cwd, randomFile) : randomFile;
36
+ if (fs.existsSync(randomFilePath)) {
37
+ return;
38
+ }
39
+ else {
40
+ await createRandomFile(randomFile, options);
41
+ }
42
+ }
43
+ export function useRandFile() {
44
+ // istanbul ignore next
45
+ if (g_config.opensslVersion && g_config.opensslVersion.toLowerCase().indexOf("libressl") > -1) {
46
+ return false;
47
+ }
48
+ return true;
49
+ }
50
+ //# sourceMappingURL=_create_random_file.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_create_random_file.js","sourceRoot":"","sources":["../../../../lib/toolbox/with_openssl/_create_random_file.ts"],"names":[],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