| 1 | import type * as transfer from "@distilled.cloud/aws/transfer"; |
| 2 | import type * as Effect from "effect/Effect"; |
| 3 | import * as Binding from "../../Binding.ts"; |
| 4 | import type { Server } from "./Server.ts"; |
| 5 | |
| 6 | /** |
| 7 | * Runtime binding for `transfer:TestIdentityProvider`. |
| 8 | * |
| 9 | * Exercises the bound {@link Server}'s custom identity provider |
| 10 | * (`API_GATEWAY`, `AWS_LAMBDA`, or `AWS_DIRECTORY_SERVICE`) with a user |
| 11 | * name and optional password, returning the provider's raw response and |
| 12 | * status code — the `ServerId` is injected from the binding. The password |
| 13 | * is `Redacted` end-to-end (distilled marks `UserPassword` sensitive). |
| 14 | * Calling it on a `SERVICE_MANAGED` server fails with the typed |
| 15 | * `InvalidRequestException`. Provide the implementation with |
| 16 | * `Effect.provide(AWS.Transfer.TestIdentityProviderHttp)`. |
| 17 | * ### Diagnosing Authentication |
| 18 | * **Example:** Test a User's Credentials |
| 19 | * ```typescript |
| 20 | * import * as Redacted from "effect/Redacted"; |
| 21 | * |
| 22 | * // init — bind the operation to the server |
| 23 | * const testIdentityProvider = yield* AWS.Transfer.TestIdentityProvider(server); |
| 24 | * |
| 25 | * // runtime |
| 26 | * const result = yield* testIdentityProvider({ |
| 27 | * UserName: "alice", |
| 28 | * UserPassword: Redacted.make("secret"), |
| 29 | * ServerProtocol: "SFTP", |
| 30 | * }); |
| 31 | * yield* Effect.log(`identity provider replied ${result.StatusCode}`); |
| 32 | * ``` |
| 33 | * |
| 34 | * @binding |
| 35 | */ |
| 36 | export interface TestIdentityProvider extends Binding.Service< |
| 37 | TestIdentityProvider, |
| 38 | "AWS.Transfer.TestIdentityProvider", |
| 39 | ( |
| 40 | server: Server, |
| 41 | ) => Effect.Effect< |
| 42 | ( |
| 43 | request: Omit<transfer.TestIdentityProviderRequest, "ServerId">, |
| 44 | ) => Effect.Effect< |
| 45 | transfer.TestIdentityProviderResponse, |
| 46 | transfer.TestIdentityProviderError |
| 47 | > |
| 48 | > |
| 49 | > {} |
| 50 | export const TestIdentityProvider = Binding.Service<TestIdentityProvider>( |
| 51 | "AWS.Transfer.TestIdentityProvider", |
| 52 | ); |