Cloud Defense Logo

Products

Solutions

Company

Book A Live Demo

Top 10 Examples of "node-opcua-service-endpoints in functional component" in JavaScript

Dive into secure and efficient coding practices with our curated list of the top 10 examples showcasing 'node-opcua-service-endpoints' in functional components in JavaScript. Our advanced machine learning engine meticulously scans each line of code, cross-referencing millions of open source libraries to ensure your implementation is not just functional, but also robust and secure. Elevate your React applications to new heights by mastering the art of handling side effects, API calls, and asynchronous operations with confidence and precision.

"use strict";
var should = require("should");
var assert = require("node-opcua-assert").assert;


var endpoints_service = require("node-opcua-service-endpoints");

var GetEndpointsResponse = endpoints_service.GetEndpointsResponse;


var EndpointDescription = require("node-opcua-service-endpoints").EndpointDescription;
var ApplicationType = require("node-opcua-service-endpoints").ApplicationType;
var UserTokenType = require("node-opcua-service-endpoints").UserTokenType;
var MessageSecurityMode = require("node-opcua-service-secure-channel").MessageSecurityMode;

exports.fixture1 = (function () {
    // empty  GetEndpointsResponse
    return new GetEndpointsResponse();

})();

exports.makeEndPoint = function () {

    var data = {
        endpointUrl: "toto",

        server: {
export const fakeCloseSecureChannelResponse = new CloseSecureChannelResponse({});

export const fakeOpenSecureChannelResponse = new OpenSecureChannelResponse({
    serverProtocolVersion: 0,

    securityToken: {
        channelId: 23,
        createdAt: new Date(), // now
        revisedLifetime: 30000,
        tokenId: 1,
    },
    serverNonce: Buffer.from("qwerty")
});

export const fakeGetEndpointsResponse = new GetEndpointsResponse({
    endpoints: [
        {
            endpointUrl: "fake://localhost:2033/SomeAddress"
        }
    ]
});

export const fakeCreateSessionResponse = new CreateSessionResponse({});
export const fakeActivateSessionResponse = new ActivateSessionResponse({});

export class MockServerTransport extends EventEmitter {

    private _replies: any;
    private _mockTransport: DirectTransport;
    private _counter: number;
"use strict";
var should = require("should");
var assert = require("node-opcua-assert").assert;


var endpoints_service = require("node-opcua-service-endpoints");

var GetEndpointsResponse = endpoints_service.GetEndpointsResponse;


var EndpointDescription = require("node-opcua-service-endpoints").EndpointDescription;
var ApplicationType = require("node-opcua-service-endpoints").ApplicationType;
var UserTokenType = require("node-opcua-service-endpoints").UserTokenType;
var MessageSecurityMode = require("node-opcua-service-secure-channel").MessageSecurityMode;

exports.fixture1 = (function () {
    // empty  GetEndpointsResponse
    return new GetEndpointsResponse();

})();

exports.makeEndPoint = function () {

    var data = {
        endpointUrl: "toto",

        server: {

            applicationUri: "OPCUA  node-js",
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
            });
        }
endPoint.on("message", function (message, channel) {
        self.on_request(message, channel);
    });

    endPoint.on("error", function (err) {
        console.log("OPCUAServer endpoint error", err);

        // set serverState to ServerState.Failed;
        self.engine.setServerState(ServerState.Failed);

        self.shutdown(function () {
        });
    });

    self.serverInfo.applicationType = ApplicationType.SERVER;


    self.userManager = options.userManager || {};
    if (!_.isFunction(self.userManager.isValidUser)) {
        self.userManager.isValidUser = function (/*userName,password*/) {
            return false;
        };
    }

    self.discoveryServerEndpointUrl = options.discoveryServerEndpointUrl || "opc.tcp://localhost:4840";
    assert(typeof self.discoveryServerEndpointUrl === "string");
    self.capabilitiesForMDNS = options.capabilitiesForMDNS || [ "NA" ];
    self.registerServerMethod = options.registerServerMethod || RegisterServerMethod.HIDDEN;
    _installRegisterServerManager(self);
}
util.inherits(OPCUAServer, OPCUABaseServer);
}

    if (options.allowAnonymous) {

        userIdentityTokens.push({
            policyId: "anonymous",
            tokenType: UserTokenType.Anonymous,

            issuedTokenType: null,
            issuerEndpointUrl: null,
            securityPolicyUri: null
        });
    }

    // return the endpoint object
    const endpoint = new EndpointDescription({

        endpointUrl: options.endpointUrl,

        server: undefined, // options.server,
        serverCertificate: options.serverCertificateChain,

        securityMode: options.securityMode,
        securityPolicyUri,
        userIdentityTokens,

        securityLevel: options.securityLevel,
        transportProfileUri: default_transportProfileUri
    }) as EndpointDescriptionEx;

    (endpoint as any).__defineGetter__("endpointUrl", () => {
        return resolveFullyQualifiedDomainName(options.endpointUrl);
}

    if (options.allowAnonymous) {

        userIdentityTokens.push({
            policyId: "anonymous",
            tokenType: UserTokenType.Anonymous,

            issuedTokenType: null,
            issuerEndpointUrl: null,
            securityPolicyUri: null
        });
    }

    // return the endpoint object
    const endpoint = new EndpointDescription({

        endpointUrl: options.endpointUrl,

        server: undefined, // options.server,
        serverCertificate: options.serverCertificateChain,

        securityMode: options.securityMode,
        securityPolicyUri,
        userIdentityTokens,

        securityLevel: options.securityLevel,
        transportProfileUri: default_transportProfileUri
    }) as EndpointDescriptionEx;

    (endpoint as any).__defineGetter__("endpointUrl", () => {
        return resolveFullyQualifiedDomainName(options.endpointUrl);
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;
// try one level up
        filename = path.join(__dirname, p);
        if(!fs.existsSync(filename)) {
            throw new Error("Cannot find filename " + filename + " ( __dirname = " + __dirname);
        }
    }
    return filename;
}

const debugLog = require("node-opcua-debug").make_debugLog(__filename);

const StatusCodes = require("node-opcua-status-code").StatusCodes;

const endpoints_service = require("node-opcua-service-endpoints");
const GetEndpointsResponse = endpoints_service.GetEndpointsResponse;
const ApplicationType = endpoints_service.ApplicationType;

const OPCUASecureObject = require("node-opcua-common").OPCUASecureObject;


const discovery_service = require("node-opcua-service-discovery");
const FindServersRequest = discovery_service.FindServersRequest;
const FindServersResponse = discovery_service.FindServersResponse;
const LocalizedText = require("node-opcua-data-model").LocalizedText;

const default_server_info = {

    // The globally unique identifier for the application instance. This URI is used as
    // ServerUri in Services if the application is a Server.
    applicationUri: "urn:NodeOPCUA-Server-default",

    // The globally unique identifier for the product.
// services
module.exports.browse_service = require("node-opcua-service-browse");
module.exports.read_service = require("node-opcua-service-read");
module.exports.write_service = require("node-opcua-service-write");
module.exports.call_service = require("node-opcua-service-call");

module.exports.session_service = require("node-opcua-service-session");
module.exports.AnonymousIdentityToken = module.exports.session_service.AnonymousIdentityToken;
module.exports.UserNameIdentityToken = module.exports.session_service.UserNameIdentityToken;

module.exports.register_node_service = require("node-opcua-service-register-node");

module.exports.get_endpoints_service = require("node-opcua-service-endpoints");
module.exports.EndpointDescription = require("node-opcua-service-endpoints").EndpointDescription;
module.exports.ApplicationType = require("node-opcua-service-endpoints").ApplicationType;
module.exports.UserTokenPolicy = require("node-opcua-service-endpoints").UserTokenPolicy;
module.exports.UserIdentityTokenType = require("node-opcua-service-endpoints").UserIdentityTokenType;

module.exports.subscription_service = require("node-opcua-service-subscription");
module.exports.historizing_service = require("node-opcua-service-history");
module.exports.discovery_service = require("node-opcua-service-discovery");
module.exports.secure_channel_service = require("node-opcua-service-secure-channel");

module.exports.translate_browse_paths_to_node_ids_service = require("node-opcua-service-translate-browse-path");
module.exports.BrowsePath = require("node-opcua-service-translate-browse-path").BrowsePath;
module.exports.makeRelativePath = require("node-opcua-service-translate-browse-path").makeRelativePath;
module.exports.makeBrowsePath = require("node-opcua-service-translate-browse-path").makeBrowsePath;

module.exports.query_service = require("node-opcua-service-query");
module.exports.node_managment_service = require("node-opcua-service-node-management");

Is your System Free of Underlying Vulnerabilities?
Find Out Now