@vm0/cli 9.238.2 → 9.238.4

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 (114) hide show
  1. package/{agent-232YB3UW.js → agent-DY657IHK.js} +6 -8
  2. package/{agent-232YB3UW.js.map → agent-DY657IHK.js.map} +1 -1
  3. package/{banking-W4YOUOGR.js → banking-WZ5ZXNHW.js} +4 -6
  4. package/{banking-W4YOUOGR.js.map → banking-WZ5ZXNHW.js.map} +1 -1
  5. package/{chat-U7IY4EFM.js → chat-ORHRUMSC.js} +5 -7
  6. package/{chat-U7IY4EFM.js.map → chat-ORHRUMSC.js.map} +1 -1
  7. package/{chunk-TDHY3N5U.js → chunk-6TXV6T6G.js} +2 -2
  8. package/{chunk-QRWCZFSW.js → chunk-APIZB5CD.js} +5 -7
  9. package/{chunk-QRWCZFSW.js.map → chunk-APIZB5CD.js.map} +1 -1
  10. package/{chunk-LSV2VNTU.js → chunk-CYF7PHDS.js} +2832 -1327
  11. package/chunk-CYF7PHDS.js.map +1 -0
  12. package/{chunk-63SY7N6Y.js → chunk-EH4MVCB3.js} +2 -2
  13. package/{chunk-5IL2HDF6.js → chunk-GA7UX3FL.js} +1408 -32
  14. package/chunk-GA7UX3FL.js.map +1 -0
  15. package/{chunk-OJDPK7NK.js → chunk-GU4IPLKQ.js} +2 -2
  16. package/{chunk-OJDPK7NK.js.map → chunk-GU4IPLKQ.js.map} +1 -1
  17. package/{chunk-LKJRJF2G.js → chunk-JH5O3APS.js} +3 -3
  18. package/{chunk-PT3JWQPE.js → chunk-MZTSDUUX.js} +2 -2
  19. package/{chunk-HVKP7UPZ.js → chunk-XVW5RA46.js} +23 -1051
  20. package/chunk-XVW5RA46.js.map +1 -0
  21. package/{chunk-V2OYP5BZ.js → chunk-Z4SU5SW5.js} +227 -200
  22. package/chunk-Z4SU5SW5.js.map +1 -0
  23. package/{chunk-H3PJLBYQ.js → chunk-ZRG2A3OV.js} +4 -4
  24. package/{computer-use-FMWOZUIP.js → computer-use-NKBLGFEQ.js} +3 -4
  25. package/{computer-use-FMWOZUIP.js.map → computer-use-NKBLGFEQ.js.map} +1 -1
  26. package/{connector-YOH3JOKV.js → connector-7AIQZYTK.js} +5 -7
  27. package/{connector-YOH3JOKV.js.map → connector-7AIQZYTK.js.map} +1 -1
  28. package/{credit-BSKBYVKJ.js → credit-TIOONK33.js} +5 -7
  29. package/{credit-BSKBYVKJ.js.map → credit-TIOONK33.js.map} +1 -1
  30. package/{developer-support-MLHK3AS5.js → developer-support-IM7P3PNY.js} +3 -4
  31. package/{developer-support-MLHK3AS5.js.map → developer-support-IM7P3PNY.js.map} +1 -1
  32. package/{doctor-AXSIJ2XY.js → doctor-UG5O6IF2.js} +32 -18
  33. package/doctor-UG5O6IF2.js.map +1 -0
  34. package/{generate-IX7Y7HZH.js → generate-FFZOGVVZ.js} +6 -8
  35. package/{generate-IX7Y7HZH.js.map → generate-FFZOGVVZ.js.map} +1 -1
  36. package/{github-DLJEXA4P.js → github-B4A2NYZE.js} +3 -4
  37. package/{github-DLJEXA4P.js.map → github-B4A2NYZE.js.map} +1 -1
  38. package/{goal-R6NDTIHJ.js → goal-MQVOVTDO.js} +3 -4
  39. package/{goal-R6NDTIHJ.js.map → goal-MQVOVTDO.js.map} +1 -1
  40. package/google-contacts.generated-FL6Z7MTD.js +16 -0
  41. package/google-contacts.generated-FL6Z7MTD.js.map +1 -0
  42. package/google-contacts.generated-Q67YBTPW.js +16 -0
  43. package/google-contacts.generated-Q67YBTPW.js.map +1 -0
  44. package/google-forms.generated-AOKO24AB.js +16 -0
  45. package/google-forms.generated-AOKO24AB.js.map +1 -0
  46. package/google-forms.generated-KDCHIV43.js +16 -0
  47. package/google-forms.generated-KDCHIV43.js.map +1 -0
  48. package/{host-VD5GWO4T.js → host-OP2HJH6Y.js} +4 -6
  49. package/{host-VD5GWO4T.js.map → host-OP2HJH6Y.js.map} +1 -1
  50. package/index.js +17 -20
  51. package/index.js.map +1 -1
  52. package/{logs-NQI3ITVT.js → logs-CA6HKKD7.js} +8 -11
  53. package/{logs-NQI3ITVT.js.map → logs-CA6HKKD7.js.map} +1 -1
  54. package/{maps-XLAARX76.js → maps-IR4XLNKS.js} +4 -6
  55. package/{maps-XLAARX76.js.map → maps-IR4XLNKS.js.map} +1 -1
  56. package/{memory-UUNI5B2C.js → memory-KRW4WNNT.js} +4 -6
  57. package/{memory-UUNI5B2C.js.map → memory-KRW4WNNT.js.map} +1 -1
  58. package/{model-LMW4L5P6.js → model-N4ZX7CTX.js} +6 -8
  59. package/{model-LMW4L5P6.js.map → model-N4ZX7CTX.js.map} +1 -1
  60. package/{model-provider-2FCSBI3H.js → model-provider-U4P563EL.js} +5 -7
  61. package/{model-provider-2FCSBI3H.js.map → model-provider-U4P563EL.js.map} +1 -1
  62. package/{org-N6CEZGPY.js → org-IESFCHFN.js} +10 -12
  63. package/{org-N6CEZGPY.js.map → org-IESFCHFN.js.map} +1 -1
  64. package/package.json +1 -1
  65. package/{phone-LZ5VKEA5.js → phone-EBV43OF4.js} +4 -6
  66. package/{phone-LZ5VKEA5.js.map → phone-EBV43OF4.js.map} +1 -1
  67. package/{preference-F2IDGWK3.js → preference-ZBNLMRLI.js} +4 -6
  68. package/{preference-F2IDGWK3.js.map → preference-ZBNLMRLI.js.map} +1 -1
  69. package/{relationship-7EV3WLB3.js → relationship-TP2F7LLQ.js} +4 -6
  70. package/{relationship-7EV3WLB3.js.map → relationship-TP2F7LLQ.js.map} +1 -1
  71. package/{resource-MJISJ52Q.js → resource-OTHN2AGX.js} +5 -7
  72. package/{resource-MJISJ52Q.js.map → resource-OTHN2AGX.js.map} +1 -1
  73. package/{search-SEXZVPOC.js → search-4JZ5XQIQ.js} +8 -11
  74. package/{search-SEXZVPOC.js.map → search-4JZ5XQIQ.js.map} +1 -1
  75. package/{secret-Z3CACK36.js → secret-73Y3IETU.js} +12 -26
  76. package/secret-73Y3IETU.js.map +1 -0
  77. package/{slack-QDZZZ2AV.js → slack-5NXJ5HF5.js} +4 -6
  78. package/{slack-QDZZZ2AV.js.map → slack-5NXJ5HF5.js.map} +1 -1
  79. package/{teams-LG4URJER.js → teams-DXT4NI2S.js} +4 -6
  80. package/{teams-LG4URJER.js.map → teams-DXT4NI2S.js.map} +1 -1
  81. package/{telegram-GLGHTNGM.js → telegram-DRWWXQNJ.js} +4 -6
  82. package/{telegram-GLGHTNGM.js.map → telegram-DRWWXQNJ.js.map} +1 -1
  83. package/{variable-TXYIWD3G.js → variable-LP5GN2VJ.js} +4 -6
  84. package/{variable-TXYIWD3G.js.map → variable-LP5GN2VJ.js.map} +1 -1
  85. package/{video-E56LX44R.js → video-TNA6D37U.js} +2 -3
  86. package/{video-E56LX44R.js.map → video-TNA6D37U.js.map} +1 -1
  87. package/{web-Q3NRMNK3.js → web-KNGVOG6B.js} +3 -4
  88. package/{web-Q3NRMNK3.js.map → web-KNGVOG6B.js.map} +1 -1
  89. package/{whoami-HRHU43T7.js → whoami-O7ZRGGC7.js} +6 -8
  90. package/{whoami-HRHU43T7.js.map → whoami-O7ZRGGC7.js.map} +1 -1
  91. package/{workflow-S46MZV7Z.js → workflow-FYC7N3RU.js} +5 -7
  92. package/workflow-FYC7N3RU.js.map +1 -0
  93. package/zero.js +34 -51
  94. package/zero.js.map +1 -1
  95. package/automation-7MAK66QT.js +0 -31
  96. package/automation-7MAK66QT.js.map +0 -1
  97. package/chunk-5BTPFZG2.js +0 -1301
  98. package/chunk-5BTPFZG2.js.map +0 -1
  99. package/chunk-5IL2HDF6.js.map +0 -1
  100. package/chunk-HVKP7UPZ.js.map +0 -1
  101. package/chunk-JUTUEPIR.js +0 -512
  102. package/chunk-JUTUEPIR.js.map +0 -1
  103. package/chunk-LSV2VNTU.js.map +0 -1
  104. package/chunk-V2OYP5BZ.js.map +0 -1
  105. package/doctor-AXSIJ2XY.js.map +0 -1
  106. package/schedule-OSHL7HWT.js +0 -33
  107. package/schedule-OSHL7HWT.js.map +0 -1
  108. package/secret-Z3CACK36.js.map +0 -1
  109. package/workflow-S46MZV7Z.js.map +0 -1
  110. /package/{chunk-TDHY3N5U.js.map → chunk-6TXV6T6G.js.map} +0 -0
  111. /package/{chunk-63SY7N6Y.js.map → chunk-EH4MVCB3.js.map} +0 -0
  112. /package/{chunk-LKJRJF2G.js.map → chunk-JH5O3APS.js.map} +0 -0
  113. /package/{chunk-PT3JWQPE.js.map → chunk-MZTSDUUX.js.map} +0 -0
  114. /package/{chunk-H3PJLBYQ.js.map → chunk-ZRG2A3OV.js.map} +0 -0
