| 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 GeneratePinDataRequest extends Omit< |
| 7 | paymentcryptographydata.GeneratePinDataInput, |
| 8 | "GenerationKeyIdentifier" | "EncryptionKeyIdentifier" |
| 9 | > {} |
| 10 | |
| 11 | /** |
| 12 | * Runtime binding for `payment-cryptography:GeneratePinData` — generates |
| 13 | * PIN-related data (PIN, PVV, PIN block) under a PIN generation {@link Key} |
| 14 | * (e.g. a Visa PVK) and returns the PIN block encrypted under a PIN |
| 15 | * encryption {@link Key} (PEK). Provide `GeneratePinDataHttp` on the |
| 16 | * Function to satisfy this service. |
| 17 | * ### PIN Data |
| 18 | * **Example:** Generate a Visa PIN + PVV |
| 19 | * ```typescript |
| 20 | * // init |
| 21 | * const generatePin = yield* PaymentCryptography.GeneratePinData(pvk, pek); |
| 22 | * |
| 23 | * // runtime |
| 24 | * const generated = yield* generatePin({ |
| 25 | * GenerationAttributes: { VisaPin: { PinVerificationKeyIndex: 1 } }, |
| 26 | * PrimaryAccountNumber: "9123456789012345", |
| 27 | * PinBlockFormat: "ISO_FORMAT_0", |
| 28 | * }); |
| 29 | * // generated.EncryptedPinBlock + generated.PinData.VerificationValue |
| 30 | * ``` |
| 31 | * |
| 32 | * @binding |
| 33 | */ |
| 34 | export interface GeneratePinData extends Binding.Service< |
| 35 | GeneratePinData, |
| 36 | "AWS.PaymentCryptography.GeneratePinData", |
| 37 | <G extends Key, E extends Key>( |
| 38 | generationKey: G, |
| 39 | encryptionKey: E, |
| 40 | ) => Effect.Effect< |
| 41 | ( |
| 42 | request: GeneratePinDataRequest, |
| 43 | ) => Effect.Effect< |
| 44 | paymentcryptographydata.GeneratePinDataOutput, |
| 45 | paymentcryptographydata.GeneratePinDataError |
| 46 | > |
| 47 | > |
| 48 | > {} |
| 49 | |
| 50 | export const GeneratePinData = Binding.Service<GeneratePinData>( |
| 51 | "AWS.PaymentCryptography.GeneratePinData", |
| 52 | ); |