greip.js 2.4.5 → 2.4.7
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 +5 -1
- package/lib/index.d.ts +12 -0
- package/lib/index.js +14 -10
- package/lib/types.d.ts +19 -0
- package/lib/util.d.ts +9 -0
- package/lib/util.js +29 -4
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -41,7 +41,7 @@ yarn add greip.js
|
|
|
41
41
|
### 2. For CDN Integration
|
|
42
42
|
|
|
43
43
|
```html
|
|
44
|
-
<script src="https://cdn.jsdelivr.net/gh/Greipio/javascript/greip.bundle.js" type="text/javascript"
|
|
44
|
+
<script src="https://cdn.jsdelivr.net/gh/Greipio/javascript/greip.bundle.js" type="text/javascript"></script>
|
|
45
45
|
```
|
|
46
46
|
|
|
47
47
|
### 3. For Node.js
|
|
@@ -346,3 +346,7 @@ You can find the full guide of this package by visiting our [documentation page]
|
|
|
346
346
|
|
|
347
347
|
- [Greip Developers](https://greip.io)
|
|
348
348
|
- [All Contributors](https://github.com/Greipio/javascript/graphs/contributors)
|
|
349
|
+
|
|
350
|
+
## Repo Activity
|
|
351
|
+
|
|
352
|
+

|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Options } from './types';
|
|
2
|
+
export declare const GeoIP: (options: Options) => Promise<unknown>;
|
|
3
|
+
export declare const Lookup: (options: Options) => Promise<unknown>;
|
|
4
|
+
export declare const Threats: (options: Options) => Promise<unknown>;
|
|
5
|
+
export declare const BulkLookup: (options: Options) => Promise<unknown>;
|
|
6
|
+
export declare const Country: (options: Options) => Promise<unknown>;
|
|
7
|
+
export declare const BadWord: (options: Options) => Promise<unknown>;
|
|
8
|
+
export declare const ASN: (options: Options) => Promise<unknown>;
|
|
9
|
+
export declare const EmailValidation: (options: Options) => Promise<unknown>;
|
|
10
|
+
export declare const PaymentFraud: (options: Options) => Promise<unknown>;
|
|
11
|
+
export declare const PhoneValidation: (options: Options) => Promise<unknown>;
|
|
12
|
+
export declare const IBANValidation: (options: Options) => Promise<unknown>;
|
package/lib/index.js
CHANGED
|
@@ -14,6 +14,8 @@ var GeoIP = function (options) {
|
|
|
14
14
|
var lang1 = options.lang || 'EN';
|
|
15
15
|
var mode1 = options.mode || 'live';
|
|
16
16
|
lang1 = lang1.toUpperCase();
|
|
17
|
+
// GFP data
|
|
18
|
+
var gfpData = (0, util_1.getGFP)();
|
|
17
19
|
// Validate the params variable items
|
|
18
20
|
params.forEach(function (perParam) {
|
|
19
21
|
if (perParam.length > 0) {
|
|
@@ -42,7 +44,7 @@ var GeoIP = function (options) {
|
|
|
42
44
|
mode1 +
|
|
43
45
|
'" you specified is unknown.\nYou can use: `live` or `test`.\nRead more at: https://docs.greip.io/api-reference/endpoint/ip-geolocation/geoip'));
|
|
44
46
|
}
|
|
45
|
-
(0, util_1.makeHttpRquest)('
|
|
47
|
+
(0, util_1.makeHttpRquest)('/geoip', {
|
|
46
48
|
key: options.key,
|
|
47
49
|
params: params.join(','),
|
|
48
50
|
format: format1,
|
|
@@ -52,6 +54,8 @@ var GeoIP = function (options) {
|
|
|
52
54
|
if (typeof res !== 'object')
|
|
53
55
|
res = JSON.parse(res);
|
|
54
56
|
resolve(res);
|
|
57
|
+
}, {
|
|
58
|
+
gfp: gfpData,
|
|
55
59
|
});
|
|
56
60
|
});
|
|
57
61
|
};
|
|
@@ -101,7 +105,7 @@ var Lookup = function (options) {
|
|
|
101
105
|
mode1 +
|
|
102
106
|
'" you specified is unknown.\nYou can use: `live` or `test`.\nRead more at: https://docs.greip.io/api-reference/endpoint/ip-geolocation/ip-lookup'));
|
|
103
107
|
}
|
|
104
|
-
(0, util_1.makeHttpRquest)('
|
|
108
|
+
(0, util_1.makeHttpRquest)('/lookup/ip', {
|
|
105
109
|
ip: ip1,
|
|
106
110
|
key: options.key,
|
|
107
111
|
params: params.join(','),
|
|
@@ -142,7 +146,7 @@ var Threats = function (options) {
|
|
|
142
146
|
mode1 +
|
|
143
147
|
'" 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
148
|
}
|
|
145
|
-
(0, util_1.makeHttpRquest)('threats', {
|
|
149
|
+
(0, util_1.makeHttpRquest)('/lookup/ip/threats', {
|
|
146
150
|
ip: ip1,
|
|
147
151
|
key: options.key,
|
|
148
152
|
format: format1,
|
|
@@ -207,7 +211,7 @@ var BulkLookup = function (options) {
|
|
|
207
211
|
mode1 +
|
|
208
212
|
'" you specified is unknown.\nYou can use: `live` or `test`.\nRead more at: https://docs.greip.io/api-reference/endpoint/ip-geolocation/ip-lookup'));
|
|
209
213
|
}
|
|
210
|
-
(0, util_1.makeHttpRquest)('
|
|
214
|
+
(0, util_1.makeHttpRquest)('/lookup/ip/bulk', {
|
|
211
215
|
ips: ips1,
|
|
212
216
|
key: options.key,
|
|
213
217
|
params: params.join(','),
|
|
@@ -268,7 +272,7 @@ var Country = function (options) {
|
|
|
268
272
|
mode1 +
|
|
269
273
|
'" you specified is unknown.\nYou can use: `live` or `test`.\nRead more at: https://docs.greip.io/api-reference/endpoint/other-services/country-data'));
|
|
270
274
|
}
|
|
271
|
-
(0, util_1.makeHttpRquest)('
|
|
275
|
+
(0, util_1.makeHttpRquest)('/lookup/country', {
|
|
272
276
|
CountryCode: countryCode,
|
|
273
277
|
key: options.key,
|
|
274
278
|
params: params.join(','),
|
|
@@ -318,7 +322,7 @@ var BadWord = function (options) {
|
|
|
318
322
|
mode1 +
|
|
319
323
|
'" you specified is unknown.\nYou can use: `live` or `test`.\nRead more at: https://docs.greip.io/api-reference/endpoint/other-services/profanity-detection'));
|
|
320
324
|
}
|
|
321
|
-
(0, util_1.makeHttpRquest)('
|
|
325
|
+
(0, util_1.makeHttpRquest)('/scoring/profanity', {
|
|
322
326
|
text: text1,
|
|
323
327
|
key: options.key,
|
|
324
328
|
params: params.join(','),
|
|
@@ -352,7 +356,7 @@ var ASN = function (options) {
|
|
|
352
356
|
mode1 +
|
|
353
357
|
'" you specified is unknown.\nYou can use: `live` or `test`.\nRead more at: https://docs.greip.io/api-reference/endpoint/ip-geolocation/asn-lookup'));
|
|
354
358
|
}
|
|
355
|
-
(0, util_1.makeHttpRquest)('
|
|
359
|
+
(0, util_1.makeHttpRquest)('/lookup/asn', {
|
|
356
360
|
asn: asn1,
|
|
357
361
|
key: options.key,
|
|
358
362
|
mode: mode1,
|
|
@@ -383,7 +387,7 @@ var EmailValidation = function (options) {
|
|
|
383
387
|
mode1 +
|
|
384
388
|
'" you specified is unknown.\nYou can use: `live` or `test`.\nRead more at: https://docs.greip.io/api-reference/endpoint/data-validation/email-lookup'));
|
|
385
389
|
}
|
|
386
|
-
(0, util_1.makeHttpRquest)('
|
|
390
|
+
(0, util_1.makeHttpRquest)('/scoring/email', {
|
|
387
391
|
email: email1,
|
|
388
392
|
key: options.key,
|
|
389
393
|
mode: mode1,
|
|
@@ -446,7 +450,7 @@ var PhoneValidation = function (options) {
|
|
|
446
450
|
mode1 +
|
|
447
451
|
'" you specified is unknown.\nYou can use: `live` or `test`.\nRead more at: https://docs.greip.io/api-reference/endpoint/data-validation/phone-lookup'));
|
|
448
452
|
}
|
|
449
|
-
(0, util_1.makeHttpRquest)('
|
|
453
|
+
(0, util_1.makeHttpRquest)('/scoring/phone', {
|
|
450
454
|
phone: phone1,
|
|
451
455
|
countryCode: countryCode1,
|
|
452
456
|
key: options.key,
|
|
@@ -478,7 +482,7 @@ var IBANValidation = function (options) {
|
|
|
478
482
|
mode1 +
|
|
479
483
|
'" you specified is unknown.\nYou can use: `live` or `test`.\nRead more at: https://docs.greip.io/api-reference/endpoint/payment-fraud/iban-validation'));
|
|
480
484
|
}
|
|
481
|
-
(0, util_1.makeHttpRquest)('
|
|
485
|
+
(0, util_1.makeHttpRquest)('/lookup/iban', {
|
|
482
486
|
iban: iban1,
|
|
483
487
|
key: options.key,
|
|
484
488
|
mode: mode1,
|
package/lib/types.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface Options {
|
|
2
|
+
ips?: string[];
|
|
3
|
+
ip?: string;
|
|
4
|
+
source?: string;
|
|
5
|
+
key?: string;
|
|
6
|
+
params?: string[];
|
|
7
|
+
format?: string;
|
|
8
|
+
lang?: string;
|
|
9
|
+
mode?: string;
|
|
10
|
+
countryCode?: string;
|
|
11
|
+
text?: string;
|
|
12
|
+
asn?: string;
|
|
13
|
+
email?: string;
|
|
14
|
+
phone?: string;
|
|
15
|
+
iban?: string;
|
|
16
|
+
data?: {
|
|
17
|
+
[key: string]: string | number | string[] | object | boolean;
|
|
18
|
+
};
|
|
19
|
+
}
|
package/lib/util.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const baseURL = "https://greipapi.com";
|
|
2
|
+
export declare const availableGeoIPParams: string[];
|
|
3
|
+
export declare const availableLanguages: string[];
|
|
4
|
+
export declare const availableFormats: string[];
|
|
5
|
+
export declare const availableCountryParams: string[];
|
|
6
|
+
export declare const serialize: (obj: any) => string;
|
|
7
|
+
export declare const makeHttpRquest: (endpoint: string, options: any, callback: (data: object) => void, headers?: any) => void;
|
|
8
|
+
export declare const makePostRquest: (endpoint: string, options: any, callback: (data: object) => void) => void;
|
|
9
|
+
export declare const getGFP: () => string | null;
|
package/lib/util.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.makePostRquest = exports.makeHttpRquest = exports.serialize = exports.availableCountryParams = exports.availableFormats = exports.availableLanguages = exports.availableGeoIPParams = exports.baseURL = void 0;
|
|
3
|
+
exports.getGFP = 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://greipapi.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'];
|
|
@@ -16,10 +16,12 @@ var serialize = function (obj) {
|
|
|
16
16
|
return str.join('&');
|
|
17
17
|
};
|
|
18
18
|
exports.serialize = serialize;
|
|
19
|
-
var makeHttpRquest = function (endpoint, options, callback) {
|
|
19
|
+
var makeHttpRquest = function (endpoint, options, callback, headers) {
|
|
20
20
|
options.source = 'JS-Package';
|
|
21
21
|
axios_1.default
|
|
22
|
-
.get(exports.baseURL +
|
|
22
|
+
.get(exports.baseURL + endpoint + '?' + (0, exports.serialize)(options), {
|
|
23
|
+
headers: headers,
|
|
24
|
+
})
|
|
23
25
|
.then(function (response) {
|
|
24
26
|
if (response.status === 200) {
|
|
25
27
|
callback(response.data);
|
|
@@ -50,3 +52,26 @@ var makePostRquest = function (endpoint, options, callback) {
|
|
|
50
52
|
});
|
|
51
53
|
};
|
|
52
54
|
exports.makePostRquest = makePostRquest;
|
|
55
|
+
var getGFP = function () {
|
|
56
|
+
try {
|
|
57
|
+
var timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
58
|
+
var primaryLanguage = navigator.language;
|
|
59
|
+
var preferredLanguages = navigator.languages;
|
|
60
|
+
var screenWidth = window.screen.width;
|
|
61
|
+
var screenHeight = window.screen.height;
|
|
62
|
+
var plugins = typeof navigator.plugins !== 'undefined' ? Array.from(navigator.plugins).map(function (plugin) { return plugin.name; }) : null;
|
|
63
|
+
var gfpData = JSON.stringify({
|
|
64
|
+
timezone: timezone,
|
|
65
|
+
primary_language: primaryLanguage,
|
|
66
|
+
preferred_languages: preferredLanguages,
|
|
67
|
+
screen_width: screenWidth,
|
|
68
|
+
screen_height: screenHeight,
|
|
69
|
+
plugins: plugins,
|
|
70
|
+
});
|
|
71
|
+
return gfpData;
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
exports.getGFP = getGFP;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "greip.js",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.7",
|
|
4
4
|
"description": "The official Javascript library of Greip.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Greip",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
},
|
|
36
36
|
"scripts": {
|
|
37
37
|
"test": "jest --config jestconfig.json",
|
|
38
|
-
"build": "tsc
|
|
38
|
+
"build": "tsc && webpack",
|
|
39
39
|
"format": "prettier --write \"src/**/*.ts\"",
|
|
40
40
|
"lint": "tslint -p tsconfig.json",
|
|
41
41
|
"prepare": "npm run build",
|