node-opcua-server 2.71.0 → 2.72.2

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