greip.js 2.2.0 → 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
@@ -2,20 +2,21 @@
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>
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,44 +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
46
- Let's say that we want to get the visitor IP Address. So we do the following:
53
+
54
+ Here's how you use the API Methods:
47
55
  <br /><br />
48
56
 
49
- For Node.js, React.js & React Native:
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) => {
66
+ console.log(res.data); // Log Response
67
+ })
68
+ .catch((error: any) => {
69
+ console.log(error);
70
+ });
71
+ ```
72
+
73
+ <br />
74
+
75
+ ## 2. IP Lookup Method
76
+
77
+ ```javascript
78
+ import { Lookup } from 'greip.js';
79
+
80
+ await Lookup({
81
+ key: 'your-api-key',
82
+ ip: '1.1.1.1',
83
+ })
84
+ .then((res: any) => {
56
85
  console.log(res.data); // Log Response
57
- });
86
+ })
87
+ .catch((error: any) => {
88
+ console.log(error);
89
+ });
90
+ ```
91
+
92
+ <br />
93
+
94
+ ## 3. Bulk IP Lookup Method
95
+
96
+ ```javascript
97
+ import { BulkLookup } from 'greip.js';
98
+
99
+ await BulkLookup({
100
+ key: 'your-api-key',
101
+ ips: ['1.1.1.1', '2.2.2.2'],
102
+ })
103
+ .then((res: any) => {
104
+ console.log(res.data); // Log Response
105
+ })
106
+ .catch((error: any) => {
107
+ console.log(error);
108
+ });
109
+ ```
110
+
111
+ <br />
112
+
113
+ ## 4. ASN Lookup Method
114
+
115
+ ```javascript
116
+ import { ASN } from 'greip.js';
117
+
118
+ await ASN({
119
+ key: 'your-api-key',
120
+ asn: 'AS01',
121
+ })
122
+ .then((res: any) => {
123
+ console.log(res.data); // Log Response
124
+ })
125
+ .catch((error: any) => {
126
+ console.log(error);
127
+ });
128
+ ```
129
+
130
+ <br />
131
+
132
+ ## 5. Profanity Detection Method
133
+
134
+ ```javascript
135
+ import { BadWord } from 'greip.js';
136
+
137
+ await BadWord({
138
+ key: 'your-api-key',
139
+ text: 'This is just normal sample text.',
140
+ })
141
+ .then((res: any) => {
142
+ console.log(res.data); // Log Response
143
+ })
144
+ .catch((error: any) => {
145
+ console.log(error);
146
+ });
147
+ ```
148
+
149
+ <br />
150
+
151
+ ## 6. Country Lookup Method
152
+
153
+ ```javascript
154
+ import { Country } from 'greip.js';
155
+
156
+ await Country({
157
+ key: 'your-api-key',
158
+ countryCode: 'SA',
159
+ })
160
+ .then((res: any) => {
161
+ console.log(res.data); // Log Response
162
+ })
163
+ .catch((error: any) => {
164
+ console.log(error);
165
+ });
166
+ ```
167
+
168
+ <br />
169
+
170
+ ## 7. Email Validation Method
171
+
172
+ ```javascript
173
+ import { EmailValidation } from 'greip.js';
174
+
175
+ await EmailValidation({
176
+ key: 'your-api-key',
177
+ email: 'name@domain.com',
178
+ })
179
+ .then((res: any) => {
180
+ console.log(res.data); // Log Response
181
+ })
182
+ .catch((error: any) => {
183
+ console.log(error);
184
+ });
185
+ ```
186
+
187
+ <br />
188
+
189
+ ## 8. Phone Validation Method
190
+
191
+ ```javascript
192
+ import { PhoneValidation } from 'greip.js';
193
+
194
+ await PhoneValidation({
195
+ key: 'your-api-key',
196
+ phone: '123123123',
197
+ countryCode: 'US',
198
+ })
199
+ .then((res: any) => {
200
+ console.log(res.data); // Log Response
201
+ })
202
+ .catch((error: any) => {
203
+ console.log(error);
204
+ });
205
+ ```
206
+
207
+ <br />
208
+
209
+ ## 9. Payment Fraud Prevention Method
210
+
211
+ ```javascript
212
+ import { PaymentFraud } from 'greip.js';
213
+
214
+ await PaymentFraud({
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,
231
+ },
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) => {
279
+ console.log(res.data); // Log Response
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
+ });
58
301
  ```
59
302
 
60
303
  <br /><br />
304
+
61
305
  # 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).
63
306
 
64
- <br /><br />
307
+ You can find the full guide of this package by visiting our [Documentation Page](https://docs.greip.io/).
308
+
65
309
  # Credits
66
- * [Greip Developers](https://greip.io)
67
- * [All Contributors](https://github.com/gre-dev/Greip-JS/graphs/contributors)
68
310
 
69
- <br /><br />
311
+ - [Greip Developers](https://greip.io)
312
+ - [All Contributors](https://github.com/Greipio/Greip-JS/graphs/contributors)
313
+
70
314
  # License
71
- The MIT License (MIT). Please see [License](https://github.com/gre-dev/Greip-JS/blob/main/LICENSE) File for more information.
315
+
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,9 +1,9 @@
1
1
  {
2
2
  "name": "greip.js",
3
- "version": "2.2.0",
3
+ "version": "2.3.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,19 @@
14
14
  "ip",
15
15
  "api",
16
16
  "geolocation",
17
- "geoip"
17
+ "geoip",
18
+ "fraud prevention",
19
+ "abuse",
20
+ "ai",
21
+ "asn",
22
+ "iban"
18
23
  ],
19
24
  "files": [
20
25
  "lib/**/*"
21
26
  ],
22
- "homepage": "https://github.com/gre-dev/Greip-JS#readme",
27
+ "homepage": "https://github.com/Greipio/Greip-JS#readme",
23
28
  "bugs": {
24
- "url": "https://github.com/gre-dev/Greip-JS/issues",
29
+ "url": "https://github.com/Greipio/Greip-JS/issues",
25
30
  "email": "info@greip.io"
26
31
  },
27
32
  "funding": {
@@ -41,7 +46,7 @@
41
46
  },
42
47
  "repository": {
43
48
  "type": "git",
44
- "url": "https://github.com/gre-dev/Greip-JS.git"
49
+ "url": "https://github.com/Greipio/Greip-JS.git"
45
50
  },
46
51
  "dependencies": {
47
52
  "axios": "^0.25.0"