File
Blob: src/cloudflare/internal/sockets.d.ts
| 1 | // Copyright (c) 2023 Cloudflare, Inc. |
| 2 | // Licensed under the Apache 2.0 license found in the LICENSE file or at: |
| 3 | // https://opensource.org/licenses/Apache-2.0 |
| 4 | |
| 5 | // Type definitions for c++ implementation. |
| 6 | |
| 7 | import { type ServiceStub } from 'cloudflare-internal:workers'; |
| 8 | |
| 9 | export class Socket { |
| 10 | readonly readable: unknown; |
| 11 | readonly writable: unknown; |
| 12 | readonly closed: Promise<void>; |
| 13 | close(): Promise<void>; |
| 14 | startTls(options: TlsOptions): Socket; |
| 15 | } |
| 16 | |
| 17 | export type TlsOptions = { |
| 18 | expectedServerHostname?: string; |
| 19 | }; |
| 20 | |
| 21 | export type SocketAddress = { |
| 22 | hostname: string; |
| 23 | port: number; |
| 24 | }; |
| 25 | |
| 26 | export type SocketOptions = { |
| 27 | secureTransport?: 'off' | 'on' | 'starttls'; |
| 28 | allowHalfOpen?: boolean; |
| 29 | }; |
| 30 | |
| 31 | export function connect( |
| 32 | address: string | SocketAddress, |
| 33 | options?: SocketOptions |
| 34 | ): Socket; |
| 35 | |
| 36 | export function internalNewHttpClient(socket: Socket): Promise<ServiceStub>; |