node-opcua-server 2.74.0 → 2.76.1

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 (69) hide show
  1. package/dist/base_server.d.ts +110 -110
  2. package/dist/base_server.js +473 -473
  3. package/dist/factory.d.ts +12 -12
  4. package/dist/factory.js +23 -23
  5. package/dist/filter/check_where_clause_on_address_space.d.ts +3 -0
  6. package/dist/filter/check_where_clause_on_address_space.js +23 -0
  7. package/dist/filter/check_where_clause_on_address_space.js.map +1 -0
  8. package/dist/filter/extract_event_fields.d.ts +10 -0
  9. package/dist/filter/extract_event_fields.js +18 -0
  10. package/dist/filter/extract_event_fields.js.map +1 -0
  11. package/dist/helper.d.ts +10 -10
  12. package/dist/helper.js +75 -75
  13. package/dist/history_server_capabilities.d.ts +35 -35
  14. package/dist/history_server_capabilities.js +43 -43
  15. package/dist/i_channel_data.d.ts +13 -13
  16. package/dist/i_channel_data.js +2 -2
  17. package/dist/i_register_server_manager.d.ts +16 -16
  18. package/dist/i_register_server_manager.js +2 -2
  19. package/dist/i_server_side_publish_engine.d.ts +36 -36
  20. package/dist/i_server_side_publish_engine.js +49 -49
  21. package/dist/i_socket_data.d.ts +11 -11
  22. package/dist/i_socket_data.js +2 -2
  23. package/dist/index.d.ts +16 -16
  24. package/dist/index.js +32 -32
  25. package/dist/monitored_item.d.ts +177 -177
  26. package/dist/monitored_item.js +1001 -999
  27. package/dist/monitored_item.js.map +1 -1
  28. package/dist/node_sampler.d.ts +3 -3
  29. package/dist/node_sampler.js +75 -75
  30. package/dist/opcua_server.d.ts +747 -650
  31. package/dist/opcua_server.js +2431 -2396
  32. package/dist/opcua_server.js.map +1 -1
  33. package/dist/queue.d.ts +11 -11
  34. package/dist/queue.js +71 -71
  35. package/dist/register_server_manager.d.ts +96 -96
  36. package/dist/register_server_manager.js +584 -584
  37. package/dist/register_server_manager_hidden.d.ts +17 -17
  38. package/dist/register_server_manager_hidden.js +27 -27
  39. package/dist/register_server_manager_mdns_only.d.ts +22 -22
  40. package/dist/register_server_manager_mdns_only.js +55 -55
  41. package/dist/server_capabilities.d.ts +148 -148
  42. package/dist/server_capabilities.js +92 -92
  43. package/dist/server_end_point.d.ts +183 -183
  44. package/dist/server_end_point.js +817 -817
  45. package/dist/server_engine.d.ts +317 -317
  46. package/dist/server_engine.js +1716 -1716
  47. package/dist/server_publish_engine.d.ts +113 -113
  48. package/dist/server_publish_engine.js +541 -541
  49. package/dist/server_publish_engine_for_orphan_subscriptions.d.ts +16 -16
  50. package/dist/server_publish_engine_for_orphan_subscriptions.js +51 -51
  51. package/dist/server_session.d.ts +182 -182
  52. package/dist/server_session.js +739 -739
  53. package/dist/server_subscription.d.ts +421 -421
  54. package/dist/server_subscription.js +1346 -1347
  55. package/dist/server_subscription.js.map +1 -1
  56. package/dist/sessions_compatible_for_transfer.d.ts +2 -2
  57. package/dist/sessions_compatible_for_transfer.js +39 -39
  58. package/dist/user_manager.d.ts +32 -32
  59. package/dist/user_manager.js +74 -74
  60. package/dist/user_manager_ua.d.ts +3 -3
  61. package/dist/user_manager_ua.js +39 -39
  62. package/dist/validate_filter.d.ts +5 -5
  63. package/dist/validate_filter.js +60 -60
  64. package/package.json +47 -48
  65. package/source/filter/check_where_clause_on_address_space.ts +29 -0
  66. package/source/filter/extract_event_fields.ts +21 -0
  67. package/source/monitored_item.ts +5 -11
  68. package/source/opcua_server.ts +154 -14
  69. package/source/server_subscription.ts +2 -4
@@ -1,61 +1,61 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.validateFilter = void 0;
4
- /**
5
- * @module node-opcua-server
6
- */
7
- const node_opcua_assert_1 = require("node-opcua-assert");
8
- const node_opcua_data_model_1 = require("node-opcua-data-model");
9
- const node_opcua_data_model_2 = require("node-opcua-data-model");
10
- const node_opcua_nodeid_1 = require("node-opcua-nodeid");
11
- const node_opcua_service_filter_1 = require("node-opcua-service-filter");
12
- const node_opcua_service_subscription_1 = require("node-opcua-service-subscription");
13
- const node_opcua_status_code_1 = require("node-opcua-status-code");
14
- function __validateDataChangeFilter(filter, itemToMonitor, node) {
15
- (0, node_opcua_assert_1.assert)(itemToMonitor.attributeId === node_opcua_data_model_1.AttributeIds.Value);
16
- if (node.nodeClass !== node_opcua_data_model_2.NodeClass.Variable) {
17
- return node_opcua_status_code_1.StatusCodes.BadNodeIdInvalid;
18
- }
19
- (0, node_opcua_assert_1.assert)(node.nodeClass === node_opcua_data_model_2.NodeClass.Variable);
20
- // if node is not Numerical=> DataChangeFilter
21
- (0, node_opcua_assert_1.assert)(node.dataType instanceof node_opcua_nodeid_1.NodeId);
22
- const dataType = node.addressSpace.findDataType(node.dataType);
23
- const dataTypeNumber = node.addressSpace.findDataType("Number");
24
- if (filter.deadbandType !== node_opcua_service_subscription_1.DeadbandType.None) {
25
- if (!dataType.isSupertypeOf(dataTypeNumber)) {
26
- return node_opcua_status_code_1.StatusCodes.BadFilterNotAllowed;
27
- }
28
- }
29
- if (filter.deadbandType === node_opcua_service_subscription_1.DeadbandType.Percent) {
30
- if (filter.deadbandValue < 0 || filter.deadbandValue > 100) {
31
- return node_opcua_status_code_1.StatusCodes.BadDeadbandFilterInvalid;
32
- }
33
- // node must also have a valid euRange
34
- if (!node.euRange) {
35
- // tslint:disable:no-console
36
- console.log(" node has no euRange ! Dead band Percent cannot be used on node " + node.nodeId.toString());
37
- return node_opcua_status_code_1.StatusCodes.BadMonitoredItemFilterUnsupported;
38
- }
39
- }
40
- return node_opcua_status_code_1.StatusCodes.Good;
41
- }
42
- function validateFilter(filter, itemToMonitor, node) {
43
- // handle filter information
44
- if (filter && filter instanceof node_opcua_service_filter_1.EventFilter && itemToMonitor.attributeId !== node_opcua_data_model_1.AttributeIds.EventNotifier) {
45
- // invalid filter on Event
46
- return node_opcua_status_code_1.StatusCodes.BadFilterNotAllowed;
47
- }
48
- if (filter && filter instanceof node_opcua_service_filter_1.DataChangeFilter && itemToMonitor.attributeId !== node_opcua_data_model_1.AttributeIds.Value) {
49
- // invalid DataChange filter on non Value Attribute
50
- return node_opcua_status_code_1.StatusCodes.BadFilterNotAllowed;
51
- }
52
- if (filter && itemToMonitor.attributeId !== node_opcua_data_model_1.AttributeIds.EventNotifier && itemToMonitor.attributeId !== node_opcua_data_model_1.AttributeIds.Value) {
53
- return node_opcua_status_code_1.StatusCodes.BadFilterNotAllowed;
54
- }
55
- if (filter instanceof node_opcua_service_filter_1.DataChangeFilter) {
56
- return __validateDataChangeFilter(filter, itemToMonitor, node);
57
- }
58
- return node_opcua_status_code_1.StatusCodes.Good;
59
- }
60
- exports.validateFilter = validateFilter;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validateFilter = void 0;
4
+ /**
5
+ * @module node-opcua-server
6
+ */
7
+ const node_opcua_assert_1 = require("node-opcua-assert");
8
+ const node_opcua_data_model_1 = require("node-opcua-data-model");
9
+ const node_opcua_data_model_2 = require("node-opcua-data-model");
10
+ const node_opcua_nodeid_1 = require("node-opcua-nodeid");
11
+ const node_opcua_service_filter_1 = require("node-opcua-service-filter");
12
+ const node_opcua_service_subscription_1 = require("node-opcua-service-subscription");
13
+ const node_opcua_status_code_1 = require("node-opcua-status-code");
14
+ function __validateDataChangeFilter(filter, itemToMonitor, node) {
15
+ (0, node_opcua_assert_1.assert)(itemToMonitor.attributeId === node_opcua_data_model_1.AttributeIds.Value);
16
+ if (node.nodeClass !== node_opcua_data_model_2.NodeClass.Variable) {
17
+ return node_opcua_status_code_1.StatusCodes.BadNodeIdInvalid;
18
+ }
19
+ (0, node_opcua_assert_1.assert)(node.nodeClass === node_opcua_data_model_2.NodeClass.Variable);
20
+ // if node is not Numerical=> DataChangeFilter
21
+ (0, node_opcua_assert_1.assert)(node.dataType instanceof node_opcua_nodeid_1.NodeId);
22
+ const dataType = node.addressSpace.findDataType(node.dataType);
23
+ const dataTypeNumber = node.addressSpace.findDataType("Number");
24
+ if (filter.deadbandType !== node_opcua_service_subscription_1.DeadbandType.None) {
25
+ if (!dataType.isSupertypeOf(dataTypeNumber)) {
26
+ return node_opcua_status_code_1.StatusCodes.BadFilterNotAllowed;
27
+ }
28
+ }
29
+ if (filter.deadbandType === node_opcua_service_subscription_1.DeadbandType.Percent) {
30
+ if (filter.deadbandValue < 0 || filter.deadbandValue > 100) {
31
+ return node_opcua_status_code_1.StatusCodes.BadDeadbandFilterInvalid;
32
+ }
33
+ // node must also have a valid euRange
34
+ if (!node.euRange) {
35
+ // tslint:disable:no-console
36
+ console.log(" node has no euRange ! Dead band Percent cannot be used on node " + node.nodeId.toString());
37
+ return node_opcua_status_code_1.StatusCodes.BadMonitoredItemFilterUnsupported;
38
+ }
39
+ }
40
+ return node_opcua_status_code_1.StatusCodes.Good;
41
+ }
42
+ function validateFilter(filter, itemToMonitor, node) {
43
+ // handle filter information
44
+ if (filter && filter instanceof node_opcua_service_filter_1.EventFilter && itemToMonitor.attributeId !== node_opcua_data_model_1.AttributeIds.EventNotifier) {
45
+ // invalid filter on Event
46
+ return node_opcua_status_code_1.StatusCodes.BadFilterNotAllowed;
47
+ }
48
+ if (filter && filter instanceof node_opcua_service_filter_1.DataChangeFilter && itemToMonitor.attributeId !== node_opcua_data_model_1.AttributeIds.Value) {
49
+ // invalid DataChange filter on non Value Attribute
50
+ return node_opcua_status_code_1.StatusCodes.BadFilterNotAllowed;
51
+ }
52
+ if (filter && itemToMonitor.attributeId !== node_opcua_data_model_1.AttributeIds.EventNotifier && itemToMonitor.attributeId !== node_opcua_data_model_1.AttributeIds.Value) {
53
+ return node_opcua_status_code_1.StatusCodes.BadFilterNotAllowed;
54
+ }
55
+ if (filter instanceof node_opcua_service_filter_1.DataChangeFilter) {
56
+ return __validateDataChangeFilter(filter, itemToMonitor, node);
57
+ }
58
+ return node_opcua_status_code_1.StatusCodes.Good;
59
+ }
60
+ exports.validateFilter = validateFilter;
61
61
  //# sourceMappingURL=validate_filter.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-opcua-server",
