greip.js 2.3.4 → 2.4.0

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 CHANGED
@@ -16,11 +16,11 @@ The official Javascript package of Greip API
16
16
 
17
17
  [![npm version](https://badge.fury.io/js/greip.js.svg)](https://badge.fury.io/js/greip.js)
18
18
    
19
- ![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/gre-dev/javascript?color=green&label=Minified%20size&logo=github)
19
+ ![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/Greipio/javascript?color=green&label=Minified%20size&logo=github)
20
20
    
21
- [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
21
+ [![License: Apache 2.0](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/license/apache-2-0)
22
22
    
23
- ![API Status](https://img.shields.io/website?down_color=orange&down_message=down&label=API%20status&up_color=green&up_message=up&url=https%3A%2F%2Fgregeoip.com)
23
+ ![API Status](https://img.shields.io/website?down_color=orange&down_message=down&label=API%20status&up_color=green&up_message=up&url=https%3A%2F%greipapi.com)
24
24
 
25
25
  ---
26
26
 
@@ -104,7 +104,24 @@ await GeoIP({
104
104
  });
105
105
  ```
106
106
 
107
- ### 2. IP Lookup Method
107
+ ### 2. IP Threats Method
108
+
109
+ Use this method to retrieve threat intelligence information associated with a given IP address.
110
+
111
+ ```javascript
112
+ await Threats({
113
+ key: 'your-api-key',
114
+ ip: '1.1.1.1',
115
+ })
116
+ .then((res: any) => {
117
+ console.log(res.data); // Log Response
118
+ })
119
+ .catch((error: any) => {
120
+ console.log(error);
121
+ });
122
+ ```
123
+
124
+ ### 3. IP Lookup Method
108
125
 
109
126
  Use this method to retrieve the information of a given IP address.
110
127
 
@@ -121,7 +138,7 @@ await Lookup({
121
138
  });
122
139
  ```
123
140
 
124
- ### 3. Bulk IP Lookup Method
141
+ ### 4. Bulk IP Lookup Method
125
142
 
126
143
  You can use this method to retrieve the information of multiple IP addresses (no need to use the `Lookup` method inside a loop).
127
144
 
@@ -138,7 +155,7 @@ await BulkLookup({
138
155
  });
139
156
  ```
140
157
 
141
- ### 4. ASN Lookup Method
158
+ ### 5. ASN Lookup Method
142
159
 
143
160
  In this method, Greip will help you lookup any given AS Number and returning all data related to it, like: name, org (the organization name), country, domain, email, phone, totalIPs, list of all routes (v4 & v6) related the given AS Number, etc.
144
161
 
@@ -155,7 +172,7 @@ await ASN({
155
172
  });
156
173
  ```
157
174
 
158
- ### 5. Profanity Detection Method
175
+ ### 6. Profanity Detection Method
159
176
 
160
177
  This method can be used to detect abuse of your website/app. It’s a great way to know more about your user inputs and whether they contain profanity (bad words) or not before releasing them to the public.
161
178
 
@@ -172,7 +189,7 @@ await BadWord({
172
189
  });
173
190
  ```
174
191
 
175
- ### 6. Country Lookup Method
192
+ ### 7. Country Lookup Method
176
193
 
177
194
  This method can help you retrieve information of the given country.
178
195
 
@@ -189,7 +206,7 @@ await Country({
189
206
  });
190
207
  ```
191
208
 
192
- ### 7. Email Validation Method
209
+ ### 8. Email Validation Method
193
210
 
194
211
  This method provides an additional layer of validation for your system. While validating email syntax is important, it is not sufficient.
195
212
 
@@ -208,7 +225,7 @@ await EmailValidation({
208
225
  });
209
226
  ```
210
227
 
211
- ### 8. Phone Validation Method
228
+ ### 9. Phone Validation Method
212
229
 
213
230
  This method can be used as an extra-layer of your system for validating phone numbers. It validates phone number syntax and valid-possibility.
214
231
 
@@ -226,7 +243,7 @@ await PhoneValidation({
226
243
  });
227
244
  ```
228
245
 
229
- ### 9. Payment Fraud Prevention Method
246
+ ### 10. Payment Fraud Prevention Method
230
247
 
231
248
  Prevent financial losses by deploying AI-Powered modules.
232
249
 
@@ -303,7 +320,7 @@ await PaymentFraud({
303
320
  });
304
321
  ```
305
322
 
306
- ### 10. IBAN Validation Method
323
+ ### 11. IBAN Validation Method
307
324
 
308
325
  This method allows you to validate International Bank Account Numbers (IBANs) and retrieve additional information about the country associated with the IBAN.
309
326
 
package/lib/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { Options } from './types';
2
2
  export declare const GeoIP: (options: Options) => Promise<unknown>;
3
3
  export declare const Lookup: (options: Options) => Promise<unknown>;
4
+ export declare const Threats: (options: Options) => Promise<unknown>;
4
5
  export declare const BulkLookup: (options: Options) => Promise<unknown>;
5
6
  export declare const Country: (options: Options) => Promise<unknown>;
6
7
  export declare const BadWord: (options: Options) => Promise<unknown>;
package/lib/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.IBANValidation = exports.PhoneValidation = exports.PaymentFraud = exports.EmailValidation = exports.ASN = exports.BadWord = exports.Country = exports.BulkLookup = exports.Lookup = exports.GeoIP = void 0;
3
+ exports.IBANValidation = exports.PhoneValidation = exports.PaymentFraud = exports.EmailValidation = exports.ASN = exports.BadWord = exports.Country = exports.BulkLookup = exports.Threats = exports.Lookup = exports.GeoIP = void 0;
4
4
  var util_1 = require("./util");
5
5
  var GeoIP = function (options) {
6
6
  if (typeof options !== 'object')
@@ -116,6 +116,45 @@ var Lookup = function (options) {
116
116
  });
117
117
  };
118
118
  exports.Lookup = Lookup;
119
+ var Threats = function (options) {
120
+ if (typeof options !== 'object')
121
+ options = {};
122
+ if (!options.key || options.key.length < 1) {
123
+ throw new Error('You should pass the API Key.');
124
+ }
125
+ return new Promise(function (resolve, reject) {
126
+ var ip1 = options.ip || '';
127
+ var format1 = options.format || 'JSON';
128
+ var mode1 = options.mode || 'live';
129
+ // Validate the ip variable
130
+ if (ip1.length < 7) {
131
+ reject(new Error('You should pass the `ip` parameter.'));
132
+ }
133
+ // Validate the format variable
134
+ if (!util_1.availableFormats.includes(format1)) {
135
+ reject(new Error('The `format` option value "' +
136
+ format1 +
137
+ '" you specified is unknown.\nYou can use: `JSON`, `XML`, `CSV` or `Newline`.\nRead more at: https://docs.greip.io/api-reference/endpoint/ip-geolocation/ip-lookup'));
138
+ }
139
+ // Validate the mode variable
140
+ if (mode1 !== 'live' && mode1 !== 'test') {
141
+ reject(new Error('The `mode` option value "' +
142
+ mode1 +
143
+ '" you specified is unknown.\nYou can use: `live` or `test`.\nRead more at: https://docs.greip.io/api-reference/endpoint/ip-geolocation/ip-lookup'));
144
+ }
145
+ (0, util_1.makeHttpRquest)('threats', {
146
+ ip: ip1,
147
+ key: options.key,
148
+ format: format1,
149
+ mode: mode1,
150
+ }, function (res) {
151
+ if (typeof res !== 'object')
152
+ res = JSON.parse(res);
153
+ resolve(res);
154
+ });
155
+ });
156
+ };
157
+ exports.Threats = Threats;
119
158
  var BulkLookup = function (options) {
120
159
  if (typeof options !== 'object')
121
160
  options = {};
package/lib/util.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export declare const baseURL = "https://gregeoip.com/";
1
+ export declare const baseURL = "https://greipapi.com/";
2
2
  export declare const availableGeoIPParams: string[];
3
3
  export declare const availableLanguages: string[];
4
4
  export declare const availableFormats: string[];
package/lib/util.js CHANGED
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.makePostRquest = exports.makeHttpRquest = exports.serialize = exports.availableCountryParams = exports.availableFormats = exports.availableLanguages = exports.availableGeoIPParams = exports.baseURL = void 0;
4
4
  var axios_1 = require("axios");
5
- exports.baseURL = 'https://gregeoip.com/';
5
+ exports.baseURL = 'https://greipapi.com/';
6
6
  exports.availableGeoIPParams = ['location', 'security', 'timezone', 'currency', 'device'];
7
7
  exports.availableLanguages = ['EN', 'AR', 'DE', 'FR', 'ES', 'JA', 'ZH', 'RU'];
8
8
  exports.availableFormats = ['JSON', 'XML', 'CSV', 'Newline'];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "greip.js",
3
- "version": "2.3.4",
3
+ "version": "2.4.0",
4
4
  "description": "The official Javascript library of Greip.",
5
5
  "author": {
6
6
  "name": "Greip",