node-opcua-server 2.64.1 → 2.65.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 (57) hide show
  1. package/dist/base_server.d.ts +110 -110
  2. package/dist/base_server.js +473 -473
  3. package/dist/factory.d.ts +12 -12
  4. package/dist/factory.js +23 -23
  5. package/dist/history_server_capabilities.d.ts +35 -35
  6. package/dist/history_server_capabilities.js +43 -43
  7. package/dist/i_channel_data.d.ts +13 -13
  8. package/dist/i_channel_data.js +2 -2
  9. package/dist/i_register_server_manager.d.ts +16 -16
  10. package/dist/i_register_server_manager.js +2 -2
  11. package/dist/i_server_side_publish_engine.d.ts +36 -36
  12. package/dist/i_server_side_publish_engine.js +49 -49
  13. package/dist/i_socket_data.d.ts +11 -11
  14. package/dist/i_socket_data.js +2 -2
  15. package/dist/index.d.ts +14 -14
  16. package/dist/index.js +26 -26
  17. package/dist/monitored_item.d.ts +176 -176
  18. package/dist/monitored_item.js +998 -998
  19. package/dist/node_sampler.d.ts +3 -3
  20. package/dist/node_sampler.js +75 -75
  21. package/dist/opcua_server.d.ts +654 -654
  22. package/dist/opcua_server.js +2389 -2389
  23. package/dist/opcua_server.js.map +1 -1
  24. package/dist/queue.d.ts +11 -11
  25. package/dist/queue.js +71 -71
  26. package/dist/register_server_manager.d.ts +95 -95
  27. package/dist/register_server_manager.js +584 -584
  28. package/dist/register_server_manager_hidden.d.ts +17 -17
  29. package/dist/register_server_manager_hidden.js +27 -27
  30. package/dist/register_server_manager_mdns_only.d.ts +22 -22
  31. package/dist/register_server_manager_mdns_only.js +57 -57
  32. package/dist/server_capabilities.d.ts +61 -61
  33. package/dist/server_capabilities.js +108 -108
  34. package/dist/server_end_point.d.ts +183 -183
  35. package/dist/server_end_point.js +816 -816
  36. package/dist/server_engine.d.ts +315 -315
  37. package/dist/server_engine.js +1678 -1678
  38. package/dist/server_publish_engine.d.ts +112 -112
  39. package/dist/server_publish_engine.js +530 -530
  40. package/dist/server_publish_engine_for_orphan_subscriptions.d.ts +16 -16
  41. package/dist/server_publish_engine_for_orphan_subscriptions.js +49 -49
  42. package/dist/server_session.d.ts +180 -180
  43. package/dist/server_session.js +737 -737
  44. package/dist/server_subscription.d.ts +395 -395
  45. package/dist/server_subscription.js +1316 -1316
  46. package/dist/sessions_compatible_for_transfer.d.ts +2 -2
  47. package/dist/sessions_compatible_for_transfer.js +36 -36
  48. package/dist/validate_filter.d.ts +5 -5
  49. package/dist/validate_filter.js +60 -60
  50. package/package.json +27 -27
  51. package/source/opcua_server.ts +1 -1
  52. package/dist/I_register_server_manager.d.ts +0 -15
  53. package/dist/I_register_server_manager.js +0 -3
  54. package/dist/I_register_server_manager.js.map +0 -1
  55. package/dist/continuation_point_manager.d.ts +0 -18
  56. package/dist/continuation_point_manager.js +0 -84
  57. package/dist/continuation_point_manager.js.map +0 -1
@@ -1,654 +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 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 {};
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 {};