Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
nodeIdType = NodeIdType.NUMERIC;
break;
case EnumNodeIdEncoding.FourBytes:
namespace = stream.readUInt8();
value = stream.readUInt16();
nodeIdType = NodeIdType.NUMERIC;
break;
case EnumNodeIdEncoding.Numeric:
namespace = stream.readUInt16();
value = stream.readUInt32();
nodeIdType = NodeIdType.NUMERIC;
break;
case EnumNodeIdEncoding.String:
namespace = stream.readUInt16();
value = decodeString(stream);
nodeIdType = NodeIdType.STRING;
break;
case EnumNodeIdEncoding.ByteString:
namespace = stream.readUInt16();
value = decodeByteString(stream);
nodeIdType = NodeIdType.BYTESTRING;
break;
default:
if (encodingByte !== EnumNodeIdEncoding.Guid) {
/*jslint bitwise: true */
// console.log(" encoding_byte = 0x" + encodingByte.toString(16),
// " bin=", ("0000000000000000" + encodingByte.toString(2)).substr(-16),
// encodingByte, encodingByte & 0x3f);
throw new Error(" encoding_byte = " + encodingByte.toString(16));
}
namespace = stream.readUInt16();
if (isUInt8(nodeId.value as number) &&
!nodeId.namespace &&
!(nodeId as ExpandedNodeId).namespaceUri &&
!(nodeId as ExpandedNodeId).serverIndex) {
encodingByte = encodingByte | EnumNodeIdEncoding.TwoBytes;
} else if (
isUInt16(nodeId.value as number) &&
isUInt8(nodeId.namespace) &&
!(nodeId as ExpandedNodeId).namespaceUri &&
!(nodeId as ExpandedNodeId).serverIndex
) {
encodingByte = encodingByte | EnumNodeIdEncoding.FourBytes;
} else {
encodingByte = encodingByte | EnumNodeIdEncoding.Numeric;
}
} else if (nodeId.identifierType === NodeIdType.STRING) {
encodingByte = encodingByte | EnumNodeIdEncoding.String;
} else if (nodeId.identifierType === NodeIdType.BYTESTRING) {
encodingByte = encodingByte | EnumNodeIdEncoding.ByteString;
} else if (nodeId.identifierType === NodeIdType.GUID) {
encodingByte = encodingByte | EnumNodeIdEncoding.Guid;
}
if (nodeId.hasOwnProperty("namespaceUri") && (nodeId as ExpandedNodeId).namespaceUri) {
encodingByte = encodingByte | EnumNodeIdEncoding.NamespaceUriFlag;
}
if (nodeId.hasOwnProperty("serverIndex") && (nodeId as ExpandedNodeId).serverIndex) {
encodingByte = encodingByte | EnumNodeIdEncoding.ServerIndexFlag;
}
return encodingByte;
}