Skip to content

Commit

Permalink
hotfix browser compat
Browse files Browse the repository at this point in the history
  • Loading branch information
dskvr committed Apr 8, 2024
1 parent e1de874 commit a965177
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "@nostrwatch/nocap-every-adapter-default",
"version": "1.2.1",
"version": "1.2.2",
"type": "module",
"main": "index.js",
"license": "MIT",
"dependencies": {
"@nostrwatch/nocap-dns-adapter-default": "^1.0.2",
"@nostrwatch/nocap-geo-adapter-default": "^1.0.2",
"@nostrwatch/nocap-geo-adapter-default": "^1.0.3",
"@nostrwatch/nocap-info-adapter-default": "^1.0.1",
"@nostrwatch/nocap-ssl-adapter-default": "^1.0.1",
"@nostrwatch/nocap-websocket-adapter-default": "^1.2.0"
Expand Down
14 changes: 13 additions & 1 deletion packages/nocap/adapters/default/GeoAdapterDefault/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,23 @@ import { fetch } from 'cross-fetch'
this.$ = parent
}

isNodeEnvironment() {
return typeof global !== 'undefined' && global?.process?.versions?.node;
}

getApiKey() {
if (this.isNodeEnvironment()) {
return process.env.IP_API_KEY ? process.env.IP_API_KEY : this.$.config.adapterOptions.geo.apiKey;
} else {
return this.$.config.adapterOptions.geo.apiKey;
}
}

async check_geo(){
let endpoint
const iparr = this.$.results.get('dns')?.data.ipv4
const ip = iparr[iparr.length-1]
const apiKey = typeof process !== 'undefined' && process?.env?.IP_API_KEY? process.env.IP_API_KEY: this.$.config.adapterOptions.geo.apiKey
const apiKey = this.getApiKey();
//todo, enable override via options
const fields = 'proxy,mobile,timezone,continent,continentCode,country,countryCode,region,regionName,city,district,zip,lat,lon,isp,as,asname,query'
if(typeof ip !== 'string')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nostrwatch/nocap-geo-adapter-default",
"version": "1.0.2",
"version": "1.0.3",
"type": "module",
"main": "index.js",
"license": "MIT",
Expand Down
4 changes: 2 additions & 2 deletions packages/nocap/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nostrwatch/nocap",
"version": "0.4.6",
"version": "0.4.7",
"main": "src/index.js",
"type": "module",
"license": "MIT",
Expand All @@ -10,7 +10,7 @@
},
"dependencies": {
"@nostrwatch/logger": "^0.0.5",
"@nostrwatch/nocap-every-adapter-default": "^1.2.1",
"@nostrwatch/nocap-every-adapter-default": "^1.2.2",
"@nostrwatch/utils": "^0.0.3",
"fetch-h2": "3.0.2",
"get-ssl-certificate": "2.3.3",
Expand Down

0 comments on commit a965177

Please sign in to comment.