Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ipdata

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ipdata - npm Package Compare versions

Comparing version 2.0.0-next.2 to 2.0.0

1

lib/ipdata.d.ts

@@ -1,2 +0,1 @@

export declare function clearCache(ip?: string): void;
export interface LookupResponse {

@@ -3,0 +2,0 @@ ip: string;

62

lib/ipdata.js

@@ -14,3 +14,29 @@ "use strict";

var DEFAULT_IP = 'DEFAULT_IP';
var VALID_FIELDS = ['ip', 'is_eu', 'city', 'region', 'region_code', 'country_name', 'country_code', 'continent_name', 'continent_code', 'latitude', 'longitude', 'asn', 'organisation', 'postal', 'calling_code', 'flag', 'emoji_flag', 'emoji_unicode', 'carrier', 'languages', 'currency', 'time_zone', 'threat', 'count', 'status'];
var VALID_FIELDS = [
'ip',
'is_eu',
'city',
'region',
'region_code',
'country_name',
'country_code',
'continent_name',
'continent_code',
'latitude',
'longitude',
'asn',
'organisation',
'postal',
'calling_code',
'flag',
'emoji_flag',
'emoji_unicode',
'carrier',
'languages',
'currency',
'time_zone',
'threat',
'count',
'status',
];
var BASE_URL = 'https://api.ipdata.co/';

@@ -31,4 +57,3 @@ function isValidIP(ip) {

}
for (var _i = 0, fields_1 = fields; _i < fields_1.length; _i++) {
var field = fields_1[_i];
fields.forEach(function (field) {
var index = VALID_FIELDS.indexOf(field);

@@ -38,12 +63,5 @@ if (index === -1) {

}
}
});
return true;
}
function clearCache(ip) {
if (isValidIP(ip)) {
return cache.del(ip);
}
return cache.reset();
}
exports.clearCache = clearCache;
var IPData = /** @class */ (function () {

@@ -88,6 +106,3 @@ function IPData(apiKey, useCache) {

data = tslib_1.__assign(tslib_1.__assign({}, response.data), { status: response.status });
if (selectField) {
data = { 'select_field': response.data, status: response.status };
}
if (this.useCache) {
if ((!selectField || !fields) && this.useCache) {
cache.set(ip || DEFAULT_IP, data);

@@ -105,6 +120,3 @@ }

}
else {
throw e_1;
}
return [3 /*break*/, 4];
throw e_1;
case 4: return [2 /*return*/, cache.get(ip || DEFAULT_IP)];

@@ -117,3 +129,3 @@ }

return tslib_1.__awaiter(this, void 0, void 0, function () {
var params, _i, ips_1, ip, response, e_2, response;
var params, response, e_2, response;
return tslib_1.__generator(this, function (_a) {

@@ -126,8 +138,7 @@ switch (_a.label) {

}
for (_i = 0, ips_1 = ips; _i < ips_1.length; _i++) {
ip = ips_1[_i];
ips.forEach(function (ip) {
if (!isValidIP(ip)) {
throw new Error(ip + " is an invalid IP address.");
}
}
});
if (fields && isValidFields(fields)) {

@@ -149,6 +160,3 @@ params.fields = fields.join(',');

}
else {
throw e_2;
}
return [3 /*break*/, 4];
throw e_2;
case 4: return [2 /*return*/];

@@ -155,0 +163,0 @@ }

{
"name": "ipdata",
"version": "2.0.0-next.2",
"version": "2.0.0",
"description": "JavaScript library to gather information for an ip using https://ipdata.co.",

@@ -5,0 +5,0 @@ "main": "./lib/index.js",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc