1import type * as kms from "@distilled.cloud/gcp/cloudkms_v1";
2import type * as Effect from "effect/Effect";
3import * as Binding from "../../Binding.ts";
4import type { RuntimeContext } from "../../RuntimeContext.ts";
5import type { CryptoKey } from "./CryptoKey.ts";
6
7export interface DecryptRequest extends Omit<
8 kms.DecryptProjectsLocationsKeyRingsCryptoKeysRequest,
9 "name"
10> {}
11
12/**
13 * Runtime binding for Cloud KMS `cryptoKeys.decrypt`.
14 *
15 * Bind this operation to a {@link CryptoKey} in a Function/Action init
16 * phase. Provide {@link DecryptHttp}. The CryptoKey purpose must be
17 * `ENCRYPT_DECRYPT`.
18 *
19 * ### Decrypting Data
20 * **Example:** Decrypt a ciphertext
21 * ```typescript
22 * const decrypt = yield* GCP.KMS.Decrypt(key);
23 * const { plaintext } = yield* decrypt({
24 * body: { ciphertext },
25 * });
26 * ```
27 *
28 * @binding
29 * @category KMS
30 */
31export interface Decrypt extends Binding.Service<
32 Decrypt,
33 "GCP.KMS.Decrypt",
34 (
35 key: CryptoKey,
36 ) => Effect.Effect<
37 (
38 request?: DecryptRequest,
39 ) => Effect.Effect<
40 kms.DecryptResponse,
41 kms.DecryptProjectsLocationsKeyRingsCryptoKeysError,
42 RuntimeContext
43 >
44 >
45> {}
46
47export const Decrypt = Binding.Service<Decrypt>("GCP.KMS.Decrypt");