import { Credentials, type ResolvedCredentials } from "@distilled.cloud/cloudflare/Credentials"; import * as Config from "effect/Config"; import * as Effect from "effect/Effect"; import * as Layer from "effect/Layer"; import { AlchemyProfile } from "../Auth/Profile.ts"; export { Credentials, fromEnv } from "@distilled.cloud/cloudflare/Credentials"; declare module "@distilled.cloud/cloudflare/Credentials" { interface Credentials { readonly kind: "Credentials"; } } /** * Memoize a credentials-resolution effect until shortly before the resolved * credentials expire. * * The distilled HTTP client resolves the `Credentials` service's effect on * *every* request (`yield* config.credentials`), which is what allows OAuth * tokens to rotate mid-process — a dev session can outlive the ~1h access * token, so caching the first resolution forever leaves the process making * API calls with a dead token until restart. At the same time, resolution * acquires a cross-process file lock (`auth.read`), so resolving fresh on * every request would stampede that lock under high concurrency (e.g. * `unsafe nuke`). * * This cache serves both needs: callers get the cached credentials while * they are still valid, the resolver re-runs (refreshing + persisting the * token) once the refresh window is reached, and a mutex makes resolution * single-flight so concurrent callers share one lock acquisition. */ export declare const cacheUntilExpiry: (resolve: Effect.Effect, now?: () => number) => Effect.Effect; /** * Build a `Credentials` layer that resolves Cloudflare credentials via the * Alchemy AuthProvider using the configured profile (defaults to "default", * overridable with the `ALCHEMY_PROFILE` env/config value). */ export declare const fromAuthProvider: () => Layer.Layer; //# sourceMappingURL=Credentials.d.ts.map