node-opcua-server 2.73.1 → 2.76.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.
Files changed (72) hide show
  1. package/LICENSE +3 -1
  2. package/dist/base_server.d.ts +110 -110
  3. package/dist/base_server.js +473 -473
  4. package/dist/factory.d.ts +12 -12
  5. package/dist/factory.js +23 -23
  6. package/dist/filter/check_where_clause_on_address_space.d.ts +3 -0
  7. package/dist/filter/check_where_clause_on_address_space.js +23 -0
  8. package/dist/filter/check_where_clause_on_address_space.js.map +1 -0
  9. package/dist/filter/extract_event_fields.d.ts +10 -0
  10. package/dist/filter/extract_event_fields.js +18 -0
  11. package/dist/filter/extract_event_fields.js.map +1 -0
  12. package/dist/helper.d.ts +10 -10
  13. package/dist/helper.js +75 -75
  14. package/dist/history_server_capabilities.d.ts +35 -35
  15. package/dist/history_server_capabilities.js +43 -43
  16. package/dist/i_channel_data.d.ts +13 -13
  17. package/dist/i_channel_data.js +2 -2
  18. package/dist/i_register_server_manager.d.ts +16 -16
  19. package/dist/i_register_server_manager.js +2 -2
  20. package/dist/i_server_side_publish_engine.d.ts +36 -36
  21. package/dist/i_server_side_publish_engine.js +49 -49
  22. package/dist/i_socket_data.d.ts +11 -11
  23. package/dist/i_socket_data.js +2 -2
  24. package/dist/index.d.ts +16 -16
  25. package/dist/index.js +32 -32
  26. package/dist/monitored_item.d.ts +177 -177
  27. package/dist/monitored_item.js +1001 -999
  28. package/dist/monitored_item.js.map +1 -1
  29. package/dist/node_sampler.d.ts +3 -3
  30. package/dist/node_sampler.js +75 -75
  31. package/dist/opcua_server.d.ts +747 -650
  32. package/dist/opcua_server.js +2431 -2394
  33. package/dist/opcua_server.js.map +1 -1
  34. package/dist/queue.d.ts +11 -11
  35. package/dist/queue.js +71 -71
  36. package/dist/register_server_manager.d.ts +96 -96
  37. package/dist/register_server_manager.js +584 -584
  38. package/dist/register_server_manager_hidden.d.ts +17 -17
  39. package/dist/register_server_manager_hidden.js +27 -27
  40. package/dist/register_server_manager_mdns_only.d.ts +22 -22
  41. package/dist/register_server_manager_mdns_only.js +55 -55
  42. package/dist/server_capabilities.d.ts +148 -148
  43. package/dist/server_capabilities.js +92 -92
  44. package/dist/server_end_point.d.ts +183 -183
  45. package/dist/server_end_point.js +817 -817
  46. package/dist/server_engine.d.ts +317 -317
  47. package/dist/server_engine.js +1716 -1716
  48. package/dist/server_publish_engine.d.ts +113 -112
  49. package/dist/server_publish_engine.js +541 -535
  50. package/dist/server_publish_engine.js.map +1 -1
  51. package/dist/server_publish_engine_for_orphan_subscriptions.d.ts +16 -16
  52. package/dist/server_publish_engine_for_orphan_subscriptions.js +51 -51
  53. package/dist/server_session.d.ts +182 -182
  54. package/dist/server_session.js +739 -739
  55. package/dist/server_subscription.d.ts +421 -421
  56. package/dist/server_subscription.js +1346 -1345
  57. package/dist/server_subscription.js.map +1 -1
  58. package/dist/sessions_compatible_for_transfer.d.ts +2 -2
  59. package/dist/sessions_compatible_for_transfer.js +39 -39
  60. package/dist/user_manager.d.ts +32 -32
  61. package/dist/user_manager.js +74 -74
  62. package/dist/user_manager_ua.d.ts +3 -3
  63. package/dist/user_manager_ua.js +39 -39
  64. package/dist/validate_filter.d.ts +5 -5
  65. package/dist/validate_filter.js +60 -60
  66. package/package.json +50 -51
  67. package/source/filter/check_where_clause_on_address_space.ts +29 -0
  68. package/source/filter/extract_event_fields.ts +21 -0
  69. package/source/monitored_item.ts +5 -11
  70. package/source/opcua_server.ts +175 -36
  71. package/source/server_publish_engine.ts +24 -19
  72. package/source/server_subscription.ts +11 -10
