@octokit/oauth-methods
Advanced tools
Comparing version 2.0.3 to 2.0.4
@@ -12,3 +12,3 @@ 'use strict'; | ||
const VERSION = "2.0.3"; | ||
const VERSION = "2.0.4"; | ||
@@ -28,3 +28,2 @@ function requestToOAuthBaseUrl(request) { | ||
const response = await request(route, withOAuthParameters); | ||
if ("error" in response.data) { | ||
@@ -34,8 +33,7 @@ const error = new requestError.RequestError(`${response.data.error_description} (${response.data.error}, ${response.data.error_uri})`, 400, { | ||
headers: response.headers | ||
}); // @ts-ignore add custom response property until https://github.com/octokit/request-error.js/issues/169 is resolved | ||
}); | ||
// @ts-ignore add custom response property until https://github.com/octokit/request-error.js/issues/169 is resolved | ||
error.response = response; | ||
throw error; | ||
} | ||
return response; | ||
@@ -48,5 +46,6 @@ } | ||
}) { | ||
const baseUrl = requestToOAuthBaseUrl(request$1); // @ts-expect-error TypeScript wants `clientType` to be set explicitly ¯\_(ツ)_/¯ | ||
return oauthAuthorizationUrl.oauthAuthorizationUrl({ ...options, | ||
const baseUrl = requestToOAuthBaseUrl(request$1); | ||
// @ts-expect-error TypeScript wants `clientType` to be set explicitly ¯\_(ツ)_/¯ | ||
return oauthAuthorizationUrl.oauthAuthorizationUrl({ | ||
...options, | ||
baseUrl | ||
@@ -57,4 +56,3 @@ }); | ||
async function exchangeWebFlowCode(options) { | ||
const request$1 = options.request || | ||
/* istanbul ignore next: we always pass a custom request in tests */ | ||
const request$1 = options.request || /* istanbul ignore next: we always pass a custom request in tests */ | ||
request.request; | ||
@@ -74,3 +72,2 @@ const response = await oauthRequest(request$1, "POST /login/oauth/access_token", { | ||
}; | ||
if (options.clientType === "github-app") { | ||
@@ -81,11 +78,9 @@ if ("refresh_token" in response.data) { | ||
} | ||
delete authentication.scopes; | ||
} | ||
return { ...response, | ||
return { | ||
...response, | ||
authentication | ||
}; | ||
} | ||
function toTimestamp(apiTimeInMs, expirationInSeconds) { | ||
@@ -96,4 +91,3 @@ return new Date(apiTimeInMs + expirationInSeconds * 1000).toISOString(); | ||
async function createDeviceCode(options) { | ||
const request$1 = options.request || | ||
/* istanbul ignore next: we always pass a custom request in tests */ | ||
const request$1 = options.request || /* istanbul ignore next: we always pass a custom request in tests */ | ||
request.request; | ||
@@ -103,7 +97,5 @@ const parameters = { | ||
}; | ||
if ("scopes" in options && Array.isArray(options.scopes)) { | ||
parameters.scope = options.scopes.join(" "); | ||
} | ||
return oauthRequest(request$1, "POST /login/device/code", parameters); | ||
@@ -113,4 +105,3 @@ } | ||
async function exchangeDeviceCode(options) { | ||
const request$1 = options.request || | ||
/* istanbul ignore next: we always pass a custom request in tests */ | ||
const request$1 = options.request || /* istanbul ignore next: we always pass a custom request in tests */ | ||
request.request; | ||
@@ -128,7 +119,5 @@ const response = await oauthRequest(request$1, "POST /login/oauth/access_token", { | ||
}; | ||
if ("clientSecret" in options) { | ||
authentication.clientSecret = options.clientSecret; | ||
} | ||
if (options.clientType === "github-app") { | ||
@@ -139,11 +128,9 @@ if ("refresh_token" in response.data) { | ||
} | ||
delete authentication.scopes; | ||
} | ||
return { ...response, | ||
return { | ||
...response, | ||
authentication | ||
}; | ||
} | ||
function toTimestamp$1(apiTimeInMs, expirationInSeconds) { | ||
@@ -154,6 +141,4 @@ return new Date(apiTimeInMs + expirationInSeconds * 1000).toISOString(); | ||
async function checkToken(options) { | ||
const request$1 = options.request || | ||
/* istanbul ignore next: we always pass a custom request in tests */ | ||
request.request; // @ts-expect-error - TODO: I don't get why TS is complaining here. It works with `defaultRequest` directly | ||
const request$1 = options.request || /* istanbul ignore next: we always pass a custom request in tests */ | ||
request.request; | ||
const response = await request$1("POST /applications/{client_id}/token", { | ||
@@ -174,8 +159,7 @@ headers: { | ||
if (response.data.expires_at) authentication.expiresAt = response.data.expires_at; | ||
if (options.clientType === "github-app") { | ||
delete authentication.scopes; | ||
} | ||
return { ...response, | ||
return { | ||
...response, | ||
authentication | ||
@@ -186,4 +170,3 @@ }; | ||
async function refreshToken(options) { | ||
const request$1 = options.request || | ||
/* istanbul ignore next: we always pass a custom request in tests */ | ||
const request$1 = options.request || /* istanbul ignore next: we always pass a custom request in tests */ | ||
request.request; | ||
@@ -206,7 +189,7 @@ const response = await oauthRequest(request$1, "POST /login/oauth/access_token", { | ||
}; | ||
return { ...response, | ||
return { | ||
...response, | ||
authentication | ||
}; | ||
} | ||
function toTimestamp$2(apiTimeInMs, expirationInSeconds) { | ||
@@ -225,7 +208,5 @@ return new Date(apiTimeInMs + expirationInSeconds * 1000).toISOString(); | ||
} = options; | ||
const request$1 = optionsRequest || | ||
/* istanbul ignore next: we always pass a custom request in tests */ | ||
const request$1 = optionsRequest || /* istanbul ignore next: we always pass a custom request in tests */ | ||
request.request; | ||
const response = await request$1("POST /applications/{client_id}/token/scoped", // @ts-expect-error - TODO: I don't get why TS is complaining here. It works with `defaultRequest` directly | ||
{ | ||
const response = await request$1("POST /applications/{client_id}/token/scoped", { | ||
headers: { | ||
@@ -245,5 +226,5 @@ authorization: `basic ${btoa(`${clientId}:${clientSecret}`)}` | ||
expiresAt: response.data.expires_at | ||
} : {}); // @ts-expect-error - response.status type is incompatible (200 vs number) | ||
return { ...response, | ||
} : {}); | ||
return { | ||
...response, | ||
authentication | ||
@@ -254,8 +235,6 @@ }; | ||
async function resetToken(options) { | ||
const request$1 = options.request || | ||
/* istanbul ignore next: we always pass a custom request in tests */ | ||
const request$1 = options.request || /* istanbul ignore next: we always pass a custom request in tests */ | ||
request.request; | ||
const auth = btoa(`${options.clientId}:${options.clientSecret}`); | ||
const response = await request$1("PATCH /applications/{client_id}/token", // @ts-expect-error - TODO: I don't get why TS is complaining here. It works with `defaultRequest` directly | ||
{ | ||
const response = await request$1("PATCH /applications/{client_id}/token", { | ||
headers: { | ||
@@ -275,8 +254,7 @@ authorization: `basic ${auth}` | ||
if (response.data.expires_at) authentication.expiresAt = response.data.expires_at; | ||
if (options.clientType === "github-app") { | ||
delete authentication.scopes; | ||
} | ||
return { ...response, | ||
return { | ||
...response, | ||
authentication | ||
@@ -287,8 +265,6 @@ }; | ||
async function deleteToken(options) { | ||
const request$1 = options.request || | ||
/* istanbul ignore next: we always pass a custom request in tests */ | ||
const request$1 = options.request || /* istanbul ignore next: we always pass a custom request in tests */ | ||
request.request; | ||
const auth = btoa(`${options.clientId}:${options.clientSecret}`); | ||
return request$1("DELETE /applications/{client_id}/token", // @ts-expect-error - TODO: I don't get why TS is complaining here. It works with `defaultRequest` directly | ||
{ | ||
return request$1("DELETE /applications/{client_id}/token", { | ||
headers: { | ||
@@ -303,8 +279,6 @@ authorization: `basic ${auth}` | ||
async function deleteAuthorization(options) { | ||
const request$1 = options.request || | ||
/* istanbul ignore next: we always pass a custom request in tests */ | ||
const request$1 = options.request || /* istanbul ignore next: we always pass a custom request in tests */ | ||
request.request; | ||
const auth = btoa(`${options.clientId}:${options.clientSecret}`); | ||
return request$1("DELETE /applications/{client_id}/grant", // @ts-expect-error - TODO: I don't get why TS is complaining here. It works with `defaultRequest` directly | ||
{ | ||
return request$1("DELETE /applications/{client_id}/grant", { | ||
headers: { | ||
@@ -311,0 +285,0 @@ authorization: `basic ${auth}` |
@@ -7,3 +7,2 @@ import { request as defaultRequest } from "@octokit/request"; | ||
defaultRequest; | ||
// @ts-expect-error - TODO: I don't get why TS is complaining here. It works with `defaultRequest` directly | ||
const response = await request("POST /applications/{client_id}/token", { | ||
@@ -10,0 +9,0 @@ headers: { |
@@ -8,5 +8,3 @@ import { request as defaultRequest } from "@octokit/request"; | ||
const auth = btoa(`${options.clientId}:${options.clientSecret}`); | ||
return request("DELETE /applications/{client_id}/grant", | ||
// @ts-expect-error - TODO: I don't get why TS is complaining here. It works with `defaultRequest` directly | ||
{ | ||
return request("DELETE /applications/{client_id}/grant", { | ||
headers: { | ||
@@ -13,0 +11,0 @@ authorization: `basic ${auth}`, |
@@ -8,5 +8,3 @@ import { request as defaultRequest } from "@octokit/request"; | ||
const auth = btoa(`${options.clientId}:${options.clientSecret}`); | ||
return request("DELETE /applications/{client_id}/token", | ||
// @ts-expect-error - TODO: I don't get why TS is complaining here. It works with `defaultRequest` directly | ||
{ | ||
return request("DELETE /applications/{client_id}/token", { | ||
headers: { | ||
@@ -13,0 +11,0 @@ authorization: `basic ${auth}`, |
@@ -8,5 +8,3 @@ import { request as defaultRequest } from "@octokit/request"; | ||
const auth = btoa(`${options.clientId}:${options.clientSecret}`); | ||
const response = await request("PATCH /applications/{client_id}/token", | ||
// @ts-expect-error - TODO: I don't get why TS is complaining here. It works with `defaultRequest` directly | ||
{ | ||
const response = await request("PATCH /applications/{client_id}/token", { | ||
headers: { | ||
@@ -13,0 +11,0 @@ authorization: `basic ${auth}`, |
@@ -8,5 +8,3 @@ import { request as defaultRequest } from "@octokit/request"; | ||
defaultRequest; | ||
const response = await request("POST /applications/{client_id}/token/scoped", | ||
// @ts-expect-error - TODO: I don't get why TS is complaining here. It works with `defaultRequest` directly | ||
{ | ||
const response = await request("POST /applications/{client_id}/token/scoped", { | ||
headers: { | ||
@@ -25,4 +23,3 @@ authorization: `basic ${btoa(`${clientId}:${clientSecret}`)}`, | ||
}, response.data.expires_at ? { expiresAt: response.data.expires_at } : {}); | ||
// @ts-expect-error - response.status type is incompatible (200 vs number) | ||
return { ...response, authentication }; | ||
} |
@@ -1,1 +0,1 @@ | ||
export const VERSION = "2.0.3"; | ||
export const VERSION = "2.0.4"; |
@@ -1,1 +0,1 @@ | ||
export declare const VERSION = "2.0.3"; | ||
export declare const VERSION = "2.0.4"; |
{ | ||
"name": "@octokit/oauth-methods", | ||
"description": "Set of stateless request methods to create, check, reset, refresh, and delete user access tokens for OAuth and GitHub Apps", | ||
"version": "2.0.3", | ||
"version": "2.0.4", | ||
"license": "MIT", | ||
@@ -24,3 +24,3 @@ "files": [ | ||
"@octokit/request-error": "^3.0.0", | ||
"@octokit/types": "^7.0.0", | ||
"@octokit/types": "^8.0.0", | ||
"btoa-lite": "^1.0.0" | ||
@@ -35,10 +35,10 @@ }, | ||
"@types/btoa-lite": "^1.0.0", | ||
"@types/jest": "^28.0.0", | ||
"@types/jest": "^29.0.0", | ||
"@types/node": "^16.0.0", | ||
"fetch-mock": "^9.11.0", | ||
"jest": "^28.0.0", | ||
"jest": "^29.0.0", | ||
"prettier": "2.7.1", | ||
"semantic-release": "^19.0.0", | ||
"semantic-release-plugin-update-version-in-files": "^1.1.0", | ||
"ts-jest": "^28.0.0", | ||
"ts-jest": "^29.0.0", | ||
"typescript": "^4.2.3" | ||
@@ -45,0 +45,0 @@ }, |
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
99400
868
+ Added@octokit/openapi-types@14.0.0(transitive)
+ Added@octokit/types@8.2.1(transitive)
- Removed@octokit/openapi-types@13.13.1(transitive)
- Removed@octokit/types@7.5.1(transitive)
Updated@octokit/types@^8.0.0