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

@octokit/oauth-app

Package Overview
Dependencies
Maintainers
3
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@octokit/oauth-app - npm Package Compare versions

Comparing version 1.0.1 to 1.1.0

6

dist-node/index.js

@@ -15,3 +15,3 @@ 'use strict';

const VERSION = "1.0.1";
const VERSION = "1.1.0";

@@ -406,2 +406,6 @@ function addEventHandler(state, eventName, eventHandler) {

if (route === `GET ${options.pathPrefix}/callback`) {
if (query.error) {
throw new Error(`[@octokit/oauth-app] ${query.error} ${query.error_description}`);
}
if (!query.state || !query.code) {

@@ -408,0 +412,0 @@ throw new Error('[@octokit/oauth-app] Both "code" & "state" parameters are required');

10

dist-src/index.js

@@ -5,3 +5,3 @@ import { createOAuthAppAuth } from "@octokit/auth-oauth-app";

import { OAuthAppOctokit } from "./oauth-app-octokit";
import { getAuthorizationUrlWithState } from "./methods/get-authorization-url";
import { getAuthorizationUrlWithState, } from "./methods/get-authorization-url";
import { createTokenWithState } from "./methods/create-token";

@@ -11,3 +11,3 @@ import { checkTokenWithState } from "./methods/check-token";

import { deleteTokenWithState } from "./methods/delete-token";
import { deleteAuthorizationWithState } from "./methods/delete-authorization";
import { deleteAuthorizationWithState, } from "./methods/delete-authorization";
export { getAuthorizationUrl } from "./methods/get-authorization-url";

@@ -27,4 +27,4 @@ export { createToken } from "./methods/create-token";

clientId: options.clientId,
clientSecret: options.clientSecret
}
clientSecret: options.clientSecret,
},
});

@@ -40,3 +40,3 @@ const state = {

octokit,
eventHandlers: {}
eventHandlers: {},
};

@@ -43,0 +43,0 @@ this.on = addEventHandler.bind(null, state);

@@ -10,8 +10,8 @@ import { request as defaultRequest } from "@octokit/request";

headers: {
authorization: `basic ${btoa(`${options.clientId}:${options.clientSecret}`)}`
}
authorization: `basic ${btoa(`${options.clientId}:${options.clientSecret}`)}`,
},
});
return sendCheckTokenRequest(request, {
client_id: options.clientId,
access_token: options.token
access_token: options.token,
});

@@ -22,4 +22,4 @@ }

client_id: state.clientId,
access_token: options.token
access_token: options.token,
});
}

@@ -8,3 +8,3 @@ import { createOAuthAppAuth } from "@octokit/auth-oauth-app";

state: options.state,
code: options.code
code: options.code,
});

@@ -17,3 +17,3 @@ return { token, scopes };

clientId,
clientSecret
clientSecret,
});

@@ -31,5 +31,5 @@ return createTokenWithAuth(auth, otherOptions);

return new state.Octokit({ auth: result.token });
}
},
});
return result;
}

@@ -13,9 +13,9 @@ import { createOAuthAppAuth } from "@octokit/auth-oauth-app";

clientId: options.clientId,
clientSecret: options.clientSecret
}).hook
}
clientSecret: options.clientSecret,
}).hook,
},
});
return sendDeleteAuthorizationRequest(request, {
client_id: options.clientId,
access_token: options.token
access_token: options.token,
});

@@ -30,3 +30,3 @@ }

return new state.Octokit({ auth: options.token });
}
},
});

@@ -39,7 +39,7 @@ await emitEvent(state, {

return new state.Octokit({ auth: options.token });
}
},
});
const result = await sendDeleteAuthorizationRequest(state.octokit.request, {
client_id: state.clientId,
access_token: options.token
access_token: options.token,
});

@@ -49,3 +49,3 @@ await emitEvent(state, {

action: "deleted",
token: options.token
token: options.token,
});

@@ -55,5 +55,5 @@ await emitEvent(state, {

action: "deleted",
token: options.token
token: options.token,
});
return result;
}

@@ -11,8 +11,8 @@ import { request as defaultRequest } from "@octokit/request";

headers: {
authorization: `basic ${btoa(`${options.clientId}:${options.clientSecret}`)}`
}
authorization: `basic ${btoa(`${options.clientId}:${options.clientSecret}`)}`,
},
});
return sendDeleteTokenRequest(request, {
client_id: options.clientId,
access_token: options.token
access_token: options.token,
});

@@ -27,7 +27,7 @@ }

return new state.Octokit({ auth: options.token });
}
},
});
const result = await sendDeleteTokenRequest(state.octokit.request, {
client_id: state.clientId,
access_token: options.token
access_token: options.token,
});

@@ -37,5 +37,5 @@ await emitEvent(state, {

action: "deleted",
token: options.token
token: options.token,
});
return result;
}

@@ -12,4 +12,4 @@ import { oauthAuthorizationUrl } from "@octokit/oauth-authorization-url";

log: state.log,
scopes: state.defaultScopes
scopes: state.defaultScopes,
}, options));
}

