mirror of
https://github.com/AikidoSec/safe-chain.git
synced 2026-05-26 20:20:49 +00:00
Cleanup
This commit is contained in:
parent
290a630526
commit
157725a25a
2 changed files with 5 additions and 46 deletions
|
|
@ -1,7 +1,9 @@
|
|||
import { getMinimumPackageAgeHours } from "../../../config/settings.js";
|
||||
import { ui } from "../../../environment/userInteraction.js";
|
||||
|
||||
let hasSuppressedVersions = false;
|
||||
const state = {
|
||||
hasSuppressedVersions: false,
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {NodeJS.Dict<string | string[]>} headers
|
||||
|
|
@ -109,7 +111,7 @@ export function modifyNpmInfoResponse(body, headers) {
|
|||
* @param {string} version
|
||||
*/
|
||||
function deleteVersionFromJson(json, version) {
|
||||
hasSuppressedVersions = true;
|
||||
state.hasSuppressedVersions = true;
|
||||
|
||||
ui.writeVerbose(
|
||||
`Safe-chain: ${version} is newer than ${getMinimumPackageAgeHours()} hours and was removed (minimumPackageAgeInHours setting).`
|
||||
|
|
@ -168,7 +170,7 @@ function getMostRecentTag(tagList) {
|
|||
* @returns {boolean}
|
||||
*/
|
||||
export function getHasSuppressedVersions() {
|
||||
return hasSuppressedVersions;
|
||||
return state.hasSuppressedVersions;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,43 +0,0 @@
|
|||
/**
|
||||
* @typedef {Object} ResponseInterceptorBuilder
|
||||
* @property {() => ResponseInterceptor} build
|
||||
* @property {(modificationFunc: (body: Buffer) => Buffer) => void} modifyBody
|
||||
*
|
||||
* @typedef {Object} ResponseInterceptor
|
||||
* @property {(buffer: Buffer) => Buffer} modifyBody
|
||||
*/
|
||||
|
||||
/**
|
||||
* @returns {ResponseInterceptorBuilder}
|
||||
*/
|
||||
export function createResponseInterceptorBuilder() {
|
||||
/** @type {Array<(body: Buffer) => Buffer>} */
|
||||
let modifyBodyFuncs = [];
|
||||
|
||||
return {
|
||||
modifyBody: (func) => modifyBodyFuncs.push(func),
|
||||
build: () => createResponseInterceptor(modifyBodyFuncs),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {ResponseInterceptor}
|
||||
* @param {Array<(body: Buffer) => Buffer>} modifyBodyFuncs
|
||||
*/
|
||||
function createResponseInterceptor(modifyBodyFuncs) {
|
||||
/**
|
||||
* @param {Buffer} body
|
||||
* @returns {Buffer}
|
||||
*/
|
||||
function modifyBody(body) {
|
||||
let modifiedBody = body;
|
||||
|
||||
for (var func of modifyBodyFuncs) {
|
||||
modifiedBody = func(body);
|
||||
}
|
||||
|
||||
return modifiedBody;
|
||||
}
|
||||
|
||||
return { modifyBody };
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue