| 1 | import * as GCP from "@/GCP"; |
| 2 | import * as Effect from "effect/Effect"; |
| 3 | import { serveProbes } from "../../bindingHost.ts"; |
| 4 | import { lifecycleAppId } from "../common.ts"; |
| 5 | |
| 6 | /** Debug token registered on the `GCP_TEST_FIREBASE_APP_ID` app. */ |
| 7 | export const Local = GCP.FirebaseAppCheck.AppsDebugToken("Local", { |
| 8 | app: lifecycleAppId ?? "", |
| 9 | displayName: "alchemy-exchange", |
| 10 | }); |
| 11 | |
| 12 | /** |
| 13 | * Effect-native Cloud Run service exercising every App Check binding as its |
| 14 | * own runtime service account. Deployed from {@link ../Bindings.test.ts}. |
| 15 | */ |
| 16 | export default class AppCheckBindingsHost extends GCP.Function<AppCheckBindingsHost>()( |
| 17 | "AppCheckBindingsHost", |
| 18 | { main: import.meta.url, invokerIamDisabled: true }, |
| 19 | Effect.gen(function* () { |
| 20 | const exchange = yield* GCP.FirebaseAppCheck.ExchangeDebugToken( |
| 21 | yield* Local, |
| 22 | ); |
| 23 | |
| 24 | return { |
| 25 | fetch: serveProbes({ |
| 26 | exchangeDebugToken: exchange(), |
| 27 | }), |
| 28 | }; |
| 29 | }).pipe(Effect.provide(GCP.FirebaseAppCheck.ExchangeDebugTokenHttp)), |
| 30 | ) {} |