Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function adapt(server) {
// Xx console.log(" xxxx",server);
// Xx console.log(" xxx ", (new ApplicationDescription()).toString());
return new ApplicationDescription({
applicationName: server.applicationName,
applicationUri: server.applicationUri,
productUri: server.productUri,
applicationType: server.applicationType,
gatewayServerUri: server.gatewayServerUri,
discoveryProfileUri: server.discoveryProfileUri,
discoveryUrls: server.discoveryUrls
});
}
public createSession(options: any): ServerSession {
options = options || {};
debugLog("createSession : increasing serverDiagnosticsSummary cumulatedSessionCount/currentSessionCount ");
this.serverDiagnosticsSummary.cumulatedSessionCount += 1;
this.serverDiagnosticsSummary.currentSessionCount += 1;
this.clientDescription = options.clientDescription || new ApplicationDescription({});
const sessionTimeout = options.sessionTimeout || 1000;
assert(_.isNumber(sessionTimeout));
const session = new ServerSession(this, sessionTimeout);
const key = session.authenticationToken.toString();
this._sessions[key] = session;
// see spec OPC Unified Architecture, Part 2 page 26 Release 1.02
// TODO : When a Session is created, the Server adds an entry for the Client
// in its SessionDiagnosticsArray Variable
const engine = this;
function adapt(applicationDescription: ApplicationDescription): ApplicationDescription {
return new ApplicationDescription({
applicationName: applicationDescription.applicationName,
applicationType: applicationDescription.applicationType,
applicationUri: applicationDescription.applicationUri,
discoveryProfileUri: applicationDescription.discoveryProfileUri,
discoveryUrls: applicationDescription.discoveryUrls,
gatewayServerUri: applicationDescription.gatewayServerUri,
productUri: applicationDescription.productUri
});
}
options.certificateFile = options.certificateFile || constructFilename("certificates/server_selfsigned_cert_2048.pem");
options.privateKeyFile = options.privateKeyFile || constructFilename("certificates/PKI/own/private/private_key.pem");
super(options);
const self = this;
self.endpoints = [];
self.options = options;
this.serverInfo = _.clone(default_server_info);
this.serverInfo = _.extend(this.serverInfo, options.serverInfo);
self.serverInfo.applicationName = new LocalizedText(self.serverInfo.applicationName);
this.serverInfo = new endpoints_service.ApplicationDescription(this.serverInfo);
self.serverCertificateManager = options.serverCertificateManager || new CertificateManager({
name: "certificates"
});
}
public dispose() {
this._certificateChain = emptyCertificate;
this._privateKey = emptyPrivateKeyPEM;
assert(Object.keys(this._channels).length === 0, "OPCUAServerEndPoint channels must have been deleted");
this._channels = {};
this.serverInfo = new ApplicationDescription({});
this._endpoints = [];
assert(this._endpoints.length === 0, "endpoints must have been deleted");
this._endpoints = [];
this._server = undefined;
this._listen_callback = null;
this.removeAllListeners();
}
options = options || {} as OPCUABaseServerOptions;
options.certificateFile = options.certificateFile ||
constructFilename("certificates/server_selfsigned_cert_2048.pem");
options.privateKeyFile = options.privateKeyFile ||
constructFilename("certificates/PKI/own/private/private_key.pem");
super(options);
this.capabilitiesForMDNS = [];
this.endpoints = [];
this.options = options;
const serverInfo: any = _.extend(_.clone(default_server_info), options.serverInfo);
serverInfo.applicationName = new LocalizedText(serverInfo.applicationName);
this.serverInfo = new ApplicationDescription(serverInfo);
this.serverCertificateManager = options.serverCertificateManager
|| new OPCUACertificateManager({
name: "certificates"
});
}
public dispose() {
this._certificateChain = emptyCertificate;
this._privateKey = emptyPrivateKeyPEM;
assert(Object.keys(this._channels).length === 0, "OPCUAServerEndPoint channels must have been deleted");
this._channels = {};
this.serverInfo = new ApplicationDescription({});
this._endpoints = [];
assert(this._endpoints.length === 0, "endpoints must have been deleted");
this._endpoints = [];
this._server = undefined;
this._listen_callback = null;
this.removeAllListeners();
}