Upgrade octokit to v4.1.2
This commit is contained in:
parent
dbbcbe019d
commit
c1745a9831
1214 changed files with 160765 additions and 0 deletions
44
node_modules/@octokit/oauth-authorization-url/dist-src/index.js
generated
vendored
Normal file
44
node_modules/@octokit/oauth-authorization-url/dist-src/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
function oauthAuthorizationUrl(options) {
|
||||
const clientType = options.clientType || "oauth-app";
|
||||
const baseUrl = options.baseUrl || "https://github.com";
|
||||
const result = {
|
||||
clientType,
|
||||
allowSignup: options.allowSignup === false ? false : true,
|
||||
clientId: options.clientId,
|
||||
login: options.login || null,
|
||||
redirectUrl: options.redirectUrl || null,
|
||||
state: options.state || Math.random().toString(36).substr(2),
|
||||
url: ""
|
||||
};
|
||||
if (clientType === "oauth-app") {
|
||||
const scopes = "scopes" in options ? options.scopes : [];
|
||||
result.scopes = typeof scopes === "string" ? scopes.split(/[,\s]+/).filter(Boolean) : scopes;
|
||||
}
|
||||
result.url = urlBuilderAuthorize(`${baseUrl}/login/oauth/authorize`, result);
|
||||
return result;
|
||||
}
|
||||
function urlBuilderAuthorize(base, options) {
|
||||
const map = {
|
||||
allowSignup: "allow_signup",
|
||||
clientId: "client_id",
|
||||
login: "login",
|
||||
redirectUrl: "redirect_uri",
|
||||
scopes: "scope",
|
||||
state: "state"
|
||||
};
|
||||
let url = base;
|
||||
Object.keys(map).filter((k) => options[k] !== null).filter((k) => {
|
||||
if (k !== "scopes")
|
||||
return true;
|
||||
if (options.clientType === "github-app")
|
||||
return false;
|
||||
return !Array.isArray(options[k]) || options[k].length > 0;
|
||||
}).map((key) => [map[key], `${options[key]}`]).forEach(([key, value], index) => {
|
||||
url += index === 0 ? `?` : "&";
|
||||
url += `${key}=${encodeURIComponent(value)}`;
|
||||
});
|
||||
return url;
|
||||
}
|
||||
export {
|
||||
oauthAuthorizationUrl
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue