chore: Update the sdk to match the rust and vica verse

This commit is contained in:
J H
2024-03-18 10:53:38 -06:00
parent 9715873007
commit 973284607d
27 changed files with 173 additions and 90 deletions

View File

@@ -59,12 +59,13 @@ type AddSslOptions = {
preferredExternalPort: number
addXForwardedHeaders: boolean | null /** default: false */
}
type Security = { secure: false; ssl: false } | { secure: true; ssl: boolean }
type Security = { ssl: boolean }
export type BindOptions = {
scheme: Scheme
preferredExternalPort: number
addSsl: AddSslOptions | null
} & Security
secure: Security | null
}
type KnownProtocols = typeof knownProtocols
type ProtocolsWithSslVariants = {
[K in keyof KnownProtocols]: KnownProtocols[K] extends {
@@ -79,14 +80,15 @@ type NotProtocolsWithSslVariants = Exclude<
>
type BindOptionsByKnownProtocol =
| ({
| {
protocol: ProtocolsWithSslVariants
preferredExternalPort?: number
preferredExternalPort: number | null
scheme: Scheme | null
} & ({ noAddSsl: true } | { addSsl?: Partial<AddSslOptions> }))
addSsl: Partial<AddSslOptions> | null
}
| {
protocol: NotProtocolsWithSslVariants
preferredExternalPort?: number
preferredExternalPort: number | null
scheme: Scheme | null
addSsl: AddSslOptions | null
}
@@ -120,17 +122,12 @@ export class Host {
private async bindPortForUnknown(
internalPort: number,
options:
| ({
scheme: Scheme
preferredExternalPort: number
addSsl: AddSslOptions | null
} & { secure: false; ssl: false })
| ({
scheme: Scheme
preferredExternalPort: number
addSsl: AddSslOptions | null
} & { secure: true; ssl: boolean }),
options: {
scheme: Scheme
preferredExternalPort: number
addSsl: AddSslOptions | null
secure: { ssl: boolean } | null
},
) {
await this.options.effects.bind({
kind: this.options.kind,
@@ -154,18 +151,13 @@ export class Host {
knownProtocols[options.protocol].defaultPort
const addSsl = this.getAddSsl(options, protoInfo)
const security: Security = !protoInfo.secure
? {
secure: protoInfo.secure,
ssl: protoInfo.ssl,
}
: { secure: false, ssl: false }
const secure: Security | null = !protoInfo.secure ? null : { ssl: false }
const newOptions = {
scheme,
preferredExternalPort,
addSsl,
...security,
secure,
}
await this.options.effects.bind({