New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@adguard/diff-builder

Package Overview
Dependencies
Maintainers
3
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@adguard/diff-builder - npm Package Compare versions

Comparing version 1.0.16 to 1.0.17

dist/types/diff-updater/unacceptable-response-error.d.ts

53

CHANGELOG.md

@@ -8,72 +8,117 @@ # Diff Builder Changelog

## [1.0.17] - 2024-03-25
### Added
- Throwing of `UnacceptableResponseError` by `DiffUpdater.applyPatch()`
if response status is unacceptable [AdguardBrowserExtension#2717].
[AdguardBrowserExtension#2717]: https://github.com/AdguardTeam/AdguardBrowserExtension/issues/2717
[1.0.17]: https://github.com/AdguardTeam/DiffBuilder/compare/v1.0.16...v1.0.17
## [1.0.16] - 2024-03-18
### Fixed
- Checking validity of builded patch.
[1.0.16]: https://github.com/AdguardTeam/DiffBuilder/compare/v1.0.13...v1.0.16
## [1.0.13] - 2024-01-17
### Changed
- Use forked `diff` package.
[1.0.13]: https://github.com/AdguardTeam/DiffBuilder/compare/v1.0.12...v1.0.13
## [1.0.12] - 2024-01-17
### Changed
- Throw error when response status for network request is invalid.
[1.0.12]: https://github.com/AdguardTeam/DiffBuilder/compare/v1.0.11...v1.0.12
## [1.0.11] - 2024-01-16
### Fixed
- Do not delete a patch if it is empty.
### Added
- Validating for generated patch.
## Changed
- Write generated patch to folder with new filter.
[1.0.11]: https://github.com/AdguardTeam/DiffBuilder/compare/v1.0.10...v1.0.11
## [1.0.10] - 2024-01-11
### Fixed
- Deleting outdated patches.
- Fixed line endings in updated tags.
[1.0.10]: https://github.com/AdguardTeam/DiffBuilder/compare/v1.0.9...v1.0.10
## [1.0.9] - 2024-01-08
### Fixed
- Use last available version of `jsdiff` to fix error with large patches.
[1.0.9]: https://github.com/AdguardTeam/DiffBuilder/compare/v1.0.8...v1.0.9
## [1.0.8] - 2023-12-29
### Changed
- Use fetch instead of axios for file urls
[1.0.8]: https://github.com/AdguardTeam/DiffBuilder/compare/v1.0.7...v1.0.8
## [1.0.7] - 2023-12-29
### Fixed
- Handle backslashes '\' for Windows file paths.
[1.0.7]: https://github.com/AdguardTeam/DiffBuilder/compare/v1.0.6...v1.0.7
## [1.0.6] - 2023-12-26
### Fixed
- Handle user agent headers in the filter content.
[1.0.6]: https://github.com/AdguardTeam/DiffBuilder/compare/v1.0.5...v1.0.6
## [1.0.5] - 2023-12-25
### Fixed
- Bug with cutting filter content to first 50 lines.
[1.0.5]: https://github.com/AdguardTeam/DiffBuilder/compare/v1.0.4...v1.0.5
## [1.0.4] - 2023-12-25
### Changed
- The algorithm has been modified to ignore changes in the 'Diff-Path' and

@@ -85,12 +130,20 @@ 'Checksum' tags, but it now accounts for the presence of the 'Checksum' tag

[1.0.4]: https://github.com/AdguardTeam/DiffBuilder/compare/v1.0.3...v1.0.4
## [1.0.3] - 2023-12-20
### Fixed
- Recalculate only first found checksum.
[1.0.3]: https://github.com/AdguardTeam/DiffBuilder/compare/v1.0.2...v1.0.3
## [1.0.2] - 2023-12-20
### Fixed
- Recalculating checksum of the new filter after adding Diff-Path tag.
[1.0.2]: https://github.com/AdguardTeam/DiffBuilder/compare/v1.0.1...v1.0.2

48

dist/api/updater/cjs/index.js

@@ -709,3 +709,21 @@ 'use strict';

const ERROR_NAME = 'UnacceptableResponseError';
/**
* Customized error class for unacceptable responses for patch requests.
*/
class UnacceptableResponseError extends Error {
/**
* Constructs a new `UnacceptableResponseError` instance.
*
* @param message Error message.
*/
constructor(message) {
super(message);
this.name = ERROR_NAME;
// For proper work of the "instanceof" operator
Object.setPrototypeOf(this, UnacceptableResponseError.prototype);
}
}
/**
* If the differential update is not available the server may signal about that

@@ -844,4 +862,9 @@ * by returning one of the following responses.

*
* @throws {Error} If there is an error during the network request, the file
* is not found, or the file is empty.
* @throws
* 1. An {@link Error} if:
* - there is an error during the network request,
* - the file is not found,
* - or the file is empty.
* 2. The {@link UnacceptableResponseError} if network-hosted file request
* returns an unacceptable status code, e.g. 403.
*/

@@ -860,5 +883,5 @@ const downloadFile = async (baseURL, fileUrl, isFileHostedViaNetworkProtocol, isRecursiveUpdate, log) => {

if (!acceptableHttpStatusCodes.includes(response.status)) {
const err = `Error during network request: ${response.status} ${response.statusText}`;
const err = `Unacceptable response for network request: ${response.status} ${response.statusText}`;
log(err);
throw new Error(err);
throw new UnacceptableResponseError(err);
}

@@ -881,2 +904,3 @@ }

catch (e) {
// We ignore errors for local files
if (!isFileHostedViaNetworkProtocol) {

@@ -886,2 +910,6 @@ log(`Error during file request to "${baseURL}"/"${fileUrl}": ${getErrorMessage(e)}`);

}
if (e instanceof UnacceptableResponseError) {
// re-throw the error as is
throw e;
}
throw new Error(`Error during network request: ${getErrorMessage(e)}`, { cause: e });

@@ -922,4 +950,7 @@ }

*
* @throws {Error} If there is an error during the patch application process
* or during network request.
* @throws
* 1. An {@link Error} if there is an error during
* - the patch application process
* - during network request.
* 2. The {@link UnacceptableResponseError} if the network request returns an unacceptable status code.
*/

@@ -952,2 +983,6 @@ const applyPatch = async (params) => {

catch (e) {
if (e instanceof UnacceptableResponseError) {
// re-throw the error as is
throw e;
}
// eslint-disable-next-line max-len

@@ -994,1 +1029,2 @@ throw new Error(`Error during downloading patch file from "${diffPath}": ${getErrorMessage(e)}`, { cause: e });

exports.DiffUpdater = DiffUpdater;
exports.UnacceptableResponseError = UnacceptableResponseError;

@@ -707,3 +707,21 @@ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};

const ERROR_NAME = 'UnacceptableResponseError';
/**
* Customized error class for unacceptable responses for patch requests.
*/
class UnacceptableResponseError extends Error {
/**
* Constructs a new `UnacceptableResponseError` instance.
*
* @param message Error message.
*/
constructor(message) {
super(message);
this.name = ERROR_NAME;
// For proper work of the "instanceof" operator
Object.setPrototypeOf(this, UnacceptableResponseError.prototype);
}
}
/**
* If the differential update is not available the server may signal about that

@@ -842,4 +860,9 @@ * by returning one of the following responses.

*
* @throws {Error} If there is an error during the network request, the file
* is not found, or the file is empty.
* @throws
* 1. An {@link Error} if:
* - there is an error during the network request,
* - the file is not found,
* - or the file is empty.
* 2. The {@link UnacceptableResponseError} if network-hosted file request
* returns an unacceptable status code, e.g. 403.
*/

@@ -858,5 +881,5 @@ const downloadFile = async (baseURL, fileUrl, isFileHostedViaNetworkProtocol, isRecursiveUpdate, log) => {

if (!acceptableHttpStatusCodes.includes(response.status)) {
const err = `Error during network request: ${response.status} ${response.statusText}`;
const err = `Unacceptable response for network request: ${response.status} ${response.statusText}`;
log(err);
throw new Error(err);
throw new UnacceptableResponseError(err);
}

@@ -879,2 +902,3 @@ }

catch (e) {
// We ignore errors for local files
if (!isFileHostedViaNetworkProtocol) {

@@ -884,2 +908,6 @@ log(`Error during file request to "${baseURL}"/"${fileUrl}": ${getErrorMessage(e)}`);

}
if (e instanceof UnacceptableResponseError) {
// re-throw the error as is
throw e;
}
throw new Error(`Error during network request: ${getErrorMessage(e)}`, { cause: e });

@@ -920,4 +948,7 @@ }

*
* @throws {Error} If there is an error during the patch application process
* or during network request.
* @throws
* 1. An {@link Error} if there is an error during
* - the patch application process
* - during network request.
* 2. The {@link UnacceptableResponseError} if the network request returns an unacceptable status code.
*/

@@ -950,2 +981,6 @@ const applyPatch = async (params) => {

catch (e) {
if (e instanceof UnacceptableResponseError) {
// re-throw the error as is
throw e;
}
// eslint-disable-next-line max-len

@@ -991,2 +1026,2 @@ throw new Error(`Error during downloading patch file from "${diffPath}": ${getErrorMessage(e)}`, { cause: e });

export { DiffUpdater };
export { DiffUpdater, UnacceptableResponseError };

3

dist/types/diff-updater/index.d.ts
import { type ApplyPatchParams } from './update';
import { UnacceptableResponseError } from './unacceptable-response-error';
declare const DiffUpdater: {
applyPatch: (params: ApplyPatchParams) => Promise<string | null>;
};
export { DiffUpdater, type ApplyPatchParams, };
export { DiffUpdater, UnacceptableResponseError, type ApplyPatchParams, };

@@ -52,5 +52,8 @@ /**

*
* @throws {Error} If there is an error during the patch application process
* or during network request.
* @throws
* 1. An {@link Error} if there is an error during
* - the patch application process
* - during network request.
* 2. The {@link UnacceptableResponseError} if the network request returns an unacceptable status code.
*/
export declare const applyPatch: (params: ApplyPatchParams) => Promise<string | null>;
{
"name": "@adguard/diff-builder",
"version": "1.0.16",
"version": "1.0.17",
"description": "A tool for generating differential updates for filter lists.",

@@ -5,0 +5,0 @@ "repository": {

import { applyPatch, type ApplyPatchParams } from './update';
import { UnacceptableResponseError } from './unacceptable-response-error';

@@ -9,3 +10,4 @@ const DiffUpdater = {

DiffUpdater,
UnacceptableResponseError,
type ApplyPatchParams,
};

@@ -10,2 +10,3 @@ import { calculateChecksumSHA1 } from '../common/calculate-checksum';

import { parseTag } from '../diff-builder/tags';
import { UnacceptableResponseError } from './unacceptable-response-error';

@@ -227,4 +228,9 @@ /**

*
* @throws {Error} If there is an error during the network request, the file
* is not found, or the file is empty.
* @throws
* 1. An {@link Error} if:
* - there is an error during the network request,
* - the file is not found,
* - or the file is empty.
* 2. The {@link UnacceptableResponseError} if network-hosted file request
* returns an unacceptable status code, e.g. 403.
*/

@@ -251,5 +257,5 @@ const downloadFile = async (

if (!acceptableHttpStatusCodes.includes(response.status)) {
const err = `Error during network request: ${response.status} ${response.statusText}`;
const err = `Unacceptable response for network request: ${response.status} ${response.statusText}`;
log(err);
throw new Error(err);
throw new UnacceptableResponseError(err);
}

@@ -274,2 +280,3 @@ }

} catch (e) {
// We ignore errors for local files
if (!isFileHostedViaNetworkProtocol) {

@@ -279,2 +286,6 @@ log(`Error during file request to "${baseURL}"/"${fileUrl}": ${getErrorMessage(e)}`);

}
if (e instanceof UnacceptableResponseError) {
// re-throw the error as is
throw e;
}
throw new Error(`Error during network request: ${getErrorMessage(e)}`, { cause: e });

@@ -318,4 +329,7 @@ }

*
* @throws {Error} If there is an error during the patch application process
* or during network request.
* @throws
* 1. An {@link Error} if there is an error during
* - the patch application process
* - during network request.
* 2. The {@link UnacceptableResponseError} if the network request returns an unacceptable status code.
*/

@@ -366,2 +380,6 @@ export const applyPatch = async (params: ApplyPatchParams): Promise<string | null> => {

} catch (e) {
if (e instanceof UnacceptableResponseError) {
// re-throw the error as is
throw e;
}
// eslint-disable-next-line max-len

@@ -368,0 +386,0 @@ throw new Error(`Error during downloading patch file from "${diffPath}": ${getErrorMessage(e)}`, { cause: e });

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc