The best way to control Claude Code, Codex and more from any computer or phone

main
ts 54 lines 1.81 KB
Raw
1 import * as ACME from "@alchemy.run/acme";
2 import * as Cloudflare from "@alchemy.run/cloudflare";
3 import * as ZeroSsl from "@distilled.cloud/zerossl";
4 import * as AdoptPolicy from "alchemy/AdoptPolicy";
5 import * as Output from "alchemy/Output";
6 import { retain } from "alchemy/RemovalPolicy";
7 import * as Effect from "effect/Effect";
8 import * as FetchHttpClient from "effect/http/FetchHttpClient";
9 import * as Layer from "effect/Layer";
10
11 export const ZONE_NAME = "alchemy-test-2.us";
12
13 /** The standing test zone, adopted (never deleted on destroy). */
14 export const Zone = Cloudflare.Zone.Zone("AcmeZone", {
15 name: ZONE_NAME,
16 }).pipe(AdoptPolicy.adopt(), retain());
17
18 export const Staging = ACME.Account("Staging", {
19 ca: ACME.LetsEncryptStaging,
20 contact: ["mailto:ops@alchemy.run"],
21 termsOfServiceAgreed: true,
22 });
23
24 /**
25 * External Account Binding minted from `ZERO_SSL_KEY` when the stack is
26 * evaluated. Only `newAccount` consumes it; later deploys reuse the account.
27 *
28 * Minted once and cached: each prop below evaluates the effect, and the
29 * pair must match. Props resolve `Output`s and `Config`s, not bare Effects,
30 * so each half is lifted with `Output.fromEffect`.
31 */
32 const zeroSslEab = Effect.runSync(
33 Effect.cached(
34 ZeroSsl.zerossl
35 .generateEabCredentials({})
36 .pipe(
37 Effect.provide(Layer.mergeAll(ZeroSsl.CredentialsFromEnv, FetchHttpClient.layer)),
38 Effect.orDie,
39 ),
40 ),
41 );
42
43 /**
44 * Let's Encrypt staging returned TLS errors from Workers during bring-up;
45 * the deployed-Worker test uses ZeroSSL.
46 */
47 export const ZeroSSLAccount = ACME.Account("ZeroSSL", {
48 ca: ACME.ZeroSSL,
49 eab: {
50 keyId: Output.fromEffect(zeroSslEab.pipe(Effect.map((eab) => eab.eab_kid!))),
51 hmacKey: Output.fromEffect(zeroSslEab.pipe(Effect.map((eab) => eab.eab_hmac_key!))),
52 },
53 termsOfServiceAgreed: true,
54 });