Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
this.read = async (data: Buffer) => {
this.logger.info(`read() buffer.length: ${data.length}`);
const {header: {serialization}} = persistencePartsUtil.split(data);
const decryptedData = await encryptionAdapter.read(data);
if (serialization && serialization.type === "msgpack") {
this.logger.verbose(`"msgpack.decode" start`);
const decoded = msgpack.decode(decryptedData) as FsDb;
this.logger.verbose(`"msgpack.decode" end`);
return decoded;
}
const readableStream = bufferToStream(decryptedData);
return new Promise((resolve, reject) => {
this.logger.verbose(`"oboe" start`);
// TODO replace "oboe" with alternative library that doesn't block the Event Loop so heavily
// review the following libraries:
// - https://gitlab.com/philbooth/bfj
// - https://github.com/ibmruntimes/yieldable-json
// or consider moving parsing to a separate Worker/Process
oboe(readableStream)
.done((parsed) => {
public async *messages(): AsyncIterableIterator<
OpenNewTabReply | StdOutMessage
> {
for await (const data of this.connection) {
if (!data) continue
// TODO: maybe throw an error??
if (typeof data === "string") continue
const messages = BinaryMessageFormat.parse(data)
for (const message of messages) {
const decoded = decode(message) as [string, Buffer]
const type = decoded[0]
const payload = decode(decoded[1])
switch (type) {
case "OpenNewTabReply":
yield OpenNewTabReply.fromJS(payload)
break
case "StdOutMessage": {
const stdOut = StdOutMessage.fromJS(payload)
stdOut.data = Array.from(
(payload as { Data: number[] })["Data"],
)
yield stdOut
break
}
public async *messages(): AsyncIterableIterator<
OpenNewTabReply | StdOutMessage
> {
for await (const data of this.connection) {
if (!data) continue
// TODO: maybe throw an error??
if (typeof data === "string") continue
const messages = BinaryMessageFormat.parse(data)
for (const message of messages) {
const decoded = decode(message) as [string, Buffer]
const type = decoded[0]
const payload = decode(decoded[1])
switch (type) {
case "OpenNewTabReply":
yield OpenNewTabReply.fromJS(payload)
break
case "StdOutMessage": {
const stdOut = StdOutMessage.fromJS(payload)
stdOut.data = Array.from(
(payload as { Data: number[] })["Data"],
)
yield stdOut
break
}
default:
async _recv(name) {
for await (const [packet] of this.sockets[name]) {
this.bytes_recv += packet.length;
return msgpack.decode(packet);
}
}
tx.data().forEach((datum) => {
if(
datum
&& datum[0].toString() === '19HxigV4QyBv3tHpQVcUEQyq1pzZVdoAut'
&& datum[2].toString() == 'application/msgpack'
) {
try {
results.push(msgpack.decode(datum[1]));
} catch (err) {}
}
});
return results;
const deserializeMessage = (buffer: Uint8Array): Messages => {
const [type, payload] = decode(buffer) as [string, unknown]
switch (type) {
case "OpenNewTabReply": {
return OpenNewTabReply.fromJS(payload)
}
case "OutputEvent": {
const message = OutputEvent.fromJS(payload)
message.data = Array.from((payload as { Data: number[] })["Data"])
return message
}
default:
return new UnknownMessage(type, payload)
}
}