node-opcua-crypto 4.7.0 → 4.9.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/LICENSE CHANGED
@@ -1,23 +1,23 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) Etienne Rossignon 2015-2022
4
- Copyright (c) Sterfive.com 2022-2024
5
-
6
- Permission is hereby granted, free of charge, to any person obtaining a copy
7
- of this software and associated documentation files (the "Software"), to deal
8
- in the Software without restriction, including without limitation the rights
9
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- copies of the Software, and to permit persons to whom the Software is
11
- furnished to do so, subject to the following conditions:
12
-
13
- The above copyright notice and this permission notice shall be included in all
14
- copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
- SOFTWARE.
23
-
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) Etienne Rossignon 2015-2022
4
+ Copyright (c) Sterfive.com 2022-2024
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
23
+
package/README.md CHANGED
@@ -1,114 +1,114 @@
1
- # node-opcua-crypto
2
-
3
- NodeOPCUA Crypto is a powerful JavaScript module for handling security and cryptography for OPCUA. It's written in TypeScript and runs smoothly on Node.js and in the browser.
4
-
5
- [![NPM download](https://img.shields.io/npm/dm/node-opcua-crypto.svg)](https://www.npmtrends.com/node-opcua-crypto)
6
- [![NPM version](https://img.shields.io/npm/v/node-opcua-crypto)](https://www.npmjs.com/package/node-opcua-crypto?activeTab=versions)
7
- [![Build Status](https://github.com/node-opcua/node-opcua-crypto/actions/workflows/main.yml/badge.svg)](https://github.com/node-opcua/node-opcua-crypto/actions/workflows/main.yml)
8
- [![Code Climate](https://codeclimate.com/github/node-opcua/node-opcua-crypto/badges/gpa.svg)](https://codeclimate.com/github/node-opcua/node-opcua-crypto)
9
- [![Coverage Status](https://coveralls.io/repos/github/node-opcua/node-opcua-crypto/badge.svg?branch=master)](https://coveralls.io/github/node-opcua/node-opcua-crypto?branch=master)
10
- [![install size](https://packagephobia.com/badge?p=node-opcua-crypto)](https://packagephobia.com/result?p=node-opcua-crypto)
11
- [![FOSSA Status](https://app.fossa.com/api/projects/custom%2B20248%2Fgithub.com%2Fnode-opcua%2Fnode-opcua-crypto.svg?type=shield)](https://app.fossa.com/projects/custom%2B20248%2Fgithub.com%2Fnode-opcua%2Fnode-opcua-crypto?ref=badge_shield)
12
- <!-- [![Test Coverage](https://codeclimate.com/github/node-opcua/node-opcua-crypto/badges/coverage.svg)](https://codeclimate.com/github/node-opcua/node-opcua-crypto/coverage) -->
13
-
14
- ## Features
15
-
16
- * a comprehensive set of cryptographic functionalities.
17
- * supports both Node.js and browser environments.
18
- * compatible with TypeScript for robust, type-safe coding.
19
- * implements advanced security standards for OPCUA.
20
-
21
- ## Getting Started
22
-
23
- To use NodeOPCUA Crypto in your project, follow these steps:
24
-
25
- #### Installation
26
-
27
- ``` bash
28
- npm install nodeopcua-crypto
29
- ```
30
-
31
- ### Usage
32
-
33
- ``` bash
34
-
35
- import { generatePrivateKey, privateKeyToPEM, CertificatePurpose, createSelfSignedCertificate } from "./node-opcua-crypto.js";
36
-
37
- async function demonstratePrivateKeyAndSelfSignedCertificateCreation() {
38
-
39
- // create the Private Key
40
- const privateKey = await generatePrivateKey();
41
-
42
- // convert the private key to a PEM format
43
- const { privPem } = await privateKeyToPEM(privateKey);
44
-
45
- console.log(privPem);
46
-
47
- // create a self-sign certificate
48
- const { cert } = await createSelfSignedCertificate({
49
- privateKey,
50
- notAfter: new Date(2025, 1, 1),
51
- notBefore: new Date(2019, 1, 1),
52
- subject: "CN=Test",
53
- dns: ["DNS1", "DNS2"],
54
- ip: ["192.168.1.1"],
55
- applicationUri: "urn:HOSTNAME:ServerDescription",
56
- purpose: CertificatePurpose.ForApplication,
57
- });
58
- console.log(cert);
59
- }
60
- demonstratePrivateKeyAndSelfSignedCertificateCreation();
61
-
62
-
63
- ```
64
-
65
- Please refer to the examples directory for more specific use cases and comprehensive samples.
66
-
67
-
68
- ## Support
69
-
70
- For any inquiries or issues related to NodeOPCUA Crypto, you can contact us at contact@sterfive.com. Please note that priority support is available to NodeOPCUA Support Subscription members.
71
-
72
- ### Getting professional support
73
-
74
- NodeOPCUA PKI is developed and maintained by sterfive.com.
75
-
76
- To get professional support, consider subscribing to the node-opcua membership community:
77
-
78
- [![Professional Support](https://img.shields.io/static/v1?style=for-the-badge&label=Professional&message=Support&labelColor=blue&color=green&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB2ZXJzaW9uPSIxLjEiIGlkPSJMYXllcl8xIiB4PSIwcHgiIHk9IjBweCIgdmlld0JveD0iMCAwIDQ5MS41MiA0OTEuNTIiIHN0eWxlPSJlbmFibGUtYmFja2dyb3VuZDpuZXcgMCAwIDQ5MS41MiA0OTEuNTI7IiB4bWw6c3BhY2U9InByZXNlcnZlIj4NCjxnPg0KCTxnPg0KCQk8cGF0aCBkPSJNNDg3Ljk4OSwzODkuNzU1bC05My4xMDktOTIuOTc2Yy00LjgxMy00LjgwNi0xMi42NDItNC42NzQtMTcuMjczLDAuMzA3Yy03LjE0OCw3LjY4OS0xNC42NCwxNS41NTQtMjEuNzMsMjIuNjM0ICAgIGMtMC4yNzEsMC4yNy0wLjUwMSwwLjQ5My0wLjc2MywwLjc1NUw0NjcuMyw0MzIuNTA0YzguOTEtMTAuNjE0LDE2LjY1Ny0yMC40MSwyMS43My0yNi45NyAgICBDNDkyLjcyLDQwMC43NjIsNDkyLjI1NywzOTQuMDE5LDQ4Ny45ODksMzg5Ljc1NXoiLz4NCgk8L2c+DQo8L2c+DQo8Zz4NCgk8Zz4NCgkJPHBhdGggZD0iTTMzNC4zLDMzNy42NjFjLTM0LjMwNCwxMS4zNzktNzcuNTYsMC40MTMtMTE0LjU1NC0yOS41NDJjLTQ5LjAyMS0zOS42OTMtNzUuOTcyLTEwMi42NDItNjUuODM4LTE1MC41OTNMMzcuNjM0LDQxLjQxOCAgICBDMTcuNjUzLDU5LjQyNCwwLDc4LjU0NSwwLDkwYzAsMTQxLjc1MSwyNjAuMzQ0LDQxNS44OTYsNDAxLjUwMyw0MDAuOTMxYzExLjI5Ni0xLjE5OCwzMC4xNzYtMTguNjUxLDQ4LjA2Mi0zOC4xNjdMMzM0LjMsMzM3LjY2MSAgICB6Ii8+DQoJPC9nPg0KPC9nPg0KPGc+DQoJPGc+DQoJCTxwYXRoIGQ9Ik0xOTMuODU0LDk2LjA0MUwxMDEuMjEzLDMuNTNjLTQuMjI1LTQuMjItMTAuODgyLTQuNzI0LTE1LjY2NC0xLjE0NWMtNi42NTQsNC45ODMtMTYuNjQ4LDEyLjY1MS0yNy40NTMsMjEuNDk4ICAgIGwxMTEuOTQ1LDExMS43ODVjMC4wNjEtMC4wNiwwLjExMS0wLjExMywwLjE3Mi0wLjE3NGM3LjIzOC03LjIyOCwxNS4zNTUtMTQuODg1LDIzLjI5MS0yMi4xNjcgICAgQzE5OC41MzQsMTA4LjcxMywxOTguNjg0LDEwMC44NjMsMTkzLjg1NCw5Ni4wNDF6Ii8+DQoJPC9nPg0KPC9nPg0KPGc+DQo8L2c+DQo8Zz4NCjwvZz4NCjxnPg0KPC9nPg0KPGc+DQo8L2c+DQo8Zz4NCjwvZz4NCjxnPg0KPC9nPg0KPGc+DQo8L2c+DQo8Zz4NCjwvZz4NCjxnPg0KPC9nPg0KPGc+DQo8L2c+DQo8Zz4NCjwvZz4NCjxnPg0KPC9nPg0KPGc+DQo8L2c+DQo8Zz4NCjwvZz4NCjxnPg0KPC9nPg0KPC9zdmc+)](https://support.sterfive.com)
79
-
80
- or contact [sterfive](https://www.sterfive.com) for dedicated consulting and more advanced support.
81
-
82
- ## Contributing
83
-
84
- We appreciate contributions from the community. To contribute:
85
-
86
- * Fork the repository.
87
- * Create a new branch.
88
- * Commit your changes.
89
- * Submit a pull request.
90
- * Sign the CLA (Contributor Licence Agreement) form
91
-
92
- For more detailed instructions, refer to the CONTRIBUTING.md file.
93
-
94
- ## License
95
-
96
- NodeOPCUA Crypto is MIT licensed. See the LICENSE file for full license details.
97
-
98
- Copyright © 2023-2024 Sterfive.com.
99
-
100
- ## Disclaimer
101
-
102
- NodeOPCUA Crypto is provided as-is, and while we strive to ensure its quality and security, Sterfive.com cannot be held liable for any damage caused directly or indirectly by the usage of this module.
103
-
104
- Please report any issues or vulnerabilities you find via the issue tracker.
105
-
106
- Thank you for considering NodeOPCUA Crypto for your OPCUA cryptography needs. We look forward to seeing what you build with i
107
-
108
-
109
-
110
- ## Supporting the development effort - Sponsors & Backers
111
-
112
- If you like `node-opcua-pki` and if you are relying on it in one of your projects, please consider becoming a backer and [sponsoring us](https://github.com/sponsors/node-opcua), this will help us to maintain a high-quality stack and constant evolution of this module.
113
-
114
- If your company would like to participate and influence the development of future versions of `node-opcua` please contact [sterfive](mailto:contact@sterfive.com).
1
+ # node-opcua-crypto
2
+
3
+ NodeOPCUA Crypto is a powerful JavaScript module for handling security and cryptography for OPCUA. It's written in TypeScript and runs smoothly on Node.js and in the browser.
4
+
5
+ [![NPM download](https://img.shields.io/npm/dm/node-opcua-crypto.svg)](https://www.npmtrends.com/node-opcua-crypto)
6
+ [![NPM version](https://img.shields.io/npm/v/node-opcua-crypto)](https://www.npmjs.com/package/node-opcua-crypto?activeTab=versions)
7
+ [![Build Status](https://github.com/node-opcua/node-opcua-crypto/actions/workflows/main.yml/badge.svg)](https://github.com/node-opcua/node-opcua-crypto/actions/workflows/main.yml)
8
+ [![Code Climate](https://codeclimate.com/github/node-opcua/node-opcua-crypto/badges/gpa.svg)](https://codeclimate.com/github/node-opcua/node-opcua-crypto)
9
+ [![Coverage Status](https://coveralls.io/repos/github/node-opcua/node-opcua-crypto/badge.svg?branch=master)](https://coveralls.io/github/node-opcua/node-opcua-crypto?branch=master)
10
+ [![install size](https://packagephobia.com/badge?p=node-opcua-crypto)](https://packagephobia.com/result?p=node-opcua-crypto)
11
+ [![FOSSA Status](https://app.fossa.com/api/projects/custom%2B20248%2Fgithub.com%2Fnode-opcua%2Fnode-opcua-crypto.svg?type=shield)](https://app.fossa.com/projects/custom%2B20248%2Fgithub.com%2Fnode-opcua%2Fnode-opcua-crypto?ref=badge_shield)
12
+ <!-- [![Test Coverage](https://codeclimate.com/github/node-opcua/node-opcua-crypto/badges/coverage.svg)](https://codeclimate.com/github/node-opcua/node-opcua-crypto/coverage) -->
13
+
14
+ ## Features
15
+
16
+ * a comprehensive set of cryptographic functionalities.
17
+ * supports both Node.js and browser environments.
18
+ * compatible with TypeScript for robust, type-safe coding.
19
+ * implements advanced security standards for OPCUA.
20
+
21
+ ## Getting Started
22
+
23
+ To use NodeOPCUA Crypto in your project, follow these steps:
24
+
25
+ #### Installation
26
+
27
+ ``` bash
28
+ npm install nodeopcua-crypto
29
+ ```
30
+
31
+ ### Usage
32
+
33
+ ``` bash
34
+
35
+ import { generatePrivateKey, privateKeyToPEM, CertificatePurpose, createSelfSignedCertificate } from "./node-opcua-crypto.js";
36
+
37
+ async function demonstratePrivateKeyAndSelfSignedCertificateCreation() {
38
+
39
+ // create the Private Key
40
+ const privateKey = await generatePrivateKey();
41
+
42
+ // convert the private key to a PEM format
43
+ const { privPem } = await privateKeyToPEM(privateKey);
44
+
45
+ console.log(privPem);
46
+
47
+ // create a self-sign certificate
48
+ const { cert } = await createSelfSignedCertificate({
49
+ privateKey,
50
+ notAfter: new Date(2025, 1, 1),
51
+ notBefore: new Date(2019, 1, 1),
52
+ subject: "CN=Test",
53
+ dns: ["DNS1", "DNS2"],
54
+ ip: ["192.168.1.1"],
55
+ applicationUri: "urn:HOSTNAME:ServerDescription",
56
+ purpose: CertificatePurpose.ForApplication,
57
+ });
58
+ console.log(cert);
59
+ }
60
+ demonstratePrivateKeyAndSelfSignedCertificateCreation();
61
+
62
+
63
+ ```
64
+
65
+ Please refer to the examples directory for more specific use cases and comprehensive samples.
66
+
67
+
68
+ ## Support
69
+
70
+ For any inquiries or issues related to NodeOPCUA Crypto, you can contact us at contact@sterfive.com. Please note that priority support is available to NodeOPCUA Support Subscription members.
71
+
72
+ ### Getting professional support
73
+
74
+ NodeOPCUA PKI is developed and maintained by sterfive.com.
75
+
76
+ To get professional support, consider subscribing to the node-opcua membership community:
77
+
78
+ [![Professional Support](https://img.shields.io/static/v1?style=for-the-badge&label=Professional&message=Support&labelColor=blue&color=green&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB2ZXJzaW9uPSIxLjEiIGlkPSJMYXllcl8xIiB4PSIwcHgiIHk9IjBweCIgdmlld0JveD0iMCAwIDQ5MS41MiA0OTEuNTIiIHN0eWxlPSJlbmFibGUtYmFja2dyb3VuZDpuZXcgMCAwIDQ5MS41MiA0OTEuNTI7IiB4bWw6c3BhY2U9InByZXNlcnZlIj4NCjxnPg0KCTxnPg0KCQk8cGF0aCBkPSJNNDg3Ljk4OSwzODkuNzU1bC05My4xMDktOTIuOTc2Yy00LjgxMy00LjgwNi0xMi42NDItNC42NzQtMTcuMjczLDAuMzA3Yy03LjE0OCw3LjY4OS0xNC42NCwxNS41NTQtMjEuNzMsMjIuNjM0ICAgIGMtMC4yNzEsMC4yNy0wLjUwMSwwLjQ5My0wLjc2MywwLjc1NUw0NjcuMyw0MzIuNTA0YzguOTEtMTAuNjE0LDE2LjY1Ny0yMC40MSwyMS43My0yNi45NyAgICBDNDkyLjcyLDQwMC43NjIsNDkyLjI1NywzOTQuMDE5LDQ4Ny45ODksMzg5Ljc1NXoiLz4NCgk8L2c+DQo8L2c+DQo8Zz4NCgk8Zz4NCgkJPHBhdGggZD0iTTMzNC4zLDMzNy42NjFjLTM0LjMwNCwxMS4zNzktNzcuNTYsMC40MTMtMTE0LjU1NC0yOS41NDJjLTQ5LjAyMS0zOS42OTMtNzUuOTcyLTEwMi42NDItNjUuODM4LTE1MC41OTNMMzcuNjM0LDQxLjQxOCAgICBDMTcuNjUzLDU5LjQyNCwwLDc4LjU0NSwwLDkwYzAsMTQxLjc1MSwyNjAuMzQ0LDQxNS44OTYsNDAxLjUwMyw0MDAuOTMxYzExLjI5Ni0xLjE5OCwzMC4xNzYtMTguNjUxLDQ4LjA2Mi0zOC4xNjdMMzM0LjMsMzM3LjY2MSAgICB6Ii8+DQoJPC9nPg0KPC9nPg0KPGc+DQoJPGc+DQoJCTxwYXRoIGQ9Ik0xOTMuODU0LDk2LjA0MUwxMDEuMjEzLDMuNTNjLTQuMjI1LTQuMjItMTAuODgyLTQuNzI0LTE1LjY2NC0xLjE0NWMtNi42NTQsNC45ODMtMTYuNjQ4LDEyLjY1MS0yNy40NTMsMjEuNDk4ICAgIGwxMTEuOTQ1LDExMS43ODVjMC4wNjEtMC4wNiwwLjExMS0wLjExMywwLjE3Mi0wLjE3NGM3LjIzOC03LjIyOCwxNS4zNTUtMTQuODg1LDIzLjI5MS0yMi4xNjcgICAgQzE5OC41MzQsMTA4LjcxMywxOTguNjg0LDEwMC44NjMsMTkzLjg1NCw5Ni4wNDF6Ii8+DQoJPC9nPg0KPC9nPg0KPGc+DQo8L2c+DQo8Zz4NCjwvZz4NCjxnPg0KPC9nPg0KPGc+DQo8L2c+DQo8Zz4NCjwvZz4NCjxnPg0KPC9nPg0KPGc+DQo8L2c+DQo8Zz4NCjwvZz4NCjxnPg0KPC9nPg0KPGc+DQo8L2c+DQo8Zz4NCjwvZz4NCjxnPg0KPC9nPg0KPGc+DQo8L2c+DQo8Zz4NCjwvZz4NCjxnPg0KPC9nPg0KPC9zdmc+)](https://support.sterfive.com)
79
+
80
+ or contact [sterfive](https://www.sterfive.com) for dedicated consulting and more advanced support.
81
+
82
+ ## Contributing
83
+
84
+ We appreciate contributions from the community. To contribute:
85
+
86
+ * Fork the repository.
87
+ * Create a new branch.
88
+ * Commit your changes.
89
+ * Submit a pull request.
90
+ * Sign the CLA (Contributor Licence Agreement) form
91
+
92
+ For more detailed instructions, refer to the CONTRIBUTING.md file.
93
+
94
+ ## License
95
+
96
+ NodeOPCUA Crypto is MIT licensed. See the LICENSE file for full license details.
97
+
98
+ Copyright © 2023-2024 Sterfive.com.
99
+
100
+ ## Disclaimer
101
+
102
+ NodeOPCUA Crypto is provided as-is, and while we strive to ensure its quality and security, Sterfive.com cannot be held liable for any damage caused directly or indirectly by the usage of this module.
103
+
104
+ Please report any issues or vulnerabilities you find via the issue tracker.
105
+
106
+ Thank you for considering NodeOPCUA Crypto for your OPCUA cryptography needs. We look forward to seeing what you build with i
107
+
108
+
109
+
110
+ ## Supporting the development effort - Sponsors & Backers
111
+
112
+ If you like `node-opcua-pki` and if you are relying on it in one of your projects, please consider becoming a backer and [sponsoring us](https://github.com/sponsors/node-opcua), this will help us to maintain a high-quality stack and constant evolution of this module.
113
+
114
+ If your company would like to participate and influence the development of future versions of `node-opcua` please contact [sterfive](mailto:contact@sterfive.com).
package/index.mjs CHANGED
@@ -1 +1 @@
1
- export * from "./dist/index.mjs";
1
+ export * from "./dist/index.mjs";
package/index_web.ts CHANGED
@@ -1 +1 @@
1
- export * from "./source/index.js";
1
+ export * from "./source/index.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-opcua-crypto",
3
- "version": "4.7.0",
3
+ "version": "4.9.0",
4
4
  "description": "Crypto tools for Node-OPCUA",
5
5
  "types": "./dist/index.d.ts",
6
6
  "main": "./dist/index.js",
@@ -46,18 +46,18 @@
46
46
  "node": ">15.0"
47
47
  },
48
48
  "devDependencies": {
49
- "@types/node": "^20.11.5",
49
+ "@types/node": "^20.14.10",
50
50
  "lorem-ipsum": "^2.0.8"
51
51
  },
52
52
  "dependencies": {
53
- "@peculiar/webcrypto": "^1.4.4",
54
- "@peculiar/x509": "^1.9.6",
55
- "@types/jsrsasign": "^10.5.12",
53
+ "@peculiar/webcrypto": "^1.5.0",
54
+ "@peculiar/x509": "^1.11.0",
55
+ "@types/jsrsasign": "^10.5.14",
56
56
  "@types/sshpk": "^1.17.4",
57
57
  "assert": "^2.1.0",
58
58
  "chalk": "^4.1.2",
59
59
  "hexy": "0.3.5",
60
- "jsrsasign": "^11.0.0",
60
+ "jsrsasign": "^11.1.0",
61
61
  "sshpk": "^1.18.0"
62
62
  },
63
63
  "repository": {
@@ -67,5 +67,5 @@
67
67
  "bugs": {
68
68
  "url": "https://github.com/node-opcua/node-opcua-crypto/issues"
69
69
  },
70
- "gitHead": "24f9357d755a84a70fee9e516ff682f4bbb66c3c"
70
+ "gitHead": "32e5c2e92f1ab76caf6166a6049736e2ac77a9f4"
71
71
  }
@@ -1,173 +0,0 @@
1
- import {
2
- __dirname,
3
- convertPEMtoDER,
4
- generateKeyPair,
5
- identifyPemType,
6
- privateKeyToPEM,
7
- removeTrailingLF,
8
- toPem
9
- } from "./chunk-PET55CDS.mjs";
10
-
11
- // source_nodejs/read.ts
12
- import assert from "assert";
13
- import fs from "fs";
14
- import path from "path";
15
- import { createPrivateKey, createPublicKey } from "crypto";
16
- import sshpk from "sshpk";
17
- function _readPemFile(filename) {
18
- assert(typeof filename === "string");
19
- return removeTrailingLF(fs.readFileSync(filename, "utf-8"));
20
- }
21
- function _readPemOrDerFileAsDER(filename) {
22
- if (filename.match(/.*\.der/)) {
23
- return fs.readFileSync(filename);
24
- }
25
- const raw_key = _readPemFile(filename);
26
- return convertPEMtoDER(raw_key);
27
- }
28
- function readCertificate(filename) {
29
- return _readPemOrDerFileAsDER(filename);
30
- }
31
- function readPublicKey(filename) {
32
- if (filename.match(/.*\.der/)) {
33
- const der = fs.readFileSync(filename);
34
- return createPublicKey(der);
35
- } else {
36
- const raw_key = _readPemFile(filename);
37
- return createPublicKey(raw_key);
38
- }
39
- }
40
- function myCreatePrivateKey(rawKey) {
41
- if (!createPrivateKey || process.env.NO_CREATE_PRIVATEKEY) {
42
- if (rawKey instanceof Buffer) {
43
- const pemKey = toPem(rawKey, "PRIVATE KEY");
44
- assert(["RSA PRIVATE KEY", "PRIVATE KEY"].indexOf(identifyPemType(pemKey)) >= 0);
45
- return { hidden: pemKey };
46
- }
47
- return { hidden: ensureTrailingLF(rawKey) };
48
- }
49
- const backup = process.env.OPENSSL_CONF;
50
- process.env.OPENSSL_CONF = "/dev/null";
51
- const retValue = createPrivateKey(rawKey);
52
- process.env.OPENSSL_CONF = backup;
53
- return { hidden: retValue };
54
- }
55
- function makePrivateKeyThumbPrint(privateKey) {
56
- return Buffer.alloc(0);
57
- }
58
- function ensureTrailingLF(str) {
59
- return str.match(/\n$/) ? str : str + "\n";
60
- }
61
- function readPrivateKey(filename) {
62
- if (filename.match(/.*\.der/)) {
63
- const der = fs.readFileSync(filename);
64
- return myCreatePrivateKey(der);
65
- } else {
66
- const raw_key = _readPemFile(filename);
67
- return myCreatePrivateKey(raw_key);
68
- }
69
- }
70
- function readCertificatePEM(filename) {
71
- return _readPemFile(filename);
72
- }
73
- function readPublicKeyPEM(filename) {
74
- return _readPemFile(filename);
75
- }
76
- function readPrivateKeyPEM(filename) {
77
- return _readPemFile(filename);
78
- }
79
- var _g_certificate_store = "";
80
- function setCertificateStore(store) {
81
- const old_store = _g_certificate_store;
82
- _g_certificate_store = store;
83
- return old_store;
84
- }
85
- function getCertificateStore() {
86
- if (!_g_certificate_store) {
87
- _g_certificate_store = path.join(__dirname, "../../certificates/");
88
- }
89
- return _g_certificate_store;
90
- }
91
- function readPrivateRsaKey(filename) {
92
- if (!createPrivateKey) {
93
- throw new Error("createPrivateKey is not supported in this environment");
94
- }
95
- if (filename.substring(0, 1) !== "." && !fs.existsSync(filename)) {
96
- filename = path.join(getCertificateStore(), filename);
97
- }
98
- const content = fs.readFileSync(filename, "utf8");
99
- const sshKey = sshpk.parsePrivateKey(content, "auto");
100
- const key = sshKey.toString("pkcs1");
101
- const hidden = createPrivateKey({ format: "pem", type: "pkcs1", key });
102
- return { hidden };
103
- }
104
- function readPublicRsaKey(filename) {
105
- if (filename.substring(0, 1) !== "." && !fs.existsSync(filename)) {
106
- filename = path.join(getCertificateStore(), filename);
107
- }
108
- const content = fs.readFileSync(filename, "utf-8");
109
- const sshKey = sshpk.parseKey(content, "ssh");
110
- const key = sshKey.toString("pkcs1");
111
- return createPublicKey({ format: "pem", type: "pkcs1", key });
112
- }
113
-
114
- // source_nodejs/read_certificate_revocation_list.ts
115
- import fs2 from "fs";
116
- import { promisify } from "util";
117
- async function readCertificateRevocationList(filename) {
118
- const crl = await promisify(fs2.readFile)(filename);
119
- if (crl[0] === 48 && crl[1] === 130) {
120
- return crl;
121
- }
122
- const raw_crl = crl.toString();
123
- return convertPEMtoDER(raw_crl);
124
- }
125
-
126
- // source_nodejs/read_certificate_signing_request.ts
127
- import fs3 from "fs";
128
- import { promisify as promisify2 } from "util";
129
- async function readCertificateSigningRequest(filename) {
130
- const csr = await promisify2(fs3.readFile)(filename);
131
- if (csr[0] === 48 && csr[1] === 130) {
132
- return csr;
133
- }
134
- const raw_crl = csr.toString();
135
- return convertPEMtoDER(raw_crl);
136
- }
137
-
138
- // source_nodejs/generate_private_key_filename.ts
139
- import fs4 from "fs";
140
- import jsrsasign from "jsrsasign";
141
- async function generatePrivateKeyFile(privateKeyFilename, modulusLength) {
142
- const keys = await generateKeyPair(modulusLength);
143
- const privateKeyPem = await privateKeyToPEM(keys.privateKey);
144
- await fs4.promises.writeFile(privateKeyFilename, privateKeyPem.privPem, "utf-8");
145
- privateKeyPem.privPem = "";
146
- privateKeyPem.privDer = new Uint8Array(0);
147
- }
148
- async function generatePrivateKeyFileAlternate(privateKeyFilename, modulusLength) {
149
- const kp = jsrsasign.KEYUTIL.generateKeypair("RSA", modulusLength);
150
- const prv = kp.prvKeyObj;
151
- const pub = kp.pubKeyObj;
152
- const prvpem = jsrsasign.KEYUTIL.getPEM(prv, "PKCS8PRV");
153
- await fs4.promises.writeFile(privateKeyFilename, prvpem, "utf-8");
154
- }
155
-
156
- export {
157
- readCertificate,
158
- readPublicKey,
159
- makePrivateKeyThumbPrint,
160
- readPrivateKey,
161
- readCertificatePEM,
162
- readPublicKeyPEM,
163
- readPrivateKeyPEM,
164
- setCertificateStore,
165
- getCertificateStore,
166
- readPrivateRsaKey,
167
- readPublicRsaKey,
168
- readCertificateRevocationList,
169
- readCertificateSigningRequest,
170
- generatePrivateKeyFile,
171
- generatePrivateKeyFileAlternate
172
- };
173
- //# sourceMappingURL=chunk-2LYR7MB3.mjs.map
@@ -1 +0,0 @@
1
- //# sourceMappingURL=chunk-5NV4OKIV.mjs.map