greip.js 2.1.4 → 2.2.1

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
@@ -2,14 +2,14 @@
2
2
  <h1>Greip Javascript Library</h1>
3
3
  <p>The official JS library of Greip API</p>
4
4
  <br />
5
- <a href="https://github.com/gre-dev/Greip-JS/issues/new">Report Issue</a> ·
6
- <a href="https://github.com/gre-dev/Greip-JS/discussions/new">Request Feature</a> ·
5
+ <a href="https://github.com/Greipio/Greip-JS/issues/new">Report Issue</a> ·
6
+ <a href="https://github.com/Greipio/Greip-JS/discussions/new">Request Feature</a> ·
7
7
  <a href="https://greip.io" target="_BLANK">Home Page</a> ·
8
8
  <a href="https://docs.greip.io/tools-and-libraries/js" target="_BLANK">API Docs</a>
9
9
  <br />
10
10
  <br />
11
11
  <a href="https://www.npmjs.com/package/greip.js" title="NPM Package" href="_BLANK"><img src="https://img.shields.io/badge/npm-CB3837?style=for-the-badge&logo=npm&logoColor=white"></a>
12
- <a href="https://github.com/gre-dev/Greip-JS" title="Github Repo" href="_BLANK"><img src="https://img.shields.io/badge/GitHub-100000?style=for-the-badge&logo=github&logoColor=white"></a>
12
+ <a href="https://github.com/Greipio/Greip-JS" title="Github Repo" href="_BLANK"><img src="https://img.shields.io/badge/GitHub-100000?style=for-the-badge&logo=github&logoColor=white"></a>
13
13
  <a href="https://www.patreon.com/gredev" title="Patreon Profile - GRE Development Ltd." href="_BLANK"><img src="https://img.shields.io/badge/Patreon-ff424e?style=for-the-badge&logo=patreon&logoColor=white"></a>
14
14
  <img src="https://img.shields.io/badge/JavaScript-323330?style=for-the-badge&logo=javascript&logoColor=F7DF1E" title="Javascript">
15
15
  </div>
@@ -43,10 +43,10 @@ yarn add greip.js
43
43
  <br /><br />
44
44
 
45
45
  # Usage
46
- Let's say that we want to get the visitor IP Address. So we do the following:
46
+ Here's how you use the API Methods:
47
47
  <br /><br />
48
48
 
49
- For Node.js, React.js & React Native:
49
+ ## 1. IP Geolocation Method
50
50
  ```javascript
51
51
  import { GeoIP } from 'greip.js';
52
52
 
@@ -56,16 +56,181 @@ await GeoIP({
56
56
  console.log(res.data); // Log Response
57
57
  });
58
58
  ```
59
+ <br />
59
60
 
