Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// istanbul ignore next
if (!state) {
throw new Error("Cannot find state with name " + toStateNode);
}
assert(state.browseName.name!.toString() === toStateNode);
toStateNode = state;
}
const fromStateNode = this.currentStateNode;
toStateNode = this._coerceNode(toStateNode) as any as State;
assert(toStateNode.nodeClass === NodeClass.Object);
this.currentState.setValueFromSource({
dataType: DataType.LocalizedText,
value: coerceLocalizedText(toStateNode.browseName.toString())
}, StatusCodes.Good);
this.currentStateNode = toStateNode;
const transitionNode = this.findTransitionNode(fromStateNode, toStateNode);
if (transitionNode) {
// xx console.log("transitionNode ",transitionNode.toString());
// The inherited Property SourceNode shall be filled with the NodeId of the StateMachine instance where the
// Transition occurs. If the Transition occurs in a SubStateMachine, then the NodeId of the SubStateMachine
// has to be used. If the Transition occurs between a StateMachine and a SubStateMachine, then the NodeId of
// the StateMachine has to be used, independent of the direction of the Transition.
// Transition identifies the Transition that triggered the Event.
// FromState identifies the State before the Transition.
// ToState identifies the State after the Transition.
this.raiseEvent("TransitionEventType", {
if (Object.keys(previousConfMap).length !== 0) {
debugLog(" Warning some conf need to be removed !");
}
} else {
// server is announced offline
if (key in this.registeredServers) {
const server1 = this.registeredServers[key];
debugLog(chalk.cyan("unregistering server : "), chalk.yellow(server1.serverUri!));
configurationResults = [];
discoveryConfigurations = server1.discoveryConfiguration || [];
for (const conf of discoveryConfigurations) {
await _stop_announcedOnMulticastSubnet(conf);
configurationResults.push(StatusCodes.Good);
}
delete this.registeredServers[key];
}
}
const response = new RegisterServerXResponse({
configurationResults
});
return response;
}
}
function addElement(options, uaArrayVariableNode) {
assert(uaArrayVariableNode," must provide an UAVariable containing the array");
assert(uaArrayVariableNode instanceof UAVariable,"expecting a UAVariable node here");
// verify that arr has been created correctly
assert(!!uaArrayVariableNode.$$variableType && !!uaArrayVariableNode.$$dataType,
"did you create the array Node with createExtObjArrayNode ?");
assert(uaArrayVariableNode.$$dataType instanceof UADataType);
assert(uaArrayVariableNode.$$dataType._extensionObjectConstructor instanceof Function);
const checkValue = uaArrayVariableNode.readValue();
assert(checkValue.statusCode === StatusCodes.Good);
assert(checkValue.value.dataType === DataType.ExtensionObject);
const addressSpace = uaArrayVariableNode.addressSpace;
let extensionObject = null;
let elVar = null;
let browseName;
if (options instanceof UAVariable) {
elVar = options;
extensionObject = elVar.$extensionObject; // get shared extension object
assert(extensionObject instanceof uaArrayVariableNode.$$dataType._extensionObjectConstructor,
"the provided variable must expose a Extension Object of the expected type ");
// add a reference
uaArrayVariableNode.addReference({referenceType: "HasComponent", isFoward: true, nodeId: elVar.nodeId});
//xx elVar.bindExtensionObject();
session.republish(request, (err: Error | null, response?: RepublishResponse) => {
if (!err && response!.responseHeader.serviceResult.equals(StatusCodes.Good)) {
// reprocess notification message and keep going
subscription.onNotificationMessage(response!.notificationMessage);
} else {
if (!err) {
err = new Error(response!.responseHeader.serviceResult.toString());
}
debugLog(" _send_republish ends with ", err.message);
isDone = true;
}
callback2(err ? err : undefined);
});
};
if (this.receiverCertificate) {
// extract public key
extractPublicKeyFromCertificate(this.receiverCertificate, (err, key) => {
if (!err) {
if (key) {
this.receiverPublicKey = key;
this.receiverPublicKeyLength = rsa_length(key);
}
callback(null, StatusCodes.Good);
} else {
callback(err);
}
});
} else {
this.receiverPublicKey = null;
callback(null, StatusCodes.Good);
}
});
}
return StatusCodes.BadCertificateTimeInvalid;
}
// Has SoftwareCertificate has been revoked by the issuer ?
// TODO: check if certificate is revoked or not ...
// StatusCodes.BadCertificateRevoked
// is issuer Certificate valid and has not been revoked by the CA that issued it. ?
// TODO : check validity of issuer certificate
// StatusCodes.BadCertificateIssuerRevoked
//does the URI specified in the ApplicationDescription match the URI in the Certificate ?
// TODO : check ApplicationDescription of issuer certificate
// return StatusCodes.BadCertificateUriInvalid
return StatusCodes.Good;
}
session.read(nodesToRead, 1, function (err, dataValues) {
if (dataValues[0].statusCode === StatusCodes.Good) {
clientObject.dataValue = dataValues[0].value;
}
if (dataValues[1].statusCode === StatusCodes.Good) {
//xx console.log("AccessLevel ", results[3].value.toString())
clientObject.userAccessLevel = coerceAccessLevelFlag(dataValues[1].value.value);
}
if (dataValues[2].statusCode === StatusCodes.Good) {
clientObject.accessLevel = coerceAccessLevelFlag(dataValues[2].value.value);
}
callback(err);
});
}
if (diagnosticInfo.symbolicId >=0) {
encoding_mask = set_flag(encoding_mask, DiagnosticInfo_EncodingByte.SymbolicId);
}
if (diagnosticInfo.namespaceUri >=0) {
encoding_mask = set_flag(encoding_mask, DiagnosticInfo_EncodingByte.NamespaceUri);
}
if (diagnosticInfo.localizedText >=0) {
encoding_mask = set_flag(encoding_mask, DiagnosticInfo_EncodingByte.LocalizedText);
}
if (diagnosticInfo.locale >= 0) {
encoding_mask = set_flag(encoding_mask, DiagnosticInfo_EncodingByte.Locale);
}
if (diagnosticInfo.additionalInfo) {
encoding_mask = set_flag(encoding_mask, DiagnosticInfo_EncodingByte.AdditionalInfo);
}
if (diagnosticInfo.innerStatusCode && diagnosticInfo.innerStatusCode !== StatusCodes.Good) {
encoding_mask = set_flag(encoding_mask, DiagnosticInfo_EncodingByte.InnerStatusCode);
}
if (diagnosticInfo.innerDiagnosticInfo) {
encoding_mask = set_flag(encoding_mask, DiagnosticInfo_EncodingByte.InnerDiagnosticInfo);
}
return encoding_mask;
}
nodeId: node.nodeId,
attributeId: attributeId
}));
try {
const dataValues = await this.session.read(nodesToRead);
const results: any[] = [];
for (let i = 0; i < nodesToRead.length; i++) {
const nodeToRead = nodesToRead[i];
const dataValue = dataValues[i];
if (dataValue.statusCode !== StatusCodes.Good) {
continue;
}
const s = toString1(nodeToRead.attributeId, dataValue);
results.push({
attribute: attributeIdtoString[nodeToRead.attributeId],
text: s
});
}
return results;
} catch (err) {
return [];
}
}
function isValidSecurityPolicy(securityPolicy: SecurityPolicy) {
switch (securityPolicy) {
case SecurityPolicy.None:
case SecurityPolicy.Basic128Rsa15:
case SecurityPolicy.Basic256:
case SecurityPolicy.Basic256Sha256:
return StatusCodes.Good;
default:
return StatusCodes.BadSecurityPolicyRejected;
}
}