@optimiser/common 1.0.229 → 1.0.230
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/dist/lib/utility.js +33 -34
- package/package.json +1 -1
package/dist/lib/utility.js
CHANGED
|
@@ -88,13 +88,13 @@ var bson_1 = require("bson");
|
|
|
88
88
|
var Excel = __importStar(require("exceljs"));
|
|
89
89
|
var path_1 = __importDefault(require("path"));
|
|
90
90
|
var fs_1 = __importDefault(require("fs"));
|
|
91
|
-
var
|
|
91
|
+
var geoip = __importStar(require("geoip-lite"));
|
|
92
92
|
var crypto_1 = __importDefault(require("crypto"));
|
|
93
93
|
var constants_1 = __importDefault(require("../constants"));
|
|
94
94
|
var mail_1 = require("../utility/mail");
|
|
95
95
|
var errorHandlerForServices_1 = __importDefault(require("../utility/errorHandlerForServices"));
|
|
96
96
|
var cryptoService = __importStar(require("../utility/crypto"));
|
|
97
|
-
var
|
|
97
|
+
var countrycode_1 = require("./countrycode");
|
|
98
98
|
require("moment-timezone");
|
|
99
99
|
var sanitize = require('mongo-sanitize');
|
|
100
100
|
function GetObjectByKeyValueFromList(list, key, val) {
|
|
@@ -2973,40 +2973,39 @@ function ConvertFileByteSize(bytes) {
|
|
|
2973
2973
|
exports.ConvertFileByteSize = ConvertFileByteSize;
|
|
2974
2974
|
function GetIPDetailsFromReq(req) {
|
|
2975
2975
|
return __awaiter(this, void 0, void 0, function () {
|
|
2976
|
-
var ip,
|
|
2976
|
+
var ip, ipDetails;
|
|
2977
2977
|
return __generator(this, function (_a) {
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
console.log("In req.headers['x-forwarded-for']"); /* Temp for brijesh */
|
|
2986
|
-
ip = req.headers['x-forwarded-for'].split(",")[0];
|
|
2987
|
-
}
|
|
2988
|
-
else if (req.connection && req.connection.remoteAddress) {
|
|
2989
|
-
ip = req.connection.remoteAddress;
|
|
2990
|
-
}
|
|
2991
|
-
else {
|
|
2992
|
-
ip = req.ip;
|
|
2993
|
-
}
|
|
2994
|
-
domainName = req.headers.host ? req.headers.host : req.headers.origin;
|
|
2995
|
-
return [4 /*yield*/, axios_1.default.post("https://" + domainName + "/user/noauth/getlocationfromip", { ip: ip }, {
|
|
2996
|
-
httpsAgent: new https_1.default.Agent({
|
|
2997
|
-
rejectUnauthorized: false
|
|
2998
|
-
})
|
|
2999
|
-
})];
|
|
3000
|
-
case 1:
|
|
3001
|
-
ipDetails = (_a.sent()).data;
|
|
3002
|
-
ipDetails = ipDetails.data;
|
|
3003
|
-
/* if (ipDetails) {
|
|
3004
|
-
ipDetails.countryName = countryCode(ipDetails.country)
|
|
3005
|
-
ipDetails.ip = ip
|
|
3006
|
-
} */
|
|
3007
|
-
console.log('>>IP DE ', ipDetails);
|
|
3008
|
-
return [2 /*return*/, ipDetails];
|
|
2978
|
+
if (req.headers['x-original-forwarded-for']) {
|
|
2979
|
+
//console.log("In req.headers['x-original-forwarded-for']");
|
|
2980
|
+
ip = req.headers['x-original-forwarded-for'];
|
|
2981
|
+
}
|
|
2982
|
+
else if (req.headers['x-forwarded-for']) {
|
|
2983
|
+
//console.log("In req.headers['x-forwarded-for']");
|
|
2984
|
+
ip = req.headers['x-forwarded-for'].split(",")[0];
|
|
3009
2985
|
}
|
|
2986
|
+
else if (req.connection && req.connection.remoteAddress) {
|
|
2987
|
+
ip = req.connection.remoteAddress;
|
|
2988
|
+
}
|
|
2989
|
+
else {
|
|
2990
|
+
ip = req.ip;
|
|
2991
|
+
}
|
|
2992
|
+
ipDetails = geoip.lookup(ip);
|
|
2993
|
+
if (ipDetails) {
|
|
2994
|
+
ipDetails.countryName = countrycode_1.getCountryFromCode(ipDetails.country);
|
|
2995
|
+
ipDetails.ip = ip;
|
|
2996
|
+
// }
|
|
2997
|
+
//return connection.ReturnJsonResponse(req, res, { Status: 200, Message: 'success', Data: ipDetails, Type: 'POST', LogData: false });
|
|
2998
|
+
}
|
|
2999
|
+
else {
|
|
3000
|
+
ipDetails = '';
|
|
3001
|
+
}
|
|
3002
|
+
//ipDetails = ipDetails.data;
|
|
3003
|
+
/* if (ipDetails) {
|
|
3004
|
+
ipDetails.countryName = countryCode(ipDetails.country)
|
|
3005
|
+
ipDetails.ip = ip
|
|
3006
|
+
} */
|
|
3007
|
+
console.log('>>IP DE ', ipDetails);
|
|
3008
|
+
return [2 /*return*/, ipDetails];
|
|
3010
3009
|
});
|
|
3011
3010
|
});
|
|
3012
3011
|
}
|