(
options: Tls.ConnectionOptions & {
readonly openTimeout?: Duration.Input | undefined
/**
* Maximum chunks per pull. Defaults to 4096 unless a positive safe integer or Infinity is supplied.
* Use Infinity for unbounded batching.
*/
readonly chunkSize?: number | undefined
}
)
| 594 | * @since 4.0.0 |
| 595 | */ |
| 596 | export const makeTls = ( |
| 597 | options: Tls.ConnectionOptions & { |
| 598 | readonly openTimeout?: Duration.Input | undefined |
| 599 | /** |
| 600 | * Maximum chunks per pull. Defaults to 4096 unless a positive safe integer or Infinity is supplied. |
| 601 | * Use Infinity for unbounded batching. |
| 602 | */ |
| 603 | readonly chunkSize?: number | undefined |
| 604 | } |
| 605 | ): Effect.Effect<Socket.Socket> => |
| 606 | fromDuplex( |
| 607 | Effect.contextWith((context: Context.Context<Scope.Scope>) => { |
| 608 | let conn: Tls.TLSSocket | undefined |
| 609 | let isOpen = false |
| 610 | return Effect.flatMap( |
| 611 | Scope.addFinalizer( |
| 612 | Context.get(context, Scope.Scope), |
| 613 | Effect.sync(() => { |
| 614 | if (!conn) return |
| 615 | closeSocket(conn, isOpen) |
| 616 | }) |
| 617 | ), |
| 618 | () => |
| 619 | Effect.callback<Tls.TLSSocket, Socket.SocketError, never>((resume) => { |
| 620 | conn = Tls.connect(options) |
| 621 | conn.once("secureConnect", () => { |
| 622 | isOpen = true |
| 623 | resume(Effect.succeed(conn!)) |
| 624 | }) |
| 625 | conn.on("error", (cause: Error) => { |
| 626 | resume(Effect.fail( |
| 627 | new Socket.SocketError({ |
| 628 | reason: new Socket.SocketOpenError({ kind: "Unknown", cause }) |
| 629 | }) |
| 630 | )) |
| 631 | }) |
| 632 | }) |
| 633 | ) |
| 634 | }), |
| 635 | options |
| 636 | ) |
| 637 | |
| 638 | /** |
| 639 | * Creates a `Channel` over a TLS socket, reading arrays of `Uint8Array` |
no test coverage detected