@authhero/proxy 0.7.5 → 0.8.1

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.
@@ -0,0 +1,40 @@
1
+ import type { ProxyDataAdapter } from "../adapter";
2
+ /**
3
+ * Minimal structural view of a Cloudflare KV namespace's read surface. Declared
4
+ * locally so `@authhero/proxy` stays free of a hard `@cloudflare/workers-types`
5
+ * dependency — a real `KVNamespace` binding is structurally assignable to this.
6
+ */
7
+ export interface KvNamespaceReader {
8
+ get<T = unknown>(key: string, type: "json"): Promise<T | null>;
9
+ }
10
+ /**
11
+ * Minimal structural view of a Cloudflare KV namespace's write surface, consumed
12
+ * by the control-plane publisher. A real `KVNamespace` is assignable to this.
13
+ */
14
+ export interface KvNamespaceWriter {
15
+ put(key: string, value: string): Promise<void>;
16
+ delete(key: string): Promise<void>;
17
+ }
18
+ export declare const DEFAULT_KV_HOST_KEY_PREFIX = "authhero-proxy-host:";
19
+ /**
20
+ * Build the KV key for a host. Shared by the proxy reader
21
+ * (`createKvProxyAdapter`) and the control-plane publisher so both agree on the
22
+ * exact key format. Hosts are lowercased for case-insensitive lookups.
23
+ */
24
+ export declare function buildKvHostKey(keyPrefix: string, host: string): string;
25
+ export interface KvProxyAdapterOptions {
26
+ kv: KvNamespaceReader;
27
+ keyPrefix?: string;
28
+ timeoutMs?: number;
29
+ }
30
+ /**
31
+ * Build a `ProxyDataAdapter` that resolves hosts from a Cloudflare KV namespace.
32
+ * The control plane publishes the full `ResolvedHost` blob per host into KV; the
33
+ * proxy reads it with a single, unauthenticated, edge-local `KV.get` — faster
34
+ * and more reliable on cold reads than the two-hop HTTP control-plane adapter.
35
+ *
36
+ * Intended to sit in the `upstream` seam of `createCacheAdapterHostCache` as the
37
+ * durable-edge layer. A null from KV means "not found"; callers can keep the
38
+ * HTTP adapter as a miss / `stale-if-error` fallback during cutover.
39
+ */
40
+ export declare function createKvProxyAdapter(options: KvProxyAdapterOptions): ProxyDataAdapter;
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "type": "git",
12
12
  "url": "https://github.com/markusahlstrand/authhero"
13
13
  },
14
- "version": "0.7.5",
14
+ "version": "0.8.1",
15
15
  "files": [
16
16
  "dist"
17
17
  ],
@@ -40,7 +40,7 @@
40
40
  "hono": "^4.6.8"
41
41
  },
42
42
  "dependencies": {
43
- "@authhero/adapter-interfaces": "3.4.1"
43
+ "@authhero/adapter-interfaces": "3.5.0"
44
44
  },
45
45
  "scripts": {
46
46
  "build": "vite build && tsc -p tsconfig.types.json && rollup -c rollup.dts.config.mjs",