16 lines
421 B
JavaScript
16 lines
421 B
JavaScript
import { isJWT } from "./is-jwt.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
|
|
};
|
|
}
|
|
export {
|
|
auth
|
|
};
|