mirror of
https://github.com/github/codeql-action.git
synced 2025-12-27 01:30:10 +08:00
24 lines
685 B
JavaScript
24 lines
685 B
JavaScript
import { getAppAuthentication } from "./get-app-authentication.js";
|
|
import { getInstallationAuthentication } from "./get-installation-authentication.js";
|
|
async function auth(state, authOptions) {
|
|
switch (authOptions.type) {
|
|
case "app":
|
|
return getAppAuthentication(state);
|
|
case "oauth-app":
|
|
return state.oauthApp({ type: "oauth-app" });
|
|
case "installation":
|
|
authOptions;
|
|
return getInstallationAuthentication(state, {
|
|
...authOptions,
|
|
type: "installation"
|
|
});
|
|
case "oauth-user":
|
|
return state.oauthApp(authOptions);
|
|
default:
|
|
throw new Error(`Invalid auth type: ${authOptions.type}`);
|
|
}
|
|
}
|
|
export {
|
|
auth
|
|
};
|