The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import type * as kms from "@distilled.cloud/aws/kms"; |
| 2 | import * as Binding from "alchemy/Binding"; |
| 3 | import type * as Effect from "effect/Effect"; |
| 4 | import type { AliasName } from "./Alias.ts"; |
| 5 | import type { Key } from "./Key.ts"; |
| 6 | |
| 7 | export interface DeriveSharedSecretRequest extends Omit<kms.DeriveSharedSecretRequest, "KeyId"> {} |
| 8 | |
| 9 | /** |
| 10 | * Runtime binding for `kms:DeriveSharedSecret`. |
| 11 | * |
| 12 | * Bind this operation to a KEY_AGREEMENT KMS {@link Key} (or the `alias/...` |
| 13 | * name of a pre-existing key) to get a callable that automatically injects |
| 14 | * the `KeyId`. Runs ECDH between the bound key's private key (inside KMS) |
| 15 | * and a peer's public key, returning the raw shared secret for use with a |
| 16 | * key-derivation function. |
| 17 | * |
| 18 | * The `SharedSecret` in the response is wrapped in `Redacted` so it never |
| 19 | * leaks into logs — unwrap with `Redacted.value(...)` at the point of use. |
| 20 | * |
| 21 | * ### Key Agreement |
| 22 | * **Example:** Derive a Shared Secret |
| 23 | * ```typescript |
| 24 | * const deriveSharedSecret = yield* AWS.KMS.DeriveSharedSecret(agreementKey); |
| 25 | * |
| 26 | * const { SharedSecret } = yield* deriveSharedSecret({ |
| 27 | * KeyAgreementAlgorithm: "ECDH", |
| 28 | * PublicKey: peerPublicKeyDer, // DER-encoded SubjectPublicKeyInfo |
| 29 | * }); |
| 30 | * ``` |
| 31 | * |
| 32 | * @binding |
| 33 | */ |
| 34 | export interface DeriveSharedSecret extends Binding.Service< |
| 35 | DeriveSharedSecret, |
| 36 | "AWS.KMS.DeriveSharedSecret", |
| 37 | ( |
| 38 | key: Key | AliasName, |
| 39 | ) => Effect.Effect< |
| 40 | ( |
| 41 | request: DeriveSharedSecretRequest, |
| 42 | ) => Effect.Effect<kms.DeriveSharedSecretResponse, kms.DeriveSharedSecretError> |
| 43 | > |
| 44 | > {} |
| 45 | |
| 46 | export const DeriveSharedSecret = Binding.Service<DeriveSharedSecret>("AWS.KMS.DeriveSharedSecret"); |