@adamlui/geolocate 2.0.6 → 2.0.8
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/README.md +33 -31
- package/dist/cli.min.js +3 -3
- package/dist/geolocate.min.js +3 -3
- package/docs/README.md +33 -31
- package/docs/SECURITY.md +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
# <picture><source media="(prefers-color-scheme: dark)" srcset="https://
|
|
1
|
+
# <picture><source media="(prefers-color-scheme: dark)" srcset="https://media.geolocatejs.org/images/icons/wire-globe/white/icon32.png?e735b99"><img height=28 src="https://media.geolocatejs.org/images/icons/wire-globe/black/icon32.png?e735b99"></picture> geolocate
|
|
2
2
|
|
|
3
3
|
### Fetch IP geolocation data from the CLI.
|
|
4
4
|
|
|
5
|
-
<a href="https://
|
|
5
|
+
<a href="https://www.npmjs.com/package/@adamlui/geolocate"><img height=31 src="https://img.shields.io/npm/dm/@adamlui/geolocate?logo=npm&color=af68ff&logoColor=white&labelColor=464646&style=for-the-badge"></a>
|
|
6
|
+
<a href="#%EF%B8%8F-mit-license"><img height=31 src="https://img.shields.io/badge/License-MIT-orange.svg?logo=internetarchive&logoColor=white&labelColor=464646&style=for-the-badge"></a>
|
|
7
|
+
<a href="https://github.com/adamlui/js-utils/releases/tag/geolocate-2.0.8"><img height=31 src="https://img.shields.io/badge/Latest_Build-2.0.8-44cc11.svg?logo=icinga&logoColor=white&labelColor=464646&style=for-the-badge"></a>
|
|
6
8
|
<a href="https://www.npmjs.com/package/@adamlui/geolocate?activeTab=code"><img height=31 src="https://img.shields.io/npm/unpacked-size/%40adamlui%2Fgeolocate?style=for-the-badge&logo=ebox&logoColor=white&labelColor=464646&color=blue"></a>
|
|
7
|
-
<a href="https://github.com/adamlui/js-utils/blob/geolocate-2.0.
|
|
9
|
+
<a href="https://github.com/adamlui/js-utils/blob/geolocate-2.0.8/geolocate/dist/geolocate.min.js"><img height=31 src="https://img.shields.io/github/size/adamlui/js-utils/geolocate/dist/geolocate.min.js?branch=geolocate-2.0.8&label=Minified%20Size&logo=databricks&logoColor=white&labelColor=464646&color=ff69b4&style=for-the-badge"></a>
|
|
8
10
|
<a href="https://sonarcloud.io/component_measures?metric=new_vulnerabilities&id=adamlui_js-utils:geolocate/src/geolocate.js"><img height=31 src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fsonarcloud.io%2Fapi%2Fmeasures%2Fcomponent%3Fcomponent%3Dadamlui_js-utils%3Ageolocate%2Fsrc%2Fgeolocate.js%26metricKeys%3Dvulnerabilities&query=%24.component.measures.0.value&style=for-the-badge&logo=sonarcloud&logoColor=white&labelColor=464646&label=Vulnerabilities&color=gold"></a>
|
|
9
11
|
|
|
10
12
|
<br>
|
|
11
13
|
|
|
12
|
-
<img height=6px width="100%" src="https://
|
|
14
|
+
<img height=6px width="100%" src="https://media.js-utils.com/images/separators/gradient-aqua.png?c0192d3">
|
|
13
15
|
|
|
14
16
|
## ⚡ Installation
|
|
15
17
|
|
|
@@ -33,7 +35,7 @@ $ npm install @adamlui/geolocate
|
|
|
33
35
|
|
|
34
36
|
<br>
|
|
35
37
|
|
|
36
|
-
<img height=6px width="100%" src="https://
|
|
38
|
+
<img height=6px width="100%" src="https://media.js-utils.com/images/separators/gradient-aqua.png?c0192d3">
|
|
37
39
|
|
|
38
40
|
## 💻 Command line usage
|
|
39
41
|
|
|
@@ -45,7 +47,7 @@ $ geolocate [ip1] [ip2] [...]
|
|
|
45
47
|
|
|
46
48
|
Sample output:
|
|
47
49
|
|
|
48
|
-
<img src="https://
|
|
50
|
+
<img src="https://media.geolocatejs.org/images/screenshots/cli/geolocate-8.8.8.8-cmd-output.png?7b16322">
|
|
49
51
|
|
|
50
52
|
**📝 Note:** If no IPv4 address is passed, your own one will be used.
|
|
51
53
|
|
|
@@ -62,13 +64,13 @@ Info commands:
|
|
|
62
64
|
|
|
63
65
|
<br>
|
|
64
66
|
|
|
65
|
-
<img height=6px width="100%" src="https://
|
|
67
|
+
<img height=6px width="100%" src="https://media.js-utils.com/images/separators/gradient-aqua.png?c0192d3">
|
|
66
68
|
|
|
67
69
|
## 🔌 Importing the API
|
|
68
70
|
|
|
69
71
|
You can also import **geolocate** into your app to use its main API method.
|
|
70
72
|
|
|
71
|
-
### <img height=18 src="https://
|
|
73
|
+
### <img height=18 src="https://media.js-utils.com/images/icons/platforms/node.js/icon25x28.png?3e22bae"> Node.js
|
|
72
74
|
|
|
73
75
|
#### ECMAScript*:
|
|
74
76
|
|
|
@@ -84,28 +86,28 @@ const geo = require('@adamlui/geolocate');
|
|
|
84
86
|
|
|
85
87
|
###### _*Node.js version 14 or higher required_
|
|
86
88
|
|
|
87
|
-
### <picture><source media="(prefers-color-scheme: dark)" srcset="https://
|
|
89
|
+
### <picture><source media="(prefers-color-scheme: dark)" srcset="https://media.js-utils.com/images/icons/platforms/web/light/icon25.png?3e22bae"><img width=16 src="https://media.js-utils.com/images/icons/platforms/web/dark/icon25.png?3e22bae"></picture> Web
|
|
88
90
|
|
|
89
91
|
#### <> HTML script tag:
|
|
90
92
|
|
|
91
93
|
```html
|
|
92
|
-
<script src="https://cdn.jsdelivr.net/npm/@adamlui/geolocate@2.0.
|
|
94
|
+
<script src="https://cdn.jsdelivr.net/npm/@adamlui/geolocate@2.0.8/dist/geolocate.min.js"></script>
|
|
93
95
|
```
|
|
94
96
|
|
|
95
97
|
#### ES6:
|
|
96
98
|
|
|
97
99
|
```js
|
|
98
100
|
(async () => {
|
|
99
|
-
await import('https://cdn.jsdelivr.net/npm/@adamlui/geolocate@2.0.
|
|
101
|
+
await import('https://cdn.jsdelivr.net/npm/@adamlui/geolocate@2.0.8/dist/geolocate.min.js');
|
|
100
102
|
// Your code here...
|
|
101
103
|
})();
|
|
102
104
|
```
|
|
103
105
|
|
|
104
|
-
### <img height=17 src="https://
|
|
106
|
+
### <img height=17 src="https://media.js-utils.com/images/icons/platforms/tampermonkey/icon28.png?4fd2fa7"><img height=17.5 src="https://media.js-utils.com/images/icons/platforms/violentmonkey/icon25.png?2fe972c"> Greasemonkey
|
|
105
107
|
|
|
106
108
|
```js
|
|
107
109
|
...
|
|
108
|
-
// @require https://cdn.jsdelivr.net/npm/@adamlui/geolocate@2.0.
|
|
110
|
+
// @require https://cdn.jsdelivr.net/npm/@adamlui/geolocate@2.0.8/dist/geolocate.min.js
|
|
109
111
|
// ==/UserScript==
|
|
110
112
|
|
|
111
113
|
// Your code here...
|
|
@@ -113,11 +115,11 @@ const geo = require('@adamlui/geolocate');
|
|
|
113
115
|
|
|
114
116
|
<br>
|
|
115
117
|
|
|
116
|
-
**📝 Note:** To always import the latest version (not recommended in production!) remove the `@2.0.
|
|
118
|
+
**📝 Note:** To always import the latest version (not recommended in production!) remove the `@2.0.8` version tag from the jsDelivr URL: `https://cdn.jsdelivr.net/npm/@adamlui/geolocate/dist/geolocate.min.js`
|
|
117
119
|
|
|
118
120
|
<br>
|
|
119
121
|
|
|
120
|
-
<img height=6px width="100%" src="https://
|
|
122
|
+
<img height=6px width="100%" src="https://media.js-utils.com/images/separators/gradient-aqua.png?c0192d3">
|
|
121
123
|
|
|
122
124
|
## 📋 API usage
|
|
123
125
|
|
|
@@ -168,11 +170,11 @@ Name | Type | Description | Default Value
|
|
|
168
170
|
|
|
169
171
|
<br>
|
|
170
172
|
|
|
171
|
-
<img height=6px width="100%" src="https://
|
|
173
|
+
<img height=6px width="100%" src="https://media.js-utils.com/images/separators/gradient-aqua.png?c0192d3">
|
|
172
174
|
|
|
173
175
|
## 🏛️ MIT License
|
|
174
176
|
|
|
175
|
-
**Copyright ©
|
|
177
|
+
**Copyright © 2024 [Adam Lui](https://github.com/adamlui).**
|
|
176
178
|
|
|
177
179
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
178
180
|
|
|
@@ -182,32 +184,32 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
|
|
|
182
184
|
|
|
183
185
|
<br>
|
|
184
186
|
|
|
185
|
-
<img height=6px width="100%" src="https://
|
|
187
|
+
<img height=6px width="100%" src="https://media.js-utils.com/images/separators/gradient-aqua.png?c0192d3">
|
|
186
188
|
|
|
187
189
|
## 🛠️ Related utilities
|
|
188
190
|
|
|
189
|
-
### <picture><source media="(prefers-color-scheme: dark)" srcset="https://
|
|
191
|
+
### <picture><source media="(prefers-color-scheme: dark)" srcset="https://media.generate-ip.org/images/icons/node-graph/white/icon55x49.png?b4eb06e"><img height=21 src="https://media.generate-ip.org/images/icons/node-graph/black/icon55x49.png?b4eb06e"></picture> [generate-ip](https://js-utils.com/generate-ip) <a href="https://github.com/toolleeo/cli-apps#networking"><img height=18 src="https://media.js-utils.com/images/badges/awesome/badge.svg?7b16322"></a>
|
|
190
192
|
|
|
191
|
-
> Randomly generate, format, and validate IPv4
|
|
192
|
-
<br>[Install](https://docs.
|
|
193
|
-
[Readme](https://docs.
|
|
194
|
-
[API usage](https://docs.
|
|
195
|
-
[CLI usage](https://docs.
|
|
193
|
+
> Randomly generate, format, and validate IPv4 + IPv6 + MAC addresses.
|
|
194
|
+
<br>[Install](https://docs.generate-ip.org/#-installation) /
|
|
195
|
+
[Readme](https://docs.generate-ip.org/#readme) /
|
|
196
|
+
[API usage](https://docs.generate-ip.org/#-api-usage) /
|
|
197
|
+
[CLI usage](https://docs.generate-ip.org/#-command-line-usage) /
|
|
196
198
|
[Discuss](https://github.js-utils.com/discussions)
|
|
197
199
|
|
|
198
|
-
### [🔒 generate-pw](../generate-pw) <a href="https://github.com/toolleeo/cli-apps#password-managers"><img height=18 src="https://
|
|
200
|
+
### [🔒 generate-pw](../generate-pw) <a href="https://github.com/toolleeo/cli-apps#password-managers"><img height=18 src="https://media.js-utils.com/images/badges/awesome/badge.svg?7b16322"></a>
|
|
199
201
|
|
|
200
202
|
> Randomly generate, strengthen, and validate cryptographically-secure passwords.
|
|
201
|
-
<br>[Install](https://docs.
|
|
202
|
-
[Readme](https://docs.
|
|
203
|
-
[API usage](https://docs.
|
|
204
|
-
[CLI usage](https://docs.
|
|
203
|
+
<br>[Install](https://docs.generatepw.org/#-installation) /
|
|
204
|
+
[Readme](https://docs.generatepw.org/#readme) /
|
|
205
|
+
[API usage](https://docs.generatepw.org/#-api-usage) /
|
|
206
|
+
[CLI usage](https://docs.generatepw.org/#-command-line-usage) /
|
|
205
207
|
[Discuss](https://github.js-utils.com/discussions)
|
|
206
208
|
|
|
207
209
|
<br>
|
|
208
210
|
|
|
209
|
-
<img height=6px width="100%" src="https://
|
|
211
|
+
<img height=6px width="100%" src="https://media.js-utils.com/images/separators/gradient-aqua.png?c0192d3">
|
|
210
212
|
|
|
211
|
-
<picture><source media="(prefers-color-scheme: dark)" srcset="https://
|
|
213
|
+
<picture><source media="(prefers-color-scheme: dark)" srcset="https://media.js-utils.com/images/icons/home/white/icon32x27.png?e735b99"><img height=13 src="https://media.js-utils.com/images/icons/home/dark-gray/icon32x27.png?e735b99"></picture> <a href="https://js-utils.com">**More JavaScript utilities**</a> /
|
|
212
214
|
<a href="https://github.js-utils.com/discussions">Discuss</a> /
|
|
213
215
|
<a href="#-geolocate">Back to top ↑</a>
|
package/dist/cli.min.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
3
|
* © 2024 Adam Lui under the MIT license.
|
|
4
|
-
* Source: https://code.
|
|
5
|
-
* Documentation: https://docs.
|
|
4
|
+
* Source: https://code.geolocatejs.org
|
|
5
|
+
* Documentation: https://docs.geolocatejs.org
|
|
6
6
|
*/
|
|
7
|
-
const pkgName="@adamlui/geolocate",copyright="© 2024 Adam Lui under the MIT license.",cmdFormat="geolocate [ip1] [ip2] [...] [options|commands]",srcURL="https://code.
|
|
7
|
+
const pkgName="@adamlui/geolocate",copyright="© 2024 Adam Lui under the MIT license.",cmdFormat="geolocate [ip1] [ip2] [...] [options|commands]",srcURL="https://code.geolocatejs.org",docURL="https://docs.geolocatejs.org/#-command-line-usage";(async()=>{const e=require(__dirname.match(/src/)?"./geolocate":"./geolocate.min"),n=require("fs"),s=require("path"),i=require("child_process")["execSync"],t="[0m",r="[1;97m";let p="en";if("win32"==process.platform)try{p=i("(Get-Culture).TwoLetterISOLanguageName",{shell:"powershell",encoding:"utf-8"}).trim()}catch(e){}else{var c=process.env;p=(c.LANG||c.LANGUAGE||c.LC_ALL||c.LC_MESSAGES||c.LC_NAME||"en").split(".")[0]}let a={};var o,c=new Promise((t,r)=>{const c="https://cdn.jsdelivr.net/gh/adamlui/js-utils@a5c8e2226bf51470166791e66238cb4e3ed0e2d8/geolocate/_locales/",e=(p?p.replace("-","_"):"en")+"/";let a=c+e+"messages.json",l=0;h(a).then(async function o(e){try{const n=await e.json(),s={};for(const i in n)"object"==typeof n[i]&&"message"in n[i]&&(s[i]=n[i].message);t(s)}catch(e){if(3==++l)return t({});h(a=p.includes("-")&&1==l?a.replace(/([^_]*)_[^/]*(\/.*)/,"$1$2"):c+"en/messages.json").then(o).catch(r)}}).catch(r)});try{a=await c}catch(e){}const l={},g={flags:{quietMode:/^--?q(?:uiet)?(?:-?mode)?$/},infoCmds:{help:/^--?h(?:elp)?$/,version:/^--?ve?r?s?i?o?n?$/}};if(process.argv.forEach(o=>{var e,n;o.startsWith("-")&&(e=Object.keys(g.flags).find(e=>g.flags[e].test(o)),n=Object.keys(g.infoCmds).find(e=>g.infoCmds[e].test(o)),e?l[e]=!0:n||(console.error(`
|
|
8
8
|
${"[1;91m"+(a.prefix_error||"ERROR")}: `+`Arg [${o}] ${a.error_notRecognized||"not recognized"}.[0m`),console.info(`
|
|
9
9
|
${"[1;33m"+(a.info_validArgs||"Valid arguments are below")}.[0m`),u(["configOptions","infoCmds"]),process.exit(1)))}),process.argv.some(e=>g.infoCmds.help.test(e)))u();else if(process.argv.some(e=>g.infoCmds.version.test(e))){c=i(`npm view ${pkgName} version`).toString().trim()||"none";let e,o=process.cwd();for(;"/"!=o;){var m=s.join(o,"package.json");if(n.existsSync(m)){m=require(m);e=(m.dependencies?.[pkgName]||m.devDependencies?.[pkgName])?.match(/(\d+\.\d+\.\d+)/)[0]||"none";break}o=s.dirname(o)}console.info(`
|
|
10
10
|
${a.prefix_globalVer||"Global version"}: `+c),console.info(`${a.prefix_localVer||"Local version"}: `+e)}else{var f,d=[];for(const $ of process.argv.slice(2))$.startsWith("-")||(f=$.replace(/[[\]]/g,""),d.push(f));c=await e.locate(d,{verbose:!l.quietMode});c||process.exit(1),l.quietMode||1!=c.length||(console.info(`
|
package/dist/geolocate.min.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* © 2024 Adam Lui under the MIT license.
|
|
3
|
-
* Source: https://code.
|
|
4
|
-
* Documentation: https://docs.
|
|
3
|
+
* Source: https://code.geolocatejs.org
|
|
4
|
+
* Documentation: https://docs.geolocatejs.org
|
|
5
5
|
*/
|
|
6
|
-
async function geolocate(e,
|
|
6
|
+
async function geolocate(e,n={}){var o={verbose:!0};(e=Array.isArray(e)?e:[e])[0]=e[0]||await fetch("https://ifconfig.me/ip").then(e=>e.text()).catch(()=>fetch("http://ip-api.com/json/").then(e=>e.json()).then(e=>e.query)).catch(async()=>{try{var e=require("child_process")["exec"],o=require("util")["promisify"],{stdout:t,stderr:r}=await o(e)("curl -s ifconfig.me");return r?console.error("geolocate() »",r):t.trim()}catch(e){console.error("geolocate() »",e)}});for(const t of e){n.verbose&&console.info(`geolocate() » Validating ${t}...`);let o;try{o=require("generate-ip").ipv4.validate}catch(e){await import("https://cdn.jsdelivr.net/npm/generate-ip/dist/generate-ip.min.js"),o=ipv4.validate}if(o&&!o(t,{verbose:!1}))return console.error(`geolocate() » ERROR: ${t} is not a valid IPv4 address.`)}if(validateOptions(n,o,"https://docs.geolocatejs.org/#locateips-options","geolocate('8.8.8.8', { verbose: false })")){n={...o,...n};try{var c=[];for(const i of e){n.verbose&&console.info(`geolocate() » Fetching geolocation data for ${i}...`);let{status:e,org:o,as:t,query:r,...a}=await(await fetchData("http://ip-api.com/json/"+i)).json();a={ip:i,...a},c.push(a)}return!n.verbose||"undefined"!=typeof require&&/cli(?:\.min)?\.js$/.test(require.main.filename)||console.info("geolocate() » Success! Check returned array."),c}catch(e){console.error("geolocate() » ERROR:",e.message)}}}function fetchData(r){return"undefined"==typeof fetch?new Promise((t,o)=>{try{var e=r.match(/^([^:]+):\/\//)[1];/^https?$/.test(e)||o(new Error("Invalid fetchData() URL.")),require(e).get(r,e=>{let o="";e.on("data",e=>o+=e),e.on("end",()=>t({json:()=>JSON.parse(o)}))}).on("error",e=>o(new Error(e.message)))}catch(e){o(new Error("Environment not supported."))}}):fetch(r)}function validateOptions(e,o,t,r){const a=JSON.stringify(o,null,2).replace(/"([^"]+)":/g,"$1:").replace(/"/g,"'").replace(/\n\s*/g," "),n=Object.keys(o).join(", "),c=Object.keys(o).filter(e=>"boolean"==typeof o[e]);let i="validateOptions() » ";try{i=validateOptions.caller?.name+"() » "}catch(e){}var s=r.split(",").findIndex(e=>e.trim().startsWith("{"))+1,l=(s+=["st","nd","rd"][s-1]||"th",()=>{console.info(`${i}Valid options: [ ${n} ]`),console.info(i+"If omitted, default settings are: "+a)}),f=()=>{console.info(i+"For more help, please visit "+t)};if("object"!=typeof e)return console.error(i+`ERROR: ${"0th"==s?"[O":s+" arg [o"}ptions] can only be an object of key/values.`),console.info(i+"Example valid call: "+r),l(),f(),!1;for(const p in e){if(!Object.prototype.hasOwnProperty.call(o,p))return console.error(`${i}ERROR: \`${p}\` is an invalid option.`),l(),f(),!1;if(c.includes(p)&&"boolean"!=typeof e[p])return console.error(`${i}ERROR: [${p}] option can only be \`true\` or \`false\`.`),f(),!1}return!0}const funcAliases={geolocate:["Geolocate","geoLocate","GeoLocate","locate","Locate"]};try{module.exports={geolocate:geolocate}}catch(e){}try{window.geo={geolocate:geolocate}}catch(e){}for(const _ in funcAliases){try{funcAliases[_].forEach(e=>module.exports[e]=module.exports[_])}catch(e){}try{funcAliases[_].forEach(e=>window.geo[e]=window.geo[_])}catch(e){}}
|
package/docs/README.md
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
# <picture><source media="(prefers-color-scheme: dark)" srcset="https://
|
|
1
|
+
# <picture><source media="(prefers-color-scheme: dark)" srcset="https://media.geolocatejs.org/images/icons/wire-globe/white/icon32.png?e735b99"><img height=28 src="https://media.geolocatejs.org/images/icons/wire-globe/black/icon32.png?e735b99"></picture> geolocate
|
|
2
2
|
|
|
3
3
|
### Fetch IP geolocation data from the CLI.
|
|
4
4
|
|
|
5
|
-
<a href="https://
|
|
5
|
+
<a href="https://www.npmjs.com/package/@adamlui/geolocate"><img height=31 src="https://img.shields.io/npm/dm/@adamlui/geolocate?logo=npm&color=af68ff&logoColor=white&labelColor=464646&style=for-the-badge"></a>
|
|
6
|
+
<a href="#%EF%B8%8F-mit-license"><img height=31 src="https://img.shields.io/badge/License-MIT-orange.svg?logo=internetarchive&logoColor=white&labelColor=464646&style=for-the-badge"></a>
|
|
7
|
+
<a href="https://github.com/adamlui/js-utils/releases/tag/geolocate-2.0.8"><img height=31 src="https://img.shields.io/badge/Latest_Build-2.0.8-44cc11.svg?logo=icinga&logoColor=white&labelColor=464646&style=for-the-badge"></a>
|
|
6
8
|
<a href="https://www.npmjs.com/package/@adamlui/geolocate?activeTab=code"><img height=31 src="https://img.shields.io/npm/unpacked-size/%40adamlui%2Fgeolocate?style=for-the-badge&logo=ebox&logoColor=white&labelColor=464646&color=blue"></a>
|
|
7
|
-
<a href="https://github.com/adamlui/js-utils/blob/geolocate-2.0.
|
|
9
|
+
<a href="https://github.com/adamlui/js-utils/blob/geolocate-2.0.8/geolocate/dist/geolocate.min.js"><img height=31 src="https://img.shields.io/github/size/adamlui/js-utils/geolocate/dist/geolocate.min.js?branch=geolocate-2.0.8&label=Minified%20Size&logo=databricks&logoColor=white&labelColor=464646&color=ff69b4&style=for-the-badge"></a>
|
|
8
10
|
<a href="https://sonarcloud.io/component_measures?metric=new_vulnerabilities&id=adamlui_js-utils:geolocate/src/geolocate.js"><img height=31 src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fsonarcloud.io%2Fapi%2Fmeasures%2Fcomponent%3Fcomponent%3Dadamlui_js-utils%3Ageolocate%2Fsrc%2Fgeolocate.js%26metricKeys%3Dvulnerabilities&query=%24.component.measures.0.value&style=for-the-badge&logo=sonarcloud&logoColor=white&labelColor=464646&label=Vulnerabilities&color=gold"></a>
|
|
9
11
|
|
|
10
12
|
<br>
|
|
11
13
|
|
|
12
|
-
<img height=6px width="100%" src="https://
|
|
14
|
+
<img height=6px width="100%" src="https://media.js-utils.com/images/separators/gradient-aqua.png?c0192d3">
|
|
13
15
|
|
|
14
16
|
## ⚡ Installation
|
|
15
17
|
|
|
@@ -33,7 +35,7 @@ $ npm install @adamlui/geolocate
|
|
|
33
35
|
|
|
34
36
|
<br>
|
|
35
37
|
|
|
36
|
-
<img height=6px width="100%" src="https://
|
|
38
|
+
<img height=6px width="100%" src="https://media.js-utils.com/images/separators/gradient-aqua.png?c0192d3">
|
|
37
39
|
|
|
38
40
|
## 💻 Command line usage
|
|
39
41
|
|
|
@@ -45,7 +47,7 @@ $ geolocate [ip1] [ip2] [...]
|
|
|
45
47
|
|
|
46
48
|
Sample output:
|
|
47
49
|
|
|
48
|
-
<img src="https://
|
|
50
|
+
<img src="https://media.geolocatejs.org/images/screenshots/cli/geolocate-8.8.8.8-cmd-output.png?7b16322">
|
|
49
51
|
|
|
50
52
|
**📝 Note:** If no IPv4 address is passed, your own one will be used.
|
|
51
53
|
|
|
@@ -62,13 +64,13 @@ Info commands:
|
|
|
62
64
|
|
|
63
65
|
<br>
|
|
64
66
|
|
|
65
|
-
<img height=6px width="100%" src="https://
|
|
67
|
+
<img height=6px width="100%" src="https://media.js-utils.com/images/separators/gradient-aqua.png?c0192d3">
|
|
66
68
|
|
|
67
69
|
## 🔌 Importing the API
|
|
68
70
|
|
|
69
71
|
You can also import **geolocate** into your app to use its main API method.
|
|
70
72
|
|
|
71
|
-
### <img height=18 src="https://
|
|
73
|
+
### <img height=18 src="https://media.js-utils.com/images/icons/platforms/node.js/icon25x28.png?3e22bae"> Node.js
|
|
72
74
|
|
|
73
75
|
#### ECMAScript*:
|
|
74
76
|
|
|
@@ -84,28 +86,28 @@ const geo = require('@adamlui/geolocate');
|
|
|
84
86
|
|
|
85
87
|
###### _*Node.js version 14 or higher required_
|
|
86
88
|
|
|
87
|
-
### <picture><source media="(prefers-color-scheme: dark)" srcset="https://
|
|
89
|
+
### <picture><source media="(prefers-color-scheme: dark)" srcset="https://media.js-utils.com/images/icons/platforms/web/light/icon25.png?3e22bae"><img width=16 src="https://media.js-utils.com/images/icons/platforms/web/dark/icon25.png?3e22bae"></picture> Web
|
|
88
90
|
|
|
89
91
|
#### <> HTML script tag:
|
|
90
92
|
|
|
91
93
|
```html
|
|
92
|
-
<script src="https://cdn.jsdelivr.net/npm/@adamlui/geolocate@2.0.
|
|
94
|
+
<script src="https://cdn.jsdelivr.net/npm/@adamlui/geolocate@2.0.8/dist/geolocate.min.js"></script>
|
|
93
95
|
```
|
|
94
96
|
|
|
95
97
|
#### ES6:
|
|
96
98
|
|
|
97
99
|
```js
|
|
98
100
|
(async () => {
|
|
99
|
-
await import('https://cdn.jsdelivr.net/npm/@adamlui/geolocate@2.0.
|
|
101
|
+
await import('https://cdn.jsdelivr.net/npm/@adamlui/geolocate@2.0.8/dist/geolocate.min.js');
|
|
100
102
|
// Your code here...
|
|
101
103
|
})();
|
|
102
104
|
```
|
|
103
105
|
|
|
104
|
-
### <img height=17 src="https://
|
|
106
|
+
### <img height=17 src="https://media.js-utils.com/images/icons/platforms/tampermonkey/icon28.png?4fd2fa7"><img height=17.5 src="https://media.js-utils.com/images/icons/platforms/violentmonkey/icon25.png?2fe972c"> Greasemonkey
|
|
105
107
|
|
|
106
108
|
```js
|
|
107
109
|
...
|
|
108
|
-
// @require https://cdn.jsdelivr.net/npm/@adamlui/geolocate@2.0.
|
|
110
|
+
// @require https://cdn.jsdelivr.net/npm/@adamlui/geolocate@2.0.8/dist/geolocate.min.js
|
|
109
111
|
// ==/UserScript==
|
|
110
112
|
|
|
111
113
|
// Your code here...
|
|
@@ -113,11 +115,11 @@ const geo = require('@adamlui/geolocate');
|
|
|
113
115
|
|
|
114
116
|
<br>
|
|
115
117
|
|
|
116
|
-
**📝 Note:** To always import the latest version (not recommended in production!) remove the `@2.0.
|
|
118
|
+
**📝 Note:** To always import the latest version (not recommended in production!) remove the `@2.0.8` version tag from the jsDelivr URL: `https://cdn.jsdelivr.net/npm/@adamlui/geolocate/dist/geolocate.min.js`
|
|
117
119
|
|
|
118
120
|
<br>
|
|
119
121
|
|
|
120
|
-
<img height=6px width="100%" src="https://
|
|
122
|
+
<img height=6px width="100%" src="https://media.js-utils.com/images/separators/gradient-aqua.png?c0192d3">
|
|
121
123
|
|
|
122
124
|
## 📋 API usage
|
|
123
125
|
|
|
@@ -168,11 +170,11 @@ Name | Type | Description | Default Value
|
|
|
168
170
|
|
|
169
171
|
<br>
|
|
170
172
|
|
|
171
|
-
<img height=6px width="100%" src="https://
|
|
173
|
+
<img height=6px width="100%" src="https://media.js-utils.com/images/separators/gradient-aqua.png?c0192d3">
|
|
172
174
|
|
|
173
175
|
## 🏛️ MIT License
|
|
174
176
|
|
|
175
|
-
**Copyright ©
|
|
177
|
+
**Copyright © 2024 [Adam Lui](https://github.com/adamlui).**
|
|
176
178
|
|
|
177
179
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
178
180
|
|
|
@@ -182,32 +184,32 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
|
|
|
182
184
|
|
|
183
185
|
<br>
|
|
184
186
|
|
|
185
|
-
<img height=6px width="100%" src="https://
|
|
187
|
+
<img height=6px width="100%" src="https://media.js-utils.com/images/separators/gradient-aqua.png?c0192d3">
|
|
186
188
|
|
|
187
189
|
## 🛠️ Related utilities
|
|
188
190
|
|
|
189
|
-
### <picture><source media="(prefers-color-scheme: dark)" srcset="https://
|
|
191
|
+
### <picture><source media="(prefers-color-scheme: dark)" srcset="https://media.generate-ip.org/images/icons/node-graph/white/icon55x49.png?b4eb06e"><img height=21 src="https://media.generate-ip.org/images/icons/node-graph/black/icon55x49.png?b4eb06e"></picture> [generate-ip](https://js-utils.com/generate-ip) <a href="https://github.com/toolleeo/cli-apps#networking"><img height=18 src="https://media.js-utils.com/images/badges/awesome/badge.svg?7b16322"></a>
|
|
190
192
|
|
|
191
|
-
> Randomly generate, format, and validate IPv4
|
|
192
|
-
<br>[Install](https://docs.
|
|
193
|
-
[Readme](https://docs.
|
|
194
|
-
[API usage](https://docs.
|
|
195
|
-
[CLI usage](https://docs.
|
|
193
|
+
> Randomly generate, format, and validate IPv4 + IPv6 + MAC addresses.
|
|
194
|
+
<br>[Install](https://docs.generate-ip.org/#-installation) /
|
|
195
|
+
[Readme](https://docs.generate-ip.org/#readme) /
|
|
196
|
+
[API usage](https://docs.generate-ip.org/#-api-usage) /
|
|
197
|
+
[CLI usage](https://docs.generate-ip.org/#-command-line-usage) /
|
|
196
198
|
[Discuss](https://github.js-utils.com/discussions)
|
|
197
199
|
|
|
198
|
-
### [🔒 generate-pw](../generate-pw) <a href="https://github.com/toolleeo/cli-apps#password-managers"><img height=18 src="https://
|
|
200
|
+
### [🔒 generate-pw](../generate-pw) <a href="https://github.com/toolleeo/cli-apps#password-managers"><img height=18 src="https://media.js-utils.com/images/badges/awesome/badge.svg?7b16322"></a>
|
|
199
201
|
|
|
200
202
|
> Randomly generate, strengthen, and validate cryptographically-secure passwords.
|
|
201
|
-
<br>[Install](https://docs.
|
|
202
|
-
[Readme](https://docs.
|
|
203
|
-
[API usage](https://docs.
|
|
204
|
-
[CLI usage](https://docs.
|
|
203
|
+
<br>[Install](https://docs.generatepw.org/#-installation) /
|
|
204
|
+
[Readme](https://docs.generatepw.org/#readme) /
|
|
205
|
+
[API usage](https://docs.generatepw.org/#-api-usage) /
|
|
206
|
+
[CLI usage](https://docs.generatepw.org/#-command-line-usage) /
|
|
205
207
|
[Discuss](https://github.js-utils.com/discussions)
|
|
206
208
|
|
|
207
209
|
<br>
|
|
208
210
|
|
|
209
|
-
<img height=6px width="100%" src="https://
|
|
211
|
+
<img height=6px width="100%" src="https://media.js-utils.com/images/separators/gradient-aqua.png?c0192d3">
|
|
210
212
|
|
|
211
|
-
<picture><source media="(prefers-color-scheme: dark)" srcset="https://
|
|
213
|
+
<picture><source media="(prefers-color-scheme: dark)" srcset="https://media.js-utils.com/images/icons/home/white/icon32x27.png?e735b99"><img height=13 src="https://media.js-utils.com/images/icons/home/dark-gray/icon32x27.png?e735b99"></picture> <a href="https://js-utils.com">**More JavaScript utilities**</a> /
|
|
212
214
|
<a href="https://github.js-utils.com/discussions">Discuss</a> /
|
|
213
215
|
<a href="#-geolocate">Back to top ↑</a>
|
package/docs/SECURITY.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# 🛡️ Security Policy
|
|
2
2
|
|
|
3
|
-
If you find a vulnerability, please open a [draft security advisory](https://github.
|
|
3
|
+
If you find a vulnerability, please open a [draft security advisory](https://github.js-utils.com/security/advisories/new).
|
|
4
4
|
|
|
5
5
|
Pull requests are also welcome, but for safety reasons, send an email to <adam@kudoai.com> and wait for a response before making it public.
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adamlui/geolocate",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.8",
|
|
4
4
|
"description": "Fetch IP geolocation data from the CLI.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Adam Lui",
|
|
7
7
|
"email": "adam@kudoai.com",
|
|
8
8
|
"url": "https://github.com/adamlui"
|
|
9
9
|
},
|
|
10
|
-
"homepage": "https://
|
|
10
|
+
"homepage": "https://geolocatejs.org",
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"main": "dist/geolocate.min.js",
|
|
13
13
|
"files": [
|
|
@@ -47,9 +47,9 @@
|
|
|
47
47
|
"url": "https://github.com/adamlui/js-utils/issues"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"generate-ip": "^2.
|
|
50
|
+
"generate-ip": "^2.3.0"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@adamlui/minify.js": "^1.
|
|
53
|
+
"@adamlui/minify.js": "^1.6.1"
|
|
54
54
|
}
|
|
55
55
|
}
|