3
- "version": "2.74.0",
3
+ "version": "2.76.1",
4
4
  "description": "pure nodejs OPCUA SDK - module -server",
5
5
  "scripts": {
6
6
  "build": "tsc -b",
@@ -13,62 +13,61 @@
13
13
  "types": "./dist/index.d.ts",
14
14
  "dependencies": {
15
15
  "@ster5/global-mutex": "^1.2.0",
16
- "@types/underscore": "^1.11.4",
17
16
  "async": "^3.2.4",
17
+ "chalk": "4.1.2",
18
18
  "dequeue": "^1.0.5",
19
19
  "lodash": "4.17.21",
20
- "node-opcua-address-space": "2.74.0",
21
- "node-opcua-assert": "2.74.0",
22
- "node-opcua-basic-types": "2.74.0",
23
- "node-opcua-binary-stream": "2.74.0",
24
- "node-opcua-certificate-manager": "2.74.0",
25
- "node-opcua-client": "2.74.0",
26
- "node-opcua-client-dynamic-extension-object": "2.74.0",
27
- "node-opcua-common": "2.74.0",
20
+ "node-opcua-address-space": "2.76.1",
21
+ "node-opcua-address-space-base": "2.76.0",
22
+ "node-opcua-assert": "2.76.0",
23
+ "node-opcua-basic-types": "2.76.0",
24
+ "node-opcua-binary-stream": "2.76.0",
25
+ "node-opcua-certificate-manager": "2.76.0",
26
+ "node-opcua-client": "2.76.1",
27
+ "node-opcua-client-dynamic-extension-object": "2.76.0",
28
+ "node-opcua-common": "2.76.0",
28
29
  "node-opcua-constants": "2.74.0",
29
30
  "node-opcua-crypto": "^1.11.0",
30
- "node-opcua-data-access": "2.74.0",
31
- "node-opcua-data-model": "2.74.0",
32
- "node-opcua-data-value": "2.74.0",
33
- "node-opcua-date-time": "2.74.0",
34
- "node-opcua-debug": "2.74.0",
35
- "node-opcua-enum": "2.74.0",
36
- "node-opcua-extension-object": "2.74.0",
37
- "node-opcua-factory": "2.74.0",
38
- "node-opcua-hostname": "2.74.0",
39
- "node-opcua-nodeid": "2.74.0",
40
- "node-opcua-nodeset-ua": "2.74.0",
31
+ "node-opcua-data-access": "2.76.0",
32
+ "node-opcua-data-model": "2.76.0",
33
+ "node-opcua-data-value": "2.76.0",
34
+ "node-opcua-date-time": "2.76.0",
35
+ "node-opcua-debug": "2.76.0",
36
+ "node-opcua-extension-object": "2.76.0",
37
+ "node-opcua-factory": "2.76.0",
38
+ "node-opcua-hostname": "2.76.0",
39
+ "node-opcua-nodeid": "2.76.0",
41
40
  "node-opcua-nodesets": "2.74.0",
42
- "node-opcua-numeric-range": "2.74.0",
43
- "node-opcua-object-registry": "2.74.0",
44
- "node-opcua-pki": "^2.17.0",
45
- "node-opcua-secure-channel": "2.74.0",
46
- "node-opcua-service-browse": "2.74.0",
47
- "node-opcua-service-call": "2.74.0",
48
- "node-opcua-service-discovery": "2.74.0",
49
- "node-opcua-service-endpoints": "2.74.0",
50
- "node-opcua-service-filter": "2.74.0",
51
- "node-opcua-service-history": "2.74.0",
52
- "node-opcua-service-node-management": "2.74.0",
53
- "node-opcua-service-query": "2.74.0",
54
- "node-opcua-service-read": "2.74.0",
55
- "node-opcua-service-register-node": "2.74.0",
56
- "node-opcua-service-secure-channel": "2.74.0",
57
- "node-opcua-service-session": "2.74.0",
58
- "node-opcua-service-subscription": "2.74.0",
59
- "node-opcua-service-translate-browse-path": "2.74.0",
60
- "node-opcua-service-write": "2.74.0",
61
- "node-opcua-status-code": "2.74.0",
62
- "node-opcua-transport": "2.74.0",
63
- "node-opcua-types": "2.74.0",
64
- "node-opcua-utils": "2.74.0",
65
- "node-opcua-variant": "2.74.0"
41
+ "node-opcua-numeric-range": "2.76.0",
42
+ "node-opcua-object-registry": "2.76.0",
43
+ "node-opcua-secure-channel": "2.76.0",
44
+ "node-opcua-service-browse": "2.76.0",
45
+ "node-opcua-service-call": "2.76.0",
46
+ "node-opcua-service-discovery": "2.76.0",
47
+ "node-opcua-service-endpoints": "2.76.0",
48
+ "node-opcua-service-filter": "2.76.0",
49
+ "node-opcua-service-history": "2.76.0",
50
+ "node-opcua-service-node-management": "2.76.0",
51
+ "node-opcua-service-query": "2.76.0",
52
+ "node-opcua-service-read": "2.76.0",
53
+ "node-opcua-service-register-node": "2.76.0",
54
+ "node-opcua-service-secure-channel": "2.76.0",
55
+ "node-opcua-service-session": "2.76.0",
56
+ "node-opcua-service-subscription": "2.76.0",
57
+ "node-opcua-service-translate-browse-path": "2.76.0",
58
+ "node-opcua-service-write": "2.76.0",
59
+ "node-opcua-status-code": "2.76.0",
60
+ "node-opcua-types": "2.76.0",
61
+ "node-opcua-utils": "2.76.0",
62
+ "node-opcua-variant": "2.76.0",
63
+ "thenify": "^3.3.1"
66
64
  },
67
65
  "devDependencies": {
68
- "node-opcua-leak-detector": "2.74.0",
66
+ "node-opcua-leak-detector": "2.76.0",
69
67
  "node-opcua-test-helpers": "2.74.0",
70
68
  "should": "^13.2.3",
71
- "sinon": "^14.0.0"
69
+ "sinon": "^14.0.0",
70
+ "underscore": "^1.13.4"
72
71
  },
73
72
  "author": "Etienne Rossignon",
74
73
  "license": "MIT",
@@ -85,5 +84,5 @@
85
84
  "internet of things"
86
85
  ],
