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

@octokit/oauth-app

Package Overview
Dependencies
Maintainers
2
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 3.5.1 to 3.6.0

dist-src/middleware/aws-lambda/api-gateway-v2-parse-request.js

52

dist-node/index.js

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

const VERSION = "3.5.1";
const VERSION = "3.6.0";

@@ -787,2 +787,51 @@ function addEventHandler(state, eventName, eventHandler) {

function parseRequest$2(request) {
const {
method
} = request.requestContext.http;
let url = request.rawPath;
const {
stage
} = request.requestContext;
if (url.startsWith("/" + stage)) url = url.substring(stage.length + 1);
if (request.rawQueryString) url += "?" + request.rawQueryString;
const headers = request.headers;
const text = async () => request.body || "";
return {
method,
url,
headers,
text
};
}
function sendResponse$2(octokitResponse) {
return {
statusCode: octokitResponse.status,
headers: octokitResponse.headers,
body: octokitResponse.text
};
}
async function onUnhandledRequestDefaultAWSAPIGatewayV2(event) {
const request = parseRequest$2(event);
const response = onUnhandledRequestDefault(request);
return sendResponse$2(response);
}
function createAWSLambdaAPIGatewayV2Handler(app, {
pathPrefix,
onUnhandledRequest = onUnhandledRequestDefaultAWSAPIGatewayV2
} = {}) {
return async function (event) {
const request = parseRequest$2(event);
const response = await handleRequest(app, {
pathPrefix
}, request);
return response ? sendResponse$2(response) : onUnhandledRequest(event);
};
}
class OAuthApp {

@@ -841,4 +890,5 @@ constructor(options) {

exports.OAuthApp = OAuthApp;
exports.createAWSLambdaAPIGatewayV2Handler = createAWSLambdaAPIGatewayV2Handler;
exports.createCloudflareHandler = createCloudflareHandler;
exports.createNodeMiddleware = createNodeMiddleware;
//# sourceMappingURL=index.js.map

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

export { createCloudflareHandler } from "./middleware/cloudflare/index";
export { createAWSLambdaAPIGatewayV2Handler } from "./middleware/aws-lambda/api-gateway-v2";
export class OAuthApp {

@@ -18,0 +19,0 @@ constructor(options) {

2

dist-src/version.js

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

export const VERSION = "3.5.1";
export const VERSION = "3.6.0";

@@ -13,2 +13,3 @@ import { GetUserOctokitWithStateInterface } from "./methods/get-user-octokit";

export { createCloudflareHandler } from "./middleware/cloudflare/index";
export { createAWSLambdaAPIGatewayV2Handler } from "./middleware/aws-lambda/api-gateway-v2";
declare type Constructor<T> = new (...args: any[]) => T;

@@ -15,0 +16,0 @@ export declare class OAuthApp<TOptions extends Options<ClientType> = Options<"oauth-app">> {

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

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

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

"@octokit/oauth-methods": "^1.2.2",
"@types/aws-lambda": "^8.10.83",
"fromentries": "^1.3.1",

@@ -34,3 +35,3 @@ "universal-user-agent": "^6.0.0"

"@pika/plugin-ts-standard-pkg": "^0.9.2",
"@types/jest": "^26.0.0",
"@types/jest": "^27.0.0",
"@types/node": "^14.0.4",

@@ -43,6 +44,6 @@ "@types/node-fetch": "^2.5.4",

"node-fetch": "^2.6.0",
"prettier": "2.3.2",
"semantic-release": "^17.0.3",
"prettier": "2.4.1",
"semantic-release": "^18.0.0",
"semantic-release-plugin-update-version-in-files": "^1.0.0",
"ts-jest": "^27.0.0-next.12",
"ts-jest": "^27.0.0",
"typescript": "^4.0.2"

@@ -49,0 +50,0 @@ },

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

```js
const { octokit } = await app.getUserOctokit({ code: "code123" });
const octokit = await app.getUserOctokit({ code: "code123" });
```

@@ -1058,2 +1058,92 @@

### `createAWSLambdaAPIGatewayV2Handler(app, options)`
Event handler for AWS Lambda using API Gateway V2 HTTP integration.
```js
// worker.js
import {
OAuthApp,
createAWSLambdaAPIGatewayV2Handler,
} from "@octokit/oauth-app";
const app = new OAuthApp({
clientType: "oauth-app",
clientId: "1234567890abcdef1234",
clientSecret: "1234567890abcdef1234567890abcdef12345678",
});
export const handler = createAWSLambdaAPIGatewayV2Handler(app, {
pathPrefix: "/api/github/oauth",
});
// can now receive user authorization callbacks at /api/github/oauth/callback
```
<table width="100%">
<thead align=left>
<tr>
<th width=150>
name
</th>
<th width=70>
type
</th>
<th>
description
</th>
</tr>
</thead>
<tbody align=left valign=top>
<tr>
<th>
<code>app</code>
</th>
<th>
<code>OAuthApp instance</code>
</th>
<td>
<strong>Required</strong>.
</td>
</tr>
<tr>
<th>
<code>options.pathPrefix</code>
</th>
<th>
<code>string</code>
</th>
<td>
All exposed paths will be prefixed with the provided prefix. Defaults to `"/api/github/oauth"`
</td>
</tr>
<tr>
<th>
<code>options.onUnhandledRequest</code>
</th>
<th>
<code>function</code>
</th>
<td>Defaults to returns:
```js
function onUnhandledRequest(request) {
return
{
status: 404,
headers: { "content-type": "application/json" },
body: JSON.stringify({
error: `Unknown route: [METHOD] [URL]`,
})
}
);
}
```
</td>
</tr>
</tbody>
</table>
## Contributing

@@ -1060,0 +1150,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