The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 06:00 UTC
| 1 | import { lazyCredentials } from "alchemy/Auth/Resolve"; |
| 2 | import * as Effect from "effect/Effect"; |
| 3 | import * as Layer from "effect/Layer"; |
| 4 | import { |
| 5 | CLOUDFLARE_AUTH_PROVIDER_NAME, |
| 6 | type CloudflareResolvedCredentials, |
| 7 | } from "./Auth/AuthConfig.ts"; |
| 8 | import { CloudflareEnvironment } from "./CloudflareEnvironmentService.ts"; |
| 9 | |
| 10 | export { CloudflareEnvironment } from "./CloudflareEnvironmentService.ts"; |
| 11 | |
| 12 | export const fromProfile = () => |
| 13 | Layer.effect( |
| 14 | CloudflareEnvironment, |
| 15 | // Building providers must work before Cloudflare is configured, so the |
| 16 | // credentials resolve on first use. They carry the OAuth access token, |
| 17 | // so cache only until it expires, like `Credentials.fromAuthProvider`. |
| 18 | // `CloudflareEnvironment` is typed as never failing, so a failure dies. |
| 19 | lazyCredentials<CloudflareResolvedCredentials>()( |
| 20 | CLOUDFLARE_AUTH_PROVIDER_NAME, |
| 21 | (creds) => creds, |
| 22 | { expiresAt: (creds) => (creds.type === "oauth" ? creds.expires : undefined) }, |
| 23 | ).pipe(Effect.map(Effect.orDie)), |
| 24 | ); |