@bleedingdev/modern-js-server-runtime-extensions 3.5.0-ultramodern.6 → 3.5.0-ultramodern.76

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 (179) hide show
  1. package/dist/cjs/contract-gate-snapshot-normalization.js +122 -0
  2. package/dist/cjs/contract-gate-snapshot-store/file-store.js +102 -0
  3. package/dist/cjs/contract-gate-snapshot-store/http-store.js +133 -0
  4. package/dist/cjs/contract-gate-snapshot-store/index.js +58 -0
  5. package/dist/cjs/contract-gate-snapshot-store/resolve.js +124 -0
  6. package/dist/cjs/contract-gate-snapshot-store/types.js +44 -0
  7. package/dist/cjs/contractGateAutopilot.js +22 -70
  8. package/dist/cjs/index.js +6 -25
  9. package/dist/cjs/mfCache.js +2 -2
  10. package/dist/cjs/module-federation-css/collector.js +79 -0
  11. package/dist/cjs/module-federation-css/index.js +55 -0
  12. package/dist/cjs/module-federation-css/manifest.js +129 -0
  13. package/dist/cjs/module-federation-css/plugin.js +71 -0
  14. package/dist/cjs/module-federation-css/remote.js +133 -0
  15. package/dist/cjs/runtime-fallback-signal/index.js +93 -0
  16. package/dist/cjs/runtime-fallback-signal/model.js +157 -0
  17. package/dist/cjs/runtime-fallback-signal/resolver.js +163 -0
  18. package/dist/cjs/runtime-fallback-signal/store.js +83 -0
  19. package/dist/cjs/runtimeFallbackSignal.js +32 -281
  20. package/dist/cjs/telemetry/canary.js +180 -0
  21. package/dist/cjs/telemetry/canaryEvaluation.js +79 -0
  22. package/dist/cjs/telemetry/canarySetup.js +107 -0
  23. package/dist/cjs/telemetry/envelope.js +223 -0
  24. package/dist/cjs/telemetry/exporters.js +148 -0
  25. package/dist/cjs/telemetry/lifecycle.js +98 -0
  26. package/dist/cjs/telemetry/metrics.js +115 -0
  27. package/dist/cjs/telemetry/plugin.js +185 -0
  28. package/dist/cjs/telemetry/registry.js +296 -0
  29. package/dist/cjs/telemetry/registryTypes.js +46 -0
  30. package/dist/cjs/telemetry/runtimeEndpoints.js +135 -0
  31. package/dist/cjs/telemetry.js +32 -343
  32. package/dist/cjs/telemetryCore.js +14 -767
  33. package/dist/esm/contract-gate-snapshot-normalization.mjs +81 -0
  34. package/dist/esm/contract-gate-snapshot-store/file-store.mjs +51 -0
  35. package/dist/esm/contract-gate-snapshot-store/http-store.mjs +92 -0
  36. package/dist/esm/contract-gate-snapshot-store/index.mjs +4 -0
  37. package/dist/esm/contract-gate-snapshot-store/resolve.mjs +70 -0
  38. package/dist/esm/contract-gate-snapshot-store/types.mjs +3 -0
  39. package/dist/esm/contractGateAutopilot.mjs +21 -69
  40. package/dist/esm/index.mjs +1 -2
  41. package/dist/esm/mfCache.mjs +2 -2
  42. package/dist/esm/module-federation-css/collector.mjs +38 -0
  43. package/dist/esm/module-federation-css/index.mjs +4 -0
  44. package/dist/esm/module-federation-css/manifest.mjs +69 -0
  45. package/dist/esm/module-federation-css/plugin.mjs +33 -0
  46. package/dist/esm/module-federation-css/remote.mjs +92 -0
  47. package/dist/esm/runtime-fallback-signal/index.mjs +3 -0
  48. package/dist/esm/runtime-fallback-signal/model.mjs +73 -0
  49. package/dist/esm/runtime-fallback-signal/resolver.mjs +107 -0
  50. package/dist/esm/runtime-fallback-signal/store.mjs +39 -0
  51. package/dist/esm/runtimeFallbackSignal.mjs +1 -222
  52. package/dist/esm/telemetry/canary.mjs +142 -0
  53. package/dist/esm/telemetry/canaryEvaluation.mjs +41 -0
  54. package/dist/esm/telemetry/canarySetup.mjs +69 -0
  55. package/dist/esm/telemetry/envelope.mjs +164 -0
  56. package/dist/esm/telemetry/exporters.mjs +104 -0
  57. package/dist/esm/telemetry/lifecycle.mjs +60 -0
  58. package/dist/esm/telemetry/metrics.mjs +77 -0
  59. package/dist/esm/telemetry/plugin.mjs +87 -0
  60. package/dist/esm/telemetry/registry.mjs +258 -0
  61. package/dist/esm/telemetry/registryTypes.mjs +8 -0
  62. package/dist/esm/telemetry/runtimeEndpoints.mjs +94 -0
  63. package/dist/esm/telemetry.mjs +1 -275
  64. package/dist/esm/telemetryCore.mjs +6 -759
  65. package/dist/esm-node/contract-gate-snapshot-normalization.mjs +82 -0
  66. package/dist/esm-node/contract-gate-snapshot-store/file-store.mjs +52 -0
  67. package/dist/esm-node/contract-gate-snapshot-store/http-store.mjs +93 -0
  68. package/dist/esm-node/contract-gate-snapshot-store/index.mjs +5 -0
  69. package/dist/esm-node/contract-gate-snapshot-store/resolve.mjs +71 -0
  70. package/dist/esm-node/contract-gate-snapshot-store/types.mjs +4 -0
  71. package/dist/esm-node/contractGateAutopilot.mjs +21 -69
  72. package/dist/esm-node/index.mjs +1 -2
  73. package/dist/esm-node/mfCache.mjs +2 -2
  74. package/dist/esm-node/module-federation-css/collector.mjs +39 -0
  75. package/dist/esm-node/module-federation-css/index.mjs +5 -0
  76. package/dist/esm-node/module-federation-css/manifest.mjs +70 -0
  77. package/dist/esm-node/module-federation-css/plugin.mjs +34 -0
  78. package/dist/esm-node/module-federation-css/remote.mjs +93 -0
  79. package/dist/esm-node/runtime-fallback-signal/index.mjs +4 -0
  80. package/dist/esm-node/runtime-fallback-signal/model.mjs +74 -0
  81. package/dist/esm-node/runtime-fallback-signal/resolver.mjs +108 -0
  82. package/dist/esm-node/runtime-fallback-signal/store.mjs +40 -0
  83. package/dist/esm-node/runtimeFallbackSignal.mjs +1 -222
  84. package/dist/esm-node/telemetry/canary.mjs +143 -0
  85. package/dist/esm-node/telemetry/canaryEvaluation.mjs +42 -0
  86. package/dist/esm-node/telemetry/canarySetup.mjs +70 -0
  87. package/dist/esm-node/telemetry/envelope.mjs +165 -0
  88. package/dist/esm-node/telemetry/exporters.mjs +105 -0
  89. package/dist/esm-node/telemetry/lifecycle.mjs +61 -0
  90. package/dist/esm-node/telemetry/metrics.mjs +78 -0
  91. package/dist/esm-node/telemetry/plugin.mjs +88 -0
  92. package/dist/esm-node/telemetry/registry.mjs +259 -0
  93. package/dist/esm-node/telemetry/registryTypes.mjs +9 -0
  94. package/dist/esm-node/telemetry/runtimeEndpoints.mjs +95 -0
  95. package/dist/esm-node/telemetry.mjs +1 -275
  96. package/dist/esm-node/telemetryCore.mjs +6 -759
  97. package/dist/types/contract-gate-snapshot-normalization.d.ts +15 -0
  98. package/dist/types/contract-gate-snapshot-store/file-store.d.ts +3 -0
  99. package/dist/types/contract-gate-snapshot-store/http-store.d.ts +5 -0
  100. package/dist/types/contract-gate-snapshot-store/index.d.ts +5 -0
  101. package/dist/types/contract-gate-snapshot-store/resolve.d.ts +9 -0
  102. package/dist/types/{contractGateSnapshotStore.d.ts → contract-gate-snapshot-store/types.d.ts} +1 -11
  103. package/dist/types/contractGateAutopilot.d.ts +3 -6
  104. package/dist/types/index.d.ts +1 -2
  105. package/dist/types/module-federation-css/collector.d.ts +25 -0
  106. package/dist/types/module-federation-css/index.d.ts +8 -0
  107. package/dist/types/module-federation-css/manifest.d.ts +28 -0
  108. package/dist/types/module-federation-css/plugin.d.ts +23 -0
  109. package/dist/types/module-federation-css/remote.d.ts +20 -0
  110. package/dist/types/runtime-fallback-signal/index.d.ts +4 -0
  111. package/dist/types/runtime-fallback-signal/model.d.ts +70 -0
  112. package/dist/types/runtime-fallback-signal/resolver.d.ts +29 -0
  113. package/dist/types/runtime-fallback-signal/store.d.ts +4 -0
  114. package/dist/types/runtimeFallbackSignal.d.ts +1 -94
  115. package/dist/types/telemetry/canary.d.ts +85 -0
  116. package/dist/types/telemetry/canaryEvaluation.d.ts +20 -0
  117. package/dist/types/telemetry/canarySetup.d.ts +17 -0
  118. package/dist/types/telemetry/envelope.d.ts +55 -0
  119. package/dist/types/telemetry/exporters.d.ts +12 -0
  120. package/dist/types/telemetry/lifecycle.d.ts +18 -0
  121. package/dist/types/telemetry/metrics.d.ts +3 -0
  122. package/dist/types/telemetry/plugin.d.ts +12 -0
  123. package/dist/types/telemetry/registry.d.ts +69 -0
  124. package/dist/types/telemetry/registryTypes.d.ts +50 -0
  125. package/dist/types/telemetry/runtimeEndpoints.d.ts +35 -0
  126. package/dist/types/telemetry.d.ts +1 -12
  127. package/dist/types/telemetryCore.d.ts +6 -257
  128. package/package.json +11 -13
  129. package/src/contract-gate-snapshot-normalization.ts +155 -0
  130. package/src/contract-gate-snapshot-store/file-store.ts +83 -0
  131. package/src/contract-gate-snapshot-store/http-store.ts +159 -0
  132. package/src/contract-gate-snapshot-store/index.ts +20 -0
  133. package/src/contract-gate-snapshot-store/resolve.ts +179 -0
  134. package/src/contract-gate-snapshot-store/types.ts +64 -0
  135. package/src/contractGateAutopilot.ts +39 -131
  136. package/src/index.ts +1 -17
  137. package/src/mfCache.ts +3 -1
  138. package/src/module-federation-css/collector.ts +82 -0
  139. package/src/module-federation-css/index.ts +14 -0
  140. package/src/module-federation-css/manifest.ts +163 -0
  141. package/src/module-federation-css/plugin.ts +86 -0
  142. package/src/module-federation-css/remote.ts +165 -0
  143. package/src/runtime-fallback-signal/index.ts +34 -0
  144. package/src/runtime-fallback-signal/model.ts +230 -0
  145. package/src/runtime-fallback-signal/resolver.ts +304 -0
  146. package/src/runtime-fallback-signal/store.ts +78 -0
  147. package/src/runtimeFallbackSignal.ts +1 -584
  148. package/src/telemetry/canary.ts +291 -0
  149. package/src/telemetry/canaryEvaluation.ts +83 -0
  150. package/src/telemetry/canarySetup.ts +160 -0
  151. package/src/telemetry/envelope.ts +277 -0
  152. package/src/telemetry/exporters.ts +165 -0
  153. package/src/telemetry/lifecycle.ts +138 -0
  154. package/src/telemetry/metrics.ts +141 -0
  155. package/src/telemetry/plugin.ts +197 -0
  156. package/src/telemetry/registry.ts +424 -0
  157. package/src/telemetry/registryTypes.ts +63 -0
  158. package/src/telemetry/runtimeEndpoints.ts +172 -0
  159. package/src/telemetry.ts +1 -554
  160. package/src/telemetryCore.ts +34 -1332
  161. package/tests/contractGateAutopilot.test.ts +205 -0
  162. package/tests/contractGateSnapshotStore.test.ts +54 -1
  163. package/tests/helpers.ts +1 -0
  164. package/tests/moduleFederationCss.test.ts +1 -1
  165. package/tests/registration.test.ts +1 -1
  166. package/tests/telemetry.test.ts +51 -0
  167. package/tests/telemetryAutopilot.test.ts +141 -0
  168. package/tests/telemetryCanaryOrchestrator.test.ts +225 -0
  169. package/tests/telemetryLifecycle.test.ts +253 -2
  170. package/tests/telemetryRegistryQueueMatrix.test.ts +227 -0
  171. package/dist/cjs/contractGateSnapshotStore.js +0 -253
  172. package/dist/cjs/moduleFederationCss.js +0 -285
  173. package/dist/esm/contractGateSnapshotStore.mjs +0 -190
  174. package/dist/esm/moduleFederationCss.mjs +0 -225
  175. package/dist/esm-node/contractGateSnapshotStore.mjs +0 -192
  176. package/dist/esm-node/moduleFederationCss.mjs +0 -226
  177. package/dist/types/moduleFederationCss.d.ts +0 -87
  178. package/src/contractGateSnapshotStore.ts +0 -420
  179. package/src/moduleFederationCss.ts +0 -473
