node-opcua-crypto 5.2.0 → 5.3.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.
- package/dist/{chunk-LCGIBEY5.cjs → chunk-7GWSCCWS.cjs} +42 -2
- package/dist/chunk-7GWSCCWS.cjs.map +1 -0
- package/dist/{chunk-WXGEXWZG.js → chunk-QGNXSXUU.js} +41 -1
- package/dist/chunk-QGNXSXUU.js.map +1 -0
- package/dist/index.cjs +14 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +13 -1
- package/dist/source_nodejs/index.cjs +14 -2
- package/dist/source_nodejs/index.cjs.map +1 -1
- package/dist/source_nodejs/index.d.cts +28 -1
- package/dist/source_nodejs/index.d.ts +28 -1
- package/dist/source_nodejs/index.js +13 -1
- package/package.json +2 -2
- package/dist/chunk-LCGIBEY5.cjs.map +0 -1
- package/dist/chunk-WXGEXWZG.js.map +0 -1
|
@@ -46,6 +46,14 @@ function _readPemOrDerFileAsDER(filename) {
|
|
|
46
46
|
function readCertificate(filename) {
|
|
47
47
|
return _readPemOrDerFileAsDER(filename);
|
|
48
48
|
}
|
|
49
|
+
async function readCertificateAsync(filename) {
|
|
50
|
+
const buf = await _fs2.default.promises.readFile(filename);
|
|
51
|
+
if (filename.match(/.*\.der/)) {
|
|
52
|
+
return buf;
|
|
53
|
+
}
|
|
54
|
+
const raw_key = _chunkERHE4VFScjs.removeTrailingLF.call(void 0, buf.toString("utf-8"));
|
|
55
|
+
return _chunkERHE4VFScjs.convertPEMtoDER.call(void 0, raw_key);
|
|
56
|
+
}
|
|
49
57
|
function readPublicKey(filename) {
|
|
50
58
|
if (filename.match(/.*\.der/)) {
|
|
51
59
|
const der = _fs2.default.readFileSync(filename);
|
|
@@ -55,6 +63,13 @@ function readPublicKey(filename) {
|
|
|
55
63
|
return _crypto.createPublicKey.call(void 0, raw_key);
|
|
56
64
|
}
|
|
57
65
|
}
|
|
66
|
+
async function readPublicKeyAsync(filename) {
|
|
67
|
+
const buf = await _fs2.default.promises.readFile(filename);
|
|
68
|
+
if (filename.match(/.*\.der/)) {
|
|
69
|
+
return _crypto.createPublicKey.call(void 0, buf);
|
|
70
|
+
}
|
|
71
|
+
return _crypto.createPublicKey.call(void 0, _chunkERHE4VFScjs.removeTrailingLF.call(void 0, buf.toString("utf-8")));
|
|
72
|
+
}
|
|
58
73
|
function myCreatePrivateKey(rawKey) {
|
|
59
74
|
if (!_crypto.createPrivateKey || process.env.NO_CREATE_PRIVATEKEY) {
|
|
60
75
|
if (Buffer.isBuffer(rawKey)) {
|
|
@@ -83,15 +98,34 @@ function readPrivateKey(filename) {
|
|
|
83
98
|
return myCreatePrivateKey(raw_key);
|
|
84
99
|
}
|
|
85
100
|
}
|
|
101
|
+
async function readPrivateKeyAsync(filename) {
|
|
102
|
+
const buf = await _fs2.default.promises.readFile(filename);
|
|
103
|
+
if (filename.match(/.*\.der/)) {
|
|
104
|
+
return myCreatePrivateKey(buf);
|
|
105
|
+
}
|
|
106
|
+
return myCreatePrivateKey(_chunkERHE4VFScjs.removeTrailingLF.call(void 0, buf.toString("utf-8")));
|
|
107
|
+
}
|
|
86
108
|
function readCertificatePEM(filename) {
|
|
87
109
|
return _readPemFile(filename);
|
|
88
110
|
}
|
|
111
|
+
async function readCertificatePEMAsync(filename) {
|
|
112
|
+
const buf = await _fs2.default.promises.readFile(filename, "utf-8");
|
|
113
|
+
return _chunkERHE4VFScjs.removeTrailingLF.call(void 0, buf);
|
|
114
|
+
}
|
|
89
115
|
function readPublicKeyPEM(filename) {
|
|
90
116
|
return _readPemFile(filename);
|
|
91
117
|
}
|
|
118
|
+
async function readPublicKeyPEMAsync(filename) {
|
|
119
|
+
const buf = await _fs2.default.promises.readFile(filename, "utf-8");
|
|
120
|
+
return _chunkERHE4VFScjs.removeTrailingLF.call(void 0, buf);
|
|
121
|
+
}
|
|
92
122
|
function readPrivateKeyPEM(filename) {
|
|
93
123
|
return _readPemFile(filename);
|
|
94
124
|
}
|
|
125
|
+
async function readPrivateKeyPEMAsync(filename) {
|
|
126
|
+
const buf = await _fs2.default.promises.readFile(filename, "utf-8");
|
|
127
|
+
return _chunkERHE4VFScjs.removeTrailingLF.call(void 0, buf);
|
|
128
|
+
}
|
|
95
129
|
var _g_certificate_store = "";
|
|
96
130
|
function setCertificateStore(store) {
|
|
97
131
|
const old_store = _g_certificate_store;
|
|
@@ -164,5 +198,11 @@ async function readCertificateSigningRequest(filename) {
|
|
|
164
198
|
|
|
165
199
|
|
|
166
200
|
|
|
167
|
-
|
|
168
|
-
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
exports.generatePrivateKeyFile = generatePrivateKeyFile; exports.generatePrivateKeyFileAlternate = generatePrivateKeyFileAlternate; exports.readCertificate = readCertificate; 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;
|
|
208
|
+
//# sourceMappingURL=chunk-7GWSCCWS.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/node-opcua-crypto/node-opcua-crypto/packages/node-opcua-crypto/dist/chunk-7GWSCCWS.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"],"names":["fs"],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;ACcA,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,CAAU,kBAAA,EAAoB,UAAA,EAAY,OAAO,CAAA;AACvE;ADpBA;AACA;AELA,gFAAmB;AACnB;AACA;AACA,wEAAiB;AACjB,4EAAkB;AAclB,SAAS,YAAA,CAAa,QAAA,EAAuB;AACzC,EAAA,8BAAA,OAAc,SAAA,IAAa,QAAQ,CAAA;AACnC,EAAA,OAAO,gDAAA,YAAiBA,CAAG,YAAA,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A;AACkC,IAAA;AACX,IAAA;AAC9B,EAAA;AACJ;AAK0C;AACR,EAAA;AACC,EAAA;AACE,IAAA;AACjC,EAAA;AAC0B,EAAA;AAC9B;AAEmC;AACH,EAAA;AAChC;AAKsB;AACY,EAAA;AACH,EAAA;AAC/B;AAEiC;AACD,EAAA;AAChC;AAKsB;AACY,EAAA;AACH,EAAA;AAC/B;AAKkC;AACF,EAAA;AAChC;AAMsB;AACY,EAAA;AACH,EAAA;AAC/B;AAEmC;AAEC;AACd,EAAA;AACK,EAAA;AAChB,EAAA;AACX;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;AF/DmC;AACA;AG5IpB;AAIO;AACY,EAAA;AACI,EAAA;AAEvB,IAAA;AACX,EAAA;AAC6B,EAAA;AACC,EAAA;AAClC;AH0ImC;AACA;AIvJpB;AAMO;AACY,EAAA;AACI,EAAA;AAEvB,IAAA;AACX,EAAA;AAC6B,EAAA;AACC,EAAA;AAClC;AJmJmC;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-7GWSCCWS.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 { 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\n/**\n * read a DER or PEM certificate from file\n */\nexport function readCertificate(filename: string): Certificate {\n return _readPemOrDerFileAsDER(filename) as Certificate;\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 */\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 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"]}
|
|
@@ -47,6 +47,14 @@ function _readPemOrDerFileAsDER(filename) {
|
|
|
47
47
|
function readCertificate(filename) {
|
|
48
48
|
return _readPemOrDerFileAsDER(filename);
|
|
49
49
|
}
|
|
50
|
+
async function readCertificateAsync(filename) {
|
|
51
|
+
const buf = await fs2.promises.readFile(filename);
|
|
52
|
+
if (filename.match(/.*\.der/)) {
|
|
53
|
+
return buf;
|
|
54
|
+
}
|
|
55
|
+
const raw_key = removeTrailingLF(buf.toString("utf-8"));
|
|
56
|
+
return convertPEMtoDER(raw_key);
|
|
57
|
+
}
|
|
50
58
|
function readPublicKey(filename) {
|
|
51
59
|
if (filename.match(/.*\.der/)) {
|
|
52
60
|
const der = fs2.readFileSync(filename);
|
|
@@ -56,6 +64,13 @@ function readPublicKey(filename) {
|
|
|
56
64
|
return createPublicKey(raw_key);
|
|
57
65
|
}
|
|
58
66
|
}
|
|
67
|
+
async function readPublicKeyAsync(filename) {
|
|
68
|
+
const buf = await fs2.promises.readFile(filename);
|
|
69
|
+
if (filename.match(/.*\.der/)) {
|
|
70
|
+
return createPublicKey(buf);
|
|
71
|
+
}
|
|
72
|
+
return createPublicKey(removeTrailingLF(buf.toString("utf-8")));
|
|
73
|
+
}
|
|
59
74
|
function myCreatePrivateKey(rawKey) {
|
|
60
75
|
if (!createPrivateKey || process.env.NO_CREATE_PRIVATEKEY) {
|
|
61
76
|
if (Buffer.isBuffer(rawKey)) {
|
|
@@ -84,15 +99,34 @@ function readPrivateKey(filename) {
|
|
|
84
99
|
return myCreatePrivateKey(raw_key);
|
|
85
100
|
}
|
|
86
101
|
}
|
|
102
|
+
async function readPrivateKeyAsync(filename) {
|
|
103
|
+
const buf = await fs2.promises.readFile(filename);
|
|
104
|
+
if (filename.match(/.*\.der/)) {
|
|
105
|
+
return myCreatePrivateKey(buf);
|
|
106
|
+
}
|
|
107
|
+
return myCreatePrivateKey(removeTrailingLF(buf.toString("utf-8")));
|
|
108
|
+
}
|
|
87
109
|
function readCertificatePEM(filename) {
|
|
88
110
|
return _readPemFile(filename);
|
|
89
111
|
}
|
|
112
|
+
async function readCertificatePEMAsync(filename) {
|
|
113
|
+
const buf = await fs2.promises.readFile(filename, "utf-8");
|
|
114
|
+
return removeTrailingLF(buf);
|
|
115
|
+
}
|
|
90
116
|
function readPublicKeyPEM(filename) {
|
|
91
117
|
return _readPemFile(filename);
|
|
92
118
|
}
|
|
119
|
+
async function readPublicKeyPEMAsync(filename) {
|
|
120
|
+
const buf = await fs2.promises.readFile(filename, "utf-8");
|
|
121
|
+
return removeTrailingLF(buf);
|
|
122
|
+
}
|
|
93
123
|
function readPrivateKeyPEM(filename) {
|
|
94
124
|
return _readPemFile(filename);
|
|
95
125
|
}
|
|
126
|
+
async function readPrivateKeyPEMAsync(filename) {
|
|
127
|
+
const buf = await fs2.promises.readFile(filename, "utf-8");
|
|
128
|
+
return removeTrailingLF(buf);
|
|
129
|
+
}
|
|
96
130
|
var _g_certificate_store = "";
|
|
97
131
|
function setCertificateStore(store) {
|
|
98
132
|
const old_store = _g_certificate_store;
|
|
@@ -154,11 +188,17 @@ export {
|
|
|
154
188
|
generatePrivateKeyFile,
|
|
155
189
|
generatePrivateKeyFileAlternate,
|
|
156
190
|
readCertificate,
|
|
191
|
+
readCertificateAsync,
|
|
157
192
|
readPublicKey,
|
|
193
|
+
readPublicKeyAsync,
|
|
158
194
|
readPrivateKey,
|
|
195
|
+
readPrivateKeyAsync,
|
|
159
196
|
readCertificatePEM,
|
|
197
|
+
readCertificatePEMAsync,
|
|
160
198
|
readPublicKeyPEM,
|
|
199
|
+
readPublicKeyPEMAsync,
|
|
161
200
|
readPrivateKeyPEM,
|
|
201
|
+
readPrivateKeyPEMAsync,
|
|
162
202
|
setCertificateStore,
|
|
163
203
|
getCertificateStore,
|
|
164
204
|
readPrivateRsaKey,
|
|
@@ -166,4 +206,4 @@ export {
|
|
|
166
206
|
readCertificateRevocationList,
|
|
167
207
|
readCertificateSigningRequest
|
|
168
208
|
};
|
|
169
|
-
//# sourceMappingURL=chunk-
|
|
209
|
+
//# sourceMappingURL=chunk-QGNXSXUU.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../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"],"sourcesContent":["// ---------------------------------------------------------------------------------------------------------------------\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 { 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\n/**\n * read a DER or PEM certificate from file\n */\nexport function readCertificate(filename: string): Certificate {\n return _readPemOrDerFileAsDER(filename) as Certificate;\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 */\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 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"],"mappings":";;;;;;;;;;;AAuBA,SAAS,2BAA2B;AACpC,OAAO,QAAQ;AAEf,eAAsB,uBAAuB,oBAA4B,eAA0C;AAC/G,QAAM,OAAO,MAAM,gBAAgB,aAAa;AAChD,QAAM,gBAAgB,MAAM,gBAAgB,KAAK,UAAU;AAC3D,QAAM,GAAG,SAAS,UAAU,oBAAoB,cAAc,SAAS,OAAO;AAC9E,gBAAc,UAAU;AACxB,gBAAc,UAAU,IAAI,YAAY,CAAC;AAC7C;AAQA,eAAsB,gCAAgC,oBAA4B,eAAmC;AACjH,QAAM,EAAE,WAAW,IAAI,oBAAoB,OAAO;AAAA,IAC9C;AAAA,IACA,oBAAoB,EAAE,MAAM,SAAS,QAAQ,MAAM;AAAA,IACnD,mBAAmB,EAAE,MAAM,QAAQ,QAAQ,MAAM;AAAA,EACrD,CAAC;AACD,QAAM,GAAG,SAAS,UAAU,oBAAoB,YAAY,OAAO;AACvE;;;ACxBA,OAAO,YAAY;AACnB,SAAS,kBAAkB,uBAAuB;AAClD,OAAOA,SAAQ;AACf,OAAO,UAAU;AACjB,OAAO,WAAW;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MC,IAAG,SAAS,SAAS,QAAQ;AAC/C,MAAI,IAAI,CAAC,MAAM,MAAQ,IAAI,CAAC,MAAM,KAAM;AAEpC,WAAO;AAAA,EACX;AACA,QAAM,UAAU,IAAI,SAAS;AAC7B,SAAO,gBAAgB,OAAO;AAClC;;;ACZA,OAAOC,SAAQ;AAMf,eAAsB,8BAA8B,UAAsD;AACtG,QAAM,MAAM,MAAMC,IAAG,SAAS,SAAS,QAAQ;AAC/C,MAAI,IAAI,CAAC,MAAM,MAAQ,IAAI,CAAC,MAAM,KAAM;AAEpC,WAAO;AAAA,EACX;AACA,QAAM,UAAU,IAAI,SAAS;AAC7B,SAAO,gBAAgB,OAAO;AAClC;","names":["fs","fs","fs","fs","fs","fs"]}
|
package/dist/index.cjs
CHANGED
|
@@ -13,7 +13,13 @@
|
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
var _chunk7GWSCCWScjs = require('./chunk-7GWSCCWS.cjs');
|
|
17
23
|
|
|
18
24
|
|
|
19
25
|
|
|
@@ -181,5 +187,11 @@ var _chunkERHE4VFScjs = require('./chunk-ERHE4VFS.cjs');
|
|
|
181
187
|
|
|
182
188
|
|
|
183
189
|
|
|
184
|
-
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
exports.CertificatePurpose = _chunkERHE4VFScjs.CertificatePurpose; exports.PaddingAlgorithm = _chunkERHE4VFScjs.PaddingAlgorithm; exports.RSA_PKCS1_OAEP_PADDING = _chunkERHE4VFScjs.RSA_PKCS1_OAEP_PADDING; exports.RSA_PKCS1_PADDING = _chunkERHE4VFScjs.RSA_PKCS1_PADDING; exports.Subject = _chunkERHE4VFScjs.Subject; exports._coercePrivateKey = _chunkERHE4VFScjs._coercePrivateKey; exports.asn1 = _chunkERHE4VFScjs.asn1; exports.certificateMatchesPrivateKey = _chunkERHE4VFScjs.certificateMatchesPrivateKey; exports.coerceCertificate = _chunkERHE4VFScjs.coerceCertificate; exports.coerceCertificatePem = _chunkERHE4VFScjs.coerceCertificatePem; exports.coercePEMorDerToPrivateKey = _chunkERHE4VFScjs.coercePEMorDerToPrivateKey; exports.coercePrivateKeyPem = _chunkERHE4VFScjs.coercePrivateKeyPem; exports.coercePublicKeyPem = _chunkERHE4VFScjs.coercePublicKeyPem; exports.coerceRsaPublicKeyPem = _chunkERHE4VFScjs.coerceRsaPublicKeyPem; exports.combine_der = _chunkERHE4VFScjs.combine_der; exports.computeDerivedKeys = _chunkERHE4VFScjs.computeDerivedKeys; exports.computePaddingFooter = _chunkERHE4VFScjs.computePaddingFooter; exports.convertPEMtoDER = _chunkERHE4VFScjs.convertPEMtoDER; exports.createCertificateSigningRequest = _chunkERHE4VFScjs.createCertificateSigningRequest; exports.createPrivateKeyFromNodeJSCrypto = _chunkERHE4VFScjs.createPrivateKeyFromNodeJSCrypto; exports.createSelfSignedCertificate = _chunkERHE4VFScjs.createSelfSignedCertificate; exports.decryptBufferWithDerivedKeys = _chunkERHE4VFScjs.decryptBufferWithDerivedKeys; exports.derToPrivateKey = _chunkERHE4VFScjs.derToPrivateKey; exports.encryptBufferWithDerivedKeys = _chunkERHE4VFScjs.encryptBufferWithDerivedKeys; exports.exploreAsn1 = _chunkERHE4VFScjs.exploreAsn1; exports.exploreCertificate = _chunkERHE4VFScjs.exploreCertificate; exports.exploreCertificateInfo = _chunkERHE4VFScjs.exploreCertificateInfo; exports.exploreCertificateRevocationList = _chunkERHE4VFScjs.exploreCertificateRevocationList; exports.exploreCertificateSigningRequest = _chunkERHE4VFScjs.exploreCertificateSigningRequest; exports.explorePrivateKey = _chunkERHE4VFScjs.explorePrivateKey; exports.extractPublicKeyFromCertificate = _chunkERHE4VFScjs.extractPublicKeyFromCertificate; exports.extractPublicKeyFromCertificateSync = _chunkERHE4VFScjs.extractPublicKeyFromCertificateSync; exports.generateKeyPair = _chunkERHE4VFScjs.generateKeyPair; exports.generatePrivateKey = _chunkERHE4VFScjs.generatePrivateKey; exports.generatePrivateKeyFile = _chunk7GWSCCWScjs.generatePrivateKeyFile; exports.generatePrivateKeyFileAlternate = _chunk7GWSCCWScjs.generatePrivateKeyFileAlternate; exports.getCertificateStore = _chunk7GWSCCWScjs.getCertificateStore; exports.hexDump = _chunkERHE4VFScjs.hexDump; exports.identifyDERContent = _chunkERHE4VFScjs.identifyDERContent; exports.identifyPemType = _chunkERHE4VFScjs.identifyPemType; exports.isCrlIssuedByCertificate = _chunkERHE4VFScjs.isCrlIssuedByCertificate; exports.isKeyObject = _chunkERHE4VFScjs.isKeyObject; exports.makeMessageChunkSignature = _chunkERHE4VFScjs.makeMessageChunkSignature; exports.makeMessageChunkSignatureWithDerivedKeys = _chunkERHE4VFScjs.makeMessageChunkSignatureWithDerivedKeys; exports.makePrivateKeyFromPem = _chunkERHE4VFScjs.makePrivateKeyFromPem; exports.makePrivateKeyThumbPrint = _chunkERHE4VFScjs.makePrivateKeyThumbPrint; exports.makePseudoRandomBuffer = _chunkERHE4VFScjs.makePseudoRandomBuffer; exports.makeSHA1Thumbprint = _chunkERHE4VFScjs.makeSHA1Thumbprint; exports.pemToPrivateKey = _chunkERHE4VFScjs.pemToPrivateKey; exports.privateDecrypt = _chunkERHE4VFScjs.privateDecrypt; exports.privateDecrypt_long = _chunkERHE4VFScjs.privateDecrypt_long; exports.privateDecrypt_native = _chunkERHE4VFScjs.privateDecrypt_native; exports.privateKeyToPEM = _chunkERHE4VFScjs.privateKeyToPEM; exports.publicEncrypt = _chunkERHE4VFScjs.publicEncrypt; exports.publicEncrypt_long = _chunkERHE4VFScjs.publicEncrypt_long; exports.publicEncrypt_native = _chunkERHE4VFScjs.publicEncrypt_native; exports.publicKeyAndPrivateKeyMatches = _chunkERHE4VFScjs.publicKeyAndPrivateKeyMatches; exports.readCertificate = _chunk7GWSCCWScjs.readCertificate; exports.readCertificateAsync = _chunk7GWSCCWScjs.readCertificateAsync; exports.readCertificatePEM = _chunk7GWSCCWScjs.readCertificatePEM; exports.readCertificatePEMAsync = _chunk7GWSCCWScjs.readCertificatePEMAsync; exports.readCertificateRevocationList = _chunk7GWSCCWScjs.readCertificateRevocationList; exports.readCertificateSigningRequest = _chunk7GWSCCWScjs.readCertificateSigningRequest; exports.readCertificationRequestInfo = _chunkERHE4VFScjs.readCertificationRequestInfo; exports.readExtension = _chunkERHE4VFScjs.readExtension; exports.readNameForCrl = _chunkERHE4VFScjs.readNameForCrl; exports.readPrivateKey = _chunk7GWSCCWScjs.readPrivateKey; exports.readPrivateKeyAsync = _chunk7GWSCCWScjs.readPrivateKeyAsync; exports.readPrivateKeyPEM = _chunk7GWSCCWScjs.readPrivateKeyPEM; exports.readPrivateKeyPEMAsync = _chunk7GWSCCWScjs.readPrivateKeyPEMAsync; exports.readPrivateRsaKey = _chunk7GWSCCWScjs.readPrivateRsaKey; exports.readPublicKey = _chunk7GWSCCWScjs.readPublicKey; exports.readPublicKeyAsync = _chunk7GWSCCWScjs.readPublicKeyAsync; exports.readPublicKeyPEM = _chunk7GWSCCWScjs.readPublicKeyPEM; exports.readPublicKeyPEMAsync = _chunk7GWSCCWScjs.readPublicKeyPEMAsync; exports.readPublicRsaKey = _chunk7GWSCCWScjs.readPublicRsaKey; exports.readTbsCertificate = _chunkERHE4VFScjs.readTbsCertificate; exports.reduceLength = _chunkERHE4VFScjs.reduceLength; exports.removePadding = _chunkERHE4VFScjs.removePadding; exports.removeTrailingLF = _chunkERHE4VFScjs.removeTrailingLF; exports.rsaLengthPrivateKey = _chunkERHE4VFScjs.rsaLengthPrivateKey; exports.rsaLengthPublicKey = _chunkERHE4VFScjs.rsaLengthPublicKey; exports.rsaLengthRsaPublicKey = _chunkERHE4VFScjs.rsaLengthRsaPublicKey; exports.setCertificateStore = _chunk7GWSCCWScjs.setCertificateStore; exports.split_der = _chunkERHE4VFScjs.split_der; exports.toPem = _chunkERHE4VFScjs.toPem; exports.toPem2 = _chunkERHE4VFScjs.toPem2; exports.verifyCertificateChain = _chunkERHE4VFScjs.verifyCertificateChain; exports.verifyCertificateOrClrSignature = _chunkERHE4VFScjs.verifyCertificateOrClrSignature; exports.verifyCertificateRevocationListSignature = _chunkERHE4VFScjs.verifyCertificateRevocationListSignature; exports.verifyCertificateSignature = _chunkERHE4VFScjs.verifyCertificateSignature; exports.verifyChunkSignature = _chunkERHE4VFScjs.verifyChunkSignature; exports.verifyChunkSignatureWithDerivedKeys = _chunkERHE4VFScjs.verifyChunkSignatureWithDerivedKeys; exports.verifyCrlIssuedByCertificate = _chunkERHE4VFScjs.verifyCrlIssuedByCertificate; exports.verifyMessageChunkSignature = _chunkERHE4VFScjs.verifyMessageChunkSignature;
|
|
185
197
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/node-opcua-crypto/node-opcua-crypto/packages/node-opcua-crypto/dist/index.cjs"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;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;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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;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;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;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;AACF,
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/node-opcua-crypto/node-opcua-crypto/packages/node-opcua-crypto/dist/index.cjs"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;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;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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;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;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;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;AACA;AACA;AACA;AACA;AACF,onNAAC","file":"/home/runner/work/node-opcua-crypto/node-opcua-crypto/packages/node-opcua-crypto/dist/index.cjs"}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { AttributeTypeAndValue, AuthorityKeyIdentifier, BasicConstraints, CertificateExtension, CertificateInfo, CertificateInternals, CertificateRevocationListInfo, CertificateSerialNumber, CertificateSigningRequestInfo, ComputeDerivedKeysOptions, CreateSelfSignCertificateOptions, DERContentType, DerivedKeys, DirectoryName, ExtensionRequest, Extensions, Name, PaddingAlgorithm, PrivateKeyInternals, PublicKeyLength, RSA_PKCS1_OAEP_PADDING, RSA_PKCS1_PADDING, RevokedCertificate, Subject, SubjectAltName, SubjectOptions, SubjectPublicKey, SubjectPublicKeyInfo, TBSCertList, TbsCertificate, Validity, VerifyChunkSignatureOptions, VerifyMessageChunkSignatureOptions, Version, X509ExtKeyUsage, X509KeyUsage, _VerifyStatus, _coercePrivateKey, asn1, certificateMatchesPrivateKey, coerceCertificate, coerceCertificatePem, coercePEMorDerToPrivateKey, coercePrivateKeyPem, coercePublicKeyPem, coerceRsaPublicKeyPem, combine_der, computeDerivedKeys, computePaddingFooter, convertPEMtoDER, createCertificateSigningRequest, createSelfSignedCertificate, decryptBufferWithDerivedKeys, derToPrivateKey, encryptBufferWithDerivedKeys, exploreAsn1, exploreCertificate, exploreCertificateInfo, exploreCertificateRevocationList, exploreCertificateSigningRequest, explorePrivateKey, extractPublicKeyFromCertificate, extractPublicKeyFromCertificateSync, generateKeyPair, generatePrivateKey, hexDump, identifyDERContent, identifyPemType, isCrlIssuedByCertificate, makeMessageChunkSignature, makeMessageChunkSignatureWithDerivedKeys, makePrivateKeyFromPem, makePrivateKeyThumbPrint, makePseudoRandomBuffer, makeSHA1Thumbprint, pemToPrivateKey, privateDecrypt, privateDecrypt_long, privateDecrypt_native, privateKeyToPEM, publicEncrypt, publicEncrypt_long, publicEncrypt_native, publicKeyAndPrivateKeyMatches, readCertificationRequestInfo, readExtension, readNameForCrl, readTbsCertificate, reduceLength, removePadding, removeTrailingLF, rsaLengthPrivateKey, rsaLengthPublicKey, rsaLengthRsaPublicKey, split_der, toPem, toPem2, verifyCertificateChain, verifyCertificateOrClrSignature, verifyCertificateRevocationListSignature, verifyCertificateSignature, verifyChunkSignature, verifyChunkSignatureWithDerivedKeys, verifyCrlIssuedByCertificate, verifyMessageChunkSignature } from './source/index_web.cjs';
|
|
2
|
-
export { CertificateSigningRequest, generatePrivateKeyFile, generatePrivateKeyFileAlternate, getCertificateStore, readCertificate, readCertificatePEM, readCertificateRevocationList, readCertificateSigningRequest, readPrivateKey, readPrivateKeyPEM, readPrivateRsaKey, readPublicKey, readPublicKeyPEM, readPublicRsaKey, setCertificateStore } from './source_nodejs/index.cjs';
|
|
2
|
+
export { CertificateSigningRequest, generatePrivateKeyFile, generatePrivateKeyFileAlternate, getCertificateStore, readCertificate, readCertificateAsync, readCertificatePEM, readCertificatePEMAsync, readCertificateRevocationList, readCertificateSigningRequest, readPrivateKey, readPrivateKeyAsync, readPrivateKeyPEM, readPrivateKeyPEMAsync, readPrivateRsaKey, readPublicKey, readPublicKeyAsync, readPublicKeyPEM, readPublicKeyPEMAsync, readPublicRsaKey, setCertificateStore } from './source_nodejs/index.cjs';
|
|
3
3
|
export { C as Certificate, d as CertificatePEM, h as CertificatePurpose, g as CertificateRevocationList, D as DER, K as KeyObject, N as Nonce, b as PEM, P as PrivateKey, e as PrivateKeyPEM, a as PublicKey, f as PublicKeyPEM, S as Signature, c as createPrivateKeyFromNodeJSCrypto, i as isKeyObject } from './common-DxHkx4Pv.cjs';
|
|
4
4
|
import '@peculiar/x509';
|
|
5
5
|
import 'node:crypto';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { AttributeTypeAndValue, AuthorityKeyIdentifier, BasicConstraints, CertificateExtension, CertificateInfo, CertificateInternals, CertificateRevocationListInfo, CertificateSerialNumber, CertificateSigningRequestInfo, ComputeDerivedKeysOptions, CreateSelfSignCertificateOptions, DERContentType, DerivedKeys, DirectoryName, ExtensionRequest, Extensions, Name, PaddingAlgorithm, PrivateKeyInternals, PublicKeyLength, RSA_PKCS1_OAEP_PADDING, RSA_PKCS1_PADDING, RevokedCertificate, Subject, SubjectAltName, SubjectOptions, SubjectPublicKey, SubjectPublicKeyInfo, TBSCertList, TbsCertificate, Validity, VerifyChunkSignatureOptions, VerifyMessageChunkSignatureOptions, Version, X509ExtKeyUsage, X509KeyUsage, _VerifyStatus, _coercePrivateKey, asn1, certificateMatchesPrivateKey, coerceCertificate, coerceCertificatePem, coercePEMorDerToPrivateKey, coercePrivateKeyPem, coercePublicKeyPem, coerceRsaPublicKeyPem, combine_der, computeDerivedKeys, computePaddingFooter, convertPEMtoDER, createCertificateSigningRequest, createSelfSignedCertificate, decryptBufferWithDerivedKeys, derToPrivateKey, encryptBufferWithDerivedKeys, exploreAsn1, exploreCertificate, exploreCertificateInfo, exploreCertificateRevocationList, exploreCertificateSigningRequest, explorePrivateKey, extractPublicKeyFromCertificate, extractPublicKeyFromCertificateSync, generateKeyPair, generatePrivateKey, hexDump, identifyDERContent, identifyPemType, isCrlIssuedByCertificate, makeMessageChunkSignature, makeMessageChunkSignatureWithDerivedKeys, makePrivateKeyFromPem, makePrivateKeyThumbPrint, makePseudoRandomBuffer, makeSHA1Thumbprint, pemToPrivateKey, privateDecrypt, privateDecrypt_long, privateDecrypt_native, privateKeyToPEM, publicEncrypt, publicEncrypt_long, publicEncrypt_native, publicKeyAndPrivateKeyMatches, readCertificationRequestInfo, readExtension, readNameForCrl, readTbsCertificate, reduceLength, removePadding, removeTrailingLF, rsaLengthPrivateKey, rsaLengthPublicKey, rsaLengthRsaPublicKey, split_der, toPem, toPem2, verifyCertificateChain, verifyCertificateOrClrSignature, verifyCertificateRevocationListSignature, verifyCertificateSignature, verifyChunkSignature, verifyChunkSignatureWithDerivedKeys, verifyCrlIssuedByCertificate, verifyMessageChunkSignature } from './source/index_web.js';
|
|
2
|
-
export { CertificateSigningRequest, generatePrivateKeyFile, generatePrivateKeyFileAlternate, getCertificateStore, readCertificate, readCertificatePEM, readCertificateRevocationList, readCertificateSigningRequest, readPrivateKey, readPrivateKeyPEM, readPrivateRsaKey, readPublicKey, readPublicKeyPEM, readPublicRsaKey, setCertificateStore } from './source_nodejs/index.js';
|
|
2
|
+
export { CertificateSigningRequest, generatePrivateKeyFile, generatePrivateKeyFileAlternate, getCertificateStore, readCertificate, readCertificateAsync, readCertificatePEM, readCertificatePEMAsync, readCertificateRevocationList, readCertificateSigningRequest, readPrivateKey, readPrivateKeyAsync, readPrivateKeyPEM, readPrivateKeyPEMAsync, readPrivateRsaKey, readPublicKey, readPublicKeyAsync, readPublicKeyPEM, readPublicKeyPEMAsync, readPublicRsaKey, setCertificateStore } from './source_nodejs/index.js';
|
|
3
3
|
export { C as Certificate, d as CertificatePEM, h as CertificatePurpose, g as CertificateRevocationList, D as DER, K as KeyObject, N as Nonce, b as PEM, P as PrivateKey, e as PrivateKeyPEM, a as PublicKey, f as PublicKeyPEM, S as Signature, c as createPrivateKeyFromNodeJSCrypto, i as isKeyObject } from './common-DxHkx4Pv.js';
|
|
4
4
|
import '@peculiar/x509';
|
|
5
5
|
import 'node:crypto';
|
package/dist/index.js
CHANGED
|
@@ -3,17 +3,23 @@ import {
|
|
|
3
3
|
generatePrivateKeyFileAlternate,
|
|
4
4
|
getCertificateStore,
|
|
5
5
|
readCertificate,
|
|
6
|
+
readCertificateAsync,
|
|
6
7
|
readCertificatePEM,
|
|
8
|
+
readCertificatePEMAsync,
|
|
7
9
|
readCertificateRevocationList,
|
|
8
10
|
readCertificateSigningRequest,
|
|
9
11
|
readPrivateKey,
|
|
12
|
+
readPrivateKeyAsync,
|
|
10
13
|
readPrivateKeyPEM,
|
|
14
|
+
readPrivateKeyPEMAsync,
|
|
11
15
|
readPrivateRsaKey,
|
|
12
16
|
readPublicKey,
|
|
17
|
+
readPublicKeyAsync,
|
|
13
18
|
readPublicKeyPEM,
|
|
19
|
+
readPublicKeyPEMAsync,
|
|
14
20
|
readPublicRsaKey,
|
|
15
21
|
setCertificateStore
|
|
16
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-QGNXSXUU.js";
|
|
17
23
|
import {
|
|
18
24
|
CertificatePurpose,
|
|
19
25
|
PaddingAlgorithm,
|
|
@@ -150,17 +156,23 @@ export {
|
|
|
150
156
|
publicEncrypt_native,
|
|
151
157
|
publicKeyAndPrivateKeyMatches,
|
|
152
158
|
readCertificate,
|
|
159
|
+
readCertificateAsync,
|
|
153
160
|
readCertificatePEM,
|
|
161
|
+
readCertificatePEMAsync,
|
|
154
162
|
readCertificateRevocationList,
|
|
155
163
|
readCertificateSigningRequest,
|
|
156
164
|
readCertificationRequestInfo,
|
|
157
165
|
readExtension,
|
|
158
166
|
readNameForCrl,
|
|
159
167
|
readPrivateKey,
|
|
168
|
+
readPrivateKeyAsync,
|
|
160
169
|
readPrivateKeyPEM,
|
|
170
|
+
readPrivateKeyPEMAsync,
|
|
161
171
|
readPrivateRsaKey,
|
|
162
172
|
readPublicKey,
|
|
173
|
+
readPublicKeyAsync,
|
|
163
174
|
readPublicKeyPEM,
|
|
175
|
+
readPublicKeyPEMAsync,
|
|
164
176
|
readPublicRsaKey,
|
|
165
177
|
readTbsCertificate,
|
|
166
178
|
reduceLength,
|
|
@@ -13,7 +13,13 @@
|
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
var _chunk7GWSCCWScjs = require('../chunk-7GWSCCWS.cjs');
|
|
17
23
|
require('../chunk-ERHE4VFS.cjs');
|
|
18
24
|
|
|
19
25
|
|
|
@@ -30,5 +36,11 @@ require('../chunk-ERHE4VFS.cjs');
|
|
|
30
36
|
|
|
31
37
|
|
|
32
38
|
|
|
33
|
-
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
exports.generatePrivateKeyFile = _chunk7GWSCCWScjs.generatePrivateKeyFile; exports.generatePrivateKeyFileAlternate = _chunk7GWSCCWScjs.generatePrivateKeyFileAlternate; exports.getCertificateStore = _chunk7GWSCCWScjs.getCertificateStore; exports.readCertificate = _chunk7GWSCCWScjs.readCertificate; exports.readCertificateAsync = _chunk7GWSCCWScjs.readCertificateAsync; exports.readCertificatePEM = _chunk7GWSCCWScjs.readCertificatePEM; exports.readCertificatePEMAsync = _chunk7GWSCCWScjs.readCertificatePEMAsync; exports.readCertificateRevocationList = _chunk7GWSCCWScjs.readCertificateRevocationList; exports.readCertificateSigningRequest = _chunk7GWSCCWScjs.readCertificateSigningRequest; exports.readPrivateKey = _chunk7GWSCCWScjs.readPrivateKey; exports.readPrivateKeyAsync = _chunk7GWSCCWScjs.readPrivateKeyAsync; exports.readPrivateKeyPEM = _chunk7GWSCCWScjs.readPrivateKeyPEM; exports.readPrivateKeyPEMAsync = _chunk7GWSCCWScjs.readPrivateKeyPEMAsync; exports.readPrivateRsaKey = _chunk7GWSCCWScjs.readPrivateRsaKey; exports.readPublicKey = _chunk7GWSCCWScjs.readPublicKey; exports.readPublicKeyAsync = _chunk7GWSCCWScjs.readPublicKeyAsync; exports.readPublicKeyPEM = _chunk7GWSCCWScjs.readPublicKeyPEM; exports.readPublicKeyPEMAsync = _chunk7GWSCCWScjs.readPublicKeyPEMAsync; exports.readPublicRsaKey = _chunk7GWSCCWScjs.readPublicRsaKey; exports.setCertificateStore = _chunk7GWSCCWScjs.setCertificateStore;
|
|
34
46
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/node-opcua-crypto/node-opcua-crypto/packages/node-opcua-crypto/dist/source_nodejs/index.cjs"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,yDAA8B;AAC9B,iCAA8B;AAC9B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/node-opcua-crypto/node-opcua-crypto/packages/node-opcua-crypto/dist/source_nodejs/index.cjs"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,yDAA8B;AAC9B,iCAA8B;AAC9B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,u4CAAC","file":"/home/runner/work/node-opcua-crypto/node-opcua-crypto/packages/node-opcua-crypto/dist/source_nodejs/index.cjs"}
|
|
@@ -14,21 +14,48 @@ declare function generatePrivateKeyFileAlternate(privateKeyFilename: string, mod
|
|
|
14
14
|
* read a DER or PEM certificate from file
|
|
15
15
|
*/
|
|
16
16
|
declare function readCertificate(filename: string): Certificate;
|
|
17
|
+
/**
|
|
18
|
+
* Async version of {@link readCertificate}.
|
|
19
|
+
* Uses `fs.promises.readFile` so the event loop is not blocked
|
|
20
|
+
* during I/O.
|
|
21
|
+
*/
|
|
22
|
+
declare function readCertificateAsync(filename: string): Promise<Certificate>;
|
|
17
23
|
/**
|
|
18
24
|
* read a DER or PEM certificate from file
|
|
19
25
|
*/
|
|
20
26
|
declare function readPublicKey(filename: string): KeyObject;
|
|
27
|
+
/**
|
|
28
|
+
* Async version of {@link readPublicKey}.
|
|
29
|
+
*/
|
|
30
|
+
declare function readPublicKeyAsync(filename: string): Promise<KeyObject>;
|
|
21
31
|
/**
|
|
22
32
|
* read a DER or PEM certificate from file
|
|
23
33
|
*/
|
|
24
34
|
declare function readPrivateKey(filename: string): PrivateKey;
|
|
35
|
+
/**
|
|
36
|
+
* Async version of {@link readPrivateKey}.
|
|
37
|
+
*/
|
|
38
|
+
declare function readPrivateKeyAsync(filename: string): Promise<PrivateKey>;
|
|
25
39
|
declare function readCertificatePEM(filename: string): CertificatePEM;
|
|
40
|
+
/**
|
|
41
|
+
* Async version of {@link readCertificatePEM}.
|
|
42
|
+
*/
|
|
43
|
+
declare function readCertificatePEMAsync(filename: string): Promise<CertificatePEM>;
|
|
26
44
|
declare function readPublicKeyPEM(filename: string): PublicKeyPEM;
|
|
45
|
+
/**
|
|
46
|
+
* Async version of {@link readPublicKeyPEM}.
|
|
47
|
+
*/
|
|
48
|
+
declare function readPublicKeyPEMAsync(filename: string): Promise<PublicKeyPEM>;
|
|
27
49
|
/**
|
|
28
50
|
*
|
|
29
51
|
* @deprecated
|
|
30
52
|
*/
|
|
31
53
|
declare function readPrivateKeyPEM(filename: string): PrivateKeyPEM;
|
|
54
|
+
/**
|
|
55
|
+
* Async version of {@link readPrivateKeyPEM}.
|
|
56
|
+
* @deprecated
|
|
57
|
+
*/
|
|
58
|
+
declare function readPrivateKeyPEMAsync(filename: string): Promise<PrivateKeyPEM>;
|
|
32
59
|
declare function setCertificateStore(store: string): string;
|
|
33
60
|
declare function getCertificateStore(): string;
|
|
34
61
|
/**
|
|
@@ -43,4 +70,4 @@ declare function readCertificateRevocationList(filename: string): Promise<Certif
|
|
|
43
70
|
type CertificateSigningRequest = Buffer;
|
|
44
71
|
declare function readCertificateSigningRequest(filename: string): Promise<CertificateSigningRequest>;
|
|
45
72
|
|
|
46
|
-
export { type CertificateSigningRequest, generatePrivateKeyFile, generatePrivateKeyFileAlternate, getCertificateStore, readCertificate, readCertificatePEM, readCertificateRevocationList, readCertificateSigningRequest, readPrivateKey, readPrivateKeyPEM, readPrivateRsaKey, readPublicKey, readPublicKeyPEM, readPublicRsaKey, setCertificateStore };
|
|
73
|
+
export { type CertificateSigningRequest, generatePrivateKeyFile, generatePrivateKeyFileAlternate, getCertificateStore, readCertificate, readCertificateAsync, readCertificatePEM, readCertificatePEMAsync, readCertificateRevocationList, readCertificateSigningRequest, readPrivateKey, readPrivateKeyAsync, readPrivateKeyPEM, readPrivateKeyPEMAsync, readPrivateRsaKey, readPublicKey, readPublicKeyAsync, readPublicKeyPEM, readPublicKeyPEMAsync, readPublicRsaKey, setCertificateStore };
|
|
@@ -14,21 +14,48 @@ declare function generatePrivateKeyFileAlternate(privateKeyFilename: string, mod
|
|
|
14
14
|
* read a DER or PEM certificate from file
|
|
15
15
|
*/
|
|
16
16
|
declare function readCertificate(filename: string): Certificate;
|
|
17
|
+
/**
|
|
18
|
+
* Async version of {@link readCertificate}.
|
|
19
|
+
* Uses `fs.promises.readFile` so the event loop is not blocked
|
|
20
|
+
* during I/O.
|
|
21
|
+
*/
|
|
22
|
+
declare function readCertificateAsync(filename: string): Promise<Certificate>;
|
|
17
23
|
/**
|
|
18
24
|
* read a DER or PEM certificate from file
|
|
19
25
|
*/
|
|
20
26
|
declare function readPublicKey(filename: string): KeyObject;
|
|
27
|
+
/**
|
|
28
|
+
* Async version of {@link readPublicKey}.
|
|
29
|
+
*/
|
|
30
|
+
declare function readPublicKeyAsync(filename: string): Promise<KeyObject>;
|
|
21
31
|
/**
|
|
22
32
|
* read a DER or PEM certificate from file
|
|
23
33
|
*/
|
|
24
34
|
declare function readPrivateKey(filename: string): PrivateKey;
|
|
35
|
+
/**
|
|
36
|
+
* Async version of {@link readPrivateKey}.
|
|
37
|
+
*/
|
|
38
|
+
declare function readPrivateKeyAsync(filename: string): Promise<PrivateKey>;
|
|
25
39
|
declare function readCertificatePEM(filename: string): CertificatePEM;
|
|
40
|
+
/**
|
|
41
|
+
* Async version of {@link readCertificatePEM}.
|
|
42
|
+
*/
|
|
43
|
+
declare function readCertificatePEMAsync(filename: string): Promise<CertificatePEM>;
|
|
26
44
|
declare function readPublicKeyPEM(filename: string): PublicKeyPEM;
|
|
45
|
+
/**
|
|
46
|
+
* Async version of {@link readPublicKeyPEM}.
|
|
47
|
+
*/
|
|
48
|
+
declare function readPublicKeyPEMAsync(filename: string): Promise<PublicKeyPEM>;
|
|
27
49
|
/**
|
|
28
50
|
*
|
|
29
51
|
* @deprecated
|
|
30
52
|
*/
|
|
31
53
|
declare function readPrivateKeyPEM(filename: string): PrivateKeyPEM;
|
|
54
|
+
/**
|
|
55
|
+
* Async version of {@link readPrivateKeyPEM}.
|
|
56
|
+
* @deprecated
|
|
57
|
+
*/
|
|
58
|
+
declare function readPrivateKeyPEMAsync(filename: string): Promise<PrivateKeyPEM>;
|
|
32
59
|
declare function setCertificateStore(store: string): string;
|
|
33
60
|
declare function getCertificateStore(): string;
|
|
34
61
|
/**
|
|
@@ -43,4 +70,4 @@ declare function readCertificateRevocationList(filename: string): Promise<Certif
|
|
|
43
70
|
type CertificateSigningRequest = Buffer;
|
|
44
71
|
declare function readCertificateSigningRequest(filename: string): Promise<CertificateSigningRequest>;
|
|
45
72
|
|
|
46
|
-
export { type CertificateSigningRequest, generatePrivateKeyFile, generatePrivateKeyFileAlternate, getCertificateStore, readCertificate, readCertificatePEM, readCertificateRevocationList, readCertificateSigningRequest, readPrivateKey, readPrivateKeyPEM, readPrivateRsaKey, readPublicKey, readPublicKeyPEM, readPublicRsaKey, setCertificateStore };
|
|
73
|
+
export { type CertificateSigningRequest, generatePrivateKeyFile, generatePrivateKeyFileAlternate, getCertificateStore, readCertificate, readCertificateAsync, readCertificatePEM, readCertificatePEMAsync, readCertificateRevocationList, readCertificateSigningRequest, readPrivateKey, readPrivateKeyAsync, readPrivateKeyPEM, readPrivateKeyPEMAsync, readPrivateRsaKey, readPublicKey, readPublicKeyAsync, readPublicKeyPEM, readPublicKeyPEMAsync, readPublicRsaKey, setCertificateStore };
|
|
@@ -3,31 +3,43 @@ import {
|
|
|
3
3
|
generatePrivateKeyFileAlternate,
|
|
4
4
|
getCertificateStore,
|
|
5
5
|
readCertificate,
|
|
6
|
+
readCertificateAsync,
|
|
6
7
|
readCertificatePEM,
|
|
8
|
+
readCertificatePEMAsync,
|
|
7
9
|
readCertificateRevocationList,
|
|
8
10
|
readCertificateSigningRequest,
|
|
9
11
|
readPrivateKey,
|
|
12
|
+
readPrivateKeyAsync,
|
|
10
13
|
readPrivateKeyPEM,
|
|
14
|
+
readPrivateKeyPEMAsync,
|
|
11
15
|
readPrivateRsaKey,
|
|
12
16
|
readPublicKey,
|
|
17
|
+
readPublicKeyAsync,
|
|
13
18
|
readPublicKeyPEM,
|
|
19
|
+
readPublicKeyPEMAsync,
|
|
14
20
|
readPublicRsaKey,
|
|
15
21
|
setCertificateStore
|
|
16
|
-
} from "../chunk-
|
|
22
|
+
} from "../chunk-QGNXSXUU.js";
|
|
17
23
|
import "../chunk-KCVNMSLI.js";
|
|
18
24
|
export {
|
|
19
25
|
generatePrivateKeyFile,
|
|
20
26
|
generatePrivateKeyFileAlternate,
|
|
21
27
|
getCertificateStore,
|
|
22
28
|
readCertificate,
|
|
29
|
+
readCertificateAsync,
|
|
23
30
|
readCertificatePEM,
|
|
31
|
+
readCertificatePEMAsync,
|
|
24
32
|
readCertificateRevocationList,
|
|
25
33
|
readCertificateSigningRequest,
|
|
26
34
|
readPrivateKey,
|
|
35
|
+
readPrivateKeyAsync,
|
|
27
36
|
readPrivateKeyPEM,
|
|
37
|
+
readPrivateKeyPEMAsync,
|
|
28
38
|
readPrivateRsaKey,
|
|
29
39
|
readPublicKey,
|
|
40
|
+
readPublicKeyAsync,
|
|
30
41
|
readPublicKeyPEM,
|
|
42
|
+
readPublicKeyPEMAsync,
|
|
31
43
|
readPublicRsaKey,
|
|
32
44
|
setCertificateStore
|
|
33
45
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-opcua-crypto",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.3.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Crypto tools for Node-OPCUA",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -86,5 +86,5 @@
|
|
|
86
86
|
"LICENSE",
|
|
87
87
|
"README.md"
|
|
88
88
|
],
|
|
89
|
-
"gitHead": "
|
|
89
|
+
"gitHead": "8660de787a060bca52573588214fd7f715e637a4"
|
|
90
90
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/node-opcua-crypto/node-opcua-crypto/packages/node-opcua-crypto/dist/chunk-LCGIBEY5.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"],"names":["fs"],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;ACcA,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;AAA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X,EAAA;AACO,EAAA;AACI,EAAA;AAChB,EAAA;AACpB;AAEiC;AACI,EAAA;AACR,IAAA;AACzB,EAAA;AACgC,EAAA;AACF,EAAA;AACF,EAAA;AACK,EAAA;AACrC;AFpCmC;AACA;AG1GpB;AAIO;AACY,EAAA;AACI,EAAA;AAEvB,IAAA;AACX,EAAA;AAC6B,EAAA;AACC,EAAA;AAClC;AHwGmC;AACA;AIrHpB;AAMO;AACY,EAAA;AACI,EAAA;AAEvB,IAAA;AACX,EAAA;AAC6B,EAAA;AACC,EAAA;AAClC;AJiHmC;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-LCGIBEY5.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 { 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\n/**\n * read a DER or PEM certificate from file\n */\nexport function readCertificate(filename: string): Certificate {\n return _readPemOrDerFileAsDER(filename) 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// 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\nexport function readCertificatePEM(filename: string): CertificatePEM {\n return _readPemFile(filename);\n}\n\nexport function readPublicKeyPEM(filename: string): PublicKeyPEM {\n return _readPemFile(filename);\n}\n/**\n *\n * @deprecated\n */\nexport function readPrivateKeyPEM(filename: string): PrivateKeyPEM {\n return _readPemFile(filename);\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"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../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"],"sourcesContent":["// ---------------------------------------------------------------------------------------------------------------------\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 { 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\n/**\n * read a DER or PEM certificate from file\n */\nexport function readCertificate(filename: string): Certificate {\n return _readPemOrDerFileAsDER(filename) 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// 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\nexport function readCertificatePEM(filename: string): CertificatePEM {\n return _readPemFile(filename);\n}\n\nexport function readPublicKeyPEM(filename: string): PublicKeyPEM {\n return _readPemFile(filename);\n}\n/**\n *\n * @deprecated\n */\nexport function readPrivateKeyPEM(filename: string): PrivateKeyPEM {\n return _readPemFile(filename);\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"],"mappings":";;;;;;;;;;;AAuBA,SAAS,2BAA2B;AACpC,OAAO,QAAQ;AAEf,eAAsB,uBAAuB,oBAA4B,eAA0C;AAC/G,QAAM,OAAO,MAAM,gBAAgB,aAAa;AAChD,QAAM,gBAAgB,MAAM,gBAAgB,KAAK,UAAU;AAC3D,QAAM,GAAG,SAAS,UAAU,oBAAoB,cAAc,SAAS,OAAO;AAC9E,gBAAc,UAAU;AACxB,gBAAc,UAAU,IAAI,YAAY,CAAC;AAC7C;AAQA,eAAsB,gCAAgC,oBAA4B,eAAmC;AACjH,QAAM,EAAE,WAAW,IAAI,oBAAoB,OAAO;AAAA,IAC9C;AAAA,IACA,oBAAoB,EAAE,MAAM,SAAS,QAAQ,MAAM;AAAA,IACnD,mBAAmB,EAAE,MAAM,QAAQ,QAAQ,MAAM;AAAA,EACrD,CAAC;AACD,QAAM,GAAG,SAAS,UAAU,oBAAoB,YAAY,OAAO;AACvE;;;ACxBA,OAAO,YAAY;AACnB,SAAS,kBAAkB,uBAAuB;AAClD,OAAOA,SAAQ;AACf,OAAO,UAAU;AACjB,OAAO,WAAW;AAclB,SAAS,aAAa,UAAuB;AACzC,SAAO,OAAO,aAAa,QAAQ;AACnC,SAAO,iBAAiBC,IAAG,aAAa,UAAU,OAAO,CAAC;AAC9D;AAEA,SAAS,uBAAuB,UAAuB;AACnD,MAAI,SAAS,MAAM,SAAS,GAAG;AAC3B,WAAOA,IAAG,aAAa,QAAQ;AAAA,EACnC;AACA,QAAM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