@vm0/cli 9.222.1 → 9.222.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/{agent-URKTRVVY.js → agent-LPPBYNS2.js} +4 -4
  2. package/{automation-7TUOVCC6.js → automation-BB4N3JL7.js} +5 -5
  3. package/{banking-7XABHZ5S.js → banking-WAVEYEQR.js} +2 -2
  4. package/{chat-GZ4XQAP5.js → chat-WLUTTBQU.js} +2 -2
  5. package/{chunk-LR3SNXFF.js → chunk-3QZMZ46V.js} +133 -4
  6. package/chunk-3QZMZ46V.js.map +1 -0
  7. package/{chunk-EZKHVXE7.js → chunk-4IPZWDAI.js} +3 -3
  8. package/{chunk-BYBPO5VT.js → chunk-5FY5RVWK.js} +3 -3
  9. package/chunk-72DXWQL4.js +1178 -0
  10. package/chunk-72DXWQL4.js.map +1 -0
  11. package/{chunk-P2NVIMW4.js → chunk-A5RF3VZM.js} +2 -2
  12. package/{chunk-L7YXAPYN.js → chunk-K7F6VF2Z.js} +2 -2
  13. package/{chunk-CS63UKLQ.js → chunk-OFENJD2Q.js} +25 -5
  14. package/{chunk-CS63UKLQ.js.map → chunk-OFENJD2Q.js.map} +1 -1
  15. package/{chunk-SYUXIMDL.js → chunk-V2NS7MND.js} +2 -2
  16. package/{chunk-XTEZGNJE.js → chunk-XX44OKQX.js} +2 -2
  17. package/{computer-use-6THXLNRO.js → computer-use-V7RXYM5A.js} +2 -2
  18. package/{connector-BGMSHIXW.js → connector-ZFFOQO63.js} +2 -2
  19. package/{credit-XRZDIE2G.js → credit-O3ELRY7X.js} +2 -2
  20. package/{developer-support-EJDZWL42.js → developer-support-2VYEJ4UE.js} +2 -2
  21. package/{doctor-EYR3IG4Y.js → doctor-F5ETPBLW.js} +261 -65
  22. package/doctor-F5ETPBLW.js.map +1 -0
  23. package/{generate-3P3NAGH5.js → generate-MESJMO2O.js} +2 -2
  24. package/{github-JT7U4DRN.js → github-3QYZVKIQ.js} +2 -2
  25. package/{goal-45PIBJPM.js → goal-A5RMK7GY.js} +2 -2
  26. package/{host-AAOX4PLN.js → host-3R44HEX5.js} +2 -2
  27. package/index.js +13 -13
  28. package/{logs-T3NAE3H7.js → logs-TCWPJYIU.js} +6 -6
  29. package/{maps-FWZYMSGN.js → maps-OADWY7SG.js} +2 -2
  30. package/{model-IMFZNZ6Y.js → model-VEADPWRX.js} +3 -3
  31. package/{model-provider-KEK475GA.js → model-provider-SHA27BOM.js} +3 -3
  32. package/{org-YG2ZZRRJ.js → org-MI6FIM3U.js} +2 -2
  33. package/package.json +1 -1
  34. package/{phone-JFF2IT5G.js → phone-IIC43L5Z.js} +2 -2
  35. package/{preference-WVQAW5ME.js → preference-JE7EYXOC.js} +2 -2
  36. package/{resource-U3LUKPPU.js → resource-Q646DK57.js} +2 -2
  37. package/{search-GTOC3GPL.js → search-5A5HM5EN.js} +6 -6
  38. package/{secret-QGULS25L.js → secret-JGEU4F2W.js} +3 -3
  39. package/{slack-DVAIY7U3.js → slack-QLEY2HSE.js} +2 -2
  40. package/{telegram-5C3ALERN.js → telegram-UCBPY4FU.js} +2 -2
  41. package/{variable-G6CSZGS2.js → variable-XB45XMPQ.js} +2 -2
  42. package/{web-PJK4UZXI.js → web-DWIOAOMH.js} +2 -2
  43. package/{whoami-P7IJ4FES.js → whoami-P7LQBBTB.js} +4 -4
  44. package/{workflow-4JOVGGV6.js → workflow-ETGLSZ5Y.js} +2 -2
  45. package/zero.js +31 -31
  46. package/chunk-KJNJT27A.js +0 -612
  47. package/chunk-KJNJT27A.js.map +0 -1
  48. package/chunk-LR3SNXFF.js.map +0 -1
  49. package/doctor-EYR3IG4Y.js.map +0 -1
  50. /package/{agent-URKTRVVY.js.map → agent-LPPBYNS2.js.map} +0 -0
  51. /package/{automation-7TUOVCC6.js.map → automation-BB4N3JL7.js.map} +0 -0
  52. /package/{banking-7XABHZ5S.js.map → banking-WAVEYEQR.js.map} +0 -0
  53. /package/{chat-GZ4XQAP5.js.map → chat-WLUTTBQU.js.map} +0 -0
  54. /package/{chunk-EZKHVXE7.js.map → chunk-4IPZWDAI.js.map} +0 -0
  55. /package/{chunk-BYBPO5VT.js.map → chunk-5FY5RVWK.js.map} +0 -0
  56. /package/{chunk-P2NVIMW4.js.map → chunk-A5RF3VZM.js.map} +0 -0
  57. /package/{chunk-L7YXAPYN.js.map → chunk-K7F6VF2Z.js.map} +0 -0
  58. /package/{chunk-SYUXIMDL.js.map → chunk-V2NS7MND.js.map} +0 -0
  59. /package/{chunk-XTEZGNJE.js.map → chunk-XX44OKQX.js.map} +0 -0
  60. /package/{computer-use-6THXLNRO.js.map → computer-use-V7RXYM5A.js.map} +0 -0
  61. /package/{connector-BGMSHIXW.js.map → connector-ZFFOQO63.js.map} +0 -0
  62. /package/{credit-XRZDIE2G.js.map → credit-O3ELRY7X.js.map} +0 -0
  63. /package/{developer-support-EJDZWL42.js.map → developer-support-2VYEJ4UE.js.map} +0 -0
  64. /package/{generate-3P3NAGH5.js.map → generate-MESJMO2O.js.map} +0 -0
  65. /package/{github-JT7U4DRN.js.map → github-3QYZVKIQ.js.map} +0 -0
  66. /package/{goal-45PIBJPM.js.map → goal-A5RMK7GY.js.map} +0 -0
  67. /package/{host-AAOX4PLN.js.map → host-3R44HEX5.js.map} +0 -0
  68. /package/{logs-T3NAE3H7.js.map → logs-TCWPJYIU.js.map} +0 -0
  69. /package/{maps-FWZYMSGN.js.map → maps-OADWY7SG.js.map} +0 -0
  70. /package/{model-IMFZNZ6Y.js.map → model-VEADPWRX.js.map} +0 -0
  71. /package/{model-provider-KEK475GA.js.map → model-provider-SHA27BOM.js.map} +0 -0
  72. /package/{org-YG2ZZRRJ.js.map → org-MI6FIM3U.js.map} +0 -0
  73. /package/{phone-JFF2IT5G.js.map → phone-IIC43L5Z.js.map} +0 -0
  74. /package/{preference-WVQAW5ME.js.map → preference-JE7EYXOC.js.map} +0 -0
  75. /package/{resource-U3LUKPPU.js.map → resource-Q646DK57.js.map} +0 -0
  76. /package/{search-GTOC3GPL.js.map → search-5A5HM5EN.js.map} +0 -0
  77. /package/{secret-QGULS25L.js.map → secret-JGEU4F2W.js.map} +0 -0
  78. /package/{slack-DVAIY7U3.js.map → slack-QLEY2HSE.js.map} +0 -0
  79. /package/{telegram-5C3ALERN.js.map → telegram-UCBPY4FU.js.map} +0 -0
  80. /package/{variable-G6CSZGS2.js.map → variable-XB45XMPQ.js.map} +0 -0
  81. /package/{web-PJK4UZXI.js.map → web-DWIOAOMH.js.map} +0 -0
  82. /package/{whoami-P7IJ4FES.js.map → whoami-P7LQBBTB.js.map} +0 -0
  83. /package/{workflow-4JOVGGV6.js.map → workflow-ETGLSZ5Y.js.map} +0 -0
