@ac-kit/net-address 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +46 -0
- package/LICENSE +28 -0
- package/README.md +65 -0
- package/dist/errors.d.ts +6 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +10 -0
- package/dist/errors.js.map +1 -0
- package/dist/eui/constants.d.ts +7 -0
- package/dist/eui/constants.d.ts.map +1 -0
- package/dist/eui/constants.js +7 -0
- package/dist/eui/constants.js.map +1 -0
- package/dist/eui/eui-bits.d.ts +99 -0
- package/dist/eui/eui-bits.d.ts.map +1 -0
- package/dist/eui/eui-bits.js +138 -0
- package/dist/eui/eui-bits.js.map +1 -0
- package/dist/eui/eui-convert.d.ts +37 -0
- package/dist/eui/eui-convert.d.ts.map +1 -0
- package/dist/eui/eui-convert.js +76 -0
- package/dist/eui/eui-convert.js.map +1 -0
- package/dist/eui/interface-identifier.d.ts +24 -0
- package/dist/eui/interface-identifier.d.ts.map +1 -0
- package/dist/eui/interface-identifier.js +47 -0
- package/dist/eui/interface-identifier.js.map +1 -0
- package/dist/eui/parse-eui.d.ts +31 -0
- package/dist/eui/parse-eui.d.ts.map +1 -0
- package/dist/eui/parse-eui.js +93 -0
- package/dist/eui/parse-eui.js.map +1 -0
- package/dist/eui/print-eui.d.ts +44 -0
- package/dist/eui/print-eui.d.ts.map +1 -0
- package/dist/eui/print-eui.js +64 -0
- package/dist/eui/print-eui.js.map +1 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +29 -0
- package/dist/index.js.map +1 -0
- package/dist/ipv4/classify-ipv4.d.ts +69 -0
- package/dist/ipv4/classify-ipv4.d.ts.map +1 -0
- package/dist/ipv4/classify-ipv4.js +129 -0
- package/dist/ipv4/classify-ipv4.js.map +1 -0
- package/dist/ipv4/constants.d.ts +5 -0
- package/dist/ipv4/constants.d.ts.map +1 -0
- package/dist/ipv4/constants.js +5 -0
- package/dist/ipv4/constants.js.map +1 -0
- package/dist/ipv4/ipv4-prefix.d.ts +52 -0
- package/dist/ipv4/ipv4-prefix.d.ts.map +1 -0
- package/dist/ipv4/ipv4-prefix.js +81 -0
- package/dist/ipv4/ipv4-prefix.js.map +1 -0
- package/dist/ipv4/parse-ipv4.d.ts +49 -0
- package/dist/ipv4/parse-ipv4.d.ts.map +1 -0
- package/dist/ipv4/parse-ipv4.js +169 -0
- package/dist/ipv4/parse-ipv4.js.map +1 -0
- package/dist/ipv4/print-ipv4.d.ts +50 -0
- package/dist/ipv4/print-ipv4.d.ts.map +1 -0
- package/dist/ipv4/print-ipv4.js +76 -0
- package/dist/ipv4/print-ipv4.js.map +1 -0
- package/dist/ipv6/classify-ipv6.d.ts +79 -0
- package/dist/ipv6/classify-ipv6.d.ts.map +1 -0
- package/dist/ipv6/classify-ipv6.js +148 -0
- package/dist/ipv6/classify-ipv6.js.map +1 -0
- package/dist/ipv6/constants.d.ts +5 -0
- package/dist/ipv6/constants.d.ts.map +1 -0
- package/dist/ipv6/constants.js +5 -0
- package/dist/ipv6/constants.js.map +1 -0
- package/dist/ipv6/ipv4-mapped.d.ts +43 -0
- package/dist/ipv6/ipv4-mapped.d.ts.map +1 -0
- package/dist/ipv6/ipv4-mapped.js +65 -0
- package/dist/ipv6/ipv4-mapped.js.map +1 -0
- package/dist/ipv6/ipv6-prefix.d.ts +51 -0
- package/dist/ipv6/ipv6-prefix.d.ts.map +1 -0
- package/dist/ipv6/ipv6-prefix.js +78 -0
- package/dist/ipv6/ipv6-prefix.js.map +1 -0
- package/dist/ipv6/parse-ipv6.d.ts +50 -0
- package/dist/ipv6/parse-ipv6.d.ts.map +1 -0
- package/dist/ipv6/parse-ipv6.js +148 -0
- package/dist/ipv6/parse-ipv6.js.map +1 -0
- package/dist/ipv6/print-ipv6.d.ts +37 -0
- package/dist/ipv6/print-ipv6.d.ts.map +1 -0
- package/dist/ipv6/print-ipv6.js +93 -0
- package/dist/ipv6/print-ipv6.js.map +1 -0
- package/dist/port/endpoint.d.ts +47 -0
- package/dist/port/endpoint.d.ts.map +1 -0
- package/dist/port/endpoint.js +104 -0
- package/dist/port/endpoint.js.map +1 -0
- package/dist/port/ephemeral-port.d.ts +17 -0
- package/dist/port/ephemeral-port.d.ts.map +1 -0
- package/dist/port/ephemeral-port.js +26 -0
- package/dist/port/ephemeral-port.js.map +1 -0
- package/dist/port/port.d.ts +69 -0
- package/dist/port/port.d.ts.map +1 -0
- package/dist/port/port.js +94 -0
- package/dist/port/port.js.map +1 -0
- package/dist/prefix/_numeric-range.d.ts +23 -0
- package/dist/prefix/_numeric-range.d.ts.map +1 -0
- package/dist/prefix/_numeric-range.js +57 -0
- package/dist/prefix/_numeric-range.js.map +1 -0
- package/dist/prefix/_prefix-length.d.ts +7 -0
- package/dist/prefix/_prefix-length.d.ts.map +1 -0
- package/dist/prefix/_prefix-length.js +13 -0
- package/dist/prefix/_prefix-length.js.map +1 -0
- package/dist/prefix/aggregate.d.ts +45 -0
- package/dist/prefix/aggregate.d.ts.map +1 -0
- package/dist/prefix/aggregate.js +97 -0
- package/dist/prefix/aggregate.js.map +1 -0
- package/dist/prefix/bit-address.d.ts +110 -0
- package/dist/prefix/bit-address.d.ts.map +1 -0
- package/dist/prefix/bit-address.js +165 -0
- package/dist/prefix/bit-address.js.map +1 -0
- package/dist/prefix/bit-prefix.d.ts +79 -0
- package/dist/prefix/bit-prefix.d.ts.map +1 -0
- package/dist/prefix/bit-prefix.js +135 -0
- package/dist/prefix/bit-prefix.js.map +1 -0
- package/dist/prefix/bit-range.d.ts +49 -0
- package/dist/prefix/bit-range.d.ts.map +1 -0
- package/dist/prefix/bit-range.js +100 -0
- package/dist/prefix/bit-range.js.map +1 -0
- package/dist/prefix/compare.d.ts +21 -0
- package/dist/prefix/compare.d.ts.map +1 -0
- package/dist/prefix/compare.js +33 -0
- package/dist/prefix/compare.js.map +1 -0
- package/dist/prefix/mask.d.ts +26 -0
- package/dist/prefix/mask.d.ts.map +1 -0
- package/dist/prefix/mask.js +48 -0
- package/dist/prefix/mask.js.map +1 -0
- package/dist/prefix/set-ops.d.ts +38 -0
- package/dist/prefix/set-ops.d.ts.map +1 -0
- package/dist/prefix/set-ops.js +71 -0
- package/dist/prefix/set-ops.js.map +1 -0
- package/package.json +66 -0
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { assertBitAddressWidth, bitAddressBitAt, bitAddressIsZero, bitAddressToBigInt, } from "../prefix/bit-address.js";
|
|
2
|
+
import { bitPrefixContains } from "../prefix/bit-prefix.js";
|
|
3
|
+
import { IPV6_BIT_WIDTH } from "./constants.js";
|
|
4
|
+
import { isIpv6Ipv4Compatible, isIpv6Ipv4Mapped } from "./ipv4-mapped.js";
|
|
5
|
+
import { parseIpv6Address, parseIpv6Prefix } from "./parse-ipv6.js";
|
|
6
|
+
/** `::` — the unspecified address, RFC 4291 §2.5.2. */
|
|
7
|
+
export const IPV6_UNSPECIFIED_ADDRESS = parseIpv6Address("::");
|
|
8
|
+
/** `::1` — the loopback address, RFC 4291 §2.5.3. */
|
|
9
|
+
export const IPV6_LOOPBACK_ADDRESS = parseIpv6Address("::1");
|
|
10
|
+
/** `fe80::/10` — link-local unicast, RFC 4291 §2.5.6. */
|
|
11
|
+
export const IPV6_LINK_LOCAL_PREFIX = parseIpv6Prefix("fe80::/10");
|
|
12
|
+
/** `fc00::/7` — unique local addresses, RFC 4193. */
|
|
13
|
+
export const IPV6_UNIQUE_LOCAL_PREFIX = parseIpv6Prefix("fc00::/7");
|
|
14
|
+
/** `ff00::/8` — multicast, RFC 4291 §2.7. */
|
|
15
|
+
export const IPV6_MULTICAST_PREFIX = parseIpv6Prefix("ff00::/8");
|
|
16
|
+
/** `2001:db8::/32` — documentation, RFC 3849. */
|
|
17
|
+
export const IPV6_DOCUMENTATION_PREFIX = parseIpv6Prefix("2001:db8::/32");
|
|
18
|
+
/** `2001::/32` — Teredo tunnelling, RFC 4380. */
|
|
19
|
+
export const IPV6_TEREDO_PREFIX = parseIpv6Prefix("2001::/32");
|
|
20
|
+
/** `2002::/16` — 6to4, RFC 3056. */
|
|
21
|
+
export const IPV6_6TO4_PREFIX = parseIpv6Prefix("2002::/16");
|
|
22
|
+
/**
|
|
23
|
+
* Classifies an address against RFC 4291 and the RFC 6890 special-purpose
|
|
24
|
+
* registry.
|
|
25
|
+
*
|
|
26
|
+
* Ordered narrowest first, because the blocks nest: `::1` sits inside `::/96`
|
|
27
|
+
* and must be reported as loopback rather than as IPv4-compatible, and
|
|
28
|
+
* `2001:db8::/32` sits beside — not inside — Teredo's `2001::/32`. O(1).
|
|
29
|
+
*
|
|
30
|
+
* @throws RangeError When the address is not 128 bits wide.
|
|
31
|
+
*/
|
|
32
|
+
export function classifyIpv6Address(address) {
|
|
33
|
+
assertBitAddressWidth(address, IPV6_BIT_WIDTH);
|
|
34
|
+
if (bitAddressIsZero(address)) {
|
|
35
|
+
return "unspecified";
|
|
36
|
+
}
|
|
37
|
+
if (bitAddressToBigInt(address) === 1n) {
|
|
38
|
+
return "loopback";
|
|
39
|
+
}
|
|
40
|
+
if (isIpv6Ipv4Mapped(address)) {
|
|
41
|
+
return "ipv4-mapped";
|
|
42
|
+
}
|
|
43
|
+
if (isIpv6Ipv4Compatible(address)) {
|
|
44
|
+
return "ipv4-compatible";
|
|
45
|
+
}
|
|
46
|
+
if (bitPrefixContains(IPV6_MULTICAST_PREFIX, address)) {
|
|
47
|
+
return "multicast";
|
|
48
|
+
}
|
|
49
|
+
if (bitPrefixContains(IPV6_LINK_LOCAL_PREFIX, address)) {
|
|
50
|
+
return "link-local";
|
|
51
|
+
}
|
|
52
|
+
if (bitPrefixContains(IPV6_UNIQUE_LOCAL_PREFIX, address)) {
|
|
53
|
+
return "unique-local";
|
|
54
|
+
}
|
|
55
|
+
if (bitPrefixContains(IPV6_DOCUMENTATION_PREFIX, address)) {
|
|
56
|
+
return "documentation";
|
|
57
|
+
}
|
|
58
|
+
if (bitPrefixContains(IPV6_TEREDO_PREFIX, address)) {
|
|
59
|
+
return "teredo";
|
|
60
|
+
}
|
|
61
|
+
if (bitPrefixContains(IPV6_6TO4_PREFIX, address)) {
|
|
62
|
+
return "6to4";
|
|
63
|
+
}
|
|
64
|
+
return "global";
|
|
65
|
+
}
|
|
66
|
+
/** Whether the address is `::`. */
|
|
67
|
+
export function isIpv6Unspecified(address) {
|
|
68
|
+
return classifyIpv6Address(address) === "unspecified";
|
|
69
|
+
}
|
|
70
|
+
/** Whether the address is `::1`. */
|
|
71
|
+
export function isIpv6Loopback(address) {
|
|
72
|
+
return classifyIpv6Address(address) === "loopback";
|
|
73
|
+
}
|
|
74
|
+
/** Whether the address is in `fe80::/10`. */
|
|
75
|
+
export function isIpv6LinkLocal(address) {
|
|
76
|
+
return classifyIpv6Address(address) === "link-local";
|
|
77
|
+
}
|
|
78
|
+
/** Whether the address is in `fc00::/7`. */
|
|
79
|
+
export function isIpv6UniqueLocal(address) {
|
|
80
|
+
return classifyIpv6Address(address) === "unique-local";
|
|
81
|
+
}
|
|
82
|
+
/** Whether the address is in `ff00::/8`. */
|
|
83
|
+
export function isIpv6Multicast(address) {
|
|
84
|
+
return classifyIpv6Address(address) === "multicast";
|
|
85
|
+
}
|
|
86
|
+
/** Whether the address is in `2001:db8::/32`. */
|
|
87
|
+
export function isIpv6Documentation(address) {
|
|
88
|
+
return classifyIpv6Address(address) === "documentation";
|
|
89
|
+
}
|
|
90
|
+
/** Whether the address is in `2001::/32`. */
|
|
91
|
+
export function isIpv6Teredo(address) {
|
|
92
|
+
return classifyIpv6Address(address) === "teredo";
|
|
93
|
+
}
|
|
94
|
+
/** Whether the address is in `2002::/16`. */
|
|
95
|
+
export function isIpv6SixToFour(address) {
|
|
96
|
+
return classifyIpv6Address(address) === "6to4";
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Whether the address falls in any enumerated special-purpose block.
|
|
100
|
+
*
|
|
101
|
+
* An SSRF guard wants this on the parsed address, and must also unwrap an
|
|
102
|
+
* IPv4-mapped literal with `ipv4FromIpv6` before classifying:
|
|
103
|
+
* `::ffff:127.0.0.1` is loopback, and no substring test for `127.` finds it.
|
|
104
|
+
*/
|
|
105
|
+
export function isIpv6SpecialPurpose(address) {
|
|
106
|
+
return classifyIpv6Address(address) !== "global";
|
|
107
|
+
}
|
|
108
|
+
const MULTICAST_SCOPES = {
|
|
109
|
+
0x0: "reserved",
|
|
110
|
+
0x1: "interface-local",
|
|
111
|
+
0x2: "link-local",
|
|
112
|
+
0x3: "realm-local",
|
|
113
|
+
0x4: "admin-local",
|
|
114
|
+
0x5: "site-local",
|
|
115
|
+
0x8: "organization-local",
|
|
116
|
+
0xe: "global",
|
|
117
|
+
0xf: "reserved",
|
|
118
|
+
};
|
|
119
|
+
/**
|
|
120
|
+
* The scope nibble of a multicast address.
|
|
121
|
+
*
|
|
122
|
+
* @returns `null` when the address is not multicast.
|
|
123
|
+
* @throws RangeError When the address is not 128 bits wide.
|
|
124
|
+
*/
|
|
125
|
+
export function ipv6MulticastScope(address) {
|
|
126
|
+
assertBitAddressWidth(address, IPV6_BIT_WIDTH);
|
|
127
|
+
if (!bitPrefixContains(IPV6_MULTICAST_PREFIX, address)) {
|
|
128
|
+
return null;
|
|
129
|
+
}
|
|
130
|
+
// RFC 4291 §2.7 lays the second octet out as `flgs` then `scop`.
|
|
131
|
+
return (MULTICAST_SCOPES[Number((address.value >> BigInt(IPV6_BIT_WIDTH - 16)) & 0xfn)] ?? "unassigned");
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Whether the multicast address is transient — assigned dynamically rather than
|
|
135
|
+
* by IANA, which is the `T` flag of RFC 4291 §2.7.
|
|
136
|
+
*
|
|
137
|
+
* @returns `null` when the address is not multicast.
|
|
138
|
+
* @throws RangeError When the address is not 128 bits wide.
|
|
139
|
+
*/
|
|
140
|
+
export function isIpv6TransientMulticast(address) {
|
|
141
|
+
assertBitAddressWidth(address, IPV6_BIT_WIDTH);
|
|
142
|
+
if (!bitPrefixContains(IPV6_MULTICAST_PREFIX, address)) {
|
|
143
|
+
return null;
|
|
144
|
+
}
|
|
145
|
+
// The `T` flag is the last of the four `flgs` bits, so bit 11 overall.
|
|
146
|
+
return bitAddressBitAt(address, 11) === 1;
|
|
147
|
+
}
|
|
148
|
+
//# sourceMappingURL=classify-ipv6.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"classify-ipv6.js","sourceRoot":"","sources":["../../src/ipv6/classify-ipv6.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,qBAAqB,EACrB,eAAe,EACf,gBAAgB,EAChB,kBAAkB,GAClB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAkB,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAC1E,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEpE,uDAAuD;AACvD,MAAM,CAAC,MAAM,wBAAwB,GAAe,gBAAgB,CAAC,IAAI,CAAC,CAAC;AAE3E,qDAAqD;AACrD,MAAM,CAAC,MAAM,qBAAqB,GAAe,gBAAgB,CAAC,KAAK,CAAC,CAAC;AAEzE,yDAAyD;AACzD,MAAM,CAAC,MAAM,sBAAsB,GAAc,eAAe,CAAC,WAAW,CAAC,CAAC;AAE9E,qDAAqD;AACrD,MAAM,CAAC,MAAM,wBAAwB,GAAc,eAAe,CAAC,UAAU,CAAC,CAAC;AAE/E,6CAA6C;AAC7C,MAAM,CAAC,MAAM,qBAAqB,GAAc,eAAe,CAAC,UAAU,CAAC,CAAC;AAE5E,iDAAiD;AACjD,MAAM,CAAC,MAAM,yBAAyB,GACrC,eAAe,CAAC,eAAe,CAAC,CAAC;AAElC,iDAAiD;AACjD,MAAM,CAAC,MAAM,kBAAkB,GAAc,eAAe,CAAC,WA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G,EAAE,YAAY;IACjB,GAAG,EAAE,oBAAoB;IACzB,GAAG,EAAE,QAAQ;IACb,GAAG,EAAE,UAAU;CACf,CAAC;AAEF;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CACjC,OAAmB;IAEnB,qBAAqB,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;IAE/C,IAAI,CAAC,iBAAiB,CAAC,qBAAqB,EAAE,OAAO,CAAC,EAAE,CAAC;QACxD,OAAO,IAAI,CAAC;IACb,CAAC;IAED,iEAAiE;IACjE,OAAO,CACN,gBAAgB,CACf,MAAM,CAAC,CAAC,OAAO,CAAC,KAAK,IAAI,MAAM,CAAC,cAAc,GAAG,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAC7D,IAAI,YAAY,CACjB,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,wBAAwB,CAAC,OAAmB;IAC3D,qBAAqB,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;IAE/C,IAAI,CAAC,iBAAiB,CAAC,qBAAqB,EAAE,OAAO,CAAC,EAAE,CAAC;QACxD,OAAO,IAAI,CAAC;IACb,CAAC;IAED,uEAAuE;IACvE,OAAO,eAAe,CAAC,OAAO,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC;AAC3C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/ipv6/constants.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,eAAO,MAAM,cAAc,MAAM,CAAC;AAElC,yDAAyD;AACzD,eAAO,MAAM,gBAAgB,IAAI,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/ipv6/constants.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,CAAC;AAElC,yDAAyD;AACzD,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { type BitAddress } from "../prefix/bit-address.js";
|
|
2
|
+
import { type BitPrefix } from "../prefix/bit-prefix.js";
|
|
3
|
+
/** `::ffff:0:0/96` — the IPv4-mapped block, RFC 4291 §2.5.5.2. */
|
|
4
|
+
export declare const IPV6_IPV4_MAPPED_PREFIX: BitPrefix;
|
|
5
|
+
/** `::/96` — the deprecated IPv4-compatible block, RFC 4291 §2.5.5.1. */
|
|
6
|
+
export declare const IPV6_IPV4_COMPATIBLE_PREFIX: BitPrefix;
|
|
7
|
+
/**
|
|
8
|
+
* Whether the address is IPv4-mapped — `::ffff:a.b.c.d`.
|
|
9
|
+
*
|
|
10
|
+
* @throws RangeError When the address is not 128 bits wide.
|
|
11
|
+
*/
|
|
12
|
+
export declare function isIpv6Ipv4Mapped(address: BitAddress): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Whether the address is IPv4-compatible — `::a.b.c.d`, deprecated by RFC 4291.
|
|
15
|
+
*
|
|
16
|
+
* `::` and `::1` are excluded: both fall in `::/96` numerically but neither
|
|
17
|
+
* embeds an IPv4 address.
|
|
18
|
+
*
|
|
19
|
+
* @throws RangeError When the address is not 128 bits wide.
|
|
20
|
+
*/
|
|
21
|
+
export declare function isIpv6Ipv4Compatible(address: BitAddress): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* The IPv4-mapped form of an IPv4 address: `192.0.2.1` becomes
|
|
24
|
+
* `::ffff:192.0.2.1`.
|
|
25
|
+
*
|
|
26
|
+
* @throws RangeError When the address is not 32 bits wide.
|
|
27
|
+
*/
|
|
28
|
+
export declare function ipv6FromIpv4(address: BitAddress): BitAddress;
|
|
29
|
+
/**
|
|
30
|
+
* The IPv4 address an IPv4-mapped or IPv4-compatible literal embeds.
|
|
31
|
+
*
|
|
32
|
+
* @returns `null` when the address embeds neither.
|
|
33
|
+
* @throws RangeError When the address is not 128 bits wide.
|
|
34
|
+
*/
|
|
35
|
+
export declare function ipv4FromIpv6(address: BitAddress): BitAddress | null;
|
|
36
|
+
/**
|
|
37
|
+
* Widens an IPv4 prefix to its IPv4-mapped counterpart: `10.0.0.0/8` becomes
|
|
38
|
+
* `::ffff:10.0.0.0/104`.
|
|
39
|
+
*
|
|
40
|
+
* @throws RangeError When the prefix is not over a 32-bit address.
|
|
41
|
+
*/
|
|
42
|
+
export declare function ipv6PrefixFromIpv4Prefix(prefix: BitPrefix): BitPrefix;
|
|
43
|
+
//# sourceMappingURL=ipv4-mapped.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ipv4-mapped.d.ts","sourceRoot":"","sources":["../../src/ipv6/ipv4-mapped.ts"],"names":[],"mappings":"AACA,OAAO,EACN,KAAK,UAAU,EAIf,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,KAAK,SAAS,EAAmB,MAAM,yBAAyB,CAAC;AAI1E,kEAAkE;AAClE,eAAO,MAAM,uBAAuB,EAAE,SACL,CAAC;AAElC,yEAAyE;AACzE,eAAO,MAAM,2BAA2B,EAAE,SAAoC,CAAC;AAE/E;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAI7D;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAIjE;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,UAAU,GAAG,UAAU,CAO5D;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,UAAU,GAAG,UAAU,GAAG,IAAI,CASnE;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,SAAS,GAAG,SAAS,CAKrE"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { IPV4_BIT_WIDTH } from "../ipv4/constants.js";
|
|
2
|
+
import { assertBitAddressWidth, bitAddressFromBigInt, bitAddressToBigInt, } from "../prefix/bit-address.js";
|
|
3
|
+
import { createBitPrefix } from "../prefix/bit-prefix.js";
|
|
4
|
+
import { IPV6_BIT_WIDTH } from "./constants.js";
|
|
5
|
+
import { parseIpv6Prefix } from "./parse-ipv6.js";
|
|
6
|
+
/** `::ffff:0:0/96` — the IPv4-mapped block, RFC 4291 §2.5.5.2. */
|
|
7
|
+
export const IPV6_IPV4_MAPPED_PREFIX = parseIpv6Prefix("::ffff:0:0/96");
|
|
8
|
+
/** `::/96` — the deprecated IPv4-compatible block, RFC 4291 §2.5.5.1. */
|
|
9
|
+
export const IPV6_IPV4_COMPATIBLE_PREFIX = parseIpv6Prefix("::/96");
|
|
10
|
+
/**
|
|
11
|
+
* Whether the address is IPv4-mapped — `::ffff:a.b.c.d`.
|
|
12
|
+
*
|
|
13
|
+
* @throws RangeError When the address is not 128 bits wide.
|
|
14
|
+
*/
|
|
15
|
+
export function isIpv6Ipv4Mapped(address) {
|
|
16
|
+
assertBitAddressWidth(address, IPV6_BIT_WIDTH);
|
|
17
|
+
return address.value >> BigInt(IPV4_BIT_WIDTH) === 0xffffn;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Whether the address is IPv4-compatible — `::a.b.c.d`, deprecated by RFC 4291.
|
|
21
|
+
*
|
|
22
|
+
* `::` and `::1` are excluded: both fall in `::/96` numerically but neither
|
|
23
|
+
* embeds an IPv4 address.
|
|
24
|
+
*
|
|
25
|
+
* @throws RangeError When the address is not 128 bits wide.
|
|
26
|
+
*/
|
|
27
|
+
export function isIpv6Ipv4Compatible(address) {
|
|
28
|
+
assertBitAddressWidth(address, IPV6_BIT_WIDTH);
|
|
29
|
+
return address.value >> BigInt(IPV4_BIT_WIDTH) === 0n && address.value > 1n;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The IPv4-mapped form of an IPv4 address: `192.0.2.1` becomes
|
|
33
|
+
* `::ffff:192.0.2.1`.
|
|
34
|
+
*
|
|
35
|
+
* @throws RangeError When the address is not 32 bits wide.
|
|
36
|
+
*/
|
|
37
|
+
export function ipv6FromIpv4(address) {
|
|
38
|
+
assertBitAddressWidth(address, IPV4_BIT_WIDTH);
|
|
39
|
+
return {
|
|
40
|
+
value: (0xffffn << BigInt(IPV4_BIT_WIDTH)) | address.value,
|
|
41
|
+
bitWidth: IPV6_BIT_WIDTH,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* The IPv4 address an IPv4-mapped or IPv4-compatible literal embeds.
|
|
46
|
+
*
|
|
47
|
+
* @returns `null` when the address embeds neither.
|
|
48
|
+
* @throws RangeError When the address is not 128 bits wide.
|
|
49
|
+
*/
|
|
50
|
+
export function ipv4FromIpv6(address) {
|
|
51
|
+
if (!isIpv6Ipv4Mapped(address) && !isIpv6Ipv4Compatible(address)) {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
return bitAddressFromBigInt(bitAddressToBigInt(address) & 0xffffffffn, IPV4_BIT_WIDTH);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Widens an IPv4 prefix to its IPv4-mapped counterpart: `10.0.0.0/8` becomes
|
|
58
|
+
* `::ffff:10.0.0.0/104`.
|
|
59
|
+
*
|
|
60
|
+
* @throws RangeError When the prefix is not over a 32-bit address.
|
|
61
|
+
*/
|
|
62
|
+
export function ipv6PrefixFromIpv4Prefix(prefix) {
|
|
63
|
+
return createBitPrefix(ipv6FromIpv4(prefix.address), IPV6_BIT_WIDTH - IPV4_BIT_WIDTH + prefix.prefixLength);
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=ipv4-mapped.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ipv4-mapped.js","sourceRoot":"","sources":["../../src/ipv6/ipv4-mapped.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAEN,qBAAqB,EACrB,oBAAoB,EACpB,kBAAk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oBAAoB,CAC1B,kBAAkB,CAAC,OAAO,CAAC,GAAG,WAAc,EAC5C,cAAc,CACd,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,wBAAwB,CAAC,MAAiB;IACzD,OAAO,eAAe,CACrB,YAAY,CAAC,MAAM,CAAC,OAAO,CAAC,EAC5B,cAAc,GAAG,cAAc,GAAG,MAAM,CAAC,YAAY,CACrD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { type BitAddress } from "../prefix/bit-address.js";
|
|
2
|
+
import { type BitPrefix } from "../prefix/bit-prefix.js";
|
|
3
|
+
import type { BitRange } from "../prefix/bit-range.js";
|
|
4
|
+
/**
|
|
5
|
+
* The prefix's lowest address, host bits cleared.
|
|
6
|
+
*
|
|
7
|
+
* @throws RangeError When the prefix is not over a 128-bit address.
|
|
8
|
+
*/
|
|
9
|
+
export declare function ipv6NetworkAddress(prefix: BitPrefix): BitAddress;
|
|
10
|
+
/**
|
|
11
|
+
* The prefix's highest address. IPv6 has no broadcast address, so this is an
|
|
12
|
+
* ordinary assignable one.
|
|
13
|
+
*
|
|
14
|
+
* @throws RangeError When the prefix is not over a 128-bit address.
|
|
15
|
+
*/
|
|
16
|
+
export declare function ipv6LastAddress(prefix: BitPrefix): BitAddress;
|
|
17
|
+
/**
|
|
18
|
+
* How many addresses the prefix covers. A `bigint`, because a `/64` holds 2⁶⁴
|
|
19
|
+
* of them and a `double` cannot count that far exactly.
|
|
20
|
+
*
|
|
21
|
+
* @throws RangeError When the prefix is not over a 128-bit address.
|
|
22
|
+
*/
|
|
23
|
+
export declare function ipv6AddressCount(prefix: BitPrefix): bigint;
|
|
24
|
+
/**
|
|
25
|
+
* Every address of the prefix.
|
|
26
|
+
*
|
|
27
|
+
* IPv6 reserves no broadcast address, so unlike IPv4 nothing is excluded at the
|
|
28
|
+
* top. The lowest address is the Subnet-Router anycast address (RFC 4291
|
|
29
|
+
* §2.6.1) on a subnet with a 64-bit interface identifier, which is why
|
|
30
|
+
* {@link ipv6SubnetRouterAnycastAddress} names it separately rather than this
|
|
31
|
+
* range dropping it.
|
|
32
|
+
*
|
|
33
|
+
* @throws RangeError When the prefix is not over a 128-bit address.
|
|
34
|
+
*/
|
|
35
|
+
export declare function ipv6UsableHostRange(prefix: BitPrefix): BitRange;
|
|
36
|
+
/**
|
|
37
|
+
* The Subnet-Router anycast address, RFC 4291 §2.6.1: the subnet prefix with an
|
|
38
|
+
* all-zero interface identifier. Every router on the link answers to it.
|
|
39
|
+
*
|
|
40
|
+
* @throws RangeError When the prefix is not over a 128-bit address.
|
|
41
|
+
*/
|
|
42
|
+
export declare function ipv6SubnetRouterAnycastAddress(prefix: BitPrefix): BitAddress;
|
|
43
|
+
/**
|
|
44
|
+
* The first address after the Subnet-Router anycast address — where host
|
|
45
|
+
* numbering conventionally starts.
|
|
46
|
+
*
|
|
47
|
+
* @throws RangeError When the prefix is not over a 128-bit address, or covers a
|
|
48
|
+
* single address.
|
|
49
|
+
*/
|
|
50
|
+
export declare function ipv6FirstHost(prefix: BitPrefix): BitAddress;
|
|
51
|
+
//# sourceMappingURL=ipv6-prefix.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ipv6-prefix.d.ts","sourceRoot":"","sources":["../../src/ipv6/ipv6-prefix.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,UAAU,EAGf,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACN,KAAK,SAAS,EAId,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAOvD;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,SAAS,GAAG,UAAU,CAIhE;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,SAAS,GAAG,UAAU,CAI7D;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,SAAS,GAAG,MAAM,CAI1D;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,SAAS,GAAG,QAAQ,CAO/D;AAED;;;;;GAKG;AACH,wBAAgB,8BAA8B,CAAC,MAAM,EAAE,SAAS,GAAG,UAAU,CAI5E;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,SAAS,GAAG,UAAU,CAQ3D"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { assertBitAddressWidth, bitAddressAdd, } from "../prefix/bit-address.js";
|
|
2
|
+
import { bitPrefixAddressCount, bitPrefixFirstAddress, bitPrefixLastAddress, } from "../prefix/bit-prefix.js";
|
|
3
|
+
import { IPV6_BIT_WIDTH } from "./constants.js";
|
|
4
|
+
function assertIpv6Prefix(prefix) {
|
|
5
|
+
assertBitAddressWidth(prefix.address, IPV6_BIT_WIDTH);
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* The prefix's lowest address, host bits cleared.
|
|
9
|
+
*
|
|
10
|
+
* @throws RangeError When the prefix is not over a 128-bit address.
|
|
11
|
+
*/
|
|
12
|
+
export function ipv6NetworkAddress(prefix) {
|
|
13
|
+
assertIpv6Prefix(prefix);
|
|
14
|
+
return bitPrefixFirstAddress(prefix);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* The prefix's highest address. IPv6 has no broadcast address, so this is an
|
|
18
|
+
* ordinary assignable one.
|
|
19
|
+
*
|
|
20
|
+
* @throws RangeError When the prefix is not over a 128-bit address.
|
|
21
|
+
*/
|
|
22
|
+
export function ipv6LastAddress(prefix) {
|
|
23
|
+
assertIpv6Prefix(prefix);
|
|
24
|
+
return bitPrefixLastAddress(prefix);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* How many addresses the prefix covers. A `bigint`, because a `/64` holds 2⁶⁴
|
|
28
|
+
* of them and a `double` cannot count that far exactly.
|
|
29
|
+
*
|
|
30
|
+
* @throws RangeError When the prefix is not over a 128-bit address.
|
|
31
|
+
*/
|
|
32
|
+
export function ipv6AddressCount(prefix) {
|
|
33
|
+
assertIpv6Prefix(prefix);
|
|
34
|
+
return bitPrefixAddressCount(prefix);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Every address of the prefix.
|
|
38
|
+
*
|
|
39
|
+
* IPv6 reserves no broadcast address, so unlike IPv4 nothing is excluded at the
|
|
40
|
+
* top. The lowest address is the Subnet-Router anycast address (RFC 4291
|
|
41
|
+
* §2.6.1) on a subnet with a 64-bit interface identifier, which is why
|
|
42
|
+
* {@link ipv6SubnetRouterAnycastAddress} names it separately rather than this
|
|
43
|
+
* range dropping it.
|
|
44
|
+
*
|
|
45
|
+
* @throws RangeError When the prefix is not over a 128-bit address.
|
|
46
|
+
*/
|
|
47
|
+
export function ipv6UsableHostRange(prefix) {
|
|
48
|
+
assertIpv6Prefix(prefix);
|
|
49
|
+
return {
|
|
50
|
+
first: bitPrefixFirstAddress(prefix),
|
|
51
|
+
last: bitPrefixLastAddress(prefix),
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* The Subnet-Router anycast address, RFC 4291 §2.6.1: the subnet prefix with an
|
|
56
|
+
* all-zero interface identifier. Every router on the link answers to it.
|
|
57
|
+
*
|
|
58
|
+
* @throws RangeError When the prefix is not over a 128-bit address.
|
|
59
|
+
*/
|
|
60
|
+
export function ipv6SubnetRouterAnycastAddress(prefix) {
|
|
61
|
+
assertIpv6Prefix(prefix);
|
|
62
|
+
return bitPrefixFirstAddress(prefix);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* The first address after the Subnet-Router anycast address — where host
|
|
66
|
+
* numbering conventionally starts.
|
|
67
|
+
*
|
|
68
|
+
* @throws RangeError When the prefix is not over a 128-bit address, or covers a
|
|
69
|
+
* single address.
|
|
70
|
+
*/
|
|
71
|
+
export function ipv6FirstHost(prefix) {
|
|
72
|
+
assertIpv6Prefix(prefix);
|
|
73
|
+
if (prefix.prefixLength === IPV6_BIT_WIDTH) {
|
|
74
|
+
return bitPrefixFirstAddress(prefix);
|
|
75
|
+
}
|
|
76
|
+
return bitAddressAdd(bitPrefixFirstAddress(prefix), 1n);
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=ipv6-prefix.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ipv6-prefix.js","sourceRoot":"","sources":["../../src/ipv6/ipv6-prefix.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,qBAAqB,EACrB,aAAa,GACb,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAEN,qBAAqB,EACrB,qBAAqB,EACrB,oBAAoB,GACpB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEhD,SAAS,gBAAgB,CAAC,MAAiB;IAC1C,qBAAqB,CAAC,MAAM,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;AACvD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAAiB;IACnD,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAEzB,OAAO,qBAAqB,CAAC,MAAM,CAAC,CAAC;AACtC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAC,MAAiB;IAChD,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAEzB,OAAO,oBAAoB,CAAC,MAAM,CAAC,CAAC;AACrC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,MAAiB;IACjD,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAEzB,OAAO,qBAAqB,CAAC,MAAM,CAAC,CAAC;AACtC,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,mBAAmB,CAAC,MAAiB;IACpD,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAEzB,OAAO;QACN,KAAK,EAAE,qBAAqB,CAAC,MAAM,CAAC;QACpC,IAAI,EAAE,oBAAoB,CAAC,MAAM,CAAC;KAClC,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,8BAA8B,CAAC,MAAiB;IAC/D,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAEzB,OAAO,qBAAqB,CAAC,MAAM,CAAC,CAAC;AACtC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,MAAiB;IAC9C,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAEzB,IAAI,MAAM,CAAC,YAAY,KAAK,cAAc,EAAE,CAAC;QAC5C,OAAO,qBAAqB,CAAC,MAAM,CAAC,CAAC;IACtC,CAAC;IAED,OAAO,aAAa,CAAC,qBAAqB,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC,CAAC;AACzD,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { BitAddress } from "../prefix/bit-address.js";
|
|
2
|
+
import { type BitPrefix } from "../prefix/bit-prefix.js";
|
|
3
|
+
/**
|
|
4
|
+
* An address together with the RFC 4007 zone that disambiguates it.
|
|
5
|
+
*
|
|
6
|
+
* A link-local address is only meaningful beside the interface it is scoped to,
|
|
7
|
+
* which is what `fe80::1%eth0` says.
|
|
8
|
+
*/
|
|
9
|
+
export type Ipv6ScopedAddress = {
|
|
10
|
+
readonly address: BitAddress;
|
|
11
|
+
/** The text after `%`, verbatim. `null` when the literal carried none. */
|
|
12
|
+
readonly zoneId: string | null;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Parses an RFC 4291 §2.2 literal: eight groups, or a `::` run standing for one
|
|
16
|
+
* or more zero groups, optionally ending in a strict dotted quad.
|
|
17
|
+
*
|
|
18
|
+
* A zone identifier is rejected here; {@link parseIpv6ScopedAddress} takes one.
|
|
19
|
+
* An embedded IPv4 part must be a strict dotted quad, for the reason
|
|
20
|
+
* `parseIpv4Address` documents.
|
|
21
|
+
*
|
|
22
|
+
* @returns The address, 128 bits wide.
|
|
23
|
+
* @throws NetAddressSyntaxError When `text` is not such a literal.
|
|
24
|
+
*/
|
|
25
|
+
export declare function parseIpv6Address(text: string): BitAddress;
|
|
26
|
+
/** {@link parseIpv6Address}, answering `null` instead of throwing. O(1). */
|
|
27
|
+
export declare function tryParseIpv6Address(text: string): BitAddress | null;
|
|
28
|
+
/**
|
|
29
|
+
* Parses an RFC 4291 literal with an optional RFC 4007 zone identifier.
|
|
30
|
+
*
|
|
31
|
+
* Everything after `%` is the zone, verbatim. RFC 6874's `%25` percent-encoding
|
|
32
|
+
* is a URI-layer concern: decode it before calling, or a zone genuinely named
|
|
33
|
+
* `25eth0` becomes indistinguishable from an encoded `eth0`.
|
|
34
|
+
*
|
|
35
|
+
* @throws NetAddressSyntaxError When `text` is not such a literal, or the zone
|
|
36
|
+
* is empty.
|
|
37
|
+
*/
|
|
38
|
+
export declare function parseIpv6ScopedAddress(text: string): Ipv6ScopedAddress;
|
|
39
|
+
/** {@link parseIpv6ScopedAddress}, answering `null` instead of throwing. */
|
|
40
|
+
export declare function tryParseIpv6ScopedAddress(text: string): Ipv6ScopedAddress | null;
|
|
41
|
+
/**
|
|
42
|
+
* Parses CIDR notation over an IPv6 literal. Host bits are kept.
|
|
43
|
+
*
|
|
44
|
+
* @throws NetAddressSyntaxError When `text` is not `address/length`, or the
|
|
45
|
+
* length is not an integer in `[0, 128]`.
|
|
46
|
+
*/
|
|
47
|
+
export declare function parseIpv6Prefix(text: string): BitPrefix;
|
|
48
|
+
/** {@link parseIpv6Prefix}, answering `null` instead of throwing. O(1). */
|
|
49
|
+
export declare function tryParseIpv6Prefix(text: string): BitPrefix | null;
|
|
50
|
+
//# sourceMappingURL=parse-ipv6.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-ipv6.d.ts","sourceRoot":"","sources":["../../src/ipv6/parse-ipv6.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,KAAK,SAAS,EAAmB,MAAM,yBAAyB,CAAC;AAG1E;;;;;GAKG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC/B,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC;IAE7B,0EAA0E;IAC1E,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B,CAAC;AAmDF;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAQzD;AAED,4EAA4E;AAC5E,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI,CA4CnE;AAED;;;;;;;;;GASG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,iBAAiB,CAQtE;AAED,4EAA4E;AAC5E,wBAAgB,yBAAyB,CACxC,IAAI,EAAE,MAAM,GACV,iBAAiB,GAAG,IAAI,CAiB1B;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAQvD;AAED,2EAA2E;AAC3E,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAmBjE"}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { NetAddressSyntaxError } from "../errors.js";
|
|
2
|
+
import { tryParseIpv4Address } from "../ipv4/parse-ipv4.js";
|
|
3
|
+
import { createBitPrefix } from "../prefix/bit-prefix.js";
|
|
4
|
+
import { IPV6_BIT_WIDTH, IPV6_GROUP_COUNT } from "./constants.js";
|
|
5
|
+
const HEX_GROUP_PATTERN = /^[0-9a-fA-F]{1,4}$/;
|
|
6
|
+
/** Appends the 16-bit groups a `:`-separated run spells, or answers `false`. */
|
|
7
|
+
function readGroups(parts, groups) {
|
|
8
|
+
for (let index = 0; index < parts.length; index++) {
|
|
9
|
+
// Non-null: `index` runs over the array's own length.
|
|
10
|
+
const part = parts[index];
|
|
11
|
+
// A dotted quad is only legal as the final element, and must be strict:
|
|
12
|
+
// `::ffff:0177.0.0.1` would otherwise smuggle loopback past a check.
|
|
13
|
+
if (part.includes(".")) {
|
|
14
|
+
if (index !== parts.length - 1) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
const embedded = tryParseIpv4Address(part);
|
|
18
|
+
if (embedded === null) {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
groups.push(Number(embedded.value >> 16n), Number(embedded.value & 0xffffn));
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
if (!HEX_GROUP_PATTERN.test(part)) {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
groups.push(Number.parseInt(part, 16));
|
|
28
|
+
}
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
function groupsToAddress(groups) {
|
|
32
|
+
let value = 0n;
|
|
33
|
+
for (let index = 0; index < groups.length; index++) {
|
|
34
|
+
// Non-null: `index` runs over the array's own length.
|
|
35
|
+
value = (value << 16n) | BigInt(groups[index]);
|
|
36
|
+
}
|
|
37
|
+
return { value, bitWidth: IPV6_BIT_WIDTH };
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Parses an RFC 4291 §2.2 literal: eight groups, or a `::` run standing for one
|
|
41
|
+
* or more zero groups, optionally ending in a strict dotted quad.
|
|
42
|
+
*
|
|
43
|
+
* A zone identifier is rejected here; {@link parseIpv6ScopedAddress} takes one.
|
|
44
|
+
* An embedded IPv4 part must be a strict dotted quad, for the reason
|
|
45
|
+
* `parseIpv4Address` documents.
|
|
46
|
+
*
|
|
47
|
+
* @returns The address, 128 bits wide.
|
|
48
|
+
* @throws NetAddressSyntaxError When `text` is not such a literal.
|
|
49
|
+
*/
|
|
50
|
+
export function parseIpv6Address(text) {
|
|
51
|
+
const address = tryParseIpv6Address(text);
|
|
52
|
+
if (address === null) {
|
|
53
|
+
throw new NetAddressSyntaxError(text, "not an IPv6 address");
|
|
54
|
+
}
|
|
55
|
+
return address;
|
|
56
|
+
}
|
|
57
|
+
/** {@link parseIpv6Address}, answering `null` instead of throwing. O(1). */
|
|
58
|
+
export function tryParseIpv6Address(text) {
|
|
59
|
+
if (text.includes("%")) {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
const compressionIndex = text.indexOf("::");
|
|
63
|
+
if (compressionIndex < 0) {
|
|
64
|
+
const groups = [];
|
|
65
|
+
if (!readGroups(text.split(":"), groups)) {
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
return groups.length === IPV6_GROUP_COUNT ? groupsToAddress(groups) : null;
|
|
69
|
+
}
|
|
70
|
+
if (text.includes("::", compressionIndex + 1)) {
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
const headText = text.slice(0, compressionIndex);
|
|
74
|
+
const tailText = text.slice(compressionIndex + 2);
|
|
75
|
+
const head = [];
|
|
76
|
+
const tail = [];
|
|
77
|
+
if (!readGroups(headText === "" ? [] : headText.split(":"), head) ||
|
|
78
|
+
!readGroups(tailText === "" ? [] : tailText.split(":"), tail)) {
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
// `::` stands for at least one group, so the explicit ones must leave room.
|
|
82
|
+
if (head.length + tail.length >= IPV6_GROUP_COUNT) {
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
const zeros = Array.from({ length: IPV6_GROUP_COUNT - head.length - tail.length }, () => 0);
|
|
86
|
+
return groupsToAddress([...head, ...zeros, ...tail]);
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Parses an RFC 4291 literal with an optional RFC 4007 zone identifier.
|
|
90
|
+
*
|
|
91
|
+
* Everything after `%` is the zone, verbatim. RFC 6874's `%25` percent-encoding
|
|
92
|
+
* is a URI-layer concern: decode it before calling, or a zone genuinely named
|
|
93
|
+
* `25eth0` becomes indistinguishable from an encoded `eth0`.
|
|
94
|
+
*
|
|
95
|
+
* @throws NetAddressSyntaxError When `text` is not such a literal, or the zone
|
|
96
|
+
* is empty.
|
|
97
|
+
*/
|
|
98
|
+
export function parseIpv6ScopedAddress(text) {
|
|
99
|
+
const scoped = tryParseIpv6ScopedAddress(text);
|
|
100
|
+
if (scoped === null) {
|
|
101
|
+
throw new NetAddressSyntaxError(text, "not a scoped IPv6 address");
|
|
102
|
+
}
|
|
103
|
+
return scoped;
|
|
104
|
+
}
|
|
105
|
+
/** {@link parseIpv6ScopedAddress}, answering `null` instead of throwing. */
|
|
106
|
+
export function tryParseIpv6ScopedAddress(text) {
|
|
107
|
+
const percentIndex = text.indexOf("%");
|
|
108
|
+
if (percentIndex < 0) {
|
|
109
|
+
const address = tryParseIpv6Address(text);
|
|
110
|
+
return address === null ? null : { address, zoneId: null };
|
|
111
|
+
}
|
|
112
|
+
const zoneId = text.slice(percentIndex + 1);
|
|
113
|
+
const address = tryParseIpv6Address(text.slice(0, percentIndex));
|
|
114
|
+
if (address === null || zoneId.length === 0 || zoneId.includes("%")) {
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
return { address, zoneId };
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Parses CIDR notation over an IPv6 literal. Host bits are kept.
|
|
121
|
+
*
|
|
122
|
+
* @throws NetAddressSyntaxError When `text` is not `address/length`, or the
|
|
123
|
+
* length is not an integer in `[0, 128]`.
|
|
124
|
+
*/
|
|
125
|
+
export function parseIpv6Prefix(text) {
|
|
126
|
+
const prefix = tryParseIpv6Prefix(text);
|
|
127
|
+
if (prefix === null) {
|
|
128
|
+
throw new NetAddressSyntaxError(text, "not an IPv6 CIDR prefix");
|
|
129
|
+
}
|
|
130
|
+
return prefix;
|
|
131
|
+
}
|
|
132
|
+
/** {@link parseIpv6Prefix}, answering `null` instead of throwing. O(1). */
|
|
133
|
+
export function tryParseIpv6Prefix(text) {
|
|
134
|
+
const slash = text.lastIndexOf("/");
|
|
135
|
+
if (slash < 0) {
|
|
136
|
+
return null;
|
|
137
|
+
}
|
|
138
|
+
const address = tryParseIpv6Address(text.slice(0, slash));
|
|
139
|
+
const lengthText = text.slice(slash + 1);
|
|
140
|
+
if (address === null || !/^(?:0|[1-9][0-9]{0,2})$/.test(lengthText)) {
|
|
141
|
+
return null;
|
|
142
|
+
}
|
|
143
|
+
const prefixLength = Number(lengthText);
|
|
144
|
+
return prefixLength <= IPV6_BIT_WIDTH
|
|
145
|
+
? createBitPrefix(address, prefixLength)
|
|
146
|
+
: null;
|
|
147
|
+
}
|
|
148
|
+
//# sourceMappingURL=parse-ipv6.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-ipv6.js","sourceRoot":"","sources":["../../src/ipv6/parse-ipv6.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,EAAkB,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1E,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAelE,MAAM,iBAAiB,GAAG,oBAAoB,CAAC;AAE/C,gFAAgF;AAChF,SAAS,UAAU,CAAC,KAAwB,EAAE,MAAgB;IAC7D,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC;QACnD,sDAAsD;QACtD,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAE,CAAC;QAE3B,wEAAwE;QACxE,qEAAqE;QACrE,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YACxB,IAAI,KAAK,KAAK,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAChC,OAAO,KAAK,CAAC;YACd,CAAC;YAED,MAAM,QAAQ,GAAG,mBAAmB,CAAC,IAAI,CAAC,CAAC;YAE3C,IAAI,QAA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