| 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 GenerateMacEmvPinChangeRequest extends Omit< |
| 7 | paymentcryptographydata.GenerateMacEmvPinChangeInput, |
| 8 | | "NewPinPekIdentifier" |
| 9 | | "SecureMessagingIntegrityKeyIdentifier" |
| 10 | | "SecureMessagingConfidentialityKeyIdentifier" |
| 11 | > {} |
| 12 | |
| 13 | /** |
| 14 | * Runtime binding for `payment-cryptography:GenerateMacEmvPinChange` — |
| 15 | * generates the issuer-script MAC (and re-encrypted PIN block) for an EMV |
| 16 | * PIN change command. Binds three {@link Key}s: the new PIN encryption key |
| 17 | * (PEK) the changed PIN is encrypted under, and the secure-messaging |
| 18 | * integrity and confidentiality issuer master keys. Provide |
| 19 | * `GenerateMacEmvPinChangeHttp` on the Function to satisfy this service. |
| 20 | * ### EMV PIN Change |
| 21 | * **Example:** Generate the issuer-script MAC for a PIN change |
| 22 | * ```typescript |
| 23 | * // init |
| 24 | * const generatePinChangeMac = yield* PaymentCryptography.GenerateMacEmvPinChange( |
| 25 | * newPinPek, |
| 26 | * secureMessagingIntegrityKey, |
| 27 | * secureMessagingConfidentialityKey, |
| 28 | * ); |
| 29 | * |
| 30 | * // runtime |
| 31 | * const result = yield* generatePinChangeMac({ |
| 32 | * NewEncryptedPinBlock: newEncryptedPinBlock, |
| 33 | * PinBlockFormat: "ISO_FORMAT_0", |
| 34 | * MessageData: messageDataHex, |
| 35 | * DerivationMethodAttributes: { Emv2000: { ... } }, |
| 36 | * }); |
| 37 | * ``` |
| 38 | * |
| 39 | * @binding |
| 40 | */ |
| 41 | export interface GenerateMacEmvPinChange extends Binding.Service< |
| 42 | GenerateMacEmvPinChange, |
| 43 | "AWS.PaymentCryptography.GenerateMacEmvPinChange", |
| 44 | <P extends Key, I extends Key, C extends Key>( |
| 45 | newPinPek: P, |
| 46 | secureMessagingIntegrityKey: I, |
| 47 | secureMessagingConfidentialityKey: C, |
| 48 | ) => Effect.Effect< |
| 49 | ( |
| 50 | request: GenerateMacEmvPinChangeRequest, |
| 51 | ) => Effect.Effect< |
| 52 | paymentcryptographydata.GenerateMacEmvPinChangeOutput, |
| 53 | paymentcryptographydata.GenerateMacEmvPinChangeError |
| 54 | > |
| 55 | > |
| 56 | > {} |
| 57 | |
| 58 | export const GenerateMacEmvPinChange = Binding.Service<GenerateMacEmvPinChange>( |
| 59 | "AWS.PaymentCryptography.GenerateMacEmvPinChange", |
| 60 | ); |