@ac-kit/net-address 0.5.0 → 0.6.1

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.
Files changed (74) hide show
  1. package/CHANGELOG.md +123 -0
  2. package/README.md +81 -1
  3. package/dist/eui/eui-bits.d.ts.map +1 -1
  4. package/dist/eui/eui-bits.js +7 -6
  5. package/dist/eui/eui-bits.js.map +1 -1
  6. package/dist/eui/print-eui.d.ts.map +1 -1
  7. package/dist/eui/print-eui.js +4 -4
  8. package/dist/eui/print-eui.js.map +1 -1
  9. package/dist/index.d.ts +4 -0
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +4 -0
  12. package/dist/index.js.map +1 -1
  13. package/dist/ip/_ip-width.d.ts +3 -0
  14. package/dist/ip/_ip-width.d.ts.map +1 -0
  15. package/dist/ip/_ip-width.js +9 -0
  16. package/dist/ip/_ip-width.js.map +1 -0
  17. package/dist/ip/classify-ip.d.ts +54 -0
  18. package/dist/ip/classify-ip.d.ts.map +1 -0
  19. package/dist/ip/classify-ip.js +64 -0
  20. package/dist/ip/classify-ip.js.map +1 -0
  21. package/dist/ip/global-address-check.d.ts +56 -0
  22. package/dist/ip/global-address-check.d.ts.map +1 -0
  23. package/dist/ip/global-address-check.js +60 -0
  24. package/dist/ip/global-address-check.js.map +1 -0
  25. package/dist/ip/ip-address.d.ts.map +1 -1
  26. package/dist/ip/ip-address.js +5 -8
  27. package/dist/ip/ip-address.js.map +1 -1
  28. package/dist/ip/ip-prefix.d.ts +37 -0
  29. package/dist/ip/ip-prefix.d.ts.map +1 -0
  30. package/dist/ip/ip-prefix.js +70 -0
  31. package/dist/ip/ip-prefix.js.map +1 -0
  32. package/dist/ip/url-host.d.ts +31 -0
  33. package/dist/ip/url-host.d.ts.map +1 -0
  34. package/dist/ip/url-host.js +43 -0
  35. package/dist/ip/url-host.js.map +1 -0
  36. package/dist/ipv4/classify-ipv4.d.ts +16 -4
  37. package/dist/ipv4/classify-ipv4.d.ts.map +1 -1
  38. package/dist/ipv4/classify-ipv4.js +33 -18
  39. package/dist/ipv4/classify-ipv4.js.map +1 -1
  40. package/dist/ipv4/parse-ipv4.d.ts +4 -1
  41. package/dist/ipv4/parse-ipv4.d.ts.map +1 -1
  42. package/dist/ipv4/parse-ipv4.js +41 -13
  43. package/dist/ipv4/parse-ipv4.js.map +1 -1
  44. package/dist/ipv4/print-ipv4.d.ts.map +1 -1
  45. package/dist/ipv4/print-ipv4.js +2 -1
  46. package/dist/ipv4/print-ipv4.js.map +1 -1
  47. package/dist/ipv6/_embedded-ipv4.d.ts +8 -0
  48. package/dist/ipv6/_embedded-ipv4.d.ts.map +1 -0
  49. package/dist/ipv6/_embedded-ipv4.js +11 -0
  50. package/dist/ipv6/_embedded-ipv4.js.map +1 -0
  51. package/dist/ipv6/classify-ipv6.d.ts +51 -9
  52. package/dist/ipv6/classify-ipv6.d.ts.map +1 -1
  53. package/dist/ipv6/classify-ipv6.js +82 -13
  54. package/dist/ipv6/classify-ipv6.js.map +1 -1
  55. package/dist/ipv6/ipv4-mapped.d.ts.map +1 -1
  56. package/dist/ipv6/ipv4-mapped.js +6 -4
  57. package/dist/ipv6/ipv4-mapped.js.map +1 -1
  58. package/dist/ipv6/print-ipv6.d.ts +43 -10
  59. package/dist/ipv6/print-ipv6.d.ts.map +1 -1
  60. package/dist/ipv6/print-ipv6.js +65 -18
  61. package/dist/ipv6/print-ipv6.js.map +1 -1
  62. package/dist/port/port.js +2 -2
  63. package/dist/port/port.js.map +1 -1
  64. package/dist/prefix/_frozen.d.ts +6 -0
  65. package/dist/prefix/_frozen.d.ts.map +1 -0
  66. package/dist/prefix/_frozen.js +17 -0
  67. package/dist/prefix/_frozen.js.map +1 -0
  68. package/dist/prefix/aggregate.d.ts.map +1 -1
  69. package/dist/prefix/aggregate.js +2 -1
  70. package/dist/prefix/aggregate.js.map +1 -1
  71. package/dist/prefix/bit-address.d.ts.map +1 -1
  72. package/dist/prefix/bit-address.js +2 -2
  73. package/dist/prefix/bit-address.js.map +1 -1
  74. package/package.json +6 -5
package/CHANGELOG.md CHANGED
@@ -1,5 +1,128 @@
1
1
  # @ac-kit/net-address
2
2
 
