@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.
Files changed (176) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/LICENSES/typebox-LICENSE +23 -0
  3. package/README.md +295 -2
  4. package/dist/annotations.d.ts +44 -0
  5. package/dist/annotations.d.ts.map +1 -0
  6. package/dist/annotations.js +193 -0
  7. package/dist/annotations.js.map +1 -0
  8. package/dist/builders.d.ts +114 -0
  9. package/dist/builders.d.ts.map +1 -0
  10. package/dist/builders.js +98 -0
  11. package/dist/builders.js.map +1 -0
  12. package/dist/checks.d.ts +87 -0
  13. package/dist/checks.d.ts.map +1 -0
  14. package/dist/checks.js +447 -0
  15. package/dist/checks.js.map +1 -0
  16. package/dist/coerce.d.ts +53 -0
  17. package/dist/coerce.d.ts.map +1 -0
  18. package/dist/coerce.js +585 -0
  19. package/dist/coerce.js.map +1 -0
  20. package/dist/compiler.d.ts +53 -0
  21. package/dist/compiler.d.ts.map +1 -0
  22. package/dist/compiler.js +532 -0
  23. package/dist/compiler.js.map +1 -0
  24. package/dist/explain.d.ts +29 -0
  25. package/dist/explain.d.ts.map +1 -0
  26. package/dist/explain.js +381 -0
  27. package/dist/explain.js.map +1 -0
  28. package/dist/formats/index.d.ts +7 -0
  29. package/dist/formats/index.d.ts.map +1 -0
  30. package/dist/formats/index.js +51 -0
  31. package/dist/formats/index.js.map +1 -0
  32. package/dist/formats/typebox/date.d.ts +7 -0
  33. package/dist/formats/typebox/date.d.ts.map +1 -0
  34. package/dist/formats/typebox/date.js +47 -0
  35. package/dist/formats/typebox/date.js.map +1 -0
  36. package/dist/formats/typebox/date_time.d.ts +7 -0
  37. package/dist/formats/typebox/date_time.d.ts.map +1 -0
  38. package/dist/formats/typebox/date_time.js +39 -0
  39. package/dist/formats/typebox/date_time.js.map +1 -0
  40. package/dist/formats/typebox/duration.d.ts +6 -0
  41. package/dist/formats/typebox/duration.d.ts.map +1 -0
  42. package/dist/formats/typebox/duration.js +36 -0
  43. package/dist/formats/typebox/duration.js.map +1 -0
  44. package/dist/formats/typebox/email.d.ts +6 -0
  45. package/dist/formats/typebox/email.d.ts.map +1 -0
  46. package/dist/formats/typebox/email.js +36 -0
  47. package/dist/formats/typebox/email.js.map +1 -0
  48. package/dist/formats/typebox/hostname.d.ts +8 -0
  49. package/dist/formats/typebox/hostname.d.ts.map +1 -0
  50. package/dist/formats/typebox/hostname.js +38 -0
  51. package/dist/formats/typebox/hostname.js.map +1 -0
  52. package/dist/formats/typebox/idn_email.d.ts +6 -0
  53. package/dist/formats/typebox/idn_email.d.ts.map +1 -0
  54. package/dist/formats/typebox/idn_email.js +36 -0
  55. package/dist/formats/typebox/idn_email.js.map +1 -0
  56. package/dist/formats/typebox/idn_hostname.d.ts +9 -0
  57. package/dist/formats/typebox/idn_hostname.d.ts.map +1 -0
  58. package/dist/formats/typebox/idn_hostname.js +39 -0
  59. package/dist/formats/typebox/idn_hostname.js.map +1 -0
  60. package/dist/formats/typebox/idna/format/bidi.d.ts +4 -0
  61. package/dist/formats/typebox/idna/format/bidi.d.ts.map +1 -0
  62. package/dist/formats/typebox/idna/format/bidi.js +132 -0
  63. package/dist/formats/typebox/idna/format/bidi.js.map +1 -0
  64. package/dist/formats/typebox/idna/format/puny.d.ts +4 -0
  65. package/dist/formats/typebox/idna/format/puny.d.ts.map +1 -0
  66. package/dist/formats/typebox/idna/format/puny.js +172 -0
  67. package/dist/formats/typebox/idna/format/puny.js.map +1 -0
  68. package/dist/formats/typebox/idna/hostname.d.ts +2 -0
  69. package/dist/formats/typebox/idna/hostname.d.ts.map +1 -0
  70. package/dist/formats/typebox/idna/hostname.js +43 -0
  71. package/dist/formats/typebox/idna/hostname.js.map +1 -0
  72. package/dist/formats/typebox/idna/idn-hostname.d.ts +2 -0
  73. package/dist/formats/typebox/idna/idn-hostname.d.ts.map +1 -0
  74. package/dist/formats/typebox/idna/idn-hostname.js +71 -0
  75. package/dist/formats/typebox/idna/idn-hostname.js.map +1 -0
  76. package/dist/formats/typebox/idna/index.d.ts +3 -0
  77. package/dist/formats/typebox/idna/index.d.ts.map +1 -0
  78. package/dist/formats/typebox/idna/index.js +30 -0
  79. package/dist/formats/typebox/idna/index.js.map +1 -0
  80. package/dist/formats/typebox/idna/label/ascii.d.ts +2 -0
  81. package/dist/formats/typebox/idna/label/ascii.d.ts.map +1 -0
  82. package/dist/formats/typebox/idna/label/ascii.js +37 -0
  83. package/dist/formats/typebox/idna/label/ascii.js.map +1 -0
  84. package/dist/formats/typebox/idna/label/puny.d.ts +2 -0
  85. package/dist/formats/typebox/idna/label/puny.d.ts.map +1 -0
  86. package/dist/formats/typebox/idna/label/puny.js +56 -0
  87. package/dist/formats/typebox/idna/label/puny.js.map +1 -0
  88. package/dist/formats/typebox/idna/label/unicode.d.ts +2 -0
  89. package/dist/formats/typebox/idna/label/unicode.d.ts.map +1 -0
  90. package/dist/formats/typebox/idna/label/unicode.js +134 -0
  91. package/dist/formats/typebox/idna/label/unicode.js.map +1 -0
  92. package/dist/formats/typebox/idna/pattern/pattern.d.ts +31 -0
  93. package/dist/formats/typebox/idna/pattern/pattern.d.ts.map +1 -0
  94. package/dist/formats/typebox/idna/pattern/pattern.js +98 -0
  95. package/dist/formats/typebox/idna/pattern/pattern.js.map +1 -0
  96. package/dist/formats/typebox/ipv4.d.ts +6 -0
  97. package/dist/formats/typebox/ipv4.d.ts.map +1 -0
  98. package/dist/formats/typebox/ipv4.js +36 -0
  99. package/dist/formats/typebox/ipv4.js.map +1 -0
  100. package/dist/formats/typebox/ipv6.d.ts +6 -0
  101. package/dist/formats/typebox/ipv6.d.ts.map +1 -0
  102. package/dist/formats/typebox/ipv6.js +36 -0
  103. package/dist/formats/typebox/ipv6.js.map +1 -0
  104. package/dist/formats/typebox/iri.d.ts +6 -0
  105. package/dist/formats/typebox/iri.d.ts.map +1 -0
  106. package/dist/formats/typebox/iri.js +63 -0
  107. package/dist/formats/typebox/iri.js.map +1 -0
  108. package/dist/formats/typebox/iri_reference.d.ts +6 -0
  109. package/dist/formats/typebox/iri_reference.d.ts.map +1 -0
  110. package/dist/formats/typebox/iri_reference.js +40 -0
  111. package/dist/formats/typebox/iri_reference.js.map +1 -0
  112. package/dist/formats/typebox/json_pointer.d.ts +7 -0
  113. package/dist/formats/typebox/json_pointer.d.ts.map +1 -0
  114. package/dist/formats/typebox/json_pointer.js +37 -0
  115. package/dist/formats/typebox/json_pointer.js.map +1 -0
  116. package/dist/formats/typebox/json_pointer_uri_fragment.d.ts +7 -0
  117. package/dist/formats/typebox/json_pointer_uri_fragment.d.ts.map +1 -0
  118. package/dist/formats/typebox/json_pointer_uri_fragment.js +37 -0
  119. package/dist/formats/typebox/json_pointer_uri_fragment.js.map +1 -0
  120. package/dist/formats/typebox/regex.d.ts +6 -0
  121. package/dist/formats/typebox/regex.d.ts.map +1 -0
  122. package/dist/formats/typebox/regex.js +41 -0
  123. package/dist/formats/typebox/regex.js.map +1 -0
  124. package/dist/formats/typebox/relative_json_pointer.d.ts +7 -0
  125. package/dist/formats/typebox/relative_json_pointer.d.ts.map +1 -0
  126. package/dist/formats/typebox/relative_json_pointer.js +37 -0
  127. package/dist/formats/typebox/relative_json_pointer.js.map +1 -0
  128. package/dist/formats/typebox/time.d.ts +6 -0
  129. package/dist/formats/typebox/time.d.ts.map +1 -0
  130. package/dist/formats/typebox/time.js +60 -0
  131. package/dist/formats/typebox/time.js.map +1 -0
  132. package/dist/formats/typebox/uri.d.ts +6 -0
  133. package/dist/formats/typebox/uri.d.ts.map +1 -0
  134. package/dist/formats/typebox/uri.js +36 -0
  135. package/dist/formats/typebox/uri.js.map +1 -0
  136. package/dist/formats/typebox/uri_reference.d.ts +6 -0
  137. package/dist/formats/typebox/uri_reference.d.ts.map +1 -0
  138. package/dist/formats/typebox/uri_reference.js +36 -0
  139. package/dist/formats/typebox/uri_reference.js.map +1 -0
  140. package/dist/formats/typebox/uri_template.d.ts +6 -0
  141. package/dist/formats/typebox/uri_template.d.ts.map +1 -0
  142. package/dist/formats/typebox/uri_template.js +37 -0
  143. package/dist/formats/typebox/uri_template.js.map +1 -0
  144. package/dist/formats/typebox/url.d.ts +7 -0
  145. package/dist/formats/typebox/url.d.ts.map +1 -0
  146. package/dist/formats/typebox/url.js +36 -0
  147. package/dist/formats/typebox/url.js.map +1 -0
  148. package/dist/formats/typebox/uuid.d.ts +7 -0
  149. package/dist/formats/typebox/uuid.d.ts.map +1 -0
  150. package/dist/formats/typebox/uuid.js +37 -0
  151. package/dist/formats/typebox/uuid.js.map +1 -0
  152. package/dist/index.d.ts +4 -0
  153. package/dist/index.d.ts.map +1 -0
  154. package/dist/index.js +5 -0
  155. package/dist/index.js.map +1 -0
  156. package/dist/resolver.d.ts +57 -0
  157. package/dist/resolver.d.ts.map +1 -0
  158. package/dist/resolver.js +202 -0
  159. package/dist/resolver.js.map +1 -0
  160. package/dist/shared.d.ts +9 -0
  161. package/dist/shared.d.ts.map +1 -0
  162. package/dist/shared.js +33 -0
  163. package/dist/shared.js.map +1 -0
  164. package/dist/typebox-static.d.ts +48 -0
  165. package/dist/typebox-static.d.ts.map +1 -0
  166. package/dist/typebox-static.js +5 -0
  167. package/dist/typebox-static.js.map +1 -0
  168. package/dist/types.d.ts +48 -0
  169. package/dist/types.d.ts.map +1 -0
  170. package/dist/types.js +3 -0
  171. package/dist/types.js.map +1 -0
  172. package/dist/validator.d.ts +39 -0
  173. package/dist/validator.d.ts.map +1 -0
  174. package/dist/validator.js +71 -0
  175. package/dist/validator.js.map +1 -0
  176. package/package.json +59 -5
@@ -0,0 +1,172 @@
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 Pattern from "../pattern/pattern.js";
29
+ // ------------------------------------------------------------------
30
+ // PunyCode (RFC 3492)
31
+ // ------------------------------------------------------------------
32
+ const PUNYCODE_BASE = 36;
33
+ const PUNYCODE_TMIN = 1;
34
+ const PUNYCODE_TMAX = 26;
35
+ const PUNYCODE_SKEW = 38;
36
+ const PUNYCODE_DAMP = 700;
37
+ const PUNYCODE_INITIAL_BIAS = 72;
38
+ const PUNYCODE_INITIAL_N = 128;
39
+ // ------------------------------------------------------------------
40
+ // ThrowDontCare
41
+ // ------------------------------------------------------------------
42
+ function ThrowDontCare() {
43
+ throw null;
44
+ }
45
+ // ------------------------------------------------------------------
46
+ // IsAcePrefixed
47
+ // ------------------------------------------------------------------
48
+ export function IsAcePrefixed(value) {
49
+ return value.toLowerCase().startsWith("xn--");
50
+ }
51
+ // ------------------------------------------------------------------
52
+ // Adapt
53
+ // ------------------------------------------------------------------
54
+ function Adapt(delta, numPoints, firstTime) {
55
+ delta = firstTime ? Math.floor(delta / PUNYCODE_DAMP) : delta >> 1;
56
+ delta += Math.floor(delta / numPoints);
57
+ let k = 0;
58
+ while (delta > ((PUNYCODE_BASE - PUNYCODE_TMIN) * PUNYCODE_TMAX) >> 1) {
59
+ delta = Math.floor(delta / (PUNYCODE_BASE - PUNYCODE_TMIN));
60
+ k += PUNYCODE_BASE;
61
+ }
62
+ return k + Math.floor(((PUNYCODE_BASE - PUNYCODE_TMIN + 1) * delta) / (delta + PUNYCODE_SKEW));
63
+ }
64
+ // ------------------------------------------------------------------
65
+ // Decode
66
+ // ------------------------------------------------------------------
67
+ export function Decode(value) {
68
+ const output = [];
69
+ let n = PUNYCODE_INITIAL_N;
70
+ let i = 0;
71
+ let bias = PUNYCODE_INITIAL_BIAS;
72
+ const delimIdx = value.lastIndexOf("-");
73
+ if (delimIdx > 0) {
74
+ for (let j = 0; j < delimIdx; j++) {
75
+ const cp = value.charCodeAt(j);
76
+ if (cp >= 128)
77
+ ThrowDontCare(); // throw new Error('Invalid punycode: non-basic before delimiter')
78
+ output.push(cp);
79
+ }
80
+ }
81
+ let inIdx = delimIdx < 0 ? 0 : delimIdx + 1;
82
+ while (inIdx < value.length) {
83
+ const oldi = i;
84
+ let w = 1;
85
+ let k = PUNYCODE_BASE;
86
+ while (true) {
87
+ if (inIdx >= value.length)
88
+ ThrowDontCare(); // throw new Error('Invalid punycode: unexpected end of input')
89
+ const ch = value.charCodeAt(inIdx++);
90
+ let digit;
91
+ if (ch >= 0x61 && ch <= 0x7a)
92
+ digit = ch - 0x61; // a-z => 0-25
93
+ else if (ch >= 0x30 && ch <= 0x39)
94
+ digit = ch - 0x30 + 26; // 0-9 => 26-35
95
+ // else if (ch >= 0x41 && ch <= 0x5a) digit = ch - 0x41 // A-Z => 0-25 // (no-spec-coverage)
96
+ else
97
+ ThrowDontCare(); // throw new Error('Invalid punycode: bad digit character')
98
+ i += digit * w;
99
+ const t = k <= bias ? PUNYCODE_TMIN : k >= bias + PUNYCODE_TMAX ? PUNYCODE_TMAX : k - bias;
100
+ if (digit < t)
101
+ break;
102
+ w *= PUNYCODE_BASE - t;
103
+ k += PUNYCODE_BASE;
104
+ }
105
+ const outLen = output.length + 1;
106
+ bias = Adapt(i - oldi, outLen, oldi === 0);
107
+ n += Math.floor(i / outLen);
108
+ i %= outLen;
109
+ output.splice(i, 0, n);
110
+ i++;
111
+ }
112
+ return String.fromCodePoint(...output);
113
+ }
114
+ // ------------------------------------------------------------------
115
+ // DigitToChar
116
+ // ------------------------------------------------------------------
117
+ function DigitToChar(digit) {
118
+ return digit < 26 ? String.fromCharCode(digit + 0x61) : String.fromCharCode(digit - 26 + 0x30);
119
+ }
120
+ // ------------------------------------------------------------------
121
+ // Encode
122
+ //
123
+ // Encodes a Unicode string into its Punycode payload (the part that
124
+ // follows the 'xn--' ACE prefix). Used to compute the true A-label
125
+ // length of a U-label, since the 63-octet label length limit (RFC
126
+ // 5891 §4.2.4) applies to the encoded form, not the code point count.
127
+ // ------------------------------------------------------------------
128
+ const RE_REPLACE_NON_ASCII = new RegExp(Pattern.RE_NON_ASCII.source, "gu");
129
+ export function Encode(input) {
130
+ // Extract basic ASCII characters and set initial output array state
131
+ const basic = input.replace(RE_REPLACE_NON_ASCII, "");
132
+ const basicLength = basic.length;
133
+ const result = basicLength > 0 ? [basic, "-"] : [];
134
+ // Extract unicode codepoints
135
+ const codePoints = Array.from(input, (char) => char.codePointAt(0));
136
+ let n = PUNYCODE_INITIAL_N;
137
+ let delta = 0;
138
+ let bias = PUNYCODE_INITIAL_BIAS;
139
+ let handledCPCount = basicLength;
140
+ while (handledCPCount < codePoints.length) {
141
+ let m = Infinity;
142
+ for (const cp of codePoints) {
143
+ if (cp >= n && cp < m)
144
+ m = cp;
145
+ }
146
+ delta += (m - n) * (handledCPCount + 1);
147
+ n = m;
148
+ for (const cp of codePoints) {
149
+ if (cp < n)
150
+ delta++;
151
+ if (cp === n) {
152
+ let q = delta;
153
+ for (let k = PUNYCODE_BASE;; k += PUNYCODE_BASE) {
154
+ const t = k <= bias ? PUNYCODE_TMIN : k >= bias + PUNYCODE_TMAX ? PUNYCODE_TMAX : k - bias;
155
+ if (q < t)
156
+ break;
157
+ const digit = t + ((q - t) % (PUNYCODE_BASE - t));
158
+ result.push(DigitToChar(digit));
159
+ q = Math.floor((q - t) / (PUNYCODE_BASE - t));
160
+ }
161
+ result.push(DigitToChar(q));
162
+ bias = Adapt(delta, handledCPCount + 1, handledCPCount === basicLength);
163
+ delta = 0;
164
+ handledCPCount++;
165
+ }
166
+ }
167
+ delta++;
168
+ n++;
169
+ }
170
+ return result.join("");
171
+ }
172
+ //# sourceMappingURL=puny.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"puny.js","sourceRoot":"","sources":["../../../../../src/formats/typebox/idna/format/puny.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;6EA0B6E;AAE7E,OAAO,KAAK,OAAO,MAAM,uBAAuB,CAAC;AAEjD,qEAAqE;AACrE,sBAAsB;AACtB,qEAAqE;AACrE,MAAM,aAAa,GAAG,EAAE,CAAC;AACzB,MAAM,aAAa,GAAG,CAAC,CAAC;AACxB,MAAM,aAAa,GAAG,EAAE,CAAC;AACzB,MAAM,aAAa,GAAG,EAAE,CAAC;AACzB,MAAM,aAAa,GAAG,GAAG,CAAC;AAC1B,MAAM,qBAAqB,GAAG,EAAE,CAAC;AACjC,MAAM,kBAAkB,GAAG,GAAG,CAAC;AAE/B,qEAAqE;AACrE,gBAAgB;AAChB,qEAAqE;AACrE,SAAS,aAAa;IACrB,MAAM,IAAI,CAAC;AACZ,CAAC;AACD,qEAAqE;AACrE,gBAAgB;AAChB,qEAAqE;AACrE,MAAM,UAAU,aAAa,CAAC,KAAa;IAC1C,OAAO,KAAK,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;AAC/C,CAAC;AACD,qEAAqE;AACrE,QAAQ;AACR,qEAAqE;AACrE,SAAS,KAAK,CAAC,KAAa,EAAE,SAAiB,EAAE,SAAkB;IAClE,KAAK,GAAG,SAA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BAChC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,aAAa,GAAG,CAAC,CAAC,CAAC,CAAC;gBAC/C,CAAC;gBACD,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;gBAC5B,IAAI,GAAG,KAAK,CAAC,KAAK,EAAE,cAAc,GAAG,CAAC,EAAE,cAAc,KAAK,WAAW,CAAC,CAAC;gBACxE,KAAK,GAAG,CAAC,CAAC;gBACV,cAAc,EAAE,CAAC;YAClB,CAAC;QACF,CAAC;QACD,KAAK,EAAE,CAAC;QACR,CAAC,EAAE,CAAC;IACL,CAAC;IACD,OAAO,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACxB,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\nimport * as Pattern from \"../pattern/pattern.ts\";\n\n// ------------------------------------------------------------------\n// PunyCode (RFC 3492)\n// ------------------------------------------------------------------\nconst PUNYCODE_BASE = 36;\nconst PUNYCODE_TMIN = 1;\nconst PUNYCODE_TMAX = 26;\nconst PUNYCODE_SKEW = 38;\nconst PUNYCODE_DAMP = 700;\nconst PUNYCODE_INITIAL_BIAS = 72;\nconst PUNYCODE_INITIAL_N = 128;\n\n// ------------------------------------------------------------------\n// ThrowDontCare\n// ------------------------------------------------------------------\nfunction ThrowDontCare(): never {\n\tthrow null;\n}\n// ------------------------------------------------------------------\n// IsAcePrefixed\n// ------------------------------------------------------------------\nexport function IsAcePrefixed(value: string): boolean {\n\treturn value.toLowerCase().startsWith(\"xn--\");\n}\n// ------------------------------------------------------------------\n// Adapt\n// ------------------------------------------------------------------\nfunction Adapt(delta: number, numPoints: number, firstTime: boolean): number {\n\tdelta = firstTime ? Math.floor(delta / PUNYCODE_DAMP) : delta >> 1;\n\tdelta += Math.floor(delta / numPoints);\n\tlet k = 0;\n\twhile (delta > ((PUNYCODE_BASE - PUNYCODE_TMIN) * PUNYCODE_TMAX) >> 1) {\n\t\tdelta = Math.floor(delta / (PUNYCODE_BASE - PUNYCODE_TMIN));\n\t\tk += PUNYCODE_BASE;\n\t}\n\treturn k + Math.floor(((PUNYCODE_BASE - PUNYCODE_TMIN + 1) * delta) / (delta + PUNYCODE_SKEW));\n}\n// ------------------------------------------------------------------\n// Decode\n// ------------------------------------------------------------------\nexport function Decode(value: string): string {\n\tconst output: number[] = [];\n\tlet n = PUNYCODE_INITIAL_N;\n\tlet i = 0;\n\tlet bias = PUNYCODE_INITIAL_BIAS;\n\tconst delimIdx = value.lastIndexOf(\"-\");\n\tif (delimIdx > 0) {\n\t\tfor (let j = 0; j < delimIdx; j++) {\n\t\t\tconst cp = value.charCodeAt(j);\n\t\t\tif (cp >= 128) ThrowDontCare(); // throw new Error('Invalid punycode: non-basic before delimiter')\n\t\t\toutput.push(cp);\n\t\t}\n\t}\n\tlet inIdx = delimIdx < 0 ? 0 : delimIdx + 1;\n\twhile (inIdx < value.length) {\n\t\tconst oldi = i;\n\t\tlet w = 1;\n\t\tlet k = PUNYCODE_BASE;\n\t\twhile (true) {\n\t\t\tif (inIdx >= value.length) ThrowDontCare(); // throw new Error('Invalid punycode: unexpected end of input')\n\t\t\tconst ch = value.charCodeAt(inIdx++);\n\t\t\tlet digit: number;\n\t\t\tif (ch >= 0x61 && ch <= 0x7a)\n\t\t\t\tdigit = ch - 0x61; // a-z => 0-25\n\t\t\telse if (ch >= 0x30 && ch <= 0x39)\n\t\t\t\tdigit = ch - 0x30 + 26; // 0-9 => 26-35\n\t\t\t// else if (ch >= 0x41 && ch <= 0x5a) digit = ch - 0x41 // A-Z => 0-25 // (no-spec-coverage)\n\t\t\telse ThrowDontCare(); // throw new Error('Invalid punycode: bad digit character')\n\t\t\ti += digit * w;\n\t\t\tconst t = k <= bias ? PUNYCODE_TMIN : k >= bias + PUNYCODE_TMAX ? PUNYCODE_TMAX : k - bias;\n\t\t\tif (digit < t) break;\n\t\t\tw *= PUNYCODE_BASE - t;\n\t\t\tk += PUNYCODE_BASE;\n\t\t}\n\t\tconst outLen = output.length + 1;\n\t\tbias = Adapt(i - oldi, outLen, oldi === 0);\n\t\tn += Math.floor(i / outLen);\n\t\ti %= outLen;\n\t\toutput.splice(i, 0, n);\n\t\ti++;\n\t}\n\treturn String.fromCodePoint(...output);\n}\n// ------------------------------------------------------------------\n// DigitToChar\n// ------------------------------------------------------------------\nfunction DigitToChar(digit: number): string {\n\treturn digit < 26 ? String.fromCharCode(digit + 0x61) : String.fromCharCode(digit - 26 + 0x30);\n}\n// ------------------------------------------------------------------\n// Encode\n//\n// Encodes a Unicode string into its Punycode payload (the part that\n// follows the 'xn--' ACE prefix). Used to compute the true A-label\n// length of a U-label, since the 63-octet label length limit (RFC\n// 5891 §4.2.4) applies to the encoded form, not the code point count.\n// ------------------------------------------------------------------\nconst RE_REPLACE_NON_ASCII = new RegExp(Pattern.RE_NON_ASCII.source, \"gu\");\nexport function Encode(input: string): string {\n\t// Extract basic ASCII characters and set initial output array state\n\tconst basic = input.replace(RE_REPLACE_NON_ASCII, \"\");\n\tconst basicLength = basic.length;\n\tconst result = basicLength > 0 ? [basic, \"-\"] : [];\n\t// Extract unicode codepoints\n\tconst codePoints = Array.from(input, (char) => char.codePointAt(0)!);\n\tlet n = PUNYCODE_INITIAL_N;\n\tlet delta = 0;\n\tlet bias = PUNYCODE_INITIAL_BIAS;\n\tlet handledCPCount = basicLength;\n\twhile (handledCPCount < codePoints.length) {\n\t\tlet m = Infinity;\n\t\tfor (const cp of codePoints) {\n\t\t\tif (cp >= n && cp < m) m = cp;\n\t\t}\n\t\tdelta += (m - n) * (handledCPCount + 1);\n\t\tn = m;\n\t\tfor (const cp of codePoints) {\n\t\t\tif (cp < n) delta++;\n\t\t\tif (cp === n) {\n\t\t\t\tlet q = delta;\n\t\t\t\tfor (let k = PUNYCODE_BASE; ; k += PUNYCODE_BASE) {\n\t\t\t\t\tconst t = k <= bias ? PUNYCODE_TMIN : k >= bias + PUNYCODE_TMAX ? PUNYCODE_TMAX : k - bias;\n\t\t\t\t\tif (q < t) break;\n\t\t\t\t\tconst digit = t + ((q - t) % (PUNYCODE_BASE - t));\n\t\t\t\t\tresult.push(DigitToChar(digit));\n\t\t\t\t\tq = Math.floor((q - t) / (PUNYCODE_BASE - t));\n\t\t\t\t}\n\t\t\t\tresult.push(DigitToChar(q));\n\t\t\t\tbias = Adapt(delta, handledCPCount + 1, handledCPCount === basicLength);\n\t\t\t\tdelta = 0;\n\t\t\t\thandledCPCount++;\n\t\t\t}\n\t\t}\n\t\tdelta++;\n\t\tn++;\n\t}\n\treturn result.join(\"\");\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export declare function IsHostname(value: string): boolean;
2
+ //# sourceMappingURL=hostname.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hostname.d.ts","sourceRoot":"","sources":["../../../../src/formats/typebox/idna/hostname.ts"],"names":[],"mappings":"AAqCA,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAIjD"}
@@ -0,0 +1,43 @@
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 LabelAscii from "./label/ascii.js";
29
+ import * as LabelPuny from "./label/puny.js";
30
+ function IsValidLabelLength(value) {
31
+ return value.length > 0 && value.length <= 63;
32
+ }
33
+ function IsLabel(value) {
34
+ return IsValidLabelLength(value) && (LabelPuny.IsPunyLabel(value) || LabelAscii.IsAsciiLabel(value));
35
+ }
36
+ export function IsHostname(value) {
37
+ if (value.length === 0 || value.length > 253)
38
+ return false;
39
+ if (value.charCodeAt(value.length - 1) === 46)
40
+ return false;
41
+ return value.split(".").every((label) => IsLabel(label));
42
+ }
43
+ //# sourceMappingURL=hostname.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hostname.js","sourceRoot":"","sources":["../../../../src/formats/typebox/idna/hostname.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;6EA0B6E;AAE7E,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAC;AAC/C,OAAO,KAAK,SAAS,MAAM,iBAAiB,CAAC;AAE7C,SAAS,kBAAkB,CAAC,KAAa;IACxC,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,KAAK,CAAC,MAAM,IAAI,EAAE,CAAC;AAC/C,CAAC;AACD,SAAS,OAAO,CAAC,KAAa;IAC7B,OAAO,kBAAkB,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,UAAU,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC;AACtG,CAAC;AACD,MAAM,UAAU,UAAU,CAAC,KAAa;IACvC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,GAAG,GAAG;QAAE,OAAO,KAAK,CAAC;IAC3D,IAAI,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,EAAE;QAAE,OAAO,KAAK,CAAC;IAC5D,OAAO,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;AAC1D,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\nimport * as LabelAscii from \"./label/ascii.ts\";\nimport * as LabelPuny from \"./label/puny.ts\";\n\nfunction IsValidLabelLength(value: string): boolean {\n\treturn value.length > 0 && value.length <= 63;\n}\nfunction IsLabel(value: string): boolean {\n\treturn IsValidLabelLength(value) && (LabelPuny.IsPunyLabel(value) || LabelAscii.IsAsciiLabel(value));\n}\nexport function IsHostname(value: string): boolean {\n\tif (value.length === 0 || value.length > 253) return false;\n\tif (value.charCodeAt(value.length - 1) === 46) return false;\n\treturn value.split(\".\").every((label) => IsLabel(label));\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export declare function IsIdnHostname(value: string): boolean;
2
+ //# sourceMappingURL=idn-hostname.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"idn-hostname.d.ts","sourceRoot":"","sources":["../../../../src/formats/typebox/idna/idn-hostname.ts"],"names":[],"mappings":"AAgEA,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAOpD"}
@@ -0,0 +1,71 @@
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 LabelPuny from "./label/puny.js";
30
+ import * as LabelUnicode from "./label/unicode.js";
31
+ // ------------------------------------------------------------------
32
+ // IsLabel
33
+ // ------------------------------------------------------------------
34
+ function IsValidLabelLength(value) {
35
+ return value.length > 0 && value.length <= 63;
36
+ }
37
+ function IsLabel(value) {
38
+ return IsValidLabelLength(value) && (LabelPuny.IsPunyLabel(value) || LabelUnicode.IsUnicodeLabel(value));
39
+ }
40
+ // ------------------------------------------------------------------
41
+ // NormalizeHostname
42
+ //
43
+ // Normalizes a hostname for label validation. Maps fullwidth
44
+ // codepoints to their ASCII equivalent (e.g. 'a' U+FF41 maps to
45
+ // 'a'), then normalizes for NFC such that equivalent codepoint
46
+ // sequences can be uniformly compared. It also removes codepoints
47
+ // that IDNA mapping ignores, and converts full stop variants to
48
+ // ASCII '.' so the hostname can be split into labels.
49
+ // ------------------------------------------------------------------
50
+ function NormalizeHostname(value) {
51
+ return (value
52
+ .replace(/[\uff01-\uff5e]/g, (char) => String.fromCharCode(char.charCodeAt(0) - 0xfee0)) // RE_FULLWIDTH_MAPPING
53
+ .normalize("NFC")
54
+ // biome-ignore lint/suspicious/noMisleadingCharacterClass: a set of single code points to remove (u flag), by design.
55
+ .replace(/[\u00ad\u034f\u180b-\u180d\u200b\ufe00-\ufe0f\u{e0100}-\u{e01ef}]/gu, "") // RE_IGNORED_MAPPING
56
+ .replace(/[\u002E\u3002\uFF0E\uFF61]/g, ".")); // RE_FULL_STOP_MAPPING
57
+ }
58
+ // ------------------------------------------------------------------
59
+ // IsIdnHostname
60
+ // ------------------------------------------------------------------
61
+ export function IsIdnHostname(value) {
62
+ if (value.length === 0 || value.includes(" "))
63
+ return false;
64
+ const normalized = NormalizeHostname(value);
65
+ if (normalized.length > 253)
66
+ return false;
67
+ const labels = normalized.split(".");
68
+ const hasBidiChars = labels.some((label) => FormatBidi.HasBidiChars(label));
69
+ return labels.every((label) => IsLabel(label) && (!hasBidiChars || FormatBidi.SatisfiesBidiRule(label)));
70
+ }
71
+ //# sourceMappingURL=idn-hostname.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"idn-hostname.js","sourceRoot":"","sources":["../../../../src/formats/typebox/idna/idn-hostname.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;6EA0B6E;AAE7E,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAC;AAC/C,OAAO,KAAK,SAAS,MAAM,iBAAiB,CAAC;AAC7C,OAAO,KAAK,YAAY,MAAM,oBAAoB,CAAC;AAEnD,qEAAqE;AACrE,UAAU;AACV,qEAAqE;AACrE,SAAS,kBAAkB,CAAC,KAAa;IACxC,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,KAAK,CAAC,MAAM,IAAI,EAAE,CAAC;AAC/C,CAAC;AACD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AC;IAC5E,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,YAAY,IAAI,UAAU,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAC1G,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\nimport * as FormatBidi from \"./format/bidi.ts\";\nimport * as LabelPuny from \"./label/puny.ts\";\nimport * as LabelUnicode from \"./label/unicode.ts\";\n\n// ------------------------------------------------------------------\n// IsLabel\n// ------------------------------------------------------------------\nfunction IsValidLabelLength(value: string): boolean {\n\treturn value.length > 0 && value.length <= 63;\n}\nfunction IsLabel(value: string): boolean {\n\treturn IsValidLabelLength(value) && (LabelPuny.IsPunyLabel(value) || LabelUnicode.IsUnicodeLabel(value));\n}\n// ------------------------------------------------------------------\n// NormalizeHostname\n//\n// Normalizes a hostname for label validation. Maps fullwidth\n// codepoints to their ASCII equivalent (e.g. 'a' U+FF41 maps to\n// 'a'), then normalizes for NFC such that equivalent codepoint\n// sequences can be uniformly compared. It also removes codepoints\n// that IDNA mapping ignores, and converts full stop variants to\n// ASCII '.' so the hostname can be split into labels.\n// ------------------------------------------------------------------\nfunction NormalizeHostname(value: string): string {\n\treturn (\n\t\tvalue\n\t\t\t.replace(/[\\uff01-\\uff5e]/g, (char) => String.fromCharCode(char.charCodeAt(0) - 0xfee0)) // RE_FULLWIDTH_MAPPING\n\t\t\t.normalize(\"NFC\")\n\t\t\t// biome-ignore lint/suspicious/noMisleadingCharacterClass: a set of single code points to remove (u flag), by design.\n\t\t\t.replace(/[\\u00ad\\u034f\\u180b-\\u180d\\u200b\\ufe00-\\ufe0f\\u{e0100}-\\u{e01ef}]/gu, \"\") // RE_IGNORED_MAPPING\n\t\t\t.replace(/[\\u002E\\u3002\\uFF0E\\uFF61]/g, \".\")\n\t); // RE_FULL_STOP_MAPPING\n}\n// ------------------------------------------------------------------\n// IsIdnHostname\n// ------------------------------------------------------------------\nexport function IsIdnHostname(value: string): boolean {\n\tif (value.length === 0 || value.includes(\" \")) return false;\n\tconst normalized = NormalizeHostname(value);\n\tif (normalized.length > 253) return false;\n\tconst labels = normalized.split(\".\");\n\tconst hasBidiChars = labels.some((label) => FormatBidi.HasBidiChars(label));\n\treturn labels.every((label) => IsLabel(label) && (!hasBidiChars || FormatBidi.SatisfiesBidiRule(label)));\n}\n"]}
@@ -0,0 +1,3 @@
1
+ export * from "./hostname.ts";
2
+ export * from "./idn-hostname.ts";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/formats/typebox/idna/index.ts"],"names":[],"mappings":"AA4BA,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC"}
@@ -0,0 +1,30 @@
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
+ export * from "./hostname.js";
29
+ export * from "./idn-hostname.js";
30
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/formats/typebox/idna/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;6EA0B6E;AAE7E,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,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\nexport * from \"./hostname.ts\";\nexport * from \"./idn-hostname.ts\";\n"]}
@@ -0,0 +1,2 @@
1
+ export declare function IsAsciiLabel(value: string): boolean;
2
+ //# sourceMappingURL=ascii.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ascii.d.ts","sourceRoot":"","sources":["../../../../../src/formats/typebox/idna/label/ascii.ts"],"names":[],"mappings":"AAiCA,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAMnD"}
@@ -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
+ import * as Pattern from "../pattern/pattern.js";
29
+ // -------------------------------------------------------------------
30
+ // Validates an ASCII LDH label per RFC 5891 §4.2.3.1
31
+ // -------------------------------------------------------------------
32
+ export function IsAsciiLabel(value) {
33
+ return (Pattern.RE_RULE_HYPHEN_PLACEMENT.test(value) &&
34
+ Pattern.RE_RULE_NOT_RESERVED_ACE.test(value) &&
35
+ Pattern.RE_ASCII_LDH.test(value));
36
+ }
37
+ //# sourceMappingURL=ascii.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ascii.js","sourceRoot":"","sources":["../../../../../src/formats/typebox/idna/label/ascii.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;6EA0B6E;AAE7E,OAAO,KAAK,OAAO,MAAM,uBAAuB,CAAC;AAEjD,sEAAsE;AACtE,qDAAqD;AACrD,sEAAsE;AACtE,MAAM,UAAU,YAAY,CAAC,KAAa;IACzC,OAAO,CACN,OAAO,CAAC,wBAAwB,CAAC,IAAI,CAAC,KAAK,CAAC;QAC5C,OAAO,CAAC,wBAAwB,CAAC,IAAI,CAAC,KAAK,CAAC;QAC5C,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAChC,CAAC;AACH,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\nimport * as Pattern from \"../pattern/pattern.ts\";\n\n// -------------------------------------------------------------------\n// Validates an ASCII LDH label per RFC 5891 §4.2.3.1\n// -------------------------------------------------------------------\nexport function IsAsciiLabel(value: string): boolean {\n\treturn (\n\t\tPattern.RE_RULE_HYPHEN_PLACEMENT.test(value) &&\n\t\tPattern.RE_RULE_NOT_RESERVED_ACE.test(value) &&\n\t\tPattern.RE_ASCII_LDH.test(value)\n\t);\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export declare function IsPunyLabel(value: string): boolean;
2
+ //# sourceMappingURL=puny.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"puny.d.ts","sourceRoot":"","sources":["../../../../../src/formats/typebox/idna/label/puny.ts"],"names":[],"mappings":"AAmCA,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAiBlD"}
@@ -0,0 +1,56 @@
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 FormatPuny from "../format/puny.js";
29
+ import * as Pattern from "../pattern/pattern.js";
30
+ import * as LabelUnicode from "./unicode.js";
31
+ // ------------------------------------------------------------------
32
+ // IsPunyLabel
33
+ // ------------------------------------------------------------------
34
+ export function IsPunyLabel(value) {
35
+ if (!FormatPuny.IsAcePrefixed(value))
36
+ return false;
37
+ try {
38
+ const body = value.slice(4).toLowerCase();
39
+ // A payload consisting of only a hyphen, or starting with the delimiter
40
+ // (like "-9uc"), has 0 basic ASCII characters preceding it and is malformed.
41
+ if (body.lastIndexOf("-") === 0)
42
+ return false;
43
+ const decoded = FormatPuny.Decode(body);
44
+ // RFC 5890 §2.3.2.1 - a U-label must contain at least one non-ASCII
45
+ // character. Code-unit level check: any non-ASCII codepoint has at least
46
+ // one UTF-16 unit >= 0x80 (surrogate halves included), so no need to
47
+ // decode codepoints or allocate a character array to answer this.
48
+ if (!Pattern.RE_NON_ASCII.test(decoded))
49
+ return false;
50
+ return LabelUnicode.IsUnicodeLabel(decoded);
51
+ }
52
+ catch {
53
+ return false;
54
+ }
55
+ }
56
+ //# sourceMappingURL=puny.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"puny.js","sourceRoot":"","sources":["../../../../../src/formats/typebox/idna/label/puny.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;6EA0B6E;AAE7E,OAAO,KAAK,UAAU,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,OAAO,MAAM,uBAAuB,CAAC;AACjD,OAAO,KAAK,YAAY,MAAM,cAAc,CAAC;AAE7C,qEAAqE;AACrE,cAAc;AACd,qEAAqE;AACrE,MAAM,UAAU,WAAW,CAAC,KAAa;IACxC,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IACnD,IAAI,CAAC;QACJ,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;QAC1C,wEAAwE;QACxE,6EAA6E;QAC7E,IAAI,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,KAAK,CAAC;YAAE,OAAO,KAAK,CAAC;QAC9C,MAAM,OAAO,GAAG,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACxC,oEAAoE;QACpE,yEAAyE;QACzE,qEAAqE;QACrE,kEAAkE;QAClE,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC;YAAE,OAAO,KAAK,CAAC;QACtD,OAAO,YAAY,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;IAC7C,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,KAAK,CAAC;IACd,CAAC;AACF,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\nimport * as FormatPuny from \"../format/puny.ts\";\nimport * as Pattern from \"../pattern/pattern.ts\";\nimport * as LabelUnicode from \"./unicode.ts\";\n\n// ------------------------------------------------------------------\n// IsPunyLabel\n// ------------------------------------------------------------------\nexport function IsPunyLabel(value: string): boolean {\n\tif (!FormatPuny.IsAcePrefixed(value)) return false;\n\ttry {\n\t\tconst body = value.slice(4).toLowerCase();\n\t\t// A payload consisting of only a hyphen, or starting with the delimiter\n\t\t// (like \"-9uc\"), has 0 basic ASCII characters preceding it and is malformed.\n\t\tif (body.lastIndexOf(\"-\") === 0) return false;\n\t\tconst decoded = FormatPuny.Decode(body);\n\t\t// RFC 5890 §2.3.2.1 - a U-label must contain at least one non-ASCII\n\t\t// character. Code-unit level check: any non-ASCII codepoint has at least\n\t\t// one UTF-16 unit >= 0x80 (surrogate halves included), so no need to\n\t\t// decode codepoints or allocate a character array to answer this.\n\t\tif (!Pattern.RE_NON_ASCII.test(decoded)) return false;\n\t\treturn LabelUnicode.IsUnicodeLabel(decoded);\n\t} catch {\n\t\treturn false;\n\t}\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export declare function IsUnicodeLabel(value: string): boolean;
2
+ //# sourceMappingURL=unicode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unicode.d.ts","sourceRoot":"","sources":["../../../../../src/formats/typebox/idna/label/unicode.ts"],"names":[],"mappings":"AA8DA,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CA2DrD"}