@openclaw/slack 2026.8.1-beta.3 → 2026.8.1
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/account-configured-sUohAxZr.js +33 -0
- package/dist/account-inspect-CN2hBsim.js +87 -0
- package/dist/account-inspect-api.js +1 -1
- package/dist/{accounts-BlzxuYle.js → accounts-Dm_H77gH.js} +7 -10
- package/dist/{accounts.runtime-CbabBL8x.js → accounts.runtime-DRuEK6mL.js} +1 -1
- package/dist/{action-runtime-D6jg2CQd.js → action-runtime-044ldvNL.js} +53 -48
- package/dist/action-runtime.runtime-BL3KzX13.js +2 -0
- package/dist/{actions-DFk0ANVB.js → actions-BI7JkfVm.js} +266 -96
- package/dist/api.js +12 -12
- package/dist/{approval-handler.runtime-BNvAoKdK.js → approval-handler.runtime-DYv0UIZS.js} +53 -176
- package/dist/{channel-CA5w7qDF.js → channel-1vIJOzPx.js} +77 -142
- package/dist/channel-config-api.js +1 -1
- package/dist/channel-plugin-api.js +1 -1
- package/dist/{channel-type-CZWv55Wu.js → channel-type-DlFSKeIZ.js} +3 -3
- package/dist/{channel.setup-CpyYsEXH.js → channel.setup-ofDi3_Pu.js} +34 -49
- package/dist/{config-schema-CN3XZRX5.js → config-schema-BVIMyiDN.js} +19 -12
- package/dist/configured-state.js +34 -0
- package/dist/{directory-config-BGYyuzWh.js → directory-config-DqfQ42OV.js} +1 -1
- package/dist/directory-contract-api.js +1 -1
- package/dist/{directory-live-DjUJQLbq.js → directory-live-BPaNHjmP.js} +2 -2
- package/dist/{group-policy-DyfB_ZIE.js → group-policy-BdwszjYn.js} +581 -743
- package/dist/{message-tool-api-CqMr5Rmc.js → message-tool-api-CJ0kjcg5.js} +23 -5
- package/dist/message-tool-api.js +1 -1
- package/dist/{monitor-Chrecrb9.js → monitor-Dq5Cmrvp.js} +3 -3
- package/dist/{outbound-adapter-DuRqAQXK.js → outbound-adapter-DYaI8ThX.js} +93 -68
- package/dist/{pipeline.runtime-Bbfd5VFW.js → pipeline.runtime-Bd22U0ga.js} +128 -160
- package/dist/{policy-BKXSxrIS.js → policy-CtQVbde1.js} +2 -1
- package/dist/{probe-BVA65leh.js → probe-0usmAb0i.js} +209 -22
- package/dist/{provider-CUUiwsg2.js → provider-CN_8hFv2.js} +243 -146
- package/dist/{relay-source-mhpMMRG-.js → relay-source-BNGpsdwV.js} +1 -1
- package/dist/{replies-SnWyXcsL.js → replies-BSiRQOJ1.js} +15 -5
- package/dist/{resolve-channels-BSpqC8jU.js → resolve-channels-Czheznc8.js} +1 -1
- package/dist/{resolve-users-Dvz9pDe0.js → resolve-users-BAOlNimr.js} +1 -1
- package/dist/runtime-api.js +11 -11
- package/dist/{scopes-BSk4GZvZ.js → scopes-COSlmhnH.js} +1 -1
- package/dist/{send-CtnOxKCc.js → send-DS9ICrBI.js} +39 -31
- package/dist/send-results-eeOu_HYm.js +23 -0
- package/dist/{send.runtime-kYctMHSd.js → send.runtime-D_Bb6IuH.js} +1 -1
- package/dist/setup-plugin-api.js +1 -1
- package/dist/{setup-surface-BPFfp6So.js → setup-surface-BGnd2pSe.js} +6 -6
- package/dist/{shared-DJBaslN7.js → shared-D5B-5hBg.js} +26 -6
- package/dist/{slash-dispatch.runtime-Cf2FTrnf.js → slash-dispatch.runtime-CilDmI0c.js} +3 -3
- package/node_modules/@slack/bolt/node_modules/@types/node/README.md +1 -1
- package/node_modules/@slack/bolt/node_modules/@types/node/child_process.d.ts +0 -1
- package/node_modules/@slack/bolt/node_modules/@types/node/crypto.d.ts +6 -6
- package/node_modules/@slack/bolt/node_modules/@types/node/dns/promises.d.ts +5 -5
- package/node_modules/@slack/bolt/node_modules/@types/node/dns.d.ts +5 -5
- package/node_modules/@slack/bolt/node_modules/@types/node/fs.d.ts +7 -0
- package/node_modules/@slack/bolt/node_modules/@types/node/http.d.ts +30 -0
- package/node_modules/@slack/bolt/node_modules/@types/node/http2.d.ts +4 -4
- package/node_modules/@slack/bolt/node_modules/@types/node/os.d.ts +30 -30
- package/node_modules/@slack/bolt/node_modules/@types/node/package.json +2 -2
- package/node_modules/@slack/bolt/node_modules/@types/node/perf_hooks.d.ts +2 -1
- package/node_modules/@slack/bolt/node_modules/@types/node/process.d.ts +42 -43
- package/node_modules/@slack/bolt/node_modules/@types/node/quic.d.ts +1049 -84
- package/node_modules/@slack/bolt/node_modules/@types/node/sqlite.d.ts +14 -1
- package/node_modules/@slack/bolt/node_modules/@types/node/stream/iter.d.ts +3 -2
- package/node_modules/@slack/bolt/node_modules/@types/node/test.d.ts +61 -0
- package/node_modules/@slack/bolt/node_modules/@types/node/v8.d.ts +20 -23
- package/node_modules/@slack/bolt/node_modules/body-parser/node_modules/content-type/README.md +2 -0
- package/node_modules/@slack/bolt/node_modules/body-parser/node_modules/content-type/dist/index.d.ts +20 -0
- package/node_modules/@slack/bolt/node_modules/body-parser/node_modules/content-type/dist/index.js +20 -14
- package/node_modules/@slack/bolt/node_modules/body-parser/node_modules/content-type/dist/index.js.map +1 -1
- package/node_modules/@slack/bolt/node_modules/body-parser/node_modules/content-type/package.json +1 -1
- package/node_modules/@slack/bolt/node_modules/type-is/node_modules/content-type/README.md +2 -0
- package/node_modules/@slack/bolt/node_modules/type-is/node_modules/content-type/dist/index.d.ts +20 -0
- package/node_modules/@slack/bolt/node_modules/type-is/node_modules/content-type/dist/index.js +20 -14
- package/node_modules/@slack/bolt/node_modules/type-is/node_modules/content-type/dist/index.js.map +1 -1
- package/node_modules/@slack/bolt/node_modules/type-is/node_modules/content-type/package.json +1 -1
- package/node_modules/@slack/socket-mode/node_modules/@types/node/README.md +1 -1
- package/node_modules/@slack/socket-mode/node_modules/@types/node/child_process.d.ts +0 -1
- package/node_modules/@slack/socket-mode/node_modules/@types/node/crypto.d.ts +6 -6
- package/node_modules/@slack/socket-mode/node_modules/@types/node/dns/promises.d.ts +5 -5
- package/node_modules/@slack/socket-mode/node_modules/@types/node/dns.d.ts +5 -5
- package/node_modules/@slack/socket-mode/node_modules/@types/node/fs.d.ts +7 -0
- package/node_modules/@slack/socket-mode/node_modules/@types/node/http.d.ts +30 -0
- package/node_modules/@slack/socket-mode/node_modules/@types/node/http2.d.ts +4 -4
- package/node_modules/@slack/socket-mode/node_modules/@types/node/os.d.ts +30 -30
- package/node_modules/@slack/socket-mode/node_modules/@types/node/package.json +2 -2
- package/node_modules/@slack/socket-mode/node_modules/@types/node/perf_hooks.d.ts +2 -1
- package/node_modules/@slack/socket-mode/node_modules/@types/node/process.d.ts +42 -43
- package/node_modules/@slack/socket-mode/node_modules/@types/node/quic.d.ts +1049 -84
- package/node_modules/@slack/socket-mode/node_modules/@types/node/sqlite.d.ts +14 -1
- package/node_modules/@slack/socket-mode/node_modules/@types/node/stream/iter.d.ts +3 -2
- package/node_modules/@slack/socket-mode/node_modules/@types/node/test.d.ts +61 -0
- package/node_modules/@slack/socket-mode/node_modules/@types/node/v8.d.ts +20 -23
- package/node_modules/@slack/web-api/node_modules/@types/node/README.md +1 -1
- package/node_modules/@slack/web-api/node_modules/@types/node/child_process.d.ts +0 -1
- package/node_modules/@slack/web-api/node_modules/@types/node/crypto.d.ts +6 -6
- package/node_modules/@slack/web-api/node_modules/@types/node/dns/promises.d.ts +5 -5
- package/node_modules/@slack/web-api/node_modules/@types/node/dns.d.ts +5 -5
- package/node_modules/@slack/web-api/node_modules/@types/node/fs.d.ts +7 -0
- package/node_modules/@slack/web-api/node_modules/@types/node/http.d.ts +30 -0
- package/node_modules/@slack/web-api/node_modules/@types/node/http2.d.ts +4 -4
- package/node_modules/@slack/web-api/node_modules/@types/node/os.d.ts +30 -30
- package/node_modules/@slack/web-api/node_modules/@types/node/package.json +2 -2
- package/node_modules/@slack/web-api/node_modules/@types/node/perf_hooks.d.ts +2 -1
- package/node_modules/@slack/web-api/node_modules/@types/node/process.d.ts +42 -43
- package/node_modules/@slack/web-api/node_modules/@types/node/quic.d.ts +1049 -84
- package/node_modules/@slack/web-api/node_modules/@types/node/sqlite.d.ts +14 -1
- package/node_modules/@slack/web-api/node_modules/@types/node/stream/iter.d.ts +3 -2
- package/node_modules/@slack/web-api/node_modules/@types/node/test.d.ts +61 -0
- package/node_modules/@slack/web-api/node_modules/@types/node/v8.d.ts +20 -23
- 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 +23 -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/node_modules/ws/lib/permessage-deflate.js +3 -1
- package/node_modules/ws/package.json +1 -1
- package/openclaw.plugin.json +14 -6
- package/package.json +9 -7
- package/dist/account-configured-BwfXBo_F.js +0 -14
- package/dist/account-inspect-YJvFBbCR.js +0 -89
- package/dist/action-runtime.runtime-JtoOK9l5.js +0 -2
- package/dist/actions.runtime-CYLsYRai.js +0 -2
- package/dist/runtime-api-DBi7xc_g.js +0 -10
- package/dist/slack-client-kind-BXyOOICI.js +0 -94
- 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,23 @@
|
|
|
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
|
+
function IsValidLabelLength(value) {
|
|
5
|
+
return value.length > 0 && value.length <= 63;
|
|
6
|
+
}
|
|
7
|
+
function IsLabel(value) {
|
|
8
|
+
return IsValidLabelLength(value) && (LabelPuny.IsPunyLabel(value) ||
|
|
9
|
+
LabelUnicode.IsUnicodeLabel(value));
|
|
10
|
+
}
|
|
11
|
+
function NormalizeHostname(value) {
|
|
12
|
+
return value.normalize('NFC').replace(/[\u002E\u3002\uFF0E\uFF61]/g, '.');
|
|
13
|
+
}
|
|
14
|
+
export function IsIdnHostname(value) {
|
|
15
|
+
if (value.length === 0 || value.includes(' '))
|
|
16
|
+
return false;
|
|
17
|
+
const normalized = NormalizeHostname(value);
|
|
18
|
+
if (normalized.length > 253)
|
|
19
|
+
return false;
|
|
20
|
+
const labels = normalized.split('.');
|
|
21
|
+
const hasBidiChars = labels.some((label) => FormatBidi.HasBidiChars(label));
|
|
22
|
+
return labels.every((label) => IsLabel(label) && (!hasBidiChars || FormatBidi.SatisfiesBidiRule(label)));
|
|
23
|
+
}
|
|
@@ -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
|
}
|
|
@@ -1,60 +1,14 @@
|
|
|
1
1
|
// deno-lint-ignore-file no-control-regex
|
|
2
|
-
//
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
return true;
|
|
7
|
-
}
|
|
8
|
-
catch {
|
|
9
|
-
return false;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
// deno-coverage-ignore-stop
|
|
2
|
+
// Rejects unencoded spaces (0x20), backslashes, control characters (0x00-0x1F, 0x7F), or malformed percent-encodings
|
|
3
|
+
const InvalidIriChars = /[\x00-\x20\x7F\\]|%(?![0-9a-fA-F]{2})/;
|
|
4
|
+
// Detects malformed scheme/authority patterns lacking a colon (e.g. "httpx//example.com")
|
|
5
|
+
const MalformedScheme = /^[a-zA-Z][a-zA-Z0-9+\-.]*\/\//;
|
|
13
6
|
/**
|
|
14
|
-
* Returns true if the value is
|
|
15
|
-
* @specification
|
|
7
|
+
* Returns true if the value is an IRI reference
|
|
8
|
+
* @specification https://tools.ietf.org/html/rfc3987
|
|
16
9
|
*/
|
|
17
10
|
export function IsIriReference(value) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
return false;
|
|
22
|
-
}
|
|
23
|
-
if (value.includes('\\')) { // Backslash (U+005C)
|
|
24
|
-
return false;
|
|
25
|
-
}
|
|
26
|
-
// ASCII control characters (U+0000-U+001F and U+007F)
|
|
27
|
-
if (/[\x00-\x1F\x7F]/.test(value)) {
|
|
28
|
-
return false;
|
|
29
|
-
}
|
|
30
|
-
// 2. Check for invalid percent-encoding
|
|
31
|
-
// A percent sign '%' must always be followed by exactly two hexadecimal characters.
|
|
32
|
-
// This regex finds a '%' that is NOT followed by two hexadecimal characters.
|
|
33
|
-
// - `%` matches a literal percent sign.
|
|
34
|
-
// - `(?!...)` is a negative lookahead, asserting that what follows is NOT.
|
|
35
|
-
// - `[0-9a-fA-F]{2}` matches exactly two hexadecimal digits.
|
|
36
|
-
// So, if a '%' is found that is not immediately followed by two hex digits, this regex will match.
|
|
37
|
-
if (/%(?![0-9a-fA-F]{2})/.test(value)) {
|
|
38
|
-
return false;
|
|
39
|
-
}
|
|
40
|
-
// 3. Handle empty string (valid relative reference to the current document)
|
|
41
|
-
if (value === '') {
|
|
42
|
-
return true;
|
|
43
|
-
}
|
|
44
|
-
// 4. Determine if it's attempting to be an absolute IRI or a relative IRI, and parse.
|
|
45
|
-
const colonIndex = value.indexOf(':');
|
|
46
|
-
const hasValidSchemePrefix = colonIndex > 0 && // Colon must not be at the very beginning (e.g., ":foo")
|
|
47
|
-
/^[a-zA-Z][a-zA-Z0-9+\-.]*$/.test(value.substring(0, colonIndex));
|
|
48
|
-
if (hasValidSchemePrefix) {
|
|
49
|
-
return TryUrl(value);
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
// This handles cases like `httpx//example.com/path` which look like malformed absolute URIs.
|
|
53
|
-
const looksLikeMalformedSchemeAndAuthority = value.match(/^([a-zA-Z][a-zA-Z0-9+\-.]*)(\/\/)/);
|
|
54
|
-
if (looksLikeMalformedSchemeAndAuthority && colonIndex === -1) {
|
|
55
|
-
return false;
|
|
56
|
-
}
|
|
57
|
-
// Otherwise, it's a relative IRI reference.
|
|
58
|
-
return TryUrl(value);
|
|
59
|
-
}
|
|
11
|
+
return (!InvalidIriChars.test(value) &&
|
|
12
|
+
!MalformedScheme.test(value) &&
|
|
13
|
+
URL.canParse(value, 'http://example.com'));
|
|
60
14
|
}
|
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Returns true if the value is a regular expression string pattern
|
|
3
|
-
* @specification
|
|
4
|
-
* @source ajv-formats
|
|
3
|
+
* @specification https://ecma-international.org/ecma-262
|
|
5
4
|
*/
|
|
6
5
|
export function IsRegex(value) {
|
|
7
|
-
if (value.length === 0) {
|
|
8
|
-
return false;
|
|
9
|
-
}
|
|
10
6
|
try {
|
|
11
|
-
new RegExp(value);
|
|
7
|
+
new RegExp(value, 'u');
|
|
12
8
|
return true;
|
|
13
9
|
}
|
|
14
10
|
catch {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Returns true if the value is
|
|
3
|
-
* @specification
|
|
2
|
+
* Returns true if the value is an ISO time string
|
|
3
|
+
* @specification https://datatracker.ietf.org/doc/html/rfc3339
|
|
4
4
|
*/
|
|
5
5
|
export declare function IsTime(value: string, strictTimeZone?: boolean): boolean;
|
|
@@ -1,27 +1,32 @@
|
|
|
1
|
-
const TIME = /^(\d\d):(\d\d):(\d\d(?:\.\d+)?
|
|
1
|
+
const TIME = /^(\d\d):(\d\d):(\d\d)(?:\.\d+)?(?:([Zz])|([+-])(\d\d):(\d\d))?$/;
|
|
2
2
|
/**
|
|
3
|
-
* Returns true if the value is
|
|
4
|
-
* @specification
|
|
3
|
+
* Returns true if the value is an ISO time string
|
|
4
|
+
* @specification https://datatracker.ietf.org/doc/html/rfc3339
|
|
5
5
|
*/
|
|
6
6
|
export function IsTime(value, strictTimeZone = true) {
|
|
7
7
|
const matches = TIME.exec(value);
|
|
8
8
|
if (!matches)
|
|
9
9
|
return false;
|
|
10
|
+
// Require timezone offset or 'Z'/'z' when strictTimeZone is true
|
|
11
|
+
if (strictTimeZone && !matches[4] && !matches[5])
|
|
12
|
+
return false;
|
|
10
13
|
const hr = +matches[1];
|
|
11
14
|
const min = +matches[2];
|
|
12
15
|
const sec = +matches[3];
|
|
13
|
-
|
|
14
|
-
const tzH = +(matches[5] || 0); // tzH is now matches[5]
|
|
15
|
-
const tzM = +(matches[6] || 0); // tzM is now matches[6]
|
|
16
|
-
if (tzH > 23 || tzM > 59)
|
|
17
|
-
return false; // Check for valid hour/minute range in offset
|
|
18
|
-
if (strictTimeZone && !matches[4] && value.toLowerCase().indexOf('z') === -1) {
|
|
19
|
-
// If strictTimeZone is true, and neither 'Z' nor a '+/-' offset was found
|
|
16
|
+
if (hr > 23 || min > 59 || sec > 60)
|
|
20
17
|
return false;
|
|
18
|
+
if (matches[5]) {
|
|
19
|
+
const tzH = +matches[6];
|
|
20
|
+
const tzM = +matches[7];
|
|
21
|
+
if (tzH > 23 || tzM > 59)
|
|
22
|
+
return false;
|
|
21
23
|
}
|
|
22
|
-
if (
|
|
24
|
+
if (sec < 60)
|
|
23
25
|
return true;
|
|
24
|
-
|
|
25
|
-
const
|
|
26
|
-
|
|
26
|
+
// Leap second handling: must normalize to 23:59:60 UTC (1439 total UTC minutes)
|
|
27
|
+
const tzSign = matches[5] === '-' ? -1 : 1;
|
|
28
|
+
const tzH = +(matches[6] || 0);
|
|
29
|
+
const tzM = +(matches[7] || 0);
|
|
30
|
+
const totalUtcMin = (hr * 60 + min) - tzSign * (tzH * 60 + tzM);
|
|
31
|
+
return (totalUtcMin % 1440 + 1440) % 1440 === 1439;
|
|
27
32
|
}
|