1import { makeOAuthClient } from "../../Auth/OAuthFlow.ts";
2
3/**
4 * Alchemy's public Cloudflare OAuth client registration. The client is
5 * public (PKCE, no secret); rotating it invalidates previously stored
6 * credentials, which {@link usesCurrentClient} detects for a clean
7 * re-login.
8 */
9export const OAUTH_CLIENT_ID = "e7e25ec474419def6ba38d2d2638b122";
10export const OAUTH_REDIRECT_URI = "https://alchemy.run/auth/callback";
11export const OAUTH_LOCAL_CALLBACK_URI = "http://localhost:9976/auth/callback";
12export const OAUTH_ENDPOINTS = {
13 authorize: "https://dash.cloudflare.com/oauth2/auth",
14 token: "https://dash.cloudflare.com/oauth2/token",
15 revoke: "https://dash.cloudflare.com/oauth2/revoke",
16};
17
18export {
19 OAuthCredentials,
20 OAuthError,
21 type Authorization,
22} from "../../Auth/OAuthFlow.ts";
23
24/**
25 * Cloudflare's browser OAuth client: a public client using PKCE, with
26 * per-authorization scopes and a revocation endpoint. All flow mechanics
27 * live in the shared {@link makeOAuthClient} kit — this module only
28 * supplies Cloudflare's registration facts.
29 */
30const client = makeOAuthClient({
31 clientId: OAUTH_CLIENT_ID,
32 endpoints: OAUTH_ENDPOINTS,
33 redirectUri: OAUTH_REDIRECT_URI,
34 localCallbackUri: OAUTH_LOCAL_CALLBACK_URI,
35 auth: { kind: "pkce" },
36});
37
38export const {
39 authorize,
40 callback,
41 exchange,
42 exchangeCallbackInput,
43 refresh,
44 revoke,
45 usesCurrentClient,
46} = client;