87
86
  "homepage": "http://node-opcua.github.io/",
88
- "gitHead": "003ee041795f3b737afaaef5721045ee31ea9f77"
87
+ "gitHead": "d87d1dc4ab8f153a442f83552e3264621f0a409b"
89
88
  }
@@ -0,0 +1,29 @@
1
+ import { IAddressSpace, ISessionContext, IEventData } from "node-opcua-address-space-base";
2
+ import { checkFilter } from "node-opcua-service-filter";
3
+ import { FilterContextOnAddressSpace } from "node-opcua-service-filter";
4
+ import { ContentFilter } from "node-opcua-types";
5
+
6
+ export function checkWhereClauseOnAdressSpace(
7
+ addressSpace: IAddressSpace,
8
+ sessionContext: ISessionContext,
9
+ whereClause: ContentFilter,
10
+ eventData: IEventData
11
+ ): boolean {
12
+
13
+
14
+ // const filterContext: FilterContext = {
15
+ // addressSpace,
16
+ // sessionContext,
17
+ // rootNode: eventData.$eventDataSource!,
18
+ // extractValue(operand: FilterOperand) {
19
+ // if (operand instanceof SimpleAttributeOperand) {
20
+ // return extractEventFields(filterContext.sessionContext, [operand], eventData)[0];
21
+ // } else {
22
+ // return new Variant({ dataType: DataType.Null });
23
+ // }
24
+ // }
25
+ // };
26
+ const filterContext = new FilterContextOnAddressSpace(sessionContext, eventData);
27
+
28
+ return checkFilter(filterContext, whereClause);
29
+ }
@@ -0,0 +1,21 @@
1
+ import { IEventData, ISessionContext } from "node-opcua-address-space-base";
2
+ import { extractEventFieldsBase } from "node-opcua-service-filter";
3
+ import { FilterContextOnAddressSpace } from "node-opcua-service-filter";
4
+ import { SimpleAttributeOperand } from "node-opcua-types";
5
+ import { Variant } from "node-opcua-variant";
6
+ //
7
+
8
+ /**
9
+ * @method extractEventFields
10
+ * extract a array of eventFields from a event node, matching the selectClauses
11
+ * @param selectClauses
12
+ * @param eventData : a pseudo Node that provides a browse Method and a readValue(nodeId)
13
+ */
14
+ export function extractEventFields(
15
+ sessionContext: ISessionContext,
16
+ selectClauses: SimpleAttributeOperand[],
17
+ eventData: IEventData
18
+ ): Variant[] {
19
+ const context = new FilterContextOnAddressSpace(sessionContext, eventData);
20
+ return extractEventFieldsBase(context, selectClauses);
21
+ }
@@ -4,16 +4,9 @@
4
4
  import { EventEmitter } from "events";
