@datadome/fraud-sdk-node
Version:
Fraud Protection - Node.js SDK
82 lines • 2.22 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.truncationSize = truncationSize;
exports.truncateValue = truncateValue;
function truncationSize(fieldName) {
switch (fieldName) {
case 'SecCHDeviceMemory':
case 'SecCHUAMobile':
return 8;
case 'SecCHUAArch':
return 16;
case 'SecCHUAPlatform':
return 32;
case 'ContentType':
return 64;
case 'AcceptCharset':
case 'AcceptEncoding':
case 'ClientID':
case 'Connection':
case 'From':
case 'SecCHUA':
case 'SecCHUAModel':
case 'XRealIp':
return 128;
case 'AcceptLanguage':
case 'SecCHUAFullVersionList':
return 256;
case 'Accept':
case 'Origin':
case 'ServerHostname':
case 'Host':
return 512;
case 'UserAgent':
return 768;
case 'Referer':
return 1024;
case 'Request':
return 2048;
case 'XForwardedForIp':
return -512;
case 'AddressCountryCode':
return 2;
case 'UserExternalUrl':
case 'UserPictureUrl':
return 10;
case 'AddressRegionCode':
case 'AddressZipCode':
return 15;
case 'UserPhone':
return 16;
case 'UserFirstName':
case 'UserLastName':
case 'AddressName':
return 50;
case 'UserDisplayName':
return 100;
case 'AddressLine1':
case 'AddressLine2':
case 'AddressCity':
case 'SessionId':
return 255;
case 'Account':
case 'UserId':
case 'UserEmail':
case 'UserDescription':
return 320;
case 'UserUrlItem':
return 2048;
default:
return 0;
}
}
function truncateValue(value, maxLength) {
if (value === undefined) {
return '';
}
if (maxLength == null || maxLength === 0) {
return value;
}
return maxLength < 0 ? value.slice(maxLength) : value.slice(0, maxLength);
}
//# sourceMappingURL=utils.js.map