@gibme/ipinfo 0.0.10 → 1.0.1

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.
package/dist/types.d.ts CHANGED
@@ -21,3 +21,40 @@ export interface PrefixInfo {
21
21
  allocated: Date;
22
22
  as?: ASNEntry;
23
23
  }
24
+ export declare namespace Workers {
25
+ interface Response {
26
+ status: 'success' | 'fail';
27
+ message?: string;
28
+ query: string;
29
+ country: string;
30
+ countryCode: string;
31
+ region: string;
32
+ regionName: string;
33
+ city: string;
34
+ zip: string;
35
+ lat: number;
36
+ lon: number;
37
+ timezone: string;
38
+ isp: string;
39
+ org: string;
40
+ as: string;
41
+ }
42
+ }
43
+ export interface CheckIPResponse {
44
+ query: string;
45
+ country: string;
46
+ countryCode: string;
47
+ region: string;
48
+ regionName: string;
49
+ city: string;
50
+ zip: string;
51
+ lat: number;
52
+ lon: number;
53
+ timezone: string;
54
+ isp: string;
55
+ org?: string;
56
+ as: {
57
+ asn: number;
58
+ name: string;
59
+ };
60
+ }
package/dist/web.d.ts ADDED
@@ -0,0 +1,10 @@
1
+ import { CheckIPResponse } from './types';
2
+ /**
3
+ * Looks up information regarding the IP address supplied; OR,
4
+ * if no address is supplied, looks up information regarding
5
+ * our client's IP address
6
+ *
7
+ * @param address
8
+ * @constructor
9
+ */
10
+ export declare const CheckIP: (address?: string) => Promise<CheckIPResponse | undefined>;
package/dist/web.js ADDED
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ // Copyright (c) 2016-2024, Brandon Lehmann <brandonlehmann@gmail.com>
3
+ //
4
+ // Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ // of this software and associated documentation files (the "Software"), to deal
6
+ // in the Software without restriction, including without limitation the rights
7
+ // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ // copies of the Software, and to permit persons to whom the Software is
9
+ // furnished to do so, subject to the following conditions:
10
+ //
11
+ // The above copyright notice and this permission notice shall be included in all
12
+ // copies or substantial portions of the Software.
13
+ //
14
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ // SOFTWARE.
21
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
22
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
23
+ return new (P || (P = Promise))(function (resolve, reject) {
24
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
25
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
26
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
27
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
28
+ });
29
+ };
30
+ var __importDefault = (this && this.__importDefault) || function (mod) {
31
+ return (mod && mod.__esModule) ? mod : { "default": mod };
32
+ };
33
+ Object.defineProperty(exports, "__esModule", { value: true });
34
+ exports.CheckIP = void 0;
35
+ const fetch_1 = __importDefault(require("@gibme/fetch"));
36
+ /**
37
+ * Looks up information regarding the IP address supplied; OR,
38
+ * if no address is supplied, looks up information regarding
39
+ * our client's IP address
40
+ *
41
+ * @param address
42
+ * @constructor
43
+ */
44
+ const CheckIP = (address) => __awaiter(void 0, void 0, void 0, function* () {
45
+ const url = `https://ipinfo.hostmanager.workers.dev/${address ? `?ip=${address}` : ''}`;
46
+ const response = yield fetch_1.default.get(url);
47
+ if (!response.ok) {
48
+ return undefined;
49
+ }
50
+ const json = yield response.json();
51
+ if (json.status === 'fail') {
52
+ return undefined;
53
+ }
54
+ const [as, name] = json.as.split(' ', 2)
55
+ .map(elem => elem.trim());
56
+ const asn = parseInt(as.replace('AS', '')) || 0;
57
+ return {
58
+ query: json.query,
59
+ country: json.country,
60
+ countryCode: json.countryCode,
61
+ region: json.region,
62
+ regionName: json.regionName,
63
+ city: json.city,
64
+ zip: json.zip,
65
+ lat: json.lat,
66
+ lon: json.lon,
67
+ timezone: json.timezone,
68
+ isp: json.isp,
69
+ org: json.org.length !== 0 ? json.org : undefined,
70
+ as: {
71
+ asn,
72
+ name
73
+ }
74
+ };
75
+ });
76
+ exports.CheckIP = CheckIP;
77
+ //# sourceMappingURL=web.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"web.js","sourceRoot":"","sources":["../src/web.ts"],"names":[],"mappings":";AAAA,sEAAsE;AACtE,EAAE;AACF,+EAA+E;AAC/E,gFAAgF;AAChF,+EAA+E;AAC/E,4EAA4E;AAC5E,wEAAwE;AACxE,2DAA2D;AAC3D,EAAE;AACF,iFAAiF;AACjF,kDAAkD;AAClD,EAAE;AACF,6EAA6E;AAC7E,2EAA2E;AAC3E,8EAA8E;AAC9E,yEAAyE;AACzE,gFAAgF;AAChF,gFAAgF;AAChF,YAAY;;;;;;;;;;;;;;;AAGZ,yDAAiC;AAEjC;;;;;;;GAOG;AACI,MAAM,OAAO,GAAG,CACnB,OAAgB,EACoB,EAAE;IACtC,MAAM,GAAG,GAAG,0CAA0C,OAAO,CAAC,CAAC,CAAC,OAAO,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;IAExF,MAAM,QAAQ,GAAG,MAAM,eAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAEtC,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACf,OAAO,SAAS,CAAC;IACrB,CAAC;IAED,MAAM,IAAI,GAAqB,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;IAErD,IAAI,IAAI,CAAC,MAAM,KAAK,MAAM,EAAE,CAAC;QACzB,OAAO,SAAS,CAAC;IACrB,CAAC;IAED,MAAM,CAAC,EAAE,EAAE,IAAI,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC;SACnC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;IAE9B,MAAM,GAAG,GAAG,QAAQ,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;IAEhD,OAAO;QACH,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,OAAO,EAAE,IAAI,CAAC,OAAO;QACrB,WAAW,EAAE,IAAI,CAAC,WAAW;QAC7B,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,UAAU,EAAE,IAAI,CAAC,UAAU;QAC3B,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,GAAG,EAAE,IAAI,CAAC,GAAG;QACb,GAAG,EAAE,IAAI,CAAC,GAAG;QACb,GAAG,EAAE,IAAI,CAAC,GAAG;QACb,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,GAAG,EAAE,IAAI,CAAC,GAAG;QACb,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS;QACjD,EAAE,EAAE;YACA,GAAG;YACH,IAAI;SACP;KACJ,CAAC;AACN,CAAC,CAAA,CAAC;AAxCW,QAAA,OAAO,WAwClB"}
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@gibme/ipinfo",
3
- "version": "0.0.10",
3
+ "version": "1.0.1",
4
4
  "description": "A simple IP information lookup helper using Team CYMRU services",