3
+ ## 0.6.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 34e8cfa: An error message that quotes an argument of the wrong kind or value describes
8
+ it with `@ac-kit/core`'s `describeValue`, so building the message can no
9
+ longer throw on a symbol or run a hostile `toString`. The text changes: a
10
+ string is JSON-quoted (`got "sideways"`), `-0` keeps its sign, and an object is
11
+ named by its kind. Affected: `bitAddressFromBigInt`, `ipv4FromUint32`,
12
+ `toPortNumber`, `splitBitPrefixInto` and `printIpv6Address`' form, the HTTP
13
+ cookie jar's limits, the fetch, redirect and content-decoding limits and the
14
+ HTTP/1, HTTP/2 and HTTP/3 servers' response statuses, `OscPeer`'s
15
+ `maxPacketSize`, the QUIC `maxUdpPayloadSize`, `oshash`'s `size`,
16
+ `hammingDistancesInto`' query, the luma grid's `width` and `height`,
17
+ `phash`'s variant, `FakeWallClock`'s milliseconds, the piano partials, input-latency, chord-verifier and
18
+ tick-synthesis arguments of `@ac-kit/media-piano-audio`, and `@ac-kit/model-music`'s reference
19
+ pitch, tempo map and time signatures.
20
+ - Updated dependencies [34e8cfa]
21
+ - Updated dependencies [34e8cfa]
22
+ - Updated dependencies [34e8cfa]
23
+ - Updated dependencies [34e8cfa]
24
+ - Updated dependencies [34e8cfa]
25
+ - Updated dependencies [34e8cfa]
26
+ - Updated dependencies [34e8cfa]
27
+ - Updated dependencies [34e8cfa]
28
+ - Updated dependencies [34e8cfa]
29
+ - Updated dependencies [34e8cfa]
30
+ - Updated dependencies [34e8cfa]
31
+ - Updated dependencies [34e8cfa]
32
+ - Updated dependencies [34e8cfa]
33
+ - Updated dependencies [34e8cfa]
34
+ - Updated dependencies [34e8cfa]
35
+ - Updated dependencies [34e8cfa]
36
+ - Updated dependencies [34e8cfa]
37
+ - Updated dependencies [34e8cfa]
38
+ - Updated dependencies [34e8cfa]
39
+ - Updated dependencies [34e8cfa]
40
+ - Updated dependencies [34e8cfa]
41
+ - Updated dependencies [34e8cfa]
42
+ - Updated dependencies [34e8cfa]
43
+ - @ac-kit/algo@0.5.0
44
+ - @ac-kit/core@0.12.0
45
+ - @ac-kit/math-numbers@0.2.9
46
+
47
+ ## 0.6.0
48
+
49
+ ### Minor Changes
50
+
51
+ - 065cf8d: Either-family helpers. `classifyIpAddress(address)` names the special-purpose
52
+ block of an IPv4 or IPv6 address (`IpAddressScope`), an IPv4-mapped address
53
+ classified as the IPv4 address it reaches (`::ffff:127.0.0.1` is
54
+ `"loopback"`). `isGlobalIpAddress(address)` answers whether a server may be sent
55
+ to it: `"global"`, or a NAT64 `64:ff9b::/96` address carrying a global IPv4
56
+ address; every other scope, multicast and reserved space included, is refused.
57
+ Both throw `RangeError` for a width other than 32 or 128.
58
+
59
+ `createGlobalAddressCheck({ allow })` is that test as a destination check, the
60
+ `checkAddress` of `@ac-kit/net-transport-node`'s `createTcpConnector` and
61
+ `@ac-kit/net-quic`'s `createQuicConnector`: it throws `BlockedAddressError`,
62
+ with the refused `address` and its `scope`, unless the address is global or its
63
+ scope is in `allow` (read once, when the check is created). It sees addresses
64
+ only: URL and redirect checks stay the HTTP client's.
65
+
66
+ `tryParseUrlHostAddress(host)` answers the address a parsed URL's host is —
67
+ given the `URL` or its `hostname`, as the WHATWG URL parser normalised it —
68
+ canonical (`[::ffff:7f00:1]` is `127.0.0.1`), or `null` for a domain. It reads
69
+ only a dotted quad or a bracketed IPv6 literal, so text that did not come out
70
+ of `URL` must not be passed: `null` for it proves nothing.
71
+
72
+ `parseIpPrefix`/`tryParseIpPrefix` read CIDR notation over either family;
73
+ `parseIpPrefixOrAddress`/`tryParseIpPrefixOrAddress` also take a bare address,
74
+ as a `/32` or `/128`; `printIpPrefix` prints either family's prefix.
75
+ - 065cf8d: `printIpv6Address(address, { form })`, and `printIpv6Prefix` and
76
+ `printIpv6ScopedAddress` alike: `"canonical"` (the default) is the RFC 5952
77
+ form as before; `"uncompressed"` writes all eight groups without `::` or
78
+ leading zeros; `"expanded"` writes all eight as four lowercase digits. Neither
79
+ of the last two uses a dotted quad. An unknown form throws `RangeError`.
80
+
81
+ **Breaking:** the three printers no longer type-check when passed point-free to
82
+ `Array.prototype.map`, whose index would land on `options`. Migration: wrap
83
+ them in a unary function — `addresses.map((address) =>
84
+ printIpv6Address(address))`, `prefixes.map((prefix) => printIpv6Prefix(prefix))`
85
+ and `scopedAddresses.map((scoped) => printIpv6ScopedAddress(scoped))`.
86
+ - 065cf8d: Classify every block the IANA special-purpose registries mark not globally
87
+ reachable, and the IPv6 space outside global unicast. `Ipv4AddressScope` gains
88
+ `"protocol-assignment"` (`192.0.0.0/24`) and `"6to4-relay"`
89
+ (`192.88.99.0/24`, deprecated by RFC 7526). `Ipv6AddressScope` gains `"nat64"`
90
+ (`64:ff9b::/96`), `"local-nat64"` (`64:ff9b:1::/48`), `"discard"`
91
+ (`100::/64`), `"dummy"` (`100:0:0:1::/64`), `"benchmarking"` (`2001:2::/48`),
92
+ `"protocol-assignment"` (the rest of `2001::/23`), `"segment-routing"`
93
+ (`5f00::/16`), `"site-local"` (`fec0::/10`) and `"reserved"`: everything
94
+ outside `2000::/3` no other scope names (`fe00::/9`, `4000::/3`, …) and the
95
+ returned 6bone block `3ffe::/16`. `"documentation"` covers `3fff::/20` too, and
96
+ IPv6 `"global"` now means inside `2000::/3`. Each block has a prefix constant
97
+ (`IPV4_6TO4_RELAY_PREFIX`, `IPV6_SITE_LOCAL_PREFIX`,
98
+ `IPV6_GLOBAL_UNICAST_PREFIX`, `IPV6_6BONE_PREFIX`, `IPV6_NAT64_PREFIX`, …).
99
+
100
+ Every exported prefix, address and option preset is frozen, address and prefix
101
+ alike: assigning to one throws in strict code instead of changing later
102
+ classifications.
103
+
104
+ **Breaking:** addresses in these blocks no longer classify as `"global"`, so
105
+ `isIpv4SpecialPurpose` and `isIpv6SpecialPurpose` now report them. Code
106
+ switching exhaustively over `Ipv4AddressScope` or `Ipv6AddressScope` must
107
+ handle the new values. `IPV6_DOCUMENTATION_PREFIX` is removed in favour of
108
+ `IPV6_DOCUMENTATION_PREFIXES`. Migration:
109
+ `bitPrefixContains(IPV6_DOCUMENTATION_PREFIX, address)` becomes
110
+ `bitPrefixesContain(IPV6_DOCUMENTATION_PREFIXES, address)`, or
111
+ `classifyIpv6Address(address) === "documentation"`.
112
+
113
+ ### Patch Changes
114
+
115
+ - 065cf8d: `parseInetAtonIpv4Address` and `parseIpv4Address` give up on hostile input at
116
+ once: a string of millions of dots is refused after scanning to its fifth part,
117
+ and a part with more significant digits than 32 bits hold is refused before
118
+ it is converted.
119
+ - Updated dependencies [065cf8d]
120
+ - Updated dependencies [065cf8d]
121
+ - Updated dependencies [065cf8d]
122
+ - @ac-kit/core@0.11.0
123
+ - @ac-kit/algo@0.4.1
124
+ - @ac-kit/math-numbers@0.2.8
125
+
3
126
  ## 0.5.0
