@authhero/proxy 0.7.5 → 0.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.
- package/README.md +56 -0
- package/dist/proxy.cjs +1 -1
- package/dist/proxy.d.ts +42 -2
- package/dist/proxy.mjs +39 -1
- package/dist/tsconfig.types.tsbuildinfo +1 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/kv-adapter/index.d.ts +40 -0
- package/dist/types/kv-adapter/index.test.d.ts +1 -0
- package/package.json +1 -1
|
@@ -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 {};
|