@openclaw/whatsapp 2026.8.1-beta.3 → 2026.8.2

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 (263) hide show
  1. package/dist/{accounts-BX2fZUyR.js → accounts-CeKQbu_s.js} +9 -26
  2. package/dist/{action-runtime-pM-ExU0l.js → action-runtime-Bw0loEdy.js} +2 -2
  3. package/dist/action-runtime-api.js +1 -1
  4. package/dist/action-runtime.runtime.js +1 -1
  5. package/dist/{call-tool-api.js → agent-tools-api.js} +13 -6
  6. package/dist/{agent-tools-login-BjRpD-JQ.js → agent-tools-login-B-2qZPzc.js} +12 -3
  7. package/dist/api.js +10 -10
  8. package/dist/{approval-handler.runtime-CkMMvUjk.js → approval-handler.runtime-DeyPb57-.js} +3 -3
  9. package/dist/{approval-reactions-Jyr1JaAK.js → approval-reactions-DGDA6hQ7.js} +7 -5
  10. package/dist/{auth-store-CtpBqH5S.js → auth-store-DTj1H9pv.js} +5 -3
  11. package/dist/{channel-DRMYRfZ8.js → channel-DxMmDjqK.js} +26 -24
  12. package/dist/channel-config-api.js +1 -1
  13. package/dist/channel-plugin-api.js +1 -1
  14. package/dist/{channel-react-action-CstrR0CT.js → channel-react-action-BUp7Wbfr.js} +3 -3
  15. package/dist/{channel.runtime-X3JC2gaq.js → channel.runtime-BwSnyXRX.js} +4 -4
  16. package/dist/{channel.setup-DhBBhbQv.js → channel.setup-aOFLSQyw.js} +1 -1
  17. package/dist/{config-schema-BQP5YCeK.js → config-schema-BYA6e_Ii.js} +6 -4
  18. package/dist/{connection-controller-CIYuBJrs.js → connection-controller-BvkxsbWi.js} +2 -2
  19. package/dist/{constants-HU41RHGI.js → constants-C7m81BNe.js} +1 -1
  20. package/dist/{directory-config-P7_3U73Z.js → directory-config-LgxYJLWY.js} +3 -3
  21. package/dist/directory-contract-api.js +1 -1
  22. package/dist/{group-session-key-DmFc_Cqi.js → group-session-key-KUguLmSZ.js} +4 -4
  23. package/dist/index.js +4 -4
  24. package/dist/light-runtime-api.js +2 -2
  25. package/dist/{login-BkpKpndm.js → login-Bk_jiXKD.js} +6 -5
  26. package/dist/{login-qr-1dpv6jjT.js → login-qr-B3m61NqA.js} +43 -20
  27. package/dist/login-qr-runtime.js +1 -1
  28. package/dist/{monitor-IzwQKizW.js → monitor-CTsyo-HE.js} +185 -162
  29. package/dist/{question-reactions-D3eAeB0i.js → question-reactions-B9D6MHXZ.js} +1 -1
  30. package/dist/runtime-api.js +9 -9
  31. package/dist/{send-CwvTU4RI.js → send-DiPjiygK.js} +54 -29
  32. package/dist/{send-api-obOSm2cC.js → send-api-kFcuhSiY.js} +43 -41
  33. package/dist/{setup-finalize-n4K2I2gJ.js → setup-finalize-CqH5wTK5.js} +7 -6
  34. package/dist/setup-plugin-api.js +1 -1
  35. package/dist/{setup-surface-Cwn3zyxK.js → setup-surface-Dm3T6S8t.js} +3 -3
  36. package/dist/{shared-wg42NKFB.js → shared-DDjonGys.js} +7 -6
  37. package/dist/{socket-close-2T0_jZTN.js → socket-close-CpkkJZCU.js} +9 -6
  38. package/dist/{targets-runtime-TMk0lGuy.js → targets-runtime-RBjx3pg_.js} +1 -2
  39. package/dist/{text-runtime-CaKLhowd.js → text-runtime-DyfmcATV.js} +1 -1
  40. package/node_modules/baileys/lib/Defaults/index.js +1 -1
  41. package/node_modules/baileys/lib/Socket/business.d.ts.map +1 -1
  42. package/node_modules/baileys/lib/Socket/chats.d.ts +1 -0
  43. package/node_modules/baileys/lib/Socket/chats.d.ts.map +1 -1
  44. package/node_modules/baileys/lib/Socket/chats.js +10 -5
  45. package/node_modules/baileys/lib/Socket/chats.js.map +1 -1
  46. package/node_modules/baileys/lib/Socket/communities.d.ts.map +1 -1
  47. package/node_modules/baileys/lib/Socket/groups.d.ts.map +1 -1
  48. package/node_modules/baileys/lib/Socket/index.d.ts.map +1 -1
  49. package/node_modules/baileys/lib/Socket/messages-recv.d.ts.map +1 -1
  50. package/node_modules/baileys/lib/Socket/messages-send.d.ts.map +1 -1
  51. package/node_modules/baileys/lib/Socket/newsletter.d.ts.map +1 -1
  52. package/node_modules/baileys/lib/Socket/socket.d.ts.map +1 -1
  53. package/node_modules/baileys/lib/Socket/socket.js +3 -0
  54. package/node_modules/baileys/lib/Socket/socket.js.map +1 -1
  55. package/node_modules/baileys/lib/Types/index.d.ts +1 -0
  56. package/node_modules/baileys/lib/Types/index.d.ts.map +1 -1
  57. package/node_modules/baileys/lib/Types/index.js.map +1 -1
  58. package/node_modules/baileys/lib/Utils/browser-utils.d.ts.map +1 -1
  59. package/node_modules/baileys/lib/Utils/browser-utils.js +1 -0
  60. package/node_modules/baileys/lib/Utils/browser-utils.js.map +1 -1
  61. package/node_modules/baileys/lib/Utils/generics.d.ts +1 -0
  62. package/node_modules/baileys/lib/Utils/generics.d.ts.map +1 -1
  63. package/node_modules/baileys/lib/Utils/generics.js +1 -1
  64. package/node_modules/baileys/lib/Utils/generics.js.map +1 -1
  65. package/node_modules/baileys/lib/Utils/tc-token-utils.d.ts.map +1 -1
  66. package/node_modules/baileys/lib/Utils/tc-token-utils.js +3 -2
  67. package/node_modules/baileys/lib/Utils/tc-token-utils.js.map +1 -1
  68. package/node_modules/baileys/lib/Utils/validate-connection.d.ts.map +1 -1
  69. package/node_modules/baileys/lib/Utils/validate-connection.js +9 -2
  70. package/node_modules/baileys/lib/Utils/validate-connection.js.map +1 -1
  71. package/node_modules/baileys/node_modules/content-type/README.md +2 -0
  72. package/node_modules/baileys/node_modules/content-type/dist/index.d.ts +20 -0
  73. package/node_modules/baileys/node_modules/content-type/dist/index.js +20 -14
  74. package/node_modules/baileys/node_modules/content-type/dist/index.js.map +1 -1
  75. package/node_modules/baileys/node_modules/content-type/package.json +1 -1
  76. package/node_modules/baileys/node_modules/file-type/package.json +1 -1
  77. package/node_modules/baileys/node_modules/file-type/readme.md +3 -0
  78. package/node_modules/baileys/node_modules/file-type/source/detectors/zip.js +6 -1
  79. package/node_modules/baileys/node_modules/file-type/source/index.d.ts +3 -0
  80. package/node_modules/baileys/node_modules/file-type/source/index.js +25 -13
  81. package/node_modules/baileys/node_modules/music-metadata/LICENSE.txt +9 -9
  82. package/node_modules/baileys/node_modules/music-metadata/README.md +878 -878
  83. package/node_modules/baileys/node_modules/music-metadata/lib/ParseError.d.ts +1 -1
  84. package/node_modules/baileys/node_modules/music-metadata/lib/ParseError.js +1 -1
  85. package/node_modules/baileys/node_modules/music-metadata/lib/asf/AsfObject.d.ts +1 -4
  86. package/node_modules/baileys/node_modules/music-metadata/lib/asf/AsfObject.js +66 -30
  87. package/node_modules/baileys/node_modules/music-metadata/lib/asf/AsfParser.d.ts +5 -1
  88. package/node_modules/baileys/node_modules/music-metadata/lib/asf/AsfParser.js +94 -25
  89. package/node_modules/baileys/node_modules/music-metadata/lib/dsf/DsfChunk.js +2 -2
  90. package/node_modules/baileys/node_modules/music-metadata/lib/dsf/DsfParser.js +38 -13
  91. package/node_modules/baileys/node_modules/music-metadata/lib/mp4/AtomToken.js +2 -1
  92. package/node_modules/baileys/node_modules/music-metadata/lib/mp4/MP4Parser.js +34 -7
  93. package/node_modules/baileys/node_modules/music-metadata/lib/ogg/speex/SpeexStream.d.ts +7 -0
  94. package/node_modules/baileys/node_modules/music-metadata/lib/ogg/speex/SpeexStream.js +13 -0
  95. package/node_modules/baileys/node_modules/music-metadata/lib/riff/RiffChunk.js +1 -1
  96. package/node_modules/baileys/node_modules/music-metadata/package.json +156 -156
  97. package/node_modules/baileys/node_modules/process-warning/.github/dependabot.yml +42 -2
  98. package/node_modules/baileys/node_modules/process-warning/.github/workflows/ci.yml +12 -1
  99. package/node_modules/baileys/node_modules/process-warning/.github/workflows/lock-threads.yml +19 -0
  100. package/node_modules/baileys/node_modules/process-warning/LICENSE +1 -1
  101. package/node_modules/baileys/node_modules/process-warning/README.md +41 -2
  102. package/node_modules/baileys/node_modules/process-warning/index.js +85 -17
  103. package/node_modules/baileys/node_modules/process-warning/package.json +6 -7
  104. package/node_modules/baileys/node_modules/process-warning/test/emit-once-only.test.js +3 -3
  105. package/node_modules/baileys/node_modules/process-warning/test/emit-reset.test.js +4 -4
  106. package/node_modules/baileys/node_modules/process-warning/test/emit-unlimited.test.js +2 -2
  107. package/node_modules/baileys/node_modules/process-warning/test/spy-warning.test.js +143 -0
  108. package/node_modules/baileys/node_modules/process-warning/types/index.d.ts +15 -1
  109. package/node_modules/baileys/node_modules/process-warning/types/index.tst.ts +48 -0
  110. package/node_modules/baileys/node_modules/protobufjs/README.md +61 -84
  111. package/node_modules/baileys/node_modules/protobufjs/dist/light/protobuf.js +66 -45
  112. package/node_modules/baileys/node_modules/protobufjs/dist/light/protobuf.js.map +1 -1
  113. package/node_modules/baileys/node_modules/protobufjs/dist/light/protobuf.min.js +3 -3
  114. package/node_modules/baileys/node_modules/protobufjs/dist/light/protobuf.min.js.map +1 -1
  115. package/node_modules/baileys/node_modules/protobufjs/dist/minimal/protobuf.js +47 -40
  116. package/node_modules/baileys/node_modules/protobufjs/dist/minimal/protobuf.js.map +1 -1
  117. package/node_modules/baileys/node_modules/protobufjs/dist/minimal/protobuf.min.js +3 -3
  118. package/node_modules/baileys/node_modules/protobufjs/dist/minimal/protobuf.min.js.map +1 -1
  119. package/node_modules/baileys/node_modules/protobufjs/dist/protobuf.js +92 -68
  120. package/node_modules/baileys/node_modules/protobufjs/dist/protobuf.js.map +1 -1
  121. package/node_modules/baileys/node_modules/protobufjs/dist/protobuf.min.js +3 -3
  122. package/node_modules/baileys/node_modules/protobufjs/dist/protobuf.min.js.map +1 -1
  123. package/node_modules/baileys/node_modules/protobufjs/ext/descriptor.js +26 -10
  124. package/node_modules/baileys/node_modules/protobufjs/index.d.ts +3 -0
  125. package/node_modules/baileys/node_modules/protobufjs/package.json +1 -1
  126. package/node_modules/baileys/node_modules/protobufjs/src/converter.js +5 -1
  127. package/node_modules/baileys/node_modules/protobufjs/src/enum.js +5 -2
  128. package/node_modules/baileys/node_modules/protobufjs/src/field.js +6 -1
  129. package/node_modules/baileys/node_modules/protobufjs/src/parse.js +26 -23
  130. package/node_modules/baileys/node_modules/protobufjs/src/reader.js +36 -9
  131. package/node_modules/baileys/node_modules/protobufjs/src/util/codegen.js +3 -1
  132. package/node_modules/baileys/node_modules/protobufjs/src/util/utf8.js +2 -28
  133. package/node_modules/baileys/node_modules/protobufjs/src/writer.js +7 -1
  134. package/node_modules/baileys/node_modules/ws/lib/permessage-deflate.js +3 -1
  135. package/node_modules/baileys/node_modules/ws/package.json +1 -1
  136. package/node_modules/baileys/package.json +1 -1
  137. package/node_modules/typebox/build/format/date.d.mts +1 -1
  138. package/node_modules/typebox/build/format/date.mjs +1 -1
  139. package/node_modules/typebox/build/format/date_time.d.mts +2 -2
  140. package/node_modules/typebox/build/format/date_time.mjs +3 -3
  141. package/node_modules/typebox/build/format/email.d.mts +1 -1
  142. package/node_modules/typebox/build/format/email.mjs +2 -2
  143. package/node_modules/typebox/build/format/hostname.mjs +2 -10
  144. package/node_modules/typebox/build/format/idn_email.d.mts +1 -1
  145. package/node_modules/typebox/build/format/idn_email.mjs +3 -3
  146. package/node_modules/typebox/build/format/idn_hostname.d.mts +1 -0
  147. package/node_modules/typebox/build/format/idn_hostname.mjs +3 -11
  148. package/node_modules/typebox/build/format/idna/format/bidi.d.mts +3 -0
  149. package/node_modules/typebox/build/format/idna/format/bidi.mjs +98 -0
  150. package/node_modules/typebox/build/format/idna/format/puny.d.mts +3 -0
  151. package/node_modules/typebox/build/format/idna/format/puny.mjs +144 -0
  152. package/node_modules/typebox/build/format/idna/hostname.d.mts +1 -0
  153. package/node_modules/typebox/build/format/idna/hostname.mjs +16 -0
  154. package/node_modules/typebox/build/format/idna/idn-hostname.d.mts +1 -0
  155. package/node_modules/typebox/build/format/idna/idn-hostname.mjs +41 -0
  156. package/node_modules/typebox/build/format/idna/index.d.mts +2 -0
  157. package/node_modules/typebox/build/format/idna/index.mjs +2 -0
  158. package/node_modules/typebox/build/format/idna/label/ascii.d.mts +1 -0
  159. package/node_modules/typebox/build/format/idna/label/ascii.mjs +9 -0
  160. package/node_modules/typebox/build/format/idna/label/puny.d.mts +1 -0
  161. package/node_modules/typebox/build/format/idna/label/puny.mjs +28 -0
  162. package/node_modules/typebox/build/format/idna/label/unicode.d.mts +1 -0
  163. package/node_modules/typebox/build/format/idna/label/unicode.mjs +106 -0
  164. package/node_modules/typebox/build/format/idna/pattern/pattern.d.mts +30 -0
  165. package/node_modules/typebox/build/format/idna/pattern/pattern.mjs +70 -0
  166. package/node_modules/typebox/build/format/ipv4.d.mts +0 -1
  167. package/node_modules/typebox/build/format/ipv4.mjs +2 -32
  168. package/node_modules/typebox/build/format/ipv6.mjs +2 -61
  169. package/node_modules/typebox/build/format/iri.d.mts +2 -2
  170. package/node_modules/typebox/build/format/iri.mjs +26 -8
  171. package/node_modules/typebox/build/format/iri_reference.d.mts +2 -2
  172. package/node_modules/typebox/build/format/iri_reference.mjs +9 -55
  173. package/node_modules/typebox/build/format/regex.d.mts +1 -2
  174. package/node_modules/typebox/build/format/regex.mjs +2 -6
  175. package/node_modules/typebox/build/format/time.d.mts +2 -2
  176. package/node_modules/typebox/build/format/time.mjs +19 -14
  177. package/node_modules/typebox/build/format/uri.d.mts +1 -1
  178. package/node_modules/typebox/build/format/uri.mjs +3 -130
  179. package/node_modules/typebox/build/format/uri_reference.d.mts +1 -1
  180. package/node_modules/typebox/build/format/uri_reference.mjs +2 -3
  181. package/node_modules/typebox/build/format/uri_template.d.mts +2 -3
  182. package/node_modules/typebox/build/format/uri_template.mjs +4 -5
  183. package/node_modules/typebox/build/format/url.d.mts +3 -3
  184. package/node_modules/typebox/build/format/url.mjs +4 -5
  185. package/node_modules/typebox/build/guard/emit.d.mts +3 -1
  186. package/node_modules/typebox/build/guard/emit.mjs +12 -5
  187. package/node_modules/typebox/build/guard/guard.d.mts +8 -2
  188. package/node_modules/typebox/build/guard/guard.mjs +25 -4
  189. package/node_modules/typebox/build/guard/string.d.mts +2 -2
  190. package/node_modules/typebox/build/guard/string.mjs +7 -7
  191. package/node_modules/typebox/build/schema/engine/_context.mjs +3 -3
  192. package/node_modules/typebox/build/schema/engine/_functions.mjs +1 -2
  193. package/node_modules/typebox/build/schema/engine/_regexp.d.mts +2 -0
  194. package/node_modules/typebox/build/schema/engine/_regexp.mjs +4 -0
  195. package/node_modules/typebox/build/schema/engine/_stack.mjs +12 -13
  196. package/node_modules/typebox/build/schema/engine/additionalItems.mjs +17 -7
  197. package/node_modules/typebox/build/schema/engine/additionalProperties.mjs +4 -3
  198. package/node_modules/typebox/build/schema/engine/contains.mjs +18 -6
  199. package/node_modules/typebox/build/schema/engine/enum.mjs +1 -1
  200. package/node_modules/typebox/build/schema/engine/items.mjs +26 -6
  201. package/node_modules/typebox/build/schema/engine/maxContains.mjs +3 -3
  202. package/node_modules/typebox/build/schema/engine/minContains.mjs +14 -4
  203. package/node_modules/typebox/build/schema/engine/not.mjs +4 -2
  204. package/node_modules/typebox/build/schema/engine/oneOf.mjs +7 -6
  205. package/node_modules/typebox/build/schema/engine/pattern.mjs +3 -2
  206. package/node_modules/typebox/build/schema/engine/patternProperties.mjs +4 -3
  207. package/node_modules/typebox/build/schema/engine/ref.mjs +1 -7
  208. package/node_modules/typebox/build/schema/engine/schema.mjs +13 -4
  209. package/node_modules/typebox/build/schema/engine/type.mjs +1 -1
  210. package/node_modules/typebox/build/schema/resolve/resolve.d.mts +4 -1
  211. package/node_modules/typebox/build/schema/resolve/resolve.mjs +202 -1
  212. package/node_modules/typebox/build/schema/static/propertyNames.d.mts +5 -0
  213. package/node_modules/typebox/build/schema/static/propertyNames.mjs +3 -0
  214. package/node_modules/typebox/build/schema/static/schema.d.mts +3 -0
  215. package/node_modules/typebox/build/schema/types/index.d.mts +0 -2
  216. package/node_modules/typebox/build/schema/types/index.mjs +0 -2
  217. package/node_modules/typebox/build/system/memory/clone.mjs +14 -11
  218. package/node_modules/typebox/build/system/memory/discard.mjs +6 -5
  219. package/node_modules/typebox/build/system/settings/settings.d.mts +9 -0
  220. package/node_modules/typebox/build/system/settings/settings.mjs +2 -0
  221. package/node_modules/typebox/build/type/engine/call/distribute_arguments.d.mts +6 -1
  222. package/node_modules/typebox/build/type/engine/call/distribute_arguments.mjs +16 -3
  223. package/node_modules/typebox/build/type/engine/call/instantiate.mjs +34 -4
  224. package/node_modules/typebox/build/type/engine/evaluate/broaden.d.mts +5 -5
  225. package/node_modules/typebox/build/type/engine/evaluate/broaden.mjs +20 -26
  226. package/node_modules/typebox/build/type/engine/evaluate/compare.d.mts +6 -10
  227. package/node_modules/typebox/build/type/engine/evaluate/compare.mjs +9 -13
  228. package/node_modules/typebox/build/type/engine/evaluate/composite.d.mts +7 -4
  229. package/node_modules/typebox/build/type/engine/evaluate/composite.mjs +12 -19
  230. package/node_modules/typebox/build/type/engine/evaluate/distribute.d.mts +4 -20
  231. package/node_modules/typebox/build/type/engine/evaluate/distribute.mjs +8 -20
  232. package/node_modules/typebox/build/type/engine/evaluate/evaluate.d.mts +4 -4
  233. package/node_modules/typebox/build/type/engine/evaluate/evaluate.mjs +11 -8
  234. package/node_modules/typebox/build/type/engine/evaluate/flatten.d.mts +1 -1
  235. package/node_modules/typebox/build/type/engine/evaluate/flatten.mjs +3 -4
  236. package/node_modules/typebox/build/type/engine/evaluate/narrow.d.mts +17 -2
  237. package/node_modules/typebox/build/type/engine/evaluate/narrow.mjs +26 -6
  238. package/node_modules/typebox/build/type/engine/exclude/operation.mjs +3 -4
  239. package/node_modules/typebox/build/type/engine/extract/operation.d.mts +1 -1
  240. package/node_modules/typebox/build/type/engine/extract/operation.mjs +3 -4
  241. package/node_modules/typebox/build/type/engine/priority/priority.d.mts +2 -2
  242. package/node_modules/typebox/build/type/engine/priority/priority.mjs +3 -4
  243. package/node_modules/typebox/build/type/script/mapping.d.mts +32 -29
  244. package/node_modules/typebox/build/type/script/mapping.mjs +18 -25
  245. package/node_modules/typebox/build/type/script/parser.d.mts +19 -25
  246. package/node_modules/typebox/build/type/script/parser.mjs +27 -23
  247. package/node_modules/typebox/build/value/errors/errors.d.mts +2 -2
  248. package/node_modules/typebox/build/value/errors/errors.mjs +1 -1
  249. package/node_modules/typebox/package.json +27 -27
  250. package/node_modules/typebox/readme.md +79 -82
  251. package/openclaw.plugin.json +2 -1
  252. package/package.json +6 -6
  253. package/node_modules/baileys/node_modules/process-warning/types/index.test-d.ts +0 -36
  254. package/node_modules/typebox/build/format/_idna.d.mts +0 -2
  255. package/node_modules/typebox/build/format/_idna.mjs +0 -246
  256. package/node_modules/typebox/build/format/_puny.d.mts +0 -1
  257. package/node_modules/typebox/build/format/_puny.mjs +0 -77
  258. package/node_modules/typebox/build/schema/resolve/ref.d.mts +0 -3
  259. package/node_modules/typebox/build/schema/resolve/ref.mjs +0 -146
  260. package/node_modules/typebox/build/schema/types/contentEncoding.d.mts +0 -9
  261. package/node_modules/typebox/build/schema/types/contentEncoding.mjs +0 -13
  262. package/node_modules/typebox/build/schema/types/contentMediaType.d.mts +0 -9
  263. package/node_modules/typebox/build/schema/types/contentMediaType.mjs +0 -13