5
5
  import * as chalk from "chalk";
6
6
  import { assert } from "node-opcua-assert";
7
- import {
8
- BaseNode,
9
- IEventData,
10
- extractEventFields,
11
- makeAttributeEventName,
12
- SessionContext,
13
- UAVariable,
14
- checkWhereClause,
15
- AddressSpace
16
- } from "node-opcua-address-space";
7
+ import { BaseNode, IEventData, makeAttributeEventName, SessionContext, UAVariable, AddressSpace } from "node-opcua-address-space";
8
+
9
+ import { extractEventFields } from "node-opcua-service-filter";
17
10
  import { DateTime, UInt32 } from "node-opcua-basic-types";
18
11
  import { NodeClass, QualifiedNameOptions } from "node-opcua-data-model";
19
12
  import { AttributeIds } from "node-opcua-data-model";
@@ -61,6 +54,7 @@ import { sameVariant, Variant } from "node-opcua-variant";
61
54
 
62
55
  import { appendToTimer, removeFromTimer } from "./node_sampler";
63
56
  import { validateFilter } from "./validate_filter";
57
+ import { checkWhereClauseOnAdressSpace } from "./filter/check_where_clause_on_address_space";
64
58
 
65
59
  export type QueueItem = MonitoredItemNotification | EventFieldList;
66
60
 