4
127
 
5
128
  ### Minor Changes
package/README.md CHANGED
@@ -52,13 +52,44 @@ The same reasoning runs through the rest of the package. `parsePort` rejects
52
52
  has no single reading. An all-digit host such as `2130706433` stays a *name*,
53
53
  since only a resolver can say what it points at — classify what the resolver
54
54
  returns, never the string. `parseIpAddress` takes either family, and nothing
55
- else: no brackets, zone, port or prefix.
55
+ else: no brackets, zone, port or prefix. `parseIpPrefix` takes CIDR notation
56
+ over either family, and `parseIpPrefixOrAddress` a bare address too, as the
57
+ prefix holding it alone (`10.0.0.1` reads as `10.0.0.1/32`) — what an address
58
+ list or a firewall rule takes.
59
+
60
+ ## Reading a URL's host
61
+
62
+ `tryParseUrlHostAddress` answers the address a parsed URL's host is, or `null`
63
+ for a domain. It takes the `URL` itself or its `hostname` — the host the WHATWG
64
+ URL parser already normalised, which writes every address as a dotted quad or
65
+ a bracketed IPv6 literal however the input spelled it (`0x7f.1`,
66
+ `2130706433`, `%31%32%37.0.0.1`, full-width digits). It reads nothing else, so
67
+ raw text that never went through `URL` must not be passed: `null` for it proves
68
+ nothing. The result is canonical, so `[::ffff:7f00:1]` is `127.0.0.1`:
69
+
70
+ ```ts
71
+ import { isGlobalIpAddress, tryParseUrlHostAddress } from "@ac-kit/net-address";
72
+
73
+ const address = tryParseUrlHostAddress(new URL(href));
74
+ if (address !== null && !isGlobalIpAddress(address)) {
75
+ throw new Error("refusing a non-global address");
76
+ }
77
+ ```
78
+
79
+ A domain can still resolve to anything, so this is the early check only: the
80
+ addresses it resolves to need the same test where the connection is made — see
81
+ below.
56
82
 
57
83
  ## Printing is canonical
58
84
 
59
85
  `printIpv6Address` produces the RFC 5952 form: lowercase, leading zeros
60
86
  suppressed, the longest run of zero groups compressed to `::` — leftmost on a
61
87
  tie, never for a single group — and IPv4-mapped addresses in dotted form.
88
+ `{ form: "uncompressed" }` writes all eight groups without `::`
89
+ (`2001:db8:0:0:0:0:0:1`), and `{ form: "expanded" }` all eight as four digits
90
+ each (`2001:0db8:0000:0000:0000:0000:0000:0001`), the fixed-width form that
91
+ sorts as the address does. `printIpv6Prefix` and `printIpv6ScopedAddress` take
92
+ the same option.
62
93
 
63
94
  `printEui` defaults to the IEEE Std 802 canonical spelling,
64
95
  `00-1A-2B-3C-4D-5E`. RFC 7042 writes `00:1a:2b:3c:4d:5e` instead, so pass
@@ -72,6 +103,55 @@ client; `printIpAddress` then prints either family. `tryParseResolvedIpAddress`
72
103
  reads an address as a resolver or a socket reports it — either family, a zone
73
104
  dropped, canonical — for a connector checking where it is about to connect.
74
105
 
