Socket
Socket
Sign inDemoInstall

@octokit/auth-oauth-app

Package Overview
Dependencies
Maintainers
4
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@octokit/auth-oauth-app - npm Package Compare versions

Comparing version 5.0.5 to 5.0.6

128

dist-node/index.js

@@ -1,12 +0,43 @@

'use strict';
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
Object.defineProperty(exports, '__esModule', { value: true });
// pkg/dist-src/index.js
var dist_src_exports = {};
__export(dist_src_exports, {
createOAuthAppAuth: () => createOAuthAppAuth,
createOAuthUserAuth: () => import_auth_oauth_user3.createOAuthUserAuth
});
module.exports = __toCommonJS(dist_src_exports);
var import_universal_user_agent = require("universal-user-agent");
var import_request = require("@octokit/request");
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
var universalUserAgent = require('universal-user-agent');
var request = require('@octokit/request');
var btoa = _interopDefault(require('btoa-lite'));
var authOauthUser = require('@octokit/auth-oauth-user');
// pkg/dist-src/auth.js
var import_btoa_lite = __toESM(require("btoa-lite"));
var import_auth_oauth_user = require("@octokit/auth-oauth-user");
async function auth(state, authOptions) {

@@ -20,3 +51,5 @@ if (authOptions.type === "oauth-app") {

headers: {
authorization: `basic ${btoa(`${state.clientId}:${state.clientSecret}`)}`
authorization: `basic ${(0, import_btoa_lite.default)(
`${state.clientId}:${state.clientSecret}`
)}`
}

@@ -26,10 +59,6 @@ };

if ("factory" in authOptions) {
const {
type,
...options
} = {
const { type, ...options } = {
...authOptions,
...state
};
// @ts-expect-error TODO: `option` cannot be never, is this a bug?
return authOptions.factory(options);

@@ -43,7 +72,6 @@ }

};
// TS: Look what you made me do
const userAuth = state.clientType === "oauth-app" ? await authOauthUser.createOAuthUserAuth({
const userAuth = state.clientType === "oauth-app" ? await (0, import_auth_oauth_user.createOAuthUserAuth)({
...common,
clientType: state.clientType
}) : await authOauthUser.createOAuthUserAuth({
}) : await (0, import_auth_oauth_user.createOAuthUserAuth)({
...common,

@@ -55,18 +83,25 @@ clientType: state.clientType

async function hook(state, request, route, parameters) {
let endpoint = request.endpoint.merge(route, parameters);
// Do not intercept OAuth Web/Device flow request
// pkg/dist-src/hook.js
var import_btoa_lite2 = __toESM(require("btoa-lite"));
var import_auth_oauth_user2 = require("@octokit/auth-oauth-user");
async function hook(state, request2, route, parameters) {
let endpoint = request2.endpoint.merge(
route,
parameters
);
if (/\/login\/(oauth\/access_token|device\/code)$/.test(endpoint.url)) {
return request(endpoint);
return request2(endpoint);
}
if (state.clientType === "github-app" && !authOauthUser.requiresBasicAuth(endpoint.url)) {
throw new Error(`[@octokit/auth-oauth-app] GitHub Apps cannot use their client ID/secret for basic authentication for endpoints other than "/applications/{client_id}/**". "${endpoint.method} ${endpoint.url}" is not supported.`);
if (state.clientType === "github-app" && !(0, import_auth_oauth_user2.requiresBasicAuth)(endpoint.url)) {
throw new Error(
`[@octokit/auth-oauth-app] GitHub Apps cannot use their client ID/secret for basic authentication for endpoints other than "/applications/{client_id}/**". "${endpoint.method} ${endpoint.url}" is not supported.`
);
}
const credentials = btoa(`${state.clientId}:${state.clientSecret}`);
const credentials = (0, import_btoa_lite2.default)(`${state.clientId}:${state.clientSecret}`);
endpoint.headers.authorization = `basic ${credentials}`;
try {
return await request(endpoint);
return await request2(endpoint);
} catch (error) {
/* istanbul ignore if */
if (error.status !== 401) throw error;
if (error.status !== 401)
throw error;
error.message = `[@octokit/auth-oauth-app] "${endpoint.method} ${endpoint.url}" does not support clientId/clientSecret basic authentication.`;

@@ -77,14 +112,19 @@ throw error;

const VERSION = "5.0.5";
// pkg/dist-src/version.js
var VERSION = "5.0.6";
// pkg/dist-src/index.js
var import_auth_oauth_user3 = require("@octokit/auth-oauth-user");
function createOAuthAppAuth(options) {
const state = Object.assign({
request: request.request.defaults({
headers: {
"user-agent": `octokit-auth-oauth-app.js/${VERSION} ${universalUserAgent.getUserAgent()}`
}
}),
clientType: "oauth-app"
}, options);
// @ts-expect-error not worth the extra code to appease TS
const state = Object.assign(
{
request: import_request.request.defaults({
headers: {
"user-agent": `octokit-auth-oauth-app.js/${VERSION} ${(0, import_universal_user_agent.getUserAgent)()}`
}
}),
clientType: "oauth-app"
},
options
);
return Object.assign(auth.bind(null, state), {

@@ -94,10 +134,6 @@ hook: hook.bind(null, state)

}
Object.defineProperty(exports, 'createOAuthUserAuth', {
enumerable: true,
get: function () {
return authOauthUser.createOAuthUserAuth;
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
createOAuthAppAuth,
createOAuthUserAuth
});
exports.createOAuthAppAuth = createOAuthAppAuth;
//# sourceMappingURL=index.js.map
import btoa from "btoa-lite";
import { createOAuthUserAuth } from "@octokit/auth-oauth-user";
export async function auth(state, authOptions) {
if (authOptions.type === "oauth-app") {
return {
type: "oauth-app",
clientId: state.clientId,
clientSecret: state.clientSecret,
clientType: state.clientType,
headers: {
authorization: `basic ${btoa(`${state.clientId}:${state.clientSecret}`)}`,
},
};
}
if ("factory" in authOptions) {
const { type, ...options } = {
...authOptions,
...state,
};
// @ts-expect-error TODO: `option` cannot be never, is this a bug?
return authOptions.factory(options);
}
const common = {
clientId: state.clientId,
clientSecret: state.clientSecret,
request: state.request,
...authOptions,
async function auth(state, authOptions) {
if (authOptions.type === "oauth-app") {
return {
type: "oauth-app",
clientId: state.clientId,
clientSecret: state.clientSecret,
clientType: state.clientType,
headers: {
authorization: `basic ${btoa(
`${state.clientId}:${state.clientSecret}`
)}`
}
};
// TS: Look what you made me do
const userAuth = state.clientType === "oauth-app"
? await createOAuthUserAuth({
...common,
clientType: state.clientType,
})
: await createOAuthUserAuth({
...common,
clientType: state.clientType,
});
return userAuth();
}
if ("factory" in authOptions) {
const { type, ...options } = {
...authOptions,
...state
};
return authOptions.factory(options);
}
const common = {
clientId: state.clientId,
clientSecret: state.clientSecret,
request: state.request,
...authOptions
};
const userAuth = state.clientType === "oauth-app" ? await createOAuthUserAuth({
...common,
clientType: state.clientType
}) : await createOAuthUserAuth({
...common,
clientType: state.clientType
});
return userAuth();
}
export {
auth
};
import btoa from "btoa-lite";
import { requiresBasicAuth } from "@octokit/auth-oauth-user";
export async function hook(state, request, route, parameters) {
let endpoint = request.endpoint.merge(route, parameters);
// Do not intercept OAuth Web/Device flow request
if (/\/login\/(oauth\/access_token|device\/code)$/.test(endpoint.url)) {
return request(endpoint);
}
if (state.clientType === "github-app" && !requiresBasicAuth(endpoint.url)) {
throw new Error(`[@octokit/auth-oauth-app] GitHub Apps cannot use their client ID/secret for basic authentication for endpoints other than "/applications/{client_id}/**". "${endpoint.method} ${endpoint.url}" is not supported.`);
}
const credentials = btoa(`${state.clientId}:${state.clientSecret}`);
endpoint.headers.authorization = `basic ${credentials}`;
try {
return await request(endpoint);
}
catch (error) {
/* istanbul ignore if */
if (error.status !== 401)
throw error;
error.message = `[@octokit/auth-oauth-app] "${endpoint.method} ${endpoint.url}" does not support clientId/clientSecret basic authentication.`;
throw error;
}
async function hook(state, request, route, parameters) {
let endpoint = request.endpoint.merge(
route,
parameters
);
if (/\/login\/(oauth\/access_token|device\/code)$/.test(endpoint.url)) {
return request(endpoint);
}
if (state.clientType === "github-app" && !requiresBasicAuth(endpoint.url)) {
throw new Error(
`[@octokit/auth-oauth-app] GitHub Apps cannot use their client ID/secret for basic authentication for endpoints other than "/applications/{client_id}/**". "${endpoint.method} ${endpoint.url}" is not supported.`
);
}
const credentials = btoa(`${state.clientId}:${state.clientSecret}`);
endpoint.headers.authorization = `basic ${credentials}`;
try {
return await request(endpoint);
} catch (error) {
if (error.status !== 401)
throw error;
error.message = `[@octokit/auth-oauth-app] "${endpoint.method} ${endpoint.url}" does not support clientId/clientSecret basic authentication.`;
throw error;
}
}
export {
hook
};

@@ -6,16 +6,22 @@ import { getUserAgent } from "universal-user-agent";

import { VERSION } from "./version";
export { createOAuthUserAuth } from "@octokit/auth-oauth-user";
export function createOAuthAppAuth(options) {
const state = Object.assign({
request: request.defaults({
headers: {
"user-agent": `octokit-auth-oauth-app.js/${VERSION} ${getUserAgent()}`,
},
}),
clientType: "oauth-app",
}, options);
// @ts-expect-error not worth the extra code to appease TS
return Object.assign(auth.bind(null, state), {
hook: hook.bind(null, state),
});
import { createOAuthUserAuth } from "@octokit/auth-oauth-user";
function createOAuthAppAuth(options) {
const state = Object.assign(
{
request: request.defaults({
headers: {
"user-agent": `octokit-auth-oauth-app.js/${VERSION} ${getUserAgent()}`
}
}),
clientType: "oauth-app"
},
options
);
return Object.assign(auth.bind(null, state), {
hook: hook.bind(null, state)
});
}
export {
createOAuthAppAuth,
createOAuthUserAuth
};

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

export const VERSION = "5.0.5";
const VERSION = "5.0.6";
export {
VERSION
};

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

import { OAuthAppState, GitHubAppState, AppAuthOptions, WebFlowAuthOptions, OAuthAppDeviceFlowAuthOptions, GitHubAppDeviceFlowAuthOptions, FactoryOAuthAppWebFlow, FactoryOAuthAppDeviceFlow, FactoryGitHubWebFlow, FactoryGitHubDeviceFlow, AppAuthentication, OAuthAppUserAuthentication, GitHubAppUserAuthentication, GitHubAppUserAuthenticationWithExpiration } from "./types";
import type { OAuthAppState, GitHubAppState, AppAuthOptions, WebFlowAuthOptions, OAuthAppDeviceFlowAuthOptions, GitHubAppDeviceFlowAuthOptions, FactoryOAuthAppWebFlow, FactoryOAuthAppDeviceFlow, FactoryGitHubWebFlow, FactoryGitHubDeviceFlow, AppAuthentication, OAuthAppUserAuthentication, GitHubAppUserAuthentication, GitHubAppUserAuthenticationWithExpiration } from "./types";
export declare function auth(state: OAuthAppState | GitHubAppState, authOptions: AppAuthOptions): Promise<AppAuthentication>;

@@ -3,0 +3,0 @@ export declare function auth(state: OAuthAppState, authOptions: WebFlowAuthOptions): Promise<OAuthAppUserAuthentication>;

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

import { EndpointOptions, RequestParameters, Route, RequestInterface, OctokitResponse } from "@octokit/types";
import { OAuthAppState, GitHubAppState } from "./types";
import type { EndpointOptions, RequestParameters, Route, RequestInterface, OctokitResponse } from "@octokit/types";
import type { OAuthAppState, GitHubAppState } from "./types";
export declare function hook(state: OAuthAppState | GitHubAppState, request: RequestInterface, route: Route | EndpointOptions, parameters?: RequestParameters): Promise<OctokitResponse<any>>;

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

import { OAuthAppStrategyOptions, GitHubAppStrategyOptions, OAuthAppAuthInterface, GitHubAuthInterface } from "./types";
export { OAuthAppStrategyOptions, GitHubAppStrategyOptions, AppAuthOptions, WebFlowAuthOptions, OAuthAppDeviceFlowAuthOptions, GitHubAppDeviceFlowAuthOptions, OAuthAppAuthInterface, GitHubAuthInterface, AppAuthentication, OAuthAppUserAuthentication, GitHubAppUserAuthentication, GitHubAppUserAuthenticationWithExpiration, FactoryGitHubWebFlow, FactoryGitHubDeviceFlow, } from "./types";
import type { OAuthAppStrategyOptions, GitHubAppStrategyOptions, OAuthAppAuthInterface, GitHubAuthInterface } from "./types";
export type { OAuthAppStrategyOptions, GitHubAppStrategyOptions, AppAuthOptions, WebFlowAuthOptions, OAuthAppDeviceFlowAuthOptions, GitHubAppDeviceFlowAuthOptions, OAuthAppAuthInterface, GitHubAuthInterface, AppAuthentication, OAuthAppUserAuthentication, GitHubAppUserAuthentication, GitHubAppUserAuthenticationWithExpiration, FactoryGitHubWebFlow, FactoryGitHubDeviceFlow, } from "./types";
export { createOAuthUserAuth } from "@octokit/auth-oauth-user";
export declare function createOAuthAppAuth(options: OAuthAppStrategyOptions): OAuthAppAuthInterface;
export declare function createOAuthAppAuth(options: GitHubAppStrategyOptions): GitHubAuthInterface;

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

import { EndpointOptions, RequestParameters, Route, RequestInterface, OctokitResponse } from "@octokit/types";
import type { EndpointOptions, RequestParameters, Route, RequestInterface, OctokitResponse } from "@octokit/types";
import * as AuthOAuthUser from "@octokit/auth-oauth-user";

@@ -3,0 +3,0 @@ import * as DeviceTypes from "@octokit/auth-oauth-device";

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

export declare const VERSION = "5.0.5";
export declare const VERSION = "5.0.6";

@@ -1,87 +0,97 @@

import { getUserAgent } from 'universal-user-agent';
import { request } from '@octokit/request';
import btoa from 'btoa-lite';
import { createOAuthUserAuth, requiresBasicAuth } from '@octokit/auth-oauth-user';
export { createOAuthUserAuth } from '@octokit/auth-oauth-user';
// pkg/dist-src/index.js
import { getUserAgent } from "universal-user-agent";
import { request } from "@octokit/request";
// pkg/dist-src/auth.js
import btoa from "btoa-lite";
import { createOAuthUserAuth } from "@octokit/auth-oauth-user";
async function auth(state, authOptions) {
if (authOptions.type === "oauth-app") {
return {
type: "oauth-app",
clientId: state.clientId,
clientSecret: state.clientSecret,
clientType: state.clientType,
headers: {
authorization: `basic ${btoa(`${state.clientId}:${state.clientSecret}`)}`,
},
};
}
if ("factory" in authOptions) {
const { type, ...options } = {
...authOptions,
...state,
};
// @ts-expect-error TODO: `option` cannot be never, is this a bug?
return authOptions.factory(options);
}
const common = {
clientId: state.clientId,
clientSecret: state.clientSecret,
request: state.request,
...authOptions,
if (authOptions.type === "oauth-app") {
return {
type: "oauth-app",
clientId: state.clientId,
clientSecret: state.clientSecret,
clientType: state.clientType,
headers: {
authorization: `basic ${btoa(
`${state.clientId}:${state.clientSecret}`
)}`
}
};
// TS: Look what you made me do
const userAuth = state.clientType === "oauth-app"
? await createOAuthUserAuth({
...common,
clientType: state.clientType,
})
: await createOAuthUserAuth({
...common,
clientType: state.clientType,
});
return userAuth();
}
if ("factory" in authOptions) {
const { type, ...options } = {
...authOptions,
...state
};
return authOptions.factory(options);
}
const common = {
clientId: state.clientId,
clientSecret: state.clientSecret,
request: state.request,
...authOptions
};
const userAuth = state.clientType === "oauth-app" ? await createOAuthUserAuth({
...common,
clientType: state.clientType
}) : await createOAuthUserAuth({
...common,
clientType: state.clientType
});
return userAuth();
}
async function hook(state, request, route, parameters) {
let endpoint = request.endpoint.merge(route, parameters);
// Do not intercept OAuth Web/Device flow request
if (/\/login\/(oauth\/access_token|device\/code)$/.test(endpoint.url)) {
return request(endpoint);
}
if (state.clientType === "github-app" && !requiresBasicAuth(endpoint.url)) {
throw new Error(`[@octokit/auth-oauth-app] GitHub Apps cannot use their client ID/secret for basic authentication for endpoints other than "/applications/{client_id}/**". "${endpoint.method} ${endpoint.url}" is not supported.`);
}
const credentials = btoa(`${state.clientId}:${state.clientSecret}`);
endpoint.headers.authorization = `basic ${credentials}`;
try {
return await request(endpoint);
}
catch (error) {
/* istanbul ignore if */
if (error.status !== 401)
throw error;
error.message = `[@octokit/auth-oauth-app] "${endpoint.method} ${endpoint.url}" does not support clientId/clientSecret basic authentication.`;
throw error;
}
// pkg/dist-src/hook.js
import btoa2 from "btoa-lite";
import { requiresBasicAuth } from "@octokit/auth-oauth-user";
async function hook(state, request2, route, parameters) {
let endpoint = request2.endpoint.merge(
route,
parameters
);
if (/\/login\/(oauth\/access_token|device\/code)$/.test(endpoint.url)) {
return request2(endpoint);
}
if (state.clientType === "github-app" && !requiresBasicAuth(endpoint.url)) {
throw new Error(
`[@octokit/auth-oauth-app] GitHub Apps cannot use their client ID/secret for basic authentication for endpoints other than "/applications/{client_id}/**". "${endpoint.method} ${endpoint.url}" is not supported.`
);
}
const credentials = btoa2(`${state.clientId}:${state.clientSecret}`);
endpoint.headers.authorization = `basic ${credentials}`;
try {
return await request2(endpoint);
} catch (error) {
if (error.status !== 401)
throw error;
error.message = `[@octokit/auth-oauth-app] "${endpoint.method} ${endpoint.url}" does not support clientId/clientSecret basic authentication.`;
throw error;
}
}
const VERSION = "5.0.5";
// pkg/dist-src/version.js
var VERSION = "5.0.6";
// pkg/dist-src/index.js
import { createOAuthUserAuth as createOAuthUserAuth2 } from "@octokit/auth-oauth-user";
function createOAuthAppAuth(options) {
const state = Object.assign({
request: request.defaults({
headers: {
"user-agent": `octokit-auth-oauth-app.js/${VERSION} ${getUserAgent()}`,
},
}),
clientType: "oauth-app",
}, options);
// @ts-expect-error not worth the extra code to appease TS
return Object.assign(auth.bind(null, state), {
hook: hook.bind(null, state),
});
const state = Object.assign(
{
request: request.defaults({
headers: {
"user-agent": `octokit-auth-oauth-app.js/${VERSION} ${getUserAgent()}`
}
}),
clientType: "oauth-app"
},
options
);
return Object.assign(auth.bind(null, state), {
hook: hook.bind(null, state)
});
}
export { createOAuthAppAuth };
//# sourceMappingURL=index.js.map
export {
createOAuthAppAuth,
createOAuthUserAuth2 as createOAuthUserAuth
};
{
"name": "@octokit/auth-oauth-app",
"publishConfig": {
"access": "public"
},
"version": "5.0.6",
"description": "GitHub OAuth App authentication for JavaScript",
"version": "5.0.5",
"license": "MIT",
"files": [
"dist-*/",
"bin/"
],
"source": "dist-src/index.js",
"types": "dist-types/index.d.ts",
"main": "dist-node/index.js",
"module": "dist-web/index.js",
"pika": true,
"sideEffects": false,
"repository": "github:octokit/auth-oauth-app.js",
"keywords": [

@@ -23,3 +16,4 @@ "github",

],
"repository": "github:octokit/auth-oauth-app.js",
"author": "Gregor Martynus (https://github.com/gr2m)",
"license": "MIT",
"dependencies": {

@@ -36,14 +30,13 @@ "@octokit/auth-oauth-device": "^4.0.0",

"@octokit/core": "^4.0.0",
"@pika/pack": "^0.3.7",
"@pika/plugin-build-node": "^0.9.0",
"@pika/plugin-build-web": "^0.9.0",
"@pika/plugin-ts-standard-pkg": "^0.9.0",
"@octokit/tsconfig": "^2.0.0",
"@types/fetch-mock": "^7.3.1",
"@types/jest": "^29.0.0",
"esbuild": "^0.17.19",
"fetch-mock": "^9.0.0",
"glob": "^10.2.7",
"jest": "^29.0.0",
"prettier": "2.8.3",
"prettier": "2.8.8",
"semantic-release-plugin-update-version-in-files": "^1.0.0",
"ts-jest": "^29.0.0",
"typescript": "^4.0.0"
"typescript": "^5.0.0"
},

@@ -53,5 +46,11 @@ "engines": {

},
"publishConfig": {
"access": "public"
}
"files": [
"dist-*/**",
"bin/**"
],
"main": "dist-node/index.js",
"browser": "dist-web/index.js",
"types": "dist-types/index.d.ts",
"module": "dist-src/index.js",
"sideEffects": false
}

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