node-opcua-server 2.167.0 → 2.168.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/addressSpace_accessor.d.ts +6 -6
- package/dist/addressSpace_accessor.js +2 -2
- package/dist/addressSpace_accessor.js.map +1 -1
- package/dist/base_server.d.ts +14 -3
- package/dist/base_server.js +63 -41
- package/dist/base_server.js.map +1 -1
- package/dist/extract_password_from_blob.js +1 -3
- package/dist/extract_password_from_blob.js.map +1 -1
- package/dist/factory.d.ts +2 -3
- package/dist/factory.js.map +1 -1
- package/dist/filter/check_where_clause_on_address_space.d.ts +2 -2
- package/dist/filter/check_where_clause_on_address_space.js +1 -2
- package/dist/filter/check_where_clause_on_address_space.js.map +1 -1
- package/dist/filter/extract_event_fields.d.ts +3 -3
- package/dist/filter/extract_event_fields.js +1 -2
- package/dist/filter/extract_event_fields.js.map +1 -1
- package/dist/helper.d.ts +3 -3
- package/dist/helper.js +4 -8
- package/dist/helper.js.map +1 -1
- package/dist/i_address_space_accessor.d.ts +4 -4
- package/dist/i_channel_data.d.ts +1 -1
- package/dist/i_register_server_manager.d.ts +1 -1
- package/dist/i_server_side_publish_engine.d.ts +8 -6
- package/dist/i_server_side_publish_engine.js +7 -2
- package/dist/i_server_side_publish_engine.js.map +1 -1
- package/dist/index.d.ts +8 -7
- package/dist/index.js +8 -7
- package/dist/index.js.map +1 -1
- package/dist/invalidate_server_certificate_cache.d.ts +16 -0
- package/dist/invalidate_server_certificate_cache.js +28 -0
- package/dist/invalidate_server_certificate_cache.js.map +1 -0
- package/dist/monitored_item.d.ts +10 -11
- package/dist/monitored_item.js +38 -39
- package/dist/monitored_item.js.map +1 -1
- package/dist/node_sampler.d.ts +1 -1
- package/dist/node_sampler.js +2 -4
- package/dist/node_sampler.js.map +1 -1
- package/dist/opcua_server.d.ts +57 -62
- package/dist/opcua_server.js +7 -7
- package/dist/opcua_server.js.map +1 -1
- package/dist/register_server_manager_hidden.d.ts +1 -1
- package/dist/register_server_manager_hidden.js +2 -4
- package/dist/register_server_manager_hidden.js.map +1 -1
- package/dist/register_server_manager_mdns_only.d.ts +1 -1
- package/dist/register_server_manager_mdns_only.js.map +1 -1
- package/dist/sampling_func.d.ts +2 -2
- package/dist/server_capabilities.d.ts +3 -3
- package/dist/server_capabilities.js.map +1 -1
- package/dist/server_end_point.d.ts +45 -2
- package/dist/server_end_point.js +130 -32
- package/dist/server_end_point.js.map +1 -1
- package/dist/server_engine.js +29 -25
- package/dist/server_engine.js.map +1 -1
- package/dist/server_publish_engine.d.ts +5 -5
- package/dist/server_publish_engine.js +29 -23
- package/dist/server_publish_engine.js.map +1 -1
- package/dist/server_publish_engine_for_orphan_subscriptions.d.ts +2 -2
- package/dist/server_publish_engine_for_orphan_subscriptions.js.map +1 -1
- package/dist/server_session.d.ts +9 -10
- package/dist/server_session.js +11 -12
- package/dist/server_session.js.map +1 -1
- package/dist/server_subscription.d.ts +13 -13
- package/dist/server_subscription.js +100 -79
- package/dist/server_subscription.js.map +1 -1
- package/dist/sessions_compatible_for_transfer.d.ts +1 -1
- package/dist/sessions_compatible_for_transfer.js +1 -1
- package/dist/sessions_compatible_for_transfer.js.map +1 -1
- package/dist/user_manager.d.ts +4 -4
- package/dist/user_manager.js +1 -1
- package/dist/user_manager.js.map +1 -1
- package/dist/user_manager_ua.d.ts +2 -2
- package/dist/user_manager_ua.js +2 -2
- package/dist/user_manager_ua.js.map +1 -1
- package/dist/validate_filter.d.ts +7 -4
- package/dist/validate_filter.js +5 -6
- package/dist/validate_filter.js.map +1 -1
- package/package.json +46 -46
- package/source/addressSpace_accessor.ts +24 -24
- package/source/base_server.ts +73 -59
- package/source/extract_password_from_blob.ts +3 -11
- package/source/factory.ts +2 -4
- package/source/filter/check_where_clause_on_address_space.ts +4 -7
- package/source/filter/extract_event_fields.ts +4 -5
- package/source/helper.ts +9 -13
- package/source/i_address_space_accessor.ts +13 -4
- package/source/i_channel_data.ts +1 -1
- package/source/i_register_server_manager.ts +2 -4
- package/source/i_server_side_publish_engine.ts +16 -9
- package/source/index.ts +10 -9
- package/source/invalidate_server_certificate_cache.ts +26 -0
- package/source/monitored_item.ts +44 -42
- package/source/node_sampler.ts +9 -11
- package/source/opcua_server.ts +68 -88
- package/source/register_server_manager_hidden.ts +3 -5
- package/source/register_server_manager_mdns_only.ts +1 -3
- package/source/sampling_func.ts +2 -2
- package/source/server_capabilities.ts +9 -6
- package/source/server_end_point.ts +142 -42
- package/source/server_engine.ts +22 -22
- package/source/server_publish_engine.ts +35 -30
- package/source/server_publish_engine_for_orphan_subscriptions.ts +3 -3
- package/source/server_session.ts +36 -33
- package/source/server_subscription.ts +182 -184
- package/source/sessions_compatible_for_transfer.ts +9 -9
- package/source/user_manager.ts +7 -7
- package/source/user_manager_ua.ts +3 -5
- package/source/validate_filter.ts +9 -11
package/source/monitored_item.ts
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module node-opcua-server
|
|
3
3
|
*/
|
|
4
|
-
|
|
4
|
+
|
|
5
5
|
import chalk from "chalk";
|
|
6
|
+
import { EventEmitter } from "events";
|
|
7
|
+
import {
|
|
8
|
+
type AddressSpace,
|
|
9
|
+
type BaseNode,
|
|
10
|
+
type IEventData,
|
|
11
|
+
makeAttributeEventName,
|
|
12
|
+
SessionContext,
|
|
13
|
+
type UAVariable
|
|
14
|
+
} from "node-opcua-address-space";
|
|
15
|
+
import type { ISessionContext, UAMethod, UAObject } from "node-opcua-address-space-base";
|
|
6
16
|
import { assert } from "node-opcua-assert";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { extractEventFields } from "node-opcua-service-filter";
|
|
10
|
-
import { DateTime, UInt32 } from "node-opcua-basic-types";
|
|
11
|
-
import { NodeClass, QualifiedNameOptions } from "node-opcua-data-model";
|
|
12
|
-
import { AttributeIds } from "node-opcua-data-model";
|
|
17
|
+
import type { DateTime, UInt32 } from "node-opcua-basic-types";
|
|
18
|
+
import { AttributeIds, NodeClass, type QualifiedNameOptions } from "node-opcua-data-model";
|
|
13
19
|
import {
|
|
14
20
|
apply_timestamps,
|
|
21
|
+
coerceTimestampsToReturn,
|
|
15
22
|
DataValue,
|
|
16
23
|
extractRange,
|
|
17
24
|
sameDataValue,
|
|
18
|
-
coerceTimestampsToReturn,
|
|
19
25
|
sameStatusCode
|
|
20
26
|
} from "node-opcua-data-value";
|
|
21
27
|
import { checkDebugFlag, make_debugLog, make_errorLog, make_warningLog } from "node-opcua-debug";
|
|
22
|
-
import { ExtensionObject } from "node-opcua-extension-object";
|
|
23
|
-
import { NodeId } from "node-opcua-nodeid";
|
|
24
|
-
import { NumericalRange0, NumericRange } from "node-opcua-numeric-range";
|
|
28
|
+
import type { ExtensionObject } from "node-opcua-extension-object";
|
|
29
|
+
import type { NodeId } from "node-opcua-nodeid";
|
|
30
|
+
import { type NumericalRange0, NumericRange } from "node-opcua-numeric-range";
|
|
25
31
|
import { ObjectRegistry } from "node-opcua-object-registry";
|
|
26
|
-
import { EventFilter } from "node-opcua-service-filter";
|
|
27
|
-
import { ReadValueId, TimestampsToReturn } from "node-opcua-service-read";
|
|
28
|
-
import {
|
|
29
|
-
MonitoredItemModifyResult,
|
|
30
|
-
MonitoredItemNotification,
|
|
31
|
-
MonitoringMode,
|
|
32
|
-
MonitoringParameters
|
|
33
|
-
} from "node-opcua-service-subscription";
|
|
32
|
+
import { EventFilter, extractEventFields } from "node-opcua-service-filter";
|
|
33
|
+
import { ReadValueId, type TimestampsToReturn } from "node-opcua-service-read";
|
|
34
34
|
import {
|
|
35
35
|
DataChangeFilter,
|
|
36
36
|
DataChangeTrigger,
|
|
@@ -38,25 +38,28 @@ import {
|
|
|
38
38
|
isOutsideDeadbandAbsolute,
|
|
39
39
|
isOutsideDeadbandNone,
|
|
40
40
|
isOutsideDeadbandPercent,
|
|
41
|
-
|
|
41
|
+
MonitoredItemModifyResult,
|
|
42
|
+
MonitoredItemNotification,
|
|
43
|
+
MonitoringMode,
|
|
44
|
+
MonitoringParameters,
|
|
45
|
+
type PseudoRange
|
|
42
46
|
} from "node-opcua-service-subscription";
|
|
43
|
-
import { CallbackT, StatusCode, StatusCodes } from "node-opcua-status-code";
|
|
47
|
+
import { type CallbackT, StatusCode, StatusCodes } from "node-opcua-status-code";
|
|
44
48
|
import {
|
|
45
49
|
DataChangeNotification,
|
|
46
50
|
EventFieldList,
|
|
47
51
|
EventNotificationList,
|
|
48
|
-
MonitoringFilter,
|
|
49
|
-
ReadValueIdOptions,
|
|
50
|
-
SimpleAttributeOperand,
|
|
51
|
-
SubscriptionDiagnosticsDataType
|
|
52
|
+
type MonitoringFilter,
|
|
53
|
+
type ReadValueIdOptions,
|
|
54
|
+
type SimpleAttributeOperand,
|
|
55
|
+
type SubscriptionDiagnosticsDataType
|
|
52
56
|
} from "node-opcua-types";
|
|
53
57
|
import { sameVariant, Variant, VariantArrayType } from "node-opcua-variant";
|
|
54
|
-
|
|
58
|
+
import { checkWhereClauseOnAdressSpace as checkWhereClauseOnAddressSpace } from "./filter/check_where_clause_on_address_space";
|
|
55
59
|
import { appendToTimer, removeFromTimer } from "./node_sampler";
|
|
60
|
+
import type { SamplingFunc } from "./sampling_func";
|
|
61
|
+
import type { MonitoredItemBase } from "./server_subscription";
|
|
56
62
|
import { validateFilter } from "./validate_filter";
|
|
57
|
-
import { checkWhereClauseOnAdressSpace as checkWhereClauseOnAddressSpace } from "./filter/check_where_clause_on_address_space";
|
|
58
|
-
import { SamplingFunc } from "./sampling_func";
|
|
59
|
-
import { MonitoredItemBase } from "./server_subscription";
|
|
60
63
|
|
|
61
64
|
const errorLog = make_errorLog(__filename);
|
|
62
65
|
|
|
@@ -100,8 +103,8 @@ function _adjust_queue_size(queueSize: number): number {
|
|
|
100
103
|
|
|
101
104
|
function _validate_parameters(monitoringParameters: any) {
|
|
102
105
|
// xx assert(options instanceof MonitoringParameters);
|
|
103
|
-
assert(Object.
|
|
104
|
-
assert(Object.
|
|
106
|
+
assert(Object.hasOwn(monitoringParameters, "clientHandle"));
|
|
107
|
+
assert(Object.hasOwn(monitoringParameters, "samplingInterval"));
|
|
105
108
|
assert(isFinite(monitoringParameters.clientHandle));
|
|
106
109
|
assert(isFinite(monitoringParameters.samplingInterval));
|
|
107
110
|
assert(typeof monitoringParameters.discardOldest === "boolean");
|
|
@@ -394,10 +397,11 @@ export class MonitoredItem extends EventEmitter implements MonitoredItemBase {
|
|
|
394
397
|
public overflow: boolean;
|
|
395
398
|
public oldDataValue: DataValue;
|
|
396
399
|
|
|
397
|
-
|
|
398
400
|
#monitoringMode: MonitoringMode = MonitoringMode.Invalid;
|
|
399
401
|
|
|
400
|
-
public get monitoringMode() {
|
|
402
|
+
public get monitoringMode() {
|
|
403
|
+
return this.#monitoringMode;
|
|
404
|
+
}
|
|
401
405
|
|
|
402
406
|
public timestampsToReturn: TimestampsToReturn;
|
|
403
407
|
public itemToMonitor: any;
|
|
@@ -424,7 +428,7 @@ export class MonitoredItem extends EventEmitter implements MonitoredItemBase {
|
|
|
424
428
|
constructor(options: MonitoredItemOptions) {
|
|
425
429
|
super();
|
|
426
430
|
|
|
427
|
-
assert(Object.
|
|
431
|
+
assert(Object.hasOwn(options, "monitoredItemId"));
|
|
428
432
|
assert(!options.monitoringMode, "use setMonitoring mode explicitly to activate the monitored item");
|
|
429
433
|
|
|
430
434
|
options.itemToMonitor = options.itemToMonitor || defaultItemToMonitor;
|
|
@@ -470,7 +474,6 @@ export class MonitoredItem extends EventEmitter implements MonitoredItemBase {
|
|
|
470
474
|
}
|
|
471
475
|
|
|
472
476
|
public setMonitoringMode(monitoringMode: MonitoringMode): StatusCode {
|
|
473
|
-
|
|
474
477
|
if (monitoringMode === this.monitoringMode) {
|
|
475
478
|
// nothing to do
|
|
476
479
|
return StatusCodes.BadNothingToDo;
|
|
@@ -480,7 +483,6 @@ export class MonitoredItem extends EventEmitter implements MonitoredItemBase {
|
|
|
480
483
|
}
|
|
481
484
|
const old_monitoringMode = this.monitoringMode;
|
|
482
485
|
|
|
483
|
-
|
|
484
486
|
if (monitoringMode === MonitoringMode.Disabled) {
|
|
485
487
|
this.#monitoringMode = monitoringMode;
|
|
486
488
|
this._stop_sampling();
|
|
@@ -1200,7 +1202,7 @@ export class MonitoredItem extends EventEmitter implements MonitoredItemBase {
|
|
|
1200
1202
|
}
|
|
1201
1203
|
|
|
1202
1204
|
private _setOverflowBit(notification: any) {
|
|
1203
|
-
if (Object.
|
|
1205
|
+
if (Object.hasOwn(notification, "value")) {
|
|
1204
1206
|
assert(notification.value.statusCode.equals(StatusCodes.Good));
|
|
1205
1207
|
notification.value.statusCode = StatusCode.makeStatusCode(
|
|
1206
1208
|
notification.value.statusCode,
|
|
@@ -1301,11 +1303,11 @@ export class MonitoredItem extends EventEmitter implements MonitoredItemBase {
|
|
|
1301
1303
|
) {
|
|
1302
1304
|
throw new Error(
|
|
1303
1305
|
"dataValue.value.value cannot be the same object twice! " +
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1306
|
+
this.node!.browseName.toString() +
|
|
1307
|
+
" " +
|
|
1308
|
+
dataValue.toString() +
|
|
1309
|
+
" " +
|
|
1310
|
+
chalk.cyan(this.oldDataValue.toString())
|
|
1309
1311
|
);
|
|
1310
1312
|
}
|
|
1311
1313
|
|
package/source/node_sampler.ts
CHANGED
|
@@ -9,14 +9,14 @@ import { hrtime } from "node-opcua-utils";
|
|
|
9
9
|
const debugLog = make_debugLog(__filename);
|
|
10
10
|
const doDebug = checkDebugFlag(__filename);
|
|
11
11
|
|
|
12
|
-
import { MonitoredItem } from "./monitored_item";
|
|
12
|
+
import type { MonitoredItem } from "./monitored_item";
|
|
13
13
|
|
|
14
14
|
interface ITimer {
|
|
15
|
-
_samplingId: NodeJS.Timeout | false
|
|
16
|
-
monitoredItems: Record<string,any
|
|
15
|
+
_samplingId: NodeJS.Timeout | false;
|
|
16
|
+
monitoredItems: Record<string, any>;
|
|
17
17
|
monitoredItemsCount: number;
|
|
18
|
-
|
|
19
|
-
const timers: Record<string,ITimer> = {};
|
|
18
|
+
}
|
|
19
|
+
const timers: Record<string, ITimer> = {};
|
|
20
20
|
const NS_PER_SEC = 1e9;
|
|
21
21
|
|
|
22
22
|
interface MonitoredItemPriv {
|
|
@@ -24,7 +24,7 @@ interface MonitoredItemPriv {
|
|
|
24
24
|
}
|
|
25
25
|
function sampleMonitoredItem(monitoredItem: MonitoredItem) {
|
|
26
26
|
const _monitoredItem = monitoredItem as unknown as MonitoredItemPriv;
|
|
27
|
-
|
|
27
|
+
|
|
28
28
|
if (monitoredItem.monitoringMode === MonitoringMode.Disabled) {
|
|
29
29
|
return;
|
|
30
30
|
}
|
|
@@ -50,7 +50,7 @@ export function appendToTimer(monitoredItem: MonitoredItem): string {
|
|
|
50
50
|
const start = doDebug ? hrtime() : undefined;
|
|
51
51
|
let counter = 0;
|
|
52
52
|
for (const m in _t.monitoredItems) {
|
|
53
|
-
if (Object.
|
|
53
|
+
if (Object.hasOwn(_t.monitoredItems, m)) {
|
|
54
54
|
sampleMonitoredItem(_t.monitoredItems[m]);
|
|
55
55
|
counter++;
|
|
56
56
|
}
|
|
@@ -60,9 +60,7 @@ export function appendToTimer(monitoredItem: MonitoredItem): string {
|
|
|
60
60
|
const elapsed = hrtime(start);
|
|
61
61
|
debugLog(
|
|
62
62
|
`Sampler ${samplingInterval} ms : Benchmark took ${(
|
|
63
|
-
(elapsed[0] * NS_PER_SEC + elapsed[1]) /
|
|
64
|
-
1000 /
|
|
65
|
-
1000.0
|
|
63
|
+
(elapsed[0] * NS_PER_SEC + elapsed[1]) / 1000 / 1000.0
|
|
66
64
|
).toFixed(3)} milliseconds for ${counter} elements`
|
|
67
65
|
);
|
|
68
66
|
}
|
|
@@ -91,7 +89,7 @@ export function removeFromTimer(monitoredItem: MonitoredItem): void {
|
|
|
91
89
|
_t.monitoredItemsCount--;
|
|
92
90
|
assert(_t.monitoredItemsCount >= 0);
|
|
93
91
|
if (_t.monitoredItemsCount === 0) {
|
|
94
|
-
if (_t._samplingId !==false) {
|
|
92
|
+
if (_t._samplingId !== false) {
|
|
95
93
|
clearInterval(_t._samplingId);
|
|
96
94
|
}
|
|
97
95
|
delete timers[key];
|
package/source/opcua_server.ts
CHANGED
|
@@ -36,7 +36,7 @@ import {
|
|
|
36
36
|
import { assert } from "node-opcua-assert";
|
|
37
37
|
import type { ByteString, UAString } from "node-opcua-basic-types";
|
|
38
38
|
import { getDefaultCertificateManager, type OPCUACertificateManager } from "node-opcua-certificate-manager";
|
|
39
|
-
import { ServerState } from "node-opcua-common";
|
|
39
|
+
import { SecretHolder, ServerState } from "node-opcua-common";
|
|
40
40
|
import { type Certificate, combine_der, exploreCertificate, type Nonce } from "node-opcua-crypto/web";
|
|
41
41
|
import {
|
|
42
42
|
AttributeIds,
|
|
@@ -958,10 +958,64 @@ export interface OPCUAServerOptions extends OPCUABaseServerOptions, OPCUAServerE
|
|
|
958
958
|
}
|
|
959
959
|
|
|
960
960
|
const g_requestExactEndpointUrl = !!process.env.NODEOPCUA_SERVER_REQUEST_EXACT_ENDPOINT_URL;
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
961
|
+
export interface OPCUAServerEvents {
|
|
962
|
+
/** event raised when a new session is created */
|
|
963
|
+
create_session: [session: ServerSession];
|
|
964
|
+
/** event raised when a session is activated */
|
|
965
|
+
session_activated: [session: ServerSession, userIdentityToken: UserIdentityToken];
|
|
966
|
+
/** event raised when a session is closed */
|
|
967
|
+
session_closed: [session: ServerSession, deleteSubscriptions: boolean];
|
|
968
|
+
/** event raised after the server address space has been initialized */
|
|
969
|
+
post_initialize: [];
|
|
970
|
+
/**
|
|
971
|
+
* emitted when the server is trying to register with the LDS
|
|
972
|
+
* but the connection has failed (backoff signal)
|
|
973
|
+
*/
|
|
974
|
+
serverRegistrationPending: [];
|
|
975
|
+
/** event raised when server has been successfully registered on the LDS */
|
|
976
|
+
serverRegistered: [];
|
|
977
|
+
/** event raised when server registration has been successfully renewed on the LDS */
|
|
978
|
+
serverRegistrationRenewed: [];
|
|
979
|
+
/** event raised when server has been successfully unregistered from the LDS */
|
|
980
|
+
serverUnregistered: [];
|
|
981
|
+
/** event raised after the server has raised an OPCUA event toward a client */
|
|
982
|
+
event: [eventData: unknown];
|
|
983
|
+
/**
|
|
984
|
+
* event raised when the server receives a request from a connected client.
|
|
985
|
+
* Useful for trace/diagnostics.
|
|
986
|
+
*/
|
|
987
|
+
request: [request: Request, channel: ServerSecureChannelLayer];
|
|
988
|
+
/**
|
|
989
|
+
* event raised when the server sends a response to a connected client.
|
|
990
|
+
* Useful for trace/diagnostics.
|
|
991
|
+
*/
|
|
992
|
+
response: [response: Response, channel: ServerSecureChannelLayer];
|
|
993
|
+
/**
|
|
994
|
+
* event raised when a new secure channel transport is initialized (HEL/ACK complete).
|
|
995
|
+
* Note: securityPolicy and securityMode are NOT yet established at this point.
|
|
996
|
+
* Use "channelSecured" for post-handshake notifications.
|
|
997
|
+
*/
|
|
998
|
+
newChannel: [channel: ServerSecureChannelLayer, endpoint: OPCUAServerEndPoint];
|
|
999
|
+
/**
|
|
1000
|
+
* event raised when a secure channel has completed the OpenSecureChannel handshake.
|
|
1001
|
+
* At this point securityPolicy, securityMode, and clientCertificate are available.
|
|
1002
|
+
*/
|
|
1003
|
+
channelSecured: [channel: ServerSecureChannelLayer, endpoint: OPCUAServerEndPoint];
|
|
1004
|
+
/** event raised when a secure channel is closed */
|
|
1005
|
+
closeChannel: [channel: ServerSecureChannelLayer, endpoint: OPCUAServerEndPoint];
|
|
1006
|
+
/**
|
|
1007
|
+
* event raised when the server refused a TCP connection from a client
|
|
1008
|
+
* (for instance because too many connections)
|
|
1009
|
+
*/
|
|
1010
|
+
connectionRefused: [socketData: ISocketData, endpoint: OPCUAServerEndPoint];
|
|
1011
|
+
/**
|
|
1012
|
+
* event raised when an OpenSecureChannel has failed,
|
|
1013
|
+
* e.g. invalid certificate or malformed message
|
|
1014
|
+
*/
|
|
1015
|
+
openSecureChannelFailure: [socketData: ISocketData, channelData: IChannelData, endpoint: OPCUAServerEndPoint];
|
|
1016
|
+
}
|
|
1017
|
+
|
|
1018
|
+
export class OPCUAServer extends OPCUABaseServer<OPCUAServerEvents> {
|
|
965
1019
|
public engine!: ServerEngine;
|
|
966
1020
|
public registerServerMethod: RegisterServerMethod;
|
|
967
1021
|
public discoveryServerEndpointUrl!: string;
|
|
@@ -3776,6 +3830,15 @@ export class OPCUAServer extends OPCUABaseServer {
|
|
|
3776
3830
|
serverInfo: this.serverInfo,
|
|
3777
3831
|
transportSettings: serverOptions.transportSettings
|
|
3778
3832
|
});
|
|
3833
|
+
|
|
3834
|
+
// SecretHolder reads certificateFile/privateKeyFile from `this`
|
|
3835
|
+
// on each access, so it follows Object.defineProperty redirects
|
|
3836
|
+
// (e.g. from push cert management) automatically.
|
|
3837
|
+
// Note: creates a cycle (server → endpoint → SecretHolder → server)
|
|
3838
|
+
// which is harmless — V8 mark-and-sweep handles it, and
|
|
3839
|
+
// endpoint.dispose() breaks it by replacing #certProvider.
|
|
3840
|
+
endPoint.setCertificateProvider(new SecretHolder(this));
|
|
3841
|
+
|
|
3779
3842
|
return endPoint;
|
|
3780
3843
|
}
|
|
3781
3844
|
|
|
@@ -3839,89 +3902,6 @@ export class OPCUAServer extends OPCUABaseServer {
|
|
|
3839
3902
|
await this.userCertificateManager.initialize();
|
|
3840
3903
|
}
|
|
3841
3904
|
|
|
3842
|
-
public on(event: "create_session", eventHandler: (session: ServerSession) => void): this;
|
|
3843
|
-
|
|
3844
|
-
public on(event: "session_activated", eventHandler: (session: ServerSession) => void): this;
|
|
3845
|
-
|
|
3846
|
-
public on(event: "session_closed", eventHandler: (session: ServerSession, reason: string) => void): this;
|
|
3847
|
-
|
|
3848
|
-
public on(event: "post_initialize", eventHandler: () => void): this;
|
|
3849
|
-
|
|
3850
|
-
/**
|
|
3851
|
-
* emitted when the server is trying to registered the LDS
|
|
3852
|
-
* but when the connection to the lds has failed
|
|
3853
|
-
* serverRegistrationPending is sent when the backoff signal of the
|
|
3854
|
-
* connection process is raised
|
|
3855
|
-
* @event serverRegistrationPending
|
|
3856
|
-
*/
|
|
3857
|
-
public on(event: "serverRegistrationPending", eventHandler: () => void): this;
|
|
3858
|
-
|
|
3859
|
-
/**
|
|
3860
|
-
* event raised when server has been successfully registered on the local discovery server
|
|
3861
|
-
* @event serverRegistered
|
|
3862
|
-
*/
|
|
3863
|
-
public on(event: "serverRegistered", eventHandler: () => void): this;
|
|
3864
|
-
|
|
3865
|
-
/**
|
|
3866
|
-
* event raised when server registration has been successfully renewed on the local discovery server
|
|
3867
|
-
* @event serverRegistered
|
|
3868
|
-
*/
|
|
3869
|
-
public on(event: "serverRegistrationRenewed", eventHandler: () => void): this;
|
|
3870
|
-
|
|
3871
|
-
/**
|
|
3872
|
-
* event raised when server has been successfully unregistered from the local discovery server
|
|
3873
|
-
* @event serverUnregistered
|
|
3874
|
-
*/
|
|
3875
|
-
public on(event: "serverUnregistered", eventHandler: () => void): this;
|
|
3876
|
-
|
|
3877
|
-
/**
|
|
3878
|
-
* event raised after the server has raised an OPCUA event toward a client
|
|
3879
|
-
*/
|
|
3880
|
-
public on(event: "event", eventHandler: (eventData: unknown) => void): this;
|
|
3881
|
-
|
|
3882
|
-
/**
|
|
3883
|
-
* event raised when the server received a request from one of its connected client.
|
|
3884
|
-
* useful for trace purpose.
|
|
3885
|
-
*/
|
|
3886
|
-
public on(event: "request", eventHandler: (request: Request, channel: ServerSecureChannelLayer) => void): this;
|
|
3887
|
-
|
|
3888
|
-
/**
|
|
3889
|
-
* event raised when the server send an response to a request to one of its connected client.
|
|
3890
|
-
* useful for trace purpose.
|
|
3891
|
-
*/
|
|
3892
|
-
public on(event: "response", eventHandler: (request: Response, channel: ServerSecureChannelLayer) => void): this;
|
|
3893
|
-
|
|
3894
|
-
/**
|
|
3895
|
-
* event raised when a new secure channel is opened
|
|
3896
|
-
*/
|
|
3897
|
-
public on(event: "newChannel", eventHandler: (channel: ServerSecureChannelLayer, endpoint: OPCUAServerEndPoint) => void): this;
|
|
3898
|
-
|
|
3899
|
-
/**
|
|
3900
|
-
* event raised when a new secure channel is closed
|
|
3901
|
-
*/
|
|
3902
|
-
public on(
|
|
3903
|
-
event: "closeChannel",
|
|
3904
|
-
eventHandler: (channel: ServerSecureChannelLayer, endpoint: OPCUAServerEndPoint) => void
|
|
3905
|
-
): this;
|
|
3906
|
-
|
|
3907
|
-
/**
|
|
3908
|
-
* event raised when the server refused a tcp connection from a client. ( for instance because too any connections)
|
|
3909
|
-
*/
|
|
3910
|
-
public on(event: "connectionRefused", eventHandler: (socketData: ISocketData, endpoint: OPCUAServerEndPoint) => void): this;
|
|
3911
|
-
|
|
3912
|
-
/**
|
|
3913
|
-
* event raised when a OpenSecureChannel has failed, it could be a invalid certificate or malformed message
|
|
3914
|
-
*/
|
|
3915
|
-
public on(
|
|
3916
|
-
event: "openSecureChannelFailure",
|
|
3917
|
-
eventHandler: (socketData: ISocketData, channelData: IChannelData, endpoint: OPCUAServerEndPoint) => void
|
|
3918
|
-
): this;
|
|
3919
|
-
|
|
3920
|
-
public on(event: string, eventHandler: (...args: unknown[]) => void): this;
|
|
3921
|
-
// biome-ignore lint/suspicious/noExplicitAny: must match EventEmitter.on() signature
|
|
3922
|
-
public on(event: string, eventHandler: (...args: any[]) => void): this {
|
|
3923
|
-
return super.on(event, eventHandler);
|
|
3924
|
-
}
|
|
3925
3905
|
}
|
|
3926
3906
|
|
|
3927
3907
|
const userIdentityTokenPasswordRemoved = (userIdentityToken?: UserIdentityToken): UserIdentityToken => {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @module node-opcua-server
|
|
3
3
|
*/
|
|
4
4
|
import { EventEmitter } from "events";
|
|
5
|
-
import { IRegisterServerManager, RegisterServerManagerStatus } from "./i_register_server_manager";
|
|
5
|
+
import { type IRegisterServerManager, RegisterServerManagerStatus } from "./i_register_server_manager";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* a IRegisterServerManager that hides the server from any local discover server
|
|
@@ -17,11 +17,9 @@ export class RegisterServerManagerHidden extends EventEmitter implements IRegist
|
|
|
17
17
|
super();
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
public async stop(): Promise<void> {
|
|
21
|
-
}
|
|
20
|
+
public async stop(): Promise<void> {}
|
|
22
21
|
|
|
23
|
-
public async start(): Promise<void> {
|
|
24
|
-
}
|
|
22
|
+
public async start(): Promise<void> {}
|
|
25
23
|
|
|
26
24
|
public dispose(): void {
|
|
27
25
|
//
|
|
@@ -7,7 +7,7 @@ import { EventEmitter } from "events";
|
|
|
7
7
|
import { assert } from "node-opcua-assert";
|
|
8
8
|
import { BonjourHolder } from "node-opcua-service-discovery";
|
|
9
9
|
import { OPCUABaseServer } from "./base_server";
|
|
10
|
-
import { IRegisterServerManager, RegisterServerManagerStatus } from "./i_register_server_manager";
|
|
10
|
+
import { type IRegisterServerManager, RegisterServerManagerStatus } from "./i_register_server_manager";
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* a RegisterServerManager that declare the server the OPCUA Bonjour service
|
|
@@ -31,7 +31,6 @@ export class RegisterServerManagerMDNSONLY extends EventEmitter implements IRegi
|
|
|
31
31
|
|
|
32
32
|
public async stop(): Promise<void> {
|
|
33
33
|
if (this.bonjour) {
|
|
34
|
-
|
|
35
34
|
this._state = RegisterServerManagerStatus.UNREGISTERING;
|
|
36
35
|
await this.bonjour.stopAnnouncedOnMulticastSubnet();
|
|
37
36
|
this.emit("serverUnregistered");
|
|
@@ -51,7 +50,6 @@ export class RegisterServerManagerMDNSONLY extends EventEmitter implements IRegi
|
|
|
51
50
|
const name = this.server.serverInfo.applicationUri!;
|
|
52
51
|
const port = this.server.endpoints[0].port;
|
|
53
52
|
|
|
54
|
-
|
|
55
53
|
this._state = RegisterServerManagerStatus.REGISTERING;
|
|
56
54
|
await this.bonjour.announcedOnMulticastSubnet({
|
|
57
55
|
capabilities: capabilities,
|
package/source/sampling_func.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ISessionContext } from "node-opcua-address-space-base";
|
|
2
|
-
import { DataValue } from "node-opcua-data-value";
|
|
1
|
+
import type { ISessionContext } from "node-opcua-address-space-base";
|
|
2
|
+
import type { DataValue } from "node-opcua-data-value";
|
|
3
3
|
|
|
4
4
|
export type SamplingFunc = (
|
|
5
5
|
context: ISessionContext,
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
* @module node-opcua-server
|
|
3
3
|
*/
|
|
4
4
|
// tslint:disable:max-classes-per-file
|
|
5
|
-
import { Double, UInt32 } from "node-opcua-basic-types";
|
|
5
|
+
import type { Double, UInt32 } from "node-opcua-basic-types";
|
|
6
6
|
import { BinaryStream } from "node-opcua-binary-stream";
|
|
7
|
-
import { QualifiedName } from "node-opcua-data-model";
|
|
7
|
+
import type { QualifiedName } from "node-opcua-data-model";
|
|
8
8
|
import { make_warningLog } from "node-opcua-debug";
|
|
9
|
-
import { SignedSoftwareCertificate } from "node-opcua-types";
|
|
9
|
+
import type { SignedSoftwareCertificate } from "node-opcua-types";
|
|
10
10
|
|
|
11
11
|
const warningLog = make_warningLog(__filename);
|
|
12
12
|
|
|
@@ -237,14 +237,17 @@ export class ServerCapabilities implements IServerCapabilities {
|
|
|
237
237
|
this.maxByteStringLength = options.maxByteStringLength || defaultServerCapabilities.maxByteStringLength;
|
|
238
238
|
|
|
239
239
|
if (BinaryStream.maxStringLength < this.maxStringLength) {
|
|
240
|
-
warningLog(
|
|
240
|
+
warningLog(
|
|
241
|
+
`ServerCapabilities.maxStringLength ${this.maxStringLength} is greater that the allowed limite BinaryStream.maxStringLength = ${BinaryStream.maxStringLength}\nPlease adjust the value.`
|
|
242
|
+
);
|
|
241
243
|
}
|
|
242
244
|
|
|
243
245
|
if (BinaryStream.maxByteStringLength < this.maxByteStringLength) {
|
|
244
|
-
warningLog(
|
|
246
|
+
warningLog(
|
|
247
|
+
`ServerCapabilities.maxByteStringLength ${this.maxByteStringLength} is greater that the allowed limite BinaryStream.maxByteStringLength = ${BinaryStream.maxByteStringLength}\nPlease adjust the value.`
|
|
248
|
+
);
|
|
245
249
|
}
|
|
246
250
|
|
|
247
|
-
|
|
248
251
|
this.maxBrowseContinuationPoints =
|
|
249
252
|
options.maxBrowseContinuationPoints || defaultServerCapabilities.maxBrowseContinuationPoints;
|
|
250
253
|
this.maxQueryContinuationPoints =
|