node-opcua-server-configuration 2.163.1 → 2.164.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/dist/clientTools/certificate_types.d.ts +17 -0
  2. package/dist/clientTools/certificate_types.js +20 -0
  3. package/dist/clientTools/certificate_types.js.map +1 -0
  4. package/dist/clientTools/get_certificate_key_type.d.ts +6 -0
  5. package/dist/clientTools/get_certificate_key_type.js +55 -0
  6. package/dist/clientTools/get_certificate_key_type.js.map +1 -0
  7. package/dist/clientTools/index.d.ts +2 -1
  8. package/dist/clientTools/index.js +2 -17
  9. package/dist/clientTools/index.js.map +1 -1
  10. package/dist/clientTools/push_certificate_management_client.d.ts +10 -10
  11. package/dist/clientTools/push_certificate_management_client.js +85 -89
  12. package/dist/clientTools/push_certificate_management_client.js.map +1 -1
  13. package/dist/index.d.ts +9 -7
  14. package/dist/index.js +9 -23
  15. package/dist/index.js.map +1 -1
  16. package/dist/push_certificate_manager.d.ts +4 -4
  17. package/dist/push_certificate_manager.js +1 -2
  18. package/dist/server/certificate_validation.d.ts +15 -0
  19. package/dist/server/certificate_validation.js +76 -0
  20. package/dist/server/certificate_validation.js.map +1 -0
  21. package/dist/server/file_transaction_manager.d.ts +30 -0
  22. package/dist/server/file_transaction_manager.js +223 -0
  23. package/dist/server/file_transaction_manager.js.map +1 -0
  24. package/dist/server/install_certificate_file_watcher.d.ts +1 -1
  25. package/dist/server/install_certificate_file_watcher.js +8 -14
  26. package/dist/server/install_certificate_file_watcher.js.map +1 -1
  27. package/dist/server/install_push_certitifate_management.d.ts +6 -6
  28. package/dist/server/install_push_certitifate_management.js +61 -65
  29. package/dist/server/install_push_certitifate_management.js.map +1 -1
  30. package/dist/server/promote_trust_list.d.ts +1 -1
  31. package/dist/server/promote_trust_list.js +323 -82
  32. package/dist/server/promote_trust_list.js.map +1 -1
  33. package/dist/server/push_certificate_manager/apply_changes.d.ts +3 -0
  34. package/dist/server/push_certificate_manager/apply_changes.js +59 -0
  35. package/dist/server/push_certificate_manager/apply_changes.js.map +1 -0
  36. package/dist/server/push_certificate_manager/create_signing_request.d.ts +5 -0
  37. package/dist/server/push_certificate_manager/create_signing_request.js +108 -0
  38. package/dist/server/push_certificate_manager/create_signing_request.js.map +1 -0
  39. package/dist/server/push_certificate_manager/get_rejected_list.d.ts +3 -0
  40. package/dist/server/push_certificate_manager/get_rejected_list.js +46 -0
  41. package/dist/server/push_certificate_manager/get_rejected_list.js.map +1 -0
  42. package/dist/server/push_certificate_manager/internal_context.d.ts +35 -0
  43. package/dist/server/push_certificate_manager/internal_context.js +45 -0
  44. package/dist/server/push_certificate_manager/internal_context.js.map +1 -0
  45. package/dist/server/push_certificate_manager/subject_to_string.d.ts +3 -0
  46. package/dist/server/push_certificate_manager/subject_to_string.js +27 -0
  47. package/dist/server/push_certificate_manager/subject_to_string.js.map +1 -0
  48. package/dist/server/push_certificate_manager/update_certificate.d.ts +5 -0
  49. package/dist/server/push_certificate_manager/update_certificate.js +132 -0
  50. package/dist/server/push_certificate_manager/update_certificate.js.map +1 -0
  51. package/dist/server/push_certificate_manager/util.d.ts +29 -0
  52. package/dist/server/push_certificate_manager/util.js +117 -0
  53. package/dist/server/push_certificate_manager/util.js.map +1 -0
  54. package/dist/server/push_certificate_manager_helpers.d.ts +5 -2
  55. package/dist/server/push_certificate_manager_helpers.js +109 -112
  56. package/dist/server/push_certificate_manager_helpers.js.map +1 -1
  57. package/dist/server/push_certificate_manager_server_impl.d.ts +16 -29
  58. package/dist/server/push_certificate_manager_server_impl.js +49 -437
  59. package/dist/server/push_certificate_manager_server_impl.js.map +1 -1
  60. package/dist/server/roles_and_permissions.d.ts +1 -1
  61. package/dist/server/roles_and_permissions.js +24 -27
  62. package/dist/server/roles_and_permissions.js.map +1 -1
  63. package/dist/server/tools.d.ts +1 -1
  64. package/dist/server/tools.js +7 -13
  65. package/dist/server/tools.js.map +1 -1
  66. package/dist/server/trust_list_server.d.ts +2 -2
  67. package/dist/server/trust_list_server.js +40 -29
  68. package/dist/server/trust_list_server.js.map +1 -1
  69. package/dist/standard_certificate_types.js +6 -9
  70. package/dist/standard_certificate_types.js.map +1 -1
  71. package/dist/trust_list.d.ts +2 -2
  72. package/dist/trust_list.js +1 -2
  73. package/dist/trust_list_impl.js +1 -2
  74. package/dist/trust_list_impl.js.map +1 -1
  75. package/package.json +29 -30
  76. package/source/clientTools/certificate_types.ts +21 -0
  77. package/source/clientTools/get_certificate_key_type.ts +73 -0
  78. package/source/clientTools/index.ts +2 -1
  79. package/source/clientTools/push_certificate_management_client.ts +49 -44
  80. package/source/index.ts +9 -7
  81. package/source/push_certificate_manager.ts +15 -17
  82. package/source/server/certificate_validation.ts +103 -0
  83. package/source/server/file_transaction_manager.ts +253 -0
  84. package/source/server/install_certificate_file_watcher.ts +15 -11
  85. package/source/server/install_push_certitifate_management.ts +52 -51
  86. package/source/server/promote_trust_list.ts +362 -73
  87. package/source/server/push_certificate_manager/apply_changes.ts +63 -0
  88. package/source/server/push_certificate_manager/create_signing_request.ts +137 -0
  89. package/source/server/push_certificate_manager/get_rejected_list.ts +63 -0
  90. package/source/server/push_certificate_manager/internal_context.ts +63 -0
  91. package/source/server/push_certificate_manager/subject_to_string.ts +25 -0
  92. package/source/server/push_certificate_manager/update_certificate.ts +201 -0
  93. package/source/server/push_certificate_manager/util.ts +145 -0
  94. package/source/server/push_certificate_manager_helpers.ts +61 -51
  95. package/source/server/push_certificate_manager_server_impl.ts +94 -553
  96. package/source/server/roles_and_permissions.ts +7 -8
  97. package/source/server/tools.ts +2 -5
  98. package/source/server/trust_list_server.ts +24 -9
  99. package/source/standard_certificate_types.ts +2 -3
  100. package/source/trust_list.ts +26 -33
@@ -1,15 +1,14 @@
1
- import { PermissionType, RolePermissionTypeOptions, WellKnownRoles } from "node-opcua-address-space";
2
- import { makePermissionFlag, allPermissions } from "node-opcua-data-model";
1
+ import { PermissionType, type RolePermissionTypeOptions, WellKnownRoles } from "node-opcua-address-space";
2
+ import { allPermissions, makePermissionFlag } from "node-opcua-data-model";
3
3
 
4
4
  export const rolePermissionRestricted: RolePermissionTypeOptions[] = [
5
-
6
5
  {
7
6
  roleId: WellKnownRoles.Anonymous,
8
- permissions: PermissionType.Browse,
7
+ permissions: PermissionType.Browse
9
8
  },
10
9
  {
11
10
  roleId: WellKnownRoles.AuthenticatedUser,
12
- permissions: PermissionType.Browse,
11
+ permissions: PermissionType.Browse
13
12
  },
14
13
  {
15
14
  roleId: WellKnownRoles.ConfigureAdmin,
@@ -18,14 +17,14 @@ export const rolePermissionRestricted: RolePermissionTypeOptions[] = [
18
17
  {
19
18
  roleId: WellKnownRoles.SecurityAdmin,
20
19
  permissions: allPermissions
21
- },
20
+ }
22
21
  ];
23
22
  export const rolePermissionAdminOnly: RolePermissionTypeOptions[] = [
24
23
  {
25
24
  roleId: WellKnownRoles.SecurityAdmin,
26
25
  permissions: allPermissions
27
- },
28
- /* {
26
+ }
27
+ /* {
29
28
  roleId: WellKnownRoles.Anonymous,
30
29
  permissions: PermissionType.Browse
31
30
  },
@@ -1,10 +1,8 @@
1
- import { ISessionContext, WellKnownRoles } from "node-opcua-address-space";
1
+ import { type ISessionContext, WellKnownRoles } from "node-opcua-address-space";
2
2
  import { MessageSecurityMode } from "node-opcua-secure-channel";
3
3
 
4
4
  export function hasExpectedUserAccess(context: ISessionContext) {
5
- if (!context ||
6
- !context.session ||
7
- !context.session.userIdentityToken) {
5
+ if (!context || !context.session || !context.session.userIdentityToken) {
8
6
  return false;
9
7
  }
10
8
  return context.currentUserHasRole(WellKnownRoles.SecurityAdmin);
@@ -13,4 +11,3 @@ export function hasExpectedUserAccess(context: ISessionContext) {
13
11
  export function hasEncryptedChannel(context: ISessionContext) {
14
12
  return !!(context.session?.channel?.securityMode === MessageSecurityMode.SignAndEncrypt);
15
13
  }
16
-
@@ -1,12 +1,11 @@
1
- import fs from "fs";
2
- import path from "path";
3
-
4
- import { OPCUACertificateManager } from "node-opcua-certificate-manager";
5
- import { TrustListDataType } from "node-opcua-types";
6
- import { AbstractFs } from "node-opcua-file-transfer";
1
+ import fs from "node:fs";
2
+ import path from "node:path";
7
3
  import { BinaryStream } from "node-opcua-binary-stream";
4
+ import type { OPCUACertificateManager } from "node-opcua-certificate-manager";
8
5
  import { readCertificate, readCertificateRevocationList } from "node-opcua-crypto";
9
6
  import { make_errorLog } from "node-opcua-debug";
7
+ import type { AbstractFs } from "node-opcua-file-transfer";
8
+ import { TrustListDataType } from "node-opcua-types";
10
9
 
11
10
  const errorLog = make_errorLog("TrustListServer");
12
11
 
@@ -20,6 +19,7 @@ async function readAll(folder: string): Promise<Buffer[]> {
20
19
  const buf = await readCertificate(file);
21
20
  results.push(buf);
22
21
  } else if (ext === ".crl") {
22
+ // Strict validation: only accept valid CRL files
23
23
  const buf = await readCertificateRevocationList(file);
24
24
  results.push(buf);
25
25
  } else {
@@ -53,13 +53,28 @@ export async function buildTrustList(
53
53
  trustList.trustedCertificates = await readAll(certificateManager.trustedFolder);
54
54
  }
55
55
  if ((trustListFlag & TrustListMasks.TrustedCrls) === TrustListMasks.TrustedCrls) {
56
- trustList.trustedCrls = await readAll(certificateManager.crlFolder);
56
+ const crlFolder = certificateManager.crlFolder;
57
+ if (fs.existsSync(crlFolder)) {
58
+ trustList.trustedCrls = await readAll(crlFolder);
59
+ } else {
60
+ trustList.trustedCrls = [];
61
+ }
57
62
  }
58
63
  if ((trustListFlag & TrustListMasks.IssuerCertificates) === TrustListMasks.IssuerCertificates) {
59
- trustList.issuerCertificates = await readAll(certificateManager.issuersCertFolder);
64
+ const issuersCertFolder = certificateManager.issuersCertFolder;
65
+ if (fs.existsSync(issuersCertFolder)) {
66
+ trustList.issuerCertificates = await readAll(issuersCertFolder);
67
+ } else {
68
+ trustList.issuerCertificates = [];
69
+ }
60
70
  }
61
71
  if ((trustListFlag & TrustListMasks.IssuerCrls) === TrustListMasks.IssuerCrls) {
62
- trustList.issuerCrls = await readAll(certificateManager.issuersCrlFolder);
72
+ const issuersCrlFolder = certificateManager.issuersCrlFolder;
73
+ if (fs.existsSync(issuersCrlFolder)) {
74
+ trustList.issuerCrls = await readAll(issuersCrlFolder);
75
+ } else {
76
+ trustList.issuerCrls = [];
77
+ }
63
78
  }
64
79
  return trustList;
65
80
  }
@@ -3,10 +3,9 @@
3
3
  */
4
4
  import { resolveNodeId } from "node-opcua-nodeid";
5
5
 
6
- export const CertificateType = {
6
+ export const CertificateType = {
7
7
  Application: resolveNodeId("ApplicationCertificateType"),
8
8
  Https: resolveNodeId("HttpsCertificateType"),
9
9
  RsaMinApplication: resolveNodeId("RsaMinApplicationCertificateType"),
10
- RsaSha256Application: resolveNodeId("RsaSha256ApplicationCertificateType"),
10
+ RsaSha256Application: resolveNodeId("RsaSha256ApplicationCertificateType")
11
11
  };
12
-
@@ -1,26 +1,25 @@
1
- import { StatusCode } from "node-opcua-status-code";
1
+ import type { StatusCode } from "node-opcua-status-code";
2
2
 
3
3
  /**
4
4
  * @module node-opcua-server-configuration
5
5
  */
6
6
  export interface ITrustList {
7
-
8
7
  /**
9
8
  * The CloseAndUpdate Method closes the file and applies the changes to the Trust List. It can
10
9
  * only be called if the file was opened for writing. If the Close Method is called any cached data
11
10
  * is discarded and the Trust List is not changed.
12
- *
11
+ *
13
12
  * The Server shall verify that every Certificate in the new Trust List is valid according to the
14
13
  * mandatory rules defined in Part 4. If an invalid Certificate is found the Server shall return an
15
14
  * error and shall not update the Trust List. If only part of the Trust List is being updated the
16
15
  * Server creates a temporary Trust List that includes the existing Trust List plus any updates
17
16
  * and validates the temporary Trust List.
18
- *
17
+ *
19
18
  * If the file cannot be processed this Method still closes the file and discards the data before
20
19
  * returning an error. This Method is required if the Server supports updates to the Trust List.
21
20
  * The structure uploaded includes a mask (see 7.5.8) which specifies which fields are updated.
22
21
  * If a bit is not set then the associated field is not changed.
23
- *
22
+ *
24
23
  * @param fileHandle UInt32 - The handle of the previously opened file
25
24
  * @return applyChangesRequired - A flag indicating whether the ApplyChanges Method (see 7.7.5) shall be called
26
25
  * before the new Trust List will be used by the Server.
@@ -31,46 +30,43 @@ export interface ITrustList {
31
30
  * error.
32
31
  */
33
32
  closeAndUpdate(
34
- // fileHandle: UInt32,
35
- applyChangesRequired: boolean
33
+ // fileHandle: UInt32,
34
+ applyChangesRequired: boolean
36
35
  ): Promise<boolean>;
37
36
 
38
37
  /**
39
- * The AddCertificate Method allows a Client to add a single Certificate to the Trust List.
40
- *
38
+ * The AddCertificate Method allows a Client to add a single Certificate to the Trust List.
39
+ *
41
40
  * The Server shall verify that the Certificate is valid according to the rules defined in Part 4.
42
- *
41
+ *
43
42
  * If an invalid Certificate is found the Server shall return an error and shall not update the Trust List.
44
- *
43
+ *
45
44
  * If the Certificate is issued by a CA then the Client shall provide the entire chain in the
46
- * certificate argument (see Part 6).
47
- *
48
- * After validating the Certificate, the Server shall add the CA Certificates to the Issuers list in the Trust List.
49
- *
45
+ * certificate argument (see Part 6).
46
+ *
47
+ * After validating the Certificate, the Server shall add the CA Certificates to the Issuers list in the Trust List.
48
+ *
50
49
  * The leaf Certificate is added to the list specified by the isTrustedCertificate argument.
51
- *
50
+ *
52
51
  * This method cannot be called if the file object is open
53
52
  * @param certificate - The DER encoded Certificate to add as a ByteStrng
54
- * @param isTrustedCertificate - If TRUE the Certificate is added to the Trusted Certificates List. If FALSE the Certificate is added to the Issuer Certificates List.
53
+ * @param isTrustedCerticopy ficate - If TRUE the Certificate is added to the Trusted Certificates List. If FALSE the Certificate is added to the Issuer Certificates List.
55
54
  *
56
- * **Result Code**
55
+ * **Result Code**
57
56
  * - BadUserAccessDenied: The current user does not have the rights required.
58
57
  * - BadCertificateInvalid: The certificate to add is invalid.
59
58
  * - BadInvalidState: The object is opened.
60
- *
59
+ *
61
60
  */
62
- addCertificate(
63
- certificate: Buffer,
64
- isTrustedCertificate: boolean
65
- ): Promise<StatusCode>;
61
+ addCertificate(certificate: Buffer, isTrustedCertificate: boolean): Promise<StatusCode>;
66
62
 
67
63
  /**
68
- * The RemoveCertificate Method allows a Client to remove a single Certificate from the Trust List.
69
- *
64
+ * The RemoveCertificate Method allows a Client to remove a single Certificate from the Trust List.
65
+ *
70
66
  * It returns BadInvalidArgument if the thumbprint does not match a Certificate in the Trust List.
71
- *
67
+ *
72
68
  * If the Certificate is a CA Certificate with associated CRLs then all CRLs are removed as well.
73
- *
69
+ *
74
70
  * This method cannot be called if the file object is open.
75
71
  *
76
72
  * @param thumbprint - The SHA1 hash of the Certificate to remove
@@ -81,11 +77,8 @@ export interface ITrustList {
81
77
  * -BadUserAccessDenied: The current user does not have the rights required.
82
78
  * -BadInvalidArgument: The certificate to remove was not found.
83
79
  * -BadInvalidState: The object is opened.
84
- *
85
- *
80
+ *
81
+ *
86
82
  */
87
- removeCertificate(
88
- thumbprint: string,
89
- isTrustedCertificate: boolean
90
- ): Promise<StatusCode>;
83
+ removeCertificate(thumbprint: string, isTrustedCertificate: boolean): Promise<StatusCode>;
91
84
  }