@@ -11,8 +11,8 @@ import { request as defaultRequest } from "@octokit/request";

headers: {
authorization: `basic ${btoa(`${options.clientId}:${options.clientSecret}`)}`
}
authorization: `basic ${btoa(`${options.clientId}:${options.clientSecret}`)}`,
},
});
return sendResetTokenRequest(request, {
client_id: options.clientId,
access_token: options.token
access_token: options.token,
});

@@ -23,3 +23,3 @@ }

client_id: state.clientId,
access_token: options.token
access_token: options.token,
});

@@ -33,7 +33,7 @@ await emitEvent(state, {

return new state.Octokit({
auth: result.token
auth: result.token,
});
}
},
});
return result;
}
import { middleware } from "./middleware";
import { onUnhandledRequestDefault } from "./on-unhandled-request-default";
export function getNodeMiddleware(app, { pathPrefix = "/api/github/oauth", onUnhandledRequest = onUnhandledRequestDefault } = {}) {
export function getNodeMiddleware(app, { pathPrefix = "/api/github/oauth", onUnhandledRequest = onUnhandledRequestDefault, } = {}) {
return middleware.bind(null, app, {
pathPrefix,
onUnhandledRequest
onUnhandledRequest,
});
}

@@ -9,6 +9,6 @@ import { parseRequest } from "./parse-request";

response.writeHead(400, {
"content-type": "application/json"
"content-type": "application/json",
});
return response.end(JSON.stringify({
error: "[@octokit/oauth-app] request error"
error: "[@octokit/oauth-app] request error",
}));

@@ -23,3 +23,3 @@ }

allowSignup: query.allowSignup,
redirectUrl: query.redirectUrl
redirectUrl: query.redirectUrl,
});

@@ -30,2 +30,5 @@ response.writeHead(302, { location: url });

if (route === `GET ${options.pathPrefix}/callback`) {
if (query.error) {
throw new Error(`[@octokit/oauth-app] ${query.error} ${query.error_description}`);
}
if (!query.state || !query.code) {

@@ -36,6 +39,6 @@ throw new Error('[@octokit/oauth-app] Both "code" & "state" parameters are required');

state: query.state,
code: query.code
code: query.code,
});
response.writeHead(200, {
"content-type": "text/html"
"content-type": "text/html",
});

@@ -55,6 +58,6 @@ response.write(`<h1>Token created successfull</h1>

state: oauthState,
code
code,
});
response.writeHead(201, {
"content-type": "application/json"
"content-type": "application/json",
});

@@ -69,6 +72,6 @@ return response.end(JSON.stringify({ token, scopes }));

const result = await app.checkToken({
token
token,
});
response.writeHead(200, {
"content-type": "application/json"
"content-type": "application/json",
});

@@ -83,6 +86,6 @@ return response.end(JSON.stringify(result));

const result = await app.resetToken({
token
token,
});
response.writeHead(200, {
"content-type": "application/json"
"content-type": "application/json",
});

@@ -97,3 +100,3 @@ return response.end(JSON.stringify(result));

await app.deleteToken({
token
token,
});

@@ -109,3 +112,3 @@ response.writeHead(204);

await app.deleteAuthorization({
token
token,
});

@@ -119,8 +122,8 @@ response.writeHead(204);

response.writeHead(400, {
"content-type": "application/json"
"content-type": "application/json",
});
response.end(JSON.stringify({
error: error.message
error: error.message,
}));
}
}
export function onUnhandledRequestDefault(request, response) {
response.writeHead(404, {
"content-type": "application/json"
"content-type": "application/json",
});
response.end(JSON.stringify({
error: `Unknown route: ${request.method} ${request.url}`
error: `Unknown route: ${request.method} ${request.url}`,
}));
}

@@ -15,3 +15,3 @@ // @ts-ignore remove once Node 10 is out maintenance. Replace with Object.fromEntries

.on("error", reject)
.on("data", chunk => bodyChunks.push(chunk))
.on("data", (chunk) => bodyChunks.push(chunk))
.on("end", async () => {

@@ -18,0 +18,0 @@ const bodyString = Buffer.concat(bodyChunks).toString();

@@ -5,3 +5,3 @@ import { Octokit } from "@octokit/core";

export const OAuthAppOctokit = Octokit.defaults({
userAgent: `octokit-oauth-app.js/${VERSION} ${getUserAgent()}`
userAgent: `octokit-oauth-app.js/${VERSION} ${getUserAgent()}`,
});

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

export const VERSION = "1.0.1";
export const VERSION = "1.1.0";
/// <reference types="node" />
import { OAuthApp } from "../../index";
import { MiddlewareOptions } from "./types";
export declare function getNodeMiddleware(app: OAuthApp, { pathPrefix, onUnhandledRequest }?: MiddlewareOptions): (request: import("http").IncomingMessage, response: import("http").ServerResponse) => Promise<void>;
export declare function getNodeMiddleware(app: OAuthApp, { pathPrefix, onUnhandledRequest, }?: MiddlewareOptions): (request: import("http").IncomingMessage, response: import("http").ServerResponse) => Promise<void>;

@@ -14,2 +14,5 @@ /// <reference types="node" />

allowSignup?: boolean;
error?: string;
error_description?: string;
error_url?: string;
};

@@ -16,0 +19,0 @@ body?: {

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

export declare const VERSION = "1.0.1";
export declare const VERSION = "1.1.0";
{
"name": "@octokit/oauth-app",
"description": "GitHub OAuth toolset for Node.js",
"version": "1.0.1",
"version": "1.1.0",
"license": "MIT",

@@ -26,3 +26,3 @@ "files": [

"fromentries": "^1.2.0",
"universal-user-agent": "^4.0.0"
"universal-user-agent": "^5.0.0"
},

@@ -36,7 +36,7 @@ "devDependencies": {

"@types/node-fetch": "^2.5.4",
"fetch-mock": "^8.3.2",
"fetch-mock": "^9.0.0",
"jest": "^25.1.0",
"nock": "^12.0.1",
"node-fetch": "^2.6.0",
"prettier": "^1.19.1",
"prettier": "^2.0.0",
"semantic-release": "^17.0.3",

@@ -43,0 +43,0 @@ "semantic-release-plugin-update-version-in-files": "^1.0.0",

@@ -67,3 +67,3 @@ # oauth-app.js

clientId: "0123",
clientSecret: "0123secret"
clientSecret: "0123secret",
});

@@ -76,5 +76,3 @@

require("http")
.createServer(getNodeMiddleware(app))
.listen(3000);
require("http").createServer(getNodeMiddleware(app)).listen(3000);
// can now receive user authorization callbacks at /api/github/oauth/callback

@@ -89,3 +87,5 @@ ```

- Simple Node server with the default OAuth routes as well as static files served from a `public/` folder: https://glitch.com/~github-oauth-client
- Node server with static files served from `public/` folder, hosted on Glitch: https://glitch.com/~github-oauth-client
- Serverless functions, hosted on [Zeit's now](https://zeit.co/): https://github.com/gr2m/octokit-oauth-app-now-example
- Serverless functions, hosted on AWS (via [begin.com](https://begin.com/)): https://github.com/gr2m/octokit-oauth-app-begin-example/

@@ -184,4 +184,4 @@ ## Constructor options

Octokit: Octokit.defaults({
baseUrl: "https://ghe.my-company.com/api/v3"
})
baseUrl: "https://ghe.my-company.com/api/v3",
}),
});