package/chunk-KJNJT27A.js DELETED
@@ -1,612 +0,0 @@
1
- #!/usr/bin/env node
2
- import { createRequire as __createRequire } from "node:module";
3
- const require = __createRequire(import.meta.url);
4
- import {
5
- hasBaseUrlParams,
6
- hasRawWhitespace,
7
- hasUnsafeUrlCodepoint,
8
- parseSegment,
9
- splitPathSegments,
10
- validateBaseUrl
11
- } from "./chunk-LR3SNXFF.js";
12
- import {
13
- init_esm_shims
14
- } from "./chunk-DIRAZ3YX.js";
15
-
16
- // ../../packages/connectors/src/firewall-rule-matcher.ts
17
- init_esm_shims();
18
- var VALID_RULE_METHODS = /* @__PURE__ */ new Set([
19
- "GET",
20
- "POST",
21
- "PUT",
22
- "PATCH",
23
- "DELETE",
24
- "HEAD",
25
- "OPTIONS",
26
- "ANY"
27
- ]);
28
- var FORBIDDEN_RUNTIME_HOST_CHARS = new Set("#%*,/<>?@\\^|{}".split(""));
29
- var FORBIDDEN_BASE_PATTERN_HOST_CHARS = new Set("#%,/<>?@\\^|".split(""));
30
- var PERCENT_ESCAPE_LENGTH = 3;
31
- var HEX_DIGITS = new Set("0123456789abcdefABCDEF".split(""));
32
- var PATH_SCORE_MULTIPLIER = 1e6;
33
- var AUTHORITY_SCORE_MULTIPLIER = 100;
34
- var LITERAL_SEGMENT_SCORE = 1e3;
35
- var MIXED_PARAM_SEGMENT_SCORE = 100;
36
- var PLAIN_PARAM_SEGMENT_SCORE = 10;
37
- var PLUS_GREEDY_SEGMENT_SCORE = 1;
38
- var ROOT_PATH_SCORE = 1;
39
- var STATIC_BASE_SCORE_BONUS = 1;
40
- var PERCENT_DECODED_AUTHORITY_SYNTAX_CHARS = /* @__PURE__ */ new Set([
41
- "{",
42
- "}",
43
- "*",
44
- ".",
45
- "\u3002",
46
- "\uFF0E",
47
- "\uFF61",
48
- ":"
49
- ]);
50
- function matchMixedSegment(runtime, prefix, suffix) {
51
- if (!runtime.startsWith(prefix)) return null;
52
- if (!runtime.endsWith(suffix)) return null;
53
- if (runtime.length <= prefix.length + suffix.length) return null;
54
- return runtime.slice(prefix.length, runtime.length - suffix.length);
55
- }
56
- function hasNonEmptySegment(segments, start) {
57
- for (let i = start; i < segments.length; i++) {
58
- if (segments[i] !== "") return true;
59
- }
60
- return false;
61
- }
62
- function codePointLength(value) {
63
- return [...value].length;
64
- }
65
- function hasUnsafeRuntimeUrlSyntax(value) {
66
- return hasUnsafeUrlCodepoint(value) || hasRawWhitespace(value) || value.includes("\\") || !value.includes("://");
67
- }
68
- function stripTrailingSlash(value) {
69
- return value.endsWith("/") ? value.slice(0, -1) : value;
70
- }
71
- function isInvalidGreedyParam(patternIndex, lastPatternIndex, prefix, suffix) {
72
- return patternIndex !== lastPatternIndex || prefix !== "" || suffix !== "";
73
- }
74
- function pathSpecificity(pattern) {
75
- if (!pattern.startsWith("/") || pattern.includes("?") || pattern.includes("#") || pattern.includes("\\") || hasRawWhitespace(pattern) || hasUnsafeUrlCodepoint(pattern)) {
76
- return null;
77
- }
78
- let literalSegments = 0;
79
- let mixedParamSegments = 0;
80
- let plainParamSegments = 0;
81
- let plusGreedySegments = 0;
82
- let starGreedySegments = 0;
83
- let literalChars = 0;
84
- const segments = splitPathSegments(pattern);
85
- const paramNames = /* @__PURE__ */ new Set();
86
- const lastSegmentIndex = segments.length - 1;
87
- for (let index = 0; index < segments.length; index += 1) {
88
- const seg = segments[index];
89
- const parsed = parseSegment(seg);
90
- if (parsed.kind === "error") return null;
91
- if (parsed.kind === "literal") {
92
- literalSegments += 1;
93
- literalChars += codePointLength(parsed.value);
94
- continue;
95
- }
96
- if (paramNames.has(parsed.name)) return null;
97
- paramNames.add(parsed.name);
98
- if (parsed.greedy !== "" && isInvalidGreedyParam(
99
- index,
100
- lastSegmentIndex,
101
- parsed.prefix,
102
- parsed.suffix
103
- )) {
104
- return null;
105
- }
106
- literalChars += codePointLength(parsed.prefix) + codePointLength(parsed.suffix);
107
- if (parsed.prefix !== "" || parsed.suffix !== "") {
108
- mixedParamSegments += 1;
109
- } else if (parsed.greedy === "+") {
110
- plusGreedySegments += 1;
111
- } else if (parsed.greedy === "*") {
112
- starGreedySegments += 1;
113
- } else {
114
- plainParamSegments += 1;
115
- }
116
- }
117
- return [
118
- literalSegments,
119
- mixedParamSegments,
120
- plainParamSegments,
121
- plusGreedySegments,
122
- -starGreedySegments,
123
- literalChars,
124
- segments.length
125
- ];
126
- }
127
- function comparePathSpecificity(left, right) {
128
- for (let i = 0; i < left.length; i++) {
129
- const difference = left[i] - right[i];
130
- if (difference !== 0) return difference;
131
- }
132
- return 0;
133
- }
134
- function matchingRulePath(rule, upperMethod) {
135
- const spaceIdx = rule.indexOf(" ");
136
- if (spaceIdx === -1) return null;
137
- const ruleMethod = rule.slice(0, spaceIdx);
138
- if (!VALID_RULE_METHODS.has(ruleMethod)) return null;
139
- if (ruleMethod !== "ANY" && ruleMethod !== upperMethod) return null;
140
- return rule.slice(spaceIdx + 1);
141
- }
142
- function isValidPermissionName(permissionName) {
143
- return permissionName !== "" && permissionName !== "all";
144
- }
145
- function isObjectRecord(value) {
146
- if (typeof value !== "object" || value === null || Array.isArray(value)) {
147
- return false;
148
- }
149
- const prototype = Object.getPrototypeOf(value);
150
- return prototype === Object.prototype || prototype === null;
151
- }
152
- function getRoutingApiPermissionRuleSetsForMatch(api, serviceName, apiBase) {
153
- if (!isObjectRecord(api)) return null;
154
- if (typeof api.base !== "string") return null;
155
- try {
156
- validateBaseUrl(api.base, serviceName);
157
- } catch {
158
- return null;
159
- }
160
- if (apiBase !== null && stripTrailingSlash(api.base) !== apiBase) return null;
161
- if (!Array.isArray(api.routes)) return null;
162
- const rulesByPermission = /* @__PURE__ */ new Map();
163
- for (const route of api.routes) {
164
- if (!isObjectRecord(route)) continue;
165
- if (typeof route.permissionName !== "string") continue;
166
- if (!isValidPermissionName(route.permissionName)) continue;
167
- if (typeof route.rule !== "string") continue;
168
- const rules = rulesByPermission.get(route.permissionName);
169
- if (rules) {
170
- rules.push(route.rule);
171
- } else {
172
- rulesByPermission.set(route.permissionName, [route.rule]);
173
- }
174
- }
175
- return [...rulesByPermission.entries()].map(([name, rules]) => {
176
- return { name, rules };
177
- });
178
- }
179
- function recordPermissionMatch(state, permission, specificity) {
180
- if (state.bestSpecificity === null || comparePathSpecificity(specificity, state.bestSpecificity) > 0) {
181
- state.bestSpecificity = specificity;
182
- state.matched.length = 0;
183
- }
184
- if (comparePathSpecificity(specificity, state.bestSpecificity) === 0 && !state.matched.includes(permission)) {
185
- state.matched.push(permission);
186
- }
187
- }
188
- function relativePathFromSegments(segments, consumed) {
189
- const rest = segments.slice(consumed).join("/");
190
- return rest === "" ? "/" : `/${rest}`;
191
- }
192
- function stripUrlQueryAndFragment(url) {
193
- const queryIndex = url.indexOf("?");
194
- const fragmentIndex = url.indexOf("#");
195
- let end = url.length;
196
- if (queryIndex !== -1) end = Math.min(end, queryIndex);
197
- if (fragmentIndex !== -1) end = Math.min(end, fragmentIndex);
198
- return url.slice(0, end);
199
- }
200
- function rawPathFromUrl(url) {
201
- const urlWithoutQuery = stripUrlQueryAndFragment(url);
202
- const schemeEnd = urlWithoutQuery.indexOf("://");
203
- const authorityStart = schemeEnd === -1 ? 0 : schemeEnd + 3;
204
- const pathStart = urlWithoutQuery.indexOf("/", authorityStart);
205
- return pathStart === -1 ? "/" : urlWithoutQuery.slice(pathStart);
206
- }
207
- function rawBasePathFromUrl(url) {
208
- const urlWithoutQuery = stripUrlQueryAndFragment(url);
209
- const schemeEnd = urlWithoutQuery.indexOf("://");
210
- const authorityStart = schemeEnd === -1 ? 0 : schemeEnd + 3;
211
- const pathStart = urlWithoutQuery.indexOf("/", authorityStart);
212
- return pathStart === -1 ? "" : urlWithoutQuery.slice(pathStart);
213
- }
214
- function rawAuthorityFromUrl(url) {
215
- const urlWithoutQuery = stripUrlQueryAndFragment(url);
216
- const schemeEnd = urlWithoutQuery.indexOf("://");
217
- if (schemeEnd === -1) return null;
218
- const authorityStart = schemeEnd + 3;
219
- const pathStart = urlWithoutQuery.indexOf("/", authorityStart);
220
- const authority = pathStart === -1 ? urlWithoutQuery.slice(authorityStart) : urlWithoutQuery.slice(authorityStart, pathStart);
221
- return authority === "" ? null : authority;
222
- }
223
- function hasNonAscii(value) {
224
- for (let index = 0; index < value.length; index += 1) {
225
- if (value.charCodeAt(index) > 127) return true;
226
- }
227
- return false;
228
- }
229
- function rawHostFromAuthority(authority) {
230
- const withoutUserinfo = authority.slice(authority.lastIndexOf("@") + 1);
231
- if (withoutUserinfo.startsWith("[")) {
232
- const closeBracket = withoutUserinfo.indexOf("]");
233
- return closeBracket === -1 ? withoutUserinfo : withoutUserinfo.slice(0, closeBracket + 1);
234
- }
235
- const portSeparator = withoutUserinfo.lastIndexOf(":");
236
- return portSeparator === -1 ? withoutUserinfo : withoutUserinfo.slice(0, portSeparator);
237
- }
238
- function authorityHasEmptyPort(authority) {
239
- const withoutUserinfo = authority.slice(authority.lastIndexOf("@") + 1);
240
- if (withoutUserinfo.startsWith("[")) {
241
- const closeBracket = withoutUserinfo.indexOf("]");
242
- if (closeBracket === -1) return false;
243
- return withoutUserinfo.slice(closeBracket + 1) === ":";
244
- }
245
- const portSeparator = withoutUserinfo.lastIndexOf(":");
246
- if (portSeparator === -1) return false;
247
- return withoutUserinfo.indexOf(":") === portSeparator && portSeparator === withoutUserinfo.length - 1;
248
- }
249
- function rawAuthorityHostStartsWithDigit(authority) {
250
- const firstChar = rawHostFromAuthority(authority)[0];
251
- return firstChar !== void 0 && firstChar >= "0" && firstChar <= "9";
252
- }
253
- function runtimeAuthorityOriginForHostValidation(url) {
254
- const authority = rawAuthorityFromUrl(url);
255
- if (authority === null) return null;
256
- if (!authority.includes("%") && !hasNonAscii(authority) && !rawAuthorityHostStartsWithDigit(authority)) {
257
- return null;
258
- }
259
- const schemeEnd = url.indexOf("://");
260
- if (schemeEnd === -1) return null;
261
- return `${url.slice(0, schemeEnd)}://${authority}`;
262
- }
263
- function hasPercentEncodedAuthoritySyntax(value) {
264
- let index = value.indexOf("%");
265
- while (index !== -1) {
266
- let runEnd = index;
267
- while (runEnd < value.length && value[runEnd] === "%") {
268
- const firstHexDigit = value[runEnd + 1];
269
- const secondHexDigit = value[runEnd + 2];
270
- if (!firstHexDigit || !secondHexDigit || !HEX_DIGITS.has(firstHexDigit) || !HEX_DIGITS.has(secondHexDigit)) {
271
- return true;
272
- }
273
- runEnd += PERCENT_ESCAPE_LENGTH;
274
- }
275
- let decodedRun;
276
- try {
277
- decodedRun = decodeURIComponent(value.slice(index, runEnd));
278
- } catch {
279
- return true;
280
- }
281
- for (const char of decodedRun) {
282
- if (PERCENT_DECODED_AUTHORITY_SYNTAX_CHARS.has(char)) {
283
- return true;
284
- }
285
- }
286
- index = value.indexOf("%", runEnd);
287
- }
288
- return false;
289
- }
290
- function hasMalformedRuntimeAuthoritySyntax(url) {
291
- const authority = rawAuthorityFromUrl(url);
292
- if (authority === null) return false;
293
- return authority.includes("\\") || authorityHasEmptyPort(authority) || hasPercentEncodedAuthoritySyntax(authority);
294
- }
295
- function scoreLiteralSegment(segment) {
296
- return LITERAL_SEGMENT_SCORE + codePointLength(segment);
297
- }
298
- function scorePatternSegment(segment, allowParams) {
299
- if (!allowParams) return scoreLiteralSegment(segment);
300
- const parsed = parseSegment(segment);
301
- if (parsed.kind === "error") return 0;
302
- if (parsed.kind === "literal") {
303
- return scoreLiteralSegment(parsed.value);
304
- }
305
- const literalChars = codePointLength(parsed.prefix) + codePointLength(parsed.suffix);
306
- if (parsed.prefix !== "" || parsed.suffix !== "") {
307
- return MIXED_PARAM_SEGMENT_SCORE + literalChars;
308
- }
309
- if (parsed.greedy === "+") return PLUS_GREEDY_SEGMENT_SCORE;
310
- if (parsed.greedy === "*") return 0;
311
- return PLAIN_PARAM_SEGMENT_SCORE;
312
- }
313
- function scorePatternSegments(segments, allowParams) {
314
- return segments.reduce((score, segment) => {
315
- return score + scorePatternSegment(segment, allowParams);
316
- }, 0);
317
- }
318
- function scorePathPattern(path, allowParams) {
319
- if (path === "") return 0;
320
- if (path === "/") return ROOT_PATH_SCORE;
321
- return scorePatternSegments(splitPathSegments(path), allowParams);
322
- }
323
- function splitAuthoritySegments(authority) {
324
- if (authority.startsWith("[")) return [authority];
325
- const normalized = authority.endsWith(".") ? authority.slice(0, -1) : authority;
326
- return normalized === "" ? [] : normalized.split(".");
327
- }
328
- function baseUrlSpecificityScore(rawBase, hasParams) {
329
- const baseForMatch = stripTrailingSlash(rawBase);
330
- const authorityScore = scorePatternSegments(
331
- splitAuthoritySegments(rawAuthorityFromUrl(baseForMatch) ?? ""),
332
- hasParams
333
- );
334
- const pathScore = scorePathPattern(
335
- rawBasePathFromUrl(baseForMatch),
336
- hasParams
337
- );
338
- return pathScore * PATH_SCORE_MULTIPLIER + authorityScore * AUTHORITY_SCORE_MULTIPLIER + (hasParams ? 0 : STATIC_BASE_SCORE_BONUS);
339
- }
340
- function matchStaticBasePathPrefix(path, pattern) {
341
- if (pattern === "") {
342
- return path === "" ? "/" : path;
343
- }
344
- if (pattern === "/") {
345
- if (!path.startsWith(pattern)) return null;
346
- const relativePath2 = path.slice(pattern.length);
347
- if (relativePath2 !== "" && !relativePath2.startsWith("/")) return null;
348
- return relativePath2 === "" ? "/" : relativePath2;
349
- }
350
- if (!path.startsWith(pattern)) return null;
351
- const relativePath = path.slice(pattern.length);
352
- if (relativePath !== "" && !relativePath.startsWith("/")) return null;
353
- return relativePath === "" ? "/" : relativePath;
354
- }
355
- function normalizeUrlHostname(hostname, options = {}) {
356
- let normalized = hostname.toLowerCase();
357
- if (normalized.endsWith(".")) {
358
- normalized = normalized.slice(0, -1);
359
- if (normalized === "" || normalized.endsWith(".")) {
360
- return null;
361
- }
362
- }
363
- if (normalized.split(".").some((label) => {
364
- return label === "";
365
- })) {
366
- return null;
367
- }
368
- const forbiddenChars = options.allowHostParams === true ? FORBIDDEN_BASE_PATTERN_HOST_CHARS : FORBIDDEN_RUNTIME_HOST_CHARS;
369
- if (!normalized.startsWith("[") && [...normalized].some((char) => {
370
- return forbiddenChars.has(char);
371
- })) {
372
- return null;
373
- }
374
- return normalized;
375
- }
376
- function normalizedUrlAuthority(parsed, options = {}) {
377
- if (parsed.username !== "" || parsed.password !== "") {
378
- return null;
379
- }
380
- const hostname = normalizeUrlHostname(parsed.hostname, options);
381
- if (hostname === null || hostname === "") {
382
- return null;
383
- }
384
- return parsed.port === "" ? hostname : `${hostname}:${parsed.port}`;
385
- }
386
- function matchStaticFirewallBaseUrl(url, rawBase) {
387
- const parsedUrl = new URL(url);
388
- const parsedBase = new URL(rawBase);
389
- if (parsedUrl.protocol.toLowerCase() !== parsedBase.protocol.toLowerCase()) {
390
- return null;
391
- }
392
- const baseHasParams = hasBaseUrlParams(rawBase);
393
- const baseForMatch = stripTrailingSlash(rawBase);
394
- const urlAuthority = normalizedUrlAuthority(parsedUrl);
395
- const baseAuthority = normalizedUrlAuthority(parsedBase, {
396
- allowHostParams: baseHasParams
397
- });
398
- if (urlAuthority === null || baseAuthority === null) return null;
399
- if (baseHasParams) {
400
- if (matchFirewallHost(urlAuthority, baseAuthority) === null) return null;
401
- } else if (urlAuthority !== baseAuthority) {
402
- return null;
403
- }
404
- const basePath = rawBasePathFromUrl(baseForMatch);
405
- const relativePath = baseHasParams ? matchFirewallPathPrefix(rawPathFromUrl(url), basePath) : matchStaticBasePathPrefix(rawPathFromUrl(url), basePath);
406
- if (relativePath === null) return null;
407
- const displayBase = stripTrailingSlash(rawBase);
408
- return {
409
- displayBase,
410
- relativePath,
411
- score: baseUrlSpecificityScore(rawBase, baseHasParams)
412
- };
413
- }
414
- function matchFirewallBaseUrl(url, rawBase) {
415
- if (hasUnsafeRuntimeUrlSyntax(url) || hasMalformedRuntimeAuthoritySyntax(url)) {
416
- return null;
417
- }
418
- const runtimeAuthorityOrigin = runtimeAuthorityOriginForHostValidation(url);
419
- try {
420
- if (runtimeAuthorityOrigin !== null) {
421
- validateBaseUrl(runtimeAuthorityOrigin, "runtime");
422
- }
423
- validateBaseUrl(rawBase, "firewall");
424
- return matchStaticFirewallBaseUrl(url, rawBase);
425
- } catch {
426
- return null;
427
- }
428
- }
429
- function matchFirewallHost(host, pattern) {
430
- const hostSegsOrig = host.split(".");
431
- const hostSegsLower = hostSegsOrig.map((segment) => {
432
- return segment.toLowerCase();
433
- });
434
- const patternSegs = pattern.split(".").reverse();
435
- hostSegsOrig.reverse();
436
- hostSegsLower.reverse();
437
- const params = {};
438
- let hi = 0;
439
- const lastPatternIndex = patternSegs.length - 1;
440
- for (let patternIndex = 0; patternIndex < patternSegs.length; patternIndex++) {
441
- const seg = patternSegs[patternIndex];
442
- const parsed = parseSegment(seg);
443
- if (parsed.kind === "error") return null;
444
- if (parsed.kind === "literal") {
445
- if (hi >= hostSegsLower.length || hostSegsLower[hi] !== parsed.value.toLowerCase()) {
446
- return null;
447
- }
448
- hi += 1;
449
- continue;
450
- }
451
- const { name, prefix, suffix, greedy } = parsed;
452
- if (greedy === "+") {
453
- if (isInvalidGreedyParam(patternIndex, lastPatternIndex, prefix, suffix))
454
- return null;
455
- if (hi >= hostSegsOrig.length) return null;
456
- params[name] = hostSegsOrig.slice(hi).reverse().join(".");
457
- return params;
458
- }
459
- if (greedy === "*") {
460
- if (isInvalidGreedyParam(patternIndex, lastPatternIndex, prefix, suffix))
461
- return null;
462
- params[name] = hostSegsOrig.slice(hi).reverse().join(".");
463
- return params;
464
- }
465
- if (hi >= hostSegsOrig.length) return null;
466
- if (prefix === "" && suffix === "") {
467
- params[name] = hostSegsLower[hi];
468
- } else {
469
- const captured = matchMixedSegment(
470
- hostSegsLower[hi],
471
- prefix.toLowerCase(),
472
- suffix.toLowerCase()
473
- );
474
- if (captured === null) return null;
475
- params[name] = captured;
476
- }
477
- hi += 1;
478
- }
479
- return hi === hostSegsOrig.length ? params : null;
480
- }
481
- function matchFirewallPathPrefix(path, pattern) {
482
- const pathSegs = splitPathSegments(path);
483
- const patternSegs = splitPathSegments(pattern);
484
- let pi = 0;
485
- const lastPatternIndex = patternSegs.length - 1;
486
- for (let patternIndex = 0; patternIndex < patternSegs.length; patternIndex++) {
487
- const seg = patternSegs[patternIndex];
488
- const parsed = parseSegment(seg);
489
- if (parsed.kind === "error") return null;
490
- if (parsed.kind === "literal") {
491
- if (pi >= pathSegs.length || pathSegs[pi] !== parsed.value) return null;
492
- pi += 1;
493
- continue;
494
- }
495
- const { prefix, suffix, greedy } = parsed;
496
- if (greedy === "+") {
497
- if (isInvalidGreedyParam(patternIndex, lastPatternIndex, prefix, suffix))
498
- return null;
499
- if (pi >= pathSegs.length || !hasNonEmptySegment(pathSegs, pi)) {
500
- return null;
501
- }
502
- return "/";
503
- }
504
- if (greedy === "*") {
505
- if (isInvalidGreedyParam(patternIndex, lastPatternIndex, prefix, suffix))
506
- return null;
507
- return "/";
508
- }
509
- if (pi >= pathSegs.length) return null;
510
- const runtime = pathSegs[pi];
511
- if (prefix === "" && suffix === "") {
512
- if (runtime === "") return null;
513
- } else if (matchMixedSegment(runtime, prefix, suffix) === null) {
514
- return null;
515
- }
516
- pi += 1;
517
- }
518
- return relativePathFromSegments(pathSegs, pi);
519
- }
520
- function matchFirewallPath(path, pattern) {
521
- const pathSegs = splitPathSegments(path);
522
- const patternSegs = splitPathSegments(pattern);
523
- const params = {};
524
- let pi = 0;
525
- const lastPatternIndex = patternSegs.length - 1;
526
- for (let patternIndex = 0; patternIndex < patternSegs.length; patternIndex++) {
527
- const seg = patternSegs[patternIndex];
528
- const parsed = parseSegment(seg);
529
- if (parsed.kind === "error") return null;
530
- if (parsed.kind === "literal") {
531
- if (pi >= pathSegs.length || pathSegs[pi] !== parsed.value) return null;
532
- pi++;
533
- continue;
534
- }
535
- const { name, prefix, suffix, greedy } = parsed;
536
- if (greedy === "+") {
537
- if (isInvalidGreedyParam(patternIndex, lastPatternIndex, prefix, suffix))
538
- return null;
539
- if (pi >= pathSegs.length || !hasNonEmptySegment(pathSegs, pi)) {
540
- return null;
541
- }
542
- params[name] = pathSegs.slice(pi).join("/");
543
- return params;
544
- }
545
- if (greedy === "*") {
546
- if (isInvalidGreedyParam(patternIndex, lastPatternIndex, prefix, suffix))
547
- return null;
548
- params[name] = pathSegs.slice(pi).join("/");
549
- return params;
550
- }
551
- if (pi >= pathSegs.length) return null;
552
- const runtime = pathSegs[pi];
553
- if (prefix === "" && suffix === "") {
554
- if (runtime === "") return null;
555
- params[name] = runtime;
556
- } else {
557
- const captured = matchMixedSegment(runtime, prefix, suffix);
558
- if (captured === null) return null;
559
- params[name] = captured;
560
- }
561
- pi++;
562
- }
563
- if (pi !== pathSegs.length) return null;
564
- return params;
565
- }
566
- function findMatchingRoutingPermissions(method, path, apis, options = {}) {
567
- if (!Array.isArray(apis)) return [];
568
- const serviceName = options.serviceName ?? "routing";
569
- const apiBase = options.apiBase === void 0 ? null : stripTrailingSlash(options.apiBase);
570
- const matchApis = [];
571
- for (const api of apis) {
572
- const permissionRuleSets = getRoutingApiPermissionRuleSetsForMatch(
573
- api,
574
- serviceName,
575
- apiBase
576
- );
577
- if (permissionRuleSets !== null) {
578
- matchApis.push({ permissionRuleSets });
579
- }
580
- }
581
- return findMatchingPermissionRuleSets(method, path, matchApis);
582
- }
583
- function findMatchingPermissionRuleSets(method, path, apis) {
584
- const upperMethod = method.toUpperCase();
585
- const matched = [];
586
- for (const api of apis) {
587
- const state = { bestSpecificity: null, matched: [] };
588
- for (const permission of api.permissionRuleSets) {
589
- for (const rule of permission.rules) {
590
- const rest = matchingRulePath(rule, upperMethod);
591
- if (rest === null) continue;
592
- if (matchFirewallPath(path, rest) !== null) {
593
- const specificity = pathSpecificity(rest);
594
- if (specificity === null) continue;
595
- recordPermissionMatch(state, permission.name, specificity);
596
- }
597
- }
598
- }
599
- for (const permission of state.matched) {
600
- if (!matched.includes(permission)) {
601
- matched.push(permission);
602
- }
603
- }
604
- }
605
- return matched;
606
- }
607
-
608
- export {
609
- matchFirewallBaseUrl,
610
- findMatchingRoutingPermissions
611
- };
612
- //# sourceMappingURL=chunk-KJNJT27A.js.map