node-opcua-server 2.68.1 → 2.70.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/monitored_item.d.ts +1 -0
- package/dist/opcua_server.d.ts +1 -1
- package/dist/opcua_server.js +9 -8
- package/dist/opcua_server.js.map +1 -1
- package/dist/register_server_manager.d.ts +1 -0
- package/dist/register_server_manager_mdns_only.js +6 -8
- package/dist/register_server_manager_mdns_only.js.map +1 -1
- package/dist/server_engine.d.ts +2 -1
- package/dist/server_engine.js +49 -39
- package/dist/server_engine.js.map +1 -1
- package/dist/server_session.d.ts +1 -0
- package/package.json +87 -88
- package/source/opcua_server.ts +12 -13
- package/source/register_server_manager_mdns_only.ts +6 -8
- package/source/server_engine.ts +10 -10
package/source/opcua_server.ts
CHANGED
|
@@ -167,8 +167,7 @@ import { CreateMonitoredItemHook, DeleteMonitoredItemHook, Subscription } from "
|
|
|
167
167
|
import { ISocketData } from "./i_socket_data";
|
|
168
168
|
import { IChannelData } from "./i_channel_data";
|
|
169
169
|
import { UAUserManagerBase, makeUserManager, UserManagerOptions } from "./user_manager";
|
|
170
|
-
import { bindRoleSet} from "./user_manager_ua";
|
|
171
|
-
|
|
170
|
+
import { bindRoleSet } from "./user_manager_ua";
|
|
172
171
|
|
|
173
172
|
function isSubscriptionIdInvalid(subscriptionId: number): boolean {
|
|
174
173
|
return subscriptionId < 0 || subscriptionId >= 0xffffffff;
|
|
@@ -605,7 +604,8 @@ function validate_applicationUri(channel: ServerSecureChannelLayer, request: Cre
|
|
|
605
604
|
return true; // can't check
|
|
606
605
|
}
|
|
607
606
|
const e = exploreCertificate(clientCertificate);
|
|
608
|
-
const
|
|
607
|
+
const uniformResourceIdentifier = e.tbsCertificate.extensions!.subjectAltName?.uniformResourceIdentifier ?? null;
|
|
608
|
+
const applicationUriFromCert = uniformResourceIdentifier && uniformResourceIdentifier.length > 0 ? uniformResourceIdentifier[0] : null;
|
|
609
609
|
|
|
610
610
|
/* istanbul ignore next */
|
|
611
611
|
if (applicationUriFromCert !== applicationUri) {
|
|
@@ -848,7 +848,7 @@ export interface OPCUAServerOptions extends OPCUABaseServerOptions, OPCUAServerE
|
|
|
848
848
|
* - MDNS: the server publish itself to the mDNS Multicast network directly
|
|
849
849
|
* - LDS: the server registers itself to the LDS or LDS-ME (Local Discovery Server)
|
|
850
850
|
*
|
|
851
|
-
* @default
|
|
851
|
+
* @default .HIDDEN - by default the server
|
|
852
852
|
* will not register itself to the local discovery server
|
|
853
853
|
*
|
|
854
854
|
*/
|
|
@@ -1309,8 +1309,8 @@ export class OPCUAServer extends OPCUABaseServer {
|
|
|
1309
1309
|
debugLog("OPCUAServer is now unregistering itself from the discovery server " + this.buildInfo);
|
|
1310
1310
|
this.registerServerManager!.stop((err?: Error | null) => {
|
|
1311
1311
|
debugLog("OPCUAServer unregistered from discovery server", err);
|
|
1312
|
-
setTimeout(() => {
|
|
1313
|
-
this.engine.shutdown();
|
|
1312
|
+
setTimeout(async () => {
|
|
1313
|
+
await this.engine.shutdown();
|
|
1314
1314
|
|
|
1315
1315
|
debugLog("OPCUAServer#shutdown: started");
|
|
1316
1316
|
OPCUABaseServer.prototype.shutdown.call(this, (err1?: Error) => {
|
|
@@ -1403,7 +1403,7 @@ export class OPCUAServer extends OPCUABaseServer {
|
|
|
1403
1403
|
clientCertificate: Certificate,
|
|
1404
1404
|
clientNonce: Nonce
|
|
1405
1405
|
): SignatureData | undefined {
|
|
1406
|
-
return computeSignature(clientCertificate, clientNonce, this.getPrivateKey(), channel.messageBuilder
|
|
1406
|
+
return computeSignature(clientCertificate, clientNonce, this.getPrivateKey(), channel.messageBuilder!.securityPolicy);
|
|
1407
1407
|
}
|
|
1408
1408
|
|
|
1409
1409
|
/**
|
|
@@ -1419,7 +1419,7 @@ export class OPCUAServer extends OPCUABaseServer {
|
|
|
1419
1419
|
clientSignature: SignatureData
|
|
1420
1420
|
): boolean {
|
|
1421
1421
|
const clientCertificate = channel.receiverCertificate!;
|
|
1422
|
-
const securityPolicy = channel.messageBuilder
|
|
1422
|
+
const securityPolicy = channel.messageBuilder!.securityPolicy;
|
|
1423
1423
|
const serverCertificate = this.getCertificate();
|
|
1424
1424
|
|
|
1425
1425
|
const result = verifySignature(serverCertificate, session.nonce!, clientSignature, clientCertificate, securityPolicy);
|
|
@@ -1472,7 +1472,7 @@ export class OPCUAServer extends OPCUABaseServer {
|
|
|
1472
1472
|
callback: (err: Error | null, statusCode?: StatusCode) => void
|
|
1473
1473
|
): void {
|
|
1474
1474
|
assert(userIdentityToken instanceof X509IdentityToken);
|
|
1475
|
-
assert(typeof callback ===
|
|
1475
|
+
assert(typeof callback === "function");
|
|
1476
1476
|
|
|
1477
1477
|
const securityPolicy = adjustSecurityPolicy(channel, userTokenPolicy.securityPolicyUri);
|
|
1478
1478
|
|
|
@@ -1605,7 +1605,7 @@ export class OPCUAServer extends OPCUABaseServer {
|
|
|
1605
1605
|
endpointDescription: EndpointDescription,
|
|
1606
1606
|
callback: (err: Error | null, statusCode?: StatusCode) => void
|
|
1607
1607
|
): void {
|
|
1608
|
-
assert(typeof callback ===
|
|
1608
|
+
assert(typeof callback === "function");
|
|
1609
1609
|
/* istanbul ignore next */
|
|
1610
1610
|
if (!userIdentityToken) {
|
|
1611
1611
|
throw new Error("Invalid token");
|
|
@@ -2064,10 +2064,9 @@ export class OPCUAServer extends OPCUABaseServer {
|
|
|
2064
2064
|
if (statusCode !== StatusCodes.Good) {
|
|
2065
2065
|
/* istanbul ignore next */
|
|
2066
2066
|
if (!(statusCode && statusCode instanceof StatusCode)) {
|
|
2067
|
-
|
|
2067
|
+
return rejectConnection(this, StatusCodes.BadCertificateInvalid);
|
|
2068
2068
|
}
|
|
2069
|
-
|
|
2070
|
-
return rejectConnection(this, statusCode!);
|
|
2069
|
+
return rejectConnection(this, statusCode);
|
|
2071
2070
|
}
|
|
2072
2071
|
session.userIdentityToken = request.userIdentityToken as UserIdentityToken;
|
|
2073
2072
|
|
|
@@ -29,12 +29,11 @@ export class RegisterServerManagerMDNSONLY extends EventEmitter implements IRegi
|
|
|
29
29
|
|
|
30
30
|
public stop(callback: () => void): void {
|
|
31
31
|
if (this.bonjour) {
|
|
32
|
-
this.bonjour.
|
|
32
|
+
this.bonjour.stopAnnouncedOnMulticastSubnetWithCallback(()=>{
|
|
33
|
+
this.emit("serverUnregistered");
|
|
34
|
+
setImmediate(callback);
|
|
35
|
+
});
|
|
33
36
|
}
|
|
34
|
-
setImmediate(() => {
|
|
35
|
-
this.emit("serverUnregistered");
|
|
36
|
-
setImmediate(callback);
|
|
37
|
-
});
|
|
38
37
|
}
|
|
39
38
|
|
|
40
39
|
public start(callback: () => void): void {
|
|
@@ -44,13 +43,12 @@ export class RegisterServerManagerMDNSONLY extends EventEmitter implements IRegi
|
|
|
44
43
|
}
|
|
45
44
|
assert(this.server instanceof OPCUABaseServer);
|
|
46
45
|
|
|
47
|
-
this.bonjour.
|
|
46
|
+
this.bonjour.announcedOnMulticastSubnetWithCallback({
|
|
48
47
|
capabilities: this.server.capabilitiesForMDNS,
|
|
49
48
|
name: this.server.serverInfo.applicationUri!,
|
|
50
49
|
path: "/", // <- to do
|
|
51
50
|
port: this.server.endpoints[0].port
|
|
52
|
-
})
|
|
53
|
-
setImmediate(() => {
|
|
51
|
+
}, ()=>{
|
|
54
52
|
this.emit("serverRegistered");
|
|
55
53
|
setImmediate(callback);
|
|
56
54
|
});
|
package/source/server_engine.ts
CHANGED
|
@@ -104,9 +104,9 @@ function upperCaseFirst(str: string) {
|
|
|
104
104
|
return str.slice(0, 1).toUpperCase() + str.slice(1);
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
-
function shutdownAndDisposeAddressSpace(this: ServerEngine) {
|
|
107
|
+
async function shutdownAndDisposeAddressSpace(this: ServerEngine) {
|
|
108
108
|
if (this.addressSpace) {
|
|
109
|
-
this.addressSpace.shutdown();
|
|
109
|
+
await this.addressSpace.shutdown();
|
|
110
110
|
this.addressSpace.dispose();
|
|
111
111
|
delete (this as any).addressSpace;
|
|
112
112
|
}
|
|
@@ -288,6 +288,7 @@ export interface CreateSessionOption {
|
|
|
288
288
|
|
|
289
289
|
export type ClosingReason = "Timeout" | "Terminated" | "CloseSession" | "Forcing";
|
|
290
290
|
|
|
291
|
+
export type ShutdownTask = (this: ServerEngine) => void | Promise<void>;
|
|
291
292
|
/**
|
|
292
293
|
*
|
|
293
294
|
*/
|
|
@@ -309,7 +310,7 @@ export class ServerEngine extends EventEmitter {
|
|
|
309
310
|
private _sessions: { [key: string]: ServerSession };
|
|
310
311
|
private _closedSessions: { [key: string]: ServerSession };
|
|
311
312
|
private _orphanPublishEngine?: ServerSidePublishEngineForOrphanSubscription;
|
|
312
|
-
private _shutdownTasks:
|
|
313
|
+
private _shutdownTasks: ShutdownTask[];
|
|
313
314
|
private _applicationUri: string;
|
|
314
315
|
private _expectedShutdownTime!: Date;
|
|
315
316
|
private _serverStatus: ServerStatusDataType;
|
|
@@ -473,7 +474,7 @@ export class ServerEngine extends EventEmitter {
|
|
|
473
474
|
/**
|
|
474
475
|
* @method shutdown
|
|
475
476
|
*/
|
|
476
|
-
public shutdown(): void {
|
|
477
|
+
public async shutdown(): Promise<void> {
|
|
477
478
|
debugLog("ServerEngine#shutdown");
|
|
478
479
|
|
|
479
480
|
this._internalState = "shutdown";
|
|
@@ -504,7 +505,7 @@ export class ServerEngine extends EventEmitter {
|
|
|
504
505
|
|
|
505
506
|
// perform registerShutdownTask
|
|
506
507
|
for (const task of this._shutdownTasks) {
|
|
507
|
-
task.call(this);
|
|
508
|
+
await task.call(this);
|
|
508
509
|
}
|
|
509
510
|
|
|
510
511
|
this.dispose();
|
|
@@ -1078,8 +1079,6 @@ export class ServerEngine extends EventEmitter {
|
|
|
1078
1079
|
});
|
|
1079
1080
|
};
|
|
1080
1081
|
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
1082
|
bindServerDiagnostics();
|
|
1084
1083
|
|
|
1085
1084
|
bindServerStatus();
|
|
@@ -1090,7 +1089,7 @@ export class ServerEngine extends EventEmitter {
|
|
|
1090
1089
|
|
|
1091
1090
|
const bindExtraStuff = () => {
|
|
1092
1091
|
// mainly for compliance
|
|
1093
|
-
|
|
1092
|
+
/*
|
|
1094
1093
|
// The version number for the data type description. i=104
|
|
1095
1094
|
bindStandardScalar(VariableIds.DataTypeDescriptionType_DataTypeVersion, DataType.String, () => {
|
|
1096
1095
|
return "0";
|
|
@@ -1125,6 +1124,7 @@ export class ServerEngine extends EventEmitter {
|
|
|
1125
1124
|
return namingRuleType.MandatoryPlaceholder ? namingRuleType.MandatoryPlaceholder.value : 0;
|
|
1126
1125
|
});
|
|
1127
1126
|
}
|
|
1127
|
+
*/
|
|
1128
1128
|
};
|
|
1129
1129
|
|
|
1130
1130
|
bindExtraStuff();
|
|
@@ -1893,7 +1893,7 @@ export class ServerEngine extends EventEmitter {
|
|
|
1893
1893
|
): void {
|
|
1894
1894
|
const referenceTime = new Date(Date.now() - maxAge);
|
|
1895
1895
|
|
|
1896
|
-
assert(typeof callback ===
|
|
1896
|
+
assert(typeof callback === "function");
|
|
1897
1897
|
const objectMap: Record<string, BaseNode> = {};
|
|
1898
1898
|
for (const nodeToRefresh of nodesToRefresh) {
|
|
1899
1899
|
// only consider node for which the caller wants to read the Value attribute
|
|
@@ -2078,7 +2078,7 @@ export class ServerEngine extends EventEmitter {
|
|
|
2078
2078
|
callback: CallbackT<HistoryReadResult>
|
|
2079
2079
|
): void {
|
|
2080
2080
|
assert(context instanceof SessionContext);
|
|
2081
|
-
assert(typeof callback ===
|
|
2081
|
+
assert(typeof callback === "function");
|
|
2082
2082
|
|
|
2083
2083
|
const nodeId = nodeToRead.nodeId;
|
|
2084
2084
|
const indexRange = nodeToRead.indexRange;
|