@@ -201,3 +201,3 @@ ```

```js
app.on("token.created", async context => {
app.on("token.created", async (context) => {
const { data } = await context.octokit.request("GET /user");

@@ -311,3 +311,3 @@ app.log.info(`New token created for ${data.login}`);

state: "state123",
scopes: ["repo"]
scopes: ["repo"],
});

@@ -395,3 +395,3 @@ ```

state: "state123",
code: "code123"
code: "code123",
});

@@ -533,3 +533,3 @@ ```

const { token } = await app.resetToken({
token: "token123"
token: "token123",
});

@@ -574,3 +574,3 @@ // "token123" is no longer valid. Use `token` instead

await app.deleteToken({
token: "token123"
token: "token123",
});

@@ -615,3 +615,3 @@ // "token123" is no longer valid.

await app.deleteAuthorization({
token: "token123"
token: "token123",
});

@@ -663,3 +663,3 @@ // "token123" is no longer valid, and no tokens can be created until the app gets re-authorized.

deleteToken,
deleteAuthorization
deleteAuthorization,
} = require("@octokit/oauth-app");

@@ -676,3 +676,3 @@ ```

clientId: "0123",
state: "state123"
state: "state123",
});

@@ -796,3 +796,3 @@ ```

state: "state123",
code: "code123"
code: "code123",
});

@@ -913,3 +913,3 @@ ```

clientSecret: "0123secret",
token: "token123"
token: "token123",
});

@@ -987,3 +987,3 @@ console.log(

clientSecret: "0123secret",
token: "token123"
token: "token123",
});

@@ -1053,3 +1053,3 @@ // "token123" is no longer valid. Use `token` instead

clientSecret: "0123secret",
token: "token123"
token: "token123",
});

@@ -1119,3 +1119,3 @@ // "token123" is no longer valid

clientSecret: "0123secret",
token: "token123"
token: "token123",
});

@@ -1202,12 +1202,10 @@ // "token123" is no longer valid

clientId: "0123",
clientSecret: "0123secret"
clientSecret: "0123secret",
});
const middleware = getNodeMiddleware(app, {
pathPrefix: "/api/github/oauth/"
pathPrefix: "/api/github/oauth/",
});
require("http")
.createServer(getNodeMiddleware(app))
.listen(3000);
require("http").createServer(getNodeMiddleware(app)).listen(3000);
// can now receive user authorization callbacks at /api/github/oauth/callback

@@ -1268,7 +1266,7 @@ ```

response.writeHead(400, {
"content-type": "application/json"
"content-type": "application/json",
});
response.end(
JSON.stringify({
error: error.message
error: error.message,
})

@@ -1275,0 +1273,0 @@ );

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