The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import * as ecr from "@distilled.cloud/aws/ecr"; |
| 2 | import * as Effect from "effect/Effect"; |
| 3 | import * as Layer from "effect/Layer"; |
| 4 | import * as AWSBindings from "../AWSBindings.ts"; |
| 5 | import { GetAuthorizationToken } from "./GetAuthorizationToken.ts"; |
| 6 | |
| 7 | /** |
| 8 | * HTTP implementation of {@link GetAuthorizationToken} over the ECR API. |
| 9 | * Registry-level (not repository-scoped): the token authorizes Docker |
| 10 | * `login` against the whole private registry, and `ecr:GetAuthorizationToken` |
| 11 | * supports no resource-level permissions, so the grant is on `"*"`. |
| 12 | */ |
| 13 | export const GetAuthorizationTokenHttp = Layer.effect( |
| 14 | GetAuthorizationToken, |
| 15 | Effect.gen(function* () { |
| 16 | const bind = yield* AWSBindings.Bind; |
| 17 | const op = yield* AWSBindings.withCredentials(ecr.getAuthorizationToken); |
| 18 | |
| 19 | return Effect.fn(function* () { |
| 20 | if (!globalThis.__ALCHEMY_RUNTIME__) { |
| 21 | yield* bind`AWS.ECR.GetAuthorizationToken()`({ |
| 22 | policyStatements: [ |
| 23 | { |
| 24 | Effect: "Allow", |
| 25 | Action: ["ecr:GetAuthorizationToken"], |
| 26 | Resource: ["*"], |
| 27 | }, |
| 28 | ], |
| 29 | }); |
| 30 | } |
| 31 | return Effect.fn("AWS.ECR.GetAuthorizationToken")(function* () { |
| 32 | return yield* op({}); |
| 33 | }); |
| 34 | }); |
| 35 | }), |
| 36 | ); |