import * as SecretsStore from "@distilled.cloud/cloudflare/secrets-store"; import * as workers from "@distilled.cloud/cloudflare/workers"; import * as Effect from "effect/Effect"; import * as Layer from "effect/Layer"; import * as HttpClient from "effect/unstable/http/HttpClient"; import * as Config from "effect/Config"; import { AlchemyContext } from "../../AlchemyContext.ts"; import { AuthError } from "../../Auth/AuthProvider.ts"; import { CredentialsStore } from "../../Auth/Credentials.ts"; import * as Output from "../../Output.ts"; import { State, type StateService } from "../../State/State.ts"; import * as Access from "../Access.ts"; import * as CloudflareEnvironment from "../CloudflareEnvironment.ts"; import { type StoredStateStoreCredentials } from "./CredentialsFile.ts"; export declare const state: () => Layer.Layer; export interface BootstrapOptions { /** @default "alchemy-state-store" */ workerName?: string; /** @default false */ force?: boolean; /** @default "default" */ profile?: string; } export declare const bootstrap: (options?: BootstrapOptions) => Effect.Effect; export interface TeardownOptions { /** @default "alchemy-state-store" */ workerName?: string; /** @default "default" */ profile?: string; /** * Delete the account Secrets Store too, but only once the state-store * secrets have been removed and no other secrets remain in it. A store that * still holds foreign secrets is left in place. * @default true */ deleteEmptySecretsStore?: boolean; } /** * The inverse of {@link bootstrap}: tear down the Cloudflare-deployed state * store. Deletes the state-store Worker and the secrets it created in the * account Secrets Store (the bearer token + the encryption key), then deletes * the Secrets Store itself if it is left empty, and drops the locally cached * state-store credentials for the profile. * * Idempotent — missing resources are treated as already-gone, so it is safe to * re-run. Intended for reclaiming a throwaway account after testing; on a * shared account it only removes resources alchemy created. */ export declare const teardownStateStore: (options?: TeardownOptions) => Effect.Effect; /** * Writes against a *just-deployed* state-store worker can fail * transiently while Cloudflare propagates the script, its route, and * its Secrets Store bindings to the edge: * * - 404 — the workers.dev route isn't serving the new script yet * - 401 — the worker is up but its auth-token secret binding hasn't * propagated, so token validation reads a stale/absent value * - 5xx — the Store DO dies while its encryption-key secret binding * is still propagating * - transport errors (no response) — cold workers.dev host blips * * @internal exported for unit testing. */ export declare const isTransientBootstrapWriteError: (error: { cause?: unknown; }) => boolean; /** * Log in to a Cloudflare-deployed HTTP state-store. * * 1. Find the single account-wide Secrets Store. * 2. Upload a short-lived edge-preview worker that binds the * auth-token secret and returns its value. * 3. Derive the state-store worker URL from * {@link STATE_STORE_SCRIPT_NAME} and the account's workers.dev * subdomain. * 4. Persist `{ url, token }` under the `http-state-store` * credentials file. * * Requirements are covered by the Cloudflare provider stack — * `CloudflareEnvironment`, `Credentials`, `HttpClient`, and * `FileSystem`. */ export declare const loginWithCloudflare: (profileName: string, force: boolean) => Effect.Effect; declare class StateStoreVersionNotReady extends Error { readonly expected: number; readonly observed: number | undefined; readonly _tag = "StateStoreVersionNotReady"; constructor(expected: number, observed: number | undefined); } /** * Edge-preview reads are flaky in ways that clear up on their own: * the workers.dev edge can serve a generic Cloudflare 400/502 HTML * page while preview routing propagates ("Secret probe returned * ..."), the session-create call can hit transient API blips, and the * probe fetch can fail at the transport level ("fetch failed"). * Retry everything except causes that are clearly permanent * (bad credentials, invalid routes). * * @internal exported for unit testing. */ export declare const isTransientEdgeSessionError: (error: unknown) => boolean; export {}; //# sourceMappingURL=State.d.ts.map