@open-condo/miniapp-utils
Version:
A set of helper functions / components / hooks used to build new condo apps fast
114 lines (107 loc) • 5.59 kB
text/typescript
/**
* The functional version, creates a checking function that takes an IPv4 Address and
* returns whether or not it is contained in (one of) the subnet(s).
* @param subnetOrSubnets the IPv4 CIDR to test (or an array of them)
* @throws if the subnet is not a valid IP addresses, or the CIDR prefix length
* is not valid
*/
declare function createChecker$2(subnetOrSubnets: string | string[]): (address: string) => boolean;
/**
* Test if the given IPv4 address is contained in the specified subnet.
* @param address the IPv4 address to check
* @param subnetOrSubnets the IPv4 CIDR to test (or an array of them)
* @throws if the address or subnet are not valid IP addresses, or the CIDR prefix length
* is not valid
*/
declare function isInSubnet$2(address: string, subnetOrSubnets: string | string[]): boolean;
/** Test if the given IP address is a private/internal IP address. */
declare function isPrivate$2(address: string): boolean;
/** Test if the given IP address is a localhost address. */
declare function isLocalhost$2(address: string): boolean;
/** Test if the given IP address is in a known reserved range and not a normal host IP */
declare function isReserved$2(address: string): boolean;
/**
* Test if the given IP address is a special address of any kind (private, reserved,
* localhost)
*/
declare function isSpecial$2(address: string): boolean;
declare namespace ipv4 {
export { createChecker$2 as createChecker, isInSubnet$2 as isInSubnet, isLocalhost$2 as isLocalhost, isPrivate$2 as isPrivate, isReserved$2 as isReserved, isSpecial$2 as isSpecial };
}
/**
* Given a mapped IPv4 address, return the bare IPv4 equivalent.
*/
declare function extractMappedIpv4(ip: string): string;
/**
* Test if the given IPv6 address is contained in the specified subnet.
* @param address the IPv6 address to check
* @param subnetOrSubnets the IPv6 CIDR to test (or an array of them)
* @throws if the address or subnet are not valid IP addresses, or the CIDR prefix length
* is not valid
*/
declare function isInSubnet$1(address: string, subnetOrSubnets: string | string[]): boolean;
/**
* Create a function to test if a given IPv6 address is contained in the specified subnet.
* @param subnetOrSubnets the IPv6 CIDR to test (or an array of them)
* @throws if the subnet(s) are not valid IP addresses, or the CIDR prefix lengths
* are not valid
*/
declare function createChecker$1(subnetOrSubnets: string | string[]): (address: string) => boolean;
/** Test if the given IP address is a private/internal IP address. */
declare function isPrivate$1(address: string): boolean;
/** Test if the given IP address is a localhost address. */
declare function isLocalhost$1(address: string): boolean;
/** Test if the given IP address is an IPv4 address mapped onto IPv6 */
declare function isIPv4MappedAddress$1(address: string): boolean;
/** Test if the given IP address is in a known reserved range and not a normal host IP */
declare function isReserved$1(address: string): boolean;
/**
* Test if the given IP address is a special address of any kind (private, reserved,
* localhost)
*/
declare function isSpecial$1(address: string): boolean;
declare const ipv6_extractMappedIpv4: typeof extractMappedIpv4;
declare namespace ipv6 {
export { createChecker$1 as createChecker, ipv6_extractMappedIpv4 as extractMappedIpv4, isIPv4MappedAddress$1 as isIPv4MappedAddress, isInSubnet$1 as isInSubnet, isLocalhost$1 as isLocalhost, isPrivate$1 as isPrivate, isReserved$1 as isReserved, isSpecial$1 as isSpecial };
}
/**
* Returns true if the string represents an IPv4 address. Matches Node.js net.isIPv4
* functionality.
*/
declare function isIPv4(s: string): boolean;
/**
* Returns true if the string represents an IPv6 address. Matches Node.js net.isIPv6
* functionality.
*/
declare function isIPv6(s: string): boolean;
declare function isIP(s: string): 4 | 6 | 0;
/**
* Test if the given IP address is contained in the specified subnet.
* @param address the IPv4 or IPv6 address to check
* @param subnetOrSubnets the IPv4 or IPv6 CIDR to test (or an array of them)
* @throws if any of the address or subnet(s) are not valid IP addresses, or the CIDR
* prefix length is not valid
*/
declare function isInSubnet(address: string, subnetOrSubnets: string | string[]): boolean;
/**
* Create a function to test if the given IP address is contained in the specified subnet.
* @param subnetOrSubnets the IPv4 or IPv6 CIDR to test (or an array of them)
* @throws if any of the subnet(s) are not valid IP addresses, or the CIDR
* prefix length is not valid
*/
declare function createChecker(subnetOrSubnets: string | string[]): (address: string) => boolean;
/** Test if the given IP address is a private/internal IP address. */
declare function isPrivate(address: string): boolean;
/** Test if the given IP address is a localhost address. */
declare function isLocalhost(address: string): boolean;
/** Test if the given IP address is an IPv4 address mapped onto IPv6 */
declare function isIPv4MappedAddress(address: string): boolean;
/** Test if the given IP address is in a known reserved range and not a normal host IP */
declare function isReserved(address: string): boolean;
/**
* Test if the given IP address is a special address of any kind (private, reserved,
* localhost)
*/
declare function isSpecial(address: string): boolean;
declare const check: typeof isInSubnet;
export { ipv4 as IPv4, ipv6 as IPv6, check, createChecker, isIP, isIPv4, isIPv4MappedAddress, isIPv6, isInSubnet, isLocalhost, isPrivate, isReserved, isSpecial };