@kedge/server 0.10.1 → 0.11.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kedge/server",
3
- "version": "0.10.1",
3
+ "version": "0.11.0",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -22,8 +22,8 @@
22
22
  "hono": "4.13.13",
23
23
  "@hono/zod-openapi": "1.6.3",
24
24
  "zod": "4.6.7",
25
- "@kedge/core": "0.10.1",
26
- "@kedge/plugin-sdk": "0.10.1"
25
+ "@kedge/core": "0.11.0",
26
+ "@kedge/plugin-sdk": "0.11.0"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@cloudflare/workers-types": "5.20261024.1"
package/src/access.ts CHANGED
@@ -307,9 +307,10 @@ export function adminGate(auth: AuthDeps, perms: AdminPermissions, now: () => nu
307
307
  if (cred?.via === "bearer" && cred.token.startsWith("sk_")) {
308
308
  const found = await resolveKey(c, auth, cred.token, t);
309
309
  access = { ctx: found.ctx, via: "key", key: found.key, resolved: found };
310
- } else if (cred?.via === "bearer" && cred.token.startsWith("kcs_")) {
311
- // A CLI session (p0.10 §6.2): admitted here, on /admin/* only, never as a staff session.
312
- const found = await auth.access.cliSession(cred.token, t);
310
+ } else if (cred?.via === "bearer" && (cred.token.startsWith("kcs_") || cred.token.startsWith("kcb_"))) {
311
+ // A CLI session (p0.10 §6.2): admitted here, on /admin/* only, never as a staff session. A bound one
312
+ // only at its origin, the one Cloudflare routed this request to, never a header the client sends (p0.11 §3).
313
+ const found = await auth.access.cliSession(cred.token, t, new URL(c.req.url).origin);
313
314
  if (!found) throw new KedgeError("UNAUTHORIZED", "This CLI session has ended; run the command again");
314
315
  access = { ctx: found.ctx, via: "bearer", resolved: found };
315
316
  } else if (cred) {
package/src/types.ts CHANGED
@@ -232,7 +232,8 @@ export interface AccessStore {
232
232
  maintain(session: AccessSession, now: number): Promise<number | null>;
233
233
  apiKey(presented: string, now: number): Promise<ResolvedAccess | null>;
234
234
  /** A CLI session's principal (p0.10 §6.2), or null when the token names no unexpired one. */
235
- cliSession(token: string, now: number): Promise<ResolvedAccess | null>;
235
+ /** `origin` is the request's own URL's: a bound (`kcb_`) session is admitted only there (p0.11 §3). */
236
+ cliSession(token: string, now: number, origin: string): Promise<ResolvedAccess | null>;
236
237
  keyTouchDue(key: { lastUsedAt: number | null }, now: number): boolean;
237
238
  touchKey(keyId: string, now: number): Promise<void>;
238
239
  /** Counts a failed key verification against the address; false once past the limit (§4.3). */