| 1 | import type * as signer from "@distilled.cloud/aws/signer"; |
| 2 | import type * as Effect from "effect/Effect"; |
| 3 | import * as Binding from "../../Binding.ts"; |
| 4 | import type { SigningProfile } from "./SigningProfile.ts"; |
| 5 | |
| 6 | /** |
| 7 | * Runtime binding for `signer:SignPayload`. |
| 8 | * |
| 9 | * Signs a binary payload synchronously with the bound {@link SigningProfile} |
| 10 | * and returns the signature inline — the API behind Notation container-image |
| 11 | * signing (use a `Notation-OCI-SHA384-ECDSA` profile). The profile name is |
| 12 | * injected from the binding. Provide the implementation with |
| 13 | * `Effect.provide(AWS.Signer.SignPayloadHttp)`. |
| 14 | * ### Signing Code |
| 15 | * **Example:** Sign a Notation Payload |
| 16 | * ```typescript |
| 17 | * // init — bind the operation to the Notation profile |
| 18 | * const signPayload = yield* AWS.Signer.SignPayload(profile); |
| 19 | * |
| 20 | * // runtime |
| 21 | * const { jobId, signature } = yield* signPayload({ |
| 22 | * payload: new TextEncoder().encode(JSON.stringify(notaryPayload)), |
| 23 | * payloadFormat: "application/vnd.cncf.notary.payload.v1+json", |
| 24 | * }); |
| 25 | * ``` |
| 26 | * |
| 27 | * @binding |
| 28 | */ |
| 29 | export interface SignPayload extends Binding.Service< |
| 30 | SignPayload, |
| 31 | "AWS.Signer.SignPayload", |
| 32 | ( |
| 33 | profile: SigningProfile, |
| 34 | ) => Effect.Effect< |
| 35 | ( |
| 36 | request: Omit<signer.SignPayloadRequest, "profileName">, |
| 37 | ) => Effect.Effect<signer.SignPayloadResponse, signer.SignPayloadError> |
| 38 | > |
| 39 | > {} |
| 40 | export const SignPayload = Binding.Service<SignPayload>( |
| 41 | "AWS.Signer.SignPayload", |
| 42 | ); |