@ac-kit/net-address 0.5.0 → 0.6.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 +79 -0
- package/README.md +81 -1
- package/dist/eui/eui-bits.d.ts.map +1 -1
- package/dist/eui/eui-bits.js +7 -6
- package/dist/eui/eui-bits.js.map +1 -1
- package/dist/eui/print-eui.d.ts.map +1 -1
- package/dist/eui/print-eui.js +4 -4
- package/dist/eui/print-eui.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/ip/_ip-width.d.ts +3 -0
- package/dist/ip/_ip-width.d.ts.map +1 -0
- package/dist/ip/_ip-width.js +9 -0
- package/dist/ip/_ip-width.js.map +1 -0
- package/dist/ip/classify-ip.d.ts +54 -0
- package/dist/ip/classify-ip.d.ts.map +1 -0
- package/dist/ip/classify-ip.js +64 -0
- package/dist/ip/classify-ip.js.map +1 -0
- package/dist/ip/global-address-check.d.ts +56 -0
- package/dist/ip/global-address-check.d.ts.map +1 -0
- package/dist/ip/global-address-check.js +60 -0
- package/dist/ip/global-address-check.js.map +1 -0
- package/dist/ip/ip-address.d.ts.map +1 -1
- package/dist/ip/ip-address.js +5 -8
- package/dist/ip/ip-address.js.map +1 -1
- package/dist/ip/ip-prefix.d.ts +37 -0
- package/dist/ip/ip-prefix.d.ts.map +1 -0
- package/dist/ip/ip-prefix.js +70 -0
- package/dist/ip/ip-prefix.js.map +1 -0
- package/dist/ip/url-host.d.ts +31 -0
- package/dist/ip/url-host.d.ts.map +1 -0
- package/dist/ip/url-host.js +43 -0
- package/dist/ip/url-host.js.map +1 -0
- package/dist/ipv4/classify-ipv4.d.ts +16 -4
- package/dist/ipv4/classify-ipv4.d.ts.map +1 -1
- package/dist/ipv4/classify-ipv4.js +33 -18
- package/dist/ipv4/classify-ipv4.js.map +1 -1
- package/dist/ipv4/parse-ipv4.d.ts +4 -1
- package/dist/ipv4/parse-ipv4.d.ts.map +1 -1
- package/dist/ipv4/parse-ipv4.js +41 -13
- package/dist/ipv4/parse-ipv4.js.map +1 -1
- package/dist/ipv6/_embedded-ipv4.d.ts +8 -0
- package/dist/ipv6/_embedded-ipv4.d.ts.map +1 -0
- package/dist/ipv6/_embedded-ipv4.js +11 -0
- package/dist/ipv6/_embedded-ipv4.js.map +1 -0
- package/dist/ipv6/classify-ipv6.d.ts +51 -9
- package/dist/ipv6/classify-ipv6.d.ts.map +1 -1
- package/dist/ipv6/classify-ipv6.js +82 -13
- package/dist/ipv6/classify-ipv6.js.map +1 -1
- package/dist/ipv6/ipv4-mapped.d.ts.map +1 -1
- package/dist/ipv6/ipv4-mapped.js +6 -4
- package/dist/ipv6/ipv4-mapped.js.map +1 -1
- package/dist/ipv6/print-ipv6.d.ts +43 -10
- package/dist/ipv6/print-ipv6.d.ts.map +1 -1
- package/dist/ipv6/print-ipv6.js +64 -18
- package/dist/ipv6/print-ipv6.js.map +1 -1
- package/dist/prefix/_frozen.d.ts +6 -0
- package/dist/prefix/_frozen.d.ts.map +1 -0
- package/dist/prefix/_frozen.js +17 -0
- package/dist/prefix/_frozen.js.map +1 -0
- package/package.json +5 -4
|
@@ -6,31 +6,72 @@ export declare const IPV6_UNSPECIFIED_ADDRESS: BitAddress;
|
|
|
6
6
|
export declare const IPV6_LOOPBACK_ADDRESS: BitAddress;
|
|
7
7
|
/** `fe80::/10` — link-local unicast, RFC 4291 §2.5.6. */
|
|
8
8
|
export declare const IPV6_LINK_LOCAL_PREFIX: BitPrefix;
|
|
9
|
+
/**
|
|
10
|
+
* `fec0::/10` — site-local, deprecated by RFC 3879 but still routed inside some
|
|
11
|
+
* networks.
|
|
12
|
+
*/
|
|
13
|
+
export declare const IPV6_SITE_LOCAL_PREFIX: BitPrefix;
|
|
9
14
|
/** `fc00::/7` — unique local addresses, RFC 4193. */
|
|
10
15
|
export declare const IPV6_UNIQUE_LOCAL_PREFIX: BitPrefix;
|
|
11
16
|
/** `ff00::/8` — multicast, RFC 4291 §2.7. */
|
|
12
17
|
export declare const IPV6_MULTICAST_PREFIX: BitPrefix;
|
|
13
|
-
/** `2001:db8::/32` — documentation, RFC 3849. */
|
|
14
|
-
export declare const
|
|
18
|
+
/** `2001:db8::/32` and `3fff::/20` — documentation, RFC 3849 and RFC 9637. */
|
|
19
|
+
export declare const IPV6_DOCUMENTATION_PREFIXES: readonly BitPrefix[];
|
|
15
20
|
/** `2001::/32` — Teredo tunnelling, RFC 4380. */
|
|
16
21
|
export declare const IPV6_TEREDO_PREFIX: BitPrefix;
|
|
22
|
+
/** `2001:2::/48` — network device benchmarking, RFC 5180. */
|
|
23
|
+
export declare const IPV6_BENCHMARKING_PREFIX: BitPrefix;
|
|
24
|
+
/**
|
|
25
|
+
* `2001::/23` — IETF protocol assignments, RFC 2928: Teredo and benchmarking
|
|
26
|
+
* among them, and the anycast, AMT, AS112 and ORCHIDv2 blocks.
|
|
27
|
+
*/
|
|
28
|
+
export declare const IPV6_PROTOCOL_ASSIGNMENTS_PREFIX: BitPrefix;
|
|
17
29
|
/** `2002::/16` — 6to4, RFC 3056. */
|
|
18
30
|
export declare const IPV6_6TO4_PREFIX: BitPrefix;
|
|
31
|
+
/**
|
|
32
|
+
* `64:ff9b::/96` — the well-known IPv4/IPv6 translation prefix, RFC 6052: a
|
|
33
|
+
* NAT64 gateway forwards it to the IPv4 address in its last 32 bits.
|
|
34
|
+
*/
|
|
35
|
+
export declare const IPV6_NAT64_PREFIX: BitPrefix;
|
|
36
|
+
/** `64:ff9b:1::/48` — local-use IPv4/IPv6 translation, RFC 8215. */
|
|
37
|
+
export declare const IPV6_LOCAL_NAT64_PREFIX: BitPrefix;
|
|
38
|
+
/** `100::/64` — discard-only, RFC 6666. */
|
|
39
|
+
export declare const IPV6_DISCARD_PREFIX: BitPrefix;
|
|
40
|
+
/** `100:0:0:1::/64` — the dummy prefix, RFC 9780. */
|
|
41
|
+
export declare const IPV6_DUMMY_PREFIX: BitPrefix;
|
|
42
|
+
/** `5f00::/16` — segment routing (SRv6) SIDs, RFC 9602. */
|
|
43
|
+
export declare const IPV6_SRV6_SID_PREFIX: BitPrefix;
|
|
44
|
+
/**
|
|
45
|
+
* `2000::/3` — global unicast, RFC 4291 §2.4: the only block IANA assigns
|
|
46
|
+
* unicast addresses from. Outside it and the blocks above, the address space is
|
|
47
|
+
* reserved by the IETF.
|
|
48
|
+
*/
|
|
49
|
+
export declare const IPV6_GLOBAL_UNICAST_PREFIX: BitPrefix;
|
|
50
|
+
/** `3ffe::/16` — the 6bone test network, returned to IANA by RFC 3701. */
|
|
51
|
+
export declare const IPV6_6BONE_PREFIX: BitPrefix;
|
|
19
52
|
/**
|
|
20
53
|
* Which special-purpose block an address falls in.
|
|
21
54
|
*
|
|
22
|
-
* `"global"` means none of the blocks below —
|
|
23
|
-
* necessarily routable
|
|
24
|
-
*
|
|
55
|
+
* `"global"` means global unicast (`2000::/3`) in none of the blocks below —
|
|
56
|
+
* not that the address is necessarily routable. Every block the IANA registry
|
|
57
|
+
* marks not globally reachable is one of them; so are three it does not:
|
|
58
|
+
* Teredo, 6to4 and `2001::/23` whole, though the registry marks the anycast,
|
|
59
|
+
* AMT, AS112 and ORCHIDv2 blocks inside it reachable. `"reserved"` is the
|
|
60
|
+
* address space the IETF has kept back — everything outside `2000::/3` no other
|
|
61
|
+
* scope names, such as `fe00::/9` and `4000::/3` — and the returned 6bone
|
|
62
|
+
* block, `3ffe::/16`. `"nat64"` is as reachable as the IPv4 address it
|
|
63
|
+
* carries.
|
|
25
64
|
*/
|
|
26
|
-
export type Ipv6AddressScope = "unspecified" | "loopback" | "ipv4-mapped" | "ipv4-compatible" | "link-local" | "unique-local" | "multicast" | "documentation" | "teredo" | "6to4" | "global";
|
|
65
|
+
export type Ipv6AddressScope = "unspecified" | "loopback" | "ipv4-mapped" | "ipv4-compatible" | "link-local" | "site-local" | "unique-local" | "multicast" | "documentation" | "teredo" | "benchmarking" | "protocol-assignment" | "6to4" | "nat64" | "local-nat64" | "discard" | "dummy" | "segment-routing" | "reserved" | "global";
|
|
27
66
|
/**
|
|
28
67
|
* Classifies an address against RFC 4291 and the RFC 6890 special-purpose
|
|
29
68
|
* registry.
|
|
30
69
|
*
|
|
31
70
|
* Ordered narrowest first, because the blocks nest: `::1` sits inside `::/96`
|
|
32
|
-
* and must be reported as loopback rather than as IPv4-compatible, and
|
|
33
|
-
* `2001:db8::/32` sits beside — not inside
|
|
71
|
+
* and must be reported as loopback rather than as IPv4-compatible, and Teredo
|
|
72
|
+
* and benchmarking inside `2001::/23`; `2001:db8::/32` sits beside — not inside
|
|
73
|
+
* — either. Whatever is left is `"global"` inside `2000::/3`, and `"reserved"`
|
|
74
|
+
* outside it. O(1).
|
|
34
75
|
*
|
|
35
76
|
* @throws RangeError When the address is not 128 bits wide.
|
|
36
77
|
*/
|
|
@@ -45,7 +86,7 @@ export declare function isIpv6LinkLocal(address: BitAddress): boolean;
|
|
|
45
86
|
export declare function isIpv6UniqueLocal(address: BitAddress): boolean;
|
|
46
87
|
/** Whether the address is in `ff00::/8`. */
|
|
47
88
|
export declare function isIpv6Multicast(address: BitAddress): boolean;
|
|
48
|
-
/** Whether the address is in `2001:db8::/32`. */
|
|
89
|
+
/** Whether the address is in `2001:db8::/32` or `3fff::/20`. */
|
|
49
90
|
export declare function isIpv6Documentation(address: BitAddress): boolean;
|
|
50
91
|
/** Whether the address is in `2001::/32`. */
|
|
51
92
|
export declare function isIpv6Teredo(address: BitAddress): boolean;
|
|
@@ -57,6 +98,7 @@ export declare function isIpv6SixToFour(address: BitAddress): boolean;
|
|
|
57
98
|
* An SSRF guard wants this on the parsed address, and must also unwrap an
|
|
58
99
|
* IPv4-mapped literal with `ipv4FromIpv6` before classifying:
|
|
59
100
|
* `::ffff:127.0.0.1` is loopback, and no substring test for `127.` finds it.
|
|
101
|
+
* `isGlobalIpAddress` does both, for either family.
|
|
60
102
|
*/
|
|
61
103
|
export declare function isIpv6SpecialPurpose(address: BitAddress): boolean;
|
|
62
104
|
/** How far a multicast address is allowed to travel, RFC 4291 §2.7. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"classify-ipv6.d.ts","sourceRoot":"","sources":["../../src/ipv6/classify-ipv6.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"classify-ipv6.d.ts","sourceRoot":"","sources":["../../src/ipv6/classify-ipv6.ts"],"names":[],"mappings":"AAKA,OAAO,EACN,KAAK,UAAU,EAKf,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,KAAK,SAAS,EAAqB,MAAM,yBAAyB,CAAC;AAM5E,uDAAuD;AACvD,eAAO,MAAM,wBAAwB,EAAE,UAEtC,CAAC;AAEF,qDAAqD;AACrD,eAAO,MAAM,qBAAqB,EAAE,UAEnC,CAAC;AAEF,yDAAyD;AACzD,eAAO,MAAM,sBAAsB,EAAE,SAEpC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,sBAAsB,EAAE,SAEpC,CAAC;AAEF,qDAAqD;AACrD,eAAO,MAAM,wBAAwB,EAAE,SAEtC,CAAC;AAEF,6CAA6C;AAC7C,eAAO,MAAM,qBAAqB,EAAE,SAEnC,CAAC;AAEF,8EAA8E;AAC9E,eAAO,MAAM,2BAA2B,EAAE,SAAS,SAAS,EAIzD,CAAC;AAEJ,iDAAiD;AACjD,eAAO,MAAM,kBAAkB,EAAE,SAEhC,CAAC;AAEF,6DAA6D;AAC7D,eAAO,MAAM,wBAAwB,EAAE,SAEtC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,gCAAgC,EAAE,SAE9C,CAAC;AAEF,oCAAoC;AACpC,eAAO,MAAM,gBAAgB,EAAE,SAE9B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,iBAAiB,EAAE,SAE/B,CAAC;AAEF,oEAAoE;AACpE,eAAO,MAAM,uBAAuB,EAAE,SAErC,CAAC;AAEF,2CAA2C;AAC3C,eAAO,MAAM,mBAAm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CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAE5D;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAEjE;AAED,uEAAuE;AACvE,MAAM,MAAM,kBAAkB,GAC3B,UAAU,GACV,iBAAiB,GACjB,YAAY,GACZ,aAAa,GACb,aAAa,GACb,YAAY,GACZ,oBAAoB,GACpB,QAAQ,GACR,YAAY,CAAC;AAchB;;;;;GAKG;AACH,wBAAgB,kBAAkB,CACjC,OAAO,EAAE,UAAU,GACjB,kBAAkB,GAAG,IAAI,CAa3B;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,GAAG,IAAI,CAS5E"}
|
|
@@ -1,31 +1,71 @@
|
|
|
1
|
+
import { freezeBitAddress, freezeBitPrefix, freezeBitPrefixes, } from "../prefix/_frozen.js";
|
|
1
2
|
import { assertBitAddressWidth, bitAddressBitAt, bitAddressIsZero, bitAddressToBigInt, } from "../prefix/bit-address.js";
|
|
2
3
|
import { bitPrefixContains } from "../prefix/bit-prefix.js";
|
|
4
|
+
import { bitPrefixesContain } from "../prefix/set-ops.js";
|
|
3
5
|
import { IPV6_BIT_WIDTH } from "./constants.js";
|
|
4
6
|
import { isIpv6Ipv4Compatible, isIpv6Ipv4Mapped } from "./ipv4-mapped.js";
|
|
5
7
|
import { parseIpv6Address, parseIpv6Prefix } from "./parse-ipv6.js";
|
|
6
8
|
/** `::` — the unspecified address, RFC 4291 §2.5.2. */
|
|
7
|
-
export const IPV6_UNSPECIFIED_ADDRESS = parseIpv6Address("::");
|
|
9
|
+
export const IPV6_UNSPECIFIED_ADDRESS = freezeBitAddress(parseIpv6Address("::"));
|
|
8
10
|
/** `::1` — the loopback address, RFC 4291 §2.5.3. */
|
|
9
|
-
export const IPV6_LOOPBACK_ADDRESS = parseIpv6Address("::1");
|
|
11
|
+
export const IPV6_LOOPBACK_ADDRESS = freezeBitAddress(parseIpv6Address("::1"));
|
|
10
12
|
/** `fe80::/10` — link-local unicast, RFC 4291 §2.5.6. */
|
|
11
|
-
export const IPV6_LINK_LOCAL_PREFIX = parseIpv6Prefix("fe80::/10");
|
|
13
|
+
export const IPV6_LINK_LOCAL_PREFIX = freezeBitPrefix(parseIpv6Prefix("fe80::/10"));
|
|
14
|
+
/**
|
|
15
|
+
* `fec0::/10` — site-local, deprecated by RFC 3879 but still routed inside some
|
|
16
|
+
* networks.
|
|
17
|
+
*/
|
|
18
|
+
export const IPV6_SITE_LOCAL_PREFIX = freezeBitPrefix(parseIpv6Prefix("fec0::/10"));
|
|
12
19
|
/** `fc00::/7` — unique local addresses, RFC 4193. */
|
|
13
|
-
export const IPV6_UNIQUE_LOCAL_PREFIX = parseIpv6Prefix("fc00::/7");
|
|
20
|
+
export const IPV6_UNIQUE_LOCAL_PREFIX = freezeBitPrefix(parseIpv6Prefix("fc00::/7"));
|
|
14
21
|
/** `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
|
|
22
|
+
export const IPV6_MULTICAST_PREFIX = freezeBitPrefix(parseIpv6Prefix("ff00::/8"));
|
|
23
|
+
/** `2001:db8::/32` and `3fff::/20` — documentation, RFC 3849 and RFC 9637. */
|
|
24
|
+
export const IPV6_DOCUMENTATION_PREFIXES = freezeBitPrefixes([
|
|
25
|
+
parseIpv6Prefix("2001:db8::/32"),
|
|
26
|
+
parseIpv6Prefix("3fff::/20"),
|
|
27
|
+
]);
|
|
18
28
|
/** `2001::/32` — Teredo tunnelling, RFC 4380. */
|
|
19
|
-
export const IPV6_TEREDO_PREFIX = parseIpv6Prefix("2001::/32");
|
|
29
|
+
export const IPV6_TEREDO_PREFIX = freezeBitPrefix(parseIpv6Prefix("2001::/32"));
|
|
30
|
+
/** `2001:2::/48` — network device benchmarking, RFC 5180. */
|
|
31
|
+
export const IPV6_BENCHMARKING_PREFIX = freezeBitPrefix(parseIpv6Prefix("2001:2::/48"));
|
|
32
|
+
/**
|
|
33
|
+
* `2001::/23` — IETF protocol assignments, RFC 2928: Teredo and benchmarking
|
|
34
|
+
* among them, and the anycast, AMT, AS112 and ORCHIDv2 blocks.
|
|
35
|
+
*/
|
|
36
|
+
export const IPV6_PROTOCOL_ASSIGNMENTS_PREFIX = freezeBitPrefix(parseIpv6Prefix("2001::/23"));
|
|
20
37
|
/** `2002::/16` — 6to4, RFC 3056. */
|
|
21
|
-
export const IPV6_6TO4_PREFIX = parseIpv6Prefix("2002::/16");
|
|
38
|
+
export const IPV6_6TO4_PREFIX = freezeBitPrefix(parseIpv6Prefix("2002::/16"));
|
|
39
|
+
/**
|
|
40
|
+
* `64:ff9b::/96` — the well-known IPv4/IPv6 translation prefix, RFC 6052: a
|
|
41
|
+
* NAT64 gateway forwards it to the IPv4 address in its last 32 bits.
|
|
42
|
+
*/
|
|
43
|
+
export const IPV6_NAT64_PREFIX = freezeBitPrefix(parseIpv6Prefix("64:ff9b::/96"));
|
|
44
|
+
/** `64:ff9b:1::/48` — local-use IPv4/IPv6 translation, RFC 8215. */
|
|
45
|
+
export const IPV6_LOCAL_NAT64_PREFIX = freezeBitPrefix(parseIpv6Prefix("64:ff9b:1::/48"));
|
|
46
|
+
/** `100::/64` — discard-only, RFC 6666. */
|
|
47
|
+
export const IPV6_DISCARD_PREFIX = freezeBitPrefix(parseIpv6Prefix("100::/64"));
|
|
48
|
+
/** `100:0:0:1::/64` — the dummy prefix, RFC 9780. */
|
|
49
|
+
export const IPV6_DUMMY_PREFIX = freezeBitPrefix(parseIpv6Prefix("100:0:0:1::/64"));
|
|
50
|
+
/** `5f00::/16` — segment routing (SRv6) SIDs, RFC 9602. */
|
|
51
|
+
export const IPV6_SRV6_SID_PREFIX = freezeBitPrefix(parseIpv6Prefix("5f00::/16"));
|
|
52
|
+
/**
|
|
53
|
+
* `2000::/3` — global unicast, RFC 4291 §2.4: the only block IANA assigns
|
|
54
|
+
* unicast addresses from. Outside it and the blocks above, the address space is
|
|
55
|
+
* reserved by the IETF.
|
|
56
|
+
*/
|
|
57
|
+
export const IPV6_GLOBAL_UNICAST_PREFIX = freezeBitPrefix(parseIpv6Prefix("2000::/3"));
|
|
58
|
+
/** `3ffe::/16` — the 6bone test network, returned to IANA by RFC 3701. */
|
|
59
|
+
export const IPV6_6BONE_PREFIX = freezeBitPrefix(parseIpv6Prefix("3ffe::/16"));
|
|
22
60
|
/**
|
|
23
61
|
* Classifies an address against RFC 4291 and the RFC 6890 special-purpose
|
|
24
62
|
* registry.
|
|
25
63
|
*
|
|
26
64
|
* 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
|
|
65
|
+
* and must be reported as loopback rather than as IPv4-compatible, and Teredo
|
|
66
|
+
* and benchmarking inside `2001::/23`; `2001:db8::/32` sits beside — not inside
|
|
67
|
+
* — either. Whatever is left is `"global"` inside `2000::/3`, and `"reserved"`
|
|
68
|
+
* outside it. O(1).
|
|
29
69
|
*
|
|
30
70
|
* @throws RangeError When the address is not 128 bits wide.
|
|
31
71
|
*/
|
|
@@ -49,18 +89,46 @@ export function classifyIpv6Address(address) {
|
|
|
49
89
|
if (bitPrefixContains(IPV6_LINK_LOCAL_PREFIX, address)) {
|
|
50
90
|
return "link-local";
|
|
51
91
|
}
|
|
92
|
+
if (bitPrefixContains(IPV6_SITE_LOCAL_PREFIX, address)) {
|
|
93
|
+
return "site-local";
|
|
94
|
+
}
|
|
52
95
|
if (bitPrefixContains(IPV6_UNIQUE_LOCAL_PREFIX, address)) {
|
|
53
96
|
return "unique-local";
|
|
54
97
|
}
|
|
55
|
-
if (
|
|
98
|
+
if (bitPrefixesContain(IPV6_DOCUMENTATION_PREFIXES, address)) {
|
|
56
99
|
return "documentation";
|
|
57
100
|
}
|
|
58
101
|
if (bitPrefixContains(IPV6_TEREDO_PREFIX, address)) {
|
|
59
102
|
return "teredo";
|
|
60
103
|
}
|
|
104
|
+
if (bitPrefixContains(IPV6_BENCHMARKING_PREFIX, address)) {
|
|
105
|
+
return "benchmarking";
|
|
106
|
+
}
|
|
107
|
+
if (bitPrefixContains(IPV6_PROTOCOL_ASSIGNMENTS_PREFIX, address)) {
|
|
108
|
+
return "protocol-assignment";
|
|
109
|
+
}
|
|
61
110
|
if (bitPrefixContains(IPV6_6TO4_PREFIX, address)) {
|
|
62
111
|
return "6to4";
|
|
63
112
|
}
|
|
113
|
+
if (bitPrefixContains(IPV6_NAT64_PREFIX, address)) {
|
|
114
|
+
return "nat64";
|
|
115
|
+
}
|
|
116
|
+
if (bitPrefixContains(IPV6_LOCAL_NAT64_PREFIX, address)) {
|
|
117
|
+
return "local-nat64";
|
|
118
|
+
}
|
|
119
|
+
if (bitPrefixContains(IPV6_DISCARD_PREFIX, address)) {
|
|
120
|
+
return "discard";
|
|
121
|
+
}
|
|
122
|
+
if (bitPrefixContains(IPV6_DUMMY_PREFIX, address)) {
|
|
123
|
+
return "dummy";
|
|
124
|
+
}
|
|
125
|
+
if (bitPrefixContains(IPV6_SRV6_SID_PREFIX, address)) {
|
|
126
|
+
return "segment-routing";
|
|
127
|
+
}
|
|
128
|
+
if (!bitPrefixContains(IPV6_GLOBAL_UNICAST_PREFIX, address) ||
|
|
129
|
+
bitPrefixContains(IPV6_6BONE_PREFIX, address)) {
|
|
130
|
+
return "reserved";
|
|
131
|
+
}
|
|
64
132
|
return "global";
|
|
65
133
|
}
|
|
66
134
|
/** Whether the address is `::`. */
|
|
@@ -83,7 +151,7 @@ export function isIpv6UniqueLocal(address) {
|
|
|
83
151
|
export function isIpv6Multicast(address) {
|
|
84
152
|
return classifyIpv6Address(address) === "multicast";
|
|
85
153
|
}
|
|
86
|
-
/** Whether the address is in `2001:db8::/32`. */
|
|
154
|
+
/** Whether the address is in `2001:db8::/32` or `3fff::/20`. */
|
|
87
155
|
export function isIpv6Documentation(address) {
|
|
88
156
|
return classifyIpv6Address(address) === "documentation";
|
|
89
157
|
}
|
|
@@ -101,6 +169,7 @@ export function isIpv6SixToFour(address) {
|
|
|
101
169
|
* An SSRF guard wants this on the parsed address, and must also unwrap an
|
|
102
170
|
* IPv4-mapped literal with `ipv4FromIpv6` before classifying:
|
|
103
171
|
* `::ffff:127.0.0.1` is loopback, and no substring test for `127.` finds it.
|
|
172
|
+
* `isGlobalIpAddress` does both, for either family.
|
|
104
173
|
*/
|
|
105
174
|
export function isIpv6SpecialPurpose(address) {
|
|
106
175
|
return classifyIpv6Address(address) !== "global";
|
|
@@ -1 +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;
|
|
1
|
+
{"version":3,"file":"classify-ipv6.js","sourceRoot":"","sources":["../../src/ipv6/classify-ipv6.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,gBAAgB,EAChB,eAAe,EACf,iBAAiB,GACjB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAEN,qBAAqB,EACrB,eAAe,EACf,gBAAgB,EAChB,kBAAkB,GAClB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAkB,iBAAiB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E,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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ipv4-mapped.d.ts","sourceRoot":"","sources":["../../src/ipv6/ipv4-mapped.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ipv4-mapped.d.ts","sourceRoot":"","sources":["../../src/ipv6/ipv4-mapped.ts"],"names":[],"mappings":"AAEA,OAAO,EACN,KAAK,UAAU,EAEf,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,KAAK,SAAS,EAAmB,MAAM,yBAAyB,CAAC;AAK1E,kEAAkE;AAClE,eAAO,MAAM,uBAAuB,EAAE,SAErC,CAAC;AAEF,yEAAyE;AACzE,eAAO,MAAM,2BAA2B,EAAE,SAEzC,CAAC;AAEF;;;;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,CAMnE;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,SAAS,GAAG,SAAS,CAKrE"}
|
package/dist/ipv6/ipv4-mapped.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { IPV4_BIT_WIDTH } from "../ipv4/constants.js";
|
|
2
|
-
import {
|
|
2
|
+
import { freezeBitPrefix } from "../prefix/_frozen.js";
|
|
3
|
+
import { assertBitAddressWidth, } from "../prefix/bit-address.js";
|
|
3
4
|
import { createBitPrefix } from "../prefix/bit-prefix.js";
|
|
5
|
+
import { embeddedIpv4Address } from "./_embedded-ipv4.js";
|
|
4
6
|
import { IPV6_BIT_WIDTH } from "./constants.js";
|
|
5
7
|
import { parseIpv6Prefix } from "./parse-ipv6.js";
|
|
6
8
|
/** `::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");
|
|
9
|
+
export const IPV6_IPV4_MAPPED_PREFIX = freezeBitPrefix(parseIpv6Prefix("::ffff:0:0/96"));
|
|
8
10
|
/** `::/96` — the deprecated IPv4-compatible block, RFC 4291 §2.5.5.1. */
|
|
9
|
-
export const IPV6_IPV4_COMPATIBLE_PREFIX = parseIpv6Prefix("::/96");
|
|
11
|
+
export const IPV6_IPV4_COMPATIBLE_PREFIX = freezeBitPrefix(parseIpv6Prefix("::/96"));
|
|
10
12
|
/**
|
|
11
13
|
* Whether the address is IPv4-mapped — `::ffff:a.b.c.d`.
|
|
12
14
|
*
|
|
@@ -51,7 +53,7 @@ export function ipv4FromIpv6(address) {
|
|
|
51
53
|
if (!isIpv6Ipv4Mapped(address) && !isIpv6Ipv4Compatible(address)) {
|
|
52
54
|
return null;
|
|
53
55
|
}
|
|
54
|
-
return
|
|
56
|
+
return embeddedIpv4Address(address);
|
|
55
57
|
}
|
|
56
58
|
/**
|
|
57
59
|
* Widens an IPv4 prefix to its IPv4-mapped counterpart: `10.0.0.0/8` becomes
|
|
@@ -1 +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,
|
|
1
|
+
{"version":3,"file":"ipv4-mapped.js","sourceRoot":"","sources":["../../src/ipv6/ipv4-mapped.ts"],"names":[],"mappings":"A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B,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,OAAmB;IAC/C,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC,EAAE,CAAC;QAClE,OAAO,IAAI,CAAC;IACb,CAAC;IAED,OAAO,mBAAmB,CAAC,OAAO,CAAC,CAAC;AACrC,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"}
|
|
@@ -1,32 +1,65 @@
|
|
|
1
1
|
import { type BitAddress } from "../prefix/bit-address.js";
|
|
2
2
|
import type { BitPrefix } from "../prefix/bit-prefix.js";
|
|
3
3
|
import type { Ipv6ScopedAddress } from "./parse-ipv6.js";
|
|
4
|
+
/** Which spelling of an IPv6 address {@link printIpv6Address} writes. */
|
|
5
|
+
export type Ipv6PrintForm =
|
|
6
|
+
/** RFC 5952: `2001:db8::1`, and `::ffff:192.0.2.1` for an IPv4-mapped one. */
|
|
7
|
+
"canonical"
|
|
8
|
+
/** Eight groups, no `::`, no leading zeros: `2001:db8:0:0:0:0:0:1`. */
|
|
9
|
+
| "uncompressed"
|
|
10
|
+
/** Eight groups of four lowercase digits: `2001:0db8:0000:…:0001`. */
|
|
11
|
+
| "expanded";
|
|
12
|
+
/** How {@link printIpv6Address} spells an address. */
|
|
13
|
+
export type Ipv6PrintOptions = {
|
|
14
|
+
/** Default: `"canonical"`. */
|
|
15
|
+
readonly form?: Ipv6PrintForm;
|
|
16
|
+
};
|
|
4
17
|
/**
|
|
5
|
-
* Prints the
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
18
|
+
* Prints the address in one of the RFC 4291 §2.2 spellings, all lowercase.
|
|
19
|
+
*
|
|
20
|
+
* - `"canonical"`, the default, is the RFC 5952 form: no leading zeros in a
|
|
21
|
+
* group, the longest run of zero groups compressed to `::` — leftmost on a
|
|
22
|
+
* tie, and never for a single group — and an IPv4-mapped address printed
|
|
23
|
+
* `::ffff:a.b.c.d`, per §5. Reach for it whenever the text is compared,
|
|
24
|
+
* stored, logged or shown.
|
|
25
|
+
* - `"uncompressed"` writes all eight groups, no `::` and no leading zeros:
|
|
26
|
+
* `2001:db8:0:0:0:0:0:1`.
|
|
27
|
+
* - `"expanded"` writes all eight groups as four digits each, 39 characters
|
|
28
|
+
* always: `2001:0db8:0000:0000:0000:0000:0000:0001`. It sorts as the address
|
|
29
|
+
* does, and is what fixed-width columns and `sipcalc`'s "Expanded Address"
|
|
30
|
+
* use.
|
|
31
|
+
*
|
|
32
|
+
* The last two never use a dotted quad, an IPv4-mapped address included. Every
|
|
33
|
+
* form parses back to the same address with `parseIpv6Address`.
|
|
9
34
|
*
|
|
10
35
|
* O(1): the address has a fixed eight groups.
|
|
11
36
|
*
|
|
12
|
-
* @
|
|
37
|
+
* @example
|
|
38
|
+
* const address = parseIpv6Address("2001:db8::1");
|
|
39
|
+
* printIpv6Address(address); // "2001:db8::1"
|
|
40
|
+
* printIpv6Address(address, { form: "uncompressed" }); // "2001:db8:0:0:0:0:0:1"
|
|
41
|
+
*
|
|
42
|
+
* @throws RangeError When the address is not 128 bits wide, or `form` is none
|
|
43
|
+
* of the above.
|
|
13
44
|
*/
|
|
14
|
-
export declare function printIpv6Address(address: BitAddress): string;
|
|
45
|
+
export declare function printIpv6Address(address: BitAddress, options?: Ipv6PrintOptions): string;
|
|
15
46
|
/**
|
|
16
|
-
* Prints the canonical form
|
|
47
|
+
* Prints the address, in the canonical form unless `options` picks another,
|
|
48
|
+
* followed by `%zone` when it carries one.
|
|
17
49
|
*
|
|
18
50
|
* The zone is emitted verbatim, not percent-encoded: RFC 6874's `%25` belongs
|
|
19
51
|
* to whatever URI the caller is building.
|
|
20
52
|
*
|
|
21
53
|
* @throws RangeError When the address is not 128 bits wide.
|
|
22
54
|
*/
|
|
23
|
-
export declare function printIpv6ScopedAddress(scoped: Ipv6ScopedAddress): string;
|
|
55
|
+
export declare function printIpv6ScopedAddress(scoped: Ipv6ScopedAddress, options?: Ipv6PrintOptions): string;
|
|
24
56
|
/**
|
|
25
|
-
* Prints CIDR notation, keeping any host bits the prefix carries
|
|
57
|
+
* Prints CIDR notation, keeping any host bits the prefix carries; the address
|
|
58
|
+
* in the canonical form unless `options` picks another.
|
|
26
59
|
*
|
|
27
60
|
* @throws RangeError When the prefix is not over a 128-bit address.
|
|
28
61
|
*/
|
|
29
|
-
export declare function printIpv6Prefix(prefix: BitPrefix): string;
|
|
62
|
+
export declare function printIpv6Prefix(prefix: BitPrefix, options?: Ipv6PrintOptions): string;
|
|
30
63
|
/**
|
|
31
64
|
* The `ip6.arpa` name for the address, as RFC 3596 §2.5 defines it: the 32
|
|
32
65
|
* nibbles in reverse order, dot-separated, with no trailing dot.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"print-ipv6.d.ts","sourceRoot":"","sources":["../../src/ipv6/print-ipv6.ts"],"names":[],"mappings":"AACA,OAAO,EACN,KAAK,UAAU,EAEf,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAGzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAqCzD
|
|
1
|
+
{"version":3,"file":"print-ipv6.d.ts","sourceRoot":"","sources":["../../src/ipv6/print-ipv6.ts"],"names":[],"mappings":"AACA,OAAO,EACN,KAAK,UAAU,EAEf,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAGzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAqCzD,yEAAyE;AACzE,MAAM,MAAM,aAAa;AACxB,8EAA8E;AAC5E,WAAW;AACb,uEAAuE;GACrE,cAAc;AAChB,sEAAsE;GACpE,UAAU,CAAC;AAEd,sDAAsD;AACtD,MAAM,MAAM,gBAAgB,GAAG;IAC9B,8BAA8B;IAC9B,QAAQ,CAAC,IAAI,CAAC,EAAE,aAAa,CAAC;CAC9B,CAAC;AA6CF;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,gBAAgB,CAC/B,OAAO,EAAE,UAAU,EACnB,OAAO,CAAC,EAAE,gBAAgB,GACxB,MAAM,CAeR;AAED;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CACrC,MAAM,EAAE,iBAAiB,EACzB,OAAO,CAAC,EAAE,gBAAgB,GACxB,MAAM,CAIR;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAC9B,MAAM,EAAE,SAAS,EACjB,OAAO,CAAC,EAAE,gBAAgB,GACxB,MAAM,CAER;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,UAAU,GAAG,MAAM,CAY3D"}
|
package/dist/ipv6/print-ipv6.js
CHANGED
|
@@ -28,18 +28,9 @@ function longestZeroRun(groups) {
|
|
|
28
28
|
}
|
|
29
29
|
return best;
|
|
30
30
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
* never for a single group. An IPv4-mapped address is printed `::ffff:a.b.c.d`,
|
|
35
|
-
* per §5.
|
|
36
|
-
*
|
|
37
|
-
* O(1): the address has a fixed eight groups.
|
|
38
|
-
*
|
|
39
|
-
* @throws RangeError When the address is not 128 bits wide.
|
|
40
|
-
*/
|
|
41
|
-
export function printIpv6Address(address) {
|
|
42
|
-
assertBitAddressWidth(address, IPV6_BIT_WIDTH);
|
|
31
|
+
// The whole address in hexadecimal: four digits per 16-bit group.
|
|
32
|
+
const IPV6_HEX_DIGIT_COUNT = IPV6_BIT_WIDTH / 4;
|
|
33
|
+
function printRfc5952(address) {
|
|
43
34
|
if (isIpv6Ipv4Mapped(address)) {
|
|
44
35
|
// Non-null: a mapped address always embeds an IPv4 address.
|
|
45
36
|
return `::ffff:${printIpv4Address(ipv4FromIpv6(address))}`;
|
|
@@ -54,25 +45,80 @@ export function printIpv6Address(address) {
|
|
|
54
45
|
.slice(run.start + run.length)
|
|
55
46
|
.join(":")}`;
|
|
56
47
|
}
|
|
48
|
+
/** Eight colon-separated groups, each four digits or, unpadded, its value. */
|
|
49
|
+
function printAllGroups(address, isPadded) {
|
|
50
|
+
// One bigint conversion for the whole address, then string slicing only.
|
|
51
|
+
const digits = address.value.toString(16).padStart(IPV6_HEX_DIGIT_COUNT, "0");
|
|
52
|
+
let text = "";
|
|
53
|
+
for (let start = 0; start < IPV6_HEX_DIGIT_COUNT; start += 4) {
|
|
54
|
+
const group = digits.slice(start, start + 4);
|
|
55
|
+
text += `${start === 0 ? "" : ":"}${isPadded ? group : Number.parseInt(group, 16).toString(16)}`;
|
|
56
|
+
}
|
|
57
|
+
return text;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Prints the address in one of the RFC 4291 §2.2 spellings, all lowercase.
|
|
61
|
+
*
|
|
62
|
+
* - `"canonical"`, the default, is the RFC 5952 form: no leading zeros in a
|
|
63
|
+
* group, the longest run of zero groups compressed to `::` — leftmost on a
|
|
64
|
+
* tie, and never for a single group — and an IPv4-mapped address printed
|
|
65
|
+
* `::ffff:a.b.c.d`, per §5. Reach for it whenever the text is compared,
|
|
66
|
+
* stored, logged or shown.
|
|
67
|
+
* - `"uncompressed"` writes all eight groups, no `::` and no leading zeros:
|
|
68
|
+
* `2001:db8:0:0:0:0:0:1`.
|
|
69
|
+
* - `"expanded"` writes all eight groups as four digits each, 39 characters
|
|
70
|
+
* always: `2001:0db8:0000:0000:0000:0000:0000:0001`. It sorts as the address
|
|
71
|
+
* does, and is what fixed-width columns and `sipcalc`'s "Expanded Address"
|
|
72
|
+
* use.
|
|
73
|
+
*
|
|
74
|
+
* The last two never use a dotted quad, an IPv4-mapped address included. Every
|
|
75
|
+
* form parses back to the same address with `parseIpv6Address`.
|
|
76
|
+
*
|
|
77
|
+
* O(1): the address has a fixed eight groups.
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* const address = parseIpv6Address("2001:db8::1");
|
|
81
|
+
* printIpv6Address(address); // "2001:db8::1"
|
|
82
|
+
* printIpv6Address(address, { form: "uncompressed" }); // "2001:db8:0:0:0:0:0:1"
|
|
83
|
+
*
|
|
84
|
+
* @throws RangeError When the address is not 128 bits wide, or `form` is none
|
|
85
|
+
* of the above.
|
|
86
|
+
*/
|
|
87
|
+
export function printIpv6Address(address, options) {
|
|
88
|
+
assertBitAddressWidth(address, IPV6_BIT_WIDTH);
|
|
89
|
+
const form = options?.form ?? "canonical";
|
|
90
|
+
switch (form) {
|
|
91
|
+
case "canonical":
|
|
92
|
+
return printRfc5952(address);
|
|
93
|
+
case "uncompressed":
|
|
94
|
+
return printAllGroups(address, false);
|
|
95
|
+
case "expanded":
|
|
96
|
+
return printAllGroups(address, true);
|
|
97
|
+
default:
|
|
98
|
+
throw new RangeError(`Unknown IPv6 print form ${String(form)}`);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
57
101
|
/**
|
|
58
|
-
* Prints the canonical form
|
|
102
|
+
* Prints the address, in the canonical form unless `options` picks another,
|
|
103
|
+
* followed by `%zone` when it carries one.
|
|
59
104
|
*
|
|
60
105
|
* The zone is emitted verbatim, not percent-encoded: RFC 6874's `%25` belongs
|
|
61
106
|
* to whatever URI the caller is building.
|
|
62
107
|
*
|
|
63
108
|
* @throws RangeError When the address is not 128 bits wide.
|
|
64
109
|
*/
|
|
65
|
-
export function printIpv6ScopedAddress(scoped) {
|
|
66
|
-
const text = printIpv6Address(scoped.address);
|
|
110
|
+
export function printIpv6ScopedAddress(scoped, options) {
|
|
111
|
+
const text = printIpv6Address(scoped.address, options);
|
|
67
112
|
return scoped.zoneId === null ? text : `${text}%${scoped.zoneId}`;
|
|
68
113
|
}
|
|
69
114
|
/**
|
|
70
|
-
* Prints CIDR notation, keeping any host bits the prefix carries
|
|
115
|
+
* Prints CIDR notation, keeping any host bits the prefix carries; the address
|
|
116
|
+
* in the canonical form unless `options` picks another.
|
|
71
117
|
*
|
|
72
118
|
* @throws RangeError When the prefix is not over a 128-bit address.
|
|
73
119
|
*/
|
|
74
|
-
export function printIpv6Prefix(prefix) {
|
|
75
|
-
return `${printIpv6Address(prefix.address)}/${prefix.prefixLength}`;
|
|
120
|
+
export function printIpv6Prefix(prefix, options) {
|
|
121
|
+
return `${printIpv6Address(prefix.address, options)}/${prefix.prefixLength}`;
|
|
76
122
|
}
|
|
77
123
|
/**
|
|
78
124
|
* The `ip6.arpa` name for the address, as RFC 3596 §2.5 defines it: the 32
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"print-ipv6.js","sourceRoot":"","sources":["../../src/ipv6/print-ipv6.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAEN,qBAAqB,GACrB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAGlE;;;GAGG;AACH,SAAS,cAAc,CACtB,MAAyB;IAEzB,IAAI,IAAI,GAA6C,IAAI,CAAC;IAC1D,IAAI,QAAQ,GAAG,CAAC,CAAC,CAAC;IAElB,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC;QACrD,IAAI,KAAK,GAAG,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC;YAClD,IAAI,QAAQ,GAAG,CAAC,EAAE,CAAC;gBAClB,QAAQ,GAAG,KAAK,CAAC;YAClB,CAAC;YAED,SAAS;QACV,CAAC;QAED,IAAI,QA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|
|
|
1
|
+
import type { BitAddress } from "./bit-address.js";
|
|
2
|
+
import type { BitPrefix } from "./bit-prefix.js";
|
|
3
|
+
export declare function freezeBitAddress(address: BitAddress): BitAddress;
|
|
4
|
+
export declare function freezeBitPrefix(prefix: BitPrefix): BitPrefix;
|
|
5
|
+
export declare function freezeBitPrefixes(prefixes: BitPrefix[]): readonly BitPrefix[];
|
|
6
|
+
//# sourceMappingURL=_frozen.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_frozen.d.ts","sourceRoot":"","sources":["../../src/prefix/_frozen.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAMjD,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,UAAU,GAAG,UAAU,CAEhE;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,SAAS,GAAG,SAAS,CAI5D;AAED,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,SAAS,EAAE,GAAG,SAAS,SAAS,EAAE,CAM7E"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// An exported constant is the same object the classifiers read, so a caller
|
|
2
|
+
// assigning to one would change every later classification in the process.
|
|
3
|
+
// Frozen, the assignment throws in strict code and is ignored elsewhere.
|
|
4
|
+
export function freezeBitAddress(address) {
|
|
5
|
+
return Object.freeze(address);
|
|
6
|
+
}
|
|
7
|
+
export function freezeBitPrefix(prefix) {
|
|
8
|
+
freezeBitAddress(prefix.address);
|
|
9
|
+
return Object.freeze(prefix);
|
|
10
|
+
}
|
|
11
|
+
export function freezeBitPrefixes(prefixes) {
|
|
12
|
+
for (const prefix of prefixes) {
|
|
13
|
+
freezeBitPrefix(prefix);
|
|
14
|
+
}
|
|
15
|
+
return Object.freeze(prefixes);
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=_frozen.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_frozen.js","sourceRoot":"","sources":["../../src/prefix/_frozen.ts"],"names":[],"mappings":"AAGA,4EAA4E;AAC5E,2EAA2E;AAC3E,yEAAyE;AAEzE,MAAM,UAAU,gBAAgB,CAAC,OAAmB;IACnD,OAAO,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;AAC/B,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,MAAiB;IAChD,gBAAgB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAEjC,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AAC9B,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,QAAqB;IACtD,KAAK,MAAM,MAAM,IAAI,QAAQ,EAAE,CAAC;QAC/B,eAAe,CAAC,MAAM,CAAC,CAAC;IACzB,CAAC;IAED,OAAO,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;AAChC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ac-kit/net-address",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Network addresses: IPv4, IPv6, EUI-48/EUI-64 and ports, over one fixed-width prefix core.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cidr",
|
|
@@ -46,12 +46,13 @@
|
|
|
46
46
|
"prepack": "yarn build"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@ac-kit/algo": "^0.4.
|
|
50
|
-
"@ac-kit/core": "^0.
|
|
51
|
-
"@ac-kit/math-numbers": "^0.2.
|
|
49
|
+
"@ac-kit/algo": "^0.4.1",
|
|
50
|
+
"@ac-kit/core": "^0.11.0",
|
|
51
|
+
"@ac-kit/math-numbers": "^0.2.8",
|
|
52
52
|
"@types/web": "^0.0.367"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
+
"@ac-kit/math-random": "0.3.0",
|
|
55
56
|
"@ac-kit/tsconfig": "0.1.0",
|
|
56
57
|
"@ac-kit/typedoc-config": "0.1.0",
|
|
57
58
|
"@ac-kit/vitest-config": "0.1.1",
|