Socket
Socket
Sign inDemoInstall

@octokit/request-error

Package Overview
Dependencies
6
Maintainers
3
Versions
37
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.4 to 1.1.0

dist-node/index.js.map

1

dist-node/index.js

@@ -55,1 +55,2 @@ 'use strict';

exports.RequestError = RequestError;
//# sourceMappingURL=index.js.map

3

dist-types/index.d.ts

@@ -1,2 +0,3 @@

import { RequestOptions, ResponseHeaders, RequestErrorOptions } from "./types";
import { RequestOptions, ResponseHeaders } from "@octokit/types";
import { RequestErrorOptions } from "./types";
/**

@@ -3,0 +4,0 @@ * Error with extra properties to help with debugging

@@ -1,34 +0,2 @@

/**
* Relative or absolute URL. Examples: `'/orgs/:org'`, `https://example.com/foo/bar`
*/
export declare type Url = string;
/**
* Request method
*/
export declare type Method = "DELETE" | "GET" | "HEAD" | "PATCH" | "POST" | "PUT";
export declare type RequestHeaders = {
/**
* Used for API previews and custom formats
*/
accept?: string;
/**
* Redacted authorization header
*/
authorization?: string;
"user-agent"?: string;
[header: string]: string | number | undefined;
};
export declare type ResponseHeaders = {
[header: string]: string;
};
export declare type EndpointRequestOptions = {
[option: string]: any;
};
export declare type RequestOptions = {
method: Method;
url: Url;
headers: RequestHeaders;
body?: any;
request?: EndpointRequestOptions;
};
import { RequestOptions, ResponseHeaders } from "@octokit/types";
export declare type RequestErrorOptions = {

@@ -35,0 +3,0 @@ headers: ResponseHeaders;

import { Deprecation } from 'deprecation';
import once from 'once';
const logOnce = once(deprecation => console.warn(deprecation));
const logOnce = once((deprecation) => console.warn(deprecation));
/**
* Error with extra properties to help with debugging
*/
class RequestError extends Error {
constructor(message, statusCode, options) {
super(message); // Maintains proper stack trace (only available on V8)
/* istanbul ignore next */
if (Error.captureStackTrace) {
Error.captureStackTrace(this, this.constructor);
constructor(message, statusCode, options) {
super(message);
// Maintains proper stack trace (only available on V8)
/* istanbul ignore next */
if (Error.captureStackTrace) {
Error.captureStackTrace(this, this.constructor);
}
this.name = "HttpError";
this.status = statusCode;
Object.defineProperty(this, "code", {
get() {
logOnce(new Deprecation("[@octokit/request-error] `error.code` is deprecated, use `error.status`."));
return statusCode;
}
});
this.headers = options.headers;
// redact request credentials without mutating original request options
const requestCopy = Object.assign({}, options.request);
if (options.request.headers.authorization) {
requestCopy.headers = Object.assign({}, options.request.headers, {
authorization: options.request.headers.authorization.replace(/ .*$/, " [REDACTED]")
});
}
requestCopy.url = requestCopy.url
// client_id & client_secret can be passed as URL query parameters to increase rate limit
// see https://developer.github.com/v3/#increasing-the-unauthenticated-rate-limit-for-oauth-applications
.replace(/\bclient_secret=\w+/g, "client_secret=[REDACTED]")
// OAuth tokens can be passed as URL query parameters, although it is not recommended
// see https://developer.github.com/v3/#oauth2-token-sent-in-a-header
.replace(/\baccess_token=\w+/g, "access_token=[REDACTED]");
this.request = requestCopy;
}
this.name = "HttpError";
this.status = statusCode;
Object.defineProperty(this, "code", {
get() {
logOnce(new Deprecation("[@octokit/request-error] `error.code` is deprecated, use `error.status`."));
return statusCode;
}
});
this.headers = options.headers; // redact request credentials without mutating original request options
const requestCopy = Object.assign({}, options.request);
if (options.request.headers.authorization) {
requestCopy.headers = Object.assign({}, options.request.headers, {
authorization: options.request.headers.authorization.replace(/ .*$/, " [REDACTED]")
});
}
requestCopy.url = requestCopy.url // client_id & client_secret can be passed as URL query parameters to increase rate limit
// see https://developer.github.com/v3/#increasing-the-unauthenticated-rate-limit-for-oauth-applications
.replace(/\bclient_secret=\w+/g, "client_secret=[REDACTED]") // OAuth tokens can be passed as URL query parameters, although it is not recommended
// see https://developer.github.com/v3/#oauth2-token-sent-in-a-header
.replace(/\baccess_token=\w+/g, "access_token=[REDACTED]");
this.request = requestCopy;
}
}
export { RequestError };
//# sourceMappingURL=index.js.map
{
"name": "@octokit/request-error",
"description": "Error class for Octokit request errors",
"version": "1.0.4",
"version": "1.1.0",
"license": "MIT",

@@ -10,6 +10,2 @@ "files": [

],
"source": "dist-src/index.js",
"types": "dist-types/index.d.ts",
"main": "dist-node/index.js",
"module": "dist-web/index.js",
"pika": true,

@@ -32,2 +28,3 @@ "sideEffects": false,

"dependencies": {
"@octokit/types": "^2.0.0",
"deprecation": "^2.0.0",

@@ -37,8 +34,7 @@ "once": "^1.4.0"

"devDependencies": {
"@pika/pack": "^0.3.7",
"@pika/plugin-build-node": "^0.4.0",
"@pika/plugin-build-web": "^0.4.0",
"@pika/plugin-bundle-web": "^0.4.0",
"@pika/plugin-ts-standard-pkg": "^0.4.0",
"@semantic-release/git": "^7.0.12",
"@pika/pack": "^0.5.0",
"@pika/plugin-build-node": "^0.7.0",
"@pika/plugin-build-web": "^0.7.0",
"@pika/plugin-bundle-web": "^0.7.0",
"@pika/plugin-ts-standard-pkg": "^0.7.0",
"@types/jest": "^24.0.12",

@@ -56,3 +52,7 @@ "@types/node": "^12.0.2",

"access": "public"
}
},
"source": "dist-src/index.js",
"types": "dist-types/index.d.ts",
"main": "dist-node/index.js",
"deno": "dist-web/index.js"
}
SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc