@reyaxyz/risk-sdk 0.3.4 → 0.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.
|
@@ -43,47 +43,11 @@ var GeofencingClient = /** @class */ (function () {
|
|
|
43
43
|
}
|
|
44
44
|
GeofencingClient.prototype.checkIPAddress = function (params) {
|
|
45
45
|
return __awaiter(this, void 0, void 0, function () {
|
|
46
|
-
var cachedResult, url, response, ipInfo, error_1;
|
|
47
46
|
return __generator(this, function (_a) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
// Return the cached result if available
|
|
53
|
-
return [2 /*return*/, {
|
|
54
|
-
isVpn: cachedResult.privacy.vpn,
|
|
55
|
-
}];
|
|
56
|
-
}
|
|
57
|
-
url = "https://ipinfo.io/".concat(params.ipAddress, "?token=").concat(this.ipInfoApiKey);
|
|
58
|
-
_a.label = 1;
|
|
59
|
-
case 1:
|
|
60
|
-
_a.trys.push([1, 4, , 5]);
|
|
61
|
-
return [4 /*yield*/, fetch(url, {
|
|
62
|
-
method: 'GET',
|
|
63
|
-
headers: {
|
|
64
|
-
Accept: 'application/json',
|
|
65
|
-
},
|
|
66
|
-
})];
|
|
67
|
-
case 2:
|
|
68
|
-
response = _a.sent();
|
|
69
|
-
// Check if the response is successful
|
|
70
|
-
if (!response.ok) {
|
|
71
|
-
throw new Error("Error fetching IP info: ".concat(response.statusText));
|
|
72
|
-
}
|
|
73
|
-
return [4 /*yield*/, response.json()];
|
|
74
|
-
case 3:
|
|
75
|
-
ipInfo = (_a.sent());
|
|
76
|
-
// Proceed with the rest of your logic
|
|
77
|
-
this.cache[params.ipAddress] = ipInfo;
|
|
78
|
-
return [2 /*return*/, {
|
|
79
|
-
isVpn: ipInfo.privacy.vpn,
|
|
80
|
-
}];
|
|
81
|
-
case 4:
|
|
82
|
-
error_1 = _a.sent();
|
|
83
|
-
console.error('Failed to fetch IP info:', error_1);
|
|
84
|
-
throw new Error('Failed to check IP address');
|
|
85
|
-
case 5: return [2 /*return*/];
|
|
86
|
-
}
|
|
47
|
+
console.log(params.ipAddress);
|
|
48
|
+
return [2 /*return*/, {
|
|
49
|
+
isVpn: false,
|
|
50
|
+
}];
|
|
87
51
|
});
|
|
88
52
|
});
|
|
89
53
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"/","sources":["clients/modules/geofencing/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA;IAIE,0BAAY,YAAoB;QAFxB,UAAK,GAAgB,EAAE,CAAC,CAAC,oCAAoC;QAGnE,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACnC,CAAC;IAEK,yCAAc,GAApB,UACE,MAA4B
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"/","sources":["clients/modules/geofencing/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA;IAIE,0BAAY,YAAoB;QAFxB,UAAK,GAAgB,EAAE,CAAC,CAAC,oCAAoC;QAGnE,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACnC,CAAC;IAEK,yCAAc,GAApB,UACE,MAA4B;;;gBAE5B,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;gBAC9B,sBAAO;wBACL,KAAK,EAAE,KAAK;qBACb,EAAC;;;KAuCH;IACH,uBAAC;AAAD,CAAC,AAtDD,IAsDC","sourcesContent":["import { IpInfo } from '@reyaxyz/common';\nimport { CheckIPAddressParams, CheckIPAddressResult } from './types';\n\n// Define a cache interface\ninterface IpInfoCache {\n [key: string]: IpInfo;\n}\n\nexport default class GeofencingClient {\n readonly ipInfoApiKey: string;\n private cache: IpInfoCache = {}; // Cache for storing IP info results\n\n constructor(ipInfoApiKey: string) {\n this.ipInfoApiKey = ipInfoApiKey;\n }\n\n async checkIPAddress(\n params: CheckIPAddressParams,\n ): Promise<CheckIPAddressResult> {\n console.log(params.ipAddress);\n return {\n isVpn: false,\n };\n // // Check if we already have the result in cache\n // const cachedResult = this.cache[params.ipAddress];\n // if (cachedResult) {\n // // Return the cached result if available\n // return {\n // isVpn: cachedResult.privacy.vpn,\n // };\n // }\n //\n // // If the result is not in cache, make a request to ipinfo\n // const url = `https://ipinfo.io/${params.ipAddress}?token=${this.ipInfoApiKey}`;\n //\n // try {\n // const response = await fetch(url, {\n // method: 'GET',\n // headers: {\n // Accept: 'application/json',\n // },\n // });\n //\n // // Check if the response is successful\n // if (!response.ok) {\n // throw new Error(`Error fetching IP info: ${response.statusText}`);\n // }\n //\n // // Use type assertion here\n // const ipInfo = (await response.json()) as IpInfo;\n //\n // // Proceed with the rest of your logic\n // this.cache[params.ipAddress] = ipInfo;\n //\n // return {\n // isVpn: ipInfo.privacy.vpn,\n // };\n // } catch (error) {\n // console.error('Failed to fetch IP info:', error);\n // throw new Error('Failed to check IP address');\n // }\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["clients/modules/geofencing/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAOrE,MAAM,CAAC,OAAO,OAAO,gBAAgB;IACnC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,OAAO,CAAC,KAAK,CAAmB;gBAEpB,YAAY,EAAE,MAAM;IAI1B,cAAc,CAClB,MAAM,EAAE,oBAAoB,GAC3B,OAAO,CAAC,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["clients/modules/geofencing/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAOrE,MAAM,CAAC,OAAO,OAAO,gBAAgB;IACnC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,OAAO,CAAC,KAAK,CAAmB;gBAEpB,YAAY,EAAE,MAAM;IAI1B,cAAc,CAClB,MAAM,EAAE,oBAAoB,GAC3B,OAAO,CAAC,oBAAoB,CAAC;CA4CjC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reyaxyz/risk-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"registry": "https://registry.npmjs.org"
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
"generate:coverage-badges": "npx istanbul-badges-readme --silent"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@reyaxyz/common": "0.
|
|
36
|
+
"@reyaxyz/common": "0.69.0"
|
|
37
37
|
},
|
|
38
38
|
"packageManager": "pnpm@8.10.4",
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "44248bc6ba59e432efdd5de00916fa16e81dd499"
|
|
40
40
|
}
|
|
@@ -17,43 +17,47 @@ export default class GeofencingClient {
|
|
|
17
17
|
async checkIPAddress(
|
|
18
18
|
params: CheckIPAddressParams,
|
|
19
19
|
): Promise<CheckIPAddressResult> {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
//
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
20
|
+
console.log(params.ipAddress);
|
|
21
|
+
return {
|
|
22
|
+
isVpn: false,
|
|
23
|
+
};
|
|
24
|
+
// // Check if we already have the result in cache
|
|
25
|
+
// const cachedResult = this.cache[params.ipAddress];
|
|
26
|
+
// if (cachedResult) {
|
|
27
|
+
// // Return the cached result if available
|
|
28
|
+
// return {
|
|
29
|
+
// isVpn: cachedResult.privacy.vpn,
|
|
30
|
+
// };
|
|
31
|
+
// }
|
|
32
|
+
//
|
|
33
|
+
// // If the result is not in cache, make a request to ipinfo
|
|
34
|
+
// const url = `https://ipinfo.io/${params.ipAddress}?token=${this.ipInfoApiKey}`;
|
|
35
|
+
//
|
|
36
|
+
// try {
|
|
37
|
+
// const response = await fetch(url, {
|
|
38
|
+
// method: 'GET',
|
|
39
|
+
// headers: {
|
|
40
|
+
// Accept: 'application/json',
|
|
41
|
+
// },
|
|
42
|
+
// });
|
|
43
|
+
//
|
|
44
|
+
// // Check if the response is successful
|
|
45
|
+
// if (!response.ok) {
|
|
46
|
+
// throw new Error(`Error fetching IP info: ${response.statusText}`);
|
|
47
|
+
// }
|
|
48
|
+
//
|
|
49
|
+
// // Use type assertion here
|
|
50
|
+
// const ipInfo = (await response.json()) as IpInfo;
|
|
51
|
+
//
|
|
52
|
+
// // Proceed with the rest of your logic
|
|
53
|
+
// this.cache[params.ipAddress] = ipInfo;
|
|
54
|
+
//
|
|
55
|
+
// return {
|
|
56
|
+
// isVpn: ipInfo.privacy.vpn,
|
|
57
|
+
// };
|
|
58
|
+
// } catch (error) {
|
|
59
|
+
// console.error('Failed to fetch IP info:', error);
|
|
60
|
+
// throw new Error('Failed to check IP address');
|
|
61
|
+
// }
|
|
58
62
|
}
|
|
59
63
|
}
|