Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public renewEventId() {
const addressSpace = this.condition.addressSpace;
// create a new event Id for this new condition
const eventId = addressSpace.generateEventId();
const ret = this._set_var("eventId", DataType.ByteString, eventId.value);
// xx var branch = self; console.log("MMMMMMMMrenewEventId branch " +
// branch.getBranchId().toString() + " eventId = " + branch.getEventId().toString("hex"));
return ret;
}
ConditionSnapshot.prototype.renewEventId = function() {
const self = this;
const addressSpace = self.condition.addressSpace;
// create a new event Id for this new condition
const eventId = addressSpace.generateEventId();
const ret = self._set_var("eventId", DataType.ByteString, eventId.value);
//xx var branch = self; console.log("MMMMMMMMrenewEventId branch " + branch.getBranchId().toString() + " eventId = " + branch.getEventId().toString("hex"));
return ret;
};
const data = Buffer.alloc(length);
let ret;
try {
ret = await promisify(fs.read)(_fileInfo.fd, data, 0, length, _fileInfo.position[1]);
_fileInfo.position[1] += ret.bytesRead;
} catch (err) {
errorLog("Read error : ", err.message);
return { statusCode: StatusCodes.BadUnexpectedError };
}
// Data Contains the returned data of the file. If the ByteString is empty it indicates that the end
// of the file is reached.
return {
outputArguments: [
{ dataType: DataType.ByteString, value: data.slice(0, ret.bytesRead) }
],
statusCode: StatusCodes.Good
};
}
if (basicType === DataType.Byte && this.valueRank === 1) {
if (variant.arrayType === VariantArrayType.Scalar && variant.dataType === DataType.ByteString) {
if ((this.dataType.value === DataType.Byte) && (this.dataType.namespace === 0)) { // Byte
variant.arrayType = VariantArrayType.Array;
variant.dataType = DataType.Byte;
assert(variant.dataType === DataType.Byte);
assert(!variant.value || variant.value instanceof Buffer);
}
}
}
if (basicType === DataType.ByteString && this.valueRank === -1 /* Scalar*/) {
if (variant.arrayType === VariantArrayType.Array && variant.dataType === DataType.Byte) {
if ((this.dataType.value === DataType.ByteString) && (this.dataType.namespace === 0)) { // Byte
variant.arrayType = VariantArrayType.Scalar;
variant.dataType = DataType.ByteString;
assert(variant.dataType === DataType.ByteString);
assert(!variant.value || variant.value instanceof Buffer);
}
}
}
return variant;
}
UAAcknowledgeableConditionBase.prototype._raiseAuditConditionAcknowledgeEvent = function(branch) {
// raise the AuditConditionAcknowledgeEventType
const eventData = {
// EventType
eventId: { dataType: DataType.ByteString, value: branch.getEventId() },
//xx branchId: branch.branchId.readValue().value,
// AuditEventType
actionTimeStamp: { dataType: DataType.DateTime, value : new Date() },
status: { dataType: DataType.StatusCodes, value: StatusCodes.Good },
serverId: {},
clientAuditEntryId: {},
clientUserId: {},
methodId: {},
inputArguments: {},
comment: {dataType: DataType.LocalizedText, value: branch.getComment() }
};
this.raiseEvent("AuditConditionAcknowledgeEventType",eventData);
};
finish: function () {
const base64text = this.text;
const byteString = Buffer.from(base64text, "base64");
this.parent.parent.obj.value = {
dataType: DataType.ByteString,
arrayType: VariantArrayType.Scalar,
value: byteString
};
}
},
const result = await this.session.call({
inputArguments: [
{ dataType: DataType.UInt32, value: this.fileHandle },
{
arrayType: VariantArrayType.Scalar,
dataType: DataType.Int32,
value: bytesToRead
}
],
methodId: this.readNodeId,
objectId: this.fileNodeId
});
if (result.statusCode !== StatusCodes.Good) {
throw new Error("Error " + result.statusCode.toString());
}
if (!result.outputArguments || result.outputArguments[0].dataType !== DataType.ByteString) {
throw new Error("Error invalid output");
}
return result.outputArguments![0].value as Buffer;
}
const pushCertificateManager = getPushCertificateManager(this);
if (!pushCertificateManager) {
return { statusCode: StatusCodes.BadNotImplemented };
}
const result = await pushCertificateManager.getRejectedList();
if (result.statusCode !== StatusCodes.Good) {
return { statusCode: result.statusCode };
}
return {
outputArguments: [
{
arrayType: VariantArrayType.Array,
dataType: DataType.ByteString,
value: result.certificates
}
],
statusCode: StatusCodes.Good
};
}
function canRange(dataValue: DataValue): boolean {
return dataValue.value && ((dataValue.value.arrayType !== VariantArrayType.Scalar) ||
((dataValue.value.arrayType === VariantArrayType.Scalar) && (dataValue.value.dataType === DataType.ByteString))
||
((dataValue.value.arrayType === VariantArrayType.Scalar) && (dataValue.value.dataType === DataType.String)));
}
public async write(data: Buffer): Promise {
await this.ensureInitialized();
if (!this.fileHandle) {
throw new Error("File has node been opened yet");
}
const result = await this.session.call({
inputArguments: [
{ dataType: DataType.UInt32, value: this.fileHandle },
{
arrayType: VariantArrayType.Scalar,
dataType: DataType.ByteString,
value: data
}
],
methodId: this.writeNodeId,
objectId: this.fileNodeId
});
if (result.statusCode !== StatusCodes.Good) {
throw new Error("Error " + result.statusCode.toString());
}
return;
}