106
+ ## Classifying an address
107
+
108
+ `classifyIpv4Address` and `classifyIpv6Address` name the special-purpose block
109
+ an address falls in — `"loopback"`, `"private"`, `"link-local"`, `"shared"`
110
+ (carrier-grade NAT), `"unique-local"`, `"site-local"`, `"documentation"`,
111
+ `"nat64"` and the rest. `"global"` is what is left: for IPv6, only inside
112
+ `2000::/3`, the global unicast block; the rest of the IPv6 space, kept back by
113
+ the IETF, is `"reserved"`, as is the returned 6bone block `3ffe::/16`.
114
+ `classifyIpAddress` takes either family, and classifies an IPv4-mapped address
115
+ as the IPv4 address it reaches, so `::ffff:127.0.0.1` is `"loopback"`.
116
+
117
+ `isGlobalIpAddress` is the question a server-side fetcher asks of every address
118
+ it may connect to. It fails closed: besides every block the IANA registries
119
+ mark not globally reachable, it refuses multicast, Teredo, 6to4, the
120
+ IPv4-compatible form, the deprecated 6to4 relay block `192.88.99.0/24`,
121
+ site-local and reserved space, and the whole of `192.0.0.0/24` and `2001::/23`,
122
+ reachable anycast addresses inside them included. An address under the NAT64
123
+ well-known prefix `64:ff9b::/96` is judged by the IPv4 address it carries, so
124
+ an IPv6-only host behind DNS64 still reaches IPv4-only sites. It knows nothing
125
+ of the network it runs on: a NAT64 prefix of its own, or global addresses that
126
+ must not be reached from it, are the deployment's to refuse.
127
+
128
+ The prefix constants the classifiers read (`IPV4_PRIVATE_PREFIXES`,
129
+ `IPV6_NAT64_PREFIX`, …) are frozen: changing one cannot change a
130
+ classification.
131
+
132
+ ## Refusing destinations
133
+
134
+ `createGlobalAddressCheck()` turns `isGlobalIpAddress` into a check that throws
135
+ `BlockedAddressError`, carrying the refused `address` and its `scope`. It is
136
+ the `checkAddress` that `@ac-kit/net-transport-node`'s `createTcpConnector` and
137
+ `@ac-kit/net-quic`'s `createQuicConnector` run on every address a name
138
+ resolves to before connecting, so a name resolving to `127.0.0.1` or
139
+ `169.254.169.254` is refused as surely as the literal. `allow` lets chosen
140
+ scopes through, such as `"loopback"` in a test or `"private"` for an intranet
141
+ fetcher:
142
+
143
+ ```ts
144
+ import { createGlobalAddressCheck } from "@ac-kit/net-address";
145
+ import { createTcpConnector } from "@ac-kit/net-transport-node";
146
+
147
+ const connect = createTcpConnector({ checkAddress: createGlobalAddressCheck() });
148
+ ```
149
+
150
+ It sees addresses only. Which URLs may be fetched and whether a redirect may be
151
+ followed — an HTTP client's `beforeRedirect` — are still the caller's to check,
152
+ and so is the deployment's own destination policy: its global addresses, a
153
+ NAT64 prefix of its own, a proxy that resolves names itself.
154
+
75
155
  See the
