greip.js 2.2.1 → 2.3.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
@@ -16,6 +16,7 @@
16
16
  <br />
17
17
 
18
18
  ---
19
+
19
20
  <br />
20
21
 
21
22
  [![npm version](https://badge.fury.io/js/greip.js.svg)](https://badge.fury.io/js/greip.js)
@@ -28,209 +29,288 @@
28
29
  <br /><br />
29
30
 
30
31
  # Requirements
32
+
31
33
  No requirements for using this package.
32
34
  <br /><br />
33
35
 
34
36
  # Installation
37
+
35
38
  For Node.js, React.js & React Native:
39
+
36
40
  ```
37
41
  npm i greip.js --save
38
42
  ```
43
+
39
44
  or
45
+
40
46
  ```
41
47
  yarn add greip.js
42
48
  ```
49
+
43
50
  <br /><br />
44
51
 
45
52
  # Usage
53
+
46
54
  Here's how you use the API Methods:
47
55
  <br /><br />
48
56
 
49
57
  ## 1. IP Geolocation Method
58
+
50
59
  ```javascript
51
- import { GeoIP } from 'greip.js';
60
+ import { GeoIP } from 'greip.js';
52
61
 
53
62
  await GeoIP({
54
- key: 'your-api-key',
55
- }).then((res: any) => {
63
+ key: 'your-api-key',
64
+ })
65
+ .then((res: any) => {
56
66
  console.log(res.data); // Log Response
57
- });
67
+ })
68
+ .catch((error: any) => {
69
+ console.log(error);
70
+ });
58
71
  ```
72
+
59
73
  <br />
60
74
 
61
75
  ## 2. IP Lookup Method
76
+
62
77
  ```javascript
63
- import { Lookup } from 'greip.js';
78
+ import { Lookup } from 'greip.js';
64
79
 
65
80
  await Lookup({
66
- key: 'your-api-key',
67
- ip: '1.1.1.1',
68
- }).then((res: any) => {
81
+ key: 'your-api-key',
82
+ ip: '1.1.1.1',
83
+ })
84
+ .then((res: any) => {
69
85
  console.log(res.data); // Log Response
70
- });
86
+ })
87
+ .catch((error: any) => {
88
+ console.log(error);
89
+ });
71
90
  ```
91
+
72
92
  <br />
73
93
 
74
94
  ## 3. Bulk IP Lookup Method
95
+
75
96
  ```javascript
76
- import { BulkLookup } from 'greip.js';
97
+ import { BulkLookup } from 'greip.js';
77
98
 
78
99
  await BulkLookup({
79
- key: 'your-api-key',
80
- ips: ['1.1.1.1', '2.2.2.2'],
81
- }).then((res: any) => {
100
+ key: 'your-api-key',
101
+ ips: ['1.1.1.1', '2.2.2.2'],
102
+ })
103
+ .then((res: any) => {
82
104
  console.log(res.data); // Log Response
83
- });
105
+ })
106
+ .catch((error: any) => {
107
+ console.log(error);
108
+ });
84
109
  ```
110
+
85
111
  <br />
86
112
 
87
113
  ## 4. ASN Lookup Method
114
+
88
115
  ```javascript
89
- import { ASN } from 'greip.js';
116
+ import { ASN } from 'greip.js';
90
117
 
91
118
  await ASN({
92
- key: 'your-api-key',
93
- asn: 'AS01',
94
- }).then((res: any) => {
119
+ key: 'your-api-key',
120
+ asn: 'AS01',
121
+ })
122
+ .then((res: any) => {
95
123
  console.log(res.data); // Log Response
96
- });
124
+ })
125
+ .catch((error: any) => {
126
+ console.log(error);
127
+ });
97
128
  ```
129
+
98
130
  <br />
99
131
 
100
132
  ## 5. Profanity Detection Method
133
+
101
134
  ```javascript
102
- import { BadWord } from 'greip.js';
135
+ import { BadWord } from 'greip.js';
103
136
 
104
137
  await BadWord({
105
- key: 'your-api-key',
106
- text: 'This is just normal sample text.',
107
- }).then((res: any) => {
138
+ key: 'your-api-key',
139
+ text: 'This is just normal sample text.',
140
+ })
141
+ .then((res: any) => {
108
142
  console.log(res.data); // Log Response
109
- });
143
+ })
144
+ .catch((error: any) => {
145
+ console.log(error);
146
+ });
110
147
  ```
148
+
111
149
  <br />
112
150
 
113
151
  ## 6. Country Lookup Method
152
+
114
153
  ```javascript
115
- import { Country } from 'greip.js';
154
+ import { Country } from 'greip.js';
116
155
 
117
156
  await Country({
118
- key: 'your-api-key',
119
- countryCode: 'SA',
120
- }).then((res: any) => {
157
+ key: 'your-api-key',
158
+ countryCode: 'SA',
159
+ })
160
+ .then((res: any) => {
121
161
  console.log(res.data); // Log Response
122
- });
162
+ })
163
+ .catch((error: any) => {
164
+ console.log(error);
165
+ });
123
166
  ```
167
+
124
168
  <br />
125
169
 
126
170
  ## 7. Email Validation Method
171
+
127
172
  ```javascript
128
- import { EmailValidation } from 'greip.js';
173
+ import { EmailValidation } from 'greip.js';
129
174
 
130
175
  await EmailValidation({
131
- key: 'your-api-key',
132
- email: 'name@domain.com',
133
- }).then((res: any) => {
176
+ key: 'your-api-key',
177
+ email: 'name@domain.com',
178
+ })
179
+ .then((res: any) => {
134
180
  console.log(res.data); // Log Response
135
- });
181
+ })
182
+ .catch((error: any) => {
183
+ console.log(error);
184
+ });
136
185
  ```
186
+
137
187
  <br />
138
188
 
139
189
  ## 8. Phone Validation Method
190
+
140
191
  ```javascript
141
- import { PhoneValidation } from 'greip.js';
192
+ import { PhoneValidation } from 'greip.js';
142
193
 
143
194
  await PhoneValidation({
144
- key: 'your-api-key',
145
- phone: '123123123',
146
- countryCode: 'US',
147
- }).then((res: any) => {
195
+ key: 'your-api-key',
196
+ phone: '123123123',
197
+ countryCode: 'US',
198
+ })
199
+ .then((res: any) => {
148
200
  console.log(res.data); // Log Response
149
- });
201
+ })
202
+ .catch((error: any) => {
203
+ console.log(error);
204
+ });
150
205
  ```
206
+
151
207
  <br />
152
208
 
153
209
  ## 9. Payment Fraud Prevention Method
210
+
154
211
  ```javascript
155
- import { PaymentFraud } from 'greip.js';
212
+ import { PaymentFraud } from 'greip.js';
156
213
 
157
214
  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,
215
+ key: 'your-api-key',
216
+ data: {
217
+ action: 'purchase',
218
+ website_domain: '',
219
+ website_name: '',
220
+ merchant_id: 21,
221
+ shipment_id: 1,
222
+ transaction_id: 100,
223
+ transaction_amount: 1000000,
224
+ transaction_currency: 'GBP',
225
+ cart_items: {
226
+ item_id: 1,
227
+ item_name: 'Product name',
228
+ item_quantity: 1,
229
+ item_price: '1100.55',
230
+ item_category_id: 1,
219
231
  },
220
- }).then((res: any) => {
232
+ isDigitalProducts: true,
233
+ coupon: 'ASDF',
234
+ customer_id: 1,
235
+ customer_firstname: 'First',
236
+ customer_lastname: 'Last',
237
+ customer_pob: 'London',
238
+ customer_ip: '1.1.1.1',
239
+ customer_country: 'GB',
240
+ customer_region: 'London',
241
+ customer_city: 'London',
242
+ customer_zip: 'NW10 7PQ',
243
+ customer_street: '7 Coronation Road',
244
+ customer_street2: '',
245
+ customer_latitude: 0.123,
246
+ customer_longitude: 0.123,
247
+ customer_device_id: 'UNIQUE_DEVICE_ID',
248
+ customer_phone: '000000000',
249
+ customer_registration_date: 1677554670,
250
+ customer_balance: '1000.00',
251
+ customer_dob: '1997-19-05',
252
+ customer_email: 'name@domain.com',
253
+ customer_2fa: true,
254
+ customer_useragent: 'Mozill almaden sdfwer',
255
+ shipping_country: 'GB',
256
+ shipping_region: 'London',
257
+ shipping_city: 'London',
258
+ shipping_zip: 'NW10 7PQ',
259
+ shipping_street: '7 Coronation Road',
260
+ shipping_street2: '',
261
+ shipping_latitude: 0.123,
262
+ shipping_longitude: 0.123,
263
+ billing_country: 'GB',
264
+ billing_region: 'London',
265
+ billing_city: 'London',
266
+ billing_zip: 'NW10 7PQ',
267
+ billing_street: '7 Coronation Road',
268
+ billing_street2: '',
269
+ billing_latitude: 0.123,
270
+ billing_longitude: 0.123,
271
+ payment_type: 'applepay',
272
+ card_name: 'First Last',
273
+ card_number: '1234XXXXXXXX1234',
274
+ card_expiry: '29/05',
275
+ cvv_result: true,
276
+ },
277
+ })
278
+ .then((res: any) => {
221
279
  console.log(res.data); // Log Response
222
- });
280
+ })
281
+ .catch((error: any) => {
282
+ console.log(error);
283
+ });
284
+ ```
285
+
286
+ <br>
287
+
288
+ ## 10. IBAN Validation Method
289
+
290
+ ```javascript
291
+ await IBANValidation({
292
+ key: 'your-api-key',
293
+ iban: 'BY86AKBB10100000002966000000',
294
+ })
295
+ .then((res: any) => {
296
+ console.log(res); // Log Response
297
+ })
298
+ .catch((error: any) => {
299
+ console.log(error);
300
+ });
223
301
  ```
302
+
224
303
  <br /><br />
225
304
 
226
305
  # Options, Methods and More
306
+
227
307
  You can find the full guide of this package by visiting our [Documentation Page](https://docs.greip.io/).
228
308
 
229
- <br /><br />
230
309
  # Credits
231
- * [Greip Developers](https://greip.io)
232
- * [All Contributors](https://github.com/Greipio/Greip-JS/graphs/contributors)
233
310
 
234
- <br /><br />
311
+ - [Greip Developers](https://greip.io)
312
+ - [All Contributors](https://github.com/Greipio/Greip-JS/graphs/contributors)
313
+
235
314
  # License
315
+
236
316
  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
@@ -8,3 +8,4 @@ export declare const ASN: (options: Options) => Promise<unknown>;
8
8
  export declare const EmailValidation: (options: Options) => Promise<unknown>;
9
9
  export declare const PaymentFraud: (options: Options) => Promise<unknown>;
10
10
  export declare const PhoneValidation: (options: Options) => Promise<unknown>;
11
+ export declare const IBANValidation: (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.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.Lookup = exports.GeoIP = void 0;
4
4
  var util_1 = require("./util");
5
5
  var GeoIP = function (options) {
6
6
  if (typeof options !== 'object')
@@ -366,7 +366,7 @@ var PaymentFraud = function (options) {
366
366
  var data1 = options.data || [];
367
367
  var mode1 = options.mode || 'live';
368
368
  // Validate the text variable
369
- if (data1.length < 1) {
369
+ if (typeof data1 !== 'object' || Array.isArray(data1)) {
370
370
  reject(new Error('You should pass the `data` parameter.'));
371
371
  }
372
372
  // Validate the mode variable
@@ -420,3 +420,34 @@ var PhoneValidation = function (options) {
420
420
  });
421
421
  };
422
422
  exports.PhoneValidation = PhoneValidation;
423
+ var IBANValidation = function (options) {
424
+ if (typeof options !== 'object')
425
+ options = {};
426
+ if (!options.key || options.key.length < 1) {
427
+ throw new Error('You should pass the API Key.');
428
+ }
429
+ return new Promise(function (resolve, reject) {
430
+ var iban1 = options.iban || '';
431
+ var mode1 = options.mode || 'live';
432
+ // Validate the text variable
433
+ if (iban1.length < 1) {
434
+ reject(new Error('You should pass the `iban` parameter.'));
435
+ }
436
+ // Validate the mode variable
437
+ if (mode1 !== 'live' && mode1 !== 'test') {
438
+ reject(new Error('The `mode` option value "' +
439
+ mode1 +
440
+ '" you specified is unknown.\nYou can use: `live` or `test`.\nRead more at: https://docs.greip.io/options/development-environment'));
441
+ }
442
+ (0, util_1.makeHttpRquest)('validateIBAN', {
443
+ iban: iban1,
444
+ key: options.key,
445
+ mode: mode1,
446
+ }, function (res) {
447
+ if (typeof res !== 'object')
448
+ res = JSON.parse(res);
449
+ resolve(res);
450
+ });
451
+ });
452
+ };
453
+ exports.IBANValidation = IBANValidation;
package/lib/types.d.ts CHANGED
@@ -12,6 +12,7 @@ export interface Options {
12
12
  asn?: string;
13
13
  email?: string;
14
14
  phone?: string;
15
+ iban?: string;
15
16
  data?: {
16
17
  [key: string]: string | number | string[] | object | boolean;
17
18
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "greip.js",
3
- "version": "2.2.1",
3
+ "version": "2.3.1",
4
4
  "description": "The official JS library of Greip.",
5
5
  "author": {
6
6
  "name": "Greip",
@@ -15,17 +15,18 @@
15
15
  "api",
16
16
  "geolocation",
17
17
  "geoip",
18
- "fraud",
18
+ "fraud prevention",
19
19
  "abuse",
20
20
  "ai",
21
- "asn"
21
+ "asn",
22
+ "iban"
22
23
  ],
23
24
  "files": [
24
25
  "lib/**/*"
25
26
  ],
26
- "homepage": "https://github.com/Greipio/Greip-PHP#readme",
27
+ "homepage": "https://github.com/Greipio/Greip-JS#readme",
27
28
  "bugs": {
28
- "url": "https://github.com/Greipio/Greip-PHP/issues",
29
+ "url": "https://github.com/Greipio/Greip-JS/issues",
29
30
  "email": "info@greip.io"
30
31
  },
31
32
  "funding": {
@@ -45,7 +46,7 @@
45
46
  },
46
47
  "repository": {
47
48
  "type": "git",
48
- "url": "https://github.com/Greipio/Greip-PHP.git"
49
+ "url": "https://github.com/Greipio/Greip-JS.git"
49
50
  },
50
51
  "dependencies": {
51
52
  "axios": "^0.25.0"