The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 06:00 UTC
| 1 | import * as binaryauthorization from "@distilled.cloud/gcp/binaryauthorization_v1"; |
| 2 | import * as Effect from "effect/Effect"; |
| 3 | import * as Layer from "effect/Layer"; |
| 4 | import * as GCPBindings from "../GCPBindings.ts"; |
| 5 | import { grantFor } from "../HttpBinding.ts"; |
| 6 | import type { Attestor } from "./Attestor.ts"; |
| 7 | import { GetAttestor, type GetAttestorRequest } from "./GetAttestor.ts"; |
| 8 | |
| 9 | /** |
| 10 | * HTTP implementation of {@link GetAttestor}. |
| 11 | * |
| 12 | * @layer |
| 13 | * @provides GCP.BinaryAuthorization.GetAttestor |
| 14 | */ |
| 15 | export const GetAttestorHttp = Layer.effect( |
| 16 | GetAttestor, |
| 17 | Effect.gen(function* () { |
| 18 | const bind = yield* GCPBindings.Bind; |
| 19 | const getAttestor = yield* GCPBindings.withCredentials( |
| 20 | binaryauthorization.getProjectsAttestors, |
| 21 | ); |
| 22 | return Effect.fn(function* (attestor: Attestor) { |
| 23 | if (!globalThis.__ALCHEMY_RUNTIME__) { |
| 24 | yield* bind`GCP.BinaryAuthorization.GetAttestor(${attestor})`({ |
| 25 | iam: [ |
| 26 | grantFor( |
| 27 | { |
| 28 | role: "roles/binaryauthorization.attestorsViewer", |
| 29 | on: "binaryauthorization.attestor", |
| 30 | }, |
| 31 | attestor.name, |
| 32 | ), |
| 33 | ], |
| 34 | }); |
| 35 | } |
| 36 | const name = yield* attestor.name; |
| 37 | return Effect.fn(`GCP.BinaryAuthorization.GetAttestor(${attestor.LogicalId})`)(function* ( |
| 38 | request?: GetAttestorRequest, |
| 39 | ) { |
| 40 | const attestorName = yield* name; |
| 41 | return yield* getAttestor({ |
| 42 | ...request, |
| 43 | name: attestorName, |
| 44 | }); |
| 45 | }); |
| 46 | }); |
| 47 | }), |
| 48 | ); |