@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
|
@@ -13,7 +13,7 @@ var Namespace = $protobuf.Namespace,
|
|
|
13
13
|
Method = $protobuf.Method,
|
|
14
14
|
patterns = $protobuf.util.patterns;
|
|
15
15
|
|
|
16
|
-
var
|
|
16
|
+
var integerRe = /^[+-]?[0-9]+$/,
|
|
17
17
|
typeRefRe = patterns.typeRefRe;
|
|
18
18
|
|
|
19
19
|
// --- Root ---
|
|
@@ -519,17 +519,33 @@ function Field_fromDescriptor(descriptor, ctx, nested) {
|
|
|
519
519
|
|
|
520
520
|
if (descriptor.defaultValue && descriptor.defaultValue.length) {
|
|
521
521
|
var defaultValue = descriptor.defaultValue;
|
|
522
|
-
switch (
|
|
523
|
-
case "
|
|
524
|
-
defaultValue
|
|
522
|
+
switch (fieldType) {
|
|
523
|
+
case "double": case "float":
|
|
524
|
+
switch (defaultValue.toLowerCase()) {
|
|
525
|
+
case "inf": defaultValue = Infinity; break;
|
|
526
|
+
case "-inf": defaultValue = -Infinity; break;
|
|
527
|
+
case "nan": case "-nan": defaultValue = NaN; break;
|
|
528
|
+
default:
|
|
529
|
+
defaultValue = Number(defaultValue);
|
|
530
|
+
if (Number.isNaN(defaultValue))
|
|
531
|
+
throw Error("illegal default value for " + fieldType);
|
|
532
|
+
break;
|
|
533
|
+
}
|
|
525
534
|
break;
|
|
526
|
-
case "
|
|
527
|
-
defaultValue
|
|
535
|
+
case "int32": case "uint32": case "sint32": case "fixed32": case "sfixed32":
|
|
536
|
+
if (!integerRe.test(defaultValue))
|
|
537
|
+
throw Error("illegal default value for " + fieldType);
|
|
538
|
+
defaultValue = parseInt(defaultValue, 10);
|
|
528
539
|
break;
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
540
|
+
case "int64": case "uint64": case "sint64": case "fixed64": case "sfixed64":
|
|
541
|
+
if (!integerRe.test(defaultValue))
|
|
542
|
+
throw Error("illegal default value for " + fieldType);
|
|
543
|
+
break;
|
|
544
|
+
case "bool":
|
|
545
|
+
switch (defaultValue) {
|
|
546
|
+
case "true": case "TRUE": defaultValue = true; break;
|
|
547
|
+
case "false": case "FALSE": defaultValue = false; break;
|
|
548
|
+
}
|
|
533
549
|
break;
|
|
534
550
|
}
|
|
535
551
|
field.setOption("default", defaultValue);
|
|
@@ -2918,6 +2918,9 @@ export class Writer {
|
|
|
2918
2918
|
/** Stack of forked length-prefix positions. */
|
|
2919
2919
|
states: (number[]|null);
|
|
2920
2920
|
|
|
2921
|
+
/** Initial backing buffer size in bytes. Defaults to 128. */
|
|
2922
|
+
static initialBufferSize: number;
|
|
2923
|
+
|
|
2921
2924
|
/**
|
|
2922
2925
|
* Current write position.
|
|
2923
2926
|
* @deprecated Use {@link Writer#pos} instead.
|
|
@@ -303,7 +303,11 @@ converter.toObject = function toObject(mtype) {
|
|
|
303
303
|
("d%s=%j", prop, arrayDefault)
|
|
304
304
|
("if(o.bytes!==Array)d%s=util.newBuffer(d%s)", prop, prop)
|
|
305
305
|
("}");
|
|
306
|
-
} else
|
|
306
|
+
} else if ((field.type === "double" || field.type === "float") && typeof field.typeDefault === "number"
|
|
307
|
+
&& (!isFinite(field.typeDefault) || Object.is(field.typeDefault, -0))) gen
|
|
308
|
+
("d%s=%f", prop, field.typeDefault)
|
|
309
|
+
("if(o.json&&!isFinite(d%s))d%s=String(d%s)", prop, prop, prop);
|
|
310
|
+
else gen
|
|
307
311
|
("d%s=%j", prop, field.typeDefault); // also messages (=null)
|
|
308
312
|
} gen
|
|
309
313
|
("}");
|
|
@@ -82,8 +82,11 @@ function Enum(name, values, options, comment, comments, valuesOptions) {
|
|
|
82
82
|
|
|
83
83
|
if (values)
|
|
84
84
|
for (var keys = Object.keys(values), i = 0; i < keys.length; ++i)
|
|
85
|
-
if (keys[i] !== "__proto__" && typeof values[keys[i]] === "number") // use forward entries only
|
|
86
|
-
this.
|
|
85
|
+
if (keys[i] !== "__proto__" && typeof values[keys[i]] === "number") { // use forward entries only
|
|
86
|
+
this.values[keys[i]] = values[keys[i]];
|
|
87
|
+
if (this.valuesById[values[keys[i]]] === undefined)
|
|
88
|
+
this.valuesById[values[keys[i]]] = keys[i];
|
|
89
|
+
}
|
|
87
90
|
}
|
|
88
91
|
|
|
89
92
|
/**
|
|
@@ -371,12 +371,17 @@ Field.prototype.resolve = function resolve() {
|
|
|
371
371
|
|
|
372
372
|
// convert to internal data type if necesssary
|
|
373
373
|
if (this.long) {
|
|
374
|
-
|
|
374
|
+
var unsigned = this.type === "uint64" || this.type === "fixed64";
|
|
375
|
+
this.typeDefault = typeof this.typeDefault === "string"
|
|
376
|
+
? util.Long.fromString(this.typeDefault, unsigned)
|
|
377
|
+
: util.Long.fromNumber(this.typeDefault, unsigned);
|
|
375
378
|
|
|
376
379
|
/* istanbul ignore else */
|
|
377
380
|
if (Object.freeze)
|
|
378
381
|
Object.freeze(this.typeDefault); // long instances are meant to be immutable anyway (i.e. use small int cache that even requires it)
|
|
379
382
|
|
|
383
|
+
} else if (types.long[this.type] !== undefined && typeof this.typeDefault === "string") {
|
|
384
|
+
this.typeDefault = parseInt(this.typeDefault, 10);
|
|
380
385
|
} else if (this.bytes && typeof this.typeDefault === "string") {
|
|
381
386
|
var buf;
|
|
382
387
|
if (util.base64.test(this.typeDefault))
|
|
@@ -23,6 +23,8 @@ var base10Re = /^[1-9][0-9]*$/,
|
|
|
23
23
|
base16NegRe = /^-?0[x][0-9a-fA-F]+$/,
|
|
24
24
|
base8Re = /^0[0-7]+$/,
|
|
25
25
|
base8NegRe = /^-?0[0-7]+$/,
|
|
26
|
+
integerTypeRe = /^(?:u?int|sint|s?fixed)(?:32|64)$/,
|
|
27
|
+
unsignedTypeRe = /^(?:uint|fixed)(?:32|64)$/,
|
|
26
28
|
numberRe = util.patterns.numberRe,
|
|
27
29
|
nameRe = /^[a-zA-Z_][a-zA-Z_0-9]*$/,
|
|
28
30
|
typeRefRe = util.patterns.typeRefRe;
|
|
@@ -202,7 +204,7 @@ function parse(source, root, options) {
|
|
|
202
204
|
case "nan": case "NAN": case "Nan": case "NaN":
|
|
203
205
|
return NaN;
|
|
204
206
|
case "0":
|
|
205
|
-
return 0;
|
|
207
|
+
return sign * 0;
|
|
206
208
|
}
|
|
207
209
|
if (base10Re.test(token))
|
|
208
210
|
return sign * parseInt(token, 10);
|
|
@@ -219,32 +221,31 @@ function parse(source, root, options) {
|
|
|
219
221
|
throw illegal(token, "number", insideTryCatch);
|
|
220
222
|
}
|
|
221
223
|
|
|
222
|
-
function
|
|
223
|
-
if (token === null)
|
|
224
|
+
function parseInteger(token, acceptNegative, name) {
|
|
225
|
+
if (token === null)
|
|
224
226
|
throw illegal(token, "end of input");
|
|
225
|
-
|
|
227
|
+
if (!acceptNegative && token.charAt(0) === "-")
|
|
228
|
+
throw illegal(token, name || "integer");
|
|
229
|
+
if (token === "0" || token === "-0")
|
|
230
|
+
return 0;
|
|
231
|
+
var value;
|
|
232
|
+
if (base10NegRe.test(token))
|
|
233
|
+
value = parseInt(token, 10);
|
|
234
|
+
else if (base16NegRe.test(token))
|
|
235
|
+
value = parseInt(token, 16);
|
|
236
|
+
else if (base8NegRe.test(token))
|
|
237
|
+
value = parseInt(token, 8);
|
|
238
|
+
else
|
|
239
|
+
throw illegal(token, name || "integer");
|
|
240
|
+
return value || 0;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
function parseId(token, acceptNegative, max) {
|
|
226
244
|
switch (token) {
|
|
227
245
|
case "max": case "MAX": case "Max":
|
|
228
246
|
return max || maxFieldId;
|
|
229
|
-
case "0":
|
|
230
|
-
return 0;
|
|
231
247
|
}
|
|
232
|
-
|
|
233
|
-
/* istanbul ignore if */
|
|
234
|
-
if (!acceptNegative && token.charAt(0) === "-")
|
|
235
|
-
throw illegal(token, "id");
|
|
236
|
-
|
|
237
|
-
if (base10NegRe.test(token))
|
|
238
|
-
return parseInt(token, 10);
|
|
239
|
-
if (base16NegRe.test(token))
|
|
240
|
-
return parseInt(token, 16);
|
|
241
|
-
|
|
242
|
-
/* istanbul ignore else */
|
|
243
|
-
if (base8NegRe.test(token))
|
|
244
|
-
return parseInt(token, 8);
|
|
245
|
-
|
|
246
|
-
/* istanbul ignore next */
|
|
247
|
-
throw illegal(token, "id");
|
|
248
|
+
return parseInteger(token, acceptNegative, "id");
|
|
248
249
|
}
|
|
249
250
|
|
|
250
251
|
function parsePackage() {
|
|
@@ -881,7 +882,9 @@ function parse(source, root, options) {
|
|
|
881
882
|
return objectResult;
|
|
882
883
|
}
|
|
883
884
|
|
|
884
|
-
var simpleValue =
|
|
885
|
+
var simpleValue = name === "default" && parent instanceof Field && integerTypeRe.test(parent.type)
|
|
886
|
+
? parseInteger(next(), !unsignedTypeRe.test(parent.type))
|
|
887
|
+
: readValue(true);
|
|
885
888
|
setOption(parent, name, simpleValue);
|
|
886
889
|
return simpleValue;
|
|
887
890
|
// Does not enforce a delimiter to be universal
|
|
@@ -395,9 +395,18 @@ Reader.prototype.double = function read_double() {
|
|
|
395
395
|
*/
|
|
396
396
|
Reader.prototype.uint32s = function read_uint32s(array) {
|
|
397
397
|
if (array === undefined) array = [];
|
|
398
|
-
var end = this.uint32() + this.pos;
|
|
399
|
-
while (
|
|
400
|
-
|
|
398
|
+
var end = this.uint32() + this.pos, buf = this.buf, pos = this.pos, value;
|
|
399
|
+
while (pos < end) {
|
|
400
|
+
value = buf[pos++];
|
|
401
|
+
if (value < 128)
|
|
402
|
+
array.push(value);
|
|
403
|
+
else {
|
|
404
|
+
this.pos = pos - 1;
|
|
405
|
+
array.push(this.uint32());
|
|
406
|
+
pos = this.pos;
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
this.pos = pos;
|
|
401
410
|
return array;
|
|
402
411
|
};
|
|
403
412
|
|
|
@@ -408,9 +417,18 @@ Reader.prototype.uint32s = function read_uint32s(array) {
|
|
|
408
417
|
*/
|
|
409
418
|
Reader.prototype.int32s = function read_int32s(array) {
|
|
410
419
|
if (array === undefined) array = [];
|
|
411
|
-
var end = this.uint32() + this.pos;
|
|
412
|
-
while (
|
|
413
|
-
|
|
420
|
+
var end = this.uint32() + this.pos, buf = this.buf, pos = this.pos, value;
|
|
421
|
+
while (pos < end) {
|
|
422
|
+
value = buf[pos++];
|
|
423
|
+
if (value < 128)
|
|
424
|
+
array.push(value);
|
|
425
|
+
else {
|
|
426
|
+
this.pos = pos - 1;
|
|
427
|
+
array.push(this.int32());
|
|
428
|
+
pos = this.pos;
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
this.pos = pos;
|
|
414
432
|
return array;
|
|
415
433
|
};
|
|
416
434
|
|
|
@@ -434,9 +452,18 @@ Reader.prototype.sint32s = function read_sint32s(array) {
|
|
|
434
452
|
*/
|
|
435
453
|
Reader.prototype.bools = function read_bools(array) {
|
|
436
454
|
if (array === undefined) array = [];
|
|
437
|
-
var end = this.uint32() + this.pos;
|
|
438
|
-
while (
|
|
439
|
-
|
|
455
|
+
var end = this.uint32() + this.pos, buf = this.buf, pos = this.pos, value;
|
|
456
|
+
while (pos < end) {
|
|
457
|
+
value = buf[pos++];
|
|
458
|
+
if (value < 128)
|
|
459
|
+
array.push(value !== 0);
|
|
460
|
+
else {
|
|
461
|
+
this.pos = pos - 1;
|
|
462
|
+
array.push(this.bool());
|
|
463
|
+
pos = this.pos;
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
this.pos = pos;
|
|
440
467
|
return array;
|
|
441
468
|
};
|
|
442
469
|
|
|
@@ -64,7 +64,9 @@ function codegen(functionParams, functionName) {
|
|
|
64
64
|
formatStringOrScope = formatStringOrScope.replace(/%([%dfijs])/g, function replace($0, $1) {
|
|
65
65
|
var value = formatParams[formatOffset++];
|
|
66
66
|
switch ($1) {
|
|
67
|
-
case "d": case "f":
|
|
67
|
+
case "d": case "f":
|
|
68
|
+
value = Number(value);
|
|
69
|
+
return Object.is(value, -0) ? "-0" : String(value);
|
|
68
70
|
case "i": return String(Math.floor(value));
|
|
69
71
|
case "j": return JSON.stringify(value);
|
|
70
72
|
case "s": return String(value);
|
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
* @namespace
|
|
7
7
|
*/
|
|
8
8
|
var utf8 = exports,
|
|
9
|
-
replacementChar = "\ufffd",
|
|
10
9
|
looseDecoder = new TextDecoder("utf-8", { ignoreBOM: true }),
|
|
11
10
|
strictDecoder;
|
|
12
11
|
var TEXT_DECODER_MIN_LENGTH = 64;
|
|
@@ -41,31 +40,6 @@ utf8.length = function utf8_length(string) {
|
|
|
41
40
|
return len;
|
|
42
41
|
};
|
|
43
42
|
|
|
44
|
-
function utf8_read_js(buffer, start, end, str) {
|
|
45
|
-
for (var i = start; i < end;) {
|
|
46
|
-
var t = buffer[i++];
|
|
47
|
-
if (t <= 0x7F) {
|
|
48
|
-
str += String.fromCharCode(t);
|
|
49
|
-
} else if (t >= 0xC0 && t < 0xE0) {
|
|
50
|
-
var c2 = (t & 0x1F) << 6 | buffer[i++] & 0x3F;
|
|
51
|
-
str += c2 >= 0x80 ? String.fromCharCode(c2) : replacementChar;
|
|
52
|
-
} else if (t >= 0xE0 && t < 0xF0) {
|
|
53
|
-
var c3 = (t & 0xF) << 12 | (buffer[i++] & 0x3F) << 6 | buffer[i++] & 0x3F;
|
|
54
|
-
str += c3 >= 0x800 ? String.fromCharCode(c3) : replacementChar;
|
|
55
|
-
} else if (t >= 0xF0) {
|
|
56
|
-
var t2 = (t & 7) << 18 | (buffer[i++] & 0x3F) << 12 | (buffer[i++] & 0x3F) << 6 | buffer[i++] & 0x3F;
|
|
57
|
-
if (t2 < 0x10000 || t2 > 0x10FFFF)
|
|
58
|
-
str += replacementChar;
|
|
59
|
-
else {
|
|
60
|
-
t2 -= 0x10000;
|
|
61
|
-
str += String.fromCharCode(0xD800 + (t2 >> 10));
|
|
62
|
-
str += String.fromCharCode(0xDC00 + (t2 & 0x3FF));
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
return str;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
43
|
function utf8_read_decoder(decoder, buffer, start, end) {
|
|
70
44
|
var source = start === 0 && end === buffer.length
|
|
71
45
|
? buffer
|
|
@@ -100,14 +74,14 @@ utf8.read = function utf8_read_loose(buffer, start, end) {
|
|
|
100
74
|
c7 = buffer[i + 6];
|
|
101
75
|
c8 = buffer[i + 7];
|
|
102
76
|
if ((c1 | c2 | c3 | c4 | c5 | c6 | c7 | c8) & 0x80)
|
|
103
|
-
return
|
|
77
|
+
return str + utf8_read_decoder(looseDecoder, buffer, i, end);
|
|
104
78
|
str += String.fromCharCode(c1, c2, c3, c4, c5, c6, c7, c8);
|
|
105
79
|
}
|
|
106
80
|
|
|
107
81
|
for (; i < end; ++i) {
|
|
108
82
|
c1 = buffer[i];
|
|
109
83
|
if (c1 & 0x80)
|
|
110
|
-
return
|
|
84
|
+
return str + utf8_read_decoder(looseDecoder, buffer, i, end);
|
|
111
85
|
str += String.fromCharCode(c1);
|
|
112
86
|
}
|
|
113
87
|
|
|
@@ -26,7 +26,7 @@ function Writer() {
|
|
|
26
26
|
* Backing buffer.
|
|
27
27
|
* @type {Uint8Array}
|
|
28
28
|
*/
|
|
29
|
-
this.buf = this.constructor.alloc(
|
|
29
|
+
this.buf = this.constructor.alloc(Writer.initialBufferSize);
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
32
|
* Cached DataView over {@link Writer#buf}.
|
|
@@ -41,6 +41,12 @@ function Writer() {
|
|
|
41
41
|
this.states = null;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
/**
|
|
45
|
+
* Initial backing buffer size in bytes. Defaults to 128.
|
|
46
|
+
* @type {number}
|
|
47
|
+
*/
|
|
48
|
+
Writer.initialBufferSize = 128;
|
|
49
|
+
|
|
44
50
|
/**
|
|
45
51
|
* Current write position.
|
|
46
52
|
* @name Writer#len
|
|
@@ -167,7 +167,9 @@ class PerMessageDeflate {
|
|
|
167
167
|
(typeof opts.serverMaxWindowBits === 'number' &&
|
|
168
168
|
opts.serverMaxWindowBits > params.server_max_window_bits))) ||
|
|
169
169
|
(typeof opts.clientMaxWindowBits === 'number' &&
|
|
170
|
-
|
|
170
|
+
(typeof params.client_max_window_bits === 'number'
|
|
171
|
+
? opts.clientMaxWindowBits > params.client_max_window_bits
|
|
172
|
+
: !params.client_max_window_bits))
|
|
171
173
|
) {
|
|
172
174
|
return false;
|
|
173
175
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Returns true if the value is a ISO8601 DateTime string
|
|
3
|
-
* @
|
|
3
|
+
* @specification https://datatracker.ietf.org/doc/html/rfc3339
|
|
4
4
|
* @example `2020-12-12T20:20:40+00:00`
|
|
5
5
|
*/
|
|
6
|
-
export declare function IsDateTime(value: string
|
|
6
|
+
export declare function IsDateTime(value: string): boolean;
|
|
@@ -2,10 +2,10 @@ import { IsDate } from './date.mjs';
|
|
|
2
2
|
import { IsTime } from './time.mjs';
|
|
3
3
|
/**
|
|
4
4
|
* Returns true if the value is a ISO8601 DateTime string
|
|
5
|
-
* @
|
|
5
|
+
* @specification https://datatracker.ietf.org/doc/html/rfc3339
|
|
6
6
|
* @example `2020-12-12T20:20:40+00:00`
|
|
7
7
|
*/
|
|
8
|
-
export function IsDateTime(value
|
|
8
|
+
export function IsDateTime(value) {
|
|
9
9
|
const dateTime = value.split(/T/i);
|
|
10
|
-
return dateTime.length === 2 && IsDate(dateTime[0]) && IsTime(dateTime[1]
|
|
10
|
+
return dateTime.length === 2 && IsDate(dateTime[0]) && IsTime(dateTime[1]);
|
|
11
11
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
const Email = /^(
|
|
1
|
+
const Email = /^(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[^"\\]|\\[\x20-\x7e])*")@(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*|\[(?:IPv6:[a-f0-9:]+|(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])(?:\.(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){3})\])$/i;
|
|
2
2
|
/**
|
|
3
3
|
* Returns true if the value is an Email
|
|
4
|
-
* @specification
|
|
4
|
+
* @specification https://datatracker.ietf.org/doc/html/rfc5322
|
|
5
5
|
*/
|
|
6
6
|
export function IsEmail(value) {
|
|
7
7
|
return Email.test(value);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as Idna from './
|
|
1
|
+
import * as Idna from './idna/index.mjs';
|
|
2
2
|
/**
|
|
3
3
|
* Returns true if the value is a valid hostname.
|
|
4
4
|
* @specification https://tools.ietf.org/html/rfc1123
|
|
@@ -6,13 +6,5 @@ import * as Idna from './_idna.mjs';
|
|
|
6
6
|
* @specification https://tools.ietf.org/html/rfc5892
|
|
7
7
|
*/
|
|
8
8
|
export function IsHostname(value) {
|
|
9
|
-
|
|
10
|
-
return false;
|
|
11
|
-
if (value.charCodeAt(value.length - 1) === 46)
|
|
12
|
-
return false;
|
|
13
|
-
for (const label of value.split('.')) {
|
|
14
|
-
if (!Idna.IsLabel(label))
|
|
15
|
-
return false;
|
|
16
|
-
}
|
|
17
|
-
return true;
|
|
9
|
+
return Idna.IsHostname(value);
|
|
18
10
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
const IdnEmail = /^(
|
|
1
|
+
const IdnEmail = /^(?:[A-Za-z0-9!#$%&'*+\/=?^_`{|}~\u{0080}-\u{10FFFF}-]+(?:\.[A-Za-z0-9!#$%&'*+\/=?^_`{|}~\u{0080}-\u{10FFFF}-]+)*|"(?:[^"\\]|\\.)*")@[\p{L}\p{N}](?:[\p{L}\p{N}-]{0,62})(?<!-)(?:\.[\p{L}\p{N}](?:[\p{L}\p{N}-]{0,62})(?<!-))*$/iu;
|
|
2
2
|
/**
|
|
3
3
|
* Returns true if the value is an IdnEmail
|
|
4
|
-
* @specification
|
|
4
|
+
* @specification https://datatracker.ietf.org/doc/html/rfc4952
|
|
5
5
|
*/
|
|
6
6
|
export function IsIdnEmail(value) {
|
|
7
|
-
return IdnEmail.test(value);
|
|
7
|
+
return IdnEmail.test(value.normalize('NFC'));
|
|
8
8
|
}
|
|
@@ -3,5 +3,6 @@
|
|
|
3
3
|
* @specification https://tools.ietf.org/html/rfc3490
|
|
4
4
|
* @specification https://tools.ietf.org/html/rfc5891
|
|
5
5
|
* @specification https://tools.ietf.org/html/rfc5892
|
|
6
|
+
* @specification https://tools.ietf.org/html/rfc5893
|
|
6
7
|
*/
|
|
7
8
|
export declare function IsIdnHostname(value: string): boolean;
|
|
@@ -1,19 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as Idna from './idna/index.mjs';
|
|
2
2
|
/**
|
|
3
3
|
* Returns true if the value is a valid internationalized (IDN) hostname.
|
|
4
4
|
* @specification https://tools.ietf.org/html/rfc3490
|
|
5
5
|
* @specification https://tools.ietf.org/html/rfc5891
|
|
6
6
|
* @specification https://tools.ietf.org/html/rfc5892
|
|
7
|
+
* @specification https://tools.ietf.org/html/rfc5893
|
|
7
8
|
*/
|
|
8
9
|
export function IsIdnHostname(value) {
|
|
9
|
-
|
|
10
|
-
return false;
|
|
11
|
-
const canonical = value.normalize('NFC').replace(/[\u002E\u3002\uFF0E\uFF61]/g, '.');
|
|
12
|
-
if (canonical.length > 253)
|
|
13
|
-
return false;
|
|
14
|
-
for (const label of canonical.split('.')) {
|
|
15
|
-
if (!IsIdnLabel(label))
|
|
16
|
-
return false;
|
|
17
|
-
}
|
|
18
|
-
return true;
|
|
10
|
+
return Idna.IsIdnHostname(value);
|
|
19
11
|
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
// deno-fmt-ignore-file
|
|
2
|
+
import * as FormatPuny from './puny.mjs';
|
|
3
|
+
import * as Pattern from '../pattern/pattern.mjs';
|
|
4
|
+
// ------------------------------------------------------------------
|
|
5
|
+
// LOCAL REGEX: Allowed Bidi classes per direction (RFC 5893)
|
|
6
|
+
// ------------------------------------------------------------------
|
|
7
|
+
const RE_RTL_ALLOWED = /^(?:R|AL|AN|EN|ES|CS|ET|ON|BN|NSM)$/;
|
|
8
|
+
const RE_LTR_ALLOWED = /^(?:L|EN|ES|CS|ET|ON|BN|NSM)$/;
|
|
9
|
+
const RE_RTL_CLASSES = /^(?:R|AL|AN)$/;
|
|
10
|
+
// ------------------------------------------------------------------
|
|
11
|
+
// HasBidiChars
|
|
12
|
+
//
|
|
13
|
+
// Decodes a punycode label to its Unicode form (if it is one) and
|
|
14
|
+
// checks whether the result is an RTL label per RFC 5893 §1.4.
|
|
15
|
+
// ------------------------------------------------------------------
|
|
16
|
+
export function HasBidiChars(value) {
|
|
17
|
+
if (FormatPuny.IsAcePrefixed(value)) {
|
|
18
|
+
try {
|
|
19
|
+
return HasRightToLeftCharacters(FormatPuny.Decode(value.slice(4).toLowerCase()));
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return HasRightToLeftCharacters(value);
|
|
26
|
+
}
|
|
27
|
+
// ------------------------------------------------------------------
|
|
28
|
+
// GetBidiClass
|
|
29
|
+
// ------------------------------------------------------------------
|
|
30
|
+
function GetBidiClass(codePoint) {
|
|
31
|
+
const char = String.fromCodePoint(codePoint);
|
|
32
|
+
return (Pattern.RE_EUROPEAN_NUMBER.test(char) ? 'EN' :
|
|
33
|
+
Pattern.RE_ARABIC_INDIC_DIGIT.test(char) ? 'AN' :
|
|
34
|
+
// Pattern.RE_EUROPEAN_SEPARATOR.test(char) ? 'ES' : // (no-spec-coverage)
|
|
35
|
+
// Pattern.RE_COMMON_SEPARATOR.test(char) ? 'CS' : // (no-spec-coverage)
|
|
36
|
+
Pattern.RE_MARK_NONSPACING.test(char) ? 'NSM' :
|
|
37
|
+
Pattern.RE_SCRIPT_HEBREW.test(char) ? 'R' :
|
|
38
|
+
Pattern.RE_SCRIPT_ARABIC_LETTER.test(char) ? 'AL' :
|
|
39
|
+
Pattern.RE_LETTER.test(char) ? 'L' :
|
|
40
|
+
'ON');
|
|
41
|
+
}
|
|
42
|
+
// ------------------------------------------------------------------
|
|
43
|
+
// HasRightToLeftCharacters
|
|
44
|
+
//
|
|
45
|
+
// Per RFC 5893 §1.4: "An RTL label is a label that contains at least
|
|
46
|
+
// one character of type R, AL, or AN." Used to determine whether a
|
|
47
|
+
// domain name is a "Bidi domain name" (RFC 5893 §1.4), in which case
|
|
48
|
+
// the Bidi Rule applies to every label in the domain.
|
|
49
|
+
// ------------------------------------------------------------------
|
|
50
|
+
export function HasRightToLeftCharacters(value) {
|
|
51
|
+
for (const ch of value)
|
|
52
|
+
if (RE_RTL_CLASSES.test(GetBidiClass(ch.codePointAt(0))))
|
|
53
|
+
return true;
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
// ------------------------------------------------------------------
|
|
57
|
+
// SatisfiesBidiRule
|
|
58
|
+
// ------------------------------------------------------------------
|
|
59
|
+
export function SatisfiesBidiRule(value) {
|
|
60
|
+
let isRtl = false;
|
|
61
|
+
let allowed = RE_LTR_ALLOWED;
|
|
62
|
+
let sawEN = false;
|
|
63
|
+
let sawAN = false;
|
|
64
|
+
let isFirst = true;
|
|
65
|
+
// let lastClass: string | null = null // (no-spec-coverage)
|
|
66
|
+
for (const ch of value) {
|
|
67
|
+
const bidiClass = GetBidiClass(ch.codePointAt(0));
|
|
68
|
+
if (isFirst) {
|
|
69
|
+
// 1. The first character must be a character with Bidi property L, R, or AL.
|
|
70
|
+
if (bidiClass !== 'L' && bidiClass !== 'R' && bidiClass !== 'AL')
|
|
71
|
+
return false;
|
|
72
|
+
isRtl = bidiClass === 'R' || bidiClass === 'AL';
|
|
73
|
+
allowed = isRtl ? RE_RTL_ALLOWED : RE_LTR_ALLOWED;
|
|
74
|
+
isFirst = false;
|
|
75
|
+
}
|
|
76
|
+
// 2 / 5. Only characters in the allowed set for this direction may appear.
|
|
77
|
+
if (!allowed.test(bidiClass))
|
|
78
|
+
return false;
|
|
79
|
+
if (bidiClass === 'EN')
|
|
80
|
+
sawEN = true;
|
|
81
|
+
else if (bidiClass === 'AN')
|
|
82
|
+
sawAN = true;
|
|
83
|
+
// if (bidiClass !== 'NSM') lastClass = bidiClass // (no-spec-coverage)
|
|
84
|
+
}
|
|
85
|
+
if (isRtl && sawEN && sawAN)
|
|
86
|
+
return false; // spec coverage path
|
|
87
|
+
// (no-spec-coverage)
|
|
88
|
+
// if (isRtl) {
|
|
89
|
+
// // 3. The end of the label must be R, AL, EN, or AN (ignoring trailing NSM).
|
|
90
|
+
// // if (lastClass !== 'R' && lastClass !== 'AL' && lastClass !== 'EN' && lastClass !== 'AN') return false
|
|
91
|
+
// // 4. If an EN is present, no AN may be present, and vice versa.
|
|
92
|
+
// if (sawEN && sawAN) return false
|
|
93
|
+
// } else {
|
|
94
|
+
// // 6. The end of the label must be L or EN (ignoring trailing NSM).
|
|
95
|
+
// // if (lastClass !== 'L' && lastClass !== 'EN') return false
|
|
96
|
+
// }
|
|
97
|
+
return true;
|
|
98
|
+
}
|