node-opcua-crypto 5.3.2 → 5.3.4
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/dist/{chunk-TSW463FI.cjs → chunk-AZUYUXWD.cjs} +18 -16
- package/dist/chunk-AZUYUXWD.cjs.map +1 -0
- package/dist/{chunk-ODR4HUB7.js → chunk-P5QLLSP2.js} +13 -11
- package/dist/chunk-P5QLLSP2.js.map +1 -0
- package/dist/{chunk-UEEZA3YS.js → chunk-ULNIL7FF.js} +2 -2
- package/dist/{chunk-IKQT3ICS.cjs → chunk-XDS5YIBC.cjs} +22 -22
- package/dist/{chunk-IKQT3ICS.cjs.map → chunk-XDS5YIBC.cjs.map} +1 -1
- package/dist/index.cjs +3 -3
- package/dist/index.js +2 -2
- package/dist/source/index_web.cjs +2 -2
- package/dist/source/index_web.d.cts +9 -2
- package/dist/source/index_web.d.ts +9 -2
- package/dist/source/index_web.js +1 -1
- package/dist/source_nodejs/index.cjs +3 -3
- package/dist/source_nodejs/index.js +2 -2
- package/package.json +3 -2
- package/dist/chunk-ODR4HUB7.js.map +0 -1
- package/dist/chunk-TSW463FI.cjs.map +0 -1
- /package/dist/{chunk-UEEZA3YS.js.map → chunk-ULNIL7FF.js.map} +0 -0
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
removeTrailingLF,
|
|
9
9
|
split_der,
|
|
10
10
|
toPem
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-P5QLLSP2.js";
|
|
12
12
|
|
|
13
13
|
// source_nodejs/generate_private_key_filename.ts
|
|
14
14
|
import { generateKeyPairSync } from "crypto";
|
|
@@ -280,4 +280,4 @@ export {
|
|
|
280
280
|
writeCertificateChainDer,
|
|
281
281
|
writeCertificateChainDerAsync
|
|
282
282
|
};
|
|
283
|
-
//# sourceMappingURL=chunk-
|
|
283
|
+
//# sourceMappingURL=chunk-ULNIL7FF.js.map
|
|
@@ -7,14 +7,14 @@
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunkAZUYUXWDcjs = require('./chunk-AZUYUXWD.cjs');
|
|
11
11
|
|
|
12
12
|
// source_nodejs/generate_private_key_filename.ts
|
|
13
13
|
var _crypto = require('crypto');
|
|
14
14
|
var _fs = require('fs'); var _fs2 = _interopRequireDefault(_fs);
|
|
15
15
|
async function generatePrivateKeyFile(privateKeyFilename, modulusLength) {
|
|
16
|
-
const keys = await
|
|
17
|
-
const privateKeyPem = await
|
|
16
|
+
const keys = await _chunkAZUYUXWDcjs.generateKeyPair.call(void 0, modulusLength);
|
|
17
|
+
const privateKeyPem = await _chunkAZUYUXWDcjs.privateKeyToPEM.call(void 0, keys.privateKey);
|
|
18
18
|
await _fs2.default.promises.writeFile(privateKeyFilename, privateKeyPem.privPem, "utf-8");
|
|
19
19
|
privateKeyPem.privPem = "";
|
|
20
20
|
privateKeyPem.privDer = new ArrayBuffer(0);
|
|
@@ -36,7 +36,7 @@ var _path = require('path'); var _path2 = _interopRequireDefault(_path);
|
|
|
36
36
|
var _sshpk = require('sshpk'); var _sshpk2 = _interopRequireDefault(_sshpk);
|
|
37
37
|
function _readPemFile(filename) {
|
|
38
38
|
_assert2.default.call(void 0, typeof filename === "string");
|
|
39
|
-
return
|
|
39
|
+
return _chunkAZUYUXWDcjs.removeTrailingLF.call(void 0, _fs2.default.readFileSync(filename, "utf-8"));
|
|
40
40
|
}
|
|
41
41
|
function _countPemCertBlocks(pem) {
|
|
42
42
|
const matches = pem.match(/-----BEGIN CERTIFICATE-----/g);
|
|
@@ -53,11 +53,11 @@ function readCertificate(filename) {
|
|
|
53
53
|
`[node-opcua-crypto] readCertificate: "${_path2.default.basename(filename)}" contains ${count} PEM certificate block(s) but only the first will be used. Use readCertificateChain() to read all certificates.`
|
|
54
54
|
);
|
|
55
55
|
}
|
|
56
|
-
return
|
|
56
|
+
return _chunkAZUYUXWDcjs.convertPEMtoDER.call(void 0, pem);
|
|
57
57
|
}
|
|
58
58
|
function readCertificateChain(filename) {
|
|
59
59
|
if (filename.match(/.*\.der/)) {
|
|
60
|
-
return
|
|
60
|
+
return _chunkAZUYUXWDcjs.split_der.call(void 0, _fs2.default.readFileSync(filename));
|
|
61
61
|
}
|
|
62
62
|
const pem = _readPemFile(filename);
|
|
63
63
|
return _extractAllPemDerCertificates(pem);
|
|
@@ -65,9 +65,9 @@ function readCertificateChain(filename) {
|
|
|
65
65
|
async function readCertificateChainAsync(filename) {
|
|
66
66
|
const buf = await _fs2.default.promises.readFile(filename);
|
|
67
67
|
if (filename.match(/.*\.der/)) {
|
|
68
|
-
return
|
|
68
|
+
return _chunkAZUYUXWDcjs.split_der.call(void 0, buf);
|
|
69
69
|
}
|
|
70
|
-
const pem =
|
|
70
|
+
const pem = _chunkAZUYUXWDcjs.removeTrailingLF.call(void 0, buf.toString("utf-8"));
|
|
71
71
|
return _extractAllPemDerCertificates(pem);
|
|
72
72
|
}
|
|
73
73
|
function _extractAllPemDerCertificates(pem) {
|
|
@@ -87,14 +87,14 @@ async function readCertificateAsync(filename) {
|
|
|
87
87
|
if (filename.match(/.*\.der/)) {
|
|
88
88
|
return buf;
|
|
89
89
|
}
|
|
90
|
-
const raw_key =
|
|
90
|
+
const raw_key = _chunkAZUYUXWDcjs.removeTrailingLF.call(void 0, buf.toString("utf-8"));
|
|
91
91
|
const count = _countPemCertBlocks(raw_key);
|
|
92
92
|
if (count > 1) {
|
|
93
93
|
console.warn(
|
|
94
94
|
`[node-opcua-crypto] readCertificateAsync: "${_path2.default.basename(filename)}" contains ${count} PEM certificate block(s) but only the first will be used. Use readCertificateChainAsync() to read all certificates.`
|
|
95
95
|
);
|
|
96
96
|
}
|
|
97
|
-
return
|
|
97
|
+
return _chunkAZUYUXWDcjs.convertPEMtoDER.call(void 0, raw_key);
|
|
98
98
|
}
|
|
99
99
|
function readPublicKey(filename) {
|
|
100
100
|
if (filename.match(/.*\.der/)) {
|
|
@@ -110,13 +110,13 @@ async function readPublicKeyAsync(filename) {
|
|
|
110
110
|
if (filename.match(/.*\.der/)) {
|
|
111
111
|
return _crypto.createPublicKey.call(void 0, buf);
|
|
112
112
|
}
|
|
113
|
-
return _crypto.createPublicKey.call(void 0,
|
|
113
|
+
return _crypto.createPublicKey.call(void 0, _chunkAZUYUXWDcjs.removeTrailingLF.call(void 0, buf.toString("utf-8")));
|
|
114
114
|
}
|
|
115
115
|
function myCreatePrivateKey(rawKey) {
|
|
116
116
|
if (!_crypto.createPrivateKey || process.env.NO_CREATE_PRIVATEKEY) {
|
|
117
117
|
if (Buffer.isBuffer(rawKey)) {
|
|
118
|
-
const pemKey =
|
|
119
|
-
_assert2.default.call(void 0, ["RSA PRIVATE KEY", "PRIVATE KEY"].indexOf(
|
|
118
|
+
const pemKey = _chunkAZUYUXWDcjs.toPem.call(void 0, rawKey, "PRIVATE KEY");
|
|
119
|
+
_assert2.default.call(void 0, ["RSA PRIVATE KEY", "PRIVATE KEY"].indexOf(_chunkAZUYUXWDcjs.identifyPemType.call(void 0, pemKey)) >= 0);
|
|
120
120
|
return { hidden: pemKey };
|
|
121
121
|
}
|
|
122
122
|
return { hidden: ensureTrailingLF(rawKey) };
|
|
@@ -145,28 +145,28 @@ async function readPrivateKeyAsync(filename) {
|
|
|
145
145
|
if (filename.match(/.*\.der/)) {
|
|
146
146
|
return myCreatePrivateKey(buf);
|
|
147
147
|
}
|
|
148
|
-
return myCreatePrivateKey(
|
|
148
|
+
return myCreatePrivateKey(_chunkAZUYUXWDcjs.removeTrailingLF.call(void 0, buf.toString("utf-8")));
|
|
149
149
|
}
|
|
150
150
|
function readCertificatePEM(filename) {
|
|
151
151
|
return _readPemFile(filename);
|
|
152
152
|
}
|
|
153
153
|
async function readCertificatePEMAsync(filename) {
|
|
154
154
|
const buf = await _fs2.default.promises.readFile(filename, "utf-8");
|
|
155
|
-
return
|
|
155
|
+
return _chunkAZUYUXWDcjs.removeTrailingLF.call(void 0, buf);
|
|
156
156
|
}
|
|
157
157
|
function readPublicKeyPEM(filename) {
|
|
158
158
|
return _readPemFile(filename);
|
|
159
159
|
}
|
|
160
160
|
async function readPublicKeyPEMAsync(filename) {
|
|
161
161
|
const buf = await _fs2.default.promises.readFile(filename, "utf-8");
|
|
162
|
-
return
|
|
162
|
+
return _chunkAZUYUXWDcjs.removeTrailingLF.call(void 0, buf);
|
|
163
163
|
}
|
|
164
164
|
function readPrivateKeyPEM(filename) {
|
|
165
165
|
return _readPemFile(filename);
|
|
166
166
|
}
|
|
167
167
|
async function readPrivateKeyPEMAsync(filename) {
|
|
168
168
|
const buf = await _fs2.default.promises.readFile(filename, "utf-8");
|
|
169
|
-
return
|
|
169
|
+
return _chunkAZUYUXWDcjs.removeTrailingLF.call(void 0, buf);
|
|
170
170
|
}
|
|
171
171
|
var _g_certificate_store = "";
|
|
172
172
|
function setCertificateStore(store) {
|
|
@@ -211,7 +211,7 @@ async function readCertificateRevocationList(filename) {
|
|
|
211
211
|
return crl;
|
|
212
212
|
}
|
|
213
213
|
const raw_crl = crl.toString();
|
|
214
|
-
return
|
|
214
|
+
return _chunkAZUYUXWDcjs.convertPEMtoDER.call(void 0, raw_crl);
|
|
215
215
|
}
|
|
216
216
|
|
|
217
217
|
// source_nodejs/read_certificate_signing_request.ts
|
|
@@ -222,14 +222,14 @@ async function readCertificateSigningRequest(filename) {
|
|
|
222
222
|
return csr;
|
|
223
223
|
}
|
|
224
224
|
const raw_crl = csr.toString();
|
|
225
|
-
return
|
|
225
|
+
return _chunkAZUYUXWDcjs.convertPEMtoDER.call(void 0, raw_crl);
|
|
226
226
|
}
|
|
227
227
|
|
|
228
228
|
// source_nodejs/write.ts
|
|
229
229
|
|
|
230
230
|
function certificatesToPem(certificates) {
|
|
231
231
|
const certs = Array.isArray(certificates) ? certificates : [certificates];
|
|
232
|
-
return `${certs.map((der) =>
|
|
232
|
+
return `${certs.map((der) => _chunkAZUYUXWDcjs.toPem.call(void 0, der, "CERTIFICATE")).join("\n")}
|
|
233
233
|
`;
|
|
234
234
|
}
|
|
235
235
|
function writeCertificateChain(filename, certificates) {
|
|
@@ -240,7 +240,7 @@ async function writeCertificateChainAsync(filename, certificates) {
|
|
|
240
240
|
}
|
|
241
241
|
function certificatesToDer(certificates) {
|
|
242
242
|
const certs = Array.isArray(certificates) ? certificates : [certificates];
|
|
243
|
-
return
|
|
243
|
+
return _chunkAZUYUXWDcjs.combine_der.call(void 0, certs);
|
|
244
244
|
}
|
|
245
245
|
function writeCertificateChainDer(filename, certificates) {
|
|
246
246
|
_fs2.default.writeFileSync(filename, certificatesToDer(certificates));
|
|
@@ -279,4 +279,4 @@ async function writeCertificateChainDerAsync(filename, certificates) {
|
|
|
279
279
|
|
|
280
280
|
|
|
281
281
|
exports.generatePrivateKeyFile = generatePrivateKeyFile; exports.generatePrivateKeyFileAlternate = generatePrivateKeyFileAlternate; exports.readCertificate = readCertificate; exports.readCertificateChain = readCertificateChain; exports.readCertificateChainAsync = readCertificateChainAsync; exports.readCertificateAsync = readCertificateAsync; exports.readPublicKey = readPublicKey; exports.readPublicKeyAsync = readPublicKeyAsync; exports.readPrivateKey = readPrivateKey; exports.readPrivateKeyAsync = readPrivateKeyAsync; exports.readCertificatePEM = readCertificatePEM; exports.readCertificatePEMAsync = readCertificatePEMAsync; exports.readPublicKeyPEM = readPublicKeyPEM; exports.readPublicKeyPEMAsync = readPublicKeyPEMAsync; exports.readPrivateKeyPEM = readPrivateKeyPEM; exports.readPrivateKeyPEMAsync = readPrivateKeyPEMAsync; exports.setCertificateStore = setCertificateStore; exports.getCertificateStore = getCertificateStore; exports.readPrivateRsaKey = readPrivateRsaKey; exports.readPublicRsaKey = readPublicRsaKey; exports.readCertificateRevocationList = readCertificateRevocationList; exports.readCertificateSigningRequest = readCertificateSigningRequest; exports.certificatesToPem = certificatesToPem; exports.writeCertificateChain = writeCertificateChain; exports.writeCertificateChainAsync = writeCertificateChainAsync; exports.certificatesToDer = certificatesToDer; exports.writeCertificateChainDer = writeCertificateChainDer; exports.writeCertificateChainDerAsync = writeCertificateChainDerAsync;
|
|
282
|
-
//# sourceMappingURL=chunk-
|
|
282
|
+
//# sourceMappingURL=chunk-XDS5YIBC.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/node-opcua-crypto/node-opcua-crypto/packages/node-opcua-crypto/dist/chunk-IKQT3ICS.cjs","../source_nodejs/generate_private_key_filename.ts","../source_nodejs/read.ts","../source_nodejs/read_certificate_revocation_list.ts","../source_nodejs/read_certificate_signing_request.ts","../source_nodejs/write.ts"],"names":["fs"],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;ACYA,gCAAoC;AACpC,gEAAe;AAEf,MAAA,SAAsB,sBAAA,CAAuB,kBAAA,EAA4B,aAAA,EAA0C;AAC/G,EAAA,MAAM,KAAA,EAAO,MAAM,+CAAA,aAA6B,CAAA;AAChD,EAAA,MAAM,cAAA,EAAgB,MAAM,+CAAA,IAAgB,CAAK,UAAU,CAAA;AAC3D,EAAA,MAAM,YAAA,CAAG,QAAA,CAAS,SAAA,CAAU,kBAAA,EAAoB,aAAA,CAAc,OAAA,EAAS,OAAO,CAAA;AAC9E,EAAA,aAAA,CAAc,QAAA,EAAU,EAAA;AACxB,EAAA,aAAA,CAAc,QAAA,EAAU,IAAI,WAAA,CAAY,CAAC,CAAA;AAC7C;AAQA,MAAA,SAAsB,+BAAA,CAAgC,kBAAA,EAA4B,aAAA,EAAmC;AACjH,EAAA,MAAM,EAAE,WAAW,EAAA,EAAI,yCAAA,KAAoB,EAAO;AAAA,IAC9C,aAAA;AAAA,IACA,kBAAA,EAAoB,EAAE,IAAA,EAAM,OAAA,EAAS,MAAA,EAAQ,MAAM,CAAA;AAAA,IACnD,iBAAA,EAAmB,EAAE,IAAA,EAAM,MAAA,EAAQ,MAAA,EAAQ,MAAM;AAAA,EACrD,CAAC,CAAA;AACD,EAAA,MAAM,YAAA,CAAG,QAAA,CAAS,SAAA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AAC8C;AACf,EAAA;AACK,IAAA;AAChC,EAAA;AACO,EAAA;AACX;AAKkC;AACP,EAAA;AACH,IAAA;AACpB,EAAA;AACiC,EAAA;AACR,IAAA;AACzB,EAAA;AACgC,EAAA;AACX,EAAA;AACO,EAAA;AACI,EAAA;AAChB,EAAA;AACpB;AAEiC;AACI,EAAA;AACR,IAAA;AACzB,EAAA;AACgC,EAAA;AACF,EAAA;AACF,EAAA;AACK,EAAA;AACrC;AF1GmC;AACA;AGtLpB;AAIO;AACY,EAAA;AACI,EAAA;AAEvB,IAAA;AACX,EAAA;AAC6B,EAAA;AACC,EAAA;AAClC;AHoLmC;AACA;AIjMpB;AAMO;AACY,EAAA;AACI,EAAA;AAEvB,IAAA;AACX,EAAA;AAC6B,EAAA;AACC,EAAA;AAClC;AJ6LmC;AACA;AK5MpB;AAemB;AACF,EAAA;AACC,EAAA;AAAqC;AACtE;AAQsC;AACP,EAAA;AAC/B;AAKsB;AACU,EAAA;AAChC;AAUkC;AACF,EAAA;AACJ,EAAA;AAC5B;AAQyC;AACV,EAAA;AAC/B;AAKsB;AACU,EAAA;AAChC;ALkKmC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/node-opcua-crypto/node-opcua-crypto/packages/node-opcua-crypto/dist/chunk-IKQT3ICS.cjs","sourcesContent":[null,"// ---------------------------------------------------------------------------------------------------------------------\n// node-opcua-crypto\n// ---------------------------------------------------------------------------------------------------------------------\n// Copyright (c) 2014-2022 - Etienne Rossignon - etienne.rossignon (at) gadz.org\n// Copyright (c) 2022-2026 - Sterfive.com\n// ---------------------------------------------------------------------------------------------------------------------\n//\n// This project is licensed under the terms of the MIT license.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated\n// documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the\n// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to\n// permit persons to whom the Software is furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the\n// Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE\n// WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\n// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n// ---------------------------------------------------------------------------------------------------------------------\n\nimport { generateKeyPairSync } from \"node:crypto\";\nimport fs from \"node:fs\";\nimport { generateKeyPair, privateKeyToPEM } from \"../source/index.js\";\nexport async function generatePrivateKeyFile(privateKeyFilename: string, modulusLength: 1024 | 2048 | 3072 | 4096) {\n const keys = await generateKeyPair(modulusLength);\n const privateKeyPem = await privateKeyToPEM(keys.privateKey);\n await fs.promises.writeFile(privateKeyFilename, privateKeyPem.privPem, \"utf-8\");\n privateKeyPem.privPem = \"\";\n privateKeyPem.privDer = new ArrayBuffer(0);\n}\n\n/**\n * alternate function to generate PrivateKeyFile, using native\n * node:crypto.\n *\n * This function is slower than generatePrivateKeyFile\n */\nexport async function generatePrivateKeyFileAlternate(privateKeyFilename: string, modulusLength: 2048 | 3072 | 4096) {\n const { privateKey } = generateKeyPairSync(\"rsa\", {\n modulusLength,\n privateKeyEncoding: { type: \"pkcs8\", format: \"pem\" },\n publicKeyEncoding: { type: \"spki\", format: \"pem\" },\n });\n await fs.promises.writeFile(privateKeyFilename, privateKey, \"utf-8\");\n}\n","// ---------------------------------------------------------------------------------------------------------------------\n// node-opcua-crypto\n// ---------------------------------------------------------------------------------------------------------------------\n// Copyright (c) 2014-2022 - Etienne Rossignon - etienne.rossignon (at) gadz.org\n// Copyright (c) 2022-2026 - Sterfive.com\n// ---------------------------------------------------------------------------------------------------------------------\n//\n// This project is licensed under the terms of the MIT license.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated\n// documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the\n// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to\n// permit persons to whom the Software is furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the\n// Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE\n// WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\n// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n// ---------------------------------------------------------------------------------------------------------------------\n\nimport assert from \"node:assert\";\nimport { createPrivateKey, createPublicKey } from \"node:crypto\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport sshpk from \"sshpk\";\nimport type {\n Certificate,\n CertificatePEM,\n DER,\n KeyObject,\n PEM,\n PrivateKey,\n PrivateKeyPEM,\n PublicKey,\n PublicKeyPEM,\n} from \"../source/common.js\";\nimport { split_der } from \"../source/crypto_explore_certificate.js\";\nimport { convertPEMtoDER, identifyPemType, removeTrailingLF, toPem } from \"../source/crypto_utils.js\";\n\nfunction _readPemFile(filename: string): PEM {\n assert(typeof filename === \"string\");\n return removeTrailingLF(fs.readFileSync(filename, \"utf-8\"));\n}\n\nfunction _readPemOrDerFileAsDER(filename: string): DER {\n if (filename.match(/.*\\.der/)) {\n return fs.readFileSync(filename) as Buffer;\n }\n const raw_key: string = _readPemFile(filename);\n return convertPEMtoDER(raw_key);\n}\n\nfunction _countPemCertBlocks(pem: string): number {\n const matches = pem.match(/-----BEGIN CERTIFICATE-----/g);\n return matches ? matches.length : 0;\n}\n\n/**\n * Read a DER or PEM certificate from file.\n *\n * **Note:** If the PEM file contains multiple certificate blocks\n * (e.g. a leaf cert + CA chain), only the **first** certificate\n * is returned. Use {@link readCertificateChain} to read all\n * certificates individually.\n *\n * @deprecated Use {@link readCertificateChain} instead, which\n * returns each certificate as a separate DER buffer.\n */\nexport function readCertificate(filename: string): Certificate {\n if (filename.match(/.*\\.der/)) {\n return fs.readFileSync(filename) as Certificate;\n }\n const pem = _readPemFile(filename);\n const count = _countPemCertBlocks(pem);\n if (count > 1) {\n console.warn(\n `[node-opcua-crypto] readCertificate: \"${path.basename(filename)}\"` +\n ` contains ${count} PEM certificate block(s) but only the first` +\n ` will be used. Use readCertificateChain() to read all certificates.`,\n );\n }\n return convertPEMtoDER(pem) as Certificate;\n}\n\n/**\n * Read a PEM or DER certificate file that may contain multiple\n * certificates (e.g. a leaf cert + CA issuer chain) and return\n * each certificate as a separate DER `Buffer`.\n *\n * - For a DER file, returns a single-element array.\n * - For a PEM file with N certificate blocks, returns N elements\n * in the same order they appear in the file (leaf first).\n */\nexport function readCertificateChain(filename: string): Certificate[] {\n if (filename.match(/.*\\.der/)) {\n return split_der(fs.readFileSync(filename) as Certificate);\n }\n const pem = _readPemFile(filename);\n return _extractAllPemDerCertificates(pem);\n}\n\n/**\n * Async version of {@link readCertificateChain}.\n */\nexport async function readCertificateChainAsync(filename: string): Promise<Certificate[]> {\n const buf = await fs.promises.readFile(filename);\n if (filename.match(/.*\\.der/)) {\n return split_der(buf as Certificate);\n }\n const pem = removeTrailingLF(buf.toString(\"utf-8\"));\n return _extractAllPemDerCertificates(pem);\n}\n\n/**\n * Extract all CERTIFICATE PEM blocks from a PEM string and\n * return each as a separate DER `Buffer`.\n */\nfunction _extractAllPemDerCertificates(pem: string): Certificate[] {\n const certs: Certificate[] = [];\n const regex = /-----BEGIN CERTIFICATE-----\\r?\\n([/+=a-zA-Z0-9\\r\\n]*)\\r?\\n-----END CERTIFICATE-----/g;\n let match: RegExpExecArray | null;\n match = regex.exec(pem);\n while (match !== null) {\n const base64 = match[1].replace(/\\r?\\n/g, \"\");\n certs.push(Buffer.from(base64, \"base64\") as Certificate);\n match = regex.exec(pem);\n }\n return certs;\n}\n\n/**\n * Async version of {@link readCertificate}.\n * Uses `fs.promises.readFile` so the event loop is not blocked\n * during I/O.\n *\n * **Note:** If the PEM file contains multiple certificate blocks,\n * only the first is returned. Use {@link readCertificateChainAsync}.\n *\n * @deprecated Use {@link readCertificateChainAsync} instead.\n */\nexport async function readCertificateAsync(filename: string): Promise<Certificate> {\n const buf = await fs.promises.readFile(filename);\n if (filename.match(/.*\\.der/)) {\n return buf as Certificate;\n }\n const raw_key = removeTrailingLF(buf.toString(\"utf-8\"));\n const count = _countPemCertBlocks(raw_key);\n if (count > 1) {\n console.warn(\n `[node-opcua-crypto] readCertificateAsync: \"${path.basename(filename)}\"` +\n ` contains ${count} PEM certificate block(s) but only the first` +\n ` will be used. Use readCertificateChainAsync() to read all certificates.`,\n );\n }\n return convertPEMtoDER(raw_key) as Certificate;\n}\n\n/**\n * read a DER or PEM certificate from file\n */\nexport function readPublicKey(filename: string): KeyObject {\n if (filename.match(/.*\\.der/)) {\n const der = fs.readFileSync(filename) as Buffer;\n return createPublicKey(der);\n } else {\n const raw_key: string = _readPemFile(filename);\n return createPublicKey(raw_key);\n }\n}\n\n/**\n * Async version of {@link readPublicKey}.\n */\nexport async function readPublicKeyAsync(filename: string): Promise<KeyObject> {\n const buf = await fs.promises.readFile(filename);\n if (filename.match(/.*\\.der/)) {\n return createPublicKey(buf);\n }\n return createPublicKey(removeTrailingLF(buf.toString(\"utf-8\")));\n}\n\n// console.log(\"createPrivateKey\", (crypto as any).createPrivateKey, process.env.NO_CREATE_PRIVATEKEY);\n\nfunction myCreatePrivateKey(rawKey: string | Buffer): PrivateKey {\n if (!createPrivateKey || process.env.NO_CREATE_PRIVATEKEY) {\n // we are not running nodejs or createPrivateKey is not supported in the environment\n if (Buffer.isBuffer(rawKey)) {\n const pemKey = toPem(rawKey, \"PRIVATE KEY\");\n assert([\"RSA PRIVATE KEY\", \"PRIVATE KEY\"].indexOf(identifyPemType(pemKey) as string) >= 0);\n return { hidden: pemKey };\n }\n return { hidden: ensureTrailingLF(rawKey as string) };\n }\n // see https://askubuntu.com/questions/1409458/openssl-config-cuases-error-in-node-js-crypto-how-should-the-config-be-updated\n const backup = process.env.OPENSSL_CONF;\n process.env.OPENSSL_CONF = \"/dev/null\";\n const retValue = createPrivateKey(rawKey);\n process.env.OPENSSL_CONF = backup;\n return { hidden: retValue };\n}\n\nfunction ensureTrailingLF(str: string): string {\n return str.match(/\\n$/) ? str : `${str}\\n`;\n}\n/**\n * read a DER or PEM certificate from file\n */\nexport function readPrivateKey(filename: string): PrivateKey {\n if (filename.match(/.*\\.der/)) {\n const der: Buffer = fs.readFileSync(filename);\n return myCreatePrivateKey(der);\n } else {\n const raw_key: string = _readPemFile(filename);\n return myCreatePrivateKey(raw_key);\n }\n}\n\n/**\n * Async version of {@link readPrivateKey}.\n */\nexport async function readPrivateKeyAsync(filename: string): Promise<PrivateKey> {\n const buf = await fs.promises.readFile(filename);\n if (filename.match(/.*\\.der/)) {\n return myCreatePrivateKey(buf);\n }\n return myCreatePrivateKey(removeTrailingLF(buf.toString(\"utf-8\")));\n}\n\nexport function readCertificatePEM(filename: string): CertificatePEM {\n return _readPemFile(filename);\n}\n\n/**\n * Async version of {@link readCertificatePEM}.\n */\nexport async function readCertificatePEMAsync(filename: string): Promise<CertificatePEM> {\n const buf = await fs.promises.readFile(filename, \"utf-8\");\n return removeTrailingLF(buf);\n}\n\nexport function readPublicKeyPEM(filename: string): PublicKeyPEM {\n return _readPemFile(filename);\n}\n\n/**\n * Async version of {@link readPublicKeyPEM}.\n */\nexport async function readPublicKeyPEMAsync(filename: string): Promise<PublicKeyPEM> {\n const buf = await fs.promises.readFile(filename, \"utf-8\");\n return removeTrailingLF(buf);\n}\n/**\n *\n * @deprecated\n */\nexport function readPrivateKeyPEM(filename: string): PrivateKeyPEM {\n return _readPemFile(filename);\n}\n\n/**\n * Async version of {@link readPrivateKeyPEM}.\n * @deprecated\n */\nexport async function readPrivateKeyPEMAsync(filename: string): Promise<PrivateKeyPEM> {\n const buf = await fs.promises.readFile(filename, \"utf-8\");\n return removeTrailingLF(buf);\n}\n\nlet _g_certificate_store: string = \"\";\n\nexport function setCertificateStore(store: string): string {\n const old_store = _g_certificate_store;\n _g_certificate_store = store;\n return old_store;\n}\nexport function getCertificateStore(): string {\n if (!_g_certificate_store) {\n _g_certificate_store = path.join(__dirname, \"../../certificates/\");\n }\n return _g_certificate_store;\n}\n/**\n *\n * @param filename\n */\nexport function readPrivateRsaKey(filename: string): PrivateKey {\n if (!createPrivateKey) {\n throw new Error(\"createPrivateKey is not supported in this environment\");\n }\n if (filename.substring(0, 1) !== \".\" && !fs.existsSync(filename)) {\n filename = path.join(getCertificateStore(), filename);\n }\n const content = fs.readFileSync(filename, \"utf8\");\n const sshKey = sshpk.parsePrivateKey(content, \"auto\");\n const key = sshKey.toString(\"pkcs1\") as PEM;\n const hidden = createPrivateKey({ format: \"pem\", type: \"pkcs1\", key });\n return { hidden };\n}\n\nexport function readPublicRsaKey(filename: string): PublicKey {\n if (filename.substring(0, 1) !== \".\" && !fs.existsSync(filename)) {\n filename = path.join(getCertificateStore(), filename);\n }\n const content = fs.readFileSync(filename, \"utf-8\");\n const sshKey = sshpk.parseKey(content, \"ssh\");\n const key = sshKey.toString(\"pkcs1\") as PEM;\n return createPublicKey({ format: \"pem\", type: \"pkcs1\", key });\n}\n","// ---------------------------------------------------------------------------------------------------------------------\n// node-opcua-crypto\n// ---------------------------------------------------------------------------------------------------------------------\n// Copyright (c) 2014-2022 - Etienne Rossignon - etienne.rossignon (at) gadz.org\n// Copyright (c) 2022-2026 - Sterfive.com\n// ---------------------------------------------------------------------------------------------------------------------\n//\n// This project is licensed under the terms of the MIT license.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated\n// documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the\n// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to\n// permit persons to whom the Software is furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the\n// Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE\n// WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\n// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n// ---------------------------------------------------------------------------------------------------------------------\n\nimport fs from \"node:fs\";\nimport type { CertificateRevocationList } from \"../source/common.js\";\nimport { convertPEMtoDER } from \"../source/crypto_utils.js\";\n\nexport async function readCertificateRevocationList(filename: string): Promise<CertificateRevocationList> {\n const crl = await fs.promises.readFile(filename);\n if (crl[0] === 0x30 && crl[1] === 0x82) {\n // der format\n return crl as CertificateRevocationList;\n }\n const raw_crl = crl.toString();\n return convertPEMtoDER(raw_crl);\n}\n","// ---------------------------------------------------------------------------------------------------------------------\n// node-opcua-crypto\n// ---------------------------------------------------------------------------------------------------------------------\n// Copyright (c) 2014-2022 - Etienne Rossignon - etienne.rossignon (at) gadz.org\n// Copyright (c) 2022-2026 - Sterfive.com\n// ---------------------------------------------------------------------------------------------------------------------\n//\n// This project is licensed under the terms of the MIT license.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated\n// documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the\n// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to\n// permit persons to whom the Software is furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the\n// Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE\n// WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\n// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n// ---------------------------------------------------------------------------------------------------------------------\n\nimport fs from \"node:fs\";\nimport type { CertificateRevocationList } from \"../source/common.js\";\nimport { convertPEMtoDER } from \"../source/crypto_utils.js\";\n\nexport type CertificateSigningRequest = Buffer;\n\nexport async function readCertificateSigningRequest(filename: string): Promise<CertificateSigningRequest> {\n const csr = await fs.promises.readFile(filename);\n if (csr[0] === 0x30 && csr[1] === 0x82) {\n // der format\n return csr as CertificateRevocationList;\n }\n const raw_crl = csr.toString();\n return convertPEMtoDER(raw_crl);\n}\n","// ---------------------------------------------------------------------------------------------------------------------\n// node-opcua-crypto\n// ---------------------------------------------------------------------------------------------------------------------\n// Copyright (c) 2014-2022 - Etienne Rossignon - etienne.rossignon (at) gadz.org\n// Copyright (c) 2022-2026 - Sterfive.com\n// ---------------------------------------------------------------------------------------------------------------------\n//\n// This project is licensed under the terms of the MIT license.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated\n// documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the\n// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to\n// permit persons to whom the Software is furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the\n// Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE\n// WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\n// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n// ---------------------------------------------------------------------------------------------------------------------\n\nimport fs from \"node:fs\";\n\nimport type { Certificate } from \"../source/common.js\";\nimport { combine_der } from \"../source/crypto_explore_certificate.js\";\nimport { toPem } from \"../source/crypto_utils.js\";\n\n// ── PEM ──────────────────────────────────────────────────────\n\n/**\n * Convert one or more DER certificates to a PEM string.\n *\n * Accepts a single `Certificate` (DER buffer) or an array.\n * Returns a multi-block PEM string with each certificate\n * separated by a newline.\n */\nexport function certificatesToPem(certificates: Certificate | Certificate[]): string {\n const certs = Array.isArray(certificates) ? certificates : [certificates];\n return `${certs.map((der) => toPem(der, \"CERTIFICATE\")).join(\"\\n\")}\\n`;\n}\n\n/**\n * Write one or more DER certificates to a PEM file.\n *\n * Each certificate is written as a separate PEM block in the\n * order provided (typically leaf first, then issuer chain).\n */\nexport function writeCertificateChain(filename: string, certificates: Certificate | Certificate[]): void {\n fs.writeFileSync(filename, certificatesToPem(certificates), \"utf-8\");\n}\n\n/**\n * Async version of {@link writeCertificateChain}.\n */\nexport async function writeCertificateChainAsync(filename: string, certificates: Certificate | Certificate[]): Promise<void> {\n await fs.promises.writeFile(filename, certificatesToPem(certificates), \"utf-8\");\n}\n\n// ── DER ──────────────────────────────────────────────────────\n\n/**\n * Convert one or more DER certificates to a single concatenated\n * DER buffer (OPC UA certificate chain format).\n *\n * Accepts a single `Certificate` (DER buffer) or an array.\n */\nexport function certificatesToDer(certificates: Certificate | Certificate[]): Certificate {\n const certs = Array.isArray(certificates) ? certificates : [certificates];\n return combine_der(certs);\n}\n\n/**\n * Write one or more DER certificates to a `.der` file as a\n * concatenated DER chain (OPC UA binary chain format).\n *\n * Order should be leaf first, then issuer chain.\n */\nexport function writeCertificateChainDer(filename: string, certificates: Certificate | Certificate[]): void {\n fs.writeFileSync(filename, certificatesToDer(certificates));\n}\n\n/**\n * Async version of {@link writeCertificateChainDer}.\n */\nexport async function writeCertificateChainDerAsync(filename: string, certificates: Certificate | Certificate[]): Promise<void> {\n await fs.promises.writeFile(filename, certificatesToDer(certificates));\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/node-opcua-crypto/node-opcua-crypto/packages/node-opcua-crypto/dist/chunk-XDS5YIBC.cjs","../source_nodejs/generate_private_key_filename.ts","../source_nodejs/read.ts","../source_nodejs/read_certificate_revocation_list.ts","../source_nodejs/read_certificate_signing_request.ts","../source_nodejs/write.ts"],"names":["fs"],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;ACYA,gCAAoC;AACpC,gEAAe;AAEf,MAAA,SAAsB,sBAAA,CAAuB,kBAAA,EAA4B,aAAA,EAA0C;AAC/G,EAAA,MAAM,KAAA,EAAO,MAAM,+CAAA,aAA6B,CAAA;AAChD,EAAA,MAAM,cAAA,EAAgB,MAAM,+CAAA,IAAgB,CAAK,UAAU,CAAA;AAC3D,EAAA,MAAM,YAAA,CAAG,QAAA,CAAS,SAAA,CAAU,kBAAA,EAAoB,aAAA,CAAc,OAAA,EAAS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ACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/node-opcua-crypto/node-opcua-crypto/packages/node-opcua-crypto/dist/chunk-XDS5YIBC.cjs","sourcesContent":[null,"// ---------------------------------------------------------------------------------------------------------------------\n// node-opcua-crypto\n// ---------------------------------------------------------------------------------------------------------------------\n// Copyright (c) 2014-2022 - Etienne Rossignon - etienne.rossignon (at) gadz.org\n// Copyright (c) 2022-2026 - Sterfive.com\n// ---------------------------------------------------------------------------------------------------------------------\n//\n// This project is licensed under the terms of the MIT license.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated\n// documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the\n// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to\n// permit persons to whom the Software is furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the\n// Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE\n// WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\n// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n// ---------------------------------------------------------------------------------------------------------------------\n\nimport { generateKeyPairSync } from \"node:crypto\";\nimport fs from \"node:fs\";\nimport { generateKeyPair, privateKeyToPEM } from \"../source/index.js\";\nexport async function generatePrivateKeyFile(privateKeyFilename: string, modulusLength: 1024 | 2048 | 3072 | 4096) {\n const keys = await generateKeyPair(modulusLength);\n const privateKeyPem = await privateKeyToPEM(keys.privateKey);\n await fs.promises.writeFile(privateKeyFilename, privateKeyPem.privPem, \"utf-8\");\n privateKeyPem.privPem = \"\";\n privateKeyPem.privDer = new ArrayBuffer(0);\n}\n\n/**\n * alternate function to generate PrivateKeyFile, using native\n * node:crypto.\n *\n * This function is slower than generatePrivateKeyFile\n */\nexport async function generatePrivateKeyFileAlternate(privateKeyFilename: string, modulusLength: 2048 | 3072 | 4096) {\n const { privateKey } = generateKeyPairSync(\"rsa\", {\n modulusLength,\n privateKeyEncoding: { type: \"pkcs8\", format: \"pem\" },\n publicKeyEncoding: { type: \"spki\", format: \"pem\" },\n });\n await fs.promises.writeFile(privateKeyFilename, privateKey, \"utf-8\");\n}\n","// ---------------------------------------------------------------------------------------------------------------------\n// node-opcua-crypto\n// ---------------------------------------------------------------------------------------------------------------------\n// Copyright (c) 2014-2022 - Etienne Rossignon - etienne.rossignon (at) gadz.org\n// Copyright (c) 2022-2026 - Sterfive.com\n// ---------------------------------------------------------------------------------------------------------------------\n//\n// This project is licensed under the terms of the MIT license.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated\n// documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the\n// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to\n// permit persons to whom the Software is furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the\n// Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE\n// WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\n// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n// ---------------------------------------------------------------------------------------------------------------------\n\nimport assert from \"node:assert\";\nimport { createPrivateKey, createPublicKey } from \"node:crypto\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport sshpk from \"sshpk\";\nimport type {\n Certificate,\n CertificatePEM,\n DER,\n KeyObject,\n PEM,\n PrivateKey,\n PrivateKeyPEM,\n PublicKey,\n PublicKeyPEM,\n} from \"../source/common.js\";\nimport { split_der } from \"../source/crypto_explore_certificate.js\";\nimport { convertPEMtoDER, identifyPemType, removeTrailingLF, toPem } from \"../source/crypto_utils.js\";\n\nfunction _readPemFile(filename: string): PEM {\n assert(typeof filename === \"string\");\n return removeTrailingLF(fs.readFileSync(filename, \"utf-8\"));\n}\n\nfunction _readPemOrDerFileAsDER(filename: string): DER {\n if (filename.match(/.*\\.der/)) {\n return fs.readFileSync(filename) as Buffer;\n }\n const raw_key: string = _readPemFile(filename);\n return convertPEMtoDER(raw_key);\n}\n\nfunction _countPemCertBlocks(pem: string): number {\n const matches = pem.match(/-----BEGIN CERTIFICATE-----/g);\n return matches ? matches.length : 0;\n}\n\n/**\n * Read a DER or PEM certificate from file.\n *\n * **Note:** If the PEM file contains multiple certificate blocks\n * (e.g. a leaf cert + CA chain), only the **first** certificate\n * is returned. Use {@link readCertificateChain} to read all\n * certificates individually.\n *\n * @deprecated Use {@link readCertificateChain} instead, which\n * returns each certificate as a separate DER buffer.\n */\nexport function readCertificate(filename: string): Certificate {\n if (filename.match(/.*\\.der/)) {\n return fs.readFileSync(filename) as Certificate;\n }\n const pem = _readPemFile(filename);\n const count = _countPemCertBlocks(pem);\n if (count > 1) {\n console.warn(\n `[node-opcua-crypto] readCertificate: \"${path.basename(filename)}\"` +\n ` contains ${count} PEM certificate block(s) but only the first` +\n ` will be used. Use readCertificateChain() to read all certificates.`,\n );\n }\n return convertPEMtoDER(pem) as Certificate;\n}\n\n/**\n * Read a PEM or DER certificate file that may contain multiple\n * certificates (e.g. a leaf cert + CA issuer chain) and return\n * each certificate as a separate DER `Buffer`.\n *\n * - For a DER file, returns a single-element array.\n * - For a PEM file with N certificate blocks, returns N elements\n * in the same order they appear in the file (leaf first).\n */\nexport function readCertificateChain(filename: string): Certificate[] {\n if (filename.match(/.*\\.der/)) {\n return split_der(fs.readFileSync(filename) as Certificate);\n }\n const pem = _readPemFile(filename);\n return _extractAllPemDerCertificates(pem);\n}\n\n/**\n * Async version of {@link readCertificateChain}.\n */\nexport async function readCertificateChainAsync(filename: string): Promise<Certificate[]> {\n const buf = await fs.promises.readFile(filename);\n if (filename.match(/.*\\.der/)) {\n return split_der(buf as Certificate);\n }\n const pem = removeTrailingLF(buf.toString(\"utf-8\"));\n return _extractAllPemDerCertificates(pem);\n}\n\n/**\n * Extract all CERTIFICATE PEM blocks from a PEM string and\n * return each as a separate DER `Buffer`.\n */\nfunction _extractAllPemDerCertificates(pem: string): Certificate[] {\n const certs: Certificate[] = [];\n const regex = /-----BEGIN CERTIFICATE-----\\r?\\n([/+=a-zA-Z0-9\\r\\n]*)\\r?\\n-----END CERTIFICATE-----/g;\n let match: RegExpExecArray | null;\n match = regex.exec(pem);\n while (match !== null) {\n const base64 = match[1].replace(/\\r?\\n/g, \"\");\n certs.push(Buffer.from(base64, \"base64\") as Certificate);\n match = regex.exec(pem);\n }\n return certs;\n}\n\n/**\n * Async version of {@link readCertificate}.\n * Uses `fs.promises.readFile` so the event loop is not blocked\n * during I/O.\n *\n * **Note:** If the PEM file contains multiple certificate blocks,\n * only the first is returned. Use {@link readCertificateChainAsync}.\n *\n * @deprecated Use {@link readCertificateChainAsync} instead.\n */\nexport async function readCertificateAsync(filename: string): Promise<Certificate> {\n const buf = await fs.promises.readFile(filename);\n if (filename.match(/.*\\.der/)) {\n return buf as Certificate;\n }\n const raw_key = removeTrailingLF(buf.toString(\"utf-8\"));\n const count = _countPemCertBlocks(raw_key);\n if (count > 1) {\n console.warn(\n `[node-opcua-crypto] readCertificateAsync: \"${path.basename(filename)}\"` +\n ` contains ${count} PEM certificate block(s) but only the first` +\n ` will be used. Use readCertificateChainAsync() to read all certificates.`,\n );\n }\n return convertPEMtoDER(raw_key) as Certificate;\n}\n\n/**\n * read a DER or PEM certificate from file\n */\nexport function readPublicKey(filename: string): KeyObject {\n if (filename.match(/.*\\.der/)) {\n const der = fs.readFileSync(filename) as Buffer;\n return createPublicKey(der);\n } else {\n const raw_key: string = _readPemFile(filename);\n return createPublicKey(raw_key);\n }\n}\n\n/**\n * Async version of {@link readPublicKey}.\n */\nexport async function readPublicKeyAsync(filename: string): Promise<KeyObject> {\n const buf = await fs.promises.readFile(filename);\n if (filename.match(/.*\\.der/)) {\n return createPublicKey(buf);\n }\n return createPublicKey(removeTrailingLF(buf.toString(\"utf-8\")));\n}\n\n// console.log(\"createPrivateKey\", (crypto as any).createPrivateKey, process.env.NO_CREATE_PRIVATEKEY);\n\nfunction myCreatePrivateKey(rawKey: string | Buffer): PrivateKey {\n if (!createPrivateKey || process.env.NO_CREATE_PRIVATEKEY) {\n // we are not running nodejs or createPrivateKey is not supported in the environment\n if (Buffer.isBuffer(rawKey)) {\n const pemKey = toPem(rawKey, \"PRIVATE KEY\");\n assert([\"RSA PRIVATE KEY\", \"PRIVATE KEY\"].indexOf(identifyPemType(pemKey) as string) >= 0);\n return { hidden: pemKey };\n }\n return { hidden: ensureTrailingLF(rawKey as string) };\n }\n // see https://askubuntu.com/questions/1409458/openssl-config-cuases-error-in-node-js-crypto-how-should-the-config-be-updated\n const backup = process.env.OPENSSL_CONF;\n process.env.OPENSSL_CONF = \"/dev/null\";\n const retValue = createPrivateKey(rawKey);\n process.env.OPENSSL_CONF = backup;\n return { hidden: retValue };\n}\n\nfunction ensureTrailingLF(str: string): string {\n return str.match(/\\n$/) ? str : `${str}\\n`;\n}\n/**\n * read a DER or PEM certificate from file\n */\nexport function readPrivateKey(filename: string): PrivateKey {\n if (filename.match(/.*\\.der/)) {\n const der: Buffer = fs.readFileSync(filename);\n return myCreatePrivateKey(der);\n } else {\n const raw_key: string = _readPemFile(filename);\n return myCreatePrivateKey(raw_key);\n }\n}\n\n/**\n * Async version of {@link readPrivateKey}.\n */\nexport async function readPrivateKeyAsync(filename: string): Promise<PrivateKey> {\n const buf = await fs.promises.readFile(filename);\n if (filename.match(/.*\\.der/)) {\n return myCreatePrivateKey(buf);\n }\n return myCreatePrivateKey(removeTrailingLF(buf.toString(\"utf-8\")));\n}\n\nexport function readCertificatePEM(filename: string): CertificatePEM {\n return _readPemFile(filename);\n}\n\n/**\n * Async version of {@link readCertificatePEM}.\n */\nexport async function readCertificatePEMAsync(filename: string): Promise<CertificatePEM> {\n const buf = await fs.promises.readFile(filename, \"utf-8\");\n return removeTrailingLF(buf);\n}\n\nexport function readPublicKeyPEM(filename: string): PublicKeyPEM {\n return _readPemFile(filename);\n}\n\n/**\n * Async version of {@link readPublicKeyPEM}.\n */\nexport async function readPublicKeyPEMAsync(filename: string): Promise<PublicKeyPEM> {\n const buf = await fs.promises.readFile(filename, \"utf-8\");\n return removeTrailingLF(buf);\n}\n/**\n *\n * @deprecated\n */\nexport function readPrivateKeyPEM(filename: string): PrivateKeyPEM {\n return _readPemFile(filename);\n}\n\n/**\n * Async version of {@link readPrivateKeyPEM}.\n * @deprecated\n */\nexport async function readPrivateKeyPEMAsync(filename: string): Promise<PrivateKeyPEM> {\n const buf = await fs.promises.readFile(filename, \"utf-8\");\n return removeTrailingLF(buf);\n}\n\nlet _g_certificate_store: string = \"\";\n\nexport function setCertificateStore(store: string): string {\n const old_store = _g_certificate_store;\n _g_certificate_store = store;\n return old_store;\n}\nexport function getCertificateStore(): string {\n if (!_g_certificate_store) {\n _g_certificate_store = path.join(__dirname, \"../../certificates/\");\n }\n return _g_certificate_store;\n}\n/**\n *\n * @param filename\n */\nexport function readPrivateRsaKey(filename: string): PrivateKey {\n if (!createPrivateKey) {\n throw new Error(\"createPrivateKey is not supported in this environment\");\n }\n if (filename.substring(0, 1) !== \".\" && !fs.existsSync(filename)) {\n filename = path.join(getCertificateStore(), filename);\n }\n const content = fs.readFileSync(filename, \"utf8\");\n const sshKey = sshpk.parsePrivateKey(content, \"auto\");\n const key = sshKey.toString(\"pkcs1\") as PEM;\n const hidden = createPrivateKey({ format: \"pem\", type: \"pkcs1\", key });\n return { hidden };\n}\n\nexport function readPublicRsaKey(filename: string): PublicKey {\n if (filename.substring(0, 1) !== \".\" && !fs.existsSync(filename)) {\n filename = path.join(getCertificateStore(), filename);\n }\n const content = fs.readFileSync(filename, \"utf-8\");\n const sshKey = sshpk.parseKey(content, \"ssh\");\n const key = sshKey.toString(\"pkcs1\") as PEM;\n return createPublicKey({ format: \"pem\", type: \"pkcs1\", key });\n}\n","// ---------------------------------------------------------------------------------------------------------------------\n// node-opcua-crypto\n// ---------------------------------------------------------------------------------------------------------------------\n// Copyright (c) 2014-2022 - Etienne Rossignon - etienne.rossignon (at) gadz.org\n// Copyright (c) 2022-2026 - Sterfive.com\n// ---------------------------------------------------------------------------------------------------------------------\n//\n// This project is licensed under the terms of the MIT license.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated\n// documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the\n// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to\n// permit persons to whom the Software is furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the\n// Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE\n// WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\n// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n// ---------------------------------------------------------------------------------------------------------------------\n\nimport fs from \"node:fs\";\nimport type { CertificateRevocationList } from \"../source/common.js\";\nimport { convertPEMtoDER } from \"../source/crypto_utils.js\";\n\nexport async function readCertificateRevocationList(filename: string): Promise<CertificateRevocationList> {\n const crl = await fs.promises.readFile(filename);\n if (crl[0] === 0x30 && crl[1] === 0x82) {\n // der format\n return crl as CertificateRevocationList;\n }\n const raw_crl = crl.toString();\n return convertPEMtoDER(raw_crl);\n}\n","// ---------------------------------------------------------------------------------------------------------------------\n// node-opcua-crypto\n// ---------------------------------------------------------------------------------------------------------------------\n// Copyright (c) 2014-2022 - Etienne Rossignon - etienne.rossignon (at) gadz.org\n// Copyright (c) 2022-2026 - Sterfive.com\n// ---------------------------------------------------------------------------------------------------------------------\n//\n// This project is licensed under the terms of the MIT license.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated\n// documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the\n// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to\n// permit persons to whom the Software is furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the\n// Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE\n// WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\n// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n// ---------------------------------------------------------------------------------------------------------------------\n\nimport fs from \"node:fs\";\nimport type { CertificateRevocationList } from \"../source/common.js\";\nimport { convertPEMtoDER } from \"../source/crypto_utils.js\";\n\nexport type CertificateSigningRequest = Buffer;\n\nexport async function readCertificateSigningRequest(filename: string): Promise<CertificateSigningRequest> {\n const csr = await fs.promises.readFile(filename);\n if (csr[0] === 0x30 && csr[1] === 0x82) {\n // der format\n return csr as CertificateRevocationList;\n }\n const raw_crl = csr.toString();\n return convertPEMtoDER(raw_crl);\n}\n","// ---------------------------------------------------------------------------------------------------------------------\n// node-opcua-crypto\n// ---------------------------------------------------------------------------------------------------------------------\n// Copyright (c) 2014-2022 - Etienne Rossignon - etienne.rossignon (at) gadz.org\n// Copyright (c) 2022-2026 - Sterfive.com\n// ---------------------------------------------------------------------------------------------------------------------\n//\n// This project is licensed under the terms of the MIT license.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated\n// documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the\n// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to\n// permit persons to whom the Software is furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the\n// Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE\n// WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\n// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n// ---------------------------------------------------------------------------------------------------------------------\n\nimport fs from \"node:fs\";\n\nimport type { Certificate } from \"../source/common.js\";\nimport { combine_der } from \"../source/crypto_explore_certificate.js\";\nimport { toPem } from \"../source/crypto_utils.js\";\n\n// ── PEM ──────────────────────────────────────────────────────\n\n/**\n * Convert one or more DER certificates to a PEM string.\n *\n * Accepts a single `Certificate` (DER buffer) or an array.\n * Returns a multi-block PEM string with each certificate\n * separated by a newline.\n */\nexport function certificatesToPem(certificates: Certificate | Certificate[]): string {\n const certs = Array.isArray(certificates) ? certificates : [certificates];\n return `${certs.map((der) => toPem(der, \"CERTIFICATE\")).join(\"\\n\")}\\n`;\n}\n\n/**\n * Write one or more DER certificates to a PEM file.\n *\n * Each certificate is written as a separate PEM block in the\n * order provided (typically leaf first, then issuer chain).\n */\nexport function writeCertificateChain(filename: string, certificates: Certificate | Certificate[]): void {\n fs.writeFileSync(filename, certificatesToPem(certificates), \"utf-8\");\n}\n\n/**\n * Async version of {@link writeCertificateChain}.\n */\nexport async function writeCertificateChainAsync(filename: string, certificates: Certificate | Certificate[]): Promise<void> {\n await fs.promises.writeFile(filename, certificatesToPem(certificates), \"utf-8\");\n}\n\n// ── DER ──────────────────────────────────────────────────────\n\n/**\n * Convert one or more DER certificates to a single concatenated\n * DER buffer (OPC UA certificate chain format).\n *\n * Accepts a single `Certificate` (DER buffer) or an array.\n */\nexport function certificatesToDer(certificates: Certificate | Certificate[]): Certificate {\n const certs = Array.isArray(certificates) ? certificates : [certificates];\n return combine_der(certs);\n}\n\n/**\n * Write one or more DER certificates to a `.der` file as a\n * concatenated DER chain (OPC UA binary chain format).\n *\n * Order should be leaf first, then issuer chain.\n */\nexport function writeCertificateChainDer(filename: string, certificates: Certificate | Certificate[]): void {\n fs.writeFileSync(filename, certificatesToDer(certificates));\n}\n\n/**\n * Async version of {@link writeCertificateChainDer}.\n */\nexport async function writeCertificateChainDerAsync(filename: string, certificates: Certificate | Certificate[]): Promise<void> {\n await fs.promises.writeFile(filename, certificatesToDer(certificates));\n}\n"]}
|
package/dist/index.cjs
CHANGED
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
|
|
30
|
-
var
|
|
30
|
+
var _chunkXDS5YIBCcjs = require('./chunk-XDS5YIBC.cjs');
|
|
31
31
|
|
|
32
32
|
|
|
33
33
|
|
|
@@ -106,7 +106,7 @@ var _chunkIKQT3ICScjs = require('./chunk-IKQT3ICS.cjs');
|
|
|
106
106
|
|
|
107
107
|
|
|
108
108
|
|
|
109
|
-
var
|
|
109
|
+
var _chunkAZUYUXWDcjs = require('./chunk-AZUYUXWD.cjs');
|
|
110
110
|
|
|
111
111
|
|
|
112
112
|
|
|
@@ -213,5 +213,5 @@ var _chunkTSW463FIcjs = require('./chunk-TSW463FI.cjs');
|
|
|
213
213
|
|
|
214
214
|
|
|
215
215
|
|
|
216
|
-
exports.CertificatePurpose =
|
|
216
|
+
exports.CertificatePurpose = _chunkAZUYUXWDcjs.CertificatePurpose; exports.PaddingAlgorithm = _chunkAZUYUXWDcjs.PaddingAlgorithm; exports.RSA_PKCS1_OAEP_PADDING = _chunkAZUYUXWDcjs.RSA_PKCS1_OAEP_PADDING; exports.RSA_PKCS1_PADDING = _chunkAZUYUXWDcjs.RSA_PKCS1_PADDING; exports.Subject = _chunkAZUYUXWDcjs.Subject; exports._coercePrivateKey = _chunkAZUYUXWDcjs._coercePrivateKey; exports.asn1 = _chunkAZUYUXWDcjs.asn1; exports.certificateMatchesPrivateKey = _chunkAZUYUXWDcjs.certificateMatchesPrivateKey; exports.certificatesToDer = _chunkXDS5YIBCcjs.certificatesToDer; exports.certificatesToPem = _chunkXDS5YIBCcjs.certificatesToPem; exports.clearExploreCertificateCache = _chunkAZUYUXWDcjs.clearExploreCertificateCache; exports.coerceCertificate = _chunkAZUYUXWDcjs.coerceCertificate; exports.coerceCertificatePem = _chunkAZUYUXWDcjs.coerceCertificatePem; exports.coercePEMorDerToPrivateKey = _chunkAZUYUXWDcjs.coercePEMorDerToPrivateKey; exports.coercePrivateKeyPem = _chunkAZUYUXWDcjs.coercePrivateKeyPem; exports.coercePublicKeyPem = _chunkAZUYUXWDcjs.coercePublicKeyPem; exports.coerceRsaPublicKeyPem = _chunkAZUYUXWDcjs.coerceRsaPublicKeyPem; exports.combine_der = _chunkAZUYUXWDcjs.combine_der; exports.computeDerivedKeys = _chunkAZUYUXWDcjs.computeDerivedKeys; exports.computePaddingFooter = _chunkAZUYUXWDcjs.computePaddingFooter; exports.convertPEMtoDER = _chunkAZUYUXWDcjs.convertPEMtoDER; exports.createCertificateSigningRequest = _chunkAZUYUXWDcjs.createCertificateSigningRequest; exports.createPrivateKeyFromNodeJSCrypto = _chunkAZUYUXWDcjs.createPrivateKeyFromNodeJSCrypto; exports.createSelfSignedCertificate = _chunkAZUYUXWDcjs.createSelfSignedCertificate; exports.decryptBufferWithDerivedKeys = _chunkAZUYUXWDcjs.decryptBufferWithDerivedKeys; exports.derToPrivateKey = _chunkAZUYUXWDcjs.derToPrivateKey; exports.encryptBufferWithDerivedKeys = _chunkAZUYUXWDcjs.encryptBufferWithDerivedKeys; exports.exploreAsn1 = _chunkAZUYUXWDcjs.exploreAsn1; exports.exploreCertificate = _chunkAZUYUXWDcjs.exploreCertificate; exports.exploreCertificateInfo = _chunkAZUYUXWDcjs.exploreCertificateInfo; exports.exploreCertificateRevocationList = _chunkAZUYUXWDcjs.exploreCertificateRevocationList; exports.exploreCertificateSigningRequest = _chunkAZUYUXWDcjs.exploreCertificateSigningRequest; exports.explorePrivateKey = _chunkAZUYUXWDcjs.explorePrivateKey; exports.extractPublicKeyFromCertificate = _chunkAZUYUXWDcjs.extractPublicKeyFromCertificate; exports.extractPublicKeyFromCertificateSync = _chunkAZUYUXWDcjs.extractPublicKeyFromCertificateSync; exports.generateKeyPair = _chunkAZUYUXWDcjs.generateKeyPair; exports.generatePrivateKey = _chunkAZUYUXWDcjs.generatePrivateKey; exports.generatePrivateKeyFile = _chunkXDS5YIBCcjs.generatePrivateKeyFile; exports.generatePrivateKeyFileAlternate = _chunkXDS5YIBCcjs.generatePrivateKeyFileAlternate; exports.getCertificateStore = _chunkXDS5YIBCcjs.getCertificateStore; exports.hexDump = _chunkAZUYUXWDcjs.hexDump; exports.identifyDERContent = _chunkAZUYUXWDcjs.identifyDERContent; exports.identifyPemType = _chunkAZUYUXWDcjs.identifyPemType; exports.isCrlIssuedByCertificate = _chunkAZUYUXWDcjs.isCrlIssuedByCertificate; exports.isKeyObject = _chunkAZUYUXWDcjs.isKeyObject; exports.makeMessageChunkSignature = _chunkAZUYUXWDcjs.makeMessageChunkSignature; exports.makeMessageChunkSignatureWithDerivedKeys = _chunkAZUYUXWDcjs.makeMessageChunkSignatureWithDerivedKeys; exports.makePrivateKeyFromPem = _chunkAZUYUXWDcjs.makePrivateKeyFromPem; exports.makePrivateKeyThumbPrint = _chunkAZUYUXWDcjs.makePrivateKeyThumbPrint; exports.makePseudoRandomBuffer = _chunkAZUYUXWDcjs.makePseudoRandomBuffer; exports.makeSHA1Thumbprint = _chunkAZUYUXWDcjs.makeSHA1Thumbprint; exports.pemToPrivateKey = _chunkAZUYUXWDcjs.pemToPrivateKey; exports.privateDecrypt = _chunkAZUYUXWDcjs.privateDecrypt; exports.privateDecrypt_long = _chunkAZUYUXWDcjs.privateDecrypt_long; exports.privateDecrypt_native = _chunkAZUYUXWDcjs.privateDecrypt_native; exports.privateKeyToPEM = _chunkAZUYUXWDcjs.privateKeyToPEM; exports.publicEncrypt = _chunkAZUYUXWDcjs.publicEncrypt; exports.publicEncrypt_long = _chunkAZUYUXWDcjs.publicEncrypt_long; exports.publicEncrypt_native = _chunkAZUYUXWDcjs.publicEncrypt_native; exports.publicKeyAndPrivateKeyMatches = _chunkAZUYUXWDcjs.publicKeyAndPrivateKeyMatches; exports.readCertificate = _chunkXDS5YIBCcjs.readCertificate; exports.readCertificateAsync = _chunkXDS5YIBCcjs.readCertificateAsync; exports.readCertificateChain = _chunkXDS5YIBCcjs.readCertificateChain; exports.readCertificateChainAsync = _chunkXDS5YIBCcjs.readCertificateChainAsync; exports.readCertificatePEM = _chunkXDS5YIBCcjs.readCertificatePEM; exports.readCertificatePEMAsync = _chunkXDS5YIBCcjs.readCertificatePEMAsync; exports.readCertificateRevocationList = _chunkXDS5YIBCcjs.readCertificateRevocationList; exports.readCertificateSigningRequest = _chunkXDS5YIBCcjs.readCertificateSigningRequest; exports.readCertificationRequestInfo = _chunkAZUYUXWDcjs.readCertificationRequestInfo; exports.readExtension = _chunkAZUYUXWDcjs.readExtension; exports.readNameForCrl = _chunkAZUYUXWDcjs.readNameForCrl; exports.readPrivateKey = _chunkXDS5YIBCcjs.readPrivateKey; exports.readPrivateKeyAsync = _chunkXDS5YIBCcjs.readPrivateKeyAsync; exports.readPrivateKeyPEM = _chunkXDS5YIBCcjs.readPrivateKeyPEM; exports.readPrivateKeyPEMAsync = _chunkXDS5YIBCcjs.readPrivateKeyPEMAsync; exports.readPrivateRsaKey = _chunkXDS5YIBCcjs.readPrivateRsaKey; exports.readPublicKey = _chunkXDS5YIBCcjs.readPublicKey; exports.readPublicKeyAsync = _chunkXDS5YIBCcjs.readPublicKeyAsync; exports.readPublicKeyPEM = _chunkXDS5YIBCcjs.readPublicKeyPEM; exports.readPublicKeyPEMAsync = _chunkXDS5YIBCcjs.readPublicKeyPEMAsync; exports.readPublicRsaKey = _chunkXDS5YIBCcjs.readPublicRsaKey; exports.readTbsCertificate = _chunkAZUYUXWDcjs.readTbsCertificate; exports.reduceLength = _chunkAZUYUXWDcjs.reduceLength; exports.removePadding = _chunkAZUYUXWDcjs.removePadding; exports.removeTrailingLF = _chunkAZUYUXWDcjs.removeTrailingLF; exports.rsaLengthPrivateKey = _chunkAZUYUXWDcjs.rsaLengthPrivateKey; exports.rsaLengthPublicKey = _chunkAZUYUXWDcjs.rsaLengthPublicKey; exports.rsaLengthRsaPublicKey = _chunkAZUYUXWDcjs.rsaLengthRsaPublicKey; exports.setCertificateStore = _chunkXDS5YIBCcjs.setCertificateStore; exports.split_der = _chunkAZUYUXWDcjs.split_der; exports.toPem = _chunkAZUYUXWDcjs.toPem; exports.toPem2 = _chunkAZUYUXWDcjs.toPem2; exports.verifyCertificateChain = _chunkAZUYUXWDcjs.verifyCertificateChain; exports.verifyCertificateOrClrSignature = _chunkAZUYUXWDcjs.verifyCertificateOrClrSignature; exports.verifyCertificateRevocationListSignature = _chunkAZUYUXWDcjs.verifyCertificateRevocationListSignature; exports.verifyCertificateSignature = _chunkAZUYUXWDcjs.verifyCertificateSignature; exports.verifyChunkSignature = _chunkAZUYUXWDcjs.verifyChunkSignature; exports.verifyChunkSignatureWithDerivedKeys = _chunkAZUYUXWDcjs.verifyChunkSignatureWithDerivedKeys; exports.verifyCrlIssuedByCertificate = _chunkAZUYUXWDcjs.verifyCrlIssuedByCertificate; exports.verifyMessageChunkSignature = _chunkAZUYUXWDcjs.verifyMessageChunkSignature; exports.verify_certificate_der_structure = _chunkAZUYUXWDcjs.verify_certificate_der_structure; exports.writeCertificateChain = _chunkXDS5YIBCcjs.writeCertificateChain; exports.writeCertificateChainAsync = _chunkXDS5YIBCcjs.writeCertificateChainAsync; exports.writeCertificateChainDer = _chunkXDS5YIBCcjs.writeCertificateChainDer; exports.writeCertificateChainDerAsync = _chunkXDS5YIBCcjs.writeCertificateChainDerAsync;
|
|
217
217
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.js
CHANGED
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
writeCertificateChainAsync,
|
|
28
28
|
writeCertificateChainDer,
|
|
29
29
|
writeCertificateChainDerAsync
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-ULNIL7FF.js";
|
|
31
31
|
import {
|
|
32
32
|
CertificatePurpose,
|
|
33
33
|
PaddingAlgorithm,
|
|
@@ -106,7 +106,7 @@ import {
|
|
|
106
106
|
verifyCrlIssuedByCertificate,
|
|
107
107
|
verifyMessageChunkSignature,
|
|
108
108
|
verify_certificate_der_structure
|
|
109
|
-
} from "./chunk-
|
|
109
|
+
} from "./chunk-P5QLLSP2.js";
|
|
110
110
|
export {
|
|
111
111
|
CertificatePurpose,
|
|
112
112
|
PaddingAlgorithm,
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
|
|
77
77
|
|
|
78
78
|
|
|
79
|
-
var
|
|
79
|
+
var _chunkAZUYUXWDcjs = require('../chunk-AZUYUXWD.cjs');
|
|
80
80
|
|
|
81
81
|
|
|
82
82
|
|
|
@@ -155,5 +155,5 @@ var _chunkTSW463FIcjs = require('../chunk-TSW463FI.cjs');
|
|
|
155
155
|
|
|
156
156
|
|
|
157
157
|
|
|
158
|
-
exports.CertificatePurpose =
|
|
158
|
+
exports.CertificatePurpose = _chunkAZUYUXWDcjs.CertificatePurpose; exports.PaddingAlgorithm = _chunkAZUYUXWDcjs.PaddingAlgorithm; exports.RSA_PKCS1_OAEP_PADDING = _chunkAZUYUXWDcjs.RSA_PKCS1_OAEP_PADDING; exports.RSA_PKCS1_PADDING = _chunkAZUYUXWDcjs.RSA_PKCS1_PADDING; exports.Subject = _chunkAZUYUXWDcjs.Subject; exports._coercePrivateKey = _chunkAZUYUXWDcjs._coercePrivateKey; exports.asn1 = _chunkAZUYUXWDcjs.asn1; exports.certificateMatchesPrivateKey = _chunkAZUYUXWDcjs.certificateMatchesPrivateKey; exports.clearExploreCertificateCache = _chunkAZUYUXWDcjs.clearExploreCertificateCache; exports.coerceCertificate = _chunkAZUYUXWDcjs.coerceCertificate; exports.coerceCertificatePem = _chunkAZUYUXWDcjs.coerceCertificatePem; exports.coercePEMorDerToPrivateKey = _chunkAZUYUXWDcjs.coercePEMorDerToPrivateKey; exports.coercePrivateKeyPem = _chunkAZUYUXWDcjs.coercePrivateKeyPem; exports.coercePublicKeyPem = _chunkAZUYUXWDcjs.coercePublicKeyPem; exports.coerceRsaPublicKeyPem = _chunkAZUYUXWDcjs.coerceRsaPublicKeyPem; exports.combine_der = _chunkAZUYUXWDcjs.combine_der; exports.computeDerivedKeys = _chunkAZUYUXWDcjs.computeDerivedKeys; exports.computePaddingFooter = _chunkAZUYUXWDcjs.computePaddingFooter; exports.convertPEMtoDER = _chunkAZUYUXWDcjs.convertPEMtoDER; exports.createCertificateSigningRequest = _chunkAZUYUXWDcjs.createCertificateSigningRequest; exports.createPrivateKeyFromNodeJSCrypto = _chunkAZUYUXWDcjs.createPrivateKeyFromNodeJSCrypto; exports.createSelfSignedCertificate = _chunkAZUYUXWDcjs.createSelfSignedCertificate; exports.decryptBufferWithDerivedKeys = _chunkAZUYUXWDcjs.decryptBufferWithDerivedKeys; exports.derToPrivateKey = _chunkAZUYUXWDcjs.derToPrivateKey; exports.encryptBufferWithDerivedKeys = _chunkAZUYUXWDcjs.encryptBufferWithDerivedKeys; exports.exploreAsn1 = _chunkAZUYUXWDcjs.exploreAsn1; exports.exploreCertificate = _chunkAZUYUXWDcjs.exploreCertificate; exports.exploreCertificateInfo = _chunkAZUYUXWDcjs.exploreCertificateInfo; exports.exploreCertificateRevocationList = _chunkAZUYUXWDcjs.exploreCertificateRevocationList; exports.exploreCertificateSigningRequest = _chunkAZUYUXWDcjs.exploreCertificateSigningRequest; exports.explorePrivateKey = _chunkAZUYUXWDcjs.explorePrivateKey; exports.extractPublicKeyFromCertificate = _chunkAZUYUXWDcjs.extractPublicKeyFromCertificate; exports.extractPublicKeyFromCertificateSync = _chunkAZUYUXWDcjs.extractPublicKeyFromCertificateSync; exports.generateKeyPair = _chunkAZUYUXWDcjs.generateKeyPair; exports.generatePrivateKey = _chunkAZUYUXWDcjs.generatePrivateKey; exports.hexDump = _chunkAZUYUXWDcjs.hexDump; exports.identifyDERContent = _chunkAZUYUXWDcjs.identifyDERContent; exports.identifyPemType = _chunkAZUYUXWDcjs.identifyPemType; exports.isCrlIssuedByCertificate = _chunkAZUYUXWDcjs.isCrlIssuedByCertificate; exports.isKeyObject = _chunkAZUYUXWDcjs.isKeyObject; exports.makeMessageChunkSignature = _chunkAZUYUXWDcjs.makeMessageChunkSignature; exports.makeMessageChunkSignatureWithDerivedKeys = _chunkAZUYUXWDcjs.makeMessageChunkSignatureWithDerivedKeys; exports.makePrivateKeyFromPem = _chunkAZUYUXWDcjs.makePrivateKeyFromPem; exports.makePrivateKeyThumbPrint = _chunkAZUYUXWDcjs.makePrivateKeyThumbPrint; exports.makePseudoRandomBuffer = _chunkAZUYUXWDcjs.makePseudoRandomBuffer; exports.makeSHA1Thumbprint = _chunkAZUYUXWDcjs.makeSHA1Thumbprint; exports.pemToPrivateKey = _chunkAZUYUXWDcjs.pemToPrivateKey; exports.privateDecrypt = _chunkAZUYUXWDcjs.privateDecrypt; exports.privateDecrypt_long = _chunkAZUYUXWDcjs.privateDecrypt_long; exports.privateDecrypt_native = _chunkAZUYUXWDcjs.privateDecrypt_native; exports.privateKeyToPEM = _chunkAZUYUXWDcjs.privateKeyToPEM; exports.publicEncrypt = _chunkAZUYUXWDcjs.publicEncrypt; exports.publicEncrypt_long = _chunkAZUYUXWDcjs.publicEncrypt_long; exports.publicEncrypt_native = _chunkAZUYUXWDcjs.publicEncrypt_native; exports.publicKeyAndPrivateKeyMatches = _chunkAZUYUXWDcjs.publicKeyAndPrivateKeyMatches; exports.readCertificationRequestInfo = _chunkAZUYUXWDcjs.readCertificationRequestInfo; exports.readExtension = _chunkAZUYUXWDcjs.readExtension; exports.readNameForCrl = _chunkAZUYUXWDcjs.readNameForCrl; exports.readTbsCertificate = _chunkAZUYUXWDcjs.readTbsCertificate; exports.reduceLength = _chunkAZUYUXWDcjs.reduceLength; exports.removePadding = _chunkAZUYUXWDcjs.removePadding; exports.removeTrailingLF = _chunkAZUYUXWDcjs.removeTrailingLF; exports.rsaLengthPrivateKey = _chunkAZUYUXWDcjs.rsaLengthPrivateKey; exports.rsaLengthPublicKey = _chunkAZUYUXWDcjs.rsaLengthPublicKey; exports.rsaLengthRsaPublicKey = _chunkAZUYUXWDcjs.rsaLengthRsaPublicKey; exports.split_der = _chunkAZUYUXWDcjs.split_der; exports.toPem = _chunkAZUYUXWDcjs.toPem; exports.toPem2 = _chunkAZUYUXWDcjs.toPem2; exports.verifyCertificateChain = _chunkAZUYUXWDcjs.verifyCertificateChain; exports.verifyCertificateOrClrSignature = _chunkAZUYUXWDcjs.verifyCertificateOrClrSignature; exports.verifyCertificateRevocationListSignature = _chunkAZUYUXWDcjs.verifyCertificateRevocationListSignature; exports.verifyCertificateSignature = _chunkAZUYUXWDcjs.verifyCertificateSignature; exports.verifyChunkSignature = _chunkAZUYUXWDcjs.verifyChunkSignature; exports.verifyChunkSignatureWithDerivedKeys = _chunkAZUYUXWDcjs.verifyChunkSignatureWithDerivedKeys; exports.verifyCrlIssuedByCertificate = _chunkAZUYUXWDcjs.verifyCrlIssuedByCertificate; exports.verifyMessageChunkSignature = _chunkAZUYUXWDcjs.verifyMessageChunkSignature; exports.verify_certificate_der_structure = _chunkAZUYUXWDcjs.verify_certificate_der_structure;
|
|
159
159
|
//# sourceMappingURL=index_web.cjs.map
|
|
@@ -419,9 +419,16 @@ declare function createSelfSignedCertificate({ privateKey, notAfter, notBefore,
|
|
|
419
419
|
der: x509.X509Certificate;
|
|
420
420
|
}>;
|
|
421
421
|
|
|
422
|
-
declare function identifyPemType(rawKey:
|
|
422
|
+
declare function identifyPemType(rawKey: Certificate | Certificate[] | string): undefined | string;
|
|
423
423
|
declare function removeTrailingLF(str: string): string;
|
|
424
|
-
declare function toPem(raw_key:
|
|
424
|
+
declare function toPem(raw_key: Certificate | Certificate[] | string, pem: string): string;
|
|
425
|
+
/**
|
|
426
|
+
* Convert a PEM string to DER format.
|
|
427
|
+
* If the PEM string contains multiple certificates, they will be concatenated in DER format.
|
|
428
|
+
*
|
|
429
|
+
* @param raw_key The PEM string to convert.
|
|
430
|
+
* @returns The DER buffer.
|
|
431
|
+
*/
|
|
425
432
|
declare function convertPEMtoDER(raw_key: PEM): DER;
|
|
426
433
|
declare function hexDump(buffer: Buffer, width?: number): string;
|
|
427
434
|
interface MakeMessageChunkSignatureOptions {
|
|
@@ -419,9 +419,16 @@ declare function createSelfSignedCertificate({ privateKey, notAfter, notBefore,
|
|
|
419
419
|
der: x509.X509Certificate;
|
|
420
420
|
}>;
|
|
421
421
|
|
|
422
|
-
declare function identifyPemType(rawKey:
|
|
422
|
+
declare function identifyPemType(rawKey: Certificate | Certificate[] | string): undefined | string;
|
|
423
423
|
declare function removeTrailingLF(str: string): string;
|
|
424
|
-
declare function toPem(raw_key:
|
|
424
|
+
declare function toPem(raw_key: Certificate | Certificate[] | string, pem: string): string;
|
|
425
|
+
/**
|
|
426
|
+
* Convert a PEM string to DER format.
|
|
427
|
+
* If the PEM string contains multiple certificates, they will be concatenated in DER format.
|
|
428
|
+
*
|
|
429
|
+
* @param raw_key The PEM string to convert.
|
|
430
|
+
* @returns The DER buffer.
|
|
431
|
+
*/
|
|
425
432
|
declare function convertPEMtoDER(raw_key: PEM): DER;
|
|
426
433
|
declare function hexDump(buffer: Buffer, width?: number): string;
|
|
427
434
|
interface MakeMessageChunkSignatureOptions {
|
package/dist/source/index_web.js
CHANGED
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
|
|
30
|
-
var
|
|
31
|
-
require('../chunk-
|
|
30
|
+
var _chunkXDS5YIBCcjs = require('../chunk-XDS5YIBC.cjs');
|
|
31
|
+
require('../chunk-AZUYUXWD.cjs');
|
|
32
32
|
|
|
33
33
|
|
|
34
34
|
|
|
@@ -58,5 +58,5 @@ require('../chunk-TSW463FI.cjs');
|
|
|
58
58
|
|
|
59
59
|
|
|
60
60
|
|
|
61
|
-
exports.certificatesToDer =
|
|
61
|
+
exports.certificatesToDer = _chunkXDS5YIBCcjs.certificatesToDer; exports.certificatesToPem = _chunkXDS5YIBCcjs.certificatesToPem; exports.generatePrivateKeyFile = _chunkXDS5YIBCcjs.generatePrivateKeyFile; exports.generatePrivateKeyFileAlternate = _chunkXDS5YIBCcjs.generatePrivateKeyFileAlternate; exports.getCertificateStore = _chunkXDS5YIBCcjs.getCertificateStore; exports.readCertificate = _chunkXDS5YIBCcjs.readCertificate; exports.readCertificateAsync = _chunkXDS5YIBCcjs.readCertificateAsync; exports.readCertificateChain = _chunkXDS5YIBCcjs.readCertificateChain; exports.readCertificateChainAsync = _chunkXDS5YIBCcjs.readCertificateChainAsync; exports.readCertificatePEM = _chunkXDS5YIBCcjs.readCertificatePEM; exports.readCertificatePEMAsync = _chunkXDS5YIBCcjs.readCertificatePEMAsync; exports.readCertificateRevocationList = _chunkXDS5YIBCcjs.readCertificateRevocationList; exports.readCertificateSigningRequest = _chunkXDS5YIBCcjs.readCertificateSigningRequest; exports.readPrivateKey = _chunkXDS5YIBCcjs.readPrivateKey; exports.readPrivateKeyAsync = _chunkXDS5YIBCcjs.readPrivateKeyAsync; exports.readPrivateKeyPEM = _chunkXDS5YIBCcjs.readPrivateKeyPEM; exports.readPrivateKeyPEMAsync = _chunkXDS5YIBCcjs.readPrivateKeyPEMAsync; exports.readPrivateRsaKey = _chunkXDS5YIBCcjs.readPrivateRsaKey; exports.readPublicKey = _chunkXDS5YIBCcjs.readPublicKey; exports.readPublicKeyAsync = _chunkXDS5YIBCcjs.readPublicKeyAsync; exports.readPublicKeyPEM = _chunkXDS5YIBCcjs.readPublicKeyPEM; exports.readPublicKeyPEMAsync = _chunkXDS5YIBCcjs.readPublicKeyPEMAsync; exports.readPublicRsaKey = _chunkXDS5YIBCcjs.readPublicRsaKey; exports.setCertificateStore = _chunkXDS5YIBCcjs.setCertificateStore; exports.writeCertificateChain = _chunkXDS5YIBCcjs.writeCertificateChain; exports.writeCertificateChainAsync = _chunkXDS5YIBCcjs.writeCertificateChainAsync; exports.writeCertificateChainDer = _chunkXDS5YIBCcjs.writeCertificateChainDer; exports.writeCertificateChainDerAsync = _chunkXDS5YIBCcjs.writeCertificateChainDerAsync;
|
|
62
62
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -27,8 +27,8 @@ import {
|
|
|
27
27
|
writeCertificateChainAsync,
|
|
28
28
|
writeCertificateChainDer,
|
|
29
29
|
writeCertificateChainDerAsync
|
|
30
|
-
} from "../chunk-
|
|
31
|
-
import "../chunk-
|
|
30
|
+
} from "../chunk-ULNIL7FF.js";
|
|
31
|
+
import "../chunk-P5QLLSP2.js";
|
|
32
32
|
export {
|
|
33
33
|
certificatesToDer,
|
|
34
34
|
certificatesToPem,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-opcua-crypto",
|
|
3
|
-
"version": "5.3.
|
|
3
|
+
"version": "5.3.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Crypto tools for Node-OPCUA",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -72,6 +72,7 @@
|
|
|
72
72
|
"dependencies": {
|
|
73
73
|
"@peculiar/webcrypto": "^1.5.0",
|
|
74
74
|
"@peculiar/x509": "^2.0.0",
|
|
75
|
+
"reflect-metadata": "^0.2.2",
|
|
75
76
|
"sshpk": "^1.18.0"
|
|
76
77
|
},
|
|
77
78
|
"repository": {
|
|
@@ -86,5 +87,5 @@
|
|
|
86
87
|
"LICENSE",
|
|
87
88
|
"README.md"
|
|
88
89
|
],
|
|
89
|
-
"gitHead": "
|
|
90
|
+
"gitHead": "64eadc79f3f61c0ab82060cc8c20359a188cb541"
|
|
90
91
|
}
|