Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
console.log("Looking for.. [" + fentry + "].... " + cmsg["actname"]);
if (fentry === undefined) {
// send an REXEC-NAK message: {REXEC-NAK, ASY, ACTIVITY, actid, device_id, error_code}
var nmsg = {"cmd": "REXEC-NAK", "opt": "ASY", "actname": "ACTIVITY", "actid": cmsg["actid"], "actarg": cmsg["actarg"], "args": ["NOT-FOUND"]};
var encodemsg = cbor.encode(nmsg);
sock.send(encodemsg);
console.log("Sent the message..NOT-FOUND");
}
else
{
// create actid, select lease-value, put entry in the activity table
// send [REXEC-ACK ASY ACTIVITY actid device_id lease-value (arg0) ]
activityTable[cmsg["actid"]] = undefined;
var nmsg = {"cmd": "REXEC-ACK", "opt": "ASY", "actname": "ACTIVITY", "actid": cmsg["actid"], "actarg": cmsg["actarg"], "args": []};
var encodemsg = cbor.encode(nmsg);
sock.send(encodemsg);
// Run function
var res = fentry.func.apply(this, cmsg["args"]);
activityTable[cmsg["actid"]] = res;
console.log("Execution complete.. results stored...");
}
}
var fentry = funcRegistry[cmsg["actname"]];
console.log("Looking for.. [" + fentry + "].... " + cmsg["actname"]);
if (fentry === undefined) {
// send an REXEC-NAK message: {REXEC-NAK, SYN, ACTIVITY, actid, device_id, error_code}
var nmsg = {"cmd": "REXEC-NAK", "opt": "SYN", "actname": "ACTIVITY",
"actid": cmsg["actid"], "actarg": cmsg["actarg"], "args": ["NOT-FOUND"]};
var encodemsg = cbor.encode(nmsg);
sock.send(encodemsg);
console.log("Sent the message..NOT-FOUND");
}
else
if (checkArgsType(cmsg["args"], fentry.mask) !== true) {
// send an REXEC-NAK message: {REXEC-NAK, SYN, ACTIVITY, actid, device_id, error_code}
var nmsg = {"cmd": "REXEC-NAK", "opt": "SYN", "actname": "ACTIVITY",
"actid": cmsg["actid"], "actarg": cmsg["actarg"], "args": ["ILLEGAL-PARAMS"]};
var encodemsg = cbor.encode(nmsg);
sock.send(encodemsg);
console.log("Sent the message..ILLEGAL-PARAMS");
}
else
{
// create actid, select lease-value, put entry in the activity table
// send [REXEC-ACK SYN ACTIVITY actid device_id lease-value (arg0) ]
activityTable[cmsg["actid"]] = undefined;
var nmsg = {"cmd": "REXEC-ACK", "opt": "SYN", "actname": "ACTIVITY",
"actid": cmsg["actid"], "actarg": cmsg["actarg"], "args": []};
var encodemsg = cbor.encode(nmsg);
sock.send(encodemsg);
// Run function
var res = fentry.func.apply(this, cmsg["args"]);
const derivationPath = [HARDENED_THRESHOLD, childIndex]
addressPayload = encryptDerivationPath(derivationPath, hdPassphrase)
addressAttributes = new Map([[1, cbor.encode(addressPayload)]])
derivedHdNode = deriveHdNode(parentHdNode, childIndex)
}
const addressRoot = getAddressRoot(derivedHdNode, addressPayload)
const addressType = 0 // Public key address
const addressData = [addressRoot, addressAttributes, addressType]
const addressDataEncoded = cbor.encode(addressData)
const address = base58.encode(
cbor.encode([
new cbor.Tagged(24, addressDataEncoded),
crc32Unsigned(addressDataEncoded)
])
)
return {
address,
childIndex,
hdNode: derivedHdNode
}
}
rsp_message['m2m:rsp'].pc[prop][prop2]['@'] = {rn : rsp_message['m2m:rsp'].pc[prop][prop2][prop3]};
delete rsp_message['m2m:rsp'].pc[prop][prop2][prop3];
}
}
}
}
}
}
}
var bodyString = js2xmlparser.parse("m2m:rsp", rsp_message['m2m:rsp']);
ws_conn.sendUTF(bodyString.toString());
}
else if (bodytype === 'cbor') { // 'cbor'
bodyString = cbor.encode(rsp_message['m2m:rsp']).toString('hex');
var bytearray = Buffer.from(bodyString, 'hex');
ws_conn.send(bytearray);
}
else { // 'json'
ws_conn.sendUTF(JSON.stringify(rsp_message['m2m:rsp']));
}
}
adminProcessor(rep, msg, function(obj) {
var encode = cbor.encode(obj);
rep.send(encode);
console.log(obj);
});
} catch(err) {
function sendMsg(sock, obj) {
console.log("Sending.." + obj["opt"]);
console.log(obj);
try {
var encoded = cbor.encode(obj);
sock.send(encoded);
} catch (err) {
console.log(err);
}
console.log("End sendMsg");
}
outputs: outputs.map(out => {
const [address, value] = out
return { address: bs58.encode(cbor.encode(address)), value }
}),
witnesses: witnesses.map(w => {
function hashBlake2b256(input) {
return Buffer.from(blakejs.blake2b(cbor.encode(input), null, 32))
}
function sendPong(sock, msg, callback) {
var src = msg["opt"];
msg["cmd"] = "PONG";
msg["opt"] = getMyType();
var encoded = cbor.encode(msg);
sock.send(encoded);
callback(src, msg);
}
encodeCBOR(encoder) {
return encoder.pushAny([
this.type,
new cbor.Tagged(24, cbor.encode([this.publicString, this.signature]))
]);
}
}