@@ -0,0 +1,133 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, getters, values)=>{
5
+ var define = (defs, kind)=>{
6
+ for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
7
+ enumerable: true,
8
+ [kind]: defs[key]
9
+ });
10
+ };
11
+ define(getters, "get");
12
+ define(values, "value");
13
+ };
14
+ })();
15
+ (()=>{
16
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
17
+ })();
18
+ (()=>{
19
+ __webpack_require__.r = (exports1)=>{
20
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
21
+ value: 'Module'
22
+ });
23
+ Object.defineProperty(exports1, '__esModule', {
24
+ value: true
25
+ });
26
+ };
27
+ })();
28
+ var __webpack_exports__ = {};
29
+ __webpack_require__.r(__webpack_exports__);
30
+ __webpack_require__.d(__webpack_exports__, {
31
+ collectDirectRemoteModuleFederationCss: ()=>collectDirectRemoteModuleFederationCss,
32
+ collectDirectRemoteModuleFederationCssWithMeta: ()=>collectDirectRemoteModuleFederationCssWithMeta
33
+ });
34
+ const external_manifest_js_namespaceObject = require("./manifest.js");
35
+ const DEFAULT_REMOTE_MANIFEST_TIMEOUT = 1500;
36
+ const fetchJsonWithTimeout = async (url, fetcher, timeout)=>{
37
+ const controller = new AbortController();
38
+ let timeoutId;
39
+ try {
40
+ const response = await Promise.race([
41
+ fetcher(url, {
42
+ signal: controller.signal
43
+ }),
44
+ new Promise((_, reject)=>{
45
+ timeoutId = setTimeout(()=>{
46
+ controller.abort();
47
+ reject(new Error(`Request timed out after ${timeout}ms`));
48
+ }, timeout);
49
+ })
50
+ ]);
51
+ if (!response.ok) throw new Error(`Unexpected status ${response.status}`);
52
+ return await response.json();
53
+ } finally{
54
+ if (timeoutId) clearTimeout(timeoutId);
55
+ }
56
+ };
57
+ const collectDirectRemoteModuleFederationCssWithMeta = async (pwd, options = {})=>{
58
+ const hostManifest = await (0, external_manifest_js_namespaceObject.getHostManifest)(pwd, options.monitors);
59
+ if (!hostManifest) return {
60
+ assets: [],
61
+ errored: false
62
+ };
63
+ const fetcher = options.fetcher || globalThis.fetch?.bind(globalThis);
64
+ if (!fetcher) {
65
+ (0, external_manifest_js_namespaceObject.warn)(options.monitors, 'Skip module federation remote CSS collection because fetch is unavailable.');
66
+ return {
67
+ assets: [],
68
+ errored: false
69
+ };
70
+ }
71
+ const timeout = options.timeout ?? DEFAULT_REMOTE_MANIFEST_TIMEOUT;
72
+ const remoteResults = await Promise.all((hostManifest.remotes || []).map(async (remote)=>{
73
+ if (!remote.entry) return {
74
+ assets: [],
75
+ errored: false
76
+ };
77
+ const remoteEntry = (0, external_manifest_js_namespaceObject.normalizeRemoteEntry)(remote.entry);
78
+ if (!remoteEntry) return {
79
+ assets: [],
80
+ errored: false
81
+ };
82
+ let remoteManifestUrl;
83
+ try {
84
+ remoteManifestUrl = new URL(remoteEntry).toString();
85
+ } catch {
86
+ (0, external_manifest_js_namespaceObject.warn)(options.monitors, 'Skip module federation remote CSS collection for non-absolute manifest URL %s', remoteEntry);
87
+ return {
88
+ assets: [],
89
+ errored: false
90
+ };
91
+ }
92
+ try {
93
+ const remoteManifest = await fetchJsonWithTimeout(remoteManifestUrl, fetcher, timeout);
94
+ return {
95
+ assets: (0, external_manifest_js_namespaceObject.collectModuleFederationManifestCss)(remoteManifest, remoteManifestUrl),
96
+ errored: false
97
+ };
98
+ } catch (error) {
99
+ (0, external_manifest_js_namespaceObject.warn)(options.monitors, 'Load module federation remote manifest %s failed, error = %s', remoteManifestUrl, error instanceof Error ? error.message : error);
100
+ return {
101
+ assets: [],
102
+ errored: true
103
+ };
104
+ }
105
+ }));
106
+ const cssAssets = [];
107
+ const seen = new Set();
108
+ let errored = false;
109
+ for (const result of remoteResults){
110
+ errored = errored || result.errored;
111
+ for (const asset of result.assets)if (!seen.has(asset)) {
112
+ seen.add(asset);
113
+ cssAssets.push(asset);
114
+ }
115
+ }
116
+ return {
117
+ assets: cssAssets,
118
+ errored
119
+ };
120
+ };
121
+ const collectDirectRemoteModuleFederationCss = async (pwd, options = {})=>{
122
+ const { assets } = await collectDirectRemoteModuleFederationCssWithMeta(pwd, options);
123
+ return assets;
124
+ };
125
+ exports.collectDirectRemoteModuleFederationCss = __webpack_exports__.collectDirectRemoteModuleFederationCss;
126
+ exports.collectDirectRemoteModuleFederationCssWithMeta = __webpack_exports__.collectDirectRemoteModuleFederationCssWithMeta;
127
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
128
+ "collectDirectRemoteModuleFederationCss",
129
+ "collectDirectRemoteModuleFederationCssWithMeta"
130
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
131
+ Object.defineProperty(exports, '__esModule', {
132
+ value: true
133
+ });
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, getters, values)=>{
5
+ var define = (defs, kind)=>{
6
+ for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
7
+ enumerable: true,
8
+ [kind]: defs[key]
9
+ });
10
+ };
11
+ define(getters, "get");
12
+ define(values, "value");
13
+ };
14
+ })();
15
+ (()=>{
16
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
17
+ })();
18
+ (()=>{
19
+ __webpack_require__.r = (exports1)=>{
20
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
21
+ value: 'Module'
22
+ });
23
+ Object.defineProperty(exports1, '__esModule', {
24
+ value: true
25
+ });
26
+ };
27
+ })();
28
+ var __webpack_exports__ = {};
29
+ __webpack_require__.r(__webpack_exports__);
30
+ __webpack_require__.d(__webpack_exports__, {
31
+ DEFAULT_RUNTIME_FALLBACK_FAILURE_HOLD_MS: ()=>external_model_js_namespaceObject.DEFAULT_RUNTIME_FALLBACK_FAILURE_HOLD_MS,
32
+ DEFAULT_RUNTIME_FALLBACK_GATE_NAME: ()=>external_model_js_namespaceObject.DEFAULT_RUNTIME_FALLBACK_GATE_NAME,
33
+ DEFAULT_RUNTIME_FALLBACK_MAX_BODY_BYTES: ()=>external_model_js_namespaceObject.DEFAULT_RUNTIME_FALLBACK_MAX_BODY_BYTES,
34
+ DEFAULT_RUNTIME_FALLBACK_SIGNAL_ENDPOINT: ()=>external_model_js_namespaceObject.DEFAULT_RUNTIME_FALLBACK_SIGNAL_ENDPOINT,
35
+ DEFAULT_RUNTIME_STATUS_ENDPOINT: ()=>external_model_js_namespaceObject.DEFAULT_RUNTIME_STATUS_ENDPOINT,
36
+ createRuntimeFallbackSignalRuntimeState: ()=>external_store_js_namespaceObject.createRuntimeFallbackSignalRuntimeState,
37
+ createRuntimeSignalError: ()=>external_model_js_namespaceObject.createRuntimeSignalError,
38
+ enforceRuntimeFallbackSignalAuth: ()=>external_resolver_js_namespaceObject.enforceRuntimeFallbackSignalAuth,
39
+ enforceRuntimeFallbackSignalAuthToken: ()=>external_resolver_js_namespaceObject.enforceRuntimeFallbackSignalAuthToken,
40
+ enforceRuntimeFallbackSignalTrustPolicy: ()=>external_resolver_js_namespaceObject.enforceRuntimeFallbackSignalTrustPolicy,
41
+ getRuntimeSignalErrorStatusCode: ()=>external_model_js_namespaceObject.getRuntimeSignalErrorStatusCode,
42
+ normalizeRequiredRuntimeFallbackSignalAuthConfig: ()=>external_resolver_js_namespaceObject.normalizeRequiredRuntimeFallbackSignalAuthConfig,
43
+ normalizeRuntimeFallbackSignalAuthConfig: ()=>external_resolver_js_namespaceObject.normalizeRuntimeFallbackSignalAuthConfig,
44
+ normalizeRuntimeFallbackTrustPolicy: ()=>external_resolver_js_namespaceObject.normalizeRuntimeFallbackTrustPolicy,
45
+ parseRuntimeFallbackSignalPayload: ()=>external_model_js_namespaceObject.parseRuntimeFallbackSignalPayload,
46
+ parseRuntimeFallbackSignalPayloadFromRawBody: ()=>external_model_js_namespaceObject.parseRuntimeFallbackSignalPayloadFromRawBody,
47
+ persistRuntimeFallbackContractGate: ()=>external_store_js_namespaceObject.persistRuntimeFallbackContractGate,
48
+ resolveRuntimeFallbackSignalEndpoint: ()=>external_resolver_js_namespaceObject.resolveRuntimeFallbackSignalEndpoint
49
+ });
50
+ const external_model_js_namespaceObject = require("./model.js");
51
+ const external_resolver_js_namespaceObject = require("./resolver.js");
52
+ const external_store_js_namespaceObject = require("./store.js");
53
+ exports.DEFAULT_RUNTIME_FALLBACK_FAILURE_HOLD_MS = __webpack_exports__.DEFAULT_RUNTIME_FALLBACK_FAILURE_HOLD_MS;
54
+ exports.DEFAULT_RUNTIME_FALLBACK_GATE_NAME = __webpack_exports__.DEFAULT_RUNTIME_FALLBACK_GATE_NAME;
55
+ exports.DEFAULT_RUNTIME_FALLBACK_MAX_BODY_BYTES = __webpack_exports__.DEFAULT_RUNTIME_FALLBACK_MAX_BODY_BYTES;
56
+ exports.DEFAULT_RUNTIME_FALLBACK_SIGNAL_ENDPOINT = __webpack_exports__.DEFAULT_RUNTIME_FALLBACK_SIGNAL_ENDPOINT;
57
+ exports.DEFAULT_RUNTIME_STATUS_ENDPOINT = __webpack_exports__.DEFAULT_RUNTIME_STATUS_ENDPOINT;
58
+ exports.createRuntimeFallbackSignalRuntimeState = __webpack_exports__.createRuntimeFallbackSignalRuntimeState;
59
+ exports.createRuntimeSignalError = __webpack_exports__.createRuntimeSignalError;
60
+ exports.enforceRuntimeFallbackSignalAuth = __webpack_exports__.enforceRuntimeFallbackSignalAuth;
61
+ exports.enforceRuntimeFallbackSignalAuthToken = __webpack_exports__.enforceRuntimeFallbackSignalAuthToken;
62
+ exports.enforceRuntimeFallbackSignalTrustPolicy = __webpack_exports__.enforceRuntimeFallbackSignalTrustPolicy;
63
+ exports.getRuntimeSignalErrorStatusCode = __webpack_exports__.getRuntimeSignalErrorStatusCode;
64
+ exports.normalizeRequiredRuntimeFallbackSignalAuthConfig = __webpack_exports__.normalizeRequiredRuntimeFallbackSignalAuthConfig;
65
+ exports.normalizeRuntimeFallbackSignalAuthConfig = __webpack_exports__.normalizeRuntimeFallbackSignalAuthConfig;
66
+ exports.normalizeRuntimeFallbackTrustPolicy = __webpack_exports__.normalizeRuntimeFallbackTrustPolicy;
67
+ exports.parseRuntimeFallbackSignalPayload = __webpack_exports__.parseRuntimeFallbackSignalPayload;
68
+ exports.parseRuntimeFallbackSignalPayloadFromRawBody = __webpack_exports__.parseRuntimeFallbackSignalPayloadFromRawBody;
69
+ exports.persistRuntimeFallbackContractGate = __webpack_exports__.persistRuntimeFallbackContractGate;
70
+ exports.resolveRuntimeFallbackSignalEndpoint = __webpack_exports__.resolveRuntimeFallbackSignalEndpoint;
71
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
72
+ "DEFAULT_RUNTIME_FALLBACK_FAILURE_HOLD_MS",
73
+ "DEFAULT_RUNTIME_FALLBACK_GATE_NAME",
74
+ "DEFAULT_RUNTIME_FALLBACK_MAX_BODY_BYTES",
75
+ "DEFAULT_RUNTIME_FALLBACK_SIGNAL_ENDPOINT",
76
+ "DEFAULT_RUNTIME_STATUS_ENDPOINT",
77
+ "createRuntimeFallbackSignalRuntimeState",
78
+ "createRuntimeSignalError",
79
+ "enforceRuntimeFallbackSignalAuth",
80
+ "enforceRuntimeFallbackSignalAuthToken",
81
+ "enforceRuntimeFallbackSignalTrustPolicy",
82
+ "getRuntimeSignalErrorStatusCode",
83
+ "normalizeRequiredRuntimeFallbackSignalAuthConfig",
84
+ "normalizeRuntimeFallbackSignalAuthConfig",
85
+ "normalizeRuntimeFallbackTrustPolicy",
86
+ "parseRuntimeFallbackSignalPayload",
87
+ "parseRuntimeFallbackSignalPayloadFromRawBody",
88
+ "persistRuntimeFallbackContractGate",
89
+ "resolveRuntimeFallbackSignalEndpoint"
90
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
91
+ Object.defineProperty(exports, '__esModule', {
92
+ value: true
93
+ });
@@ -0,0 +1,157 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, getters, values)=>{
5
+ var define = (defs, kind)=>{
6
+ for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
7
+ enumerable: true,
8
+ [kind]: defs[key]
9
+ });
10
+ };
11
+ define(getters, "get");
12
+ define(values, "value");
13
+ };
14
+ })();
15
+ (()=>{
16
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
17
+ })();
18
+ (()=>{
19
+ __webpack_require__.r = (exports1)=>{
20
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
21
+ value: 'Module'
22
+ });
23
+ Object.defineProperty(exports1, '__esModule', {
24
+ value: true
25
+ });
26
+ };
27
+ })();
28
+ var __webpack_exports__ = {};
29
+ __webpack_require__.r(__webpack_exports__);
30
+ const DEFAULT_RUNTIME_FALLBACK_SIGNAL_ENDPOINT = '/_modern/contract-gates/runtime-fallback';
31
+ const DEFAULT_RUNTIME_STATUS_ENDPOINT = '/_modern/runtime/status';
32
+ const DEFAULT_RUNTIME_FALLBACK_GATE_NAME = 'runtime-mf-fallback-health';
33
+ const DEFAULT_RUNTIME_FALLBACK_FAILURE_HOLD_MS = 300000;
34
+ const DEFAULT_RUNTIME_FALLBACK_MAX_BODY_BYTES = 16384;
35
+ const DEFAULT_RUNTIME_FALLBACK_AUTH_HEADER = 'x-modernjs-runtime-signal-token';
36
+ const DEFAULT_RUNTIME_FALLBACK_TRUST_MAX_SIGNALS_PER_WINDOW = 30;
37
+ const DEFAULT_RUNTIME_FALLBACK_TRUST_WINDOW_MS = 60000;
38
+ const DEFAULT_RUNTIME_FALLBACK_TRUST_DEDUPE_WINDOW_MS = 10000;
39
+ function createRuntimeSignalError(message, code) {
40
+ const error = new Error(message);
41
+ error.code = code;
42
+ return error;
43
+ }
44
+ function getRuntimeSignalErrorStatusCode(signalError) {
45
+ if ('PAYLOAD_TOO_LARGE' === signalError.code) return 413;
46
+ if ('INVALID_PAYLOAD' === signalError.code) return 400;
47
+ if ('UNAUTHORIZED' === signalError.code) return 401;
48
+ if ('RATE_LIMITED' === signalError.code) return 429;
49
+ if ('UNTRUSTED_SOURCE' === signalError.code) return 403;
50
+ return 500;
51
+ }
52
+ function normalizeRuntimeSignalOrigin(value) {
53
+ if ('string' != typeof value || 0 === value.trim().length) return;
54
+ try {
55
+ return new URL(value).origin;
56
+ } catch (_error) {
57
+ return;
58
+ }
59
+ }
60
+ function normalizeRuntimeSignalAppName(payload) {
61
+ if ('string' != typeof payload.appName) return 'unknown';
62
+ const normalized = payload.appName.trim();
63
+ return normalized.length > 0 ? normalized : 'unknown';
64
+ }
65
+ function normalizeRuntimeSignalRuntimeDigest(payload) {
66
+ if ('string' == typeof payload.runtimeDigest && payload.runtimeDigest.trim()) return payload.runtimeDigest.trim();
67
+ const metadata = payload.metadata;
68
+ if (metadata && 'object' == typeof metadata && !Array.isArray(metadata) && 'string' == typeof metadata.runtimeDigest) {
69
+ const digest = String(metadata.runtimeDigest).trim();
70
+ if (digest) return digest;
71
+ }
72
+ }
73
+ function getUtf8ByteLength(input) {
74
+ if ("u" > typeof Buffer) return Buffer.byteLength(input);
75
+ return new TextEncoder().encode(input).length;
76
+ }
77
+ async function parseRuntimeFallbackSignalPayload(c, maxBodyBytes) {
78
+ const contentLengthHeader = c.req.header('content-length');
79
+ if (contentLengthHeader) {
80
+ const contentLength = Number.parseInt(contentLengthHeader, 10);
81
+ if (Number.isFinite(contentLength) && contentLength > maxBodyBytes) throw createRuntimeSignalError('runtime fallback signal payload too large', 'PAYLOAD_TOO_LARGE');
82
+ }
83
+ const rawBody = await c.req.raw.text();
84
+ const payload = parseRuntimeFallbackSignalPayloadFromRawBody(rawBody, maxBodyBytes);
85
+ return {
86
+ rawBody,
87
+ payload
88
+ };
89
+ }
90
+ function parseRuntimeFallbackSignalPayloadFromRawBody(rawBody, maxBodyBytes) {
91
+ if (!rawBody || 0 === rawBody.trim().length) throw createRuntimeSignalError('runtime fallback signal body empty', 'INVALID_PAYLOAD');
92
+ if (getUtf8ByteLength(rawBody) > maxBodyBytes) throw createRuntimeSignalError('runtime fallback signal payload too large', 'PAYLOAD_TOO_LARGE');
93
+ let payload;
94
+ try {
95
+ payload = JSON.parse(rawBody);
96
+ } catch (_error) {
97
+ throw createRuntimeSignalError('runtime fallback signal body must be valid JSON', 'INVALID_PAYLOAD');
98
+ }
99
+ if (!payload || 'object' != typeof payload || Array.isArray(payload)) throw createRuntimeSignalError('runtime fallback signal body must be a JSON object', 'INVALID_PAYLOAD');
100
+ return payload;
101
+ }
102
+ __webpack_require__.d(__webpack_exports__, {
103
+ createRuntimeSignalError: ()=>createRuntimeSignalError,
104
+ getRuntimeSignalErrorStatusCode: ()=>getRuntimeSignalErrorStatusCode,
105
+ normalizeRuntimeSignalAppName: ()=>normalizeRuntimeSignalAppName,
106
+ normalizeRuntimeSignalOrigin: ()=>normalizeRuntimeSignalOrigin,
107
+ normalizeRuntimeSignalRuntimeDigest: ()=>normalizeRuntimeSignalRuntimeDigest,
108
+ parseRuntimeFallbackSignalPayload: ()=>parseRuntimeFallbackSignalPayload,
109
+ parseRuntimeFallbackSignalPayloadFromRawBody: ()=>parseRuntimeFallbackSignalPayloadFromRawBody
110
+ }, {
111
+ DEFAULT_RUNTIME_FALLBACK_AUTH_HEADER: DEFAULT_RUNTIME_FALLBACK_AUTH_HEADER,
112
+ DEFAULT_RUNTIME_FALLBACK_FAILURE_HOLD_MS: DEFAULT_RUNTIME_FALLBACK_FAILURE_HOLD_MS,
113
+ DEFAULT_RUNTIME_FALLBACK_GATE_NAME: DEFAULT_RUNTIME_FALLBACK_GATE_NAME,
114
+ DEFAULT_RUNTIME_FALLBACK_MAX_BODY_BYTES: DEFAULT_RUNTIME_FALLBACK_MAX_BODY_BYTES,
115
+ DEFAULT_RUNTIME_FALLBACK_SIGNAL_ENDPOINT: DEFAULT_RUNTIME_FALLBACK_SIGNAL_ENDPOINT,
116
+ DEFAULT_RUNTIME_FALLBACK_TRUST_DEDUPE_WINDOW_MS: DEFAULT_RUNTIME_FALLBACK_TRUST_DEDUPE_WINDOW_MS,
117
+ DEFAULT_RUNTIME_FALLBACK_TRUST_MAX_SIGNALS_PER_WINDOW: DEFAULT_RUNTIME_FALLBACK_TRUST_MAX_SIGNALS_PER_WINDOW,
118
+ DEFAULT_RUNTIME_FALLBACK_TRUST_WINDOW_MS: DEFAULT_RUNTIME_FALLBACK_TRUST_WINDOW_MS,
119
+ DEFAULT_RUNTIME_STATUS_ENDPOINT: DEFAULT_RUNTIME_STATUS_ENDPOINT
120
+ });
121
+ exports.DEFAULT_RUNTIME_FALLBACK_AUTH_HEADER = __webpack_exports__.DEFAULT_RUNTIME_FALLBACK_AUTH_HEADER;
122
+ exports.DEFAULT_RUNTIME_FALLBACK_FAILURE_HOLD_MS = __webpack_exports__.DEFAULT_RUNTIME_FALLBACK_FAILURE_HOLD_MS;
123
+ exports.DEFAULT_RUNTIME_FALLBACK_GATE_NAME = __webpack_exports__.DEFAULT_RUNTIME_FALLBACK_GATE_NAME;
124
+ exports.DEFAULT_RUNTIME_FALLBACK_MAX_BODY_BYTES = __webpack_exports__.DEFAULT_RUNTIME_FALLBACK_MAX_BODY_BYTES;
125
+ exports.DEFAULT_RUNTIME_FALLBACK_SIGNAL_ENDPOINT = __webpack_exports__.DEFAULT_RUNTIME_FALLBACK_SIGNAL_ENDPOINT;
126
+ exports.DEFAULT_RUNTIME_FALLBACK_TRUST_DEDUPE_WINDOW_MS = __webpack_exports__.DEFAULT_RUNTIME_FALLBACK_TRUST_DEDUPE_WINDOW_MS;
127
+ exports.DEFAULT_RUNTIME_FALLBACK_TRUST_MAX_SIGNALS_PER_WINDOW = __webpack_exports__.DEFAULT_RUNTIME_FALLBACK_TRUST_MAX_SIGNALS_PER_WINDOW;
128
+ exports.DEFAULT_RUNTIME_FALLBACK_TRUST_WINDOW_MS = __webpack_exports__.DEFAULT_RUNTIME_FALLBACK_TRUST_WINDOW_MS;
129
+ exports.DEFAULT_RUNTIME_STATUS_ENDPOINT = __webpack_exports__.DEFAULT_RUNTIME_STATUS_ENDPOINT;
130
+ exports.createRuntimeSignalError = __webpack_exports__.createRuntimeSignalError;
131
+ exports.getRuntimeSignalErrorStatusCode = __webpack_exports__.getRuntimeSignalErrorStatusCode;
132
+ exports.normalizeRuntimeSignalAppName = __webpack_exports__.normalizeRuntimeSignalAppName;
133
+ exports.normalizeRuntimeSignalOrigin = __webpack_exports__.normalizeRuntimeSignalOrigin;
134
+ exports.normalizeRuntimeSignalRuntimeDigest = __webpack_exports__.normalizeRuntimeSignalRuntimeDigest;
135
+ exports.parseRuntimeFallbackSignalPayload = __webpack_exports__.parseRuntimeFallbackSignalPayload;
136
+ exports.parseRuntimeFallbackSignalPayloadFromRawBody = __webpack_exports__.parseRuntimeFallbackSignalPayloadFromRawBody;
137
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
138
+ "DEFAULT_RUNTIME_FALLBACK_AUTH_HEADER",
139
+ "DEFAULT_RUNTIME_FALLBACK_FAILURE_HOLD_MS",
140
+ "DEFAULT_RUNTIME_FALLBACK_GATE_NAME",
141
+ "DEFAULT_RUNTIME_FALLBACK_MAX_BODY_BYTES",
142
+ "DEFAULT_RUNTIME_FALLBACK_SIGNAL_ENDPOINT",
143
+ "DEFAULT_RUNTIME_FALLBACK_TRUST_DEDUPE_WINDOW_MS",
144
+ "DEFAULT_RUNTIME_FALLBACK_TRUST_MAX_SIGNALS_PER_WINDOW",
145
+ "DEFAULT_RUNTIME_FALLBACK_TRUST_WINDOW_MS",
146
+ "DEFAULT_RUNTIME_STATUS_ENDPOINT",
147
+ "createRuntimeSignalError",
148
+ "getRuntimeSignalErrorStatusCode",
149
+ "normalizeRuntimeSignalAppName",
150
+ "normalizeRuntimeSignalOrigin",
151
+ "normalizeRuntimeSignalRuntimeDigest",
152
+ "parseRuntimeFallbackSignalPayload",
153
+ "parseRuntimeFallbackSignalPayloadFromRawBody"
154
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
155
+ Object.defineProperty(exports, '__esModule', {
156
+ value: true
157
+ });
@@ -0,0 +1,163 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, getters, values)=>{
5
+ var define = (defs, kind)=>{
6
+ for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
7
+ enumerable: true,
8
+ [kind]: defs[key]
9
+ });
10
+ };
11
+ define(getters, "get");
12
+ define(values, "value");
13
+ };
14
+ })();
15
+ (()=>{
16
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
17
+ })();
18
+ (()=>{
19
+ __webpack_require__.r = (exports1)=>{
20
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
21
+ value: 'Module'
22
+ });
23
+ Object.defineProperty(exports1, '__esModule', {
24
+ value: true
25
+ });
26
+ };
27
+ })();
28
+ var __webpack_exports__ = {};
29
+ __webpack_require__.r(__webpack_exports__);
30
+ __webpack_require__.d(__webpack_exports__, {
31
+ enforceRuntimeFallbackSignalAuth: ()=>enforceRuntimeFallbackSignalAuth,
32
+ enforceRuntimeFallbackSignalAuthToken: ()=>enforceRuntimeFallbackSignalAuthToken,
33
+ enforceRuntimeFallbackSignalTrustPolicy: ()=>enforceRuntimeFallbackSignalTrustPolicy,
34
+ normalizeRequiredRuntimeFallbackSignalAuthConfig: ()=>normalizeRequiredRuntimeFallbackSignalAuthConfig,
35
+ normalizeRuntimeFallbackSignalAuthConfig: ()=>normalizeRuntimeFallbackSignalAuthConfig,
36
+ normalizeRuntimeFallbackTrustPolicy: ()=>normalizeRuntimeFallbackTrustPolicy,
37
+ resolveRuntimeFallbackSignalEndpoint: ()=>resolveRuntimeFallbackSignalEndpoint
38
+ });
39
+ const external_node_crypto_namespaceObject = require("node:crypto");
40
+ const external_model_js_namespaceObject = require("./model.js");
41
+ const external_store_js_namespaceObject = require("./store.js");
42
+ function resolveRuntimeFallbackSignalEndpoint(configuredEndpoint) {
43
+ if ('string' == typeof configuredEndpoint && configuredEndpoint.trim()) return configuredEndpoint.trim();
44
+ return external_model_js_namespaceObject.DEFAULT_RUNTIME_FALLBACK_SIGNAL_ENDPOINT;
45
+ }
46
+ function normalizeRuntimeFallbackSignalAuthConfig(configured) {
47
+ const headerName = 'string' == typeof configured?.headerName && configured.headerName.trim() ? configured.headerName.trim().toLowerCase() : external_model_js_namespaceObject.DEFAULT_RUNTIME_FALLBACK_AUTH_HEADER;
48
+ const expectedFromEnv = 'string' == typeof configured?.expectedValueEnv && configured.expectedValueEnv.trim().length > 0 ? process.env[configured.expectedValueEnv.trim()] : void 0;
49
+ const expectedFromConfig = 'string' == typeof configured?.expectedValue && configured.expectedValue.trim().length > 0 ? configured.expectedValue.trim() : void 0;
50
+ const expectedValue = expectedFromConfig || expectedFromEnv;
51
+ const enabled = configured?.enabled === true;
52
+ if (enabled && !expectedValue) throw new Error('[telemetry.canary.autopilot.runtimeFallbackSignal] auth.enabled true but no expected token configured');
53
+ return {
54
+ enabled,
55
+ headerName,
56
+ expectedValue
57
+ };
58
+ }
59
+ function normalizeRequiredRuntimeFallbackSignalAuthConfig(configured) {
60
+ if (configured?.enabled === false) throw new Error('[telemetry.canary.autopilot.runtimeFallbackSignal] auth.enabled cannot be false when runtimeFallbackSignal.enabled is true');
61
+ const authConfig = normalizeRuntimeFallbackSignalAuthConfig(configured);
62
+ if (!authConfig.expectedValue) throw new Error('[telemetry.canary.autopilot.runtimeFallbackSignal] auth.expectedValue or auth.expectedValueEnv is required when runtimeFallbackSignal.enabled is true');
63
+ return {
64
+ ...authConfig,
65
+ enabled: true
66
+ };
67
+ }
68
+ function safeTokenEquals(candidate, expected) {
69
+ const candidateDigest = (0, external_node_crypto_namespaceObject.createHash)('sha256').update(candidate).digest();
70
+ const expectedDigest = (0, external_node_crypto_namespaceObject.createHash)('sha256').update(expected).digest();
71
+ return (0, external_node_crypto_namespaceObject.timingSafeEqual)(candidateDigest, expectedDigest);
72
+ }
73
+ function enforceRuntimeFallbackSignalAuthToken(token, authConfig) {
74
+ if (!authConfig.enabled) return;
75
+ if (!token || !authConfig.expectedValue || !safeTokenEquals(token, authConfig.expectedValue)) throw (0, external_model_js_namespaceObject.createRuntimeSignalError)('runtime fallback signal auth failed', 'UNAUTHORIZED');
76
+ }
77
+ function enforceRuntimeFallbackSignalAuth(c, runtimeSignalConfig) {
78
+ enforceRuntimeFallbackSignalAuthToken(c.req.header(runtimeSignalConfig.auth.headerName), runtimeSignalConfig.auth);
79
+ }
80
+ const normalizeInteger = (value, fallback, minimum)=>{
81
+ const candidate = 'number' == typeof value && Number.isFinite(value) ? value : fallback;
82
+ return Math.max(minimum, Math.floor(candidate));
83
+ };
84
+ function normalizeRuntimeFallbackTrustPolicy(configured) {
85
+ const allowedApps = Array.isArray(configured?.allowedApps) ? configured.allowedApps.map((item)=>'string' == typeof item ? item.trim() : '').filter(Boolean) : [];
86
+ const allowedEntryOrigins = Array.isArray(configured?.allowedEntryOrigins) ? configured.allowedEntryOrigins.map((item)=>(0, external_model_js_namespaceObject.normalizeRuntimeSignalOrigin)(item)).filter((item)=>Boolean(item)) : [];
87
+ const expectedRuntimeDigests = {};
88
+ Object.entries(configured?.expectedRuntimeDigests || {}).forEach(([appName, digest])=>{
89
+ if ('string' == typeof appName && appName.trim().length > 0 && 'string' == typeof digest && digest.trim().length > 0) expectedRuntimeDigests[appName.trim()] = digest.trim();
90
+ });
91
+ return {
92
+ allowedApps,
93
+ allowedEntryOrigins,
94
+ expectedRuntimeDigests,
95
+ enforceRuntimeDigest: configured?.enforceRuntimeDigest === true,
96
+ maxSignalsPerWindow: normalizeInteger(configured?.maxSignalsPerWindow, external_model_js_namespaceObject.DEFAULT_RUNTIME_FALLBACK_TRUST_MAX_SIGNALS_PER_WINDOW, 1),
97
+ windowMs: normalizeInteger(configured?.windowMs, external_model_js_namespaceObject.DEFAULT_RUNTIME_FALLBACK_TRUST_WINDOW_MS, 1),
98
+ dedupeWindowMs: normalizeInteger(configured?.dedupeWindowMs, external_model_js_namespaceObject.DEFAULT_RUNTIME_FALLBACK_TRUST_DEDUPE_WINDOW_MS, 0)
99
+ };
100
+ }
101
+ function enforceRuntimeFallbackSignalTrustPolicy(payload, runtimeSignalContext, source = {}) {
102
+ const { trustPolicy, runtimeState } = runtimeSignalContext;
103
+ const now = Date.now();
104
+ (0, external_store_js_namespaceObject.cleanupRuntimeFallbackSignalRuntimeState)(now, runtimeState, trustPolicy);
105
+ const appName = (0, external_model_js_namespaceObject.normalizeRuntimeSignalAppName)(payload);
106
+ const entryOrigin = (0, external_model_js_namespaceObject.normalizeRuntimeSignalOrigin)(payload.entry);
107
+ const runtimeDigest = (0, external_model_js_namespaceObject.normalizeRuntimeSignalRuntimeDigest)(payload);
108
+ if (trustPolicy.allowedApps.length > 0 && !trustPolicy.allowedApps.includes(appName)) throw (0, external_model_js_namespaceObject.createRuntimeSignalError)(`runtime fallback signal app "${appName}" is not trusted`, 'UNTRUSTED_SOURCE');
109
+ if (trustPolicy.allowedEntryOrigins.length > 0) {
110
+ if (!entryOrigin || !trustPolicy.allowedEntryOrigins.includes(entryOrigin)) throw (0, external_model_js_namespaceObject.createRuntimeSignalError)(`runtime fallback signal entry origin "${entryOrigin || 'unknown'}" is not trusted`, 'UNTRUSTED_SOURCE');
111
+ }
112
+ const expectedDigest = trustPolicy.expectedRuntimeDigests[appName];
113
+ if (expectedDigest && runtimeDigest !== expectedDigest) throw (0, external_model_js_namespaceObject.createRuntimeSignalError)(`runtime fallback runtimeDigest mismatch for app "${appName}"`, 'UNTRUSTED_SOURCE');
114
+ if (trustPolicy.enforceRuntimeDigest && !runtimeDigest) throw (0, external_model_js_namespaceObject.createRuntimeSignalError)(`runtime fallback signal app "${appName}" missing runtimeDigest`, 'UNTRUSTED_SOURCE');
115
+ const dedupeFingerprint = JSON.stringify({
116
+ appName,
117
+ entryOrigin: entryOrigin || 'unknown',
118
+ reason: payload.reason || 'runtime_fallback',
119
+ phase: payload.phase || 'unknown',
120
+ runtimeDigest: runtimeDigest || 'unknown'
121
+ });
122
+ const dedupeWindowMs = trustPolicy.dedupeWindowMs;
123
+ if (dedupeWindowMs > 0) {
124
+ const lastSeenAt = runtimeState.dedupeByFingerprint.get(dedupeFingerprint);
125
+ runtimeState.dedupeByFingerprint.set(dedupeFingerprint, now);
126
+ if ('number' == typeof lastSeenAt && now - lastSeenAt <= dedupeWindowMs) return {
127
+ deduped: true
128
+ };
129
+ } else runtimeState.dedupeByFingerprint.set(dedupeFingerprint, now);
130
+ const remoteAddress = source.remoteAddress?.trim();
131
+ const sourceKey = remoteAddress || 'unknown-remote';
132
+ const rateState = runtimeState.rateLimitBySource.get(sourceKey);
133
+ if (!rateState || now - rateState.windowStartedAt > trustPolicy.windowMs) runtimeState.rateLimitBySource.set(sourceKey, {
134
+ count: 1,
135
+ windowStartedAt: now
136
+ });
137
+ else {
138
+ if (rateState.count >= trustPolicy.maxSignalsPerWindow) throw (0, external_model_js_namespaceObject.createRuntimeSignalError)(`runtime fallback signal rate-limited source "${sourceKey}"`, 'RATE_LIMITED');
139
+ rateState.count += 1;
140
+ }
141
+ return {
142
+ deduped: false
143
+ };
144
+ }
145
+ exports.enforceRuntimeFallbackSignalAuth = __webpack_exports__.enforceRuntimeFallbackSignalAuth;
146
+ exports.enforceRuntimeFallbackSignalAuthToken = __webpack_exports__.enforceRuntimeFallbackSignalAuthToken;
147
+ exports.enforceRuntimeFallbackSignalTrustPolicy = __webpack_exports__.enforceRuntimeFallbackSignalTrustPolicy;
148
+ exports.normalizeRequiredRuntimeFallbackSignalAuthConfig = __webpack_exports__.normalizeRequiredRuntimeFallbackSignalAuthConfig;
149
+ exports.normalizeRuntimeFallbackSignalAuthConfig = __webpack_exports__.normalizeRuntimeFallbackSignalAuthConfig;
150
+ exports.normalizeRuntimeFallbackTrustPolicy = __webpack_exports__.normalizeRuntimeFallbackTrustPolicy;
151
+ exports.resolveRuntimeFallbackSignalEndpoint = __webpack_exports__.resolveRuntimeFallbackSignalEndpoint;
152
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
153
+ "enforceRuntimeFallbackSignalAuth",
154
+ "enforceRuntimeFallbackSignalAuthToken",
155
+ "enforceRuntimeFallbackSignalTrustPolicy",
156
+ "normalizeRequiredRuntimeFallbackSignalAuthConfig",
157
+ "normalizeRuntimeFallbackSignalAuthConfig",
158
+ "normalizeRuntimeFallbackTrustPolicy",
159
+ "resolveRuntimeFallbackSignalEndpoint"
160
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
161
+ Object.defineProperty(exports, '__esModule', {
162
+ value: true
163
+ });
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, getters, values)=>{
5
+ var define = (defs, kind)=>{
6
+ for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
7
+ enumerable: true,
8
+ [kind]: defs[key]
9
+ });
10
+ };
11
+ define(getters, "get");
12
+ define(values, "value");
13
+ };
14
+ })();
15
+ (()=>{
16
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
17
+ })();
18
+ (()=>{
19
+ __webpack_require__.r = (exports1)=>{
20
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
21
+ value: 'Module'
22
+ });
23
+ Object.defineProperty(exports1, '__esModule', {
24
+ value: true
25
+ });
26
+ };
27
+ })();
28
+ var __webpack_exports__ = {};
29
+ __webpack_require__.r(__webpack_exports__);
30
+ __webpack_require__.d(__webpack_exports__, {
31
+ cleanupRuntimeFallbackSignalRuntimeState: ()=>cleanupRuntimeFallbackSignalRuntimeState,
32
+ createRuntimeFallbackSignalRuntimeState: ()=>createRuntimeFallbackSignalRuntimeState,
33
+ persistRuntimeFallbackContractGate: ()=>persistRuntimeFallbackContractGate
34
+ });
35
+ const index_js_namespaceObject = require("../contract-gate-snapshot-store/index.js");
36
+ function createRuntimeFallbackSignalRuntimeState() {
37
+ return {
38
+ rateLimitBySource: new Map(),
39
+ dedupeByFingerprint: new Map()
40
+ };
41
+ }
42
+ function cleanupRuntimeFallbackSignalRuntimeState(now, runtimeState, trustPolicy) {
43
+ const rateLimitWindowMs = Math.max(1, trustPolicy.windowMs);
44
+ for (const [sourceKey, rateState] of runtimeState.rateLimitBySource)if (now - rateState.windowStartedAt > rateLimitWindowMs) runtimeState.rateLimitBySource.delete(sourceKey);
45
+ const dedupeWindowMs = Math.max(0, trustPolicy.dedupeWindowMs);
46
+ if (0 === dedupeWindowMs) return void runtimeState.dedupeByFingerprint.clear();
47
+ for (const [fingerprint, lastSeenAt] of runtimeState.dedupeByFingerprint)if (now - lastSeenAt > dedupeWindowMs) runtimeState.dedupeByFingerprint.delete(fingerprint);
48
+ }
49
+ async function persistRuntimeFallbackContractGate(payload, runtimeSignalConfig) {
50
+ const now = Date.now();
51
+ const gateSnapshotStore = await runtimeSignalConfig.gateSnapshotStore;
52
+ const snapshot = await gateSnapshotStore.readSnapshot() || {};
53
+ const existingGates = snapshot.gates && 'object' == typeof snapshot.gates ? snapshot.gates : {};
54
+ const reason = 'string' == typeof payload.reason ? payload.reason : 'runtime_fallback';
55
+ const phase = 'string' == typeof payload.phase ? payload.phase : 'unknown';
56
+ const appName = 'string' == typeof payload.appName ? payload.appName : 'unknown';
57
+ const entry = 'string' == typeof payload.entry ? payload.entry : void 0;
58
+ snapshot.schemaVersion = 'number' == typeof snapshot.schemaVersion ? snapshot.schemaVersion : index_js_namespaceObject.CONTRACT_GATE_SNAPSHOT_SCHEMA_VERSION;
59
+ snapshot.updatedAt = now;
60
+ snapshot.gates = {
61
+ ...existingGates,
62
+ [runtimeSignalConfig.gateName]: {
63
+ passed: false,
64
+ reason: `runtime_fallback:${reason} phase=${phase} app=${appName}${entry ? ` entry=${entry}` : ''}`,
65
+ updatedAt: now,
66
+ expiresAt: now + runtimeSignalConfig.failureHoldMs,
67
+ source: 'runtime-mf-fallback-signal',
68
+ metadata: payload
69
+ }
70
+ };
71
+ await gateSnapshotStore.writeSnapshot(snapshot);
72
+ }
73
+ exports.cleanupRuntimeFallbackSignalRuntimeState = __webpack_exports__.cleanupRuntimeFallbackSignalRuntimeState;
74
+ exports.createRuntimeFallbackSignalRuntimeState = __webpack_exports__.createRuntimeFallbackSignalRuntimeState;
75
+ exports.persistRuntimeFallbackContractGate = __webpack_exports__.persistRuntimeFallbackContractGate;
76
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
77
+ "cleanupRuntimeFallbackSignalRuntimeState",
78
+ "createRuntimeFallbackSignalRuntimeState",
79
+ "persistRuntimeFallbackContractGate"
80
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
81
+ Object.defineProperty(exports, '__esModule', {
82
+ value: true
83
+ });