@@ -1,650 +1,747 @@
1
- /**
2
- * @module node-opcua-server
3
- */
4
- /// <reference types="node" />
5
- import { EventEmitter } from "events";
6
- import { PseudoVariantBoolean, PseudoVariantByteString, PseudoVariantDateTime, PseudoVariantDuration, PseudoVariantExtensionObject, PseudoVariantExtensionObjectArray, PseudoVariantLocalizedText, PseudoVariantNodeId, PseudoVariantString, RaiseEventData } from "node-opcua-address-space";
7
- import { OPCUACertificateManager } from "node-opcua-certificate-manager";
8
- import { Certificate, Nonce } from "node-opcua-crypto";
9
- import { NodeId } from "node-opcua-nodeid";
10
- import { ObjectRegistry } from "node-opcua-object-registry";
11
- import { Message, MessageSecurityMode, Request, Response, SecurityPolicy, ServerSecureChannelLayer, SignatureData } from "node-opcua-secure-channel";
12
- import { BrowseNextResponse, BrowseResponse } from "node-opcua-service-browse";
13
- import { CallResponse } from "node-opcua-service-call";
14
- import { HistoryReadResponse } from "node-opcua-service-history";
15
- import { ReadResponse } from "node-opcua-service-read";
16
- import { RegisterNodesResponse, UnregisterNodesResponse } from "node-opcua-service-register-node";
17
- import { UserNameIdentityToken, X509IdentityToken } from "node-opcua-service-session";
18
- import { CreateMonitoredItemsResponse, CreateSubscriptionResponse, DeleteSubscriptionsResponse, ModifyMonitoredItemsResponse, ModifySubscriptionResponse, RepublishResponse, SetPublishingModeResponse, SetTriggeringResponse, TransferSubscriptionsResponse } from "node-opcua-service-subscription";
19
- import { TranslateBrowsePathsToNodeIdsResponse } from "node-opcua-service-translate-browse-path";
20
- import { WriteResponse } from "node-opcua-service-write";
21
- import { StatusCode } from "node-opcua-status-code";
22
- import { ApplicationDescriptionOptions, BuildInfo, EndpointDescription, UserIdentityToken, UserTokenPolicy } from "node-opcua-types";
23
- import { OPCUABaseServer, OPCUABaseServerOptions } from "./base_server";
24
- import { IRegisterServerManager } from "./i_register_server_manager";
25
- import { ServerCapabilitiesOptions } from "./server_capabilities";
26
- import { OPCUAServerEndPoint } from "./server_end_point";
27
- import { CreateSessionOption, ServerEngine } from "./server_engine";
28
- import { ServerSession } from "./server_session";
29
- import { CreateMonitoredItemHook, DeleteMonitoredItemHook, Subscription } from "./server_subscription";
30
- import { ISocketData } from "./i_socket_data";
31
- import { IChannelData } from "./i_channel_data";
32
- import { UAUserManagerBase, UserManagerOptions } from "./user_manager";
33
- declare type ResponseClassType = typeof BrowseResponse | typeof BrowseNextResponse | typeof CallResponse | typeof CreateMonitoredItemsResponse | typeof CreateSubscriptionResponse | typeof DeleteSubscriptionsResponse | typeof HistoryReadResponse | typeof ModifyMonitoredItemsResponse | typeof ModifySubscriptionResponse | typeof ReadResponse | typeof RegisterNodesResponse | typeof RepublishResponse | typeof SetPublishingModeResponse | typeof SetTriggeringResponse | typeof TransferSubscriptionsResponse | typeof TranslateBrowsePathsToNodeIdsResponse | typeof UnregisterNodesResponse | typeof WriteResponse;
34
- export declare function filterDiagnosticInfo(returnDiagnostics: number, response: CallResponse): void;
35
- export declare enum RegisterServerMethod {
36
- HIDDEN = 1,
37
- MDNS = 2,
38
- LDS = 3
39
- }
40
- export interface OPCUAServerEndpointOptions {
41
- /**
42
- * the primary hostname of the endpoint.
43
- * @default getFullyQualifiedDomainName()
44
- */
45
- hostname?: string;
46
- /**
47
- * the TCP port to listen to.
48
- * @default 26543
49
- */
50
- port?: number;
51
- /**
52
- * the possible security policies that the server will expose
53
- * @default [SecurityPolicy.None, SecurityPolicy.Basic128Rsa15, SecurityPolicy.Basic256Sha256, SecurityPolicy.Aes128_Sha256_RsaOaep, SecurityPolicy.Aes256_Sha256_RsaPss ]
54
- */
55
- securityPolicies?: SecurityPolicy[];
56
- /**
57
- * the possible security mode that the server will expose
58
- * @default [MessageSecurityMode.None, MessageSecurityMode.Sign, MessageSecurityMode.SignAndEncrypt]
59
- */
60
- securityModes?: MessageSecurityMode[];
61
- /**
62
- * tells if the server default endpoints should allow anonymous connection.
63
- * @default true
64
- */
65
- allowAnonymous?: boolean;
66
- /** alternate hostname or IP to use */
67
- alternateHostname?: string | string[];
68
- /**
69
- * true, if discovery service on secure channel shall be disabled
70
- */
71
- disableDiscovery?: boolean;
72
- }
73
- export interface OPCUAServerOptions extends OPCUABaseServerOptions, OPCUAServerEndpointOptions {
74
- alternateEndpoints?: OPCUAServerEndpointOptions[];
75
- /**
76
- * the server certificate full path filename
77
- *
78
- * the certificate should be in PEM format
79
- */
80
- certificateFile?: string;
81
- /**
82
- * the server private key full path filename
83
- *
84
- * This file should contains the private key that has been used to generate
85
- * the server certificate file.
86
- *
87
- * the private key should be in PEM format
88
- *
89
- */
90
- privateKeyFile?: string;
91
- /**
92
- * the default secure token life time in ms.
93
- */
94
- defaultSecureTokenLifetime?: number;
95
- /**
96
- * the HEL/ACK transaction timeout in ms.
97
- *
98
- * Use a large value ( i.e 15000 ms) for slow connections or embedded devices.
99
- * @default 10000
100
- */
101
- timeout?: number;
102
- /**
103
- * the maximum number of simultaneous sessions allowed.
104
- * @default 10
105
- * @deprecated use serverCapabilities: { maxSessions: } instead
106
-
107
- */
108
- maxAllowedSessionNumber?: number;
109
- /**
110
- * the maximum number authorized simultaneous connections per endpoint
111
- * @default 10
112
- */
113
- maxConnectionsPerEndpoint?: number;
114
- /**
115
- * the nodeset.xml file(s) to load
116
- *
117
- * node-opcua comes with pre-installed node-set files that can be used
118
- *
119
- * example:
120
- *
121
- * ``` javascript
122
- *
123
- * ```
124
- */
125
- nodeset_filename?: string[] | string;
126
- /**
127
- * the server Info
128
- *
129
- * this object contains the value that will populate the
130
- * Root/ObjectS/Server/ServerInfo OPCUA object in the address space.
131
- */
132
- serverInfo?: ApplicationDescriptionOptions;
133
- buildInfo?: {
134
- productName?: string;
135
- productUri?: string | null;
136
- manufacturerName?: string;
137
- softwareVersion?: string;
138
- buildNumber?: string;
139
- buildDate?: Date;
140
- };
141
- /**
142
- * an object that implements user authentication methods
143
- */
144
- userManager?: UserManagerOptions;
145
- /** resource Path is a string added at the end of the url such as "/UA/Server" */
146
- resourcePath?: string;
147
- /**
148
- *
149
- */
150
- serverCapabilities?: ServerCapabilitiesOptions;
151
- /**
152
- * if server shall raise AuditingEvent
153
- * @default true
154
- */
155
- isAuditing?: boolean;
156
- /**
157
- * strategy used by the server to declare itself to a discovery server
158
- *
159
- * - HIDDEN: the server doesn't expose itself to the external world
160
- * - MDNS: the server publish itself to the mDNS Multicast network directly
161
- * - LDS: the server registers itself to the LDS or LDS-ME (Local Discovery Server)
162
- *
163
- * @default .HIDDEN - by default the server
164
- * will not register itself to the local discovery server
165
- *
166
- */
167
- registerServerMethod?: RegisterServerMethod;
168
- /**
169
- *
170
- * @default "opc.tcp://localhost:4840"]
171
- */
172
- discoveryServerEndpointUrl?: string;
173
- /**
174
- *
175
- * supported server capabilities for the Multicast (mDNS)
176
- * @default ["NA"]
177
- * the possible values are any of node-opcua-discovery.serverCapabilities)
178
- *
179
- */
180
- capabilitiesForMDNS?: string[];
181
- /**
182
- * user Certificate Manager
183
- * this certificate manager holds the X509 certificates used
184
- * by client that uses X509 certificate token to impersonate a user
185
- */
186
- userCertificateManager?: OPCUACertificateManager;
187
- /**
188
- * Server Certificate Manager
189
- *
190
- * this certificate manager will be used by the server to access
191
- * and store certificates from the connecting clients
192
- */
193
- serverCertificateManager?: OPCUACertificateManager;
194
- /**
195
- *
196
- */
197
- onCreateMonitoredItem?: CreateMonitoredItemHook;
198
- onDeleteMonitoredItem?: DeleteMonitoredItemHook;
199
- }
200
- export interface OPCUAServer {
201
- /**
202
- *
203
- */
204
- engine: ServerEngine;
205
- /**
206
- *
207
- */
208
- registerServerMethod: RegisterServerMethod;
209
- /**
210
- *
211
- */
212
- discoveryServerEndpointUrl: string;
213
- /**
214
- *
215
- */
216
- registerServerManager?: IRegisterServerManager;
217
- /**
218
- *
219
- */
220
- capabilitiesForMDNS: string[];
221
- /**
222
- *
223
- */
224
- userCertificateManager: OPCUACertificateManager;
225
- }
226
- /**
227
- *
228
- */
229
- export declare class OPCUAServer extends OPCUABaseServer {
230
- static defaultShutdownTimeout: number;
231
- /**
232
- * if requestExactEndpointUrl is set to true the server will only accept createSession that have a endpointUrl that strictly matches
233
- * one of the provided endpoint.
234
- * This mean that if the server expose a endpoint with url such as opc.tcp://MYHOSTNAME:1234, client will not be able to reach the server
235
- * with the ip address of the server.
236
- * requestExactEndpointUrl = true => emulates the Prosys Server behavior
237
- * requestExactEndpointUrl = false => emulates the Unified Automation behavior.
238
- */
239
- static requestExactEndpointUrl: boolean;
240
- /**
241
- * total number of bytes written by the server since startup
242
- */
243
- get bytesWritten(): number;
244
- /**
245
- * total number of bytes read by the server since startup
246
- */
247
- get bytesRead(): number;
248
- /**
249
- * Number of transactions processed by the server since startup
250
- */
251
- get transactionsCount(): number;
252
- /**
253
- * The server build info
254
- */
255
- get buildInfo(): BuildInfo;
256
- /**
257
- * the number of connected channel on all existing end points
258
- */
259
- get currentChannelCount(): number;
260
- /**
261
- * The number of active subscriptions from all sessions
262
- */
263
- get currentSubscriptionCount(): number;
264
- /**
265
- * the number of session activation requests that have been rejected
266
- */
267
- get rejectedSessionCount(): number;
268
- /**
269
- * the number of request that have been rejected
270
- */
271
- get rejectedRequestsCount(): number;
272
- /**
273
- * the number of sessions that have been aborted
274
- */
275
- get sessionAbortCount(): number;
276
- /**
277
- * the publishing interval count
278
- */
279
- get publishingIntervalCount(): number;
280
- /**
281
- * the number of sessions currently active
282
- */
283
- get currentSessionCount(): number;
284
- /**
285
- * true if the server has been initialized
286
- *
287
- */
288
- get initialized(): boolean;
289
- /**
290
- * is the server auditing ?
291
- */
292
- get isAuditing(): boolean;
293
- static registry: ObjectRegistry;
294
- static fallbackSessionName: string;
295
- /**
296
- * the maximum number of subscription that can be created per server
297
- * @deprecated
298
- */
299
- static deprectated_MAX_SUBSCRIPTION: number;
300
- /**
301
- * the maximum number of concurrent sessions allowed on the server
302
- */
303
- get maxAllowedSessionNumber(): number;
304
- /**
305
- * the maximum number for concurrent connection per end point
306
- */
307
- maxConnectionsPerEndpoint: number;
308
- /**
309
- * false if anonymous connection are not allowed
310
- */
311
- allowAnonymous: boolean;
312
- /**
313
- * the user manager
314
- */
315
- userManager: UAUserManagerBase;
316
- readonly options: OPCUAServerOptions;
317
- private objectFactory?;
318
- private _delayInit?;
319
- constructor(options?: OPCUAServerOptions);
320
- /**
321
- * Initialize the server by installing default node set.
322
- *
323
- * and instruct the server to listen to its endpoints.
324
- *
325
- * ```javascript
326
- * const server = new OPCUAServer();
327
- * await server.initialize();
328
- *
329
- * // default server namespace is now initialized
330
- * // it is a good time to create life instance objects
331
- * const namespace = server.engine.addressSpace.getOwnNamespace();
332
- * namespace.addObject({
333
- * browseName: "SomeObject",
334
- * organizedBy: server.engine.addressSpace.rootFolder.objects
335
- * });
336
- *
337
- * // the addressSpace is now complete
338
- * // let's now start listening to clients
339
- * await server.start();
340
- * ```
341
- */
342
- initialize(): Promise<void>;
343
- initialize(done: () => void): void;
344
- /**
345
- * Initiate the server by starting all its endpoints
346
- * @async
347
- */
348
- start(): Promise<void>;
349
- start(done: () => void): void;
350
- /**
351
- * shutdown all server endpoints
352
- * @method shutdown
353
- * @async
354
- * @param timeout the timeout (in ms) before the server is actually shutdown
355
- *
356
- * @example
357
- *
358
- * ```javascript
359
- * // shutdown immediately
360
- * server.shutdown(function(err) {
361
- * });
362
- * ```
363
- * ```ts
364
- * // in typescript with promises
365
- * server.shutdown(10000).then(()=>{
366
- * console.log("Server has shutdown");
367
- * });
368
- * ```
369
- * ```javascript
370
- * // shutdown within 10 seconds
371
- * server.engine.shutdownReason = coerceLocalizedText("Shutdown for maintenance");
372
- * server.shutdown(10000,function(err) {
373
- * });
374
- * ```
375
- */
376
- shutdown(timeout?: number): Promise<void>;
377
- shutdown(callback: (err?: Error) => void): void;
378
- shutdown(timeout: number, callback: (err?: Error) => void): void;
379
- dispose(): void;
380
- /**
381
- * create and register a new session
382
- * @internal
383
- */
384
- protected createSession(options: CreateSessionOption): ServerSession;
385
- /**
386
- * retrieve a session by authentication token
387
- * @internal
388
- */
389
- protected getSession(authenticationToken: NodeId, activeOnly?: boolean): ServerSession | null;
390
- /**
391
- *
392
- * @param channel
393
- * @param clientCertificate
394
- * @param clientNonce
395
- * @internal
396
- */
397
- protected computeServerSignature(channel: ServerSecureChannelLayer, clientCertificate: Certificate, clientNonce: Nonce): SignatureData | undefined;
398
- /**
399
- *
400
- * @param session
401
- * @param channel
402
- * @param clientSignature
403
- * @internal
404
- */
405
- protected verifyClientSignature(session: ServerSession, channel: ServerSecureChannelLayer, clientSignature: SignatureData): boolean;
406
- protected isValidUserNameIdentityToken(channel: ServerSecureChannelLayer, session: ServerSession, userTokenPolicy: UserTokenPolicy, userIdentityToken: UserNameIdentityToken, userTokenSignature: SignatureData, callback: (err: Error | null, statusCode?: StatusCode) => void): void;
407
- protected isValidX509IdentityToken(channel: ServerSecureChannelLayer, session: ServerSession, userTokenPolicy: UserTokenPolicy, userIdentityToken: X509IdentityToken, userTokenSignature: SignatureData, callback: (err: Error | null, statusCode?: StatusCode) => void): void;
408
- /**
409
- * @internal
410
- */
411
- protected userNameIdentityTokenAuthenticateUser(channel: ServerSecureChannelLayer, session: ServerSession, userTokenPolicy: UserTokenPolicy, userIdentityToken: UserNameIdentityToken, callback: (err: Error | null, isAuthorized?: boolean) => void): void;
412
- /**
413
- * @internal
414
- */
415
- protected isValidUserIdentityToken(channel: ServerSecureChannelLayer, session: ServerSession, userIdentityToken: UserIdentityToken, userTokenSignature: SignatureData, endpointDescription: EndpointDescription, callback: (err: Error | null, statusCode?: StatusCode) => void): void;
416
- /**
417
- *
418
- * @internal
419
- * @param channel
420
- * @param session
421
- * @param userIdentityToken
422
- * @param callback
423
- * @returns {*}
424
- */
425
- protected isUserAuthorized(channel: ServerSecureChannelLayer, session: ServerSession, userIdentityToken: UserIdentityToken, callback: (err: Error | null, isAuthorized?: boolean) => void): void;
426
- protected makeServerNonce(): Nonce;
427
- protected _on_CreateSessionRequest(message: Message, channel: ServerSecureChannelLayer): Promise<void>;
428
- /**
429
- *
430
- * @method _on_ActivateSessionRequest
431
- * @private
432
- *
433
- *
434
- */
435
- protected _on_ActivateSessionRequest(message: Message, channel: ServerSecureChannelLayer): void;
436
- protected prepare(message: Message, channel: ServerSecureChannelLayer): void;
437
- /**
438
- * ensure that action is performed on a valid session object,
439
- * @method _apply_on_SessionObject
440
- * @param ResponseClass the constructor of the response Class
441
- * @param message
442
- * @param channel
443
- * @param actionToPerform
444
- * @param actionToPerform.session {ServerSession}
445
- * @param actionToPerform.sendResponse
446
- * @param actionToPerform.sendResponse.response
447
- * @param actionToPerform.sendError
448
- * @param actionToPerform.sendError.statusCode
449
- * @param actionToPerform.sendError.diagnostics
450
- *
451
- * @private
452
- */
453
- protected _apply_on_SessionObject(ResponseClass: ResponseClassType, message: Message, channel: ServerSecureChannelLayer, actionToPerform: (session: ServerSession, sendResponse: (response: Response) => void, sendError: (statusCode: StatusCode) => void) => void | Promise<void>): Promise<void>;
454
- protected _apply_on_Subscription(ResponseClass: ResponseClassType, message: Message, channel: ServerSecureChannelLayer, actionToPerform: (session: ServerSession, subscription: Subscription, sendResponse: (response: Response) => void, sendError: (statusCode: StatusCode) => void) => Promise<void>): Promise<void>;
455
- protected _apply_on_SubscriptionIds<T>(ResponseClass: typeof SetPublishingModeResponse | typeof TransferSubscriptionsResponse | typeof DeleteSubscriptionsResponse, message: Message, channel: ServerSecureChannelLayer, actionToPerform: (session: ServerSession, subscriptionId: number) => Promise<T>): void;
456
- protected _apply_on_Subscriptions(ResponseClass: typeof SetPublishingModeResponse | typeof TransferSubscriptionsResponse | typeof DeleteSubscriptionsResponse, message: Message, channel: ServerSecureChannelLayer, actionToPerform: (session: ServerSession, subscription: Subscription) => Promise<StatusCode>): void;
457
- private _closeSession;
458
- /**
459
- * @method _on_CloseSessionRequest
460
- * @param message
461
- * @param channel
462
- * @private
463
- */
464
- protected _on_CloseSessionRequest(message: Message, channel: ServerSecureChannelLayer): void;
465
- /**
466
- * @method _on_BrowseRequest
467
- * @param message
468
- * @param channel
469
- * @private
470
- */
471
- protected _on_BrowseRequest(message: Message, channel: ServerSecureChannelLayer): void;
472
- /**
473
- * @method _on_BrowseNextRequest
474
- * @param message
475
- * @param channel
476
- * @private
477
- */
478
- protected _on_BrowseNextRequest(message: Message, channel: ServerSecureChannelLayer): void;
479
- protected _on_ReadRequest(message: Message, channel: ServerSecureChannelLayer): void;
480
- protected _on_HistoryReadRequest(message: Message, channel: ServerSecureChannelLayer): void;
481
- protected _on_WriteRequest(message: Message, channel: ServerSecureChannelLayer): void;
482
- protected _on_CreateSubscriptionRequest(message: Message, channel: ServerSecureChannelLayer): void;
483
- protected _on_DeleteSubscriptionsRequest(message: Message, channel: ServerSecureChannelLayer): void;
484
- protected _on_TransferSubscriptionsRequest(message: Message, channel: ServerSecureChannelLayer): void;
485
- protected _on_CreateMonitoredItemsRequest(message: Message, channel: ServerSecureChannelLayer): void;
486
- protected _on_ModifySubscriptionRequest(message: Message, channel: ServerSecureChannelLayer): void;
487
- protected _on_ModifyMonitoredItemsRequest(message: Message, channel: ServerSecureChannelLayer): void;
488
- protected _on_PublishRequest(message: Message, channel: ServerSecureChannelLayer): void;
489
- protected _on_SetPublishingModeRequest(message: Message, channel: ServerSecureChannelLayer): void;
490
- protected _on_DeleteMonitoredItemsRequest(message: Message, channel: ServerSecureChannelLayer): void;
491
- protected _on_SetTriggeringRequest(message: Message, channel: ServerSecureChannelLayer): void;
492
- protected _beforeDeleteSubscription(subscription: Subscription): Promise<void>;
493
- protected _on_RepublishRequest(message: Message, channel: ServerSecureChannelLayer): void;
494
- protected _on_SetMonitoringModeRequest(message: Message, channel: ServerSecureChannelLayer): void;
495
- protected _on_TranslateBrowsePathsToNodeIdsRequest(message: Message, channel: ServerSecureChannelLayer): void;
496
- protected _on_CallRequest(message: Message, channel: ServerSecureChannelLayer): void;
497
- protected _on_RegisterNodesRequest(message: Message, channel: ServerSecureChannelLayer): void;
498
- protected _on_UnregisterNodesRequest(message: Message, channel: ServerSecureChannelLayer): void;
499
- protected _on_Cancel(message: Message, channel: ServerSecureChannelLayer): void;
500
- protected _on_AddNodes(message: Message, channel: ServerSecureChannelLayer): void;
501
- protected _on_AddReferences(message: Message, channel: ServerSecureChannelLayer): void;
502
- protected _on_DeleteNodes(message: Message, channel: ServerSecureChannelLayer): void;
503
- protected _on_DeleteReferences(message: Message, channel: ServerSecureChannelLayer): void;
504
- protected _on_QueryFirst(message: Message, channel: ServerSecureChannelLayer): void;
505
- protected _on_QueryNext(message: Message, channel: ServerSecureChannelLayer): void;
506
- protected _on_HistoryUpdate(message: Message, channel: ServerSecureChannelLayer): void;
507
- private createEndpoint;
508
- private createEndpointDescriptions;
509
- initializeCM(): Promise<void>;
510
- }
511
- export interface RaiseEventAuditEventData extends RaiseEventData {
512
- actionTimeStamp: PseudoVariantDateTime;
513
- status: PseudoVariantBoolean;
514
- serverId: PseudoVariantString;
515
- /**
516
- * ClientAuditEntryId contains the human-readable AuditEntryId defined in Part 3.
517
- */
518
- clientAuditEntryId: PseudoVariantString;
519
- /**
520
- * The ClientUserId identifies the user of the client requesting an action. The ClientUserId can be
521
- * obtained from the UserIdentityToken passed in the ActivateSession call.
522
- */
523
- clientUserId: PseudoVariantString;
524
- sourceName: PseudoVariantString;
525
- }
526
- export interface RaiseEventAuditUpdateMethodEventData extends RaiseEventAuditEventData {
527
- methodId: PseudoVariantNodeId;
528
- inputArguments: any;
529
- }
530
- export interface RaiseEventAuditConditionCommentEventData extends RaiseEventAuditUpdateMethodEventData {
531
- eventId: PseudoVariantByteString;
532
- comment: PseudoVariantLocalizedText;
533
- }
534
- export interface RaiseEventAuditSessionEventData extends RaiseEventAuditEventData {
535
- /**
536
- * part 5 - 6.4.7 AuditSessionEventType
537
- */
538
- sessionId: PseudoVariantNodeId;
539
- }
540
- export interface RaiseEventAuditCreateSessionEventData extends RaiseEventAuditSessionEventData {
541
- /**
542
- * part 5 - 6.4.8 AuditCreateSessionEventType
543
- * SecureChannelId shall uniquely identify the SecureChannel.
544
- * The application shall use the same identifier in
545
- * all AuditEvents related to the Session Service Set (AuditCreateSessionEventType, AuditActivateSessionEventType
546
- * and their subtypes) and the SecureChannel Service Set (AuditChannelEventType and its subtype
547
- */
548
- secureChannelId: PseudoVariantString;
549
- revisedSessionTimeout: PseudoVariantDuration;
550
- clientCertificate: PseudoVariantByteString;
551
- clientCertificateThumbprint: PseudoVariantString;
552
- }
553
- export interface RaiseEventAuditActivateSessionEventData extends RaiseEventAuditSessionEventData {
554
- /**
555
- * part 5 - 6.4.10 AuditActivateSessionEventType
556
- */
557
- clientSoftwareCertificates: PseudoVariantExtensionObjectArray;
558
- /**
559
- * UserIdentityToken reflects the userIdentityToken parameter of the ActivateSession Service call.
560
- * For Username/Password tokens the password should NOT be included.
561
- */
562
- userIdentityToken: PseudoVariantExtensionObject;
563
- /**
564
- * SecureChannelId shall uniquely identify the SecureChannel. The application shall use the same identifier
565
- * in all AuditEvents related to the Session Service Set (AuditCreateSessionEventType,
566
- * AuditActivateSessionEventType and their subtypes) and the SecureChannel Service Set
567
- * (AuditChannelEventType and its subtypes).
568
- */
569
- secureChannelId: PseudoVariantString;
570
- }
571
- export interface RaiseEventTransitionEventData extends RaiseEventData {
572
- }
573
- export interface RaiseEventAuditUrlMismatchEventTypeData extends RaiseEventData {
574
- endpointUrl: PseudoVariantString;
575
- }
576
- export interface OPCUAServer {
577
- /**
578
- * @internal
579
- * @param eventType
580
- * @param options
581
- */
582
- raiseEvent(eventType: "AuditSessionEventType", options: RaiseEventAuditSessionEventData): void;
583
- raiseEvent(eventType: "AuditCreateSessionEventType", options: RaiseEventAuditCreateSessionEventData): void;
584
- raiseEvent(eventType: "AuditActivateSessionEventType", options: RaiseEventAuditActivateSessionEventData): void;
585
- raiseEvent(eventType: "AuditCreateSessionEventType", options: RaiseEventData): void;
586
- raiseEvent(eventType: "AuditConditionCommentEventType", options: RaiseEventAuditConditionCommentEventData): void;
587
- raiseEvent(eventType: "AuditUrlMismatchEventType", options: RaiseEventAuditUrlMismatchEventTypeData): void;
588
- raiseEvent(eventType: "TransitionEventType", options: RaiseEventTransitionEventData): void;
589
- }
590
- export interface OPCUAServer extends EventEmitter {
591
- on(event: "create_session", eventHandler: (session: ServerSession) => void): this;
592
- on(event: "session_activated", eventHandler: (session: ServerSession) => void): this;
593
- on(event: "session_closed", eventHandler: (session: ServerSession, reason: string) => void): this;
594
- on(event: "post_initialize", eventHandler: () => void): this;
595
- /**
596
- * emitted when the server is trying to registered the LDS
597
- * but when the connection to the lds has failed
598
- * serverRegistrationPending is sent when the backoff signal of the
599
- * connection process is raised
600
- * @event serverRegistrationPending
601
- */
602
- on(event: "serverRegistrationPending", eventHandler: () => void): this;
603
- /**
604
- * event raised when server has been successfully registered on the local discovery server
605
- * @event serverRegistered
606
- */
607
- on(event: "serverRegistered", eventHandler: () => void): this;
608
- /**
609
- * event raised when server registration has been successfully renewed on the local discovery server
610
- * @event serverRegistered
611
- */
612
- on(event: "serverRegistrationRenewed", eventHandler: () => void): this;
613
- /**
614
- * event raised when server has been successfully unregistered from the local discovery server
615
- * @event serverUnregistered
616
- */
617
- on(event: "serverUnregistered", eventHandler: () => void): this;
618
- /**
619
- * event raised after the server has raised an OPCUA event toward a client
620
- */
621
- on(event: "event", eventHandler: (eventData: any) => void): this;
622
- /**
623
- * event raised when the server received a request from one of its connected client.
624
- * useful for trace purpose.
625
- */
626
- on(event: "request", eventHandler: (request: Request, channel: ServerSecureChannelLayer) => void): this;
627
- /**
628
- * event raised when the server send an response to a request to one of its connected client.
629
- * useful for trace purpose.
630
- */
631
- on(event: "response", eventHandler: (request: Response, channel: ServerSecureChannelLayer) => void): this;
632
- /**
633
- * event raised when a new secure channel is opened
634
- */
635
- on(event: "newChannel", eventHandler: (channel: ServerSecureChannelLayer, endpoint: OPCUAServerEndPoint) => void): this;
636
- /**
637
- * event raised when a new secure channel is closed
638
- */
639
- on(event: "closeChannel", eventHandler: (channel: ServerSecureChannelLayer, endpoint: OPCUAServerEndPoint) => void): this;
640
- /**
641
- * event raised when the server refused a tcp connection from a client. ( for instance because too any connections)
642
- */
643
- on(event: "connectionRefused", eventHandler: (socketData: ISocketData, endpoint: OPCUAServerEndPoint) => void): this;
644
- /**
645
- * event raised when a OpenSecureChannel has failed, it could be a invalid certificate or malformed message
646
- */
647
- on(event: "openSecureChannelFailure", eventHandler: (socketData: ISocketData, channelData: IChannelData, endpoint: OPCUAServerEndPoint) => void): this;
648
- on(event: string, eventHandler: (...args: [any?, ...any[]]) => void): this;
649
- }
650
- export {};
1
+ /**
2
+ * @module node-opcua-server
3
+ */
4
+ /// <reference types="node" />
5
+ import { EventEmitter } from "events";
6
+ import { PseudoVariantBoolean, PseudoVariantByteString, PseudoVariantDateTime, PseudoVariantDuration, PseudoVariantExtensionObject, PseudoVariantExtensionObjectArray, PseudoVariantLocalizedText, PseudoVariantNodeId, PseudoVariantString, RaiseEventData, PseudoVariantStringPredefined } from "node-opcua-address-space";
7
+ import { OPCUACertificateManager } from "node-opcua-certificate-manager";
8
+ import { Certificate, Nonce } from "node-opcua-crypto";
9
+ import { NodeId } from "node-opcua-nodeid";
10
+ import { ObjectRegistry } from "node-opcua-object-registry";
11
+ import { Message, MessageSecurityMode, Request, Response, SecurityPolicy, ServerSecureChannelLayer, SignatureData } from "node-opcua-secure-channel";
12
+ import { BrowseNextResponse, BrowseResponse } from "node-opcua-service-browse";
13
+ import { CallResponse } from "node-opcua-service-call";
14
+ import { HistoryReadResponse } from "node-opcua-service-history";
15
+ import { ReadResponse } from "node-opcua-service-read";
16
+ import { RegisterNodesResponse, UnregisterNodesResponse } from "node-opcua-service-register-node";
17
+ import { UserNameIdentityToken, X509IdentityToken } from "node-opcua-service-session";
18
+ import { CreateMonitoredItemsResponse, CreateSubscriptionResponse, DeleteSubscriptionsResponse, ModifyMonitoredItemsResponse, ModifySubscriptionResponse, RepublishResponse, SetPublishingModeResponse, SetTriggeringResponse, TransferSubscriptionsResponse } from "node-opcua-service-subscription";
19
+ import { TranslateBrowsePathsToNodeIdsResponse } from "node-opcua-service-translate-browse-path";
20
+ import { WriteResponse } from "node-opcua-service-write";
21
+ import { StatusCode } from "node-opcua-status-code";
22
+ import { ApplicationDescriptionOptions, BuildInfo, EndpointDescription, UserIdentityToken, UserTokenPolicy } from "node-opcua-types";
23
+ import { OPCUABaseServer, OPCUABaseServerOptions } from "./base_server";
24
+ import { IRegisterServerManager } from "./i_register_server_manager";
25
+ import { ServerCapabilitiesOptions } from "./server_capabilities";
26
+ import { OPCUAServerEndPoint } from "./server_end_point";
27
+ import { CreateSessionOption, ServerEngine } from "./server_engine";
28
+ import { ServerSession } from "./server_session";
29
+ import { CreateMonitoredItemHook, DeleteMonitoredItemHook, Subscription } from "./server_subscription";
30
+ import { ISocketData } from "./i_socket_data";
31
+ import { IChannelData } from "./i_channel_data";
32
+ import { UAUserManagerBase, UserManagerOptions } from "./user_manager";
33
+ declare type ResponseClassType = typeof BrowseResponse | typeof BrowseNextResponse | typeof CallResponse | typeof CreateMonitoredItemsResponse | typeof CreateSubscriptionResponse | typeof DeleteSubscriptionsResponse | typeof HistoryReadResponse | typeof ModifyMonitoredItemsResponse | typeof ModifySubscriptionResponse | typeof ReadResponse | typeof RegisterNodesResponse | typeof RepublishResponse | typeof SetPublishingModeResponse | typeof SetTriggeringResponse | typeof TransferSubscriptionsResponse | typeof TranslateBrowsePathsToNodeIdsResponse | typeof UnregisterNodesResponse | typeof WriteResponse;
34
+ export declare function filterDiagnosticInfo(returnDiagnostics: number, response: CallResponse): void;
35
+ export declare enum RegisterServerMethod {
36
+ HIDDEN = 1,
37
+ MDNS = 2,
38
+ LDS = 3
39
+ }
40
+ export interface OPCUAServerEndpointOptions {
41
+ /**
42
+ * the primary hostname of the endpoint.
43
+ * @default getFullyQualifiedDomainName()
44
+ */
45
+ hostname?: string;
46
+ /**
47
+ * the TCP port to listen to.
48
+ * @default 26543
49
+ */
50
+ port?: number;
51
+ /**
52
+ * the possible security policies that the server will expose
53
+ * @default [SecurityPolicy.None, SecurityPolicy.Basic128Rsa15, SecurityPolicy.Basic256Sha256, SecurityPolicy.Aes128_Sha256_RsaOaep, SecurityPolicy.Aes256_Sha256_RsaPss ]
54
+ */
55
+ securityPolicies?: SecurityPolicy[];
56
+ /**
57
+ * the possible security mode that the server will expose
58
+ * @default [MessageSecurityMode.None, MessageSecurityMode.Sign, MessageSecurityMode.SignAndEncrypt]
59
+ */
60
+ securityModes?: MessageSecurityMode[];
61
+ /**
62
+ * tells if the server default endpoints should allow anonymous connection.
63
+ * @default true
64
+ */
65
+ allowAnonymous?: boolean;
66
+ /** alternate hostname or IP to use */
67
+ alternateHostname?: string | string[];
68
+ /**
69
+ * true, if discovery service on secure channel shall be disabled
70
+ */
71
+ disableDiscovery?: boolean;
72
+ }
73
+ export interface OPCUAServerOptions extends OPCUABaseServerOptions, OPCUAServerEndpointOptions {
74
+ alternateEndpoints?: OPCUAServerEndpointOptions[];
75
+ /**
76
+ * the server certificate full path filename
77
+ *
78
+ * the certificate should be in PEM format
79
+ */
80
+ certificateFile?: string;
81
+ /**
82
+ * the server private key full path filename
83
+ *
84
+ * This file should contains the private key that has been used to generate
85
+ * the server certificate file.
86
+ *
87
+ * the private key should be in PEM format
88
+ *
89
+ */
90
+ privateKeyFile?: string;
91
+ /**
92
+ * the default secure token life time in ms.
93
+ */
94
+ defaultSecureTokenLifetime?: number;
95
+ /**
96
+ * the HEL/ACK transaction timeout in ms.
97
+ *
98
+ * Use a large value ( i.e 15000 ms) for slow connections or embedded devices.
99
+ * @default 10000
100
+ */
101
+ timeout?: number;
102
+ /**
103
+ * the maximum number of simultaneous sessions allowed.
104
+ * @default 10
105
+ * @deprecated use serverCapabilities: { maxSessions: } instead
106
+
107
+ */
108
+ maxAllowedSessionNumber?: number;
109
+ /**
110
+ * the maximum number authorized simultaneous connections per endpoint
111
+ * @default 10
112
+ */
113
+ maxConnectionsPerEndpoint?: number;
114
+ /**
115
+ * the nodeset.xml file(s) to load
116
+ *
117
+ * node-opcua comes with pre-installed node-set files that can be used
118
+ *
119
+ * example:
120
+ *
121
+ * ``` javascript
122
+ *
123
+ * ```
124
+ */
125
+ nodeset_filename?: string[] | string;
126
+ /**
127
+ * the server Info
128
+ *
129
+ * this object contains the value that will populate the
130
+ * Root/ObjectS/Server/ServerInfo OPCUA object in the address space.
131
+ */
132
+ serverInfo?: ApplicationDescriptionOptions;
133
+ buildInfo?: {
134
+ productName?: string;
135
+ productUri?: string | null;
136
+ manufacturerName?: string;
137
+ softwareVersion?: string;
138
+ buildNumber?: string;
139
+ buildDate?: Date;
140
+ };
141
+ /**
142
+ * an object that implements user authentication methods
143
+ */
144
+ userManager?: UserManagerOptions;
145
+ /** resource Path is a string added at the end of the url such as "/UA/Server" */
146
+ resourcePath?: string;
147
+ /**
148
+ *
149
+ */
150
+ serverCapabilities?: ServerCapabilitiesOptions;
151
+ /**
152
+ * if server shall raise AuditingEvent
153
+ * @default true
154
+ */
155
+ isAuditing?: boolean;
156
+ /**
157
+ * strategy used by the server to declare itself to a discovery server
158
+ *
159
+ * - HIDDEN: the server doesn't expose itself to the external world
160
+ * - MDNS: the server publish itself to the mDNS Multicast network directly
161
+ * - LDS: the server registers itself to the LDS or LDS-ME (Local Discovery Server)
162
+ *
163
+ * @default .HIDDEN - by default the server
164
+ * will not register itself to the local discovery server
165
+ *
166
+ */
167
+ registerServerMethod?: RegisterServerMethod;
168
+ /**
169
+ *
170
+ * @default "opc.tcp://localhost:4840"]
171
+ */
172
+ discoveryServerEndpointUrl?: string;
173
+ /**
174
+ *
175
+ * supported server capabilities for the Multicast (mDNS)
176
+ * @default ["NA"]
177
+ * the possible values are any of node-opcua-discovery.serverCapabilities)
178
+ *
179
+ */
180
+ capabilitiesForMDNS?: string[];
181
+ /**
182
+ * user Certificate Manager
183
+ * this certificate manager holds the X509 certificates used
184
+ * by client that uses X509 certificate token to impersonate a user
185
+ */
186
+ userCertificateManager?: OPCUACertificateManager;
187
+ /**
188
+ * Server Certificate Manager
189
+ *
190
+ * this certificate manager will be used by the server to access
191
+ * and store certificates from the connecting clients
192
+ */
193
+ serverCertificateManager?: OPCUACertificateManager;
194
+ /**
195
+ *
196
+ */
197
+ onCreateMonitoredItem?: CreateMonitoredItemHook;
198
+ onDeleteMonitoredItem?: DeleteMonitoredItemHook;
199
+ }
200
+ export interface OPCUAServer {
201
+ /**
202
+ *
203
+ */
204
+ engine: ServerEngine;
205
+ /**
206
+ *
207
+ */
208
+ registerServerMethod: RegisterServerMethod;
209
+ /**
210
+ *
211
+ */
212
+ discoveryServerEndpointUrl: string;
213
+ /**
214
+ *
215
+ */
216
+ registerServerManager?: IRegisterServerManager;
217
+ /**
218
+ *
219
+ */
220
+ capabilitiesForMDNS: string[];
221
+ /**
222
+ *
223
+ */
224
+ userCertificateManager: OPCUACertificateManager;
225
+ }
226
+ /**
227
+ *
228
+ */
229
+ export declare class OPCUAServer extends OPCUABaseServer {
230
+ static defaultShutdownTimeout: number;
231
+ /**
232
+ * if requestExactEndpointUrl is set to true the server will only accept createSession that have a endpointUrl that strictly matches
233
+ * one of the provided endpoint.
234
+ * This mean that if the server expose a endpoint with url such as opc.tcp://MYHOSTNAME:1234, client will not be able to reach the server
235
+ * with the ip address of the server.
236
+ * requestExactEndpointUrl = true => emulates the Prosys Server behavior
237
+ * requestExactEndpointUrl = false => emulates the Unified Automation behavior.
238
+ */
239
+ static requestExactEndpointUrl: boolean;
240
+ /**
241
+ * total number of bytes written by the server since startup
242
+ */
243
+ get bytesWritten(): number;
244
+ /**
245
+ * total number of bytes read by the server since startup
246
+ */
247
+ get bytesRead(): number;
248
+ /**
249
+ * Number of transactions processed by the server since startup
250
+ */
251
+ get transactionsCount(): number;
252
+ /**
253
+ * The server build info
254
+ */
255
+ get buildInfo(): BuildInfo;
256
+ /**
257
+ * the number of connected channel on all existing end points
258
+ */
259
+ get currentChannelCount(): number;
260
+ /**
261
+ * The number of active subscriptions from all sessions
262
+ */
263
+ get currentSubscriptionCount(): number;
264
+ /**
265
+ * the number of session activation requests that have been rejected
266
+ */
267
+ get rejectedSessionCount(): number;
268
+ /**
269
+ * the number of request that have been rejected
270
+ */
271
+ get rejectedRequestsCount(): number;
272
+ /**
273
+ * the number of sessions that have been aborted
274
+ */
275
+ get sessionAbortCount(): number;
276
+ /**
277
+ * the publishing interval count
278
+ */
279
+ get publishingIntervalCount(): number;
280
+ /**
281
+ * the number of sessions currently active
282
+ */
283
+ get currentSessionCount(): number;
284
+ /**
285
+ * true if the server has been initialized
286
+ *
287
+ */
288
+ get initialized(): boolean;
289
+ /**
290
+ * is the server auditing ?
291
+ */
292
+ get isAuditing(): boolean;
293
+ static registry: ObjectRegistry;
294
+ static fallbackSessionName: string;
295
+ /**
296
+ * the maximum number of subscription that can be created per server
297
+ * @deprecated
298
+ */
299
+ static deprectated_MAX_SUBSCRIPTION: number;
300
+ /**
301
+ * the maximum number of concurrent sessions allowed on the server
302
+ */
303
+ get maxAllowedSessionNumber(): number;
304
+ /**
305
+ * the maximum number for concurrent connection per end point
306
+ */
307
+ maxConnectionsPerEndpoint: number;
308
+ /**
309
+ * false if anonymous connection are not allowed
310
+ */
311
+ allowAnonymous: boolean;
312
+ /**
313
+ * the user manager
314
+ */
315
+ userManager: UAUserManagerBase;
316
+ readonly options: OPCUAServerOptions;
317
+ private objectFactory?;
318
+ private _delayInit?;
319
+ constructor(options?: OPCUAServerOptions);
320
+ /**
321
+ * Initialize the server by installing default node set.
322
+ *
323
+ * and instruct the server to listen to its endpoints.
324
+ *
325
+ * ```javascript
326
+ * const server = new OPCUAServer();
327
+ * await server.initialize();
328
+ *
329
+ * // default server namespace is now initialized
330
+ * // it is a good time to create life instance objects
331
+ * const namespace = server.engine.addressSpace.getOwnNamespace();
332
+ * namespace.addObject({
333
+ * browseName: "SomeObject",
334
+ * organizedBy: server.engine.addressSpace.rootFolder.objects
335
+ * });
336
+ *
337
+ * // the addressSpace is now complete
338
+ * // let's now start listening to clients
339
+ * await server.start();
340
+ * ```
341
+ */
342
+ initialize(): Promise<void>;
343
+ initialize(done: () => void): void;
344
+ /**
345
+ * Initiate the server by starting all its endpoints
346
+ * @async
347
+ */
348
+ start(): Promise<void>;
349
+ start(done: () => void): void;
350
+ /**
351
+ * shutdown all server endpoints
352
+ * @method shutdown
353
+ * @async
354
+ * @param timeout the timeout (in ms) before the server is actually shutdown
355
+ *
356
+ * @example
357
+ *
358
+ * ```javascript
359
+ * // shutdown immediately
360
+ * server.shutdown(function(err) {
361
+ * });
362
+ * ```
363
+ * ```ts
364
+ * // in typescript with promises
365
+ * server.shutdown(10000).then(()=>{
366
+ * console.log("Server has shutdown");
367
+ * });
368
+ * ```
369
+ * ```javascript
370
+ * // shutdown within 10 seconds
371
+ * server.engine.shutdownReason = coerceLocalizedText("Shutdown for maintenance");
372
+ * server.shutdown(10000,function(err) {
373
+ * });
374
+ * ```
375
+ */
376
+ shutdown(timeout?: number): Promise<void>;
377
+ shutdown(callback: (err?: Error) => void): void;
378
+ shutdown(timeout: number, callback: (err?: Error) => void): void;
379
+ dispose(): void;
380
+ raiseEvent(eventType: "AuditSessionEventType", options: RaiseEventAuditSessionEventData): void;
381
+ raiseEvent(eventType: "AuditCreateSessionEventType", options: RaiseEventAuditCreateSessionEventData): void;
382
+ raiseEvent(eventType: "AuditActivateSessionEventType", options: RaiseEventAuditActivateSessionEventData): void;
383
+ raiseEvent(eventType: "AuditCreateSessionEventType", options: RaiseEventData): void;
384
+ raiseEvent(eventType: "AuditConditionCommentEventType", options: RaiseEventAuditConditionCommentEventData): void;
385
+ raiseEvent(eventType: "AuditUrlMismatchEventType", options: RaiseEventAuditUrlMismatchEventTypeData): void;
386
+ raiseEvent(eventType: "TransitionEventType", options: RaiseEventTransitionEventData): void;
387
+ raiseEvent(eventType: "AuditCertificateInvalidEventType", options: RaiseAuditCertificateInvalidEventData): void;
388
+ raiseEvent(eventType: "AuditCertificateExpiredEventType", options: RaiseAuditCertificateExpiredEventData): void;
389
+ raiseEvent(eventType: "AuditCertificateUntrustedEventType", options: RaiseAuditCertificateUntrustedEventData): void;
390
+ raiseEvent(eventType: "AuditCertificateRevokedEventType", options: RaiseAuditCertificateRevokedEventData): void;
391
+ raiseEvent(eventType: "AuditCertificateMismatchEventType", options: RaiseAuditCertificateMismatchEventData): void;
392
+ /**
393
+ * create and register a new session
394
+ * @internal
395
+ */
396
+ protected createSession(options: CreateSessionOption): ServerSession;
397
+ /**
398
+ * retrieve a session by authentication token
399
+ * @internal
400
+ */
401
+ protected getSession(authenticationToken: NodeId, activeOnly?: boolean): ServerSession | null;
402
+ /**
403
+ *
404
+ * @param channel
405
+ * @param clientCertificate
406
+ * @param clientNonce
407
+ * @internal
408
+ */
409
+ protected computeServerSignature(channel: ServerSecureChannelLayer, clientCertificate: Certificate, clientNonce: Nonce): SignatureData | undefined;
410
+ /**
411
+ *
412
+ * @param session
413
+ * @param channel
414
+ * @param clientSignature
415
+ * @internal
416
+ */
417
+ protected verifyClientSignature(session: ServerSession, channel: ServerSecureChannelLayer, clientSignature: SignatureData): boolean;
418
+ protected isValidUserNameIdentityToken(channel: ServerSecureChannelLayer, session: ServerSession, userTokenPolicy: UserTokenPolicy, userIdentityToken: UserNameIdentityToken, userTokenSignature: SignatureData, callback: (err: Error | null, statusCode?: StatusCode) => void): void;
419
+ protected isValidX509IdentityToken(channel: ServerSecureChannelLayer, session: ServerSession, userTokenPolicy: UserTokenPolicy, userIdentityToken: X509IdentityToken, userTokenSignature: SignatureData, callback: (err: Error | null, statusCode?: StatusCode) => void): void;
420
+ /**
421
+ * @internal
422
+ */
423
+ protected userNameIdentityTokenAuthenticateUser(channel: ServerSecureChannelLayer, session: ServerSession, userTokenPolicy: UserTokenPolicy, userIdentityToken: UserNameIdentityToken, callback: (err: Error | null, isAuthorized?: boolean) => void): void;
424
+ /**
425
+ * @internal
426
+ */
427
+ protected isValidUserIdentityToken(channel: ServerSecureChannelLayer, session: ServerSession, userIdentityToken: UserIdentityToken, userTokenSignature: SignatureData, endpointDescription: EndpointDescription, callback: (err: Error | null, statusCode?: StatusCode) => void): void;
428
+ /**
429
+ *
430
+ * @internal
431
+ * @param channel
432
+ * @param session
433
+ * @param userIdentityToken
434
+ * @param callback
435
+ * @returns {*}
436
+ */
437
+ protected isUserAuthorized(channel: ServerSecureChannelLayer, session: ServerSession, userIdentityToken: UserIdentityToken, callback: (err: Error | null, isAuthorized?: boolean) => void): void;
438
+ protected makeServerNonce(): Nonce;
439
+ protected _on_CreateSessionRequest(message: Message, channel: ServerSecureChannelLayer): Promise<void>;
440
+ /**
441
+ *
442
+ * @method _on_ActivateSessionRequest
443
+ * @private
444
+ *
445
+ *
446
+ */
447
+ protected _on_ActivateSessionRequest(message: Message, channel: ServerSecureChannelLayer): void;
448
+ protected prepare(message: Message, channel: ServerSecureChannelLayer): void;
449
+ /**
450
+ * ensure that action is performed on a valid session object,
451
+ * @method _apply_on_SessionObject
452
+ * @param ResponseClass the constructor of the response Class
453
+ * @param message
454
+ * @param channel
455
+ * @param actionToPerform
456
+ * @param actionToPerform.session {ServerSession}
457
+ * @param actionToPerform.sendResponse
458
+ * @param actionToPerform.sendResponse.response
459
+ * @param actionToPerform.sendError
460
+ * @param actionToPerform.sendError.statusCode
461
+ * @param actionToPerform.sendError.diagnostics
462
+ *
463
+ * @private
464
+ */
465
+ protected _apply_on_SessionObject(ResponseClass: ResponseClassType, message: Message, channel: ServerSecureChannelLayer, actionToPerform: (session: ServerSession, sendResponse: (response: Response) => void, sendError: (statusCode: StatusCode) => void) => void | Promise<void>): Promise<void>;
466
+ protected _apply_on_Subscription(ResponseClass: ResponseClassType, message: Message, channel: ServerSecureChannelLayer, actionToPerform: (session: ServerSession, subscription: Subscription, sendResponse: (response: Response) => void, sendError: (statusCode: StatusCode) => void) => Promise<void>): Promise<void>;
467
+ protected _apply_on_SubscriptionIds<T>(ResponseClass: typeof SetPublishingModeResponse | typeof TransferSubscriptionsResponse | typeof DeleteSubscriptionsResponse, message: Message, channel: ServerSecureChannelLayer, actionToPerform: (session: ServerSession, subscriptionId: number) => Promise<T>): void;
468
+ protected _apply_on_Subscriptions(ResponseClass: typeof SetPublishingModeResponse | typeof TransferSubscriptionsResponse | typeof DeleteSubscriptionsResponse, message: Message, channel: ServerSecureChannelLayer, actionToPerform: (session: ServerSession, subscription: Subscription) => Promise<StatusCode>): void;
469
+ private _closeSession;
470
+ /**
471
+ * @method _on_CloseSessionRequest
472
+ * @param message
473
+ * @param channel
474
+ * @private
475
+ */
476
+ protected _on_CloseSessionRequest(message: Message, channel: ServerSecureChannelLayer): void;
477
+ /**
478
+ * @method _on_BrowseRequest
479
+ * @param message
480
+ * @param channel
481
+ * @private
482
+ */
483
+ protected _on_BrowseRequest(message: Message, channel: ServerSecureChannelLayer): void;
484
+ /**
485
+ * @method _on_BrowseNextRequest
486
+ * @param message
487
+ * @param channel
488
+ * @private
489
+ */
490
+ protected _on_BrowseNextRequest(message: Message, channel: ServerSecureChannelLayer): void;
491
+ protected _on_ReadRequest(message: Message, channel: ServerSecureChannelLayer): void;
492
+ protected _on_HistoryReadRequest(message: Message, channel: ServerSecureChannelLayer): void;
493
+ protected _on_WriteRequest(message: Message, channel: ServerSecureChannelLayer): void;
494
+ protected _on_CreateSubscriptionRequest(message: Message, channel: ServerSecureChannelLayer): void;
495
+ protected _on_DeleteSubscriptionsRequest(message: Message, channel: ServerSecureChannelLayer): void;
496
+ protected _on_TransferSubscriptionsRequest(message: Message, channel: ServerSecureChannelLayer): void;
497
+ protected _on_CreateMonitoredItemsRequest(message: Message, channel: ServerSecureChannelLayer): void;
498
+ protected _on_ModifySubscriptionRequest(message: Message, channel: ServerSecureChannelLayer): void;
499
+ protected _on_ModifyMonitoredItemsRequest(message: Message, channel: ServerSecureChannelLayer): void;
500
+ protected _on_PublishRequest(message: Message, channel: ServerSecureChannelLayer): void;
501
+ protected _on_SetPublishingModeRequest(message: Message, channel: ServerSecureChannelLayer): void;
502
+ protected _on_DeleteMonitoredItemsRequest(message: Message, channel: ServerSecureChannelLayer): void;
503
+ protected _on_SetTriggeringRequest(message: Message, channel: ServerSecureChannelLayer): void;
504
+ protected _beforeDeleteSubscription(subscription: Subscription): Promise<void>;
505
+ protected _on_RepublishRequest(message: Message, channel: ServerSecureChannelLayer): void;
506
+ protected _on_SetMonitoringModeRequest(message: Message, channel: ServerSecureChannelLayer): void;
507
+ protected _on_TranslateBrowsePathsToNodeIdsRequest(message: Message, channel: ServerSecureChannelLayer): void;
508
+ protected _on_CallRequest(message: Message, channel: ServerSecureChannelLayer): void;
509
+ protected _on_RegisterNodesRequest(message: Message, channel: ServerSecureChannelLayer): void;
510
+ protected _on_UnregisterNodesRequest(message: Message, channel: ServerSecureChannelLayer): void;
511
+ protected _on_Cancel(message: Message, channel: ServerSecureChannelLayer): void;
512
+ protected _on_AddNodes(message: Message, channel: ServerSecureChannelLayer): void;
513
+ protected _on_AddReferences(message: Message, channel: ServerSecureChannelLayer): void;
514
+ protected _on_DeleteNodes(message: Message, channel: ServerSecureChannelLayer): void;
515
+ protected _on_DeleteReferences(message: Message, channel: ServerSecureChannelLayer): void;
516
+ protected _on_QueryFirst(message: Message, channel: ServerSecureChannelLayer): void;
517
+ protected _on_QueryNext(message: Message, channel: ServerSecureChannelLayer): void;
518
+ protected _on_HistoryUpdate(message: Message, channel: ServerSecureChannelLayer): void;
519
+ private createEndpoint;
520
+ private createEndpointDescriptions;
521
+ initializeCM(): Promise<void>;
522
+ }
523
+ export interface RaiseEventAuditEventData extends RaiseEventData {
524
+ actionTimeStamp: PseudoVariantDateTime;
525
+ status: PseudoVariantBoolean;
526
+ serverId: PseudoVariantString;
527
+ /**
528
+ * ClientAuditEntryId contains the human-readable AuditEntryId defined in Part 3.
529
+ */
530
+ clientAuditEntryId: PseudoVariantString;
531
+ /**
532
+ * The ClientUserId identifies the user of the client requesting an action. The ClientUserId can be
533
+ * obtained from the UserIdentityToken passed in the ActivateSession call.
534
+ */
535
+ clientUserId: PseudoVariantString;
536
+ sourceName: PseudoVariantString;
537
+ }
538
+ export interface RaiseEventAuditUpdateMethodEventData extends RaiseEventAuditEventData {
539
+ methodId: PseudoVariantNodeId;
540
+ inputArguments: any;
541
+ }
542
+ export interface RaiseEventAuditConditionCommentEventData extends RaiseEventAuditUpdateMethodEventData {
543
+ eventId: PseudoVariantByteString;
544
+ comment: PseudoVariantLocalizedText;
545
+ }
546
+ export interface RaiseEventAuditSessionEventData extends RaiseEventAuditEventData {
547
+ /**
548
+ * part 5 - 6.4.7 AuditSessionEventType
549
+ */
550
+ sessionId: PseudoVariantNodeId;
551
+ }
552
+ export interface RaiseEventAuditCreateSessionEventData extends RaiseEventAuditSessionEventData {
553
+ /**
554
+ * part 5 - 6.4.8 AuditCreateSessionEventType
555
+ * SecureChannelId shall uniquely identify the SecureChannel.
556
+ * The application shall use the same identifier in
557
+ * all AuditEvents related to the Session Service Set (AuditCreateSessionEventType, AuditActivateSessionEventType
558
+ * and their subtypes) and the SecureChannel Service Set (AuditChannelEventType and its subtype
559
+ */
560
+ secureChannelId: PseudoVariantString;
561
+ revisedSessionTimeout: PseudoVariantDuration;
562
+ clientCertificate: PseudoVariantByteString;
563
+ clientCertificateThumbprint: PseudoVariantString;
564
+ }
565
+ export interface RaiseEventAuditActivateSessionEventData extends RaiseEventAuditSessionEventData {
566
+ /**
567
+ * part 5 - 6.4.10 AuditActivateSessionEventType
568
+ */
569
+ clientSoftwareCertificates: PseudoVariantExtensionObjectArray;
570
+ /**
571
+ * UserIdentityToken reflects the userIdentityToken parameter of the ActivateSession Service call.
572
+ * For Username/Password tokens the password should NOT be included.
573
+ */
574
+ userIdentityToken: PseudoVariantExtensionObject;
575
+ /**
576
+ * SecureChannelId shall uniquely identify the SecureChannel. The application shall use the same identifier
577
+ * in all AuditEvents related to the Session Service Set (AuditCreateSessionEventType,
578
+ * AuditActivateSessionEventType and their subtypes) and the SecureChannel Service Set
579
+ * (AuditChannelEventType and its subtypes).
580
+ */
581
+ secureChannelId: PseudoVariantString;
582
+ }
583
+ export interface RaiseEventTransitionEventData extends RaiseEventData {
584
+ }
585
+ export interface RaiseEventAuditUrlMismatchEventTypeData extends RaiseEventData {
586
+ endpointUrl: PseudoVariantString;
587
+ }
588
+ /**
589
+ * The SourceName for Events of this type shall be “Security/Certificate”.
590
+ */
591
+ export interface RaiseAuditCertificateEventData extends RaiseEventData {
592
+ certificate: PseudoVariantByteString;
593
+ sourceName: PseudoVariantStringPredefined<"Security/Certificate">;
594
+ }
595
+ /**
596
+ * This EventType inherits all Properties of the AuditCertificateEventType.
597
+ * Either the InvalidHostname or InvalidUri shall be provided.
598
+ */
599
+ export interface RaiseAuditCertificateDataMismatchEventData extends RaiseAuditCertificateEventData {
600
+ /**
601
+ * InvalidHostname is the string that represents the host name passed in as part of the URL
602
+ * that is found to be invalid. If the host name was not invalid it can be null.
603
+ */
604
+ invalidHostname: PseudoVariantString;
605
+ invalidUri: PseudoVariantString;
606
+ }
607
+ export interface RaiseAuditCertificateUntrustedEventData extends RaiseAuditCertificateEventData {
608
+ }
609
+ /**
610
+ * This EventType inherits all Properties of the AuditCertificateEventType.
611
+ *
612
+ * The SourceName for Events of this type shall be “Security/Certificate”.
613
+ *
614
+ * The Message Variable shall include a description of why the certificate was expired
615
+ * (i.e. time before start or time after end).
616
+ *
617
+ * There are no additional Properties defined for this EventType.
618
+ *
619
+ */
620
+ export interface RaiseAuditCertificateExpiredEventData extends RaiseAuditCertificateEventData {
621
+ }
622
+ /**
623
+ * This EventType inherits all Properties of the AuditCertificateEventType.
624
+ *
625
+ * The SourceName for Events of this type shall be “Security/Certificate”.
626
+ *
627
+ * The Message shall include a description of why the certificate is invalid.
628
+ *
629
+ * There are no additional Properties defined for this EventType.
630
+ */
631
+ export interface RaiseAuditCertificateInvalidEventData extends RaiseAuditCertificateEventData {
632
+ }
633
+ /**
634
+ * This EventType inherits all Properties of the AuditCertificateEventType.
635
+ *
636
+ * The SourceName for Events of this type shall be “Security/Certificate”.
637
+ *
638
+ * The Message Variable shall include a description of why the certificate is not trusted.
639
+ * If a trust chain is involved then the certificate that failed in the trust chain should be described.
640
+ * There are no additional Properties defined for this EventType.
641
+ */
642
+ export interface RaiseAuditCertificateUntrustedEventData extends RaiseAuditCertificateEventData {
643
+ }
644
+ /**
645
+ * This EventType inherits all Properties of the AuditCertificateEventType.
646
+ *
647
+ * The SourceName for Events of this type shall be “Security/Certificate”.
648
+ *
649
+ * The Message Variable shall include a description of why the certificate is revoked
650
+ * (was the revocation list unavailable or was the certificate on the list).
651
+ *
652
+ * There are no additional Properties defined for this EventType.
653
+ */
654
+ export interface RaiseAuditCertificateRevokedEventData extends RaiseAuditCertificateEventData {
655
+ sourceName: PseudoVariantStringPredefined<"Security/Certificate">;
656
+ }
657
+ /**
658
+ * This EventType inherits all Properties of the AuditCertificateEventType.
659
+ *
660
+ * The SourceName for Events of this type shall be “Security/Certificate”.
661
+ *
662
+ * The Message Variable shall include a description of misuse of the certificate.
663
+ *
664
+ * There are no additional Properties defined for this EventType
665
+ */
666
+ export interface RaiseAuditCertificateMismatchEventData extends RaiseAuditCertificateEventData {
667
+ }
668
+ export interface OPCUAServer {
669
+ /**
670
+ * @internal
671
+ * @param eventType
672
+ * @param options
673
+ */
674
+ raiseEvent(eventType: "AuditSessionEventType", options: RaiseEventAuditSessionEventData): void;
675
+ raiseEvent(eventType: "AuditCreateSessionEventType", options: RaiseEventAuditCreateSessionEventData): void;
676
+ raiseEvent(eventType: "AuditActivateSessionEventType", options: RaiseEventAuditActivateSessionEventData): void;
677
+ raiseEvent(eventType: "AuditCreateSessionEventType", options: RaiseEventData): void;
678
+ raiseEvent(eventType: "AuditConditionCommentEventType", options: RaiseEventAuditConditionCommentEventData): void;
679
+ raiseEvent(eventType: "AuditUrlMismatchEventType", options: RaiseEventAuditUrlMismatchEventTypeData): void;
680
+ raiseEvent(eventType: "TransitionEventType", options: RaiseEventTransitionEventData): void;
681
+ raiseEvent(eventType: "AuditCertificateInvalidEventType", options: RaiseAuditCertificateInvalidEventData): void;
682
+ raiseEvent(eventType: "AuditCertificateExpiredEventType", options: RaiseAuditCertificateExpiredEventData): void;
683
+ raiseEvent(eventType: "AuditCertificateUntrustedEventType", options: RaiseAuditCertificateUntrustedEventData): void;
684
+ raiseEvent(eventType: "AuditCertificateRevokedEventType", options: RaiseAuditCertificateRevokedEventData): void;
685
+ raiseEvent(eventType: "AuditCertificateMismatchEventType", options: RaiseAuditCertificateMismatchEventData): void;
686
+ }
687
+ export interface OPCUAServer extends EventEmitter {
688
+ on(event: "create_session", eventHandler: (session: ServerSession) => void): this;
689
+ on(event: "session_activated", eventHandler: (session: ServerSession) => void): this;
690
+ on(event: "session_closed", eventHandler: (session: ServerSession, reason: string) => void): this;
691
+ on(event: "post_initialize", eventHandler: () => void): this;
692
+ /**
693
+ * emitted when the server is trying to registered the LDS
694
+ * but when the connection to the lds has failed
695
+ * serverRegistrationPending is sent when the backoff signal of the
696
+ * connection process is raised
697
+ * @event serverRegistrationPending
698
+ */
699
+ on(event: "serverRegistrationPending", eventHandler: () => void): this;
700
+ /**
701
+ * event raised when server has been successfully registered on the local discovery server
702
+ * @event serverRegistered
703
+ */
704
+ on(event: "serverRegistered", eventHandler: () => void): this;
705
+ /**
706
+ * event raised when server registration has been successfully renewed on the local discovery server
707
+ * @event serverRegistered
708
+ */
709
+ on(event: "serverRegistrationRenewed", eventHandler: () => void): this;
710
+ /**
711
+ * event raised when server has been successfully unregistered from the local discovery server
712
+ * @event serverUnregistered
713
+ */
714
+ on(event: "serverUnregistered", eventHandler: () => void): this;
715
+ /**
716
+ * event raised after the server has raised an OPCUA event toward a client
717
+ */
718
+ on(event: "event", eventHandler: (eventData: any) => void): this;
719
+ /**
720
+ * event raised when the server received a request from one of its connected client.
721
+ * useful for trace purpose.
722
+ */
723
+ on(event: "request", eventHandler: (request: Request, channel: ServerSecureChannelLayer) => void): this;
724
+ /**
725
+ * event raised when the server send an response to a request to one of its connected client.
726
+ * useful for trace purpose.
727
+ */
728
+ on(event: "response", eventHandler: (request: Response, channel: ServerSecureChannelLayer) => void): this;
729
+ /**
730
+ * event raised when a new secure channel is opened
731
+ */
732
+ on(event: "newChannel", eventHandler: (channel: ServerSecureChannelLayer, endpoint: OPCUAServerEndPoint) => void): this;
733
+ /**
734
+ * event raised when a new secure channel is closed
735
+ */
736
+ on(event: "closeChannel", eventHandler: (channel: ServerSecureChannelLayer, endpoint: OPCUAServerEndPoint) => void): this;
737
+ /**
738
+ * event raised when the server refused a tcp connection from a client. ( for instance because too any connections)
739
+ */
740
+ on(event: "connectionRefused", eventHandler: (socketData: ISocketData, endpoint: OPCUAServerEndPoint) => void): this;
741
+ /**
742
+ * event raised when a OpenSecureChannel has failed, it could be a invalid certificate or malformed message
743
+ */
744
+ on(event: "openSecureChannelFailure", eventHandler: (socketData: ISocketData, channelData: IChannelData, endpoint: OPCUAServerEndPoint) => void): this;
745
+ on(event: string, eventHandler: (...args: [any?, ...any[]]) => void): this;
746
+ }
747
+ export {};