🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

header-generator

Package Overview
Dependencies
Maintainers
2
Versions
130
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

header-generator - npm Package Compare versions

Comparing version

to
2.1.0-dev.0

2

header-generator.d.ts

@@ -128,3 +128,3 @@ import { SUPPORTED_BROWSERS, MISSING_VALUE_DATASET_TOKEN, SUPPORTED_OPERATING_SYSTEMS, SUPPORTED_DEVICES, SUPPORTED_HTTP_VERSIONS } from './constants';

*/
getHeaders(options?: Partial<HeaderGeneratorOptions>, requestDependentHeaders?: Headers): Headers;
getHeaders(options?: Partial<HeaderGeneratorOptions>, requestDependentHeaders?: Headers, userAgentValues?: string[]): Headers;
/**

@@ -131,0 +131,0 @@ * Returns a new object that contains ordered headers.

@@ -17,7 +17,7 @@ "use strict";

exports.headerGeneratorOptionsShape = {
browsers: ow_1.default.optional.array.ofType(ow_1.default.any(ow_1.default.object.exactShape(browserSpecificationShape), ow_1.default.string)),
operatingSystems: ow_1.default.optional.array.ofType(ow_1.default.string),
devices: ow_1.default.optional.array.ofType(ow_1.default.string),
browsers: ow_1.default.optional.array.ofType(ow_1.default.any(ow_1.default.object.exactShape(browserSpecificationShape), ow_1.default.string.oneOf(constants_1.SUPPORTED_BROWSERS))),
operatingSystems: ow_1.default.optional.array.ofType(ow_1.default.string.oneOf(constants_1.SUPPORTED_OPERATING_SYSTEMS)),
devices: ow_1.default.optional.array.ofType(ow_1.default.string.oneOf(constants_1.SUPPORTED_DEVICES)),
locales: ow_1.default.optional.array.ofType(ow_1.default.string),
httpVersion: ow_1.default.optional.string,
httpVersion: ow_1.default.optional.string.oneOf(constants_1.SUPPORTED_HTTP_VERSIONS),
browserListQuery: ow_1.default.optional.string,

@@ -99,8 +99,22 @@ };

*/
getHeaders(options = {}, requestDependentHeaders = {}) {
(0, ow_1.default)(options, 'HeaderGeneratorOptions', ow_1.default.object.exactShape(exports.headerGeneratorOptionsShape));
getHeaders(options = {}, requestDependentHeaders = {}, userAgentValues) {
(0, ow_1.default)(options, 'HeaderGeneratorOptions', ow_1.default.object.partialShape(exports.headerGeneratorOptionsShape));
const headerOptions = { ...this.globalOptions, ...options };
const possibleAttributeValues = this._getPossibleAttributeValues(headerOptions);
const [http1Values, http2Values] = userAgentValues ? [
generative_bayesian_network_1.utils.getPossibleValues(this.headerGeneratorNetwork, { 'User-Agent': userAgentValues }),
generative_bayesian_network_1.utils.getPossibleValues(this.headerGeneratorNetwork, { 'user-agent': userAgentValues }),
] : [null, null];
// Generate a sample of input attributes consistent with the data used to create the definition files if possible.
const inputSample = this.inputGeneratorNetwork.generateConsistentSampleWhenPossible(possibleAttributeValues);
const inputSample = this.inputGeneratorNetwork.generateConsistentSampleWhenPossible(Object.entries(possibleAttributeValues).reduce((acc, [key, value]) => {
if (key === '*BROWSER_HTTP') {
acc[key] = value.filter((x) => {
const [browserName, httpVersion] = x.split('|');
return (httpVersion === '1' ? http1Values : http2Values)?.['*BROWSER'].includes(browserName) ?? true;
});
return acc;
}
acc[key] = value.filter((x) => (http1Values?.[key]?.includes(x) || http2Values?.[key]?.includes(x)) ?? true);
return acc;
}, {}));
if (Object.keys(inputSample).length === 0) {

@@ -107,0 +121,0 @@ throw new Error('No headers based on this input can be generated. Please relax or change some of the requirements you specified.');

{
"name": "header-generator",
"version": "2.0.9",
"version": "2.1.0-dev.0",
"description": "NodeJS package for generating realistic browser-like HTTP headers.",

@@ -27,3 +27,3 @@ "author": {

"browserslist": "^4.21.1",
"generative-bayesian-network": "^2.0.8",
"generative-bayesian-network": "^2.1.0-dev.0",
"ow": "^0.28.1",

@@ -46,3 +46,3 @@ "tslib": "^2.4.0"

},
"gitHead": "f2821b289cf8a57a175a12b01b35b5f74f3f92b7"
"gitHead": "e4d978b594a458843f91df63873091c748c5cff0"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet