Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"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",
productUri: "some product uri",
const util = require("util");
const EventEmitter = require("events").EventEmitter;
const fs = require("fs");
const path = require("path");
const async = require("async");
const _ = require("underscore");
const assert = require("node-opcua-assert").assert;
const once = require("once");
const delayed = require("delayed");
const endpoints_service = require("node-opcua-service-endpoints");
const GetEndpointsRequest = endpoints_service.GetEndpointsRequest;
const GetEndpointsResponse = endpoints_service.GetEndpointsResponse;
const MessageSecurityMode = require("node-opcua-service-secure-channel").MessageSecurityMode;
const toURI = require("node-opcua-secure-channel").toURI;
const SecurityPolicy = require("node-opcua-secure-channel").SecurityPolicy;
const debugLog = require("node-opcua-debug").make_debugLog(__filename);
const doDebug = require("node-opcua-debug").checkDebugFlag(__filename);
const OPCUASecureObject = require("node-opcua-common").OPCUASecureObject;
const ClientSecureChannelLayer = require("node-opcua-secure-channel/src/client/client_secure_channel_layer").ClientSecureChannelLayer;
const ClientSession = require("./client_session").ClientSession;
const defaultConnectionStrategy = {
initialDelay: 1000,
maxDelay: 20*1000,// 20 seconds
maxRetry: -1, // infinite
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");
module.exports.ServerState = require("node-opcua-common").ServerState;
module.exports.ServiceCounter = require("node-opcua-common").ServiceCounter;
module.exports.SecurityPolicy = require("node-opcua-secure-channel").SecurityPolicy;
module.exports.MessageSecurityMode = require("node-opcua-service-secure-channel").MessageSecurityMode;
module.exports.utils = require("node-opcua-utils");
module.exports.crypto_utils = require("node-opcua-crypto");
module.exports.hexDump = require("node-opcua-debug").hexDump;
//----------------------------------------------------------------------------------------------------------------------
// client services
//----------------------------------------------------------------------------------------------------------------------
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");
const async = require("async");
const EventEmitter = require("events").EventEmitter;
const util = require("util");
const _ = require("underscore");
const discovery_service = require("node-opcua-service-discovery");
const RegisterServerRequest = discovery_service.RegisterServerRequest;
const RegisterServerResponse = discovery_service.RegisterServerResponse;
const RegisterServer2Request = discovery_service.RegisterServer2Request;
const RegisterServer2Response = discovery_service.RegisterServer2Response;
const OPCUAClientBase = require("node-opcua-client").OPCUAClientBase;
const SecurityPolicy = require("node-opcua-secure-channel").SecurityPolicy;
const coerceSecurityPolicy = require("node-opcua-secure-channel").coerceSecurityPolicy;
const MessageSecurityMode = require("node-opcua-service-secure-channel").MessageSecurityMode;
const _enumerationMessageSecurityMode = require("node-opcua-service-secure-channel")._enumerationMessageSecurityMode;
const Enum = require("node-opcua-enum").Enum;
const debugLog = require("node-opcua-debug").make_debugLog(__filename);
const RegisterServerManagerStatus = new Enum({
INACTIVE: 1,
INITIALIZING: 2,
REGISTERING: 3,
WAITING: 4,
UNREGISTERING: 5
});
const g_DefaultRegistrationServerTimeout = 8 * 60 * 1000; // 8 minutes
/**
switch (securityPolicy.key) {
case SecurityPolicy.None.key:
return null;
case SecurityPolicy.Basic128Rsa15.key:
return _Basic128Rsa15;
case SecurityPolicy.Basic256.key:
return _Basic256;
case SecurityPolicy.Basic256Sha256.key:
return _Basic256Sha256;
default:
return null;
}
}
exports.getCryptoFactory = getCryptoFactory;
const MessageSecurityMode = require("node-opcua-service-secure-channel").MessageSecurityMode;
const SignatureData = require("node-opcua-service-secure-channel").SignatureData;
function computeSignature(senderCertificate, senderNonce, receiverPrivatekey, securityPolicy) {
if (!senderNonce || !senderCertificate) {
return null;
}
const crypto_factory = getCryptoFactory(securityPolicy);
if (!crypto_factory) {
return null;
}
// This parameter is calculated by appending the clientNonce to the clientCertificate
const buffer = Buffer.concat([senderCertificate, senderNonce]);
// ... and signing the resulting sequence of bytes.
const crypto_utils = require("node-opcua-crypto");
const MessageBuilder = require("../message_builder").MessageBuilder;
const MessageChunker = require("../message_chunker").MessageChunker;
const securityPolicy_m = require("../security_policy");
const SecurityPolicy = securityPolicy_m.SecurityPolicy;
const ServerTCP_transport = require("node-opcua-transport").ServerTCP_transport;
const StatusCode = require("node-opcua-status-code").StatusCode;
const StatusCodes = require("node-opcua-status-code").StatusCodes;
const secure_channel_service = require("../services");
const AsymmetricAlgorithmSecurityHeader = secure_channel_service.AsymmetricAlgorithmSecurityHeader;
const MessageSecurityMode = require("node-opcua-service-secure-channel").MessageSecurityMode;
const ChannelSecurityToken = secure_channel_service.ChannelSecurityToken;
const ServiceFault = secure_channel_service.ServiceFault;
const OpenSecureChannelRequest = secure_channel_service.OpenSecureChannelRequest;
const OpenSecureChannelResponse = secure_channel_service.OpenSecureChannelResponse;
const SecurityTokenRequestType = secure_channel_service.SecurityTokenRequestType;
const split_der = require("node-opcua-crypto").split_der;
assert(MessageSecurityMode);
assert(ChannelSecurityToken);
assert(OpenSecureChannelRequest);
assert(OpenSecureChannelResponse);
assert(SecurityTokenRequestType);
assert(ServiceFault);
const do_trace_message = process.env.DEBUG && process.env.DEBUG.indexOf("TRACE") >= 0;
const BinaryStream = require("node-opcua-binary-stream").BinaryStream;
const ec = require("node-opcua-basic-types");
const decodeString = ec.decodeString;
const packet_analyzer = require("node-opcua-packet-analyzer").packet_analyzer;
const hexDump = require("node-opcua-debug").hexDump;
//xx require("./utils").setDebugFlag(__filename,true);
const debugLog = require("node-opcua-debug").make_debugLog(__filename);
const doDebug = require("node-opcua-debug").checkDebugFlag(__filename);
const securityPolicy_m = require("./security_policy");
const SecurityPolicy = securityPolicy_m.SecurityPolicy;
const MessageSecurityMode = require("node-opcua-service-secure-channel").MessageSecurityMode;
const crypto_utils = require("node-opcua-crypto");
const decodeStatusCode = require("node-opcua-status-code").decodeStatusCode;
/**
* @class MessageBuilder
* @extends MessageBuilderBase
* @constructor
*
* @param options
* @param options.securityMode {MessageSecurityMode} the security Mode
* @param [options.objectFactory=factories] a object that provides a constructObject(id) method
*/
function MessageBuilder(options) {
const assert = require("node-opcua-assert").assert;
require("colors");
const utils = require("node-opcua-utils");
const BinaryStream = require("node-opcua-binary-stream").BinaryStream;
const ClientTCP_transport = require("node-opcua-transport").ClientTCP_transport;
const hexDump = require("node-opcua-debug").hexDump;
const StatusCodes = require("node-opcua-status-code").StatusCodes;
const crypto_utils = require("node-opcua-crypto");
const verify_message_chunk = require("node-opcua-chunkmanager").verify_message_chunk;
const MessageSecurityMode = require("node-opcua-service-secure-channel").MessageSecurityMode;
const backoff = require("backoff");
const debug = require("node-opcua-debug");
const debugLog = debug.make_debugLog(__filename);
const doDebug = debug.checkDebugFlag(__filename);
const get_clock_tick = require("node-opcua-utils").get_clock_tick;
const readMessageHeader = require("node-opcua-chunkmanager").readMessageHeader;
const MessageBuilder = require("../message_builder").MessageBuilder;
const messageHeaderToString = require("../message_header_to_string").messageHeaderToString;
const MessageChunker = require("../message_chunker").MessageChunker;
const secure_channel_service = require("../services");
const securityPolicy_m = require("../security_policy");
const StatusCodes = require("node-opcua-status-code").StatusCodes;
const session_service = require("node-opcua-service-session");
const AnonymousIdentityToken = session_service.AnonymousIdentityToken;
const CreateSessionRequest = session_service.CreateSessionRequest;
const CreateSessionResponse = session_service.CreateSessionResponse;
const ActivateSessionRequest = session_service.ActivateSessionRequest;
const ActivateSessionResponse = session_service.ActivateSessionResponse;
const CloseSessionRequest = session_service.CloseSessionRequest;
const endpoints_service = require("node-opcua-service-endpoints");
const ApplicationDescription = endpoints_service.ApplicationDescription;
const ApplicationType = endpoints_service.ApplicationType;
const EndpointDescription = endpoints_service.EndpointDescription;
const MessageSecurityMode = require("node-opcua-service-secure-channel").MessageSecurityMode;
const SecurityPolicy = require("node-opcua-secure-channel").SecurityPolicy;
const getCryptoFactory = require("node-opcua-secure-channel").getCryptoFactory;
const fromURI = require("node-opcua-secure-channel").fromURI;
const crypto_utils = require("node-opcua-crypto");
const UserNameIdentityToken = session_service.UserNameIdentityToken;
const buffer_utils = require("node-opcua-buffer-utils");
const createFastUninitializedBuffer = buffer_utils.createFastUninitializedBuffer;
const UserIdentityTokenType = require("node-opcua-service-endpoints").UserIdentityTokenType;
const ClientSession = require("./client_session").ClientSession;
*/
const assert = require("node-opcua-assert").assert;
const async = require("async");
const util = require("util");
const fs = require("fs");
const _ = require("underscore");
const ApplicationType = require("node-opcua-service-endpoints").ApplicationType;
const StatusCodes = require("node-opcua-status-code").StatusCodes;
const SessionContext = require("node-opcua-address-space").SessionContext;
const fromURI = require("node-opcua-secure-channel").fromURI;
const SecurityPolicy = require("node-opcua-secure-channel").SecurityPolicy;
const MessageSecurityMode = require("node-opcua-service-secure-channel").MessageSecurityMode;
const utils = require("node-opcua-utils");
const debugLog = require("node-opcua-debug").make_debugLog(__filename);
const forceGarbageCollectionOnSessionClose = false;
const ServerEngine = require("./server_engine").ServerEngine;
const browse_service = require("node-opcua-service-browse");
const read_service = require("node-opcua-service-read");
const write_service = require("node-opcua-service-write");
const historizing_service = require("node-opcua-service-history");
const subscription_service = require("node-opcua-service-subscription");
const translate_service = require("node-opcua-service-translate-browse-path");
const session_service = require("node-opcua-service-session");
const register_node_service = require("node-opcua-service-register-node");