@octokit/auth-oauth-app
Advanced tools
Comparing version 3.0.7 to 3.0.8
@@ -87,15 +87,15 @@ 'use strict'; | ||
* | ||
* - [`POST /applications/:client_id/token`](https://developer.github.com/v3/apps/oauth_applications/#check-a-token) - Check a token | ||
* - [`PATCH /applications/:client_id/token`](https://developer.github.com/v3/apps/oauth_applications/#reset-a-token) - Reset a token | ||
* - [`DELETE /applications/:client_id/token`](https://developer.github.com/v3/apps/oauth_applications/#reset-a-token) - Delete an app token | ||
* - [`DELETE /applications/:client_id/grant`](https://developer.github.com/v3/apps/oauth_applications/#delete-an-app-authorization) - Delete an app authorization | ||
* - [`POST /applications/{client_id}/token`](https://developer.github.com/v3/apps/oauth_applications/#check-a-token) - Check a token | ||
* - [`PATCH /applications/{client_id}/token`](https://developer.github.com/v3/apps/oauth_applications/#reset-a-token) - Reset a token | ||
* - [`DELETE /applications/{client_id}/token`](https://developer.github.com/v3/apps/oauth_applications/#reset-a-token) - Delete an app token | ||
* - [`DELETE /applications/{client_id}/grant`](https://developer.github.com/v3/apps/oauth_applications/#delete-an-app-authorization) - Delete an app authorization | ||
* | ||
* deprecated: | ||
* | ||
* - [`GET /applications/:client_id/tokens/:access_token`](https://developer.github.com/v3/apps/oauth_applications/#check-an-authorization) - Check an authorization | ||
* - [`POST /applications/:client_id/tokens/:access_token`](https://developer.github.com/v3/apps/oauth_applications/#reset-an-authorization) - Reset an authorization | ||
* - [`DELETE /applications/:client_id/tokens/:access_token`](https://developer.github.com/v3/apps/oauth_applications/#revoke-an-authorization-for-an-application) - Revoke an authorization for an application | ||
* - [`DELETE /applications/:client_id/grants/:access_token`](https://developer.github.com/v3/apps/oauth_applications/#revoke-a-grant-for-an-application) - Revoke a grant for an application | ||
* - [`GET /applications/{client_id}/tokens/{access_token}`](https://developer.github.com/v3/apps/oauth_applications/#check-an-authorization) - Check an authorization | ||
* - [`POST /applications/{client_id}/tokens/{access_token}`](https://developer.github.com/v3/apps/oauth_applications/#reset-an-authorization) - Reset an authorization | ||
* - [`DELETE /applications/{client_id}/tokens/{access_token}`](https://developer.github.com/v3/apps/oauth_applications/#revoke-an-authorization-for-an-application) - Revoke an authorization for an application | ||
* - [`DELETE /applications/{client_id}/grants/{access_token}`](https://developer.github.com/v3/apps/oauth_applications/#revoke-a-grant-for-an-application) - Revoke a grant for an application | ||
*/ | ||
const ROUTES_REQUIRING_BASIC_AUTH = /\/applications\/:?[\w_]+\/(token|grant)(s\/:?[\w_]+)?($|\?)/; | ||
const ROUTES_REQUIRING_BASIC_AUTH = /\/applications\/[:{]?[\w_]+\}?\/(token|grant)(s\/[:{]?[\w_]+\}?)?($|\?)/; | ||
function requiresBasicAuth(url) { | ||
@@ -115,9 +115,9 @@ return url && ROUTES_REQUIRING_BASIC_AUTH.test(url); | ||
endpoint.headers.authorization = `basic ${credentials}`; | ||
const response = await request(endpoint); | ||
const parsedEndpoint = request.endpoint.parse(endpoint); // `POST /applications/:client_id/tokens/:access_token` (legacy) or | ||
// `PATCH /applications/:client_id/token` resets the passed token | ||
const response = await request(endpoint); // `POST /applications/{client_id}/tokens/{access_token}` (legacy) or | ||
// `PATCH /applications/{client_id}/token` resets the passed token | ||
// and returns a new one. If that’s the current request then update internal state. | ||
// Regex supports both the `{param}` as well as the legacy `:param` notation | ||
const isLegacyTokenResetRequest = endpoint.method === "POST" && /^\/applications\/:?[\w_]+\/tokens\/:?[\w_]+$/.test(endpoint.url); | ||
const isTokenResetRequest = endpoint.method === "PATCH" && /^\/applications\/:?[\w_]+\/token$/.test(endpoint.url); | ||
const isLegacyTokenResetRequest = endpoint.method === "POST" && /^\/applications\/[:{]?[\w_]+\}?\/tokens\/[:{]?[\w_]+\}?$/.test(endpoint.url); | ||
const isTokenResetRequest = endpoint.method === "PATCH" && /^\/applications\/[:{]?[\w_]+\}?\/token$/.test(endpoint.url); | ||
@@ -144,3 +144,3 @@ if (isLegacyTokenResetRequest || isTokenResetRequest) { | ||
const VERSION = "3.0.7"; | ||
const VERSION = "3.0.8"; | ||
@@ -147,0 +147,0 @@ function createOAuthAppAuth(options) { |
@@ -14,10 +14,10 @@ import btoa from "btoa-lite"; | ||
const response = await request(endpoint); | ||
const parsedEndpoint = request.endpoint.parse(endpoint); | ||
// `POST /applications/:client_id/tokens/:access_token` (legacy) or | ||
// `PATCH /applications/:client_id/token` resets the passed token | ||
// `POST /applications/{client_id}/tokens/{access_token}` (legacy) or | ||
// `PATCH /applications/{client_id}/token` resets the passed token | ||
// and returns a new one. If that’s the current request then update internal state. | ||
// Regex supports both the `{param}` as well as the legacy `:param` notation | ||
const isLegacyTokenResetRequest = endpoint.method === "POST" && | ||
/^\/applications\/:?[\w_]+\/tokens\/:?[\w_]+$/.test(endpoint.url); | ||
/^\/applications\/[:{]?[\w_]+\}?\/tokens\/[:{]?[\w_]+\}?$/.test(endpoint.url); | ||
const isTokenResetRequest = endpoint.method === "PATCH" && | ||
/^\/applications\/:?[\w_]+\/token$/.test(endpoint.url); | ||
/^\/applications\/[:{]?[\w_]+\}?\/token$/.test(endpoint.url); | ||
if (isLegacyTokenResetRequest || isTokenResetRequest) { | ||
@@ -27,3 +27,3 @@ state.token = { | ||
// @ts-ignore figure this out | ||
scope: response.data.scopes | ||
scope: response.data.scopes, | ||
}; | ||
@@ -30,0 +30,0 @@ } |
/** | ||
* The following endpoints require an OAuth App to authenticate using its client_id and client_secret. | ||
* | ||
* - [`POST /applications/:client_id/token`](https://developer.github.com/v3/apps/oauth_applications/#check-a-token) - Check a token | ||
* - [`PATCH /applications/:client_id/token`](https://developer.github.com/v3/apps/oauth_applications/#reset-a-token) - Reset a token | ||
* - [`DELETE /applications/:client_id/token`](https://developer.github.com/v3/apps/oauth_applications/#reset-a-token) - Delete an app token | ||
* - [`DELETE /applications/:client_id/grant`](https://developer.github.com/v3/apps/oauth_applications/#delete-an-app-authorization) - Delete an app authorization | ||
* - [`POST /applications/{client_id}/token`](https://developer.github.com/v3/apps/oauth_applications/#check-a-token) - Check a token | ||
* - [`PATCH /applications/{client_id}/token`](https://developer.github.com/v3/apps/oauth_applications/#reset-a-token) - Reset a token | ||
* - [`DELETE /applications/{client_id}/token`](https://developer.github.com/v3/apps/oauth_applications/#reset-a-token) - Delete an app token | ||
* - [`DELETE /applications/{client_id}/grant`](https://developer.github.com/v3/apps/oauth_applications/#delete-an-app-authorization) - Delete an app authorization | ||
* | ||
* deprecated: | ||
* | ||
* - [`GET /applications/:client_id/tokens/:access_token`](https://developer.github.com/v3/apps/oauth_applications/#check-an-authorization) - Check an authorization | ||
* - [`POST /applications/:client_id/tokens/:access_token`](https://developer.github.com/v3/apps/oauth_applications/#reset-an-authorization) - Reset an authorization | ||
* - [`DELETE /applications/:client_id/tokens/:access_token`](https://developer.github.com/v3/apps/oauth_applications/#revoke-an-authorization-for-an-application) - Revoke an authorization for an application | ||
* - [`DELETE /applications/:client_id/grants/:access_token`](https://developer.github.com/v3/apps/oauth_applications/#revoke-a-grant-for-an-application) - Revoke a grant for an application | ||
* - [`GET /applications/{client_id}/tokens/{access_token}`](https://developer.github.com/v3/apps/oauth_applications/#check-an-authorization) - Check an authorization | ||
* - [`POST /applications/{client_id}/tokens/{access_token}`](https://developer.github.com/v3/apps/oauth_applications/#reset-an-authorization) - Reset an authorization | ||
* - [`DELETE /applications/{client_id}/tokens/{access_token}`](https://developer.github.com/v3/apps/oauth_applications/#revoke-an-authorization-for-an-application) - Revoke an authorization for an application | ||
* - [`DELETE /applications/{client_id}/grants/{access_token}`](https://developer.github.com/v3/apps/oauth_applications/#revoke-a-grant-for-an-application) - Revoke a grant for an application | ||
*/ | ||
const ROUTES_REQUIRING_BASIC_AUTH = /\/applications\/:?[\w_]+\/(token|grant)(s\/:?[\w_]+)?($|\?)/; | ||
const ROUTES_REQUIRING_BASIC_AUTH = /\/applications\/[:{]?[\w_]+\}?\/(token|grant)(s\/[:{]?[\w_]+\}?)?($|\?)/; | ||
export function requiresBasicAuth(url) { | ||
return url && ROUTES_REQUIRING_BASIC_AUTH.test(url); | ||
} |
@@ -1,1 +0,1 @@ | ||
export const VERSION = "3.0.7"; | ||
export const VERSION = "3.0.8"; |
@@ -8,3 +8,7 @@ import * as OctokitTypes from "@octokit/types"; | ||
export declare type RequestInterface = OctokitTypes.RequestInterface; | ||
export declare type StrategyInterface = OctokitTypes.StrategyInterface<[StrategyOptions], [AuthOptions], Authentication>; | ||
export declare type StrategyInterface = OctokitTypes.StrategyInterface<[ | ||
StrategyOptions | ||
], [ | ||
AuthOptions | ||
], Authentication>; | ||
export declare type StrategyOptions = { | ||
@@ -11,0 +15,0 @@ clientId: string; |
@@ -1,1 +0,1 @@ | ||
export declare const VERSION = "3.0.7"; | ||
export declare const VERSION = "3.0.8"; |
@@ -73,15 +73,15 @@ import { getUserAgent } from 'universal-user-agent'; | ||
* | ||
* - [`POST /applications/:client_id/token`](https://developer.github.com/v3/apps/oauth_applications/#check-a-token) - Check a token | ||
* - [`PATCH /applications/:client_id/token`](https://developer.github.com/v3/apps/oauth_applications/#reset-a-token) - Reset a token | ||
* - [`DELETE /applications/:client_id/token`](https://developer.github.com/v3/apps/oauth_applications/#reset-a-token) - Delete an app token | ||
* - [`DELETE /applications/:client_id/grant`](https://developer.github.com/v3/apps/oauth_applications/#delete-an-app-authorization) - Delete an app authorization | ||
* - [`POST /applications/{client_id}/token`](https://developer.github.com/v3/apps/oauth_applications/#check-a-token) - Check a token | ||
* - [`PATCH /applications/{client_id}/token`](https://developer.github.com/v3/apps/oauth_applications/#reset-a-token) - Reset a token | ||
* - [`DELETE /applications/{client_id}/token`](https://developer.github.com/v3/apps/oauth_applications/#reset-a-token) - Delete an app token | ||
* - [`DELETE /applications/{client_id}/grant`](https://developer.github.com/v3/apps/oauth_applications/#delete-an-app-authorization) - Delete an app authorization | ||
* | ||
* deprecated: | ||
* | ||
* - [`GET /applications/:client_id/tokens/:access_token`](https://developer.github.com/v3/apps/oauth_applications/#check-an-authorization) - Check an authorization | ||
* - [`POST /applications/:client_id/tokens/:access_token`](https://developer.github.com/v3/apps/oauth_applications/#reset-an-authorization) - Reset an authorization | ||
* - [`DELETE /applications/:client_id/tokens/:access_token`](https://developer.github.com/v3/apps/oauth_applications/#revoke-an-authorization-for-an-application) - Revoke an authorization for an application | ||
* - [`DELETE /applications/:client_id/grants/:access_token`](https://developer.github.com/v3/apps/oauth_applications/#revoke-a-grant-for-an-application) - Revoke a grant for an application | ||
* - [`GET /applications/{client_id}/tokens/{access_token}`](https://developer.github.com/v3/apps/oauth_applications/#check-an-authorization) - Check an authorization | ||
* - [`POST /applications/{client_id}/tokens/{access_token}`](https://developer.github.com/v3/apps/oauth_applications/#reset-an-authorization) - Reset an authorization | ||
* - [`DELETE /applications/{client_id}/tokens/{access_token}`](https://developer.github.com/v3/apps/oauth_applications/#revoke-an-authorization-for-an-application) - Revoke an authorization for an application | ||
* - [`DELETE /applications/{client_id}/grants/{access_token}`](https://developer.github.com/v3/apps/oauth_applications/#revoke-a-grant-for-an-application) - Revoke a grant for an application | ||
*/ | ||
const ROUTES_REQUIRING_BASIC_AUTH = /\/applications\/:?[\w_]+\/(token|grant)(s\/:?[\w_]+)?($|\?)/; | ||
const ROUTES_REQUIRING_BASIC_AUTH = /\/applications\/[:{]?[\w_]+\}?\/(token|grant)(s\/[:{]?[\w_]+\}?)?($|\?)/; | ||
function requiresBasicAuth(url) { | ||
@@ -101,10 +101,10 @@ return url && ROUTES_REQUIRING_BASIC_AUTH.test(url); | ||
const response = await request(endpoint); | ||
const parsedEndpoint = request.endpoint.parse(endpoint); | ||
// `POST /applications/:client_id/tokens/:access_token` (legacy) or | ||
// `PATCH /applications/:client_id/token` resets the passed token | ||
// `POST /applications/{client_id}/tokens/{access_token}` (legacy) or | ||
// `PATCH /applications/{client_id}/token` resets the passed token | ||
// and returns a new one. If that’s the current request then update internal state. | ||
// Regex supports both the `{param}` as well as the legacy `:param` notation | ||
const isLegacyTokenResetRequest = endpoint.method === "POST" && | ||
/^\/applications\/:?[\w_]+\/tokens\/:?[\w_]+$/.test(endpoint.url); | ||
/^\/applications\/[:{]?[\w_]+\}?\/tokens\/[:{]?[\w_]+\}?$/.test(endpoint.url); | ||
const isTokenResetRequest = endpoint.method === "PATCH" && | ||
/^\/applications\/:?[\w_]+\/token$/.test(endpoint.url); | ||
/^\/applications\/[:{]?[\w_]+\}?\/token$/.test(endpoint.url); | ||
if (isLegacyTokenResetRequest || isTokenResetRequest) { | ||
@@ -114,3 +114,3 @@ state.token = { | ||
// @ts-ignore figure this out | ||
scope: response.data.scopes | ||
scope: response.data.scopes, | ||
}; | ||
@@ -125,3 +125,3 @@ } | ||
const VERSION = "3.0.7"; | ||
const VERSION = "3.0.8"; | ||
@@ -128,0 +128,0 @@ function createOAuthAppAuth(options) { |
{ | ||
"name": "@octokit/auth-oauth-app", | ||
"description": "GitHub OAuth App authentication for JavaScript", | ||
"version": "3.0.7", | ||
"version": "3.0.8", | ||
"license": "MIT", | ||
@@ -27,3 +27,3 @@ "files": [ | ||
"@octokit/request-error": "^2.0.0", | ||
"@octokit/types": "^6.0.0", | ||
"@octokit/types": "^6.0.3", | ||
"@types/btoa-lite": "^1.0.0", | ||
@@ -41,7 +41,7 @@ "btoa-lite": "^1.0.0", | ||
"fetch-mock": "^9.0.0", | ||
"jest": "^25.1.0", | ||
"jest": "^26.0.0", | ||
"semantic-release": "^17.0.0", | ||
"semantic-release-plugin-update-version-in-files": "^1.0.0", | ||
"ts-jest": "^25.1.0", | ||
"typescript": "^3.9.3" | ||
"ts-jest": "^26.0.0", | ||
"typescript": "^4.0.0" | ||
}, | ||
@@ -48,0 +48,0 @@ "publishConfig": { |
@@ -18,4 +18,4 @@ # auth-oauth-app.js | ||
- [Authentication object](#authentication-object) | ||
- [OAuth authentication](#oauth-authentication) | ||
- [OAuth access token authentication](#oauth-access-token-authentication) | ||
- [OAuth authentication](#oauth-authentication) | ||
- [OAuth access token authentication](#oauth-access-token-authentication) | ||
- [`auth.hook(request, route, parameters)` or `auth.hook(request, options)`](#authhookrequest-route-parameters-or-authhookrequest-options) | ||
@@ -428,3 +428,3 @@ - [Implementation details](#implementation-details) | ||
const { token } = await auth({ type: "token" }); | ||
await auth.hook(request, "POST /applications/:client_id/token", { | ||
await auth.hook(request, "POST /applications/{client_id}/token", { | ||
client_id: "123", | ||
@@ -431,0 +431,0 @@ access_token: token, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
58699
474
Updated@octokit/types@^6.0.3