61
+ ## 2. IP Lookup Method
62
+ ```javascript
63
+ import { Lookup } from 'greip.js';
64
+
65
+ await Lookup({
66
+ key: 'your-api-key',
67
+ ip: '1.1.1.1',
68
+ }).then((res: any) => {
69
+ console.log(res.data); // Log Response
70
+ });
71
+ ```
72
+ <br />
73
+
74
+ ## 3. Bulk IP Lookup Method
75
+ ```javascript
76
+ import { BulkLookup } from 'greip.js';
77
+
78
+ await BulkLookup({
79
+ key: 'your-api-key',
80
+ ips: ['1.1.1.1', '2.2.2.2'],
81
+ }).then((res: any) => {
82
+ console.log(res.data); // Log Response
83
+ });
84
+ ```
85
+ <br />
86
+
87
+ ## 4. ASN Lookup Method
88
+ ```javascript
89
+ import { ASN } from 'greip.js';
90
+
91
+ await ASN({
92
+ key: 'your-api-key',
93
+ asn: 'AS01',
94
+ }).then((res: any) => {
95
+ console.log(res.data); // Log Response
96
+ });
97
+ ```
98
+ <br />
99
+
100
+ ## 5. Profanity Detection Method
101
+ ```javascript
102
+ import { BadWord } from 'greip.js';
103
+
104
+ await BadWord({
105
+ key: 'your-api-key',
106
+ text: 'This is just normal sample text.',
107
+ }).then((res: any) => {
108
+ console.log(res.data); // Log Response
109
+ });
110
+ ```
111
+ <br />
112
+
113
+ ## 6. Country Lookup Method
114
+ ```javascript
115
+ import { Country } from 'greip.js';
116
+
117
+ await Country({
118
+ key: 'your-api-key',
119
+ countryCode: 'SA',
120
+ }).then((res: any) => {
121
+ console.log(res.data); // Log Response
122
+ });
123
+ ```
124
+ <br />
125
+
126
+ ## 7. Email Validation Method
127
+ ```javascript
128
+ import { EmailValidation } from 'greip.js';
129
+
130
+ await EmailValidation({
131
+ key: 'your-api-key',
132
+ email: 'name@domain.com',
133
+ }).then((res: any) => {
134
+ console.log(res.data); // Log Response
135
+ });
136
+ ```
137
+ <br />
138
+
139
+ ## 8. Phone Validation Method
140
+ ```javascript
141
+ import { PhoneValidation } from 'greip.js';
142
+
143
+ await PhoneValidation({
144
+ key: 'your-api-key',
145
+ phone: '123123123',
146
+ countryCode: 'US',
147
+ }).then((res: any) => {
148
+ console.log(res.data); // Log Response
149
+ });
150
+ ```
151
+ <br />
152
+
153
+ ## 9. Payment Fraud Prevention Method
154
+ ```javascript
155
+ import { PaymentFraud } from 'greip.js';
156
+
157
+ await PaymentFraud({
158
+ key: 'your-api-key',
159
+ data: {
160
+ action: 'purchase',
161
+ website_domain: '',
162
+ website_name: '',
163
+ merchant_id: 21,
164
+ shipment_id: 1,
165
+ transaction_id: 100,
166
+ transaction_amount: 1000000,
167
+ transaction_currency: 'GBP',
168
+ cart_items: {
169
+ item_id: 1,
170
+ item_name: 'Product name',
171
+ item_quantity: 1,
172
+ item_price: '1100.55',
173
+ item_category_id: 1,
174
+ },
175
+ isDigitalProducts: true,
176
+ coupon: 'ASDF',
177
+ customer_id: 1,
178
+ customer_firstname: 'First',
179
+ customer_lastname: 'Last',
180
+ customer_pob: 'London',
181
+ customer_ip: '1.1.1.1',
182
+ customer_country: 'GB',
183
+ customer_region: 'London',
184
+ customer_city: 'London',
185
+ customer_zip: 'NW10 7PQ',
186
+ customer_street: '7 Coronation Road',
187
+ customer_street2: '',
188
+ customer_latitude: 0.123,
189
+ customer_longitude: 0.123,
190
+ customer_device_id: 'UNIQUE_DEVICE_ID',
191
+ customer_phone: '000000000',
192
+ customer_registration_date: 1677554670,
193
+ customer_balance: '1000.00',
194
+ customer_dob: '1997-19-05',
195
+ customer_email: 'name@domain.com',
196
+ customer_2fa: true,
197
+ customer_useragent: 'Mozill almaden sdfwer',
198
+ shipping_country: 'GB',
199
+ shipping_region: 'London',
200
+ shipping_city: 'London',
201
+ shipping_zip: 'NW10 7PQ',
202
+ shipping_street: '7 Coronation Road',
203
+ shipping_street2: '',
204
+ shipping_latitude: 0.123,
205
+ shipping_longitude: 0.123,
206
+ billing_country: 'GB',
207
+ billing_region: 'London',
208
+ billing_city: 'London',
209
+ billing_zip: 'NW10 7PQ',
210
+ billing_street: '7 Coronation Road',
211
+ billing_street2: '',
212
+ billing_latitude: 0.123,
213
+ billing_longitude: 0.123,
214
+ payment_type: 'applepay',
215
+ card_name: 'First Last',
216
+ card_number: '1234XXXXXXXX1234',
217
+ card_expiry: '29/05',
218
+ cvv_result: true,
219
+ },
220
+ }).then((res: any) => {
221
+ console.log(res.data); // Log Response
222
+ });
223
+ ```
60
224
  <br /><br />
225
+
61
226
  # Options, Methods and More
