githubOAuthRedirectUri (src/oauth.ts)

crabfleet · src/oauth.ts · typescript · MIT
auth, Auth / Identity

Utility functions for GitHub OAuth redirect URI validation and canonical URL generation.

// Source: https://github.com/openclaw/crabfleet | License: MIT | Copyright 2026 openclaw
// Provided via justclaw.it.com; keep this notice with the code.
import { isLiteralLoopbackHostname } from "./url-security.ts";

export const githubOAuthCallbackPath = "/auth/github/callback";
export const githubOAuthLoginPath = "/login/github";

export function githubOAuthRedirectUri(requestUrl: string | URL, configured?: string): string {
  if (configured !== undefined) return configuredGitHubOAuthRedirectUri(configured);
  const url = new URL(requestUrl);
  if (url.username || url.password)
    throw new Error("GitHub OAuth request URL cannot use credentials");
  if (
    url.protocol !== "https:" &&
    !(url.protocol === "http:" && isLiteralLoopbackHostname(url.hostname))
  ) {
    throw new Erro

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key