The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 04:45 UTC
| 1 | import * as paymentcryptographydata from "@distilled.cloud/aws/payment-cryptography-data"; |
| 2 | import * as Effect from "effect/Effect"; |
| 3 | import * as Layer from "effect/Layer"; |
| 4 | import * as AWSBindings from "../AWSBindings.ts"; |
| 5 | import { |
| 6 | GenerateMacEmvPinChange, |
| 7 | type GenerateMacEmvPinChangeRequest, |
| 8 | } from "./GenerateMacEmvPinChange.ts"; |
| 9 | import type { Key } from "./Key.ts"; |
| 10 | |
| 11 | /** |
| 12 | * HTTP implementation of {@link GenerateMacEmvPinChange} — bespoke (not |
| 13 | * scaffolded): the operation spans three keys (the new PIN PEK plus the |
| 14 | * secure-messaging integrity and confidentiality keys). Grants the host |
| 15 | * Function `payment-cryptography:GenerateMacEmvPinChange` on all three key |
| 16 | * ARNs and injects each identifier at runtime. |
| 17 | */ |
| 18 | export const GenerateMacEmvPinChangeHttp = Layer.effect( |
| 19 | GenerateMacEmvPinChange, |
| 20 | Effect.gen(function* () { |
| 21 | const bind = yield* AWSBindings.Bind; |
| 22 | const generateMacEmvPinChange = yield* AWSBindings.withCredentials( |
| 23 | paymentcryptographydata.generateMacEmvPinChange, |
| 24 | ); |
| 25 | |
| 26 | return Effect.fn(function* <P extends Key, I extends Key, C extends Key>( |
| 27 | newPinPek: P, |
| 28 | secureMessagingIntegrityKey: I, |
| 29 | secureMessagingConfidentialityKey: C, |
| 30 | ) { |
| 31 | const NewPinPekArn = yield* newPinPek.keyArn; |
| 32 | const IntegrityKeyArn = yield* secureMessagingIntegrityKey.keyArn; |
| 33 | const ConfidentialityKeyArn = yield* secureMessagingConfidentialityKey.keyArn; |
| 34 | if (!globalThis.__ALCHEMY_RUNTIME__) { |
| 35 | for (const key of [ |
| 36 | newPinPek, |
| 37 | secureMessagingIntegrityKey, |
| 38 | secureMessagingConfidentialityKey, |
| 39 | ]) { |
| 40 | yield* bind`AWS.PaymentCryptography.GenerateMacEmvPinChange(${key})`({ |
| 41 | policyStatements: [ |
| 42 | { |
| 43 | Effect: "Allow", |
| 44 | Action: ["payment-cryptography:GenerateMacEmvPinChange"], |
| 45 | Resource: [key.keyArn], |
| 46 | }, |
| 47 | ], |
| 48 | }); |
| 49 | } |
| 50 | } |
| 51 | return Effect.fn(`AWS.PaymentCryptography.GenerateMacEmvPinChange(${newPinPek.LogicalId})`)( |
| 52 | function* (request: GenerateMacEmvPinChangeRequest) { |
| 53 | return yield* generateMacEmvPinChange({ |
| 54 | ...request, |
| 55 | NewPinPekIdentifier: yield* NewPinPekArn, |
| 56 | SecureMessagingIntegrityKeyIdentifier: yield* IntegrityKeyArn, |
| 57 | SecureMessagingConfidentialityKeyIdentifier: yield* ConfidentialityKeyArn, |
| 58 | }); |
| 59 | }, |
| 60 | ); |
| 61 | }); |
| 62 | }), |
| 63 | ); |