createOauthCallbackMarkerValue (supabase/oauth-callback-marker.ts)

sexyvoice · apps/web/lib/supabase/oauth-callback-marker.ts · typescript · Apache-2.0
auth, tag:embed-classified

Module exposing: createOauthCallbackMarkerValue, verifyOauthCallbackMarkerValue, OAUTH_CALLBACK_COOKIE_MAX_AGE_SECONDS, getOauthCallbackMarkerSecret, createOauthCallbackMarkerSignature

// Source: https://github.com/gianpaj/sexyvoice | License: Apache-2.0 | Copyright 2023 Vercel, Inc
// Provided via justclaw.it.com; keep this notice with the code.
import { createHmac, timingSafeEqual } from 'node:crypto';

import { OAUTH_CALLBACK_COOKIE_NAME } from './constants';

export const OAUTH_CALLBACK_COOKIE_MAX_AGE_SECONDS = 60;

function getOauthCallbackMarkerSecret(): string | null {
  return (
    process.env.OAUTH_CALLBACK_MARKER_SECRET ??
    process.env.API_KEY_HMAC_SECRET ??
    null
  );
}

function createOauthCallbackMarkerSignature(expiresAt: number): string | null {
  const secret = getOauthCallbackMarkerSecret();
  if (!secret) {
    return null;
  }

  return createHmac('sha256', secret)
    .update(`${OAUTH_CALLBACK_COOKIE_NAME}.${expiresAt}`)
    .digest('hex');
}



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

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

Get a free API key