diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b512c09 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +node_modules \ No newline at end of file diff --git a/Makefile b/Makefile deleted file mode 100755 index 6db34cb..0000000 --- a/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -test: - ./node_modules/.bin/mocha --reporter spec - - .PHONY: test diff --git a/README.md b/README.md index 060b769..5e03c0d 100644 --- a/README.md +++ b/README.md @@ -38,16 +38,16 @@ Content-Length: 0 #### Example: rcinfo ``` -rcinfo = { type: 'HEP', +rcinfo = { + type: 'HEP', version: 3, - payload_type: 'SIP', captureId: '2001', capturePass: 'myHep', - ip_family: 2, - time_sec: 1433719443, - time_usec: 979, + protocolFamily: 2, + timeSeconds: 1433719443, + timeUseconds: 979, protocol: 17, - proto_type: 1, + payloadType: 1, srcIp: '192.168.100.1', dstIp: '192.168.1.23', srcPort: 5060, diff --git a/index.js b/index.js index 675bce0..604f97a 100755 --- a/index.js +++ b/index.js @@ -23,531 +23,430 @@ * **/ -var debug = false; +const debug = false; // Module import -var Parser = require("binary-parser").Parser; -var mixinDeep = require('mixin-deep'); -var extensions = {}; +const Parser = require("binary-parser").Parser; +const mixinDeep = require("mixin-deep"); +const assert = require("assert"); +const ip = require("ip"); + +let extensions = {}; module.exports = { - /** - * Decode HEP3 Packet to JSON Object. - * - * @param {Buffer} hep message - * @return {Object} - */ - decapsulate: function(message) { - if (debug) console.log('Decoding HEP3 Packet...'); - try { - var HEP = hepHeader.parse(message); - if(HEP.payload && HEP.payload.length>0){ - var data = HEP.payload; - var tot = 0; - var decoded = {}; - var PAYLOAD; - while(true){ - PAYLOAD = hepParse.parse( data.slice(tot) ); - var tmp = hepDecode(PAYLOAD); - decoded = mixinDeep(decoded, tmp); - tot += PAYLOAD.length; - if(tot>=HEP.payload.length) { break; } - } - if(debug) console.log(decoded); - return decoded; - } - } catch(e) { - return false; - } - - }, - /** - * Encode HEP3 Packet from JSON Object. - * - * @param {String} sip_msg - * @param {String} hep_json - * @return {Buffer} hep message - */ - encapsulate: function(msg,rcinfo) { - if (debug) console.log('Sending HEP3 Packet...'); - var header = Buffer.allocUnsafe(6); - header.write ("HEP3"); - - var ip_family = Buffer.allocUnsafe(7); - ip_family.writeUInt16BE(0x0000, 0); - ip_family.writeUInt16BE(0x0001,2); - ip_family.writeUInt8(rcinfo.protocolFamily,6); - ip_family.writeUInt16BE(ip_family.length,4); - - var ip_proto = Buffer.allocUnsafe(7); - ip_proto.writeUInt16BE(0x0000, 0); - ip_proto.writeUInt16BE(0x0002, 2); - ip_proto.writeUInt8(rcinfo.protocol,6); - ip_proto.writeUInt16BE(ip_proto.length,4); - - /*ip*/ - var d = rcinfo.srcIp ? rcinfo.srcIp.split('.') : ['127','0','0','1']; - var tmpip = ((((((+d[0])*256)+(+d[1]))*256)+(+d[2]))*256)+(+d[3]); - - var src_ip4 = Buffer.allocUnsafe(10); - src_ip4.writeUInt16BE(0x0000, 0); - src_ip4.writeUInt16BE(0x0003, 2); - src_ip4.writeUInt32BE(tmpip,6); - src_ip4.writeUInt16BE(src_ip4.length,4); - - d = rcinfo.dstIp ? rcinfo.dstIp.split('.') : ['127','0','0','1']; - tmpip = ((((((+d[0])*256)+(+d[1]))*256)+(+d[2]))*256)+(+d[3]); - - var dst_ip4 = Buffer.allocUnsafe(10); - dst_ip4.writeUInt16BE(0x0000, 0); - dst_ip4.writeUInt16BE(0x0004, 2); - dst_ip4.writeUInt32BE(tmpip,6); - dst_ip4.writeUInt16BE(dst_ip4.length,4); - - var src_port = Buffer.allocUnsafe(8); - var tmpA = rcinfo.srcPort ? parseInt(rcinfo.srcPort,10) : 0; - src_port.writeUInt16BE(0x0000, 0); - src_port.writeUInt16BE(0x0007, 2); - src_port.writeUInt16BE(tmpA,6); - src_port.writeUInt16BE(src_port.length,4); - - var dst_port = Buffer.allocUnsafe(8); - tmpA = rcinfo.dstPort ? parseInt(rcinfo.dstPort, 10) : 0; - dst_port.writeUInt16BE(0x0000, 0); - dst_port.writeUInt16BE(0x0008, 2); - dst_port.writeUInt16BE(tmpA,6); - dst_port.writeUInt16BE(dst_port.length,4); - - tmpA = ToUint32(rcinfo.timeSeconds); - var time_sec = Buffer.allocUnsafe(10); - time_sec.writeUInt16BE(0x0000, 0); - time_sec.writeUInt16BE(0x0009, 2); - time_sec.writeUInt32BE(tmpA,6); - time_sec.writeUInt16BE(time_sec.length,4); - - tmpA = ToUint32(rcinfo.timeUseconds); - var time_usec = Buffer.allocUnsafe(10); - time_usec.writeUInt16BE(0x0000, 0); - time_usec.writeUInt16BE(0x000a, 2); - time_usec.writeUInt32BE(tmpA,6); - time_usec.writeUInt16BE(time_usec.length,4); - - var proto_type = Buffer.allocUnsafe(7); - proto_type.writeUInt16BE(0x0000, 0); - proto_type.writeUInt16BE(0x000b,2); - proto_type.writeUInt8(rcinfo.payloadType,6); - proto_type.writeUInt16BE(proto_type.length,4); - - tmpA = ToUint32(rcinfo.captureId); - var capt_id = Buffer.allocUnsafe(10); - capt_id.writeUInt16BE(0x0000, 0); - capt_id.writeUInt16BE(0x000c, 2); - capt_id.writeUInt32BE(tmpA,6); - capt_id.writeUInt16BE(capt_id.length,4); - - // HEPNodeName w/ Fallback to HEP Capture ID - tmpA = rcinfo.hepNodeName ? rcinfo.hepNodeName : "" + rcinfo.captureId; - var hepnodename_chunk = Buffer.allocUnsafe(6 + tmpA.length); - hepnodename_chunk.writeUInt16BE(0x0000, 0); - hepnodename_chunk.writeUInt16BE(0x0013, 2); - hepnodename_chunk.write(tmpA,6, tmpA.length); - hepnodename_chunk.writeUInt16BE(hepnodename_chunk.length,4); - - var auth_chunk; - if(typeof rcinfo.capturePass === 'string') { - auth_chunk = Buffer.allocUnsafe(6 + rcinfo.capturePass.length); - auth_chunk.writeUInt16BE(0x0000, 0); - auth_chunk.writeUInt16BE(0x000e, 2); - auth_chunk.write(rcinfo.capturePass,6, rcinfo.capturePass.length); - auth_chunk.writeUInt16BE(auth_chunk.length,4); - } - else { - auth_chunk = Buffer.allocUnsafe(0); - } + /** + * Decode HEP3 Packet to JSON Object. + * + * @param {Buffer} hep message + * @return {Object} + */ + decapsulate: function (message) { + if (debug) console.log('Decoding HEP3 Packet...'); + try { + let HEP = hepHeader.parse(message); + if (HEP.payload && HEP.payload.length > 0) { + let data = HEP.payload; + let tot = 0; + let decoded = {}; + let PAYLOAD; + while (true) { + PAYLOAD = hepParse.parse(data.subarray(tot)); + let tmp = hepDecode(PAYLOAD); + decoded = mixinDeep(decoded, tmp); + tot += PAYLOAD.length; + if (tot >= HEP.payload.length) { break; } + } + if (debug) console.log(decoded); + return decoded; + } + } catch (e) { + return false; + } - var payload_chunk = Buffer.allocUnsafe(6 + msg.length); - payload_chunk.writeUInt16BE(0x0000, 0); - payload_chunk.writeUInt16BE(0x000f, 2); - payload_chunk.write(msg, 6, msg.length); - payload_chunk.writeUInt16BE(payload_chunk.length,4); - - var extensions_chunk = Buffer.allocUnsafe(0); - for(var i in extensions) { - for(var j in extensions[i]) { - var extdef = extensions[i][j]; - if(typeof extdef === "object" && - typeof extdef.keyName === "string" && - typeof rcinfo[extdef.keyName] !== 'undefined') { - var this_chunk; - var data = rcinfo[extdef.keyName]; - var failed = true; - if(/\d{1,}/.test(extdef.type)) { - var bitLength = extdef.type.match(/\d{1,}/)[0]; - var size = Math.floor(bitLength/8)+6; - this_chunk = Buffer.allocUnsafe(size); - this_chunk.writeUInt16BE(i, 0); - this_chunk.writeUInt16BE(j, 2); - if(typeof this_chunk["write"+extdef.type] === 'function') { - this_chunk['write'+extdef.type](data ,6); - failed = false; - } - else if(typeof this_chunk["write"+extdef.type+"BE"] === 'function') { - this_chunk['write'+extdef.type+"BE"](data ,6); - failed = false; - } - this_chunk.writeUInt16BE(this_chunk.length,4); + }, + /** + * Encode HEP3 Packet from JSON Object. + * + * @param {String} sip_msg + * @param {String} hep_json + * @return {Buffer} hep message + */ + encapsulate: function (msg, rcinfo) { + if (debug) console.log('Sending HEP3 Packet...'); + let header = Buffer.allocUnsafe(6); + header.write("HEP3"); + + let ip_family = Buffer.allocUnsafe(7); + ip_family.writeUInt16BE(0x0000, 0); + ip_family.writeUInt16BE(0x0001, 2); + ip_family.writeUInt8(rcinfo.protocolFamily, 6); + ip_family.writeUInt16BE(ip_family.length, 4); + + let ip_proto = Buffer.allocUnsafe(7); + ip_proto.writeUInt16BE(0x0000, 0); + ip_proto.writeUInt16BE(0x0002, 2); + ip_proto.writeUInt8(rcinfo.protocol, 6); + ip_proto.writeUInt16BE(ip_proto.length, 4); + + /*ip*/ + let src_ip = Buffer.allocUnsafe(rcinfo.protocolFamily == 10 ? 22 : 10); + src_ip.writeUInt16BE(0x0000, 0); + src_ip.writeUInt16BE(rcinfo.protocolFamily == 10 ? 0x0005 : 0x0003, 2); + ip.toBuffer(rcinfo.srcIp).copy(src_ip, 6); + src_ip.writeUInt16BE(src_ip.length, 4); + + let dst_ip = Buffer.allocUnsafe(rcinfo.protocolFamily == 10 ? 22 : 10); + dst_ip.writeUInt16BE(0x0000, 0); + dst_ip.writeUInt16BE(rcinfo.protocolFamily == 10 ? 0x0006 : 0x0004, 2); + ip.toBuffer(rcinfo.dstIp).copy(dst_ip, 6); + dst_ip.writeUInt16BE(dst_ip.length, 4); + + /*port*/ + let src_port = Buffer.allocUnsafe(8); + let tmpA = rcinfo.srcPort ? parseInt(rcinfo.srcPort, 10) : 0; + src_port.writeUInt16BE(0x0000, 0); + src_port.writeUInt16BE(0x0007, 2); + src_port.writeUInt16BE(tmpA, 6); + src_port.writeUInt16BE(src_port.length, 4); + + let dst_port = Buffer.allocUnsafe(8); + tmpA = rcinfo.dstPort ? parseInt(rcinfo.dstPort, 10) : 0; + dst_port.writeUInt16BE(0x0000, 0); + dst_port.writeUInt16BE(0x0008, 2); + dst_port.writeUInt16BE(tmpA, 6); + dst_port.writeUInt16BE(dst_port.length, 4); + + tmpA = ToUint32(rcinfo.timeSeconds); + let time_sec = Buffer.allocUnsafe(10); + time_sec.writeUInt16BE(0x0000, 0); + time_sec.writeUInt16BE(0x0009, 2); + time_sec.writeUInt32BE(tmpA, 6); + time_sec.writeUInt16BE(time_sec.length, 4); + + tmpA = ToUint32(rcinfo.timeUseconds); + let time_usec = Buffer.allocUnsafe(10); + time_usec.writeUInt16BE(0x0000, 0); + time_usec.writeUInt16BE(0x000a, 2); + time_usec.writeUInt32BE(tmpA, 6); + time_usec.writeUInt16BE(time_usec.length, 4); + + let proto_type = Buffer.allocUnsafe(7); + proto_type.writeUInt16BE(0x0000, 0); + proto_type.writeUInt16BE(0x000b, 2); + proto_type.writeUInt8(rcinfo.payloadType, 6); + proto_type.writeUInt16BE(proto_type.length, 4); + + tmpA = ToUint32(rcinfo.captureId); + let capt_id = Buffer.allocUnsafe(10); + capt_id.writeUInt16BE(0x0000, 0); + capt_id.writeUInt16BE(0x000c, 2); + capt_id.writeUInt32BE(tmpA, 6); + capt_id.writeUInt16BE(capt_id.length, 4); + + // HEPNodeName w/ Fallback to HEP Capture ID + tmpA = rcinfo.hepNodeName ? rcinfo.hepNodeName : "" + rcinfo.captureId; + let hepnodename_chunk = Buffer.allocUnsafe(6 + tmpA.length); + hepnodename_chunk.writeUInt16BE(0x0000, 0); + hepnodename_chunk.writeUInt16BE(0x0013, 2); + hepnodename_chunk.write(tmpA, 6, tmpA.length); + hepnodename_chunk.writeUInt16BE(hepnodename_chunk.length, 4); + + let auth_chunk; + if (typeof rcinfo.capturePass === 'string') { + auth_chunk = Buffer.allocUnsafe(6 + rcinfo.capturePass.length); + auth_chunk.writeUInt16BE(0x0000, 0); + auth_chunk.writeUInt16BE(0x000e, 2); + auth_chunk.write(rcinfo.capturePass, 6, rcinfo.capturePass.length); + auth_chunk.writeUInt16BE(auth_chunk.length, 4); } - else if(/string$/.test(extdef.type) || extdef.type === undefined) { - this_chunk = Buffer.allocUnsafe(6+data.length); - this_chunk.writeUInt16BE(i, 0); - this_chunk.writeUInt16BE(j, 2); - this_chunk.write(data, 6, data.length); - this_chunk.writeUInt16BE(this_chunk.length, 4); - failed = false; + else { + auth_chunk = Buffer.allocUnsafe(0); } - if(typeof this_chunk !== 'undefined' && !failed) { - extensions_chunk = Buffer.concat([extensions_chunk, this_chunk]); + + let payload_chunk = Buffer.allocUnsafe(6 + msg.length); + payload_chunk.writeUInt16BE(0x0000, 0); + payload_chunk.writeUInt16BE(0x000f, 2); + payload_chunk.write(msg, 6, msg.length); + payload_chunk.writeUInt16BE(payload_chunk.length, 4); + + let extensions_chunk = Buffer.allocUnsafe(0); + for (let i in extensions) { + for (let j in extensions[i]) { + let extdef = extensions[i][j]; + if (typeof extdef === "object" && + typeof extdef.keyName === "string" && + typeof rcinfo[extdef.keyName] !== 'undefined') { + let this_chunk; + let data = rcinfo[extdef.keyName]; + let failed = true; + if (/\d{1,}/.test(extdef.type)) { + const bitLength = extdef.type.match(/\d{1,}/)[0]; + const size = Math.floor(bitLength / 8) + 6; + this_chunk = Buffer.allocUnsafe(size); + this_chunk.writeUInt16BE(i, 0); + this_chunk.writeUInt16BE(j, 2); + if (typeof this_chunk["write" + extdef.type] === 'function') { + this_chunk['write' + extdef.type](data, 6); + failed = false; + } + else if (typeof this_chunk["write" + extdef.type + "BE"] === 'function') { + this_chunk['write' + extdef.type + "BE"](data, 6); + failed = false; + } + this_chunk.writeUInt16BE(this_chunk.length, 4); + } + else if (/string$/.test(extdef.type) || extdef.type === undefined) { + this_chunk = Buffer.allocUnsafe(6 + data.length); + this_chunk.writeUInt16BE(i, 0); + this_chunk.writeUInt16BE(j, 2); + this_chunk.write(data, 6, data.length); + this_chunk.writeUInt16BE(this_chunk.length, 4); + failed = false; + } + if (typeof this_chunk !== 'undefined' && !failed) { + extensions_chunk = Buffer.concat([extensions_chunk, this_chunk]); + } + } + } } - } - } - } - var hep_message, correlation_chunk; - - if ((rcinfo.proto_type == 32 || rcinfo.proto_type == 35 ) && rcinfo.correlation_id.length) { - - // create correlation chunk - correlation_chunk = Buffer.allocUnsafe(6 + rcinfo.correlation_id.length); - correlation_chunk.writeUInt16BE(0x0000, 0); - correlation_chunk.writeUInt16BE(0x0011, 2); - correlation_chunk.write(rcinfo.correlation_id,6, rcinfo.correlation_id.length); - correlation_chunk.writeUInt16BE(correlation_chunk.length,4); - - tmpA = ToUint16(rcinfo.mos); - var mos = Buffer.allocUnsafe(8); - mos.writeUInt16BE(0x0000, 0); - mos.writeUInt16BE(0x0020, 2); - mos.writeUInt16BE(tmpA,6); - mos.writeUInt16BE(mos.length,4); - - hep_message = Buffer.concat([ - header, - ip_family, - ip_proto, - src_ip4, - dst_ip4, - src_port, - dst_port, - time_sec, - time_usec, - proto_type, - capt_id, - hepnodename_chunk, - auth_chunk, - correlation_chunk, - mos, - payload_chunk, - extensions_chunk - ]); + let hep_message, correlation_chunk; + + if ((rcinfo.proto_type == 32 || rcinfo.proto_type == 35) && rcinfo.correlation_id.length) { + + // create correlation chunk + correlation_chunk = Buffer.allocUnsafe(6 + rcinfo.correlation_id.length); + correlation_chunk.writeUInt16BE(0x0000, 0); + correlation_chunk.writeUInt16BE(0x0011, 2); + correlation_chunk.write(rcinfo.correlation_id, 6, rcinfo.correlation_id.length); + correlation_chunk.writeUInt16BE(correlation_chunk.length, 4); + + tmpA = ToUint16(rcinfo.mos); + let mos = Buffer.allocUnsafe(8); + mos.writeUInt16BE(0x0000, 0); + mos.writeUInt16BE(0x0020, 2); + mos.writeUInt16BE(tmpA, 6); + mos.writeUInt16BE(mos.length, 4); + + hep_message = Buffer.concat([ + header, + ip_family, + ip_proto, + src_ip, + dst_ip, + src_port, + dst_port, + time_sec, + time_usec, + proto_type, + capt_id, + hepnodename_chunk, + auth_chunk, + correlation_chunk, + mos, + payload_chunk, + extensions_chunk + ]); - } - // HEP TYPE 101 w/ mandatory json_chunk (string) - else if (rcinfo.transaction_type && rcinfo.transaction_type.length && rcinfo.correlation_id.length) { - - // create correlation chunk - correlation_chunk = Buffer.allocUnsafe(6 + rcinfo.correlation_id.length); - correlation_chunk.writeUInt16BE(0x0000, 0); - correlation_chunk.writeUInt16BE(0x0011, 2); - correlation_chunk.write(rcinfo.correlation_id,6, rcinfo.correlation_id.length); - correlation_chunk.writeUInt16BE(correlation_chunk.length,4); - - // create transaction_type chunk - var transaction_type = Buffer.allocUnsafe(6 + rcinfo.transaction_type.length); - transaction_type.writeUInt16BE(0x0000, 0); - transaction_type.writeUInt16BE(0x0024, 2); - transaction_type.write(rcinfo.transaction_type,6, rcinfo.transaction_type.length); - transaction_type.writeUInt16BE(transaction_type.length,4); - - hep_message = Buffer.concat([ - header, - ip_family, - ip_proto, - src_ip4, - dst_ip4, - src_port, - dst_port, - time_sec, - time_usec, - proto_type, - capt_id, - hepnodename_chunk, - auth_chunk, - correlation_chunk, - transaction_type, - payload_chunk, - extensions_chunk - ]); + } + // HEP TYPE 101 w/ mandatory json_chunk (string) + else if (rcinfo.transaction_type && rcinfo.transaction_type.length && rcinfo.correlation_id.length) { + + // create correlation chunk + correlation_chunk = Buffer.allocUnsafe(6 + rcinfo.correlation_id.length); + correlation_chunk.writeUInt16BE(0x0000, 0); + correlation_chunk.writeUInt16BE(0x0011, 2); + correlation_chunk.write(rcinfo.correlation_id, 6, rcinfo.correlation_id.length); + correlation_chunk.writeUInt16BE(correlation_chunk.length, 4); + + // create transaction_type chunk + var transaction_type = Buffer.allocUnsafe(6 + rcinfo.transaction_type.length); + transaction_type.writeUInt16BE(0x0000, 0); + transaction_type.writeUInt16BE(0x0024, 2); + transaction_type.write(rcinfo.transaction_type, 6, rcinfo.transaction_type.length); + transaction_type.writeUInt16BE(transaction_type.length, 4); + + hep_message = Buffer.concat([ + header, + ip_family, + ip_proto, + src_ip, + dst_ip, + src_port, + dst_port, + time_sec, + time_usec, + proto_type, + capt_id, + hepnodename_chunk, + auth_chunk, + correlation_chunk, + transaction_type, + payload_chunk, + extensions_chunk + ]); - } - else if (rcinfo.correlation_id && rcinfo.correlation_id.length) { - - // create correlation chunk - correlation_chunk = Buffer.allocUnsafe(6 + rcinfo.correlation_id.length); - correlation_chunk.writeUInt16BE(0x0000, 0); - correlation_chunk.writeUInt16BE(0x0011, 2); - correlation_chunk.write(rcinfo.correlation_id,6, rcinfo.correlation_id.length); - correlation_chunk.writeUInt16BE(correlation_chunk.length,4); - - hep_message = Buffer.concat([ - header, - ip_family, - ip_proto, - src_ip4, - dst_ip4, - src_port, - dst_port, - time_sec, - time_usec, - proto_type, - capt_id, - hepnodename_chunk, - auth_chunk, - correlation_chunk, - payload_chunk, - extensions_chunk - ]); - } - else { - - hep_message = Buffer.concat([ - header, - ip_family, - ip_proto, - src_ip4, - dst_ip4, - src_port, - dst_port, - time_sec, - time_usec, - proto_type, - capt_id, - hepnodename_chunk, - auth_chunk, - payload_chunk, - extensions_chunk - ]); + } + else if (rcinfo.correlation_id && rcinfo.correlation_id.length) { + + // create correlation chunk + correlation_chunk = Buffer.allocUnsafe(6 + rcinfo.correlation_id.length); + correlation_chunk.writeUInt16BE(0x0000, 0); + correlation_chunk.writeUInt16BE(0x0011, 2); + correlation_chunk.write(rcinfo.correlation_id, 6, rcinfo.correlation_id.length); + correlation_chunk.writeUInt16BE(correlation_chunk.length, 4); + + hep_message = Buffer.concat([ + header, + ip_family, + ip_proto, + src_ip, + dst_ip, + src_port, + dst_port, + time_sec, + time_usec, + proto_type, + capt_id, + hepnodename_chunk, + auth_chunk, + correlation_chunk, + payload_chunk, + extensions_chunk + ]); + } + else { + hep_message = Buffer.concat([ + header, + ip_family, + ip_proto, + src_ip, + dst_ip, + src_port, + dst_port, + time_sec, + time_usec, + proto_type, + capt_id, + hepnodename_chunk, + auth_chunk, + payload_chunk, + extensions_chunk + ]); - } - hep_message.writeUInt16BE(hep_message.length, 4); - return hep_message; + } + hep_message.writeUInt16BE(hep_message.length, 4); + return hep_message; - }, + }, - encode: function(json) { - return String(json) - .toString("binary"); - }, + encode: function (json) { + return String(json) + .toString("binary"); + }, - decode: function(hep) { - return String(hep) - .toString('utf8'); - }, + decode: function (hep) { + return String(hep) + .toString('utf8'); + }, - addVendorExtensions: function(json) { - extensions = mixinDeep(extensions, json); - } + addVendorExtensions: function (json) { + extensions = mixinDeep(extensions, json); + } }; /* Functions */ -var modulo = function (a, b) { - return a - Math.floor(a/b)*b; +const modulo = function (a, b) { + return a - Math.floor(a / b) * b; }; -var ToUint32 = function (x) { - return modulo(ToInteger(x), Math.pow(2, 32)); +const ToUint32 = function (x) { + return modulo(ToInteger(x), Math.pow(2, 32)); }; -var ToUint16 = function (x) { - return modulo(ToInteger(x), Math.pow(2, 16)); +const ToUint16 = function (x) { + return modulo(ToInteger(x), Math.pow(2, 16)); }; -var ToInteger =function (x) { - x = Number(x); - return x < 0 ? Math.ceil(x) : Math.floor(x); -}; - -var ntohl = function (val) { - return ((val & 0xFF) << 24) - | ((val & 0xFF00) << 8) - | ((val >> 8) & 0xFF00) - | ((val >> 24) & 0xFF); -}; - -var inet_pton = function inet_pton(a) { - - var r, m, x, i, j, f = String.fromCharCode; - // IPv4 - m = a.match(/^(?:\d{1,3}(?:\.|$)){4}/); - if (m) { - m = m[0].split('.'); - m = f(m[0]) + f(m[1]) + f(m[2]) + f(m[3]); - // Return if 4 bytes, otherwise false. - return m.length === 4 ? m : false; - } - r = /^((?:[\da-f]{1,4}(?::|)){0,8})(::)?((?:[\da-f]{1,4}(?::|)){0,8})$/; - // IPv6 - m = a.match(r); - if (m) { - // Translate each hexadecimal value. - for (j = 1; j < 4; j++) { - // Indice 2 is :: and if no length, continue. - if (j === 2 || m[j].length === 0) { - continue; - } - m[j] = m[j].split(':'); - for (i = 0; i < m[j].length; i++) { - m[j][i] = parseInt(m[j][i], 16); - // Would be NaN if it was blank, return false. - if (isNaN(m[j][i])) { - // Invalid IP. - return false; - } - m[j][i] = f(m[j][i] >> 8) + f(m[j][i] & 0xFF); - } - m[j] = m[j].join(''); - } - x = m[1].length + m[3].length; - if (x === 16) { - return m[1] + m[3]; - } else if (x < 16 && m[2].length > 0) { - return m[1] + (new Array(16 - x + 1)) - .join('\x00') + m[3]; - } - } - // Invalid IP. - return false; +const ToInteger = function (x) { + x = Number(x); + return x < 0 ? Math.ceil(x) : Math.floor(x); }; // Build an IP packet header Parser -var hepHeader = new Parser() - .endianess("big") - .string("hep", { length: 4, stripNull: true, assert: "HEP3" }) - .uint16("hepLength") - .buffer("payload", { length: function () {return this.hepLength - 6; } }); // Length of HepMessage is defined including the 6 Byte Header - -var hepParse = new Parser() - .endianess("big") - .uint16("vendor") - .uint16("type") - .uint16("length") - .buffer("chunk", { length: function () {return this.length-6;} }); // Length of Chunk is defined including the 6 Byte header - -var hepIps = new Parser() - .endianess("big") - .array("ip",{ - type: "uint8", - length: 4 - }); - -var hepDecode = function(data){ - switch(data.type) { - case 1: - return { rcinfo: { protocolFamily: data.chunk.readUInt8() } }; - case 2: - return { rcinfo: { protocol: data.chunk.readUInt8() } }; - case 3: - return { rcinfo: { srcIp: hepIps.parse(data.chunk).ip.join('.') } }; - case 4: - return { rcinfo: { dstIp: hepIps.parse(data.chunk).ip.join('.') } }; - case 7: - return { rcinfo: { srcPort: data.chunk.readUInt16BE() } }; - case 8: - return { rcinfo: { dstPort: data.chunk.readUInt16BE() } }; - case 9: - return { rcinfo: { timeSeconds: data.chunk.readUInt32BE() } }; - case 10: - return { rcinfo: { timeUseconds: data.chunk.readUInt32BE() } }; - case 11: - return { rcinfo: { payloadType: data.chunk.readUInt8() } }; - case 12: - return { rcinfo: { captureId: data.chunk.readUInt32BE() } }; - case 14: - return { rcinfo: { capturePass: data.chunk.toString() } }; - case 15: - return { payload: data.chunk.toString() }; - case 17: - return { rcinfo: { correlation_id: data.chunk.toString() } }; - case 19: - return { rcinfo: { hepNodeName: data.chunk.toString() } }; - case 32: - return { rcinfo: { mos: data.chunk.readUInt16BE() } }; - case 36: - return { rcinfo: { transaction_type: data.chunk.readUInt16BE() } }; - default: - var returnData = {}; - if(typeof extensions[data.vendor] === 'object' && - typeof extensions[data.vendor][data.type] === 'object' && - typeof extensions[data.vendor][data.type].keyName) { - returnData.rcinfo = {}; - var keyName = extensions[data.vendor][data.type].keyName; - var type = extensions[data.vendor][data.type].type; - if(typeof type === 'string') { - if(typeof data.chunk['read'+type] === 'function') { - returnData.rcinfo[keyName] = data.chunk['read'+type](); - } - else if(typeof data.chunk['read'+type+"BE"] === 'function') { - returnData.rcinfo[keyName] = data.chunk['read'+type+"BE"](); - } - } - else { - returnData.rcinfo[keyName] = data.chunk.toString(); - } +const hepHeader = new Parser() + .endianess("big") + .string("hep", { length: 4, stripNull: true, assert: "HEP3" }) + .uint16("hepLength") + .buffer("payload", { length: function () { return this.hepLength - 6; } }); // Length of HepMessage is defined including the 6 Byte Header + +const hepParse = new Parser() + .endianess("big") + .uint16("vendor") + .uint16("type") + .uint16("length") + .buffer("chunk", { length: function () { return this.length - 6; } }); // Length of Chunk is defined including the 6 Byte header + +const hepDecode = function (data) { + switch (data.type) { + case 1: + return { rcinfo: { protocolFamily: data.chunk.readUInt8() } }; + case 2: + return { rcinfo: { protocol: data.chunk.readUInt8() } }; + case 3: + return { rcinfo: { srcIp: ip.toString(data.chunk) } }; + case 4: + return { rcinfo: { dstIp: ip.toString(data.chunk) } }; + case 5: + return { rcinfo: { srcIp: ip.toString(data.chunk) } }; + case 6: + return { rcinfo: { dstIp: ip.toString(data.chunk) } }; + case 7: + return { rcinfo: { srcPort: data.chunk.readUInt16BE() } }; + case 8: + return { rcinfo: { dstPort: data.chunk.readUInt16BE() } }; + case 9: + return { rcinfo: { timeSeconds: data.chunk.readUInt32BE() } }; + case 10: + return { rcinfo: { timeUseconds: data.chunk.readUInt32BE() } }; + case 11: + return { rcinfo: { payloadType: data.chunk.readUInt8() } }; + case 12: + return { rcinfo: { captureId: data.chunk.readUInt32BE() } }; + case 14: + return { rcinfo: { capturePass: data.chunk.toString() } }; + case 15: + return { payload: data.chunk.toString() }; + case 17: + return { rcinfo: { correlation_id: data.chunk.toString() } }; + case 19: + return { rcinfo: { hepNodeName: data.chunk.toString() } }; + case 32: + return { rcinfo: { mos: data.chunk.readUInt16BE() } }; + case 36: + return { rcinfo: { transaction_type: data.chunk.readUInt16BE() } }; + default: + var returnData = {}; + if (typeof extensions[data.vendor] === 'object' && + typeof extensions[data.vendor][data.type] === 'object' && + typeof extensions[data.vendor][data.type].keyName) { + returnData.rcinfo = {}; + const keyName = extensions[data.vendor][data.type].keyName; + const type = extensions[data.vendor][data.type].type; + if (typeof type === 'string') { + if (typeof data.chunk['read' + type] === 'function') { + returnData.rcinfo[keyName] = data.chunk['read' + type](); + } + else if (typeof data.chunk['read' + type + "BE"] === 'function') { + returnData.rcinfo[keyName] = data.chunk['read' + type + "BE"](); + } + } + else { + returnData.rcinfo[keyName] = data.chunk.toString(); + } + } + return returnData; } - return returnData; - } -}; - -function deepMerge(o1,o2) { - for (var k in o2) { - if (typeof(o2[k])=='object') { - if(!o1[k]) o1[k] = {}; - //console.log(merge(o1[k],o2[k]) ); - o1[k] = deepMerge(o1[k],o2[k]); - } else { - o1[k] = o2[k]; - } - } - return o1; -} - - -/* - Appendix A: HEP3 JSON Format (prototype) -*/ - -/* -var hepPacket = { - "type": "HEP", - "version": 3, - "rcinfo": { - "protocolFamily": 2, - "protocol": 17, - "srcIp": "192.168.3.12", - "srcPort": 5060, - "dstIp": "192.168.3.11", - "dstPort": 5060, - "timestamp": "2015-06-11T12:36:08:222Z", - "timestampUSecs": 0, - "captureId": 241, - "hepNodeName": "ams01-voip", - "capturePass": "myHep", - "payload_type": "SIP" - }, - "payload": { - "data": "INVITE sip:9999@homer SIP/2.0\r\n..." - } - }; - -*/ +}; \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 9cf6fbe..06902cb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,8 +1,1029 @@ { "name": "hep-js", "version": "1.0.20", - "lockfileVersion": 1, + "lockfileVersion": 2, "requires": true, + "packages": { + "": { + "name": "hep-js", + "version": "1.0.20", + "license": "GPLv2", + "dependencies": { + "binary-parser": "^2.2.1", + "ip": "^1.1.8", + "mixin-deep": "^2.0.1" + }, + "devDependencies": { + "chai": "^4.3.8", + "mocha": "^10.2.0" + } + }, + "node_modules/ansi-colors": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz", + "integrity": "sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/anymatch": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", + "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", + "dev": true, + "dependencies": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", + "dev": true + }, + "node_modules/assertion-error": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", + "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", + "dev": true, + "engines": { + "node": "*" + } + }, + "node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true + }, + "node_modules/binary-extensions": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", + "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/binary-parser": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/binary-parser/-/binary-parser-2.2.1.tgz", + "integrity": "sha512-5ATpz/uPDgq5GgEDxTB4ouXCde7q2lqAQlSdBRQVl/AJnxmQmhIfyxJx+0MGu//D5rHQifkfGbWWlaysG0o9NA==", + "engines": { + "node": ">=12" + } + }, + "node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/braces": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", + "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "dev": true, + "dependencies": { + "fill-range": "^7.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/browser-stdout": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", + "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", + "dev": true + }, + "node_modules/camelcase": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.3.0.tgz", + "integrity": "sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/chai": { + "version": "4.3.8", + "resolved": "https://registry.npmjs.org/chai/-/chai-4.3.8.tgz", + "integrity": "sha512-vX4YvVVtxlfSZ2VecZgFUTU5qPCYsobVI2O9FmwEXBhDigYGQA6jRXCycIs1yJnnWbZ6/+a2zNIF5DfVCcJBFQ==", + "dev": true, + "dependencies": { + "assertion-error": "^1.1.0", + "check-error": "^1.0.2", + "deep-eql": "^4.1.2", + "get-func-name": "^2.0.0", + "loupe": "^2.3.1", + "pathval": "^1.1.1", + "type-detect": "^4.0.5" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/chalk/node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/check-error": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", + "integrity": "sha512-BrgHpW9NURQgzoNyjfq0Wu6VFO6D7IZEmJNdtgNqpzGG8RuNFHt2jQxWlAs4HMe119chBnv+34syEZtc6IhLtA==", + "dev": true, + "engines": { + "node": "*" + } + }, + "node_modules/chokidar": { + "version": "3.5.3", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz", + "integrity": "sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://paulmillr.com/funding/" + } + ], + "dependencies": { + "anymatch": "~3.1.2", + "braces": "~3.0.2", + "glob-parent": "~5.1.2", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.6.0" + }, + "engines": { + "node": ">= 8.10.0" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + } + }, + "node_modules/cliui": { + "version": "7.0.4", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", + "integrity": "sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==", + "dev": true, + "dependencies": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.0", + "wrap-ansi": "^7.0.0" + } + }, + "node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "node_modules/concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", + "dev": true + }, + "node_modules/debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dev": true, + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/debug/node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, + "node_modules/decamelize": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-4.0.0.tgz", + "integrity": "sha512-9iE1PgSik9HeIIw2JO94IidnE3eBoQrFJ3w7sFuzSX4DpmZ3v5sZpUiV5Swcf6mQEF+Y0ru8Neo+p+nyh2J+hQ==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/deep-eql": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-4.1.3.tgz", + "integrity": "sha512-WaEtAOpRA1MQ0eohqZjpGD8zdI0Ovsm8mmFhaDN8dvDZzyoUMcYDnf5Y6iu7HTXxf8JDS23qWa4a+hKCDyOPzw==", + "dev": true, + "dependencies": { + "type-detect": "^4.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/diff": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-5.0.0.tgz", + "integrity": "sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w==", + "dev": true, + "engines": { + "node": ">=0.3.1" + } + }, + "node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true + }, + "node_modules/escalade": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", + "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/fill-range": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", + "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "dev": true, + "dependencies": { + "to-regex-range": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/find-up": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", + "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", + "dev": true, + "dependencies": { + "locate-path": "^6.0.0", + "path-exists": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/flat": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/flat/-/flat-5.0.2.tgz", + "integrity": "sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ==", + "dev": true, + "bin": { + "flat": "cli.js" + } + }, + "node_modules/fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", + "dev": true + }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/get-caller-file": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", + "dev": true, + "engines": { + "node": "6.* || 8.* || >= 10.*" + } + }, + "node_modules/get-func-name": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz", + "integrity": "sha512-Hm0ixYtaSZ/V7C8FJrtZIuBBI+iSgL+1Aq82zSu8VQNB4S3Gk8e7Qs3VwBDJAhmRZcFqkl3tQu36g/Foh5I5ig==", + "dev": true, + "engines": { + "node": "*" + } + }, + "node_modules/glob": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz", + "integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==", + "dev": true, + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dev": true, + "dependencies": { + "is-glob": "^4.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/glob/node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/glob/node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/he": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", + "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", + "dev": true, + "bin": { + "he": "bin/he" + } + }, + "node_modules/inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", + "dev": true, + "dependencies": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true + }, + "node_modules/ip": { + "version": "1.1.8", + "resolved": "https://registry.npmjs.org/ip/-/ip-1.1.8.tgz", + "integrity": "sha512-PuExPYUiu6qMBQb4l06ecm6T6ujzhmh+MeJcW9wa89PoAz5pvd4zPgN5WJV104mb6S2T1AwNIAaB70JNrLQWhg==" + }, + "node_modules/is-binary-path": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", + "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "dev": true, + "dependencies": { + "binary-extensions": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "dev": true, + "dependencies": { + "is-extglob": "^2.1.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "dev": true, + "engines": { + "node": ">=0.12.0" + } + }, + "node_modules/is-plain-obj": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-2.1.0.tgz", + "integrity": "sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/is-unicode-supported": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz", + "integrity": "sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/js-yaml": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", + "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", + "dev": true, + "dependencies": { + "argparse": "^2.0.1" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, + "node_modules/locate-path": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", + "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", + "dev": true, + "dependencies": { + "p-locate": "^5.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/log-symbols": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz", + "integrity": "sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==", + "dev": true, + "dependencies": { + "chalk": "^4.1.0", + "is-unicode-supported": "^0.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/loupe": { + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/loupe/-/loupe-2.3.6.tgz", + "integrity": "sha512-RaPMZKiMy8/JruncMU5Bt6na1eftNoo++R4Y+N2FrxkDVTrGvcyzFTsaGif4QTeKESheMGegbhw6iUAq+5A8zA==", + "dev": true, + "dependencies": { + "get-func-name": "^2.0.0" + } + }, + "node_modules/minimatch": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.0.1.tgz", + "integrity": "sha512-nLDxIFRyhDblz3qMuq+SoRZED4+miJ/G+tdDrjkkkRnjAsBexeGpgjLEQ0blJy7rHhR2b93rhQY4SvyWu9v03g==", + "dev": true, + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/mixin-deep": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-2.0.1.tgz", + "integrity": "sha512-imbHQNRglyaplMmjBLL3V5R6Bfq5oM+ivds3SKgc6oRtzErEnBUUc5No11Z2pilkUvl42gJvi285xTNswcKCMA==", + "engines": { + "node": ">=6" + } + }, + "node_modules/mocha": { + "version": "10.2.0", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.2.0.tgz", + "integrity": "sha512-IDY7fl/BecMwFHzoqF2sg/SHHANeBoMMXFlS9r0OXKDssYE1M5O43wUY/9BVPeIvfH2zmEbBfseqN9gBQZzXkg==", + "dev": true, + "dependencies": { + "ansi-colors": "4.1.1", + "browser-stdout": "1.3.1", + "chokidar": "3.5.3", + "debug": "4.3.4", + "diff": "5.0.0", + "escape-string-regexp": "4.0.0", + "find-up": "5.0.0", + "glob": "7.2.0", + "he": "1.2.0", + "js-yaml": "4.1.0", + "log-symbols": "4.1.0", + "minimatch": "5.0.1", + "ms": "2.1.3", + "nanoid": "3.3.3", + "serialize-javascript": "6.0.0", + "strip-json-comments": "3.1.1", + "supports-color": "8.1.1", + "workerpool": "6.2.1", + "yargs": "16.2.0", + "yargs-parser": "20.2.4", + "yargs-unparser": "2.0.0" + }, + "bin": { + "_mocha": "bin/_mocha", + "mocha": "bin/mocha.js" + }, + "engines": { + "node": ">= 14.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/mochajs" + } + }, + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "dev": true + }, + "node_modules/nanoid": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.3.tgz", + "integrity": "sha512-p1sjXuopFs0xg+fPASzQ28agW1oHD7xDsd9Xkf3T15H3c/cifrFHVwrh74PdoklAPi+i7MdRsE47vm2r6JoB+w==", + "dev": true, + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, + "node_modules/normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "dev": true, + "dependencies": { + "wrappy": "1" + } + }, + "node_modules/p-limit": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", + "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", + "dev": true, + "dependencies": { + "yocto-queue": "^0.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/p-locate": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", + "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", + "dev": true, + "dependencies": { + "p-limit": "^3.0.2" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/pathval": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.1.tgz", + "integrity": "sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==", + "dev": true, + "engines": { + "node": "*" + } + }, + "node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true, + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/randombytes": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", + "integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==", + "dev": true, + "dependencies": { + "safe-buffer": "^5.1.0" + } + }, + "node_modules/readdirp": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", + "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "dev": true, + "dependencies": { + "picomatch": "^2.2.1" + }, + "engines": { + "node": ">=8.10.0" + } + }, + "node_modules/require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/serialize-javascript": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.0.tgz", + "integrity": "sha512-Qr3TosvguFt8ePWqsvRfrKyQXIiW+nGbYpy8XK24NQHE83caxWt+mIymTT19DGFbNWNLfEwsrkSmN64lVWB9ag==", + "dev": true, + "dependencies": { + "randombytes": "^2.1.0" + } + }, + "node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-json-comments": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", + "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", + "dev": true, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/supports-color": { + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", + "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", + "dev": true, + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/supports-color?sponsor=1" + } + }, + "node_modules/to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dev": true, + "dependencies": { + "is-number": "^7.0.0" + }, + "engines": { + "node": ">=8.0" + } + }, + "node_modules/type-detect": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", + "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/workerpool": { + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.2.1.tgz", + "integrity": "sha512-ILEIE97kDZvF9Wb9f6h5aXK4swSlKGUcOEGiIYb2OOu/IrDU9iwj0fD//SsA6E5ibwJxpEvhullJY4Sl4GcpAw==", + "dev": true + }, + "node_modules/wrap-ansi": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "dev": true, + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", + "dev": true + }, + "node_modules/y18n": { + "version": "5.0.8", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", + "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", + "dev": true, + "engines": { + "node": ">=10" + } + }, + "node_modules/yargs": { + "version": "16.2.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", + "integrity": "sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==", + "dev": true, + "dependencies": { + "cliui": "^7.0.2", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "require-directory": "^2.1.1", + "string-width": "^4.2.0", + "y18n": "^5.0.5", + "yargs-parser": "^20.2.2" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/yargs-parser": { + "version": "20.2.4", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.4.tgz", + "integrity": "sha512-WOkpgNhPTlE73h4VFAFsOnomJVaovO8VqLDzy5saChRBFQFBoMYirowyW+Q9HB4HFF4Z7VZTiG3iSzJJA29yRA==", + "dev": true, + "engines": { + "node": ">=10" + } + }, + "node_modules/yargs-unparser": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/yargs-unparser/-/yargs-unparser-2.0.0.tgz", + "integrity": "sha512-7pRTIA9Qc1caZ0bZ6RYRGbHJthJWuakf+WmHK0rVeLkNrrGhfoabBNdue6kdINI6r4if7ocq9aD/n7xwKOdzOA==", + "dev": true, + "dependencies": { + "camelcase": "^6.0.0", + "decamelize": "^4.0.0", + "flat": "^5.0.2", + "is-plain-obj": "^2.1.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/yocto-queue": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", + "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + } + }, "dependencies": { "ansi-colors": { "version": "4.1.1", @@ -26,9 +1047,9 @@ } }, "anymatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.2.tgz", - "integrity": "sha512-P43ePfOAIupkguHUycrc4qJ9kz8ZiuOUijaETwX7THt0Y/GNK7v0aa8rY816xWjZ7rJdA5XdMcpVFTKMq+RvWg==", + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", + "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", "dev": true, "requires": { "normalize-path": "^3.0.0", @@ -60,18 +1081,17 @@ "dev": true }, "binary-parser": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/binary-parser/-/binary-parser-1.3.2.tgz", - "integrity": "sha512-VDhHcpeF1/ZZy1XvDmYD67bBjRNm1gacw+772xNd5BnTH6ax5TzlDV5dl7216/UlQXQoN9vug07ehk7e0PhNUw==" + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/binary-parser/-/binary-parser-2.2.1.tgz", + "integrity": "sha512-5ATpz/uPDgq5GgEDxTB4ouXCde7q2lqAQlSdBRQVl/AJnxmQmhIfyxJx+0MGu//D5rHQifkfGbWWlaysG0o9NA==" }, "brace-expansion": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", "dev": true, "requires": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" + "balanced-match": "^1.0.0" } }, "braces": { @@ -96,14 +1116,18 @@ "dev": true }, "chai": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/chai/-/chai-3.0.0.tgz", - "integrity": "sha1-cb/RA0/IwtjFBTh1uzj1mypvGSg=", + "version": "4.3.8", + "resolved": "https://registry.npmjs.org/chai/-/chai-4.3.8.tgz", + "integrity": "sha512-vX4YvVVtxlfSZ2VecZgFUTU5qPCYsobVI2O9FmwEXBhDigYGQA6jRXCycIs1yJnnWbZ6/+a2zNIF5DfVCcJBFQ==", "dev": true, "requires": { - "assertion-error": "^1.0.1", - "deep-eql": "^0.1.3", - "type-detect": "^1.0.0" + "assertion-error": "^1.1.0", + "check-error": "^1.0.2", + "deep-eql": "^4.1.2", + "get-func-name": "^2.0.0", + "loupe": "^2.3.1", + "pathval": "^1.1.1", + "type-detect": "^4.0.5" } }, "chalk": { @@ -127,6 +1151,12 @@ } } }, + "check-error": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", + "integrity": "sha512-BrgHpW9NURQgzoNyjfq0Wu6VFO6D7IZEmJNdtgNqpzGG8RuNFHt2jQxWlAs4HMe119chBnv+34syEZtc6IhLtA==", + "dev": true + }, "chokidar": { "version": "3.5.3", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz", @@ -199,20 +1229,12 @@ "dev": true }, "deep-eql": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-0.1.3.tgz", - "integrity": "sha1-71WKyrjeJSBs1xOQbXTlaTDrafI=", + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-4.1.3.tgz", + "integrity": "sha512-WaEtAOpRA1MQ0eohqZjpGD8zdI0Ovsm8mmFhaDN8dvDZzyoUMcYDnf5Y6iu7HTXxf8JDS23qWa4a+hKCDyOPzw==", "dev": true, "requires": { - "type-detect": "0.1.1" - }, - "dependencies": { - "type-detect": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-0.1.1.tgz", - "integrity": "sha1-C6XsKohWQORw6k6FBZcZANrFiCI=", - "dev": true - } + "type-detect": "^4.0.0" } }, "diff": { @@ -271,9 +1293,9 @@ "dev": true }, "fsevents": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", - "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", "dev": true, "optional": true }, @@ -283,6 +1305,12 @@ "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", "dev": true }, + "get-func-name": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz", + "integrity": "sha512-Hm0ixYtaSZ/V7C8FJrtZIuBBI+iSgL+1Aq82zSu8VQNB4S3Gk8e7Qs3VwBDJAhmRZcFqkl3tQu36g/Foh5I5ig==", + "dev": true + }, "glob": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz", @@ -297,6 +1325,16 @@ "path-is-absolute": "^1.0.0" }, "dependencies": { + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, "minimatch": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", @@ -345,6 +1383,11 @@ "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", "dev": true }, + "ip": { + "version": "1.1.8", + "resolved": "https://registry.npmjs.org/ip/-/ip-1.1.8.tgz", + "integrity": "sha512-PuExPYUiu6qMBQb4l06ecm6T6ujzhmh+MeJcW9wa89PoAz5pvd4zPgN5WJV104mb6S2T1AwNIAaB70JNrLQWhg==" + }, "is-binary-path": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", @@ -421,6 +1464,15 @@ "is-unicode-supported": "^0.1.0" } }, + "loupe": { + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/loupe/-/loupe-2.3.6.tgz", + "integrity": "sha512-RaPMZKiMy8/JruncMU5Bt6na1eftNoo++R4Y+N2FrxkDVTrGvcyzFTsaGif4QTeKESheMGegbhw6iUAq+5A8zA==", + "dev": true, + "requires": { + "get-func-name": "^2.0.0" + } + }, "minimatch": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.0.1.tgz", @@ -428,17 +1480,6 @@ "dev": true, "requires": { "brace-expansion": "^2.0.1" - }, - "dependencies": { - "brace-expansion": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", - "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", - "dev": true, - "requires": { - "balanced-match": "^1.0.0" - } - } } }, "mixin-deep": { @@ -447,9 +1488,9 @@ "integrity": "sha512-imbHQNRglyaplMmjBLL3V5R6Bfq5oM+ivds3SKgc6oRtzErEnBUUc5No11Z2pilkUvl42gJvi285xTNswcKCMA==" }, "mocha": { - "version": "10.1.0", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.1.0.tgz", - "integrity": "sha512-vUF7IYxEoN7XhQpFLxQAEMtE4W91acW4B6En9l97MwE9stL1A9gusXfoHZCLVHDUJ/7V5+lbCM6yMqzo5vNymg==", + "version": "10.2.0", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.2.0.tgz", + "integrity": "sha512-IDY7fl/BecMwFHzoqF2sg/SHHANeBoMMXFlS9r0OXKDssYE1M5O43wUY/9BVPeIvfH2zmEbBfseqN9gBQZzXkg==", "dev": true, "requires": { "ansi-colors": "4.1.1", @@ -532,6 +1573,12 @@ "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", "dev": true }, + "pathval": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.1.tgz", + "integrity": "sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==", + "dev": true + }, "picomatch": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", @@ -622,9 +1669,9 @@ } }, "type-detect": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-1.0.0.tgz", - "integrity": "sha1-diIXzAbbJY7EiQihKY6LlRIejqI=", + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", + "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", "dev": true }, "workerpool": { diff --git a/package.json b/package.json index 65b4bbc..bc8df7f 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "HEP3 Library for Node.JS", "main": "index.js", "scripts": { - "test": "make test" + "test": "mocha --reporter spec" }, "repository": { "type": "git", @@ -31,12 +31,13 @@ "bugs": { "url": "https://github.com/sipcapture/hep-js/issues" }, - "devDependencies": { - "mocha": "~10.1.0", - "chai": "~3.0.0" - }, "dependencies": { - "binary-parser": "^1.3.2", - "mixin-deep": "^2.0.0" + "binary-parser": "^2.2.1", + "ip": "^1.1.8", + "mixin-deep": "^2.0.1" + }, + "devDependencies": { + "chai": "^4.3.8", + "mocha": "^10.2.0" } } diff --git a/test/index.js b/test/index.js index 9c86d91..2bd3804 100755 --- a/test/index.js +++ b/test/index.js @@ -1,18 +1,42 @@ -var should = require('chai').should(), - hepnode = require('../index'), - encode = hepnode.encode, - decode = hepnode.decode; +var should = require("chai").should(), + hepnode = require("../index"), + encode = hepnode.encode, + decode = hepnode.decode, + encapsulate = hepnode.encapsulate, + decapsulate = hepnode.decapsulate; -describe('#escape', function() { - it('HEP Encoder', function() { - encode('HEP3').should.equal('HEP3').toString("binary"); +describe("#escape", function () { + it("HEP Encoder", function () { + encode("HEP3").should.equal("HEP3").toString("binary"); }); - }); -describe('#unescape', function() { - it('HEP Decoder', function() { - decode(('HEP3').toString("binary")).should.equal('HEP3'); +describe("#unescape", function () { + it("HEP Decoder", function () { + decode("HEP3".toString("binary")).should.equal("HEP3"); }); +}); + +describe("ipv6", function () { + const rcinfo = { + protocolFamily: 10, + protocol: 6, + srcIp: "2001:566:f831:79:0:36:3dd6:3201", + dstIp: "2001:555:f831:720::1234", + srcPort: 12298, + dstPort: 6100, + timeSeconds: 1433719443, + timeUseconds: 979, + payloadType: 1, + captureId: 2001, + hepNodeName: "abc" + }; + const payload = + 'INVITE sip:9999999996;phone-context=ims.mnc123.mnc100.3gppnetwork.org@ims.mnc123.mnc100.3gppnetwork.org;user=phone SIP/2.0\r\nVia: SIP/2.0/TCP [2001:566:f831:23:0:32:f692:9d01]:6100;branch=z9hG4bK-524287-1---9322df8bee339153;rport;transport=TCP\r\nMax-Forwards: 70\r\nRoute: \r\nProxy-Require: sec-agree\r\nRequire: sec-agree\r\nContact: ;+sip.instance="";+g.3gpp.icsi-ref="urn%3Aurn-7%3A3gpp-service.ims.icsi.mmtel";+g.3gpp.mid-call;+g.3gpp.srvcc-alerting;+g.3gpp.ps2cs-srvcc-orig-pre-alerting\r\nTo: \r\nFrom: ;tag=6e42722f\r\nCall-ID: UYbWSyst2FrgtQ8hAkq2Ig..@2001:555:f831:23:0:32:f692:9d01\r\nCSeq: 1 INVITE\r\nSession-Expires: 1800\r\nAccept: application/sdp, application/3gpp-ims+xml\r\nAllow: INVITE, ACK, OPTIONS, CANCEL, BYE, UPDATE, INFO, REFER, NOTIFY, MESSAGE, PRACK\r\nContent-Type: application/sdp\r\nSupported: timer, 100rel, precondition, gruu, sec-agree\r\nUser-Agent: SM-G975W-G975WVLS5GUD1 Samsung IMS 6.0\r\nSecurity-Verify: ipsec-3gpp;prot=esp;mod=trans;spi-c=12656;spi-s=12657;port-c=12656;port-s=12657;alg=hmac-sha-1-96;ealg=null\r\nP-Preferred-Identity: \r\nAccept-Contact: *;+g.3gpp.icsi-ref="urn%3Aurn-7%3A3gpp-service.ims.icsi.mmtel"\r\nP-Early-Media: supported\r\nP-Preferred-Service: urn:urn-7:3gpp-service.ims.icsi.mmtel\r\nP-Access-Network-Info: 3GPP-E-UTRAN-FDD;utran-cell-id-3gpp=3022202b001afad00\r\nContent-Length: 920\r\n\r\nv=0\r\no=SAMSUNG-IMS-UE 448775668462 448775668462 IN IP6 2001:555:f831:23:0:32:f692:9d01\r\ns=SS VOIP\r\nc=IN IP6 2001:566:f831:23:0:32:f692:9d01\r\nt=0 0\r\nm=audio 1284 RTP/AVP 127 116 107 118 96 111 110\r\nb=AS:50\r\nb=RS:0\r\nb=RR:2500\r\na=rtpmap:127 EVS/16000\r\na=fmtp:127 br=5.9-24.4;bw=nb-swb;ch-aw-recv=2\r\na=rtpmap:116 AMR-WB/16000/1\r\na=fmtp:116 mode-set=0,1,2;mode-change-capability=2;max-red=220\r\na=rtpmap:107 AMR-WB/16000/1\r\na=fmtp:107 mode-set=0,1,2;octet-align=1;mode-change-capability=2;max-red=220\r\na=rtpmap:118 AMR/8000/1\r\na=fmtp:118 mode-change-capability=2;max-red=220\r\na=rtpmap:96 AMR/8000/1\r\na=fmtp:96 octet-align=1;mode-change-capability=2;max-red=220\r\na=rtpmap:111 telephone-event/16000\r\na=fmtp:111 0-15\r\na=rtpmap:110 telephone-event/8000\r\na=fmtp:110 0-15\r\na=curr:qos local none\r\na=curr:qos remote none\r\na=des:qos mandatory local sendrecv\r\na=des:qos optional remote sendrecv\r\na=sendrecv\r\na=ptime:20\r\na=maxptime:240\r\n\r\n\r\n'; + + it("HEP encapsulate/decapsulate", function () { + const hepCapsulated = encapsulate(payload, rcinfo); + decapsulate(hepCapsulated).should.eql({rcinfo: rcinfo, payload: payload}); + }); });