@kya-os/checkpoint-shared 1.7.0 → 1.8.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 (224) hide show
  1. package/CHANGELOG.md +122 -9
  2. package/README.md +24 -7
  3. package/dist/beacon-nonce/index.d.mts +1 -0
  4. package/dist/beacon-nonce/index.d.mts.map +1 -1
  5. package/dist/beacon-nonce/index.d.ts +1 -0
  6. package/dist/beacon-nonce/index.d.ts.map +1 -1
  7. package/dist/beacon-nonce/index.js +9 -3
  8. package/dist/beacon-nonce/index.mjs +9 -4
  9. package/dist/beacon-nonce/index.mjs.map +1 -1
  10. package/dist/beacon-types/index.d.mts +23 -1
  11. package/dist/beacon-types/index.d.mts.map +1 -1
  12. package/dist/beacon-types/index.d.ts +23 -1
  13. package/dist/beacon-types/index.d.ts.map +1 -1
  14. package/dist/beacon-types/index.js +49 -4
  15. package/dist/beacon-types/index.mjs +47 -4
  16. package/dist/beacon-types/index.mjs.map +1 -1
  17. package/dist/{browser-posture-BLhw-MON.d.mts → browser-posture-5fPrsxx7.d.mts} +6 -6
  18. package/dist/{browser-posture-BLhw-MON.d.mts.map → browser-posture-5fPrsxx7.d.mts.map} +1 -1
  19. package/dist/{browser-posture-B8YiPa5c.d.ts → browser-posture-CCR1kh5e.d.ts} +6 -6
  20. package/dist/{browser-posture-B8YiPa5c.d.ts.map → browser-posture-CCR1kh5e.d.ts.map} +1 -1
  21. package/dist/browser-posture-proof.d.mts +16 -2
  22. package/dist/browser-posture-proof.d.mts.map +1 -1
  23. package/dist/browser-posture-proof.d.ts +16 -2
  24. package/dist/browser-posture-proof.d.ts.map +1 -1
  25. package/dist/browser-posture-proof.js +73 -17
  26. package/dist/browser-posture-proof.mjs +71 -17
  27. package/dist/browser-posture-proof.mjs.map +1 -1
  28. package/dist/browser-posture.d.mts +1 -1
  29. package/dist/browser-posture.d.ts +1 -1
  30. package/dist/browser-posture.js +6 -5
  31. package/dist/browser-posture.mjs +4 -3
  32. package/dist/browser-posture.mjs.map +1 -1
  33. package/dist/browser.d.mts +25 -4
  34. package/dist/browser.d.mts.map +1 -1
  35. package/dist/browser.d.ts +25 -4
  36. package/dist/browser.d.ts.map +1 -1
  37. package/dist/browser.js +1 -1
  38. package/dist/browser.mjs +1 -1
  39. package/dist/browser.mjs.map +1 -1
  40. package/dist/canonical-signer/index.js +30 -28
  41. package/dist/canonical-signer/index.mjs +31 -1
  42. package/dist/canonical-signer/index.mjs.map +1 -1
  43. package/dist/clearance.d.mts +1 -1
  44. package/dist/clearance.d.ts +1 -1
  45. package/dist/clearance.js +2 -2
  46. package/dist/clearance.mjs +2 -2
  47. package/dist/client-ip-B7w-uHfS.d.mts +55 -0
  48. package/dist/client-ip-B7w-uHfS.d.mts.map +1 -0
  49. package/dist/client-ip-B7w-uHfS.d.ts +55 -0
  50. package/dist/client-ip-B7w-uHfS.d.ts.map +1 -0
  51. package/dist/{client-ip-CW6pRyLf.js → client-ip-B8wFzJ5f.js} +117 -7
  52. package/dist/{client-ip-B2Xeo-GK.mjs → client-ip-DIJyr6px.mjs} +113 -9
  53. package/dist/client-ip-DIJyr6px.mjs.map +1 -0
  54. package/dist/client-ip.d.mts +2 -2
  55. package/dist/client-ip.d.ts +2 -2
  56. package/dist/client-ip.js +3 -2
  57. package/dist/client-ip.mjs +2 -2
  58. package/dist/detection-reason-mapping-B9RSkOs8.js +277 -0
  59. package/dist/detection-reason-mapping-BGymWIPl.mjs +249 -0
  60. package/dist/detection-reason-mapping-BGymWIPl.mjs.map +1 -0
  61. package/dist/detection-reason-mapping-CQexNvR7.d.mts +52 -0
  62. package/dist/detection-reason-mapping-CQexNvR7.d.mts.map +1 -0
  63. package/dist/detection-reason-mapping-CQexNvR7.d.ts +52 -0
  64. package/dist/detection-reason-mapping-CQexNvR7.d.ts.map +1 -0
  65. package/dist/engine-enforcing-AYEcgNsb.js +39 -0
  66. package/dist/engine-enforcing-B5eNfCpG.mjs +29 -0
  67. package/dist/engine-enforcing-B5eNfCpG.mjs.map +1 -0
  68. package/dist/engine-enforcing-DiOclGqf.d.mts +11 -0
  69. package/dist/engine-enforcing-DiOclGqf.d.mts.map +1 -0
  70. package/dist/engine-enforcing-DiOclGqf.d.ts +11 -0
  71. package/dist/engine-enforcing-DiOclGqf.d.ts.map +1 -0
  72. package/dist/engine-info.d.mts +2 -0
  73. package/dist/engine-info.d.ts +2 -0
  74. package/dist/engine-info.js +4 -0
  75. package/dist/engine-info.mjs +3 -0
  76. package/dist/errors/index.d.mts +5 -0
  77. package/dist/errors/index.d.mts.map +1 -1
  78. package/dist/errors/index.d.ts +5 -0
  79. package/dist/errors/index.d.ts.map +1 -1
  80. package/dist/errors/index.js +23 -4
  81. package/dist/errors/index.mjs +23 -4
  82. package/dist/errors/index.mjs.map +1 -1
  83. package/dist/{external-B7WI9FyQ.d.ts → external-m3Kmafwj.d.mts} +2 -2
  84. package/dist/{external-B7WI9FyQ.d.mts.map → external-m3Kmafwj.d.mts.map} +1 -1
  85. package/dist/{external-B7WI9FyQ.d.mts → external-m3Kmafwj.d.ts} +2 -2
  86. package/dist/{external-B7WI9FyQ.d.ts.map → external-m3Kmafwj.d.ts.map} +1 -1
  87. package/dist/fetcher-CivUCbhL.d.ts +44 -0
  88. package/dist/fetcher-CivUCbhL.d.ts.map +1 -0
  89. package/dist/fetcher-cXQsbm6s.d.mts +44 -0
  90. package/dist/fetcher-cXQsbm6s.d.mts.map +1 -0
  91. package/dist/gateway-client-ip.d.mts +1 -1
  92. package/dist/gateway-client-ip.d.ts +1 -1
  93. package/dist/gateway-client-ip.js +2 -2
  94. package/dist/gateway-client-ip.mjs +2 -2
  95. package/dist/host-adapter/index.d.mts +2 -2
  96. package/dist/host-adapter/index.d.ts +2 -2
  97. package/dist/host-adapter/index.js +2 -1
  98. package/dist/host-adapter/index.mjs +2 -2
  99. package/dist/{host-adapter-CwW9YB0U.js → host-adapter-0F8EpbD6.js} +59 -0
  100. package/dist/{host-adapter-C-4IxmqM.mjs → host-adapter-DHyISsIf.mjs} +55 -2
  101. package/dist/{host-adapter-C-4IxmqM.mjs.map → host-adapter-DHyISsIf.mjs.map} +1 -1
  102. package/dist/index-B3cHxr3O.d.mts +156 -0
  103. package/dist/index-B3cHxr3O.d.mts.map +1 -0
  104. package/dist/index-CXbOY7gB.d.ts +156 -0
  105. package/dist/index-CXbOY7gB.d.ts.map +1 -0
  106. package/dist/index.d.mts +8331 -12630
  107. package/dist/index.d.mts.map +1 -1
  108. package/dist/index.d.ts +8331 -12630
  109. package/dist/index.d.ts.map +1 -1
  110. package/dist/index.js +2515 -6663
  111. package/dist/index.mjs +2438 -6371
  112. package/dist/index.mjs.map +1 -1
  113. package/dist/kya-http.d.mts +2 -2
  114. package/dist/kya-http.d.ts +2 -2
  115. package/dist/kya-http.js +9 -1
  116. package/dist/kya-http.mjs +3 -2
  117. package/dist/mcpi/dashboard-config/index.d.mts.map +1 -1
  118. package/dist/mcpi/dashboard-config/index.d.ts.map +1 -1
  119. package/dist/mcpi/status-list/index.d.mts +72 -0
  120. package/dist/mcpi/status-list/index.d.mts.map +1 -0
  121. package/dist/mcpi/status-list/index.d.ts +72 -0
  122. package/dist/mcpi/status-list/index.d.ts.map +1 -0
  123. package/dist/mcpi/status-list/index.js +703 -0
  124. package/dist/mcpi/status-list/index.mjs +684 -0
  125. package/dist/mcpi/status-list/index.mjs.map +1 -0
  126. package/dist/patterns-B2r7M9wR.js +243 -0
  127. package/dist/patterns-B7dQoeE3.mjs +173 -0
  128. package/dist/patterns-B7dQoeE3.mjs.map +1 -0
  129. package/dist/patterns-Bp40cwh2.d.mts +110 -0
  130. package/dist/patterns-Bp40cwh2.d.mts.map +1 -0
  131. package/dist/patterns-Bp40cwh2.d.ts +110 -0
  132. package/dist/patterns-Bp40cwh2.d.ts.map +1 -0
  133. package/dist/patterns.d.mts +2 -0
  134. package/dist/patterns.d.ts +2 -0
  135. package/dist/patterns.js +15 -0
  136. package/dist/patterns.mjs +3 -0
  137. package/dist/policy/enforcement.d.mts +3 -2
  138. package/dist/policy/enforcement.d.ts +3 -2
  139. package/dist/policy/enforcement.js +8 -2
  140. package/dist/policy/enforcement.mjs +3 -2
  141. package/dist/policy/fetcher.d.mts +2 -0
  142. package/dist/policy/fetcher.d.ts +2 -0
  143. package/dist/policy/fetcher.js +240 -0
  144. package/dist/policy/fetcher.mjs +238 -0
  145. package/dist/policy/fetcher.mjs.map +1 -0
  146. package/dist/policy/schemas.d.mts +3 -0
  147. package/dist/policy/schemas.d.ts +3 -0
  148. package/dist/policy/schemas.js +27 -0
  149. package/dist/policy/schemas.mjs +4 -0
  150. package/dist/{posture-origins-Ba83O0cD.mjs → posture-origins-Ci6k4Zh1.js} +24 -173
  151. package/dist/{posture-origins-CdVOdiMT.js → posture-origins-DGyS4Vuk.mjs} +2 -267
  152. package/dist/posture-origins-DGyS4Vuk.mjs.map +1 -0
  153. package/dist/{project-verification-key-BccT12tQ.js → project-verification-key-B-L3D2nC.js} +1 -1
  154. package/dist/{project-verification-key-66N4edKn.mjs → project-verification-key-CWXdu3-n.mjs} +2 -2
  155. package/dist/{project-verification-key-66N4edKn.mjs.map → project-verification-key-CWXdu3-n.mjs.map} +1 -1
  156. package/dist/provider-registry.d.mts +2 -0
  157. package/dist/provider-registry.d.ts +2 -0
  158. package/dist/provider-registry.js +51 -0
  159. package/dist/provider-registry.mjs +3 -0
  160. package/dist/reason-codes.d.mts +2 -0
  161. package/dist/reason-codes.d.ts +2 -0
  162. package/dist/reason-codes.js +8 -0
  163. package/dist/reason-codes.mjs +3 -0
  164. package/dist/{registered-sid-hUl-bvM5.mjs → registered-sid-26hNxp6t.mjs} +11 -2
  165. package/dist/registered-sid-26hNxp6t.mjs.map +1 -0
  166. package/dist/registered-sid-D6KCaT1E.d.mts +33 -0
  167. package/dist/registered-sid-D6KCaT1E.d.mts.map +1 -0
  168. package/dist/registered-sid-D6KCaT1E.d.ts +33 -0
  169. package/dist/registered-sid-D6KCaT1E.d.ts.map +1 -0
  170. package/dist/{registered-sid-eLCNZvIF.js → registered-sid-DVGTSH0L.js} +15 -0
  171. package/dist/ruleset-hash-Cmv8MSO5.js +34 -0
  172. package/dist/ruleset-hash-IRN5eI9H.d.mts +5 -0
  173. package/dist/ruleset-hash-IRN5eI9H.d.mts.map +1 -0
  174. package/dist/ruleset-hash-IRN5eI9H.d.ts +5 -0
  175. package/dist/ruleset-hash-IRN5eI9H.d.ts.map +1 -0
  176. package/dist/ruleset-hash-QQIaLuPi.mjs +30 -0
  177. package/dist/ruleset-hash-QQIaLuPi.mjs.map +1 -0
  178. package/dist/{index-HaqfPtaL.d.ts → schemas-02CI7jgm.d.mts} +11 -183
  179. package/dist/schemas-02CI7jgm.d.mts.map +1 -0
  180. package/dist/{schemas-YhagYDx_.js → schemas-BlScS1it.js} +0 -20
  181. package/dist/{index-B7rTovHa.d.mts → schemas-C_3C72SR.d.ts} +11 -183
  182. package/dist/schemas-C_3C72SR.d.ts.map +1 -0
  183. package/dist/schemas-Cm4C4Z5G.js +703 -0
  184. package/dist/schemas-DPIT8usF.mjs +525 -0
  185. package/dist/schemas-DPIT8usF.mjs.map +1 -0
  186. package/dist/{schemas-7qodsG-Z.mjs → schemas-IHAhH3gV.mjs} +2 -16
  187. package/dist/schemas-IHAhH3gV.mjs.map +1 -0
  188. package/dist/{step-up-COlmWJN8.mjs → step-up-BK0oBi11.mjs} +91 -41
  189. package/dist/step-up-BK0oBi11.mjs.map +1 -0
  190. package/dist/{step-up-C2d8C20x.js → step-up-Bp8RAQwv.js} +117 -55
  191. package/dist/{step-up-BjP--hG-.d.mts → step-up-Bz12gYKT.d.mts} +28 -12
  192. package/dist/step-up-Bz12gYKT.d.mts.map +1 -0
  193. package/dist/{step-up-BjP--hG-.d.ts → step-up-Bz12gYKT.d.ts} +28 -12
  194. package/dist/step-up-Bz12gYKT.d.ts.map +1 -0
  195. package/dist/test-fixtures/index.d.mts +4 -4
  196. package/dist/test-fixtures/index.d.mts.map +1 -1
  197. package/dist/test-fixtures/index.d.ts +4 -4
  198. package/dist/test-fixtures/index.d.ts.map +1 -1
  199. package/dist/test-fixtures/index.js +4 -4
  200. package/dist/test-fixtures/index.mjs +4 -4
  201. package/dist/test-fixtures/index.mjs.map +1 -1
  202. package/dist/verification-BAw9N8Pt.js +181 -0
  203. package/dist/verification-Cvvv86TT.mjs +123 -0
  204. package/dist/verification-Cvvv86TT.mjs.map +1 -0
  205. package/fixtures/client-ip-resolution.n01.json +101 -0
  206. package/fixtures/reviewer-grant-revocation.v1.json +53 -81
  207. package/package.json +37 -2
  208. package/dist/client-ip-B2Xeo-GK.mjs.map +0 -1
  209. package/dist/client-ip-DFamiNoz.d.mts +0 -34
  210. package/dist/client-ip-DFamiNoz.d.mts.map +0 -1
  211. package/dist/client-ip-DFamiNoz.d.ts +0 -34
  212. package/dist/client-ip-DFamiNoz.d.ts.map +0 -1
  213. package/dist/index-B7rTovHa.d.mts.map +0 -1
  214. package/dist/index-HaqfPtaL.d.ts.map +0 -1
  215. package/dist/posture-origins-Ba83O0cD.mjs.map +0 -1
  216. package/dist/registered-sid-D3g-gZQF.d.mts +0 -11
  217. package/dist/registered-sid-D3g-gZQF.d.mts.map +0 -1
  218. package/dist/registered-sid-D3g-gZQF.d.ts +0 -11
  219. package/dist/registered-sid-D3g-gZQF.d.ts.map +0 -1
  220. package/dist/registered-sid-hUl-bvM5.mjs.map +0 -1
  221. package/dist/schemas-7qodsG-Z.mjs.map +0 -1
  222. package/dist/step-up-BjP--hG-.d.mts.map +0 -1
  223. package/dist/step-up-BjP--hG-.d.ts.map +0 -1
  224. package/dist/step-up-COlmWJN8.mjs.map +0 -1
