@earendil-works/pi-schema 0.0.0-stage → 1.5.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 +13 -0
- package/LICENSES/typebox-LICENSE +23 -0
- package/README.md +295 -2
- package/dist/annotations.d.ts +44 -0
- package/dist/annotations.d.ts.map +1 -0
- package/dist/annotations.js +193 -0
- package/dist/annotations.js.map +1 -0
- package/dist/builders.d.ts +114 -0
- package/dist/builders.d.ts.map +1 -0
- package/dist/builders.js +98 -0
- package/dist/builders.js.map +1 -0
- package/dist/checks.d.ts +87 -0
- package/dist/checks.d.ts.map +1 -0
- package/dist/checks.js +447 -0
- package/dist/checks.js.map +1 -0
- package/dist/coerce.d.ts +53 -0
- package/dist/coerce.d.ts.map +1 -0
- package/dist/coerce.js +585 -0
- package/dist/coerce.js.map +1 -0
- package/dist/compiler.d.ts +53 -0
- package/dist/compiler.d.ts.map +1 -0
- package/dist/compiler.js +532 -0
- package/dist/compiler.js.map +1 -0
- package/dist/explain.d.ts +29 -0
- package/dist/explain.d.ts.map +1 -0
- package/dist/explain.js +381 -0
- package/dist/explain.js.map +1 -0
- package/dist/formats/index.d.ts +7 -0
- package/dist/formats/index.d.ts.map +1 -0
- package/dist/formats/index.js +51 -0
- package/dist/formats/index.js.map +1 -0
- package/dist/formats/typebox/date.d.ts +7 -0
- package/dist/formats/typebox/date.d.ts.map +1 -0
- package/dist/formats/typebox/date.js +47 -0
- package/dist/formats/typebox/date.js.map +1 -0
- package/dist/formats/typebox/date_time.d.ts +7 -0
- package/dist/formats/typebox/date_time.d.ts.map +1 -0
- package/dist/formats/typebox/date_time.js +39 -0
- package/dist/formats/typebox/date_time.js.map +1 -0
- package/dist/formats/typebox/duration.d.ts +6 -0
- package/dist/formats/typebox/duration.d.ts.map +1 -0
- package/dist/formats/typebox/duration.js +36 -0
- package/dist/formats/typebox/duration.js.map +1 -0
- package/dist/formats/typebox/email.d.ts +6 -0
- package/dist/formats/typebox/email.d.ts.map +1 -0
- package/dist/formats/typebox/email.js +36 -0
- package/dist/formats/typebox/email.js.map +1 -0
- package/dist/formats/typebox/hostname.d.ts +8 -0
- package/dist/formats/typebox/hostname.d.ts.map +1 -0
- package/dist/formats/typebox/hostname.js +38 -0
- package/dist/formats/typebox/hostname.js.map +1 -0
- package/dist/formats/typebox/idn_email.d.ts +6 -0
- package/dist/formats/typebox/idn_email.d.ts.map +1 -0
- package/dist/formats/typebox/idn_email.js +36 -0
- package/dist/formats/typebox/idn_email.js.map +1 -0
- package/dist/formats/typebox/idn_hostname.d.ts +9 -0
- package/dist/formats/typebox/idn_hostname.d.ts.map +1 -0
- package/dist/formats/typebox/idn_hostname.js +39 -0
- package/dist/formats/typebox/idn_hostname.js.map +1 -0
- package/dist/formats/typebox/idna/format/bidi.d.ts +4 -0
- package/dist/formats/typebox/idna/format/bidi.d.ts.map +1 -0
- package/dist/formats/typebox/idna/format/bidi.js +132 -0
- package/dist/formats/typebox/idna/format/bidi.js.map +1 -0
- package/dist/formats/typebox/idna/format/puny.d.ts +4 -0
- package/dist/formats/typebox/idna/format/puny.d.ts.map +1 -0
- package/dist/formats/typebox/idna/format/puny.js +172 -0
- package/dist/formats/typebox/idna/format/puny.js.map +1 -0
- package/dist/formats/typebox/idna/hostname.d.ts +2 -0
- package/dist/formats/typebox/idna/hostname.d.ts.map +1 -0
- package/dist/formats/typebox/idna/hostname.js +43 -0
- package/dist/formats/typebox/idna/hostname.js.map +1 -0
- package/dist/formats/typebox/idna/idn-hostname.d.ts +2 -0
- package/dist/formats/typebox/idna/idn-hostname.d.ts.map +1 -0
- package/dist/formats/typebox/idna/idn-hostname.js +71 -0
- package/dist/formats/typebox/idna/idn-hostname.js.map +1 -0
- package/dist/formats/typebox/idna/index.d.ts +3 -0
- package/dist/formats/typebox/idna/index.d.ts.map +1 -0
- package/dist/formats/typebox/idna/index.js +30 -0
- package/dist/formats/typebox/idna/index.js.map +1 -0
- package/dist/formats/typebox/idna/label/ascii.d.ts +2 -0
- package/dist/formats/typebox/idna/label/ascii.d.ts.map +1 -0
- package/dist/formats/typebox/idna/label/ascii.js +37 -0
- package/dist/formats/typebox/idna/label/ascii.js.map +1 -0
- package/dist/formats/typebox/idna/label/puny.d.ts +2 -0
- package/dist/formats/typebox/idna/label/puny.d.ts.map +1 -0
- package/dist/formats/typebox/idna/label/puny.js +56 -0
- package/dist/formats/typebox/idna/label/puny.js.map +1 -0
- package/dist/formats/typebox/idna/label/unicode.d.ts +2 -0
- package/dist/formats/typebox/idna/label/unicode.d.ts.map +1 -0
- package/dist/formats/typebox/idna/label/unicode.js +134 -0
- package/dist/formats/typebox/idna/label/unicode.js.map +1 -0
- package/dist/formats/typebox/idna/pattern/pattern.d.ts +31 -0
- package/dist/formats/typebox/idna/pattern/pattern.d.ts.map +1 -0
- package/dist/formats/typebox/idna/pattern/pattern.js +98 -0
- package/dist/formats/typebox/idna/pattern/pattern.js.map +1 -0
- package/dist/formats/typebox/ipv4.d.ts +6 -0
- package/dist/formats/typebox/ipv4.d.ts.map +1 -0
- package/dist/formats/typebox/ipv4.js +36 -0
- package/dist/formats/typebox/ipv4.js.map +1 -0
- package/dist/formats/typebox/ipv6.d.ts +6 -0
- package/dist/formats/typebox/ipv6.d.ts.map +1 -0
- package/dist/formats/typebox/ipv6.js +36 -0
- package/dist/formats/typebox/ipv6.js.map +1 -0
- package/dist/formats/typebox/iri.d.ts +6 -0
- package/dist/formats/typebox/iri.d.ts.map +1 -0
- package/dist/formats/typebox/iri.js +63 -0
- package/dist/formats/typebox/iri.js.map +1 -0
- package/dist/formats/typebox/iri_reference.d.ts +6 -0
- package/dist/formats/typebox/iri_reference.d.ts.map +1 -0
- package/dist/formats/typebox/iri_reference.js +40 -0
- package/dist/formats/typebox/iri_reference.js.map +1 -0
- package/dist/formats/typebox/json_pointer.d.ts +7 -0
- package/dist/formats/typebox/json_pointer.d.ts.map +1 -0
- package/dist/formats/typebox/json_pointer.js +37 -0
- package/dist/formats/typebox/json_pointer.js.map +1 -0
- package/dist/formats/typebox/json_pointer_uri_fragment.d.ts +7 -0
- package/dist/formats/typebox/json_pointer_uri_fragment.d.ts.map +1 -0
- package/dist/formats/typebox/json_pointer_uri_fragment.js +37 -0
- package/dist/formats/typebox/json_pointer_uri_fragment.js.map +1 -0
- package/dist/formats/typebox/regex.d.ts +6 -0
- package/dist/formats/typebox/regex.d.ts.map +1 -0
- package/dist/formats/typebox/regex.js +41 -0
- package/dist/formats/typebox/regex.js.map +1 -0
- package/dist/formats/typebox/relative_json_pointer.d.ts +7 -0
- package/dist/formats/typebox/relative_json_pointer.d.ts.map +1 -0
- package/dist/formats/typebox/relative_json_pointer.js +37 -0
- package/dist/formats/typebox/relative_json_pointer.js.map +1 -0
- package/dist/formats/typebox/time.d.ts +6 -0
- package/dist/formats/typebox/time.d.ts.map +1 -0
- package/dist/formats/typebox/time.js +60 -0
- package/dist/formats/typebox/time.js.map +1 -0
- package/dist/formats/typebox/uri.d.ts +6 -0
- package/dist/formats/typebox/uri.d.ts.map +1 -0
- package/dist/formats/typebox/uri.js +36 -0
- package/dist/formats/typebox/uri.js.map +1 -0
- package/dist/formats/typebox/uri_reference.d.ts +6 -0
- package/dist/formats/typebox/uri_reference.d.ts.map +1 -0
- package/dist/formats/typebox/uri_reference.js +36 -0
- package/dist/formats/typebox/uri_reference.js.map +1 -0
- package/dist/formats/typebox/uri_template.d.ts +6 -0
- package/dist/formats/typebox/uri_template.d.ts.map +1 -0
- package/dist/formats/typebox/uri_template.js +37 -0
- package/dist/formats/typebox/uri_template.js.map +1 -0
- package/dist/formats/typebox/url.d.ts +7 -0
- package/dist/formats/typebox/url.d.ts.map +1 -0
- package/dist/formats/typebox/url.js +36 -0
- package/dist/formats/typebox/url.js.map +1 -0
- package/dist/formats/typebox/uuid.d.ts +7 -0
- package/dist/formats/typebox/uuid.d.ts.map +1 -0
- package/dist/formats/typebox/uuid.js +37 -0
- package/dist/formats/typebox/uuid.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/resolver.d.ts +57 -0
- package/dist/resolver.d.ts.map +1 -0
- package/dist/resolver.js +202 -0
- package/dist/resolver.js.map +1 -0
- package/dist/shared.d.ts +9 -0
- package/dist/shared.d.ts.map +1 -0
- package/dist/shared.js +33 -0
- package/dist/shared.js.map +1 -0
- package/dist/typebox-static.d.ts +48 -0
- package/dist/typebox-static.d.ts.map +1 -0
- package/dist/typebox-static.js +5 -0
- package/dist/typebox-static.js.map +1 -0
- package/dist/types.d.ts +48 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/dist/validator.d.ts +39 -0
- package/dist/validator.d.ts.map +1 -0
- package/dist/validator.js +71 -0
- package/dist/validator.js.map +1 -0
- package/package.json +59 -5
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/*--------------------------------------------------------------------------
|
|
2
|
+
|
|
3
|
+
TypeBox
|
|
4
|
+
|
|
5
|
+
The MIT License (MIT)
|
|
6
|
+
|
|
7
|
+
Copyright (c) 2017-2026 Haydn Paterson
|
|
8
|
+
|
|
9
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
10
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
11
|
+
in the Software without restriction, including without limitation the rights
|
|
12
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
13
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
14
|
+
furnished to do so, subject to the following conditions:
|
|
15
|
+
|
|
16
|
+
The above copyright notice and this permission notice shall be included in
|
|
17
|
+
all copies or substantial portions of the Software.
|
|
18
|
+
|
|
19
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
23
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
24
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
25
|
+
THE SOFTWARE.
|
|
26
|
+
|
|
27
|
+
---------------------------------------------------------------------------*/
|
|
28
|
+
import * as FormatBidi from "../format/bidi.js";
|
|
29
|
+
import * as FormatPuny from "../format/puny.js";
|
|
30
|
+
import * as Pattern from "../pattern/pattern.js";
|
|
31
|
+
// ------------------------------------------------------------------
|
|
32
|
+
// ExceedsMaxALabelLength
|
|
33
|
+
//
|
|
34
|
+
// RFC 5890 §2.3.2.1: an A-label (the ACE-encoded form of a label,
|
|
35
|
+
// "xn--" + punycode) must not exceed 63 octets. Only labels
|
|
36
|
+
// containing non-ASCII characters need checking - a pure-ASCII label
|
|
37
|
+
// has no "xn--" prefix and is used as-is, so its punycode-encoded
|
|
38
|
+
// length is irrelevant. The ASCII check is a cheap short-circuit that
|
|
39
|
+
// avoids running the punycode encoder on labels that don't need it.
|
|
40
|
+
// ------------------------------------------------------------------
|
|
41
|
+
function ExceedsMaxALabelLength(value) {
|
|
42
|
+
return Pattern.RE_NON_ASCII.test(value) && FormatPuny.Encode(value).length + 4 > 63;
|
|
43
|
+
}
|
|
44
|
+
// ------------------------------------------------------------------
|
|
45
|
+
// HasInvalidHyphens
|
|
46
|
+
//
|
|
47
|
+
// RFC 5891 §4.2.3.2: label must not start or end with a hyphen, and
|
|
48
|
+
// must not have hyphens in the 3rd and 4th codepoint positions (the
|
|
49
|
+
// ACE prefix reservation, e.g. "xn--"). Operates on `chars` (the
|
|
50
|
+
// per-codepoint string array) rather than raw string indices so
|
|
51
|
+
// supplementary-plane characters earlier in the label don't throw
|
|
52
|
+
// off the codepoint-position count.
|
|
53
|
+
// ------------------------------------------------------------------
|
|
54
|
+
function HasInvalidHyphens(chars) {
|
|
55
|
+
if (chars[0] === "-" || chars[chars.length - 1] === "-")
|
|
56
|
+
return true;
|
|
57
|
+
return chars.slice(2).join("").startsWith("--");
|
|
58
|
+
}
|
|
59
|
+
// ------------------------------------------------------------------
|
|
60
|
+
// IsUnicodeLabel
|
|
61
|
+
// ------------------------------------------------------------------
|
|
62
|
+
export function IsUnicodeLabel(value) {
|
|
63
|
+
// RFC 5890 §2.3.2.1: Ensure Max Length
|
|
64
|
+
if (ExceedsMaxALabelLength(value))
|
|
65
|
+
return false;
|
|
66
|
+
// RFC 5893 - Bidi Rule (applies whenever this label itself is RTL)
|
|
67
|
+
if (FormatBidi.HasRightToLeftCharacters(value) && !FormatBidi.SatisfiesBidiRule(value))
|
|
68
|
+
return false;
|
|
69
|
+
const chars = [...value];
|
|
70
|
+
const codePoints = chars.map((c) => c.codePointAt(0));
|
|
71
|
+
const length = codePoints.length;
|
|
72
|
+
// RFC 5891 §4.2.3.2: Hyphen rules
|
|
73
|
+
if (HasInvalidHyphens(chars))
|
|
74
|
+
return false;
|
|
75
|
+
// RFC 5891 §4.2.3.2 - Must not begin with a combining mark
|
|
76
|
+
if (Pattern.RE_COMBINING_MARK.test(chars[0]))
|
|
77
|
+
return false;
|
|
78
|
+
let hasJapanese = false;
|
|
79
|
+
// let hasArabicIndic = false // (no-spec-coverage)
|
|
80
|
+
// let hasExtendedArabicIndic = false // (no-spec-coverage)
|
|
81
|
+
for (let i = 0; i < length; i++) {
|
|
82
|
+
const codePoint = codePoints[i];
|
|
83
|
+
const char = chars[i];
|
|
84
|
+
// 1. DISALLOWED exceptions
|
|
85
|
+
if (Pattern.RE_RFC5892_DISALLOWED.test(char))
|
|
86
|
+
return false;
|
|
87
|
+
// 1b. General category (PVALID) enforcement
|
|
88
|
+
if (!Pattern.RE_PERMITTED_CATEGORY.test(char))
|
|
89
|
+
return false;
|
|
90
|
+
// 2. Collect Flags
|
|
91
|
+
if (Pattern.RE_SCRIPT_JAPANESE.test(char))
|
|
92
|
+
hasJapanese = true;
|
|
93
|
+
// if (Pattern.RE_ARABIC_INDIC_DIGIT.test(char)) hasArabicIndic = true // (no-spec-coverage)
|
|
94
|
+
// if (Pattern.RE_EXT_ARABIC_INDIC_DIGIT.test(char)) hasExtendedArabicIndic = true // (no-spec-coverage)
|
|
95
|
+
// 3. CONTEXTO / CONTEXTJ Neighbor Rules
|
|
96
|
+
const prev = codePoints[i - 1], next = codePoints[i + 1];
|
|
97
|
+
switch (codePoint) {
|
|
98
|
+
case 0x00b7:
|
|
99
|
+
if (prev !== 0x006c || next !== 0x006c)
|
|
100
|
+
return false;
|
|
101
|
+
break; // MIDDLE DOT (Catalan)
|
|
102
|
+
case 0x0375:
|
|
103
|
+
if (!next || !Pattern.RE_SCRIPT_GREEK.test(chars[i + 1]))
|
|
104
|
+
return false;
|
|
105
|
+
break; // Greek KERAIA
|
|
106
|
+
case 0x05f3:
|
|
107
|
+
case 0x05f4:
|
|
108
|
+
if (!prev || !Pattern.RE_SCRIPT_HEBREW.test(chars[i - 1]))
|
|
109
|
+
return false;
|
|
110
|
+
break; // Hebrew GERESH
|
|
111
|
+
case 0x200c: // ZWNJ - RFC 5892 Appendix A.1
|
|
112
|
+
// Note: Full validation requires a Unicode joining type table. We reject
|
|
113
|
+
// only when preceded by ASCII (U+0000-U+007F), which can never satisfy
|
|
114
|
+
// the Virama or cursive-joining rules.
|
|
115
|
+
if (!prev || (prev < 0x0080 && !Pattern.RE_VIRAMA.test(chars[i - 1])))
|
|
116
|
+
return false;
|
|
117
|
+
break;
|
|
118
|
+
case 0x200d: // ZWJ: RFC 5892 Appendix A.2
|
|
119
|
+
if (!prev || !Pattern.RE_VIRAMA.test(chars[i - 1]))
|
|
120
|
+
return false;
|
|
121
|
+
break;
|
|
122
|
+
case 0x30fb: // Checked at end via hasJapanese
|
|
123
|
+
break; // KATAKANA MIDDLE DOT
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
// 4. Global Context Validations (Post-loop)
|
|
127
|
+
// RFC 5892 Appendix A.7 - Katakana Middle Dot requirement
|
|
128
|
+
if (value.includes("\u30fb") && !hasJapanese)
|
|
129
|
+
return false;
|
|
130
|
+
// RFC 5892 Appendix A.8/A.9 - Mixing Arabic Digits
|
|
131
|
+
// if (hasArabicIndic && hasExtendedArabicIndic) return false // (no-spec-coverage)
|
|
132
|
+
return true;
|
|
133
|
+
}
|
|
134
|
+
//# sourceMappingURL=unicode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unicode.js","sourceRoot":"","sources":["../../../../../src/formats/typebox/idna/label/unicode.ts"],"names":[],"mappings":"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","sourcesContent":["/*--------------------------------------------------------------------------\n\nTypeBox\n\nThe MIT License (MIT)\n\nCopyright (c) 2017-2026 Haydn Paterson\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n\n---------------------------------------------------------------------------*/\n\nimport * as FormatBidi from \"../format/bidi.ts\";\nimport * as FormatPuny from \"../format/puny.ts\";\nimport * as Pattern from \"../pattern/pattern.ts\";\n\n// ------------------------------------------------------------------\n// ExceedsMaxALabelLength\n//\n// RFC 5890 §2.3.2.1: an A-label (the ACE-encoded form of a label,\n// \"xn--\" + punycode) must not exceed 63 octets. Only labels\n// containing non-ASCII characters need checking - a pure-ASCII label\n// has no \"xn--\" prefix and is used as-is, so its punycode-encoded\n// length is irrelevant. The ASCII check is a cheap short-circuit that\n// avoids running the punycode encoder on labels that don't need it.\n// ------------------------------------------------------------------\nfunction ExceedsMaxALabelLength(value: string): boolean {\n\treturn Pattern.RE_NON_ASCII.test(value) && FormatPuny.Encode(value).length + 4 > 63;\n}\n// ------------------------------------------------------------------\n// HasInvalidHyphens\n//\n// RFC 5891 §4.2.3.2: label must not start or end with a hyphen, and\n// must not have hyphens in the 3rd and 4th codepoint positions (the\n// ACE prefix reservation, e.g. \"xn--\"). Operates on `chars` (the\n// per-codepoint string array) rather than raw string indices so\n// supplementary-plane characters earlier in the label don't throw\n// off the codepoint-position count.\n// ------------------------------------------------------------------\nfunction HasInvalidHyphens(chars: string[]): boolean {\n\tif (chars[0] === \"-\" || chars[chars.length - 1] === \"-\") return true;\n\treturn chars.slice(2).join(\"\").startsWith(\"--\");\n}\n// ------------------------------------------------------------------\n// IsUnicodeLabel\n// ------------------------------------------------------------------\nexport function IsUnicodeLabel(value: string): boolean {\n\t// RFC 5890 §2.3.2.1: Ensure Max Length\n\tif (ExceedsMaxALabelLength(value)) return false;\n\t// RFC 5893 - Bidi Rule (applies whenever this label itself is RTL)\n\tif (FormatBidi.HasRightToLeftCharacters(value) && !FormatBidi.SatisfiesBidiRule(value)) return false;\n\tconst chars = [...value];\n\tconst codePoints = chars.map((c) => c.codePointAt(0)!);\n\tconst length = codePoints.length;\n\t// RFC 5891 §4.2.3.2: Hyphen rules\n\tif (HasInvalidHyphens(chars)) return false;\n\t// RFC 5891 §4.2.3.2 - Must not begin with a combining mark\n\tif (Pattern.RE_COMBINING_MARK.test(chars[0])) return false;\n\tlet hasJapanese = false;\n\t// let hasArabicIndic = false // (no-spec-coverage)\n\t// let hasExtendedArabicIndic = false // (no-spec-coverage)\n\tfor (let i = 0; i < length; i++) {\n\t\tconst codePoint = codePoints[i];\n\t\tconst char = chars[i];\n\t\t// 1. DISALLOWED exceptions\n\t\tif (Pattern.RE_RFC5892_DISALLOWED.test(char)) return false;\n\t\t// 1b. General category (PVALID) enforcement\n\t\tif (!Pattern.RE_PERMITTED_CATEGORY.test(char)) return false;\n\t\t// 2. Collect Flags\n\t\tif (Pattern.RE_SCRIPT_JAPANESE.test(char)) hasJapanese = true;\n\t\t// if (Pattern.RE_ARABIC_INDIC_DIGIT.test(char)) hasArabicIndic = true // (no-spec-coverage)\n\t\t// if (Pattern.RE_EXT_ARABIC_INDIC_DIGIT.test(char)) hasExtendedArabicIndic = true // (no-spec-coverage)\n\t\t// 3. CONTEXTO / CONTEXTJ Neighbor Rules\n\t\tconst prev = codePoints[i - 1],\n\t\t\tnext = codePoints[i + 1];\n\t\tswitch (codePoint) {\n\t\t\tcase 0x00b7:\n\t\t\t\tif (prev !== 0x006c || next !== 0x006c) return false;\n\t\t\t\tbreak; // MIDDLE DOT (Catalan)\n\t\t\tcase 0x0375:\n\t\t\t\tif (!next || !Pattern.RE_SCRIPT_GREEK.test(chars[i + 1])) return false;\n\t\t\t\tbreak; // Greek KERAIA\n\t\t\tcase 0x05f3:\n\t\t\tcase 0x05f4:\n\t\t\t\tif (!prev || !Pattern.RE_SCRIPT_HEBREW.test(chars[i - 1])) return false;\n\t\t\t\tbreak; // Hebrew GERESH\n\t\t\tcase 0x200c: // ZWNJ - RFC 5892 Appendix A.1\n\t\t\t\t// Note: Full validation requires a Unicode joining type table. We reject\n\t\t\t\t// only when preceded by ASCII (U+0000-U+007F), which can never satisfy\n\t\t\t\t// the Virama or cursive-joining rules.\n\t\t\t\tif (!prev || (prev < 0x0080 && !Pattern.RE_VIRAMA.test(chars[i - 1]))) return false;\n\t\t\t\tbreak;\n\t\t\tcase 0x200d: // ZWJ: RFC 5892 Appendix A.2\n\t\t\t\tif (!prev || !Pattern.RE_VIRAMA.test(chars[i - 1])) return false;\n\t\t\t\tbreak;\n\t\t\tcase 0x30fb: // Checked at end via hasJapanese\n\t\t\t\tbreak; // KATAKANA MIDDLE DOT\n\t\t}\n\t}\n\t// 4. Global Context Validations (Post-loop)\n\t// RFC 5892 Appendix A.7 - Katakana Middle Dot requirement\n\tif (value.includes(\"\\u30fb\") && !hasJapanese) return false;\n\t// RFC 5892 Appendix A.8/A.9 - Mixing Arabic Digits\n\t// if (hasArabicIndic && hasExtendedArabicIndic) return false // (no-spec-coverage)\n\treturn true;\n}\n"]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export declare const RE_RULE_HYPHEN_PLACEMENT: RegExp;
|
|
2
|
+
export declare const RE_RULE_NOT_RESERVED_ACE: RegExp;
|
|
3
|
+
export declare const RE_ASCII_LDH: RegExp;
|
|
4
|
+
export declare const RE_ASCII: RegExp;
|
|
5
|
+
export declare const RE_NON_ASCII: RegExp;
|
|
6
|
+
export declare const RE_HIGH_SURROGATE: RegExp;
|
|
7
|
+
export declare const RE_REGIONAL_INDICATOR: RegExp;
|
|
8
|
+
export declare const RE_VARIATION_SELECTOR: RegExp;
|
|
9
|
+
export declare const RE_ZERO_WIDTH_JOINER: RegExp;
|
|
10
|
+
export declare const RE_ASCII_DIGIT: RegExp;
|
|
11
|
+
export declare const RE_ARABIC_INDIC_DIGIT: RegExp;
|
|
12
|
+
export declare const RE_EXT_ARABIC_INDIC_DIGIT: RegExp;
|
|
13
|
+
export declare const RE_COMMON_SEPARATOR: RegExp;
|
|
14
|
+
export declare const RE_EUROPEAN_SEPARATOR: RegExp;
|
|
15
|
+
export declare const RE_MARK_NONSPACING: RegExp;
|
|
16
|
+
export declare const RE_MARK_SPACING_COMBINING: RegExp;
|
|
17
|
+
export declare const RE_MARK_ENCLOSING: RegExp;
|
|
18
|
+
export declare const RE_COMBINING_MARK: RegExp;
|
|
19
|
+
export declare const RE_LETTER: RegExp;
|
|
20
|
+
export declare const RE_NUMBER_DECIMAL: RegExp;
|
|
21
|
+
export declare const RE_SCRIPT_GREEK: RegExp;
|
|
22
|
+
export declare const RE_SCRIPT_HEBREW: RegExp;
|
|
23
|
+
export declare const RE_SCRIPT_JAPANESE: RegExp;
|
|
24
|
+
export declare const RE_SCRIPT_ARABIC_LETTER: RegExp;
|
|
25
|
+
export declare const RE_VIRAMA: RegExp;
|
|
26
|
+
export declare const RE_RFC5892_DISALLOWED: RegExp;
|
|
27
|
+
export declare const RE_CONTEXTO_EXCEPTIONS: RegExp;
|
|
28
|
+
export declare const RE_PVALID_EXCEPTIONS: RegExp;
|
|
29
|
+
export declare const RE_EUROPEAN_NUMBER: RegExp;
|
|
30
|
+
export declare const RE_PERMITTED_CATEGORY: RegExp;
|
|
31
|
+
//# sourceMappingURL=pattern.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pattern.d.ts","sourceRoot":"","sources":["../../../../../src/formats/typebox/idna/pattern/pattern.ts"],"names":[],"mappings":"AAiCA,eAAO,MAAM,wBAAwB,QAAoB,CAAC;AAC1D,eAAO,MAAM,wBAAwB,QAAc,CAAC;AACpD,eAAO,MAAM,YAAY,QAAoB,CAAC;AAK9C,eAAO,MAAM,QAAQ,QAAkB,CAAC;AACxC,eAAO,MAAM,YAAY,QAAkB,CAAC;AAK5C,eAAO,MAAM,iBAAiB,QAAyB,CAAC;AACxD,eAAO,MAAM,qBAAqB,QAA2B,CAAC;AAC9D,eAAO,MAAM,qBAAqB,QAAyB,CAAC;AAC5D,eAAO,MAAM,oBAAoB,QAAc,CAAC;AAKhD,eAAO,MAAM,cAAc,QAAU,CAAC;AACtC,eAAO,MAAM,qBAAqB,QAAyB,CAAC;AAC5D,eAAO,MAAM,yBAAyB,QAAyB,CAAC;AAKhE,eAAO,MAAM,mBAAmB,QAAwC,CAAC;AACzE,eAAO,MAAM,qBAAqB,QAAwB,CAAC;AAK3D,eAAO,MAAM,kBAAkB,QAAY,CAAC;AAC5C,eAAO,MAAM,yBAAyB,QAAY,CAAC;AACnD,eAAO,MAAM,iBAAiB,QAAY,CAAC;AAC3C,eAAO,MAAM,iBAAiB,QAA0B,CAAC;AACzD,eAAO,MAAM,SAAS,QAAW,CAAC;AAClC,eAAO,MAAM,iBAAiB,QAAY,CAAC;AAK3C,eAAO,MAAM,eAAe,QAAsB,CAAC;AACnD,eAAO,MAAM,gBAAgB,QAAuB,CAAC;AACrD,eAAO,MAAM,kBAAkB,QAA4D,CAAC;AAC5F,eAAO,MAAM,uBAAuB,QAA6E,CAAC;AAKlH,eAAO,MAAM,SAAS,QACgQ,CAAC;AACvR,eAAO,MAAM,qBAAqB,QACoD,CAAC;AAEvF,eAAO,MAAM,sBAAsB,QAAgE,CAAC;AACpG,eAAO,MAAM,oBAAoB,QAAwD,CAAC;AAK1F,eAAO,MAAM,kBAAkB,QAG9B,CAAC;AAEF,eAAO,MAAM,qBAAqB,QAcjC,CAAC"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/*--------------------------------------------------------------------------
|
|
2
|
+
|
|
3
|
+
TypeBox
|
|
4
|
+
|
|
5
|
+
The MIT License (MIT)
|
|
6
|
+
|
|
7
|
+
Copyright (c) 2017-2026 Haydn Paterson
|
|
8
|
+
|
|
9
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
10
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
11
|
+
in the Software without restriction, including without limitation the rights
|
|
12
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
13
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
14
|
+
furnished to do so, subject to the following conditions:
|
|
15
|
+
|
|
16
|
+
The above copyright notice and this permission notice shall be included in
|
|
17
|
+
all copies or substantial portions of the Software.
|
|
18
|
+
|
|
19
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
23
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
24
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
25
|
+
THE SOFTWARE.
|
|
26
|
+
|
|
27
|
+
---------------------------------------------------------------------------*/
|
|
28
|
+
// deno-fmt-ignore-file
|
|
29
|
+
// -------------------------------------------------------------------
|
|
30
|
+
// Validation Rules
|
|
31
|
+
// -------------------------------------------------------------------
|
|
32
|
+
export const RE_RULE_HYPHEN_PLACEMENT = /^(?!-).*(?<!-)$/;
|
|
33
|
+
export const RE_RULE_NOT_RESERVED_ACE = /^(?!..--)/;
|
|
34
|
+
export const RE_ASCII_LDH = /^[a-zA-Z0-9-]*$/;
|
|
35
|
+
// -------------------------------------------------------------------
|
|
36
|
+
// ASCII & Encoding
|
|
37
|
+
// -------------------------------------------------------------------
|
|
38
|
+
export const RE_ASCII = /^\p{ASCII}*$/u;
|
|
39
|
+
export const RE_NON_ASCII = /[^\p{ASCII}]/u;
|
|
40
|
+
// -------------------------------------------------------------------
|
|
41
|
+
// Structural & Unicode Controls
|
|
42
|
+
// -------------------------------------------------------------------
|
|
43
|
+
export const RE_HIGH_SURROGATE = /[\u{d800}-\u{dbff}]/u;
|
|
44
|
+
export const RE_REGIONAL_INDICATOR = /[\u{1f1e6}-\u{1f1ff}]/u;
|
|
45
|
+
export const RE_VARIATION_SELECTOR = /[\u{fe00}-\u{fe0f}]/u;
|
|
46
|
+
export const RE_ZERO_WIDTH_JOINER = /\u{200d}/u;
|
|
47
|
+
// -------------------------------------------------------------------
|
|
48
|
+
// Numbers & Digits
|
|
49
|
+
// -------------------------------------------------------------------
|
|
50
|
+
export const RE_ASCII_DIGIT = /[0-9]/;
|
|
51
|
+
export const RE_ARABIC_INDIC_DIGIT = /[\u{0660}-\u{0669}]/u;
|
|
52
|
+
export const RE_EXT_ARABIC_INDIC_DIGIT = /[\u{06f0}-\u{06f9}]/u;
|
|
53
|
+
// -------------------------------------------------------------------
|
|
54
|
+
// Separators
|
|
55
|
+
// -------------------------------------------------------------------
|
|
56
|
+
export const RE_COMMON_SEPARATOR = /[\u{002e}\u{002c}\u{003a}\u{002f}]/u;
|
|
57
|
+
export const RE_EUROPEAN_SEPARATOR = /[\u{002d}\u{002b}]/u;
|
|
58
|
+
// -------------------------------------------------------------------
|
|
59
|
+
// General Categories
|
|
60
|
+
// -------------------------------------------------------------------
|
|
61
|
+
export const RE_MARK_NONSPACING = /\p{Mn}/u;
|
|
62
|
+
export const RE_MARK_SPACING_COMBINING = /\p{Mc}/u;
|
|
63
|
+
export const RE_MARK_ENCLOSING = /\p{Me}/u;
|
|
64
|
+
export const RE_COMBINING_MARK = /[\p{Mn}\p{Mc}\p{Me}]/u;
|
|
65
|
+
export const RE_LETTER = /\p{L}/u;
|
|
66
|
+
export const RE_NUMBER_DECIMAL = /\p{Nd}/u;
|
|
67
|
+
// -------------------------------------------------------------------
|
|
68
|
+
// Scripts
|
|
69
|
+
// -------------------------------------------------------------------
|
|
70
|
+
export const RE_SCRIPT_GREEK = /\p{Script=Greek}/u;
|
|
71
|
+
export const RE_SCRIPT_HEBREW = /\p{Script=Hebrew}/u;
|
|
72
|
+
export const RE_SCRIPT_JAPANESE = /[\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Han}]/u;
|
|
73
|
+
export const RE_SCRIPT_ARABIC_LETTER = /[\p{Script=Arabic}\p{Script=Syriac}\p{Script=Thaana}\p{Script=Mandaic}]/u;
|
|
74
|
+
// -------------------------------------------------------------------
|
|
75
|
+
// RFC Specifications & Context Exceptions
|
|
76
|
+
// -------------------------------------------------------------------
|
|
77
|
+
export const RE_VIRAMA = /[\u{094d}\u{09cd}\u{0a4d}\u{0acd}\u{0b4d}\u{0bcd}\u{0c4d}\u{0ccd}\u{0d3b}\u{0d3c}\u{0d4d}\u{0dca}\u{1b44}\u{1baa}\u{1bab}\u{a9c0}\u{11046}\u{1107f}\u{110b9}\u{11133}\u{11134}\u{111c0}\u{11235}\u{1134d}\u{11442}\u{114c2}\u{115bf}\u{1163f}\u{116b6}\u{11c3f}\u{11d44}\u{11d45}]/u;
|
|
78
|
+
export const RE_RFC5892_DISALLOWED = /[\u{0640}\u{07fa}\u{302e}\u{302f}\u{3031}\u{3032}\u{3033}\u{3034}\u{3035}\u{303b}]/u;
|
|
79
|
+
// biome-ignore lint/suspicious/noMisleadingCharacterClass: a set of single code points (u flag), including ZWJ and ZWNJ, by design.
|
|
80
|
+
export const RE_CONTEXTO_EXCEPTIONS = /[\u{00b7}\u{0375}\u{05f3}\u{05f4}\u{200c}\u{200d}\u{30fb}]/u;
|
|
81
|
+
export const RE_PVALID_EXCEPTIONS = /[\u{00df}\u{03c2}\u{06fd}\u{06fe}\u{0f0b}\u{3007}]/u;
|
|
82
|
+
// -------------------------------------------------------------------
|
|
83
|
+
// Composite Patterns
|
|
84
|
+
// -------------------------------------------------------------------
|
|
85
|
+
export const RE_EUROPEAN_NUMBER = new RegExp([RE_ASCII_DIGIT, RE_EXT_ARABIC_INDIC_DIGIT].map((regexp) => regexp.source).join("|"), "u");
|
|
86
|
+
export const RE_PERMITTED_CATEGORY = new RegExp([
|
|
87
|
+
RE_LETTER,
|
|
88
|
+
RE_EUROPEAN_SEPARATOR,
|
|
89
|
+
RE_COMMON_SEPARATOR,
|
|
90
|
+
RE_NUMBER_DECIMAL,
|
|
91
|
+
RE_MARK_NONSPACING,
|
|
92
|
+
RE_MARK_SPACING_COMBINING,
|
|
93
|
+
RE_CONTEXTO_EXCEPTIONS,
|
|
94
|
+
RE_PVALID_EXCEPTIONS,
|
|
95
|
+
]
|
|
96
|
+
.map((regexp) => regexp.source)
|
|
97
|
+
.join("|"), "u");
|
|
98
|
+
//# sourceMappingURL=pattern.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pattern.js","sourceRoot":"","sources":["../../../../../src/formats/typebox/idna/pattern/pattern.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;6EA0B6E;AAE7E,uBAAuB;AAEvB,sEAAsE;AACtE,mBAAmB;AACnB,sEAAsE;AACtE,MAAM,CAAC,MAAM,wBAAwB,GAAG,iBAAiB,CAAC;AAC1D,MAAM,CAAC,MAAM,wBAAwB,GAAG,WAAW,CAAC;AACpD,MAAM,CAAC,MAAM,YAAY,GAAG,iBAAiB,CAAC;AAE9C,sEAAsE;AACtE,mBAAmB;AACnB,sEAAsE;AACtE,MAAM,CAAC,MAAM,QAAQ,GAAG,eAAe,CAAC;AACxC,MAAM,CAAC,MAAM,YAAY,GAAG,eAAe,CAAC;AAE5C,sEAAsE;AACtE,gCAAgC;AAChC,sEAAsE;AACtE,MAAM,CAAC,MAAM,iBAAiB,GAAG,sBAAsB,CAAC;AACxD,MAAM,CAAC,MAAM,qBAAqB,GAAG,wBAAwB,CAAC;AAC9D,MAAM,CAAC,MAAM,qBAAqB,GAAG,sBAAsB,CAAC;AAC5D,MAAM,CAAC,MAAM,oBAAoB,GAAG,WAAW,CAAC;AAEhD,sEAAsE;AACtE,mBAAmB;AACnB,sEAAsE;AACtE,MAAM,CAAC,MAAM,cAAc,GAAG,OAAO,CAAC;AACtC,MAAM,CAAC,MAAM,qBAAqB,GAAG,sBAAsB,CAAC;AAC5D,MAAM,CAAC,MAAM,yBAAyB,GAAG,sBAAsB,CAAC;AAEhE,sEAAsE;AACtE,aAAa;AACb,sEAAsE;AACtE,MAAM,CAAC,MAAM,mBAAmB,GAAG,qCAAqC,CAAC;AACzE,MAAM,CAAC,MAAM,qBAAqB,GAAG,qBAAqB,CAAC;AAE3D,sEAAsE;AACtE,qBAAqB;AACrB,sEAAsE;AACtE,MAAM,CAAC,MAAM,kBAAkB,GAAG,SAAS,CAAC;AAC5C,MAAM,CAAC,MAAM,yBAAyB,GAAG,SAAS,CAAC;AACnD,MAAM,CAAC,MAAM,iBAAiB,GAAG,SAAS,CAAC;AAC3C,MAAM,CAAC,MAAM,iBAAiB,GAAG,uBAAuB,CAAC;AACzD,MAAM,CAAC,MAAM,SAAS,GAAG,QAAQ,CAAC;AAClC,MAAM,CAAC,MAAM,iBAAiB,GAAG,SAAS,CAAC;AAE3C,sEAAsE;AACtE,UAAU;AACV,sEAAsE;AACtE,MAAM,CAAC,MAAM,eAAe,GAAG,mBAAmB,CAAC;AACnD,MAAM,CAAC,MAAM,gBAAgB,GAAG,oBAAoB,CAAC;AACrD,MAAM,CAAC,MAAM,kBAAkB,GAAG,yDAAyD,CAAC;AAC5F,MAAM,CAAC,MAAM,uBAAuB,GAAG,0EAA0E,CAAC;AAElH,sEAAsE;AACtE,0CAA0C;AAC1C,sEAAsE;AACtE,MAAM,CAAC,MAAM,SAAS,GACrB,qRAAqR,CAAC;AACvR,MAAM,CAAC,MAAM,qBAAqB,GACjC,qFAAqF,CAAC;AACvF,oIAAoI;AACpI,MAAM,CAAC,MAAM,sBAAsB,GAAG,6DAA6D,CAAC;AACpG,MAAM,CAAC,MAAM,oBAAoB,GAAG,qDAAqD,CAAC;AAE1F,sEAAsE;AACtE,qBAAqB;AACrB,sEAAsE;AACtE,MAAM,CAAC,MAAM,kBAAkB,GAAG,IAAI,MAAM,CAC3C,CAAC,cAAc,EAAE,yBAAyB,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EACpF,GAAG,CACH,CAAC;AAEF,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,MAAM,CAC9C;IACC,SAAS;IACT,qBAAqB;IACrB,mBAAmB;IACnB,iBAAiB;IACjB,kBAAkB;IAClB,yBAAyB;IACzB,sBAAsB;IACtB,oBAAoB;CACpB;KACC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC;KAC9B,IAAI,CAAC,GAAG,CAAC,EACX,GAAG,CACH,CAAC","sourcesContent":["/*--------------------------------------------------------------------------\n\nTypeBox\n\nThe MIT License (MIT)\n\nCopyright (c) 2017-2026 Haydn Paterson\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n\n---------------------------------------------------------------------------*/\n\n// deno-fmt-ignore-file\n\n// -------------------------------------------------------------------\n// Validation Rules\n// -------------------------------------------------------------------\nexport const RE_RULE_HYPHEN_PLACEMENT = /^(?!-).*(?<!-)$/;\nexport const RE_RULE_NOT_RESERVED_ACE = /^(?!..--)/;\nexport const RE_ASCII_LDH = /^[a-zA-Z0-9-]*$/;\n\n// -------------------------------------------------------------------\n// ASCII & Encoding\n// -------------------------------------------------------------------\nexport const RE_ASCII = /^\\p{ASCII}*$/u;\nexport const RE_NON_ASCII = /[^\\p{ASCII}]/u;\n\n// -------------------------------------------------------------------\n// Structural & Unicode Controls\n// -------------------------------------------------------------------\nexport const RE_HIGH_SURROGATE = /[\\u{d800}-\\u{dbff}]/u;\nexport const RE_REGIONAL_INDICATOR = /[\\u{1f1e6}-\\u{1f1ff}]/u;\nexport const RE_VARIATION_SELECTOR = /[\\u{fe00}-\\u{fe0f}]/u;\nexport const RE_ZERO_WIDTH_JOINER = /\\u{200d}/u;\n\n// -------------------------------------------------------------------\n// Numbers & Digits\n// -------------------------------------------------------------------\nexport const RE_ASCII_DIGIT = /[0-9]/;\nexport const RE_ARABIC_INDIC_DIGIT = /[\\u{0660}-\\u{0669}]/u;\nexport const RE_EXT_ARABIC_INDIC_DIGIT = /[\\u{06f0}-\\u{06f9}]/u;\n\n// -------------------------------------------------------------------\n// Separators\n// -------------------------------------------------------------------\nexport const RE_COMMON_SEPARATOR = /[\\u{002e}\\u{002c}\\u{003a}\\u{002f}]/u;\nexport const RE_EUROPEAN_SEPARATOR = /[\\u{002d}\\u{002b}]/u;\n\n// -------------------------------------------------------------------\n// General Categories\n// -------------------------------------------------------------------\nexport const RE_MARK_NONSPACING = /\\p{Mn}/u;\nexport const RE_MARK_SPACING_COMBINING = /\\p{Mc}/u;\nexport const RE_MARK_ENCLOSING = /\\p{Me}/u;\nexport const RE_COMBINING_MARK = /[\\p{Mn}\\p{Mc}\\p{Me}]/u;\nexport const RE_LETTER = /\\p{L}/u;\nexport const RE_NUMBER_DECIMAL = /\\p{Nd}/u;\n\n// -------------------------------------------------------------------\n// Scripts\n// -------------------------------------------------------------------\nexport const RE_SCRIPT_GREEK = /\\p{Script=Greek}/u;\nexport const RE_SCRIPT_HEBREW = /\\p{Script=Hebrew}/u;\nexport const RE_SCRIPT_JAPANESE = /[\\p{Script=Hiragana}\\p{Script=Katakana}\\p{Script=Han}]/u;\nexport const RE_SCRIPT_ARABIC_LETTER = /[\\p{Script=Arabic}\\p{Script=Syriac}\\p{Script=Thaana}\\p{Script=Mandaic}]/u;\n\n// -------------------------------------------------------------------\n// RFC Specifications & Context Exceptions\n// -------------------------------------------------------------------\nexport const RE_VIRAMA =\n\t/[\\u{094d}\\u{09cd}\\u{0a4d}\\u{0acd}\\u{0b4d}\\u{0bcd}\\u{0c4d}\\u{0ccd}\\u{0d3b}\\u{0d3c}\\u{0d4d}\\u{0dca}\\u{1b44}\\u{1baa}\\u{1bab}\\u{a9c0}\\u{11046}\\u{1107f}\\u{110b9}\\u{11133}\\u{11134}\\u{111c0}\\u{11235}\\u{1134d}\\u{11442}\\u{114c2}\\u{115bf}\\u{1163f}\\u{116b6}\\u{11c3f}\\u{11d44}\\u{11d45}]/u;\nexport const RE_RFC5892_DISALLOWED =\n\t/[\\u{0640}\\u{07fa}\\u{302e}\\u{302f}\\u{3031}\\u{3032}\\u{3033}\\u{3034}\\u{3035}\\u{303b}]/u;\n// biome-ignore lint/suspicious/noMisleadingCharacterClass: a set of single code points (u flag), including ZWJ and ZWNJ, by design.\nexport const RE_CONTEXTO_EXCEPTIONS = /[\\u{00b7}\\u{0375}\\u{05f3}\\u{05f4}\\u{200c}\\u{200d}\\u{30fb}]/u;\nexport const RE_PVALID_EXCEPTIONS = /[\\u{00df}\\u{03c2}\\u{06fd}\\u{06fe}\\u{0f0b}\\u{3007}]/u;\n\n// -------------------------------------------------------------------\n// Composite Patterns\n// -------------------------------------------------------------------\nexport const RE_EUROPEAN_NUMBER = new RegExp(\n\t[RE_ASCII_DIGIT, RE_EXT_ARABIC_INDIC_DIGIT].map((regexp) => regexp.source).join(\"|\"),\n\t\"u\",\n);\n\nexport const RE_PERMITTED_CATEGORY = new RegExp(\n\t[\n\t\tRE_LETTER,\n\t\tRE_EUROPEAN_SEPARATOR,\n\t\tRE_COMMON_SEPARATOR,\n\t\tRE_NUMBER_DECIMAL,\n\t\tRE_MARK_NONSPACING,\n\t\tRE_MARK_SPACING_COMBINING,\n\t\tRE_CONTEXTO_EXCEPTIONS,\n\t\tRE_PVALID_EXCEPTIONS,\n\t]\n\t\t.map((regexp) => regexp.source)\n\t\t.join(\"|\"),\n\t\"u\",\n);\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ipv4.d.ts","sourceRoot":"","sources":["../../../src/formats/typebox/ipv4.ts"],"names":[],"mappings":"AA8BA;;;GAGG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAE7C"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/*--------------------------------------------------------------------------
|
|
2
|
+
|
|
3
|
+
TypeBox
|
|
4
|
+
|
|
5
|
+
The MIT License (MIT)
|
|
6
|
+
|
|
7
|
+
Copyright (c) 2017-2026 Haydn Paterson
|
|
8
|
+
|
|
9
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
10
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
11
|
+
in the Software without restriction, including without limitation the rights
|
|
12
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
13
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
14
|
+
furnished to do so, subject to the following conditions:
|
|
15
|
+
|
|
16
|
+
The above copyright notice and this permission notice shall be included in
|
|
17
|
+
all copies or substantial portions of the Software.
|
|
18
|
+
|
|
19
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
23
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
24
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
25
|
+
THE SOFTWARE.
|
|
26
|
+
|
|
27
|
+
---------------------------------------------------------------------------*/
|
|
28
|
+
const IPv4 = /^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/;
|
|
29
|
+
/**
|
|
30
|
+
* Returns true if the value is a IPV4 address
|
|
31
|
+
* @specification http://tools.ietf.org/html/rfc2673#section-3.2
|
|
32
|
+
*/
|
|
33
|
+
export function IsIPv4(value) {
|
|
34
|
+
return IPv4.test(value);
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=ipv4.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ipv4.js","sourceRoot":"","sources":["../../../src/formats/typebox/ipv4.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;6EA0B6E;AAE7E,MAAM,IAAI,GAAG,mFAAmF,CAAC;AAEjG;;;GAGG;AACH,MAAM,UAAU,MAAM,CAAC,KAAa;IACnC,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACzB,CAAC","sourcesContent":["/*--------------------------------------------------------------------------\n\nTypeBox\n\nThe MIT License (MIT)\n\nCopyright (c) 2017-2026 Haydn Paterson\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n\n---------------------------------------------------------------------------*/\n\nconst IPv4 = /^(?:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)\\.){3}(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)$/;\n\n/**\n * Returns true if the value is a IPV4 address\n * @specification http://tools.ietf.org/html/rfc2673#section-3.2\n */\nexport function IsIPv4(value: string): boolean {\n\treturn IPv4.test(value);\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ipv6.d.ts","sourceRoot":"","sources":["../../../src/formats/typebox/ipv6.ts"],"names":[],"mappings":"AA+BA;;;GAGG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAE7C"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/*--------------------------------------------------------------------------
|
|
2
|
+
|
|
3
|
+
TypeBox
|
|
4
|
+
|
|
5
|
+
The MIT License (MIT)
|
|
6
|
+
|
|
7
|
+
Copyright (c) 2017-2026 Haydn Paterson
|
|
8
|
+
|
|
9
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
10
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
11
|
+
in the Software without restriction, including without limitation the rights
|
|
12
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
13
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
14
|
+
furnished to do so, subject to the following conditions:
|
|
15
|
+
|
|
16
|
+
The above copyright notice and this permission notice shall be included in
|
|
17
|
+
all copies or substantial portions of the Software.
|
|
18
|
+
|
|
19
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
23
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
24
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
25
|
+
THE SOFTWARE.
|
|
26
|
+
|
|
27
|
+
---------------------------------------------------------------------------*/
|
|
28
|
+
const IPv6 = /^(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:)?[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)$/i;
|
|
29
|
+
/**
|
|
30
|
+
* Returns true if the value is an IPv6 address
|
|
31
|
+
* @specification http://tools.ietf.org/html/rfc2373#section-2.2
|
|
32
|
+
*/
|
|
33
|
+
export function IsIPv6(value) {
|
|
34
|
+
return IPv6.test(value);
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=ipv6.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ipv6.js","sourceRoot":"","sources":["../../../src/formats/typebox/ipv6.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;6EA0B6E;AAE7E,MAAM,IAAI,GACT,4hBAA4hB,CAAC;AAE9hB;;;GAGG;AACH,MAAM,UAAU,MAAM,CAAC,KAAa;IACnC,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACzB,CAAC","sourcesContent":["/*--------------------------------------------------------------------------\n\nTypeBox\n\nThe MIT License (MIT)\n\nCopyright (c) 2017-2026 Haydn Paterson\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n\n---------------------------------------------------------------------------*/\n\nconst IPv6 =\n\t/^(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:)?[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)\\.){3}(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)$/i;\n\n/**\n * Returns true if the value is an IPv6 address\n * @specification http://tools.ietf.org/html/rfc2373#section-2.2\n */\nexport function IsIPv6(value: string): boolean {\n\treturn IPv6.test(value);\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iri.d.ts","sourceRoot":"","sources":["../../../src/formats/typebox/iri.ts"],"names":[],"mappings":"AAmDA;;;GAGG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAO5C"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/*--------------------------------------------------------------------------
|
|
2
|
+
|
|
3
|
+
TypeBox
|
|
4
|
+
|
|
5
|
+
The MIT License (MIT)
|
|
6
|
+
|
|
7
|
+
Copyright (c) 2017-2026 Haydn Paterson
|
|
8
|
+
|
|
9
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
10
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
11
|
+
in the Software without restriction, including without limitation the rights
|
|
12
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
13
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
14
|
+
furnished to do so, subject to the following conditions:
|
|
15
|
+
|
|
16
|
+
The above copyright notice and this permission notice shall be included in
|
|
17
|
+
all copies or substantial portions of the Software.
|
|
18
|
+
|
|
19
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
23
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
24
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
25
|
+
THE SOFTWARE.
|
|
26
|
+
|
|
27
|
+
---------------------------------------------------------------------------*/
|
|
28
|
+
// deno-lint-ignore-file no-control-regex
|
|
29
|
+
const IpvFutureMatchMaxLength = 2048;
|
|
30
|
+
const IpvFutureMatch = /\[[vV][0-9a-fA-F]+\.[^\]]+\]/; // Guarded By IpvFutureMatchMaxLength
|
|
31
|
+
const InvalidIriChars = /[\x00-\x20<>^`{|}\\]/;
|
|
32
|
+
const InvalidPercentEncoding = /%(?![0-9a-fA-F]{2})/;
|
|
33
|
+
// ------------------------------------------------------------------
|
|
34
|
+
// NarrowIpvFuture
|
|
35
|
+
//
|
|
36
|
+
// Substitutes an IPvFuture address with a standard IPv6 loopback
|
|
37
|
+
// address ([::1]). We do this because the native URL.canParse
|
|
38
|
+
// (WHATWG standard) rejects IPvFuture literals, which are
|
|
39
|
+
// otherwise valid in RFC 3987. Because regex substitution can
|
|
40
|
+
// be expensive on large strings, this operation is strictly
|
|
41
|
+
// limited to inputs under a defined length threshold.
|
|
42
|
+
//
|
|
43
|
+
// (review-optimization)
|
|
44
|
+
//
|
|
45
|
+
// ------------------------------------------------------------------
|
|
46
|
+
function NarrowIpvFuture(value) {
|
|
47
|
+
return value.length < IpvFutureMatchMaxLength ? value.replace(IpvFutureMatch, "[::1]") : value;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Returns true if the value is a valid Internationalized Resource Identifier.
|
|
51
|
+
* @specification https://datatracker.ietf.org/doc/html/rfc3987
|
|
52
|
+
*/
|
|
53
|
+
export function IsIri(value) {
|
|
54
|
+
// 1. Reject strings containing unencoded whitespace or illegal control characters.
|
|
55
|
+
if (InvalidIriChars.test(value))
|
|
56
|
+
return false;
|
|
57
|
+
// 2. Reject malformed percent-encoding triplets.
|
|
58
|
+
if (InvalidPercentEncoding.test(value))
|
|
59
|
+
return false;
|
|
60
|
+
// 3. Delegate to the native URL parser, patching the IPvFuture edge case beforehand.
|
|
61
|
+
return URL.canParse(NarrowIpvFuture(value));
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=iri.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iri.js","sourceRoot":"","sources":["../../../src/formats/typebox/iri.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;6EA0B6E;AAE7E,yCAAyC;AAEzC,MAAM,uBAAuB,GAAG,IAAI,CAAC;AACrC,MAAM,cAAc,GAAG,8BAA8B,CAAC,CAAC,qCAAqC;AAC5F,MAAM,eAAe,GAAG,sBAAsB,CAAC;AAC/C,MAAM,sBAAsB,GAAG,qBAAqB,CAAC;AAErD,qEAAqE;AACrE,kBAAkB;AAClB,EAAE;AACF,iEAAiE;AACjE,8DAA8D;AAC9D,0DAA0D;AAC1D,8DAA8D;AAC9D,4DAA4D;AAC5D,sDAAsD;AACtD,EAAE;AACF,wBAAwB;AACxB,EAAE;AACF,qEAAqE;AACrE,SAAS,eAAe,CAAC,KAAa;IACrC,OAAO,KAAK,CAAC,MAAM,GAAG,uBAAuB,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;AAChG,CAAC;AACD;;;GAGG;AACH,MAAM,UAAU,KAAK,CAAC,KAAa;IAClC,mFAAmF;IACnF,IAAI,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAC9C,iDAAiD;IACjD,IAAI,sBAAsB,CAAC,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IACrD,qFAAqF;IACrF,OAAO,GAAG,CAAC,QAAQ,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC;AAC7C,CAAC","sourcesContent":["/*--------------------------------------------------------------------------\n\nTypeBox\n\nThe MIT License (MIT)\n\nCopyright (c) 2017-2026 Haydn Paterson\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n\n---------------------------------------------------------------------------*/\n\n// deno-lint-ignore-file no-control-regex\n\nconst IpvFutureMatchMaxLength = 2048;\nconst IpvFutureMatch = /\\[[vV][0-9a-fA-F]+\\.[^\\]]+\\]/; // Guarded By IpvFutureMatchMaxLength\nconst InvalidIriChars = /[\\x00-\\x20<>^`{|}\\\\]/;\nconst InvalidPercentEncoding = /%(?![0-9a-fA-F]{2})/;\n\n// ------------------------------------------------------------------\n// NarrowIpvFuture\n//\n// Substitutes an IPvFuture address with a standard IPv6 loopback\n// address ([::1]). We do this because the native URL.canParse\n// (WHATWG standard) rejects IPvFuture literals, which are\n// otherwise valid in RFC 3987. Because regex substitution can\n// be expensive on large strings, this operation is strictly\n// limited to inputs under a defined length threshold.\n//\n// (review-optimization)\n//\n// ------------------------------------------------------------------\nfunction NarrowIpvFuture(value: string): string {\n\treturn value.length < IpvFutureMatchMaxLength ? value.replace(IpvFutureMatch, \"[::1]\") : value;\n}\n/**\n * Returns true if the value is a valid Internationalized Resource Identifier.\n * @specification https://datatracker.ietf.org/doc/html/rfc3987\n */\nexport function IsIri(value: string): boolean {\n\t// 1. Reject strings containing unencoded whitespace or illegal control characters.\n\tif (InvalidIriChars.test(value)) return false;\n\t// 2. Reject malformed percent-encoding triplets.\n\tif (InvalidPercentEncoding.test(value)) return false;\n\t// 3. Delegate to the native URL parser, patching the IPvFuture edge case beforehand.\n\treturn URL.canParse(NarrowIpvFuture(value));\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iri_reference.d.ts","sourceRoot":"","sources":["../../../src/formats/typebox/iri_reference.ts"],"names":[],"mappings":"AAmCA;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAErD"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/*--------------------------------------------------------------------------
|
|
2
|
+
|
|
3
|
+
TypeBox
|
|
4
|
+
|
|
5
|
+
The MIT License (MIT)
|
|
6
|
+
|
|
7
|
+
Copyright (c) 2017-2026 Haydn Paterson
|
|
8
|
+
|
|
9
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
10
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
11
|
+
in the Software without restriction, including without limitation the rights
|
|
12
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
13
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
14
|
+
furnished to do so, subject to the following conditions:
|
|
15
|
+
|
|
16
|
+
The above copyright notice and this permission notice shall be included in
|
|
17
|
+
all copies or substantial portions of the Software.
|
|
18
|
+
|
|
19
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
23
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
24
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
25
|
+
THE SOFTWARE.
|
|
26
|
+
|
|
27
|
+
---------------------------------------------------------------------------*/
|
|
28
|
+
// deno-lint-ignore-file no-control-regex
|
|
29
|
+
// Rejects unencoded spaces (0x20), backslashes, control characters (0x00-0x1F, 0x7F), or malformed percent-encodings
|
|
30
|
+
const InvalidIriChars = /[\x00-\x20\x7F\\]|%(?![0-9a-fA-F]{2})/;
|
|
31
|
+
// Detects malformed scheme/authority patterns lacking a colon (e.g. "httpx//example.com")
|
|
32
|
+
const MalformedScheme = /^[a-zA-Z][a-zA-Z0-9+\-.]*\/\//;
|
|
33
|
+
/**
|
|
34
|
+
* Returns true if the value is an IRI reference
|
|
35
|
+
* @specification https://tools.ietf.org/html/rfc3987
|
|
36
|
+
*/
|
|
37
|
+
export function IsIriReference(value) {
|
|
38
|
+
return !InvalidIriChars.test(value) && !MalformedScheme.test(value) && URL.canParse(value, "http://example.com");
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=iri_reference.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iri_reference.js","sourceRoot":"","sources":["../../../src/formats/typebox/iri_reference.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;6EA0B6E;AAE7E,yCAAyC;AAEzC,qHAAqH;AACrH,MAAM,eAAe,GAAG,uCAAuC,CAAC;AAChE,0FAA0F;AAC1F,MAAM,eAAe,GAAG,+BAA+B,CAAC;AAExD;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,KAAa;IAC3C,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,QAAQ,CAAC,KAAK,EAAE,oBAAoB,CAAC,CAAC;AAClH,CAAC","sourcesContent":["/*--------------------------------------------------------------------------\n\nTypeBox\n\nThe MIT License (MIT)\n\nCopyright (c) 2017-2026 Haydn Paterson\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n\n---------------------------------------------------------------------------*/\n\n// deno-lint-ignore-file no-control-regex\n\n// Rejects unencoded spaces (0x20), backslashes, control characters (0x00-0x1F, 0x7F), or malformed percent-encodings\nconst InvalidIriChars = /[\\x00-\\x20\\x7F\\\\]|%(?![0-9a-fA-F]{2})/;\n// Detects malformed scheme/authority patterns lacking a colon (e.g. \"httpx//example.com\")\nconst MalformedScheme = /^[a-zA-Z][a-zA-Z0-9+\\-.]*\\/\\//;\n\n/**\n * Returns true if the value is an IRI reference\n * @specification https://tools.ietf.org/html/rfc3987\n */\nexport function IsIriReference(value: string): boolean {\n\treturn !InvalidIriChars.test(value) && !MalformedScheme.test(value) && URL.canParse(value, \"http://example.com\");\n}\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns true if the value is a json pointer
|
|
3
|
+
* @specification https://datatracker.ietf.org/doc/html/rfc6901
|
|
4
|
+
* @source https://github.com/ajv-validator/ajv-formats
|
|
5
|
+
*/
|
|
6
|
+
export declare function IsJsonPointer(value: string): boolean;
|
|
7
|
+
//# sourceMappingURL=json_pointer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json_pointer.d.ts","sourceRoot":"","sources":["../../../src/formats/typebox/json_pointer.ts"],"names":[],"mappings":"AA8BA;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEpD"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/*--------------------------------------------------------------------------
|
|
2
|
+
|
|
3
|
+
TypeBox
|
|
4
|
+
|
|
5
|
+
The MIT License (MIT)
|
|
6
|
+
|
|
7
|
+
Copyright (c) 2017-2026 Haydn Paterson
|
|
8
|
+
|
|
9
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
10
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
11
|
+
in the Software without restriction, including without limitation the rights
|
|
12
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
13
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
14
|
+
furnished to do so, subject to the following conditions:
|
|
15
|
+
|
|
16
|
+
The above copyright notice and this permission notice shall be included in
|
|
17
|
+
all copies or substantial portions of the Software.
|
|
18
|
+
|
|
19
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
23
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
24
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
25
|
+
THE SOFTWARE.
|
|
26
|
+
|
|
27
|
+
---------------------------------------------------------------------------*/
|
|
28
|
+
const JsonPointer = /^(?:\/(?:[^~/]|~0|~1)*)*$/;
|
|
29
|
+
/**
|
|
30
|
+
* Returns true if the value is a json pointer
|
|
31
|
+
* @specification https://datatracker.ietf.org/doc/html/rfc6901
|
|
32
|
+
* @source https://github.com/ajv-validator/ajv-formats
|
|
33
|
+
*/
|
|
34
|
+
export function IsJsonPointer(value) {
|
|
35
|
+
return JsonPointer.test(value);
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=json_pointer.js.map
|