@@ -1,9 +1,19 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __createRequire } from "node:module";
3
3
  const require = __createRequire(import.meta.url);
4
+ import {
5
+ hasBaseUrlParams,
6
+ hasRawWhitespace,
7
+ hasUnsafeFirewallPath,
8
+ hasUnsafeUrlCodepoint,
9
+ parseSegment,
10
+ splitPathSegments,
11
+ validateAuthBaseUrl,
12
+ validateBaseUrl
13
+ } from "./chunk-XVW5RA46.js";
4
14
  import {
5
15
  external_exports
6
- } from "./chunk-LSV2VNTU.js";
16
+ } from "./chunk-CYF7PHDS.js";
7
17
  import {
8
18
  init_esm_shims
9
19
  } from "./chunk-DIRAZ3YX.js";
@@ -547,6 +557,63 @@ var googleCalendar = {
547
557
  }
548
558
  };
549
559
 
560
+ // ../../packages/connectors/src/connectors/google-contacts.ts
561
+ init_esm_shims();
562
+ var googleContacts = {
563
+ "google-contacts": {
564
+ label: "Google Contacts",
565
+ category: "communication-collaboration",
566
+ tags: ["contacts", "address-book", "people"],
567
+ helpText: "Connect your Google account to access and manage contacts and contact groups",
568
+ authMethods: {
569
+ oauth: {
570
+ featureFlag: "googleContactsConnector" /* GoogleContactsConnector */,
571
+ label: "OAuth (Recommended)",
572
+ helpText: "Sign in with Google to grant Google Contacts access.",
573
+ client: {
574
+ clientRegistration: "static",
575
+ clientType: "confidential",
576
+ clientIdEnv: "GOOGLE_OAUTH_CLIENT_ID",
577
+ clientSecretEnv: "GOOGLE_OAUTH_CLIENT_SECRET"
578
+ },
579
+ storage: {
580
+ secrets: [
581
+ "GOOGLE_CONTACTS_ACCESS_TOKEN",
582
+ "GOOGLE_CONTACTS_REFRESH_TOKEN"
583
+ ],
584
+ variables: []
585
+ },
586
+ grant: {
587
+ kind: "auth-code",
588
+ scopes: [
589
+ "https://www.googleapis.com/auth/contacts",
590
+ "https://www.googleapis.com/auth/userinfo.email"
591
+ ],
592
+ outputs: {
593
+ accessToken: "$secrets.GOOGLE_CONTACTS_ACCESS_TOKEN",
594
+ refreshToken: "$secrets.GOOGLE_CONTACTS_REFRESH_TOKEN"
595
+ }
596
+ },
597
+ access: {
598
+ kind: "refresh-token",
599
+ inputs: {
600
+ refreshToken: "$secrets.GOOGLE_CONTACTS_REFRESH_TOKEN"
601
+ },
602
+ outputs: {
603
+ accessToken: "$secrets.GOOGLE_CONTACTS_ACCESS_TOKEN",
604
+ refreshToken: "$secrets.GOOGLE_CONTACTS_REFRESH_TOKEN"
605
+ },
606
+ refreshableSecrets: ["GOOGLE_CONTACTS_ACCESS_TOKEN"],
607
+ envBindings: {
608
+ GOOGLE_CONTACTS_TOKEN: "$secrets.GOOGLE_CONTACTS_ACCESS_TOKEN"
609
+ }
610
+ },
611
+ revoke: { kind: "none" }
612
+ }
613
+ }
614
+ }
615
+ };
616
+
550
617
  // ../../packages/connectors/src/connectors/google-docs.ts
551
618
  init_esm_shims();
552
619
  var googleDocs = {
@@ -599,6 +666,61 @@ var googleDocs = {
599
666
  }
600
667
  };
601
668
 
669
+ // ../../packages/connectors/src/connectors/google-forms.ts
670
+ init_esm_shims();
671
+ var googleForms = {
672
+ "google-forms": {
673
+ label: "Google Forms",
674
+ category: "docs-files-knowledge",
675
+ tags: ["forms", "surveys", "questionnaires", "responses"],
676
+ helpText: "Connect your Google account to create and manage forms and read responses",
677
+ authMethods: {
678
+ oauth: {
679
+ featureFlag: "googleFormsConnector" /* GoogleFormsConnector */,
680
+ label: "OAuth (Recommended)",
681
+ helpText: "Sign in with Google to grant Google Forms access.",
682
+ client: {
683
+ clientRegistration: "static",
684
+ clientType: "confidential",
685
+ clientIdEnv: "GOOGLE_OAUTH_CLIENT_ID",
686
+ clientSecretEnv: "GOOGLE_OAUTH_CLIENT_SECRET"
687
+ },
688
+ storage: {
689
+ secrets: ["GOOGLE_FORMS_ACCESS_TOKEN", "GOOGLE_FORMS_REFRESH_TOKEN"],
690
+ variables: []
691
+ },
692
+ grant: {
693
+ kind: "auth-code",
694
+ scopes: [
695
+ "https://www.googleapis.com/auth/forms.body",
696
+ "https://www.googleapis.com/auth/forms.responses.readonly",
697
+ "https://www.googleapis.com/auth/userinfo.email"
698
+ ],
699
+ outputs: {
700
+ accessToken: "$secrets.GOOGLE_FORMS_ACCESS_TOKEN",
701
+ refreshToken: "$secrets.GOOGLE_FORMS_REFRESH_TOKEN"
702
+ }
703
+ },
704
+ access: {
705
+ kind: "refresh-token",
706
+ inputs: {
707
+ refreshToken: "$secrets.GOOGLE_FORMS_REFRESH_TOKEN"
708
+ },
709
+ outputs: {
710
+ accessToken: "$secrets.GOOGLE_FORMS_ACCESS_TOKEN",
711
+ refreshToken: "$secrets.GOOGLE_FORMS_REFRESH_TOKEN"
712
+ },
713
+ refreshableSecrets: ["GOOGLE_FORMS_ACCESS_TOKEN"],
714
+ envBindings: {
715
+ GOOGLE_FORMS_TOKEN: "$secrets.GOOGLE_FORMS_ACCESS_TOKEN"
716
+ }
717
+ },
718
+ revoke: { kind: "none" }
719
+ }
720
+ }
721
+ }
722
+ };
723
+
602
724
  // ../../packages/connectors/src/connectors/google-cloud.ts
603
725
  init_esm_shims();
604
726
  var googleCloud = {
@@ -14143,7 +14265,9 @@ var CONNECTOR_TYPES_DEF = defineConnectors({
14143
14265
  ...slock,
14144
14266
  ...googleSheets,
14145
14267
  ...googleCalendar,
14268
+ ...googleContacts,
14146
14269
  ...googleDocs,
14270
+ ...googleForms,
14147
14271
  ...linear,
14148
14272
  ...intervalsIcu,
14149
14273
  ...vercel,
@@ -14495,9 +14619,6 @@ function connectorRuntimeEnvBindings(envBindings) {
14495
14619
  })
14496
14620
  );
14497
14621
  }
14498
- function connectorAuthMethodOwnedSecretNames(method) {
14499
- return method ? [...method.storage.secrets] : [];
14500
- }
14501
14622
  function getConnectorAuthMethodEnvBindings(type, authMethod) {
14502
14623
  const method = getConnectorAuthMethod(type, authMethod);
14503
14624
  return method ? connectorAccessRuntimeEnvBindings(method.access) : {};
@@ -14512,31 +14633,6 @@ function getConnectorEnvBindingEntries(type) {
14512
14633
  }
14513
14634
  return entries;
14514
14635
  }
