mirror of
https://github.com/github/codeql-action.git
synced 2025-12-31 03:30:14 +08:00
30 lines
746 B
JavaScript
30 lines
746 B
JavaScript
import { createOAuthUserAuth } from "@octokit/auth-oauth-user";
|
|
import { emitEvent } from "../emit-event.js";
|
|
async function getUserOctokitWithState(state, options) {
|
|
return state.octokit.auth({
|
|
type: "oauth-user",
|
|
...options,
|
|
async factory(options2) {
|
|
const octokit = new state.Octokit({
|
|
authStrategy: createOAuthUserAuth,
|
|
auth: options2
|
|
});
|
|
const authentication = await octokit.auth({
|
|
type: "get"
|
|
});
|
|
await emitEvent(state, {
|
|
name: "token",
|
|
action: "created",
|
|
token: authentication.token,
|
|
scopes: authentication.scopes,
|
|
authentication,
|
|
octokit
|
|
});
|
|
return octokit;
|
|
}
|
|
});
|
|
}
|
|
export {
|
|
getUserOctokitWithState
|
|
};
|