76
156
  [generated API docs](https://anthochamp.pages.grenadine.io/node-essentials/api/net-address/)
77
157
  for the full reference.
@@ -1 +1 @@
1
- {"version":3,"file":"eui-bits.d.ts","sourceRoot":"","sources":["../../src/eui/eui-bits.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,UAAU,EAIf,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,KAAK,SAAS,EAAmB,MAAM,yBAAyB,CAAC;AAQ1E,0DAA0D;AAC1D,eAAO,MAAM,uBAAuB,EAAE,UACN,CAAC;AAEjC,qDAAqD;AACrD,eAAO,MAAM,kBAAkB,EAAE,UAA4C,CAAC;AAE9E,gEAAgE;AAChE,eAAO,MAAM,uBAAuB,EAAE,UAErC,CAAC;AAEF,2DAA2D;AAC3D,eAAO,MAAM,kBAAkB,EAAE,UAEhC,CAAC;AAEF,6EAA6E;AAC7E,MAAM,MAAM,kBAAkB,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;AAE1D;;;;;GAKG;AACH,eAAO,MAAM,gCAAgC,EAAE,QAAQ,CACtD,MAAM,CAAC,kBAAkB,EAAE,MAAM,CAAC,CAKlC,CAAC;AAaF;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAIvD;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAE5D;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAIvD;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAE3D;AAED;;;;;GAKG;AACH,wBAAgB,MAAM,CAAC,OAAO,EAAE,UAAU,GAAG,MAAM,CAIlD;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAErD;AAED;;;;;GAKG;AACH,wBAAgB,MAAM,CAAC,OAAO,EAAE,UA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,OAAO,CAIvD;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAE3D;AAED;;;;;GAKG;AACH,wBAAgB,MAAM,CAAC,OAAO,EAAE,UAAU,GAAG,MAAM,CAIlD;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAErD;AAED;;;;;GAKG;AACH,wBAAgB,MAAM,CAAC,OAAO,EAAE,UAAU,GAAG,MAAM,GAAG,IAAI,CAEzD;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,UAAU,GAAG,SAAS,CAI3D;AAED;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CAClC,OAAO,EAAE,UAAU,EACnB,KAAK,EAAE,kBAAkB,GACvB,SAAS,CAIX;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAI3D;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAItD"}
@@ -1,26 +1,27 @@
1
+ import { freezeBitAddress } from "../prefix/_frozen.js";
1
2
  import { bitAddressBitAt, bitAddressIsAllOnes, bitAddressIsZero, } from "../prefix/bit-address.js";
2
3
  import { createBitPrefix } from "../prefix/bit-prefix.js";
3
4
  import { EUI48_BIT_WIDTH, EUI64_BIT_WIDTH, OUI_BIT_LENGTH, } from "./constants.js";
4
5
  import { parseEui48, parseEui64 } from "./parse-eui.js";
5
6
  /** `ff:ff:ff:ff:ff:ff` — the EUI-48 broadcast address. */
6
- export const EUI48_BROADCAST_ADDRESS = parseEui48("ff:ff:ff:ff:ff:ff");
7
+ export const EUI48_BROADCAST_ADDRESS = freezeBitAddress(parseEui48("ff:ff:ff:ff:ff:ff"));
7
8
  /** `00:00:00:00:00:00` — the EUI-48 null address. */
8
- export const EUI48_NULL_ADDRESS = parseEui48("00:00:00:00:00:00");
9
+ export const EUI48_NULL_ADDRESS = freezeBitAddress(parseEui48("00:00:00:00:00:00"));
9
10
  /** `ff:ff:ff:ff:ff:ff:ff:ff` — the EUI-64 broadcast address. */
10
- export const EUI64_BROADCAST_ADDRESS = parseEui64("ff:ff:ff:ff:ff:ff:ff:ff");
11
+ export const EUI64_BROADCAST_ADDRESS = freezeBitAddress(parseEui64("ff:ff:ff:ff:ff:ff:ff:ff"));
11
12
  /** `00:00:00:00:00:00:00:00` — the EUI-64 null address. */
12
- export const EUI64_NULL_ADDRESS = parseEui64("00:00:00:00:00:00:00:00");
13
+ export const EUI64_NULL_ADDRESS = freezeBitAddress(parseEui64("00:00:00:00:00:00:00:00"));
13
14
  /**
14
15
  * How many leading bits the IEEE assigns for each registry block.
15
16
  *
16
17
  * MA-L leaves 24 bits to the assignee, MA-M 20 and MA-S 12 — which is why a
17
18
  * small vendor buys an MA-S and a network card maker buys an MA-L.
18
19
  */
19
- export const EUI_ASSIGNMENT_BLOCK_BIT_LENGTHS = {
20
+ export const EUI_ASSIGNMENT_BLOCK_BIT_LENGTHS = Object.freeze({
20
21
  "ma-l": 24,
21
22
  "ma-m": 28,
22
23
  "ma-s": 36,
23
- };
24
+ });
24
25
  function assertEuiWidth(address) {
25
26
  if (address.bitWidth !== EUI48_BIT_WIDTH &&
26
27
  address.bitWidth !== EUI64_BIT_WIDTH) {
@@ -1 +1 @@
1
- {"version":3,"file":"eui-bits.js","sourceRoot":"","sources":["../../src/eui/eui-bits.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,eAAe,EACf,mBAAmB,EACnB,gBAAgB,GAChB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAkB,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1E,OAAO,EACN,eAAe,EACf,eAAe,EACf,cAAc,GACd,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAExD,0DAA0D;AAC1D,MAAM,CAAC,MAAM,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;;GAQG;AACH,wBAAgB,WAAW,CAC1B,OAAO,EAAE,UAAU,EACnB,OAAO,CAAC,EAAE,eAAe,GACvB,MAAM,CAUR"}
1
+ {"version":3,"file":"print-eui.d.ts","sourceRoot":"","sources":["../../src/eui/print-eui.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAqB,MAAM,0BAA0B,CAAC;AAG9E,oCAAoC;AACpC,MAAM,MAAM,WAAW;AACtB,0BAA0B;AACxB,OAAO;AACT,0BAA0B;GACxB,QAAQ;AACV,gEAAgE;GAC9D,KAAK;AACP,qBAAqB;GACnB,MAAM,CAAC;AAEV,wDAAwD;AACxD,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,OAAO,CAAC;AAE9C;;;;GAIG;AACH,MAAM,MAAM,eAAe,GAAG;IAC7B,2BAA2B;IAC3B,QAAQ,CAAC,QAAQ,CAAC,EAAE,WAAW,CAAC;IAChC,0BAA0B;IAC1B,QAAQ,CAAC,UAAU,CAAC,EAAE,aAAa,CAAC;CACpC,CAAC;AAEF,wEAAwE;AACxE,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,eAAe,CAGnD,CAAC;AAEH,iEAAiE;AACjE,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,eAAe,CAGnD,CAAC;AA8CH;;;;;GAKG;AACH,wBAAgB,QAAQ,CACvB,OAAO,EAAE,UAAU,EACnB,OAAO,CAAC,EAAE,eAAe,GACvB,MAAM,CAQR;AAED;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAC1B,OAAO,EAAE,UAAU,EACnB,OAAO,CAAC,EAAE,eAAe,GACvB,MAAM,CAUR"}
@@ -1,15 +1,15 @@
1
1
  import { bitAddressToBytes } from "../prefix/bit-address.js";
2
2
  import { EUI48_BIT_WIDTH, EUI64_BIT_WIDTH } from "./constants.js";
3
3
  /** The IEEE Std 802 canonical spelling: hyphen-separated, uppercase. */
4
- export const EUI_PRINT_IEEE = {
4
+ export const EUI_PRINT_IEEE = Object.freeze({
5
5
  notation: "hyphen",
6
6
  letterCase: "upper",
7
- };
7
+ });
8
8
  /** The IETF spelling of RFC 7042: colon-separated, lowercase. */
9
- export const EUI_PRINT_IETF = {
9
+ export const EUI_PRINT_IETF = Object.freeze({
10
10
  notation: "colon",
11
11
  letterCase: "lower",
12
- };
12
+ });
13
13
  function assertEuiWidth(address) {
14
14
  if (address.bitWidth !== EUI48_BIT_WIDTH &&
15
15
  address.bitWidth !== EUI64_BIT_WIDTH) {
@@ -1 +1 @@
1
- {"version":3,"file":"print-eui.js","sourceRoot":"","sources":["../../src/eui/print-eui.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC9E,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AA4BlE,wEAAwE;AACxE,MAAM,CAAC,MAAM,cAAc,GAA8B;IACxD,QAAQ,EAAE,QAAQ;IAClB,UAAU,EAAE,OAAO;CACnB,CAAC;AAEF,iEAAiE;AACjE,MAAM,CAAC,MAAM,cAAc,GAA8B;IACxD,QAAQ,EAAE,OAAO;IACjB,UAAU,EAAE,OAAO;CACnB,CAAC;AAEF,SAAS,cAAc,CAAC,OAAmB;IAC1C,IACC,OAAO,CAAC,QAAQ,KAAK,eAAe;QACpC,OAAO,CAAC,QAAQ,KAAK,eAAe,EACnC,CAAC;QACF,MAAM,IAAI,UAAU,CACnB,qCAAqC,OAAO,CAAC,QAAQ,OAAO,CAC5D,CAAC;IACH,CAAC;AACF,CAAC;AAED,SAAS,UAAU,CAClB,MAAkB,EAClB,QAAqB,EACrB,UAAyB;IAEzB,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE;QAC1C,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;QAEhD,OAAO,U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B;IAEzB,cAAc,CAAC,OAAO,CAAC,CAAC;IAExB,MAAM,QAAQ,GAAG,OAAO,EAAE,QAAQ,IAAI,cAAc,CAAC,QAAQ,CAAC;IAE9D,OAAO,UAAU,CAChB,iBAAiB,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,EACzC,QAAQ,KAAK,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,EACxC,OAAO,EAAE,UAAU,IAAI,cAAc,CAAC,UAAU,CAChD,CAAC;AACH,CAAC"}
package/dist/index.d.ts CHANGED
@@ -5,7 +5,11 @@ export * from "./eui/eui-convert.js";
5
5
  export * from "./eui/interface-identifier.js";
6
6
  export * from "./eui/parse-eui.js";
7
7
  export * from "./eui/print-eui.js";
8
+ export * from "./ip/classify-ip.js";
9
+ export * from "./ip/global-address-check.js";
8
10
  export * from "./ip/ip-address.js";
11
+ export * from "./ip/ip-prefix.js";
12
+ export * from "./ip/url-host.js";
9
13
  export * from "./ipv4/classify-ipv4.js";
10
14
  export * from "./ipv4/constants.js";
11
15
  export * from "./ipv4/ipv4-prefix.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAA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BAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC"}
package/dist/index.js CHANGED
@@ -5,7 +5,11 @@ export * from "./eui/eui-convert.js";
5
5
  export * from "./eui/interface-identifier.js";
6
6
  export * from "./eui/parse-eui.js";
7
7
  export * from "./eui/print-eui.js";
8
+ export * from "./ip/classify-ip.js";
9
+ export * from "./ip/global-address-check.js";
8
10
  export * from "./ip/ip-address.js";
11
+ export * from "./ip/ip-prefix.js";
12
+ export * from "./ip/url-host.js";
9
13
  export * from "./ipv4/classify-ipv4.js";
10
14
  export * from "./ipv4/constants.js";
11
15
  export * from "./ipv4/ipv4-prefix.js";
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC;AACzC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC;AACzC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC"}
@@ -0,0 +1,3 @@
1
+ /** Throws a `RangeError` unless `bitWidth` is an IP address's: 32 or 128. */
2
+ export declare function assertIpBitWidth(bitWidth: number): void;
3
+ //# sourceMappingURL=_ip-width.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_ip-width.d.ts","sourceRoot":"","sources":["../../src/ip/_ip-width.ts"],"names":[],"mappings":"AAGA,6EAA6E;AAC7E,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAMvD"}
@@ -0,0 +1,9 @@
1
+ import { IPV4_BIT_WIDTH } from "../ipv4/constants.js";
2
+ import { IPV6_BIT_WIDTH } from "../ipv6/constants.js";
3
+ /** Throws a `RangeError` unless `bitWidth` is an IP address's: 32 or 128. */
4
+ export function assertIpBitWidth(bitWidth) {
5
+ if (bitWidth !== IPV4_BIT_WIDTH && bitWidth !== IPV6_BIT_WIDTH) {
6
+ throw new RangeError(`An IP address is 32 or 128 bits wide, got ${bitWidth}`);
7
+ }
8
+ }
9
+ //# sourceMappingURL=_ip-width.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_ip-width.js","sourceRoot":"","sources":["../../src/ip/_ip-width.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,6EAA6E;AAC7E,MAAM,UAAU,gBAAgB,CAAC,QAAgB;IAChD,IAAI,QAAQ,KAAK,cAAc,IAAI,QAAQ,KAAK,cAAc,EAAE,CAAC;QAChE,MAAM,IAAI,UAAU,CACnB,6CAA6C,QAAQ,EAAE,CACvD,CAAC;IACH,CAAC;AACF,CAAC"}
@@ -0,0 +1,54 @@
1
+ import { type Ipv4AddressScope } from "../ipv4/classify-ipv4.js";
2
+ import { type Ipv6AddressScope } from "../ipv6/classify-ipv6.js";
3
+ import type { BitAddress } from "../prefix/bit-address.js";
4
+ /**
5
+ * Which special-purpose block an IP address of either family falls in: an
6
+ * {@link Ipv4AddressScope} or an {@link Ipv6AddressScope}. `"ipv4-mapped"` is
7
+ * never one, since {@link classifyIpAddress} classifies a mapped address as the
8
+ * IPv4 address it reaches.
9
+ */
10
+ export type IpAddressScope = Ipv4AddressScope | Exclude<Ipv6AddressScope, "ipv4-mapped">;
11
+ /**
12
+ * Classifies an address of either family against the special-purpose
13
+ * registries, as `classifyIpv4Address` or `classifyIpv6Address` would — except
14
+ * that an IPv4-mapped address (`::ffff:127.0.0.1`) is classified as the IPv4
15
+ * address it reaches (`"loopback"`), as `canonicalIpAddress` would make it.
16
+ *
17
+ * Reach for it on an address a peer or a resolver supplied, where the family is
18
+ * not known in advance; {@link isGlobalIpAddress} when only "may this be reached
19
+ * from a server" matters. O(1).
20
+ *
21
+ * @example
22
+ * classifyIpAddress(parseIpAddress("::ffff:169.254.169.254")); // "link-local"
23
+ * classifyIpAddress(parseIpAddress("fd00::1")); // "unique-local"
24
+ *
25
+ * @throws {RangeError} When the address is neither 32 nor 128 bits wide.
26
+ */
27
+ export declare function classifyIpAddress(address: BitAddress): IpAddressScope;
28
+ /**
29
+ * Whether the address is one a server may be sent to on the public Internet: it
30
+ * classifies as `"global"` with {@link classifyIpAddress}, or it is a `"nat64"`
31
+ * address (`64:ff9b::/96`) carrying a global IPv4 address — which is how an
32
+ * IPv6-only host behind DNS64 reaches every IPv4-only site.
33
+ *
34
+ * This is the check a server-side fetcher or webhook sender applies to every
35
+ * address a name resolves to (server-side request forgery). It fails closed:
36
+ * besides every block the IANA registries mark not globally reachable, it
37
+ * refuses multicast, Teredo, 6to4, the IPv4-compatible form, the deprecated
38
+ * 6to4 relay block `192.88.99.0/24`, site-local `fec0::/10`, every IPv6 address
39
+ * outside global unicast `2000::/3` and the returned 6bone block `3ffe::/16`,
40
+ * and the whole of `192.0.0.0/24` and `2001::/23`, the few anycast, AMT, AS112
41
+ * and ORCHIDv2 addresses inside them included. It knows nothing of the network
42
+ * it runs on: a translated destination other than the well-known prefix, or a
43
+ * global address of the deployment's own, is the deployment's policy to add.
44
+ * `createGlobalAddressCheck` makes it a connector's `checkAddress`. O(1).
45
+ *
46
+ * @example
47
+ * isGlobalIpAddress(parseIpAddress("8.8.8.8")); // true
48
+ * isGlobalIpAddress(parseIpAddress("::ffff:127.0.0.1")); // false
49
+ * isGlobalIpAddress(parseIpAddress("64:ff9b::808:808")); // true: 8.8.8.8
50
+ *
51
+ * @throws {RangeError} When the address is neither 32 nor 128 bits wide.
52
+ */
53
+ export declare function isGlobalIpAddress(address: BitAddress): boolean;
54
+ //# sourceMappingURL=classify-ip.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"classify-ip.d.ts","sourceRoot":"","sources":["../../src/ip/classify-ip.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,gBAAgB,EAErB,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EACN,KAAK,gBAAgB,EAErB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAG3D;;;;;GAKG;AACH,MAAM,MAAM,cAAc,GACvB,gBAAgB,GAChB,OAAO,CAAC,gBAAgB,EAAE,aAAa,CAAC,CAAC;AAE5C;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,UAAU,GAAG,cAAc,CAYrE;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAQ9D"}
@@ -0,0 +1,64 @@
1
+ import { classifyIpv4Address, } from "../ipv4/classify-ipv4.js";
2
+ import { IPV4_BIT_WIDTH } from "../ipv4/constants.js";
3
+ import { embeddedIpv4Address } from "../ipv6/_embedded-ipv4.js";
4
+ import { classifyIpv6Address, } from "../ipv6/classify-ipv6.js";
5
+ import { assertIpBitWidth } from "./_ip-width.js";
6
+ /**
7
+ * Classifies an address of either family against the special-purpose
8
+ * registries, as `classifyIpv4Address` or `classifyIpv6Address` would — except
9
+ * that an IPv4-mapped address (`::ffff:127.0.0.1`) is classified as the IPv4
10
+ * address it reaches (`"loopback"`), as `canonicalIpAddress` would make it.
11
+ *
12
+ * Reach for it on an address a peer or a resolver supplied, where the family is
13
+ * not known in advance; {@link isGlobalIpAddress} when only "may this be reached
14
+ * from a server" matters. O(1).
15
+ *
16
+ * @example
17
+ * classifyIpAddress(parseIpAddress("::ffff:169.254.169.254")); // "link-local"
18
+ * classifyIpAddress(parseIpAddress("fd00::1")); // "unique-local"
19
+ *
20
+ * @throws {RangeError} When the address is neither 32 nor 128 bits wide.
21
+ */
22
+ export function classifyIpAddress(address) {
23
+ if (address.bitWidth === IPV4_BIT_WIDTH) {
24
+ return classifyIpv4Address(address);
25
+ }
26
+ assertIpBitWidth(address.bitWidth);
27
+ const scope = classifyIpv6Address(address);
28
+ return scope === "ipv4-mapped"
29
+ ? classifyIpv4Address(embeddedIpv4Address(address))
30
+ : scope;
31
+ }
32
+ /**
33
+ * Whether the address is one a server may be sent to on the public Internet: it
34
+ * classifies as `"global"` with {@link classifyIpAddress}, or it is a `"nat64"`
35
+ * address (`64:ff9b::/96`) carrying a global IPv4 address — which is how an
36
+ * IPv6-only host behind DNS64 reaches every IPv4-only site.
37
+ *
38
+ * This is the check a server-side fetcher or webhook sender applies to every
39
+ * address a name resolves to (server-side request forgery). It fails closed:
40
+ * besides every block the IANA registries mark not globally reachable, it
41
+ * refuses multicast, Teredo, 6to4, the IPv4-compatible form, the deprecated
42
+ * 6to4 relay block `192.88.99.0/24`, site-local `fec0::/10`, every IPv6 address
43
+ * outside global unicast `2000::/3` and the returned 6bone block `3ffe::/16`,
44
+ * and the whole of `192.0.0.0/24` and `2001::/23`, the few anycast, AMT, AS112
45
+ * and ORCHIDv2 addresses inside them included. It knows nothing of the network
46
+ * it runs on: a translated destination other than the well-known prefix, or a
47
+ * global address of the deployment's own, is the deployment's policy to add.
48
+ * `createGlobalAddressCheck` makes it a connector's `checkAddress`. O(1).
49
+ *
50
+ * @example
51
+ * isGlobalIpAddress(parseIpAddress("8.8.8.8")); // true
52
+ * isGlobalIpAddress(parseIpAddress("::ffff:127.0.0.1")); // false
53
+ * isGlobalIpAddress(parseIpAddress("64:ff9b::808:808")); // true: 8.8.8.8
54
+ *
55
+ * @throws {RangeError} When the address is neither 32 nor 128 bits wide.
56
+ */
57
+ export function isGlobalIpAddress(address) {
58
+ const scope = classifyIpAddress(address);
59
+ if (scope === "nat64") {
60
+ return classifyIpv4Address(embeddedIpv4Address(address)) === "global";
61
+ }
62
+ return scope === "global";
63
+ }
64
+ //# sourceMappingURL=classify-ip.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"classify-ip.js","sourceRoot":"","sources":["../../src/ip/classify-ip.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,mBAAmB,GACnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAEN,mBAAmB,GACnB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAYlD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,iBAAiB,CAAC,OAAmB;IACpD,IAAI,OAAO,CAAC,QAAQ,KAAK,cAAc,EAAE,CAAC;QACzC,OAAO,mBAAmB,CAAC,OAAO,CAAC,CAAC;IACrC,CAAC;IAED,gBAAgB,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAEnC,MAAM,KAAK,GAAG,mBAAmB,CAAC,OAAO,CAAC,CAAC;IAE3C,OAAO,KAAK,KAAK,aAAa;QAC7B,CAAC,CAAC,mBAAmB,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC;QACnD,CAAC,CAAC,KAAK,CAAC;AACV,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,UAAU,iBAAiB,CAAC,OAAmB;IACpD,MAAM,KAAK,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAAC;IAEzC,IAAI,KAAK,KAAK,OAAO,EAAE,CAAC;QACvB,OAAO,mBAAmB,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC,KAAK,QAAQ,CAAC;IACvE,CAAC;IAED,OAAO,KAAK,KAAK,QAAQ,CAAC;AAC3B,CAAC"}
@@ -0,0 +1,56 @@
1
+ import type { Callable } from "@ac-kit/core";
2
+ import type { BitAddress } from "../prefix/bit-address.js";
3
+ import { type IpAddressScope } from "./classify-ip.js";
4
+ /**
5
+ * A destination refused by a {@link createGlobalAddressCheck} check: the address
6
+ * a connection would have reached, and the special-purpose block it falls in.
7
+ */
8
+ export declare class BlockedAddressError extends Error {
9
+ readonly address: BitAddress;
10
+ readonly scope: IpAddressScope;
11
+ constructor(address: BitAddress, scope: IpAddressScope);
12
+ }
13
+ /** Options for {@link createGlobalAddressCheck}. */
14
+ export type GlobalAddressCheckOptions = {
15
+ /**
16
+ * Scopes let through as well as global addresses: `"loopback"` for a test
17
+ * against a local server, `"private"` and `"unique-local"` for a fetcher
18
+ * meant for an intranet. Read once, when the check is created. Allowing
19
+ * `"nat64"` allows every NAT64 address, whatever IPv4 address it carries.
20
+ * Defaults to none.
21
+ */
22
+ readonly allow?: ReadonlySet<IpAddressScope>;
23
+ };
24
+ /**
25
+ * A destination check refusing every address that is not global, as
26
+ * {@link isGlobalIpAddress} judges it: loopback, private, link-local
27
+ * (`169.254.169.254`, where cloud metadata lives), carrier-grade NAT,
28
+ * documentation, multicast, reserved and every other special-purpose address,
29
+ * an IPv4-mapped one judged as its IPv4 address and a NAT64 (`64:ff9b::/96`)
30
+ * one as the IPv4 address it carries. It is the `checkAddress` that
31
+ * `@ac-kit/net-transport-node`'s `createTcpConnector` and `@ac-kit/net-quic`'s
32
+ * `createQuicConnector` take, which run it on every address a name resolves to
33
+ * before connecting.
34
+ *
35
+ * It is the floor a server-side fetcher or webhook sender needs against request
36
+ * forgery, not a whole policy. It sees addresses only: which URLs may be
37
+ * fetched, and whether a redirect may be followed — an HTTP client's
38
+ * `beforeRedirect` — are still the caller's to check. So are the deployment's
39
+ * own global addresses, a NAT64 prefix of its own and a proxy, which resolves
40
+ * names itself; wrap the check to add to it.
41
+ *
42
+ * Each call is O(1).
43
+ *
44
+ * @example
45
+ * ```ts
46
+ * const connect = createTcpConnector({ checkAddress: createGlobalAddressCheck() });
47
+ * await connect({ host: "127.0.0.1", port: 80, secure: false });
48
+ * // rejects with a BlockedAddressError, scope "loopback"
49
+ * ```;
50
+ *
51
+ * @returns A check throwing {@link BlockedAddressError} for an address that is
52
+ * neither global nor in an allowed scope, and `RangeError` for one that is
53
+ * not an IP address.
54
+ */
55
+ export declare function createGlobalAddressCheck(options?: GlobalAddressCheckOptions): Callable<[address: BitAddress]>;
56
+ //# sourceMappingURL=global-address-check.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"global-address-check.d.ts","sourceRoot":"","sources":["../../src/ip/global-address-check.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAE7C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EACN,KAAK,cAAc,EAGnB,MAAM,kBAAkB,CAAC;AAG1B;;;GAGG;AACH,qBAAa,mBAAoB,SAAQ,KAAK;IAE5C,QAAQ,CAAC,OAAO,EAAE,UAAU;IAC5B,QAAQ,CAAC,KAAK,EAAE,cAAc;IAF/B,YACU,OAAO,EAAE,UAAU,EACnB,KAAK,EAAE,cAAc,EAM9B;CACD;AAED,oDAAoD;AACpD,MAAM,MAAM,yBAAyB,GAAG;IACvC;;;;;;OAMG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,WAAW,CAAC,cAAc,CAAC,CAAC;CAC7C,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,wBAAwB,CACvC,OAAO,CAAC,EAAE,yBAAyB,GACjC,QAAQ,CAAC,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC,CAcjC"}