14515
- function getConnectorStoredSecretDisplayInfo(secretName) {
14516
- const allTypes = CONNECTOR_TYPE_KEYS;
14517
- for (const type of allTypes) {
14518
- const config = CONNECTOR_TYPES[type];
14519
- const found = Object.values(config.authMethods).some((method) => {
14520
- return connectorAuthMethodOwnedSecretNames(method).includes(secretName);
14521
- });
14522
- if (!found) {
14523
- continue;
14524
- }
14525
- const envNames = [
14526
- ...new Set(
14527
- getConnectorEnvBindingEntries(type).filter(({ valueRef }) => {
14528
- return valueRef === `$secrets.${secretName}`;
14529
- }).map(({ envName }) => {
14530
- return envName;
14531
- })
14532
- )
14533
- ];
14534
- if (envNames.length > 0) {
14535
- return { connectorLabel: config.label, envNames };
14536
- }
14537
- }
14538
- return null;
14539
- }
14540
14636
  function getDiagnosticConnectorTypeForRuntimeEnvName(envName) {
14541
14637
  for (const type of CONNECTOR_TYPE_KEYS) {
14542
14638
  const hasEnvName = getConnectorEnvBindingEntries(type).some((entry) => {
@@ -14549,10 +14645,1290 @@ function getDiagnosticConnectorTypeForRuntimeEnvName(envName) {
14549
14645
  return null;
14550
14646
  }
14551
14647
 
14648
+ // ../../packages/connectors/src/firewall-rule-matcher.ts
14649
+ init_esm_shims();
14650
+ var VALID_RULE_METHODS = /* @__PURE__ */ new Set([
14651
+ "GET",
14652
+ "POST",
14653
+ "PUT",
14654
+ "PATCH",
14655
+ "DELETE",
14656
+ "HEAD",
14657
+ "OPTIONS",
14658
+ "ANY"
14659
+ ]);
14660
+ var FORBIDDEN_RUNTIME_HOST_CHARS = new Set("#%*,/<>?@\\^|{}".split(""));
14661
+ var FORBIDDEN_BASE_PATTERN_HOST_CHARS = new Set("#%,/<>?@\\^|".split(""));
14662
+ var PERCENT_ESCAPE_LENGTH = 3;
14663
+ var HEX_DIGITS = new Set("0123456789abcdefABCDEF".split(""));
14664
+ var PATH_SCORE_MULTIPLIER = 1e6;
14665
+ var AUTHORITY_SCORE_MULTIPLIER = 100;
14666
+ var LITERAL_SEGMENT_SCORE = 1e3;
14667
+ var MIXED_PARAM_SEGMENT_SCORE = 100;
14668
+ var PLAIN_PARAM_SEGMENT_SCORE = 10;
14669
+ var PLUS_GREEDY_SEGMENT_SCORE = 1;
14670
+ var ROOT_PATH_SCORE = 1;
14671
+ var STATIC_BASE_SCORE_BONUS = 1;
14672
+ var PERCENT_DECODED_AUTHORITY_SYNTAX_CHARS = /* @__PURE__ */ new Set([
14673
+ "{",
14674
+ "}",
14675
+ "*",
14676
+ ".",
14677
+ "\u3002",
14678
+ "\uFF0E",
14679
+ "\uFF61",
14680
+ ":"
14681
+ ]);
14682
+ function matchMixedSegment(runtime2, prefix, suffix) {
14683
+ if (!runtime2.startsWith(prefix)) return null;
14684
+ if (!runtime2.endsWith(suffix)) return null;
14685
+ if (runtime2.length <= prefix.length + suffix.length) return null;
14686
+ return runtime2.slice(prefix.length, runtime2.length - suffix.length);
14687
+ }
14688
+ function hasNonEmptySegment(segments, start) {
14689
+ for (let i = start; i < segments.length; i++) {
14690
+ if (segments[i] !== "") return true;
14691
+ }
14692
+ return false;
14693
+ }
14694
+ function codePointLength(value) {
14695
+ return [...value].length;
14696
+ }
14697
+ function hasUnsafeRuntimeUrlSyntax(value) {
14698
+ return hasUnsafeUrlCodepoint(value) || hasRawWhitespace(value) || value.includes("\\") || !value.includes("://");
14699
+ }
14700
+ function stripTrailingSlash(value) {
14701
+ return value.endsWith("/") ? value.slice(0, -1) : value;
14702
+ }
14703
+ function isInvalidGreedyParam(patternIndex, lastPatternIndex, prefix, suffix) {
14704
+ return patternIndex !== lastPatternIndex || prefix !== "" || suffix !== "";
14705
+ }
14706
+ function parseStrictMatchSegment(segment2, patternIndex, lastPatternIndex) {
14707
+ const parsed = parseSegment(segment2);
14708
+ if (parsed.kind === "error") return null;
14709
+ if (parsed.kind === "param" && parsed.greedy !== "" && isInvalidGreedyParam(
14710
+ patternIndex,
14711
+ lastPatternIndex,
14712
+ parsed.prefix,
14713
+ parsed.suffix
14714
+ )) {
14715
+ return null;
14716
+ }
14717
+ return parsed;
14718
+ }
14719
+ function pathSpecificity(pattern) {
14720
+ if (!pattern.startsWith("/") || pattern.includes("?") || pattern.includes("#") || pattern.includes("\\") || hasRawWhitespace(pattern) || hasUnsafeUrlCodepoint(pattern)) {
14721
+ return null;
14722
+ }
14723
+ let literalSegments = 0;
14724
+ let mixedParamSegments = 0;
14725
+ let plainParamSegments = 0;
14726
+ let plusGreedySegments = 0;
14727
+ let starGreedySegments = 0;
14728
+ let literalChars = 0;
14729
+ const segments = splitPathSegments(pattern);
14730
+ const paramNames = /* @__PURE__ */ new Set();
14731
+ const lastSegmentIndex = segments.length - 1;
14732
+ for (let index = 0; index < segments.length; index += 1) {
14733
+ const seg = segments[index];
14734
+ const parsed = parseSegment(seg);
14735
+ if (parsed.kind === "error") return null;
14736
+ if (parsed.kind === "literal") {
14737
+ literalSegments += 1;
14738
+ literalChars += codePointLength(parsed.value);
14739
+ continue;
14740
+ }
14741
+ if (paramNames.has(parsed.name)) return null;
14742
+ paramNames.add(parsed.name);
14743
+ if (parsed.greedy !== "" && isInvalidGreedyParam(
14744
+ index,
14745
+ lastSegmentIndex,
14746
+ parsed.prefix,
14747
+ parsed.suffix
14748
+ )) {
14749
+ return null;
14750
+ }
14751
+ literalChars += codePointLength(parsed.prefix) + codePointLength(parsed.suffix);
14752
+ if (parsed.prefix !== "" || parsed.suffix !== "") {
14753
+ mixedParamSegments += 1;
14754
+ } else if (parsed.greedy === "+") {
14755
+ plusGreedySegments += 1;
14756
+ } else if (parsed.greedy === "*") {
14757
+ starGreedySegments += 1;
14758
+ } else {
14759
+ plainParamSegments += 1;
14760
+ }
14761
+ }
14762
+ return [
14763
+ literalSegments,
14764
+ mixedParamSegments,
14765
+ plainParamSegments,
14766
+ plusGreedySegments,
14767
+ -starGreedySegments,
14768
+ literalChars,
14769
+ segments.length
14770
+ ];
14771
+ }
14772
+ function comparePathSpecificity(left, right) {
14773
+ for (let i = 0; i < left.length; i++) {
14774
+ const difference = left[i] - right[i];
14775
+ if (difference !== 0) return difference;
14776
+ }
14777
+ return 0;
14778
+ }
14779
+ function compileDecisionRule(permission, rule) {
14780
+ const spaceIdx = rule.indexOf(" ");
14781
+ if (spaceIdx === -1) return null;
14782
+ const method = rule.slice(0, spaceIdx);
14783
+ if (!VALID_RULE_METHODS.has(method)) return null;
14784
+ const path = rule.slice(spaceIdx + 1);
14785
+ const specificity = pathSpecificity(path);
14786
+ if (specificity === null) return null;
14787
+ return { permission, raw: rule, method, path, specificity };
14788
+ }
14789
+ function isValidPermissionName(permissionName) {
14790
+ return permissionName !== "" && permissionName !== "all";
14791
+ }
14792
+ function isObjectRecord(value) {
14793
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
14794
+ return false;
14795
+ }
14796
+ const prototype = Object.getPrototypeOf(value);
14797
+ return prototype === Object.prototype || prototype === null;
14798
+ }
14799
+ function isStringRecord(value) {
14800
+ if (!isObjectRecord(value)) return false;
14801
+ return Object.values(value).every((entry) => {
14802
+ return typeof entry === "string";
14803
+ });
14804
+ }
14805
+ function hasEntries(value) {
14806
+ return value !== void 0 && Object.keys(value).length > 0;
14807
+ }
14808
+ function isValidAwsSigv4AuthConfig(value) {
14809
+ if (!isObjectRecord(value)) return false;
14810
+ const allowedKeys = /* @__PURE__ */ new Set([
14811
+ "accessKeyId",
14812
+ "secretAccessKey",
14813
+ "sessionToken"
14814
+ ]);
14815
+ if (Object.keys(value).some((key) => {
14816
+ return !allowedKeys.has(key);
14817
+ })) {
14818
+ return false;
14819
+ }
14820
+ if (typeof value.accessKeyId !== "string" || value.accessKeyId === "") {
14821
+ return false;
14822
+ }
14823
+ if (typeof value.secretAccessKey !== "string" || value.secretAccessKey === "") {
14824
+ return false;
14825
+ }
14826
+ const optionalValue = value.sessionToken;
14827
+ if (optionalValue !== void 0 && (typeof optionalValue !== "string" || optionalValue === "")) {
14828
+ return false;
14829
+ }
14830
+ return true;
14831
+ }
14832
+ function isValidAuthConfig(auth, serviceName) {
14833
+ if (!isObjectRecord(auth)) return false;
14834
+ if (auth.headers !== void 0 && !isStringRecord(auth.headers)) return false;
14835
+ if (auth.query !== void 0 && !isStringRecord(auth.query)) return false;
14836
+ if (auth.awsSigv4 !== void 0 && !isValidAwsSigv4AuthConfig(auth.awsSigv4)) {
14837
+ return false;
14838
+ }
14839
+ if (auth.awsSigv4 !== void 0) {
14840
+ if (hasEntries(auth.headers)) {
14841
+ return false;
14842
+ }
14843
+ if (hasEntries(auth.query)) {
14844
+ return false;
14845
+ }
14846
+ }
14847
+ if (auth.base !== void 0) {
14848
+ if (typeof auth.base !== "string") return false;
14849
+ validateAuthBaseUrl(auth.base, serviceName);
14850
+ if (auth.awsSigv4 !== void 0) return false;
14851
+ }
14852
+ return true;
14853
+ }
14854
+ function rawObjectHasOwn(value, key) {
14855
+ return Object.prototype.hasOwnProperty.call(value, key);
14856
+ }
14857
+ function isValidAuthConfigForDecision(auth, serviceName) {
14858
+ try {
14859
+ return isValidAuthConfig(auth, serviceName);
14860
+ } catch {
14861
+ return false;
14862
+ }
14863
+ }
14864
+ function canonicalJson(value) {
14865
+ if (value === null) return "null";
14866
+ if (typeof value === "string" || typeof value === "boolean") {
14867
+ return JSON.stringify(value);
14868
+ }
14869
+ if (typeof value === "number") {
14870
+ return Number.isFinite(value) ? JSON.stringify(value) : void 0;
14871
+ }
14872
+ if (Array.isArray(value)) {
14873
+ const items = [];
14874
+ for (const item of value) {
14875
+ const encoded = canonicalJson(item);
14876
+ if (encoded === void 0) return void 0;
14877
+ items.push(encoded);
14878
+ }
14879
+ return `[${items.join(",")}]`;
14880
+ }
14881
+ if (!isObjectRecord(value)) return void 0;
14882
+ const entries = [];
14883
+ for (const key of Object.keys(value).sort()) {
14884
+ const item = value[key];
14885
+ if (item === void 0) continue;
14886
+ const encoded = canonicalJson(item);
14887
+ if (encoded === void 0) return void 0;
14888
+ entries.push(`${JSON.stringify(key)}:${encoded}`);
14889
+ }
14890
+ return `{${entries.join(",")}}`;
14891
+ }
14892
+ function decisionApiRoutingIdentity(api) {
14893
+ return canonicalJson({
14894
+ base: api.base,
14895
+ hostPolicy: api.hostPolicy,
14896
+ auth: api.auth
14897
+ }) ?? null;
14898
+ }
14899
+ function compileDecisionApi(api, serviceName, nameMalformed) {
14900
+ if (typeof api.base !== "string") return null;
14901
+ let baseMalformed = false;
14902
+ try {
14903
+ validateBaseUrl(api.base, serviceName);
14904
+ } catch {
14905
+ baseMalformed = true;
14906
+ }
14907
+ const authMalformed = !isValidAuthConfigForDecision(api.auth, serviceName);
14908
+ const routingIdentity = decisionApiRoutingIdentity(api);
14909
+ const rules = [];
14910
+ const seenPermissionNames = /* @__PURE__ */ new Set();
14911
+ let hasMalformedRules = nameMalformed;
14912
+ const rawPermissions = api.permissions;
14913
+ if (Array.isArray(rawPermissions)) {
14914
+ for (const rawPermission of rawPermissions) {
14915
+ if (!isObjectRecord(rawPermission)) {
14916
+ hasMalformedRules = true;
14917
+ continue;
14918
+ }
14919
+ const permissionName = rawPermission.name;
14920
+ if (typeof permissionName !== "string" || !isValidPermissionName(permissionName)) {
14921
+ hasMalformedRules = true;
14922
+ continue;
14923
+ }
14924
+ if (seenPermissionNames.has(permissionName)) {
14925
+ hasMalformedRules = true;
14926
+ continue;
14927
+ }
14928
+ seenPermissionNames.add(permissionName);
14929
+ const rawRules = rawPermission.rules;
14930
+ if (!Array.isArray(rawRules)) {
14931
+ hasMalformedRules = true;
14932
+ continue;
14933
+ }
14934
+ if (rawRules.length === 0) {
14935
+ hasMalformedRules = true;
14936
+ }
14937
+ for (const rawRule of rawRules) {
14938
+ if (typeof rawRule !== "string") {
14939
+ hasMalformedRules = true;
14940
+ continue;
14941
+ }
14942
+ const compiledRule = compileDecisionRule(permissionName, rawRule);
14943
+ if (compiledRule === null) {
14944
+ hasMalformedRules = true;
14945
+ continue;
14946
+ }
14947
+ rules.push(compiledRule);
14948
+ }
14949
+ }
14950
+ } else if (rawObjectHasOwn(api, "permissions")) {
14951
+ hasMalformedRules = true;
14952
+ }
14953
+ return {
14954
+ rawBase: api.base,
14955
+ baseMalformed,
14956
+ authMalformed,
14957
+ hasMalformedRules,
14958
+ routingIdentity,
14959
+ rules
14960
+ };
14961
+ }
14962
+ function compileDecisionFirewall(rawFirewall) {
14963
+ if (!isObjectRecord(rawFirewall)) return null;
14964
+ const rawName = rawFirewall.name;
14965
+ const nameMalformed = typeof rawName !== "string" || rawName === "";
14966
+ const name = typeof rawName === "string" ? rawName : "";
14967
+ const rawApis = rawFirewall.apis;
14968
+ if (!Array.isArray(rawApis)) return null;
14969
+ const apis = [];
14970
+ for (const rawApi of rawApis) {
14971
+ if (!isObjectRecord(rawApi)) continue;
14972
+ const api = compileDecisionApi(rawApi, name, nameMalformed);
14973
+ if (api !== null) {
14974
+ apis.push(api);
14975
+ }
14976
+ }
14977
+ if (apis.length === 0) return null;
14978
+ return { name, nameMalformed, apis };
14979
+ }
14980
+ function compileDecisionFirewalls(rawFirewalls) {
14981
+ if (!Array.isArray(rawFirewalls) || rawFirewalls.length === 0) return [];
14982
+ const firewalls = [];
14983
+ for (const rawFirewall of rawFirewalls) {
14984
+ const firewall = compileDecisionFirewall(rawFirewall);
14985
+ if (firewall !== null) {
14986
+ firewalls.push(firewall);
14987
+ }
14988
+ }
14989
+ return firewalls;
14990
+ }
14991
+ function compilePermissionSet(rawValue) {
14992
+ if (rawValue === void 0 || rawValue === null) {
14993
+ return { values: /* @__PURE__ */ new Set(), malformed: false };
14994
+ }
14995
+ if (!Array.isArray(rawValue) || rawValue.some((item) => {
14996
+ return typeof item !== "string";
14997
+ })) {
14998
+ return { values: /* @__PURE__ */ new Set(), malformed: true };
14999
+ }
15000
+ return { values: new Set(rawValue), malformed: false };
15001
+ }
15002
+ function compileNetworkPolicies(rawNetworkPolicies) {
15003
+ if (rawNetworkPolicies === void 0 || rawNetworkPolicies === null) {
15004
+ return { policies: /* @__PURE__ */ new Map(), topLevelMalformed: false };
15005
+ }
15006
+ if (!isObjectRecord(rawNetworkPolicies)) {
15007
+ return { policies: /* @__PURE__ */ new Map(), topLevelMalformed: true };
15008
+ }
15009
+ const policies = /* @__PURE__ */ new Map();
15010
+ for (const [firewallName, grant] of Object.entries(rawNetworkPolicies)) {
15011
+ if (!isObjectRecord(grant)) {
15012
+ policies.set(firewallName, {
15013
+ blockedPermissions: /* @__PURE__ */ new Set(),
15014
+ unknownPolicy: "allow",
15015
+ permissionMalformed: true,
15016
+ unknownPolicyMalformed: false
15017
+ });
15018
+ continue;
15019
+ }
15020
+ const allow = compilePermissionSet(grant.allow);
15021
+ const deny = compilePermissionSet(grant.deny);
15022
+ const ask = compilePermissionSet(grant.ask);
15023
+ const blockedPermissions = /* @__PURE__ */ new Set([...deny.values, ...ask.values]);
15024
+ let unknownPolicy = "allow";
15025
+ let unknownPolicyMalformed = false;
15026
+ const rawUnknownPolicy = grant.unknownPolicy;
15027
+ if (rawUnknownPolicy === "allow" || rawUnknownPolicy === "deny" || rawUnknownPolicy === "ask") {
15028
+ unknownPolicy = rawUnknownPolicy;
15029
+ } else if (rawUnknownPolicy !== void 0 && rawUnknownPolicy !== null) {
15030
+ unknownPolicyMalformed = true;
15031
+ }
15032
+ policies.set(firewallName, {
15033
+ blockedPermissions,
15034
+ unknownPolicy,
15035
+ permissionMalformed: allow.malformed || deny.malformed || ask.malformed,
15036
+ unknownPolicyMalformed
15037
+ });
15038
+ }
15039
+ return { policies, topLevelMalformed: false };
15040
+ }
15041
+ function relativePathFromSegments(segments, consumed) {
15042
+ const rest = segments.slice(consumed).join("/");
15043
+ return rest === "" ? "/" : `/${rest}`;
15044
+ }
15045
+ function stripUrlQueryAndFragment(url) {
15046
+ const queryIndex = url.indexOf("?");
15047
+ const fragmentIndex = url.indexOf("#");
15048
+ let end = url.length;
15049
+ if (queryIndex !== -1) end = Math.min(end, queryIndex);
15050
+ if (fragmentIndex !== -1) end = Math.min(end, fragmentIndex);
15051
+ return url.slice(0, end);
15052
+ }
15053
+ function rawUrlAuthorityBounds(url) {
15054
+ const schemeEnd = url.indexOf("://");
15055
+ if (schemeEnd === -1) return null;
15056
+ const authorityStart = schemeEnd + 3;
15057
+ let authorityEnd = url.length;
15058
+ for (const delimiter of ["/", "?", "#"]) {
15059
+ const delimiterIndex = url.indexOf(delimiter, authorityStart);
15060
+ if (delimiterIndex !== -1)
15061
+ authorityEnd = Math.min(authorityEnd, delimiterIndex);
15062
+ }
15063
+ return { authorityStart, authorityEnd };
15064
+ }
15065
+ function replaceRawUrlAuthority(url, bounds, authority) {
15066
+ return `${url.slice(0, bounds.authorityStart)}${authority}${url.slice(bounds.authorityEnd)}`;
15067
+ }
15068
+ function stripRawUrlUserinfo(url) {
15069
+ const bounds = rawUrlAuthorityBounds(url);
15070
+ if (bounds === null) return url;
15071
+ const authority = url.slice(bounds.authorityStart, bounds.authorityEnd);
15072
+ const userinfoEnd = authority.lastIndexOf("@");
15073
+ if (userinfoEnd === -1) return url;
15074
+ return replaceRawUrlAuthority(url, bounds, authority.slice(userinfoEnd + 1));
15075
+ }
15076
+ function rawAuthorityPortIsMalformed(port) {
15077
+ if (port === "") return true;
15078
+ if (![...port].every((char) => {
15079
+ return char >= "0" && char <= "9";
15080
+ })) {
15081
+ return true;
15082
+ }
15083
+ return Number(port) > 65535;
15084
+ }
15085
+ function stripRawUrlMalformedPort(url) {
15086
+ const bounds = rawUrlAuthorityBounds(url);
15087
+ if (bounds === null) return url;
15088
+ const authority = url.slice(bounds.authorityStart, bounds.authorityEnd);
15089
+ if (authority.startsWith("[")) {
15090
+ const closeBracketIndex = authority.indexOf("]");
15091
+ if (closeBracketIndex === -1) return url;
15092
+ const portPrefix = authority.slice(closeBracketIndex + 1);
15093
+ if (!portPrefix.startsWith(":")) return url;
15094
+ if (!rawAuthorityPortIsMalformed(portPrefix.slice(1))) return url;
15095
+ return replaceRawUrlAuthority(
15096
+ url,
15097
+ bounds,
15098
+ authority.slice(0, closeBracketIndex + 1)
15099
+ );
15100
+ }
15101
+ const portSeparator = authority.lastIndexOf(":");
15102
+ if (portSeparator === -1) return url;
15103
+ if (authority.indexOf(":") !== portSeparator) return url;
15104
+ if (!rawAuthorityPortIsMalformed(authority.slice(portSeparator + 1))) {
15105
+ return url;
15106
+ }
15107
+ return replaceRawUrlAuthority(url, bounds, authority.slice(0, portSeparator));
15108
+ }
15109
+ function rawBaseForDecisionMatch(rawBase) {
15110
+ if (stripUrlQueryAndFragment(rawBase).includes("\\")) return null;
15111
+ return stripRawUrlMalformedPort(stripRawUrlUserinfo(rawBase));
15112
+ }
15113
+ function rawPathFromUrl(url) {
15114
+ const urlWithoutQuery = stripUrlQueryAndFragment(url);
15115
+ const schemeEnd = urlWithoutQuery.indexOf("://");
15116
+ const authorityStart = schemeEnd === -1 ? 0 : schemeEnd + 3;
15117
+ const pathStart = urlWithoutQuery.indexOf("/", authorityStart);
15118
+ return pathStart === -1 ? "/" : urlWithoutQuery.slice(pathStart);
15119
+ }
15120
+ function rawBasePathFromUrl(url) {
15121
+ const urlWithoutQuery = stripUrlQueryAndFragment(url);
15122
+ const schemeEnd = urlWithoutQuery.indexOf("://");
15123
+ const authorityStart = schemeEnd === -1 ? 0 : schemeEnd + 3;
15124
+ const pathStart = urlWithoutQuery.indexOf("/", authorityStart);
15125
+ return pathStart === -1 ? "" : urlWithoutQuery.slice(pathStart);
15126
+ }
15127
+ function rawAuthorityFromUrl(url) {
15128
+ const urlWithoutQuery = stripUrlQueryAndFragment(url);
15129
+ const schemeEnd = urlWithoutQuery.indexOf("://");
15130
+ if (schemeEnd === -1) return null;
15131
+ const authorityStart = schemeEnd + 3;
15132
+ const pathStart = urlWithoutQuery.indexOf("/", authorityStart);
15133
+ const authority = pathStart === -1 ? urlWithoutQuery.slice(authorityStart) : urlWithoutQuery.slice(authorityStart, pathStart);
15134
+ return authority === "" ? null : authority;
15135
+ }
15136
+ function hasNonAscii(value) {
15137
+ for (let index = 0; index < value.length; index += 1) {
15138
+ if (value.charCodeAt(index) > 127) return true;
15139
+ }
15140
+ return false;
15141
+ }
15142
+ function rawHostFromAuthority(authority) {
15143
+ const withoutUserinfo = authority.slice(authority.lastIndexOf("@") + 1);
15144
+ if (withoutUserinfo.startsWith("[")) {
15145
+ const closeBracket = withoutUserinfo.indexOf("]");
15146
+ return closeBracket === -1 ? withoutUserinfo : withoutUserinfo.slice(0, closeBracket + 1);
15147
+ }
15148
+ const portSeparator = withoutUserinfo.lastIndexOf(":");
15149
+ return portSeparator === -1 ? withoutUserinfo : withoutUserinfo.slice(0, portSeparator);
15150
+ }
15151
+ function authorityHasEmptyPort(authority) {
15152
+ const withoutUserinfo = authority.slice(authority.lastIndexOf("@") + 1);
15153
+ if (withoutUserinfo.startsWith("[")) {
15154
+ const closeBracket = withoutUserinfo.indexOf("]");
15155
+ if (closeBracket === -1) return false;
15156
+ return withoutUserinfo.slice(closeBracket + 1) === ":";
15157
+ }
15158
+ const portSeparator = withoutUserinfo.lastIndexOf(":");
15159
+ if (portSeparator === -1) return false;
15160
+ return withoutUserinfo.indexOf(":") === portSeparator && portSeparator === withoutUserinfo.length - 1;
15161
+ }
15162
+ function rawAuthorityHostStartsWithDigit(authority) {
15163
+ const firstChar = rawHostFromAuthority(authority)[0];
15164
+ return firstChar !== void 0 && firstChar >= "0" && firstChar <= "9";
15165
+ }
15166
+ function runtimeAuthorityOriginForHostValidation(url) {
15167
+ const authority = rawAuthorityFromUrl(url);
15168
+ if (authority === null) return null;
15169
+ if (!authority.includes("%") && !hasNonAscii(authority) && !rawAuthorityHostStartsWithDigit(authority)) {
15170
+ return null;
15171
+ }
15172
+ const schemeEnd = url.indexOf("://");
15173
+ if (schemeEnd === -1) return null;
15174
+ return `${url.slice(0, schemeEnd)}://${authority}`;
15175
+ }
15176
+ function hasPercentEncodedAuthoritySyntax(value) {
15177
+ let index = value.indexOf("%");
15178
+ while (index !== -1) {
15179
+ let runEnd = index;
15180
+ while (runEnd < value.length && value[runEnd] === "%") {
15181
+ const firstHexDigit = value[runEnd + 1];
15182
+ const secondHexDigit = value[runEnd + 2];
15183
+ if (!firstHexDigit || !secondHexDigit || !HEX_DIGITS.has(firstHexDigit) || !HEX_DIGITS.has(secondHexDigit)) {
15184
+ return true;
15185
+ }
15186
+ runEnd += PERCENT_ESCAPE_LENGTH;
15187
+ }
15188
+ let decodedRun;
15189
+ try {
15190
+ decodedRun = decodeURIComponent(value.slice(index, runEnd));
15191
+ } catch {
15192
+ return true;
15193
+ }
15194
+ for (const char of decodedRun) {
15195
+ if (PERCENT_DECODED_AUTHORITY_SYNTAX_CHARS.has(char)) {
15196
+ return true;
15197
+ }
15198
+ }
15199
+ index = value.indexOf("%", runEnd);
15200
+ }
15201
+ return false;
15202
+ }
15203
+ function hasMalformedRuntimeAuthoritySyntax(url) {
15204
+ const authority = rawAuthorityFromUrl(url);
15205
+ if (authority === null) return false;
15206
+ return authority.includes("\\") || authorityHasEmptyPort(authority) || hasPercentEncodedAuthoritySyntax(authority);
15207
+ }
15208
+ function scoreLiteralSegment(segment2) {
15209
+ return LITERAL_SEGMENT_SCORE + codePointLength(segment2);
15210
+ }
15211
+ function scoreParsedPatternSegment(parsed) {
15212
+ if (parsed.kind === "literal") {
15213
+ return scoreLiteralSegment(parsed.value);
15214
+ }
15215
+ const literalChars = codePointLength(parsed.prefix) + codePointLength(parsed.suffix);
15216
+ if (parsed.prefix !== "" || parsed.suffix !== "") {
15217
+ return MIXED_PARAM_SEGMENT_SCORE + literalChars;
15218
+ }
15219
+ if (parsed.greedy === "+") return PLUS_GREEDY_SEGMENT_SCORE;
15220
+ if (parsed.greedy === "*") return 0;
15221
+ return PLAIN_PARAM_SEGMENT_SCORE;
15222
+ }
15223
+ function scoreStaticSegments(segments) {
15224
+ return segments.reduce((score, segment2) => {
15225
+ return score + scoreLiteralSegment(segment2);
15226
+ }, 0);
15227
+ }
15228
+ function scorePatternSegmentsWithParser(segments, parsePatternSegment) {
15229
+ const lastPatternIndex = segments.length - 1;
15230
+ let score = 0;
15231
+ for (let index = 0; index < segments.length; index += 1) {
15232
+ const segment2 = segments[index];
15233
+ const parsed = parsePatternSegment(segment2, index, lastPatternIndex);
15234
+ if (parsed !== null) {
15235
+ score += scoreParsedPatternSegment(parsed);
15236
+ }
15237
+ }
15238
+ return score;
15239
+ }
15240
+ function scorePathPattern(path, parsePatternSegment) {
15241
+ if (path === "") return 0;
15242
+ if (path === "/") return ROOT_PATH_SCORE;
15243
+ const segments = splitPathSegments(path);
15244
+ return parsePatternSegment === null ? scoreStaticSegments(segments) : scorePatternSegmentsWithParser(segments, parsePatternSegment);
15245
+ }
15246
+ function splitAuthoritySegments(authority) {
15247
+ if (authority.startsWith("[")) return [authority];
15248
+ const normalized = authority.endsWith(".") ? authority.slice(0, -1) : authority;
15249
+ return normalized === "" ? [] : normalized.split(".");
15250
+ }
15251
+ function baseUrlSpecificityScore({
15252
+ authority,
15253
+ path,
15254
+ hasParams,
15255
+ tolerateMalformedBaseParams = false
15256
+ }) {
15257
+ const patternParser = hasParams ? tolerateMalformedBaseParams ? parseMalformedTolerantBaseSegment : parseStrictMatchSegment : null;
15258
+ const authoritySegments = splitAuthoritySegments(authority);
15259
+ const authorityScore = patternParser === null ? scoreStaticSegments(authoritySegments) : scorePatternSegmentsWithParser(
15260
+ [...authoritySegments].reverse(),
15261
+ patternParser
15262
+ );
15263
+ const pathScore = scorePathPattern(path, patternParser);
15264
+ return pathScore * PATH_SCORE_MULTIPLIER + authorityScore * AUTHORITY_SCORE_MULTIPLIER + (hasParams ? 0 : STATIC_BASE_SCORE_BONUS);
15265
+ }
15266
+ function matchStaticBasePathPrefix(path, pattern) {
15267
+ if (pattern === "") {
15268
+ return path === "" ? "/" : path;
15269
+ }
15270
+ if (pattern === "/") {
15271
+ if (!path.startsWith(pattern)) return null;
15272
+ const relativePath2 = path.slice(pattern.length);
15273
+ if (relativePath2 !== "" && !relativePath2.startsWith("/")) return null;
15274
+ return relativePath2 === "" ? "/" : relativePath2;
15275
+ }
15276
+ if (!path.startsWith(pattern)) return null;
15277
+ const relativePath = path.slice(pattern.length);
15278
+ if (relativePath !== "" && !relativePath.startsWith("/")) return null;
15279
+ return relativePath === "" ? "/" : relativePath;
15280
+ }
15281
+ function normalizeUrlHostname(hostname, options = {}) {
15282
+ let normalized = hostname.toLowerCase();
15283
+ if (normalized.endsWith(".")) {
15284
+ normalized = normalized.slice(0, -1);
15285
+ if (normalized === "" || normalized.endsWith(".")) {
15286
+ return null;
15287
+ }
15288
+ }
15289
+ if (normalized.split(".").some((label) => {
15290
+ return label === "";
15291
+ })) {
15292
+ return null;
15293
+ }
15294
+ const forbiddenChars = options.allowHostParams === true ? FORBIDDEN_BASE_PATTERN_HOST_CHARS : FORBIDDEN_RUNTIME_HOST_CHARS;
15295
+ if (!normalized.startsWith("[") && [...normalized].some((char) => {
15296
+ return forbiddenChars.has(char);
15297
+ })) {
15298
+ return null;
15299
+ }
15300
+ return normalized;
15301
+ }
15302
+ function normalizedUrlAuthority(parsed, options = {}) {
15303
+ if (parsed.username !== "" || parsed.password !== "") {
15304
+ return null;
15305
+ }
15306
+ const hostname = normalizeUrlHostname(parsed.hostname, options);
15307
+ if (hostname === null || hostname === "") {
15308
+ return null;
15309
+ }
15310
+ return parsed.port === "" ? hostname : `${hostname}:${parsed.port}`;
15311
+ }
15312
+ function matchStaticFirewallBaseUrl(url, rawBase, options = {}) {
15313
+ const parsedUrl = new URL(url);
15314
+ const parsedBase = new URL(rawBase);
15315
+ if (parsedUrl.protocol.toLowerCase() !== parsedBase.protocol.toLowerCase()) {
15316
+ return null;
15317
+ }
15318
+ const baseHasParams = hasBaseUrlParams(rawBase);
15319
+ const baseForMatch = stripTrailingSlash(rawBase);
15320
+ const urlAuthority = normalizedUrlAuthority(parsedUrl);
15321
+ const baseAuthority = normalizedUrlAuthority(parsedBase, {
15322
+ allowHostParams: baseHasParams
15323
+ });
15324
+ if (urlAuthority === null || baseAuthority === null) return null;
15325
+ if (baseHasParams) {
15326
+ const hostParams = options.tolerateMalformedBaseParams === true ? matchFirewallHostForMalformedBaseDecision(urlAuthority, baseAuthority) : matchFirewallHost(urlAuthority, baseAuthority);
15327
+ if (hostParams === null) return null;
15328
+ } else if (urlAuthority !== baseAuthority) {
15329
+ return null;
15330
+ }
15331
+ const basePath = rawBasePathFromUrl(baseForMatch);
15332
+ const relativePath = baseHasParams ? options.tolerateMalformedBaseParams === true ? matchFirewallPathPrefixForMalformedBaseDecision(
15333
+ rawPathFromUrl(url),
15334
+ basePath
15335
+ ) : matchFirewallPathPrefix(rawPathFromUrl(url), basePath) : matchStaticBasePathPrefix(rawPathFromUrl(url), basePath);
15336
+ if (relativePath === null) return null;
15337
+ const displayBase = stripTrailingSlash(rawBase);
15338
+ return {
15339
+ displayBase,
15340
+ relativePath,
15341
+ score: baseUrlSpecificityScore({
15342
+ authority: baseAuthority,
15343
+ path: basePath,
15344
+ hasParams: baseHasParams,
15345
+ tolerateMalformedBaseParams: options.tolerateMalformedBaseParams === true
15346
+ })
15347
+ };
15348
+ }
15349
+ function runtimeUrlCanMatchFirewallBase(url) {
15350
+ if (hasUnsafeUrlCodepoint(url) || hasRawWhitespace(url) || !url.includes("://") || hasMalformedRuntimeAuthoritySyntax(url)) {
15351
+ return false;
15352
+ }
15353
+ const runtimeAuthorityOrigin = runtimeAuthorityOriginForHostValidation(url);
15354
+ if (runtimeAuthorityOrigin === null) return true;
15355
+ try {
15356
+ validateBaseUrl(runtimeAuthorityOrigin, "runtime");
15357
+ return true;
15358
+ } catch {
15359
+ return false;
15360
+ }
15361
+ }
15362
+ function matchFirewallBaseUrlForDecision(url, rawBase) {
15363
+ if (!runtimeUrlCanMatchFirewallBase(url)) return null;
15364
+ const baseForMatch = rawBaseForDecisionMatch(rawBase);
15365
+ if (baseForMatch === null) return null;
15366
+ try {
15367
+ const match = matchStaticFirewallBaseUrl(url, baseForMatch, {
15368
+ tolerateMalformedBaseParams: true
15369
+ });
15370
+ if (match === null) return null;
15371
+ return { ...match, displayBase: stripTrailingSlash(rawBase) };
15372
+ } catch {
15373
+ return null;
15374
+ }
15375
+ }
15376
+ function createDecisionState() {
15377
+ return {
15378
+ bestBaseScore: null,
15379
+ bestRuleSpecificity: null,
15380
+ baseMatch: null,
15381
+ allowedMatch: null,
15382
+ deniedMatch: null,
15383
+ deniedPermissionNames: [],
15384
+ malformedConfigMatch: null,
15385
+ malformedPolicyMatch: null
15386
+ };
15387
+ }
15388
+ function acceptDecisionBaseMatch(state, match, score) {
15389
+ if (state.bestBaseScore === null || score > state.bestBaseScore) {
15390
+ state.bestBaseScore = score;
15391
+ state.bestRuleSpecificity = null;
15392
+ state.baseMatch = null;
15393
+ state.allowedMatch = null;
15394
+ state.deniedMatch = null;
15395
+ state.deniedPermissionNames = [];
15396
+ state.malformedConfigMatch = null;
15397
+ state.malformedPolicyMatch = null;
15398
+ } else if (score < state.bestBaseScore) {
15399
+ return false;
15400
+ }
15401
+ state.baseMatch ??= match;
15402
+ return true;
15403
+ }
15404
+ function acceptRuleSpecificity(state, specificity) {
15405
+ if (state.bestRuleSpecificity === null) {
15406
+ state.bestRuleSpecificity = specificity;
15407
+ return true;
15408
+ }
15409
+ const comparison = comparePathSpecificity(
15410
+ specificity,
15411
+ state.bestRuleSpecificity
15412
+ );
15413
+ if (comparison > 0) {
15414
+ state.bestRuleSpecificity = specificity;
15415
+ state.allowedMatch = null;
15416
+ state.deniedMatch = null;
15417
+ state.deniedPermissionNames = [];
15418
+ return true;
15419
+ }
15420
+ return comparison === 0;
15421
+ }
15422
+ function recordDeniedRule(state, match, permission) {
15423
+ if (!state.deniedPermissionNames.includes(permission)) {
15424
+ state.deniedPermissionNames.push(permission);
15425
+ }
15426
+ state.deniedMatch ??= match;
15427
+ }
15428
+ function resolveFirewallDecision(state, networkPolicies) {
15429
+ const baseMatch = state.baseMatch;
15430
+ if (baseMatch === null) {
15431
+ return { kind: "no_match" };
15432
+ }
15433
+ if (state.allowedMatch !== null) {
15434
+ return {
15435
+ kind: "allow",
15436
+ firewallName: state.allowedMatch.firewallName,
15437
+ base: state.allowedMatch.base,
15438
+ relativePath: state.allowedMatch.relativePath,
15439
+ permission: state.allowedMatch.permission,
15440
+ rule: state.allowedMatch.rule
15441
+ };
15442
+ }
15443
+ if (state.deniedMatch !== null) {
15444
+ return {
15445
+ kind: "block",
15446
+ firewallName: state.deniedMatch.firewallName,
15447
+ base: state.deniedMatch.base,
15448
+ relativePath: state.deniedMatch.relativePath,
15449
+ reason: "permission_denied",
15450
+ permissions: state.deniedPermissionNames
15451
+ };
15452
+ }
15453
+ if (state.malformedPolicyMatch !== null) {
15454
+ return {
15455
+ kind: "block",
15456
+ firewallName: state.malformedPolicyMatch.firewallName,
15457
+ base: state.malformedPolicyMatch.base,
15458
+ relativePath: state.malformedPolicyMatch.relativePath,
15459
+ reason: "malformed_network_policy",
15460
+ permissions: []
15461
+ };
15462
+ }
15463
+ if (state.malformedConfigMatch !== null) {
15464
+ return {
15465
+ kind: "block",
15466
+ firewallName: state.malformedConfigMatch.firewallName,
15467
+ base: state.malformedConfigMatch.base,
15468
+ relativePath: state.malformedConfigMatch.relativePath,
15469
+ reason: "malformed_firewall_config",
15470
+ permissions: []
15471
+ };
15472
+ }
15473
+ const policy = networkPolicies.policies.get(baseMatch.firewallName);
15474
+ if (policy === void 0) {
15475
+ return {
15476
+ kind: "allow",
15477
+ firewallName: baseMatch.firewallName,
15478
+ base: baseMatch.allowBase,
15479
+ relativePath: baseMatch.relativePath
15480
+ };
15481
+ }
15482
+ if (policy.unknownPolicyMalformed) {
15483
+ return {
15484
+ kind: "block",
15485
+ firewallName: baseMatch.firewallName,
15486
+ base: baseMatch.base,
15487
+ relativePath: baseMatch.relativePath,
15488
+ reason: "malformed_network_policy",
15489
+ permissions: []
15490
+ };
15491
+ }
15492
+ if (policy.unknownPolicy === "allow") {
15493
+ return {
15494
+ kind: "allow",
15495
+ firewallName: baseMatch.firewallName,
15496
+ base: baseMatch.allowBase,
15497
+ relativePath: baseMatch.relativePath
15498
+ };
15499
+ }
15500
+ return {
15501
+ kind: "block",
15502
+ firewallName: baseMatch.firewallName,
15503
+ base: baseMatch.base,
15504
+ relativePath: baseMatch.relativePath,
15505
+ reason: "unknown_endpoint",
15506
+ permissions: []
15507
+ };
15508
+ }
15509
+ function unsafePathBlockDecision(firewall, baseMatch) {
15510
+ return {
15511
+ kind: "block",
15512
+ firewallName: firewall.name,
15513
+ base: baseMatch.displayBase,
15514
+ relativePath: baseMatch.relativePath,
15515
+ reason: "unsafe_path",
15516
+ permissions: []
15517
+ };
15518
+ }
15519
+ function recordMalformedDecisionState(state, api, blockMatch) {
15520
+ if (api.baseMalformed || api.authMalformed || api.hasMalformedRules || api.routingIdentity === null) {
15521
+ state.malformedConfigMatch ??= blockMatch;
15522
+ }
15523
+ }
15524
+ function apiCannotEvaluateRules(firewall, api) {
15525
+ return firewall.nameMalformed || api.baseMalformed || api.authMalformed || api.routingIdentity === null;
15526
+ }
15527
+ function policyCannotEvaluateRules(networkPolicies, policy) {
15528
+ return networkPolicies.topLevelMalformed || policy !== void 0 && policy.permissionMalformed;
15529
+ }
15530
+ function createMatchCollection() {
15531
+ return {
15532
+ bestBaseScore: null,
15533
+ bestRuleSpecificity: null,
15534
+ apiMatches: [],
15535
+ ruleMatches: []
15536
+ };
15537
+ }
15538
+ function acceptCollectedApi(collection, match) {
15539
+ if (collection.bestBaseScore === null || match.score > collection.bestBaseScore) {
15540
+ collection.bestBaseScore = match.score;
15541
+ collection.bestRuleSpecificity = null;
15542
+ collection.apiMatches = [];
15543
+ collection.ruleMatches = [];
15544
+ } else if (match.score < collection.bestBaseScore) {
15545
+ return false;
15546
+ }
15547
+ collection.apiMatches.push(match);
15548
+ return true;
15549
+ }
15550
+ function canRuleAffectCollection(collection, specificity) {
15551
+ if (collection.bestRuleSpecificity === null) return true;
15552
+ return comparePathSpecificity(specificity, collection.bestRuleSpecificity) >= 0;
15553
+ }
15554
+ function recordCollectedRule(collection, match) {
15555
+ const bestSpecificity = collection.bestRuleSpecificity;
15556
+ if (bestSpecificity === null || comparePathSpecificity(match.rule.specificity, bestSpecificity) > 0) {
15557
+ collection.bestRuleSpecificity = match.rule.specificity;
15558
+ collection.ruleMatches = [];
15559
+ } else if (comparePathSpecificity(match.rule.specificity, bestSpecificity) < 0) {
15560
+ return;
15561
+ }
15562
+ collection.ruleMatches.push(match);
15563
+ }
15564
+ function collectDecisionRules(collection, apiMatch, upperMethod) {
15565
+ for (const rule of apiMatch.api.rules) {
15566
+ if (rule.method !== "ANY" && rule.method !== upperMethod) continue;
15567
+ if (!canRuleAffectCollection(collection, rule.specificity)) continue;
15568
+ if (matchFirewallPath(apiMatch.baseMatch.relativePath, rule.path) === null) {
15569
+ continue;
15570
+ }
15571
+ recordCollectedRule(collection, { apiMatch, rule });
15572
+ }
15573
+ }
15574
+ function winningApiMatches(collection) {
15575
+ if (collection.ruleMatches.length === 0) {
15576
+ return collection.apiMatches;
15577
+ }
15578
+ const matches = [];
15579
+ const seenOrders = /* @__PURE__ */ new Set();
15580
+ for (const ruleMatch of collection.ruleMatches) {
15581
+ if (seenOrders.has(ruleMatch.apiMatch.order)) continue;
15582
+ seenOrders.add(ruleMatch.apiMatch.order);
15583
+ matches.push(ruleMatch.apiMatch);
15584
+ }
15585
+ return matches;
15586
+ }
15587
+ function winningOwnerNames(collection) {
15588
+ const names = /* @__PURE__ */ new Set();
15589
+ for (const apiMatch of winningApiMatches(collection)) {
15590
+ if (!apiMatch.firewall.nameMalformed) {
15591
+ names.add(apiMatch.firewall.name);
15592
+ }
15593
+ }
15594
+ return [...names].sort();
15595
+ }
15596
+ function connectorAmbiguityReason(intent) {
15597
+ if (intent.status === "absent") return "connector_intent_required";
15598
+ if (intent.status === "malformed") return "malformed_connector_intent";
15599
+ return "connector_intent_not_candidate";
15600
+ }
15601
+ function selectOwner(collection, intent, upperMethod, path) {
15602
+ const [owner, ...otherOwners] = winningOwnerNames(collection);
15603
+ if (owner === void 0) return { kind: "selected", name: null };
15604
+ if (otherOwners.length === 0) {
15605
+ return { kind: "selected", name: owner };
15606
+ }
15607
+ const owners = [owner, ...otherOwners];
15608
+ if (intent.status === "present" && owners.includes(intent.value)) {
15609
+ return { kind: "selected", name: intent.value };
15610
+ }
15611
+ return {
15612
+ kind: "ambiguous",
15613
+ decision: {
15614
+ kind: "ambiguous",
15615
+ method: upperMethod,
15616
+ path,
15617
+ candidates: owners,
15618
+ reason: connectorAmbiguityReason(intent)
15619
+ }
15620
+ };
15621
+ }
15622
+ function conflictingSelectedApiDecision(collection, selectedName) {
15623
+ const [first, ...otherMatches] = winningApiMatches(collection).filter(
15624
+ (match) => {
15625
+ return match.firewall.name === selectedName && !match.firewall.nameMalformed && !match.api.baseMalformed && !match.api.authMalformed && match.api.routingIdentity !== null;
15626
+ }
15627
+ );
15628
+ if (first === void 0 || otherMatches.length === 0) return null;
15629
+ if (otherMatches.every((match) => {
15630
+ return match.api.routingIdentity === first.api.routingIdentity;
15631
+ })) {
15632
+ return null;
15633
+ }
15634
+ return {
15635
+ kind: "block",
15636
+ firewallName: selectedName,
15637
+ base: first.blockMatch.base,
15638
+ relativePath: first.blockMatch.relativePath,
15639
+ reason: "malformed_firewall_config",
15640
+ permissions: []
15641
+ };
15642
+ }
15643
+ function reduceSelectedOwner(collection, selectedName, networkPolicies) {
15644
+ if (selectedName !== null) {
15645
+ const conflict = conflictingSelectedApiDecision(collection, selectedName);
15646
+ if (conflict !== null) return conflict;
15647
+ }
15648
+ const state = createDecisionState();
15649
+ const evaluableApiOrders = /* @__PURE__ */ new Set();
15650
+ for (const apiMatch of collection.apiMatches) {
15651
+ const { firewall, api, baseMatch, blockMatch } = apiMatch;
15652
+ if (selectedName !== null && firewall.name !== selectedName && !firewall.nameMalformed) {
15653
+ continue;
15654
+ }
15655
+ const policy = networkPolicies.policies.get(firewall.name);
15656
+ acceptDecisionBaseMatch(state, baseMatch, apiMatch.score);
15657
+ recordMalformedDecisionState(state, api, blockMatch);
15658
+ if (apiCannotEvaluateRules(firewall, api)) continue;
15659
+ if (policyCannotEvaluateRules(networkPolicies, policy)) {
15660
+ state.malformedPolicyMatch ??= blockMatch;
15661
+ continue;
15662
+ }
15663
+ evaluableApiOrders.add(apiMatch.order);
15664
+ }
15665
+ for (const ruleMatch of collection.ruleMatches) {
15666
+ const { apiMatch, rule } = ruleMatch;
15667
+ if (!evaluableApiOrders.has(apiMatch.order)) continue;
15668
+ if (selectedName !== null && apiMatch.firewall.name !== selectedName) {
15669
+ continue;
15670
+ }
15671
+ const policy = networkPolicies.policies.get(apiMatch.firewall.name);
15672
+ if (!acceptRuleSpecificity(state, rule.specificity)) continue;
15673
+ if (policy !== void 0 && policy.blockedPermissions.has(rule.permission)) {
15674
+ recordDeniedRule(state, apiMatch.blockMatch, rule.permission);
15675
+ continue;
15676
+ }
15677
+ state.allowedMatch ??= {
15678
+ firewallName: apiMatch.baseMatch.firewallName,
15679
+ base: apiMatch.baseMatch.allowBase,
15680
+ relativePath: apiMatch.baseMatch.relativePath,
15681
+ permission: rule.permission,
15682
+ rule: rule.raw
15683
+ };
15684
+ }
15685
+ return resolveFirewallDecision(state, networkPolicies);
15686
+ }
15687
+ function matchFirewallBaseUrl(url, rawBase) {
15688
+ if (hasUnsafeRuntimeUrlSyntax(url) || hasMalformedRuntimeAuthoritySyntax(url)) {
15689
+ return null;
15690
+ }
15691
+ const runtimeAuthorityOrigin = runtimeAuthorityOriginForHostValidation(url);
15692
+ try {
15693
+ if (runtimeAuthorityOrigin !== null) {
15694
+ validateBaseUrl(runtimeAuthorityOrigin, "runtime");
15695
+ }
15696
+ validateBaseUrl(rawBase, "firewall");
15697
+ return matchStaticFirewallBaseUrl(url, rawBase);
15698
+ } catch {
15699
+ return null;
15700
+ }
15701
+ }
15702
+ function matchFirewallRequestDecision(firewalls, method, url, networkPolicies = void 0, connectorIntent = { status: "absent" }) {
15703
+ const decisionFirewalls = compileDecisionFirewalls(firewalls);
15704
+ if (decisionFirewalls.length === 0) return { kind: "no_match" };
15705
+ const compiledNetworkPolicies = compileNetworkPolicies(networkPolicies);
15706
+ const upperMethod = method.toUpperCase();
15707
+ const collection = createMatchCollection();
15708
+ const unsafePath = url.includes("\\") || hasUnsafeFirewallPath(rawPathFromUrl(url));
15709
+ let apiOrder = 0;
15710
+ for (const firewall of decisionFirewalls) {
15711
+ for (const api of firewall.apis) {
15712
+ const order = apiOrder;
15713
+ apiOrder += 1;
15714
+ const baseMatch = matchFirewallBaseUrlForDecision(url, api.rawBase);
15715
+ if (baseMatch === null) continue;
15716
+ if (unsafePath) return unsafePathBlockDecision(firewall, baseMatch);
15717
+ const decisionBaseMatch = {
15718
+ firewallName: firewall.name,
15719
+ base: baseMatch.displayBase,
15720
+ allowBase: api.rawBase,
15721
+ relativePath: baseMatch.relativePath
15722
+ };
15723
+ const apiMatch = {
15724
+ order,
15725
+ firewall,
15726
+ api,
15727
+ baseMatch: decisionBaseMatch,
15728
+ blockMatch: {
15729
+ firewallName: decisionBaseMatch.firewallName,
15730
+ base: decisionBaseMatch.base,
15731
+ relativePath: decisionBaseMatch.relativePath
15732
+ },
15733
+ score: baseMatch.score
15734
+ };
15735
+ if (!acceptCollectedApi(collection, apiMatch)) continue;
15736
+ collectDecisionRules(collection, apiMatch, upperMethod);
15737
+ }
15738
+ }
15739
+ const selection = selectOwner(
15740
+ collection,
15741
+ connectorIntent,
15742
+ upperMethod,
15743
+ rawPathFromUrl(url)
15744
+ );
15745
+ if (selection.kind === "ambiguous") return selection.decision;
15746
+ return reduceSelectedOwner(
15747
+ collection,
15748
+ selection.name,
15749
+ compiledNetworkPolicies
15750
+ );
15751
+ }
15752
+ function matchFirewallHostWithParser(host, pattern, parsePatternSegment) {
15753
+ const hostSegsOrig = host.split(".");
15754
+ const hostSegsLower = hostSegsOrig.map((segment2) => {
15755
+ return segment2.toLowerCase();
15756
+ });
15757
+ const patternSegs = pattern.split(".").reverse();
15758
+ hostSegsOrig.reverse();
15759
+ hostSegsLower.reverse();
15760
+ const params = {};
15761
+ let hi = 0;
15762
+ const lastPatternIndex = patternSegs.length - 1;
15763
+ for (let patternIndex = 0; patternIndex < patternSegs.length; patternIndex++) {
15764
+ const seg = patternSegs[patternIndex];
15765
+ const parsed = parsePatternSegment(seg, patternIndex, lastPatternIndex);
15766
+ if (parsed === null) return null;
15767
+ if (parsed.kind === "literal") {
15768
+ if (hi >= hostSegsLower.length || hostSegsLower[hi] !== parsed.value.toLowerCase()) {
15769
+ return null;
15770
+ }
15771
+ hi += 1;
15772
+ continue;
15773
+ }
15774
+ const { name, prefix, suffix, greedy } = parsed;
15775
+ if (greedy === "+") {
15776
+ if (hi >= hostSegsOrig.length) return null;
15777
+ params[name] = hostSegsOrig.slice(hi).reverse().join(".");
15778
+ return params;
15779
+ }
15780
+ if (greedy === "*") {
15781
+ params[name] = hostSegsOrig.slice(hi).reverse().join(".");
15782
+ return params;
15783
+ }
15784
+ if (hi >= hostSegsOrig.length) return null;
15785
+ if (prefix === "" && suffix === "") {
15786
+ params[name] = hostSegsLower[hi];
15787
+ } else {
15788
+ const captured = matchMixedSegment(
15789
+ hostSegsLower[hi],
15790
+ prefix.toLowerCase(),
15791
+ suffix.toLowerCase()
15792
+ );
15793
+ if (captured === null) return null;
15794
+ params[name] = captured;
15795
+ }
15796
+ hi += 1;
15797
+ }
15798
+ return hi === hostSegsOrig.length ? params : null;
15799
+ }
15800
+ function matchFirewallHost(host, pattern) {
15801
+ return matchFirewallHostWithParser(host, pattern, parseStrictMatchSegment);
15802
+ }
15803
+ function parseMalformedTolerantBaseSegment(segment2, patternIndex, lastPatternIndex) {
15804
+ const parsed = parseSegment(segment2);
15805
+ if (parsed.kind === "error") {
15806
+ return {
15807
+ kind: "param",
15808
+ prefix: "",
15809
+ name: `__malformed_base_segment_${patternIndex}`,
15810
+ suffix: "",
15811
+ greedy: ""
15812
+ };
15813
+ }
15814
+ if (parsed.kind === "param" && parsed.greedy !== "" && isInvalidGreedyParam(
15815
+ patternIndex,
15816
+ lastPatternIndex,
15817
+ parsed.prefix,
15818
+ parsed.suffix
15819
+ )) {
15820
+ return { ...parsed, greedy: "" };
15821
+ }
15822
+ return parsed;
15823
+ }
15824
+ function matchFirewallHostForMalformedBaseDecision(host, pattern) {
15825
+ return matchFirewallHostWithParser(
15826
+ host,
15827
+ pattern,
15828
+ parseMalformedTolerantBaseSegment
15829
+ );
15830
+ }
15831
+ function matchFirewallPathPrefixWithParser(path, pattern, parsePatternSegment) {
15832
+ const pathSegs = splitPathSegments(path);
15833
+ const patternSegs = splitPathSegments(pattern);
15834
+ let pi = 0;
15835
+ const lastPatternIndex = patternSegs.length - 1;
15836
+ for (let patternIndex = 0; patternIndex < patternSegs.length; patternIndex++) {
15837
+ const seg = patternSegs[patternIndex];
15838
+ const parsed = parsePatternSegment(seg, patternIndex, lastPatternIndex);
15839
+ if (parsed === null) return null;
15840
+ if (parsed.kind === "literal") {
15841
+ if (pi >= pathSegs.length || pathSegs[pi] !== parsed.value) return null;
15842
+ pi += 1;
15843
+ continue;
15844
+ }
15845
+ const { prefix, suffix, greedy } = parsed;
15846
+ if (greedy === "+") {
15847
+ if (pi >= pathSegs.length || !hasNonEmptySegment(pathSegs, pi)) {
15848
+ return null;
15849
+ }
15850
+ return "/";
15851
+ }
15852
+ if (greedy === "*") {
15853
+ return "/";
15854
+ }
15855
+ if (pi >= pathSegs.length) return null;
15856
+ const runtime2 = pathSegs[pi];
15857
+ if (prefix === "" && suffix === "") {
15858
+ if (runtime2 === "") return null;
15859
+ } else if (matchMixedSegment(runtime2, prefix, suffix) === null) {
15860
+ return null;
15861
+ }
15862
+ pi += 1;
15863
+ }
15864
+ return relativePathFromSegments(pathSegs, pi);
15865
+ }
15866
+ function matchFirewallPathPrefix(path, pattern) {
15867
+ return matchFirewallPathPrefixWithParser(
15868
+ path,
15869
+ pattern,
15870
+ parseStrictMatchSegment
15871
+ );
15872
+ }
15873
+ function matchFirewallPathPrefixForMalformedBaseDecision(path, pattern) {
15874
+ return matchFirewallPathPrefixWithParser(
15875
+ path,
15876
+ pattern,
15877
+ parseMalformedTolerantBaseSegment
15878
+ );
15879
+ }
15880
+ function matchFirewallPath(path, pattern) {
15881
+ const pathSegs = splitPathSegments(path);
15882
+ const patternSegs = splitPathSegments(pattern);
15883
+ const params = {};
15884
+ let pi = 0;
15885
+ const lastPatternIndex = patternSegs.length - 1;
15886
+ for (let patternIndex = 0; patternIndex < patternSegs.length; patternIndex++) {
15887
+ const seg = patternSegs[patternIndex];
15888
+ const parsed = parseSegment(seg);
15889
+ if (parsed.kind === "error") return null;
15890
+ if (parsed.kind === "literal") {
15891
+ if (pi >= pathSegs.length || pathSegs[pi] !== parsed.value) return null;
15892
+ pi++;
15893
+ continue;
15894
+ }
15895
+ const { name, prefix, suffix, greedy } = parsed;
15896
+ if (greedy === "+") {
15897
+ if (isInvalidGreedyParam(patternIndex, lastPatternIndex, prefix, suffix))
15898
+ return null;
15899
+ if (pi >= pathSegs.length || !hasNonEmptySegment(pathSegs, pi)) {
15900
+ return null;
15901
+ }
15902
+ params[name] = pathSegs.slice(pi).join("/");
15903
+ return params;
15904
+ }
15905
+ if (greedy === "*") {
15906
+ if (isInvalidGreedyParam(patternIndex, lastPatternIndex, prefix, suffix))
15907
+ return null;
15908
+ params[name] = pathSegs.slice(pi).join("/");
15909
+ return params;
15910
+ }
15911
+ if (pi >= pathSegs.length) return null;
15912
+ const runtime2 = pathSegs[pi];
15913
+ if (prefix === "" && suffix === "") {
15914
+ if (runtime2 === "") return null;
15915
+ params[name] = runtime2;
15916
+ } else {
15917
+ const captured = matchMixedSegment(runtime2, prefix, suffix);
15918
+ if (captured === null) return null;
15919
+ params[name] = captured;
15920
+ }
15921
+ pi++;
15922
+ }
15923
+ if (pi !== pathSegs.length) return null;
15924
+ return params;
15925
+ }
15926
+
14552
15927
  export {
14553
15928
  CONNECTOR_TYPES,
14554
15929
  getConnectorEnvBindingEntries,
14555
- getConnectorStoredSecretDisplayInfo,
14556
- getDiagnosticConnectorTypeForRuntimeEnvName
15930
+ getDiagnosticConnectorTypeForRuntimeEnvName,
15931
+ matchFirewallBaseUrl,
15932
+ matchFirewallRequestDecision
14557
15933
  };
14558
- //# sourceMappingURL=chunk-5IL2HDF6.js.map
15934
+ //# sourceMappingURL=chunk-GA7UX3FL.js.map