@@ -1,60 +1,14 @@
1
1
  // deno-lint-ignore-file no-control-regex
2
- // deno-coverage-ignore-start
3
- function TryUrl(value) {
4
- try {
5
- new URL(value, 'http://example.com'); // This handles relative paths correctly
6
- return true;
7
- }
8
- catch {
9
- return false;
10
- }
11
- }
12
- // deno-coverage-ignore-stop
2
+ // Rejects unencoded spaces (0x20), backslashes, control characters (0x00-0x1F, 0x7F), or malformed percent-encodings
3
+ const InvalidIriChars = /[\x00-\x20\x7F\\]|%(?![0-9a-fA-F]{2})/;
4
+ // Detects malformed scheme/authority patterns lacking a colon (e.g. "httpx//example.com")
5
+ const MalformedScheme = /^[a-zA-Z][a-zA-Z0-9+\-.]*\/\//;
13
6
  /**
14
- * Returns true if the value is a Iri reference
15
- * @specification
7
+ * Returns true if the value is an IRI reference
8
+ * @specification https://tools.ietf.org/html/rfc3987
16
9
  */
17
10
  export function IsIriReference(value) {
18
- // 1. Basic forbidden character checks (must be percent-encoded or not exist)
19
- // RFC 3987 excludes space, backslash, and control characters from being unencoded.
20
- if (value.includes(' ')) { // Unencoded space (U+0020)
21
- return false;
22
- }
23
- if (value.includes('\\')) { // Backslash (U+005C)
24
- return false;
25
- }
26
- // ASCII control characters (U+0000-U+001F and U+007F)
27
- if (/[\x00-\x1F\x7F]/.test(value)) {
28
- return false;
29
- }
30
- // 2. Check for invalid percent-encoding
31
- // A percent sign '%' must always be followed by exactly two hexadecimal characters.
32
- // This regex finds a '%' that is NOT followed by two hexadecimal characters.
33
- // - `%` matches a literal percent sign.
34
- // - `(?!...)` is a negative lookahead, asserting that what follows is NOT.
35
- // - `[0-9a-fA-F]{2}` matches exactly two hexadecimal digits.
36
- // So, if a '%' is found that is not immediately followed by two hex digits, this regex will match.
37
- if (/%(?![0-9a-fA-F]{2})/.test(value)) {
38
- return false;
39
- }
40
- // 3. Handle empty string (valid relative reference to the current document)
41
- if (value === '') {
42
- return true;
43
- }
44
- // 4. Determine if it's attempting to be an absolute IRI or a relative IRI, and parse.
45
- const colonIndex = value.indexOf(':');
46
- const hasValidSchemePrefix = colonIndex > 0 && // Colon must not be at the very beginning (e.g., ":foo")
47
- /^[a-zA-Z][a-zA-Z0-9+\-.]*$/.test(value.substring(0, colonIndex));
48
- if (hasValidSchemePrefix) {
49
- return TryUrl(value);
50
- }
51
- else {
52
- // This handles cases like `httpx//example.com/path` which look like malformed absolute URIs.
53
- const looksLikeMalformedSchemeAndAuthority = value.match(/^([a-zA-Z][a-zA-Z0-9+\-.]*)(\/\/)/);
54
- if (looksLikeMalformedSchemeAndAuthority && colonIndex === -1) {
55
- return false;
56
- }
57
- // Otherwise, it's a relative IRI reference.
58
- return TryUrl(value);
59
- }
11
+ return (!InvalidIriChars.test(value) &&
12
+ !MalformedScheme.test(value) &&
13
+ URL.canParse(value, 'http://example.com'));
60
14
  }
@@ -1,6 +1,5 @@
1
1
  /**
2
2
  * Returns true if the value is a regular expression string pattern
3
- * @specification
4
- * @source ajv-formats
3
+ * @specification https://ecma-international.org/ecma-262
5
4
  */
6
5
  export declare function IsRegex(value: string): boolean;
@@ -1,14 +1,10 @@
1
1
  /**
2
2
  * Returns true if the value is a regular expression string pattern
3
- * @specification
4
- * @source ajv-formats
3
+ * @specification https://ecma-international.org/ecma-262
5
4
  */
6
5
  export function IsRegex(value) {
7
- if (value.length === 0) {
8
- return false;
9
- }
10
6
  try {
11
- new RegExp(value);
7
+ new RegExp(value, 'u');
12
8
  return true;
13
9
  }
14
10
  catch {
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Returns true if the value is a ISO time string
3
- * @specification
2
+ * Returns true if the value is an ISO time string
3
+ * @specification https://datatracker.ietf.org/doc/html/rfc3339
4
4
  */
5
5
  export declare function IsTime(value: string, strictTimeZone?: boolean): boolean;
@@ -1,27 +1,32 @@
1
- const TIME = /^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(?:Z|([+-])(\d\d):(\d\d))?$/i;
1
+ const TIME = /^(\d\d):(\d\d):(\d\d)(?:\.\d+)?(?:([Zz])|([+-])(\d\d):(\d\d))?$/;
2
2
  /**
3
- * Returns true if the value is a ISO time string
4
- * @specification
3
+ * Returns true if the value is an ISO time string
4
+ * @specification https://datatracker.ietf.org/doc/html/rfc3339
5
5
  */
6
6
  export function IsTime(value, strictTimeZone = true) {
7
7
  const matches = TIME.exec(value);
8
8
  if (!matches)
9
9
  return false;
10
+ // Require timezone offset or 'Z'/'z' when strictTimeZone is true
11
+ if (strictTimeZone && !matches[4] && !matches[5])
12
+ return false;
10
13
  const hr = +matches[1];
11
14
  const min = +matches[2];
12
15
  const sec = +matches[3];
13
- const tzSign = matches[4] === '-' ? -1 : 1; // Use matches[4] for sign
14
- const tzH = +(matches[5] || 0); // tzH is now matches[5]
15
- const tzM = +(matches[6] || 0); // tzM is now matches[6]
16
- if (tzH > 23 || tzM > 59)
17
- return false; // Check for valid hour/minute range in offset
18
- if (strictTimeZone && !matches[4] && value.toLowerCase().indexOf('z') === -1) {
19
- // If strictTimeZone is true, and neither 'Z' nor a '+/-' offset was found
16
+ if (hr > 23 || min > 59 || sec > 60)
20
17
  return false;
18
+ if (matches[5]) {
19
+ const tzH = +matches[6];
20
+ const tzM = +matches[7];
21
+ if (tzH > 23 || tzM > 59)
22
+ return false;
21
23
  }
22
- if (hr <= 23 && min <= 59 && sec < 60)
24
+ if (sec < 60)
23
25
  return true;
24
- const utcMin = min - tzM * tzSign;
25
- const utcHr = hr - tzH * tzSign - (utcMin < 0 ? 1 : 0);
26
- return (utcHr === 23 || utcHr === -1) && (utcMin === 59 || utcMin === -1) && sec < 61;
26
+ // Leap second handling: must normalize to 23:59:60 UTC (1439 total UTC minutes)
27
+ const tzSign = matches[5] === '-' ? -1 : 1;
28
+ const tzH = +(matches[6] || 0);
29
+ const tzM = +(matches[7] || 0);
30
+ const totalUtcMin = (hr * 60 + min) - tzSign * (tzH * 60 + tzM);
31
+ return (totalUtcMin % 1440 + 1440) % 1440 === 1439;
27
32
  }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Returns true if the value matches RFC 3986 URI syntax.
2
+ * Returns true if the value is a valid Uniform Resource Identifier.
3
3
  * @specification https://tools.ietf.org/html/rfc3986
4
4
  */
5
5
  export declare function IsUri(value: string): boolean;
@@ -1,135 +1,8 @@
1
- function IsAlpha(ch) {
2
- return (ch >= 97 && ch <= 122) || (ch >= 65 && ch <= 90); // a-z, A-Z
3
- }
4
- function IsAlphaNumeric(ch) {
5
- return IsAlpha(ch) || (ch >= 48 && ch <= 57); // a-z, A-Z, 0-9
6
- }
7
- function IsHex(ch) {
8
- return (ch >= 48 && ch <= 57) || // 0-9
9
- (ch >= 65 && ch <= 70) || // A-F
10
- (ch >= 97 && ch <= 102); // a-f
11
- }
12
- function IsSchemeChar(ch) {
13
- return IsAlphaNumeric(ch) ||
14
- ch === 43 || ch === 45 || ch === 46; // '+', '-', '.'
15
- }
16
- function IsUnreserved(ch) {
17
- return IsAlphaNumeric(ch) ||
18
- ch === 45 || ch === 46 || // '-', '.'
19
- ch === 95 || ch === 126; // '_', '~'
20
- }
21
- function IsSubDelim(ch) {
22
- return ch === 33 || ch === 36 || ch === 38 || ch === 39 ||
23
- ch === 40 || ch === 41 || ch === 42 || ch === 43 ||
24
- ch === 44 || ch === 59 || ch === 61; // ! $ & ' ( ) * + , ; =
25
- }
26
- function IsPchar(ch) {
27
- return IsUnreserved(ch) || IsSubDelim(ch) || ch === 58 || ch === 64; // ':', '@'
28
- }
1
+ const Uri = /^[a-z][a-z0-9+\-.]*:(?:\/\/(?:(?:[-a-z0-9._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:[\da-f]{1,4}:){6}(?:[\da-f]{1,4}:[\da-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))|::(?:[\da-f]{1,4}:){5}(?:[\da-f]{1,4}:[\da-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))|(?:[\da-f]{1,4})?::(?:[\da-f]{1,4}:){4}(?:[\da-f]{1,4}:[\da-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))|(?:(?:[\da-f]{1,4}:){0,1}[\da-f]{1,4})?::(?:[\da-f]{1,4}:){3}(?:[\da-f]{1,4}:[\da-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))|(?:(?:[\da-f]{1,4}:){0,2}[\da-f]{1,4})?::(?:[\da-f]{1,4}:){2}(?:[\da-f]{1,4}:[\da-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))|(?:(?:[\da-f]{1,4}:){0,3}[\da-f]{1,4})?::[\da-f]{1,4}:(?:[\da-f]{1,4}:[\da-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))|(?:(?:[\da-f]{1,4}:){0,4}[\da-f]{1,4})?::(?:[\da-f]{1,4}:[\da-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))|(?:(?:[\da-f]{1,4}:){0,5}[\da-f]{1,4})?::[\da-f]{1,4}|(?:(?:[\da-f]{1,4}:){0,6}[\da-f]{1,4})?::)|v[0-9a-f]+\.[-a-z0-9._~!$&'()*+,;=:]+)\]|(?:(?: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)|(?:[-a-z0-9._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[-a-z0-9._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[-a-z0-9._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;
29
2
  /**
30
- * Returns true if the value matches RFC 3986 URI syntax.
3
+ * Returns true if the value is a valid Uniform Resource Identifier.
31
4
  * @specification https://tools.ietf.org/html/rfc3986
32
5
  */
33
6
  export function IsUri(value) {
34
- const length = value.length;
35
- if (length === 0)
36
- return false;
37
- // Scheme: must start with a letter
38
- if (!IsAlpha(value.charCodeAt(0)))
39
- return false;
40
- // Scheme: continues until ':'
41
- let i = 1;
42
- while (i < length) {
43
- const ch = value.charCodeAt(i);
44
- if (ch === 58)
45
- break; // ':'
46
- if (!IsSchemeChar(ch))
47
- return false;
48
- i++;
49
- }
50
- // Ensure scheme is terminated by ':'
51
- if (value.charCodeAt(i) !== 58)
52
- return false;
53
- i++;
54
- // Authority: optional '//'
55
- if (value.charCodeAt(i) === 47 && value.charCodeAt(i + 1) === 47) {
56
- i += 2;
57
- // Userinfo: check for '@' before path/query/fragment delimiters
58
- const authorityStart = i;
59
- let atPos = -1;
60
- for (let j = i; j < length; j++) {
61
- const ch = value.charCodeAt(j);
62
- if (ch === 64) {
63
- atPos = j;
64
- break;
65
- } // '@'
66
- if (ch === 47 || ch === 63 || ch === 35)
67
- break; // '/', '?', '#'
68
- }
69
- if (atPos !== -1) {
70
- // Userinfo: validate allowed chars and percent-encoding
71
- for (let j = authorityStart; j < atPos; j++) {
72
- const ch = value.charCodeAt(j);
73
- if (ch === 91 || ch === 93)
74
- return false; // No '[' or ']' in userinfo
75
- if (ch === 37) { // '%' percent-encoding
76
- if (j + 2 >= atPos || !IsHex(value.charCodeAt(j + 1)) || !IsHex(value.charCodeAt(j + 2)))
77
- return false;
78
- j += 2;
79
- }
80
- else if (!IsUnreserved(ch) && !IsSubDelim(ch) && ch !== 58)
81
- return false;
82
- }
83
- i = atPos + 1;
84
- }
85
- // Host: IP-literal [addr] or reg-name
86
- if (value.charCodeAt(i) === 91) { // '['
87
- i++;
88
- while (i < length && value.charCodeAt(i) !== 93)
89
- i++;
90
- if (value.charCodeAt(i) !== 93)
91
- return false; // ']'
92
- i++;
93
- }
94
- else {
95
- // Host: validate ASCII; skip validation for non-ASCII (Unicode hosts)
96
- while (i < length) {
97
- const ch = value.charCodeAt(i);
98
- if (ch === 47 || ch === 63 || ch === 35 || ch === 58)
99
- break;
100
- if (ch < 128 && !IsUnreserved(ch) && !IsSubDelim(ch))
101
- return false;
102
- i++;
103
- }
104
- }
105
- // Port: optional digits after ':'
106
- if (value.charCodeAt(i) === 58) { // ':'
107
- i++;
108
- while (i < length) {
109
- const ch = value.charCodeAt(i);
110
- if (ch === 47 || ch === 63 || ch === 35)
111
- break;
112
- if (ch < 48 || ch > 57)
113
- return false; // 0-9
114
- i++;
115
- }
116
- }
117
- }
118
- // Path, Query, and Fragment
119
- while (i < length) {
120
- const ch = value.charCodeAt(i);
121
- if (ch === 37) { // '%' percent-encoding
122
- if (i + 2 >= length || !IsHex(value.charCodeAt(i + 1)) || !IsHex(value.charCodeAt(i + 2)))
123
- return false;
124
- i += 2;
125
- }
126
- else if (ch > 127) {
127
- return false; // URI is ASCII-only
128
- }
129
- else if (!(IsPchar(ch) || ch === 47 || ch === 63 || ch === 35)) {
130
- return false; // '/', '?', '#'
131
- }
132
- i++;
133
- }
134
- return true;
7
+ return Uri.test(value);
135
8
  }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Returns true if the value is a valid URI Reference.
2
+ * Returns true if the value is a valid Uri Reference.
3
3
  * @specification https://tools.ietf.org/html/rfc3986
4
4
  */
5
5
  export declare function IsUriReference(value: string): boolean;
@@ -1,7 +1,6 @@
1
- // deno-lint-ignore-file no-control-regex
2
- const UriReference = /^(?!.*[^\x00-\x7F])(?!.*\\)(?:(?:[a-z][a-z0-9+\-.]*:)?(?:\/\/[^\s[\]{}<>^`|]*)?|[^\s[\]{}<>^`|]*)(?:\?[^\s[\]{}<>^`|]*)?(?:#[^\s[\]{}<>^`|]*)?$/i;
1
+ const UriReference = /^(?:[a-z][a-z0-9+\-.]*:(?:\/\/(?:(?:[-a-z0-9._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:[\da-f]{1,4}:){6}(?:[\da-f]{1,4}:[\da-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))|::(?:[\da-f]{1,4}:){5}(?:[\da-f]{1,4}:[\da-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))|(?:[\da-f]{1,4})?::(?:[\da-f]{1,4}:){4}(?:[\da-f]{1,4}:[\da-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))|(?:(?:[\da-f]{1,4}:){0,1}[\da-f]{1,4})?::(?:[\da-f]{1,4}:){3}(?:[\da-f]{1,4}:[\da-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))|(?:(?:[\da-f]{1,4}:){0,2}[\da-f]{1,4})?::(?:[\da-f]{1,4}:){2}(?:[\da-f]{1,4}:[\da-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))|(?:(?:[\da-f]{1,4}:){0,3}[\da-f]{1,4})?::[\da-f]{1,4}:(?:[\da-f]{1,4}:[\da-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))|(?:(?:[\da-f]{1,4}:){0,4}[\da-f]{1,4})?::(?:[\da-f]{1,4}:[\da-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))|(?:(?:[\da-f]{1,4}:){0,5}[\da-f]{1,4})?::[\da-f]{1,4}|(?:(?:[\da-f]{1,4}:){0,6}[\da-f]{1,4})?::)|v[0-9a-f]+\.[-a-z0-9._~!$&'()*+,;=:]+)\]|(?:(?: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)|(?:[-a-z0-9._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:\/\/(?:(?:[-a-z0-9._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:[\da-f]{1,4}:){6}(?:[\da-f]{1,4}:[\da-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))|::(?:[\da-f]{1,4}:){5}(?:[\da-f]{1,4}:[\da-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))|(?:[\da-f]{1,4})?::(?:[\da-f]{1,4}:){4}(?:[\da-f]{1,4}:[\da-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))|(?:(?:[\da-f]{1,4}:){0,1}[\da-f]{1,4})?::(?:[\da-f]{1,4}:){3}(?:[\da-f]{1,4}:[\da-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))|(?:(?:[\da-f]{1,4}:){0,2}[\da-f]{1,4})?::(?:[\da-f]{1,4}:){2}(?:[\da-f]{1,4}:[\da-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))|(?:(?:[\da-f]{1,4}:){0,3}[\da-f]{1,4})?::[\da-f]{1,4}:(?:[\da-f]{1,4}:[\da-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))|(?:(?:[\da-f]{1,4}:){0,4}[\da-f]{1,4})?::(?:[\da-f]{1,4}:[\da-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))|(?:(?:[\da-f]{1,4}:){0,5}[\da-f]{1,4})?::[\da-f]{1,4}|(?:(?:[\da-f]{1,4}:){0,6}[\da-f]{1,4})?::)|v[0-9a-f]+\.[-a-z0-9._~!$&'()*+,;=:]+)\]|(?:(?: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)|(?:[-a-z0-9._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[-a-z0-9._~!$&'()*+,;=@]|%[0-9a-f]{2})+(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?)(?:\?(?:[-a-z0-9._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[-a-z0-9._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;
3
2
  /**
4
- * Returns true if the value is a valid URI Reference.
3
+ * Returns true if the value is a valid Uri Reference.
5
4
  * @specification https://tools.ietf.org/html/rfc3986
6
5
  */
7
6
  export function IsUriReference(value) {
@@ -1,6 +1,5 @@
1
1
  /**
2
- * Returns true if the value is a uri template
3
- * @specification
4
- * @source ajv-formats
2
+ * Returns true if the value is a valid Uri Template
3
+ * @specification https://datatracker.ietf.org/doc/html/rfc6570
5
4
  */
6
5
  export declare function IsUriTemplate(value: string): boolean;
@@ -1,9 +1,8 @@
1
- // deno-lint-ignore-file
2
- const UriTemplate = /^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i;
1
+ // deno-lint-ignore-file no-control-regex
2
+ const UriTemplate = /^(?:(?:[^\x00-\x20"<>%\\^`{|}\x7f]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?:\.(?:[a-z0-9_]|%[0-9a-f]{2})+)*(?::[1-9]\d{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?:\.(?:[a-z0-9_]|%[0-9a-f]{2})+)*(?::[1-9]\d{0,3}|\*)?)*\})*$/i;
3
3
  /**
4
- * Returns true if the value is a uri template
5
- * @specification
6
- * @source ajv-formats
4
+ * Returns true if the value is a valid Uri Template
5
+ * @specification https://datatracker.ietf.org/doc/html/rfc6570
7
6
  */
8
7
  export function IsUriTemplate(value) {
9
8
  return UriTemplate.test(value);
@@ -1,6 +1,6 @@
1
1
  /**
2
- * Returns true if the value is a Url
3
- * @specification
4
- * @source ajv-formats
2
+ * Returns true if the value is a valid Uniform Resource Locator
3
+ * @specification https://datatracker.ietf.org/doc/html/rfc3986
4
+ * @specification https://datatracker.ietf.org/doc/html/rfc3987
5
5
  */
6
6
  export declare function IsUrl(value: string): boolean;
@@ -1,9 +1,8 @@
1
- const Url = /^(?:https?|ftp):\/\/(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)(?:\.(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu;
2
1
  /**
3
- * Returns true if the value is a Url
4
- * @specification
5
- * @source ajv-formats
2
+ * Returns true if the value is a valid Uniform Resource Locator
3
+ * @specification https://datatracker.ietf.org/doc/html/rfc3986
4
+ * @specification https://datatracker.ietf.org/doc/html/rfc3987
6
5
  */
7
6
  export function IsUrl(value) {
8
- return Url.test(value);
7
+ return URL.canParse(value);
9
8
  }
@@ -33,6 +33,9 @@ export declare function IsGreaterEqualThan(left: string, right: string): string;
33
33
  export declare function IsMinLength(value: string, length: string): string;
34
34
  export declare function IsMaxLength(value: string, length: string): string;
35
35
  export declare function Every(value: string, offset: string, params: [value: string, index: string], expression: string): string;
36
+ export declare function Some(value: string, params: [value: string, index: string], expression: string): string;
37
+ export declare function SomeAll(value: string, params: [value: string, index: string], expression: string): string;
38
+ export declare function Counted(value: string, params: [value: string, index: string], expression: string): string;
36
39
  export declare function Entries(value: string): string;
37
40
  export declare function Keys(value: string): string;
38
41
  export declare function HasPropertyKey(value: string, key: string): string;
@@ -50,5 +53,4 @@ export declare function If(condition: string, then: string): string;
50
53
  export declare function Return(expression: string): string;
51
54
  export declare function ReduceAnd(operands: string[]): string;
52
55
  export declare function ReduceOr(operands: string[]): string;
53
- export declare function PrefixIncrement(expression: string): string;
54
56
  export declare function MultipleOf(dividend: string, divisor: string): string;
@@ -110,6 +110,15 @@ export function Every(value, offset, params, expression) {
110
110
  ? `${value}.every((${params[0]}, ${params[1]}) => ${expression})`
111
111
  : `((value, callback) => { for(let index = ${offset}; index < value.length; index++) if (!callback(value[index], index)) return false; return true })(${value}, (${params[0]}, ${params[1]}) => ${expression})`;
112
112
  }
113
+ export function Some(value, params, expression) {
114
+ return `${value}.some((${params[0]}, ${params[1]}) => ${expression})`;
115
+ }
116
+ export function SomeAll(value, params, expression) {
117
+ return `((value, callback) => { let result = false; for(let index = 0; index < value.length; index++) if (callback(value[index], index)) result = true; return result })(${value}, (${params[0]}, ${params[1]}) => ${expression})`;
118
+ }
119
+ export function Counted(value, params, expression) {
120
+ return `${value}.reduce((result, ${params[0]}, ${params[1]}) => (${expression}) ? ++result : result, 0)`;
121
+ }
113
122
  // --------------------------------------------------------------------------
114
123
  // Objects
115
124
  // --------------------------------------------------------------------------
@@ -145,6 +154,8 @@ export function Member(left, right) {
145
154
  return `${left}${IsIdentifier(right) ? `.${right}` : `[${Constant(right)}]`}`;
146
155
  }
147
156
  export function Constant(value) {
157
+ if (!G.IsValueLike(value))
158
+ throw Error('Unsupported Constant');
148
159
  return G.IsString(value) ? JSON.stringify(value) : `${value}`;
149
160
  }
150
161
  export function Ternary(condition, true_, false_) {
@@ -172,15 +183,11 @@ export function ReduceAnd(operands) {
172
183
  return G.IsEqual(operands.length, 0) ? 'true' : operands.reduce((left, right) => And(left, right));
173
184
  }
174
185
  export function ReduceOr(operands) {
175
- // deno-coverage-ignore - we never observe 0 operands
176
186
  return G.IsEqual(operands.length, 0) ? 'false' : operands.reduce((left, right) => Or(left, right));
177
187
  }
178
188
  // --------------------------------------------------------------------------
179
- // Arithmetic
189
+ // MultipleOf
180
190
  // --------------------------------------------------------------------------
181
- export function PrefixIncrement(expression) {
182
- return `++${expression}`;
183
- }
184
191
  export function MultipleOf(dividend, divisor) {
185
192
  return `Guard.IsMultipleOf(${dividend}, ${divisor})`;
186
193
  }
@@ -39,10 +39,16 @@ export declare function GraphemeCount(value: string): number;
39
39
  export declare function IsMaxLength(value: string, length: number): boolean;
40
40
  /** Returns true if the string has at least the given number of graphemes */
41
41
  export declare function IsMinLength(value: string, length: number): boolean;
42
- /** Returns true if all elements from offset satisfy the callback, short-circuiting on the first failure */
42
+ /** Returns true if every element from offset satisfies the callback, short-circuiting on the first failure */
43
43
  export declare function Every<T>(value: T[], offset: number, callback: (value: T, index: number) => boolean): boolean;
44
- /** Returns true if all elements from offset satisfy the callback, visiting every element regardless of failure */
44
+ /** Returns true if every element from offset satisfies the callback, using exhaustive enumeration */
45
45
  export declare function EveryAll<T>(value: T[], offset: number, callback: (value: T, index: number) => boolean): boolean;
46
+ /** Returns true if some element satisfies the callback, short-circuiting on the first success */
47
+ export declare function Some<T>(value: T[], callback: (value: T, index: number) => boolean): boolean;
48
+ /** Returns true if some element satisfies the callback, using exhaustive enumeration */
49
+ export declare function SomeAll<T>(value: T[], callback: (value: T, index: number) => boolean): boolean;
50
+ /** Returns the count of elements that satisfy the callback */
51
+ export declare function Counted(value: unknown[], callback: (value: unknown, index: number) => boolean): number;
46
52
  /** Shifts the left-most element from an array and dispatches to the true arm, or the false arm if empty */
47
53
  export declare function ShiftLeft<T, True extends (left: T, right: T[]) => unknown, False extends () => unknown>(array: T[], true_: True, false_: False): ReturnType<True> | ReturnType<False>;
48
54
  /** Returns true if the PropertyKey is Unsafe (ref: prototype-pollution). */
@@ -129,16 +129,16 @@ export function GraphemeCount(value) {
129
129
  }
130
130
  /** Returns true if the string has at most the given number of graphemes */
131
131
  export function IsMaxLength(value, length) {
132
- return String.IsMaxLengthFast(value, length);
132
+ return String.IsMaxLength(value, length);
133
133
  }
134
134
  /** Returns true if the string has at least the given number of graphemes */
135
135
  export function IsMinLength(value, length) {
136
- return String.IsMinLengthFast(value, length);
136
+ return String.IsMinLength(value, length);
137
137
  }
138
138
  // --------------------------------------------------------------------------
139
139
  // Array
140
140
  // --------------------------------------------------------------------------
141
- /** Returns true if all elements from offset satisfy the callback, short-circuiting on the first failure */
141
+ /** Returns true if every element from offset satisfies the callback, short-circuiting on the first failure */
142
142
  export function Every(value, offset, callback) {
143
143
  for (let index = offset; index < value.length; index++) {
144
144
  if (!callback(value[index], index))
@@ -146,7 +146,7 @@ export function Every(value, offset, callback) {
146
146
  }
147
147
  return true;
148
148
  }
149
- /** Returns true if all elements from offset satisfy the callback, visiting every element regardless of failure */
149
+ /** Returns true if every element from offset satisfies the callback, using exhaustive enumeration */
150
150
  export function EveryAll(value, offset, callback) {
151
151
  let result = true;
152
152
  for (let index = offset; index < value.length; index++) {
@@ -155,6 +155,27 @@ export function EveryAll(value, offset, callback) {
155
155
  }
156
156
  return result;
157
157
  }
158
+ /** Returns true if some element satisfies the callback, short-circuiting on the first success */
159
+ export function Some(value, callback) {
160
+ for (let index = 0; index < value.length; index++) {
161
+ if (callback(value[index], index))
162
+ return true;
163
+ }
164
+ return false;
165
+ }
166
+ /** Returns true if some element satisfies the callback, using exhaustive enumeration */
167
+ export function SomeAll(value, callback) {
168
+ let result = false;
169
+ for (let index = 0; index < value.length; index++) {
170
+ if (callback(value[index], index))
171
+ result = true;
172
+ }
173
+ return result;
174
+ }
175
+ /** Returns the count of elements that satisfy the callback */
176
+ export function Counted(value, callback) {
177
+ return value.reduce((result, value, index) => callback(value, index) ? ++result : result, 0);
178
+ }
158
179
  /** Shifts the left-most element from an array and dispatches to the true arm, or the false arm if empty */
159
180
  export function ShiftLeft(array, true_, false_) {
160
181
  return (IsEqual(array.length, 0) ? false_() : true_(array[0], array.slice(1)));
@@ -1,6 +1,6 @@
1
1
  /** Returns the number of grapheme clusters in a string */
2
2
  export declare function GraphemeCount(value: string): number;
3
3
  /** Fast check for minimum grapheme length, falls back to full check if needed */
4
- export declare function IsMinLengthFast(value: string, minLength: number): boolean;
4
+ export declare function IsMinLength(value: string, minLength: number): boolean;
5
5
  /** Fast check for maximum grapheme length, falls back to full check if needed */
6
- export declare function IsMaxLengthFast(value: string, maxLength: number): boolean;
6
+ export declare function IsMaxLength(value: string, maxLength: number): boolean;
@@ -67,7 +67,7 @@ function NextGraphemeClusterIndex(value, clusterStart) {
67
67
  // Consume combining marks & variation selectors
68
68
  clusterEnd = ConsumeModifiers(value, clusterEnd);
69
69
  // Handle multi-ZWJ sequences
70
- while (clusterEnd < value.length - 1 && value[clusterEnd] === '\u200D') {
70
+ while (clusterEnd < value.length - 1 && IsZeroWidthJoiner(value.codePointAt(clusterEnd))) {
71
71
  const nextCP = value.codePointAt(clusterEnd + 1);
72
72
  clusterEnd += 1 + CodePointLength(nextCP);
73
73
  clusterEnd = ConsumeModifiers(value, clusterEnd);
@@ -106,7 +106,7 @@ export function GraphemeCount(value) {
106
106
  // IsMinLength
107
107
  // --------------------------------------------------------------------------
108
108
  /** Checks if a string has at least a minimum number of grapheme clusters */
109
- function IsMinLength(value, minLength) {
109
+ function IsMinLengthSegmented(value, minLength) {
110
110
  // ----------------------------------------------------------------
111
111
  // Inaccessible via public interface (review)
112
112
  //
@@ -129,7 +129,7 @@ function IsMinLength(value, minLength) {
129
129
  // IsMaxLength
130
130
  // --------------------------------------------------------------------------
131
131
  /** Checks if a string has at most a maximum number of grapheme clusters */
132
- function IsMaxLength(value, maxLength) {
132
+ function IsMaxLengthSegmented(value, maxLength) {
133
133
  let count = 0;
134
134
  let index = 0;
135
135
  while (index < value.length) {
@@ -144,13 +144,13 @@ function IsMaxLength(value, maxLength) {
144
144
  // IsMinLengthFast
145
145
  // --------------------------------------------------------------------------
146
146
  /** Fast check for minimum grapheme length, falls back to full check if needed */
147
- export function IsMinLengthFast(value, minLength) {
147
+ export function IsMinLength(value, minLength) {
148
148
  if (minLength === 0)
149
149
  return true; // 0-length
150
150
  let index = 0;
151
151
  while (index < value.length) {
152
152
  if (IsGraphemeCodePoint(value.charCodeAt(index))) {
153
- return IsMinLength(value, minLength);
153
+ return IsMinLengthSegmented(value, minLength);
154
154
  }
155
155
  index++;
156
156
  if (index >= minLength)
@@ -162,11 +162,11 @@ export function IsMinLengthFast(value, minLength) {
162
162
  // IsMaxLengthFast
163
163
  // --------------------------------------------------------------------------
164
164
  /** Fast check for maximum grapheme length, falls back to full check if needed */
165
- export function IsMaxLengthFast(value, maxLength) {
165
+ export function IsMaxLength(value, maxLength) {
166
166
  let index = 0;
167
167
  while (index < value.length) {
168
168
  if (IsGraphemeCodePoint(value.charCodeAt(index))) {
169
- return IsMaxLength(value, maxLength);
169
+ return IsMaxLengthSegmented(value, maxLength);
170
170
  }
171
171
  index++;
172
172
  if (index > maxLength)
@@ -7,10 +7,10 @@ import { Guard as G, EmitGuard as E } from '../../guard/index.mjs';
7
7
  function HasUnevaluatedFromObject(value) {
8
8
  return (Schema.IsUnevaluatedItems(value)
9
9
  || Schema.IsUnevaluatedProperties(value)
10
- || G.Keys(value).some(key => HasUnevaluatedFromUnknown(value[key])));
10
+ || G.Some(G.Keys(value), key => HasUnevaluatedFromUnknown(value[key])));
11
11
  }
12
12
  function HasUnevaluatedFromArray(value) {
13
- return value.some(value => HasUnevaluatedFromUnknown(value));
13
+ return G.Some(value, value => HasUnevaluatedFromUnknown(value));
14
14
  }
15
15
  function HasUnevaluatedFromUnknown(value) {
16
16
  return (G.IsArray(value) ? HasUnevaluatedFromArray(value) :
@@ -18,7 +18,7 @@ function HasUnevaluatedFromUnknown(value) {
18
18
  false);
19
19
  }
20
20
  export function HasUnevaluated(context, schema) {
21
- return HasUnevaluatedFromUnknown(schema) || G.Keys(context).some(key => HasUnevaluatedFromUnknown(context[key]));
21
+ return HasUnevaluatedFromUnknown(schema) || G.Some(G.Keys(context), key => HasUnevaluatedFromUnknown(context[key]));
22
22
  }
23
23
  // ------------------------------------------------------------------
24
24
  // BuildContext
@@ -1,5 +1,4 @@
1
1
  // deno-fmt-ignore-file
2
- import { Hashing } from '../../system/hashing/index.mjs';
3
2
  import { EmitGuard as E } from '../../guard/index.mjs';
4
3
  import { BuildSchema } from './schema.mjs';
5
4
  const index = [0];
@@ -9,7 +8,7 @@ const funcs = new Map();
9
8
  // CreateName
10
9
  // ------------------------------------------------------------------
11
10
  function NextName() {
12
- return Hashing.Hash(index[0]++);
11
+ return `${index[0]++}`;
13
12
  }
14
13
  function CreateName(schema, href) {
15
14
  if (!names.has(schema))
@@ -0,0 +1,2 @@
1
+ /** Standard RegExp with Unicode */
2
+ export declare function UnicodeRegExp(pattern: string): RegExp;
@@ -0,0 +1,4 @@
1
+ /** Standard RegExp with Unicode */
2
+ export function UnicodeRegExp(pattern) {
3
+ return new RegExp(pattern, 'u');
4
+ }