Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@octokit/auth-unauthenticated

Package Overview
Dependencies
Maintainers
2
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@octokit/auth-unauthenticated - npm Package Compare versions

Comparing version 1.0.1 to 2.0.0

22

dist-node/index.js

@@ -5,4 +5,2 @@ 'use strict';

var requestError = require('@octokit/request-error');
async function auth(reason) {

@@ -38,15 +36,8 @@ return {

const MUTATING_METHODS = ["DELETE", "PATCH", "POST", "PUT"];
async function hook(reason, request, route, parameters) {
const endpoint = request.endpoint.merge(route, parameters);
if (MUTATING_METHODS.includes(endpoint.method)) {
throw new requestError.RequestError(`"${endpoint.method} ${endpoint.url}" is not permitted due to lack of authentication. Reason: ${reason}`, 403, {
request: request.endpoint.parse(endpoint)
});
}
return request(endpoint).catch(error => {
if (error.status === 404) {
error.message = `Not found. May be due to lack of authentication. Reason: ${reason}`;
throw error;
}

@@ -56,2 +47,3 @@

error.message = `API rate limit exceeded. This maybe caused by the lack of authentication. Reason: ${reason}`;
throw error;
}

@@ -61,4 +53,14 @@

error.message = `You have triggered an abuse detection mechanism. This maybe caused by the lack of authentication. Reason: ${reason}`;
throw error;
}
if (error.status === 401) {
error.message = `Unauthorized. "${endpoint.method} ${endpoint.url}" failed most likely due to lack of authentication. Reason: ${reason}`;
throw error;
}
if (error.status >= 400 && error.status < 500) {
error.message = error.message.replace(/\.?$/, `. May be caused by lack of authentication (${reason}).`);
}
throw error;

@@ -65,0 +67,0 @@ });

@@ -1,24 +0,27 @@

import { RequestError } from "@octokit/request-error";
import { isRateLimitError } from "./is-rate-limit-error";
import { isAbuseLimitError } from "./is-abuse-limit-error";
const MUTATING_METHODS = ["DELETE", "PATCH", "POST", "PUT"];
export async function hook(reason, request, route, parameters) {
const endpoint = request.endpoint.merge(route, parameters);
if (MUTATING_METHODS.includes(endpoint.method)) {
throw new RequestError(`"${endpoint.method} ${endpoint.url}" is not permitted due to lack of authentication. Reason: ${reason}`, 403, {
request: request.endpoint.parse(endpoint),
});
}
return request(endpoint).catch((error) => {
if (error.status === 404) {
error.message = `Not found. May be due to lack of authentication. Reason: ${reason}`;
throw error;
}
if (isRateLimitError(error)) {
error.message = `API rate limit exceeded. This maybe caused by the lack of authentication. Reason: ${reason}`;
throw error;
}
if (isAbuseLimitError(error)) {
error.message = `You have triggered an abuse detection mechanism. This maybe caused by the lack of authentication. Reason: ${reason}`;
throw error;
}
if (error.status === 401) {
error.message = `Unauthorized. "${endpoint.method} ${endpoint.url}" failed most likely due to lack of authentication. Reason: ${reason}`;
throw error;
}
if (error.status >= 400 && error.status < 500) {
error.message = error.message.replace(/\.?$/, `. May be caused by lack of authentication (${reason}).`);
}
throw error;
});
}

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

import { RequestError } from '@octokit/request-error';
async function auth(reason) {

@@ -29,20 +27,24 @@ return {

const MUTATING_METHODS = ["DELETE", "PATCH", "POST", "PUT"];
async function hook(reason, request, route, parameters) {
const endpoint = request.endpoint.merge(route, parameters);
if (MUTATING_METHODS.includes(endpoint.method)) {
throw new RequestError(`"${endpoint.method} ${endpoint.url}" is not permitted due to lack of authentication. Reason: ${reason}`, 403, {
request: request.endpoint.parse(endpoint),
});
}
return request(endpoint).catch((error) => {
if (error.status === 404) {
error.message = `Not found. May be due to lack of authentication. Reason: ${reason}`;
throw error;
}
if (isRateLimitError(error)) {
error.message = `API rate limit exceeded. This maybe caused by the lack of authentication. Reason: ${reason}`;
throw error;
}
if (isAbuseLimitError(error)) {
error.message = `You have triggered an abuse detection mechanism. This maybe caused by the lack of authentication. Reason: ${reason}`;
throw error;
}
if (error.status === 401) {
error.message = `Unauthorized. "${endpoint.method} ${endpoint.url}" failed most likely due to lack of authentication. Reason: ${reason}`;
throw error;
}
if (error.status >= 400 && error.status < 500) {
error.message = error.message.replace(/\.?$/, `. May be caused by lack of authentication (${reason}).`);
}
throw error;

@@ -49,0 +51,0 @@ });

{
"name": "@octokit/auth-unauthenticated",
"description": "GitHub API token authentication for browsers and Node.js",
"version": "1.0.1",
"version": "2.0.0",
"license": "MIT",

@@ -32,5 +32,4 @@ "files": [

"@tsconfig/node10": "^1.0.3",
"@types/fetch-mock": "^7.3.1",
"@types/jest": "^26.0.0",
"fetch-mock": "^9.0.0",
"fetch-mock": "^9.10.7",
"jest": "^25.1.0",

@@ -37,0 +36,0 @@ "semantic-release": "^17.0.0",

Sorry, the diff of this file is not supported yet

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