@@ -0,0 +1,238 @@
1
+ import { E as DEFAULT_POLICY, S as CACHE_TTL, m as PolicyConfigSchema, x as safeParsePolicyConfig } from "../schemas-DPIT8usF.mjs";
2
+
3
+ //#region src/policy/fetcher.ts
4
+ /**
5
+ * Policy Fetcher
6
+ *
7
+ * Runtime-agnostic policy fetching with caching support.
8
+ * Works in Edge (Cloudflare Workers, Next.js Edge), Node.js, and browser environments.
9
+ *
10
+ * The fetcher supports:
11
+ * - In-memory caching with TTL
12
+ * - Origin reads for legacy adapters that cannot coordinate shared invalidation
13
+ * - Fallback to default policy on errors
14
+ * - Configurable API endpoints
15
+ */
16
+ function looksLikePolicyApiBody(data) {
17
+ if (typeof data !== "object" || data === null) return false;
18
+ const threshold = data.blockThreshold;
19
+ return typeof threshold === "number" && Number.isFinite(threshold);
20
+ }
21
+ /**
22
+ * The policy API serves the allow list as agent names (the `string[]` the
23
+ * gateway Worker reads), while the policy schema models each entry as an
24
+ * object. Read a name as `{ clientName }` before validating; anything else is
25
+ * left for the schema to judge.
26
+ */
27
+ function fromPolicyApiBody(data) {
28
+ const { allowList } = data;
29
+ if (!Array.isArray(allowList)) return data;
30
+ return {
31
+ ...data,
32
+ allowList: allowList.map((entry) => typeof entry === "string" ? { clientName: entry } : entry)
33
+ };
34
+ }
35
+ var PolicyUnavailableError = class extends Error {
36
+ code = "POLICY_UNAVAILABLE";
37
+ constructor() {
38
+ super("Current policy could not be loaded within the permitted bound");
39
+ this.name = "PolicyUnavailableError";
40
+ }
41
+ };
42
+ /** Recognize the same failure across independently loaded SDK package copies. */
43
+ function isPolicyUnavailableError(error) {
44
+ return error instanceof Error && error.name === "PolicyUnavailableError" && "code" in error && error.code === "POLICY_UNAVAILABLE";
45
+ }
46
+ /**
47
+ * Simple in-memory cache with TTL support
48
+ */
49
+ var MemoryCache = class {
50
+ cache = /* @__PURE__ */ new Map();
51
+ get(key) {
52
+ const entry = this.cache.get(key);
53
+ if (!entry) return null;
54
+ if (Date.now() > entry.expiresAt) {
55
+ this.cache.delete(key);
56
+ return null;
57
+ }
58
+ return entry.value;
59
+ }
60
+ set(key, value, ttlSeconds) {
61
+ this.cache.set(key, {
62
+ value,
63
+ expiresAt: Date.now() + ttlSeconds * 1e3
64
+ });
65
+ }
66
+ delete(key) {
67
+ return this.cache.delete(key);
68
+ }
69
+ clear() {
70
+ this.cache.clear();
71
+ }
72
+ };
73
+ const globalMemoryCache = new MemoryCache();
74
+ const globalPolicyCacheKeys = /* @__PURE__ */ new Map();
75
+ const fallbackCachePrefix = `${Date.now().toString(36)}:${Math.random().toString(36).slice(2)}:${Math.random().toString(36).slice(2)}`;
76
+ let fallbackCacheSequence = 0;
77
+ function nextCacheRevision() {
78
+ return globalThis.crypto?.randomUUID?.() ?? `${fallbackCachePrefix}:${++fallbackCacheSequence}`;
79
+ }
80
+ /**
81
+ * Policy fetcher with caching and fallback support
82
+ */
83
+ var PolicyFetcher = class {
84
+ config;
85
+ memoryCache;
86
+ constructor(config) {
87
+ this.config = {
88
+ apiBaseUrl: config.apiBaseUrl,
89
+ apiKey: config.apiKey,
90
+ cacheTtlSeconds: config.cacheTtlSeconds ?? CACHE_TTL.POLICY,
91
+ cacheAdapter: config.cacheAdapter,
92
+ disableMemoryCache: config.disableMemoryCache ?? false,
93
+ timeoutMs: config.timeoutMs ?? 5e3,
94
+ throwOnUnavailable: config.throwOnUnavailable ?? false,
95
+ fetchFn: config.fetchFn ?? globalThis.fetch
96
+ };
97
+ this.memoryCache = config.disableMemoryCache ? new MemoryCache() : globalMemoryCache;
98
+ }
99
+ /**
100
+ * Generate a cache key that includes the API base URL and TTL to prevent
101
+ * cache collisions when multiple fetchers use different backends or TTL settings.
102
+ */
103
+ getBaseCacheKey(projectId) {
104
+ return `policy:${this.config.apiBaseUrl.split("").reduce((hash, char) => (hash << 5) - hash + char.charCodeAt(0) | 0, 0).toString(36)}:${this.config.cacheTtlSeconds}:${projectId}`;
105
+ }
106
+ getCacheKey(projectId) {
107
+ const baseKey = this.getBaseCacheKey(projectId);
108
+ return globalPolicyCacheKeys.get(baseKey) ?? baseKey;
109
+ }
110
+ /**
111
+ * Get policy for a project, with caching
112
+ */
113
+ async getPolicy(projectId) {
114
+ const deadline = Date.now() + this.config.timeoutMs;
115
+ if (!Number.isFinite(deadline) || this.config.timeoutMs <= 0) throw new PolicyUnavailableError();
116
+ const controller = new AbortController();
117
+ const requireActiveLoad = () => {
118
+ if (controller.signal.aborted || Date.now() >= deadline) throw new PolicyUnavailableError();
119
+ };
120
+ let timer;
121
+ const expired = new Promise((_resolve, reject) => {
122
+ timer = setTimeout(() => {
123
+ const failure = new PolicyUnavailableError();
124
+ controller.abort(failure);
125
+ reject(failure);
126
+ }, this.config.timeoutMs);
127
+ });
128
+ const useMemoryCache = !this.config.disableMemoryCache && !this.config.cacheAdapter;
129
+ try {
130
+ for (let attempt = 0; attempt < 4; attempt++) {
131
+ requireActiveLoad();
132
+ const cacheKey = this.getCacheKey(projectId);
133
+ if (useMemoryCache) {
134
+ const memoryCached = this.memoryCache.get(cacheKey);
135
+ if (memoryCached) {
136
+ const cached = JSON.parse(memoryCached);
137
+ requireActiveLoad();
138
+ if (!this.isExpired(cached.expiresAt)) return cached.policy;
139
+ }
140
+ }
141
+ try {
142
+ const policy = await Promise.race([this.fetchPolicyFromApi(projectId, controller.signal), expired]);
143
+ requireActiveLoad();
144
+ if (cacheKey !== this.getCacheKey(projectId)) continue;
145
+ if (useMemoryCache) {
146
+ const now = /* @__PURE__ */ new Date();
147
+ const cached = {
148
+ policy,
149
+ projectId,
150
+ cachedAt: now.toISOString(),
151
+ expiresAt: new Date(now.getTime() + this.config.cacheTtlSeconds * 1e3).toISOString()
152
+ };
153
+ const cacheValue = JSON.stringify(cached);
154
+ requireActiveLoad();
155
+ this.memoryCache.set(cacheKey, cacheValue, this.config.cacheTtlSeconds);
156
+ }
157
+ requireActiveLoad();
158
+ return policy;
159
+ } catch (error) {
160
+ requireActiveLoad();
161
+ if (isPolicyUnavailableError(error)) throw error;
162
+ if (cacheKey !== this.getCacheKey(projectId)) continue;
163
+ console.error(`[PolicyFetcher] Failed to fetch policy for ${projectId}:`, error);
164
+ if (this.config.throwOnUnavailable) throw new PolicyUnavailableError();
165
+ return this.getDefaultPolicy();
166
+ }
167
+ }
168
+ throw new PolicyUnavailableError();
169
+ } finally {
170
+ if (timer !== void 0) clearTimeout(timer);
171
+ }
172
+ }
173
+ /**
174
+ * Fetch policy from the API
175
+ */
176
+ async fetchPolicyFromApi(projectId, signal) {
177
+ const url = `${this.config.apiBaseUrl}/api/internal/policies/${projectId}`;
178
+ const headers = {
179
+ "Content-Type": "application/json",
180
+ "User-Agent": "AgentShield-PolicyFetcher/1.0"
181
+ };
182
+ if (this.config.apiKey) headers["Authorization"] = `Bearer ${this.config.apiKey}`;
183
+ const response = await this.config.fetchFn(url, {
184
+ method: "GET",
185
+ headers,
186
+ signal,
187
+ cache: "no-store"
188
+ });
189
+ if (!response.ok) throw new Error(`API returned ${response.status}: ${response.statusText}`);
190
+ const data = await response.json();
191
+ if (!looksLikePolicyApiBody(data)) throw new Error("Policy response is not from the policy API");
192
+ const policy = safeParsePolicyConfig(fromPolicyApiBody(data));
193
+ if (!policy) throw new Error("Invalid policy response format");
194
+ return policy;
195
+ }
196
+ /**
197
+ * Get the default policy
198
+ */
199
+ getDefaultPolicy() {
200
+ return PolicyConfigSchema.parse(DEFAULT_POLICY);
201
+ }
202
+ /**
203
+ * Retire this runtime's cached policy key before any asynchronous cleanup.
204
+ * Older reads and writes cannot restore the retired entry for these fetchers.
205
+ */
206
+ async invalidateCache(projectId) {
207
+ const cacheKey = this.getCacheKey(projectId);
208
+ const baseKey = this.getBaseCacheKey(projectId);
209
+ globalPolicyCacheKeys.set(baseKey, `${baseKey}:${nextCacheRevision()}`);
210
+ globalMemoryCache.delete(cacheKey);
211
+ if (this.config.cacheAdapter?.delete) {
212
+ const keys = cacheKey === baseKey ? [baseKey] : [cacheKey, baseKey];
213
+ await Promise.all(keys.map(async (key) => {
214
+ try {
215
+ await this.config.cacheAdapter.delete(key);
216
+ } catch (error) {
217
+ console.error("[PolicyFetcher] Failed to delete from external cache:", error);
218
+ }
219
+ }));
220
+ }
221
+ }
222
+ /**
223
+ * Clear all cached policies
224
+ */
225
+ clearCache() {
226
+ if (!this.config.disableMemoryCache) this.memoryCache.clear();
227
+ }
228
+ /**
229
+ * Check if a date string is expired
230
+ */
231
+ isExpired(dateString) {
232
+ return new Date(dateString).getTime() < Date.now();
233
+ }
234
+ };
235
+
236
+ //#endregion
237
+ export { PolicyFetcher, PolicyUnavailableError, isPolicyUnavailableError };
238
+ //# sourceMappingURL=fetcher.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetcher.mjs","names":[],"sources":["../../src/policy/fetcher.ts"],"sourcesContent":["/**\n * Policy Fetcher\n *\n * Runtime-agnostic policy fetching with caching support.\n * Works in Edge (Cloudflare Workers, Next.js Edge), Node.js, and browser environments.\n *\n * The fetcher supports:\n * - In-memory caching with TTL\n * - Origin reads for legacy adapters that cannot coordinate shared invalidation\n * - Fallback to default policy on errors\n * - Configurable API endpoints\n */\n\nimport { CACHE_TTL, DEFAULT_POLICY } from './constants';\nimport { PolicyConfigSchema, safeParsePolicyConfig } from './schemas';\nimport type { PolicyConfig } from './schemas';\n\n// ============================================================================\n// Types\n// ============================================================================\n\n/**\n * Legacy cache adapter interface retained for source compatibility.\n * Get/set alone cannot fence policy revocation across runtimes, so configured\n * adapters use fresh origin reads rather than selectable memory or external entries.\n */\nexport interface PolicyCacheAdapter {\n get(key: string): Promise<string | null>;\n set(key: string, value: string, ttlSeconds: number): Promise<void>;\n /** Optional cleanup of retired entries; invalidation does not depend on deletion. */\n delete?(key: string): Promise<boolean>;\n}\n\n/**\n * Configuration for the policy fetcher\n */\nexport interface PolicyFetcherConfig {\n /** Base URL for the policy API */\n apiBaseUrl: string;\n /** API key for authentication (optional) */\n apiKey?: string;\n /** Cache TTL in seconds (default: 300) */\n cacheTtlSeconds?: number;\n /** Legacy external adapter; loads use origin authority without cache hits. */\n cacheAdapter?: PolicyCacheAdapter;\n /** Disable in-memory caching (default: false) */\n disableMemoryCache?: boolean;\n /** Total policy-load timeout, including response parsing (default: 5000ms). */\n timeoutMs?: number;\n /** Reject origin failures as POLICY_UNAVAILABLE instead of returning DEFAULT_POLICY. */\n throwOnUnavailable?: boolean;\n /** Custom fetch function (for testing or custom transport) */\n fetchFn?: typeof fetch;\n}\n\n/**\n * Cached policy entry with metadata\n */\nexport interface CachedPolicy {\n policy: PolicyConfig;\n projectId: string;\n cachedAt: string;\n expiresAt: string;\n}\n\nfunction looksLikePolicyApiBody(data: unknown): data is Record<string, unknown> {\n if (typeof data !== 'object' || data === null) return false;\n const threshold = (data as { blockThreshold?: unknown }).blockThreshold;\n return typeof threshold === 'number' && Number.isFinite(threshold);\n}\n\n/**\n * The policy API serves the allow list as agent names (the `string[]` the\n * gateway Worker reads), while the policy schema models each entry as an\n * object. Read a name as `{ clientName }` before validating; anything else is\n * left for the schema to judge.\n */\nfunction fromPolicyApiBody(data: Record<string, unknown>): Record<string, unknown> {\n const { allowList } = data;\n if (!Array.isArray(allowList)) return data;\n return {\n ...data,\n allowList: allowList.map((entry: unknown) =>\n typeof entry === 'string' ? { clientName: entry } : entry\n ),\n };\n}\n\nexport class PolicyUnavailableError extends Error {\n readonly code = 'POLICY_UNAVAILABLE';\n\n constructor() {\n super('Current policy could not be loaded within the permitted bound');\n this.name = 'PolicyUnavailableError';\n }\n}\n\n/** Recognize the same failure across independently loaded SDK package copies. */\nexport function isPolicyUnavailableError(error: unknown): boolean {\n return (\n error instanceof Error &&\n error.name === 'PolicyUnavailableError' &&\n 'code' in error &&\n error.code === 'POLICY_UNAVAILABLE'\n );\n}\n\n// ============================================================================\n// In-Memory Cache\n// ============================================================================\n\n/**\n * Simple in-memory cache with TTL support\n */\nclass MemoryCache {\n private cache = new Map<string, { value: string; expiresAt: number }>();\n\n get(key: string): string | null {\n const entry = this.cache.get(key);\n if (!entry) {\n return null;\n }\n\n if (Date.now() > entry.expiresAt) {\n this.cache.delete(key);\n return null;\n }\n\n return entry.value;\n }\n\n set(key: string, value: string, ttlSeconds: number): void {\n this.cache.set(key, {\n value,\n expiresAt: Date.now() + ttlSeconds * 1000,\n });\n }\n\n delete(key: string): boolean {\n return this.cache.delete(key);\n }\n\n clear(): void {\n this.cache.clear();\n }\n}\n\n// Global in-memory cache instance\nconst globalMemoryCache = new MemoryCache();\n// Share invalidation with other fetchers using the same backend, TTL and project.\nconst globalPolicyCacheKeys = new Map<string, string>();\nconst fallbackCachePrefix = `${Date.now().toString(36)}:${Math.random().toString(36).slice(2)}:${Math.random().toString(36).slice(2)}`;\nlet fallbackCacheSequence = 0;\n\nfunction nextCacheRevision(): string {\n // This token only separates cache generations; it is not an authentication secret.\n return globalThis.crypto?.randomUUID?.() ?? `${fallbackCachePrefix}:${++fallbackCacheSequence}`;\n}\n\n// ============================================================================\n// Policy Fetcher Class\n// ============================================================================\n\n/**\n * Policy fetcher with caching and fallback support\n */\nexport class PolicyFetcher {\n private config: Required<Omit<PolicyFetcherConfig, 'cacheAdapter' | 'apiKey'>> & {\n cacheAdapter?: PolicyCacheAdapter;\n apiKey?: string;\n };\n private memoryCache: MemoryCache;\n\n constructor(config: PolicyFetcherConfig) {\n this.config = {\n apiBaseUrl: config.apiBaseUrl,\n apiKey: config.apiKey,\n cacheTtlSeconds: config.cacheTtlSeconds ?? CACHE_TTL.POLICY,\n cacheAdapter: config.cacheAdapter,\n disableMemoryCache: config.disableMemoryCache ?? false,\n timeoutMs: config.timeoutMs ?? 5000,\n throwOnUnavailable: config.throwOnUnavailable ?? false,\n fetchFn: config.fetchFn ?? globalThis.fetch,\n };\n this.memoryCache = config.disableMemoryCache ? new MemoryCache() : globalMemoryCache;\n }\n\n /**\n * Generate a cache key that includes the API base URL and TTL to prevent\n * cache collisions when multiple fetchers use different backends or TTL settings.\n */\n private getBaseCacheKey(projectId: string): string {\n // Use a hash of the apiBaseUrl to keep keys reasonably short\n const urlHash = this.config.apiBaseUrl\n .split('')\n .reduce((hash, char) => ((hash << 5) - hash + char.charCodeAt(0)) | 0, 0)\n .toString(36);\n // Include TTL in key to prevent cross-fetcher cache interference\n // (fetcher with TTL=60 shouldn't read cache written by fetcher with TTL=300)\n return `policy:${urlHash}:${this.config.cacheTtlSeconds}:${projectId}`;\n }\n\n private getCacheKey(projectId: string): string {\n const baseKey = this.getBaseCacheKey(projectId);\n return globalPolicyCacheKeys.get(baseKey) ?? baseKey;\n }\n\n /**\n * Get policy for a project, with caching\n */\n async getPolicy(projectId: string): Promise<PolicyConfig> {\n const deadline = Date.now() + this.config.timeoutMs;\n if (!Number.isFinite(deadline) || this.config.timeoutMs <= 0)\n throw new PolicyUnavailableError();\n const controller = new AbortController();\n const requireActiveLoad = () => {\n if (controller.signal.aborted || Date.now() >= deadline) throw new PolicyUnavailableError();\n };\n let timer: ReturnType<typeof setTimeout> | undefined;\n const expired = new Promise<never>((_resolve, reject) => {\n timer = setTimeout(() => {\n const failure = new PolicyUnavailableError();\n controller.abort(failure);\n reject(failure);\n }, this.config.timeoutMs);\n });\n // Without shared revision coordination, neither a peer's entry nor a local\n // memory hit can prove current authority. Keep legacy adapters compatible\n // by using origin reads, while preserving local-only memory caching.\n const useMemoryCache = !this.config.disableMemoryCache && !this.config.cacheAdapter;\n try {\n for (let attempt = 0; attempt < 4; attempt++) {\n requireActiveLoad();\n const cacheKey = this.getCacheKey(projectId);\n if (useMemoryCache) {\n const memoryCached = this.memoryCache.get(cacheKey);\n if (memoryCached) {\n const cached = JSON.parse(memoryCached) as CachedPolicy;\n requireActiveLoad();\n if (!this.isExpired(cached.expiresAt)) return cached.policy;\n }\n }\n try {\n const policy = await Promise.race([\n this.fetchPolicyFromApi(projectId, controller.signal),\n expired,\n ]);\n requireActiveLoad();\n if (cacheKey !== this.getCacheKey(projectId)) continue;\n if (useMemoryCache) {\n const now = new Date();\n const cached: CachedPolicy = {\n policy,\n projectId,\n cachedAt: now.toISOString(),\n expiresAt: new Date(now.getTime() + this.config.cacheTtlSeconds * 1000).toISOString(),\n };\n const cacheValue = JSON.stringify(cached);\n requireActiveLoad();\n this.memoryCache.set(cacheKey, cacheValue, this.config.cacheTtlSeconds);\n }\n requireActiveLoad();\n return policy;\n } catch (error) {\n requireActiveLoad();\n if (isPolicyUnavailableError(error)) throw error;\n if (cacheKey !== this.getCacheKey(projectId)) continue;\n console.error(`[PolicyFetcher] Failed to fetch policy for ${projectId}:`, error);\n if (this.config.throwOnUnavailable) throw new PolicyUnavailableError();\n return this.getDefaultPolicy();\n }\n }\n throw new PolicyUnavailableError();\n } finally {\n if (timer !== undefined) clearTimeout(timer);\n }\n }\n\n /**\n * Fetch policy from the API\n */\n private async fetchPolicyFromApi(projectId: string, signal: AbortSignal): Promise<PolicyConfig> {\n const url = `${this.config.apiBaseUrl}/api/internal/policies/${projectId}`;\n\n const headers: Record<string, string> = {\n 'Content-Type': 'application/json',\n 'User-Agent': 'AgentShield-PolicyFetcher/1.0',\n };\n\n if (this.config.apiKey) {\n headers['Authorization'] = `Bearer ${this.config.apiKey}`;\n }\n\n const response = await this.config.fetchFn(url, {\n method: 'GET',\n headers,\n signal,\n // Origin responses permit HTTP caching; it must not restore retired authority.\n cache: 'no-store',\n });\n\n if (!response.ok) {\n throw new Error(`API returned ${response.status}: ${response.statusText}`);\n }\n\n const data = await response.json();\n\n // The API response contract requires this field; schemas also accept\n // partial user config, so validate the wire shape before applying defaults.\n if (!looksLikePolicyApiBody(data)) {\n throw new Error('Policy response is not from the policy API');\n }\n\n // Parse and validate the response\n const policy = safeParsePolicyConfig(fromPolicyApiBody(data));\n if (!policy) {\n throw new Error('Invalid policy response format');\n }\n\n return policy;\n }\n\n /**\n * Get the default policy\n */\n getDefaultPolicy(): PolicyConfig {\n return PolicyConfigSchema.parse(DEFAULT_POLICY);\n }\n\n /**\n * Retire this runtime's cached policy key before any asynchronous cleanup.\n * Older reads and writes cannot restore the retired entry for these fetchers.\n */\n async invalidateCache(projectId: string): Promise<void> {\n const cacheKey = this.getCacheKey(projectId);\n const baseKey = this.getBaseCacheKey(projectId);\n globalPolicyCacheKeys.set(baseKey, `${baseKey}:${nextCacheRevision()}`);\n\n // Retire shared memory even when this caller does not read memory entries.\n globalMemoryCache.delete(cacheKey);\n\n // Clear external cache if adapter supports delete\n if (this.config.cacheAdapter?.delete) {\n const keys = cacheKey === baseKey ? [baseKey] : [cacheKey, baseKey];\n await Promise.all(\n keys.map(async (key) => {\n try {\n await this.config.cacheAdapter!.delete!(key);\n } catch (error) {\n console.error('[PolicyFetcher] Failed to delete from external cache:', error);\n }\n })\n );\n }\n }\n\n /**\n * Clear all cached policies\n */\n clearCache(): void {\n if (!this.config.disableMemoryCache) {\n this.memoryCache.clear();\n }\n }\n\n /**\n * Check if a date string is expired\n */\n private isExpired(dateString: string): boolean {\n return new Date(dateString).getTime() < Date.now();\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAiEA,SAAS,uBAAuB,MAAgD;CAC9E,IAAI,OAAO,SAAS,YAAY,SAAS,MAAM,OAAO;CACtD,MAAM,YAAa,KAAsC;CACzD,OAAO,OAAO,cAAc,YAAY,OAAO,SAAS,SAAS;AACnE;;;;;;;AAQA,SAAS,kBAAkB,MAAwD;CACjF,MAAM,EAAE,cAAc;CACtB,IAAI,CAAC,MAAM,QAAQ,SAAS,GAAG,OAAO;CACtC,OAAO;EACL,GAAG;EACH,WAAW,UAAU,KAAK,UACxB,OAAO,UAAU,WAAW,EAAE,YAAY,MAAM,IAAI,KACtD;CACF;AACF;AAEA,IAAa,yBAAb,cAA4C,MAAM;CAChD,AAAS,OAAO;CAEhB,cAAc;EACZ,MAAM,+DAA+D;EACrE,KAAK,OAAO;CACd;AACF;;AAGA,SAAgB,yBAAyB,OAAyB;CAChE,OACE,iBAAiB,SACjB,MAAM,SAAS,4BACf,UAAU,SACV,MAAM,SAAS;AAEnB;;;;AASA,IAAM,cAAN,MAAkB;CAChB,AAAQ,wBAAQ,IAAI,IAAkD;CAEtE,IAAI,KAA4B;EAC9B,MAAM,QAAQ,KAAK,MAAM,IAAI,GAAG;EAChC,IAAI,CAAC,OACH,OAAO;EAGT,IAAI,KAAK,IAAI,IAAI,MAAM,WAAW;GAChC,KAAK,MAAM,OAAO,GAAG;GACrB,OAAO;EACT;EAEA,OAAO,MAAM;CACf;CAEA,IAAI,KAAa,OAAe,YAA0B;EACx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ACtD,MAAM,WAAW,KAAK,YAAY,SAAS;EAC3C,MAAM,UAAU,KAAK,gBAAgB,SAAS;EAC9C,sBAAsB,IAAI,SAAS,GAAG,QAAQ,GAAG,kBAAkB,GAAG;EAGtE,kBAAkB,OAAO,QAAQ;EAGjC,IAAI,KAAK,OAAO,cAAc,QAAQ;GACpC,MAAM,OAAO,aAAa,UAAU,CAAC,OAAO,IAAI,CAAC,UAAU,OAAO;GAClE,MAAM,QAAQ,IACZ,KAAK,IAAI,OAAO,QAAQ;IACtB,IAAI;KACF,MAAM,KAAK,OAAO,aAAc,OAAQ,GAAG;IAC7C,SAAS,OAAO;KACd,QAAQ,MAAM,yDAAyD,KAAK;IAC9E;GACF,CAAC,CACH;EACF;CACF;;;;CAKA,aAAmB;EACjB,IAAI,CAAC,KAAK,OAAO,oBACf,KAAK,YAAY,MAAM;CAE3B;;;;CAKA,AAAQ,UAAU,YAA6B;EAC7C,OAAO,IAAI,KAAK,UAAU,CAAC,CAAC,QAAQ,IAAI,KAAK,IAAI;CACnD;AACF"}
@@ -0,0 +1,3 @@
1
+ import { n as normalizeChallengeType, t as isEngineEnforcing } from "../engine-enforcing-DiOclGqf.mjs";
2
+ import { A as PolicyMetadataSchema, B as ThresholdConfigSchema, C as InstructPayload, D as PolicyConfig, E as PolicyConditionSchema, F as RuleMetadata, I as RuleMetadataSchema, L as SuggestedAction, M as PolicyRuleSchema, N as RedirectTarget, O as PolicyConfigSchema, P as RedirectTargetSchema, R as SuggestedActionSchema, S as EnforcementModeSchema, T as PolicyCondition, V as safeParsePolicyConfig, _ as DenyListEntry, a as BlockReason, b as EnforcementActionSchema, c as ChallengeParamsSchema, d as ConditionOperator, f as ConditionOperatorSchema, g as DecisionSchema, h as Decision, i as AssuranceTierSchema, j as PolicyRule, k as PolicyMetadata, l as ConditionField, m as ConditionValueSchema, n as AllowListEntrySchema, o as BlockReasonSchema, p as ConditionValue, r as AssuranceTier, s as ChallengeParams, t as AllowListEntry, u as ConditionFieldSchema, v as DenyListEntrySchema, w as InstructPayloadSchema, x as EnforcementMode, y as EnforcementAction, z as ThresholdConfig } from "../schemas-02CI7jgm.mjs";
3
+ export { AllowListEntry, AllowListEntrySchema, AssuranceTier, AssuranceTierSchema, BlockReason, BlockReasonSchema, ChallengeParams, ChallengeParamsSchema, ConditionField, ConditionFieldSchema, ConditionOperator, ConditionOperatorSchema, ConditionValue, ConditionValueSchema, Decision, DecisionSchema, DenyListEntry, DenyListEntrySchema, EnforcementAction, EnforcementActionSchema, EnforcementMode, EnforcementModeSchema, InstructPayload, InstructPayloadSchema, PolicyCondition, PolicyConditionSchema, PolicyConfig, PolicyConfigSchema, PolicyMetadata, PolicyMetadataSchema, PolicyRule, PolicyRuleSchema, RedirectTarget, RedirectTargetSchema, RuleMetadata, RuleMetadataSchema, SuggestedAction, SuggestedActionSchema, ThresholdConfig, ThresholdConfigSchema, isEngineEnforcing, normalizeChallengeType, safeParsePolicyConfig };
@@ -0,0 +1,3 @@
1
+ import { n as normalizeChallengeType, t as isEngineEnforcing } from "../engine-enforcing-DiOclGqf.js";
2
+ import { A as PolicyMetadataSchema, B as ThresholdConfigSchema, C as InstructPayload, D as PolicyConfig, E as PolicyConditionSchema, F as RuleMetadata, I as RuleMetadataSchema, L as SuggestedAction, M as PolicyRuleSchema, N as RedirectTarget, O as PolicyConfigSchema, P as RedirectTargetSchema, R as SuggestedActionSchema, S as EnforcementModeSchema, T as PolicyCondition, V as safeParsePolicyConfig, _ as DenyListEntry, a as BlockReason, b as EnforcementActionSchema, c as ChallengeParamsSchema, d as ConditionOperator, f as ConditionOperatorSchema, g as DecisionSchema, h as Decision, i as AssuranceTierSchema, j as PolicyRule, k as PolicyMetadata, l as ConditionField, m as ConditionValueSchema, n as AllowListEntrySchema, o as BlockReasonSchema, p as ConditionValue, r as AssuranceTier, s as ChallengeParams, t as AllowListEntry, u as ConditionFieldSchema, v as DenyListEntrySchema, w as InstructPayloadSchema, x as EnforcementMode, y as EnforcementAction, z as ThresholdConfig } from "../schemas-C_3C72SR.js";
3
+ export { AllowListEntry, AllowListEntrySchema, AssuranceTier, AssuranceTierSchema, BlockReason, BlockReasonSchema, ChallengeParams, ChallengeParamsSchema, ConditionField, ConditionFieldSchema, ConditionOperator, ConditionOperatorSchema, ConditionValue, ConditionValueSchema, Decision, DecisionSchema, DenyListEntry, DenyListEntrySchema, EnforcementAction, EnforcementActionSchema, EnforcementMode, EnforcementModeSchema, InstructPayload, InstructPayloadSchema, PolicyCondition, PolicyConditionSchema, PolicyConfig, PolicyConfigSchema, PolicyMetadata, PolicyMetadataSchema, PolicyRule, PolicyRuleSchema, RedirectTarget, RedirectTargetSchema, RuleMetadata, RuleMetadataSchema, SuggestedAction, SuggestedActionSchema, ThresholdConfig, ThresholdConfigSchema, isEngineEnforcing, normalizeChallengeType, safeParsePolicyConfig };
@@ -0,0 +1,27 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_schemas = require('../schemas-Cm4C4Z5G.js');
3
+ const require_engine_enforcing = require('../engine-enforcing-AYEcgNsb.js');
4
+
5
+ exports.AllowListEntrySchema = require_schemas.AllowListEntrySchema;
6
+ exports.AssuranceTierSchema = require_schemas.AssuranceTierSchema;
7
+ exports.BlockReasonSchema = require_schemas.BlockReasonSchema;
8
+ exports.ChallengeParamsSchema = require_schemas.ChallengeParamsSchema;
9
+ exports.ConditionFieldSchema = require_schemas.ConditionFieldSchema;
10
+ exports.ConditionOperatorSchema = require_schemas.ConditionOperatorSchema;
11
+ exports.ConditionValueSchema = require_schemas.ConditionValueSchema;
12
+ exports.DecisionSchema = require_schemas.DecisionSchema;
13
+ exports.DenyListEntrySchema = require_schemas.DenyListEntrySchema;
14
+ exports.EnforcementActionSchema = require_schemas.EnforcementActionSchema;
15
+ exports.EnforcementModeSchema = require_schemas.EnforcementModeSchema;
16
+ exports.InstructPayloadSchema = require_schemas.InstructPayloadSchema;
17
+ exports.PolicyConditionSchema = require_schemas.PolicyConditionSchema;
18
+ exports.PolicyConfigSchema = require_schemas.PolicyConfigSchema;
19
+ exports.PolicyMetadataSchema = require_schemas.PolicyMetadataSchema;
20
+ exports.PolicyRuleSchema = require_schemas.PolicyRuleSchema;
21
+ exports.RedirectTargetSchema = require_schemas.RedirectTargetSchema;
22
+ exports.RuleMetadataSchema = require_schemas.RuleMetadataSchema;
23
+ exports.SuggestedActionSchema = require_schemas.SuggestedActionSchema;
24
+ exports.ThresholdConfigSchema = require_schemas.ThresholdConfigSchema;
25
+ exports.isEngineEnforcing = require_engine_enforcing.isEngineEnforcing;
26
+ exports.normalizeChallengeType = require_engine_enforcing.normalizeChallengeType;
27
+ exports.safeParsePolicyConfig = require_schemas.safeParsePolicyConfig;
@@ -0,0 +1,4 @@
1
+ import { _ as RedirectTargetSchema, a as ConditionFieldSchema, b as ThresholdConfigSchema, c as DecisionSchema, d as EnforcementModeSchema, f as InstructPayloadSchema, g as PolicyRuleSchema, h as PolicyMetadataSchema, i as ChallengeParamsSchema, l as DenyListEntrySchema, m as PolicyConfigSchema, n as AssuranceTierSchema, o as ConditionOperatorSchema, p as PolicyConditionSchema, r as BlockReasonSchema, s as ConditionValueSchema, t as AllowListEntrySchema, u as EnforcementActionSchema, v as RuleMetadataSchema, x as safeParsePolicyConfig, y as SuggestedActionSchema } from "../schemas-DPIT8usF.mjs";
2
+ import { n as normalizeChallengeType, t as isEngineEnforcing } from "../engine-enforcing-B5eNfCpG.mjs";
3
+
4
+ export { AllowListEntrySchema, AssuranceTierSchema, BlockReasonSchema, ChallengeParamsSchema, ConditionFieldSchema, ConditionOperatorSchema, ConditionValueSchema, DecisionSchema, DenyListEntrySchema, EnforcementActionSchema, EnforcementModeSchema, InstructPayloadSchema, PolicyConditionSchema, PolicyConfigSchema, PolicyMetadataSchema, PolicyRuleSchema, RedirectTargetSchema, RuleMetadataSchema, SuggestedActionSchema, ThresholdConfigSchema, isEngineEnforcing, normalizeChallengeType, safeParsePolicyConfig };
@@ -1,174 +1,3 @@
1
- //#region src/constants/patterns.ts
2
- /**
3
- * Regular Expression Patterns
4
- *
5
- * Common regex patterns used for validation and detection
6
- */
7
- /**
8
- * Validation Patterns
9
- */
10
- const UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
11
- const VALIDATION_PATTERNS = {
12
- UUID: UUID_PATTERN,
13
- ULID: /^[0-9A-HJKMNP-TV-Z]{26}$/,
14
- SLUG: /^[a-z0-9]+(?:-[a-z0-9]+)*$/,
15
- IPV4: /^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/,
16
- IPV6: /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,
17
- IP: /^(?:(?:25[0-5]|2[0-4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-9])?)+$/,
23
- PHONE: /^[+]?[(]?[0-9]{3}[)]?[-\s.]?[0-9]{3}[-\s.]?[0-9]{4,6}$/,
24
- JWT: /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+$/,
25
- BASE64: /^[A-Za-z0-9+\/]*={0,2}$/,
26
- HEX: /^[0-9a-fA-F]+$/,
27
- MD5: /^[a-f0-9]{32}$/i,
28
- SHA1: /^[a-f0-9]{40}$/i,
29
- SHA256: /^[a-f0-9]{64}$/i,
30
- SEMVER: /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/,
31
- FILENAME: /^[a-zA-Z0-9](?:[a-zA-Z0-9 ._-]*[a-zA-Z0-9])?\.[a-zA-Z0-9_-]+$/,
32
- PATH: /^(\/[^/ ]*)+\/?$/,
33
- API_KEY: /^[A-Za-z0-9_-]{32,}$/,
34
- SECRET_KEY: /^[A-Za-z0-9_-]{64,}$/,
35
- PIXEL_ID: /^px_[A-Za-z0-9]{16}$/
36
- };
37
- /**
38
- * User Agent Patterns for Agent Detection
39
- */
40
- const USER_AGENT_PATTERNS = {
41
- OPENAI: /(?:GPTBot|ChatGPT-User|OpenAI)/i,
42
- ANTHROPIC: /(?:Claude-Web|Claude-User|anthropic-ai|claude-web|claude-user|ClaudeBot)/i,
43
- PERPLEXITY: /(?:PerplexityBot|Perplexica)/i,
44
- GOOGLE_AI: /(?:Bard|Google-InspectionTool)/i,
45
- MICROSOFT_AI: /(?:BingPreview\/.*ChatGPT|Copilot)/i,
46
- GOOGLEBOT: /Googlebot/i,
47
- BINGBOT: /(?:bingbot|BingPreview|msnbot)/i,
48
- DUCKDUCKBOT: /DuckDuckBot/i,
49
- BAIDUBOT: /Baiduspider/i,
50
- YANDEXBOT: /YandexBot/i,
51
- FACEBOOK: /(?:facebookexternalhit|facebookcatalog)/i,
52
- TWITTER: /(?:Twitterbot|TwitterImageProxy)/i,
53
- LINKEDIN: /LinkedInBot/i,
54
- WHATSAPP: /WhatsApp/i,
55
- TELEGRAM: /TelegramBot/i,
56
- DISCORD: /Discordbot/i,
57
- SLACK: /Slackbot/i,
58
- GENERIC_BOT: /(?:bot|crawler|spider|scraper|agent)/i,
59
- SCRAPY: /Scrapy/i,
60
- PUPPETEER: /(?:HeadlessChrome|Puppeteer)/i,
61
- PLAYWRIGHT: /Playwright/i,
62
- SELENIUM: /(?:selenium|webdriver)/i,
63
- POSTMAN: /PostmanRuntime/i,
64
- INSOMNIA: /insomnia/i,
65
- CURL: /curl/i,
66
- WGET: /Wget/i,
67
- HTTPIE: /HTTPie/i,
68
- UPTIMEROBOT: /UptimeRobot/i,
69
- PINGDOM: /Pingdom/i,
70
- NEWRELIC: /NewRelicPinger/i,
71
- DATADOG: /Datadog/i
72
- };
73
- /**
74
- * Header Patterns for Agent Detection
75
- */
76
- const HEADER_PATTERNS = {
77
- AI_HEADERS: /^(?:X-(?:OpenAI|Anthropic|AI|Bot|Agent|LLM))/i,
78
- AUTOMATION_HEADERS: /^(?:X-(?:Automated|Robot|Crawler|Scraper))/i,
79
- MISSING_ACCEPT: /^$/,
80
- MISSING_ACCEPT_LANGUAGE: /^$/,
81
- MISSING_ACCEPT_ENCODING: /^$/,
82
- GENERIC_ACCEPT: /^\*\/\*$/,
83
- NO_COOKIES: /^$/,
84
- PROXY_HEADERS: /^(?:X-Forwarded-|X-Real-IP|X-Originating-IP|Via|Forwarded)/i,
85
- CLOUD_HEADERS: /^(?:X-(?:AWS|Azure|GCP|Cloudflare))/i
86
- };
87
- /**
88
- * Browser Patterns
89
- */
90
- const BROWSER_PATTERNS = {
91
- CHROME: /Chrome\/([0-9.]+)/,
92
- FIREFOX: /Firefox\/([0-9.]+)/,
93
- SAFARI: /Version\/([0-9.]+).*Safari/,
94
- EDGE: /Edg\/([0-9.]+)/,
95
- OPERA: /OPR\/([0-9.]+)/,
96
- IE: /MSIE ([0-9.]+)/
97
- };
98
- /**
99
- * Operating System Patterns
100
- */
101
- const OS_PATTERNS = {
102
- WINDOWS: /Windows NT ([0-9.]+)/,
103
- MACOS: /Mac OS X ([0-9_]+)/,
104
- LINUX: /Linux/,
105
- ANDROID: /Android ([0-9.]+)/,
106
- IOS: /OS ([0-9_]+) like Mac OS X/
107
- };
108
- /**
109
- * Mobile Device Patterns
110
- */
111
- const MOBILE_PATTERNS = {
112
- MOBILE: /(?:Mobile|Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini)/i,
113
- TABLET: /(?:iPad|Android.*Tablet|Tablet.*Android|Kindle|Silk)/i,
114
- DESKTOP: /(?:Windows NT|Mac OS X|Linux|CrOS)/i
115
- };
116
- /**
117
- * Suspicious Behavior Patterns
118
- */
119
- const SUSPICIOUS_PATTERNS = {
120
- RAPID_REQUESTS: /^[0-9]{1,3}$/,
121
- SEQUENTIAL_URLS: /\?(?:page|offset|id)=[0-9]+/,
122
- API_ENDPOINTS: /\/api\/|\.json$|\.xml$/i,
123
- DIRECT_POST: /^POST$/,
124
- SQL_INJECTION: /(?:union|select|insert|update|delete|drop|create|alter|exec|script|javascript|onerror|onload|eval|src=)/i,
125
- XSS_ATTEMPT: /(?:<script|javascript:|onerror=|onclick=|<iframe|<embed|<object)/i,
126
- PATH_TRAVERSAL: /(?:\.\.\/|\.\.\\|%2e%2e%2f|%252e%252e%252f)/i,
127
- URL_ENCODED: /%[0-9a-f]{2}/i,
128
- BASE64_DATA: /data:[^;]+;base64,/i
129
- };
130
- /**
131
- * Maximum input length for pattern matching. UAs, header values, and
132
- * detection payloads are bounded in practice (<4KB even for the most
133
- * verbose Chrome/Firefox UAs). Caps worst-case complexity for any
134
- * polynomial-shaped pattern an external caller might supply to
135
- * `testPattern` / `extractMatch`; CodeQL flagged the unbounded path
136
- * (js/polynomial-redos) on PR #2576.
137
- */
138
- const MAX_PATTERN_INPUT_LENGTH = 4096;
139
- /**
140
- * Helper function to test a pattern. Returns `false` on inputs longer
141
- * than {@link MAX_PATTERN_INPUT_LENGTH} — an abuse signal we'd rather
142
- * reject than process.
143
- */
144
- function testPattern(pattern, value) {
145
- if (value.length > MAX_PATTERN_INPUT_LENGTH) return false;
146
- return pattern.test(value);
147
- }
148
- /**
149
- * Helper function to extract match from pattern. Returns `null` on
150
- * over-long inputs (same ReDoS defense as `testPattern`).
151
- */
152
- function extractMatch(pattern, value) {
153
- if (value.length > MAX_PATTERN_INPUT_LENGTH) return null;
154
- const match = value.match(pattern);
155
- return match ? match[1] || match[0] : null;
156
- }
157
- /**
158
- * Helper function to test multiple patterns
159
- */
160
- function testPatterns(patterns, value) {
161
- return patterns.some((pattern) => testPattern(pattern, value));
162
- }
163
- /**
164
- * Helper function to find matching pattern
165
- */
166
- function findMatchingPattern(patterns, value) {
167
- for (const [name, pattern] of Object.entries(patterns)) if (testPattern(pattern, value)) return name;
168
- return null;
169
- }
170
-
171
- //#endregion
172
1
  //#region src/posture-origins/index.ts
