aws-delivlib
Version:
A fabulous library for defining continuous pipelines for building, testing and releasing code libraries.
32 lines (31 loc) • 957 B
JavaScript
import { Deprecation } from "deprecation";
import { getAppAuthentication } from "./get-app-authentication";
import { getInstallationAuthentication } from "./get-installation-authentication";
async function auth(state, authOptions) {
switch (authOptions.type) {
case "app":
return getAppAuthentication(state);
case "oauth":
state.log.warn(
// @ts-expect-error `log.warn()` expects string
new Deprecation(
`[@octokit/auth-app] {type: "oauth"} is deprecated. Use {type: "oauth-app"} instead`
)
);
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
};