node-opcua-server 2.63.1 → 2.64.1

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