173
2
  /**
174
3
  * Posture origins: which page origins a project's browser posture token may
@@ -529,5 +358,27 @@ function matchAllowedOrigin(pageOrigin, allowed) {
529
358
  }
530
359
 
531
360
  //#endregion
532
- export { BROWSER_PATTERNS as a, OS_PATTERNS as c, UUID_PATTERN as d, VALIDATION_PATTERNS as f, testPatterns as g, testPattern as h, validatePostureOrigins as i, SUSPICIOUS_PATTERNS as l, findMatchingPattern as m, matchAllowedOrigin as n, HEADER_PATTERNS as o, extractMatch as p, parseOriginPattern as r, MOBILE_PATTERNS as s, isPublicSuffixLike as t, USER_AGENT_PATTERNS as u };
533
- //# sourceMappingURL=posture-origins-Ba83O0cD.mjs.map
361
+ Object.defineProperty(exports, 'isPublicSuffixLike', {
362
+ enumerable: true,
363
+ get: function () {
364
+ return isPublicSuffixLike;
365
+ }
366
+ });
367
+ Object.defineProperty(exports, 'matchAllowedOrigin', {
368
+ enumerable: true,
369
+ get: function () {
370
+ return matchAllowedOrigin;
371
+ }
372
+ });
373
+ Object.defineProperty(exports, 'parseOriginPattern', {
374
+ enumerable: true,
375
+ get: function () {
376
+ return parseOriginPattern;
377
+ }
378
+ });
379
+ Object.defineProperty(exports, 'validatePostureOrigins', {
380
+ enumerable: true,
381
+ get: function () {
382
+ return validatePostureOrigins;
383
+ }
384
+ });