@octokit/oauth-authorization-url
Advanced tools
Comparing version
@@ -5,3 +5,2 @@ 'use strict'; | ||
const BASE_URL = "https://github.com/login/oauth/authorize"; | ||
function oauthAuthorizationUrl(options) { | ||
@@ -18,3 +17,4 @@ const scopesNormalized = typeof options.scopes === "string" ? options.scopes.split(/[,\s]+/).filter(Boolean) : Array.isArray(options.scopes) ? options.scopes : []; | ||
}; | ||
result.url = urlBuilderAuthorize(BASE_URL, result); | ||
const baseUrl = options.baseUrl || "https://github.com"; | ||
result.url = urlBuilderAuthorize(`${baseUrl}/login/oauth/authorize`, result); | ||
return result; | ||
@@ -44,4 +44,3 @@ } | ||
exports.BASE_URL = BASE_URL; | ||
exports.oauthAuthorizationUrl = oauthAuthorizationUrl; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,1 @@ | ||
export const BASE_URL = "https://github.com/login/oauth/authorize"; | ||
export function oauthAuthorizationUrl(options) { | ||
@@ -14,9 +13,7 @@ const scopesNormalized = typeof options.scopes === "string" | ||
scopes: scopesNormalized, | ||
state: options.state || | ||
Math.random() | ||
.toString(36) | ||
.substr(2), | ||
url: "" | ||
state: options.state || Math.random().toString(36).substr(2), | ||
url: "", | ||
}; | ||
result.url = urlBuilderAuthorize(BASE_URL, result); | ||
const baseUrl = options.baseUrl || "https://github.com"; | ||
result.url = urlBuilderAuthorize(`${baseUrl}/login/oauth/authorize`, result); | ||
return result; | ||
@@ -31,3 +28,3 @@ } | ||
scopes: "scope", | ||
state: "state" | ||
state: "state", | ||
}; | ||
@@ -34,0 +31,0 @@ let url = base; |
import { Options, Result } from "./types"; | ||
export declare const BASE_URL = "https://github.com/login/oauth/authorize"; | ||
export declare function oauthAuthorizationUrl(options: Options): Result; |
@@ -8,2 +8,3 @@ export interface Options { | ||
state?: string; | ||
baseUrl?: string; | ||
} | ||
@@ -10,0 +11,0 @@ export interface Result { |
@@ -1,2 +0,1 @@ | ||
const BASE_URL = "https://github.com/login/oauth/authorize"; | ||
function oauthAuthorizationUrl(options) { | ||
@@ -14,9 +13,7 @@ const scopesNormalized = typeof options.scopes === "string" | ||
scopes: scopesNormalized, | ||
state: options.state || | ||
Math.random() | ||
.toString(36) | ||
.substr(2), | ||
url: "" | ||
state: options.state || Math.random().toString(36).substr(2), | ||
url: "", | ||
}; | ||
result.url = urlBuilderAuthorize(BASE_URL, result); | ||
const baseUrl = options.baseUrl || "https://github.com"; | ||
result.url = urlBuilderAuthorize(`${baseUrl}/login/oauth/authorize`, result); | ||
return result; | ||
@@ -31,3 +28,3 @@ } | ||
scopes: "scope", | ||
state: "state" | ||
state: "state", | ||
}; | ||
@@ -47,3 +44,3 @@ let url = base; | ||
export { BASE_URL, oauthAuthorizationUrl }; | ||
export { oauthAuthorizationUrl }; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@octokit/oauth-authorization-url", | ||
"description": "Universal library to retrieve GitHub’s identity URL for the OAuth web flow", | ||
"version": "4.0.1", | ||
"version": "4.1.0", | ||
"license": "MIT", | ||
@@ -28,8 +28,8 @@ "files": [ | ||
"@pika/plugin-ts-standard-pkg": "^0.9.0", | ||
"@types/jest": "^25.1.2", | ||
"jest": "^25.1.0", | ||
"@types/jest": "^26.0.0", | ||
"jest": "^26.1.0", | ||
"pika-plugin-unpkg-field": "^1.0.1", | ||
"semantic-release": "^17.0.0", | ||
"ts-jest": "^25.2.0", | ||
"typescript": "^3.4.3" | ||
"ts-jest": "^26.1.3", | ||
"typescript": "^4.0.2" | ||
}, | ||
@@ -36,0 +36,0 @@ "publishConfig": { |
@@ -7,3 +7,2 @@ # oauth-authorization-url.js | ||
[](https://travis-ci.com/octokit/oauth-authorization-url.js) | ||
[](https://greenkeeper.io/) | ||
@@ -55,3 +54,3 @@ See [GitHub’s Developer Guide for the OAuth web application flow](https://developer.github.com/enterprise/2.16/apps/building-oauth-apps/authorizing-oauth-apps/#1-request-a-users-github-identity). | ||
scopes, | ||
state | ||
state, | ||
} = oauthAuthorizationUrl({ | ||
@@ -62,3 +61,3 @@ clientId: "1234567890abcdef1234", | ||
scopes: ["repo", "admin:org"], | ||
state: "secret123" | ||
state: "secret123", | ||
}); | ||
@@ -135,3 +134,3 @@ ``` | ||
<td> | ||
When using GitHub Enterprise Server, set the baseUrl to the origin, e.g. <code>https://github.my-enterprise.com/</code>. | ||
When using GitHub Enterprise Server, set the baseUrl to the origin, e.g. <code>https://github.my-enterprise.com</code>. | ||
</td> | ||
@@ -138,0 +137,0 @@ </tr> |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
20804
-0.86%143
-4.03%215
-0.46%