From 0fbfb7a5647574252980d07e91f66322f6e8557d Mon Sep 17 00:00:00 2001 From: Ivan Antunes Date: Mon, 8 Jan 2024 10:19:36 -0300 Subject: [PATCH] first commit --- lib/exception/FreGenericException.d.ts | 6 ++ lib/exception/FreGenericException.js | 1 + lib/exception/index.d.ts | 1 + lib/exception/index.js | 1 + lib/index.d.ts | 4 ++ lib/index.js | 1 + lib/ip_filter/IpDeniedError.d.ts | 6 ++ lib/ip_filter/IpDeniedError.js | 1 + lib/ip_filter/IpFilter.d.ts | 24 +++++++ lib/ip_filter/IpFilter.js | 1 + lib/ip_filter/IpTypes.d.ts | 27 ++++++++ lib/ip_filter/IpTypes.js | 1 + lib/ip_filter/index.d.ts | 3 + lib/ip_filter/index.js | 1 + lib/utils/byte.d.ts | 65 +++++++++++++++++ lib/utils/byte.js | 1 + lib/utils/rotines.d.ts | 96 ++++++++++++++++++++++++++ lib/utils/rotines.js | 1 + package.json | 80 +++++++++++++++++++++ 19 files changed, 321 insertions(+) create mode 100644 lib/exception/FreGenericException.d.ts create mode 100644 lib/exception/FreGenericException.js create mode 100644 lib/exception/index.d.ts create mode 100644 lib/exception/index.js create mode 100644 lib/index.d.ts create mode 100644 lib/index.js create mode 100644 lib/ip_filter/IpDeniedError.d.ts create mode 100644 lib/ip_filter/IpDeniedError.js create mode 100644 lib/ip_filter/IpFilter.d.ts create mode 100644 lib/ip_filter/IpFilter.js create mode 100644 lib/ip_filter/IpTypes.d.ts create mode 100644 lib/ip_filter/IpTypes.js create mode 100644 lib/ip_filter/index.d.ts create mode 100644 lib/ip_filter/index.js create mode 100644 lib/utils/byte.d.ts create mode 100644 lib/utils/byte.js create mode 100644 lib/utils/rotines.d.ts create mode 100644 lib/utils/rotines.js create mode 100644 package.json diff --git a/lib/exception/FreGenericException.d.ts b/lib/exception/FreGenericException.d.ts new file mode 100644 index 0000000..8bd404e --- /dev/null +++ b/lib/exception/FreGenericException.d.ts @@ -0,0 +1,6 @@ +export declare class FreGenericException extends Error { + statusCode: number; + status: number; + extra?: any; + constructor(statusCode: number, message?: string | undefined, extra?: any); +} diff --git a/lib/exception/FreGenericException.js b/lib/exception/FreGenericException.js new file mode 100644 index 0000000..725a8db --- /dev/null +++ b/lib/exception/FreGenericException.js @@ -0,0 +1 @@ +'use strict';var a0_0x1ba129=a0_0x2f93;function a0_0x2f93(_0x465956,_0x481f49){var _0x10813d=a0_0x1081();return a0_0x2f93=function(_0x2f938b,_0x160dac){_0x2f938b=_0x2f938b-0xb1;var _0x76f29a=_0x10813d[_0x2f938b];return _0x76f29a;},a0_0x2f93(_0x465956,_0x481f49);}function a0_0x1081(){var _0x4c248d=['__esModule','2202938VguBQb','Exception','3099306CYzyji','extra','name','2713045qUaQZy','statusCode','2798796ekaWmh','20847jUuAkJ','3648804BGFkSO','16350712douWso','message','status','constructor','defineProperty','FreGenericException'];a0_0x1081=function(){return _0x4c248d;};return a0_0x1081();}(function(_0x31af86,_0x1e4a3d){var _0x29d495=a0_0x2f93,_0x2fccf5=_0x31af86();while(!![]){try{var _0x1ca2e5=parseInt(_0x29d495(0xbd))/0x1+parseInt(_0x29d495(0xb5))/0x2+parseInt(_0x29d495(0xb7))/0x3+parseInt(_0x29d495(0xbe))/0x4+-parseInt(_0x29d495(0xba))/0x5+parseInt(_0x29d495(0xbc))/0x6+-parseInt(_0x29d495(0xbf))/0x7;if(_0x1ca2e5===_0x1e4a3d)break;else _0x2fccf5['push'](_0x2fccf5['shift']());}catch(_0x251c9c){_0x2fccf5['push'](_0x2fccf5['shift']());}}}(a0_0x1081,0xa012c));Object[a0_0x1ba129(0xb2)](exports,a0_0x1ba129(0xb4),{'value':!![]}),exports[a0_0x1ba129(0xb3)]=void 0x0;class FreGenericException extends Error{[a0_0x1ba129(0xbb)];['status'];['extra'];constructor(_0x1c96fd,_0x5a2543,_0x21e319){var _0x149324=a0_0x1ba129;_0x5a2543=_0x5a2543??_0x149324(0xb6),super(_0x5a2543),this[_0x149324(0xc0)]=_0x5a2543,this[_0x149324(0xb9)]=this[_0x149324(0xb1)][_0x149324(0xb9)],Error['captureStackTrace'](this,this[_0x149324(0xb1)]),this[_0x149324(0xb8)]=_0x21e319,this[_0x149324(0xc1)]=this[_0x149324(0xbb)]=_0x1c96fd;}}exports[a0_0x1ba129(0xb3)]=FreGenericException; \ No newline at end of file diff --git a/lib/exception/index.d.ts b/lib/exception/index.d.ts new file mode 100644 index 0000000..f7d4a5f --- /dev/null +++ b/lib/exception/index.d.ts @@ -0,0 +1 @@ +export * from './FreGenericException'; diff --git a/lib/exception/index.js b/lib/exception/index.js new file mode 100644 index 0000000..49eb3b6 --- /dev/null +++ b/lib/exception/index.js @@ -0,0 +1 @@ +'use strict';var a1_0x5c596a=a1_0x5990;(function(_0x2ddfe9,_0x472e7e){var _0x286601=a1_0x5990,_0x43fc2e=_0x2ddfe9();while(!![]){try{var _0x2d1d5a=-parseInt(_0x286601(0x10d))/0x1+-parseInt(_0x286601(0xfd))/0x2+-parseInt(_0x286601(0xfc))/0x3+-parseInt(_0x286601(0x10c))/0x4+parseInt(_0x286601(0xff))/0x5+-parseInt(_0x286601(0x102))/0x6+parseInt(_0x286601(0x109))/0x7;if(_0x2d1d5a===_0x472e7e)break;else _0x43fc2e['push'](_0x43fc2e['shift']());}catch(_0x4aa805){_0x43fc2e['push'](_0x43fc2e['shift']());}}}(a1_0x17a2,0x6fce5));function a1_0x5990(_0x3f766e,_0x24fc72){var _0x17a2bb=a1_0x17a2();return a1_0x5990=function(_0x599063,_0x482804){_0x599063=_0x599063-0xfc;var _0x3457bd=_0x17a2bb[_0x599063];return _0x3457bd;},a1_0x5990(_0x3f766e,_0x24fc72);}var __createBinding=this&&this['__createBinding']||(Object[a1_0x5c596a(0x10a)]?function(_0x134263,_0x5c7691,_0x326342,_0x1219f9){var _0x488928=a1_0x5c596a;if(_0x1219f9===undefined)_0x1219f9=_0x326342;var _0x2deea9=Object[_0x488928(0x106)](_0x5c7691,_0x326342);(!_0x2deea9||('get'in _0x2deea9?!_0x5c7691[_0x488928(0x104)]:_0x2deea9[_0x488928(0x108)]||_0x2deea9[_0x488928(0x103)]))&&(_0x2deea9={'enumerable':!![],'get':function(){return _0x5c7691[_0x326342];}}),Object[_0x488928(0xfe)](_0x134263,_0x1219f9,_0x2deea9);}:function(_0x212ce0,_0x2f6d54,_0x3ad032,_0x48431f){if(_0x48431f===undefined)_0x48431f=_0x3ad032;_0x212ce0[_0x48431f]=_0x2f6d54[_0x3ad032];}),__exportStar=this&&this[a1_0x5c596a(0x107)]||function(_0x284ab8,_0x1dd1b9){var _0x1cfc6f=a1_0x5c596a;for(var _0x23abf8 in _0x284ab8)if(_0x23abf8!==_0x1cfc6f(0x100)&&!Object[_0x1cfc6f(0x10e)][_0x1cfc6f(0x101)][_0x1cfc6f(0x10b)](_0x1dd1b9,_0x23abf8))__createBinding(_0x1dd1b9,_0x284ab8,_0x23abf8);};Object[a1_0x5c596a(0xfe)](exports,a1_0x5c596a(0x104),{'value':!![]}),__exportStar(require(a1_0x5c596a(0x105)),exports);function a1_0x17a2(){var _0x4611f4=['call','1244220pmqDJT','359917RwzlUg','prototype','919929JDmiUG','642012dRbdot','defineProperty','2835345TPHDin','default','hasOwnProperty','3294096suzyID','configurable','__esModule','./FreGenericException','getOwnPropertyDescriptor','__exportStar','writable','12169675xFvqaQ','create'];a1_0x17a2=function(){return _0x4611f4;};return a1_0x17a2();} \ No newline at end of file diff --git a/lib/index.d.ts b/lib/index.d.ts new file mode 100644 index 0000000..8e275e7 --- /dev/null +++ b/lib/index.d.ts @@ -0,0 +1,4 @@ +export * from './utils/rotines'; +export * from './utils/byte'; +export * from './ip_filter'; +export * from './exception'; diff --git a/lib/index.js b/lib/index.js new file mode 100644 index 0000000..4986a7d --- /dev/null +++ b/lib/index.js @@ -0,0 +1 @@ +'use strict';function a2_0x25d4(){var _0x44508e=['prototype','32rzSChL','289908eCmQou','__exportStar','getOwnPropertyDescriptor','172rFsmHR','call','__createBinding','defineProperty','hasOwnProperty','./ip_filter','./utils/rotines','__esModule','19113IzxMRI','1337861CflEQy','915422HOwSLa','./utils/byte','create','get','13929620puiCpK','12wqvVvH','default','configurable','221034notCim','1583065jitWTJ'];a2_0x25d4=function(){return _0x44508e;};return a2_0x25d4();}var a2_0x16a7fb=a2_0x3a4b;(function(_0x1f7c3d,_0x4eb3f5){var _0x4f5488=a2_0x3a4b,_0x1ede06=_0x1f7c3d();while(!![]){try{var _0x8c62ff=-parseInt(_0x4f5488(0x152))/0x1+-parseInt(_0x4f5488(0x14a))/0x2+-parseInt(_0x4f5488(0x148))/0x3*(parseInt(_0x4f5488(0x159))/0x4)+parseInt(_0x4f5488(0x153))/0x5+parseInt(_0x4f5488(0x14f))/0x6*(-parseInt(_0x4f5488(0x149))/0x7)+-parseInt(_0x4f5488(0x155))/0x8*(parseInt(_0x4f5488(0x156))/0x9)+parseInt(_0x4f5488(0x14e))/0xa;if(_0x8c62ff===_0x4eb3f5)break;else _0x1ede06['push'](_0x1ede06['shift']());}catch(_0xf310f7){_0x1ede06['push'](_0x1ede06['shift']());}}}(a2_0x25d4,0x3c017));var __createBinding=this&&this[a2_0x16a7fb(0x15b)]||(Object[a2_0x16a7fb(0x14c)]?function(_0x227fd7,_0x53735f,_0xd06f3,_0x30da69){var _0x3f39ef=a2_0x16a7fb;if(_0x30da69===undefined)_0x30da69=_0xd06f3;var _0x553c16=Object[_0x3f39ef(0x158)](_0x53735f,_0xd06f3);(!_0x553c16||(_0x3f39ef(0x14d)in _0x553c16?!_0x53735f[_0x3f39ef(0x160)]:_0x553c16['writable']||_0x553c16[_0x3f39ef(0x151)]))&&(_0x553c16={'enumerable':!![],'get':function(){return _0x53735f[_0xd06f3];}}),Object['defineProperty'](_0x227fd7,_0x30da69,_0x553c16);}:function(_0x1099be,_0x4b6e51,_0x336b30,_0x21414a){if(_0x21414a===undefined)_0x21414a=_0x336b30;_0x1099be[_0x21414a]=_0x4b6e51[_0x336b30];}),__exportStar=this&&this[a2_0x16a7fb(0x157)]||function(_0x4d4ca6,_0x4622da){var _0x40d3ee=a2_0x16a7fb;for(var _0x1c265e in _0x4d4ca6)if(_0x1c265e!==_0x40d3ee(0x150)&&!Object[_0x40d3ee(0x154)][_0x40d3ee(0x15d)][_0x40d3ee(0x15a)](_0x4622da,_0x1c265e))__createBinding(_0x4622da,_0x4d4ca6,_0x1c265e);};function a2_0x3a4b(_0x2c1cbf,_0x38c923){var _0x25d456=a2_0x25d4();return a2_0x3a4b=function(_0x3a4b26,_0x492e51){_0x3a4b26=_0x3a4b26-0x148;var _0x5c5dca=_0x25d456[_0x3a4b26];return _0x5c5dca;},a2_0x3a4b(_0x2c1cbf,_0x38c923);}Object[a2_0x16a7fb(0x15c)](exports,a2_0x16a7fb(0x160),{'value':!![]}),__exportStar(require(a2_0x16a7fb(0x15f)),exports),__exportStar(require(a2_0x16a7fb(0x14b)),exports),__exportStar(require(a2_0x16a7fb(0x15e)),exports),__exportStar(require('./exception'),exports); \ No newline at end of file diff --git a/lib/ip_filter/IpDeniedError.d.ts b/lib/ip_filter/IpDeniedError.d.ts new file mode 100644 index 0000000..4e1cbdc --- /dev/null +++ b/lib/ip_filter/IpDeniedError.d.ts @@ -0,0 +1,6 @@ +export declare class IpDeniedError extends Error { + statusCode: number; + status: number; + extra?: any; + constructor(message?: string | undefined, extra?: any); +} diff --git a/lib/ip_filter/IpDeniedError.js b/lib/ip_filter/IpDeniedError.js new file mode 100644 index 0000000..c93b971 --- /dev/null +++ b/lib/ip_filter/IpDeniedError.js @@ -0,0 +1 @@ +'use strict';var a3_0x2f1406=a3_0x173f;function a3_0x173f(_0x5a53cb,_0x290ff3){var _0x1f6a92=a3_0x1f6a();return a3_0x173f=function(_0x173ff2,_0x2a5523){_0x173ff2=_0x173ff2-0x9b;var _0x9f69b=_0x1f6a92[_0x173ff2];return _0x9f69b;},a3_0x173f(_0x5a53cb,_0x290ff3);}(function(_0x3dc8a3,_0x4669dd){var _0x2a84e1=a3_0x173f,_0x4404f6=_0x3dc8a3();while(!![]){try{var _0x525b03=-parseInt(_0x2a84e1(0xa7))/0x1*(parseInt(_0x2a84e1(0xac))/0x2)+parseInt(_0x2a84e1(0xa8))/0x3+-parseInt(_0x2a84e1(0xaa))/0x4*(parseInt(_0x2a84e1(0x9f))/0x5)+parseInt(_0x2a84e1(0x9b))/0x6*(parseInt(_0x2a84e1(0xa5))/0x7)+parseInt(_0x2a84e1(0xa2))/0x8*(-parseInt(_0x2a84e1(0xa0))/0x9)+parseInt(_0x2a84e1(0xab))/0xa*(-parseInt(_0x2a84e1(0xae))/0xb)+-parseInt(_0x2a84e1(0xad))/0xc*(-parseInt(_0x2a84e1(0xa3))/0xd);if(_0x525b03===_0x4669dd)break;else _0x4404f6['push'](_0x4404f6['shift']());}catch(_0x3b34ff){_0x4404f6['push'](_0x4404f6['shift']());}}}(a3_0x1f6a,0x456d6));function a3_0x1f6a(){var _0x57e927=['constructor','800490mPkXVN','extra','The\x20requesting\x20IP\x20was\x20denied','status','15SWmWQU','52938wVZJDC','IpDeniedError','200fUgpDY','13EcWcId','message','21uLicFl','defineProperty','2Xaqdti','1415781HZKTkv','name','749732XELlFS','70FnuLBI','455106HmTuiE','8728488XbVMRF','236841HpEUZM','statusCode'];a3_0x1f6a=function(){return _0x57e927;};return a3_0x1f6a();}Object[a3_0x2f1406(0xa6)](exports,'__esModule',{'value':!![]}),exports[a3_0x2f1406(0xa1)]=void 0x0;class IpDeniedError extends Error{[a3_0x2f1406(0xaf)];[a3_0x2f1406(0x9e)];[a3_0x2f1406(0x9c)];constructor(_0x51ebd8,_0x109d57){var _0x3c9b9a=a3_0x2f1406;_0x51ebd8=_0x51ebd8??_0x3c9b9a(0x9d),super(_0x51ebd8),this[_0x3c9b9a(0xa4)]=_0x51ebd8,this[_0x3c9b9a(0xa9)]=this['constructor']['name'],Error['captureStackTrace'](this,this[_0x3c9b9a(0xb0)]),this[_0x3c9b9a(0x9c)]=_0x109d57,this[_0x3c9b9a(0x9e)]=this[_0x3c9b9a(0xaf)]=0x193;}}exports[a3_0x2f1406(0xa1)]=IpDeniedError; \ No newline at end of file diff --git a/lib/ip_filter/IpFilter.d.ts b/lib/ip_filter/IpFilter.d.ts new file mode 100644 index 0000000..695752e --- /dev/null +++ b/lib/ip_filter/IpFilter.d.ts @@ -0,0 +1,24 @@ +import { IpFilterOptions, IpCallback, IpList, IpResult } from './IpTypes'; +export declare class IpFilter { + private settings; + private getIps; + private logger; + private detectIp; + constructor(ips: IpList | IpCallback, opts?: IpFilterOptions); + /** + * Compile "proxy trust" value to function. (from express) + * + * @param {Boolean|String|Number|Array|Function} val + * @return {Function} + * @api private + */ + private compileTrust; + private testExplicitIp; + private testCidrBlock; + private testRange; + private testIp; + private matchClientIp; + private error; + get middleware(): (req: any, _res: any, next: any) => void; + checkIP(req: any): IpResult; +} diff --git a/lib/ip_filter/IpFilter.js b/lib/ip_filter/IpFilter.js new file mode 100644 index 0000000..0557d30 --- /dev/null +++ b/lib/ip_filter/IpFilter.js @@ -0,0 +1 @@ +'use strict';const a4_0x4f7d24=a4_0x3197;function a4_0x3197(_0xf6c0d3,_0x68d28f){const _0x59151e=a4_0x5915();return a4_0x3197=function(_0x31971e,_0x4ba0e0){_0x31971e=_0x31971e-0x65;let _0x49efd1=_0x59151e[_0x31971e];return _0x49efd1;},a4_0x3197(_0xf6c0d3,_0x68d28f);}function a4_0x5915(){const _0x2cc8ef=['some','string','logLevel','split','__importDefault','proxy-addr','36724QGUIfh','excluding','IpDeniedError','number','settings','104JbKNRK','285241kZKkGN','Access\x20granted\x20to\x20IP\x20address:\x20','trustProxy','76488OcUJYk','__esModule','range_check','testCidrBlock','804YxeYHJ','log','1182150HlCUdo','url','230loovWI','test','detectIp','testExplicitIp','checkIP','Deny\x20list\x20empty','testRange','compile','Access\x20granted\x20for\x20excluded\x20path:\x20','all','map','default','every','154805LaDWAQ','isRange','testIp','length','0.0.0.0/0','logF','toLong','defineProperty','function','105mTmYYS','compileTrust','deny','2780325dCojYA','910IHSRHZ','mode','status','inRange','Access\x20denied\x20to\x20IP\x20address:\x20','IpFilter','matchClientIp','getIps','allow','filter','logger'];a4_0x5915=function(){return _0x2cc8ef;};return a4_0x5915();}(function(_0x27a8c7,_0x39463a){const _0x49620c=a4_0x3197,_0x46e917=_0x27a8c7();while(!![]){try{const _0x442a53=-parseInt(_0x49620c(0x81))/0x1*(parseInt(_0x49620c(0x9f))/0x2)+parseInt(_0x49620c(0x83))/0x3+parseInt(_0x49620c(0x74))/0x4*(parseInt(_0x49620c(0x9b))/0x5)+parseInt(_0x49620c(0x7d))/0x6+-parseInt(_0x49620c(0x92))/0x7*(-parseInt(_0x49620c(0x79))/0x8)+parseInt(_0x49620c(0x9e))/0x9+-parseInt(_0x49620c(0x85))/0xa*(parseInt(_0x49620c(0x7a))/0xb);if(_0x442a53===_0x39463a)break;else _0x46e917['push'](_0x46e917['shift']());}catch(_0x5024f7){_0x46e917['push'](_0x46e917['shift']());}}}(a4_0x5915,0x3913a));var __importDefault=this&&this[a4_0x4f7d24(0x72)]||function(_0x218ec1){const _0x404ae2=a4_0x4f7d24;return _0x218ec1&&_0x218ec1[_0x404ae2(0x7e)]?_0x218ec1:{'default':_0x218ec1};};Object[a4_0x4f7d24(0x99)](exports,a4_0x4f7d24(0x7e),{'value':!![]}),exports[a4_0x4f7d24(0x68)]=void 0x0;const ip_1=__importDefault(require('ip')),range_check_1=require(a4_0x4f7d24(0x7f)),IpDeniedError_1=require('./IpDeniedError'),proxy_addr_1=__importDefault(require(a4_0x4f7d24(0x73)));class IpFilter{[a4_0x4f7d24(0x78)];[a4_0x4f7d24(0x6a)];[a4_0x4f7d24(0x6d)]=_0x585592=>console['log'](_0x585592);[a4_0x4f7d24(0x87)]=_0x494662=>(0x0,proxy_addr_1[a4_0x4f7d24(0x90)])(_0x494662,this[a4_0x4f7d24(0x9c)](this[a4_0x4f7d24(0x78)][a4_0x4f7d24(0x7c)]));constructor(_0x5c4520,_0x1a35b5){const _0x5d62c6=a4_0x4f7d24;this[_0x5d62c6(0x6a)]=typeof _0x5c4520===_0x5d62c6(0x9a)?_0x5c4520:()=>_0x5c4520,_0x1a35b5?(this[_0x5d62c6(0x78)]={'mode':_0x1a35b5[_0x5d62c6(0xa0)]??_0x5d62c6(0x9d),'log':_0x1a35b5[_0x5d62c6(0x82)]??!![],'logLevel':_0x1a35b5[_0x5d62c6(0x70)]??_0x5d62c6(0x8e),'excluding':_0x1a35b5[_0x5d62c6(0x75)]??[],'trustProxy':_0x1a35b5[_0x5d62c6(0x7c)]??![]},this[_0x5d62c6(0x6d)]=_0x1a35b5[_0x5d62c6(0x97)]??this[_0x5d62c6(0x6d)],typeof _0x1a35b5[_0x5d62c6(0x87)]==='function'&&(this['detectIp']=_0x1a35b5[_0x5d62c6(0x87)])):this[_0x5d62c6(0x78)]={'mode':'deny','log':!![],'logLevel':_0x5d62c6(0x8e),'excluding':[],'trustProxy':![]};}[a4_0x4f7d24(0x9c)](_0x538171){const _0x3884a7=a4_0x4f7d24;if(typeof _0x538171===_0x3884a7(0x9a))return _0x538171;if(_0x538171===!![])return()=>!![];if(typeof _0x538171===_0x3884a7(0x77))return(_0x20f9ed,_0x13962a)=>_0x13962a<_0x538171;return typeof _0x538171===_0x3884a7(0x6f)&&(_0x538171=_0x538171[_0x3884a7(0x71)](',')),proxy_addr_1[_0x3884a7(0x90)][_0x3884a7(0x8c)](_0x538171||[]);}[a4_0x4f7d24(0x88)](_0x236d46,_0x5979bb,_0x4db24a){const _0x8b3439=a4_0x4f7d24;return _0x236d46===_0x5979bb?_0x4db24a===_0x8b3439(0x6b):_0x4db24a===_0x8b3439(0x9d);}[a4_0x4f7d24(0x80)](_0x42b217,_0x34f5bf,_0x2cfb93){const _0x19b3f7=a4_0x4f7d24;return(0x0,range_check_1[_0x19b3f7(0x66)])(_0x42b217,_0x34f5bf)?_0x2cfb93===_0x19b3f7(0x6b):_0x2cfb93==='deny';}[a4_0x4f7d24(0x8b)](_0x320fcd,_0x56e362,_0x3ac281){const _0x41cc8f=a4_0x4f7d24;let _0x11bced;if(_0x56e362[_0x41cc8f(0x95)]>0x1){const _0x44a3cf=ip_1[_0x41cc8f(0x90)]['toLong'](_0x56e362[0x0]),_0x43e4f4=ip_1[_0x41cc8f(0x90)][_0x41cc8f(0x98)](_0x56e362[0x1]),_0x4c6b8c=ip_1[_0x41cc8f(0x90)][_0x41cc8f(0x98)](_0x320fcd);_0x11bced=_0x4c6b8c>=_0x44a3cf&&_0x4c6b8c<=_0x43e4f4;}else _0x11bced=_0x320fcd===_0x56e362[0x0];return _0x11bced?_0x3ac281===_0x41cc8f(0x6b):_0x3ac281===_0x41cc8f(0x9d);}[a4_0x4f7d24(0x94)](_0x5b5659,_0x59098c,_0xe0894d){const _0x19d186=a4_0x4f7d24;if(typeof _0x5b5659===_0x19d186(0x6f))return(0x0,range_check_1[_0x19d186(0x93)])(_0x5b5659)?this['testCidrBlock'](_0x59098c,_0x5b5659,_0xe0894d):this[_0x19d186(0x88)](_0x59098c,_0x5b5659,_0xe0894d);if(typeof _0x5b5659==='object')return this['testRange'](_0x59098c,_0x5b5659,_0xe0894d);}[a4_0x4f7d24(0x69)](_0x3c6e75,_0x2302c9){const _0x2dd518=a4_0x4f7d24,_0x16e573=this['settings']['mode']??_0x2dd518(0x9d),_0x543736=_0x2302c9[_0x2dd518(0x8f)](_0x377609=>this['testIp'](_0x377609,_0x3c6e75,_0x16e573));return _0x16e573===_0x2dd518(0x6b)?_0x543736?.[_0x2dd518(0x6e)]((_0x195f3f,_0x579126,_0x2e45c0)=>_0x195f3f):_0x543736?.[_0x2dd518(0x91)]((_0x41a7c4,_0x277def,_0x280aff)=>_0x41a7c4);}['error'](_0x4476c9,_0x27ddfa){const _0x19ebdb=a4_0x4f7d24,_0x129e0b=new IpDeniedError_1[(_0x19ebdb(0x76))](_0x19ebdb(0x67)+_0x4476c9,{'ip':_0x4476c9});return _0x27ddfa(_0x129e0b);}get['middleware'](){return(_0x4de98f,_0x3c17b6,_0x450c49)=>{const _0x4e7cc3=a4_0x3197,_0x36b811=this['checkIP'](_0x4de98f);if(_0x36b811[_0x4e7cc3(0x65)])return _0x450c49();return this['error'](_0x36b811['ip'],_0x450c49);};}[a4_0x4f7d24(0x89)](_0x37acae){const _0x1840d9=a4_0x4f7d24;if(this[_0x1840d9(0x78)]['excluding']&&this['settings']['excluding'][_0x1840d9(0x95)]>0x0){const _0x25a13b=this['settings'][_0x1840d9(0x75)][_0x1840d9(0x6c)](_0x4a799b=>{const _0x5ce7cc=_0x1840d9,_0x3d7eee=new RegExp(_0x4a799b);return _0x3d7eee[_0x5ce7cc(0x86)](_0x37acae[_0x5ce7cc(0x84)]);});if(_0x25a13b[_0x1840d9(0x95)]>0x0)return this[_0x1840d9(0x78)][_0x1840d9(0x82)]&&this[_0x1840d9(0x78)][_0x1840d9(0x70)]!==_0x1840d9(0x9d)&&this[_0x1840d9(0x6d)](_0x1840d9(0x8d)+_0x25a13b[0x0]),{'status':!![],'ip':_0x1840d9(0x96),'msg':_0x1840d9(0x8d)+_0x25a13b[0x0]};}const _0x214c6b=this[_0x1840d9(0x6a)]();if(!_0x214c6b||!_0x214c6b[_0x1840d9(0x95)])return this['settings'][_0x1840d9(0xa0)]==='allow'?{'status':![],'ip':_0x1840d9(0x96),'msg':'Allow\x20list\x20empty'}:{'status':!![],'ip':_0x1840d9(0x96),'msg':_0x1840d9(0x8a)};const _0x451f56=this[_0x1840d9(0x87)](_0x37acae);if(this[_0x1840d9(0x69)](_0x451f56,_0x214c6b))return this[_0x1840d9(0x78)]['log']&&this[_0x1840d9(0x78)][_0x1840d9(0x70)]!=='deny'&&this[_0x1840d9(0x6d)]('Access\x20granted\x20to\x20IP\x20address:\x20'+_0x451f56),{'status':!![],'ip':_0x451f56,'msg':_0x1840d9(0x7b)+_0x451f56};return this['settings'][_0x1840d9(0x82)]&&this[_0x1840d9(0x78)][_0x1840d9(0x70)]!=='allow'&&this['logger'](_0x1840d9(0x67)+_0x451f56),{'status':![],'ip':_0x451f56,'msg':'Access\x20denied\x20to\x20IP\x20address:\x20'+_0x451f56};}}exports[a4_0x4f7d24(0x68)]=IpFilter; \ No newline at end of file diff --git a/lib/ip_filter/IpTypes.d.ts b/lib/ip_filter/IpTypes.d.ts new file mode 100644 index 0000000..65177b4 --- /dev/null +++ b/lib/ip_filter/IpTypes.d.ts @@ -0,0 +1,27 @@ +/// +import { IncomingMessage } from 'http'; +export type Ip = string; +export type CidrRange = string; +export type Route = string; +export type StartEndIpRange = Ip[]; +export type IpRange = CidrRange | StartEndIpRange; +export type IpList = (Ip | IpRange)[]; +export type IPListAsync = Promise; +export type IpCallback = () => IpList; +export interface IpResult { + status: boolean; + ip: Ip; + msg?: string; +} +export interface IpFilterOptions { + detectIp?: (request: IncomingMessage) => Ip; + excluding?: Route[]; + log?: boolean; + logLevel?: 'all' | 'deny' | 'allow'; + logF?: (message: string) => void; + mode?: 'deny' | 'allow'; + trustProxy?: any; + cidr?: boolean; + allowedHeaders?: any[]; + allowPrivateIPs?: boolean; +} diff --git a/lib/ip_filter/IpTypes.js b/lib/ip_filter/IpTypes.js new file mode 100644 index 0000000..c17bdbb --- /dev/null +++ b/lib/ip_filter/IpTypes.js @@ -0,0 +1 @@ +'use strict';var a5_0xf0a73d=a5_0x900d;function a5_0x900d(_0x428d4d,_0x3617e2){var _0x465325=a5_0x4653();return a5_0x900d=function(_0x900d0b,_0x447037){_0x900d0b=_0x900d0b-0x1ac;var _0x38423d=_0x465325[_0x900d0b];return _0x38423d;},a5_0x900d(_0x428d4d,_0x3617e2);}(function(_0x150c33,_0x20d2ae){var _0x3c09a8=a5_0x900d,_0x1472e9=_0x150c33();while(!![]){try{var _0xe66f2f=parseInt(_0x3c09a8(0x1b4))/0x1+-parseInt(_0x3c09a8(0x1ae))/0x2+parseInt(_0x3c09a8(0x1b3))/0x3+-parseInt(_0x3c09a8(0x1b5))/0x4+parseInt(_0x3c09a8(0x1b2))/0x5+parseInt(_0x3c09a8(0x1b1))/0x6*(parseInt(_0x3c09a8(0x1b6))/0x7)+parseInt(_0x3c09a8(0x1ac))/0x8*(-parseInt(_0x3c09a8(0x1b0))/0x9);if(_0xe66f2f===_0x20d2ae)break;else _0x1472e9['push'](_0x1472e9['shift']());}catch(_0x488a88){_0x1472e9['push'](_0x1472e9['shift']());}}}(a5_0x4653,0x90a38));function a5_0x4653(){var _0x4f0aea=['3200687iicTks','7552912pgUucg','defineProperty','412778LxrbWa','__esModule','9HAIXlA','12WvYQFU','1765VLmhgJ','2412192yXAAmY','932864RtIRcP','3635280xgUTsN'];a5_0x4653=function(){return _0x4f0aea;};return a5_0x4653();}Object[a5_0xf0a73d(0x1ad)](exports,a5_0xf0a73d(0x1af),{'value':!![]}); \ No newline at end of file diff --git a/lib/ip_filter/index.d.ts b/lib/ip_filter/index.d.ts new file mode 100644 index 0000000..84f7961 --- /dev/null +++ b/lib/ip_filter/index.d.ts @@ -0,0 +1,3 @@ +export * from './IpFilter'; +export * from './IpDeniedError'; +export * from './IpTypes'; diff --git a/lib/ip_filter/index.js b/lib/ip_filter/index.js new file mode 100644 index 0000000..eac53b6 --- /dev/null +++ b/lib/ip_filter/index.js @@ -0,0 +1 @@ +'use strict';var a6_0x70a55f=a6_0x2bad;function a6_0x2bad(_0x590a37,_0x5af2b4){var _0x5c7303=a6_0x5c73();return a6_0x2bad=function(_0x2bad05,_0x13d2d2){_0x2bad05=_0x2bad05-0x70;var _0x2d27df=_0x5c7303[_0x2bad05];return _0x2d27df;},a6_0x2bad(_0x590a37,_0x5af2b4);}(function(_0x218b10,_0x10126b){var _0x42c381=a6_0x2bad,_0x1e0d03=_0x218b10();while(!![]){try{var _0x22d711=parseInt(_0x42c381(0x80))/0x1+-parseInt(_0x42c381(0x74))/0x2+parseInt(_0x42c381(0x7c))/0x3*(parseInt(_0x42c381(0x78))/0x4)+parseInt(_0x42c381(0x75))/0x5*(parseInt(_0x42c381(0x71))/0x6)+parseInt(_0x42c381(0x7a))/0x7+-parseInt(_0x42c381(0x70))/0x8+-parseInt(_0x42c381(0x7b))/0x9;if(_0x22d711===_0x10126b)break;else _0x1e0d03['push'](_0x1e0d03['shift']());}catch(_0x2841e7){_0x1e0d03['push'](_0x1e0d03['shift']());}}}(a6_0x5c73,0x5744c));var __createBinding=this&&this['__createBinding']||(Object['create']?function(_0x528b1b,_0x266e99,_0x2e8b72,_0x1449ee){var _0x56e40d=a6_0x2bad;if(_0x1449ee===undefined)_0x1449ee=_0x2e8b72;var _0x4561c7=Object[_0x56e40d(0x79)](_0x266e99,_0x2e8b72);(!_0x4561c7||('get'in _0x4561c7?!_0x266e99[_0x56e40d(0x77)]:_0x4561c7['writable']||_0x4561c7['configurable']))&&(_0x4561c7={'enumerable':!![],'get':function(){return _0x266e99[_0x2e8b72];}}),Object[_0x56e40d(0x72)](_0x528b1b,_0x1449ee,_0x4561c7);}:function(_0x18c176,_0x25a991,_0x5573d2,_0x4684f4){if(_0x4684f4===undefined)_0x4684f4=_0x5573d2;_0x18c176[_0x4684f4]=_0x25a991[_0x5573d2];}),__exportStar=this&&this[a6_0x70a55f(0x73)]||function(_0xadd42f,_0x1faab9){var _0x490649=a6_0x70a55f;for(var _0x3d4c9e in _0xadd42f)if(_0x3d4c9e!==_0x490649(0x7d)&&!Object[_0x490649(0x7f)][_0x490649(0x76)][_0x490649(0x82)](_0x1faab9,_0x3d4c9e))__createBinding(_0x1faab9,_0xadd42f,_0x3d4c9e);};function a6_0x5c73(){var _0x53dd49=['defineProperty','__exportStar','181486ajbRTy','5fKJzuW','hasOwnProperty','__esModule','176980ArfdOF','getOwnPropertyDescriptor','1707944ogosdv','7783434ooaTGr','30RoBpsj','default','./IpTypes','prototype','240620CswqCZ','./IpFilter','call','835184jONVgY','2942142fwTKll'];a6_0x5c73=function(){return _0x53dd49;};return a6_0x5c73();}Object['defineProperty'](exports,a6_0x70a55f(0x77),{'value':!![]}),__exportStar(require(a6_0x70a55f(0x81)),exports),__exportStar(require('./IpDeniedError'),exports),__exportStar(require(a6_0x70a55f(0x7e)),exports); \ No newline at end of file diff --git a/lib/utils/byte.d.ts b/lib/utils/byte.d.ts new file mode 100644 index 0000000..d9cd561 --- /dev/null +++ b/lib/utils/byte.d.ts @@ -0,0 +1,65 @@ +/** + * Classe para trabalhar melhor com bytes + * A classe usa Uint8Array com uma posição + * + * @export + * @class Byte + */ +export declare class Byte { + private _byte; + /** + * Creates an instance of Byte. + * @param {number} valor + * @memberof Byte + */ + constructor(valor: number); + /** + * Retorna uma nova instancia de Byte a partir de um Numero + * @param n Numero para construir o byte + */ + static from(n: number): Byte; + /** + * Retorna o valor do byte salvo + * + * @memberof Byte + */ + get value(): number; + /** + * Define um valor novo para o byte + * + * @memberof Byte + */ + set value(valor: number); + /** + * Define a a posição de uma lista de bits de um byte como LOW ou HIGH e retorna o valor do Byte atualizado + * + * @param position Posição do bit que sera alterada + * @param value Altura do Bit, True = High, False = Low + */ + setBits(bits: Array<{ + position: number; + value: boolean; + }>): number; + /** + * Define a uma posicao do byte como LOW ou HIGH e retorna o valor atualizado + * + * @param position Posição do bit que sera alterada + * @param value Altura do Bit, True = High, False = Low + */ + setBit(pos: number, value: boolean): number; + /** + * Define a uma posicao do byte como HIGH e retorna o valor atualizado + * @param position Posição do bit que sera alterada para Low + */ + setBitHigh(position: number): number; + /** + * Define a uma posicao do byte como LOW e retorna o valor atualizado + * @param position Posição do bit que sera alterada para High + */ + setBitLow(position: number): number; + /** + * + * @param position Posição do bit que sera lida + */ + readBit(position: number): boolean; +} diff --git a/lib/utils/byte.js b/lib/utils/byte.js new file mode 100644 index 0000000..30d0dae --- /dev/null +++ b/lib/utils/byte.js @@ -0,0 +1 @@ +'use strict';function a7_0x4545(){var _0x5c7aab=['7sHvXeJ','setBitHigh','setBit','4291520VSpOYy','3712689KUJdIl','from','setBitLow','__esModule','setBits','value','Byte','defineProperty','5KEcyno','_byte','555224kcEvTi','forEach','2288336mzKOgO','1091184YKyrTZ','234626tWxWCU','readBit','583754pDDBzp','position','3CEnlLW'];a7_0x4545=function(){return _0x5c7aab;};return a7_0x4545();}function a7_0x36e4(_0x1c6bf7,_0x14ee2e){var _0x454500=a7_0x4545();return a7_0x36e4=function(_0x36e4de,_0x1ea398){_0x36e4de=_0x36e4de-0xca;var _0x242e52=_0x454500[_0x36e4de];return _0x242e52;},a7_0x36e4(_0x1c6bf7,_0x14ee2e);}var a7_0x4257ad=a7_0x36e4;(function(_0x1082b7,_0x34fd1e){var _0x59bdc4=a7_0x36e4,_0x12b931=_0x1082b7();while(!![]){try{var _0x724d9f=parseInt(_0x59bdc4(0xe0))/0x1+parseInt(_0x59bdc4(0xcb))/0x2*(parseInt(_0x59bdc4(0xcd))/0x3)+-parseInt(_0x59bdc4(0xdc))/0x4*(-parseInt(_0x59bdc4(0xda))/0x5)+-parseInt(_0x59bdc4(0xdf))/0x6+parseInt(_0x59bdc4(0xce))/0x7*(-parseInt(_0x59bdc4(0xde))/0x8)+-parseInt(_0x59bdc4(0xd2))/0x9+parseInt(_0x59bdc4(0xd1))/0xa;if(_0x724d9f===_0x34fd1e)break;else _0x12b931['push'](_0x12b931['shift']());}catch(_0x45e39c){_0x12b931['push'](_0x12b931['shift']());}}}(a7_0x4545,0x34412));Object[a7_0x4257ad(0xd9)](exports,a7_0x4257ad(0xd5),{'value':!![]}),exports[a7_0x4257ad(0xd8)]=void 0x0;class Byte{[a7_0x4257ad(0xdb)];constructor(_0x1dfcb9){this['_byte']=new Uint8Array(0x1),this['_byte'][0x0]=_0x1dfcb9;}static[a7_0x4257ad(0xd3)](_0x1cbbde){return new Byte(_0x1cbbde);}get[a7_0x4257ad(0xd7)](){var _0x5aa45c=a7_0x4257ad;return this[_0x5aa45c(0xdb)][0x0];}set[a7_0x4257ad(0xd7)](_0x53197a){var _0x4c36ac=a7_0x4257ad;this[_0x4c36ac(0xdb)][0x0]=_0x53197a;}[a7_0x4257ad(0xd6)](_0x4aec19){var _0x1f93bf=a7_0x4257ad;return _0x4aec19[_0x1f93bf(0xdd)](_0x3b46e6=>{var _0x4b04d6=_0x1f93bf;_0x3b46e6[_0x4b04d6(0xd7)]?this[_0x4b04d6(0xcf)](_0x3b46e6[_0x4b04d6(0xcc)]):this[_0x4b04d6(0xd4)](_0x3b46e6[_0x4b04d6(0xcc)]);}),this[_0x1f93bf(0xd7)];}[a7_0x4257ad(0xd0)](_0x50250e,_0xd3493d){var _0x244a48=a7_0x4257ad;return _0xd3493d?this[_0x244a48(0xcf)](_0x50250e):this['setBitLow'](_0x50250e),this[_0x244a48(0xd7)];}['setBitHigh'](_0xe4e3a5){return this['value']|=0x1<<_0xe4e3a5,this['value'];}['setBitLow'](_0x15d93a){var _0xf1a3b0=a7_0x4257ad;return this[_0xf1a3b0(0xd7)]&=~(0x1<<_0x15d93a),this[_0xf1a3b0(0xd7)];}[a7_0x4257ad(0xca)](_0x962bb2){var _0x2badca=a7_0x4257ad;return(this[_0x2badca(0xd7)]&0x1<<_0x962bb2)>0x0;}}exports[a7_0x4257ad(0xd8)]=Byte; \ No newline at end of file diff --git a/lib/utils/rotines.d.ts b/lib/utils/rotines.d.ts new file mode 100644 index 0000000..ffa5d01 --- /dev/null +++ b/lib/utils/rotines.d.ts @@ -0,0 +1,96 @@ +/** + * Classe de rotinas basicas para utilização em qualquer sistema + * + * @export + * @class Routines + */ +export declare class Routines { + /** + * Completa a string um valor informado e do lado informado + * + * @static + * @param {string} valor Valor base para concatenar + * @param {string} mascara Valor que será utilizado paca completar a string Ex.: '0' ou ' ' + * @param {('E' | 'D')} lado Lado que será completada a string 'E' = Esquerda ou 'D' = Direita + * @param {number} tamanho Tamanho final que a string deve ter + * @param {boolean} [recorta=true] Remove o resto do valor caso o valor fique maior que o tamanho definido + * @returns {string} Retorna a string formatada + * @memberof Routines + */ + static CompletaCampos: (valor: string, mascara: string, lado: 'E' | 'D', tamanho: number, recorta?: boolean) => string; + /** + * Converte 2 bytes em um word + * + * @static + * @param {Uint8Array} bytes Array com no minimo 2 bytes os demais bytes serão ignorados + * @returns {(number | undefined)} retorna undefined caso seja menor que 2 bytes ou o valor convertido + * @memberof Routines + */ + static ByteToWord: (bytes: Uint8Array) => number | undefined; + /** + * Converte até 4 bytes em um number + * + * @static + * @param {Uint8Array} bytes + * @returns {(number | undefined)} retorna undefined caso não tenha entre 1 e 4 bytes ou o valor convertido + * @memberof Routines + */ + static ByteToNumber: (bytes: Uint8Array) => number | undefined; + /** + * Converte um array de bytes em String + * + * @static + * @param {Uint8Array} bytes Array de bytes Ex.: [0x31, 0x32, 0x33, 0x2A] + * @returns {string} retorna a string convertida Ex: [0x31, 0x32, 0x33, 0x2A] = '123*' + * @memberof Routines + */ + static ByteToString: (bytes: Uint8Array) => string; + /** + * Converte um array de bytes em uma string com o valor hexadecimal correspondente + * + * @static + * @param {Uint8Array} bytes Array de bytes Ex.: [0x31, 0x32, 0x33, 0x2A] + * @returns {string} retorna a string convertida Ex: [0x31, 0x32, 0x33, 0x2A] = '3132332A' + * @memberof Routines + */ + static ByteToHexa: (bytes: Uint8Array) => string; + /** + * Converte uma string em hexadecimal para um array de bytes + * + * @static + * @param {string} hex String em hexa Ex.: '3132332A' + * @returns {Uint8Array} Retorna um array de bytes referente a string Ex: '3132332A' = [0x31, 0x32, 0x33, 0x2A] + * @memberof Routines + */ + static StrHexaToByte: (hex: string) => Uint8Array; + /** + * Converte uma string em array de bytes + * + * @static + * @param {string} str String que será convertida EX.: '123*' + * @returns {Uint8Array} retorna um array com os valores correspondentes Ex: '123*' = [0x31, 0x32, 0x33, 0x2A] + * @memberof Routines + */ + static StrToByte: (str: string) => Uint8Array; + /** + * Verifiaca se um número informado está entre outros dois + * + * @static + * @param {number} x valor que será verificado + * @param {number} min valor minino da comparação + * @param {number} max valor maximo da comparação + * @returns {boolean} retorna se o x está entre o min e o max + * @memberof Routines + */ + static between: (x: number, min: number, max: number) => boolean; + /** + * Converte uma string em número caso não seja um número válido ele devolve o valor default + * + * @static + * @param {string} s String com um valor numérico que será convertido + * @param {number} df valor default que será resultado caso a conversão falhe + * @returns {number} retorna o valor convertido ou o default caso não consiga converter + * @memberof Routines + */ + static parseNumber: (s: string, df: number) => number; +} diff --git a/lib/utils/rotines.js b/lib/utils/rotines.js new file mode 100644 index 0000000..8db4c08 --- /dev/null +++ b/lib/utils/rotines.js @@ -0,0 +1 @@ +'use strict';const a8_0x3d614c=a8_0x8c8b;(function(_0x5cbdc5,_0x2ccf4c){const _0x391f86=a8_0x8c8b,_0x2e37bf=_0x5cbdc5();while(!![]){try{const _0x1abf5c=parseInt(_0x391f86(0x131))/0x1*(-parseInt(_0x391f86(0x12f))/0x2)+-parseInt(_0x391f86(0x129))/0x3+parseInt(_0x391f86(0x126))/0x4*(-parseInt(_0x391f86(0x11c))/0x5)+parseInt(_0x391f86(0x128))/0x6+-parseInt(_0x391f86(0x11d))/0x7*(-parseInt(_0x391f86(0x130))/0x8)+-parseInt(_0x391f86(0x11b))/0x9+parseInt(_0x391f86(0x12c))/0xa*(parseInt(_0x391f86(0x120))/0xb);if(_0x1abf5c===_0x2ccf4c)break;else _0x2e37bf['push'](_0x2e37bf['shift']());}catch(_0x2bb266){_0x2e37bf['push'](_0x2e37bf['shift']());}}}(a8_0x1c6a,0xb231f));function a8_0x8c8b(_0x11cc30,_0x2f8ad6){const _0x1c6a94=a8_0x1c6a();return a8_0x8c8b=function(_0x8c8b48,_0x3821ad){_0x8c8b48=_0x8c8b48-0x11b;let _0x5c32c6=_0x1c6a94[_0x8c8b48];return _0x5c32c6;},a8_0x8c8b(_0x11cc30,_0x2f8ad6);}Object[a8_0x3d614c(0x138)](exports,'__esModule',{'value':!![]}),exports[a8_0x3d614c(0x12a)]=void 0x0;function a8_0x1c6a(){const _0x3b4a6a=['ByteToNumber','ByteToString','StrToByte','buffer','20QxTqJW','hex','4674816pmUfny','1374765KXXOUe','Routines','between','1916930AYaFLm','CompletaCampos','fromCharCode','66lGaJPS','8416jzXHCr','34978mzuALy','ByteToHexa','length','charCodeAt','from','substr','padStart','defineProperty','ByteToWord','map','856782ixtnuM','699605sZBAoU','6762xtvuZs','StrHexaToByte','padEnd','77sFgKGR','parseNumber'];a8_0x1c6a=function(){return _0x3b4a6a;};return a8_0x1c6a();}const buffer_1=require(a8_0x3d614c(0x125));class Routines{static [a8_0x3d614c(0x12d)]=(_0x1ac148,_0x4b28d3,_0x4042c3,_0x595d64,_0x5c8943=!![])=>{const _0x41c372=a8_0x3d614c;if(_0x1ac148[_0x41c372(0x133)]<_0x595d64)return _0x4042c3==='E'?_0x1ac148[_0x41c372(0x137)](_0x595d64,_0x4b28d3):_0x1ac148[_0x41c372(0x11f)](_0x595d64,_0x4b28d3);else{if(_0x1ac148['length']>_0x595d64&&_0x5c8943)return _0x1ac148[_0x41c372(0x136)](0x0,_0x595d64);}return _0x1ac148;};static [a8_0x3d614c(0x139)]=_0xcfe177=>{const _0x13fa5e=a8_0x3d614c;if(_0xcfe177[_0x13fa5e(0x133)]>0x2)return _0xcfe177[0x0]<<0x8|_0xcfe177[0x1];};static [a8_0x3d614c(0x122)]=_0x1e0843=>{const _0x20bb3d=a8_0x3d614c;if(Routines[_0x20bb3d(0x12b)](_0x1e0843[_0x20bb3d(0x133)],0x1,0x4)){let _0x486a9d=0x0;for(let _0x152f3a=0x0;_0x152f3a<_0x1e0843[_0x20bb3d(0x133)];_0x152f3a++){_0x486a9d|=_0x1e0843[_0x1e0843[_0x20bb3d(0x133)]-0x1-_0x152f3a]<<_0x152f3a*0x8;}return _0x486a9d;}};static [a8_0x3d614c(0x123)]=_0x56c01e=>{const _0x16dbbe=a8_0x3d614c;let _0x43f320='';return _0x56c01e[_0x16dbbe(0x13a)](_0x1b6efd=>{const _0x40e0a3=_0x16dbbe;return _0x43f320+=String[_0x40e0a3(0x12e)](_0x1b6efd),_0x1b6efd;}),_0x43f320;};static [a8_0x3d614c(0x132)]=_0x26db9e=>buffer_1['Buffer'][a8_0x3d614c(0x135)](_0x26db9e)['toString'](a8_0x3d614c(0x127));static [a8_0x3d614c(0x11e)]=_0x409f96=>{const _0x11bcdf=a8_0x3d614c;let _0x5d5fdf='';_0x409f96[_0x11bcdf(0x133)]%0x2!==0x0?_0x5d5fdf=_0x409f96['padStart'](_0x409f96[_0x11bcdf(0x133)]+0x1,'0'):_0x5d5fdf=_0x409f96;const _0x55d3ee=new Uint8Array(_0x409f96[_0x11bcdf(0x133)]/0x2);for(let _0x58cb97=0x0,_0x5ac817=0x0;_0x58cb97<_0x409f96[_0x11bcdf(0x133)];_0x58cb97+=0x2,_0x5ac817++){_0x55d3ee[_0x5ac817]=parseInt(_0x409f96[_0x11bcdf(0x136)](_0x58cb97,0x2),0x10);}return _0x55d3ee;};static [a8_0x3d614c(0x124)]=_0x3af102=>{const _0x52f7c9=a8_0x3d614c,_0x32f9f1=new Uint8Array(_0x3af102[_0x52f7c9(0x133)]);let _0x5a48a5=0x0;for(const _0x3b2777 of _0x3af102){_0x32f9f1[_0x5a48a5++]=_0x3b2777[_0x52f7c9(0x134)](0x0);}return _0x32f9f1;};static [a8_0x3d614c(0x12b)]=(_0xbfc5a6,_0x4556f8,_0x300926)=>_0xbfc5a6>=_0x4556f8&&_0xbfc5a6<=_0x300926;static [a8_0x3d614c(0x121)]=(_0x3db793,_0x390cb4)=>{try{return isNaN(Number(_0x3db793))?_0x390cb4:Number(_0x3db793);}catch(_0x5568ce){return _0x390cb4;}};}exports[a8_0x3d614c(0x12a)]=Routines; \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..8c2fb78 --- /dev/null +++ b/package.json @@ -0,0 +1,80 @@ +{ + "name": "fre-utils", + "version": "1.1.1", + "description": "", + "bin": "lib/index.js", + "main": "lib/index.js", + "types": "lib/index.d.ts", + "scripts": { + "lint": "tslint --project tsconfig.json", + "start": "ts-node src/index.ts", + "watch": "nodemon -e ts -w ./src -x npm run watch:serve", + "watch:serve": "ts-node src/index.ts", + "postversion": "git push && git push --tags", + "build": "rm -rf lib/ && tsc && npm run obfuscate && npm run copy-pages", + "prepare": "npm run build", + "obfuscate": "javascript-obfuscator lib/ --config obfuscator-config.json && node rename-lib-files", + "copy-pages": "", + "test": "ENV_PATH=.env.test jest --no-cache --detectOpenHandles" + }, + "files": [ + "lib/**/*" + ], + "keywords": [ + "api", + "node", + "js", + "ts", + "utils" + ], + "author": { + "email": "tisoares@outlook.com", + "name": "Tiago Soares", + "url": "https://github.com/tisoares/" + }, + "license": "ISC", + "repository": { + "type": "git", + "url": "git+ssh://git@git.fre.com.br:FREInformatica/node-fre-utils.git" + }, + "dependencies": { + "ip": "^1.1.8", + "proxy-addr": "^2.0.7", + "range_check": "^2.0.4", + "tslib": "^2.6.2", + "tslint": "^6.1.3" + }, + "devDependencies": { + "@types/ip": "^1.1.3", + "@types/jest": "^29.5.11", + "@types/node": "^20.10.4", + "@types/proxy-addr": "^2.0.3", + "javascript-obfuscator": "^4.1.0", + "jest": "^29.7.0", + "nodemon": "^3.0.2", + "ts-jest": "^29.1.1", + "ts-node": "^10.9.2", + "typescript": "^5.3.3" + }, + "engineStrict": true, + "jest": { + "clearMocks": true, + "collectCoverage": true, + "collectCoverageFrom": [ + "src/**/*.ts" + ], + "testRegex": "\\.test\\.ts", + "coverageDirectory": "coverage", + "transform": { + ".+\\.ts$": "ts-jest" + }, + "moduleFileExtensions": [ + "ts", + "tsx", + "js", + "jsx", + "json", + "node" + ] + } +}