Cloud Defense Logo

Products

Solutions

Company

Book A Live Demo

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

Dive into secure and efficient coding practices with our curated list of the top 10 examples showcasing 'node-opcua-transport' 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.

constructor(expectedReplies: any) {

        super();

        this._replies = expectedReplies;
        this._counter = 0;

        this._mockTransport = new DirectTransport();
        this._mockTransport.initialize(() => {
            console.log("initialized");
        });

        this._mockTransport.server.on("data", (data: Buffer) => {

            let reply = this._replies[this._counter];
            this._counter++;
            if (reply) {

                if (_.isFunction(reply)) {
                    reply = reply.call(this);
                    // console.log(" interpreting reply as a function" + reply);
                    if (!reply) {
                        return;
                    }
// tslint:disable:no-console
import * as chalk from "chalk";
import { EventEmitter } from "events";
import { assert } from "node-opcua-assert";
import { display_trace_from_this_projet_only, hexDump, make_debugLog } from "node-opcua-debug";
import { analyseExtensionObject } from "node-opcua-packet-analyzer";
import { GetEndpointsResponse } from "node-opcua-service-endpoints";
import { CloseSecureChannelResponse, OpenSecureChannelResponse } from "node-opcua-service-secure-channel";
import { ActivateSessionResponse, CreateSessionResponse } from "node-opcua-service-session";
import { AcknowledgeMessage } from "node-opcua-transport";
import { DirectTransport } from "node-opcua-transport/dist/test_helpers";
import * as _ from "underscore";

const debugLog = make_debugLog(__filename);

export const fakeAcknowledgeMessage = new AcknowledgeMessage({
    maxChunkCount: 600000,
    maxMessageSize: 100000,
    protocolVersion: 0,
    receiveBufferSize: 8192,
    sendBufferSize: 8192,
});

export const fakeCloseSecureChannelResponse = new CloseSecureChannelResponse({});

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

    securityToken: {
        channelId: 23,
        createdAt: new Date(), // now
        revisedLifetime: 30000,
ServerSecureChannelLayer.prototype.init = function(socket, callback) {
    const self = this;

    self.transport = new ServerTCP_transport();
    self.transport.timeout = self.timeout;

    self.transport.init(socket, function(err) {
        if (err) {
            callback(err);
        } else {
            // bind low level TCP transport to messageBuilder
            self.transport.on("message", function(message_chunk) {
                assert(self.messageBuilder);
                self.messageBuilder.feed(message_chunk);
            });
            debugLog("ServerSecureChannelLayer : Transport layer has been initialized");
            debugLog("... now waiting for OpenSecureChannelRequest...");

            ServerSecureChannelLayer.registry.register(self);
MessageBuilder.prototype._read_headers = function (binaryStream) {

    MessageBuilderBase.prototype._read_headers.apply(this, arguments);
    assert(binaryStream.length === 12);

    const msgType = this.messageHeader.msgType;

    if (msgType === "HEL" || msgType === "ACK") {

        this.securityPolicy = SecurityPolicy.None;
    } else if (msgType === "ERR") {

        // extract Error StatusCode and additional message
        binaryStream.length = 8;
        const errorCode = decodeStatusCode(binaryStream);
        const message = decodeString(binaryStream);
        if (doDebug) {
            console.log(" ERROR RECEIVED FROM SENDER".red.bold, errorCode.toString().cyan, message);
            console.log(hexDump(binaryStream._buffer));
}
                    /* istanbul ignore next */
                    if (!publicKey) {
                        throw new Error("Internal Error");
                    }
                    this.receiverPublicKey = publicKey;

                    this.create(endpointUrl, callback);
                });
                return;
            }
        }

        this.endpointUrl = endpointUrl;

        const transport = new ClientTCP_transport();
        transport.timeout = this.transportTimeout;

        this._establish_connection(
            transport,
            endpointUrl,
            (err?: Error) => {

                if (err) {
                    debugLog(chalk.red("cannot connect to server"));
                    transport.dispose();
                    return callback(err);
                }

                this._on_connection(transport, callback);

            }
/* istanbul ignore next */
                if (err) {
                    return callback(err);
                }
                self.receiverPublicKey = publicKey;
                assert(!_.isUndefined(self.receiverPublicKey)); // make sure we wont go into infinite recursion calling create again.
                self.create(endpointUrl, callback);
            });
            return;
        }
        assert(typeof self.receiverPublicKey === "string");
    }


    self.endpointUrl = endpointUrl;
    const transport = new ClientTCP_transport();
    transport.timeout = self.transportTimeout;
    transport.protocolVersion = self.protocolVersion;


    // -------------------------------------------------------------------------
    // Handle reconnection
    // --------------------------------------------------------------------------
    const _establish_connection = function (transport, endpointUrl, callback) {


        let last_err = null;

        function _connect(_i_callback) {

            if (self.__call && self.__call._cancelBackoff) {
                return;
super();

        this._on_response = null;
        this.__verifId = {};
        this._abort_has_been_called = false;
        this.endpoint = null;
        this._remoteAddress = "";
        this._remotePort = 0;
        this.receiverCertificate = null;
        this.receiverPublicKey = null;
        this.receiverPublicKeyLength = 0;
        this.clientCertificate = null;
        this.clientNonce = null;

        this.transport = new ServerTCP_transport();

        this.__hash = getNextChannelId();
        assert(this.__hash > 0);

        this.channelId = null;

        this.revisedLifetime = 0;

        this.parent = options.parent;

        this.protocolVersion = 0;

        this.lastTokenId = 0;

        this.timeout = options.timeout || 30000; // connection timeout
        debugLog("server secure channel layer tiemput = ", this.timeout);
module.exports.basic_types = require("node-opcua-basic-types");

// version
module.exports.version = require("./package.json").version;

module.exports.nodesets = require("node-opcua-nodesets");
module.exports.constructNodesetFilename = module.exports.nodesets.constructNodesetFilename;
module.exports.standard_nodeset_file = module.exports.nodesets.standard_nodeset_file;
module.exports.di_nodeset_filename = module.exports.nodesets.di_nodeset_filename;
module.exports.adi_nodeset_filename = module.exports.nodesets.adi_nodeset_filename;

// an incomplete but sufficient nodeset file used during testing
module.exports.mini_nodeset_filename = require("node-opcua-address-space/test_helpers/get_mini_address_space").mini_nodeset_filename;
module.exports.empty_nodeset_filename = require("node-opcua-address-space/test_helpers/get_mini_address_space").empty_nodeset_filename;

module.exports.is_valid_endpointUrl = require("node-opcua-transport").is_valid_endpointUrl;

// filtering tools
module.exports.checkSelectClause = require("node-opcua-address-space").checkSelectClause;
module.exports.constructEventFilter = require("node-opcua-service-filter").constructEventFilter;

const address_space_for_conformance_testing = require("node-opcua-address-space-for-conformance-testing");
module.exports.build_address_space_for_conformance_testing =
    address_space_for_conformance_testing.build_address_space_for_conformance_testing;

module.exports.install_optional_cpu_and_memory_usage_node = require("node-opcua-vendor-diagnostic").install_optional_cpu_and_memory_usage_node;
module.exports.construct_demo_alarm_in_address_space = require("node-opcua-address-space/test_helpers/alarms_and_conditions_demo").construct_demo_alarm_in_address_space;

module.exports.createBoilerType = require("node-opcua-address-space/test_helpers/boiler_system").createBoilerType;
module.exports.makeBoiler = require("node-opcua-address-space/test_helpers/boiler_system").makeBoiler;

module.exports.UAProxyManager = require("node-opcua-client-proxy").UAProxyManager;
//----------------------------------------------------------------------------------------------------------------------
module.exports.OPCUAClient = require("node-opcua-client").OPCUAClient;
module.exports.OPCUAClientBase = require("node-opcua-client").OPCUAClientBase;

module.exports.NodeCrawler = require("node-opcua-client-crawler").NodeCrawler;
module.exports.ClientSubscription = require("node-opcua-client").ClientSubscription;
module.exports.ClientSession = require("node-opcua-client").ClientSession;

module.exports.client_utils = require("node-opcua-client/src/client_utils");
module.exports.perform_findServers = require("node-opcua-client").perform_findServers;
module.exports.perform_findServersOnNetwork = require("node-opcua-client").perform_findServersOnNetwork;
module.exports.readHistoryServerCapabilities = require("node-opcua-client").readHistoryServerCapabilities;

module.exports.callConditionRefresh = require("node-opcua-client/src/alarms_and_conditions/client_tools").callConditionRefresh;

module.exports.parseEndpointUrl = require("node-opcua-transport").parseEndpointUrl;

//----------------------------------------------------------------------------------------------------------------------
// Server services
//----------------------------------------------------------------------------------------------------------------------
module.exports.OPCUAServer = require("node-opcua-server").OPCUAServer;
module.exports.RegisterServerMethod = require("node-opcua-server").RegisterServerMethod;

module.exports.ServerEngine = require("node-opcua-server").ServerEngine;
module.exports.MonitoredItem = require("node-opcua-server").MonitoredItem;
module.exports.ServerSession = require("node-opcua-server").ServerSession;
module.exports.Subscription = require("node-opcua-server").Subscription;
module.exports.MonitoredItem = require("node-opcua-server").MonitoredItem;

module.exports.generate_address_space = require("node-opcua-address-space").generate_address_space;
module.exports.AddressSpace = require("node-opcua-address-space").AddressSpace;
module.exports.Namespace = require("node-opcua-address-space").Namespace;
// the Client and Server to securely negotiate the keys to use.

const _ = require("underscore");

const AsymmetricAlgorithmSecurityHeader = require("node-opcua-service-secure-channel").AsymmetricAlgorithmSecurityHeader;
const SymmetricAlgorithmSecurityHeader = require("node-opcua-service-secure-channel").SymmetricAlgorithmSecurityHeader;
const SequenceHeader = require("node-opcua-service-secure-channel").SequenceHeader;

exports.AsymmetricAlgorithmSecurityHeader = AsymmetricAlgorithmSecurityHeader;
exports.SymmetricAlgorithmSecurityHeader = SymmetricAlgorithmSecurityHeader;
exports.SequenceHeader = SequenceHeader;

exports.ErrorMessage = require("node-opcua-service-secure-channel").ErrorMessage;

//xx ChannelService
exports.AcknowledgeMessage = require("node-opcua-transport/_generated_/_auto_generated_AcknowledgeMessage").AcknowledgeMessage;
exports.HelloMessage = require("node-opcua-transport/_generated_/_auto_generated_HelloMessage").HelloMessage;

//var Padding_Schema = {
//    name: "Padding",
//    id: factories.next_available_id(),
//    fields: [
//        // The number of padding bytes (not including the byte for the PaddingSize).
//        { name: "paddingSize",        fieldType: "Byte" },
//        // Padding added to the end of the message to ensure length of the data to encrypt is an
//        // integer multiple of the encryption block size.
//        // The value of each byte of the padding is equal to PaddingSize.
//        { name: "padding",            fieldType: "Byte*" },
//
//        // The signature for the MessageChunk.
//        // The signature includes the all headers, all message data, the PaddingSize and the Padding.
//        { name: "Signatures",          fieldType: "Byte*" }

Is your System Free of Underlying Vulnerabilities?
Find Out Now