Fix StartOS 0.4 TypeScript packaging to match SDK API
This commit is contained in:
+111
@@ -0,0 +1,111 @@
|
||||
/**
|
||||
* Represents an IPv4 or IPv6 address as raw octets with arithmetic and comparison operations.
|
||||
*
|
||||
* IPv4 addresses have 4 octets, IPv6 addresses have 16 octets.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* const ip = IpAddress.parse("192.168.1.1")
|
||||
* const next = ip.add(1) // 192.168.1.2
|
||||
* ```
|
||||
*/
|
||||
export declare class IpAddress {
|
||||
octets: number[];
|
||||
private renderedAddress;
|
||||
private renderedOctets;
|
||||
protected constructor(octets: number[], renderedAddress: string);
|
||||
/**
|
||||
* Parses an IP address string into an IpAddress instance.
|
||||
* Supports both IPv4 dotted-decimal and IPv6 colon-hex notation (including `::` shorthand).
|
||||
* @param address - The IP address string to parse
|
||||
* @returns A new IpAddress instance
|
||||
* @throws Error if the address format is invalid
|
||||
*/
|
||||
static parse(address: string): IpAddress;
|
||||
/**
|
||||
* Creates an IpAddress from a raw octet array.
|
||||
* @param octets - Array of 4 octets (IPv4) or 16 octets (IPv6), each 0-255
|
||||
* @returns A new IpAddress instance
|
||||
* @throws Error if the octet array length is not 4 or 16, or any octet exceeds 255
|
||||
*/
|
||||
static fromOctets(octets: number[]): IpAddress;
|
||||
/** Returns true if this is an IPv4 address (4 octets). */
|
||||
isIpv4(): boolean;
|
||||
/** Returns true if this is an IPv6 address (16 octets). */
|
||||
isIpv6(): boolean;
|
||||
/** Returns true if this is a public IPv4 address (not in any private range). */
|
||||
isPublic(): boolean;
|
||||
/**
|
||||
* Returns a new IpAddress incremented by `n`.
|
||||
* @param n - The integer amount to add (fractional part is truncated)
|
||||
* @returns A new IpAddress with the result
|
||||
* @throws Error on overflow
|
||||
*/
|
||||
add(n: number): IpAddress;
|
||||
/**
|
||||
* Returns a new IpAddress decremented by `n`.
|
||||
* @param n - The integer amount to subtract (fractional part is truncated)
|
||||
* @returns A new IpAddress with the result
|
||||
* @throws Error on underflow
|
||||
*/
|
||||
sub(n: number): IpAddress;
|
||||
/**
|
||||
* Compares this address to another, returning -1, 0, or 1.
|
||||
* @param other - An IpAddress instance or string to compare against
|
||||
* @returns -1 if this < other, 0 if equal, 1 if this > other
|
||||
*/
|
||||
cmp(other: string | IpAddress): -1 | 0 | 1;
|
||||
/** The string representation of this IP address (e.g. `"192.168.1.1"` or `"::1"`). Cached and recomputed only when octets change. */
|
||||
get address(): string;
|
||||
}
|
||||
/**
|
||||
* Represents an IP network (CIDR notation) combining an IP address with a prefix length.
|
||||
* Extends IpAddress with network-specific operations like containment checks and broadcast calculation.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* const net = IpNet.parse("192.168.1.0/24")
|
||||
* net.contains("192.168.1.100") // true
|
||||
* net.broadcast() // 192.168.1.255
|
||||
* ```
|
||||
*/
|
||||
export declare class IpNet extends IpAddress {
|
||||
prefix: number;
|
||||
private constructor();
|
||||
/**
|
||||
* Creates an IpNet from an IpAddress and prefix length.
|
||||
* @param ip - The base IP address
|
||||
* @param prefix - The CIDR prefix length (0-32 for IPv4, 0-128 for IPv6)
|
||||
* @returns A new IpNet instance
|
||||
* @throws Error if prefix exceeds the address bit length
|
||||
*/
|
||||
static fromIpPrefix(ip: IpAddress, prefix: number): IpNet;
|
||||
/**
|
||||
* Parses a CIDR notation string (e.g. `"192.168.1.0/24"`) into an IpNet.
|
||||
* @param ipnet - The CIDR string to parse
|
||||
* @returns A new IpNet instance
|
||||
*/
|
||||
static parse(ipnet: string): IpNet;
|
||||
/**
|
||||
* Checks whether this network contains the given address or subnet.
|
||||
* @param address - An IP address or subnet (string, IpAddress, or IpNet)
|
||||
* @returns True if the address falls within this network's range
|
||||
*/
|
||||
contains(address: string | IpAddress | IpNet): boolean;
|
||||
/** Returns the network address (all host bits zeroed) for this subnet. */
|
||||
zero(): IpAddress;
|
||||
/** Returns the broadcast address (all host bits set to 1) for this subnet. */
|
||||
broadcast(): IpAddress;
|
||||
/** The CIDR notation string for this network (e.g. `"192.168.1.0/24"`). */
|
||||
get ipnet(): string;
|
||||
}
|
||||
/** All private IPv4 ranges: loopback (127.0.0.0/8), Class A (10.0.0.0/8), Class B (172.16.0.0/12), Class C (192.168.0.0/16). */
|
||||
export declare const PRIVATE_IPV4_RANGES: IpNet[];
|
||||
/** IPv4 loopback network (127.0.0.0/8). */
|
||||
export declare const IPV4_LOOPBACK: IpNet;
|
||||
/** IPv6 loopback address (::1/128). */
|
||||
export declare const IPV6_LOOPBACK: IpNet;
|
||||
/** IPv6 link-local network (fe80::/10). */
|
||||
export declare const IPV6_LINK_LOCAL: IpNet;
|
||||
/** Carrier-Grade NAT (CGNAT) address range (100.64.0.0/10), per RFC 6598. */
|
||||
export declare const CGNAT: IpNet;
|
||||
Reference in New Issue
Block a user