@nodaro/shared 3.32.0 → 3.33.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/dist/{chunk-ISJDAFKS.js → chunk-23FJQTEA.js} +8 -8
- package/dist/{chunk-ISJDAFKS.js.map → chunk-23FJQTEA.js.map} +1 -1
- package/dist/{chunk-VWGNPMJZ.cjs → chunk-2NQLSLSN.cjs} +5 -5
- package/dist/{chunk-VWGNPMJZ.cjs.map → chunk-2NQLSLSN.cjs.map} +1 -1
- package/dist/{chunk-IEBZHTPE.js → chunk-5RYLK3MQ.js} +28 -15
- package/dist/chunk-5RYLK3MQ.js.map +1 -0
- package/dist/{chunk-Z4AZW6FY.js → chunk-6WZ2VN7V.js} +5 -5
- package/dist/{chunk-Z4AZW6FY.js.map → chunk-6WZ2VN7V.js.map} +1 -1
- package/dist/{chunk-6DKDOWBL.js → chunk-7Z5LUTGU.js} +3 -3
- package/dist/{chunk-6DKDOWBL.js.map → chunk-7Z5LUTGU.js.map} +1 -1
- package/dist/{chunk-3CUFITU7.js → chunk-BG5D5CZ6.js} +67 -50
- package/dist/chunk-BG5D5CZ6.js.map +1 -0
- package/dist/{chunk-XAMC4S53.js → chunk-CUH22J4D.js} +3 -3
- package/dist/{chunk-XAMC4S53.js.map → chunk-CUH22J4D.js.map} +1 -1
- package/dist/{chunk-E2TGXG6X.cjs → chunk-D26ENTN2.cjs} +43 -43
- package/dist/{chunk-E2TGXG6X.cjs.map → chunk-D26ENTN2.cjs.map} +1 -1
- package/dist/{chunk-AVQK77G6.cjs → chunk-D6GNRSCV.cjs} +67 -50
- package/dist/chunk-D6GNRSCV.cjs.map +1 -0
- package/dist/{chunk-KHCBJ7KD.js → chunk-FT5CF6IA.js} +3 -3
- package/dist/{chunk-KHCBJ7KD.js.map → chunk-FT5CF6IA.js.map} +1 -1
- package/dist/{chunk-JX5YZ4DH.cjs → chunk-HC7VKIV5.cjs} +38 -38
- package/dist/{chunk-JX5YZ4DH.cjs.map → chunk-HC7VKIV5.cjs.map} +1 -1
- package/dist/{chunk-S5DMKUWK.cjs → chunk-HKFMXNVQ.cjs} +11 -11
- package/dist/{chunk-S5DMKUWK.cjs.map → chunk-HKFMXNVQ.cjs.map} +1 -1
- package/dist/{chunk-O5MP52U2.cjs → chunk-HRXEZ3SX.cjs} +4 -4
- package/dist/{chunk-O5MP52U2.cjs.map → chunk-HRXEZ3SX.cjs.map} +1 -1
- package/dist/{chunk-RJL7RCEM.cjs → chunk-HUR6ZJ7S.cjs} +6 -6
- package/dist/chunk-HUR6ZJ7S.cjs.map +1 -0
- package/dist/{chunk-QELDJGDK.cjs → chunk-JFS3NWZ5.cjs} +4 -4
- package/dist/{chunk-QELDJGDK.cjs.map → chunk-JFS3NWZ5.cjs.map} +1 -1
- package/dist/{chunk-5AUSSJIM.cjs → chunk-K3LLGRK7.cjs} +175 -2
- package/dist/chunk-K3LLGRK7.cjs.map +1 -0
- package/dist/{chunk-J6KHW2E5.cjs → chunk-M7GQBRZU.cjs} +16 -16
- package/dist/{chunk-J6KHW2E5.cjs.map → chunk-M7GQBRZU.cjs.map} +1 -1
- package/dist/{chunk-5U7VLG43.js → chunk-OTATNBMD.js} +3 -3
- package/dist/chunk-OTATNBMD.js.map +1 -0
- package/dist/{chunk-LPW3XNC2.js → chunk-OZSACQ2V.js} +3 -3
- package/dist/{chunk-LPW3XNC2.js.map → chunk-OZSACQ2V.js.map} +1 -1
- package/dist/{chunk-VIWSWVAW.js → chunk-PHZ23DP3.js} +3 -3
- package/dist/{chunk-VIWSWVAW.js.map → chunk-PHZ23DP3.js.map} +1 -1
- package/dist/{chunk-ZT77RY6R.js → chunk-PVJBAPYJ.js} +4 -4
- package/dist/{chunk-ZT77RY6R.js.map → chunk-PVJBAPYJ.js.map} +1 -1
- package/dist/{chunk-AROWPFO2.js → chunk-PXFQVLBX.js} +7 -4
- package/dist/chunk-PXFQVLBX.js.map +1 -0
- package/dist/{chunk-Q4CDQ2KO.js → chunk-QA3MVQ32.js} +4 -4
- package/dist/{chunk-Q4CDQ2KO.js.map → chunk-QA3MVQ32.js.map} +1 -1
- package/dist/{chunk-NB72XWXQ.cjs → chunk-SAW5OK36.cjs} +6 -6
- package/dist/{chunk-NB72XWXQ.cjs.map → chunk-SAW5OK36.cjs.map} +1 -1
- package/dist/{chunk-YHRG7UOC.js → chunk-SFW3UB2P.js} +4 -4
- package/dist/{chunk-YHRG7UOC.js.map → chunk-SFW3UB2P.js.map} +1 -1
- package/dist/chunk-TU33KYKW.cjs +25 -0
- package/dist/{chunk-WNG7HRVA.cjs.map → chunk-TU33KYKW.cjs.map} +1 -1
- package/dist/{chunk-QNGNOU4Z.js → chunk-UCFWI6D4.js} +3 -3
- package/dist/{chunk-QNGNOU4Z.js.map → chunk-UCFWI6D4.js.map} +1 -1
- package/dist/{chunk-RN3RMBJZ.js → chunk-UTQSSKSG.js} +4 -4
- package/dist/{chunk-RN3RMBJZ.js.map → chunk-UTQSSKSG.js.map} +1 -1
- package/dist/{chunk-NT6IJH4L.cjs → chunk-VA42637J.cjs} +61 -47
- package/dist/chunk-VA42637J.cjs.map +1 -0
- package/dist/{chunk-ULXI7A6Q.cjs → chunk-VNQRI2RO.cjs} +11 -11
- package/dist/{chunk-ULXI7A6Q.cjs.map → chunk-VNQRI2RO.cjs.map} +1 -1
- package/dist/{chunk-O7PUQLJ3.cjs → chunk-VXPLKQWY.cjs} +11 -8
- package/dist/chunk-VXPLKQWY.cjs.map +1 -0
- package/dist/{chunk-6IJOPRZP.cjs → chunk-WD6HJRBG.cjs} +21 -21
- package/dist/{chunk-6IJOPRZP.cjs.map → chunk-WD6HJRBG.cjs.map} +1 -1
- package/dist/{chunk-EK362Q45.cjs → chunk-WKOIGLQX.cjs} +8 -8
- package/dist/{chunk-EK362Q45.cjs.map → chunk-WKOIGLQX.cjs.map} +1 -1
- package/dist/{chunk-LKAIXWK3.js → chunk-XGFTL5XY.js} +3 -3
- package/dist/{chunk-LKAIXWK3.js.map → chunk-XGFTL5XY.js.map} +1 -1
- package/dist/{chunk-JSNV5O2F.cjs → chunk-ZL7UM6PU.cjs} +4 -4
- package/dist/{chunk-JSNV5O2F.cjs.map → chunk-ZL7UM6PU.cjs.map} +1 -1
- package/dist/{chunk-C57NEO3X.js → chunk-ZO5PBBFX.js} +173 -3
- package/dist/chunk-ZO5PBBFX.js.map +1 -0
- package/dist/entries/apps.cjs +42 -42
- package/dist/entries/apps.d.cts +10 -1
- package/dist/entries/apps.d.ts +10 -1
- package/dist/entries/apps.js +7 -7
- package/dist/entries/credits.cjs +155 -151
- package/dist/entries/credits.d.cts +41 -10
- package/dist/entries/credits.d.ts +41 -10
- package/dist/entries/credits.js +7 -7
- package/dist/entries/model-catalog.cjs +75 -63
- package/dist/entries/model-catalog.d.cts +2 -2
- package/dist/entries/model-catalog.d.ts +2 -2
- package/dist/entries/model-catalog.js +4 -4
- package/dist/entries/models.cjs +209 -209
- package/dist/entries/models.d.cts +3 -3
- package/dist/entries/models.d.ts +3 -3
- package/dist/entries/models.js +4 -4
- package/dist/entries/nodes.cjs +200 -200
- package/dist/entries/nodes.d.cts +1 -1
- package/dist/entries/nodes.d.ts +1 -1
- package/dist/entries/nodes.js +8 -8
- package/dist/entries/pipeline.cjs +149 -149
- package/dist/entries/pipeline.d.cts +6 -6
- package/dist/entries/pipeline.d.ts +6 -6
- package/dist/entries/pipeline.js +3 -3
- package/dist/entries/ugc.cjs +71 -71
- package/dist/entries/ugc.js +4 -4
- package/dist/entries/video.cjs +115 -115
- package/dist/entries/video.js +4 -4
- package/dist/entries/workflow.cjs +95 -95
- package/dist/entries/workflow.d.cts +13 -3
- package/dist/entries/workflow.d.ts +13 -3
- package/dist/entries/workflow.js +1 -1
- package/dist/index.cjs +1087 -1071
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +18 -18
- package/dist/{model-catalog-flJYaa-g.d.ts → model-catalog-V-ZNzRSd.d.cts} +91 -1
- package/dist/{model-catalog-flJYaa-g.d.cts → model-catalog-V-ZNzRSd.d.ts} +91 -1
- package/dist/{presentation-utils-BIqiCzSA.d.cts → presentation-utils-D0kxsWf9.d.cts} +2 -0
- package/dist/{presentation-utils-BdiObtwq.d.ts → presentation-utils-pZwlEAzo.d.ts} +2 -0
- package/dist/{scene-node-types-DjenYFLO.d.ts → scene-node-types-C3kl_zyK.d.cts} +1 -1
- package/dist/{scene-node-types-DjenYFLO.d.cts → scene-node-types-C3kl_zyK.d.ts} +1 -1
- package/package.json +1 -1
- package/src/__tests__/model-makers.test.ts +76 -0
- package/src/__tests__/presentation-utils.test.ts +15 -0
- package/src/__tests__/private-host.test.ts +53 -0
- package/src/component-types.ts +9 -0
- package/src/credit-identifiers.ts +62 -17
- package/src/entries/credits.ts +1 -0
- package/src/entries/model-catalog.ts +6 -0
- package/src/model-catalog.ts +207 -0
- package/src/presentation-utils.ts +7 -0
- package/src/private-host.ts +89 -59
- package/dist/chunk-3CUFITU7.js.map +0 -1
- package/dist/chunk-5AUSSJIM.cjs.map +0 -1
- package/dist/chunk-5U7VLG43.js.map +0 -1
- package/dist/chunk-AROWPFO2.js.map +0 -1
- package/dist/chunk-AVQK77G6.cjs.map +0 -1
- package/dist/chunk-C57NEO3X.js.map +0 -1
- package/dist/chunk-IEBZHTPE.js.map +0 -1
- package/dist/chunk-NT6IJH4L.cjs.map +0 -1
- package/dist/chunk-O7PUQLJ3.cjs.map +0 -1
- package/dist/chunk-RJL7RCEM.cjs.map +0 -1
- package/dist/chunk-WNG7HRVA.cjs +0 -25
|
@@ -457,6 +457,8 @@ const MEDIA_INPUT_FIELD_TYPES: ReadonlySet<InputFieldSchema["type"]> = new Set([
|
|
|
457
457
|
*
|
|
458
458
|
* An override sent under a renamed exposed-field key (an app published before
|
|
459
459
|
* the rename) lands on the node's current field — `canonicalizeOverrideKeys`.
|
|
460
|
+
*
|
|
461
|
+
* An override of `null` clears the field: the merged node has no such key.
|
|
460
462
|
*/
|
|
461
463
|
export function mergeNodeInputOverrides(
|
|
462
464
|
nodeType: string | undefined,
|
|
@@ -467,6 +469,11 @@ export function mergeNodeInputOverrides(
|
|
|
467
469
|
// A Video URL node on a new link sheds what was fetched for the old one.
|
|
468
470
|
const base = nodeType === "youtube-video" ? dropStaleVideoLinkFields(data, incoming) : data
|
|
469
471
|
const merged: Record<string, unknown> = { ...base, ...incoming }
|
|
472
|
+
// A null override CLEARS the field: the run has no value there, neither null nor the saved one. JSON cannot
|
|
473
|
+
// carry `undefined`, so this is how a run says "unset" (an app card clearing a lever the chosen model lacks).
|
|
474
|
+
for (const [key, value] of Object.entries(incoming)) {
|
|
475
|
+
if (value === null) delete merged[key]
|
|
476
|
+
}
|
|
470
477
|
const schema = nodeType ? INPUT_FIELD_MAP[nodeType] : undefined
|
|
471
478
|
if (
|
|
472
479
|
schema &&
|
package/src/private-host.ts
CHANGED
|
@@ -8,74 +8,104 @@
|
|
|
8
8
|
* Literal hosts only. A name that RESOLVES to a private address is caught where
|
|
9
9
|
* the connection is made (`safeFetch` re-validates the resolved IP); nothing
|
|
10
10
|
* here does DNS.
|
|
11
|
+
*
|
|
12
|
+
* The documentation blocks (192.0.2.0/24, 198.51.100.0/24, 203.0.113.0/24,
|
|
13
|
+
* 2001:db8::/32) are deliberately NOT refused: no network routes them, so they
|
|
14
|
+
* are no SSRF target, and this same rule decides which client addresses the
|
|
15
|
+
* server trusts and keys rate limits on (client-address.ts, hosting-ranges.ts),
|
|
16
|
+
* where they stand in for public addresses.
|
|
11
17
|
*/
|
|
12
18
|
|
|
19
|
+
function isPrivateOrReservedIPv4(a: number, b: number, c: number): boolean {
|
|
20
|
+
if (a === 0) return true // 0.0.0.0/8 "this network"
|
|
21
|
+
if (a === 127) return true // 127.0.0.0/8 loopback
|
|
22
|
+
if (a === 10) return true // 10.0.0.0/8 private
|
|
23
|
+
if (a === 172 && b >= 16 && b <= 31) return true // 172.16.0.0/12 private
|
|
24
|
+
if (a === 192 && b === 168) return true // 192.168.0.0/16 private
|
|
25
|
+
if (a === 169 && b === 254) return true // 169.254.0.0/16 link-local + AWS/GCP metadata
|
|
26
|
+
if (a === 100 && b >= 64 && b <= 127) return true // 100.64.0.0/10 CGN
|
|
27
|
+
if (a === 198 && (b === 18 || b === 19)) return true // 198.18.0.0/15 benchmarking
|
|
28
|
+
if (a === 192 && b === 0 && c === 0) return true // 192.0.0.0/24 IETF protocol assignments (DS-Lite, NAT64 discovery)
|
|
29
|
+
if (a >= 224) return true // 224.0.0.0/4 multicast + 240.0.0.0/4 reserved + 255.255.255.255
|
|
30
|
+
return false
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** The IPv4 address carried in two 16-bit groups. */
|
|
34
|
+
function embeddedIPv4IsPrivate(hi: number, lo: number): boolean {
|
|
35
|
+
return isPrivateOrReservedIPv4(hi >> 8, hi & 0xff, lo >> 8)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* The eight 16-bit groups of an IPv6 address, or null when `ip` is not one.
|
|
40
|
+
* Reads `::` compression, a dotted IPv4 tail (`::ffff:127.0.0.1`) and a zone
|
|
41
|
+
* suffix (`fe80::1%eth0`).
|
|
42
|
+
*/
|
|
43
|
+
function ipv6Groups(ip: string): number[] | null {
|
|
44
|
+
let text = ip.toLowerCase()
|
|
45
|
+
const zone = text.indexOf("%")
|
|
46
|
+
if (zone >= 0) text = text.slice(0, zone)
|
|
47
|
+
if (!text.includes(":") || !/^[0-9a-f:.]+$/.test(text)) return null
|
|
48
|
+
|
|
49
|
+
const lastColon = text.lastIndexOf(":")
|
|
50
|
+
const last = text.slice(lastColon + 1)
|
|
51
|
+
if (last.includes(".")) {
|
|
52
|
+
const parts = last.split(".")
|
|
53
|
+
if (parts.length !== 4 || parts.some((p) => !/^\d{1,3}$/.test(p) || Number(p) > 255)) return null
|
|
54
|
+
const [a, b, c, d] = parts.map(Number) as [number, number, number, number]
|
|
55
|
+
text = `${text.slice(0, lastColon + 1)}${((a << 8) | b).toString(16)}:${((c << 8) | d).toString(16)}`
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const halves = text.split("::")
|
|
59
|
+
if (halves.length > 2) return null
|
|
60
|
+
const groupsOf = (part: string) => (part === "" ? [] : part.split(":"))
|
|
61
|
+
const head = groupsOf(halves[0] ?? "")
|
|
62
|
+
const tail = halves.length === 2 ? groupsOf(halves[1] ?? "") : []
|
|
63
|
+
if ([...head, ...tail].some((g) => !/^[0-9a-f]{1,4}$/.test(g))) return null
|
|
64
|
+
if (halves.length === 1) {
|
|
65
|
+
return head.length === 8 ? head.map((g) => parseInt(g, 16)) : null
|
|
66
|
+
}
|
|
67
|
+
const missing = 8 - head.length - tail.length
|
|
68
|
+
if (missing < 1) return null
|
|
69
|
+
return [...head, ...Array<string>(missing).fill("0"), ...tail].map((g) => parseInt(g, 16))
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function isPrivateOrReservedIPv6(g: number[]): boolean {
|
|
73
|
+
const zeroThrough = (n: number) => g.slice(0, n).every((x) => x === 0)
|
|
74
|
+
const [g0 = 0, g1 = 0, g2 = 0, g3 = 0, , g5 = 0, g6 = 0, g7 = 0] = g
|
|
75
|
+
if (zeroThrough(8)) return true // :: unspecified
|
|
76
|
+
if (zeroThrough(7) && g7 === 1) return true // ::1 loopback
|
|
77
|
+
if (zeroThrough(5) && g5 === 0xffff) return embeddedIPv4IsPrivate(g6, g7) // ::ffff:0:0/96 IPv4-mapped
|
|
78
|
+
if (zeroThrough(6)) return embeddedIPv4IsPrivate(g6, g7) // ::/96 IPv4-compatible (deprecated)
|
|
79
|
+
if (g0 === 0x64 && g1 === 0xff9b && g.slice(2, 6).every((x) => x === 0)) {
|
|
80
|
+
return embeddedIPv4IsPrivate(g6, g7) // 64:ff9b::/96 NAT64: the IPv4 it reaches
|
|
81
|
+
}
|
|
82
|
+
if (g0 === 0x64 && g1 === 0xff9b && g2 === 1) return true // 64:ff9b:1::/48 local-use NAT64
|
|
83
|
+
if (g0 === 0x2002) return embeddedIPv4IsPrivate(g1, g2) // 2002::/16 6to4: the IPv4 it reaches
|
|
84
|
+
if (g0 === 0x2001 && g1 === 0) return true // 2001::/32 Teredo
|
|
85
|
+
if ((g0 & 0xfe00) === 0xfc00) return true // fc00::/7 unique-local
|
|
86
|
+
if ((g0 & 0xffc0) === 0xfe80) return true // fe80::/10 link-local (fe80:: to febf::)
|
|
87
|
+
if ((g0 & 0xffc0) === 0xfec0) return true // fec0::/10 site-local (deprecated)
|
|
88
|
+
if ((g0 & 0xff00) === 0xff00) return true // ff00::/8 multicast
|
|
89
|
+
return false
|
|
90
|
+
}
|
|
91
|
+
|
|
13
92
|
/**
|
|
14
93
|
* True if the IP belongs to a range we refuse to connect to from server-side
|
|
15
|
-
* fetches. Covers IPv4 loopback/private/link-local/cloud-metadata/
|
|
16
|
-
*
|
|
94
|
+
* fetches. Covers IPv4 loopback/private/link-local/cloud-metadata/CGN/
|
|
95
|
+
* multicast/reserved, the equivalent IPv6 classes, and every
|
|
96
|
+
* IPv6 form that carries an IPv4 address (mapped, compatible, NAT64, 6to4 —
|
|
97
|
+
* judged by the IPv4 they reach). Something with a colon that is not a valid
|
|
98
|
+
* IPv6 address is refused (fail closed); anything else that is not an IP (a
|
|
99
|
+
* host name) is not refused here.
|
|
17
100
|
*/
|
|
18
101
|
export function isPrivateOrReservedIP(ip: string): boolean {
|
|
19
102
|
const v4 = ip.match(/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/)
|
|
20
103
|
if (v4) {
|
|
21
|
-
|
|
22
|
-
const b = Number(v4[2])
|
|
23
|
-
if (a === 0) return true // 0.0.0.0/8 "this network"
|
|
24
|
-
if (a === 127) return true // 127.0.0.0/8 loopback
|
|
25
|
-
if (a === 10) return true // 10.0.0.0/8 private
|
|
26
|
-
if (a === 172 && b >= 16 && b <= 31) return true // 172.16.0.0/12 private
|
|
27
|
-
if (a === 192 && b === 168) return true // 192.168.0.0/16 private
|
|
28
|
-
if (a === 169 && b === 254) return true // 169.254.0.0/16 link-local + AWS/GCP metadata
|
|
29
|
-
if (a === 100 && b >= 64 && b <= 127) return true // 100.64.0.0/10 CGN
|
|
30
|
-
if (a === 198 && (b === 18 || b === 19)) return true // 198.18.0.0/15 benchmarking
|
|
31
|
-
if (a >= 224) return true // 224.0.0.0/4 multicast + 240.0.0.0/4 reserved + 255.255.255.255
|
|
32
|
-
return false
|
|
33
|
-
}
|
|
34
|
-
// IPv6. Hostnames from URL parsing come without brackets.
|
|
35
|
-
const lower = ip.toLowerCase()
|
|
36
|
-
if (lower === "::" || lower === "::1") return true // unspecified / loopback
|
|
37
|
-
if (lower.startsWith("fe80:") || lower.startsWith("fe80::")) return true // link-local fe80::/10
|
|
38
|
-
if (/^f[cd]/.test(lower)) return true // unique-local fc00::/7
|
|
39
|
-
if (lower.startsWith("ff")) return true // multicast ff00::/8
|
|
40
|
-
if (lower.startsWith("::ffff:")) {
|
|
41
|
-
// IPv4-mapped IPv6. WHATWG URL parsing normalises the dotted-quad tail
|
|
42
|
-
// into two hex quads (`::ffff:127.0.0.1` → `::ffff:7f00:1`), so handle
|
|
43
|
-
// both forms.
|
|
44
|
-
const tail = lower.slice(7)
|
|
45
|
-
if (tail.includes(".")) {
|
|
46
|
-
return isPrivateOrReservedIP(tail)
|
|
47
|
-
}
|
|
48
|
-
const parts = tail.split(":")
|
|
49
|
-
if (parts.length === 2) {
|
|
50
|
-
const hi = parseInt(parts[0] || "0", 16)
|
|
51
|
-
const lo = parseInt(parts[1] || "0", 16)
|
|
52
|
-
if (Number.isFinite(hi) && Number.isFinite(lo)) {
|
|
53
|
-
const ipv4 = `${(hi >> 8) & 0xff}.${hi & 0xff}.${(lo >> 8) & 0xff}.${lo & 0xff}`
|
|
54
|
-
return isPrivateOrReservedIP(ipv4)
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
// Unrecognisable mapped form — fail closed, treat as reserved.
|
|
58
|
-
return true
|
|
104
|
+
return isPrivateOrReservedIPv4(Number(v4[1]), Number(v4[2]), Number(v4[3]))
|
|
59
105
|
}
|
|
60
|
-
if (
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
// hex quads (`::7f00:1`), exactly like the ::ffff: case above — handle both,
|
|
64
|
-
// or the canonical hex form silently fails open.
|
|
65
|
-
const tail = lower.slice(2)
|
|
66
|
-
if (/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(tail)) {
|
|
67
|
-
return isPrivateOrReservedIP(tail)
|
|
68
|
-
}
|
|
69
|
-
const parts = tail.split(":")
|
|
70
|
-
if (parts.length === 2 && /^[0-9a-f]{1,4}$/.test(parts[0]) && /^[0-9a-f]{1,4}$/.test(parts[1])) {
|
|
71
|
-
const hi = parseInt(parts[0], 16)
|
|
72
|
-
const lo = parseInt(parts[1], 16)
|
|
73
|
-
if (Number.isFinite(hi) && Number.isFinite(lo)) {
|
|
74
|
-
return isPrivateOrReservedIP(`${(hi >> 8) & 0xff}.${hi & 0xff}.${(lo >> 8) & 0xff}.${lo & 0xff}`)
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
return false
|
|
106
|
+
if (!ip.includes(":")) return false
|
|
107
|
+
const groups = ipv6Groups(ip)
|
|
108
|
+
return groups === null ? true : isPrivateOrReservedIPv6(groups)
|
|
79
109
|
}
|
|
80
110
|
|
|
81
111
|
/**
|