@astrasyncai/verification-gateway 5.10.0 → 5.12.0

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 (106) hide show
  1. package/README.md +4 -0
  2. package/dist/adapters/express.d.mts +1 -1
  3. package/dist/adapters/express.d.ts +1 -1
  4. package/dist/adapters/express.js +359 -30
  5. package/dist/adapters/express.js.map +1 -1
  6. package/dist/adapters/express.mjs +359 -30
  7. package/dist/adapters/express.mjs.map +1 -1
  8. package/dist/adapters/mcp.d.mts +5 -1
  9. package/dist/adapters/mcp.d.ts +5 -1
  10. package/dist/adapters/mcp.js +168 -41
  11. package/dist/adapters/mcp.js.map +1 -1
  12. package/dist/adapters/mcp.mjs +168 -41
  13. package/dist/adapters/mcp.mjs.map +1 -1
  14. package/dist/adapters/nextjs.d.mts +1 -1
  15. package/dist/adapters/nextjs.d.ts +1 -1
  16. package/dist/adapters/nextjs.js +352 -13
  17. package/dist/adapters/nextjs.js.map +1 -1
  18. package/dist/adapters/nextjs.mjs +352 -13
  19. package/dist/adapters/nextjs.mjs.map +1 -1
  20. package/dist/adapters/sdk.d.mts +9 -1
  21. package/dist/adapters/sdk.d.ts +9 -1
  22. package/dist/adapters/sdk.js +100 -8
  23. package/dist/adapters/sdk.js.map +1 -1
  24. package/dist/adapters/sdk.mjs +100 -8
  25. package/dist/adapters/sdk.mjs.map +1 -1
  26. package/dist/agent/index.js +1 -1
  27. package/dist/agent/index.js.map +1 -1
  28. package/dist/agent/index.mjs +1 -1
  29. package/dist/agent/index.mjs.map +1 -1
  30. package/dist/bin/astrasync-claude-hook.js +805 -16
  31. package/dist/bin/astrasync-codex-hook.js +805 -16
  32. package/dist/bin/astrasync-guard.js +894 -71
  33. package/dist/bin/astrasync.js +951 -74
  34. package/dist/browser/background.js +284 -7
  35. package/dist/browser/background.js.map +1 -1
  36. package/dist/browser/background.mjs +284 -7
  37. package/dist/browser/background.mjs.map +1 -1
  38. package/dist/cli/index.d.mts +8 -8
  39. package/dist/cli/index.d.ts +8 -8
  40. package/dist/cli/index.js +22 -64
  41. package/dist/cli/index.js.map +1 -1
  42. package/dist/cli/index.mjs +22 -64
  43. package/dist/cli/index.mjs.map +1 -1
  44. package/dist/codex/index.d.mts +5 -0
  45. package/dist/codex/index.d.ts +5 -0
  46. package/dist/codex/index.js +821 -24
  47. package/dist/codex/index.js.map +1 -1
  48. package/dist/codex/index.mjs +823 -26
  49. package/dist/codex/index.mjs.map +1 -1
  50. package/dist/cursor/extension.d.mts +9 -2
  51. package/dist/cursor/extension.d.ts +9 -2
  52. package/dist/cursor/extension.js +787 -11
  53. package/dist/cursor/extension.js.map +1 -1
  54. package/dist/cursor/extension.mjs +789 -11
  55. package/dist/cursor/extension.mjs.map +1 -1
  56. package/dist/edge-config.d.mts +1 -1
  57. package/dist/edge-config.d.ts +1 -1
  58. package/dist/edge-config.js +1 -1
  59. package/dist/edge-config.js.map +1 -1
  60. package/dist/edge-config.mjs +1 -1
  61. package/dist/edge-config.mjs.map +1 -1
  62. package/dist/edge-core/index.d.mts +128 -13
  63. package/dist/edge-core/index.d.ts +128 -13
  64. package/dist/edge-core/index.js +337 -55
  65. package/dist/edge-core/index.js.map +1 -1
  66. package/dist/edge-core/index.mjs +334 -55
  67. package/dist/edge-core/index.mjs.map +1 -1
  68. package/dist/enrolment-store-8DyaIOLe.d.mts +26 -0
  69. package/dist/enrolment-store-8DyaIOLe.d.ts +26 -0
  70. package/dist/gateway/gateway.js +284 -7
  71. package/dist/gateway/gateway.js.map +1 -1
  72. package/dist/gateway/gateway.mjs +284 -7
  73. package/dist/gateway/gateway.mjs.map +1 -1
  74. package/dist/git-trigger/git-hooks.d.mts +1 -1
  75. package/dist/git-trigger/git-hooks.d.ts +1 -1
  76. package/dist/index.d.mts +215 -5
  77. package/dist/index.d.ts +215 -5
  78. package/dist/index.js +3756 -80
  79. package/dist/index.js.map +1 -1
  80. package/dist/index.mjs +3748 -80
  81. package/dist/index.mjs.map +1 -1
  82. package/dist/platform-signatures.js +4 -1
  83. package/dist/platform-signatures.js.map +1 -1
  84. package/dist/platform-signatures.mjs +4 -1
  85. package/dist/platform-signatures.mjs.map +1 -1
  86. package/dist/registration/index.js +1 -1
  87. package/dist/registration/index.js.map +1 -1
  88. package/dist/registration/index.mjs +1 -1
  89. package/dist/registration/index.mjs.map +1 -1
  90. package/dist/transport/index.js +1 -1
  91. package/dist/transport/index.js.map +1 -1
  92. package/dist/transport/index.mjs +1 -1
  93. package/dist/transport/index.mjs.map +1 -1
  94. package/dist/{types-CTmUpNpS.d.mts → types-BCkwBA84.d.mts} +12 -0
  95. package/dist/{types-CTmUpNpS.d.ts → types-BCkwBA84.d.ts} +12 -0
  96. package/dist/{types-CtFXmDzm.d.ts → types-C_b4QTyO.d.ts} +18 -0
  97. package/dist/{types-DQrn_kei.d.mts → types-DlshIIR-.d.mts} +18 -0
  98. package/dist/ui/index.d.mts +1 -1
  99. package/dist/ui/index.d.ts +1 -1
  100. package/dist/verify.d.mts +35 -4
  101. package/dist/verify.d.ts +35 -4
  102. package/dist/verify.js +130 -16
  103. package/dist/verify.js.map +1 -1
  104. package/dist/verify.mjs +129 -16
  105. package/dist/verify.mjs.map +1 -1
  106. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -51,6 +51,7 @@ __export(src_exports, {
51
51
  RegistrationTimeoutError: () => RegistrationTimeoutError,
52
52
  SDK_USER_AGENT: () => SDK_USER_AGENT,
53
53
  TRUST_LEVEL_RANGES: () => TRUST_LEVEL_RANGES,
54
+ VERIFICATION_STATUS_HEADER: () => VERIFICATION_STATUS_HEADER,
54
55
  VERSION: () => SDK_VERSION,
55
56
  _resetEdgeConfigCache: () => _resetEdgeConfigCache,
56
57
  agent: () => agent_exports,
@@ -58,9 +59,11 @@ __export(src_exports, {
58
59
  awaitStepUpApproval: () => awaitStepUpApproval,
59
60
  buildGuidance: () => buildGuidance,
60
61
  buildSdkObservedMetadata: () => buildSdkObservedMetadata,
62
+ buildVerificationUnavailableBody: () => buildVerificationUnavailableBody,
61
63
  clearCache: () => clearCache,
62
64
  createMcpMiddleware: () => createMcpMiddleware,
63
65
  degradeToObserve: () => degradeToObserve,
66
+ denyStatusFor: () => denyStatusFor,
64
67
  deriveConnectionFromHeaders: () => deriveConnectionFromHeaders,
65
68
  detectPlatformFingerprint: () => detectPlatformFingerprint,
66
69
  detectRuntime: () => detectRuntime,
@@ -77,11 +80,14 @@ __export(src_exports, {
77
80
  getWellKnownUrls: () => getWellKnownUrls,
78
81
  hasCredentials: () => hasCredentials,
79
82
  isEdgeConfig: () => isEdgeConfig,
83
+ isRejectedIdentityClaim: () => isRejectedIdentityClaim,
84
+ isVerificationUnavailable: () => isVerificationUnavailable,
80
85
  isVerifiedHopValidFor: () => isVerifiedHopValidFor,
81
86
  matchEdgePathRule: () => matchEdgePathRule,
82
87
  matchPlatformSignature: () => matchPlatformSignature,
83
88
  nextjs: () => nextjs_exports,
84
89
  normalizeDeclaredSource: () => normalizeDeclaredSource,
90
+ parseLocalPolicyYaml: () => parseYaml,
85
91
  parseVerifiedHop: () => parseVerifiedHop,
86
92
  pollStepUpStatus: () => pollStepUpStatus,
87
93
  prefetchWellKnown: () => prefetchWellKnown,
@@ -95,6 +101,8 @@ __export(src_exports, {
95
101
  serializeVerifiedHop: () => serializeVerifiedHop,
96
102
  setMcpMeta: () => setMcpMeta,
97
103
  transport: () => transport_exports,
104
+ unavailableRetryAfterSeconds: () => unavailableRetryAfterSeconds,
105
+ validateLocalPolicy: () => validatePolicy,
98
106
  verify: () => verify
99
107
  });
100
108
  module.exports = __toCommonJS(src_exports);
@@ -114,7 +122,7 @@ function getTrustLevel(score) {
114
122
  }
115
123
 
116
124
  // src/version.ts
117
- var SDK_VERSION = "5.10.0";
125
+ var SDK_VERSION = "5.12.0";
118
126
 
119
127
  // src/http.ts
120
128
  var SDK_USER_AGENT = `astrasync-sdk/${SDK_VERSION}`;
@@ -193,6 +201,59 @@ function getCachedWellKnownUrls(apiBaseUrl) {
193
201
  return cache.get(apiBaseUrl)?.data;
194
202
  }
195
203
 
204
+ // src/failure-posture.ts
205
+ var VERIFICATION_STATUS_HEADER = "X-Astra-Verification";
206
+ var DEFAULT_UNAVAILABLE_RETRY_AFTER_S = 30;
207
+ var REJECTED_IDENTITY_DIMENSIONS = /* @__PURE__ */ new Set([
208
+ "identity.invalid_agent_id",
209
+ "identity.unknown_agent",
210
+ "agent.lookup"
211
+ ]);
212
+ var UNKNOWN_AGENT_GUIDANCE = "Register your agent with AstraSync (or, inside an MCP host, add the AstraSync MCP connector for keyless, human-approved registration), then present the canonical ASTRA-* id issued after owner approval.";
213
+ var UNAVAILABLE_DIMENSIONS = /* @__PURE__ */ new Set([
214
+ "verify_access.api_error",
215
+ "middleware.internal_error"
216
+ ]);
217
+ function isVerificationUnavailable(result) {
218
+ if (result.misconfigured) return false;
219
+ return (result.failures ?? []).some((f) => UNAVAILABLE_DIMENSIONS.has(f.dimension));
220
+ }
221
+ function unavailableRetryAfterSeconds(result) {
222
+ if (typeof result.retryAfterMs === "number" && Number.isFinite(result.retryAfterMs)) {
223
+ return Math.max(1, Math.ceil(result.retryAfterMs / 1e3));
224
+ }
225
+ return DEFAULT_UNAVAILABLE_RETRY_AFTER_S;
226
+ }
227
+ function isAnonymousRead(method, credentials) {
228
+ const m = (method ?? "").toUpperCase();
229
+ if (m !== "GET" && m !== "HEAD") return false;
230
+ return !credentials.astraId && !credentials.jwt;
231
+ }
232
+ function buildVerificationUnavailableBody(result) {
233
+ return {
234
+ success: false,
235
+ error: {
236
+ code: "VERIFICATION_UNAVAILABLE",
237
+ message: "Agent verification is temporarily unavailable and this path enforces verification. Your identity was not evaluated and no denial was recorded \u2014 retry after the Retry-After interval.",
238
+ retryable: true,
239
+ retryAfterSeconds: unavailableRetryAfterSeconds(result),
240
+ ...result.failures && { failures: result.failures },
241
+ ...result.correlationId && { correlationId: result.correlationId },
242
+ guidance: {
243
+ message: "Retry the request after the Retry-After interval, with exponential backoff; the condition is transient."
244
+ }
245
+ }
246
+ };
247
+ }
248
+ function isRejectedIdentityClaim(result) {
249
+ return (result.failures ?? []).some((f) => REJECTED_IDENTITY_DIMENSIONS.has(f.dimension));
250
+ }
251
+ function denyStatusFor(result, policyDeniedCode) {
252
+ if (isRejectedIdentityClaim(result)) return { status: 403, code: "AGENT_IDENTITY_REJECTED" };
253
+ if (result.identityVerified) return { status: 403, code: policyDeniedCode };
254
+ return { status: 401, code: "UNAUTHORIZED" };
255
+ }
256
+
196
257
  // src/verify.ts
197
258
  var DEFAULT_CONFIG = {
198
259
  apiBaseUrl: "https://astrasync.ai/api",
@@ -444,11 +505,44 @@ function createGuidanceResponse(_config, reason, options = {}) {
444
505
  // coercing the absent recommendation to a policy 'deny'. Misconfig is
445
506
  // deterministic and intentionally NOT marked retryable.
446
507
  ...isApiError && { retryable: true },
508
+ ...options.httpStatus !== void 0 && { httpStatus: options.httpStatus },
509
+ ...options.retryAfterMs !== void 0 && { retryAfterMs: options.retryAfterMs },
447
510
  correlationId: options.correlationId,
448
511
  attemptId: options.attemptId,
449
512
  verifiedAt: /* @__PURE__ */ new Date()
450
513
  };
451
514
  }
515
+ async function readJsonSafe(response) {
516
+ try {
517
+ const parsed = await response.json();
518
+ return parsed && typeof parsed === "object" ? parsed : {};
519
+ } catch {
520
+ return {};
521
+ }
522
+ }
523
+ function rejectedIdentityGuidance(failures) {
524
+ const f = failures?.find((x) => REJECTED_IDENTITY_DIMENSIONS.has(x.dimension));
525
+ if (!f) return void 0;
526
+ if (f.dimension === "agent.lookup") {
527
+ return `The presented agent identifier is not registered with AstraSync. ${UNKNOWN_AGENT_GUIDANCE}`;
528
+ }
529
+ return f.guidance ? `${f.message} ${f.guidance}` : f.message;
530
+ }
531
+ var MAX_RETRY_AFTER_MS = 15 * 60 * 1e3;
532
+ function parseRetryAfterMs(response) {
533
+ const raw = response.headers?.get?.("retry-after");
534
+ if (!raw) return void 0;
535
+ const trimmed = raw.trim();
536
+ let ms;
537
+ if (/^\d+(\.\d+)?$/.test(trimmed)) {
538
+ ms = Number(trimmed) * 1e3;
539
+ } else {
540
+ const at = Date.parse(trimmed);
541
+ if (Number.isNaN(at)) return void 0;
542
+ ms = at - Date.now();
543
+ }
544
+ return Math.min(MAX_RETRY_AFTER_MS, Math.max(0, Math.round(ms)));
545
+ }
452
546
  async function callVerifyAccessAPI(config, request) {
453
547
  const { credentials, ...requestData } = request;
454
548
  const body = {
@@ -505,7 +599,8 @@ async function callVerifyAccessAPI(config, request) {
505
599
  body: JSON.stringify(body),
506
600
  signal: AbortSignal.timeout(config.verifyTimeoutMs ?? 1e4)
507
601
  });
508
- const data = await response.json();
602
+ const data = await readJsonSafe(response);
603
+ const retryAfterMs = parseRetryAfterMs(response);
509
604
  if (response.status === 410) {
510
605
  return {
511
606
  success: true,
@@ -543,6 +638,23 @@ async function callVerifyAccessAPI(config, request) {
543
638
  }
544
639
  };
545
640
  }
641
+ if (response.status === 404 && credentials.astraId && (data?.error === "AGENT_NOT_FOUND" || typeof data?.message === "string" && /agent/i.test(data.message))) {
642
+ return {
643
+ success: true,
644
+ attemptId: typeof data?.attemptId === "string" ? data.attemptId : void 0,
645
+ access: {
646
+ allowed: false,
647
+ reason: "unknown_agent",
648
+ failures: [
649
+ {
650
+ dimension: "identity.unknown_agent",
651
+ message: "The presented agent identifier is not registered with AstraSync.",
652
+ guidance: UNKNOWN_AGENT_GUIDANCE
653
+ }
654
+ ]
655
+ }
656
+ };
657
+ }
546
658
  if (!response.ok) {
547
659
  if (response.status === 401) {
548
660
  return {
@@ -557,9 +669,11 @@ async function callVerifyAccessAPI(config, request) {
557
669
  }
558
670
  return {
559
671
  success: false,
560
- error: data.message || data.error || `API returned ${response.status}`,
672
+ error: typeof data?.message === "string" && data.message || typeof data?.error === "string" && data.error || `API returned ${response.status}`,
561
673
  correlationId: typeof data?.correlationId === "string" ? data.correlationId : void 0,
562
- attemptId: typeof data?.attemptId === "string" ? data.attemptId : void 0
674
+ attemptId: typeof data?.attemptId === "string" ? data.attemptId : void 0,
675
+ httpStatus: response.status,
676
+ ...retryAfterMs !== void 0 && { retryAfterMs }
563
677
  };
564
678
  }
565
679
  return data;
@@ -631,12 +745,14 @@ async function verify(config, request, options) {
631
745
  correlationId: apiResponse.correlationId,
632
746
  attemptId: apiResponse.attemptId,
633
747
  remediation: apiResponse.remediation,
748
+ httpStatus: apiResponse.httpStatus,
749
+ retryAfterMs: apiResponse.retryAfterMs,
634
750
  urls
635
751
  });
636
752
  }
637
753
  if (!apiResponse.access?.allowed) {
638
754
  const aggregatedFailures = apiResponse.access?.failures;
639
- const idVerifiedFromBackend = apiResponse.verificationContext?.idVerified === true;
755
+ const idVerifiedFromBackend = apiResponse.verificationContext?.idVerified === true && !aggregatedFailures?.some((f) => REJECTED_IDENTITY_DIMENSIONS.has(f.dimension));
640
756
  const result2 = {
641
757
  identityVerified: idVerifiedFromBackend,
642
758
  policyAllowed: false,
@@ -648,7 +764,10 @@ async function verify(config, request, options) {
648
764
  requiresStepUp: apiResponse.access?.requiresStepUp,
649
765
  requiresApproval: apiResponse.access?.requiresApproval,
650
766
  guidance: {
651
- message: apiResponse.access?.reason || "Access denied by PDLSS policy",
767
+ // 5.12.0: a presented-but-rejected id (malformed / unknown) carries
768
+ // actionable registration guidance on its failure — surface it
769
+ // instead of the bare machine reason ('unknown_agent').
770
+ message: rejectedIdentityGuidance(aggregatedFailures) ?? (apiResponse.access?.reason || "Access denied by PDLSS policy"),
652
771
  registrationUrl: urls?.registrationUrl ?? "",
653
772
  documentationUrl: urls?.documentationUrl ?? "",
654
773
  // 5.1.0: anonymous callers land on this branch — steer MCP-hosted
@@ -748,7 +867,7 @@ async function verify(config, request, options) {
748
867
  registrationUrl: urls?.registrationUrl ?? "",
749
868
  documentationUrl: urls?.documentationUrl ?? ""
750
869
  };
751
- } else if (result.recommendation === "step_up_required") {
870
+ } else if (result.recommendation === "step_up_required" && result.identityVerified) {
752
871
  result.requiresStepUp = true;
753
872
  result.denialReasons = serverDenialReasons ?? result.recommendationReasons ?? ["Step-up verification required"];
754
873
  }
@@ -771,7 +890,7 @@ async function recordDecision(config, sessionId, decision, reason) {
771
890
  }).catch(() => {
772
891
  });
773
892
  }
774
- async function reportAttempt(config, report) {
893
+ async function reportAttempt(config, report, options = {}) {
775
894
  const apiBaseUrl = config.apiBaseUrl || DEFAULT_CONFIG.apiBaseUrl;
776
895
  const headers = { "Content-Type": "application/json" };
777
896
  if (config.apiKey) {
@@ -782,13 +901,37 @@ async function reportAttempt(config, report) {
782
901
  ...report,
783
902
  ...!report.counterpartyId && config.counterpartyId && { counterpartyId: config.counterpartyId }
784
903
  };
785
- await sdkFetch(`${apiBaseUrl}/agents/verify-access/attempt-report`, {
786
- method: "POST",
787
- headers,
788
- body: JSON.stringify(body)
789
- }).catch(() => {
790
- });
904
+ const url = `${apiBaseUrl}/agents/verify-access/attempt-report`;
905
+ const init = { method: "POST", headers, body: JSON.stringify(body) };
906
+ const fail = (failure) => {
907
+ try {
908
+ options.onFailure?.(failure);
909
+ } catch {
910
+ }
911
+ };
912
+ let response;
913
+ try {
914
+ response = await sdkFetch(url, init);
915
+ } catch (err) {
916
+ fail({ error: err instanceof Error ? err.message : String(err), retried: false });
917
+ return;
918
+ }
919
+ if (response.ok) return;
920
+ if (response.status !== 429 && response.status < 500) {
921
+ fail({ status: response.status, retried: false });
922
+ return;
923
+ }
924
+ const delayMs = Math.min(ATTEMPT_REPORT_MAX_RETRY_DELAY_MS, parseRetryAfterMs(response) ?? 500);
925
+ const timer = setTimeout(() => {
926
+ sdkFetch(url, init).then((retry) => {
927
+ if (!retry.ok) fail({ status: retry.status, retried: true });
928
+ }).catch((err) => {
929
+ fail({ error: err instanceof Error ? err.message : String(err), retried: true });
930
+ });
931
+ }, delayMs);
932
+ timer.unref?.();
791
933
  }
934
+ var ATTEMPT_REPORT_MAX_RETRY_DELAY_MS = 2e3;
792
935
  async function fetchRoutes(config, counterpartyId) {
793
936
  if (!counterpartyId) return null;
794
937
  const headers = { "Content-Type": "application/json" };
@@ -818,7 +961,10 @@ async function reportUnregisteredAttempt(config, data) {
818
961
  };
819
962
  await sdkFetch(`${apiBaseUrl}/verification-activity/unregistered-attempt`, {
820
963
  method: "POST",
821
- headers: { "Content-Type": "application/json" },
964
+ headers: {
965
+ "Content-Type": "application/json",
966
+ ...config.apiKey && { Authorization: `Bearer ${config.apiKey}` }
967
+ },
822
968
  body: JSON.stringify(body)
823
969
  }).catch(() => {
824
970
  });
@@ -840,7 +986,11 @@ async function quickVerify(config, credentials) {
840
986
  return {
841
987
  identityVerified: result.identityVerified,
842
988
  policyAllowed: result.policyAllowed,
843
- reason: result.denialReasons?.[0]
989
+ reason: result.denialReasons?.[0],
990
+ ...isVerificationUnavailable(result) && {
991
+ unavailable: true,
992
+ retryAfterMs: unavailableRetryAfterSeconds(result) * 1e3
993
+ }
844
994
  };
845
995
  }
846
996
 
@@ -1588,7 +1738,10 @@ var PLATFORM_AGENT_SIGNATURES = [
1588
1738
  {
1589
1739
  vendor: "chatgpt",
1590
1740
  displayName: "OpenAI ChatGPT",
1591
- uaPatterns: [/chatgpt/i, /openai/i, /gpt-?\d/i],
1741
+ // GPTBot (training crawler) and OAI-SearchBot (ChatGPT search) are
1742
+ // OpenAI's declared crawler UAs — `gpt-?\d` never matched them, so they
1743
+ // classified as unattributed crawlers (round-27.4 W5).
1744
+ uaPatterns: [/chatgpt/i, /openai/i, /gpt-?\d/i, /\bGPTBot\b/i, /\bOAI-SearchBot\b/i],
1592
1745
  agentCardPatterns: [/openai\.com/i, /chatgpt\.com/i],
1593
1746
  apiKeyFormatPatterns: [/^sk-proj/i, /^sk-svcacct/i],
1594
1747
  headerPatterns: [/^openai-organization/i, /^openai-project/i, /^openai-version/i]
@@ -1723,6 +1876,215 @@ var BROWSER_UA_PATTERN = /mozilla\/\d/i;
1723
1876
  var _patterns = { STATIC_EXTENSIONS, BOT_UA_PATTERN, BROWSER_UA_PATTERN, SELF_UA_PATTERN };
1724
1877
 
1725
1878
  // src/edge-core/events.ts
1879
+ async function withBudget(promise, ms) {
1880
+ let timer;
1881
+ try {
1882
+ return await Promise.race([
1883
+ promise,
1884
+ new Promise((resolve) => {
1885
+ timer = setTimeout(() => resolve(void 0), ms);
1886
+ })
1887
+ ]);
1888
+ } catch {
1889
+ return void 0;
1890
+ } finally {
1891
+ if (timer) clearTimeout(timer);
1892
+ }
1893
+ }
1894
+ var destKeyOf = (d) => `${d.apiBaseUrl}\0${d.apiKey ?? ""}\0${d.counterparty}\0${d.adapter ?? ""}`;
1895
+ var BeaconBuffer = class {
1896
+ constructor(options = {}) {
1897
+ this.queue = [];
1898
+ this.droppedSinceLast = 0;
1899
+ this.droppedTotal = 0;
1900
+ this.deliveredTotal = 0;
1901
+ this.backoffUntil = 0;
1902
+ this.collapse = /* @__PURE__ */ new Map();
1903
+ /** Keys the backend answered 401 for — later batches go unauthenticated. */
1904
+ this.rejectedKeys = /* @__PURE__ */ new Set();
1905
+ this.opts = {
1906
+ maxItems: options.maxItems ?? 1e3,
1907
+ maxBatch: options.maxBatch ?? 100,
1908
+ maxAttempts: options.maxAttempts ?? 3,
1909
+ collapseWindowMs: options.collapseWindowMs ?? 6e4,
1910
+ collapseMaxKeys: options.collapseMaxKeys ?? 1e3,
1911
+ requestTimeoutMs: options.requestTimeoutMs ?? 1e4,
1912
+ retryBackoffMs: options.retryBackoffMs ?? 1e3,
1913
+ now: options.now ?? Date.now
1914
+ };
1915
+ }
1916
+ /**
1917
+ * Queue one beacon. With a `collapseKey`, a repeat inside the window is
1918
+ * merged into a held aggregate (sent when the window closes) instead of
1919
+ * becoming its own item.
1920
+ */
1921
+ enqueue(dest, item, collapseKey) {
1922
+ const now = this.opts.now();
1923
+ if (collapseKey) {
1924
+ const entry = this.collapse.get(collapseKey);
1925
+ if (entry && now - entry.firstSeenAt < this.opts.collapseWindowMs) {
1926
+ for (const target of [entry.first, entry.held]) {
1927
+ if (target && !target.inFlight && this.queue.includes(target)) {
1928
+ target.item.repeatCount = (target.item.repeatCount ?? 1) + 1;
1929
+ return;
1930
+ }
1931
+ }
1932
+ const held = this.push(
1933
+ dest,
1934
+ { ...item, repeatCount: 1 },
1935
+ entry.firstSeenAt + this.opts.collapseWindowMs
1936
+ );
1937
+ entry.held = held;
1938
+ return;
1939
+ }
1940
+ this.collapse.delete(collapseKey);
1941
+ if (this.collapse.size >= this.opts.collapseMaxKeys) {
1942
+ const oldest = this.collapse.keys().next().value;
1943
+ if (oldest !== void 0) this.collapse.delete(oldest);
1944
+ }
1945
+ const fresh = { firstSeenAt: now };
1946
+ this.collapse.set(collapseKey, fresh);
1947
+ fresh.first = this.push(dest, item, now);
1948
+ return;
1949
+ }
1950
+ this.push(dest, item, now);
1951
+ }
1952
+ /**
1953
+ * Deliver every eligible queued item. Concurrent callers share ONE
1954
+ * in-flight drain (it survives the caller's budget and a Lambda freeze),
1955
+ * so nothing in flight is ever sent twice; items queued while it runs are
1956
+ * picked up by the same drain.
1957
+ */
1958
+ flush() {
1959
+ if (!this.inFlight) {
1960
+ this.inFlight = this.drain().finally(() => {
1961
+ this.inFlight = void 0;
1962
+ });
1963
+ }
1964
+ return this.inFlight;
1965
+ }
1966
+ /** Counters for tests and diagnostics. */
1967
+ stats() {
1968
+ return {
1969
+ queueDepth: this.queue.length,
1970
+ droppedSinceLast: this.droppedSinceLast,
1971
+ droppedTotal: this.droppedTotal,
1972
+ deliveredTotal: this.deliveredTotal,
1973
+ flushing: this.inFlight !== void 0
1974
+ };
1975
+ }
1976
+ push(dest, item, eligibleAt) {
1977
+ while (this.queue.length >= this.opts.maxItems) this.dropOldest();
1978
+ const entry = {
1979
+ dest,
1980
+ destKey: destKeyOf(dest),
1981
+ item,
1982
+ attempts: 0,
1983
+ eligibleAt,
1984
+ inFlight: false
1985
+ };
1986
+ this.queue.push(entry);
1987
+ return entry;
1988
+ }
1989
+ dropOldest() {
1990
+ if (this.queue.shift()) this.countDropped(1);
1991
+ }
1992
+ countDropped(n) {
1993
+ this.droppedSinceLast += n;
1994
+ this.droppedTotal += n;
1995
+ }
1996
+ async drain() {
1997
+ for (; ; ) {
1998
+ const now = this.opts.now();
1999
+ if (now < this.backoffUntil) return;
2000
+ const batch = this.takeBatch(now);
2001
+ if (batch.length === 0) return;
2002
+ const ok = await this.send(batch);
2003
+ if (!ok) return;
2004
+ }
2005
+ }
2006
+ /** Oldest eligible item + up to maxBatch-1 more for the same destination. */
2007
+ takeBatch(now) {
2008
+ const first = this.queue.find((q) => q.eligibleAt <= now);
2009
+ if (!first) return [];
2010
+ const batch = [];
2011
+ const rest = [];
2012
+ for (const q of this.queue) {
2013
+ if (batch.length < this.opts.maxBatch && q.destKey === first.destKey && q.eligibleAt <= now) {
2014
+ q.inFlight = true;
2015
+ batch.push(q);
2016
+ } else {
2017
+ rest.push(q);
2018
+ }
2019
+ }
2020
+ this.queue = rest;
2021
+ return batch;
2022
+ }
2023
+ /** POST one batch. Returns false when the drain should pause (backoff). */
2024
+ async send(batch) {
2025
+ const dest = batch[0].dest;
2026
+ const useKey = dest.apiKey && !this.rejectedKeys.has(dest.apiKey) ? dest.apiKey : void 0;
2027
+ const reportedDropped = this.droppedSinceLast;
2028
+ const meta = {
2029
+ droppedSinceLast: reportedDropped,
2030
+ queueDepth: this.queue.length,
2031
+ adapter: dest.adapter ?? "edge-core",
2032
+ version: SDK_VERSION
2033
+ };
2034
+ const controller = typeof AbortController !== "undefined" ? new AbortController() : void 0;
2035
+ const response = await withBudget(
2036
+ sdkFetch(`${dest.apiBaseUrl}/verification-activity/edge-events`, {
2037
+ method: "POST",
2038
+ headers: {
2039
+ "Content-Type": "application/json",
2040
+ ...useKey && { Authorization: `Bearer ${useKey}` }
2041
+ },
2042
+ body: JSON.stringify({ events: batch.map((q) => q.item), meta }),
2043
+ ...controller && { signal: controller.signal }
2044
+ }),
2045
+ this.opts.requestTimeoutMs
2046
+ );
2047
+ if (!response) controller?.abort();
2048
+ const status = response?.status;
2049
+ for (const q of batch) q.inFlight = false;
2050
+ if (status !== void 0 && status >= 200 && status < 300) {
2051
+ this.droppedSinceLast = Math.max(0, this.droppedSinceLast - reportedDropped);
2052
+ this.deliveredTotal += batch.length;
2053
+ return true;
2054
+ }
2055
+ if (status === 401 && useKey) {
2056
+ this.rejectedKeys.add(useKey);
2057
+ this.requeue(batch, false);
2058
+ return true;
2059
+ }
2060
+ if (status === 429) {
2061
+ const retryAfter = Number(response?.headers.get("retry-after"));
2062
+ const waitMs = Number.isFinite(retryAfter) && retryAfter > 0 ? Math.min(retryAfter, 120) * 1e3 : 3e4;
2063
+ this.backoffUntil = this.opts.now() + waitMs;
2064
+ this.requeue(batch, false);
2065
+ return false;
2066
+ }
2067
+ if (status !== void 0 && status >= 400 && status < 500) {
2068
+ this.countDropped(batch.length);
2069
+ return true;
2070
+ }
2071
+ this.backoffUntil = this.opts.now() + this.opts.retryBackoffMs;
2072
+ this.requeue(batch, true);
2073
+ return false;
2074
+ }
2075
+ /** Put a failed batch back at the head of the queue (order preserved). */
2076
+ requeue(batch, countAttempt) {
2077
+ const keep = [];
2078
+ for (const q of batch) {
2079
+ if (countAttempt) q.attempts += 1;
2080
+ if (q.attempts >= this.opts.maxAttempts) this.countDropped(1);
2081
+ else keep.push(q);
2082
+ }
2083
+ this.queue = [...keep, ...this.queue];
2084
+ while (this.queue.length > this.opts.maxItems) this.dropOldest();
2085
+ }
2086
+ };
2087
+ var beaconBuffer = new BeaconBuffer();
1726
2088
  function sampled(rate, random = Math.random) {
1727
2089
  if (rate <= 0) return false;
1728
2090
  if (rate >= 1) return true;
@@ -1899,12 +2261,19 @@ function defaultOnDenied(result, _req, res) {
1899
2261
  });
1900
2262
  return;
1901
2263
  }
1902
- const statusCode = !result.identityVerified ? 401 : 403;
2264
+ if (isVerificationUnavailable(result)) {
2265
+ res.setHeader("X-Astra-Gateway-Mode", "enforced");
2266
+ res.setHeader(VERIFICATION_STATUS_HEADER, "unavailable");
2267
+ res.setHeader("Retry-After", String(unavailableRetryAfterSeconds(result)));
2268
+ res.status(503).json(buildVerificationUnavailableBody(result));
2269
+ return;
2270
+ }
2271
+ const { status: statusCode, code } = denyStatusFor(result, "INSUFFICIENT_ACCESS");
1903
2272
  res.setHeader("X-Astra-Gateway-Mode", "enforced");
1904
2273
  res.status(statusCode).json({
1905
2274
  success: false,
1906
2275
  error: {
1907
- code: !result.identityVerified ? "UNAUTHORIZED" : "INSUFFICIENT_ACCESS",
2276
+ code,
1908
2277
  message: result.denialReasons?.[0] || "Access denied",
1909
2278
  guidance: result.guidance,
1910
2279
  // Round-10: aggregated per-dimension detail + correlation handle.
@@ -2152,6 +2521,21 @@ function createMiddleware(options) {
2152
2521
  result.stepUpOutcome = outcome;
2153
2522
  }
2154
2523
  }
2524
+ if (!result.policyAllowed && isVerificationUnavailable(result) && (!shouldEnforce || isAnonymousRead(req.method, credentials))) {
2525
+ res.setHeader(VERIFICATION_STATUS_HEADER, "unavailable");
2526
+ return next();
2527
+ }
2528
+ if (!shouldEnforce) {
2529
+ if (config.setPassThroughHeader) {
2530
+ res.setHeader("X-Astra-Gateway-Mode", "enforced");
2531
+ res.setHeader("X-Astra-Gateway-Reason", "evaluated-not-enforced");
2532
+ }
2533
+ if (shouldRecordDecisions && sessionId) {
2534
+ recordDecision(config, sessionId, "granted").catch(() => {
2535
+ });
2536
+ }
2537
+ return next();
2538
+ }
2155
2539
  if (!result.policyAllowed) {
2156
2540
  if (shouldRecordDecisions && sessionId) {
2157
2541
  recordDecision(config, sessionId, "denied", result.denialReasons?.[0]).catch(() => {
@@ -2171,17 +2555,6 @@ function createMiddleware(options) {
2171
2555
  onDenied(result, req, res);
2172
2556
  return;
2173
2557
  }
2174
- if (!shouldEnforce) {
2175
- if (config.setPassThroughHeader) {
2176
- res.setHeader("X-Astra-Gateway-Mode", "enforced");
2177
- res.setHeader("X-Astra-Gateway-Reason", "evaluated-not-enforced");
2178
- }
2179
- if (shouldRecordDecisions && sessionId) {
2180
- recordDecision(config, sessionId, "granted").catch(() => {
2181
- });
2182
- }
2183
- return next();
2184
- }
2185
2558
  if (routeConfig.minTrustScore && result.agent) {
2186
2559
  if (result.agent.trustScore < routeConfig.minTrustScore) {
2187
2560
  const trustFailure = {
@@ -2237,14 +2610,6 @@ function createMiddleware(options) {
2237
2610
  verifiedAt: /* @__PURE__ */ new Date(),
2238
2611
  correlationId
2239
2612
  };
2240
- const catchUrls = config.apiBaseUrl ? await getWellKnownUrls(config.apiBaseUrl).catch(() => void 0) : void 0;
2241
- if (catchUrls) {
2242
- result.guidance = {
2243
- message: `Middleware threw ${errorClass} \u2014 failing closed`,
2244
- registrationUrl: catchUrls.registrationUrl,
2245
- documentationUrl: catchUrls.documentationUrl
2246
- };
2247
- }
2248
2613
  dedupeFailures(result);
2249
2614
  return onDenied(result, req, res);
2250
2615
  }
@@ -2664,6 +3029,20 @@ function createMiddleware2(options) {
2664
3029
  }
2665
3030
  const approvalRequired = result.policyAllowed && requiresHumanApproval(result);
2666
3031
  if (approvalRequired) annotateApprovalRequired(result);
3032
+ if (!result.policyAllowed && isVerificationUnavailable(result)) {
3033
+ if (isAnonymousRead(request.method, credentials)) {
3034
+ const passThrough = NextResponse.next();
3035
+ passThrough.headers.set(VERIFICATION_STATUS_HEADER, "unavailable");
3036
+ return passThrough;
3037
+ }
3038
+ return NextResponse.json(buildVerificationUnavailableBody(result), {
3039
+ status: 503,
3040
+ headers: {
3041
+ "Retry-After": String(unavailableRetryAfterSeconds(result)),
3042
+ [VERIFICATION_STATUS_HEADER]: "unavailable"
3043
+ }
3044
+ });
3045
+ }
2667
3046
  if (!result.policyAllowed || approvalRequired) {
2668
3047
  if (result.misconfigured && pathname.startsWith("/api/")) {
2669
3048
  return NextResponse.json(
@@ -2681,13 +3060,12 @@ function createMiddleware2(options) {
2681
3060
  );
2682
3061
  }
2683
3062
  if (pathname.startsWith("/api/")) {
3063
+ const denyStatus = denyStatusFor(result, "POLICY_DENIED");
2684
3064
  return NextResponse.json(
2685
3065
  {
2686
3066
  success: false,
2687
3067
  error: {
2688
- // Round-18 G4: 401 → identity missing (re-auth); 403 → identity
2689
- // OK, policy denied (update PDLSS / step up).
2690
- code: !result.identityVerified ? "UNAUTHORIZED" : "POLICY_DENIED",
3068
+ code: denyStatus.code,
2691
3069
  message: result.denialReasons?.[0] || "Access denied",
2692
3070
  guidance: result.guidance,
2693
3071
  failures: result.failures,
@@ -2697,7 +3075,7 @@ function createMiddleware2(options) {
2697
3075
  }
2698
3076
  },
2699
3077
  {
2700
- status: !result.identityVerified ? 401 : 403,
3078
+ status: denyStatus.status,
2701
3079
  ...stepUpHoldOutcome && {
2702
3080
  headers: { "X-Astra-Step-Up": stepUpHoldOutcome }
2703
3081
  }
@@ -2824,6 +3202,12 @@ var VerificationGatewayClient = class {
2824
3202
  * fulfil against it only once the order is settled / pending_merchant. An
2825
3203
  * explicit `buyerEmail` (here or on the bridge handoff body) wins over the
2826
3204
  * account default.
3205
+ *
3206
+ * 5.12.0 approval binding: pass the bridge handoff body's `attemptId` (and
3207
+ * the same `checkoutSessionId`) so a step-up approval minted for this cart
3208
+ * is matched to — and only to — this confirm. A held cart's approval is
3209
+ * bound to its checkout session and exact value; a confirm for any other
3210
+ * cart is held for its own approval.
2827
3211
  */
2828
3212
  async confirmCheckout(options) {
2829
3213
  const credentials = {
@@ -2843,6 +3227,7 @@ var VerificationGatewayClient = class {
2843
3227
  commercePhase: "confirm",
2844
3228
  checkoutSessionId: options.checkoutSessionId,
2845
3229
  checkoutItems: options.checkoutItems,
3230
+ ...options.attemptId && { attemptId: options.attemptId },
2846
3231
  buyerEmail: options.buyerEmail,
2847
3232
  counterpartyUrl: options.counterpartyUrl,
2848
3233
  counterpartyType: options.counterpartyType
@@ -2874,11 +3259,11 @@ var VerificationGatewayClient = class {
2874
3259
  },
2875
3260
  body: JSON.stringify(options)
2876
3261
  });
2877
- const json = await res.json().catch(() => ({}));
2878
- if (!res.ok || !json.success || !json.data) {
2879
- throw new Error(`reportSettlement failed (${res.status}): ${json.error ?? "unknown error"}`);
3262
+ const json2 = await res.json().catch(() => ({}));
3263
+ if (!res.ok || !json2.success || !json2.data) {
3264
+ throw new Error(`reportSettlement failed (${res.status}): ${json2.error ?? "unknown error"}`);
2880
3265
  }
2881
- return json.data;
3266
+ return json2.data;
2882
3267
  }
2883
3268
  /**
2884
3269
  * Quick verification — checks credentials and policy in one call.
@@ -3707,8 +4092,8 @@ function extractPaymentToken(body) {
3707
4092
  const raw = coerceString3(paymentData.token);
3708
4093
  const provider = coerceString3(paymentData.provider);
3709
4094
  if (!raw) return { raw: void 0, type: null, provider };
3710
- const type = classifyPaymentToken(raw);
3711
- return { raw, type, provider };
4095
+ const type2 = classifyPaymentToken(raw);
4096
+ return { raw, type: type2, provider };
3712
4097
  }
3713
4098
  function classifyPaymentToken(token) {
3714
4099
  if (token.startsWith("spt_")) return "stripe-spt";
@@ -3935,7 +4320,7 @@ function verifyStripeWebhook(payload, signatureHeader, secret, options = {}) {
3935
4320
  return { ok: false, timestamp: parsed.timestamp, error: "signature mismatch" };
3936
4321
  }
3937
4322
  function parseStripeSignature(header) {
3938
- let timestamp = null;
4323
+ let timestamp2 = null;
3939
4324
  const v1Signatures = [];
3940
4325
  for (const part of header.split(",")) {
3941
4326
  const [rawKey, rawValue] = part.split("=");
@@ -3944,12 +4329,12 @@ function parseStripeSignature(header) {
3944
4329
  const value = rawValue.trim();
3945
4330
  if (key === "t") {
3946
4331
  const n = Number(value);
3947
- if (Number.isFinite(n)) timestamp = n;
4332
+ if (Number.isFinite(n)) timestamp2 = n;
3948
4333
  } else if (key === "v1") {
3949
4334
  v1Signatures.push(value);
3950
4335
  }
3951
4336
  }
3952
- return { timestamp, v1Signatures };
4337
+ return { timestamp: timestamp2, v1Signatures };
3953
4338
  }
3954
4339
  function hexToBuffer(hex) {
3955
4340
  if (!/^[0-9a-fA-F]+$/.test(hex) || hex.length % 2 !== 0) return null;
@@ -4156,10 +4541,10 @@ function extractAP2Mandate(sdJwtCompact) {
4156
4541
  payload,
4157
4542
  disclosures
4158
4543
  );
4159
- const type = coerceMandateType2(claims.type ?? claims.mandate_type ?? claims.mandateType);
4160
- if (!type) return null;
4161
- if (type === "intent_mandate") return buildIntent(claims);
4162
- if (type === "cart_mandate") return buildCart(claims);
4544
+ const type2 = coerceMandateType2(claims.type ?? claims.mandate_type ?? claims.mandateType);
4545
+ if (!type2) return null;
4546
+ if (type2 === "intent_mandate") return buildIntent(claims);
4547
+ if (type2 === "cart_mandate") return buildCart(claims);
4163
4548
  return buildPayment(claims);
4164
4549
  }
4165
4550
  function extractAP2Mandates(input) {
@@ -4765,8 +5150,8 @@ function extractX402FromRequest(request) {
4765
5150
  try {
4766
5151
  const decoded = (0, import_utils.safeBase64Decode)(headerValue3);
4767
5152
  if (decoded) {
4768
- const json = JSON.parse(decoded);
4769
- const parsed = tryParsePayload(json);
5153
+ const json2 = JSON.parse(decoded);
5154
+ const parsed = tryParsePayload(json2);
4770
5155
  if (parsed) return buildPayloadContext(parsed, "header");
4771
5156
  }
4772
5157
  } catch {
@@ -4791,8 +5176,8 @@ function extractX402FromResponse(response) {
4791
5176
  try {
4792
5177
  const decoded = (0, import_utils.safeBase64Decode)(headerValue3);
4793
5178
  if (decoded) {
4794
- const json = JSON.parse(decoded);
4795
- const parsed = tryParseRequired(json);
5179
+ const json2 = JSON.parse(decoded);
5180
+ const parsed = tryParseRequired(json2);
4796
5181
  if (parsed) return buildRequiredContext(parsed, "header");
4797
5182
  }
4798
5183
  } catch {
@@ -5643,8 +6028,37 @@ function dedupeFailures2(result) {
5643
6028
  result.denialReasons = [...new Set(result.denialReasons)];
5644
6029
  }
5645
6030
  }
6031
+ function isReadOnlyMcpMethod(parsed) {
6032
+ return parsed.method !== "tools/call";
6033
+ }
5646
6034
  function defaultMcpDenied(result, req, res) {
5647
6035
  const id = req.body?.id ?? null;
6036
+ if (isVerificationUnavailable(result)) {
6037
+ const retryAfterSeconds = unavailableRetryAfterSeconds(result);
6038
+ const body = buildVerificationUnavailableBody(result).error;
6039
+ res.setHeader("X-Astra-Gateway-Mode", "enforced");
6040
+ res.setHeader(VERIFICATION_STATUS_HEADER, "unavailable");
6041
+ res.setHeader("Retry-After", String(retryAfterSeconds));
6042
+ res.status(503).json({
6043
+ jsonrpc: "2.0",
6044
+ id,
6045
+ error: {
6046
+ // -32003 → verification temporarily unavailable (retryable)
6047
+ code: -32003,
6048
+ message: body.message,
6049
+ data: {
6050
+ code: body.code,
6051
+ recommendation: "error",
6052
+ retryable: true,
6053
+ retryAfterSeconds,
6054
+ guidance: body.guidance,
6055
+ failures: result.failures,
6056
+ correlationId: result.correlationId
6057
+ }
6058
+ }
6059
+ });
6060
+ return;
6061
+ }
5648
6062
  if (result.misconfigured) {
5649
6063
  res.setHeader("X-Astra-Gateway-Mode", "enforced");
5650
6064
  res.status(503).json({
@@ -5663,7 +6077,7 @@ function defaultMcpDenied(result, req, res) {
5663
6077
  });
5664
6078
  return;
5665
6079
  }
5666
- const status = !result.identityVerified ? 401 : 403;
6080
+ const { status, code: denyCode } = denyStatusFor(result, "INSUFFICIENT_ACCESS");
5667
6081
  res.setHeader("X-Astra-Gateway-Mode", "enforced");
5668
6082
  res.status(status).json({
5669
6083
  jsonrpc: "2.0",
@@ -5673,9 +6087,11 @@ function defaultMcpDenied(result, req, res) {
5673
6087
  // -32000 → unauthorized (no identity resolved)
5674
6088
  // -32001 → insufficient access (identity OK, policy denied)
5675
6089
  // -32002 → merchant verification misconfigured (handled above)
6090
+ // -32003 → verification temporarily unavailable (handled above)
5676
6091
  code: !result.identityVerified ? -32e3 : -32001,
5677
6092
  message: result.denialReasons?.[0] ?? "Access denied",
5678
6093
  data: {
6094
+ code: denyCode,
5679
6095
  guidance: result.guidance,
5680
6096
  // Round-10: aggregated per-dimension detail + correlation handle.
5681
6097
  failures: result.failures,
@@ -5803,6 +6219,9 @@ function createMcpMiddleware(options) {
5803
6219
  resolved_action: pdlss.action
5804
6220
  });
5805
6221
  }
6222
+ if (!pdlss.purpose && !shouldEnforce) {
6223
+ return next();
6224
+ }
5806
6225
  if (!pdlss.purpose) {
5807
6226
  const id = req.body?.id ?? null;
5808
6227
  res.status(400).json({
@@ -5822,6 +6241,9 @@ function createMcpMiddleware(options) {
5822
6241
  }
5823
6242
  const counterpartyUrl = config.counterpartyUrl || `${req.protocol}://${req.get("host")}${req.path}`;
5824
6243
  const shouldRecordDecisions = recordDecisions !== false;
6244
+ const forwardedFor = req.headers["x-forwarded-for"];
6245
+ const forwardedForStr = Array.isArray(forwardedFor) ? forwardedFor.join(", ") : forwardedFor;
6246
+ const sourceIp = req.ip ?? (forwardedForStr ? forwardedForStr.split(",")[0].trim() : void 0);
5825
6247
  const verificationRequest = {
5826
6248
  credentials,
5827
6249
  purpose: pdlss.purpose,
@@ -5836,9 +6258,10 @@ function createMcpMiddleware(options) {
5836
6258
  counterpartyType: config.counterpartyType || "mcp_server",
5837
6259
  enableRuntimeChallenge,
5838
6260
  callerMetadata: {
5839
- sourceIp: req.ip,
6261
+ sourceIp,
5840
6262
  userAgent: req.headers["user-agent"],
5841
6263
  host: req.headers.host,
6264
+ ...forwardedForStr && { forwardedFor: forwardedForStr },
5842
6265
  // Capture EVERY inbound header (parity with the express adapter —
5843
6266
  // MCP-only merchants have no edge to do it upstream) plus the
5844
6267
  // CDN-derived connection block. Local string work, secrets
@@ -5861,6 +6284,21 @@ function createMcpMiddleware(options) {
5861
6284
  result.stepUpOutcome = outcome;
5862
6285
  }
5863
6286
  }
6287
+ if (!result.policyAllowed && isVerificationUnavailable(result) && (!shouldEnforce || isReadOnlyMcpMethod(parsed) && !credentials.astraId && !credentials.jwt)) {
6288
+ res.setHeader(VERIFICATION_STATUS_HEADER, "unavailable");
6289
+ return next();
6290
+ }
6291
+ if (!shouldEnforce) {
6292
+ if (config.setPassThroughHeader) {
6293
+ res.setHeader("X-Astra-Gateway-Mode", "enforced");
6294
+ res.setHeader("X-Astra-Gateway-Reason", "evaluated-not-enforced");
6295
+ }
6296
+ if (shouldRecordDecisions && sessionId) {
6297
+ recordDecision(config, sessionId, "granted").catch(() => {
6298
+ });
6299
+ }
6300
+ return next();
6301
+ }
5864
6302
  if (!result.policyAllowed) {
5865
6303
  if (shouldRecordDecisions && sessionId) {
5866
6304
  recordDecision(config, sessionId, "denied", result.denialReasons?.[0]).catch(() => {
@@ -5880,17 +6318,6 @@ function createMcpMiddleware(options) {
5880
6318
  onDenied(result, req, res);
5881
6319
  return;
5882
6320
  }
5883
- if (!shouldEnforce) {
5884
- if (config.setPassThroughHeader) {
5885
- res.setHeader("X-Astra-Gateway-Mode", "enforced");
5886
- res.setHeader("X-Astra-Gateway-Reason", "evaluated-not-enforced");
5887
- }
5888
- if (shouldRecordDecisions && sessionId) {
5889
- recordDecision(config, sessionId, "granted").catch(() => {
5890
- });
5891
- }
5892
- return next();
5893
- }
5894
6321
  if (effectiveAstraId) {
5895
6322
  res.setHeader(
5896
6323
  MCP_VERIFIED_HOP_HEADER,
@@ -5931,14 +6358,6 @@ function createMcpMiddleware(options) {
5931
6358
  verifiedAt: /* @__PURE__ */ new Date(),
5932
6359
  correlationId
5933
6360
  };
5934
- const catchUrls = config.apiBaseUrl ? await getWellKnownUrls(config.apiBaseUrl).catch(() => void 0) : void 0;
5935
- if (catchUrls) {
5936
- result.guidance = {
5937
- message: `Middleware threw ${errorClass} \u2014 failing closed`,
5938
- registrationUrl: catchUrls.registrationUrl,
5939
- documentationUrl: catchUrls.documentationUrl
5940
- };
5941
- }
5942
6361
  dedupeFailures2(result);
5943
6362
  return onDenied(result, req, res);
5944
6363
  }
@@ -6674,6 +7093,3255 @@ function detectRuntime(userAgent) {
6674
7093
  }
6675
7094
  return void 0;
6676
7095
  }
7096
+
7097
+ // ../../node_modules/js-yaml/dist/js-yaml.mjs
7098
+ function getDefaultExportFromCjs(x) {
7099
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
7100
+ }
7101
+ var jsYaml = {};
7102
+ var loader = {};
7103
+ var common = {};
7104
+ var hasRequiredCommon;
7105
+ function requireCommon() {
7106
+ if (hasRequiredCommon) return common;
7107
+ hasRequiredCommon = 1;
7108
+ function isNothing(subject) {
7109
+ return typeof subject === "undefined" || subject === null;
7110
+ }
7111
+ function isObject(subject) {
7112
+ return typeof subject === "object" && subject !== null;
7113
+ }
7114
+ function toArray(sequence) {
7115
+ if (Array.isArray(sequence)) return sequence;
7116
+ else if (isNothing(sequence)) return [];
7117
+ return [sequence];
7118
+ }
7119
+ function extend(target, source) {
7120
+ if (source) {
7121
+ const sourceKeys = Object.keys(source);
7122
+ for (let index = 0, length = sourceKeys.length; index < length; index += 1) {
7123
+ const key = sourceKeys[index];
7124
+ target[key] = source[key];
7125
+ }
7126
+ }
7127
+ return target;
7128
+ }
7129
+ function repeat(string, count) {
7130
+ let result = "";
7131
+ for (let cycle = 0; cycle < count; cycle += 1) {
7132
+ result += string;
7133
+ }
7134
+ return result;
7135
+ }
7136
+ function isNegativeZero(number) {
7137
+ return number === 0 && Number.NEGATIVE_INFINITY === 1 / number;
7138
+ }
7139
+ common.isNothing = isNothing;
7140
+ common.isObject = isObject;
7141
+ common.toArray = toArray;
7142
+ common.repeat = repeat;
7143
+ common.isNegativeZero = isNegativeZero;
7144
+ common.extend = extend;
7145
+ return common;
7146
+ }
7147
+ var exception;
7148
+ var hasRequiredException;
7149
+ function requireException() {
7150
+ if (hasRequiredException) return exception;
7151
+ hasRequiredException = 1;
7152
+ function formatError(exception2, compact) {
7153
+ let where = "";
7154
+ const message = exception2.reason || "(unknown reason)";
7155
+ if (!exception2.mark) return message;
7156
+ if (exception2.mark.name) {
7157
+ where += 'in "' + exception2.mark.name + '" ';
7158
+ }
7159
+ where += "(" + (exception2.mark.line + 1) + ":" + (exception2.mark.column + 1) + ")";
7160
+ if (!compact && exception2.mark.snippet) {
7161
+ where += "\n\n" + exception2.mark.snippet;
7162
+ }
7163
+ return message + " " + where;
7164
+ }
7165
+ function YAMLException2(reason, mark) {
7166
+ Error.call(this);
7167
+ this.name = "YAMLException";
7168
+ this.reason = reason;
7169
+ this.mark = mark;
7170
+ this.message = formatError(this, false);
7171
+ if (Error.captureStackTrace) {
7172
+ Error.captureStackTrace(this, this.constructor);
7173
+ } else {
7174
+ this.stack = new Error().stack || "";
7175
+ }
7176
+ }
7177
+ YAMLException2.prototype = Object.create(Error.prototype);
7178
+ YAMLException2.prototype.constructor = YAMLException2;
7179
+ YAMLException2.prototype.toString = function toString(compact) {
7180
+ return this.name + ": " + formatError(this, compact);
7181
+ };
7182
+ exception = YAMLException2;
7183
+ return exception;
7184
+ }
7185
+ var snippet;
7186
+ var hasRequiredSnippet;
7187
+ function requireSnippet() {
7188
+ if (hasRequiredSnippet) return snippet;
7189
+ hasRequiredSnippet = 1;
7190
+ const common2 = requireCommon();
7191
+ function getLine(buffer, lineStart, lineEnd, position, maxLineLength) {
7192
+ let head = "";
7193
+ let tail = "";
7194
+ const maxHalfLength = Math.floor(maxLineLength / 2) - 1;
7195
+ if (position - lineStart > maxHalfLength) {
7196
+ head = " ... ";
7197
+ lineStart = position - maxHalfLength + head.length;
7198
+ }
7199
+ if (lineEnd - position > maxHalfLength) {
7200
+ tail = " ...";
7201
+ lineEnd = position + maxHalfLength - tail.length;
7202
+ }
7203
+ return {
7204
+ str: head + buffer.slice(lineStart, lineEnd).replace(/\t/g, "\u2192") + tail,
7205
+ pos: position - lineStart + head.length
7206
+ // relative position
7207
+ };
7208
+ }
7209
+ function padStart(string, max) {
7210
+ return common2.repeat(" ", max - string.length) + string;
7211
+ }
7212
+ function makeSnippet(mark, options) {
7213
+ options = Object.create(options || null);
7214
+ if (!mark.buffer) return null;
7215
+ if (!options.maxLength) options.maxLength = 79;
7216
+ if (typeof options.indent !== "number") options.indent = 1;
7217
+ if (typeof options.linesBefore !== "number") options.linesBefore = 3;
7218
+ if (typeof options.linesAfter !== "number") options.linesAfter = 2;
7219
+ const re = /\r?\n|\r|\0/g;
7220
+ const lineStarts = [0];
7221
+ const lineEnds = [];
7222
+ let match;
7223
+ let foundLineNo = -1;
7224
+ while (match = re.exec(mark.buffer)) {
7225
+ lineEnds.push(match.index);
7226
+ lineStarts.push(match.index + match[0].length);
7227
+ if (mark.position <= match.index && foundLineNo < 0) {
7228
+ foundLineNo = lineStarts.length - 2;
7229
+ }
7230
+ }
7231
+ if (foundLineNo < 0) foundLineNo = lineStarts.length - 1;
7232
+ let result = "";
7233
+ const lineNoLength = Math.min(mark.line + options.linesAfter, lineEnds.length).toString().length;
7234
+ const maxLineLength = options.maxLength - (options.indent + lineNoLength + 3);
7235
+ for (let i = 1; i <= options.linesBefore; i++) {
7236
+ if (foundLineNo - i < 0) break;
7237
+ const line2 = getLine(
7238
+ mark.buffer,
7239
+ lineStarts[foundLineNo - i],
7240
+ lineEnds[foundLineNo - i],
7241
+ mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo - i]),
7242
+ maxLineLength
7243
+ );
7244
+ result = common2.repeat(" ", options.indent) + padStart((mark.line - i + 1).toString(), lineNoLength) + " | " + line2.str + "\n" + result;
7245
+ }
7246
+ const line = getLine(mark.buffer, lineStarts[foundLineNo], lineEnds[foundLineNo], mark.position, maxLineLength);
7247
+ result += common2.repeat(" ", options.indent) + padStart((mark.line + 1).toString(), lineNoLength) + " | " + line.str + "\n";
7248
+ result += common2.repeat("-", options.indent + lineNoLength + 3 + line.pos) + "^\n";
7249
+ for (let i = 1; i <= options.linesAfter; i++) {
7250
+ if (foundLineNo + i >= lineEnds.length) break;
7251
+ const line2 = getLine(
7252
+ mark.buffer,
7253
+ lineStarts[foundLineNo + i],
7254
+ lineEnds[foundLineNo + i],
7255
+ mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo + i]),
7256
+ maxLineLength
7257
+ );
7258
+ result += common2.repeat(" ", options.indent) + padStart((mark.line + i + 1).toString(), lineNoLength) + " | " + line2.str + "\n";
7259
+ }
7260
+ return result.replace(/\n$/, "");
7261
+ }
7262
+ snippet = makeSnippet;
7263
+ return snippet;
7264
+ }
7265
+ var type;
7266
+ var hasRequiredType;
7267
+ function requireType() {
7268
+ if (hasRequiredType) return type;
7269
+ hasRequiredType = 1;
7270
+ const YAMLException2 = requireException();
7271
+ const TYPE_CONSTRUCTOR_OPTIONS = [
7272
+ "kind",
7273
+ "multi",
7274
+ "resolve",
7275
+ "construct",
7276
+ "instanceOf",
7277
+ "predicate",
7278
+ "represent",
7279
+ "representName",
7280
+ "defaultStyle",
7281
+ "styleAliases"
7282
+ ];
7283
+ const YAML_NODE_KINDS = [
7284
+ "scalar",
7285
+ "sequence",
7286
+ "mapping"
7287
+ ];
7288
+ function compileStyleAliases(map2) {
7289
+ const result = {};
7290
+ if (map2 !== null) {
7291
+ Object.keys(map2).forEach(function(style) {
7292
+ map2[style].forEach(function(alias) {
7293
+ result[String(alias)] = style;
7294
+ });
7295
+ });
7296
+ }
7297
+ return result;
7298
+ }
7299
+ function Type2(tag, options) {
7300
+ options = options || {};
7301
+ Object.keys(options).forEach(function(name) {
7302
+ if (TYPE_CONSTRUCTOR_OPTIONS.indexOf(name) === -1) {
7303
+ throw new YAMLException2('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.');
7304
+ }
7305
+ });
7306
+ this.options = options;
7307
+ this.tag = tag;
7308
+ this.kind = options["kind"] || null;
7309
+ this.resolve = options["resolve"] || function() {
7310
+ return true;
7311
+ };
7312
+ this.construct = options["construct"] || function(data) {
7313
+ return data;
7314
+ };
7315
+ this.instanceOf = options["instanceOf"] || null;
7316
+ this.predicate = options["predicate"] || null;
7317
+ this.represent = options["represent"] || null;
7318
+ this.representName = options["representName"] || null;
7319
+ this.defaultStyle = options["defaultStyle"] || null;
7320
+ this.multi = options["multi"] || false;
7321
+ this.styleAliases = compileStyleAliases(options["styleAliases"] || null);
7322
+ if (YAML_NODE_KINDS.indexOf(this.kind) === -1) {
7323
+ throw new YAMLException2('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.');
7324
+ }
7325
+ }
7326
+ type = Type2;
7327
+ return type;
7328
+ }
7329
+ var schema;
7330
+ var hasRequiredSchema;
7331
+ function requireSchema() {
7332
+ if (hasRequiredSchema) return schema;
7333
+ hasRequiredSchema = 1;
7334
+ const YAMLException2 = requireException();
7335
+ const Type2 = requireType();
7336
+ function compileList(schema2, name) {
7337
+ const result = [];
7338
+ schema2[name].forEach(function(currentType) {
7339
+ let newIndex = result.length;
7340
+ result.forEach(function(previousType, previousIndex) {
7341
+ if (previousType.tag === currentType.tag && previousType.kind === currentType.kind && previousType.multi === currentType.multi) {
7342
+ newIndex = previousIndex;
7343
+ }
7344
+ });
7345
+ result[newIndex] = currentType;
7346
+ });
7347
+ return result;
7348
+ }
7349
+ function compileMap() {
7350
+ const result = {
7351
+ scalar: {},
7352
+ sequence: {},
7353
+ mapping: {},
7354
+ fallback: {},
7355
+ multi: {
7356
+ scalar: [],
7357
+ sequence: [],
7358
+ mapping: [],
7359
+ fallback: []
7360
+ }
7361
+ };
7362
+ function collectType(type2) {
7363
+ if (type2.multi) {
7364
+ result.multi[type2.kind].push(type2);
7365
+ result.multi["fallback"].push(type2);
7366
+ } else {
7367
+ result[type2.kind][type2.tag] = result["fallback"][type2.tag] = type2;
7368
+ }
7369
+ }
7370
+ for (let index = 0, length = arguments.length; index < length; index += 1) {
7371
+ arguments[index].forEach(collectType);
7372
+ }
7373
+ return result;
7374
+ }
7375
+ function Schema2(definition) {
7376
+ return this.extend(definition);
7377
+ }
7378
+ Schema2.prototype.extend = function extend(definition) {
7379
+ let implicit = [];
7380
+ let explicit = [];
7381
+ if (definition instanceof Type2) {
7382
+ explicit.push(definition);
7383
+ } else if (Array.isArray(definition)) {
7384
+ explicit = explicit.concat(definition);
7385
+ } else if (definition && (Array.isArray(definition.implicit) || Array.isArray(definition.explicit))) {
7386
+ if (definition.implicit) implicit = implicit.concat(definition.implicit);
7387
+ if (definition.explicit) explicit = explicit.concat(definition.explicit);
7388
+ } else {
7389
+ throw new YAMLException2("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");
7390
+ }
7391
+ implicit.forEach(function(type2) {
7392
+ if (!(type2 instanceof Type2)) {
7393
+ throw new YAMLException2("Specified list of YAML types (or a single Type object) contains a non-Type object.");
7394
+ }
7395
+ if (type2.loadKind && type2.loadKind !== "scalar") {
7396
+ throw new YAMLException2("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");
7397
+ }
7398
+ if (type2.multi) {
7399
+ throw new YAMLException2("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.");
7400
+ }
7401
+ });
7402
+ explicit.forEach(function(type2) {
7403
+ if (!(type2 instanceof Type2)) {
7404
+ throw new YAMLException2("Specified list of YAML types (or a single Type object) contains a non-Type object.");
7405
+ }
7406
+ });
7407
+ const result = Object.create(Schema2.prototype);
7408
+ result.implicit = (this.implicit || []).concat(implicit);
7409
+ result.explicit = (this.explicit || []).concat(explicit);
7410
+ result.compiledImplicit = compileList(result, "implicit");
7411
+ result.compiledExplicit = compileList(result, "explicit");
7412
+ result.compiledTypeMap = compileMap(result.compiledImplicit, result.compiledExplicit);
7413
+ return result;
7414
+ };
7415
+ schema = Schema2;
7416
+ return schema;
7417
+ }
7418
+ var str;
7419
+ var hasRequiredStr;
7420
+ function requireStr() {
7421
+ if (hasRequiredStr) return str;
7422
+ hasRequiredStr = 1;
7423
+ const Type2 = requireType();
7424
+ str = new Type2("tag:yaml.org,2002:str", {
7425
+ kind: "scalar",
7426
+ construct: function(data) {
7427
+ return data !== null ? data : "";
7428
+ }
7429
+ });
7430
+ return str;
7431
+ }
7432
+ var seq;
7433
+ var hasRequiredSeq;
7434
+ function requireSeq() {
7435
+ if (hasRequiredSeq) return seq;
7436
+ hasRequiredSeq = 1;
7437
+ const Type2 = requireType();
7438
+ seq = new Type2("tag:yaml.org,2002:seq", {
7439
+ kind: "sequence",
7440
+ construct: function(data) {
7441
+ return data !== null ? data : [];
7442
+ }
7443
+ });
7444
+ return seq;
7445
+ }
7446
+ var map;
7447
+ var hasRequiredMap;
7448
+ function requireMap() {
7449
+ if (hasRequiredMap) return map;
7450
+ hasRequiredMap = 1;
7451
+ const Type2 = requireType();
7452
+ map = new Type2("tag:yaml.org,2002:map", {
7453
+ kind: "mapping",
7454
+ construct: function(data) {
7455
+ return data !== null ? data : {};
7456
+ }
7457
+ });
7458
+ return map;
7459
+ }
7460
+ var failsafe;
7461
+ var hasRequiredFailsafe;
7462
+ function requireFailsafe() {
7463
+ if (hasRequiredFailsafe) return failsafe;
7464
+ hasRequiredFailsafe = 1;
7465
+ const Schema2 = requireSchema();
7466
+ failsafe = new Schema2({
7467
+ explicit: [
7468
+ requireStr(),
7469
+ requireSeq(),
7470
+ requireMap()
7471
+ ]
7472
+ });
7473
+ return failsafe;
7474
+ }
7475
+ var _null;
7476
+ var hasRequired_null;
7477
+ function require_null() {
7478
+ if (hasRequired_null) return _null;
7479
+ hasRequired_null = 1;
7480
+ const Type2 = requireType();
7481
+ function resolveYamlNull(data) {
7482
+ if (data === null) return true;
7483
+ const max = data.length;
7484
+ return max === 1 && data === "~" || max === 4 && (data === "null" || data === "Null" || data === "NULL");
7485
+ }
7486
+ function constructYamlNull() {
7487
+ return null;
7488
+ }
7489
+ function isNull(object) {
7490
+ return object === null;
7491
+ }
7492
+ _null = new Type2("tag:yaml.org,2002:null", {
7493
+ kind: "scalar",
7494
+ resolve: resolveYamlNull,
7495
+ construct: constructYamlNull,
7496
+ predicate: isNull,
7497
+ represent: {
7498
+ canonical: function() {
7499
+ return "~";
7500
+ },
7501
+ lowercase: function() {
7502
+ return "null";
7503
+ },
7504
+ uppercase: function() {
7505
+ return "NULL";
7506
+ },
7507
+ camelcase: function() {
7508
+ return "Null";
7509
+ },
7510
+ empty: function() {
7511
+ return "";
7512
+ }
7513
+ },
7514
+ defaultStyle: "lowercase"
7515
+ });
7516
+ return _null;
7517
+ }
7518
+ var bool;
7519
+ var hasRequiredBool;
7520
+ function requireBool() {
7521
+ if (hasRequiredBool) return bool;
7522
+ hasRequiredBool = 1;
7523
+ const Type2 = requireType();
7524
+ function resolveYamlBoolean(data) {
7525
+ if (data === null) return false;
7526
+ const max = data.length;
7527
+ return max === 4 && (data === "true" || data === "True" || data === "TRUE") || max === 5 && (data === "false" || data === "False" || data === "FALSE");
7528
+ }
7529
+ function constructYamlBoolean(data) {
7530
+ return data === "true" || data === "True" || data === "TRUE";
7531
+ }
7532
+ function isBoolean(object) {
7533
+ return Object.prototype.toString.call(object) === "[object Boolean]";
7534
+ }
7535
+ bool = new Type2("tag:yaml.org,2002:bool", {
7536
+ kind: "scalar",
7537
+ resolve: resolveYamlBoolean,
7538
+ construct: constructYamlBoolean,
7539
+ predicate: isBoolean,
7540
+ represent: {
7541
+ lowercase: function(object) {
7542
+ return object ? "true" : "false";
7543
+ },
7544
+ uppercase: function(object) {
7545
+ return object ? "TRUE" : "FALSE";
7546
+ },
7547
+ camelcase: function(object) {
7548
+ return object ? "True" : "False";
7549
+ }
7550
+ },
7551
+ defaultStyle: "lowercase"
7552
+ });
7553
+ return bool;
7554
+ }
7555
+ var int;
7556
+ var hasRequiredInt;
7557
+ function requireInt() {
7558
+ if (hasRequiredInt) return int;
7559
+ hasRequiredInt = 1;
7560
+ const common2 = requireCommon();
7561
+ const Type2 = requireType();
7562
+ function isHexCode(c) {
7563
+ return c >= 48 && c <= 57 || c >= 65 && c <= 70 || c >= 97 && c <= 102;
7564
+ }
7565
+ function isOctCode(c) {
7566
+ return c >= 48 && c <= 55;
7567
+ }
7568
+ function isDecCode(c) {
7569
+ return c >= 48 && c <= 57;
7570
+ }
7571
+ function resolveYamlInteger(data) {
7572
+ if (data === null) return false;
7573
+ const max = data.length;
7574
+ let index = 0;
7575
+ let hasDigits = false;
7576
+ if (!max) return false;
7577
+ let ch = data[index];
7578
+ if (ch === "-" || ch === "+") {
7579
+ ch = data[++index];
7580
+ }
7581
+ if (ch === "0") {
7582
+ if (index + 1 === max) return true;
7583
+ ch = data[++index];
7584
+ if (ch === "b") {
7585
+ index++;
7586
+ for (; index < max; index++) {
7587
+ ch = data[index];
7588
+ if (ch !== "0" && ch !== "1") return false;
7589
+ hasDigits = true;
7590
+ }
7591
+ return hasDigits && isFinite(parseYamlInteger(data));
7592
+ }
7593
+ if (ch === "x") {
7594
+ index++;
7595
+ for (; index < max; index++) {
7596
+ if (!isHexCode(data.charCodeAt(index))) return false;
7597
+ hasDigits = true;
7598
+ }
7599
+ return hasDigits && isFinite(parseYamlInteger(data));
7600
+ }
7601
+ if (ch === "o") {
7602
+ index++;
7603
+ for (; index < max; index++) {
7604
+ if (!isOctCode(data.charCodeAt(index))) return false;
7605
+ hasDigits = true;
7606
+ }
7607
+ return hasDigits && isFinite(parseYamlInteger(data));
7608
+ }
7609
+ }
7610
+ for (; index < max; index++) {
7611
+ if (!isDecCode(data.charCodeAt(index))) {
7612
+ return false;
7613
+ }
7614
+ hasDigits = true;
7615
+ }
7616
+ if (!hasDigits) return false;
7617
+ return isFinite(parseYamlInteger(data));
7618
+ }
7619
+ function parseYamlInteger(data) {
7620
+ let value = data;
7621
+ let sign = 1;
7622
+ let ch = value[0];
7623
+ if (ch === "-" || ch === "+") {
7624
+ if (ch === "-") sign = -1;
7625
+ value = value.slice(1);
7626
+ ch = value[0];
7627
+ }
7628
+ if (value === "0") return 0;
7629
+ if (ch === "0") {
7630
+ if (value[1] === "b") return sign * parseInt(value.slice(2), 2);
7631
+ if (value[1] === "x") return sign * parseInt(value.slice(2), 16);
7632
+ if (value[1] === "o") return sign * parseInt(value.slice(2), 8);
7633
+ }
7634
+ return sign * parseInt(value, 10);
7635
+ }
7636
+ function constructYamlInteger(data) {
7637
+ return parseYamlInteger(data);
7638
+ }
7639
+ function isInteger(object) {
7640
+ return Object.prototype.toString.call(object) === "[object Number]" && (object % 1 === 0 && !common2.isNegativeZero(object));
7641
+ }
7642
+ int = new Type2("tag:yaml.org,2002:int", {
7643
+ kind: "scalar",
7644
+ resolve: resolveYamlInteger,
7645
+ construct: constructYamlInteger,
7646
+ predicate: isInteger,
7647
+ represent: {
7648
+ binary: function(obj) {
7649
+ return obj >= 0 ? "0b" + obj.toString(2) : "-0b" + obj.toString(2).slice(1);
7650
+ },
7651
+ octal: function(obj) {
7652
+ return obj >= 0 ? "0o" + obj.toString(8) : "-0o" + obj.toString(8).slice(1);
7653
+ },
7654
+ decimal: function(obj) {
7655
+ return obj.toString(10);
7656
+ },
7657
+ hexadecimal: function(obj) {
7658
+ return obj >= 0 ? "0x" + obj.toString(16).toUpperCase() : "-0x" + obj.toString(16).toUpperCase().slice(1);
7659
+ }
7660
+ },
7661
+ defaultStyle: "decimal",
7662
+ styleAliases: {
7663
+ binary: [2, "bin"],
7664
+ octal: [8, "oct"],
7665
+ decimal: [10, "dec"],
7666
+ hexadecimal: [16, "hex"]
7667
+ }
7668
+ });
7669
+ return int;
7670
+ }
7671
+ var float;
7672
+ var hasRequiredFloat;
7673
+ function requireFloat() {
7674
+ if (hasRequiredFloat) return float;
7675
+ hasRequiredFloat = 1;
7676
+ const common2 = requireCommon();
7677
+ const Type2 = requireType();
7678
+ const YAML_FLOAT_PATTERN = new RegExp(
7679
+ // 2.5e4, 2.5 and integers
7680
+ "^(?:[-+]?(?:[0-9]+)(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"
7681
+ );
7682
+ const YAML_FLOAT_SPECIAL_PATTERN = new RegExp(
7683
+ "^(?:[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"
7684
+ );
7685
+ function resolveYamlFloat(data) {
7686
+ if (data === null) return false;
7687
+ if (!YAML_FLOAT_PATTERN.test(data)) {
7688
+ return false;
7689
+ }
7690
+ if (isFinite(parseFloat(data, 10))) {
7691
+ return true;
7692
+ }
7693
+ return YAML_FLOAT_SPECIAL_PATTERN.test(data);
7694
+ }
7695
+ function constructYamlFloat(data) {
7696
+ let value = data.toLowerCase();
7697
+ const sign = value[0] === "-" ? -1 : 1;
7698
+ if ("+-".indexOf(value[0]) >= 0) {
7699
+ value = value.slice(1);
7700
+ }
7701
+ if (value === ".inf") {
7702
+ return sign === 1 ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
7703
+ } else if (value === ".nan") {
7704
+ return NaN;
7705
+ }
7706
+ return sign * parseFloat(value, 10);
7707
+ }
7708
+ const SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/;
7709
+ function representYamlFloat(object, style) {
7710
+ if (isNaN(object)) {
7711
+ switch (style) {
7712
+ case "lowercase":
7713
+ return ".nan";
7714
+ case "uppercase":
7715
+ return ".NAN";
7716
+ case "camelcase":
7717
+ return ".NaN";
7718
+ }
7719
+ } else if (Number.POSITIVE_INFINITY === object) {
7720
+ switch (style) {
7721
+ case "lowercase":
7722
+ return ".inf";
7723
+ case "uppercase":
7724
+ return ".INF";
7725
+ case "camelcase":
7726
+ return ".Inf";
7727
+ }
7728
+ } else if (Number.NEGATIVE_INFINITY === object) {
7729
+ switch (style) {
7730
+ case "lowercase":
7731
+ return "-.inf";
7732
+ case "uppercase":
7733
+ return "-.INF";
7734
+ case "camelcase":
7735
+ return "-.Inf";
7736
+ }
7737
+ } else if (common2.isNegativeZero(object)) {
7738
+ return "-0.0";
7739
+ }
7740
+ const res = object.toString(10);
7741
+ return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace("e", ".e") : res;
7742
+ }
7743
+ function isFloat(object) {
7744
+ return Object.prototype.toString.call(object) === "[object Number]" && (object % 1 !== 0 || common2.isNegativeZero(object));
7745
+ }
7746
+ float = new Type2("tag:yaml.org,2002:float", {
7747
+ kind: "scalar",
7748
+ resolve: resolveYamlFloat,
7749
+ construct: constructYamlFloat,
7750
+ predicate: isFloat,
7751
+ represent: representYamlFloat,
7752
+ defaultStyle: "lowercase"
7753
+ });
7754
+ return float;
7755
+ }
7756
+ var json;
7757
+ var hasRequiredJson;
7758
+ function requireJson() {
7759
+ if (hasRequiredJson) return json;
7760
+ hasRequiredJson = 1;
7761
+ json = requireFailsafe().extend({
7762
+ implicit: [
7763
+ require_null(),
7764
+ requireBool(),
7765
+ requireInt(),
7766
+ requireFloat()
7767
+ ]
7768
+ });
7769
+ return json;
7770
+ }
7771
+ var core;
7772
+ var hasRequiredCore;
7773
+ function requireCore() {
7774
+ if (hasRequiredCore) return core;
7775
+ hasRequiredCore = 1;
7776
+ core = requireJson();
7777
+ return core;
7778
+ }
7779
+ var timestamp;
7780
+ var hasRequiredTimestamp;
7781
+ function requireTimestamp() {
7782
+ if (hasRequiredTimestamp) return timestamp;
7783
+ hasRequiredTimestamp = 1;
7784
+ const Type2 = requireType();
7785
+ const YAML_DATE_REGEXP = new RegExp(
7786
+ "^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"
7787
+ );
7788
+ const YAML_TIMESTAMP_REGEXP = new RegExp(
7789
+ "^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$"
7790
+ );
7791
+ function resolveYamlTimestamp(data) {
7792
+ if (data === null) return false;
7793
+ if (YAML_DATE_REGEXP.exec(data) !== null) return true;
7794
+ if (YAML_TIMESTAMP_REGEXP.exec(data) !== null) return true;
7795
+ return false;
7796
+ }
7797
+ function constructYamlTimestamp(data) {
7798
+ let fraction = 0;
7799
+ let delta = null;
7800
+ let match = YAML_DATE_REGEXP.exec(data);
7801
+ if (match === null) match = YAML_TIMESTAMP_REGEXP.exec(data);
7802
+ if (match === null) throw new Error("Date resolve error");
7803
+ const year = +match[1];
7804
+ const month = +match[2] - 1;
7805
+ const day = +match[3];
7806
+ if (!match[4]) {
7807
+ return new Date(Date.UTC(year, month, day));
7808
+ }
7809
+ const hour = +match[4];
7810
+ const minute = +match[5];
7811
+ const second = +match[6];
7812
+ if (match[7]) {
7813
+ fraction = match[7].slice(0, 3);
7814
+ while (fraction.length < 3) {
7815
+ fraction += "0";
7816
+ }
7817
+ fraction = +fraction;
7818
+ }
7819
+ if (match[9]) {
7820
+ const tzHour = +match[10];
7821
+ const tzMinute = +(match[11] || 0);
7822
+ delta = (tzHour * 60 + tzMinute) * 6e4;
7823
+ if (match[9] === "-") delta = -delta;
7824
+ }
7825
+ const date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));
7826
+ if (delta) date.setTime(date.getTime() - delta);
7827
+ return date;
7828
+ }
7829
+ function representYamlTimestamp(object) {
7830
+ return object.toISOString();
7831
+ }
7832
+ timestamp = new Type2("tag:yaml.org,2002:timestamp", {
7833
+ kind: "scalar",
7834
+ resolve: resolveYamlTimestamp,
7835
+ construct: constructYamlTimestamp,
7836
+ instanceOf: Date,
7837
+ represent: representYamlTimestamp
7838
+ });
7839
+ return timestamp;
7840
+ }
7841
+ var merge;
7842
+ var hasRequiredMerge;
7843
+ function requireMerge() {
7844
+ if (hasRequiredMerge) return merge;
7845
+ hasRequiredMerge = 1;
7846
+ const Type2 = requireType();
7847
+ function resolveYamlMerge(data) {
7848
+ return data === "<<" || data === null;
7849
+ }
7850
+ merge = new Type2("tag:yaml.org,2002:merge", {
7851
+ kind: "scalar",
7852
+ resolve: resolveYamlMerge
7853
+ });
7854
+ return merge;
7855
+ }
7856
+ var binary;
7857
+ var hasRequiredBinary;
7858
+ function requireBinary() {
7859
+ if (hasRequiredBinary) return binary;
7860
+ hasRequiredBinary = 1;
7861
+ const Type2 = requireType();
7862
+ const BASE64_MAP = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r";
7863
+ function resolveYamlBinary(data) {
7864
+ if (data === null) return false;
7865
+ let bitlen = 0;
7866
+ const max = data.length;
7867
+ const map2 = BASE64_MAP;
7868
+ for (let idx = 0; idx < max; idx++) {
7869
+ const code = map2.indexOf(data.charAt(idx));
7870
+ if (code > 64) continue;
7871
+ if (code < 0) return false;
7872
+ bitlen += 6;
7873
+ }
7874
+ return bitlen % 8 === 0;
7875
+ }
7876
+ function constructYamlBinary(data) {
7877
+ const input = data.replace(/[\r\n=]/g, "");
7878
+ const max = input.length;
7879
+ const map2 = BASE64_MAP;
7880
+ let bits = 0;
7881
+ const result = [];
7882
+ for (let idx = 0; idx < max; idx++) {
7883
+ if (idx % 4 === 0 && idx) {
7884
+ result.push(bits >> 16 & 255);
7885
+ result.push(bits >> 8 & 255);
7886
+ result.push(bits & 255);
7887
+ }
7888
+ bits = bits << 6 | map2.indexOf(input.charAt(idx));
7889
+ }
7890
+ const tailbits = max % 4 * 6;
7891
+ if (tailbits === 0) {
7892
+ result.push(bits >> 16 & 255);
7893
+ result.push(bits >> 8 & 255);
7894
+ result.push(bits & 255);
7895
+ } else if (tailbits === 18) {
7896
+ result.push(bits >> 10 & 255);
7897
+ result.push(bits >> 2 & 255);
7898
+ } else if (tailbits === 12) {
7899
+ result.push(bits >> 4 & 255);
7900
+ }
7901
+ return new Uint8Array(result);
7902
+ }
7903
+ function representYamlBinary(object) {
7904
+ let result = "";
7905
+ let bits = 0;
7906
+ const max = object.length;
7907
+ const map2 = BASE64_MAP;
7908
+ for (let idx = 0; idx < max; idx++) {
7909
+ if (idx % 3 === 0 && idx) {
7910
+ result += map2[bits >> 18 & 63];
7911
+ result += map2[bits >> 12 & 63];
7912
+ result += map2[bits >> 6 & 63];
7913
+ result += map2[bits & 63];
7914
+ }
7915
+ bits = (bits << 8) + object[idx];
7916
+ }
7917
+ const tail = max % 3;
7918
+ if (tail === 0) {
7919
+ result += map2[bits >> 18 & 63];
7920
+ result += map2[bits >> 12 & 63];
7921
+ result += map2[bits >> 6 & 63];
7922
+ result += map2[bits & 63];
7923
+ } else if (tail === 2) {
7924
+ result += map2[bits >> 10 & 63];
7925
+ result += map2[bits >> 4 & 63];
7926
+ result += map2[bits << 2 & 63];
7927
+ result += map2[64];
7928
+ } else if (tail === 1) {
7929
+ result += map2[bits >> 2 & 63];
7930
+ result += map2[bits << 4 & 63];
7931
+ result += map2[64];
7932
+ result += map2[64];
7933
+ }
7934
+ return result;
7935
+ }
7936
+ function isBinary(obj) {
7937
+ return Object.prototype.toString.call(obj) === "[object Uint8Array]";
7938
+ }
7939
+ binary = new Type2("tag:yaml.org,2002:binary", {
7940
+ kind: "scalar",
7941
+ resolve: resolveYamlBinary,
7942
+ construct: constructYamlBinary,
7943
+ predicate: isBinary,
7944
+ represent: representYamlBinary
7945
+ });
7946
+ return binary;
7947
+ }
7948
+ var omap;
7949
+ var hasRequiredOmap;
7950
+ function requireOmap() {
7951
+ if (hasRequiredOmap) return omap;
7952
+ hasRequiredOmap = 1;
7953
+ const Type2 = requireType();
7954
+ const _hasOwnProperty = Object.prototype.hasOwnProperty;
7955
+ const _toString = Object.prototype.toString;
7956
+ function resolveYamlOmap(data) {
7957
+ if (data === null) return true;
7958
+ const objectKeys = {};
7959
+ const object = data;
7960
+ for (let index = 0, length = object.length; index < length; index += 1) {
7961
+ const pair = object[index];
7962
+ let pairHasKey = false;
7963
+ if (_toString.call(pair) !== "[object Object]") return false;
7964
+ let pairKey;
7965
+ for (pairKey in pair) {
7966
+ if (_hasOwnProperty.call(pair, pairKey)) {
7967
+ if (!pairHasKey) pairHasKey = true;
7968
+ else return false;
7969
+ }
7970
+ }
7971
+ if (!pairHasKey) return false;
7972
+ if (_hasOwnProperty.call(objectKeys, pairKey)) return false;
7973
+ Object.defineProperty(objectKeys, pairKey, { value: true });
7974
+ }
7975
+ return true;
7976
+ }
7977
+ function constructYamlOmap(data) {
7978
+ return data !== null ? data : [];
7979
+ }
7980
+ omap = new Type2("tag:yaml.org,2002:omap", {
7981
+ kind: "sequence",
7982
+ resolve: resolveYamlOmap,
7983
+ construct: constructYamlOmap
7984
+ });
7985
+ return omap;
7986
+ }
7987
+ var pairs;
7988
+ var hasRequiredPairs;
7989
+ function requirePairs() {
7990
+ if (hasRequiredPairs) return pairs;
7991
+ hasRequiredPairs = 1;
7992
+ const Type2 = requireType();
7993
+ const _toString = Object.prototype.toString;
7994
+ function resolveYamlPairs(data) {
7995
+ if (data === null) return true;
7996
+ const object = data;
7997
+ const result = new Array(object.length);
7998
+ for (let index = 0, length = object.length; index < length; index += 1) {
7999
+ const pair = object[index];
8000
+ if (_toString.call(pair) !== "[object Object]") return false;
8001
+ const keys = Object.keys(pair);
8002
+ if (keys.length !== 1) return false;
8003
+ result[index] = [keys[0], pair[keys[0]]];
8004
+ }
8005
+ return true;
8006
+ }
8007
+ function constructYamlPairs(data) {
8008
+ if (data === null) return [];
8009
+ const object = data;
8010
+ const result = new Array(object.length);
8011
+ for (let index = 0, length = object.length; index < length; index += 1) {
8012
+ const pair = object[index];
8013
+ const keys = Object.keys(pair);
8014
+ result[index] = [keys[0], pair[keys[0]]];
8015
+ }
8016
+ return result;
8017
+ }
8018
+ pairs = new Type2("tag:yaml.org,2002:pairs", {
8019
+ kind: "sequence",
8020
+ resolve: resolveYamlPairs,
8021
+ construct: constructYamlPairs
8022
+ });
8023
+ return pairs;
8024
+ }
8025
+ var set;
8026
+ var hasRequiredSet;
8027
+ function requireSet() {
8028
+ if (hasRequiredSet) return set;
8029
+ hasRequiredSet = 1;
8030
+ const Type2 = requireType();
8031
+ const _hasOwnProperty = Object.prototype.hasOwnProperty;
8032
+ function resolveYamlSet(data) {
8033
+ if (data === null) return true;
8034
+ const object = data;
8035
+ for (const key in object) {
8036
+ if (_hasOwnProperty.call(object, key)) {
8037
+ if (object[key] !== null) return false;
8038
+ }
8039
+ }
8040
+ return true;
8041
+ }
8042
+ function constructYamlSet(data) {
8043
+ return data !== null ? data : {};
8044
+ }
8045
+ set = new Type2("tag:yaml.org,2002:set", {
8046
+ kind: "mapping",
8047
+ resolve: resolveYamlSet,
8048
+ construct: constructYamlSet
8049
+ });
8050
+ return set;
8051
+ }
8052
+ var _default;
8053
+ var hasRequired_default;
8054
+ function require_default() {
8055
+ if (hasRequired_default) return _default;
8056
+ hasRequired_default = 1;
8057
+ _default = requireCore().extend({
8058
+ implicit: [
8059
+ requireTimestamp(),
8060
+ requireMerge()
8061
+ ],
8062
+ explicit: [
8063
+ requireBinary(),
8064
+ requireOmap(),
8065
+ requirePairs(),
8066
+ requireSet()
8067
+ ]
8068
+ });
8069
+ return _default;
8070
+ }
8071
+ var hasRequiredLoader;
8072
+ function requireLoader() {
8073
+ if (hasRequiredLoader) return loader;
8074
+ hasRequiredLoader = 1;
8075
+ const common2 = requireCommon();
8076
+ const YAMLException2 = requireException();
8077
+ const makeSnippet = requireSnippet();
8078
+ const DEFAULT_SCHEMA2 = require_default();
8079
+ const _hasOwnProperty = Object.prototype.hasOwnProperty;
8080
+ const CONTEXT_FLOW_IN = 1;
8081
+ const CONTEXT_FLOW_OUT = 2;
8082
+ const CONTEXT_BLOCK_IN = 3;
8083
+ const CONTEXT_BLOCK_OUT = 4;
8084
+ const CHOMPING_CLIP = 1;
8085
+ const CHOMPING_STRIP = 2;
8086
+ const CHOMPING_KEEP = 3;
8087
+ const PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
8088
+ const PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/;
8089
+ const PATTERN_FLOW_INDICATORS = /[,\[\]{}]/;
8090
+ const PATTERN_TAG_HANDLE = /^(?:!|!!|![0-9A-Za-z-]+!)$/;
8091
+ const PATTERN_TAG_URI = /^(?:!|[^,\[\]{}])(?:%[0-9a-f]{2}|[0-9a-z\-#;/?:@&=+$,_.!~*'()\[\]])*$/i;
8092
+ function _class(obj) {
8093
+ return Object.prototype.toString.call(obj);
8094
+ }
8095
+ function isEol(c) {
8096
+ return c === 10 || c === 13;
8097
+ }
8098
+ function isWhiteSpace(c) {
8099
+ return c === 9 || c === 32;
8100
+ }
8101
+ function isWsOrEol(c) {
8102
+ return c === 9 || c === 32 || c === 10 || c === 13;
8103
+ }
8104
+ function isFlowIndicator(c) {
8105
+ return c === 44 || c === 91 || c === 93 || c === 123 || c === 125;
8106
+ }
8107
+ function fromHexCode(c) {
8108
+ if (c >= 48 && c <= 57) {
8109
+ return c - 48;
8110
+ }
8111
+ const lc = c | 32;
8112
+ if (lc >= 97 && lc <= 102) {
8113
+ return lc - 97 + 10;
8114
+ }
8115
+ return -1;
8116
+ }
8117
+ function escapedHexLen(c) {
8118
+ if (c === 120) {
8119
+ return 2;
8120
+ }
8121
+ if (c === 117) {
8122
+ return 4;
8123
+ }
8124
+ if (c === 85) {
8125
+ return 8;
8126
+ }
8127
+ return 0;
8128
+ }
8129
+ function fromDecimalCode(c) {
8130
+ if (c >= 48 && c <= 57) {
8131
+ return c - 48;
8132
+ }
8133
+ return -1;
8134
+ }
8135
+ function simpleEscapeSequence(c) {
8136
+ switch (c) {
8137
+ case 48:
8138
+ return "\0";
8139
+ case 97:
8140
+ return "\x07";
8141
+ case 98:
8142
+ return "\b";
8143
+ case 116:
8144
+ return " ";
8145
+ case 9:
8146
+ return " ";
8147
+ case 110:
8148
+ return "\n";
8149
+ case 118:
8150
+ return "\v";
8151
+ case 102:
8152
+ return "\f";
8153
+ case 114:
8154
+ return "\r";
8155
+ case 101:
8156
+ return "\x1B";
8157
+ case 32:
8158
+ return " ";
8159
+ case 34:
8160
+ return '"';
8161
+ case 47:
8162
+ return "/";
8163
+ case 92:
8164
+ return "\\";
8165
+ case 78:
8166
+ return "\x85";
8167
+ case 95:
8168
+ return "\xA0";
8169
+ case 76:
8170
+ return "\u2028";
8171
+ case 80:
8172
+ return "\u2029";
8173
+ default:
8174
+ return "";
8175
+ }
8176
+ }
8177
+ function charFromCodepoint(c) {
8178
+ if (c <= 65535) {
8179
+ return String.fromCharCode(c);
8180
+ }
8181
+ return String.fromCharCode(
8182
+ (c - 65536 >> 10) + 55296,
8183
+ (c - 65536 & 1023) + 56320
8184
+ );
8185
+ }
8186
+ function setProperty(object, key, value) {
8187
+ if (key === "__proto__") {
8188
+ Object.defineProperty(object, key, {
8189
+ configurable: true,
8190
+ enumerable: true,
8191
+ writable: true,
8192
+ value
8193
+ });
8194
+ } else {
8195
+ object[key] = value;
8196
+ }
8197
+ }
8198
+ const simpleEscapeCheck = new Array(256);
8199
+ const simpleEscapeMap = new Array(256);
8200
+ for (let i = 0; i < 256; i++) {
8201
+ simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0;
8202
+ simpleEscapeMap[i] = simpleEscapeSequence(i);
8203
+ }
8204
+ function State(input, options) {
8205
+ this.input = input;
8206
+ this.filename = options["filename"] || null;
8207
+ this.schema = options["schema"] || DEFAULT_SCHEMA2;
8208
+ this.onWarning = options["onWarning"] || null;
8209
+ this.legacy = options["legacy"] || false;
8210
+ this.json = options["json"] || false;
8211
+ this.listener = options["listener"] || null;
8212
+ this.maxDepth = typeof options["maxDepth"] === "number" ? options["maxDepth"] : 100;
8213
+ this.maxTotalMergeKeys = typeof options["maxTotalMergeKeys"] === "number" ? options["maxTotalMergeKeys"] : 1e4;
8214
+ this.implicitTypes = this.schema.compiledImplicit;
8215
+ this.typeMap = this.schema.compiledTypeMap;
8216
+ this.length = input.length;
8217
+ this.position = 0;
8218
+ this.line = 0;
8219
+ this.lineStart = 0;
8220
+ this.lineIndent = 0;
8221
+ this.depth = 0;
8222
+ this.totalMergeKeys = 0;
8223
+ this.firstTabInLine = -1;
8224
+ this.documents = [];
8225
+ this.anchorMapTransactions = [];
8226
+ }
8227
+ function generateError(state, message) {
8228
+ const mark = {
8229
+ name: state.filename,
8230
+ buffer: state.input.slice(0, -1),
8231
+ // omit trailing \0
8232
+ position: state.position,
8233
+ line: state.line,
8234
+ column: state.position - state.lineStart
8235
+ };
8236
+ mark.snippet = makeSnippet(mark);
8237
+ return new YAMLException2(message, mark);
8238
+ }
8239
+ function throwError(state, message) {
8240
+ throw generateError(state, message);
8241
+ }
8242
+ function throwWarning(state, message) {
8243
+ if (state.onWarning) {
8244
+ state.onWarning.call(null, generateError(state, message));
8245
+ }
8246
+ }
8247
+ function storeAnchor(state, name, value) {
8248
+ const transactions = state.anchorMapTransactions;
8249
+ if (transactions.length !== 0) {
8250
+ const transaction = transactions[transactions.length - 1];
8251
+ if (!_hasOwnProperty.call(transaction, name)) {
8252
+ transaction[name] = {
8253
+ existed: _hasOwnProperty.call(state.anchorMap, name),
8254
+ value: state.anchorMap[name]
8255
+ };
8256
+ }
8257
+ }
8258
+ state.anchorMap[name] = value;
8259
+ }
8260
+ function beginAnchorTransaction(state) {
8261
+ state.anchorMapTransactions.push(/* @__PURE__ */ Object.create(null));
8262
+ }
8263
+ function commitAnchorTransaction(state) {
8264
+ const transaction = state.anchorMapTransactions.pop();
8265
+ const transactions = state.anchorMapTransactions;
8266
+ if (transactions.length === 0) return;
8267
+ const parent = transactions[transactions.length - 1];
8268
+ const names = Object.keys(transaction);
8269
+ for (let index = 0, length = names.length; index < length; index += 1) {
8270
+ const name = names[index];
8271
+ if (!_hasOwnProperty.call(parent, name)) {
8272
+ parent[name] = transaction[name];
8273
+ }
8274
+ }
8275
+ }
8276
+ function rollbackAnchorTransaction(state) {
8277
+ const transaction = state.anchorMapTransactions.pop();
8278
+ const names = Object.keys(transaction);
8279
+ for (let index = names.length - 1; index >= 0; index -= 1) {
8280
+ const entry = transaction[names[index]];
8281
+ if (entry.existed) {
8282
+ state.anchorMap[names[index]] = entry.value;
8283
+ } else {
8284
+ delete state.anchorMap[names[index]];
8285
+ }
8286
+ }
8287
+ }
8288
+ function snapshotState(state) {
8289
+ return {
8290
+ position: state.position,
8291
+ line: state.line,
8292
+ lineStart: state.lineStart,
8293
+ lineIndent: state.lineIndent,
8294
+ firstTabInLine: state.firstTabInLine,
8295
+ tag: state.tag,
8296
+ anchor: state.anchor,
8297
+ kind: state.kind,
8298
+ result: state.result
8299
+ };
8300
+ }
8301
+ function restoreState(state, snapshot) {
8302
+ state.position = snapshot.position;
8303
+ state.line = snapshot.line;
8304
+ state.lineStart = snapshot.lineStart;
8305
+ state.lineIndent = snapshot.lineIndent;
8306
+ state.firstTabInLine = snapshot.firstTabInLine;
8307
+ state.tag = snapshot.tag;
8308
+ state.anchor = snapshot.anchor;
8309
+ state.kind = snapshot.kind;
8310
+ state.result = snapshot.result;
8311
+ }
8312
+ const directiveHandlers = {
8313
+ YAML: function handleYamlDirective(state, name, args) {
8314
+ if (state.version !== null) {
8315
+ throwError(state, "duplication of %YAML directive");
8316
+ }
8317
+ if (args.length !== 1) {
8318
+ throwError(state, "YAML directive accepts exactly one argument");
8319
+ }
8320
+ const match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]);
8321
+ if (match === null) {
8322
+ throwError(state, "ill-formed argument of the YAML directive");
8323
+ }
8324
+ const major = parseInt(match[1], 10);
8325
+ const minor = parseInt(match[2], 10);
8326
+ if (major !== 1) {
8327
+ throwError(state, "unacceptable YAML version of the document");
8328
+ }
8329
+ state.version = args[0];
8330
+ state.checkLineBreaks = minor < 2;
8331
+ if (minor !== 1 && minor !== 2) {
8332
+ throwWarning(state, "unsupported YAML version of the document");
8333
+ }
8334
+ },
8335
+ TAG: function handleTagDirective(state, name, args) {
8336
+ let prefix;
8337
+ if (args.length !== 2) {
8338
+ throwError(state, "TAG directive accepts exactly two arguments");
8339
+ }
8340
+ const handle = args[0];
8341
+ prefix = args[1];
8342
+ if (!PATTERN_TAG_HANDLE.test(handle)) {
8343
+ throwError(state, "ill-formed tag handle (first argument) of the TAG directive");
8344
+ }
8345
+ if (_hasOwnProperty.call(state.tagMap, handle)) {
8346
+ throwError(state, 'there is a previously declared suffix for "' + handle + '" tag handle');
8347
+ }
8348
+ if (!PATTERN_TAG_URI.test(prefix)) {
8349
+ throwError(state, "ill-formed tag prefix (second argument) of the TAG directive");
8350
+ }
8351
+ try {
8352
+ prefix = decodeURIComponent(prefix);
8353
+ } catch (err) {
8354
+ throwError(state, "tag prefix is malformed: " + prefix);
8355
+ }
8356
+ state.tagMap[handle] = prefix;
8357
+ }
8358
+ };
8359
+ function captureSegment(state, start, end, checkJson) {
8360
+ if (start < end) {
8361
+ const _result = state.input.slice(start, end);
8362
+ if (checkJson) {
8363
+ for (let _position = 0, _length = _result.length; _position < _length; _position += 1) {
8364
+ const _character = _result.charCodeAt(_position);
8365
+ if (!(_character === 9 || _character >= 32 && _character <= 1114111)) {
8366
+ throwError(state, "expected valid JSON character");
8367
+ }
8368
+ }
8369
+ } else if (PATTERN_NON_PRINTABLE.test(_result)) {
8370
+ throwError(state, "the stream contains non-printable characters");
8371
+ }
8372
+ state.result += _result;
8373
+ }
8374
+ }
8375
+ function chargeMergeWork(state) {
8376
+ state.totalMergeKeys++;
8377
+ if (state.maxTotalMergeKeys !== -1 && state.totalMergeKeys > state.maxTotalMergeKeys) {
8378
+ throwError(state, "merge keys exceeded maxTotalMergeKeys (" + state.maxTotalMergeKeys + ")");
8379
+ }
8380
+ }
8381
+ function mergeMappings(state, destination, source, overridableKeys) {
8382
+ if (!common2.isObject(source)) {
8383
+ throwError(state, "cannot merge mappings; the provided source object is unacceptable");
8384
+ }
8385
+ chargeMergeWork(state);
8386
+ const sourceKeys = Object.keys(source);
8387
+ for (let index = 0, quantity = sourceKeys.length; index < quantity; index += 1) {
8388
+ const key = sourceKeys[index];
8389
+ chargeMergeWork(state);
8390
+ if (!_hasOwnProperty.call(destination, key)) {
8391
+ setProperty(destination, key, source[key]);
8392
+ overridableKeys[key] = true;
8393
+ }
8394
+ }
8395
+ }
8396
+ function storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, startLine, startLineStart, startPos) {
8397
+ if (Array.isArray(keyNode)) {
8398
+ keyNode = Array.prototype.slice.call(keyNode);
8399
+ for (let index = 0, quantity = keyNode.length; index < quantity; index += 1) {
8400
+ if (Array.isArray(keyNode[index])) {
8401
+ throwError(state, "nested arrays are not supported inside keys");
8402
+ }
8403
+ if (typeof keyNode === "object" && _class(keyNode[index]) === "[object Object]") {
8404
+ keyNode[index] = "[object Object]";
8405
+ }
8406
+ }
8407
+ }
8408
+ if (typeof keyNode === "object" && _class(keyNode) === "[object Object]") {
8409
+ keyNode = "[object Object]";
8410
+ }
8411
+ keyNode = String(keyNode);
8412
+ if (_result === null) {
8413
+ _result = {};
8414
+ }
8415
+ if (keyTag === "tag:yaml.org,2002:merge") {
8416
+ if (Array.isArray(valueNode)) {
8417
+ if (valueNode.length > 100) {
8418
+ throwError(state, "abnormal merge sequence size");
8419
+ }
8420
+ for (let index = 0, quantity = valueNode.length; index < quantity; index += 1) {
8421
+ mergeMappings(state, _result, valueNode[index], overridableKeys);
8422
+ }
8423
+ } else {
8424
+ mergeMappings(state, _result, valueNode, overridableKeys);
8425
+ }
8426
+ } else {
8427
+ if (!state.json && !_hasOwnProperty.call(overridableKeys, keyNode) && _hasOwnProperty.call(_result, keyNode)) {
8428
+ state.line = startLine || state.line;
8429
+ state.lineStart = startLineStart || state.lineStart;
8430
+ state.position = startPos || state.position;
8431
+ throwError(state, "duplicated mapping key");
8432
+ }
8433
+ setProperty(_result, keyNode, valueNode);
8434
+ delete overridableKeys[keyNode];
8435
+ }
8436
+ return _result;
8437
+ }
8438
+ function readLineBreak(state) {
8439
+ const ch = state.input.charCodeAt(state.position);
8440
+ if (ch === 10) {
8441
+ state.position++;
8442
+ } else if (ch === 13) {
8443
+ state.position++;
8444
+ if (state.input.charCodeAt(state.position) === 10) {
8445
+ state.position++;
8446
+ }
8447
+ } else {
8448
+ throwError(state, "a line break is expected");
8449
+ }
8450
+ state.line += 1;
8451
+ state.lineStart = state.position;
8452
+ state.firstTabInLine = -1;
8453
+ }
8454
+ function skipSeparationSpace(state, allowComments, checkIndent) {
8455
+ let lineBreaks = 0;
8456
+ let ch = state.input.charCodeAt(state.position);
8457
+ while (ch !== 0) {
8458
+ while (isWhiteSpace(ch)) {
8459
+ if (ch === 9 && state.firstTabInLine === -1) {
8460
+ state.firstTabInLine = state.position;
8461
+ }
8462
+ ch = state.input.charCodeAt(++state.position);
8463
+ }
8464
+ if (allowComments && ch === 35) {
8465
+ do {
8466
+ ch = state.input.charCodeAt(++state.position);
8467
+ } while (ch !== 10 && ch !== 13 && ch !== 0);
8468
+ }
8469
+ if (isEol(ch)) {
8470
+ readLineBreak(state);
8471
+ ch = state.input.charCodeAt(state.position);
8472
+ lineBreaks++;
8473
+ state.lineIndent = 0;
8474
+ while (ch === 32) {
8475
+ state.lineIndent++;
8476
+ ch = state.input.charCodeAt(++state.position);
8477
+ }
8478
+ } else {
8479
+ break;
8480
+ }
8481
+ }
8482
+ if (checkIndent !== -1 && lineBreaks !== 0 && state.lineIndent < checkIndent) {
8483
+ throwWarning(state, "deficient indentation");
8484
+ }
8485
+ return lineBreaks;
8486
+ }
8487
+ function testDocumentSeparator(state) {
8488
+ let _position = state.position;
8489
+ let ch = state.input.charCodeAt(_position);
8490
+ if ((ch === 45 || ch === 46) && ch === state.input.charCodeAt(_position + 1) && ch === state.input.charCodeAt(_position + 2)) {
8491
+ _position += 3;
8492
+ ch = state.input.charCodeAt(_position);
8493
+ if (ch === 0 || isWsOrEol(ch)) {
8494
+ return true;
8495
+ }
8496
+ }
8497
+ return false;
8498
+ }
8499
+ function writeFoldedLines(state, count) {
8500
+ if (count === 1) {
8501
+ state.result += " ";
8502
+ } else if (count > 1) {
8503
+ state.result += common2.repeat("\n", count - 1);
8504
+ }
8505
+ }
8506
+ function readPlainScalar(state, nodeIndent, withinFlowCollection) {
8507
+ let captureStart;
8508
+ let captureEnd;
8509
+ let hasPendingContent;
8510
+ let _line;
8511
+ let _lineStart;
8512
+ let _lineIndent;
8513
+ const _kind = state.kind;
8514
+ const _result = state.result;
8515
+ let ch = state.input.charCodeAt(state.position);
8516
+ if (isWsOrEol(ch) || isFlowIndicator(ch) || ch === 35 || ch === 38 || ch === 42 || ch === 33 || ch === 124 || ch === 62 || ch === 39 || ch === 34 || ch === 37 || ch === 64 || ch === 96) {
8517
+ return false;
8518
+ }
8519
+ if (ch === 63 || ch === 45) {
8520
+ const following = state.input.charCodeAt(state.position + 1);
8521
+ if (isWsOrEol(following) || withinFlowCollection && isFlowIndicator(following)) {
8522
+ return false;
8523
+ }
8524
+ }
8525
+ state.kind = "scalar";
8526
+ state.result = "";
8527
+ captureStart = captureEnd = state.position;
8528
+ hasPendingContent = false;
8529
+ while (ch !== 0) {
8530
+ if (ch === 58) {
8531
+ const following = state.input.charCodeAt(state.position + 1);
8532
+ if (isWsOrEol(following) || withinFlowCollection && isFlowIndicator(following)) {
8533
+ break;
8534
+ }
8535
+ } else if (ch === 35) {
8536
+ const preceding = state.input.charCodeAt(state.position - 1);
8537
+ if (isWsOrEol(preceding)) {
8538
+ break;
8539
+ }
8540
+ } else if (state.position === state.lineStart && testDocumentSeparator(state) || withinFlowCollection && isFlowIndicator(ch)) {
8541
+ break;
8542
+ } else if (isEol(ch)) {
8543
+ _line = state.line;
8544
+ _lineStart = state.lineStart;
8545
+ _lineIndent = state.lineIndent;
8546
+ skipSeparationSpace(state, false, -1);
8547
+ if (state.lineIndent >= nodeIndent) {
8548
+ hasPendingContent = true;
8549
+ ch = state.input.charCodeAt(state.position);
8550
+ continue;
8551
+ } else {
8552
+ state.position = captureEnd;
8553
+ state.line = _line;
8554
+ state.lineStart = _lineStart;
8555
+ state.lineIndent = _lineIndent;
8556
+ break;
8557
+ }
8558
+ }
8559
+ if (hasPendingContent) {
8560
+ captureSegment(state, captureStart, captureEnd, false);
8561
+ writeFoldedLines(state, state.line - _line);
8562
+ captureStart = captureEnd = state.position;
8563
+ hasPendingContent = false;
8564
+ }
8565
+ if (!isWhiteSpace(ch)) {
8566
+ captureEnd = state.position + 1;
8567
+ }
8568
+ ch = state.input.charCodeAt(++state.position);
8569
+ }
8570
+ captureSegment(state, captureStart, captureEnd, false);
8571
+ if (state.result) {
8572
+ return true;
8573
+ }
8574
+ state.kind = _kind;
8575
+ state.result = _result;
8576
+ return false;
8577
+ }
8578
+ function readSingleQuotedScalar(state, nodeIndent) {
8579
+ let captureStart;
8580
+ let captureEnd;
8581
+ let ch = state.input.charCodeAt(state.position);
8582
+ if (ch !== 39) {
8583
+ return false;
8584
+ }
8585
+ state.kind = "scalar";
8586
+ state.result = "";
8587
+ state.position++;
8588
+ captureStart = captureEnd = state.position;
8589
+ while ((ch = state.input.charCodeAt(state.position)) !== 0) {
8590
+ if (ch === 39) {
8591
+ captureSegment(state, captureStart, state.position, true);
8592
+ ch = state.input.charCodeAt(++state.position);
8593
+ if (ch === 39) {
8594
+ captureStart = state.position;
8595
+ state.position++;
8596
+ captureEnd = state.position;
8597
+ } else {
8598
+ return true;
8599
+ }
8600
+ } else if (isEol(ch)) {
8601
+ captureSegment(state, captureStart, captureEnd, true);
8602
+ writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
8603
+ captureStart = captureEnd = state.position;
8604
+ } else if (state.position === state.lineStart && testDocumentSeparator(state)) {
8605
+ throwError(state, "unexpected end of the document within a single quoted scalar");
8606
+ } else {
8607
+ state.position++;
8608
+ if (!isWhiteSpace(ch)) {
8609
+ captureEnd = state.position;
8610
+ }
8611
+ }
8612
+ }
8613
+ throwError(state, "unexpected end of the stream within a single quoted scalar");
8614
+ }
8615
+ function readDoubleQuotedScalar(state, nodeIndent) {
8616
+ let captureStart;
8617
+ let captureEnd;
8618
+ let tmp;
8619
+ let ch = state.input.charCodeAt(state.position);
8620
+ if (ch !== 34) {
8621
+ return false;
8622
+ }
8623
+ state.kind = "scalar";
8624
+ state.result = "";
8625
+ state.position++;
8626
+ captureStart = captureEnd = state.position;
8627
+ while ((ch = state.input.charCodeAt(state.position)) !== 0) {
8628
+ if (ch === 34) {
8629
+ captureSegment(state, captureStart, state.position, true);
8630
+ state.position++;
8631
+ return true;
8632
+ } else if (ch === 92) {
8633
+ captureSegment(state, captureStart, state.position, true);
8634
+ ch = state.input.charCodeAt(++state.position);
8635
+ if (isEol(ch)) {
8636
+ skipSeparationSpace(state, false, nodeIndent);
8637
+ } else if (ch < 256 && simpleEscapeCheck[ch]) {
8638
+ state.result += simpleEscapeMap[ch];
8639
+ state.position++;
8640
+ } else if ((tmp = escapedHexLen(ch)) > 0) {
8641
+ let hexLength = tmp;
8642
+ let hexResult = 0;
8643
+ for (; hexLength > 0; hexLength--) {
8644
+ ch = state.input.charCodeAt(++state.position);
8645
+ if ((tmp = fromHexCode(ch)) >= 0) {
8646
+ hexResult = (hexResult << 4) + tmp;
8647
+ } else {
8648
+ throwError(state, "expected hexadecimal character");
8649
+ }
8650
+ }
8651
+ state.result += charFromCodepoint(hexResult);
8652
+ state.position++;
8653
+ } else {
8654
+ throwError(state, "unknown escape sequence");
8655
+ }
8656
+ captureStart = captureEnd = state.position;
8657
+ } else if (isEol(ch)) {
8658
+ captureSegment(state, captureStart, captureEnd, true);
8659
+ writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
8660
+ captureStart = captureEnd = state.position;
8661
+ } else if (state.position === state.lineStart && testDocumentSeparator(state)) {
8662
+ throwError(state, "unexpected end of the document within a double quoted scalar");
8663
+ } else {
8664
+ state.position++;
8665
+ if (!isWhiteSpace(ch)) {
8666
+ captureEnd = state.position;
8667
+ }
8668
+ }
8669
+ }
8670
+ throwError(state, "unexpected end of the stream within a double quoted scalar");
8671
+ }
8672
+ function readFlowCollection(state, nodeIndent) {
8673
+ let readNext = true;
8674
+ let _line;
8675
+ let _lineStart;
8676
+ let _pos;
8677
+ const _tag = state.tag;
8678
+ let _result;
8679
+ const _anchor = state.anchor;
8680
+ let terminator;
8681
+ let isPair;
8682
+ let isExplicitPair;
8683
+ let isMapping;
8684
+ const overridableKeys = /* @__PURE__ */ Object.create(null);
8685
+ let keyNode;
8686
+ let keyTag;
8687
+ let valueNode;
8688
+ let ch = state.input.charCodeAt(state.position);
8689
+ if (ch === 91) {
8690
+ terminator = 93;
8691
+ isMapping = false;
8692
+ _result = [];
8693
+ } else if (ch === 123) {
8694
+ terminator = 125;
8695
+ isMapping = true;
8696
+ _result = {};
8697
+ } else {
8698
+ return false;
8699
+ }
8700
+ if (state.anchor !== null) {
8701
+ storeAnchor(state, state.anchor, _result);
8702
+ }
8703
+ ch = state.input.charCodeAt(++state.position);
8704
+ while (ch !== 0) {
8705
+ skipSeparationSpace(state, true, nodeIndent);
8706
+ ch = state.input.charCodeAt(state.position);
8707
+ if (ch === terminator) {
8708
+ state.position++;
8709
+ state.tag = _tag;
8710
+ state.anchor = _anchor;
8711
+ state.kind = isMapping ? "mapping" : "sequence";
8712
+ state.result = _result;
8713
+ return true;
8714
+ } else if (!readNext) {
8715
+ throwError(state, "missed comma between flow collection entries");
8716
+ } else if (ch === 44) {
8717
+ throwError(state, "expected the node content, but found ','");
8718
+ }
8719
+ keyTag = keyNode = valueNode = null;
8720
+ isPair = isExplicitPair = false;
8721
+ if (ch === 63) {
8722
+ const following = state.input.charCodeAt(state.position + 1);
8723
+ if (isWsOrEol(following)) {
8724
+ isPair = isExplicitPair = true;
8725
+ state.position++;
8726
+ skipSeparationSpace(state, true, nodeIndent);
8727
+ }
8728
+ }
8729
+ _line = state.line;
8730
+ _lineStart = state.lineStart;
8731
+ _pos = state.position;
8732
+ composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
8733
+ keyTag = state.tag;
8734
+ keyNode = state.result;
8735
+ skipSeparationSpace(state, true, nodeIndent);
8736
+ ch = state.input.charCodeAt(state.position);
8737
+ if ((isExplicitPair || state.line === _line) && ch === 58) {
8738
+ isPair = true;
8739
+ ch = state.input.charCodeAt(++state.position);
8740
+ skipSeparationSpace(state, true, nodeIndent);
8741
+ composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
8742
+ valueNode = state.result;
8743
+ }
8744
+ if (isMapping) {
8745
+ storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos);
8746
+ } else if (isPair) {
8747
+ _result.push(storeMappingPair(state, null, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos));
8748
+ } else {
8749
+ _result.push(keyNode);
8750
+ }
8751
+ skipSeparationSpace(state, true, nodeIndent);
8752
+ ch = state.input.charCodeAt(state.position);
8753
+ if (ch === 44) {
8754
+ readNext = true;
8755
+ ch = state.input.charCodeAt(++state.position);
8756
+ } else {
8757
+ readNext = false;
8758
+ }
8759
+ }
8760
+ throwError(state, "unexpected end of the stream within a flow collection");
8761
+ }
8762
+ function readBlockScalar(state, nodeIndent) {
8763
+ let folding;
8764
+ let chomping = CHOMPING_CLIP;
8765
+ let didReadContent = false;
8766
+ let detectedIndent = false;
8767
+ let textIndent = nodeIndent;
8768
+ let emptyLines = 0;
8769
+ let atMoreIndented = false;
8770
+ let tmp;
8771
+ let ch = state.input.charCodeAt(state.position);
8772
+ if (ch === 124) {
8773
+ folding = false;
8774
+ } else if (ch === 62) {
8775
+ folding = true;
8776
+ } else {
8777
+ return false;
8778
+ }
8779
+ state.kind = "scalar";
8780
+ state.result = "";
8781
+ while (ch !== 0) {
8782
+ ch = state.input.charCodeAt(++state.position);
8783
+ if (ch === 43 || ch === 45) {
8784
+ if (CHOMPING_CLIP === chomping) {
8785
+ chomping = ch === 43 ? CHOMPING_KEEP : CHOMPING_STRIP;
8786
+ } else {
8787
+ throwError(state, "repeat of a chomping mode identifier");
8788
+ }
8789
+ } else if ((tmp = fromDecimalCode(ch)) >= 0) {
8790
+ if (tmp === 0) {
8791
+ throwError(state, "bad explicit indentation width of a block scalar; it cannot be less than one");
8792
+ } else if (!detectedIndent) {
8793
+ textIndent = nodeIndent + tmp - 1;
8794
+ detectedIndent = true;
8795
+ } else {
8796
+ throwError(state, "repeat of an indentation width identifier");
8797
+ }
8798
+ } else {
8799
+ break;
8800
+ }
8801
+ }
8802
+ if (isWhiteSpace(ch)) {
8803
+ do {
8804
+ ch = state.input.charCodeAt(++state.position);
8805
+ } while (isWhiteSpace(ch));
8806
+ if (ch === 35) {
8807
+ do {
8808
+ ch = state.input.charCodeAt(++state.position);
8809
+ } while (!isEol(ch) && ch !== 0);
8810
+ }
8811
+ }
8812
+ while (ch !== 0) {
8813
+ readLineBreak(state);
8814
+ state.lineIndent = 0;
8815
+ ch = state.input.charCodeAt(state.position);
8816
+ while ((!detectedIndent || state.lineIndent < textIndent) && ch === 32) {
8817
+ state.lineIndent++;
8818
+ ch = state.input.charCodeAt(++state.position);
8819
+ }
8820
+ if (!detectedIndent && state.lineIndent > textIndent) {
8821
+ textIndent = state.lineIndent;
8822
+ }
8823
+ if (isEol(ch)) {
8824
+ emptyLines++;
8825
+ continue;
8826
+ }
8827
+ if (!detectedIndent && textIndent === 0) {
8828
+ throwError(state, "missing indentation for block scalar");
8829
+ }
8830
+ if (state.lineIndent < textIndent) {
8831
+ if (chomping === CHOMPING_KEEP) {
8832
+ state.result += common2.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines);
8833
+ } else if (chomping === CHOMPING_CLIP) {
8834
+ if (didReadContent) {
8835
+ state.result += "\n";
8836
+ }
8837
+ }
8838
+ break;
8839
+ }
8840
+ if (folding) {
8841
+ if (isWhiteSpace(ch)) {
8842
+ atMoreIndented = true;
8843
+ state.result += common2.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines);
8844
+ } else if (atMoreIndented) {
8845
+ atMoreIndented = false;
8846
+ state.result += common2.repeat("\n", emptyLines + 1);
8847
+ } else if (emptyLines === 0) {
8848
+ if (didReadContent) {
8849
+ state.result += " ";
8850
+ }
8851
+ } else {
8852
+ state.result += common2.repeat("\n", emptyLines);
8853
+ }
8854
+ } else {
8855
+ state.result += common2.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines);
8856
+ }
8857
+ didReadContent = true;
8858
+ detectedIndent = true;
8859
+ emptyLines = 0;
8860
+ const captureStart = state.position;
8861
+ while (!isEol(ch) && ch !== 0) {
8862
+ ch = state.input.charCodeAt(++state.position);
8863
+ }
8864
+ captureSegment(state, captureStart, state.position, false);
8865
+ }
8866
+ return true;
8867
+ }
8868
+ function readBlockSequence(state, nodeIndent) {
8869
+ const _tag = state.tag;
8870
+ const _anchor = state.anchor;
8871
+ const _result = [];
8872
+ let detected = false;
8873
+ if (state.firstTabInLine !== -1) return false;
8874
+ if (state.anchor !== null) {
8875
+ storeAnchor(state, state.anchor, _result);
8876
+ }
8877
+ let ch = state.input.charCodeAt(state.position);
8878
+ while (ch !== 0) {
8879
+ if (state.firstTabInLine !== -1) {
8880
+ state.position = state.firstTabInLine;
8881
+ throwError(state, "tab characters must not be used in indentation");
8882
+ }
8883
+ if (ch !== 45) {
8884
+ break;
8885
+ }
8886
+ const following = state.input.charCodeAt(state.position + 1);
8887
+ if (!isWsOrEol(following)) {
8888
+ break;
8889
+ }
8890
+ detected = true;
8891
+ state.position++;
8892
+ if (skipSeparationSpace(state, true, -1)) {
8893
+ if (state.lineIndent <= nodeIndent) {
8894
+ _result.push(null);
8895
+ ch = state.input.charCodeAt(state.position);
8896
+ continue;
8897
+ }
8898
+ }
8899
+ const _line = state.line;
8900
+ composeNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true);
8901
+ _result.push(state.result);
8902
+ skipSeparationSpace(state, true, -1);
8903
+ ch = state.input.charCodeAt(state.position);
8904
+ if ((state.line === _line || state.lineIndent > nodeIndent) && ch !== 0) {
8905
+ throwError(state, "bad indentation of a sequence entry");
8906
+ } else if (state.lineIndent < nodeIndent) {
8907
+ break;
8908
+ }
8909
+ }
8910
+ if (detected) {
8911
+ state.tag = _tag;
8912
+ state.anchor = _anchor;
8913
+ state.kind = "sequence";
8914
+ state.result = _result;
8915
+ return true;
8916
+ }
8917
+ return false;
8918
+ }
8919
+ function readBlockMapping(state, nodeIndent, flowIndent) {
8920
+ let allowCompact;
8921
+ let _keyLine;
8922
+ let _keyLineStart;
8923
+ let _keyPos;
8924
+ const _tag = state.tag;
8925
+ const _anchor = state.anchor;
8926
+ const _result = {};
8927
+ const overridableKeys = /* @__PURE__ */ Object.create(null);
8928
+ let keyTag = null;
8929
+ let keyNode = null;
8930
+ let valueNode = null;
8931
+ let atExplicitKey = false;
8932
+ let detected = false;
8933
+ if (state.firstTabInLine !== -1) return false;
8934
+ if (state.anchor !== null) {
8935
+ storeAnchor(state, state.anchor, _result);
8936
+ }
8937
+ let ch = state.input.charCodeAt(state.position);
8938
+ while (ch !== 0) {
8939
+ if (!atExplicitKey && state.firstTabInLine !== -1) {
8940
+ state.position = state.firstTabInLine;
8941
+ throwError(state, "tab characters must not be used in indentation");
8942
+ }
8943
+ const following = state.input.charCodeAt(state.position + 1);
8944
+ const _line = state.line;
8945
+ if ((ch === 63 || ch === 58) && isWsOrEol(following)) {
8946
+ if (ch === 63) {
8947
+ if (atExplicitKey) {
8948
+ storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
8949
+ keyTag = keyNode = valueNode = null;
8950
+ }
8951
+ detected = true;
8952
+ atExplicitKey = true;
8953
+ allowCompact = true;
8954
+ } else if (atExplicitKey) {
8955
+ atExplicitKey = false;
8956
+ allowCompact = true;
8957
+ } else {
8958
+ throwError(state, "incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line");
8959
+ }
8960
+ state.position += 1;
8961
+ ch = following;
8962
+ } else {
8963
+ _keyLine = state.line;
8964
+ _keyLineStart = state.lineStart;
8965
+ _keyPos = state.position;
8966
+ if (!composeNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true)) {
8967
+ break;
8968
+ }
8969
+ if (state.line === _line) {
8970
+ ch = state.input.charCodeAt(state.position);
8971
+ while (isWhiteSpace(ch)) {
8972
+ ch = state.input.charCodeAt(++state.position);
8973
+ }
8974
+ if (ch === 58) {
8975
+ ch = state.input.charCodeAt(++state.position);
8976
+ if (!isWsOrEol(ch)) {
8977
+ throwError(state, "a whitespace character is expected after the key-value separator within a block mapping");
8978
+ }
8979
+ if (atExplicitKey) {
8980
+ storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
8981
+ keyTag = keyNode = valueNode = null;
8982
+ }
8983
+ detected = true;
8984
+ atExplicitKey = false;
8985
+ allowCompact = false;
8986
+ keyTag = state.tag;
8987
+ keyNode = state.result;
8988
+ } else if (detected) {
8989
+ throwError(state, "can not read an implicit mapping pair; a colon is missed");
8990
+ } else {
8991
+ state.tag = _tag;
8992
+ state.anchor = _anchor;
8993
+ return true;
8994
+ }
8995
+ } else if (detected) {
8996
+ throwError(state, "can not read a block mapping entry; a multiline key may not be an implicit key");
8997
+ } else {
8998
+ state.tag = _tag;
8999
+ state.anchor = _anchor;
9000
+ return true;
9001
+ }
9002
+ }
9003
+ if (state.line === _line || state.lineIndent > nodeIndent) {
9004
+ if (atExplicitKey) {
9005
+ _keyLine = state.line;
9006
+ _keyLineStart = state.lineStart;
9007
+ _keyPos = state.position;
9008
+ }
9009
+ if (composeNode(state, nodeIndent, CONTEXT_BLOCK_OUT, true, allowCompact)) {
9010
+ if (atExplicitKey) {
9011
+ keyNode = state.result;
9012
+ } else {
9013
+ valueNode = state.result;
9014
+ }
9015
+ }
9016
+ if (!atExplicitKey) {
9017
+ storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _keyLine, _keyLineStart, _keyPos);
9018
+ keyTag = keyNode = valueNode = null;
9019
+ }
9020
+ skipSeparationSpace(state, true, -1);
9021
+ ch = state.input.charCodeAt(state.position);
9022
+ }
9023
+ if ((state.line === _line || state.lineIndent > nodeIndent) && ch !== 0) {
9024
+ throwError(state, "bad indentation of a mapping entry");
9025
+ } else if (state.lineIndent < nodeIndent) {
9026
+ break;
9027
+ }
9028
+ }
9029
+ if (atExplicitKey) {
9030
+ storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
9031
+ }
9032
+ if (detected) {
9033
+ state.tag = _tag;
9034
+ state.anchor = _anchor;
9035
+ state.kind = "mapping";
9036
+ state.result = _result;
9037
+ }
9038
+ return detected;
9039
+ }
9040
+ function readTagProperty(state) {
9041
+ let isVerbatim = false;
9042
+ let isNamed = false;
9043
+ let tagHandle;
9044
+ let tagName;
9045
+ let ch = state.input.charCodeAt(state.position);
9046
+ if (ch !== 33) return false;
9047
+ if (state.tag !== null) {
9048
+ throwError(state, "duplication of a tag property");
9049
+ }
9050
+ ch = state.input.charCodeAt(++state.position);
9051
+ if (ch === 60) {
9052
+ isVerbatim = true;
9053
+ ch = state.input.charCodeAt(++state.position);
9054
+ } else if (ch === 33) {
9055
+ isNamed = true;
9056
+ tagHandle = "!!";
9057
+ ch = state.input.charCodeAt(++state.position);
9058
+ } else {
9059
+ tagHandle = "!";
9060
+ }
9061
+ let _position = state.position;
9062
+ if (isVerbatim) {
9063
+ do {
9064
+ ch = state.input.charCodeAt(++state.position);
9065
+ } while (ch !== 0 && ch !== 62);
9066
+ if (state.position < state.length) {
9067
+ tagName = state.input.slice(_position, state.position);
9068
+ ch = state.input.charCodeAt(++state.position);
9069
+ } else {
9070
+ throwError(state, "unexpected end of the stream within a verbatim tag");
9071
+ }
9072
+ } else {
9073
+ while (ch !== 0 && !isWsOrEol(ch)) {
9074
+ if (ch === 33) {
9075
+ if (!isNamed) {
9076
+ tagHandle = state.input.slice(_position - 1, state.position + 1);
9077
+ if (!PATTERN_TAG_HANDLE.test(tagHandle)) {
9078
+ throwError(state, "named tag handle cannot contain such characters");
9079
+ }
9080
+ isNamed = true;
9081
+ _position = state.position + 1;
9082
+ } else {
9083
+ throwError(state, "tag suffix cannot contain exclamation marks");
9084
+ }
9085
+ }
9086
+ ch = state.input.charCodeAt(++state.position);
9087
+ }
9088
+ tagName = state.input.slice(_position, state.position);
9089
+ if (PATTERN_FLOW_INDICATORS.test(tagName)) {
9090
+ throwError(state, "tag suffix cannot contain flow indicator characters");
9091
+ }
9092
+ }
9093
+ if (tagName && !PATTERN_TAG_URI.test(tagName)) {
9094
+ throwError(state, "tag name cannot contain such characters: " + tagName);
9095
+ }
9096
+ try {
9097
+ tagName = decodeURIComponent(tagName);
9098
+ } catch (err) {
9099
+ throwError(state, "tag name is malformed: " + tagName);
9100
+ }
9101
+ if (isVerbatim) {
9102
+ state.tag = tagName;
9103
+ } else if (_hasOwnProperty.call(state.tagMap, tagHandle)) {
9104
+ state.tag = state.tagMap[tagHandle] + tagName;
9105
+ } else if (tagHandle === "!") {
9106
+ state.tag = "!" + tagName;
9107
+ } else if (tagHandle === "!!") {
9108
+ state.tag = "tag:yaml.org,2002:" + tagName;
9109
+ } else {
9110
+ throwError(state, 'undeclared tag handle "' + tagHandle + '"');
9111
+ }
9112
+ return true;
9113
+ }
9114
+ function readAnchorProperty(state) {
9115
+ let ch = state.input.charCodeAt(state.position);
9116
+ if (ch !== 38) return false;
9117
+ if (state.anchor !== null) {
9118
+ throwError(state, "duplication of an anchor property");
9119
+ }
9120
+ ch = state.input.charCodeAt(++state.position);
9121
+ const _position = state.position;
9122
+ while (ch !== 0 && !isWsOrEol(ch) && !isFlowIndicator(ch)) {
9123
+ ch = state.input.charCodeAt(++state.position);
9124
+ }
9125
+ if (state.position === _position) {
9126
+ throwError(state, "name of an anchor node must contain at least one character");
9127
+ }
9128
+ state.anchor = state.input.slice(_position, state.position);
9129
+ return true;
9130
+ }
9131
+ function readAlias(state) {
9132
+ let ch = state.input.charCodeAt(state.position);
9133
+ if (ch !== 42) return false;
9134
+ ch = state.input.charCodeAt(++state.position);
9135
+ const _position = state.position;
9136
+ while (ch !== 0 && !isWsOrEol(ch) && !isFlowIndicator(ch)) {
9137
+ ch = state.input.charCodeAt(++state.position);
9138
+ }
9139
+ if (state.position === _position) {
9140
+ throwError(state, "name of an alias node must contain at least one character");
9141
+ }
9142
+ const alias = state.input.slice(_position, state.position);
9143
+ if (!_hasOwnProperty.call(state.anchorMap, alias)) {
9144
+ throwError(state, 'unidentified alias "' + alias + '"');
9145
+ }
9146
+ state.result = state.anchorMap[alias];
9147
+ skipSeparationSpace(state, true, -1);
9148
+ return true;
9149
+ }
9150
+ function tryReadBlockMappingFromProperty(state, propertyStart, nodeIndent, flowIndent) {
9151
+ const fallbackState = snapshotState(state);
9152
+ beginAnchorTransaction(state);
9153
+ restoreState(state, propertyStart);
9154
+ state.tag = null;
9155
+ state.anchor = null;
9156
+ state.kind = null;
9157
+ state.result = null;
9158
+ if (readBlockMapping(state, nodeIndent, flowIndent) && state.kind === "mapping") {
9159
+ commitAnchorTransaction(state);
9160
+ return true;
9161
+ }
9162
+ rollbackAnchorTransaction(state);
9163
+ restoreState(state, fallbackState);
9164
+ return false;
9165
+ }
9166
+ function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact) {
9167
+ let allowBlockScalars;
9168
+ let allowBlockCollections;
9169
+ let indentStatus = 1;
9170
+ let atNewLine = false;
9171
+ let hasContent = false;
9172
+ let propertyStart = null;
9173
+ let type2;
9174
+ let flowIndent;
9175
+ let blockIndent;
9176
+ if (state.depth >= state.maxDepth) {
9177
+ throwError(state, "nesting exceeded maxDepth (" + state.maxDepth + ")");
9178
+ }
9179
+ state.depth += 1;
9180
+ if (state.listener !== null) {
9181
+ state.listener("open", state);
9182
+ }
9183
+ state.tag = null;
9184
+ state.anchor = null;
9185
+ state.kind = null;
9186
+ state.result = null;
9187
+ const allowBlockStyles = allowBlockScalars = allowBlockCollections = CONTEXT_BLOCK_OUT === nodeContext || CONTEXT_BLOCK_IN === nodeContext;
9188
+ if (allowToSeek) {
9189
+ if (skipSeparationSpace(state, true, -1)) {
9190
+ atNewLine = true;
9191
+ if (state.lineIndent > parentIndent) {
9192
+ indentStatus = 1;
9193
+ } else if (state.lineIndent === parentIndent) {
9194
+ indentStatus = 0;
9195
+ } else if (state.lineIndent < parentIndent) {
9196
+ indentStatus = -1;
9197
+ }
9198
+ }
9199
+ }
9200
+ if (indentStatus === 1) {
9201
+ while (true) {
9202
+ const ch = state.input.charCodeAt(state.position);
9203
+ const propertyState = snapshotState(state);
9204
+ if (atNewLine && (ch === 33 && state.tag !== null || ch === 38 && state.anchor !== null)) {
9205
+ break;
9206
+ }
9207
+ if (!readTagProperty(state) && !readAnchorProperty(state)) {
9208
+ break;
9209
+ }
9210
+ if (propertyStart === null) {
9211
+ propertyStart = propertyState;
9212
+ }
9213
+ if (skipSeparationSpace(state, true, -1)) {
9214
+ atNewLine = true;
9215
+ allowBlockCollections = allowBlockStyles;
9216
+ if (state.lineIndent > parentIndent) {
9217
+ indentStatus = 1;
9218
+ } else if (state.lineIndent === parentIndent) {
9219
+ indentStatus = 0;
9220
+ } else if (state.lineIndent < parentIndent) {
9221
+ indentStatus = -1;
9222
+ }
9223
+ } else {
9224
+ allowBlockCollections = false;
9225
+ }
9226
+ }
9227
+ }
9228
+ if (allowBlockCollections) {
9229
+ allowBlockCollections = atNewLine || allowCompact;
9230
+ }
9231
+ if (indentStatus === 1 || CONTEXT_BLOCK_OUT === nodeContext) {
9232
+ if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext) {
9233
+ flowIndent = parentIndent;
9234
+ } else {
9235
+ flowIndent = parentIndent + 1;
9236
+ }
9237
+ blockIndent = state.position - state.lineStart;
9238
+ if (indentStatus === 1) {
9239
+ if (allowBlockCollections && (readBlockSequence(state, blockIndent) || readBlockMapping(state, blockIndent, flowIndent)) || readFlowCollection(state, flowIndent)) {
9240
+ hasContent = true;
9241
+ } else {
9242
+ const ch = state.input.charCodeAt(state.position);
9243
+ if (propertyStart !== null && allowBlockStyles && !allowBlockCollections && ch !== 124 && ch !== 62 && tryReadBlockMappingFromProperty(
9244
+ state,
9245
+ propertyStart,
9246
+ propertyStart.position - propertyStart.lineStart,
9247
+ flowIndent
9248
+ )) {
9249
+ hasContent = true;
9250
+ } else if (allowBlockScalars && readBlockScalar(state, flowIndent) || readSingleQuotedScalar(state, flowIndent) || readDoubleQuotedScalar(state, flowIndent)) {
9251
+ hasContent = true;
9252
+ } else if (readAlias(state)) {
9253
+ hasContent = true;
9254
+ if (state.tag !== null || state.anchor !== null) {
9255
+ throwError(state, "alias node should not have any properties");
9256
+ }
9257
+ } else if (readPlainScalar(state, flowIndent, CONTEXT_FLOW_IN === nodeContext)) {
9258
+ hasContent = true;
9259
+ if (state.tag === null) {
9260
+ state.tag = "?";
9261
+ }
9262
+ }
9263
+ if (state.anchor !== null) {
9264
+ storeAnchor(state, state.anchor, state.result);
9265
+ }
9266
+ }
9267
+ } else if (indentStatus === 0) {
9268
+ hasContent = allowBlockCollections && readBlockSequence(state, blockIndent);
9269
+ }
9270
+ }
9271
+ if (state.tag === null) {
9272
+ if (state.anchor !== null) {
9273
+ storeAnchor(state, state.anchor, state.result);
9274
+ }
9275
+ } else if (state.tag === "?") {
9276
+ if (state.result !== null && state.kind !== "scalar") {
9277
+ throwError(state, 'unacceptable node kind for !<?> tag; it should be "scalar", not "' + state.kind + '"');
9278
+ }
9279
+ for (let typeIndex = 0, typeQuantity = state.implicitTypes.length; typeIndex < typeQuantity; typeIndex += 1) {
9280
+ type2 = state.implicitTypes[typeIndex];
9281
+ if (type2.resolve(state.result)) {
9282
+ state.result = type2.construct(state.result);
9283
+ state.tag = type2.tag;
9284
+ if (state.anchor !== null) {
9285
+ storeAnchor(state, state.anchor, state.result);
9286
+ }
9287
+ break;
9288
+ }
9289
+ }
9290
+ } else if (state.tag !== "!") {
9291
+ if (_hasOwnProperty.call(state.typeMap[state.kind || "fallback"], state.tag)) {
9292
+ type2 = state.typeMap[state.kind || "fallback"][state.tag];
9293
+ } else {
9294
+ type2 = null;
9295
+ const typeList = state.typeMap.multi[state.kind || "fallback"];
9296
+ for (let typeIndex = 0, typeQuantity = typeList.length; typeIndex < typeQuantity; typeIndex += 1) {
9297
+ if (state.tag.slice(0, typeList[typeIndex].tag.length) === typeList[typeIndex].tag) {
9298
+ type2 = typeList[typeIndex];
9299
+ break;
9300
+ }
9301
+ }
9302
+ }
9303
+ if (!type2) {
9304
+ throwError(state, "unknown tag !<" + state.tag + ">");
9305
+ }
9306
+ if (state.result !== null && type2.kind !== state.kind) {
9307
+ throwError(state, "unacceptable node kind for !<" + state.tag + '> tag; it should be "' + type2.kind + '", not "' + state.kind + '"');
9308
+ }
9309
+ if (!type2.resolve(state.result, state.tag)) {
9310
+ throwError(state, "cannot resolve a node with !<" + state.tag + "> explicit tag");
9311
+ } else {
9312
+ state.result = type2.construct(state.result, state.tag);
9313
+ if (state.anchor !== null) {
9314
+ storeAnchor(state, state.anchor, state.result);
9315
+ }
9316
+ }
9317
+ }
9318
+ if (state.listener !== null) {
9319
+ state.listener("close", state);
9320
+ }
9321
+ state.depth -= 1;
9322
+ return state.tag !== null || state.anchor !== null || hasContent;
9323
+ }
9324
+ function readDocument(state) {
9325
+ const documentStart = state.position;
9326
+ let hasDirectives = false;
9327
+ let ch;
9328
+ state.version = null;
9329
+ state.checkLineBreaks = state.legacy;
9330
+ state.tagMap = /* @__PURE__ */ Object.create(null);
9331
+ state.anchorMap = /* @__PURE__ */ Object.create(null);
9332
+ while ((ch = state.input.charCodeAt(state.position)) !== 0) {
9333
+ skipSeparationSpace(state, true, -1);
9334
+ ch = state.input.charCodeAt(state.position);
9335
+ if (state.lineIndent > 0 || ch !== 37) {
9336
+ break;
9337
+ }
9338
+ hasDirectives = true;
9339
+ ch = state.input.charCodeAt(++state.position);
9340
+ let _position = state.position;
9341
+ while (ch !== 0 && !isWsOrEol(ch)) {
9342
+ ch = state.input.charCodeAt(++state.position);
9343
+ }
9344
+ const directiveName = state.input.slice(_position, state.position);
9345
+ const directiveArgs = [];
9346
+ if (directiveName.length < 1) {
9347
+ throwError(state, "directive name must not be less than one character in length");
9348
+ }
9349
+ while (ch !== 0) {
9350
+ while (isWhiteSpace(ch)) {
9351
+ ch = state.input.charCodeAt(++state.position);
9352
+ }
9353
+ if (ch === 35) {
9354
+ do {
9355
+ ch = state.input.charCodeAt(++state.position);
9356
+ } while (ch !== 0 && !isEol(ch));
9357
+ break;
9358
+ }
9359
+ if (isEol(ch)) break;
9360
+ _position = state.position;
9361
+ while (ch !== 0 && !isWsOrEol(ch)) {
9362
+ ch = state.input.charCodeAt(++state.position);
9363
+ }
9364
+ directiveArgs.push(state.input.slice(_position, state.position));
9365
+ }
9366
+ if (ch !== 0) readLineBreak(state);
9367
+ if (_hasOwnProperty.call(directiveHandlers, directiveName)) {
9368
+ directiveHandlers[directiveName](state, directiveName, directiveArgs);
9369
+ } else {
9370
+ throwWarning(state, 'unknown document directive "' + directiveName + '"');
9371
+ }
9372
+ }
9373
+ skipSeparationSpace(state, true, -1);
9374
+ if (state.lineIndent === 0 && state.input.charCodeAt(state.position) === 45 && state.input.charCodeAt(state.position + 1) === 45 && state.input.charCodeAt(state.position + 2) === 45) {
9375
+ state.position += 3;
9376
+ skipSeparationSpace(state, true, -1);
9377
+ } else if (hasDirectives) {
9378
+ throwError(state, "directives end mark is expected");
9379
+ }
9380
+ composeNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true);
9381
+ skipSeparationSpace(state, true, -1);
9382
+ if (state.checkLineBreaks && PATTERN_NON_ASCII_LINE_BREAKS.test(state.input.slice(documentStart, state.position))) {
9383
+ throwWarning(state, "non-ASCII line breaks are interpreted as content");
9384
+ }
9385
+ state.documents.push(state.result);
9386
+ if (state.position === state.lineStart && testDocumentSeparator(state)) {
9387
+ if (state.input.charCodeAt(state.position) === 46) {
9388
+ state.position += 3;
9389
+ skipSeparationSpace(state, true, -1);
9390
+ }
9391
+ return;
9392
+ }
9393
+ if (state.position < state.length - 1) {
9394
+ throwError(state, "end of the stream or a document separator is expected");
9395
+ }
9396
+ }
9397
+ function loadDocuments(input, options) {
9398
+ input = String(input);
9399
+ options = options || {};
9400
+ if (input.length !== 0) {
9401
+ if (input.charCodeAt(input.length - 1) !== 10 && input.charCodeAt(input.length - 1) !== 13) {
9402
+ input += "\n";
9403
+ }
9404
+ if (input.charCodeAt(0) === 65279) {
9405
+ input = input.slice(1);
9406
+ }
9407
+ }
9408
+ const state = new State(input, options);
9409
+ const nullpos = input.indexOf("\0");
9410
+ if (nullpos !== -1) {
9411
+ state.position = nullpos;
9412
+ throwError(state, "null byte is not allowed in input");
9413
+ }
9414
+ state.input += "\0";
9415
+ while (state.input.charCodeAt(state.position) === 32) {
9416
+ state.lineIndent += 1;
9417
+ state.position += 1;
9418
+ }
9419
+ while (state.position < state.length - 1) {
9420
+ readDocument(state);
9421
+ }
9422
+ return state.documents;
9423
+ }
9424
+ function loadAll2(input, iterator, options) {
9425
+ if (iterator !== null && typeof iterator === "object" && typeof options === "undefined") {
9426
+ options = iterator;
9427
+ iterator = null;
9428
+ }
9429
+ const documents = loadDocuments(input, options);
9430
+ if (typeof iterator !== "function") {
9431
+ return documents;
9432
+ }
9433
+ for (let index = 0, length = documents.length; index < length; index += 1) {
9434
+ iterator(documents[index]);
9435
+ }
9436
+ }
9437
+ function load2(input, options) {
9438
+ const documents = loadDocuments(input, options);
9439
+ if (documents.length === 0) {
9440
+ return void 0;
9441
+ } else if (documents.length === 1) {
9442
+ return documents[0];
9443
+ }
9444
+ throw new YAMLException2("expected a single document in the stream, but found more");
9445
+ }
9446
+ loader.loadAll = loadAll2;
9447
+ loader.load = load2;
9448
+ return loader;
9449
+ }
9450
+ var dumper = {};
9451
+ var hasRequiredDumper;
9452
+ function requireDumper() {
9453
+ if (hasRequiredDumper) return dumper;
9454
+ hasRequiredDumper = 1;
9455
+ const common2 = requireCommon();
9456
+ const YAMLException2 = requireException();
9457
+ const DEFAULT_SCHEMA2 = require_default();
9458
+ const _toString = Object.prototype.toString;
9459
+ const _hasOwnProperty = Object.prototype.hasOwnProperty;
9460
+ const CHAR_BOM = 65279;
9461
+ const CHAR_TAB = 9;
9462
+ const CHAR_LINE_FEED = 10;
9463
+ const CHAR_CARRIAGE_RETURN = 13;
9464
+ const CHAR_SPACE = 32;
9465
+ const CHAR_EXCLAMATION = 33;
9466
+ const CHAR_DOUBLE_QUOTE = 34;
9467
+ const CHAR_SHARP = 35;
9468
+ const CHAR_PERCENT = 37;
9469
+ const CHAR_AMPERSAND = 38;
9470
+ const CHAR_SINGLE_QUOTE = 39;
9471
+ const CHAR_ASTERISK = 42;
9472
+ const CHAR_COMMA = 44;
9473
+ const CHAR_MINUS = 45;
9474
+ const CHAR_COLON = 58;
9475
+ const CHAR_EQUALS = 61;
9476
+ const CHAR_GREATER_THAN = 62;
9477
+ const CHAR_QUESTION = 63;
9478
+ const CHAR_COMMERCIAL_AT = 64;
9479
+ const CHAR_LEFT_SQUARE_BRACKET = 91;
9480
+ const CHAR_RIGHT_SQUARE_BRACKET = 93;
9481
+ const CHAR_GRAVE_ACCENT = 96;
9482
+ const CHAR_LEFT_CURLY_BRACKET = 123;
9483
+ const CHAR_VERTICAL_LINE = 124;
9484
+ const CHAR_RIGHT_CURLY_BRACKET = 125;
9485
+ const ESCAPE_SEQUENCES = {};
9486
+ ESCAPE_SEQUENCES[0] = "\\0";
9487
+ ESCAPE_SEQUENCES[7] = "\\a";
9488
+ ESCAPE_SEQUENCES[8] = "\\b";
9489
+ ESCAPE_SEQUENCES[9] = "\\t";
9490
+ ESCAPE_SEQUENCES[10] = "\\n";
9491
+ ESCAPE_SEQUENCES[11] = "\\v";
9492
+ ESCAPE_SEQUENCES[12] = "\\f";
9493
+ ESCAPE_SEQUENCES[13] = "\\r";
9494
+ ESCAPE_SEQUENCES[27] = "\\e";
9495
+ ESCAPE_SEQUENCES[34] = '\\"';
9496
+ ESCAPE_SEQUENCES[92] = "\\\\";
9497
+ ESCAPE_SEQUENCES[133] = "\\N";
9498
+ ESCAPE_SEQUENCES[160] = "\\_";
9499
+ ESCAPE_SEQUENCES[8232] = "\\L";
9500
+ ESCAPE_SEQUENCES[8233] = "\\P";
9501
+ const DEPRECATED_BOOLEANS_SYNTAX = [
9502
+ "y",
9503
+ "Y",
9504
+ "yes",
9505
+ "Yes",
9506
+ "YES",
9507
+ "on",
9508
+ "On",
9509
+ "ON",
9510
+ "n",
9511
+ "N",
9512
+ "no",
9513
+ "No",
9514
+ "NO",
9515
+ "off",
9516
+ "Off",
9517
+ "OFF"
9518
+ ];
9519
+ const DEPRECATED_BASE60_SYNTAX = /^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;
9520
+ function compileStyleMap(schema2, map2) {
9521
+ if (map2 === null) return {};
9522
+ const result = {};
9523
+ const keys = Object.keys(map2);
9524
+ for (let index = 0, length = keys.length; index < length; index += 1) {
9525
+ let tag = keys[index];
9526
+ let style = String(map2[tag]);
9527
+ if (tag.slice(0, 2) === "!!") {
9528
+ tag = "tag:yaml.org,2002:" + tag.slice(2);
9529
+ }
9530
+ const type2 = schema2.compiledTypeMap["fallback"][tag];
9531
+ if (type2 && _hasOwnProperty.call(type2.styleAliases, style)) {
9532
+ style = type2.styleAliases[style];
9533
+ }
9534
+ result[tag] = style;
9535
+ }
9536
+ return result;
9537
+ }
9538
+ function encodeHex(character) {
9539
+ let handle;
9540
+ let length;
9541
+ const string = character.toString(16).toUpperCase();
9542
+ if (character <= 255) {
9543
+ handle = "x";
9544
+ length = 2;
9545
+ } else if (character <= 65535) {
9546
+ handle = "u";
9547
+ length = 4;
9548
+ } else if (character <= 4294967295) {
9549
+ handle = "U";
9550
+ length = 8;
9551
+ } else {
9552
+ throw new YAMLException2("code point within a string may not be greater than 0xFFFFFFFF");
9553
+ }
9554
+ return "\\" + handle + common2.repeat("0", length - string.length) + string;
9555
+ }
9556
+ const QUOTING_TYPE_SINGLE = 1;
9557
+ const QUOTING_TYPE_DOUBLE = 2;
9558
+ function State(options) {
9559
+ this.schema = options["schema"] || DEFAULT_SCHEMA2;
9560
+ this.indent = Math.max(1, options["indent"] || 2);
9561
+ this.noArrayIndent = options["noArrayIndent"] || false;
9562
+ this.skipInvalid = options["skipInvalid"] || false;
9563
+ this.flowLevel = common2.isNothing(options["flowLevel"]) ? -1 : options["flowLevel"];
9564
+ this.styleMap = compileStyleMap(this.schema, options["styles"] || null);
9565
+ this.sortKeys = options["sortKeys"] || false;
9566
+ this.lineWidth = options["lineWidth"] || 80;
9567
+ this.noRefs = options["noRefs"] || false;
9568
+ this.noCompatMode = options["noCompatMode"] || false;
9569
+ this.condenseFlow = options["condenseFlow"] || false;
9570
+ this.quotingType = options["quotingType"] === '"' ? QUOTING_TYPE_DOUBLE : QUOTING_TYPE_SINGLE;
9571
+ this.forceQuotes = options["forceQuotes"] || false;
9572
+ this.replacer = typeof options["replacer"] === "function" ? options["replacer"] : null;
9573
+ this.implicitTypes = this.schema.compiledImplicit;
9574
+ this.explicitTypes = this.schema.compiledExplicit;
9575
+ this.tag = null;
9576
+ this.result = "";
9577
+ this.duplicates = [];
9578
+ this.usedDuplicates = null;
9579
+ }
9580
+ function indentString(string, spaces) {
9581
+ const ind = common2.repeat(" ", spaces);
9582
+ let position = 0;
9583
+ let result = "";
9584
+ const length = string.length;
9585
+ while (position < length) {
9586
+ let line;
9587
+ const next = string.indexOf("\n", position);
9588
+ if (next === -1) {
9589
+ line = string.slice(position);
9590
+ position = length;
9591
+ } else {
9592
+ line = string.slice(position, next + 1);
9593
+ position = next + 1;
9594
+ }
9595
+ if (line.length && line !== "\n") result += ind;
9596
+ result += line;
9597
+ }
9598
+ return result;
9599
+ }
9600
+ function generateNextLine(state, level) {
9601
+ return "\n" + common2.repeat(" ", state.indent * level);
9602
+ }
9603
+ function testImplicitResolving(state, str2) {
9604
+ for (let index = 0, length = state.implicitTypes.length; index < length; index += 1) {
9605
+ const type2 = state.implicitTypes[index];
9606
+ if (type2.resolve(str2)) {
9607
+ return true;
9608
+ }
9609
+ }
9610
+ return false;
9611
+ }
9612
+ function isWhitespace(c) {
9613
+ return c === CHAR_SPACE || c === CHAR_TAB;
9614
+ }
9615
+ function isPrintable(c) {
9616
+ return c >= 32 && c <= 126 || c >= 161 && c <= 55295 && c !== 8232 && c !== 8233 || c >= 57344 && c <= 65533 && c !== CHAR_BOM || c >= 65536 && c <= 1114111;
9617
+ }
9618
+ function isNsCharOrWhitespace(c) {
9619
+ return isPrintable(c) && c !== CHAR_BOM && // - b-char
9620
+ c !== CHAR_CARRIAGE_RETURN && c !== CHAR_LINE_FEED;
9621
+ }
9622
+ function isPlainSafe(c, prev, inblock) {
9623
+ const cIsNsCharOrWhitespace = isNsCharOrWhitespace(c);
9624
+ const cIsNsChar = cIsNsCharOrWhitespace && !isWhitespace(c);
9625
+ return (
9626
+ // ns-plain-safe
9627
+ (inblock ? cIsNsCharOrWhitespace : cIsNsCharOrWhitespace && // - c-flow-indicator
9628
+ c !== CHAR_COMMA && c !== CHAR_LEFT_SQUARE_BRACKET && c !== CHAR_RIGHT_SQUARE_BRACKET && c !== CHAR_LEFT_CURLY_BRACKET && c !== CHAR_RIGHT_CURLY_BRACKET) && // ns-plain-char
9629
+ c !== CHAR_SHARP && // false on '#'
9630
+ !(prev === CHAR_COLON && !cIsNsChar) || // false on ': '
9631
+ isNsCharOrWhitespace(prev) && !isWhitespace(prev) && c === CHAR_SHARP || // change to true on '[^ ]#'
9632
+ prev === CHAR_COLON && cIsNsChar
9633
+ );
9634
+ }
9635
+ function isPlainSafeFirst(c) {
9636
+ return isPrintable(c) && c !== CHAR_BOM && !isWhitespace(c) && // - s-white
9637
+ // - (c-indicator ::=
9638
+ // “-” | “?” | “:” | “,” | “[” | “]” | “{” | “}”
9639
+ c !== CHAR_MINUS && c !== CHAR_QUESTION && c !== CHAR_COLON && c !== CHAR_COMMA && c !== CHAR_LEFT_SQUARE_BRACKET && c !== CHAR_RIGHT_SQUARE_BRACKET && c !== CHAR_LEFT_CURLY_BRACKET && c !== CHAR_RIGHT_CURLY_BRACKET && // | “#” | “&” | “*” | “!” | “|” | “=” | “>” | “'” | “"”
9640
+ c !== CHAR_SHARP && c !== CHAR_AMPERSAND && c !== CHAR_ASTERISK && c !== CHAR_EXCLAMATION && c !== CHAR_VERTICAL_LINE && c !== CHAR_EQUALS && c !== CHAR_GREATER_THAN && c !== CHAR_SINGLE_QUOTE && c !== CHAR_DOUBLE_QUOTE && // | “%” | “@” | “`”)
9641
+ c !== CHAR_PERCENT && c !== CHAR_COMMERCIAL_AT && c !== CHAR_GRAVE_ACCENT;
9642
+ }
9643
+ function isPlainSafeLast(c) {
9644
+ return !isWhitespace(c) && c !== CHAR_COLON;
9645
+ }
9646
+ function codePointAt(string, pos) {
9647
+ const first = string.charCodeAt(pos);
9648
+ let second;
9649
+ if (first >= 55296 && first <= 56319 && pos + 1 < string.length) {
9650
+ second = string.charCodeAt(pos + 1);
9651
+ if (second >= 56320 && second <= 57343) {
9652
+ return (first - 55296) * 1024 + second - 56320 + 65536;
9653
+ }
9654
+ }
9655
+ return first;
9656
+ }
9657
+ function needIndentIndicator(string) {
9658
+ const leadingSpaceRe = /^\n* /;
9659
+ return leadingSpaceRe.test(string);
9660
+ }
9661
+ const STYLE_PLAIN = 1;
9662
+ const STYLE_SINGLE = 2;
9663
+ const STYLE_LITERAL = 3;
9664
+ const STYLE_FOLDED = 4;
9665
+ const STYLE_DOUBLE = 5;
9666
+ function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, testAmbiguousType, quotingType, forceQuotes, inblock) {
9667
+ let i;
9668
+ let char = 0;
9669
+ let prevChar = null;
9670
+ let hasLineBreak = false;
9671
+ let hasFoldableLine = false;
9672
+ const shouldTrackWidth = lineWidth !== -1;
9673
+ let previousLineBreak = -1;
9674
+ let plain = isPlainSafeFirst(codePointAt(string, 0)) && isPlainSafeLast(codePointAt(string, string.length - 1));
9675
+ if (singleLineOnly || forceQuotes) {
9676
+ for (i = 0; i < string.length; char >= 65536 ? i += 2 : i++) {
9677
+ char = codePointAt(string, i);
9678
+ if (!isPrintable(char)) {
9679
+ return STYLE_DOUBLE;
9680
+ }
9681
+ plain = plain && isPlainSafe(char, prevChar, inblock);
9682
+ prevChar = char;
9683
+ }
9684
+ } else {
9685
+ for (i = 0; i < string.length; char >= 65536 ? i += 2 : i++) {
9686
+ char = codePointAt(string, i);
9687
+ if (char === CHAR_LINE_FEED) {
9688
+ hasLineBreak = true;
9689
+ if (shouldTrackWidth) {
9690
+ hasFoldableLine = hasFoldableLine || // Foldable line = too long, and not more-indented.
9691
+ i - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== " ";
9692
+ previousLineBreak = i;
9693
+ }
9694
+ } else if (!isPrintable(char)) {
9695
+ return STYLE_DOUBLE;
9696
+ }
9697
+ plain = plain && isPlainSafe(char, prevChar, inblock);
9698
+ prevChar = char;
9699
+ }
9700
+ hasFoldableLine = hasFoldableLine || shouldTrackWidth && (i - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== " ");
9701
+ }
9702
+ if (!hasLineBreak && !hasFoldableLine) {
9703
+ if (plain && !forceQuotes && !testAmbiguousType(string)) {
9704
+ return STYLE_PLAIN;
9705
+ }
9706
+ return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE;
9707
+ }
9708
+ if (indentPerLevel > 9 && needIndentIndicator(string)) {
9709
+ return STYLE_DOUBLE;
9710
+ }
9711
+ if (!forceQuotes) {
9712
+ return hasFoldableLine ? STYLE_FOLDED : STYLE_LITERAL;
9713
+ }
9714
+ return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE;
9715
+ }
9716
+ function writeScalar(state, string, level, iskey, inblock) {
9717
+ state.dump = (function() {
9718
+ if (string.length === 0) {
9719
+ return state.quotingType === QUOTING_TYPE_DOUBLE ? '""' : "''";
9720
+ }
9721
+ if (!state.noCompatMode) {
9722
+ if (DEPRECATED_BOOLEANS_SYNTAX.indexOf(string) !== -1 || DEPRECATED_BASE60_SYNTAX.test(string)) {
9723
+ return state.quotingType === QUOTING_TYPE_DOUBLE ? '"' + string + '"' : "'" + string + "'";
9724
+ }
9725
+ }
9726
+ const indent = state.indent * Math.max(1, level);
9727
+ const lineWidth = state.lineWidth === -1 ? -1 : Math.max(Math.min(state.lineWidth, 40), state.lineWidth - indent);
9728
+ const singleLineOnly = iskey || // No block styles in flow mode.
9729
+ state.flowLevel > -1 && level >= state.flowLevel;
9730
+ function testAmbiguity(string2) {
9731
+ return testImplicitResolving(state, string2);
9732
+ }
9733
+ switch (chooseScalarStyle(
9734
+ string,
9735
+ singleLineOnly,
9736
+ state.indent,
9737
+ lineWidth,
9738
+ testAmbiguity,
9739
+ state.quotingType,
9740
+ state.forceQuotes && !iskey,
9741
+ inblock
9742
+ )) {
9743
+ case STYLE_PLAIN:
9744
+ return string;
9745
+ case STYLE_SINGLE:
9746
+ return "'" + string.replace(/'/g, "''") + "'";
9747
+ case STYLE_LITERAL:
9748
+ return "|" + blockHeader(string, state.indent) + dropEndingNewline(indentString(string, indent));
9749
+ case STYLE_FOLDED:
9750
+ return ">" + blockHeader(string, state.indent) + dropEndingNewline(indentString(foldString(string, lineWidth), indent));
9751
+ case STYLE_DOUBLE:
9752
+ return '"' + escapeString(string) + '"';
9753
+ default:
9754
+ throw new YAMLException2("impossible error: invalid scalar style");
9755
+ }
9756
+ })();
9757
+ }
9758
+ function blockHeader(string, indentPerLevel) {
9759
+ const indentIndicator = needIndentIndicator(string) ? String(indentPerLevel) : "";
9760
+ const clip = string[string.length - 1] === "\n";
9761
+ const keep = clip && (string[string.length - 2] === "\n" || string === "\n");
9762
+ const chomp = keep ? "+" : clip ? "" : "-";
9763
+ return indentIndicator + chomp + "\n";
9764
+ }
9765
+ function dropEndingNewline(string) {
9766
+ return string[string.length - 1] === "\n" ? string.slice(0, -1) : string;
9767
+ }
9768
+ function foldString(string, width) {
9769
+ const lineRe = /(\n+)([^\n]*)/g;
9770
+ let result = (function() {
9771
+ let nextLF = string.indexOf("\n");
9772
+ nextLF = nextLF !== -1 ? nextLF : string.length;
9773
+ lineRe.lastIndex = nextLF;
9774
+ return foldLine(string.slice(0, nextLF), width);
9775
+ })();
9776
+ let prevMoreIndented = string[0] === "\n" || string[0] === " ";
9777
+ let moreIndented;
9778
+ let match;
9779
+ while (match = lineRe.exec(string)) {
9780
+ const prefix = match[1];
9781
+ const line = match[2];
9782
+ moreIndented = line[0] === " ";
9783
+ result += prefix + (!prevMoreIndented && !moreIndented && line !== "" ? "\n" : "") + foldLine(line, width);
9784
+ prevMoreIndented = moreIndented;
9785
+ }
9786
+ return result;
9787
+ }
9788
+ function foldLine(line, width) {
9789
+ if (line === "" || line[0] === " ") return line;
9790
+ const breakRe = / [^ ]/g;
9791
+ let match;
9792
+ let start = 0;
9793
+ let end;
9794
+ let curr = 0;
9795
+ let next = 0;
9796
+ let result = "";
9797
+ while (match = breakRe.exec(line)) {
9798
+ next = match.index;
9799
+ if (next - start > width) {
9800
+ end = curr > start ? curr : next;
9801
+ result += "\n" + line.slice(start, end);
9802
+ start = end + 1;
9803
+ }
9804
+ curr = next;
9805
+ }
9806
+ result += "\n";
9807
+ if (line.length - start > width && curr > start) {
9808
+ result += line.slice(start, curr) + "\n" + line.slice(curr + 1);
9809
+ } else {
9810
+ result += line.slice(start);
9811
+ }
9812
+ return result.slice(1);
9813
+ }
9814
+ function escapeString(string) {
9815
+ let result = "";
9816
+ let char = 0;
9817
+ for (let i = 0; i < string.length; char >= 65536 ? i += 2 : i++) {
9818
+ char = codePointAt(string, i);
9819
+ const escapeSeq = ESCAPE_SEQUENCES[char];
9820
+ if (!escapeSeq && isPrintable(char)) {
9821
+ result += string[i];
9822
+ if (char >= 65536) result += string[i + 1];
9823
+ } else {
9824
+ result += escapeSeq || encodeHex(char);
9825
+ }
9826
+ }
9827
+ return result;
9828
+ }
9829
+ function writeFlowSequence(state, level, object) {
9830
+ let _result = "";
9831
+ const _tag = state.tag;
9832
+ for (let index = 0, length = object.length; index < length; index += 1) {
9833
+ let value = object[index];
9834
+ if (state.replacer) {
9835
+ value = state.replacer.call(object, String(index), value);
9836
+ }
9837
+ if (writeNode(state, level, value, false, false) || typeof value === "undefined" && writeNode(state, level, null, false, false)) {
9838
+ if (_result !== "") _result += "," + (!state.condenseFlow ? " " : "");
9839
+ _result += state.dump;
9840
+ }
9841
+ }
9842
+ state.tag = _tag;
9843
+ state.dump = "[" + _result + "]";
9844
+ }
9845
+ function writeBlockSequence(state, level, object, compact) {
9846
+ let _result = "";
9847
+ const _tag = state.tag;
9848
+ for (let index = 0, length = object.length; index < length; index += 1) {
9849
+ let value = object[index];
9850
+ if (state.replacer) {
9851
+ value = state.replacer.call(object, String(index), value);
9852
+ }
9853
+ if (writeNode(state, level + 1, value, true, true, false, true) || typeof value === "undefined" && writeNode(state, level + 1, null, true, true, false, true)) {
9854
+ if (!compact || _result !== "") {
9855
+ _result += generateNextLine(state, level);
9856
+ }
9857
+ if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
9858
+ _result += "-";
9859
+ } else {
9860
+ _result += "- ";
9861
+ }
9862
+ _result += state.dump;
9863
+ }
9864
+ }
9865
+ state.tag = _tag;
9866
+ state.dump = _result || "[]";
9867
+ }
9868
+ function writeFlowMapping(state, level, object) {
9869
+ let _result = "";
9870
+ const _tag = state.tag;
9871
+ const objectKeyList = Object.keys(object);
9872
+ for (let index = 0, length = objectKeyList.length; index < length; index += 1) {
9873
+ let pairBuffer = "";
9874
+ if (_result !== "") pairBuffer += ", ";
9875
+ if (state.condenseFlow) pairBuffer += '"';
9876
+ const objectKey = objectKeyList[index];
9877
+ let objectValue = object[objectKey];
9878
+ if (state.replacer) {
9879
+ objectValue = state.replacer.call(object, objectKey, objectValue);
9880
+ }
9881
+ if (!writeNode(state, level, objectKey, false, false)) {
9882
+ continue;
9883
+ }
9884
+ if (state.dump.length > 1024) pairBuffer += "? ";
9885
+ pairBuffer += state.dump + (state.condenseFlow ? '"' : "") + ":" + (state.condenseFlow ? "" : " ");
9886
+ if (!writeNode(state, level, objectValue, false, false)) {
9887
+ continue;
9888
+ }
9889
+ pairBuffer += state.dump;
9890
+ _result += pairBuffer;
9891
+ }
9892
+ state.tag = _tag;
9893
+ state.dump = "{" + _result + "}";
9894
+ }
9895
+ function writeBlockMapping(state, level, object, compact) {
9896
+ let _result = "";
9897
+ const _tag = state.tag;
9898
+ const objectKeyList = Object.keys(object);
9899
+ if (state.sortKeys === true) {
9900
+ objectKeyList.sort();
9901
+ } else if (typeof state.sortKeys === "function") {
9902
+ objectKeyList.sort(state.sortKeys);
9903
+ } else if (state.sortKeys) {
9904
+ throw new YAMLException2("sortKeys must be a boolean or a function");
9905
+ }
9906
+ for (let index = 0, length = objectKeyList.length; index < length; index += 1) {
9907
+ let pairBuffer = "";
9908
+ if (!compact || _result !== "") {
9909
+ pairBuffer += generateNextLine(state, level);
9910
+ }
9911
+ const objectKey = objectKeyList[index];
9912
+ let objectValue = object[objectKey];
9913
+ if (state.replacer) {
9914
+ objectValue = state.replacer.call(object, objectKey, objectValue);
9915
+ }
9916
+ if (!writeNode(state, level + 1, objectKey, true, true, true)) {
9917
+ continue;
9918
+ }
9919
+ const explicitPair = state.tag !== null && state.tag !== "?" || state.dump && state.dump.length > 1024;
9920
+ if (explicitPair) {
9921
+ if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
9922
+ pairBuffer += "?";
9923
+ } else {
9924
+ pairBuffer += "? ";
9925
+ }
9926
+ }
9927
+ pairBuffer += state.dump;
9928
+ if (explicitPair) {
9929
+ pairBuffer += generateNextLine(state, level);
9930
+ }
9931
+ if (!writeNode(state, level + 1, objectValue, true, explicitPair)) {
9932
+ continue;
9933
+ }
9934
+ if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
9935
+ pairBuffer += ":";
9936
+ } else {
9937
+ pairBuffer += ": ";
9938
+ }
9939
+ pairBuffer += state.dump;
9940
+ _result += pairBuffer;
9941
+ }
9942
+ state.tag = _tag;
9943
+ state.dump = _result || "{}";
9944
+ }
9945
+ function detectType(state, object, explicit) {
9946
+ const typeList = explicit ? state.explicitTypes : state.implicitTypes;
9947
+ for (let index = 0, length = typeList.length; index < length; index += 1) {
9948
+ const type2 = typeList[index];
9949
+ if ((type2.instanceOf || type2.predicate) && (!type2.instanceOf || typeof object === "object" && object instanceof type2.instanceOf) && (!type2.predicate || type2.predicate(object))) {
9950
+ if (explicit) {
9951
+ if (type2.multi && type2.representName) {
9952
+ state.tag = type2.representName(object);
9953
+ } else {
9954
+ state.tag = type2.tag;
9955
+ }
9956
+ } else {
9957
+ state.tag = "?";
9958
+ }
9959
+ if (type2.represent) {
9960
+ const style = state.styleMap[type2.tag] || type2.defaultStyle;
9961
+ let _result;
9962
+ if (_toString.call(type2.represent) === "[object Function]") {
9963
+ _result = type2.represent(object, style);
9964
+ } else if (_hasOwnProperty.call(type2.represent, style)) {
9965
+ _result = type2.represent[style](object, style);
9966
+ } else {
9967
+ throw new YAMLException2("!<" + type2.tag + '> tag resolver accepts not "' + style + '" style');
9968
+ }
9969
+ state.dump = _result;
9970
+ }
9971
+ return true;
9972
+ }
9973
+ }
9974
+ return false;
9975
+ }
9976
+ function writeNode(state, level, object, block, compact, iskey, isblockseq) {
9977
+ state.tag = null;
9978
+ state.dump = object;
9979
+ if (!detectType(state, object, false)) {
9980
+ detectType(state, object, true);
9981
+ }
9982
+ const type2 = _toString.call(state.dump);
9983
+ const inblock = block;
9984
+ if (block) {
9985
+ block = state.flowLevel < 0 || state.flowLevel > level;
9986
+ }
9987
+ const objectOrArray = type2 === "[object Object]" || type2 === "[object Array]";
9988
+ let duplicateIndex;
9989
+ let duplicate;
9990
+ if (objectOrArray) {
9991
+ duplicateIndex = state.duplicates.indexOf(object);
9992
+ duplicate = duplicateIndex !== -1;
9993
+ }
9994
+ if (state.tag !== null && state.tag !== "?" || duplicate || state.indent !== 2 && level > 0) {
9995
+ compact = false;
9996
+ }
9997
+ if (duplicate && state.usedDuplicates[duplicateIndex]) {
9998
+ state.dump = "*ref_" + duplicateIndex;
9999
+ } else {
10000
+ if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex]) {
10001
+ state.usedDuplicates[duplicateIndex] = true;
10002
+ }
10003
+ if (type2 === "[object Object]") {
10004
+ if (block && Object.keys(state.dump).length !== 0) {
10005
+ writeBlockMapping(state, level, state.dump, compact);
10006
+ if (duplicate) {
10007
+ state.dump = "&ref_" + duplicateIndex + state.dump;
10008
+ }
10009
+ } else {
10010
+ writeFlowMapping(state, level, state.dump);
10011
+ if (duplicate) {
10012
+ state.dump = "&ref_" + duplicateIndex + " " + state.dump;
10013
+ }
10014
+ }
10015
+ } else if (type2 === "[object Array]") {
10016
+ if (block && state.dump.length !== 0) {
10017
+ if (state.noArrayIndent && !isblockseq && level > 0) {
10018
+ writeBlockSequence(state, level - 1, state.dump, compact);
10019
+ } else {
10020
+ writeBlockSequence(state, level, state.dump, compact);
10021
+ }
10022
+ if (duplicate) {
10023
+ state.dump = "&ref_" + duplicateIndex + state.dump;
10024
+ }
10025
+ } else {
10026
+ writeFlowSequence(state, level, state.dump);
10027
+ if (duplicate) {
10028
+ state.dump = "&ref_" + duplicateIndex + " " + state.dump;
10029
+ }
10030
+ }
10031
+ } else if (type2 === "[object String]") {
10032
+ if (state.tag !== "?") {
10033
+ writeScalar(state, state.dump, level, iskey, inblock);
10034
+ }
10035
+ } else if (type2 === "[object Undefined]") {
10036
+ return false;
10037
+ } else {
10038
+ if (state.skipInvalid) return false;
10039
+ throw new YAMLException2("unacceptable kind of an object to dump " + type2);
10040
+ }
10041
+ if (state.tag !== null && state.tag !== "?") {
10042
+ let tagStr = encodeURI(
10043
+ state.tag[0] === "!" ? state.tag.slice(1) : state.tag
10044
+ ).replace(/!/g, "%21");
10045
+ if (state.tag[0] === "!") {
10046
+ tagStr = "!" + tagStr;
10047
+ } else if (tagStr.slice(0, 18) === "tag:yaml.org,2002:") {
10048
+ tagStr = "!!" + tagStr.slice(18);
10049
+ } else {
10050
+ tagStr = "!<" + tagStr + ">";
10051
+ }
10052
+ state.dump = tagStr + " " + state.dump;
10053
+ }
10054
+ }
10055
+ return true;
10056
+ }
10057
+ function getDuplicateReferences(object, state) {
10058
+ const objects = [];
10059
+ const duplicatesIndexes = [];
10060
+ inspectNode(object, objects, duplicatesIndexes);
10061
+ const length = duplicatesIndexes.length;
10062
+ for (let index = 0; index < length; index += 1) {
10063
+ state.duplicates.push(objects[duplicatesIndexes[index]]);
10064
+ }
10065
+ state.usedDuplicates = new Array(length);
10066
+ }
10067
+ function inspectNode(object, objects, duplicatesIndexes) {
10068
+ if (object !== null && typeof object === "object") {
10069
+ const index = objects.indexOf(object);
10070
+ if (index !== -1) {
10071
+ if (duplicatesIndexes.indexOf(index) === -1) {
10072
+ duplicatesIndexes.push(index);
10073
+ }
10074
+ } else {
10075
+ objects.push(object);
10076
+ if (Array.isArray(object)) {
10077
+ for (let i = 0, length = object.length; i < length; i += 1) {
10078
+ inspectNode(object[i], objects, duplicatesIndexes);
10079
+ }
10080
+ } else {
10081
+ const objectKeyList = Object.keys(object);
10082
+ for (let i = 0, length = objectKeyList.length; i < length; i += 1) {
10083
+ inspectNode(object[objectKeyList[i]], objects, duplicatesIndexes);
10084
+ }
10085
+ }
10086
+ }
10087
+ }
10088
+ }
10089
+ function dump2(input, options) {
10090
+ options = options || {};
10091
+ const state = new State(options);
10092
+ if (!state.noRefs) getDuplicateReferences(input, state);
10093
+ let value = input;
10094
+ if (state.replacer) {
10095
+ value = state.replacer.call({ "": value }, "", value);
10096
+ }
10097
+ if (writeNode(state, 0, value, true, true)) return state.dump + "\n";
10098
+ return "";
10099
+ }
10100
+ dumper.dump = dump2;
10101
+ return dumper;
10102
+ }
10103
+ var hasRequiredJsYaml;
10104
+ function requireJsYaml() {
10105
+ if (hasRequiredJsYaml) return jsYaml;
10106
+ hasRequiredJsYaml = 1;
10107
+ const loader2 = requireLoader();
10108
+ const dumper2 = requireDumper();
10109
+ function renamed(from, to) {
10110
+ return function() {
10111
+ throw new Error("Function yaml." + from + " is removed in js-yaml 4. Use yaml." + to + " instead, which is now safe by default.");
10112
+ };
10113
+ }
10114
+ jsYaml.Type = requireType();
10115
+ jsYaml.Schema = requireSchema();
10116
+ jsYaml.FAILSAFE_SCHEMA = requireFailsafe();
10117
+ jsYaml.JSON_SCHEMA = requireJson();
10118
+ jsYaml.CORE_SCHEMA = requireCore();
10119
+ jsYaml.DEFAULT_SCHEMA = require_default();
10120
+ jsYaml.load = loader2.load;
10121
+ jsYaml.loadAll = loader2.loadAll;
10122
+ jsYaml.dump = dumper2.dump;
10123
+ jsYaml.YAMLException = requireException();
10124
+ jsYaml.types = {
10125
+ binary: requireBinary(),
10126
+ float: requireFloat(),
10127
+ map: requireMap(),
10128
+ null: require_null(),
10129
+ pairs: requirePairs(),
10130
+ set: requireSet(),
10131
+ timestamp: requireTimestamp(),
10132
+ bool: requireBool(),
10133
+ int: requireInt(),
10134
+ merge: requireMerge(),
10135
+ omap: requireOmap(),
10136
+ seq: requireSeq(),
10137
+ str: requireStr()
10138
+ };
10139
+ jsYaml.safeLoad = renamed("safeLoad", "load");
10140
+ jsYaml.safeLoadAll = renamed("safeLoadAll", "loadAll");
10141
+ jsYaml.safeDump = renamed("safeDump", "dump");
10142
+ return jsYaml;
10143
+ }
10144
+ var jsYamlExports = requireJsYaml();
10145
+ var yaml = /* @__PURE__ */ getDefaultExportFromCjs(jsYamlExports);
10146
+ var {
10147
+ Type,
10148
+ Schema,
10149
+ FAILSAFE_SCHEMA,
10150
+ JSON_SCHEMA,
10151
+ CORE_SCHEMA,
10152
+ DEFAULT_SCHEMA,
10153
+ load,
10154
+ loadAll,
10155
+ dump,
10156
+ YAMLException,
10157
+ types,
10158
+ safeLoad,
10159
+ safeLoadAll,
10160
+ safeDump
10161
+ } = yaml;
10162
+
10163
+ // src/local-evaluator/schema.ts
10164
+ function validatePolicy(policy) {
10165
+ const errors = [];
10166
+ if (!policy || typeof policy !== "object") {
10167
+ return { valid: false, errors: [{ path: "", message: "Policy must be an object" }] };
10168
+ }
10169
+ const p = policy;
10170
+ if (typeof p.version !== "string") {
10171
+ errors.push({ path: "version", message: "version is required and must be a string" });
10172
+ }
10173
+ if (typeof p.name !== "string") {
10174
+ errors.push({ path: "name", message: "name is required and must be a string" });
10175
+ }
10176
+ if (!Array.isArray(p.purposes)) {
10177
+ errors.push({ path: "purposes", message: "purposes is required and must be an array" });
10178
+ } else {
10179
+ p.purposes.forEach((purpose, i) => {
10180
+ errors.push(...validatePurpose(purpose, `purposes[${i}]`));
10181
+ });
10182
+ }
10183
+ if (p.scope !== void 0) {
10184
+ errors.push(...validateScope(p.scope, "scope"));
10185
+ }
10186
+ if (p.limits !== void 0) {
10187
+ errors.push(...validateLimits(p.limits, "limits"));
10188
+ }
10189
+ if (p.riskThresholds !== void 0) {
10190
+ errors.push(...validateRiskThresholds(p.riskThresholds, "riskThresholds"));
10191
+ }
10192
+ return { valid: errors.length === 0, errors };
10193
+ }
10194
+ function validatePurpose(purpose, path) {
10195
+ const errors = [];
10196
+ if (!purpose || typeof purpose !== "object") {
10197
+ return [{ path, message: "purpose must be an object" }];
10198
+ }
10199
+ const p = purpose;
10200
+ if (typeof p.id !== "string" || !p.id) {
10201
+ errors.push({ path: `${path}.id`, message: "id is required and must be a non-empty string" });
10202
+ }
10203
+ if (typeof p.allowed !== "boolean") {
10204
+ errors.push({ path: `${path}.allowed`, message: "allowed is required and must be a boolean" });
10205
+ }
10206
+ if (p.targets !== void 0 && !isStringArray(p.targets)) {
10207
+ errors.push({ path: `${path}.targets`, message: "targets must be an array of strings" });
10208
+ }
10209
+ if (p.blockedPatterns !== void 0 && !isStringArray(p.blockedPatterns)) {
10210
+ errors.push({
10211
+ path: `${path}.blockedPatterns`,
10212
+ message: "blockedPatterns must be an array of strings"
10213
+ });
10214
+ }
10215
+ if (p.requiresApproval !== void 0 && typeof p.requiresApproval !== "boolean") {
10216
+ errors.push({
10217
+ path: `${path}.requiresApproval`,
10218
+ message: "requiresApproval must be a boolean"
10219
+ });
10220
+ }
10221
+ return errors;
10222
+ }
10223
+ function validateScope(scope, path) {
10224
+ const errors = [];
10225
+ if (typeof scope !== "object" || scope === null) {
10226
+ return [{ path, message: "scope must be an object" }];
10227
+ }
10228
+ const s = scope;
10229
+ for (const field of ["allowedDomains", "blockedDomains", "blockedResources"]) {
10230
+ if (s[field] !== void 0 && !isStringArray(s[field])) {
10231
+ errors.push({ path: `${path}.${field}`, message: `${field} must be an array of strings` });
10232
+ }
10233
+ }
10234
+ return errors;
10235
+ }
10236
+ function validateLimits(limits, path) {
10237
+ const errors = [];
10238
+ if (typeof limits !== "object" || limits === null) {
10239
+ return [{ path, message: "limits must be an object" }];
10240
+ }
10241
+ const l = limits;
10242
+ if (l.autonomousThreshold !== void 0 && typeof l.autonomousThreshold !== "number") {
10243
+ errors.push({
10244
+ path: `${path}.autonomousThreshold`,
10245
+ message: "autonomousThreshold must be a number"
10246
+ });
10247
+ }
10248
+ if (l.maxTransactionAmount !== void 0 && typeof l.maxTransactionAmount !== "number") {
10249
+ errors.push({
10250
+ path: `${path}.maxTransactionAmount`,
10251
+ message: "maxTransactionAmount must be a number"
10252
+ });
10253
+ }
10254
+ if (typeof l.autonomousThreshold === "number" && typeof l.maxTransactionAmount === "number" && l.autonomousThreshold > l.maxTransactionAmount) {
10255
+ errors.push({
10256
+ path: `${path}.autonomousThreshold`,
10257
+ message: "autonomousThreshold (Autonomous Limit) must be <= maxTransactionAmount (Hard Limit)"
10258
+ });
10259
+ }
10260
+ if (l.maxRequestsPerHour !== void 0 && typeof l.maxRequestsPerHour !== "number") {
10261
+ errors.push({
10262
+ path: `${path}.maxRequestsPerHour`,
10263
+ message: "maxRequestsPerHour must be a number"
10264
+ });
10265
+ }
10266
+ if (l.currency !== void 0 && typeof l.currency !== "string") {
10267
+ errors.push({ path: `${path}.currency`, message: "currency must be a string" });
10268
+ }
10269
+ return errors;
10270
+ }
10271
+ function validateRiskThresholds(thresholds, path) {
10272
+ const errors = [];
10273
+ if (typeof thresholds !== "object" || thresholds === null) {
10274
+ return [{ path, message: "riskThresholds must be an object" }];
10275
+ }
10276
+ const t = thresholds;
10277
+ for (const range of ["autoAllow", "requireApproval", "autoBlock"]) {
10278
+ if (!t[range] || typeof t[range] !== "object") {
10279
+ errors.push({
10280
+ path: `${path}.${range}`,
10281
+ message: `${range} is required and must be an object with min and max`
10282
+ });
10283
+ continue;
10284
+ }
10285
+ const r = t[range];
10286
+ if (typeof r.min !== "number" || typeof r.max !== "number") {
10287
+ errors.push({ path: `${path}.${range}`, message: `${range} must have numeric min and max` });
10288
+ } else if (r.min > r.max) {
10289
+ errors.push({ path: `${path}.${range}`, message: `${range}.min must be <= ${range}.max` });
10290
+ }
10291
+ }
10292
+ if (isValidThresholdShape(t)) {
10293
+ const thresholdObj = t;
10294
+ if (thresholdObj.autoAllow.max + 1 !== thresholdObj.requireApproval.min) {
10295
+ errors.push({
10296
+ path: `${path}`,
10297
+ message: `Gap between autoAllow.max (${thresholdObj.autoAllow.max}) and requireApproval.min (${thresholdObj.requireApproval.min}). Ranges must be contiguous.`
10298
+ });
10299
+ }
10300
+ if (thresholdObj.requireApproval.max + 1 !== thresholdObj.autoBlock.min) {
10301
+ errors.push({
10302
+ path: `${path}`,
10303
+ message: `Gap between requireApproval.max (${thresholdObj.requireApproval.max}) and autoBlock.min (${thresholdObj.autoBlock.min}). Ranges must be contiguous.`
10304
+ });
10305
+ }
10306
+ }
10307
+ return errors;
10308
+ }
10309
+ function isStringArray(val) {
10310
+ return Array.isArray(val) && val.every((v) => typeof v === "string");
10311
+ }
10312
+ function isValidThresholdShape(t) {
10313
+ for (const key of ["autoAllow", "requireApproval", "autoBlock"]) {
10314
+ const r = t[key];
10315
+ if (!r || typeof r !== "object") return false;
10316
+ const range = r;
10317
+ if (typeof range.min !== "number" || typeof range.max !== "number") return false;
10318
+ }
10319
+ return true;
10320
+ }
10321
+
10322
+ // src/local-evaluator/pdlss-parser.ts
10323
+ function parseYaml(yamlContent) {
10324
+ let parsed;
10325
+ try {
10326
+ parsed = load(yamlContent);
10327
+ } catch (err) {
10328
+ const message = err instanceof Error ? err.message : "Invalid YAML";
10329
+ return {
10330
+ policy: null,
10331
+ validation: { valid: false, errors: [{ path: "", message: `YAML parse error: ${message}` }] },
10332
+ rawYaml: yamlContent
10333
+ };
10334
+ }
10335
+ const validation = validatePolicy(parsed);
10336
+ if (!validation.valid) {
10337
+ return { policy: null, validation, rawYaml: yamlContent };
10338
+ }
10339
+ return {
10340
+ policy: parsed,
10341
+ validation,
10342
+ rawYaml: yamlContent
10343
+ };
10344
+ }
6677
10345
  // Annotate the CommonJS export names for ESM import in node:
6678
10346
  0 && (module.exports = {
6679
10347
  AgentClient,
@@ -6697,6 +10365,7 @@ function detectRuntime(userAgent) {
6697
10365
  RegistrationTimeoutError,
6698
10366
  SDK_USER_AGENT,
6699
10367
  TRUST_LEVEL_RANGES,
10368
+ VERIFICATION_STATUS_HEADER,
6700
10369
  VERSION,
6701
10370
  _resetEdgeConfigCache,
6702
10371
  agent,
@@ -6704,9 +10373,11 @@ function detectRuntime(userAgent) {
6704
10373
  awaitStepUpApproval,
6705
10374
  buildGuidance,
6706
10375
  buildSdkObservedMetadata,
10376
+ buildVerificationUnavailableBody,
6707
10377
  clearCache,
6708
10378
  createMcpMiddleware,
6709
10379
  degradeToObserve,
10380
+ denyStatusFor,
6710
10381
  deriveConnectionFromHeaders,
6711
10382
  detectPlatformFingerprint,
6712
10383
  detectRuntime,
@@ -6723,11 +10394,14 @@ function detectRuntime(userAgent) {
6723
10394
  getWellKnownUrls,
6724
10395
  hasCredentials,
6725
10396
  isEdgeConfig,
10397
+ isRejectedIdentityClaim,
10398
+ isVerificationUnavailable,
6726
10399
  isVerifiedHopValidFor,
6727
10400
  matchEdgePathRule,
6728
10401
  matchPlatformSignature,
6729
10402
  nextjs,
6730
10403
  normalizeDeclaredSource,
10404
+ parseLocalPolicyYaml,
6731
10405
  parseVerifiedHop,
6732
10406
  pollStepUpStatus,
6733
10407
  prefetchWellKnown,
@@ -6741,6 +10415,8 @@ function detectRuntime(userAgent) {
6741
10415
  serializeVerifiedHop,
6742
10416
  setMcpMeta,
6743
10417
  transport,
10418
+ unavailableRetryAfterSeconds,
10419
+ validateLocalPolicy,
6744
10420
  verify
6745
10421
  });
6746
10422
  //# sourceMappingURL=index.js.map