Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/* global describe,it,before*/
const should = require("should");
const assert = require("node-opcua-assert").assert;
const DataType = require("node-opcua-variant").DataType;
const NodeClass = require("node-opcua-data-model").NodeClass;
const resolveNodeId = require("node-opcua-nodeid").resolveNodeId;
const ObjectTypeIds = require("node-opcua-constants").ObjectTypeIds;
const VariableTypeIds = require("node-opcua-constants").VariableTypeIds;
const ReferenceTypeIds = require("node-opcua-constants").ReferenceTypeIds;
const ObjectIds = require("node-opcua-constants").ObjectIds;
const DataTypeIds = require("node-opcua-constants").DataTypeIds;
const Reference = require("..").Reference;
function dumpReferencesHierarchy(addressSpace) {
function _dump(referenceType,level) {
console.log(level,referenceType.browseName.toString(),"(",referenceType.getAllSubtypes().map(x=>x.browseName.toString()).join(" ").green,")");
const subTypes = referenceType.findReferencesExAsObject("HasSubtype");
for(let subType of subTypes) {
_dump(subType," "+ level);
const now = Date.now();
const session = this;
console.log(" name..................... ", session.name);
console.log(" sessionId................ ", session.sessionId.toString());
console.log(" authenticationToken...... ", session.authenticationToken.toString());
console.log(" timeout.................. ", session.timeout , "ms");
console.log(" serverNonce.............. ", session.serverNonce.toString("hex"));
console.log(" serverCertificate........ ", session.serverCertificate.toString("base64"));
console.log(" serverSignature.......... ", session.serverSignature);
console.log(" lastRequestSentTime...... ", new Date(session.lastRequestSentTime).toISOString(), now - session.lastRequestSentTime);
console.log(" lastResponseReceivedTime. ", new Date(session.lastResponseReceivedTime).toISOString(), now - session.lastResponseReceivedTime);
};
const AttributeIds = require("node-opcua-data-model").AttributeIds;
const ReferenceTypeIds = require("node-opcua-constants").ReferenceTypeIds;
const makeNodeId = require("node-opcua-nodeid").makeNodeId;
const resultMask = makeResultMask("ReferenceType");
function __findBasicDataType(session, dataTypeId, callback) {
assert(dataTypeId instanceof NodeId);
if (dataTypeId.value <= 25) {
// we have a well-known DataType
const dataType = DataType.get(dataTypeId.value);
callback(null, dataType);
} else {
// let's browse for the SuperType of this object
const nodeToBrowse = new browse_service.BrowseDescription({
referenceTypeId: makeNodeId(ReferenceTypeIds.HasSubtype),
const StatusCodes = require("node-opcua-status-code").StatusCodes;
const browse_service = require("node-opcua-service-browse");
const lowerFirstLetter = require("node-opcua-utils").lowerFirstLetter;
const VariableIds = require("node-opcua-constants").VariableIds;
const debugLog = require("node-opcua-debug").make_debugLog(__filename);
//
// some server do not expose the ReferenceType Node in their address space
// ReferenceType are defined by the OPCUA standard and can be prepopulated in the crawler.
// Pre-populating the ReferenceType node in the crawler will also reduce the network traffic.
//
const ReferenceTypeIds = require("node-opcua-constants").ReferenceTypeIds;
/*=
*
* @param arr
* @param maxNode
* @private
* @return {*}
*/
function _fetch_elements(arr, maxNode) {
assert(_.isArray(arr));
assert(arr.length > 0);
const high_limit = ( maxNode <= 0) ? arr.length : maxNode;
const tmp = arr.splice(0, high_limit);
assert(tmp.length > 0);
return tmp;
}
module.exports.LocalizedText = require("node-opcua-data-model").LocalizedText;
module.exports.coerceLocalizedText = require("node-opcua-data-model").coerceLocalizedText;
module.exports.QualifiedName = require("node-opcua-data-model").QualifiedName;
module.exports.coerceQualifyName = require("node-opcua-data-model").coerceQualifyName;
module.exports.NodeClass = require("node-opcua-data-model").NodeClass;
module.exports.NodeClassMask = require("node-opcua-data-model").NodeClassMask;
module.exports.AttributeIds = require("node-opcua-data-model").AttributeIds;
module.exports.AttributeNameById = require("node-opcua-data-model").AttributeNameById;
module.exports.BrowseDirection = require("node-opcua-data-model").BrowseDirection;
module.exports.VariableTypeIds = require("node-opcua-constants").VariableTypeIds;
module.exports.VariableIds = require("node-opcua-constants").VariableIds;
module.exports.MethodIds = require("node-opcua-constants").MethodIds;
module.exports.ObjectIds = require("node-opcua-constants").ObjectIds;
module.exports.ObjectTypeIds = require("node-opcua-constants").ObjectTypeIds;
module.exports.ReferenceTypeIds = require("node-opcua-constants").ReferenceTypeIds;
module.exports.DataTypeIds = require("node-opcua-constants").DataTypeIds;
// DA
module.exports.standardUnits = require("node-opcua-data-access").standardUnits;
module.exports.makeEUInformation = require("node-opcua-data-access").makeEUInformation;
module.exports.Range = require("node-opcua-data-access").Range;
//
module.exports.get_fully_qualified_domain_name = require("node-opcua-hostname").get_fully_qualified_domain_name;
module.exports.makeApplicationUrn = require("node-opcua-common").makeApplicationUrn;
// 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");
"use strict";
/**
* @module opcua.miscellaneous
* @class ToolBrowsePath
*
* @static
*/
const BrowsePath = require("../_generated_/_auto_generated_BrowsePath").BrowsePath;
const makeNodeId = require("node-opcua-nodeid").makeNodeId;
const ReferenceTypeIds = require("node-opcua-constants").ReferenceTypeIds;
const hierarchicalReferencesId = makeNodeId(ReferenceTypeIds.HierarchicalReferences);
exports.stringToQualifiedName = require("node-opcua-data-model").stringToQualifiedName;
/**
* @method constructBrowsePathFromQualifiedName
* @param startingNode
* @param browsePath
* @return {number|*|BrowsePath}
*/
function constructBrowsePathFromQualifiedName(startingNode, browsePath) {
browsePath = browsePath || [];
const elements = browsePath.map(function (targetName) {
const util = require("util");
const EventEmitter = require("events").EventEmitter;
const read_service = require("node-opcua-service-read");
const call_service = require("node-opcua-service-call");
const AttributeIds = require("node-opcua-data-model").AttributeIds;
const AccessLevelFlag = require("node-opcua-data-model").AccessLevelFlag;
const coerceAccessLevelFlag =require("node-opcua-data-model").coerceAccessLevelFlag;
const makeResultMask = require("node-opcua-data-model").makeResultMask;
const BrowseDirection = require("node-opcua-data-model").BrowseDirection;
const NodeClass = require("node-opcua-data-model").NodeClass;
const makeNodeClassMask = require("node-opcua-data-model").makeNodeClassMask;
const ReferenceTypeIds = require("node-opcua-constants").ReferenceTypeIds;
const ObjectTypeIds = require("node-opcua-constants").ObjectTypeIds;
const NodeId = require("node-opcua-nodeid").NodeId;
const makeNodeId = require("node-opcua-nodeid").makeNodeId;
const coerceNodeId = require("node-opcua-nodeid").coerceNodeId;
const StatusCodes = require("node-opcua-status-code").StatusCodes;
const lowerFirstLetter = require("node-opcua-utils").lowerFirstLetter;
const Variant = require("node-opcua-variant").Variant;
const VariantArrayType = require("node-opcua-variant").VariantArrayType;
const DataType = require("node-opcua-variant").DataType;
const ClientSession = require("node-opcua-client").ClientSession;