5
- "main": "dist/ipinfo.js",
6
- "types": "dist/ipinfo.d.ts",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
7
  "files": [
8
8
  "dist/*"
9
9
  ],
@@ -12,6 +12,7 @@
12
12
  "build": "yarn build:typescript",
13
13
  "build:docs": "./node_modules/.bin/typedoc",
14
14
  "build:typescript": "./node_modules/.bin/tsc",
15
+ "build:webpack": "./node_modules/.bin/auto-pack",
15
16
  "test": "yarn test:style && yarn test:typecheck && yarn test:mocha",
16
17
  "test:typecheck": "./node_modules/.bin/tsc --noEmit",
17
18
  "test:style": "yarn style",
@@ -19,7 +20,7 @@
19
20
  "style": "./node_modules/.bin/eslint src/**/*.ts test/**/*.ts",
20
21
  "fix-style": "./node_modules/.bin/eslint --fix src/**/*.ts test/**/*.ts",
21
22
  "fix:style": "yarn fix-style",
22
- "prepublishOnly": "yarn build"
23
+ "prepublishOnly": "yarn build && yarn build:webpack"
23
24
  },
24
25
  "repository": {
25
26
  "type": "git",
@@ -37,8 +38,17 @@
37
38
  "name": "Brandon Lehmann",
38
39
  "email": "brandonlehmann@gmail.com"
39
40
  },
40
- "dependencies": {},
41
+ "dependencies": {
42
+ "@gibme/fetch": "^1.0.14"
43
+ },
44
+ "webpack": {
45
+ "entry": {
46
+ "ipinfo": "./src/web.ts"
47
+ },
48
+ "filename": "[name].min.js"
49
+ },
41
50
  "devDependencies": {
51
+ "@gibme/auto-pack": "^0.4.2",
42
52
  "@types/mocha": "^10.0.6",
43
53
  "@types/node": "^20.11.7",
44
54
  "@typescript-eslint/eslint-plugin": "^6.19.1",
package/dist/ipinfo.d.ts DELETED
@@ -1,9 +0,0 @@
1
- import { PrefixInfo } from './types';
2
- /**
3
- * Looks up information regarding the IP address supplied
4
- *
5
- * @param address
6
- * @param max_retries
7
- */
8
- export declare const IPInfo: (address: string, max_retries?: number) => Promise<PrefixInfo | undefined>;
9
- export default IPInfo;
@@ -1 +0,0 @@
1
- {"version":3,"file":"ipinfo.js","sourceRoot":"","sources":["../src/ipinfo.ts"],"names":[],"mappings":";AAAA,sEAAsE;AACtE,EAAE;AACF,+EAA+E;AAC/E,gFAAgF;AAChF,+EAA+E;AAC/E,4EAA4E;AAC5E,wEAAwE;AACxE,2DAA2D;AAC3D,EAAE;AACF,iFAAiF;AACjF,kDAAkD;AAClD,EAAE;AACF,6EAA6E;AAC7E,2EAA2E;AAC3E,8EAA8E;AAC9E,yEAAyE;AACzE,gFAAgF;AAChF,gFAAgF;AAChF,YAAY;;;;;;;;;;;;;;;AAGZ,wDAAgC;AAEhC;;;;;GAKG;AACI,MAAM,MAAM,GAAG,CAClB,OAAe,EACf,WAAW,GAAG,CAAC,EACgB,EAAE;IACjC,OAAO,iBAAO,CAAC,SAAS,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;AACnD,CAAC,CAAA,CAAC;AALW,QAAA,MAAM,UAKjB;AAEF,kBAAe,cAAM,CAAC"}