1import type * as kms from "@distilled.cloud/aws/kms";
2import type * as Effect from "effect/Effect";
3import * as Binding from "../../Binding.ts";
4import type { AliasName } from "./Alias.ts";
5import type { Key } from "./Key.ts";
6
7export interface GenerateMacRequest extends Omit<
8 kms.GenerateMacRequest,
9 "KeyId"
10> {}
11
12/**
13 * Runtime binding for `kms:GenerateMac`.
14 *
15 * Bind this operation to an HMAC KMS {@link Key} (or the `alias/...` name of
16 * a pre-existing key) to get a callable that automatically injects the
17 * `KeyId`. Computes an HMAC inside KMS — the MAC key never leaves the HSM,
18 * so any party with `kms:VerifyMac` can validate tokens without ever
19 * holding the shared secret.
20 *
21 * ### Message Authentication
22 * **Example:** Compute an HMAC
23 * ```typescript
24 * const generateMac = yield* AWS.KMS.GenerateMac(hmacKey);
25 *
26 * const { Mac } = yield* generateMac({
27 * Message: new TextEncoder().encode("session-token-payload"),
28 * MacAlgorithm: "HMAC_SHA_256",
29 * });
30 * ```
31 *
32 * @binding
33 */
34export interface GenerateMac extends Binding.Service<
35 GenerateMac,
36 "AWS.KMS.GenerateMac",
37 (
38 key: Key | AliasName,
39 ) => Effect.Effect<
40 (
41 request: GenerateMacRequest,
42 ) => Effect.Effect<kms.GenerateMacResponse, kms.GenerateMacError>
43 >
44> {}
45
46export const GenerateMac = Binding.Service<GenerateMac>("AWS.KMS.GenerateMac");