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

fetch-request-browser

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fetch-request-browser - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

18

dist/index.d.ts

@@ -12,3 +12,4 @@ import { IRequestInput, IRequestMethod, IRequestOptions, IResponseDataType, IOptions, IRequestResponse } from './shared/types.js';

* - UNEXPECTED_RESPONSE_STATUS_CODE: if the code doesn't meet the requirements set in the options
* - CONTENT_TYPE_MISSMATCH: if the Content-Type Headers are not identical
* - INVALID_RESPONSE_CONTENT_TYPE: if the res lacks the Content-Type Header or is an empty string
* - CONTENT_TYPE_MISSMATCH: if the Content-Type Headers don't match
* - INVALID_RESPONSE_DTYPE: if the data type is not supported by the Response Instance

@@ -32,3 +33,4 @@ */

* - UNEXPECTED_RESPONSE_STATUS_CODE: if the code doesn't meet the requirements set in the options
* - CONTENT_TYPE_MISSMATCH: if the Content-Type Headers are not identical
* - INVALID_RESPONSE_CONTENT_TYPE: if the res lacks the Content-Type Header or is an empty string
* - CONTENT_TYPE_MISSMATCH: if the Content-Type Headers don't match
* - INVALID_RESPONSE_DTYPE: if the data type is not supported by the Response Instance

@@ -47,3 +49,4 @@ */

* - UNEXPECTED_RESPONSE_STATUS_CODE: if the code doesn't meet the requirements set in the options
* - CONTENT_TYPE_MISSMATCH: if the Content-Type Headers are not identical
* - INVALID_RESPONSE_CONTENT_TYPE: if the res lacks the Content-Type Header or is an empty string
* - CONTENT_TYPE_MISSMATCH: if the Content-Type Headers don't match
* - INVALID_RESPONSE_DTYPE: if the data type is not supported by the Response Instance

@@ -62,3 +65,4 @@ */

* - UNEXPECTED_RESPONSE_STATUS_CODE: if the code doesn't meet the requirements set in the options
* - CONTENT_TYPE_MISSMATCH: if the Content-Type Headers are not identical
* - INVALID_RESPONSE_CONTENT_TYPE: if the res lacks the Content-Type Header or is an empty string
* - CONTENT_TYPE_MISSMATCH: if the Content-Type Headers don't match
* - INVALID_RESPONSE_DTYPE: if the data type is not supported by the Response Instance

@@ -77,3 +81,4 @@ */

* - UNEXPECTED_RESPONSE_STATUS_CODE: if the code doesn't meet the requirements set in the options
* - CONTENT_TYPE_MISSMATCH: if the Content-Type Headers are not identical
* - INVALID_RESPONSE_CONTENT_TYPE: if the res lacks the Content-Type Header or is an empty string
* - CONTENT_TYPE_MISSMATCH: if the Content-Type Headers don't match
* - INVALID_RESPONSE_DTYPE: if the data type is not supported by the Response Instance

@@ -92,3 +97,4 @@ */

* - UNEXPECTED_RESPONSE_STATUS_CODE: if the code doesn't meet the requirements set in the options
* - CONTENT_TYPE_MISSMATCH: if the Content-Type Headers are not identical
* - INVALID_RESPONSE_CONTENT_TYPE: if the res lacks the Content-Type Header or is an empty string
* - CONTENT_TYPE_MISSMATCH: if the Content-Type Headers don't match
* - INVALID_RESPONSE_DTYPE: if the data type is not supported by the Response Instance

@@ -95,0 +101,0 @@ */

@@ -7,4 +7,5 @@ declare enum ERRORS {

UNEXPECTED_RESPONSE_STATUS_CODE = "UNEXPECTED_RESPONSE_STATUS_CODE",
INVALID_RESPONSE_CONTENT_TYPE = "INVALID_RESPONSE_CONTENT_TYPE",
CONTENT_TYPE_MISSMATCH = "CONTENT_TYPE_MISSMATCH"
}
export { ERRORS, };

@@ -1,1 +0,1 @@

