@jeffusion/bungee-core 5.17.0 → 5.19.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 (46) hide show
  1. package/dist/config-storage/gateway-target-validation.d.ts +5 -0
  2. package/dist/gateway/contracts.d.ts +29 -2
  3. package/dist/gateway/dispatch-plugin.d.ts +7 -0
  4. package/dist/gateway/dispatch-targets.d.ts +4 -0
  5. package/dist/gateway/plugin.js +2 -0
  6. package/dist/gateway/routing-plugin.d.ts +3 -1
  7. package/dist/hooks/plugin-hooks.d.ts +3 -1
  8. package/dist/main.js +271 -82
  9. package/dist/plugin-extensions.d.ts +2 -0
  10. package/dist/plugin.types.d.ts +1 -1
  11. package/dist/plugins/ai-transformer/index.js.map +3 -3
  12. package/dist/plugins/anthropic-request-sanitizer/index.js.map +3 -3
  13. package/dist/plugins/anthropic-tool-name-transformer/index.js.map +3 -3
  14. package/dist/plugins/chatgpt-oauth/control.js.map +1 -1
  15. package/dist/plugins/chatgpt-oauth/index.js +7 -4
  16. package/dist/plugins/chatgpt-oauth/index.js.map +5 -5
  17. package/dist/plugins/codex-router/control.js +49 -0
  18. package/dist/plugins/codex-router/control.js.map +11 -0
  19. package/dist/plugins/codex-router/index.js +495 -0
  20. package/dist/plugins/codex-router/index.js.map +28 -0
  21. package/dist/plugins/codex-router/manifest.json +149 -0
  22. package/dist/plugins/deepseek-reasoning-fix/index.js.map +3 -3
  23. package/dist/plugins/key-access/control.js.map +2 -2
  24. package/dist/plugins/key-access/index.js +14 -10
  25. package/dist/plugins/key-access/index.js.map +5 -5
  26. package/dist/plugins/key-access/ingress.js +14 -10
  27. package/dist/plugins/key-access/ingress.js.map +4 -4
  28. package/dist/plugins/key-rate-limit/index.js.map +3 -3
  29. package/dist/plugins/local-accounts/control.js.map +1 -1
  30. package/dist/plugins/local-accounts/index.js.map +3 -3
  31. package/dist/plugins/model-mapping/control.js.map +1 -1
  32. package/dist/plugins/model-mapping/index.js.map +4 -4
  33. package/dist/plugins/models-dev/control.js +24 -1
  34. package/dist/plugins/models-dev/control.js.map +5 -5
  35. package/dist/plugins/models-dev/index.js +24 -1
  36. package/dist/plugins/models-dev/index.js.map +7 -7
  37. package/dist/plugins/models-dev/manifest.json +12 -0
  38. package/dist/plugins/openai-messages-to-chat/index.js.map +3 -3
  39. package/dist/plugins/signature-repair/index.js.map +3 -3
  40. package/dist/plugins/token-budget/control.js.map +1 -1
  41. package/dist/plugins/token-budget/index.js.map +3 -3
  42. package/dist/plugins/token-metering/index.js.map +3 -3
  43. package/dist/plugins/token-stats/control.js.map +2 -2
  44. package/dist/plugins/token-stats/index.js.map +4 -4
  45. package/dist/scoped-plugin-registry.d.ts +1 -0
  46. package/package.json +2 -2
@@ -192,10 +192,13 @@ function matchesModel(pattern, model) {
192
192
  }
193
193
  return cursor <= end;
194
194
  }
195
- function check(target, policy) {
195
+ function protectedScopes(target, publication) {
196
+ return [...new Set([target.entryRouteId, target.routeId].filter((id) => !!id && publication.protectedRouteIds.includes(id)))];
197
+ }
198
+ function check(target, policy, scopes = [target.routeId]) {
196
199
  if (target.principal.domain === "anonymous")
197
200
  return null;
198
- if (policy && (policy.routes !== null && !policy.routes.includes(target.routeId) || policy.models !== null && (!target.model || !policy.models.some((pattern) => matchesModel(pattern, target.model)))))
201
+ if (policy && (policy.routes !== null && !scopes.every((id) => policy.routes.includes(id)) || policy.models !== null && (!target.model || !policy.models.some((pattern) => matchesModel(pattern, target.model)))))
199
202
  return { error: "key-access.scope_denied", status: 403 };
200
203
  return null;
201
204
  }
@@ -203,7 +206,7 @@ function createIngress() {
203
206
  return {
204
207
  bodyRequirements(target, value) {
205
208
  const publication = validatePublication(value);
206
- if (!publication.protectedRouteIds.includes(target.routeId) || target.principal.domain !== "data")
209
+ if (protectedScopes(target, publication).length === 0 || target.principal.domain !== "data")
207
210
  return { request: "none" };
208
211
  const policy = validatePolicy(publication.byKey[target.principal.keyId] ?? null);
209
212
  const urlModel = /\/models\/([^/:]+):(?:streamGenerateContent|generateContent)$/.test(new URL(target.url).pathname);
@@ -223,7 +226,7 @@ function createIngress() {
223
226
  },
224
227
  resolveIdentity(target, value) {
225
228
  const p = validatePublication(value);
226
- if (!p.protectedRouteIds.includes(target.routeId))
229
+ if (protectedScopes(target, p).length === 0)
227
230
  return ANONYMOUS_PRINCIPAL;
228
231
  if (!validPrincipal(target.principal, p, target.now))
229
232
  throw new DataAdmissionError(401, "unauthorized");
@@ -232,13 +235,14 @@ function createIngress() {
232
235
  plan(target, value) {
233
236
  try {
234
237
  const p = validatePublication(value);
235
- if (!p.protectedRouteIds.includes(target.routeId))
238
+ if (protectedScopes(target, p).length === 0)
236
239
  return { snapshot: null };
237
240
  if (target.principal.domain === "anonymous")
238
241
  return { denial: { error: "unauthorized", status: 401 } };
239
242
  const policy = validatePolicy(p.byKey[target.principal.keyId] ?? null);
240
- const denial = check(target, policy);
241
- return denial ? { denial } : { snapshot: { routeId: target.routeId, policy } };
243
+ const scopes = protectedScopes(target, p);
244
+ const denial = check(target, policy, scopes);
245
+ return denial ? { denial } : { snapshot: { routeId: target.routeId, entryRouteId: target.entryRouteId ?? null, scopes, policy } };
242
246
  } catch {
243
247
  return { denial: { error: "key-access.policy_unavailable", status: 503 } };
244
248
  }
@@ -248,9 +252,9 @@ function createIngress() {
248
252
  return target.principal.domain === "anonymous" ? null : { error: "key-access.invalid_grant", status: 503 };
249
253
  try {
250
254
  const s = snapshot;
251
- if (!s || s.routeId !== target.routeId)
255
+ if (!s || s.routeId !== target.routeId || (s.entryRouteId ?? null) !== (target.entryRouteId ?? null))
252
256
  return { error: "key-access.scope_denied", status: 403 };
253
- return check(target, validatePolicy(s.policy));
257
+ return check(target, validatePolicy(s.policy), s.scopes ?? [target.routeId]);
254
258
  } catch {
255
259
  return { error: "key-access.policy_unavailable", status: 503 };
256
260
  }
@@ -288,4 +292,4 @@ export {
288
292
  server_default as default
289
293
  };
290
294
 
291
- //# debugId=056D3A1723CAF0EC64756E2164756E21
295
+ //# debugId=55B327A8EE449A7A64756E2164756E21