Skip to content
← Public packages

@kody/github

Call GitHub REST, GraphQL, and pull requests with a GitHub OAuth App or a personal access token.

src/get-viewer.ts

18 lines · 747 B · TypeScript
import type { GitHubAuthInput } from "./types"
export { getViewer } from "./core"
import { getViewer } from "./core"

/**
 * Verify which GitHub identity the selected OAuth integration or PAT resolves to.
 *
 * @param params.integrationName - Saved OAuth integration; defaults to `github`.
 * @param params.secretName - PAT secret name; when set, uses the PAT lane.
 * @returns Viewer login, id, type, and profile URLs.
 * @example
 * import getGithubViewer from 'kody:@kody/github/get-viewer'
 * const viewer = await getGithubViewer()
 * // => { auth: { mode: 'oauth', integrationName: 'github', ... }, login: 'octocat', id: 1 }
 */
export default async function getGithubViewer(params: GitHubAuthInput = {}) {
  return await getViewer(params)
}