From cf6613c837cc49fc99051f3b2e5b5763524f92cb Mon Sep 17 00:00:00 2001 From: pupilTong Date: Sun, 23 Jan 2022 08:47:58 -0800 Subject: [PATCH 01/13] add mocha to github actions --- .github/workflows/node.js.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index f705267..853ebfb 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -27,6 +27,7 @@ jobs: node-version: ${{ matrix.node-version }} cache: 'npm' - run: npm install -g nyc + - run: npm install -g mocha - run: npm ci - run: npm run build --if-present - run: npm test From 1f24acfc3096df0f6fa307423a770e7816fceeb5 Mon Sep 17 00:00:00 2001 From: pupilTong Date: Sat, 29 Jan 2022 18:24:04 -0800 Subject: [PATCH 02/13] send by tun and recv by dgram still not work --- src/js/tuntap.js | 33 ++-- src/js/tuntap.js.map | 2 +- src/js/tuntap.ts | 43 +++-- tests/tun.js | 407 +++++++++++++++++++++++++------------------ 4 files changed, 274 insertions(+), 211 deletions(-) diff --git a/src/js/tuntap.js b/src/js/tuntap.js index a408d49..09ebc82 100644 --- a/src/js/tuntap.js +++ b/src/js/tuntap.js @@ -18,32 +18,39 @@ class tuntap { this._deviceMode = mode; this._fd = fs.openSync(`/dev/net/tun`, "r+"); this._ifName = tuntap2Addon_1.default.tuntapInit(this._fd, mode == "tap"); - this._writingStream = fs.createWriteStream('', { - fd: this._fd, - autoClose: false, - emitClose: false - }); this._readingStream = fs.createReadStream('', { fd: this._fd, autoClose: false, - emitClose: false + emitClose: true }); this._readingStream.setEncoding('binary'); } writePacket(packet, callback) { return __awaiter(this, void 0, void 0, function* () { - this._writingStream.write(packet, callback); + fs.writeSync(this._fd, packet); + callback(); }); } + makeSureIsUp() { + if (!this.isUp) { + throw `you must set isUp = true in order to access this method`; + } + } + ; + get onReceive() { + return this._onReceive; + } + set onReceive(newVal) { + this._onReceive = newVal; + this._readingStream.removeAllListeners('data'); + this._readingStream.on('data', this.onReceive); + } get name() { return this._ifName; } get isTap() { return this._deviceMode == "tap"; } - get writeStream() { - return this._writingStream; - } get readStream() { return this._readingStream; } @@ -103,12 +110,6 @@ class tuntap { const ifIndex = tuntap2Addon_1.default.tuntapGetIfIndex(this._ifName); tuntap2Addon_1.default.tuntapSetIpv6(ifIndex, addr, prefix); } - makeSureIsUp() { - if (!this.isUp) { - throw `you must set isUp = true in order to access this method`; - } - } - ; release() { return __awaiter(this, void 0, void 0, function* () { this._readingStream.destroy(); diff --git a/src/js/tuntap.js.map b/src/js/tuntap.js.map index be43e24..2ee831d 100644 --- a/src/js/tuntap.js.map +++ b/src/js/tuntap.js.map @@ -1 +1 @@ -{"version":3,"file":"tuntap.js","sourceRoot":"","sources":["tuntap.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,iDAAyC;AACzC,yBAAyB;AACzB,yBAAyB;AACzB,qCAAqC;AAgBrC,MAAM,MAAM;IASR,YAAY,IAAmB;QAL/B,UAAK,GAAW,KAAK,CAAC;QAMlB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QACxB,IAAI,CAAC,GAAG,GAAG,EAAE,CAAC,QAAQ,CAAC,cAAc,EAAE,IAAI,CAAC,CAAC;QAC7C,IAAI,CAAC,OAAO,GAAG,sBAAW,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,IAAI,KAAK,CAAC,CAAC;QAC/D,IAAI,CAAC,cAAc,GAAG,EAAE,CAAC,iBAAiB,CAAC,EAAE,EAAC;YAC1C,EAAE,EAAE,IAAI,CAAC,GAAG;YACZ,SAAS,EAAC,KAAK;YACf,SAAS,EAAC,KAAK;SAClB,CAAC,CAAC;QACH,IAAI,CAAC,cAAc,GAAG,EAAE,CAAC,gBAAgB,CAAC,EAAE,EAAC;YACzC,EAAE,EAAC,IAAI,CAAC,GAAG;YACX,SAAS,EAAC,KAAK;YACf,SAAS,EAAC,KAAK;SAClB,CAAC,CAAC;QACH,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,Q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C,KAAK,CAAC,CAAC;IACjB,CAAC;CACJ;AACD,iBAAS,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC"} \ No newline at end of file diff --git a/src/js/tuntap.ts b/src/js/tuntap.ts index d091372..89a9fc5 100644 --- a/src/js/tuntap.ts +++ b/src/js/tuntap.ts @@ -7,45 +7,51 @@ interface Tuntap { readonly name: string; readonly isTap:boolean; readonly isTun:boolean; - readonly writeStream:fs.WriteStream; - readonly readStream:fs.ReadStream; mac: string; mtu: number; ipv4: string; ipv6: string; isUp : boolean; + onReceive:(packet: Buffer)=>void; release: () => Promise; - writePacket:(data:Buffer,callback:(err:Error)=>void)=>Promise; + writePacket:(data:Buffer,callback:()=>void)=>Promise; } class tuntap implements Tuntap { _deviceMode: string; _fd: number; _ifName: string; _isUp:boolean = false; - _writingStream:fs.WriteStream; _readingStream:fs.ReadStream; + _onReceive:(packet: Buffer)=>void; constructor(mode: "tun" | "tap") { this._deviceMode = mode; this._fd = fs.openSync(`/dev/net/tun`, "r+"); this._ifName = tuntapAddon.tuntapInit(this._fd, mode == "tap"); - this._writingStream = fs.createWriteStream('',{ - fd: this._fd, - autoClose:false, - emitClose:false - }); this._readingStream = fs.createReadStream('',{ fd:this._fd, autoClose:false, - emitClose:false + emitClose:true }); this._readingStream.setEncoding('binary'); - // this._readingStream.on('data',(packet)=>{ - // }) } - public async writePacket(packet:Buffer, callback:(err:Error)=>void) { - this._writingStream.write(packet,callback); + public async writePacket(packet:Buffer, callback:()=>void) { + fs.writeSync(this._fd,packet); + callback(); + } + private makeSureIsUp(){ + if(!this.isUp){ + throw `you must set isUp = true in order to access this method`; + } + }; + get onReceive(): (packet: Buffer)=>void { + return this._onReceive; + } + set onReceive(newVal) { + this._onReceive = newVal; + this._readingStream.removeAllListeners('data'); + this._readingStream.on('data',this.onReceive); } get name(): string { return this._ifName; @@ -53,9 +59,6 @@ class tuntap implements Tuntap { get isTap(): boolean { return this._deviceMode == "tap"; } - get writeStream(): fs.WriteStream{ - return this._writingStream; - } get readStream(): fs.ReadStream{ return this._readingStream; } @@ -124,13 +127,7 @@ class tuntap implements Tuntap { const ifIndex = tuntapAddon.tuntapGetIfIndex(this._ifName); tuntapAddon.tuntapSetIpv6(ifIndex, addr, prefix); } - private makeSureIsUp(){ - if(!this.isUp){ - throw `you must set isUp = true in order to access this method`; - } - }; public async release():Promise { - // await fs.close(this._fd); this._readingStream.destroy(); }; } diff --git a/tests/tun.js b/tests/tun.js index 7008a6a..33b4978 100644 --- a/tests/tun.js +++ b/tests/tun.js @@ -1,183 +1,248 @@ -const {Tap,Tun} = require('..'); +const { Tap, Tun } = require(".."); const should = require("should"); -const os = require('os'); -const dgram = require('dgram'); +const os = require("os"); +const dgram = require("dgram"); describe("Test tun creating.", function () { - it("should successfuly creating object", function (done) { - const tun = new Tun(); - tun.release() - done(); - }); - it("test create two devices", function (done) { - const tun = new Tun(); - const tun2 = new Tun(); - tun.release(); - tun2.release() - done(); - }); - it("test create two type devices", function (done) { - const tun = new Tun(); - const tap = new Tap(); - tun.release() - tap.release() - done(); - }); - it("test type", function (done) { - const tun = new Tun(); - const tap = new Tap(); - should.equal(tun.isTap,false,"tun.isTap should equal `false`"); - should.equal(tap.isTun,false,"tap.isTap should equal `false`"); - tun.release() - tap.release() - done(); - }); + it("should successfuly creating object", function (done) { + const tun = new Tun(); + tun.release(); + done(); + }); + it("test create two devices", function (done) { + const tun = new Tun(); + const tun2 = new Tun(); + tun.release(); + tun2.release(); + done(); + }); + it("test create two type devices", function (done) { + const tun = new Tun(); + const tap = new Tap(); + tun.release(); + tap.release(); + done(); + }); + it("test type", function (done) { + const tun = new Tun(); + const tap = new Tap(); + should.equal(tun.isTap, false, "tun.isTap should equal `false`"); + should.equal(tap.isTun, false, "tap.isTap should equal `false`"); + tun.release(); + tap.release(); + done(); + }); }); -describe("set interface up",function(){ - let tun; - beforeEach(function(){ - tun = new Tun(); - }) - it("should success",function(done) { - tun.isUp = true; - done(); - }); - it("should exist in system", function (done) { - tun.isUp = true; - should.exist(os.networkInterfaces()[`${tun.name}`],`cannot find ${tun.name}`, "deivce doesn't exist in os"); - done(); - }); - afterEach(function(){ - tun.release() - }) +describe("set interface up", function () { + let tun; + beforeEach(function () { + tun = new Tun(); + }); + it("should success", function (done) { + tun.isUp = true; + done(); + }); + it("should exist in system", function (done) { + tun.isUp = true; + should.exist( + os.networkInterfaces()[`${tun.name}`], + `cannot find ${tun.name}`, + "deivce doesn't exist in os", + ); + done(); + }); + afterEach(function () { + tun.release(); + }); }); -describe("set interface down",function(){ - let tun; - beforeEach(function(){ - tun = new Tun(); - }) - it("set down",function(done) { - tun.isUp = false; - done(); - }); - it("set up and down",function(done) { - tun.isUp = true; - tun.isUp = false; - should.not.exist(os.networkInterfaces()[`${tun.name}`],`still existing: ${tun.name}`, `device should not exist in os`); - done(); - }) - - it("set up and down and up",function(done) { - tun.isUp = true; - tun.isUp = false; - tun.isUp = true; - should.exist(os.networkInterfaces()[`${tun.name}`],`cannot find ${tun.name}`, `device should exist in os again`); - done(); - }) - afterEach(function(){ - tun.release() - }) +describe("set interface down", function () { + let tun; + beforeEach(function () { + tun = new Tun(); + }); + it("set down", function (done) { + tun.isUp = false; + done(); + }); + it("set up and down", function (done) { + tun.isUp = true; + tun.isUp = false; + should.not.exist( + os.networkInterfaces()[`${tun.name}`], + `still existing: ${tun.name}`, + `device should not exist in os`, + ); + done(); + }); + + it("set up and down and up", function (done) { + tun.isUp = true; + tun.isUp = false; + tun.isUp = true; + should.exist( + os.networkInterfaces()[`${tun.name}`], + `cannot find ${tun.name}`, + `device should exist in os again`, + ); + done(); + }); + afterEach(function () { + tun.release(); + }); }); -describe("set ipv4 addresses",function(){ - let tun; - before(function () { - tun = new Tun(); - tun.isUp = true; - }); - it("set ipv4",function(done) { - tun.ipv4 = "1.2.3.4/8"; - should.equal(tun.ipv4,"1.2.3.4/8","ipv4 address doesn't equal to the address which we just set"); - done() - }); - it("set incorrect ipv4",function(done) { - should.throws(()=>{ - tun.ipv4 = "1.2.3.4/8/"; - },"should throw for incorrect ip"); - done() - }); - after(function(){ - tun.release(); - }) +describe("set ipv4 addresses", function () { + let tun; + before(function () { + tun = new Tun(); + tun.isUp = true; + }); + it("set ipv4", function (done) { + tun.ipv4 = "1.2.3.4/8"; + should.equal( + tun.ipv4, + "1.2.3.4/8", + "ipv4 address doesn't equal to the address which we just set", + ); + done(); + }); + it("set incorrect ipv4", function (done) { + should.throws(() => { + tun.ipv4 = "1.2.3.4/8/"; + }, "should throw for incorrect ip"); + done(); + }); + after(function () { + tun.release(); + }); }); -describe("set mtu",function(){ - let tun; - before(function () { - tun = new Tun(); - tun.isUp = true; - }); - it("set mtu",function(done) { - tun.mtu = 1400; - done(); - }); - it("get mtu",function(done) { - should.equal(tun.mtu,1400,"mtu doesn't equal to the address which we just set"); - done(); - }); - after(function(){ - tun.release(); - }) +describe("set mtu", function () { + let tun; + before(function () { + tun = new Tun(); + tun.isUp = true; + }); + it("set mtu", function (done) { + tun.mtu = 1400; + done(); + }); + it("get mtu", function (done) { + should.equal( + tun.mtu, + 1400, + "mtu doesn't equal to the address which we just set", + ); + done(); + }); + after(function () { + tun.release(); + }); }); -describe("set ipv6",function(){ - let tun; - before(function () { - tun = new Tun(); - tun.isUp = true; - }); - it("set ipv6",function(done) { - tun.ipv6 = "abcd:1:2:3::/64"; - done(); - }); - it("get ipv6",function(done) { - should.equal(tun.ipv6,"abcd:1:2:3::/64","ipv6 doesn't equal to the address which we just set"); - done(); - }); - it("set incorrect ipv6",function(done) { - should.throws(()=>{ - tun.ipv6 = "1.2.3.4:1:2"; - },"should throw for incorrect ip"); - done() - }); - after(function(){ - tun.release(); - }) +describe("set ipv6", function () { + let tun; + before(function () { + tun = new Tun(); + tun.isUp = true; + }); + it("set ipv6", function (done) { + tun.ipv6 = "abcd:1:2:3::/64"; + done(); + }); + it("get ipv6", function (done) { + should.equal( + tun.ipv6, + "abcd:1:2:3::/64", + "ipv6 doesn't equal to the address which we just set", + ); + done(); + }); + it("set incorrect ipv6", function (done) { + should.throws(() => { + tun.ipv6 = "1.2.3.4:1:2"; + }, "should throw for incorrect ip"); + done(); + }); + after(function () { + tun.release(); + }); }); -describe("test send and receive packet",function(){ - let tun; - let packet; - let socket; - // this.timeout(200000); - before(function () { - tun = new Tun(); - tun.isUp = true; - tun.ipv4 = "4.3.2.1/24" - packet = Buffer.from([ - 0x45, 0x02, 0x00, 0x54, 0x6e, 0x97, 0x00, 0x00, 0x40, 0x01, 0xf7, 0xf2, 0x0a, 0x01, 0x00, 0x13, - 0x0a, 0x00, 0x00, 0x0a, 0x08, 0x00, 0xd3, 0xf9, 0x00, 0x05, 0x00, 0x02, 0x84, 0x9e, 0xc8, 0x61, - 0x00, 0x00, 0x00, 0x00, 0x13, 0x2c, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x11, 0x12, 0x13, - 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, - 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, - 0x34, 0x35, 0x36, 0x37]); - socket = dgram.createSocket('udp4'); - - }); - it("send one packet",function(done) { - tun.writePacket(packet,()=>{}); - done(); - }); - it("receive packet",function(done) { - tun.writePacket(packet,()=>{}); - tun.readStream.on('data',(chunk)=>{ - // console.log(`${tun.name} - Receiver: ${chunk.length} bytes`); - tun.readStream.removeAllListeners('data'); - done(); - }); - socket.send("hello!",43210,'localhost',(err)=>{ +describe("test send and receive packet", function () { + let tun; + let packet; + let socket; + // this.timeout(200000); + before(function () { + tun = new Tun(); + tun.isUp = true; + tun.ipv4 = "4.3.2.1/24"; + packet = Buffer.from([ + 0x45, 0x02, 0x00, 0x54, 0x6e, 0x97, 0x00, 0x00, 0x40, 0x01, 0xf7, + 0xf2, 0x0a, 0x01, 0x00, 0x13, 0x0a, 0x00, 0x00, 0x0a, 0x08, 0x00, + 0xd3, 0xf9, 0x00, 0x05, 0x00, 0x02, 0x84, 0x9e, 0xc8, 0x61, 0x00, + 0x00, 0x00, 0x00, 0x13, 0x2c, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, + 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, + 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, + 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, + ]); + socket = dgram.createSocket("udp4"); + }); + it("send one packet", function (done) { + tun.writePacket(packet, () => {}); + done(); + }); + it("receive packet", function (done) { + tun.writePacket(packet, () => {}); + tun.onReceive = (chunk) => { + console.log(`${tun.name} - Receiver: ${chunk.length} bytes`); + done(); + } + socket.send("hello!", 43210, '4.3.2.1', (err) => {}); }) - }); - after(function(){ - tun.release(); - socket.close(); - }) -}); \ No newline at end of file + ; + after(function () { + tun.release(); + socket.close(); + }); +}); + +describe("test send by tun and receive by node socket", function () { + let tun; + let packet; + let listener; + this.timeout(20000); + before(function () { + tun = new Tun(); + tun.isUp = true; + tun.ipv4 = "4.3.2.1/24"; + // packet = Buffer.from([ + // 0x45, 0x02, 0x00, 0x21, 0x6e, 0x97, 0x00, 0x00, 0x40, 0x11, 0x87, 0x2e, 0x04, 0x03, 0x02, 0x01, + // 0x7f, 0x00, 0x00, 0x01, 0xe0, 0xb4, 0xa8, 0xca, 0x00, 0x0d, 0xfe, 0x20, 0x68, 0x65, 0x6c, 0x6c, + // 0x6f + // ]); + packet = Buffer.from([ + 0x45, 0x00, 0x00, 0x22, 0xf6, 0x45, 0x40, 0x00, 0x40, 0x11, 0x38, 0x7e, 0x04, 0x03, 0x02, 0x01, + 0x04, 0x03, 0x02, 0x01, 0xc6, 0xef, 0xa8, 0xca, 0x00, 0x0e, 0x0c, 0x27, 0x68, 0x65, 0x6c, 0x6c, + 0x6f, 0x21 + ]); + }); + it("test message 'hello!' ", function (done) { + listener = dgram.createSocket("udp4", (msg, info) => { + console.log(msg.toString("utf8")); + done(); + }); + listener.bind({ + address:'0.0.0.0', + port: 43210 + }); + setTimeout(function(packet,tun){ + + tun.writePacket(packet, () => {}); + },100,packet,tun); + }); + after(function () { + tun.release(); + listener.close(); + }); +}); From 6131fbc79d29d837e1bf51a33f464fdc6a725424 Mon Sep 17 00:00:00 2001 From: pupilTong Date: Fri, 11 Feb 2022 21:50:09 -0800 Subject: [PATCH 03/13] first working version --- README.md | 69 ++++++- package-lock.json | 427 +++++++++++-------------------------------- package.json | 28 ++- src/js/tuntap.js | 25 +-- src/js/tuntap.js.map | 2 +- src/js/tuntap.ts | 104 ++++++----- tests/tap.js | 2 +- tests/tun.js | 64 ++++--- 8 files changed, 307 insertions(+), 414 deletions(-) diff --git a/README.md b/README.md index 9d5893d..21e0142 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,70 @@ # node-tuntap2 + a opensource, asynchronized, napi-based, business friendly tuntap device driver addon for nodejs. -still under development. \ No newline at end of file + +## TL; DR + +```javascript +const {Tun, Tap} = require('tuntap2'); + +try { + const tun = new Tun(); + tun.mtu = 1400; + tun.ipv4 = '10.0.0.100/24'; + tun.ipv6 = 'abcd:1:2:3::/64'; + tun.onReceive = (buf) => { + console.log('received:', buf); + } + tun.isUp = true; + console.log(`created tun: ${tun.name}, ip: ${tun.ipv4}, ${tun.ipv6}, mtu: ${tun.mtu}`); + tun.release(); + +} +catch(e) { + console.log('error: ', e); + process.exit(0); +} +``` + +## Properties + +```typescript + interface Tuntap { + readonly name: string; + readonly isTap: boolean; + readonly isTun: boolean; + mac: string; + mtu: number; + ipv4: string; + ipv6: string; + isUp: boolean; + onReceive: (packet: Buffer) => void; + release: () => Promise; + writePacket: ( + data: Buffer, + callback: ( + err: NodeJS.ErrnoException, + written: number, + buffer: Buffer, + ) => void, + ) => void; + } +``` + +**Note:** Reading properties requires your interface in `up` status. + +**Note:** For a `Tun` device, `mac` property is readonly. + +**Node:** Please make sure the first 8bits is `00` for setting the mac address of a Tap device. + +## Performace + +The writing and reading of tuntap is based on nodejs `fs` and `readingStream`. This means these methods is running on libuv threads pool. Please set the threads pool size properly for your application. + +## TODO + +* [ ] make it compatible with `node-tuntap` +* [ ] make it compatible with `pipe()` +* [ ] add BSD os support +* [ ] add tap devices support for osx, using utun. +* [ ] add demos \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 132f04a..f489e0d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,14 +11,15 @@ "license": "Apache-2.0", "dependencies": { "bindings": "^1.5.0", - "jsonpath": "^1.1.1", + "jmespath": "^0.16.0", "node-addon-api": "^4.0.0", "prebuild-install": "^7.0.0" }, "devDependencies": { - "@types/jsonpath": "^0.2.0", + "@types/jmespath": "^0.15.0", "@types/mocha": "^9.0.0", "@types/node": "^17.0.8", + "inet_xtoy": "^1.2.1", "mocha": "^9.1.4", "nyc": "^15.1.0", "should": "^13.2.3", @@ -516,10 +517,10 @@ "node": ">=8" } }, - "node_modules/@types/jsonpath": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/@types/jsonpath/-/jsonpath-0.2.0.tgz", - "integrity": "sha512-v7qlPA0VpKUlEdhghbDqRoKMxFB3h3Ch688TApBJ6v+XLDdvWCGLJIYiPKGZnS6MAOie+IorCfNYVHOPIHSWwQ==", + "node_modules/@types/jmespath": { + "version": "0.15.0", + "resolved": "https://registry.npmjs.org/@types/jmespath/-/jmespath-0.15.0.tgz", + "integrity": "sha1-SgFikJaoYjHIkaDi3szBX1PJKR0=", "dev": true }, "node_modules/@types/mocha": { @@ -841,10 +842,16 @@ } }, "node_modules/chokidar": { - "version": "3.5.2", - "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.2.tgz", - "integrity": "sha512-ekGhOnNVPgT77r4K/U3GDhu+FQ2S8TnK/s2KbIGXi0SZWuwkZ2QNyfWdZW+TVfn84DpEP7rLeCt2UI6bJ8GwbQ==", + "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", @@ -1002,9 +1009,9 @@ } }, "node_modules/debug": { - "version": "4.3.2", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.2.tgz", - "integrity": "sha512-mOp8wKcvj7XxC78zLgw/ZA+6TSgkoE2C/ienthhRD298T7UNwAg9diBpLRxC0mOezLl4B0xV7M0cCO6P/O0Xhw==", + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.3.tgz", + "integrity": "sha512-/zxw5+vh1Tfv+4Qn7a5nsbcJKPaSvCDhojn6FEl9vupwK2VCSDtEiEtqr8DFtzYFOdz63LBkxec7DYuc2jon6Q==", "dev": true, "dependencies": { "ms": "2.1.2" @@ -1058,11 +1065,6 @@ "node": ">=4.0.0" } }, - "node_modules/deep-is": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", - "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==" - }, "node_modules/default-require-extensions": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/default-require-extensions/-/default-require-extensions-3.0.0.tgz", @@ -1147,40 +1149,11 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/escodegen": { - "version": "1.14.3", - "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-1.14.3.tgz", - "integrity": "sha512-qFcX0XJkdg+PB3xjZZG/wKSuT1PnQWx57+TVSjIMmILd2yC/6ByYElPwJnslDsuWuSAp4AwJGumarAAmJch5Kw==", - "dependencies": { - "esprima": "^4.0.1", - "estraverse": "^4.2.0", - "esutils": "^2.0.2", - "optionator": "^0.8.1" - }, - "bin": { - "escodegen": "bin/escodegen.js", - "esgenerate": "bin/esgenerate.js" - }, - "engines": { - "node": ">=4.0" - }, - "optionalDependencies": { - "source-map": "~0.6.1" - } - }, - "node_modules/escodegen/node_modules/source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "optional": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/esprima": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", + "dev": true, "bin": { "esparse": "bin/esparse.js", "esvalidate": "bin/esvalidate.js" @@ -1189,22 +1162,6 @@ "node": ">=4" } }, - "node_modules/estraverse": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", - "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", - "engines": { - "node": ">=4.0" - } - }, - "node_modules/esutils": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", - "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/expand-template": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/expand-template/-/expand-template-2.0.3.tgz", @@ -1213,11 +1170,6 @@ "node": ">=6" } }, - "node_modules/fast-levenshtein": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", - "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=" - }, "node_modules/file-uri-to-path": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", @@ -1383,9 +1335,9 @@ "integrity": "sha1-l/tdlr/eiXMxPyDoKI75oWf6ZM4=" }, "node_modules/glob": { - "version": "7.1.7", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.7.tgz", - "integrity": "sha512-OvD9ENzPLbegENnYP5UUfJIirTg4+XwMWGaQfQTY0JenxNvvIKP3U3/tAQSPIu/lHxXYSZmpXlUHeqAIdKzBLQ==", + "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", @@ -1520,6 +1472,18 @@ "node": ">=8" } }, + "node_modules/inet_xtoy": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/inet_xtoy/-/inet_xtoy-1.2.1.tgz", + "integrity": "sha512-RqtlWJNSZ2GIh//tre83qy465aHwHAfvRerwvPcgEv3uKIuQpsB1t70NQpV9jiYXApTTHkZJ05cU5UScFlgn+g==", + "dev": true, + "hasInstallScript": true, + "dependencies": { + "bindings": "^1.5.0", + "node-addon-api": "^4.0.0", + "prebuild-install": "^7.0.0" + } + }, "node_modules/inflight": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", @@ -1777,6 +1741,14 @@ "node": ">=8" } }, + "node_modules/jmespath": { + "version": "0.16.0", + "resolved": "https://registry.npmjs.org/jmespath/-/jmespath-0.16.0.tgz", + "integrity": "sha512-9FzQjJ7MATs1tSpnco1K6ayiYE3figslrXA72G2HQ/n76RzvYlofyi5QM+iX4YRs/pu3yzxlVQSST23+dMDknw==", + "engines": { + "node": ">= 0.6.0" + } + }, "node_modules/js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", @@ -1822,40 +1794,6 @@ "node": ">=6" } }, - "node_modules/jsonpath": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/jsonpath/-/jsonpath-1.1.1.tgz", - "integrity": "sha512-l6Cg7jRpixfbgoWgkrl77dgEj8RPvND0wMH6TwQmi9Qs4TFfS9u5cUFnbeKTwj5ga5Y3BTGGNI28k117LJ009w==", - "dependencies": { - "esprima": "1.2.2", - "static-eval": "2.0.2", - "underscore": "1.12.1" - } - }, - "node_modules/jsonpath/node_modules/esprima": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/esprima/-/esprima-1.2.2.tgz", - "integrity": "sha1-dqD9Zvz+FU/SkmZ9wmQBl1CxZXs=", - "bin": { - "esparse": "bin/esparse.js", - "esvalidate": "bin/esvalidate.js" - }, - "engines": { - "node": ">=0.4.0" - } - }, - "node_modules/levn": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", - "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", - "dependencies": { - "prelude-ls": "~1.1.2", - "type-check": "~0.3.2" - }, - "engines": { - "node": ">= 0.8.0" - } - }, "node_modules/locate-path": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", @@ -1962,32 +1900,32 @@ "integrity": "sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==" }, "node_modules/mocha": { - "version": "9.1.4", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-9.1.4.tgz", - "integrity": "sha512-+q2aV5VlJZuLgCWoBvGI5zEwPF9eEI0kr/sAA9Jm4xMND7RfIEyF8JE7C0JIg8WXRG+P1sdIAb5ccoHPlXLzcw==", + "version": "9.2.0", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-9.2.0.tgz", + "integrity": "sha512-kNn7E8g2SzVcq0a77dkphPsDSN7P+iYkqE0ZsGCYWRsoiKjOt+NvXfaagik8vuDa6W5Zw3qxe8Jfpt5qKf+6/Q==", "dev": true, "dependencies": { "@ungap/promise-all-settled": "1.1.2", "ansi-colors": "4.1.1", "browser-stdout": "1.3.1", - "chokidar": "3.5.2", - "debug": "4.3.2", + "chokidar": "3.5.3", + "debug": "4.3.3", "diff": "5.0.0", "escape-string-regexp": "4.0.0", "find-up": "5.0.0", - "glob": "7.1.7", + "glob": "7.2.0", "growl": "1.10.5", "he": "1.2.0", "js-yaml": "4.1.0", "log-symbols": "4.1.0", "minimatch": "3.0.4", "ms": "2.1.3", - "nanoid": "3.1.25", + "nanoid": "3.2.0", "serialize-javascript": "6.0.0", "strip-json-comments": "3.1.1", "supports-color": "8.1.1", "which": "2.0.2", - "workerpool": "6.1.5", + "workerpool": "6.2.0", "yargs": "16.2.0", "yargs-parser": "20.2.4", "yargs-unparser": "2.0.0" @@ -2023,9 +1961,9 @@ "dev": true }, "node_modules/nanoid": { - "version": "3.1.25", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.1.25.tgz", - "integrity": "sha512-rdwtIXaXCLFAQbnfqDRnI6jaRHp9fTcYBjtFKE8eezcZ7LuLjhUaQGNeMXf1HmRoCH32CLz6XwX0TtxEOS/A3Q==", + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.2.0.tgz", + "integrity": "sha512-fmsZYa9lpn69Ad5eDn7FMcnnSR+8R34W9qJEijxYhTbfOWzr22n1QxCMzXLK+ODyW2973V3Fux959iQoUxzUIA==", "dev": true, "bin": { "nanoid": "bin/nanoid.cjs" @@ -2338,22 +2276,6 @@ "wrappy": "1" } }, - "node_modules/optionator": { - "version": "0.8.3", - "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.3.tgz", - "integrity": "sha512-+IW9pACdk3XWmmTXG8m3upGUJst5XRGzxMRjXzAuJ1XnIFNvfhjjIuYkDvysnPQ7qzqVzLt78BCruntqRhWQbA==", - "dependencies": { - "deep-is": "~0.1.3", - "fast-levenshtein": "~2.0.6", - "levn": "~0.3.0", - "prelude-ls": "~1.1.2", - "type-check": "~0.3.2", - "word-wrap": "~1.2.3" - }, - "engines": { - "node": ">= 0.8.0" - } - }, "node_modules/p-limit": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", @@ -2555,14 +2477,6 @@ "node": ">=10" } }, - "node_modules/prelude-ls": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", - "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=", - "engines": { - "node": ">= 0.8.0" - } - }, "node_modules/process-nextick-args": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", @@ -2822,9 +2736,9 @@ ] }, "node_modules/simple-get": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/simple-get/-/simple-get-4.0.0.tgz", - "integrity": "sha512-ZalZGexYr3TA0SwySsr5HlgOOinS4Jsa8YB2GJ6lUNAazyAu4KG/VmzMTwAt2YVXzzVj8QmefmAonZIK2BSGcQ==", + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/simple-get/-/simple-get-4.0.1.tgz", + "integrity": "sha512-brv7p5WgH0jmQJr1ZDDfKDOSeWWg+OVypG99A/5vYGPqJ6pxiaHLy8nxtFjBA7oMa01ebA9gfh1uMCFqOuXxvA==", "funding": [ { "type": "github", @@ -2877,14 +2791,6 @@ "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", "dev": true }, - "node_modules/static-eval": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/static-eval/-/static-eval-2.0.2.tgz", - "integrity": "sha512-N/D219Hcr2bPjLxPiV+TQE++Tsmrady7TqAJugLy7Xk1EumfDWS/f5dtBbkRCGE7wKKXuYockQoj8Rm2/pVKyg==", - "dependencies": { - "escodegen": "^1.8.1" - } - }, "node_modules/string_decoder": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", @@ -3034,17 +2940,6 @@ "node": "*" } }, - "node_modules/type-check": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", - "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=", - "dependencies": { - "prelude-ls": "~1.1.2" - }, - "engines": { - "node": ">= 0.8.0" - } - }, "node_modules/type-fest": { "version": "0.8.1", "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.8.1.tgz", @@ -3076,11 +2971,6 @@ "node": ">=4.2.0" } }, - "node_modules/underscore": { - "version": "1.12.1", - "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.12.1.tgz", - "integrity": "sha512-hEQt0+ZLDVUMhebKxL4x1BTtDY7bavVofhZ9KZ4aI26X9SRaE+Y3m83XUL1UP2jn8ynjndwCCpEHdUG+9pP1Tw==" - }, "node_modules/util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", @@ -3125,18 +3015,10 @@ "string-width": "^1.0.2 || 2 || 3 || 4" } }, - "node_modules/word-wrap": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", - "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==", - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/workerpool": { - "version": "6.1.5", - "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.1.5.tgz", - "integrity": "sha512-XdKkCK0Zqc6w3iTxLckiuJ81tiD/o5rBE/m+nXpRCB+/Sq4DqkfXZ/x0jW02DG1tGsfUGXbTJyZDP+eu67haSw==", + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.2.0.tgz", + "integrity": "sha512-Rsk5qQHJ9eowMH28Jwhe8HEbmdYDX4lwoMWshiCXugjtHqMD9ZbiqSDLxcsfdqsETPzVUtX5s1Z5kStiIM6l4A==", "dev": true }, "node_modules/wrap-ansi": { @@ -3709,10 +3591,10 @@ "integrity": "sha512-ZXRY4jNvVgSVQ8DL3LTcakaAtXwTVUxE81hslsyD2AtoXW/wVob10HkOJ1X/pAlcI7D+2YoZKg5do8G/w6RYgA==", "dev": true }, - "@types/jsonpath": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/@types/jsonpath/-/jsonpath-0.2.0.tgz", - "integrity": "sha512-v7qlPA0VpKUlEdhghbDqRoKMxFB3h3Ch688TApBJ6v+XLDdvWCGLJIYiPKGZnS6MAOie+IorCfNYVHOPIHSWwQ==", + "@types/jmespath": { + "version": "0.15.0", + "resolved": "https://registry.npmjs.org/@types/jmespath/-/jmespath-0.15.0.tgz", + "integrity": "sha1-SgFikJaoYjHIkaDi3szBX1PJKR0=", "dev": true }, "@types/mocha": { @@ -3948,9 +3830,9 @@ } }, "chokidar": { - "version": "3.5.2", - "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.2.tgz", - "integrity": "sha512-ekGhOnNVPgT77r4K/U3GDhu+FQ2S8TnK/s2KbIGXi0SZWuwkZ2QNyfWdZW+TVfn84DpEP7rLeCt2UI6bJ8GwbQ==", + "version": "3.5.3", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz", + "integrity": "sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==", "dev": true, "requires": { "anymatch": "~3.1.2", @@ -4082,9 +3964,9 @@ } }, "debug": { - "version": "4.3.2", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.2.tgz", - "integrity": "sha512-mOp8wKcvj7XxC78zLgw/ZA+6TSgkoE2C/ienthhRD298T7UNwAg9diBpLRxC0mOezLl4B0xV7M0cCO6P/O0Xhw==", + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.3.tgz", + "integrity": "sha512-/zxw5+vh1Tfv+4Qn7a5nsbcJKPaSvCDhojn6FEl9vupwK2VCSDtEiEtqr8DFtzYFOdz63LBkxec7DYuc2jon6Q==", "dev": true, "requires": { "ms": "2.1.2" @@ -4117,11 +3999,6 @@ "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.6.0.tgz", "integrity": "sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==" }, - "deep-is": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", - "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==" - }, "default-require-extensions": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/default-require-extensions/-/default-require-extensions-3.0.0.tgz", @@ -4185,51 +4062,17 @@ "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", "dev": true }, - "escodegen": { - "version": "1.14.3", - "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-1.14.3.tgz", - "integrity": "sha512-qFcX0XJkdg+PB3xjZZG/wKSuT1PnQWx57+TVSjIMmILd2yC/6ByYElPwJnslDsuWuSAp4AwJGumarAAmJch5Kw==", - "requires": { - "esprima": "^4.0.1", - "estraverse": "^4.2.0", - "esutils": "^2.0.2", - "optionator": "^0.8.1", - "source-map": "~0.6.1" - }, - "dependencies": { - "source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "optional": true - } - } - }, "esprima": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", - "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==" - }, - "estraverse": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", - "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==" - }, - "esutils": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", - "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==" + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", + "dev": true }, "expand-template": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/expand-template/-/expand-template-2.0.3.tgz", "integrity": "sha512-XYfuKMvj4O35f/pOXLObndIRvyQ+/+6AhODh+OKWj9S9498pHHn/IMszH+gt0fBCRWMNfk1ZSp5x3AifmnI2vg==" }, - "fast-levenshtein": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", - "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=" - }, "file-uri-to-path": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", @@ -4344,9 +4187,9 @@ "integrity": "sha1-l/tdlr/eiXMxPyDoKI75oWf6ZM4=" }, "glob": { - "version": "7.1.7", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.7.tgz", - "integrity": "sha512-OvD9ENzPLbegENnYP5UUfJIirTg4+XwMWGaQfQTY0JenxNvvIKP3U3/tAQSPIu/lHxXYSZmpXlUHeqAIdKzBLQ==", + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz", + "integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==", "dev": true, "requires": { "fs.realpath": "^1.0.0", @@ -4434,6 +4277,17 @@ "integrity": "sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg==", "dev": true }, + "inet_xtoy": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/inet_xtoy/-/inet_xtoy-1.2.1.tgz", + "integrity": "sha512-RqtlWJNSZ2GIh//tre83qy465aHwHAfvRerwvPcgEv3uKIuQpsB1t70NQpV9jiYXApTTHkZJ05cU5UScFlgn+g==", + "dev": true, + "requires": { + "bindings": "^1.5.0", + "node-addon-api": "^4.0.0", + "prebuild-install": "^7.0.0" + } + }, "inflight": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", @@ -4634,6 +4488,11 @@ "istanbul-lib-report": "^3.0.0" } }, + "jmespath": { + "version": "0.16.0", + "resolved": "https://registry.npmjs.org/jmespath/-/jmespath-0.16.0.tgz", + "integrity": "sha512-9FzQjJ7MATs1tSpnco1K6ayiYE3figslrXA72G2HQ/n76RzvYlofyi5QM+iX4YRs/pu3yzxlVQSST23+dMDknw==" + }, "js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", @@ -4664,32 +4523,6 @@ "minimist": "^1.2.5" } }, - "jsonpath": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/jsonpath/-/jsonpath-1.1.1.tgz", - "integrity": "sha512-l6Cg7jRpixfbgoWgkrl77dgEj8RPvND0wMH6TwQmi9Qs4TFfS9u5cUFnbeKTwj5ga5Y3BTGGNI28k117LJ009w==", - "requires": { - "esprima": "1.2.2", - "static-eval": "2.0.2", - "underscore": "1.12.1" - }, - "dependencies": { - "esprima": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/esprima/-/esprima-1.2.2.tgz", - "integrity": "sha1-dqD9Zvz+FU/SkmZ9wmQBl1CxZXs=" - } - } - }, - "levn": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", - "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", - "requires": { - "prelude-ls": "~1.1.2", - "type-check": "~0.3.2" - } - }, "locate-path": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", @@ -4765,32 +4598,32 @@ "integrity": "sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==" }, "mocha": { - "version": "9.1.4", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-9.1.4.tgz", - "integrity": "sha512-+q2aV5VlJZuLgCWoBvGI5zEwPF9eEI0kr/sAA9Jm4xMND7RfIEyF8JE7C0JIg8WXRG+P1sdIAb5ccoHPlXLzcw==", + "version": "9.2.0", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-9.2.0.tgz", + "integrity": "sha512-kNn7E8g2SzVcq0a77dkphPsDSN7P+iYkqE0ZsGCYWRsoiKjOt+NvXfaagik8vuDa6W5Zw3qxe8Jfpt5qKf+6/Q==", "dev": true, "requires": { "@ungap/promise-all-settled": "1.1.2", "ansi-colors": "4.1.1", "browser-stdout": "1.3.1", - "chokidar": "3.5.2", - "debug": "4.3.2", + "chokidar": "3.5.3", + "debug": "4.3.3", "diff": "5.0.0", "escape-string-regexp": "4.0.0", "find-up": "5.0.0", - "glob": "7.1.7", + "glob": "7.2.0", "growl": "1.10.5", "he": "1.2.0", "js-yaml": "4.1.0", "log-symbols": "4.1.0", "minimatch": "3.0.4", "ms": "2.1.3", - "nanoid": "3.1.25", + "nanoid": "3.2.0", "serialize-javascript": "6.0.0", "strip-json-comments": "3.1.1", "supports-color": "8.1.1", "which": "2.0.2", - "workerpool": "6.1.5", + "workerpool": "6.2.0", "yargs": "16.2.0", "yargs-parser": "20.2.4", "yargs-unparser": "2.0.0" @@ -4811,9 +4644,9 @@ "dev": true }, "nanoid": { - "version": "3.1.25", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.1.25.tgz", - "integrity": "sha512-rdwtIXaXCLFAQbnfqDRnI6jaRHp9fTcYBjtFKE8eezcZ7LuLjhUaQGNeMXf1HmRoCH32CLz6XwX0TtxEOS/A3Q==", + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.2.0.tgz", + "integrity": "sha512-fmsZYa9lpn69Ad5eDn7FMcnnSR+8R34W9qJEijxYhTbfOWzr22n1QxCMzXLK+ODyW2973V3Fux959iQoUxzUIA==", "dev": true }, "napi-build-utils": { @@ -5059,19 +4892,6 @@ "wrappy": "1" } }, - "optionator": { - "version": "0.8.3", - "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.3.tgz", - "integrity": "sha512-+IW9pACdk3XWmmTXG8m3upGUJst5XRGzxMRjXzAuJ1XnIFNvfhjjIuYkDvysnPQ7qzqVzLt78BCruntqRhWQbA==", - "requires": { - "deep-is": "~0.1.3", - "fast-levenshtein": "~2.0.6", - "levn": "~0.3.0", - "prelude-ls": "~1.1.2", - "type-check": "~0.3.2", - "word-wrap": "~1.2.3" - } - }, "p-limit": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", @@ -5215,11 +5035,6 @@ "tunnel-agent": "^0.6.0" } }, - "prelude-ls": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", - "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=" - }, "process-nextick-args": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", @@ -5429,9 +5244,9 @@ "integrity": "sha512-cSFtAPtRhljv69IK0hTVZQ+OfE9nePi/rtJmw5UjHeVyVroEqJXP1sFztKUy1qU+xvz3u/sfYJLa947b7nAN2Q==" }, "simple-get": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/simple-get/-/simple-get-4.0.0.tgz", - "integrity": "sha512-ZalZGexYr3TA0SwySsr5HlgOOinS4Jsa8YB2GJ6lUNAazyAu4KG/VmzMTwAt2YVXzzVj8QmefmAonZIK2BSGcQ==", + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/simple-get/-/simple-get-4.0.1.tgz", + "integrity": "sha512-brv7p5WgH0jmQJr1ZDDfKDOSeWWg+OVypG99A/5vYGPqJ6pxiaHLy8nxtFjBA7oMa01ebA9gfh1uMCFqOuXxvA==", "requires": { "decompress-response": "^6.0.0", "once": "^1.3.1", @@ -5464,14 +5279,6 @@ "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", "dev": true }, - "static-eval": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/static-eval/-/static-eval-2.0.2.tgz", - "integrity": "sha512-N/D219Hcr2bPjLxPiV+TQE++Tsmrady7TqAJugLy7Xk1EumfDWS/f5dtBbkRCGE7wKKXuYockQoj8Rm2/pVKyg==", - "requires": { - "escodegen": "^1.8.1" - } - }, "string_decoder": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", @@ -5587,14 +5394,6 @@ "safe-buffer": "^5.0.1" } }, - "type-check": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", - "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=", - "requires": { - "prelude-ls": "~1.1.2" - } - }, "type-fest": { "version": "0.8.1", "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.8.1.tgz", @@ -5616,11 +5415,6 @@ "integrity": "sha512-VgYs2A2QIRuGphtzFV7aQJduJ2gyfTljngLzjpfW9FoYZF6xuw1W0vW9ghCKLfcWrCFxK81CSGRAvS1pn4fIUg==", "dev": true }, - "underscore": { - "version": "1.12.1", - "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.12.1.tgz", - "integrity": "sha512-hEQt0+ZLDVUMhebKxL4x1BTtDY7bavVofhZ9KZ4aI26X9SRaE+Y3m83XUL1UP2jn8ynjndwCCpEHdUG+9pP1Tw==" - }, "util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", @@ -5655,15 +5449,10 @@ "string-width": "^1.0.2 || 2 || 3 || 4" } }, - "word-wrap": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", - "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==" - }, "workerpool": { - "version": "6.1.5", - "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.1.5.tgz", - "integrity": "sha512-XdKkCK0Zqc6w3iTxLckiuJ81tiD/o5rBE/m+nXpRCB+/Sq4DqkfXZ/x0jW02DG1tGsfUGXbTJyZDP+eu67haSw==", + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.2.0.tgz", + "integrity": "sha512-Rsk5qQHJ9eowMH28Jwhe8HEbmdYDX4lwoMWshiCXugjtHqMD9ZbiqSDLxcsfdqsETPzVUtX5s1Z5kStiIM6l4A==", "dev": true }, "wrap-ansi": { diff --git a/package.json b/package.json index 40b31c5..0c8d872 100644 --- a/package.json +++ b/package.json @@ -13,21 +13,45 @@ }, "author": "pupiltong", "license": "Apache-2.0", + "repository": { + "type": "git", + "url": "git+https://github.com/PupilTong/node-tuntap2.git" + }, + "keywords": [ + "tunnel", + "tun", + "tap", + "internet", + "vpn" + ], + "files": [ + "src/cpp/*", + "src/js/*", + "index.js", + "index.ts", + "binding.gyp" + ], + "gypfile": true, "dependencies": { "bindings": "^1.5.0", - "jsonpath": "^1.1.1", + "jmespath": "^0.16.0", "node-addon-api": "^4.0.0", "prebuild-install": "^7.0.0" }, + "bugs": { + "url": "https://github.com/PupilTong/node-ether-xtoy/issues" + }, + "homepage": "https://github.com/PupilTong/node-ether-xtoy#readme", "binary": { "napi_versions": [ 3 ] }, "devDependencies": { - "@types/jsonpath": "^0.2.0", + "@types/jmespath": "^0.15.0", "@types/mocha": "^9.0.0", "@types/node": "^17.0.8", + "inet_xtoy": "^1.2.1", "mocha": "^9.1.4", "nyc": "^15.1.0", "should": "^13.2.3", diff --git a/src/js/tuntap.js b/src/js/tuntap.js index 09ebc82..ef9d822 100644 --- a/src/js/tuntap.js +++ b/src/js/tuntap.js @@ -11,24 +11,22 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge const tuntap2Addon_1 = require("./tuntap2Addon"); const fs = require("fs"); const os = require("os"); -const jsonpath = require("jsonpath"); +const jmespath = require("jmespath"); class tuntap { constructor(mode) { this._isUp = false; this._deviceMode = mode; this._fd = fs.openSync(`/dev/net/tun`, "r+"); this._ifName = tuntap2Addon_1.default.tuntapInit(this._fd, mode == "tap"); - this._readingStream = fs.createReadStream('', { + this._readingStream = fs.createReadStream("", { fd: this._fd, autoClose: false, - emitClose: true + emitClose: true, }); - this._readingStream.setEncoding('binary'); } writePacket(packet, callback) { return __awaiter(this, void 0, void 0, function* () { - fs.writeSync(this._fd, packet); - callback(); + fs.write(this._fd, packet, callback); }); } makeSureIsUp() { @@ -36,14 +34,13 @@ class tuntap { throw `you must set isUp = true in order to access this method`; } } - ; get onReceive() { return this._onReceive; } set onReceive(newVal) { this._onReceive = newVal; - this._readingStream.removeAllListeners('data'); - this._readingStream.on('data', this.onReceive); + this._readingStream.removeAllListeners("data"); + this._readingStream.on("data", this.onReceive); } get name() { return this._ifName; @@ -51,9 +48,6 @@ class tuntap { get isTap() { return this._deviceMode == "tap"; } - get readStream() { - return this._readingStream; - } get isTun() { return !this.isTap; } @@ -72,7 +66,7 @@ class tuntap { get mac() { this.makeSureIsUp(); const ifInfo = os.networkInterfaces(); - const mac = jsonpath.query(ifInfo, `$.${this._ifName}[?(@.mac)].mac`)[0]; + const mac = jmespath.search(ifInfo, `${this._ifName}[*].[mac]|[0]`); return mac; } get mtu() { @@ -84,7 +78,7 @@ class tuntap { get ipv4() { this.makeSureIsUp(); const ifInfo = os.networkInterfaces(); - return jsonpath.query(ifInfo, `$.${this._ifName}[?(@.family=='IPv4')].cidr`)[0]; + return jmespath.search(ifInfo, `${this._ifName}[?family=='IPv4'].cidr|[0]`); } set ipv4(ip) { const cirdArray = ip.split("/"); @@ -98,7 +92,7 @@ class tuntap { get ipv6() { this.makeSureIsUp(); const ifInfo = os.networkInterfaces(); - return jsonpath.query(ifInfo, `$.${this._ifName}[?(@.family=='IPv6')].cidr`)[0]; + return jmespath.search(ifInfo, `${this._ifName}[?family=='IPv6'].cidr|[0]`); } set ipv6(ip) { const cirdArray = ip.split("/"); @@ -115,7 +109,6 @@ class tuntap { this._readingStream.destroy(); }); } - ; } class Tap extends tuntap { constructor() { diff --git a/src/js/tuntap.js.map b/src/js/tuntap.js.map index 2ee831d..fdf217f 100644 --- a/src/js/tuntap.js.map +++ b/src/js/tuntap.js.map @@ -1 +1 @@ -{"version":3,"file":"tuntap.js","sourceRoot":"","sources":["tuntap.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,iDAAyC;AACzC,yBAAyB;AACzB,yBAAyB;AACzB,qCAAqC;AAerC,MAAM,MAAM;IASR,YAAY,IAAmB;QAL/B,UAAK,GAAW,KAAK,CAAC;QAMlB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QACxB,IAAI,CAAC,GAAG,GAAG,EAAE,CAAC,QAAQ,CAAC,cAAc,EAAE,IAAI,CAAC,CAAC;QAC7C,IAAI,CAAC,OAAO,GAAG,sBAAW,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,IAAI,KAAK,CAAC,CAAC;QAC/D,IAAI,CAAC,cAAc,GAAG,EAAE,CAAC,gBAAgB,CAAC,EAAE,EAAC;YACzC,EAAE,EAAC,IAAI,CAAC,GAAG;YACX,SAAS,EAAC,KAAK;YACf,SAAS,EAAC,IAAI;SACjB,CAAC,CAAC;QACH,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;IAC9C,CAAC;IACY,WAAW,CAAC,MAAa,EAAE,QAAiB;;YACrD,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,EAAC,MAAM,CAAC,CAAC;YAC9B,QAAQ,EAAE,CAAC;QACf,CAAC;KAAA;IACO,YAAY;QAChB,IAAG,CAAC,IAAI,CAAC,IAAI,EAAC;YACV,MAAM,yDAAyD,CAAC;SACnE;IACL,CAAC;IAAA,CAAC;IACF,IAAI,SAAS;QACT,OAAO,IAAI,CAAC,UAAU,CAAC;IAC3B,CAAC;IACD,IAAI,SAAS,CAAC,MAAM;QAChB,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC;QACzB,IAAI,CAAC,cAAc,CAAC,kBAAkB,CAAC,MAAM,CA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AI,SAAS,CAAC,MAAM,IAAI,CAAC,EAAE;YACvB,MAAM,2BAA2B,EAAE,EAAE,CAAC;SACzC;QACD,MAAM,IAAI,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;QAC1B,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;QAC7C,MAAM,OAAO,GAAG,sBAAW,CAAC,gBAAgB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC3D,sBAAW,CAAC,aAAa,CAAC,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;IACrD,CAAC;IACY,OAAO;;YAChB,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE,CAAC;QAClC,CAAC;KAAA;CACJ;AACD,MAAM,GAAI,SAAQ,MAAM;IACpB;QACI,KAAK,CAAC,KAAK,CAAC,CAAC;IACjB,CAAC;IACD,IAAI,GAAG,CAAC,GAAW;QACf,sBAAW,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;IAChD,CAAC;IACD,IAAI,GAAG;QACH,OAAO,KAAK,CAAC,GAAG,CAAC;IACrB,CAAC;CACJ;AACD,MAAM,GAAI,SAAQ,MAAM;IACpB;QACI,KAAK,CAAC,KAAK,CAAC,CAAC;IACjB,CAAC;CACJ;AACD,iBAAS,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC"} \ No newline at end of file diff --git a/src/js/tuntap.ts b/src/js/tuntap.ts index 89a9fc5..b3f386a 100644 --- a/src/js/tuntap.ts +++ b/src/js/tuntap.ts @@ -1,57 +1,69 @@ import tuntapAddon from "./tuntap2Addon"; import * as fs from "fs"; import * as os from "os"; -import * as jsonpath from "jsonpath";import { StreamOptions } from "stream"; -import { buffer } from "stream/consumers"; +import * as jmespath from "jmespath"; interface Tuntap { readonly name: string; - readonly isTap:boolean; - readonly isTun:boolean; + readonly isTap: boolean; + readonly isTun: boolean; mac: string; mtu: number; ipv4: string; ipv6: string; - isUp : boolean; - onReceive:(packet: Buffer)=>void; + isUp: boolean; + onReceive: (packet: Buffer) => void; release: () => Promise; - writePacket:(data:Buffer,callback:()=>void)=>Promise; + writePacket: ( + data: Buffer, + callback: ( + err: NodeJS.ErrnoException, + written: number, + buffer: Buffer, + ) => void, + ) => void; } class tuntap implements Tuntap { _deviceMode: string; _fd: number; _ifName: string; - _isUp:boolean = false; - _readingStream:fs.ReadStream; - _onReceive:(packet: Buffer)=>void; - + _isUp: boolean = false; + _readingStream: fs.ReadStream; + _onReceive: (packet: Buffer) => void; constructor(mode: "tun" | "tap") { this._deviceMode = mode; this._fd = fs.openSync(`/dev/net/tun`, "r+"); this._ifName = tuntapAddon.tuntapInit(this._fd, mode == "tap"); - this._readingStream = fs.createReadStream('',{ - fd:this._fd, - autoClose:false, - emitClose:true + this._readingStream = fs.createReadStream("", { + fd: this._fd, + autoClose: false, + emitClose: true, }); - this._readingStream.setEncoding('binary'); - } - public async writePacket(packet:Buffer, callback:()=>void) { - fs.writeSync(this._fd,packet); - callback(); } - private makeSureIsUp(){ - if(!this.isUp){ + public async writePacket( + packet: Buffer, + callback: ( + err: NodeJS.ErrnoException, + written: number, + buffer: Buffer, + ) => void, + ) { + // fs.writeSync(this._fd, packet); + fs.write(this._fd, packet, callback); + // callback(); + } + private makeSureIsUp() { + if (!this.isUp) { throw `you must set isUp = true in order to access this method`; } - }; - get onReceive(): (packet: Buffer)=>void { + } + get onReceive(): (packet: Buffer) => void { return this._onReceive; } set onReceive(newVal) { this._onReceive = newVal; - this._readingStream.removeAllListeners('data'); - this._readingStream.on('data',this.onReceive); + this._readingStream.removeAllListeners("data"); + this._readingStream.on("data", this.onReceive); } get name(): string { return this._ifName; @@ -59,17 +71,14 @@ class tuntap implements Tuntap { get isTap(): boolean { return this._deviceMode == "tap"; } - get readStream(): fs.ReadStream{ - return this._readingStream; - } - get isTun():boolean{ + get isTun(): boolean { return !this.isTap; } - get isUp():boolean{ + get isUp(): boolean { return this._isUp; } - set isUp(activate:boolean){ - if(activate){ + set isUp(activate: boolean) { + if (activate) { tuntapAddon.tuntapSetUp(this._ifName); } else { tuntapAddon.tuntapSetDown(this._ifName); @@ -79,10 +88,10 @@ class tuntap implements Tuntap { get mac(): string { this.makeSureIsUp(); const ifInfo = os.networkInterfaces(); - const mac: string = jsonpath.query( + const mac: string = jmespath.search( ifInfo, - `$.${this._ifName}[?(@.mac)].mac`, - )[0]; + `${this._ifName}[*].[mac]|[0]`, + ); return mac; } get mtu(): number { @@ -94,11 +103,10 @@ class tuntap implements Tuntap { get ipv4(): string { this.makeSureIsUp(); const ifInfo = os.networkInterfaces(); - - return jsonpath.query( + return jmespath.search( ifInfo, - `$.${this._ifName}[?(@.family=='IPv4')].cidr`, - )[0]; + `${this._ifName}[?family=='IPv4'].cidr|[0]`, + ); } set ipv4(ip: string) { const cirdArray = ip.split("/"); @@ -112,10 +120,10 @@ class tuntap implements Tuntap { get ipv6() { this.makeSureIsUp(); const ifInfo = os.networkInterfaces(); - return jsonpath.query( + return jmespath.search( ifInfo, - `$.${this._ifName}[?(@.family=='IPv6')].cidr`, - )[0]; + `${this._ifName}[?family=='IPv6'].cidr|[0]`, + ); } set ipv6(ip: string) { const cirdArray = ip.split("/"); @@ -127,23 +135,23 @@ class tuntap implements Tuntap { const ifIndex = tuntapAddon.tuntapGetIfIndex(this._ifName); tuntapAddon.tuntapSetIpv6(ifIndex, addr, prefix); } - public async release():Promise { + public async release() { this._readingStream.destroy(); - }; + } } class Tap extends tuntap { - constructor(){ + constructor() { super("tap"); } set mac(mac: string) { tuntapAddon.tuntapSetMac(this._ifName, mac); } - get mac():string{ + get mac(): string { return super.mac; } } class Tun extends tuntap { - constructor(){ + constructor() { super("tun"); } } diff --git a/tests/tap.js b/tests/tap.js index 09f43e7..2e1de4a 100644 --- a/tests/tap.js +++ b/tests/tap.js @@ -69,7 +69,7 @@ describe("mac address for tap",function(){ should.throws(()=>{mac = tap.mac},"should throw if dev doesn't up") tap.isUp = true; mac = tap.mac - should.equal(mac,"00:cd:ef:12:34:56", `mac address ${mac} doesn't equal to the address which we just set`); + should.equal(mac,"00:cd:ef:12:34:56", `mac address ${mac} doesn't equal to the address which we just set 00:cd:ef:12:34:56`); done(); }); after(function () { diff --git a/tests/tun.js b/tests/tun.js index 33b4978..0c9d9d0 100644 --- a/tests/tun.js +++ b/tests/tun.js @@ -2,6 +2,8 @@ const { Tap, Tun } = require(".."); const should = require("should"); const os = require("os"); const dgram = require("dgram"); +const jmespath = require('jmespath'); +const { type } = require("os"); describe("Test tun creating.", function () { it("should successfuly creating object", function (done) { const tun = new Tun(); @@ -175,7 +177,7 @@ describe("test send and receive packet", function () { before(function () { tun = new Tun(); tun.isUp = true; - tun.ipv4 = "4.3.2.1/24"; + tun.ipv4 = "4.3.2.0/24"; packet = Buffer.from([ 0x45, 0x02, 0x00, 0x54, 0x6e, 0x97, 0x00, 0x00, 0x40, 0x01, 0xf7, 0xf2, 0x0a, 0x01, 0x00, 0x13, 0x0a, 0x00, 0x00, 0x0a, 0x08, 0x00, @@ -195,7 +197,8 @@ describe("test send and receive packet", function () { it("receive packet", function (done) { tun.writePacket(packet, () => {}); tun.onReceive = (chunk) => { - console.log(`${tun.name} - Receiver: ${chunk.length} bytes`); + // console.log(`${tun.name} - Receiver: ${chunk.length} bytes`); + tun.onReceive = ()=>{}; done(); } socket.send("hello!", 43210, '4.3.2.1', (err) => {}); @@ -207,42 +210,51 @@ describe("test send and receive packet", function () { }); }); -describe("test send by tun and receive by node socket", function () { - let tun; +describe("test send by tun and receive by another tun", function () { + let tun1; + let tun2; let packet; - let listener; - this.timeout(20000); + this.timeout(2000); before(function () { - tun = new Tun(); - tun.isUp = true; - tun.ipv4 = "4.3.2.1/24"; + tun1 = new Tun(); + tun1.isUp = true; + tun1.ipv4 = "4.3.2.2/24\\"; + tun2 = new Tun(); + tun2.isUp = true; + tun2.ipv4 = "1.2.3.0/24"; // packet = Buffer.from([ // 0x45, 0x02, 0x00, 0x21, 0x6e, 0x97, 0x00, 0x00, 0x40, 0x11, 0x87, 0x2e, 0x04, 0x03, 0x02, 0x01, // 0x7f, 0x00, 0x00, 0x01, 0xe0, 0xb4, 0xa8, 0xca, 0x00, 0x0d, 0xfe, 0x20, 0x68, 0x65, 0x6c, 0x6c, // 0x6f // ]); packet = Buffer.from([ - 0x45, 0x00, 0x00, 0x22, 0xf6, 0x45, 0x40, 0x00, 0x40, 0x11, 0x38, 0x7e, 0x04, 0x03, 0x02, 0x01, - 0x04, 0x03, 0x02, 0x01, 0xc6, 0xef, 0xa8, 0xca, 0x00, 0x0e, 0x0c, 0x27, 0x68, 0x65, 0x6c, 0x6c, - 0x6f, 0x21 + 0x45, 0x00, 0x00, 0x22, 0xd5, 0xd1, 0x40, 0x00, 0x40, 0x11, 0x56, + 0xe0, 0x0a, 0x01, 0x00, 0x13, 0x01, 0x02, 0x03, 0x04, 0x98, 0x5d, + 0xa8, 0xca, 0x00, 0x0e, 0x0e, 0x39, 0x68, 0x65, 0x6c, 0x6c, 0x6f, + 0x21 ]); }); it("test message 'hello!' ", function (done) { - listener = dgram.createSocket("udp4", (msg, info) => { - console.log(msg.toString("utf8")); - done(); - }); - listener.bind({ - address:'0.0.0.0', - port: 43210 - }); - setTimeout(function(packet,tun){ - - tun.writePacket(packet, () => {}); - },100,packet,tun); + /* + must enable ipv4 forwarding in os + 1. iptables -L or iptables -P FORWARD ACCEPT + 2. sysctl net.ipv4.ip_forward=1 + */ + tun2.onReceive = (buf)=>{ + const isEqual = buf.reduce((perv, curr, index)=>{ + if(index>=packet.length)return false; + // console.log(`${curr},${packet[index]},index: ${index}`); + return (perv==1) && ((curr == packet[index]) + || index === 8 //skip TTL + || index === 10 || index === 11 //skip checksum + ); + },1); + if(isEqual)done(); + }; + tun1.writePacket(packet,()=>{}); }); after(function () { - tun.release(); - listener.close(); + tun1.release(); + tun2.release(); }); }); From cfb04a21a19a360505f043265c04d930c263b659 Mon Sep 17 00:00:00 2001 From: pupilTong Date: Fri, 11 Feb 2022 22:29:25 -0800 Subject: [PATCH 04/13] 0.0.0 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index f489e0d..901300d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "tuntap2", - "version": "0.0.1", + "version": "0.0.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "tuntap2", - "version": "0.0.1", + "version": "0.0.0", "hasInstallScript": true, "license": "Apache-2.0", "dependencies": { diff --git a/package.json b/package.json index 0c8d872..d346269 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tuntap2", - "version": "0.0.1", + "version": "0.0.0", "description": "", "main": "index.js", "types": "index.ts", From fd9b77a79c7c3bbee62718bdc03ac5c87b773721 Mon Sep 17 00:00:00 2001 From: pupilTong Date: Fri, 11 Feb 2022 22:34:11 -0800 Subject: [PATCH 05/13] add publich ci --- .github/workflows/npm-publish.yml | 34 +++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 .github/workflows/npm-publish.yml diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml new file mode 100644 index 0000000..d6ed953 --- /dev/null +++ b/.github/workflows/npm-publish.yml @@ -0,0 +1,34 @@ +# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created +# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages + +name: Node.js Package + +on: + release: + types: [published] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: 16 + - run: npm ci + - run: npm test + + publish-npm: + needs: build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: 16 + registry-url: https://registry.npmjs.org/ + - run: npm ci + - run: npm version ${{github.event.release.tag_name}} + - run: npm publish + env: + NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} \ No newline at end of file From f4c8e28a065eb9b6f07668ae3f320f3cbe075deb Mon Sep 17 00:00:00 2001 From: pupilTong Date: Fri, 11 Feb 2022 22:39:09 -0800 Subject: [PATCH 06/13] add demo in readme.md --- .gitignore | 3 +- demos/readme/index.js | 19 + demos/readme/package-lock.json | 1090 ++++++++++++++++++++++++++++++++ demos/readme/package.json | 15 + 4 files changed, 1125 insertions(+), 2 deletions(-) create mode 100644 demos/readme/index.js create mode 100644 demos/readme/package-lock.json create mode 100644 demos/readme/package.json diff --git a/.gitignore b/.gitignore index 73035df..af5f9f2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,5 @@ /build/ -/node_modules/ -dcdcd* +*node_modules* index.json .nyc_output /coverage diff --git a/demos/readme/index.js b/demos/readme/index.js new file mode 100644 index 0000000..b72b8b2 --- /dev/null +++ b/demos/readme/index.js @@ -0,0 +1,19 @@ +const {Tun, Tap} = require('tuntap2'); + +try { + const tun = new Tun(); + tun.mtu = 1400; + tun.ipv4 = '10.0.0.100/24'; + tun.ipv6 = 'abcd:1:2:3::/64'; + tun.onReceive = (buf) => { + console.log('received:', buf); + } + tun.isUp = true; + console.log(`created tun: ${tun.name}, ip: ${tun.ipv4}, ${tun.ipv6}, mtu: ${tun.mtu}`); + tun.release(); + +} +catch(e) { + console.log('error: ', e); + process.exit(0); +} \ No newline at end of file diff --git a/demos/readme/package-lock.json b/demos/readme/package-lock.json new file mode 100644 index 0000000..d544a28 --- /dev/null +++ b/demos/readme/package-lock.json @@ -0,0 +1,1090 @@ +{ + "name": "tuntap2-demo-readme", + "version": "1.0.0", + "lockfileVersion": 2, + "requires": true, + "packages": { + "": { + "name": "tuntap2-demo-readme", + "version": "1.0.0", + "license": "ISC", + "dependencies": { + "tuntap2": "^0.0.0" + } + }, + "node_modules/ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/aproba": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/aproba/-/aproba-1.2.0.tgz", + "integrity": "sha512-Y9J6ZjXtoYh8RnXVCMOU/ttDmk1aBjunq9vO0ta5x85WDQiQfUF9sIPBITdbiiIVcBo03Hi3jMxigBtsddlXRw==" + }, + "node_modules/are-we-there-yet": { + "version": "1.1.7", + "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-1.1.7.tgz", + "integrity": "sha512-nxwy40TuMiUGqMyRHgCSWZ9FM4VAoRP4xUYSTv5ImRog+h9yISPbVH7H8fASCIzYn9wlEv4zvFL7uKDMCFQm3g==", + "dependencies": { + "delegates": "^1.0.0", + "readable-stream": "^2.0.6" + } + }, + "node_modules/base64-js": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", + "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/bindings": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz", + "integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==", + "dependencies": { + "file-uri-to-path": "1.0.0" + } + }, + "node_modules/bl": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/bl/-/bl-4.1.0.tgz", + "integrity": "sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==", + "dependencies": { + "buffer": "^5.5.0", + "inherits": "^2.0.4", + "readable-stream": "^3.4.0" + } + }, + "node_modules/bl/node_modules/readable-stream": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", + "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", + "dependencies": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/buffer": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", + "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "dependencies": { + "base64-js": "^1.3.1", + "ieee754": "^1.1.13" + } + }, + "node_modules/chownr": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.4.tgz", + "integrity": "sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==" + }, + "node_modules/code-point-at": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", + "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/console-control-strings": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", + "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=" + }, + "node_modules/core-util-is": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", + "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==" + }, + "node_modules/decompress-response": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-6.0.0.tgz", + "integrity": "sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ==", + "dependencies": { + "mimic-response": "^3.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/deep-extend": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.6.0.tgz", + "integrity": "sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==", + "engines": { + "node": ">=4.0.0" + } + }, + "node_modules/delegates": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz", + "integrity": "sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o=" + }, + "node_modules/detect-libc": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.0.0.tgz", + "integrity": "sha512-S55LzUl8HUav8l9E2PBTlC5PAJrHK7tkM+XXFGD+fbsbkTzhCpG6K05LxJcUOEWzMa4v6ptcMZ9s3fOdJDu0Zw==", + "engines": { + "node": ">=8" + } + }, + "node_modules/end-of-stream": { + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz", + "integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==", + "dependencies": { + "once": "^1.4.0" + } + }, + "node_modules/expand-template": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/expand-template/-/expand-template-2.0.3.tgz", + "integrity": "sha512-XYfuKMvj4O35f/pOXLObndIRvyQ+/+6AhODh+OKWj9S9498pHHn/IMszH+gt0fBCRWMNfk1ZSp5x3AifmnI2vg==", + "engines": { + "node": ">=6" + } + }, + "node_modules/file-uri-to-path": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", + "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==" + }, + "node_modules/fs-constants": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz", + "integrity": "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==" + }, + "node_modules/gauge": { + "version": "2.7.4", + "resolved": "https://registry.npmjs.org/gauge/-/gauge-2.7.4.tgz", + "integrity": "sha1-LANAXHU4w51+s3sxcCLjJfsBi/c=", + "dependencies": { + "aproba": "^1.0.3", + "console-control-strings": "^1.0.0", + "has-unicode": "^2.0.0", + "object-assign": "^4.1.0", + "signal-exit": "^3.0.0", + "string-width": "^1.0.1", + "strip-ansi": "^3.0.1", + "wide-align": "^1.1.0" + } + }, + "node_modules/github-from-package": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/github-from-package/-/github-from-package-0.0.0.tgz", + "integrity": "sha1-l/tdlr/eiXMxPyDoKI75oWf6ZM4=" + }, + "node_modules/has-unicode": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/has-unicode/-/has-unicode-2.0.1.tgz", + "integrity": "sha1-4Ob+aijPUROIVeCG0Wkedx3iqLk=" + }, + "node_modules/ieee754": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", + "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", + "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/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + }, + "node_modules/ini": { + "version": "1.3.8", + "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.8.tgz", + "integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==" + }, + "node_modules/is-fullwidth-code-point": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", + "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", + "dependencies": { + "number-is-nan": "^1.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" + }, + "node_modules/jmespath": { + "version": "0.16.0", + "resolved": "https://registry.npmjs.org/jmespath/-/jmespath-0.16.0.tgz", + "integrity": "sha512-9FzQjJ7MATs1tSpnco1K6ayiYE3figslrXA72G2HQ/n76RzvYlofyi5QM+iX4YRs/pu3yzxlVQSST23+dMDknw==", + "engines": { + "node": ">= 0.6.0" + } + }, + "node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/mimic-response": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-3.1.0.tgz", + "integrity": "sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ==", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/minimist": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", + "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==" + }, + "node_modules/mkdirp-classic": { + "version": "0.5.3", + "resolved": "https://registry.npmjs.org/mkdirp-classic/-/mkdirp-classic-0.5.3.tgz", + "integrity": "sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==" + }, + "node_modules/napi-build-utils": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/napi-build-utils/-/napi-build-utils-1.0.2.tgz", + "integrity": "sha512-ONmRUqK7zj7DWX0D9ADe03wbwOBZxNAfF20PlGfCWQcD3+/MakShIHrMqx9YwPTfxDdF1zLeL+RGZiR9kGMLdg==" + }, + "node_modules/node-abi": { + "version": "3.8.0", + "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.8.0.tgz", + "integrity": "sha512-tzua9qWWi7iW4I42vUPKM+SfaF0vQSLAm4yO5J83mSwB7GeoWrDKC/K+8YCnYNwqP5duwazbw2X9l4m8SC2cUw==", + "dependencies": { + "semver": "^7.3.5" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/node-addon-api": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-4.3.0.tgz", + "integrity": "sha512-73sE9+3UaLYYFmDsFZnqCInzPyh3MqIwZO9cw58yIqAZhONrrabrYyYe3TuIqtIiOuTXVhsGau8hcrhhwSsDIQ==" + }, + "node_modules/npmlog": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-4.1.2.tgz", + "integrity": "sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg==", + "dependencies": { + "are-we-there-yet": "~1.1.2", + "console-control-strings": "~1.1.0", + "gauge": "~2.7.3", + "set-blocking": "~2.0.0" + } + }, + "node_modules/number-is-nan": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", + "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "dependencies": { + "wrappy": "1" + } + }, + "node_modules/prebuild-install": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/prebuild-install/-/prebuild-install-7.0.1.tgz", + "integrity": "sha512-QBSab31WqkyxpnMWQxubYAHR5S9B2+r81ucocew34Fkl98FhvKIF50jIJnNOBmAZfyNV7vE5T6gd3hTVWgY6tg==", + "dependencies": { + "detect-libc": "^2.0.0", + "expand-template": "^2.0.3", + "github-from-package": "0.0.0", + "minimist": "^1.2.3", + "mkdirp-classic": "^0.5.3", + "napi-build-utils": "^1.0.1", + "node-abi": "^3.3.0", + "npmlog": "^4.0.1", + "pump": "^3.0.0", + "rc": "^1.2.7", + "simple-get": "^4.0.0", + "tar-fs": "^2.0.0", + "tunnel-agent": "^0.6.0" + }, + "bin": { + "prebuild-install": "bin.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/process-nextick-args": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", + "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==" + }, + "node_modules/pump": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", + "integrity": "sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==", + "dependencies": { + "end-of-stream": "^1.1.0", + "once": "^1.3.1" + } + }, + "node_modules/rc": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/rc/-/rc-1.2.8.tgz", + "integrity": "sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==", + "dependencies": { + "deep-extend": "^0.6.0", + "ini": "~1.3.0", + "minimist": "^1.2.0", + "strip-json-comments": "~2.0.1" + }, + "bin": { + "rc": "cli.js" + } + }, + "node_modules/readable-stream": { + "version": "2.3.7", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", + "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", + "dependencies": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "node_modules/safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + }, + "node_modules/semver": { + "version": "7.3.5", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", + "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==", + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/set-blocking": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", + "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=" + }, + "node_modules/signal-exit": { + "version": "3.0.7", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", + "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==" + }, + "node_modules/simple-concat": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/simple-concat/-/simple-concat-1.0.1.tgz", + "integrity": "sha512-cSFtAPtRhljv69IK0hTVZQ+OfE9nePi/rtJmw5UjHeVyVroEqJXP1sFztKUy1qU+xvz3u/sfYJLa947b7nAN2Q==", + "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/simple-get": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/simple-get/-/simple-get-4.0.1.tgz", + "integrity": "sha512-brv7p5WgH0jmQJr1ZDDfKDOSeWWg+OVypG99A/5vYGPqJ6pxiaHLy8nxtFjBA7oMa01ebA9gfh1uMCFqOuXxvA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "dependencies": { + "decompress-response": "^6.0.0", + "once": "^1.3.1", + "simple-concat": "^1.0.0" + } + }, + "node_modules/string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "dependencies": { + "safe-buffer": "~5.1.0" + } + }, + "node_modules/string-width": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", + "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", + "dependencies": { + "code-point-at": "^1.0.0", + "is-fullwidth-code-point": "^1.0.0", + "strip-ansi": "^3.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/strip-ansi": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "dependencies": { + "ansi-regex": "^2.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/strip-json-comments": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", + "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/tar-fs": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-2.1.1.tgz", + "integrity": "sha512-V0r2Y9scmbDRLCNex/+hYzvp/zyYjvFbHPNgVTKfQvVrb6guiE/fxP+XblDNR011utopbkex2nM4dHNV6GDsng==", + "dependencies": { + "chownr": "^1.1.1", + "mkdirp-classic": "^0.5.2", + "pump": "^3.0.0", + "tar-stream": "^2.1.4" + } + }, + "node_modules/tar-stream": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-2.2.0.tgz", + "integrity": "sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ==", + "dependencies": { + "bl": "^4.0.3", + "end-of-stream": "^1.4.1", + "fs-constants": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^3.1.1" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/tar-stream/node_modules/readable-stream": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", + "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", + "dependencies": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/tunnel-agent": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", + "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", + "dependencies": { + "safe-buffer": "^5.0.1" + }, + "engines": { + "node": "*" + } + }, + "node_modules/tuntap2": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/tuntap2/-/tuntap2-0.0.0.tgz", + "integrity": "sha512-YibtOVhJsJAjgvaJ184Pe/J+/it/b9FK436P5gAgokQjTxB6g/fWFu8SDVuP/ukuDzn8qCbtwhGn7Y0TjtSwag==", + "hasInstallScript": true, + "dependencies": { + "bindings": "^1.5.0", + "jmespath": "^0.16.0", + "node-addon-api": "^4.0.0", + "prebuild-install": "^7.0.0" + } + }, + "node_modules/util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" + }, + "node_modules/wide-align": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.5.tgz", + "integrity": "sha512-eDMORYaPNZ4sQIuuYPDHdQvf4gyCF9rEEV/yPxGfwPkRodwEgiMUUXTx/dex+Me0wxx53S+NgUHaP7y3MGlDmg==", + "dependencies": { + "string-width": "^1.0.2 || 2 || 3 || 4" + } + }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" + }, + "node_modules/yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" + } + }, + "dependencies": { + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=" + }, + "aproba": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/aproba/-/aproba-1.2.0.tgz", + "integrity": "sha512-Y9J6ZjXtoYh8RnXVCMOU/ttDmk1aBjunq9vO0ta5x85WDQiQfUF9sIPBITdbiiIVcBo03Hi3jMxigBtsddlXRw==" + }, + "are-we-there-yet": { + "version": "1.1.7", + "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-1.1.7.tgz", + "integrity": "sha512-nxwy40TuMiUGqMyRHgCSWZ9FM4VAoRP4xUYSTv5ImRog+h9yISPbVH7H8fASCIzYn9wlEv4zvFL7uKDMCFQm3g==", + "requires": { + "delegates": "^1.0.0", + "readable-stream": "^2.0.6" + } + }, + "base64-js": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==" + }, + "bindings": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz", + "integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==", + "requires": { + "file-uri-to-path": "1.0.0" + } + }, + "bl": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/bl/-/bl-4.1.0.tgz", + "integrity": "sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==", + "requires": { + "buffer": "^5.5.0", + "inherits": "^2.0.4", + "readable-stream": "^3.4.0" + }, + "dependencies": { + "readable-stream": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", + "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", + "requires": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + } + } + } + }, + "buffer": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", + "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==", + "requires": { + "base64-js": "^1.3.1", + "ieee754": "^1.1.13" + } + }, + "chownr": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.4.tgz", + "integrity": "sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==" + }, + "code-point-at": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", + "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=" + }, + "console-control-strings": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", + "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=" + }, + "core-util-is": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", + "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==" + }, + "decompress-response": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-6.0.0.tgz", + "integrity": "sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ==", + "requires": { + "mimic-response": "^3.1.0" + } + }, + "deep-extend": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.6.0.tgz", + "integrity": "sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==" + }, + "delegates": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz", + "integrity": "sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o=" + }, + "detect-libc": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.0.0.tgz", + "integrity": "sha512-S55LzUl8HUav8l9E2PBTlC5PAJrHK7tkM+XXFGD+fbsbkTzhCpG6K05LxJcUOEWzMa4v6ptcMZ9s3fOdJDu0Zw==" + }, + "end-of-stream": { + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz", + "integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==", + "requires": { + "once": "^1.4.0" + } + }, + "expand-template": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/expand-template/-/expand-template-2.0.3.tgz", + "integrity": "sha512-XYfuKMvj4O35f/pOXLObndIRvyQ+/+6AhODh+OKWj9S9498pHHn/IMszH+gt0fBCRWMNfk1ZSp5x3AifmnI2vg==" + }, + "file-uri-to-path": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", + "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==" + }, + "fs-constants": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz", + "integrity": "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==" + }, + "gauge": { + "version": "2.7.4", + "resolved": "https://registry.npmjs.org/gauge/-/gauge-2.7.4.tgz", + "integrity": "sha1-LANAXHU4w51+s3sxcCLjJfsBi/c=", + "requires": { + "aproba": "^1.0.3", + "console-control-strings": "^1.0.0", + "has-unicode": "^2.0.0", + "object-assign": "^4.1.0", + "signal-exit": "^3.0.0", + "string-width": "^1.0.1", + "strip-ansi": "^3.0.1", + "wide-align": "^1.1.0" + } + }, + "github-from-package": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/github-from-package/-/github-from-package-0.0.0.tgz", + "integrity": "sha1-l/tdlr/eiXMxPyDoKI75oWf6ZM4=" + }, + "has-unicode": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/has-unicode/-/has-unicode-2.0.1.tgz", + "integrity": "sha1-4Ob+aijPUROIVeCG0Wkedx3iqLk=" + }, + "ieee754": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", + "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==" + }, + "inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + }, + "ini": { + "version": "1.3.8", + "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.8.tgz", + "integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==" + }, + "is-fullwidth-code-point": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", + "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", + "requires": { + "number-is-nan": "^1.0.0" + } + }, + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" + }, + "jmespath": { + "version": "0.16.0", + "resolved": "https://registry.npmjs.org/jmespath/-/jmespath-0.16.0.tgz", + "integrity": "sha512-9FzQjJ7MATs1tSpnco1K6ayiYE3figslrXA72G2HQ/n76RzvYlofyi5QM+iX4YRs/pu3yzxlVQSST23+dMDknw==" + }, + "lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "requires": { + "yallist": "^4.0.0" + } + }, + "mimic-response": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-3.1.0.tgz", + "integrity": "sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ==" + }, + "minimist": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", + "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==" + }, + "mkdirp-classic": { + "version": "0.5.3", + "resolved": "https://registry.npmjs.org/mkdirp-classic/-/mkdirp-classic-0.5.3.tgz", + "integrity": "sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==" + }, + "napi-build-utils": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/napi-build-utils/-/napi-build-utils-1.0.2.tgz", + "integrity": "sha512-ONmRUqK7zj7DWX0D9ADe03wbwOBZxNAfF20PlGfCWQcD3+/MakShIHrMqx9YwPTfxDdF1zLeL+RGZiR9kGMLdg==" + }, + "node-abi": { + "version": "3.8.0", + "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.8.0.tgz", + "integrity": "sha512-tzua9qWWi7iW4I42vUPKM+SfaF0vQSLAm4yO5J83mSwB7GeoWrDKC/K+8YCnYNwqP5duwazbw2X9l4m8SC2cUw==", + "requires": { + "semver": "^7.3.5" + } + }, + "node-addon-api": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-4.3.0.tgz", + "integrity": "sha512-73sE9+3UaLYYFmDsFZnqCInzPyh3MqIwZO9cw58yIqAZhONrrabrYyYe3TuIqtIiOuTXVhsGau8hcrhhwSsDIQ==" + }, + "npmlog": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-4.1.2.tgz", + "integrity": "sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg==", + "requires": { + "are-we-there-yet": "~1.1.2", + "console-control-strings": "~1.1.0", + "gauge": "~2.7.3", + "set-blocking": "~2.0.0" + } + }, + "number-is-nan": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", + "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=" + }, + "object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=" + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "requires": { + "wrappy": "1" + } + }, + "prebuild-install": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/prebuild-install/-/prebuild-install-7.0.1.tgz", + "integrity": "sha512-QBSab31WqkyxpnMWQxubYAHR5S9B2+r81ucocew34Fkl98FhvKIF50jIJnNOBmAZfyNV7vE5T6gd3hTVWgY6tg==", + "requires": { + "detect-libc": "^2.0.0", + "expand-template": "^2.0.3", + "github-from-package": "0.0.0", + "minimist": "^1.2.3", + "mkdirp-classic": "^0.5.3", + "napi-build-utils": "^1.0.1", + "node-abi": "^3.3.0", + "npmlog": "^4.0.1", + "pump": "^3.0.0", + "rc": "^1.2.7", + "simple-get": "^4.0.0", + "tar-fs": "^2.0.0", + "tunnel-agent": "^0.6.0" + } + }, + "process-nextick-args": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", + "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==" + }, + "pump": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", + "integrity": "sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==", + "requires": { + "end-of-stream": "^1.1.0", + "once": "^1.3.1" + } + }, + "rc": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/rc/-/rc-1.2.8.tgz", + "integrity": "sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==", + "requires": { + "deep-extend": "^0.6.0", + "ini": "~1.3.0", + "minimist": "^1.2.0", + "strip-json-comments": "~2.0.1" + } + }, + "readable-stream": { + "version": "2.3.7", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", + "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + }, + "semver": { + "version": "7.3.5", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", + "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==", + "requires": { + "lru-cache": "^6.0.0" + } + }, + "set-blocking": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", + "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=" + }, + "signal-exit": { + "version": "3.0.7", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", + "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==" + }, + "simple-concat": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/simple-concat/-/simple-concat-1.0.1.tgz", + "integrity": "sha512-cSFtAPtRhljv69IK0hTVZQ+OfE9nePi/rtJmw5UjHeVyVroEqJXP1sFztKUy1qU+xvz3u/sfYJLa947b7nAN2Q==" + }, + "simple-get": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/simple-get/-/simple-get-4.0.1.tgz", + "integrity": "sha512-brv7p5WgH0jmQJr1ZDDfKDOSeWWg+OVypG99A/5vYGPqJ6pxiaHLy8nxtFjBA7oMa01ebA9gfh1uMCFqOuXxvA==", + "requires": { + "decompress-response": "^6.0.0", + "once": "^1.3.1", + "simple-concat": "^1.0.0" + } + }, + "string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "requires": { + "safe-buffer": "~5.1.0" + } + }, + "string-width": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", + "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", + "requires": { + "code-point-at": "^1.0.0", + "is-fullwidth-code-point": "^1.0.0", + "strip-ansi": "^3.0.0" + } + }, + "strip-ansi": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "requires": { + "ansi-regex": "^2.0.0" + } + }, + "strip-json-comments": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", + "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=" + }, + "tar-fs": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-2.1.1.tgz", + "integrity": "sha512-V0r2Y9scmbDRLCNex/+hYzvp/zyYjvFbHPNgVTKfQvVrb6guiE/fxP+XblDNR011utopbkex2nM4dHNV6GDsng==", + "requires": { + "chownr": "^1.1.1", + "mkdirp-classic": "^0.5.2", + "pump": "^3.0.0", + "tar-stream": "^2.1.4" + } + }, + "tar-stream": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-2.2.0.tgz", + "integrity": "sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ==", + "requires": { + "bl": "^4.0.3", + "end-of-stream": "^1.4.1", + "fs-constants": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^3.1.1" + }, + "dependencies": { + "readable-stream": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", + "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", + "requires": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + } + } + } + }, + "tunnel-agent": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", + "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", + "requires": { + "safe-buffer": "^5.0.1" + } + }, + "tuntap2": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/tuntap2/-/tuntap2-0.0.0.tgz", + "integrity": "sha512-YibtOVhJsJAjgvaJ184Pe/J+/it/b9FK436P5gAgokQjTxB6g/fWFu8SDVuP/ukuDzn8qCbtwhGn7Y0TjtSwag==", + "requires": { + "bindings": "^1.5.0", + "jmespath": "^0.16.0", + "node-addon-api": "^4.0.0", + "prebuild-install": "^7.0.0" + } + }, + "util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" + }, + "wide-align": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.5.tgz", + "integrity": "sha512-eDMORYaPNZ4sQIuuYPDHdQvf4gyCF9rEEV/yPxGfwPkRodwEgiMUUXTx/dex+Me0wxx53S+NgUHaP7y3MGlDmg==", + "requires": { + "string-width": "^1.0.2 || 2 || 3 || 4" + } + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" + }, + "yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" + } + } +} diff --git a/demos/readme/package.json b/demos/readme/package.json new file mode 100644 index 0000000..666dfa5 --- /dev/null +++ b/demos/readme/package.json @@ -0,0 +1,15 @@ +{ + "name": "tuntap2-demo-readme", + "version": "1.0.0", + "description": "demo", + "main": "index.js", + "scripts": { + "run" :"sudo node index.js", + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "", + "license": "ISC", + "dependencies": { + "tuntap2": "^0.0.0" + } +} From 9b3c15aef953c7b6ae5c079ea322758eef8c9fce Mon Sep 17 00:00:00 2001 From: pupilTong Date: Fri, 11 Feb 2022 22:43:37 -0800 Subject: [PATCH 07/13] add contribute info --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 21e0142..06785df 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,12 @@ catch(e) { The writing and reading of tuntap is based on nodejs `fs` and `readingStream`. This means these methods is running on libuv threads pool. Please set the threads pool size properly for your application. +## Contribute + +Please feel free to create issues, Prs and tell me your ideas! + +**I REALLY APPRECIATE IT** + ## TODO * [ ] make it compatible with `node-tuntap` From d87be00c039a397a7823467e6efc8412e37e4ede Mon Sep 17 00:00:00 2001 From: pupilTong Date: Fri, 11 Feb 2022 22:51:00 -0800 Subject: [PATCH 08/13] ignor string truncation warning --- binding.gyp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/binding.gyp b/binding.gyp index a8440bb..05690be 100644 --- a/binding.gyp +++ b/binding.gyp @@ -6,10 +6,12 @@ "src/cpp/tuntap-napi.cpp", "src/cpp/tuntap-linux.cpp" ], - 'cflags!': [ '-fno-exceptions', '--std=c++17' ], - 'cflags_cc!': [ '-fno-exceptions' ], + 'cflags!': [ '-fno-exceptions', '--std=c++17', '-Wno-stringop-truncation' ], + 'cflags_cc!': [ '-fno-exceptions', '--std=c++17', '-Wno-stringop-truncation' ], "cflags+": [ - "-fvisibility=hidden" + "-fvisibility=hidden", + '--std=c++17', + '-Wno-stringop-truncation' ], "include_dirs": [ " Date: Fri, 11 Feb 2022 22:57:19 -0800 Subject: [PATCH 09/13] install mocha via root in github actions. --- .github/workflows/node.js.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index 853ebfb..d577173 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -26,8 +26,8 @@ jobs: with: node-version: ${{ matrix.node-version }} cache: 'npm' - - run: npm install -g nyc - - run: npm install -g mocha + # - run: sudo npm install -g nyc + - run: sudo npm install -g mocha - run: npm ci - run: npm run build --if-present - run: npm test From 533757266c785aa20ff6e9d5c81e0b3689fa88f9 Mon Sep 17 00:00:00 2001 From: pupilTong Date: Fri, 11 Feb 2022 22:59:15 -0800 Subject: [PATCH 10/13] enable ipv4 forwaring in github actions --- .github/workflows/node.js.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index d577173..87150cf 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -30,4 +30,5 @@ jobs: - run: sudo npm install -g mocha - run: npm ci - run: npm run build --if-present + - run: sudo sysctl net.ipv4.ip_forward=1 - run: npm test From fea76f57765310a636499f2d5d490ab82369787e Mon Sep 17 00:00:00 2001 From: pupilTong Date: Fri, 11 Feb 2022 23:01:23 -0800 Subject: [PATCH 11/13] allow iptables forwaring --- .github/workflows/node.js.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index 87150cf..0fd2a80 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -30,5 +30,6 @@ jobs: - run: sudo npm install -g mocha - run: npm ci - run: npm run build --if-present + - run: sudo iptables -L or iptables -P FORWARD ACCEPT - run: sudo sysctl net.ipv4.ip_forward=1 - run: npm test From e6e2bed9298f4c1e14ab788b16844618cc06c543 Mon Sep 17 00:00:00 2001 From: PupilTong <12288479+PupilTong@users.noreply.github.com> Date: Sat, 12 Feb 2022 15:16:39 +0800 Subject: [PATCH 12/13] Update node.js.yml --- .github/workflows/node.js.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index 0fd2a80..ad07029 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -30,6 +30,6 @@ jobs: - run: sudo npm install -g mocha - run: npm ci - run: npm run build --if-present - - run: sudo iptables -L or iptables -P FORWARD ACCEPT + - run: sudo iptables -P FORWARD ACCEPT - run: sudo sysctl net.ipv4.ip_forward=1 - run: npm test From abf5c7e914283115517d8230f6401885820538ef Mon Sep 17 00:00:00 2001 From: PupilTong <12288479+PupilTong@users.noreply.github.com> Date: Sat, 12 Feb 2022 15:20:54 +0800 Subject: [PATCH 13/13] Update npm-publish.yml --- .github/workflows/npm-publish.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml index d6ed953..2a59d98 100644 --- a/.github/workflows/npm-publish.yml +++ b/.github/workflows/npm-publish.yml @@ -16,7 +16,7 @@ jobs: with: node-version: 16 - run: npm ci - - run: npm test +# - run: sudo npm test publish-npm: needs: build @@ -31,4 +31,4 @@ jobs: - run: npm version ${{github.event.release.tag_name}} - run: npm publish env: - NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} \ No newline at end of file + NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}