1import * as Cloudflare from "@/Cloudflare";
2import * as Effect from "effect/Effect";
3import * as Redacted from "effect/Redacted";
4
5/**
6 * Hard-coded secret value the integ test asserts against to prove the
7 * Secret flows through the Worker's `env` async binding all the way to
8 * the runtime `SecretsStoreSecret.get()`.
9 */
10export const SECRET_VALUE = "sk-async-binding-secret-value";
11
12export const Store = Cloudflare.SecretsStore.Store("AsyncSecretBindingStore");
13
14/**
15 * A Secret in the store. Resolving it inside an Effect lets us declare it
16 * directly on a Worker's `env`, which is the path under test — the Worker
17 * provider must map it to a `secrets_store_secret` binding.
18 */
19export const ApiKey = Effect.gen(function* () {
20 const store = yield* Store;
21 return yield* Cloudflare.SecretsStore.Secret("AsyncBindingApiKey", {
22 store,
23 value: Redacted.make(SECRET_VALUE),
24 });
25});