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 { ValidateAttestation, type ValidateAttestationRequest } from "./ValidateAttestation.ts"; |
| 8 | |
| 9 | /** |
| 10 | * HTTP implementation of {@link ValidateAttestation}. |
| 11 | * |
| 12 | * @layer |
| 13 | * @provides GCP.BinaryAuthorization.ValidateAttestation |
| 14 | */ |
| 15 | export const ValidateAttestationHttp = Layer.effect( |
| 16 | ValidateAttestation, |
| 17 | Effect.gen(function* () { |
| 18 | const bind = yield* GCPBindings.Bind; |
| 19 | const validate = yield* GCPBindings.withCredentials( |
| 20 | binaryauthorization.validateAttestationOccurrenceProjectsAttestors, |
| 21 | ); |
| 22 | return Effect.fn(function* (attestor: Attestor) { |
| 23 | if (!globalThis.__ALCHEMY_RUNTIME__) { |
| 24 | yield* bind`GCP.BinaryAuthorization.ValidateAttestation(${attestor})`({ |
| 25 | iam: [ |
| 26 | grantFor( |
| 27 | { |
| 28 | role: "roles/binaryauthorization.attestorsVerifier", |
| 29 | on: "binaryauthorization.attestor", |
| 30 | }, |
| 31 | attestor.name, |
| 32 | ), |
| 33 | ], |
| 34 | }); |
| 35 | } |
| 36 | const project = yield* attestor.project; |
| 37 | const attestorId = yield* attestor.attestorId; |
| 38 | const noteReference = yield* attestor.noteReference; |
| 39 | return Effect.fn(`GCP.BinaryAuthorization.ValidateAttestation(${attestor.LogicalId})`)( |
| 40 | function* (request: ValidateAttestationRequest) { |
| 41 | const projectId = yield* project; |
| 42 | const id = yield* attestorId; |
| 43 | const occurrenceNote = request.occurrenceNote ?? (yield* noteReference); |
| 44 | return yield* validate({ |
| 45 | attestor: `projects/${projectId}/attestors/${id}`, |
| 46 | body: { |
| 47 | occurrenceResourceUri: request.occurrenceResourceUri, |
| 48 | occurrenceNote, |
| 49 | attestation: request.attestation, |
| 50 | }, |
| 51 | }); |
| 52 | }, |
| 53 | ); |
| 54 | }); |
| 55 | }), |
| 56 | ); |