First upload version 0.0.1
This commit is contained in:
55
node_modules/@octokit/auth-token/dist-bundle/index.js
generated
vendored
Normal file
55
node_modules/@octokit/auth-token/dist-bundle/index.js
generated
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
// pkg/dist-src/is-jwt.js
|
||||
var b64url = "(?:[a-zA-Z0-9_-]+)";
|
||||
var sep = "\\.";
|
||||
var jwtRE = new RegExp(`^${b64url}${sep}${b64url}${sep}${b64url}$`);
|
||||
var isJWT = jwtRE.test.bind(jwtRE);
|
||||
|
||||
// pkg/dist-src/auth.js
|
||||
async function auth(token) {
|
||||
const isApp = isJWT(token);
|
||||
const isInstallation = token.startsWith("v1.") || token.startsWith("ghs_");
|
||||
const isUserToServer = token.startsWith("ghu_");
|
||||
const tokenType = isApp ? "app" : isInstallation ? "installation" : isUserToServer ? "user-to-server" : "oauth";
|
||||
return {
|
||||
type: "token",
|
||||
token,
|
||||
tokenType
|
||||
};
|
||||
}
|
||||
|
||||
// pkg/dist-src/with-authorization-prefix.js
|
||||
function withAuthorizationPrefix(token) {
|
||||
if (token.split(/\./).length === 3) {
|
||||
return `bearer ${token}`;
|
||||
}
|
||||
return `token ${token}`;
|
||||
}
|
||||
|
||||
// pkg/dist-src/hook.js
|
||||
async function hook(token, request, route, parameters) {
|
||||
const endpoint = request.endpoint.merge(
|
||||
route,
|
||||
parameters
|
||||
);
|
||||
endpoint.headers.authorization = withAuthorizationPrefix(token);
|
||||
return request(endpoint);
|
||||
}
|
||||
|
||||
// pkg/dist-src/index.js
|
||||
var createTokenAuth = function createTokenAuth2(token) {
|
||||
if (!token) {
|
||||
throw new Error("[@octokit/auth-token] No token passed to createTokenAuth");
|
||||
}
|
||||
if (typeof token !== "string") {
|
||||
throw new Error(
|
||||
"[@octokit/auth-token] Token passed to createTokenAuth is not a string"
|
||||
);
|
||||
}
|
||||
token = token.replace(/^(token|bearer) +/i, "");
|
||||
return Object.assign(auth.bind(null, token), {
|
||||
hook: hook.bind(null, token)
|
||||
});
|
||||
};
|
||||
export {
|
||||
createTokenAuth
|
||||
};
|
||||
Reference in New Issue
Block a user