@@ -925,7 +919,7 @@ export class MonitoredItem extends EventEmitter {
925
919
 
926
920
  const addressSpace: AddressSpace = eventData.$eventDataSource?.addressSpace as AddressSpace;
927
921
 
928
- if (!checkWhereClause(addressSpace, SessionContext.defaultContext, this.filter.whereClause, eventData)) {
922
+ if (!checkWhereClauseOnAdressSpace(addressSpace, SessionContext.defaultContext, this.filter.whereClause, eventData)) {
929
923
  return;
930
924
  }
931
925
 
@@ -1,3 +1,4 @@
1
+ /* eslint-disable complexity */
1
2
  /**
2
3
  * @module node-opcua-server
3
4
  */
@@ -38,7 +39,8 @@ import {
38
39
  ISessionContext,
39
40
  UAView,
40
41
  EventTypeLike,
41
- UAObjectType
42
+ UAObjectType,
43
+ PseudoVariantStringPredefined
42
44
  } from "node-opcua-address-space";
43
45
  import { getDefaultCertificateManager, OPCUACertificateManager } from "node-opcua-certificate-manager";
44
46
  import { ServerState } from "node-opcua-common";
@@ -146,13 +148,15 @@ import {
146
148
  MonitoredItemCreateResult,
147
149
  IssuedIdentityToken,
148
150
  BrowseResultOptions,
149
- ServiceFault
151
+ ServiceFault,
152
+ ServerDiagnosticsSummaryDataType
150
153
  } from "node-opcua-types";
151
154
  import { DataType } from "node-opcua-variant";
152
155
  import { VariantArrayType } from "node-opcua-variant";
153
156
  import { matchUri } from "node-opcua-utils";
154
157
 
155
158
  import { UAString } from "node-opcua-basic-types";
159
+ import { ObjectIds, ObjectTypeIds } from "node-opcua-constants";
156
160
  import { OPCUABaseServer, OPCUABaseServerOptions } from "./base_server";
157
161
  import { Factory } from "./factory";
158
162
  import { IRegisterServerManager } from "./i_register_server_manager";
@@ -262,11 +266,8 @@ async function _attempt_to_close_some_old_unactivated_session(server: OPCUAServe
262
266
 
263
267
  function getRequiredEndpointInfo(endpoint: EndpointDescription) {
264
268
  assert(endpoint instanceof EndpointDescription);
265
- // It is recommended that Servers only include the server.applicationUri, endpointUrl, securityMode,
266
- // securityPolicyUri, userIdentityTokens, transportProfileUri and securityLevel with all
267
- // other parameters set to null. Only the recommended parameters shall be verified by
268
- // the client.
269
-
269
+ // https://reference.opcfoundation.org/v104/Core/docs/Part4/5.6.2/
270
+ // https://reference.opcfoundation.org/v105/Core/docs/Part4/5.6.2/
270
271
  const e = new EndpointDescription({
271
272
  endpointUrl: endpoint.endpointUrl,
272
273
  securityLevel: endpoint.securityLevel,
@@ -275,14 +276,13 @@ function getRequiredEndpointInfo(endpoint: EndpointDescription) {
275
276
  server: {
276
277
  applicationUri: endpoint.server.applicationUri,
277
278
  applicationType: endpoint.server.applicationType,
278
- applicationName: endpoint.server.applicationName
279
- // ... to be continued after verifying what fields are actually needed
279
+ applicationName: endpoint.server.applicationName,
280
+ productUri: endpoint.server.productUri
280
281
  },
281
282
  transportProfileUri: endpoint.transportProfileUri,
282
283
  userIdentityTokens: endpoint.userIdentityTokens
283
284
  });
284
285
  // reduce even further by explicitly setting unwanted members to null
285
- e.server.productUri = null;
286
286
  e.server.applicationName = null as any;
287
287
  // xx e.server.applicationType = null as any;
288
288
  e.server.gatewayServerUri = null;
@@ -299,10 +299,8 @@ function getRequiredEndpointInfo(endpoint: EndpointDescription) {
299
299
  function _serverEndpointsForCreateSessionResponse(server: OPCUAServer, endpointUrl: string | null, serverUri: string | null) {
300
300
  serverUri = null; // unused then
301
301
 
302
- // The Server shall return a set of EndpointDescriptions available for the serverUri specified in the request.
303
- // It is recommended that Servers only include the endpointUrl, securityMode,
304
- // securityPolicyUri, userIdentityTokens, transportProfileUri and securityLevel with all other parameters
305
- // set to null. Only the recommended parameters shall be verified by the client.
302
+ // https://reference.opcfoundation.org/v104/Core/docs/Part4/5.6.2/
303
+ // https://reference.opcfoundation.org/v105/Core/docs/Part4/5.6.2/
306
304
  return server
307
305
  ._get_endpoints(endpointUrl)
308
306
  .filter((e) => !(e as any).restricted) // remove restricted endpoints
@@ -1356,6 +1354,19 @@ export class OPCUAServer extends OPCUABaseServer {
1356
1354
  }
1357
1355
  }
1358
1356
 
1357
+ public raiseEvent(eventType: "AuditSessionEventType", options: RaiseEventAuditSessionEventData): void;
1358
+ public raiseEvent(eventType: "AuditCreateSessionEventType", options: RaiseEventAuditCreateSessionEventData): void;
1359
+ public raiseEvent(eventType: "AuditActivateSessionEventType", options: RaiseEventAuditActivateSessionEventData): void;
1360
+ public raiseEvent(eventType: "AuditCreateSessionEventType", options: RaiseEventData): void;
1361
+ public raiseEvent(eventType: "AuditConditionCommentEventType", options: RaiseEventAuditConditionCommentEventData): void;
1362
+ public raiseEvent(eventType: "AuditUrlMismatchEventType", options: RaiseEventAuditUrlMismatchEventTypeData): void;
1363
+ public raiseEvent(eventType: "TransitionEventType", options: RaiseEventTransitionEventData): void;
1364
+ public raiseEvent(eventType: "AuditCertificateInvalidEventType", options: RaiseAuditCertificateInvalidEventData): void;
1365
+ public raiseEvent(eventType: "AuditCertificateExpiredEventType", options: RaiseAuditCertificateExpiredEventData): void;
1366
+ public raiseEvent(eventType: "AuditCertificateUntrustedEventType", options: RaiseAuditCertificateUntrustedEventData): void;
1367
+ public raiseEvent(eventType: "AuditCertificateRevokedEventType", options: RaiseAuditCertificateRevokedEventData): void;
1368
+ public raiseEvent(eventType: "AuditCertificateMismatchEventType", options: RaiseAuditCertificateMismatchEventData): void;
1369
+
1359
1370
  public raiseEvent(eventType: EventTypeLike | UAObjectType, options: RaiseEventData): void {
1360
1371
  /* istanbul ignore next */
1361
1372
  if (!this.engine.addressSpace) {
@@ -1496,6 +1507,8 @@ export class OPCUAServer extends OPCUABaseServer {
1496
1507
  }
1497
1508
 
1498
1509
  if (!userTokenSignature || !userTokenSignature.signature) {
1510
+ this.raiseEvent("AuditCreateSessionEventType", {});
1511
+
1499
1512
  return callback(null, StatusCodes.BadUserSignatureInvalid);
1500
1513
  }
1501
1514
 
@@ -1525,6 +1538,45 @@ export class OPCUAServer extends OPCUABaseServer {
1525
1538
  if (err) {
1526
1539
  return callback(err);
1527
1540
  }
1541
+ if (this.isAuditing) {
1542
+ switch (certificateStatus) {
1543
+ case StatusCodes.Good:
1544
+ break;
1545
+ case StatusCodes.BadCertificateUntrusted:
1546
+ this.raiseEvent("AuditCertificateUntrustedEventType", {
1547
+ certificate: { dataType: DataType.ByteString, value: certificate },
1548
+ sourceName: { dataType: DataType.String, value: "Security/Certificate" }
1549
+ });
1550
+ break;
1551
+ case StatusCodes.BadCertificateTimeInvalid:
1552
+ case StatusCodes.BadCertificateIssuerTimeInvalid:
1553
+ this.raiseEvent("AuditCertificateExpiredEventType", {
1554
+ certificate: { dataType: DataType.ByteString, value: certificate },
1555
+ sourceName: { dataType: DataType.String, value: "Security/Certificate" },
1556
+ comment: { dataType: DataType.String, value: certificateStatus.toString() }
1557
+ });
1558
+ break;
1559
+ case StatusCodes.BadCertificateRevoked:
1560
+ case StatusCodes.BadCertificateRevocationUnknown:
1561
+ case StatusCodes.BadCertificateIssuerRevocationUnknown:
1562
+ this.raiseEvent("AuditCertificateRevokedEventType", {
1563
+ certificate: { dataType: DataType.ByteString, value: certificate },
1564
+ sourceName: { dataType: DataType.String, value: "Security/Certificate" },
1565
+ comment: { dataType: DataType.String, value: certificateStatus.toString() }
1566
+ });
1567
+ break;
1568
+ case StatusCodes.BadCertificateIssuerUseNotAllowed:
1569
+ case StatusCodes.BadCertificateUseNotAllowed:
1570
+ case StatusCodes.BadSecurityChecksFailed:
1571
+ this.raiseEvent("AuditCertificateMismatchEventType", {
1572
+ certificate: { dataType: DataType.ByteString, value: certificate },
1573
+ sourceName: { dataType: DataType.String, value: "Security/Certificate" },
1574
+ comment: { dataType: DataType.String, value: certificateStatus.toString() }
1575
+ });
1576
+ break;
1577
+
1578
+ }
1579
+ }
1528
1580
  if (
1529
1581
  StatusCodes.BadCertificateUntrusted === certificateStatus ||
1530
1582
  StatusCodes.BadCertificateTimeInvalid === certificateStatus ||
@@ -1538,6 +1590,7 @@ export class OPCUAServer extends OPCUABaseServer {
1538
1590
  StatusCodes.Good !== certificateStatus
1539
1591
  ) {
1540
1592
  debugLog("isValidX509IdentityToken => certificateStatus = ", certificateStatus?.toString());
1593
+
1541
1594
  return callback(null, StatusCodes.BadIdentityTokenRejected);
1542
1595
  }
1543
1596
  if (StatusCodes.Good !== certificateStatus) {
@@ -3642,6 +3695,87 @@ export interface RaiseEventTransitionEventData extends RaiseEventData {}
3642
3695
  export interface RaiseEventAuditUrlMismatchEventTypeData extends RaiseEventData {
3643
3696
  endpointUrl: PseudoVariantString;
3644
3697
  }
3698
+
3699
+ /**
3700
+ * The SourceName for Events of this type shall be “Security/Certificate”.
3701
+ */
3702
+ export interface RaiseAuditCertificateEventData extends RaiseEventData {
3703
+ certificate: PseudoVariantByteString;
3704
+ sourceName: PseudoVariantStringPredefined<"Security/Certificate">;
3705
+ }
3706
+
3707
+ /**
3708
+ * This EventType inherits all Properties of the AuditCertificateEventType.
3709
+ * Either the InvalidHostname or InvalidUri shall be provided.
3710
+ */
3711
+ export interface RaiseAuditCertificateDataMismatchEventData extends RaiseAuditCertificateEventData {
3712
+ /**
3713
+ * InvalidHostname is the string that represents the host name passed in as part of the URL
3714
+ * that is found to be invalid. If the host name was not invalid it can be null.
3715
+ */
3716
+ invalidHostname: PseudoVariantString;
3717
+ /*
3718
+ * InvalidUri is the URI that was passed in and found to not match what is contained in
3719
+ * the certificate. If the URI was not invalid it can be null.
3720
+ */
3721
+ invalidUri: PseudoVariantString;
3722
+ }
3723
+ export interface RaiseAuditCertificateUntrustedEventData extends RaiseAuditCertificateEventData {}
3724
+ /**
3725
+ * This EventType inherits all Properties of the AuditCertificateEventType.
3726
+ *
3727
+ * The SourceName for Events of this type shall be “Security/Certificate”.
3728
+ *
3729
+ * The Message Variable shall include a description of why the certificate was expired
3730
+ * (i.e. time before start or time after end).
3731
+ *
3732
+ * There are no additional Properties defined for this EventType.
3733
+ *
3734
+ */
3735
+ export interface RaiseAuditCertificateExpiredEventData extends RaiseAuditCertificateEventData {}
3736
+ /**
3737
+ * This EventType inherits all Properties of the AuditCertificateEventType.
3738
+ *
3739
+ * The SourceName for Events of this type shall be “Security/Certificate”.
3740
+ *
3741
+ * The Message shall include a description of why the certificate is invalid.
3742
+ *
3743
+ * There are no additional Properties defined for this EventType.
3744
+ */
3745
+ export interface RaiseAuditCertificateInvalidEventData extends RaiseAuditCertificateEventData {}
3746
+ /**
3747
+ * This EventType inherits all Properties of the AuditCertificateEventType.
3748
+ *
3749
+ * The SourceName for Events of this type shall be “Security/Certificate”.
3750
+ *
3751
+ * The Message Variable shall include a description of why the certificate is not trusted.
3752
+ * If a trust chain is involved then the certificate that failed in the trust chain should be described.
3753
+ * There are no additional Properties defined for this EventType.
3754
+ */
3755
+ export interface RaiseAuditCertificateUntrustedEventData extends RaiseAuditCertificateEventData {}
3756
+ /**
3757
+ * This EventType inherits all Properties of the AuditCertificateEventType.
3758
+ *
3759
+ * The SourceName for Events of this type shall be “Security/Certificate”.
3760
+ *
3761
+ * The Message Variable shall include a description of why the certificate is revoked
3762
+ * (was the revocation list unavailable or was the certificate on the list).
3763
+ *
3764
+ * There are no additional Properties defined for this EventType.
3765
+ */
3766
+ export interface RaiseAuditCertificateRevokedEventData extends RaiseAuditCertificateEventData {
3767
+ sourceName: PseudoVariantStringPredefined<"Security/Certificate">;
3768
+ }
3769
+ /**
3770
+ * This EventType inherits all Properties of the AuditCertificateEventType.
3771
+ *
3772
+ * The SourceName for Events of this type shall be “Security/Certificate”.
3773
+ *
3774
+ * The Message Variable shall include a description of misuse of the certificate.
3775
+ *
3776
+ * There are no additional Properties defined for this EventType
3777
+ */
3778
+ export interface RaiseAuditCertificateMismatchEventData extends RaiseAuditCertificateEventData {}
3645
3779
  export interface OPCUAServer {
3646
3780
  /**
3647
3781
  * @internal
@@ -3661,6 +3795,12 @@ export interface OPCUAServer {
3661
3795
  raiseEvent(eventType: "AuditUrlMismatchEventType", options: RaiseEventAuditUrlMismatchEventTypeData): void;
3662
3796
 
3663
3797
  raiseEvent(eventType: "TransitionEventType", options: RaiseEventTransitionEventData): void;
3798
+
3799
+ raiseEvent(eventType: "AuditCertificateInvalidEventType", options: RaiseAuditCertificateInvalidEventData): void;
3800
+ raiseEvent(eventType: "AuditCertificateExpiredEventType", options: RaiseAuditCertificateExpiredEventData): void;
3801
+ raiseEvent(eventType: "AuditCertificateUntrustedEventType", options: RaiseAuditCertificateUntrustedEventData): void;
3802
+ raiseEvent(eventType: "AuditCertificateRevokedEventType", options: RaiseAuditCertificateRevokedEventData): void;
3803
+ raiseEvent(eventType: "AuditCertificateMismatchEventType", options: RaiseAuditCertificateMismatchEventData): void;
3664
3804
  }
3665
3805
 
3666
3806
  export interface OPCUAServer extends EventEmitter {
@@ -6,9 +6,7 @@
6
6
  import { EventEmitter } from "events";
7
7
  import * as chalk from "chalk";
8
8
 
9
- import { AddressSpace, BaseNode, Duration, UAObjectType } from "node-opcua-address-space";
10
- import { checkSelectClauses } from "node-opcua-address-space";
11
- import { SessionContext } from "node-opcua-address-space";
9
+ import { SessionContext,AddressSpace, BaseNode, Duration, UAObjectType } from "node-opcua-address-space";
12
10
  import { assert } from "node-opcua-assert";
13
11
  import { Byte, UInt32 } from "node-opcua-basic-types";
14
12
  import { SubscriptionDiagnosticsDataType } from "node-opcua-common";
@@ -18,7 +16,7 @@ import { checkDebugFlag, make_debugLog, make_warningLog } from "node-opcua-debug
18
16
  import { NodeId } from "node-opcua-nodeid";
19
17
  import { ObjectRegistry } from "node-opcua-object-registry";
20
18
  import { SequenceNumberGenerator } from "node-opcua-secure-channel";
21
- import { EventFilter } from "node-opcua-service-filter";
19
+ import { EventFilter, checkSelectClauses } from "node-opcua-service-filter";
22
20
  import { AggregateFilter } from "node-opcua-service-subscription";
23
21
  import {
24
22
  DataChangeNotification,