| 1 | import * as paymentcryptographydata from "@distilled.cloud/aws/payment-cryptography-data"; |
| 2 | import * as Layer from "effect/Layer"; |
| 3 | import { makePaymentCryptographyKeyHttpBinding } from "./BindingHttp.ts"; |
| 4 | import { GenerateMac } from "./GenerateMac.ts"; |
| 5 | |
| 6 | /** |
| 7 | * HTTP implementation of {@link GenerateMac} — grants the host Function |
| 8 | * `payment-cryptography:GenerateMac` on the key and calls the |
| 9 | * Payment Cryptography Data API at runtime. |
| 10 | * @example Provide on a Lambda Function |
| 11 | * ```typescript |
| 12 | * Effect.gen(function* () { |
| 13 | * const macKey = yield* PaymentCryptography.Key("MacKey", { |
| 14 | * keyAttributes: { |
| 15 | * keyAlgorithm: "HMAC_SHA256", |
| 16 | * keyClass: "SYMMETRIC_KEY", |
| 17 | * keyUsage: "TR31_M7_HMAC_KEY", |
| 18 | * keyModesOfUse: { generate: true, verify: true }, |
| 19 | * }, |
| 20 | * }); |
| 21 | * const generateMac = yield* PaymentCryptography.GenerateMac(macKey); |
| 22 | * |
| 23 | * return { |
| 24 | * fetch: Effect.gen(function* () { |
| 25 | * const generated = yield* generateMac({ |
| 26 | * MessageData: messageDataHex, |
| 27 | * GenerationAttributes: { Algorithm: "HMAC" }, |
| 28 | * }); |
| 29 | * // ... |
| 30 | * }), |
| 31 | * }; |
| 32 | * }).pipe(Effect.provide(PaymentCryptography.GenerateMacHttp)) |
| 33 | * ``` |
| 34 | */ |
| 35 | export const GenerateMacHttp = Layer.effect( |
| 36 | GenerateMac, |
| 37 | makePaymentCryptographyKeyHttpBinding({ |
| 38 | tag: "AWS.PaymentCryptography.GenerateMac", |
| 39 | operation: paymentcryptographydata.generateMac, |
| 40 | actions: ["payment-cryptography:GenerateMac"], |
| 41 | }), |
| 42 | ); |