UNPKG

the-wireguard-effect

Version:

Cross platform wireguard api client for nodejs built on wireguard-go with effect-ts

1,083 lines 31.3 kB
/** * Internet schemas for wireguard configuration. * * @since 1.0.0 */ import * as Array from "effect/Array"; import * as Brand from "effect/Brand"; import * as Effect from "effect/Effect"; import * as ParseResult from "effect/ParseResult"; import * as Schema from "effect/Schema"; import * as Stream from "effect/Stream"; declare const DurationFromSeconds_base: Schema.transform<typeof Schema.Int, typeof Schema.DurationFromSelf>; /** * Transforms a `number` of seconds into a `Duration`. * * @since 1.0.0 * @category Schemas * @example * import * as Duration from "effect/Duration"; * import * as Schema from "effect/Schema"; * import { DurationFromSeconds } from "the-wireguard-effect/InternetSchemas"; * * const decodeDuration = Schema.decodeSync(DurationFromSeconds); * const duration = decodeDuration(11); * assert.strictEqual(Duration.toSeconds(duration), 11); */ export declare class DurationFromSeconds extends DurationFromSeconds_base { } declare const DurationFromSecondsString_base: Schema.transform<typeof Schema.NumberFromString, typeof DurationFromSeconds>; /** * Transforms a `string` of seconds into a `Duration`. * * @since 1.0.0 * @category Schemas * @example * import * as Duration from "effect/Duration"; * import * as Schema from "effect/Schema"; * import { DurationFromSecondsString } from "the-wireguard-effect/InternetSchemas"; * * const decodeDurationString = Schema.decodeSync( * DurationFromSecondsString * ); * const duration = decodeDurationString("12"); * assert.strictEqual(Duration.toSeconds(duration), 12); */ export declare class DurationFromSecondsString extends DurationFromSecondsString_base { } /** * @since 1.0.0 * @category Branded types */ export type PortBrand = number & Brand.Brand<"Port">; /** * @since 1.0.0 * @category Branded constructors */ export declare const PortBrand: Brand.Brand.Constructor<PortBrand>; /** * @since 1.0.0 * @category Api interface */ export type $Port = Schema.Annotable<$Port, PortBrand, Brand.Brand.Unbranded<PortBrand>, never>; /** * An operating system port number. * * @since 1.0.0 * @category Schemas * @example * import * as Schema from "effect/Schema"; * import { Port, PortBrand } from "the-wireguard-effect/InternetSchemas"; * * const port: PortBrand = PortBrand(8080); * assert.strictEqual(port, 8080); * * const decodePort = Schema.decodeSync(Port); * assert.strictEqual(decodePort(8080), 8080); * * assert.throws(() => decodePort(65536)); * assert.doesNotThrow(() => decodePort(8080)); */ export declare const Port: $Port; /** * @since 1.0.0 * @category Api interface */ export type $IPv4Family = Schema.Literal<["ipv4"]>; /** * @since 1.0.0 * @category Decoded types */ export type IPv4Family = Schema.Schema.Type<$IPv4Family>; /** * @since 1.0.0 * @category Schemas */ export declare const IPv4Family: $IPv4Family; /** * @since 1.0.0 * @category Branded types */ export type IPv4Brand = string & Brand.Brand<"IPv4">; /** * @since 1.0.0 * @category Branded constructors */ export declare const IPv4Brand: Brand.Brand.Constructor<IPv4Brand>; /** * @since 1.0.0 * @category Api interface */ export type $IPv4 = Schema.transform<Schema.filter<typeof Schema.String>, Schema.Struct<{ family: $IPv4Family; ip: Schema.BrandSchema<IPv4Brand, Brand.Brand.Unbranded<IPv4Brand>, never>; }>>; /** * @since 1.0.0 * @category Decoded types */ export type IPv4 = Schema.Schema.Type<$IPv4>; /** * @since 1.0.0 * @category Encoded types */ export type IPv4Encoded = Schema.Schema.Encoded<$IPv4>; /** * An IPv4 address. * * @since 1.0.0 * @category Schemas * @example * import * as Schema from "effect/Schema"; * import { IPv4 } from "the-wireguard-effect/InternetSchemas"; * * const decodeIPv4 = Schema.decodeSync(IPv4); * assert.deepEqual(decodeIPv4("1.1.1.1"), { * family: "ipv4", * ip: "1.1.1.1", * }); * * assert.throws(() => decodeIPv4("1.1.a.1")); * assert.doesNotThrow(() => decodeIPv4("1.1.1.2")); */ export declare const IPv4: $IPv4; /** * @since 1.0.0 * @category Branded types */ export type IPv4BigintBrand = bigint & Brand.Brand<"IPv4Bigint">; /** * @since 1.0.0 * @category Branded constructors */ export declare const IPv4BigintBrand: Brand.Brand.Constructor<IPv4BigintBrand>; /** * @since 1.0.0 * @category Api interface */ export type $IPv4Bigint = Schema.transformOrFail<$IPv4, Schema.Struct<{ family: $IPv4Family; value: Schema.BrandSchema<IPv4BigintBrand, Brand.Brand.Unbranded<IPv4BigintBrand>, never>; }>, never>; /** * @since 1.0.0 * @category Decoded types */ export type IPv4Bigint = Schema.Schema.Type<$IPv4Bigint>; /** * @since 1.0.0 * @category Encoded types */ export type IPv4BigintEncoded = Schema.Schema.Encoded<$IPv4Bigint>; /** * An IPv4 as a bigint. * * @since 1.0.0 * @category Schemas * @example * import * as Schema from "effect/Schema"; * import { * IPv4Bigint, * IPv4BigintBrand, * } from "the-wireguard-effect/InternetSchemas"; * * const x: IPv4BigintBrand = IPv4BigintBrand(748392749382n); * assert.strictEqual(x, 748392749382n); * * const decodeIPv4Bigint = Schema.decodeSync(IPv4Bigint); * const encodeIPv4Bigint = Schema.encodeSync(IPv4Bigint); * * assert.deepEqual(decodeIPv4Bigint("1.1.1.1"), { * family: "ipv4", * value: 16843009n, * }); * assert.deepEqual(decodeIPv4Bigint("254.254.254.254"), { * family: "ipv4", * value: 4278124286n, * }); * * assert.strictEqual( * encodeIPv4Bigint({ * value: IPv4BigintBrand(16843009n), * family: "ipv4", * }), * "1.1.1.1" * ); * assert.strictEqual( * encodeIPv4Bigint({ * value: IPv4BigintBrand(4278124286n), * family: "ipv4", * }), * "254.254.254.254" * ); */ export declare const IPv4Bigint: $IPv4Bigint; /** * @since 1.0.0 * @category Api interface */ export type $IPv6Family = Schema.Literal<["ipv6"]>; /** * @since 1.0.0 * @category Decoded types */ export type IPv6Family = Schema.Schema.Type<$IPv6Family>; /** * @since 1.0.0 * @category Schemas */ export declare const IPv6Family: $IPv6Family; /** * @since 1.0.0 * @category Branded types */ export type IPv6Brand = string & Brand.Brand<"IPv6">; /** * @since 1.0.0 * @category Branded constructors */ export declare const IPv6Brand: Brand.Brand.Constructor<IPv6Brand>; /** * @since 1.0.0 * @category Api interface */ export type $IPv6 = Schema.transform<Schema.filter<typeof Schema.String>, Schema.Struct<{ family: $IPv6Family; ip: Schema.BrandSchema<IPv6Brand, Brand.Brand.Unbranded<IPv6Brand>, never>; }>>; /** * @since 1.0.0 * @category Decoded types */ export type IPv6 = Schema.Schema.Type<$IPv6>; /** * @since 1.0.0 * @category Encoded types */ export type IPv6Encoded = Schema.Schema.Encoded<$IPv6>; /** * An IPv6 address. * * @since 1.0.0 * @category Schemas * @example * import * as Schema from "effect/Schema"; * import { IPv6 } from "the-wireguard-effect/InternetSchemas"; * * const decodeIPv6 = Schema.decodeSync(IPv6); * assert.deepEqual(decodeIPv6("2001:0db8:85a3:0000:0000:8a2e:0370:7334"), { * family: "ipv6", * ip: "2001:0db8:85a3:0000:0000:8a2e:0370:7334", * }); * * assert.throws(() => * decodeIPv6("2001:0db8:85a3:0000:0000:8a2e:0370:7334:") * ); * assert.throws(() => decodeIPv6("2001::85a3::0000::0370:7334")); * assert.doesNotThrow(() => * decodeIPv6("2001:0db8:85a3:0000:0000:8a2e:0370:7334") * ); */ export declare const IPv6: $IPv6; /** * @since 1.0.0 * @category Branded types */ export type IPv6BigintBrand = bigint & Brand.Brand<"IPv6Bigint">; /** * @since 1.0.0 * @category Branded constructors */ export declare const IPv6BigintBrand: Brand.Brand.Constructor<IPv6BigintBrand>; /** * @since 1.0.0 * @category Api interface */ export type $IPv6Bigint = Schema.transformOrFail<$IPv6, Schema.Struct<{ family: $IPv6Family; value: Schema.BrandSchema<IPv6BigintBrand, Brand.Brand.Unbranded<IPv6BigintBrand>, never>; }>, never>; /** * @since 1.0.0 * @category Decoded types */ export type IPv6Bigint = Schema.Schema.Type<$IPv6Bigint>; /** * @since 1.0.0 * @category Encoded types */ export type IPv6BigintEncoded = Schema.Schema.Encoded<$IPv6Bigint>; /** * An IPv6 as a bigint. * * @since 1.0.0 * @category Schemas * @example * import * as Schema from "effect/Schema"; * import { * IPv6Bigint, * IPv6BigintBrand, * } from "the-wireguard-effect/InternetSchemas"; * * const y: IPv6BigintBrand = IPv6BigintBrand(748392749382n); * assert.strictEqual(y, 748392749382n); * * const decodeIPv6Bigint = Schema.decodeSync(IPv6Bigint); * const encodeIPv6Bigint = Schema.encodeSync(IPv6Bigint); * * assert.deepEqual( * decodeIPv6Bigint("4cbd:ff70:e62b:a048:686c:4e7e:a68a:c377"), * { value: 102007852745154114519525620108359287671n, family: "ipv6" } * ); * assert.deepEqual( * decodeIPv6Bigint("d8c6:3feb:46e6:b80c:5a07:6227:ac19:caf6"), * { value: 288142618299897818094313964584331496182n, family: "ipv6" } * ); * * assert.deepEqual( * encodeIPv6Bigint({ * value: IPv6BigintBrand(102007852745154114519525620108359287671n), * family: "ipv6", * }), * "4cbd:ff70:e62b:a048:686c:4e7e:a68a:c377" * ); * assert.deepEqual( * encodeIPv6Bigint({ * value: IPv6BigintBrand(288142618299897818094313964584331496182n), * family: "ipv6", * }), * "d8c6:3feb:46e6:b80c:5a07:6227:ac19:caf6" * ); */ export declare const IPv6Bigint: $IPv6Bigint; /** * @since 1.0.0 * @category Api interface */ export type $Family = Schema.Union<[$IPv4Family, $IPv6Family]>; /** * @since 1.0.0 * @category Decoded types */ export type Family = Schema.Schema.Type<$Family>; /** * @since 1.0.0 * @category Schemas * @see {@link IPv4Family} * @see {@link IPv6Family} */ export declare const Family: $Family; /** * @since 1.0.0 * @category Api interface */ export type $Address = Schema.Union<[$IPv4, $IPv6]>; /** * @since 1.0.0 * @category Decoded types */ export type Address = Schema.Schema.Type<$Address>; /** * @since 1.0.0 * @category Encoded types */ export type AddressEncoded = Schema.Schema.Encoded<$Address>; /** * An IP address, which is either an IPv4 or IPv6 address. * * @since 1.0.0 * @category Schemas * @example * import * as Schema from "effect/Schema"; * import { Address } from "the-wireguard-effect/InternetSchemas"; * * const decodeAddress = Schema.decodeSync(Address); * * assert.throws(() => decodeAddress("1.1.b.1")); * assert.throws(() => * decodeAddress("2001:0db8:85a3:0000:0000:8a2e:0370:7334:") * ); * * assert.doesNotThrow(() => decodeAddress("1.1.1.2")); * assert.doesNotThrow(() => * decodeAddress("2001:0db8:85a3:0000:0000:8a2e:0370:7334") * ); * * @see {@link IPv4} * @see {@link IPv6} */ export declare const Address: $Address; /** * @since 1.0.0 * @category Api interface */ export type $AddressBigint = Schema.Union<[$IPv4Bigint, $IPv6Bigint]>; /** * @since 1.0.0 * @category Decoded types */ export type AddressBigint = Schema.Schema.Type<$AddressBigint>; /** * @since 1.0.0 * @category Encoded types */ export type AddressBigintEncoded = Schema.Schema.Encoded<$AddressBigint>; /** * An IP address as a bigint. * * @since 1.0.0 * @category Schemas */ export declare const AddressBigint: $AddressBigint; /** * @since 1.0.0 * @category Branded types */ export type IPv4CidrMaskBrand = number & Brand.Brand<"IPv4CidrMask">; /** * @since 1.0.0 * @category Branded constructors */ export declare const IPv4CidrMaskBrand: Brand.Brand.Constructor<IPv4CidrMaskBrand>; /** * @since 1.0.0 * @category Api interface */ export type $IPv4CidrMask = Schema.Annotable<$IPv4CidrMask, IPv4CidrMaskBrand, Brand.Brand.Unbranded<IPv4CidrMaskBrand>, never>; /** * @since 1.0.0 * @category Decoded types */ export type IPv4CidrMask = Schema.Schema.Type<$IPv4CidrMask>; /** * @since 1.0.0 * @category Encoded types */ export type IPv4CidrMaskEncoded = Schema.Schema.Encoded<$IPv4CidrMask>; /** * An ipv4 cidr mask, which is a number between 0 and 32. * * @since 1.0.0 * @category Schemas * @example * import * as Schema from "effect/Schema"; * import { * IPv4CidrMask, * IPv4CidrMaskBrand, * } from "the-wireguard-effect/InternetSchemas"; * * const mask: IPv4CidrMaskBrand = IPv4CidrMaskBrand(24); * assert.strictEqual(mask, 24); * * const decodeMask = Schema.decodeSync(IPv4CidrMask); * assert.strictEqual(decodeMask(24), 24); * * assert.throws(() => decodeMask(33)); * assert.doesNotThrow(() => decodeMask(0)); * assert.doesNotThrow(() => decodeMask(32)); */ export declare const IPv4CidrMask: $IPv4CidrMask; /** * @since 1.0.0 * @category Branded types */ export type IPv6CidrMaskBrand = number & Brand.Brand<"IPv6CidrMask">; /** * @since 1.0.0 * @category Branded constructors */ export declare const IPv6CidrMaskBrand: Brand.Brand.Constructor<IPv6CidrMaskBrand>; /** * @since 1.0.0 * @category Api interface */ export type $IPv6CidrMask = Schema.Annotable<$IPv6CidrMask, IPv6CidrMaskBrand, Brand.Brand.Unbranded<IPv6CidrMaskBrand>, never>; /** * @since 1.0.0 * @category Decoded types */ export type IPv6CidrMask = Schema.Schema.Type<$IPv6CidrMask>; /** * @since 1.0.0 * @category Encoded types */ export type IPv6CidrMaskEncoded = Schema.Schema.Encoded<$IPv6CidrMask>; /** * An ipv6 cidr mask, which is a number between 0 and 128. * * @since 1.0.0 * @category Schemas * @example * import * as Schema from "effect/Schema"; * import { * IPv6CidrMask, * IPv6CidrMaskBrand, * } from "the-wireguard-effect/InternetSchemas"; * * const mask: IPv6CidrMaskBrand = IPv6CidrMaskBrand(64); * assert.strictEqual(mask, 64); * * const decodeMask = Schema.decodeSync(IPv6CidrMask); * assert.strictEqual(decodeMask(64), 64); * * assert.throws(() => decodeMask(129)); * assert.doesNotThrow(() => decodeMask(0)); * assert.doesNotThrow(() => decodeMask(128)); */ export declare const IPv6CidrMask: $IPv6CidrMask; declare const CidrBlockBase_base: Schema.Class<CidrBlockBase<"ipv4" | "ipv6">, { address: $Address; mask: Schema.Union<[$IPv4CidrMask, $IPv6CidrMask]>; }, Schema.Struct.Encoded<{ address: $Address; mask: Schema.Union<[$IPv4CidrMask, $IPv6CidrMask]>; }>, never, { readonly address: { readonly family: "ipv4"; readonly ip: IPv4Brand; } | { readonly family: "ipv6"; readonly ip: IPv6Brand; }; } & { readonly mask: IPv4CidrMaskBrand | IPv6CidrMaskBrand; }, {}, {}>; /** * @since 1.0.0 * @category Api interface */ export declare class CidrBlockBase<_Family extends Family> extends CidrBlockBase_base { /** @since 1.0.0 */ readonly family: Family; /** * The first address in the range given by this address' subnet, often * referred to as the Network Address. * * @since 1.0.0 */ protected get networkAddressAsBigint(): Effect.Effect<_Family extends IPv4Family ? IPv4BigintBrand : _Family extends IPv6Family ? IPv6BigintBrand : never, ParseResult.ParseError, never>; /** * The first address in the range given by this address' subnet, often * referred to as the Network Address. * * @since 1.0.0 */ networkAddress(): _Family extends IPv4Family ? Effect.Effect<IPv4, ParseResult.ParseError, never> : _Family extends IPv6Family ? Effect.Effect<IPv6, ParseResult.ParseError, never> : never; /** * The last address in the range given by this address' subnet, often * referred to as the Broadcast Address. * * @since 1.0.0 */ protected get broadcastAddressAsBigint(): Effect.Effect<_Family extends IPv4Family ? IPv4BigintBrand : _Family extends IPv6Family ? IPv6BigintBrand : never, ParseResult.ParseError, never>; /** * The last address in the range given by this address' subnet, often * referred to as the Broadcast Address. * * @since 1.0.0 */ broadcastAddress(): _Family extends IPv4Family ? Effect.Effect<IPv4, ParseResult.ParseError, never> : _Family extends IPv6Family ? Effect.Effect<IPv6, ParseResult.ParseError, never> : never; /** * A stream of all addresses in the range given by this address' subnet. * * @since 1.0.0 */ get range(): _Family extends IPv4Family ? Stream.Stream<IPv4, ParseResult.ParseError, never> : _Family extends IPv6Family ? Stream.Stream<IPv6, ParseResult.ParseError, never> : never; /** * The total number of addresses in the range given by this address' subnet. * * @since 1.0.0 */ get total(): Effect.Effect<bigint, ParseResult.ParseError, never>; /** * Finds the smallest CIDR block that contains all the given IP addresses. * * @since 1.0.0 */ static readonly cidrBlockForRange: <_Family_1 extends Family>(inputs: _Family_1 extends IPv4Family ? Array.NonEmptyReadonlyArray<IPv4> : Array.NonEmptyReadonlyArray<IPv6>) => _Family_1 extends IPv4Family ? Effect.Effect<CidrBlockBase<"ipv4">, ParseResult.ParseError, never> : Effect.Effect<CidrBlockBase<"ipv6">, ParseResult.ParseError, never>; } /** * @since 1.0.0 * @category Api interface */ export type $IPv4CidrBlock = Schema.Annotable<$IPv4CidrBlock, CidrBlockBase<"ipv4">, { readonly address: string; readonly mask: number; }, never>; /** * @since 1.0.0 * @category Decoded types */ export type IPv4CidrBlock = CidrBlockBase<"ipv4">; /** * @since 1.0.0 * @category Encoded types */ export type IPv4CidrBlockEncoded = Schema.Schema.Encoded<$IPv4CidrBlock>; /** * @since 1.0.0 * @category Schemas */ export declare const IPv4CidrBlock: $IPv4CidrBlock; /** * @since 1.0.0 * @category Api interface */ export type $IPv4CidrBlockFromString = Schema.Annotable<$IPv4CidrBlockFromString, CidrBlockBase<"ipv4">, `${string}/${number}`, never>; /** * @since 1.0.0 * @category Decoded types */ export type IPv4CidrBlockFromString = Schema.Schema.Type<$IPv4CidrBlockFromString>; /** * @since 1.0.0 * @category Encoded types */ export type IPv4CidrBlockFromStringEncoded = Schema.Schema.Encoded<$IPv4CidrBlockFromString>; /** * A schema that transforms a `string` into a `CidrBlock`. * * @since 1.0.0 * @category Schemas */ export declare const IPv4CidrBlockFromString: $IPv4CidrBlockFromString; /** * @since 1.0.0 * @category Api interface */ export type $IPv6CidrBlock = Schema.transformOrFail<Schema.Struct<{ address: $IPv6; mask: $IPv6CidrMask; }>, typeof CidrBlockBase<"ipv6">, never>; /** * @since 1.0.0 * @category Decoded types */ export type IPv6CidrBlock = CidrBlockBase<"ipv6">; /** * @since 1.0.0 * @category Encoded types */ export type IPv6CidrBlockEncoded = Schema.Schema.Encoded<$IPv6CidrBlock>; /** * @since 1.0.0 * @category Schemas */ export declare const IPv6CidrBlock: $IPv6CidrBlock; /** * @since 1.0.0 * @category Api interface */ export type $IPv6CidrBlockFromString = Schema.Annotable<$IPv6CidrBlockFromString, CidrBlockBase<"ipv6">, `${string}/${number}`, never>; /** * @since 1.0.0 * @category Decoded types */ export type IPv6CidrBlockFromString = Schema.Schema.Type<$IPv6CidrBlockFromString>; /** * @since 1.0.0 * @category Encoded types */ export type IPv6CidrBlockFromStringEncoded = Schema.Schema.Encoded<$IPv6CidrBlockFromString>; /** * A schema that transforms a `string` into a `CidrBlock`. * * @since 1.0.0 * @category Schemas */ export declare const IPv6CidrBlockFromString: $IPv6CidrBlockFromString; /** * @since 1.0.0 * @category Api interface */ export type $CidrBlock = Schema.Union<[$IPv4CidrBlock, $IPv6CidrBlock]>; /** * @since 1.0.0 * @category Schemas */ export declare const CidrBlock: $CidrBlock; /** * @since 1.0.0 * @category Api interface */ export type $CidrBlockFromString = Schema.Annotable<$CidrBlockFromString, CidrBlockBase<"ipv4"> | CidrBlockBase<"ipv6">, `${string}/${number}`, never>; /** * @since 1.0.0 * @category Decoded types */ export type CidrBlockFromString = Schema.Schema.Type<$CidrBlockFromString>; /** * @since 1.0.0 * @category Encoded types */ export type CidrBlockFromStringEncoded = Schema.Schema.Encoded<$CidrBlockFromString>; /** * A schema that transforms a `string` into a `CidrBlock`. * * @since 1.0.0 * @category Schemas */ export declare const CidrBlockFromString: $CidrBlockFromString; /** * @since 1.0.0 * @category Api interface */ export type $IPv4Endpoint = Schema.Annotable<$IPv4Endpoint, { readonly address: IPv4; readonly natPort: PortBrand; readonly listenPort: PortBrand; }, `${string}:${number}` | `${string}:${number}:${number}` | { readonly ip: string; readonly port: number; readonly family: IPv4Family; } | { readonly ip: string; readonly natPort: number; readonly listenPort: number; readonly family: IPv4Family; }, never>; /** * @since 1.0.0 * @category Decoded types */ export type IPv4Endpoint = Schema.Schema.Type<$IPv4Endpoint>; /** * @since 1.0.0 * @category Encoded types */ export type IPv4EndpointEncoded = Schema.Schema.Encoded<$IPv4Endpoint>; /** * An IPv4 wireguard endpoint, which consists of an IPv4 address followed by a * nat port then an optional local port. If only one port is provided, it is * assumed that the nat port and listen port are the same. * * @since 1.0.0 * @category Schemas * @example * import * as Schema from "effect/Schema"; * import { IPv4Endpoint } from "the-wireguard-effect/InternetSchemas"; * * const decodeEndpoint = Schema.decodeSync(IPv4Endpoint); * const endpoint1 = decodeEndpoint("1.2.3.4:51820"); * const endpoint2 = decodeEndpoint("1.2.3.4:51820:41820"); * * const endpoint3 = decodeEndpoint({ * ip: "1.2.3.4", * port: 51820, * family: "ipv4", * }); * * const endpoint4 = decodeEndpoint({ * ip: "1.2.3.4", * natPort: 51820, * listenPort: 41820, * family: "ipv4", * }); */ export declare const IPv4Endpoint: $IPv4Endpoint; /** * @since 1.0.0 * @category Api interface */ export type $IPv6Endpoint = Schema.Annotable<$IPv6Endpoint, { readonly address: IPv6; readonly natPort: PortBrand; readonly listenPort: PortBrand; }, `[${string}]:${number}` | `[${string}]:${number}:${number}` | { readonly ip: string; readonly port: number; family: IPv6Family; } | { readonly ip: string; readonly natPort: number; readonly listenPort: number; family: IPv6Family; }, never>; /** * @since 1.0.0 * @category Decoded types */ export type IPv6Endpoint = Schema.Schema.Type<$IPv6Endpoint>; /** * @since 1.0.0 * @category Encoded types */ export type IPv6EndpointEncoded = Schema.Schema.Encoded<$IPv6Endpoint>; /** * An IPv6 wireguard endpoint, which consists of an IPv6 address in square * brackets followed by a nat port then an optional local port. If only one port * is provided, it is assumed that the nat port and listen port are the same. * * @since 1.0.0 * @category Schemas * @example * import * as Schema from "effect/Schema"; * import { IPv6Endpoint } from "the-wireguard-effect/InternetSchemas"; * * const decodeEndpoint = Schema.decodeSync(IPv6Endpoint); * const endpoint1 = decodeEndpoint( * "[2001:0db8:85a3:0000:0000:8a2e:0370:7334]:51820" * ); * const endpoint2 = decodeEndpoint( * "[2001:0db8:85a3:0000:0000:8a2e:0370:7334]:51820:41820" * ); * * const endpoint3 = decodeEndpoint({ * ip: "2001:0db8:85a3:0000:0000:8a2e:0370:7334", * port: 51820, * family: "ipv6", * }); * * const endpoint4 = decodeEndpoint({ * ip: "2001:0db8:85a3:0000:0000:8a2e:0370:7334", * natPort: 51820, * listenPort: 41820, * family: "ipv6", * }); */ export declare const IPv6Endpoint: $IPv6Endpoint; /** * @since 1.0.0 * @category Api interface */ export type $HostnameEndpoint = Schema.Annotable<$HostnameEndpoint, { readonly host: string; readonly natPort: PortBrand; readonly listenPort: PortBrand; }, `${string}:${number}` | `${string}:${number}:${number}` | { readonly host: string; readonly port: number; } | { readonly host: string; readonly natPort: number; readonly listenPort: number; }, never>; /** * @since 1.0.0 * @category Decoded types */ export type HostnameEndpoint = Schema.Schema.Type<$HostnameEndpoint>; /** * @since 1.0.0 * @category Encoded types */ export type HostnameEndpointEncoded = Schema.Schema.Encoded<$HostnameEndpoint>; /** * A hostname wireguard endpoint, which consists of a hostname followed by a\ * Nat port then an optional local port. If only one port is provided, it is * assumed that the nat port and listen port are the same. * * @since 1.0.0 * @category Schemas */ export declare const HostnameEndpoint: $HostnameEndpoint; /** * @since 1.0.0 * @category Api interface */ export type $Endpoint = Schema.Union<[$IPv4Endpoint, $IPv6Endpoint, $HostnameEndpoint]>; /** * @since 1.0.0 * @category Decoded types */ export type Endpoint = Schema.Schema.Type<$Endpoint>; /** * @since 1.0.0 * @category Encoded types */ export type EndpointEncoded = Schema.Schema.Encoded<$Endpoint>; /** * A wireguard endpoint, which is either an IPv4 or IPv6 endpoint. * * @since 1.0.0 * @category Schemas * @example * import * as Schema from "effect/Schema"; * * import { Endpoint } from "the-wireguard-effect/InternetSchemas"; * * const decodeEndpoint = Schema.decodeSync(Endpoint); * const endpoint1 = decodeEndpoint("1.2.3.4:51820"); * const endpoint2 = decodeEndpoint("1.2.3.4:51820:41820"); * * const endpoint3 = decodeEndpoint({ * ip: "1.2.3.4", * port: 51820, * family: "ipv4", * }); * * const endpoint4: Endpoint = decodeEndpoint({ * ip: "1.2.3.4", * natPort: 51820, * listenPort: 41820, * family: "ipv4", * }); * * const endpoint5 = decodeEndpoint( * "[2001:0db8:85a3:0000:0000:8a2e:0370:7334]:51820" * ); * const endpoint6 = decodeEndpoint( * "[2001:0db8:85a3:0000:0000:8a2e:0370:7334]:51820:41820" * ); * * const endpoint7 = decodeEndpoint({ * ip: "2001:0db8:85a3:0000:0000:8a2e:0370:7334", * port: 51820, * family: "ipv6", * }); * * const endpoint8: Endpoint = decodeEndpoint({ * ip: "2001:0db8:85a3:0000:0000:8a2e:0370:7334", * natPort: 51820, * listenPort: 41820, * family: "ipv6", * }); * * @see {@link IPv4Endpoint} * @see {@link IPv6Endpoint} * @see {@link HostnameEndpoint} */ export declare const Endpoint: $Endpoint; /** * @since 1.0.0 * @category Api interface */ export type $IPv4SetupData = Schema.Tuple<[$IPv4Endpoint, $IPv4]>; /** * @since 1.0.0 * @category Decoded types */ export type IPv4SetupData = Schema.Schema.Type<$IPv4SetupData>; /** * @since 1.0.0 * @category Encoded types */ export type IPv4SetupDataEncoded = Schema.Schema.Encoded<$IPv4SetupData>; /** * A wireguard setup data, which consists of an endpoint followed by an address. * * @since 1.0.0 * @category Schemas * @example * import * as Schema from "effect/Schema"; * import { SetupData } from "the-wireguard-effect/InternetSchemas"; * * const decodeSetupData = Schema.decodeSync(SetupData); * const setupData = decodeSetupData(["1.1.1.1:51280", "10.0.0.1"]); * * @see {@link IPv4} * @see {@link IPv4EndpointSchema} */ export declare const IPv4SetupData: $IPv4SetupData; /** * @since 1.0.0 * @category Api interface */ export type $IPv6SetupData = Schema.Tuple<[$IPv6Endpoint, $IPv6]>; /** * @since 1.0.0 * @category Decoded types */ export type IPv6SetupData = Schema.Schema.Type<$IPv6SetupData>; /** * @since 1.0.0 * @category Encoded types */ export type IPv6SetupDataEncoded = Schema.Schema.Encoded<$IPv6SetupData>; /** * A wireguard setup data, which consists of an endpoint followed by an address. * * @since 1.0.0 * @category Schemas * @example * import * as Schema from "effect/Schema"; * import { SetupData } from "the-wireguard-effect/InternetSchemas"; * * const decodeSetupData = Schema.decodeSync(SetupData); * const setupData = decodeSetupData(["1.1.1.1:51280", "10.0.0.1"]); * * @see {@link IPv6} * @see {@link IPv6EndpointSchema} */ export declare const IPv6SetupData: $IPv6SetupData; /** * @since 1.0.0 * @category Api interface */ export type $HostnameIPv4SetupData = Schema.Tuple<[$HostnameEndpoint, $IPv4]>; /** * @since 1.0.0 * @category Decoded types */ export type HostnameIPv4SetupData = Schema.Schema.Type<$HostnameIPv4SetupData>; /** * @since 1.0.0 * @category Encoded types */ export type HostnameIPv4SetupDataEncoded = Schema.Schema.Encoded<$HostnameIPv4SetupData>; /** * A wireguard setup data, which consists of an endpoint followed by an address. * * @since 1.0.0 * @category Schemas * @see {@link IPv4} * @see {@link HostnameEndpoint} */ export declare const HostnameIPv4SetupData: $HostnameIPv4SetupData; /** * @since 1.0.0 * @category Api interface */ export type $HostnameIPv6SetupData = Schema.Tuple<[$HostnameEndpoint, $IPv6]>; /** * @since 1.0.0 * @category Decoded types */ export type HostnameIPv6SetupData = Schema.Schema.Type<$HostnameIPv6SetupData>; /** * @since 1.0.0 * @category Encoded types */ export type HostnameIPv6SetupDataEncoded = Schema.Schema.Encoded<$HostnameIPv6SetupData>; /** * A wireguard setup data, which consists of an endpoint followed by an address. * * @since 1.0.0 * @category Schemas * @see {@link IPv6} * @see {@link HostnameEndpoint} */ export declare const HostnameIPv6SetupData: $HostnameIPv6SetupData; /** * @since 1.0.0 * @category Api interface */ export type $SetupData = Schema.Union<[$IPv4SetupData, $IPv6SetupData, $HostnameIPv4SetupData, $HostnameIPv6SetupData]>; /** * @since 1.0.0 * @category Decoded types */ export type SetupData = Schema.Schema.Type<$SetupData>; /** * @since 1.0.0 * @category Encoded types */ export type SetupDataEncoded = Schema.Schema.Encoded<$SetupData>; /** * A wireguard setup data, which consists of an endpoint followed by an address. * * @since 1.0.0 * @category Schemas * @example * import * as Schema from "effect/Schema"; * import { SetupData } from "the-wireguard-effect/InternetSchemas"; * * const decodeSetupData = Schema.decodeSync(SetupData); * const setupData = decodeSetupData(["1.1.1.1:51280", "10.0.0.1"]); * * @see {@link Address} * @see {@link Endpoint} */ export declare const SetupData: $SetupData; export {}; //# sourceMappingURL=InternetSchemas.d.ts.map