var ERRORS;!function(E){E.INVALID_REQUEST_URL="INVALID_REQUEST_URL",E.INVALID_REQUEST_HEADERS="INVALID_REQUEST_HEADERS",E.INVALID_REQUEST_OPTIONS="INVALID_REQUEST_OPTIONS",E.INVALID_RESPONSE_DTYPE="INVALID_RESPONSE_DTYPE",E.UNEXPECTED_RESPONSE_STATUS_CODE="UNEXPECTED_RESPONSE_STATUS_CODE",E.CONTENT_TYPE_MISSMATCH="CONTENT_TYPE_MISSMATCH"}(ERRORS||(ERRORS={}));export{ERRORS};
var ERRORS;!function(E){E.INVALID_REQUEST_URL="INVALID_REQUEST_URL",E.INVALID_REQUEST_HEADERS="INVALID_REQUEST_HEADERS",E.INVALID_REQUEST_OPTIONS="INVALID_REQUEST_OPTIONS",E.INVALID_RESPONSE_DTYPE="INVALID_RESPONSE_DTYPE",E.UNEXPECTED_RESPONSE_STATUS_CODE="UNEXPECTED_RESPONSE_STATUS_CODE",E.INVALID_RESPONSE_CONTENT_TYPE="INVALID_RESPONSE_CONTENT_TYPE",E.CONTENT_TYPE_MISSMATCH="CONTENT_TYPE_MISSMATCH"}(ERRORS||(ERRORS={}));export{ERRORS};

@@ -9,5 +9,6 @@ import { IOptions } from '../shared/types.js';

* - UNEXPECTED_RESPONSE_STATUS_CODE: if the code doesn't meet the requirements set in the options
* - CONTENT_TYPE_MISSMATCH: if the Content-Type Headers are not identical
* - INVALID_RESPONSE_CONTENT_TYPE: if the res lacks the Content-Type Header or is an empty string
* - CONTENT_TYPE_MISSMATCH: if the Content-Type Headers don't match
*/
declare const validateResponse: (req: Request, res: Response, options: IOptions) => void;
export { validateResponse, };

@@ -1,1 +0,1 @@

import{encodeError}from"error-message-utils";import{ERRORS}from"../shared/errors.js";const __buildUnexpectedCodeErrorMessage=e=>encodeError(`Request Failed: received unexpected response code '${e.status}': ${e.statusText}`,ERRORS.UNEXPECTED_RESPONSE_STATUS_CODE),__validateStatusCode=(e,t)=>{if(Array.isArray(t.acceptableStatusCodes)&&t.acceptableStatusCodes.length){if(!t.acceptableStatusCodes.includes(e.status))throw new Error(__buildUnexpectedCodeErrorMessage(e))}else if(e.status<t.acceptableStatusCodesRange.min||e.status>t.acceptableStatusCodesRange.max)throw new Error(__buildUnexpectedCodeErrorMessage(e))},__validateContentType=(e,t)=>{const r=e.headers.get("Accept"),s=t.headers.get("Content-Type");if(r!==s)throw new Error(encodeError(`The request's Accept Header '${r}' is different from the Content-Type received in the response '${s}'.`,ERRORS.CONTENT_TYPE_MISSMATCH))},validateResponse=(e,t,r)=>{__validateStatusCode(t,r),__validateContentType(e,t)};export{validateResponse};
import{encodeError}from"error-message-utils";import{ERRORS}from"../shared/errors.js";const __buildUnexpectedCodeErrorMessage=e=>encodeError(`Request Failed: received unexpected response code '${e.status}': ${e.statusText}`,ERRORS.UNEXPECTED_RESPONSE_STATUS_CODE),__validateStatusCode=(e,t)=>{if(Array.isArray(t.acceptableStatusCodes)&&t.acceptableStatusCodes.length){if(!t.acceptableStatusCodes.includes(e.status))throw new Error(__buildUnexpectedCodeErrorMessage(e))}else if(e.status<t.acceptableStatusCodesRange.min||e.status>t.acceptableStatusCodesRange.max)throw new Error(__buildUnexpectedCodeErrorMessage(e))},__validateContentType=(e,t)=>{const r=e.headers.get("Accept"),s=t.headers.get("Content-Type");if("string"!=typeof s||!s.length)throw new Error(encodeError(`The response's Content-Type Header is invalid. Received: '${s}'.`,ERRORS.INVALID_RESPONSE_CONTENT_TYPE));if(!s.includes(r))throw new Error(encodeError(`The request's Accept Header '${r}' is different to the Content-Type received in the response '${s}'.`,ERRORS.CONTENT_TYPE_MISSMATCH))},validateResponse=(e,t,r)=>{__validateStatusCode(t,r),__validateContentType(e,t)};export{validateResponse};
{
"name": "fetch-request-browser",
"version": "1.0.0",
"version": "1.0.1",
"description": "The fetch-request-browser package makes working with external APIs simple and efficient. This intuitive wrapper leverages the power of the Fetch API, providing a clean and concise interface for your API interactions.",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -6,5 +6,5 @@ # Fetch Request Browser

If you are working on a node-based environment, make use of [fetch-request-node](https://github.com/jesusgraterol/fetch-request-node) instead.
<br />

@@ -11,0 +11,0 @@

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