@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.
- package/dist/{accounts-BX2fZUyR.js → accounts-CeKQbu_s.js} +9 -26
- package/dist/{action-runtime-pM-ExU0l.js → action-runtime-Bw0loEdy.js} +2 -2
- package/dist/action-runtime-api.js +1 -1
- package/dist/action-runtime.runtime.js +1 -1
- package/dist/{call-tool-api.js → agent-tools-api.js} +13 -6
- package/dist/{agent-tools-login-BjRpD-JQ.js → agent-tools-login-B-2qZPzc.js} +12 -3
- package/dist/api.js +10 -10
- package/dist/{approval-handler.runtime-CkMMvUjk.js → approval-handler.runtime-DeyPb57-.js} +3 -3
- package/dist/{approval-reactions-Jyr1JaAK.js → approval-reactions-DGDA6hQ7.js} +7 -5
- package/dist/{auth-store-CtpBqH5S.js → auth-store-DTj1H9pv.js} +5 -3
- package/dist/{channel-DRMYRfZ8.js → channel-DxMmDjqK.js} +26 -24
- package/dist/channel-config-api.js +1 -1
- package/dist/channel-plugin-api.js +1 -1
- package/dist/{channel-react-action-CstrR0CT.js → channel-react-action-BUp7Wbfr.js} +3 -3
- package/dist/{channel.runtime-X3JC2gaq.js → channel.runtime-BwSnyXRX.js} +4 -4
- package/dist/{channel.setup-DhBBhbQv.js → channel.setup-aOFLSQyw.js} +1 -1
- package/dist/{config-schema-BQP5YCeK.js → config-schema-BYA6e_Ii.js} +6 -4
- package/dist/{connection-controller-CIYuBJrs.js → connection-controller-BvkxsbWi.js} +2 -2
- package/dist/{constants-HU41RHGI.js → constants-C7m81BNe.js} +1 -1
- package/dist/{directory-config-P7_3U73Z.js → directory-config-LgxYJLWY.js} +3 -3
- package/dist/directory-contract-api.js +1 -1
- package/dist/{group-session-key-DmFc_Cqi.js → group-session-key-KUguLmSZ.js} +4 -4
- package/dist/index.js +4 -4
- package/dist/light-runtime-api.js +2 -2
- package/dist/{login-BkpKpndm.js → login-Bk_jiXKD.js} +6 -5
- package/dist/{login-qr-1dpv6jjT.js → login-qr-B3m61NqA.js} +43 -20
- package/dist/login-qr-runtime.js +1 -1
- package/dist/{monitor-IzwQKizW.js → monitor-CTsyo-HE.js} +185 -162
- package/dist/{question-reactions-D3eAeB0i.js → question-reactions-B9D6MHXZ.js} +1 -1
- package/dist/runtime-api.js +9 -9
- package/dist/{send-CwvTU4RI.js → send-DiPjiygK.js} +54 -29
- package/dist/{send-api-obOSm2cC.js → send-api-kFcuhSiY.js} +43 -41
- package/dist/{setup-finalize-n4K2I2gJ.js → setup-finalize-CqH5wTK5.js} +7 -6
- package/dist/setup-plugin-api.js +1 -1
- package/dist/{setup-surface-Cwn3zyxK.js → setup-surface-Dm3T6S8t.js} +3 -3
- package/dist/{shared-wg42NKFB.js → shared-DDjonGys.js} +7 -6
- package/dist/{socket-close-2T0_jZTN.js → socket-close-CpkkJZCU.js} +9 -6
- package/dist/{targets-runtime-TMk0lGuy.js → targets-runtime-RBjx3pg_.js} +1 -2
- package/dist/{text-runtime-CaKLhowd.js → text-runtime-DyfmcATV.js} +1 -1
- package/node_modules/baileys/lib/Defaults/index.js +1 -1
- package/node_modules/baileys/lib/Socket/business.d.ts.map +1 -1
- package/node_modules/baileys/lib/Socket/chats.d.ts +1 -0
- package/node_modules/baileys/lib/Socket/chats.d.ts.map +1 -1
- package/node_modules/baileys/lib/Socket/chats.js +10 -5
- package/node_modules/baileys/lib/Socket/chats.js.map +1 -1
- package/node_modules/baileys/lib/Socket/communities.d.ts.map +1 -1
- package/node_modules/baileys/lib/Socket/groups.d.ts.map +1 -1
- package/node_modules/baileys/lib/Socket/index.d.ts.map +1 -1
- package/node_modules/baileys/lib/Socket/messages-recv.d.ts.map +1 -1
- package/node_modules/baileys/lib/Socket/messages-send.d.ts.map +1 -1
- package/node_modules/baileys/lib/Socket/newsletter.d.ts.map +1 -1
- package/node_modules/baileys/lib/Socket/socket.d.ts.map +1 -1
- package/node_modules/baileys/lib/Socket/socket.js +3 -0
- package/node_modules/baileys/lib/Socket/socket.js.map +1 -1
- package/node_modules/baileys/lib/Types/index.d.ts +1 -0
- package/node_modules/baileys/lib/Types/index.d.ts.map +1 -1
- package/node_modules/baileys/lib/Types/index.js.map +1 -1
- package/node_modules/baileys/lib/Utils/browser-utils.d.ts.map +1 -1
- package/node_modules/baileys/lib/Utils/browser-utils.js +1 -0
- package/node_modules/baileys/lib/Utils/browser-utils.js.map +1 -1
- package/node_modules/baileys/lib/Utils/generics.d.ts +1 -0
- package/node_modules/baileys/lib/Utils/generics.d.ts.map +1 -1
- package/node_modules/baileys/lib/Utils/generics.js +1 -1
- package/node_modules/baileys/lib/Utils/generics.js.map +1 -1
- package/node_modules/baileys/lib/Utils/tc-token-utils.d.ts.map +1 -1
- package/node_modules/baileys/lib/Utils/tc-token-utils.js +3 -2
- package/node_modules/baileys/lib/Utils/tc-token-utils.js.map +1 -1
- package/node_modules/baileys/lib/Utils/validate-connection.d.ts.map +1 -1
- package/node_modules/baileys/lib/Utils/validate-connection.js +9 -2
- package/node_modules/baileys/lib/Utils/validate-connection.js.map +1 -1
- package/node_modules/baileys/node_modules/content-type/README.md +2 -0
- package/node_modules/baileys/node_modules/content-type/dist/index.d.ts +20 -0
- package/node_modules/baileys/node_modules/content-type/dist/index.js +20 -14
- package/node_modules/baileys/node_modules/content-type/dist/index.js.map +1 -1
- package/node_modules/baileys/node_modules/content-type/package.json +1 -1
- package/node_modules/baileys/node_modules/file-type/package.json +1 -1
- package/node_modules/baileys/node_modules/file-type/readme.md +3 -0
- package/node_modules/baileys/node_modules/file-type/source/detectors/zip.js +6 -1
- package/node_modules/baileys/node_modules/file-type/source/index.d.ts +3 -0
- package/node_modules/baileys/node_modules/file-type/source/index.js +25 -13
- package/node_modules/baileys/node_modules/music-metadata/LICENSE.txt +9 -9
- package/node_modules/baileys/node_modules/music-metadata/README.md +878 -878
- package/node_modules/baileys/node_modules/music-metadata/lib/ParseError.d.ts +1 -1
- package/node_modules/baileys/node_modules/music-metadata/lib/ParseError.js +1 -1
- package/node_modules/baileys/node_modules/music-metadata/lib/asf/AsfObject.d.ts +1 -4
- package/node_modules/baileys/node_modules/music-metadata/lib/asf/AsfObject.js +66 -30
- package/node_modules/baileys/node_modules/music-metadata/lib/asf/AsfParser.d.ts +5 -1
- package/node_modules/baileys/node_modules/music-metadata/lib/asf/AsfParser.js +94 -25
- package/node_modules/baileys/node_modules/music-metadata/lib/dsf/DsfChunk.js +2 -2
- package/node_modules/baileys/node_modules/music-metadata/lib/dsf/DsfParser.js +38 -13
- package/node_modules/baileys/node_modules/music-metadata/lib/mp4/AtomToken.js +2 -1
- package/node_modules/baileys/node_modules/music-metadata/lib/mp4/MP4Parser.js +34 -7
- package/node_modules/baileys/node_modules/music-metadata/lib/ogg/speex/SpeexStream.d.ts +7 -0
- package/node_modules/baileys/node_modules/music-metadata/lib/ogg/speex/SpeexStream.js +13 -0
- package/node_modules/baileys/node_modules/music-metadata/lib/riff/RiffChunk.js +1 -1
- package/node_modules/baileys/node_modules/music-metadata/package.json +156 -156
- package/node_modules/baileys/node_modules/process-warning/.github/dependabot.yml +42 -2
- package/node_modules/baileys/node_modules/process-warning/.github/workflows/ci.yml +12 -1
- package/node_modules/baileys/node_modules/process-warning/.github/workflows/lock-threads.yml +19 -0
- package/node_modules/baileys/node_modules/process-warning/LICENSE +1 -1
- package/node_modules/baileys/node_modules/process-warning/README.md +41 -2
- package/node_modules/baileys/node_modules/process-warning/index.js +85 -17
- package/node_modules/baileys/node_modules/process-warning/package.json +6 -7
- package/node_modules/baileys/node_modules/process-warning/test/emit-once-only.test.js +3 -3
- package/node_modules/baileys/node_modules/process-warning/test/emit-reset.test.js +4 -4
- package/node_modules/baileys/node_modules/process-warning/test/emit-unlimited.test.js +2 -2
- package/node_modules/baileys/node_modules/process-warning/test/spy-warning.test.js +143 -0
- package/node_modules/baileys/node_modules/process-warning/types/index.d.ts +15 -1
- package/node_modules/baileys/node_modules/process-warning/types/index.tst.ts +48 -0
- package/node_modules/baileys/node_modules/protobufjs/README.md +61 -84
- package/node_modules/baileys/node_modules/protobufjs/dist/light/protobuf.js +66 -45
- package/node_modules/baileys/node_modules/protobufjs/dist/light/protobuf.js.map +1 -1
- package/node_modules/baileys/node_modules/protobufjs/dist/light/protobuf.min.js +3 -3
- package/node_modules/baileys/node_modules/protobufjs/dist/light/protobuf.min.js.map +1 -1
- package/node_modules/baileys/node_modules/protobufjs/dist/minimal/protobuf.js +47 -40
- package/node_modules/baileys/node_modules/protobufjs/dist/minimal/protobuf.js.map +1 -1
- package/node_modules/baileys/node_modules/protobufjs/dist/minimal/protobuf.min.js +3 -3
- package/node_modules/baileys/node_modules/protobufjs/dist/minimal/protobuf.min.js.map +1 -1
- package/node_modules/baileys/node_modules/protobufjs/dist/protobuf.js +92 -68
- package/node_modules/baileys/node_modules/protobufjs/dist/protobuf.js.map +1 -1
- package/node_modules/baileys/node_modules/protobufjs/dist/protobuf.min.js +3 -3
- package/node_modules/baileys/node_modules/protobufjs/dist/protobuf.min.js.map +1 -1
- package/node_modules/baileys/node_modules/protobufjs/ext/descriptor.js +26 -10
- package/node_modules/baileys/node_modules/protobufjs/index.d.ts +3 -0
- package/node_modules/baileys/node_modules/protobufjs/package.json +1 -1
- package/node_modules/baileys/node_modules/protobufjs/src/converter.js +5 -1
- package/node_modules/baileys/node_modules/protobufjs/src/enum.js +5 -2
- package/node_modules/baileys/node_modules/protobufjs/src/field.js +6 -1
- package/node_modules/baileys/node_modules/protobufjs/src/parse.js +26 -23
- package/node_modules/baileys/node_modules/protobufjs/src/reader.js +36 -9
- package/node_modules/baileys/node_modules/protobufjs/src/util/codegen.js +3 -1
- package/node_modules/baileys/node_modules/protobufjs/src/util/utf8.js +2 -28
- package/node_modules/baileys/node_modules/protobufjs/src/writer.js +7 -1
- package/node_modules/baileys/node_modules/ws/lib/permessage-deflate.js +3 -1
- package/node_modules/baileys/node_modules/ws/package.json +1 -1
- package/node_modules/baileys/package.json +1 -1
- package/node_modules/typebox/build/format/date.d.mts +1 -1
- package/node_modules/typebox/build/format/date.mjs +1 -1
- package/node_modules/typebox/build/format/date_time.d.mts +2 -2
- package/node_modules/typebox/build/format/date_time.mjs +3 -3
- package/node_modules/typebox/build/format/email.d.mts +1 -1
- package/node_modules/typebox/build/format/email.mjs +2 -2
- package/node_modules/typebox/build/format/hostname.mjs +2 -10
- package/node_modules/typebox/build/format/idn_email.d.mts +1 -1
- package/node_modules/typebox/build/format/idn_email.mjs +3 -3
- package/node_modules/typebox/build/format/idn_hostname.d.mts +1 -0
- package/node_modules/typebox/build/format/idn_hostname.mjs +3 -11
- package/node_modules/typebox/build/format/idna/format/bidi.d.mts +3 -0
- package/node_modules/typebox/build/format/idna/format/bidi.mjs +98 -0
- package/node_modules/typebox/build/format/idna/format/puny.d.mts +3 -0
- package/node_modules/typebox/build/format/idna/format/puny.mjs +144 -0
- package/node_modules/typebox/build/format/idna/hostname.d.mts +1 -0
- package/node_modules/typebox/build/format/idna/hostname.mjs +16 -0
- package/node_modules/typebox/build/format/idna/idn-hostname.d.mts +1 -0
- package/node_modules/typebox/build/format/idna/idn-hostname.mjs +41 -0
- package/node_modules/typebox/build/format/idna/index.d.mts +2 -0
- package/node_modules/typebox/build/format/idna/index.mjs +2 -0
- package/node_modules/typebox/build/format/idna/label/ascii.d.mts +1 -0
- package/node_modules/typebox/build/format/idna/label/ascii.mjs +9 -0
- package/node_modules/typebox/build/format/idna/label/puny.d.mts +1 -0
- package/node_modules/typebox/build/format/idna/label/puny.mjs +28 -0
- package/node_modules/typebox/build/format/idna/label/unicode.d.mts +1 -0
- package/node_modules/typebox/build/format/idna/label/unicode.mjs +106 -0
- package/node_modules/typebox/build/format/idna/pattern/pattern.d.mts +30 -0
- package/node_modules/typebox/build/format/idna/pattern/pattern.mjs +70 -0
- package/node_modules/typebox/build/format/ipv4.d.mts +0 -1
- package/node_modules/typebox/build/format/ipv4.mjs +2 -32
- package/node_modules/typebox/build/format/ipv6.mjs +2 -61
- package/node_modules/typebox/build/format/iri.d.mts +2 -2
- package/node_modules/typebox/build/format/iri.mjs +26 -8
- package/node_modules/typebox/build/format/iri_reference.d.mts +2 -2
- package/node_modules/typebox/build/format/iri_reference.mjs +9 -55
- package/node_modules/typebox/build/format/regex.d.mts +1 -2
- package/node_modules/typebox/build/format/regex.mjs +2 -6
- package/node_modules/typebox/build/format/time.d.mts +2 -2
- package/node_modules/typebox/build/format/time.mjs +19 -14
- package/node_modules/typebox/build/format/uri.d.mts +1 -1
- package/node_modules/typebox/build/format/uri.mjs +3 -130
- package/node_modules/typebox/build/format/uri_reference.d.mts +1 -1
- package/node_modules/typebox/build/format/uri_reference.mjs +2 -3
- package/node_modules/typebox/build/format/uri_template.d.mts +2 -3
- package/node_modules/typebox/build/format/uri_template.mjs +4 -5
- package/node_modules/typebox/build/format/url.d.mts +3 -3
- package/node_modules/typebox/build/format/url.mjs +4 -5
- package/node_modules/typebox/build/guard/emit.d.mts +3 -1
- package/node_modules/typebox/build/guard/emit.mjs +12 -5
- package/node_modules/typebox/build/guard/guard.d.mts +8 -2
- package/node_modules/typebox/build/guard/guard.mjs +25 -4
- package/node_modules/typebox/build/guard/string.d.mts +2 -2
- package/node_modules/typebox/build/guard/string.mjs +7 -7
- package/node_modules/typebox/build/schema/engine/_context.mjs +3 -3
- package/node_modules/typebox/build/schema/engine/_functions.mjs +1 -2
- package/node_modules/typebox/build/schema/engine/_regexp.d.mts +2 -0
- package/node_modules/typebox/build/schema/engine/_regexp.mjs +4 -0
- package/node_modules/typebox/build/schema/engine/_stack.mjs +12 -13
- package/node_modules/typebox/build/schema/engine/additionalItems.mjs +17 -7
- package/node_modules/typebox/build/schema/engine/additionalProperties.mjs +4 -3
- package/node_modules/typebox/build/schema/engine/contains.mjs +18 -6
- package/node_modules/typebox/build/schema/engine/enum.mjs +1 -1
- package/node_modules/typebox/build/schema/engine/items.mjs +26 -6
- package/node_modules/typebox/build/schema/engine/maxContains.mjs +3 -3
- package/node_modules/typebox/build/schema/engine/minContains.mjs +14 -4
- package/node_modules/typebox/build/schema/engine/not.mjs +4 -2
- package/node_modules/typebox/build/schema/engine/oneOf.mjs +7 -6
- package/node_modules/typebox/build/schema/engine/pattern.mjs +3 -2
- package/node_modules/typebox/build/schema/engine/patternProperties.mjs +4 -3
- package/node_modules/typebox/build/schema/engine/ref.mjs +1 -7
- package/node_modules/typebox/build/schema/engine/schema.mjs +13 -4
- package/node_modules/typebox/build/schema/engine/type.mjs +1 -1
- package/node_modules/typebox/build/schema/resolve/resolve.d.mts +4 -1
- package/node_modules/typebox/build/schema/resolve/resolve.mjs +202 -1
- package/node_modules/typebox/build/schema/static/propertyNames.d.mts +5 -0
- package/node_modules/typebox/build/schema/static/propertyNames.mjs +3 -0
- package/node_modules/typebox/build/schema/static/schema.d.mts +3 -0
- package/node_modules/typebox/build/schema/types/index.d.mts +0 -2
- package/node_modules/typebox/build/schema/types/index.mjs +0 -2
- package/node_modules/typebox/build/system/memory/clone.mjs +14 -11
- package/node_modules/typebox/build/system/memory/discard.mjs +6 -5
- package/node_modules/typebox/build/system/settings/settings.d.mts +9 -0
- package/node_modules/typebox/build/system/settings/settings.mjs +2 -0
- package/node_modules/typebox/build/type/engine/call/distribute_arguments.d.mts +6 -1
- package/node_modules/typebox/build/type/engine/call/distribute_arguments.mjs +16 -3
- package/node_modules/typebox/build/type/engine/call/instantiate.mjs +34 -4
- package/node_modules/typebox/build/type/engine/evaluate/broaden.d.mts +5 -5
- package/node_modules/typebox/build/type/engine/evaluate/broaden.mjs +20 -26
- package/node_modules/typebox/build/type/engine/evaluate/compare.d.mts +6 -10
- package/node_modules/typebox/build/type/engine/evaluate/compare.mjs +9 -13
- package/node_modules/typebox/build/type/engine/evaluate/composite.d.mts +7 -4
- package/node_modules/typebox/build/type/engine/evaluate/composite.mjs +12 -19
- package/node_modules/typebox/build/type/engine/evaluate/distribute.d.mts +4 -20
- package/node_modules/typebox/build/type/engine/evaluate/distribute.mjs +8 -20
- package/node_modules/typebox/build/type/engine/evaluate/evaluate.d.mts +4 -4
- package/node_modules/typebox/build/type/engine/evaluate/evaluate.mjs +11 -8
- package/node_modules/typebox/build/type/engine/evaluate/flatten.d.mts +1 -1
- package/node_modules/typebox/build/type/engine/evaluate/flatten.mjs +3 -4
- package/node_modules/typebox/build/type/engine/evaluate/narrow.d.mts +17 -2
- package/node_modules/typebox/build/type/engine/evaluate/narrow.mjs +26 -6
- package/node_modules/typebox/build/type/engine/exclude/operation.mjs +3 -4
- package/node_modules/typebox/build/type/engine/extract/operation.d.mts +1 -1
- package/node_modules/typebox/build/type/engine/extract/operation.mjs +3 -4
- package/node_modules/typebox/build/type/engine/priority/priority.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/priority/priority.mjs +3 -4
- package/node_modules/typebox/build/type/script/mapping.d.mts +32 -29
- package/node_modules/typebox/build/type/script/mapping.mjs +18 -25
- package/node_modules/typebox/build/type/script/parser.d.mts +19 -25
- package/node_modules/typebox/build/type/script/parser.mjs +27 -23
- package/node_modules/typebox/build/value/errors/errors.d.mts +2 -2
- package/node_modules/typebox/build/value/errors/errors.mjs +1 -1
- package/node_modules/typebox/package.json +27 -27
- package/node_modules/typebox/readme.md +79 -82
- package/openclaw.plugin.json +2 -1
- package/package.json +6 -6
- package/node_modules/baileys/node_modules/process-warning/types/index.test-d.ts +0 -36
- package/node_modules/typebox/build/format/_idna.d.mts +0 -2
- package/node_modules/typebox/build/format/_idna.mjs +0 -246
- package/node_modules/typebox/build/format/_puny.d.mts +0 -1
- package/node_modules/typebox/build/format/_puny.mjs +0 -77
- package/node_modules/typebox/build/schema/resolve/ref.d.mts +0 -3
- package/node_modules/typebox/build/schema/resolve/ref.mjs +0 -146
- package/node_modules/typebox/build/schema/types/contentEncoding.d.mts +0 -9
- package/node_modules/typebox/build/schema/types/contentEncoding.mjs +0 -13
- package/node_modules/typebox/build/schema/types/contentMediaType.d.mts +0 -9
- package/node_modules/typebox/build/schema/types/contentMediaType.mjs +0 -13
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import * as Pattern from '../pattern/pattern.mjs';
|
|
2
|
+
// ------------------------------------------------------------------
|
|
3
|
+
// PunyCode (RFC 3492)
|
|
4
|
+
// ------------------------------------------------------------------
|
|
5
|
+
const PUNYCODE_BASE = 36;
|
|
6
|
+
const PUNYCODE_TMIN = 1;
|
|
7
|
+
const PUNYCODE_TMAX = 26;
|
|
8
|
+
const PUNYCODE_SKEW = 38;
|
|
9
|
+
const PUNYCODE_DAMP = 700;
|
|
10
|
+
const PUNYCODE_INITIAL_BIAS = 72;
|
|
11
|
+
const PUNYCODE_INITIAL_N = 128;
|
|
12
|
+
// ------------------------------------------------------------------
|
|
13
|
+
// ThrowDontCare
|
|
14
|
+
// ------------------------------------------------------------------
|
|
15
|
+
function ThrowDontCare() {
|
|
16
|
+
throw null;
|
|
17
|
+
}
|
|
18
|
+
// ------------------------------------------------------------------
|
|
19
|
+
// IsAcePrefixed
|
|
20
|
+
// ------------------------------------------------------------------
|
|
21
|
+
export function IsAcePrefixed(value) {
|
|
22
|
+
return value.toLowerCase().startsWith('xn--');
|
|
23
|
+
}
|
|
24
|
+
// ------------------------------------------------------------------
|
|
25
|
+
// Adapt
|
|
26
|
+
// ------------------------------------------------------------------
|
|
27
|
+
function Adapt(delta, numPoints, firstTime) {
|
|
28
|
+
delta = firstTime ? Math.floor(delta / PUNYCODE_DAMP) : delta >> 1;
|
|
29
|
+
delta += Math.floor(delta / numPoints);
|
|
30
|
+
let k = 0;
|
|
31
|
+
while (delta > (((PUNYCODE_BASE - PUNYCODE_TMIN) * PUNYCODE_TMAX) >> 1)) {
|
|
32
|
+
delta = Math.floor(delta / (PUNYCODE_BASE - PUNYCODE_TMIN));
|
|
33
|
+
k += PUNYCODE_BASE;
|
|
34
|
+
}
|
|
35
|
+
return k + Math.floor(((PUNYCODE_BASE - PUNYCODE_TMIN + 1) * delta) / (delta + PUNYCODE_SKEW));
|
|
36
|
+
}
|
|
37
|
+
// ------------------------------------------------------------------
|
|
38
|
+
// Decode
|
|
39
|
+
// ------------------------------------------------------------------
|
|
40
|
+
export function Decode(value) {
|
|
41
|
+
const output = [];
|
|
42
|
+
let n = PUNYCODE_INITIAL_N;
|
|
43
|
+
let i = 0;
|
|
44
|
+
let bias = PUNYCODE_INITIAL_BIAS;
|
|
45
|
+
const delimIdx = value.lastIndexOf('-');
|
|
46
|
+
if (delimIdx > 0) {
|
|
47
|
+
for (let j = 0; j < delimIdx; j++) {
|
|
48
|
+
const cp = value.charCodeAt(j);
|
|
49
|
+
if (cp >= 128)
|
|
50
|
+
ThrowDontCare(); // throw new Error('Invalid punycode: non-basic before delimiter')
|
|
51
|
+
output.push(cp);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
let inIdx = delimIdx < 0 ? 0 : delimIdx + 1;
|
|
55
|
+
while (inIdx < value.length) {
|
|
56
|
+
const oldi = i;
|
|
57
|
+
let w = 1;
|
|
58
|
+
let k = PUNYCODE_BASE;
|
|
59
|
+
while (true) {
|
|
60
|
+
if (inIdx >= value.length)
|
|
61
|
+
ThrowDontCare(); // throw new Error('Invalid punycode: unexpected end of input')
|
|
62
|
+
const ch = value.charCodeAt(inIdx++);
|
|
63
|
+
let digit;
|
|
64
|
+
if (ch >= 0x61 && ch <= 0x7a)
|
|
65
|
+
digit = ch - 0x61; // a-z => 0-25
|
|
66
|
+
else if (ch >= 0x30 && ch <= 0x39)
|
|
67
|
+
digit = ch - 0x30 + 26; // 0-9 => 26-35
|
|
68
|
+
// else if (ch >= 0x41 && ch <= 0x5a) digit = ch - 0x41 // A-Z => 0-25 // (no-spec-coverage)
|
|
69
|
+
else
|
|
70
|
+
ThrowDontCare(); // throw new Error('Invalid punycode: bad digit character')
|
|
71
|
+
i += digit * w;
|
|
72
|
+
const t = k <= bias ? PUNYCODE_TMIN : k >= bias + PUNYCODE_TMAX ? PUNYCODE_TMAX : k - bias;
|
|
73
|
+
if (digit < t)
|
|
74
|
+
break;
|
|
75
|
+
w *= PUNYCODE_BASE - t;
|
|
76
|
+
k += PUNYCODE_BASE;
|
|
77
|
+
}
|
|
78
|
+
const outLen = output.length + 1;
|
|
79
|
+
bias = Adapt(i - oldi, outLen, oldi === 0);
|
|
80
|
+
n += Math.floor(i / outLen);
|
|
81
|
+
i %= outLen;
|
|
82
|
+
output.splice(i, 0, n);
|
|
83
|
+
i++;
|
|
84
|
+
}
|
|
85
|
+
return String.fromCodePoint(...output);
|
|
86
|
+
}
|
|
87
|
+
// ------------------------------------------------------------------
|
|
88
|
+
// DigitToChar
|
|
89
|
+
// ------------------------------------------------------------------
|
|
90
|
+
function DigitToChar(digit) {
|
|
91
|
+
return digit < 26 ? String.fromCharCode(digit + 0x61) : String.fromCharCode(digit - 26 + 0x30);
|
|
92
|
+
}
|
|
93
|
+
// ------------------------------------------------------------------
|
|
94
|
+
// Encode
|
|
95
|
+
//
|
|
96
|
+
// Encodes a Unicode string into its Punycode payload (the part that
|
|
97
|
+
// follows the 'xn--' ACE prefix). Used to compute the true A-label
|
|
98
|
+
// length of a U-label, since the 63-octet label length limit (RFC
|
|
99
|
+
// 5891 §4.2.4) applies to the encoded form, not the code point count.
|
|
100
|
+
// ------------------------------------------------------------------
|
|
101
|
+
const RE_REPLACE_NON_ASCII = new RegExp(Pattern.RE_NON_ASCII.source, 'gu');
|
|
102
|
+
export function Encode(input) {
|
|
103
|
+
// Extract basic ASCII characters and set initial output array state
|
|
104
|
+
const basic = input.replace(RE_REPLACE_NON_ASCII, '');
|
|
105
|
+
const basicLength = basic.length;
|
|
106
|
+
const result = basicLength > 0 ? [basic, '-'] : [];
|
|
107
|
+
// Extract unicode codepoints
|
|
108
|
+
const codePoints = Array.from(input, (char) => char.codePointAt(0));
|
|
109
|
+
let n = PUNYCODE_INITIAL_N;
|
|
110
|
+
let delta = 0;
|
|
111
|
+
let bias = PUNYCODE_INITIAL_BIAS;
|
|
112
|
+
let handledCPCount = basicLength;
|
|
113
|
+
while (handledCPCount < codePoints.length) {
|
|
114
|
+
let m = Infinity;
|
|
115
|
+
for (const cp of codePoints) {
|
|
116
|
+
if (cp >= n && cp < m)
|
|
117
|
+
m = cp;
|
|
118
|
+
}
|
|
119
|
+
delta += (m - n) * (handledCPCount + 1);
|
|
120
|
+
n = m;
|
|
121
|
+
for (const cp of codePoints) {
|
|
122
|
+
if (cp < n)
|
|
123
|
+
delta++;
|
|
124
|
+
if (cp === n) {
|
|
125
|
+
let q = delta;
|
|
126
|
+
for (let k = PUNYCODE_BASE;; k += PUNYCODE_BASE) {
|
|
127
|
+
const t = k <= bias ? PUNYCODE_TMIN : k >= bias + PUNYCODE_TMAX ? PUNYCODE_TMAX : k - bias;
|
|
128
|
+
if (q < t)
|
|
129
|
+
break;
|
|
130
|
+
const digit = t + ((q - t) % (PUNYCODE_BASE - t));
|
|
131
|
+
result.push(DigitToChar(digit));
|
|
132
|
+
q = Math.floor((q - t) / (PUNYCODE_BASE - t));
|
|
133
|
+
}
|
|
134
|
+
result.push(DigitToChar(q));
|
|
135
|
+
bias = Adapt(delta, handledCPCount + 1, handledCPCount === basicLength);
|
|
136
|
+
delta = 0;
|
|
137
|
+
handledCPCount++;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
delta++;
|
|
141
|
+
n++;
|
|
142
|
+
}
|
|
143
|
+
return result.join('');
|
|
144
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function IsHostname(value: string): boolean;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as LabelAscii from './label/ascii.mjs';
|
|
2
|
+
import * as LabelPuny from './label/puny.mjs';
|
|
3
|
+
function IsValidLabelLength(value) {
|
|
4
|
+
return value.length > 0 && value.length <= 63;
|
|
5
|
+
}
|
|
6
|
+
function IsLabel(value) {
|
|
7
|
+
return IsValidLabelLength(value) && (LabelPuny.IsPunyLabel(value) ||
|
|
8
|
+
LabelAscii.IsAsciiLabel(value));
|
|
9
|
+
}
|
|
10
|
+
export function IsHostname(value) {
|
|
11
|
+
if (value.length === 0 || value.length > 253)
|
|
12
|
+
return false;
|
|
13
|
+
if (value.charCodeAt(value.length - 1) === 46)
|
|
14
|
+
return false;
|
|
15
|
+
return value.split('.').every((label) => IsLabel(label));
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function IsIdnHostname(value: string): boolean;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import * as FormatBidi from './format/bidi.mjs';
|
|
2
|
+
import * as LabelUnicode from './label/unicode.mjs';
|
|
3
|
+
import * as LabelPuny from './label/puny.mjs';
|
|
4
|
+
// ------------------------------------------------------------------
|
|
5
|
+
// IsLabel
|
|
6
|
+
// ------------------------------------------------------------------
|
|
7
|
+
function IsValidLabelLength(value) {
|
|
8
|
+
return value.length > 0 && value.length <= 63;
|
|
9
|
+
}
|
|
10
|
+
function IsLabel(value) {
|
|
11
|
+
return IsValidLabelLength(value) && (LabelPuny.IsPunyLabel(value) ||
|
|
12
|
+
LabelUnicode.IsUnicodeLabel(value));
|
|
13
|
+
}
|
|
14
|
+
// ------------------------------------------------------------------
|
|
15
|
+
// NormalizeHostname
|
|
16
|
+
//
|
|
17
|
+
// Normalizes a hostname for label validation. Normalizes for NFC
|
|
18
|
+
// such that equivalent codepoint sequences can be uniformly
|
|
19
|
+
// compared. It also removes codepoints that IDNA mapping ignores,
|
|
20
|
+
// and converts full stop variants to ASCII '.' so the hostname can
|
|
21
|
+
// be split into labels.
|
|
22
|
+
// ------------------------------------------------------------------
|
|
23
|
+
function NormalizeHostname(value) {
|
|
24
|
+
return value
|
|
25
|
+
.normalize('NFC')
|
|
26
|
+
.replace(/[\u00ad\u034f\u180b-\u180d\u200b\ufe00-\ufe0f\u{e0100}-\u{e01ef}]/gu, '') // RE_IGNORED_MAPPING
|
|
27
|
+
.replace(/[\u002E\u3002\uFF0E\uFF61]/g, '.'); // RE_FULL_STOP_MAPPING
|
|
28
|
+
}
|
|
29
|
+
// ------------------------------------------------------------------
|
|
30
|
+
// IsIdnHostname
|
|
31
|
+
// ------------------------------------------------------------------
|
|
32
|
+
export function IsIdnHostname(value) {
|
|
33
|
+
if (value.length === 0 || value.includes(' '))
|
|
34
|
+
return false;
|
|
35
|
+
const normalized = NormalizeHostname(value);
|
|
36
|
+
if (normalized.length > 253)
|
|
37
|
+
return false;
|
|
38
|
+
const labels = normalized.split('.');
|
|
39
|
+
const hasBidiChars = labels.some((label) => FormatBidi.HasBidiChars(label));
|
|
40
|
+
return labels.every((label) => IsLabel(label) && (!hasBidiChars || FormatBidi.SatisfiesBidiRule(label)));
|
|
41
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function IsAsciiLabel(value: string): boolean;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as Pattern from '../pattern/pattern.mjs';
|
|
2
|
+
// -------------------------------------------------------------------
|
|
3
|
+
// Validates an ASCII LDH label per RFC 5891 §4.2.3.1
|
|
4
|
+
// -------------------------------------------------------------------
|
|
5
|
+
export function IsAsciiLabel(value) {
|
|
6
|
+
return (Pattern.RE_RULE_HYPHEN_PLACEMENT.test(value) &&
|
|
7
|
+
Pattern.RE_RULE_NOT_RESERVED_ACE.test(value) &&
|
|
8
|
+
Pattern.RE_ASCII_LDH.test(value));
|
|
9
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function IsPunyLabel(value: string): boolean;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import * as FormatPuny from '../format/puny.mjs';
|
|
2
|
+
import * as LabelUnicode from './unicode.mjs';
|
|
3
|
+
import * as Pattern from '../pattern/pattern.mjs';
|
|
4
|
+
// ------------------------------------------------------------------
|
|
5
|
+
// IsPunyLabel
|
|
6
|
+
// ------------------------------------------------------------------
|
|
7
|
+
export function IsPunyLabel(value) {
|
|
8
|
+
if (!FormatPuny.IsAcePrefixed(value))
|
|
9
|
+
return false;
|
|
10
|
+
try {
|
|
11
|
+
const body = value.slice(4).toLowerCase();
|
|
12
|
+
// A payload consisting of only a hyphen, or starting with the delimiter
|
|
13
|
+
// (like "-9uc"), has 0 basic ASCII characters preceding it and is malformed.
|
|
14
|
+
if (body.lastIndexOf('-') === 0)
|
|
15
|
+
return false;
|
|
16
|
+
const decoded = FormatPuny.Decode(body);
|
|
17
|
+
// RFC 5890 §2.3.2.1 - a U-label must contain at least one non-ASCII
|
|
18
|
+
// character. Code-unit level check: any non-ASCII codepoint has at least
|
|
19
|
+
// one UTF-16 unit >= 0x80 (surrogate halves included), so no need to
|
|
20
|
+
// decode codepoints or allocate a character array to answer this.
|
|
21
|
+
if (!Pattern.RE_NON_ASCII.test(decoded))
|
|
22
|
+
return false;
|
|
23
|
+
return LabelUnicode.IsUnicodeLabel(decoded);
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function IsUnicodeLabel(value: string): boolean;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import * as Pattern from '../pattern/pattern.mjs';
|
|
2
|
+
import * as FormatBidi from '../format/bidi.mjs';
|
|
3
|
+
import * as FormatPuny from '../format/puny.mjs';
|
|
4
|
+
// ------------------------------------------------------------------
|
|
5
|
+
// ExceedsMaxALabelLength
|
|
6
|
+
//
|
|
7
|
+
// RFC 5890 §2.3.2.1: an A-label (the ACE-encoded form of a label,
|
|
8
|
+
// "xn--" + punycode) must not exceed 63 octets. Only labels
|
|
9
|
+
// containing non-ASCII characters need checking - a pure-ASCII label
|
|
10
|
+
// has no "xn--" prefix and is used as-is, so its punycode-encoded
|
|
11
|
+
// length is irrelevant. The ASCII check is a cheap short-circuit that
|
|
12
|
+
// avoids running the punycode encoder on labels that don't need it.
|
|
13
|
+
// ------------------------------------------------------------------
|
|
14
|
+
function ExceedsMaxALabelLength(value) {
|
|
15
|
+
return Pattern.RE_NON_ASCII.test(value) && FormatPuny.Encode(value).length + 4 > 63;
|
|
16
|
+
}
|
|
17
|
+
// ------------------------------------------------------------------
|
|
18
|
+
// HasInvalidHyphens
|
|
19
|
+
//
|
|
20
|
+
// RFC 5891 §4.2.3.2: label must not start or end with a hyphen, and
|
|
21
|
+
// must not have hyphens in the 3rd and 4th codepoint positions (the
|
|
22
|
+
// ACE prefix reservation, e.g. "xn--"). Operates on `chars` (the
|
|
23
|
+
// per-codepoint string array) rather than raw string indices so
|
|
24
|
+
// supplementary-plane characters earlier in the label don't throw
|
|
25
|
+
// off the codepoint-position count.
|
|
26
|
+
// ------------------------------------------------------------------
|
|
27
|
+
function HasInvalidHyphens(chars) {
|
|
28
|
+
if (chars[0] === '-' || chars[chars.length - 1] === '-')
|
|
29
|
+
return true;
|
|
30
|
+
return chars.slice(2).join('').startsWith('--');
|
|
31
|
+
}
|
|
32
|
+
// ------------------------------------------------------------------
|
|
33
|
+
// IsUnicodeLabel
|
|
34
|
+
// ------------------------------------------------------------------
|
|
35
|
+
export function IsUnicodeLabel(value) {
|
|
36
|
+
// RFC 5890 §2.3.2.1: Ensure Max Length
|
|
37
|
+
if (ExceedsMaxALabelLength(value))
|
|
38
|
+
return false;
|
|
39
|
+
// RFC 5893 - Bidi Rule (applies whenever this label itself is RTL)
|
|
40
|
+
if (FormatBidi.HasRightToLeftCharacters(value) && !FormatBidi.SatisfiesBidiRule(value))
|
|
41
|
+
return false;
|
|
42
|
+
const chars = [...value];
|
|
43
|
+
const codePoints = chars.map((c) => c.codePointAt(0));
|
|
44
|
+
const length = codePoints.length;
|
|
45
|
+
// RFC 5891 §4.2.3.2: Hyphen rules
|
|
46
|
+
if (HasInvalidHyphens(chars))
|
|
47
|
+
return false;
|
|
48
|
+
// RFC 5891 §4.2.3.2 - Must not begin with a combining mark
|
|
49
|
+
if (Pattern.RE_COMBINING_MARK.test(chars[0]))
|
|
50
|
+
return false;
|
|
51
|
+
let hasJapanese = false;
|
|
52
|
+
// let hasArabicIndic = false // (no-spec-coverage)
|
|
53
|
+
// let hasExtendedArabicIndic = false // (no-spec-coverage)
|
|
54
|
+
for (let i = 0; i < length; i++) {
|
|
55
|
+
const codePoint = codePoints[i];
|
|
56
|
+
const char = chars[i];
|
|
57
|
+
// 1. DISALLOWED exceptions
|
|
58
|
+
if (Pattern.RE_RFC5892_DISALLOWED.test(char))
|
|
59
|
+
return false;
|
|
60
|
+
// 1b. General category (PVALID) enforcement
|
|
61
|
+
if (!Pattern.RE_PERMITTED_CATEGORY.test(char))
|
|
62
|
+
return false;
|
|
63
|
+
// 2. Collect Flags
|
|
64
|
+
if (Pattern.RE_SCRIPT_JAPANESE.test(char))
|
|
65
|
+
hasJapanese = true;
|
|
66
|
+
// if (Pattern.RE_ARABIC_INDIC_DIGIT.test(char)) hasArabicIndic = true // (no-spec-coverage)
|
|
67
|
+
// if (Pattern.RE_EXT_ARABIC_INDIC_DIGIT.test(char)) hasExtendedArabicIndic = true // (no-spec-coverage)
|
|
68
|
+
// 3. CONTEXTO / CONTEXTJ Neighbor Rules
|
|
69
|
+
const prev = codePoints[i - 1], next = codePoints[i + 1];
|
|
70
|
+
switch (codePoint) {
|
|
71
|
+
case 0x00b7:
|
|
72
|
+
if (prev !== 0x006c || next !== 0x006c)
|
|
73
|
+
return false;
|
|
74
|
+
break; // MIDDLE DOT (Catalan)
|
|
75
|
+
case 0x0375:
|
|
76
|
+
if (!next || !Pattern.RE_SCRIPT_GREEK.test(chars[i + 1]))
|
|
77
|
+
return false;
|
|
78
|
+
break; // Greek KERAIA
|
|
79
|
+
case 0x05f3:
|
|
80
|
+
case 0x05f4:
|
|
81
|
+
if (!prev || !Pattern.RE_SCRIPT_HEBREW.test(chars[i - 1]))
|
|
82
|
+
return false;
|
|
83
|
+
break; // Hebrew GERESH
|
|
84
|
+
case 0x200c: // ZWNJ - RFC 5892 Appendix A.1
|
|
85
|
+
// Note: Full validation requires a Unicode joining type table. We reject
|
|
86
|
+
// only when preceded by ASCII (U+0000-U+007F), which can never satisfy
|
|
87
|
+
// the Virama or cursive-joining rules.
|
|
88
|
+
if (!prev || (prev < 0x0080 && !Pattern.RE_VIRAMA.test(chars[i - 1])))
|
|
89
|
+
return false;
|
|
90
|
+
break;
|
|
91
|
+
case 0x200d: // ZWJ: RFC 5892 Appendix A.2
|
|
92
|
+
if (!prev || !Pattern.RE_VIRAMA.test(chars[i - 1]))
|
|
93
|
+
return false;
|
|
94
|
+
break;
|
|
95
|
+
case 0x30fb: // Checked at end via hasJapanese
|
|
96
|
+
break; // KATAKANA MIDDLE DOT
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
// 4. Global Context Validations (Post-loop)
|
|
100
|
+
// RFC 5892 Appendix A.7 - Katakana Middle Dot requirement
|
|
101
|
+
if (value.includes('\u30fb') && !hasJapanese)
|
|
102
|
+
return false;
|
|
103
|
+
// RFC 5892 Appendix A.8/A.9 - Mixing Arabic Digits
|
|
104
|
+
// if (hasArabicIndic && hasExtendedArabicIndic) return false // (no-spec-coverage)
|
|
105
|
+
return true;
|
|
106
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export declare const RE_RULE_HYPHEN_PLACEMENT: RegExp;
|
|
2
|
+
export declare const RE_RULE_NOT_RESERVED_ACE: RegExp;
|
|
3
|
+
export declare const RE_ASCII_LDH: RegExp;
|
|
4
|
+
export declare const RE_ASCII: RegExp;
|
|
5
|
+
export declare const RE_NON_ASCII: RegExp;
|
|
6
|
+
export declare const RE_HIGH_SURROGATE: RegExp;
|
|
7
|
+
export declare const RE_REGIONAL_INDICATOR: RegExp;
|
|
8
|
+
export declare const RE_VARIATION_SELECTOR: RegExp;
|
|
9
|
+
export declare const RE_ZERO_WIDTH_JOINER: RegExp;
|
|
10
|
+
export declare const RE_ASCII_DIGIT: RegExp;
|
|
11
|
+
export declare const RE_ARABIC_INDIC_DIGIT: RegExp;
|
|
12
|
+
export declare const RE_EXT_ARABIC_INDIC_DIGIT: RegExp;
|
|
13
|
+
export declare const RE_COMMON_SEPARATOR: RegExp;
|
|
14
|
+
export declare const RE_EUROPEAN_SEPARATOR: RegExp;
|
|
15
|
+
export declare const RE_MARK_NONSPACING: RegExp;
|
|
16
|
+
export declare const RE_MARK_SPACING_COMBINING: RegExp;
|
|
17
|
+
export declare const RE_MARK_ENCLOSING: RegExp;
|
|
18
|
+
export declare const RE_COMBINING_MARK: RegExp;
|
|
19
|
+
export declare const RE_LETTER: RegExp;
|
|
20
|
+
export declare const RE_NUMBER_DECIMAL: RegExp;
|
|
21
|
+
export declare const RE_SCRIPT_GREEK: RegExp;
|
|
22
|
+
export declare const RE_SCRIPT_HEBREW: RegExp;
|
|
23
|
+
export declare const RE_SCRIPT_JAPANESE: RegExp;
|
|
24
|
+
export declare const RE_SCRIPT_ARABIC_LETTER: RegExp;
|
|
25
|
+
export declare const RE_VIRAMA: RegExp;
|
|
26
|
+
export declare const RE_RFC5892_DISALLOWED: RegExp;
|
|
27
|
+
export declare const RE_CONTEXTO_EXCEPTIONS: RegExp;
|
|
28
|
+
export declare const RE_PVALID_EXCEPTIONS: RegExp;
|
|
29
|
+
export declare const RE_EUROPEAN_NUMBER: RegExp;
|
|
30
|
+
export declare const RE_PERMITTED_CATEGORY: RegExp;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// deno-fmt-ignore-file
|
|
2
|
+
// -------------------------------------------------------------------
|
|
3
|
+
// Validation Rules
|
|
4
|
+
// -------------------------------------------------------------------
|
|
5
|
+
export const RE_RULE_HYPHEN_PLACEMENT = /^(?!-).*(?<!-)$/;
|
|
6
|
+
export const RE_RULE_NOT_RESERVED_ACE = /^(?!..--)/;
|
|
7
|
+
export const RE_ASCII_LDH = /^[a-zA-Z0-9-]*$/;
|
|
8
|
+
// -------------------------------------------------------------------
|
|
9
|
+
// ASCII & Encoding
|
|
10
|
+
// -------------------------------------------------------------------
|
|
11
|
+
export const RE_ASCII = /^\p{ASCII}*$/u;
|
|
12
|
+
export const RE_NON_ASCII = /[^\p{ASCII}]/u;
|
|
13
|
+
// -------------------------------------------------------------------
|
|
14
|
+
// Structural & Unicode Controls
|
|
15
|
+
// -------------------------------------------------------------------
|
|
16
|
+
export const RE_HIGH_SURROGATE = /[\u{d800}-\u{dbff}]/u;
|
|
17
|
+
export const RE_REGIONAL_INDICATOR = /[\u{1f1e6}-\u{1f1ff}]/u;
|
|
18
|
+
export const RE_VARIATION_SELECTOR = /[\u{fe00}-\u{fe0f}]/u;
|
|
19
|
+
export const RE_ZERO_WIDTH_JOINER = /\u{200d}/u;
|
|
20
|
+
// -------------------------------------------------------------------
|
|
21
|
+
// Numbers & Digits
|
|
22
|
+
// -------------------------------------------------------------------
|
|
23
|
+
export const RE_ASCII_DIGIT = /[0-9]/;
|
|
24
|
+
export const RE_ARABIC_INDIC_DIGIT = /[\u{0660}-\u{0669}]/u;
|
|
25
|
+
export const RE_EXT_ARABIC_INDIC_DIGIT = /[\u{06f0}-\u{06f9}]/u;
|
|
26
|
+
// -------------------------------------------------------------------
|
|
27
|
+
// Separators
|
|
28
|
+
// -------------------------------------------------------------------
|
|
29
|
+
export const RE_COMMON_SEPARATOR = /[\u{002e}\u{002c}\u{003a}\u{002f}]/u;
|
|
30
|
+
export const RE_EUROPEAN_SEPARATOR = /[\u{002d}\u{002b}]/u;
|
|
31
|
+
// -------------------------------------------------------------------
|
|
32
|
+
// General Categories
|
|
33
|
+
// -------------------------------------------------------------------
|
|
34
|
+
export const RE_MARK_NONSPACING = /\p{Mn}/u;
|
|
35
|
+
export const RE_MARK_SPACING_COMBINING = /\p{Mc}/u;
|
|
36
|
+
export const RE_MARK_ENCLOSING = /\p{Me}/u;
|
|
37
|
+
export const RE_COMBINING_MARK = /[\p{Mn}\p{Mc}\p{Me}]/u;
|
|
38
|
+
export const RE_LETTER = /\p{L}/u;
|
|
39
|
+
export const RE_NUMBER_DECIMAL = /\p{Nd}/u;
|
|
40
|
+
// -------------------------------------------------------------------
|
|
41
|
+
// Scripts
|
|
42
|
+
// -------------------------------------------------------------------
|
|
43
|
+
export const RE_SCRIPT_GREEK = /\p{Script=Greek}/u;
|
|
44
|
+
export const RE_SCRIPT_HEBREW = /\p{Script=Hebrew}/u;
|
|
45
|
+
export const RE_SCRIPT_JAPANESE = /[\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Han}]/u;
|
|
46
|
+
export const RE_SCRIPT_ARABIC_LETTER = /[\p{Script=Arabic}\p{Script=Syriac}\p{Script=Thaana}\p{Script=Mandaic}]/u;
|
|
47
|
+
// -------------------------------------------------------------------
|
|
48
|
+
// RFC Specifications & Context Exceptions
|
|
49
|
+
// -------------------------------------------------------------------
|
|
50
|
+
export const RE_VIRAMA = /[\u{094d}\u{09cd}\u{0a4d}\u{0acd}\u{0b4d}\u{0bcd}\u{0c4d}\u{0ccd}\u{0d3b}\u{0d3c}\u{0d4d}\u{0dca}\u{1b44}\u{1baa}\u{1bab}\u{a9c0}\u{11046}\u{1107f}\u{110b9}\u{11133}\u{11134}\u{111c0}\u{11235}\u{1134d}\u{11442}\u{114c2}\u{115bf}\u{1163f}\u{116b6}\u{11c3f}\u{11d44}\u{11d45}]/u;
|
|
51
|
+
export const RE_RFC5892_DISALLOWED = /[\u{0640}\u{07fa}\u{302e}\u{302f}\u{3031}\u{3032}\u{3033}\u{3034}\u{3035}\u{303b}]/u;
|
|
52
|
+
export const RE_CONTEXTO_EXCEPTIONS = /[\u{00b7}\u{0375}\u{05f3}\u{05f4}\u{200c}\u{200d}\u{30fb}]/u;
|
|
53
|
+
export const RE_PVALID_EXCEPTIONS = /[\u{00df}\u{03c2}\u{06fd}\u{06fe}\u{0f0b}\u{3007}]/u;
|
|
54
|
+
// -------------------------------------------------------------------
|
|
55
|
+
// Composite Patterns
|
|
56
|
+
// -------------------------------------------------------------------
|
|
57
|
+
export const RE_EUROPEAN_NUMBER = new RegExp([
|
|
58
|
+
RE_ASCII_DIGIT,
|
|
59
|
+
RE_EXT_ARABIC_INDIC_DIGIT
|
|
60
|
+
].map((regexp) => regexp.source).join('|'), 'u');
|
|
61
|
+
export const RE_PERMITTED_CATEGORY = new RegExp([
|
|
62
|
+
RE_LETTER,
|
|
63
|
+
RE_EUROPEAN_SEPARATOR,
|
|
64
|
+
RE_COMMON_SEPARATOR,
|
|
65
|
+
RE_NUMBER_DECIMAL,
|
|
66
|
+
RE_MARK_NONSPACING,
|
|
67
|
+
RE_MARK_SPACING_COMBINING,
|
|
68
|
+
RE_CONTEXTO_EXCEPTIONS,
|
|
69
|
+
RE_PVALID_EXCEPTIONS
|
|
70
|
+
].map((regexp) => regexp.source).join('|'), 'u');
|
|
@@ -1,38 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
// Ranged Fast Path
|
|
3
|
-
// ------------------------------------------------------------------
|
|
4
|
-
/* Returns true if the value is a IPV4 address from index range offsets */
|
|
5
|
-
export function IsIPv4Internal(value, start, end) {
|
|
6
|
-
let dots = 0;
|
|
7
|
-
let num = 0;
|
|
8
|
-
let digits = 0;
|
|
9
|
-
let leading = 0;
|
|
10
|
-
for (let i = start; i < end; i++) {
|
|
11
|
-
const ch = value.charCodeAt(i);
|
|
12
|
-
if (ch === 46) { // '.'
|
|
13
|
-
if (digits === 0 || num > 255 || (leading === 48 && digits > 1))
|
|
14
|
-
return false;
|
|
15
|
-
dots++;
|
|
16
|
-
num = 0;
|
|
17
|
-
digits = 0;
|
|
18
|
-
leading = 0;
|
|
19
|
-
}
|
|
20
|
-
else if (ch >= 48 && ch <= 57) { // '0'-'9'
|
|
21
|
-
if (digits === 0)
|
|
22
|
-
leading = ch;
|
|
23
|
-
num = num * 10 + (ch - 48);
|
|
24
|
-
digits++;
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
return false;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
return dots === 3 && digits > 0 && num <= 255 && !(leading === 48 && digits > 1);
|
|
31
|
-
}
|
|
1
|
+
const IPv4 = /^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/;
|
|
32
2
|
/**
|
|
33
3
|
* Returns true if the value is a IPV4 address
|
|
34
4
|
* @specification http://tools.ietf.org/html/rfc2673#section-3.2
|
|
35
5
|
*/
|
|
36
6
|
export function IsIPv4(value) {
|
|
37
|
-
return
|
|
7
|
+
return IPv4.test(value);
|
|
38
8
|
}
|
|
@@ -1,67 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
function InRange(ch) {
|
|
3
|
-
return (ch >= 48 && ch <= 57) || // 0-9
|
|
4
|
-
(ch >= 65 && ch <= 70) || // A-F
|
|
5
|
-
(ch >= 97 && ch <= 102); // a-f
|
|
6
|
-
}
|
|
1
|
+
const IPv6 = /^(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:)?[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)$/i;
|
|
7
2
|
/**
|
|
8
3
|
* Returns true if the value is an IPv6 address
|
|
9
4
|
* @specification http://tools.ietf.org/html/rfc2373#section-2.2
|
|
10
5
|
*/
|
|
11
6
|
export function IsIPv6(value) {
|
|
12
|
-
|
|
13
|
-
if (length === 0)
|
|
14
|
-
return false;
|
|
15
|
-
let groups = 0;
|
|
16
|
-
let compressed = false;
|
|
17
|
-
let i = 0;
|
|
18
|
-
// handle leading '::'
|
|
19
|
-
if (value.charCodeAt(0) === 58 && value.charCodeAt(1) === 58) {
|
|
20
|
-
if (length === 2)
|
|
21
|
-
return true; // '::' is valid
|
|
22
|
-
compressed = true;
|
|
23
|
-
i = 2;
|
|
24
|
-
}
|
|
25
|
-
while (i < length) {
|
|
26
|
-
// read hex digits
|
|
27
|
-
let digits = 0;
|
|
28
|
-
const start = i;
|
|
29
|
-
while (i < length && InRange(value.charCodeAt(i))) {
|
|
30
|
-
i++;
|
|
31
|
-
digits++;
|
|
32
|
-
}
|
|
33
|
-
if (digits === 0)
|
|
34
|
-
return false;
|
|
35
|
-
const next = value.charCodeAt(i);
|
|
36
|
-
// check for embedded IPv4 at the end
|
|
37
|
-
if (next === 46) { // '.'
|
|
38
|
-
if (!IsIPv4Internal(value, start, length))
|
|
39
|
-
return false;
|
|
40
|
-
groups += 2;
|
|
41
|
-
i = length;
|
|
42
|
-
break;
|
|
43
|
-
}
|
|
44
|
-
if (digits > 4)
|
|
45
|
-
return false;
|
|
46
|
-
groups++;
|
|
47
|
-
if (i === length)
|
|
48
|
-
break;
|
|
49
|
-
// expect ':' separator
|
|
50
|
-
if (next !== 58)
|
|
51
|
-
return false;
|
|
52
|
-
i++;
|
|
53
|
-
// check for '::' compression
|
|
54
|
-
if (value.charCodeAt(i) === 58) {
|
|
55
|
-
if (compressed)
|
|
56
|
-
return false; // only one '::' allowed
|
|
57
|
-
// check for ':::'
|
|
58
|
-
if (value.charCodeAt(i + 1) === 58)
|
|
59
|
-
return false;
|
|
60
|
-
compressed = true;
|
|
61
|
-
i++;
|
|
62
|
-
if (i === length)
|
|
63
|
-
break; // trailing '::'
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
return compressed ? groups <= 7 : groups === 8;
|
|
7
|
+
return IPv6.test(value);
|
|
67
8
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Returns true if the value is a
|
|
3
|
-
* @specification
|
|
2
|
+
* Returns true if the value is a valid Internationalized Resource Identifier.
|
|
3
|
+
* @specification https://datatracker.ietf.org/doc/html/rfc3987
|
|
4
4
|
*/
|
|
5
5
|
export declare function IsIri(value: string): boolean;
|
|
@@ -1,13 +1,31 @@
|
|
|
1
|
+
// deno-lint-ignore-file no-control-regex
|
|
2
|
+
const IpvFutureMatchMaxLength = 2048;
|
|
3
|
+
const IpvFutureMatch = /\[[vV][0-9a-fA-F]+\.[^\]]+\]/; // Guarded By IpvFutureMatchMaxLength
|
|
4
|
+
const InvalidIriChars = /[\x00-\x20<>\^`{|}\\]/;
|
|
5
|
+
// ------------------------------------------------------------------
|
|
6
|
+
// NarrowIpvFuture
|
|
7
|
+
//
|
|
8
|
+
// Substitutes an IPvFuture address with a standard IPv6 loopback
|
|
9
|
+
// address ([::1]). We do this because the native URL.canParse
|
|
10
|
+
// (WHATWG standard) rejects IPvFuture literals, which are
|
|
11
|
+
// otherwise valid in RFC 3987. Because regex substitution can
|
|
12
|
+
// be expensive on large strings, this operation is strictly
|
|
13
|
+
// limited to inputs under a defined length threshold.
|
|
14
|
+
//
|
|
15
|
+
// (review-optimization)
|
|
16
|
+
//
|
|
17
|
+
// ------------------------------------------------------------------
|
|
18
|
+
function NarrowIpvFuture(value) {
|
|
19
|
+
return value.length < IpvFutureMatchMaxLength ? value.replace(IpvFutureMatch, '[::1]') : value;
|
|
20
|
+
}
|
|
1
21
|
/**
|
|
2
|
-
* Returns true if the value is a
|
|
3
|
-
* @specification
|
|
22
|
+
* Returns true if the value is a valid Internationalized Resource Identifier.
|
|
23
|
+
* @specification https://datatracker.ietf.org/doc/html/rfc3987
|
|
4
24
|
*/
|
|
5
25
|
export function IsIri(value) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
return true;
|
|
9
|
-
}
|
|
10
|
-
catch {
|
|
26
|
+
// 1. Reject strings containing unencoded whitespace or illegal control characters.
|
|
27
|
+
if (InvalidIriChars.test(value))
|
|
11
28
|
return false;
|
|
12
|
-
|
|
29
|
+
// 2. Delegate to the native URL parser, patching the IPvFuture edge case beforehand.
|
|
30
|
+
return URL.canParse(NarrowIpvFuture(value));
|
|
13
31
|
}
|