| 1 | import type * as paymentcryptographydata from "@distilled.cloud/aws/payment-cryptography-data"; |
| 2 | import type * as Effect from "effect/Effect"; |
| 3 | import * as Binding from "../../Binding.ts"; |
| 4 | import type { Key } from "./Key.ts"; |
| 5 | |
| 6 | export interface VerifyMacRequest extends Omit< |
| 7 | paymentcryptographydata.VerifyMacInput, |
| 8 | "KeyIdentifier" |
| 9 | > {} |
| 10 | |
| 11 | /** |
| 12 | * Runtime binding for `payment-cryptography:VerifyMac` — verifies a Message |
| 13 | * Authentication Code against hex-encoded message data under a {@link Key}. |
| 14 | * A mismatched MAC fails with the typed `VerificationFailedException`. |
| 15 | * Provide `VerifyMacHttp` on the Function to satisfy this service. |
| 16 | * ### Verifying MACs |
| 17 | * **Example:** Verify an HMAC |
| 18 | * ```typescript |
| 19 | * // init |
| 20 | * const verifyMac = yield* PaymentCryptography.VerifyMac(macKey); |
| 21 | * |
| 22 | * // runtime — MessageData and Mac are hex-encoded |
| 23 | * yield* verifyMac({ |
| 24 | * MessageData: "31323334353637383930313233343536", |
| 25 | * Mac: mac, |
| 26 | * VerificationAttributes: { Algorithm: "HMAC" }, |
| 27 | * }); |
| 28 | * ``` |
| 29 | * |
| 30 | * @binding |
| 31 | */ |
| 32 | export interface VerifyMac extends Binding.Service< |
| 33 | VerifyMac, |
| 34 | "AWS.PaymentCryptography.VerifyMac", |
| 35 | <K extends Key>( |
| 36 | key: K, |
| 37 | ) => Effect.Effect< |
| 38 | ( |
| 39 | request: VerifyMacRequest, |
| 40 | ) => Effect.Effect< |
| 41 | paymentcryptographydata.VerifyMacOutput, |
| 42 | paymentcryptographydata.VerifyMacError |
| 43 | > |
| 44 | > |
| 45 | > {} |
| 46 | |
| 47 | export const VerifyMac = Binding.Service<VerifyMac>( |
| 48 | "AWS.PaymentCryptography.VerifyMac", |
| 49 | ); |