62
- You can find the full guide of this package by visiting our [Documentation Page](https://docs.greip.io/tools-and-libraries/js).
227
+ You can find the full guide of this package by visiting our [Documentation Page](https://docs.greip.io/).
63
228
 
64
229
  <br /><br />
65
230
  # Credits
66
231
  * [Greip Developers](https://greip.io)
67
- * [All Contributors](https://github.com/gre-dev/Greip-JS/graphs/contributors)
232
+ * [All Contributors](https://github.com/Greipio/Greip-JS/graphs/contributors)
68
233
 
69
234
  <br /><br />
70
235
  # License
71
- The MIT License (MIT). Please see [License](https://github.com/gre-dev/Greip-JS/blob/main/LICENSE) File for more information.
236
+ The MIT License (MIT). Please see [License](https://github.com/Greipio/Greip-JS/blob/main/LICENSE) File for more information.
package/lib/index.d.ts CHANGED
@@ -4,3 +4,7 @@ export declare const Lookup: (options: Options) => Promise<unknown>;
4
4
  export declare const BulkLookup: (options: Options) => Promise<unknown>;
5
5
  export declare const Country: (options: Options) => Promise<unknown>;
6
6
  export declare const BadWord: (options: Options) => Promise<unknown>;
7
+ export declare const ASN: (options: Options) => Promise<unknown>;
8
+ export declare const EmailValidation: (options: Options) => Promise<unknown>;
9
+ export declare const PaymentFraud: (options: Options) => Promise<unknown>;
10
+ export declare const PhoneValidation: (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.BadWord = exports.Country = exports.BulkLookup = exports.Lookup = exports.GeoIP = void 0;
3
+ exports.PhoneValidation = exports.PaymentFraud = exports.EmailValidation = exports.ASN = exports.BadWord = exports.Country = exports.BulkLookup = 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')
@@ -10,10 +10,10 @@ var GeoIP = function (options) {
10
10
  }
11
11
  return new Promise(function (resolve, reject) {
12
12
  var params = options.params || [];
13
- var format = options.format || 'JSON';
14
- var lang = options.lang || 'EN';
15
- var mode = options.mode || 'live';
16
- lang = lang.toUpperCase();
13
+ var format1 = options.format || 'JSON';
14
+ var lang1 = options.lang || 'EN';
15
+ var mode1 = options.mode || 'live';
16
+ lang1 = lang1.toUpperCase();
17
17
  // Validate the params variable items
18
18
  params.forEach(function (perParam) {
19
19
  if (perParam.length > 0) {
@@ -25,29 +25,29 @@ var GeoIP = function (options) {
25
25
  }
26
26
  });
27
27
  // Validate the format variable
28
- if (!util_1.availableFormats.includes(format)) {
28
+ if (!util_1.availableFormats.includes(format1)) {
29
29
  reject(new Error('The `format` option value "' +
30
- lang +
30
+ format1 +
31
31
  '" you specified is unknown.\nYou can use: `JSON`, `XML`, `CSV` or `Newline`.\nRead more at: https://geoip-docs.gredev.io/sdks/js/geoip-method#options'));
32
32
  }
33
33
  // Validate the lang variable
34
- if (!util_1.availableLanguages.includes(lang)) {
34
+ if (!util_1.availableLanguages.includes(lang1)) {
35
35
  reject(new Error('The `lang` option value "' +
36
- lang +
36
+ lang1 +
37
37
  '" you specified is unknown.\nYou can use: `EN`, `AR`, `DE`, `FR`, `ES`, `JA`, `ZH` or `RU`.\nRead more at: https://geoip-docs.gredev.io/sdks/js/geoip-method#options'));
38
38
  }
39
39
  // Validate the mode variable
40
- if (mode !== 'live' && mode !== 'test') {
40
+ if (mode1 !== 'live' && mode1 !== 'test') {
41
41
  reject(new Error('The `mode` option value "' +
42
- lang +
42
+ mode1 +
43
43
  '" you specified is unknown.\nYou can use: `live` or `test`.\nRead more at: https://geoip-docs.gredev.io/sdks/js/geoip-method#options'));
44
44
  }
45
45
  (0, util_1.makeHttpRquest)('GeoIP', {
46
- 'key': options.key,
47
- 'params': params.join(','),
48
- 'format': format,
49
- 'lang': lang,
50
- 'mode': mode,
46
+ key: options.key,
47
+ params: params.join(','),
48
+ format: format1,
49
+ lang: lang1,
50
+ mode: mode1,
51
51
  }, function (res) {
52
52
  if (typeof res !== 'object')
53
53
  res = JSON.parse(res);
@@ -63,14 +63,14 @@ var Lookup = function (options) {
63
63
  throw new Error('You should pass the API Key.');
64
64
  }
65
65
  return new Promise(function (resolve, reject) {
66
- var ip = options.ip || '';
66
+ var ip1 = options.ip || '';
67
67
  var params = options.params || [];
68
- var format = options.format || 'JSON';
69
- var lang = options.lang || 'EN';
70
- var mode = options.mode || 'live';
71
- lang = lang.toUpperCase();
68
+ var format1 = options.format || 'JSON';
69
+ var lang1 = options.lang || 'EN';
70
+ var mode1 = options.mode || 'live';
71
+ lang1 = lang1.toUpperCase();
72
72
  // Validate the ip variable
73
- if (ip.length < 7) {
73
+ if (ip1.length < 7) {
74
74
  reject(new Error('You should pass the `ip` parameter.'));
75
75
  }
76
76
  // Validate the params variable items
@@ -84,30 +84,30 @@ var Lookup = function (options) {
84
84
  }
85
85
  });
86
86
  // Validate the format variable
87
- if (!util_1.availableFormats.includes(format)) {
87
+ if (!util_1.availableFormats.includes(format1)) {
88
88
  reject(new Error('The `format` option value "' +
89
- lang +
89
+ format1 +
90
90
  '" you specified is unknown.\nYou can use: `JSON`, `XML`, `CSV` or `Newline`.\nRead more at: https://geoip-docs.gredev.io/sdks/js/lookup-method#options'));
91
91
  }
92
92
  // Validate the lang variable
93
- if (!util_1.availableLanguages.includes(lang)) {
93
+ if (!util_1.availableLanguages.includes(lang1)) {
94
94
  reject(new Error('The `lang` option value "' +
95
- lang +
95
+ lang1 +
96
96
  '" you specified is unknown.\nYou can use: `EN`, `AR`, `DE`, `FR`, `ES`, `JA`, `ZH` or `RU`.\nRead more at: https://geoip-docs.gredev.io/sdks/js/lookup-method#options'));
97
97
  }
98
98
  // Validate the mode variable
99
- if (mode !== 'live' && mode !== 'test') {
99
+ if (mode1 !== 'live' && mode1 !== 'test') {
100
100
  reject(new Error('The `mode` option value "' +
101
- lang +
101
+ mode1 +
102
102
  '" you specified is unknown.\nYou can use: `live` or `test`.\nRead more at: https://geoip-docs.gredev.io/sdks/js/lookup-method#options'));
103
103
  }
104
104
  (0, util_1.makeHttpRquest)('IPLookup', {
105
- 'ip': ip,
106
- 'key': options.key,
107
- 'params': params.join(','),
108
- 'format': format,
109
- 'lang': lang,
110
- 'mode': mode,
105
+ ip: ip1,
106
+ key: options.key,
107
+ params: params.join(','),
108
+ format: format1,
109
+ lang: lang1,
110
+ mode: mode1,
111
111
  }, function (res) {
112
112
  if (typeof res !== 'object')
113
113
  res = JSON.parse(res);
@@ -123,19 +123,19 @@ var BulkLookup = function (options) {
123
123
  throw new Error('You should pass the API Key.');
124
124
  }
125
125
  return new Promise(function (resolve, reject) {
126
- var ips = options.ips || [];
126
+ var ips1 = options.ips || [];
127
127
  var params = options.params || [];
128
- var format = options.format || 'JSON';
129
- var lang = options.lang || 'EN';
130
- var mode = options.mode || 'live';
131
- lang = lang.toUpperCase();
132
- if (typeof ips !== 'object')
133
- ips = [];
128
+ var format1 = options.format || 'JSON';
129
+ var lang1 = options.lang || 'EN';
130
+ var mode1 = options.mode || 'live';
131
+ lang1 = lang1.toUpperCase();
132
+ if (typeof ips1 !== 'object')
133
+ ips1 = [];
134
134
  // Validate the ip variable
135
- if (ips.length < 1) {
135
+ if (ips1.length < 1) {
136
136
  reject(new Error('You should pass the `ips` parameter.'));
137
137
  }
138
- ips.forEach(function (perParam) {
138
+ ips1.forEach(function (perParam) {
139
139
  if (perParam.length < 7) {
140
140
  reject(new Error('You should pass a valid IP Addresses in the `ips` parameter.'));
141
141
  }
@@ -151,30 +151,30 @@ var BulkLookup = function (options) {
151
151
  }
152
152
  });
153
153
  // Validate the format variable
154
- if (!util_1.availableFormats.includes(format)) {
154
+ if (!util_1.availableFormats.includes(format1)) {
155
155
  reject(new Error('The `format` option value "' +
156
- lang +
156
+ format1 +
157
157
  '" you specified is unknown.\nYou can use: `JSON`, `XML`, `CSV` or `Newline`.\nRead more at: https://geoip-docs.gredev.io/sdks/js/lookup-method#options'));
158
158
  }
159
159
  // Validate the lang variable
160
- if (!util_1.availableLanguages.includes(lang)) {
160
+ if (!util_1.availableLanguages.includes(lang1)) {
161
161
  reject(new Error('The `lang` option value "' +
162
- lang +
162
+ lang1 +
163
163
  '" you specified is unknown.\nYou can use: `EN`, `AR`, `DE`, `FR`, `ES`, `JA`, `ZH` or `RU`.\nRead more at: https://geoip-docs.gredev.io/sdks/js/lookup-method#options'));
164
164
  }
165
165
  // Validate the mode variable
166
- if (mode !== 'live' && mode !== 'test') {
166
+ if (mode1 !== 'live' && mode1 !== 'test') {
167
167
  reject(new Error('The `mode` option value "' +
168
- lang +
168
+ mode1 +
169
169
  '" you specified is unknown.\nYou can use: `live` or `test`.\nRead more at: https://geoip-docs.gredev.io/sdks/js/lookup-method#options'));
170
170
  }
171
171
  (0, util_1.makeHttpRquest)('BulkLookup', {
172
- 'ips': ips,
173
- 'key': options.key,
174
- 'params': params.join(','),
175
- 'format': format,
176
- 'lang': lang,
177
- 'mode': mode,
172
+ ips: ips1,
173
+ key: options.key,
174
+ params: params.join(','),
175
+ format: format1,
176
+ lang: lang1,
177
+ mode: mode1,
178
178
  }, function (res) {
179
179
  if (typeof res !== 'object')
180
180
  res = JSON.parse(res);
@@ -192,11 +192,11 @@ var Country = function (options) {
192
192
  return new Promise(function (resolve, reject) {
193
193
  var countryCode = options.countryCode || '';
194
194
  var params = options.params || [];
195
- var format = options.format || 'JSON';
196
- var lang = options.lang || 'EN';
197
- var mode = options.mode || 'live';
195
+ var format1 = options.format || 'JSON';
196
+ var lang1 = options.lang || 'EN';
197
+ var mode1 = options.mode || 'live';
198
198
  countryCode = countryCode.toUpperCase();
199
- lang = lang.toUpperCase();
199
+ lang1 = lang1.toUpperCase();
200
200
  // Validate the countryCode variable
201
201
  if (countryCode.length !== 2) {
202
202
  reject(new Error('You should pass the `countryCode` parameter. Also, it should be a `ISO 3166-1 alpha-2` format.\nRead more at: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2'));
@@ -207,35 +207,35 @@ var Country = function (options) {
207
207
  if (!util_1.availableCountryParams.includes(perParam)) {
208
208
  reject(new Error('The "' +
209
209
  perParam +
210
- '" module you used is unknown.\nYou can use: `language`, `flag`, `currency` and/or `timezone`.\nRead more at: https://geoip-docs.gredev.io/sdks/js/country-method#options'));
210
+ '" module you used is unknown.\nYou can use: `language`, `flag`, `currency` and/or `timezone`.\nRead more at: https://docs.greip.io/options/development-environment'));
211
211
  }
212
212
  }
213
213
  });
214
214
  // Validate the format variable
215
- if (!util_1.availableFormats.includes(format)) {
215
+ if (!util_1.availableFormats.includes(format1)) {
216
216
  reject(new Error('The `format` option value "' +
217
- lang +
218
- '" you specified is unknown.\nYou can use: `JSON`, `XML`, `CSV` or `Newline`.\nRead more at: https://geoip-docs.gredev.io/sdks/js/country-method#options'));
217
+ format1 +
218
+ '" you specified is unknown.\nYou can use: `JSON`, `XML`, `CSV` or `Newline`.\nRead more at: https://docs.greip.io/options/development-environment'));
219
219
  }
220
220
  // Validate the lang variable
221
- if (!util_1.availableLanguages.includes(lang)) {
221
+ if (!util_1.availableLanguages.includes(lang1)) {
222
222
  reject(new Error('The `lang` option value "' +
223
- lang +
224
- '" you specified is unknown.\nYou can use: `EN`, `AR`, `DE`, `FR`, `ES`, `JA`, `ZH` or `RU`.\nRead more at: https://geoip-docs.gredev.io/sdks/js/country-method#options'));
223
+ lang1 +
224
+ '" you specified is unknown.\nYou can use: `EN`, `AR`, `DE`, `FR`, `ES`, `JA`, `ZH` or `RU`.\nRead more at: https://docs.greip.io/options/development-environment'));
225
225
  }
226
226
  // Validate the mode variable
227
- if (mode !== 'live' && mode !== 'test') {
227
+ if (mode1 !== 'live' && mode1 !== 'test') {
228
228
  reject(new Error('The `mode` option value "' +
229
- lang +
230
- '" you specified is unknown.\nYou can use: `live` or `test`.\nRead more at: https://geoip-docs.gredev.io/sdks/js/country-method#options'));
229
+ mode1 +
230
+ '" you specified is unknown.\nYou can use: `live` or `test`.\nRead more at: https://docs.greip.io/options/development-environment'));
231
231
  }
232
232
  (0, util_1.makeHttpRquest)('Country', {
233
- 'CountryCode': countryCode,
234
- 'key': options.key,
235
- 'params': params.join(','),
236
- 'format': format,
237
- 'lang': lang,
238
- 'mode': mode,
233
+ CountryCode: countryCode,
234
+ key: options.key,
235
+ params: params.join(','),
236
+ format: format1,
237
+ lang: lang1,
238
+ mode: mode1,
239
239
  }, function (res) {
240
240
  if (typeof res !== 'object')
241
241
  res = JSON.parse(res);
@@ -251,41 +251,41 @@ var BadWord = function (options) {
251
251
  throw new Error('You should pass the API Key.');
252
252
  }
253
253
  return new Promise(function (resolve, reject) {
254
- var text = options.text || '';
254
+ var text1 = options.text || '';
255
255
  var params = options.params || [];
256
- var format = options.format || 'JSON';
257
- var lang = options.lang || 'EN';
258
- var mode = options.mode || 'live';
259
- lang = lang.toUpperCase();
256
+ var format1 = options.format || 'JSON';
257
+ var lang1 = options.lang || 'EN';
258
+ var mode1 = options.mode || 'live';
259
+ lang1 = lang1.toUpperCase();
260
260
  // Validate the text variable
261
- if (text.length < 1) {
261
+ if (text1.length < 1) {
262
262
  reject(new Error('You should pass the `text` parameter.'));
263
263
  }
264
264
  // Validate the format variable
265
- if (!util_1.availableFormats.includes(format)) {
265
+ if (!util_1.availableFormats.includes(format1)) {
266
266
  reject(new Error('The `format` option value "' +
267
- lang +
268
- '" you specified is unknown.\nYou can use: `JSON`, `XML` or `CSV`.\nRead more at: https://geoip-docs.gredev.io/sdks/js/country-method#options'));
267
+ format1 +
268
+ '" you specified is unknown.\nYou can use: `JSON`, `XML` or `CSV`.\nRead more at: https://docs.greip.io/options/development-environment'));
269
269
  }
270
270
  // Validate the lang variable
271
- if (!util_1.availableLanguages.includes(lang)) {
271
+ if (!util_1.availableLanguages.includes(lang1)) {
272
272
  reject(new Error('The `lang` option value "' +
273
- lang +
274
- '" you specified is unknown.\nYou can use: `EN`, `AR`, `DE`, `FR`, `ES`, `JA`, `ZH` or `RU`.\nRead more at: https://geoip-docs.gredev.io/sdks/js/country-method#options'));
273
+ lang1 +
274
+ '" you specified is unknown.\nYou can use: `EN`, `AR`, `DE`, `FR`, `ES`, `JA`, `ZH` or `RU`.\nRead more at: https://docs.greip.io/options/development-environment'));
275
275
  }
276
276
  // Validate the mode variable
277
- if (mode !== 'live' && mode !== 'test') {
277
+ if (mode1 !== 'live' && mode1 !== 'test') {
278
278
  reject(new Error('The `mode` option value "' +
279
- lang +
280
- '" you specified is unknown.\nYou can use: `live` or `test`.\nRead more at: https://geoip-docs.gredev.io/sdks/js/country-method#options'));
279
+ mode1 +
280
+ '" you specified is unknown.\nYou can use: `live` or `test`.\nRead more at: https://docs.greip.io/options/development-environment'));
281
281
  }
282
282
  (0, util_1.makeHttpRquest)('badWords', {
283
- 'text': text,
284
- 'key': options.key,
285
- 'params': params.join(','),
286
- 'format': format,
287
- 'lang': lang,
288
- 'mode': mode,
283
+ text: text1,
284
+ key: options.key,
285
+ params: params.join(','),
286
+ format: format1,
287
+ lang: lang1,
288
+ mode: mode1,
289
289
  }, function (res) {
290
290
  if (typeof res !== 'object')
291
291
  res = JSON.parse(res);
@@ -294,3 +294,129 @@ var BadWord = function (options) {
294
294
  });
295
295
  };
296
296
  exports.BadWord = BadWord;
297
+ var ASN = function (options) {
298
+ if (typeof options !== 'object')
299
+ options = {};
300
+ if (!options.key || options.key.length < 1) {
301
+ throw new Error('You should pass the API Key.');
302
+ }
303
+ return new Promise(function (resolve, reject) {
304
+ var asn1 = options.asn || '';
305
+ var mode1 = options.mode || 'live';
306
+ // Validate the text variable
307
+ if (asn1.length < 1) {
308
+ reject(new Error('You should pass the `asn` parameter.'));
309
+ }
310
+ // Validate the mode variable
311
+ if (mode1 !== 'live' && mode1 !== 'test') {
312
+ reject(new Error('The `mode` option value "' +
313
+ mode1 +
314
+ '" you specified is unknown.\nYou can use: `live` or `test`.\nRead more at: https://docs.greip.io/options/development-environment'));
315
+ }
316
+ (0, util_1.makeHttpRquest)('ASNLookup', {
317
+ asn: asn1,
318
+ key: options.key,
319
+ mode: mode1,
320
+ }, function (res) {
321
+ if (typeof res !== 'object')
322
+ res = JSON.parse(res);
323
+ resolve(res);
324
+ });
325
+ });
326
+ };
327
+ exports.ASN = ASN;
328
+ var EmailValidation = function (options) {
329
+ if (typeof options !== 'object')
330
+ options = {};
331
+ if (!options.key || options.key.length < 1) {
332
+ throw new Error('You should pass the API Key.');
333
+ }
334
+ return new Promise(function (resolve, reject) {
335
+ var email1 = options.email || '';
336
+ var mode1 = options.mode || 'live';
337
+ // Validate the text variable
338
+ if (email1.length < 1) {
339
+ reject(new Error('You should pass the `email` parameter.'));
340
+ }
341
+ // Validate the mode variable
342
+ if (mode1 !== 'live' && mode1 !== 'test') {
343
+ reject(new Error('The `mode` option value "' +
344
+ mode1 +
345
+ '" you specified is unknown.\nYou can use: `live` or `test`.\nRead more at: https://docs.greip.io/options/development-environment'));
346
+ }
347
+ (0, util_1.makeHttpRquest)('validateEmail', {
348
+ email: email1,
349
+ key: options.key,
350
+ mode: mode1,
351
+ }, function (res) {
352
+ if (typeof res !== 'object')
353
+ res = JSON.parse(res);
354
+ resolve(res);
355
+ });
356
+ });
357
+ };
358
+ exports.EmailValidation = EmailValidation;
359
+ var PaymentFraud = function (options) {
360
+ if (typeof options !== 'object')
361
+ options = {};
362
+ if (!options.key || options.key.length < 1) {
363
+ throw new Error('You should pass the API Key.');
364
+ }
365
+ return new Promise(function (resolve, reject) {
366
+ var data1 = options.data || [];
367
+ var mode1 = options.mode || 'live';
368
+ // Validate the text variable
369
+ if (data1.length < 1) {
370
+ reject(new Error('You should pass the `data` parameter.'));
371
+ }
372
+ // Validate the mode variable
373
+ if (mode1 !== 'live' && mode1 !== 'test') {
374
+ reject(new Error('The `mode` option value "' +
375
+ mode1 +
376
+ '" you specified is unknown.\nYou can use: `live` or `test`.\nRead more at: https://docs.greip.io/options/development-environment'));
377
+ }
378
+ (0, util_1.makePostRquest)('paymentFraud', {
379
+ data: data1,
380
+ key: options.key,
381
+ mode: mode1,
382
+ }, function (res) {
383
+ if (typeof res !== 'object')
384
+ res = JSON.parse(res);
385
+ resolve(res);
386
+ });
387
+ });
388
+ };
389
+ exports.PaymentFraud = PaymentFraud;
390
+ var PhoneValidation = function (options) {
391
+ if (typeof options !== 'object')
392
+ options = {};
393
+ if (!options.key || options.key.length < 1) {
394
+ throw new Error('You should pass the API Key.');
395
+ }
396
+ return new Promise(function (resolve, reject) {
397
+ var phone1 = options.phone || '';
398
+ var countryCode1 = options.countryCode || '';
399
+ var mode1 = options.mode || 'live';
400
+ // Validate the text variable
401
+ if (phone1.length < 1 || countryCode1.length < 1) {
402
+ reject(new Error('You should pass both `phone` and `countryCode` parameters.'));
403
+ }
404
+ // Validate the mode variable
405
+ if (mode1 !== 'live' && mode1 !== 'test') {
406
+ reject(new Error('The `mode` option value "' +
407
+ mode1 +
408
+ '" you specified is unknown.\nYou can use: `live` or `test`.\nRead more at: https://docs.greip.io/options/development-environment'));
409
+ }
410
+ (0, util_1.makeHttpRquest)('validatePhone', {
411
+ phone: phone1,
412
+ countryCode: countryCode1,
413
+ key: options.key,
414
+ mode: mode1,
415
+ }, function (res) {
416
+ if (typeof res !== 'object')
417
+ res = JSON.parse(res);
418
+ resolve(res);
419
+ });
420
+ });
421
+ };
422
+ exports.PhoneValidation = PhoneValidation;
package/lib/types.d.ts CHANGED
@@ -9,4 +9,10 @@ export interface Options {
9
9
  mode?: string;
10
10
  countryCode?: string;
11
11
  text?: string;
12
+ asn?: string;
13
+ email?: string;
14
+ phone?: string;
15
+ data?: {
16
+ [key: string]: string | number | string[] | object | boolean;
17
+ };
12
18
  }
package/lib/util.d.ts CHANGED
@@ -5,3 +5,4 @@ export declare const availableFormats: string[];
5
5
  export declare const availableCountryParams: string[];
6
6
  export declare const serialize: (obj: any) => string;
7
7
  export declare const makeHttpRquest: (endpoint: string, options: any, callback: (data: object) => void) => void;
8
+ export declare const makePostRquest: (endpoint: string, options: any, callback: (data: object) => void) => void;
package/lib/util.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.makeHttpRquest = exports.serialize = exports.availableCountryParams = exports.availableFormats = exports.availableLanguages = exports.availableGeoIPParams = exports.baseURL = void 0;
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
5
  exports.baseURL = 'https://gregeoip.com/';
6
6
  exports.availableGeoIPParams = ['location', 'security', 'timezone', 'currency', 'device'];
@@ -33,3 +33,20 @@ var makeHttpRquest = function (endpoint, options, callback) {
33
33
  });
34
34
  };
35
35
  exports.makeHttpRquest = makeHttpRquest;
36
+ var makePostRquest = function (endpoint, options, callback) {
37
+ options.source = 'JS-Package';
38
+ axios_1.default
39
+ .post(exports.baseURL + '/' + endpoint, options)
40
+ .then(function (response) {
41
+ if (response.status === 200) {
42
+ callback(response.data);
43
+ }
44
+ else {
45
+ throw new Error('An unknown error occurred while sending the request to GRE GeoIP API.');
46
+ }
47
+ })
48
+ .catch(function (error) {
49
+ throw new Error('An unknown error occurred while sending the request to GRE GeoIP API.');
50
+ });
51
+ };
52
+ exports.makePostRquest = makePostRquest;
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "greip.js",
3
- "version": "2.1.4",
3
+ "version": "2.2.1",
4
4
  "description": "The official JS library of Greip.",
5
5
  "author": {
6
- "name": "GRE Development Ltd.",
6
+ "name": "Greip",
7
7
  "email": "info@greip.io",
8
8
  "url": "https://greip.io"
9
9
  },
@@ -14,14 +14,18 @@
14
14
  "ip",
15
15
  "api",
16
16
  "geolocation",
17
- "geoip"
17
+ "geoip",
18
+ "fraud",
19
+ "abuse",
20
+ "ai",
21
+ "asn"
18
22
  ],
19
23
  "files": [
20
24
  "lib/**/*"
21
25
  ],
22
- "homepage": "https://github.com/gre-dev/Greip-JS#readme",
26
+ "homepage": "https://github.com/Greipio/Greip-PHP#readme",
23
27
  "bugs": {
24
- "url": "https://github.com/gre-dev/Greip-JS/issues",
28
+ "url": "https://github.com/Greipio/Greip-PHP/issues",
25
29
  "email": "info@greip.io"
26
30
  },
27
31
  "funding": {
@@ -41,7 +45,7 @@
41
45
  },
42
46
  "repository": {
43
47
  "type": "git",
44
- "url": "https://github.com/gre-dev/Greip-JS.git"
48
+ "url": "https://github.com/Greipio/Greip-PHP.git"
45
49
  },
46
50
  "dependencies": {
47
51
  "axios": "^0.25.0"