@authhero/proxy 0.7.4 → 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/dist/proxy.d.ts CHANGED
@@ -316,6 +316,46 @@ interface HttpProxyAdapterOptions {
316
316
  */
317
317
  declare function createHttpProxyAdapter(options: HttpProxyAdapterOptions): ProxyDataAdapter;
318
318
 
319
+ /**
320
+ * Minimal structural view of a Cloudflare KV namespace's read surface. Declared
321
+ * locally so `@authhero/proxy` stays free of a hard `@cloudflare/workers-types`
322
+ * dependency — a real `KVNamespace` binding is structurally assignable to this.
323
+ */
324
+ interface KvNamespaceReader {
325
+ get<T = unknown>(key: string, type: "json"): Promise<T | null>;
326
+ }
327
+ /**
328
+ * Minimal structural view of a Cloudflare KV namespace's write surface, consumed
329
+ * by the control-plane publisher. A real `KVNamespace` is assignable to this.
330
+ */
331
+ interface KvNamespaceWriter {
332
+ put(key: string, value: string): Promise<void>;
333
+ delete(key: string): Promise<void>;
334
+ }
335
+ declare const DEFAULT_KV_HOST_KEY_PREFIX = "authhero-proxy-host:";
336
+ /**
337
+ * Build the KV key for a host. Shared by the proxy reader
338
+ * (`createKvProxyAdapter`) and the control-plane publisher so both agree on the
339
+ * exact key format. Hosts are lowercased for case-insensitive lookups.
340
+ */
341
+ declare function buildKvHostKey(keyPrefix: string, host: string): string;
342
+ interface KvProxyAdapterOptions {
343
+ kv: KvNamespaceReader;
344
+ keyPrefix?: string;
345
+ timeoutMs?: number;
346
+ }
347
+ /**
348
+ * Build a `ProxyDataAdapter` that resolves hosts from a Cloudflare KV namespace.
349
+ * The control plane publishes the full `ResolvedHost` blob per host into KV; the
350
+ * proxy reads it with a single, unauthenticated, edge-local `KV.get` — faster
351
+ * and more reliable on cold reads than the two-hop HTTP control-plane adapter.
352
+ *
353
+ * Intended to sit in the `upstream` seam of `createCacheAdapterHostCache` as the
354
+ * durable-edge layer. A null from KV means "not found"; callers can keep the
355
+ * HTTP adapter as a miss / `stale-if-error` fallback during cutover.
356
+ */
357
+ declare function createKvProxyAdapter(options: KvProxyAdapterOptions): ProxyDataAdapter;
358
+
319
359
  /**
320
360
  * Scope a control-plane bearer token must carry to call
321
361
  * `GET /api/v2/proxy/control-plane/hosts/:host` or `POST /sync`. The data
@@ -324,5 +364,5 @@ declare function createHttpProxyAdapter(options: HttpProxyAdapterOptions): Proxy
324
364
  */
325
365
  declare const PROXY_RESOLVE_HOST_SCOPE = "proxy:resolve_host";
326
366
 
327
- export { HandlerRegistry, PROXY_RESOLVE_HOST_SCOPE, basicAuthHandler, buildCacheAdapterKey, buildCacheApiKey, buildMatchFilter, cacheHandler, compileHostApp, corsHandler, createCacheAdapterHostCache, createCacheApiHostCache, createHttpProxyAdapter, createInMemoryHostCache, createProxyApp, createProxyDataPlaneHandler, createProxyDataPlaneRouter, createStaticProxyAdapter, defineHandler, dispatchNamespaceHandler, forwardedHeadersHandler, headersHandler, httpHandler, httpRoute, matchesAnyHost, matchesHost, redirectHandler, registerBuiltinHandlers, rewriteCookiesHandler, rewriteLocationHandler, serviceBindingHandler, sortRoutes, staticHandler };
328
- export type { CacheAdapterHostCacheOptions, CacheApiHostCacheOptions, HandlerBuildContext, HandlerDefinition, HostCacheOptions, HostResolverCache, HttpProxyAdapterOptions, ProxyAppOptions, ProxyDataAdapter, ProxyDataPlaneOptions, ProxyRouteHandlerSpec, ResolvedHost, StaticHostConfig, StaticProxyAdapterOptions, StaticRouteInput };
367
+ export { DEFAULT_KV_HOST_KEY_PREFIX, HandlerRegistry, PROXY_RESOLVE_HOST_SCOPE, basicAuthHandler, buildCacheAdapterKey, buildCacheApiKey, buildKvHostKey, buildMatchFilter, cacheHandler, compileHostApp, corsHandler, createCacheAdapterHostCache, createCacheApiHostCache, createHttpProxyAdapter, createInMemoryHostCache, createKvProxyAdapter, createProxyApp, createProxyDataPlaneHandler, createProxyDataPlaneRouter, createStaticProxyAdapter, defineHandler, dispatchNamespaceHandler, forwardedHeadersHandler, headersHandler, httpHandler, httpRoute, matchesAnyHost, matchesHost, redirectHandler, registerBuiltinHandlers, rewriteCookiesHandler, rewriteLocationHandler, serviceBindingHandler, sortRoutes, staticHandler };
368
+ export type { CacheAdapterHostCacheOptions, CacheApiHostCacheOptions, HandlerBuildContext, HandlerDefinition, HostCacheOptions, HostResolverCache, HttpProxyAdapterOptions, KvNamespaceReader, KvNamespaceWriter, KvProxyAdapterOptions, ProxyAppOptions, ProxyDataAdapter, ProxyDataPlaneOptions, ProxyRouteHandlerSpec, ResolvedHost, StaticHostConfig, StaticProxyAdapterOptions, StaticRouteInput };
package/dist/proxy.mjs CHANGED
@@ -2376,7 +2376,12 @@ e.array(Pn), e.object({
2376
2376
  "logins",
2377
2377
  "signups",
2378
2378
  "refresh-tokens",
2379
- "sessions"
2379
+ "sessions",
2380
+ "logouts",
2381
+ "password-changes",
2382
+ "mfa",
2383
+ "email-verifications",
2384
+ "codes-sent"
2380
2385
  ]), e.enum([
2381
2386
  "hour",
2382
2387
  "day",
@@ -3330,4 +3335,42 @@ function Yr(e) {
3330
3335
  };
3331
3336
  }
3332
3337
  //#endregion
3333
- export { F as HandlerRegistry, qr as PROXY_RESOLVE_HOST_SCOPE, Xn as basicAuthHandler, Ur as buildCacheAdapterKey, zr as buildCacheApiKey, Dr as buildMatchFilter, Qn as cacheHandler, Z as compileHostApp, qn as corsHandler, Hr as createCacheAdapterHostCache, Rr as createCacheApiHostCache, Yr as createHttpProxyAdapter, P as createInMemoryHostCache, Nr as createProxyApp, Q as createProxyDataPlaneHandler, Mr as createProxyDataPlaneRouter, Gr as createStaticProxyAdapter, I as defineHandler, xr as dispatchNamespaceHandler, $n as forwardedHeadersHandler, yn as handlerConfigSchema, Zn as headersHandler, fr as httpHandler, Kr as httpRoute, vn as matchSchema, Er as matchesAnyHost, Tr as matchesHost, j as proxyRouteInsertSchema, bn as proxyRouteSchema, xn as proxyRouteUpdateSchema, Sr as redirectHandler, wr as registerBuiltinHandlers, rr as rewriteCookiesHandler, ir as rewriteLocationHandler, gr as serviceBindingHandler, X as sortRoutes, Cr as staticHandler };
3338
+ //#region src/kv-adapter/index.ts
3339
+ var Xr = "authhero-proxy-host:";
3340
+ function Zr(e, t) {
3341
+ return `${e}${t.toLowerCase()}`;
3342
+ }
3343
+ function Qr() {
3344
+ let e = () => {
3345
+ throw Error("KV proxy adapter does not expose write access to proxy_routes; mutate via the control-plane management API");
3346
+ };
3347
+ return {
3348
+ async create() {
3349
+ return e();
3350
+ },
3351
+ async update() {
3352
+ return e();
3353
+ },
3354
+ async remove() {
3355
+ return e();
3356
+ },
3357
+ async get() {
3358
+ throw Error("KV proxy adapter does not expose per-route reads; use resolveHost");
3359
+ },
3360
+ async list() {
3361
+ throw Error("KV proxy adapter does not expose per-route reads; use resolveHost");
3362
+ }
3363
+ };
3364
+ }
3365
+ function $r(e) {
3366
+ let { kv: t, keyPrefix: n = Xr, timeoutMs: r } = e;
3367
+ return {
3368
+ proxyRoutes: Qr(),
3369
+ async resolveHost(e) {
3370
+ let i = Zr(n, e), a = t.get(i, "json");
3371
+ return (r && r > 0 ? await J(a, r, "kv.get") : await a) ?? null;
3372
+ }
3373
+ };
3374
+ }
3375
+ //#endregion
3376
+ export { Xr as DEFAULT_KV_HOST_KEY_PREFIX, F as HandlerRegistry, qr as PROXY_RESOLVE_HOST_SCOPE, Xn as basicAuthHandler, Ur as buildCacheAdapterKey, zr as buildCacheApiKey, Zr as buildKvHostKey, Dr as buildMatchFilter, Qn as cacheHandler, Z as compileHostApp, qn as corsHandler, Hr as createCacheAdapterHostCache, Rr as createCacheApiHostCache, Yr as createHttpProxyAdapter, P as createInMemoryHostCache, $r as createKvProxyAdapter, Nr as createProxyApp, Q as createProxyDataPlaneHandler, Mr as createProxyDataPlaneRouter, Gr as createStaticProxyAdapter, I as defineHandler, xr as dispatchNamespaceHandler, $n as forwardedHeadersHandler, yn as handlerConfigSchema, Zn as headersHandler, fr as httpHandler, Kr as httpRoute, vn as matchSchema, Er as matchesAnyHost, Tr as matchesHost, j as proxyRouteInsertSchema, bn as proxyRouteSchema, xn as proxyRouteUpdateSchema, Sr as redirectHandler, wr as registerBuiltinHandlers, rr as rewriteCookiesHandler, ir as rewriteLocationHandler, gr as serviceBindingHandler, X as sortRoutes, Cr as staticHandler };