UNPKG

node-red-contrib-opcua-server

Version:

Node-RED contribution nodes with next generation OPC UA in a compact and less dependencies package.

3 lines (2 loc) 6.13 kB
"use strict";module.exports={nodeOpcuaServer:require("node-opcua-server/dist/opcua_server"),choreCompact:require("./chore").de.bianco.royal.compact,debugLog:require("./chore").de.bianco.royal.compact.opcuaServerDebug,detailLog:require("./chore").de.bianco.royal.compact.opcuaServerDetailsDebug,errorLog:require("./chore").de.bianco.royal.compact.opcuaErrorDebug,readConfigOfServerNode:function(e,o){return e.name=o.name,e.port=o.port,e.endpoint=o.endpoint,e.productUri=o.productUri,e.alternateHostname=o.alternateHostname,e.maxAllowedSessionNumber=o.maxAllowedSessionNumber,e.maxConnectionsPerEndpoint=o.maxConnectionsPerEndpoint,e.maxAllowedSubscriptionNumber=o.maxAllowedSubscriptionNumber,e.maxNodesPerRead=o.maxNodesPerRead,e.maxNodesPerWrite=o.maxNodesPerWrite,e.maxNodesPerHistoryReadData=o.maxNodesPerHistoryReadData,e.maxNodesPerBrowse=o.maxNodesPerBrowse,e.maxBrowseContinuationPoints=o.maxBrowseContinuationPoints,e.maxHistoryContinuationPoints=o.maxHistoryContinuationPoints,e.delayToInit=o.delayToInit,e.delayToClose=o.delayToClose,e.serverShutdownTimeout=o.serverShutdownTimeout,e.showStatusActivities=o.showStatusActivities,e.showErrors=o.showErrors,e.publicCertificateFile=o.publicCertificateFile,e.privateCertificateFile=o.privateCertificateFile,e.allowAnonymous=o.allowAnonymous,e.opcuaUsers=o.users,e.xmlsetsOPCUA=o.xmlsetsOPCUA,e.isAuditing=o.isAuditing,e.disableDiscovery=!o.serverDiscovery,e.registerServerMethod=o.registerServerMethod,e.discoveryServerEndpointUrl=o.discoveryServerEndpointUrl,e.capabilitiesForMDNS=o.capabilitiesForMDNS?o.capabilitiesForMDNS.split(","):[o.capabilitiesForMDNS],e},initialize:function(e,o){return new module.exports.choreCompact.opcua.OPCUAServer(o)},stop:function(e,o,t){o.shutdown(e.serverShutdownTimeout,t)},getRegisterServerMethod:function(e){return require("node-opcua").RegisterServerMethod[e]},loadOPCUANodeSets:function(e,o){var t=[module.exports.choreCompact.opcuaNodesets.nodesets.standard,module.exports.choreCompact.opcuaNodesets.nodesets.di];return Array.isArray(e.xmlsetsOPCUA)&&(e.xmlsetsOPCUA.forEach(function(e){e.path&&(e.path.startsWith("public/vendor/")?t.push(module.exports.choreCompact.path.join(o,e.path)):t.push(e.path))}),module.exports.detailLog("appending xmlFiles: "+t.toString())),module.exports.detailLog("node sets:"+t.toString()),t},defaultServerOptions:function(e){var o=e.publicCertificateFile||module.exports.choreCompact.coreSecurity.serverCertificateFile("2048"),t=e.privateCertificateFile||module.exports.choreCompact.coreSecurity.serverKeyFile("2048");return{port:"string"==typeof e.port?parseInt(e.port):e.port,resourcePath:e.endpoint||"/UA/NodeRED/Compact",buildInfo:{productName:"Node-RED OPC UA Compact Server",buildNumber:"20220731",buildDate:new Date(2022,7,31)},serverCapabilities:{maxBrowseContinuationPoints:e.maxBrowseContinuationPoints,maxHistoryContinuationPoints:e.maxHistoryContinuationPoints,operationLimits:{maxNodesPerRead:e.maxNodesPerRead,maxNodesPerWrite:e.maxNodesPerWrite,maxNodesPerHistoryReadData:e.maxNodesPerHistoryReadData,maxNodesPerBrowse:e.maxNodesPerBrowse}},serverInfo:{productUri:e.productUri||"NodeOPCUA-Server-"+e.port,applicationName:{text:"NodeRED-Compact",locale:"en"},gatewayServerUri:null,discoveryProfileUri:null,discoveryUrls:[]},alternateHostname:e.alternateHostname,maxAllowedSessionNumber:e.maxAllowedSessionNumber,maxConnectionsPerEndpoint:e.maxConnectionsPerEndpoint,allowAnonymous:e.allowAnonymous,certificateFile:o,privateKeyFile:t,userManager:{isValidUser:module.exports.choreCompact.coreSecurity.checkUserLogon},isAuditing:e.isAuditing,disableDiscovery:e.disableDiscovery,registerServerMethod:1}},constructAddressSpaceFromScript:function(t,r,i){return new Promise(function(e,o){try{r(t,t.engine.addressSpace,i,e)}catch(e){o(e)}})},postInitialize:function(o,e){o.contribOPCUACompact.eventObjects={};var t=null==(t=e.engine)?void 0:t.addressSpace;t&&t.getOwnNamespace(),module.exports.constructAddressSpaceFromScript(e,o.contribOPCUACompact.constructAddressSpaceScript,o.contribOPCUACompact.eventObjects).then(function(){module.exports.choreCompact.setStatusActive(o),o.emit("server_running")}).catch(function(e){module.exports.choreCompact.setStatusError(o,e.message),o.emit("server_start_error")})},run:function(e,r){return new Promise(function(o,t){r.start(function(e){e?t(e):(r.endpoints&&r.endpoints.length&&(r.endpoints.forEach(function(e){e.endpointDescriptions().forEach(function(e){module.exports.debugLog("Server endpointUrl: "+e.endpointUrl+" securityMode: "+e.securityMode.toString()+" securityPolicyUri: "+e.securityPolicyUri?e.securityPolicyUri.toString():"None Security Policy Uri")})}),e=r.endpoints[0].endpointDescriptions()[0].endpointUrl,module.exports.debugLog("Primary Server Endpoint URL "+e)),r.on("newChannel",function(e){module.exports.debugLog("Client connected with address = "+e.remoteAddress+" port = "+e.remotePort)}),r.on("closeChannel",function(e){module.exports.debugLog("Client disconnected with address = "+e.remoteAddress+" port = "+e.remotePort)}),r.on("create_session",function(e){module.exports.debugLog("############## SESSION CREATED ##############"),e.clientDescription&&(module.exports.detailLog("Client application URI:"+e.clientDescription.applicationUri),module.exports.detailLog("Client product URI:"+e.clientDescription.productUri),module.exports.detailLog((e.clientDescription.applicationName,e.clientDescription.applicationName.toString())),module.exports.detailLog((e.clientDescription.applicationType,e.clientDescription.applicationType.toString()))),module.exports.debugLog((e.sessionName,e.sessionName.toString())),module.exports.debugLog("Session timeout:"+e.sessionTimeout),module.exports.debugLog("Session id:"+e.sessionId)}),r.on("session_closed",function(e,o){module.exports.debugLog("############## SESSION CLOSED ##############"),module.exports.detailLog("reason:"+o),module.exports.detailLog((e.sessionName,e.sessionName.toString()))}),module.exports.debugLog("Server Initialized"),r.serverInfo&&module.exports.detailLog("Server Info:"+JSON.stringify(r.serverInfo)),o())})})}}; //# sourceMappingURL=../maps/core/server.js.map