@seidor-cloud-produtos/orbit-backend-lib 1.101.25 → 1.101.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,5 @@
1
+ export declare class Net {
2
+ isCurrentIPInIPWhiteList(whiteList: string[], ignoreInvalidIP?: boolean): Promise<boolean>;
3
+ getCurrentIP(): Promise<any>;
4
+ isIP(value: string): number;
5
+ }
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Net = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const axios_1 = tslib_1.__importDefault(require("axios"));
6
+ const net_1 = tslib_1.__importDefault(require("net"));
7
+ class Net {
8
+ async isCurrentIPInIPWhiteList(whiteList, ignoreInvalidIP = false) {
9
+ const currentIP = await this.getCurrentIP();
10
+ if (!this.isIP(currentIP) && ignoreInvalidIP) {
11
+ return true;
12
+ }
13
+ return whiteList.includes(currentIP);
14
+ }
15
+ async getCurrentIP() {
16
+ try {
17
+ const response = await axios_1.default.get('https://checkip.amazonaws.com/');
18
+ return response.data.trim();
19
+ }
20
+ catch (e) {
21
+ console.log(e);
22
+ return 'invalid';
23
+ }
24
+ }
25
+ isIP(value) {
26
+ return net_1.default.isIP(value);
27
+ }
28
+ }
29
+ exports.Net = Net;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seidor-cloud-produtos/orbit-backend-lib",
3
- "version": "1.101.25",
3
+ "version": "1.101.26",
4
4
  "description": "Internal lib for backend components",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",