@authhero/proxy 0.5.0 → 0.6.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
@@ -28,6 +28,7 @@ interface HostResolverCache {
28
28
  interface HostCacheOptions {
29
29
  freshTtlMs: number;
30
30
  staleTtlMs?: number;
31
+ staleIfErrorTtlMs?: number;
31
32
  negativeTtlMs?: number;
32
33
  maxEntries?: number;
33
34
  waitUntil?: (promise: Promise<unknown>) => void;
@@ -60,6 +61,7 @@ interface ProxyAppOptions {
60
61
  resolver?: HostResolverCache;
61
62
  registry?: HandlerRegistry;
62
63
  bindings?: Record<string, unknown>;
64
+ resolveHostTimeoutMs?: number;
63
65
  }
64
66
  declare function createProxyApp(options: ProxyAppOptions): Hono;
65
67
 
@@ -70,6 +72,7 @@ interface ProxyDataPlaneOptions {
70
72
  resolver?: HostResolverCache;
71
73
  registry?: HandlerRegistry;
72
74
  bindings?: Record<string, unknown>;
75
+ resolveHostTimeoutMs?: number;
73
76
  }
74
77
  declare function createProxyDataPlaneHandler(options: ProxyDataPlaneOptions): (c: Context) => Promise<Response>;
75
78
  declare function createProxyDataPlaneRouter(options: ProxyDataPlaneOptions): Hono;
@@ -81,6 +84,8 @@ interface CacheApiHostCacheOptions {
81
84
  namespace?: string;
82
85
  cache?: Cache;
83
86
  waitUntil?: (promise: Promise<unknown>) => void;
87
+ cacheReadTimeoutMs?: number;
88
+ cacheWriteTimeoutMs?: number;
84
89
  }
85
90
  /**
86
91
  * Wraps an upstream `HostResolverCache` with a Cloudflare Cache-API layer.
@@ -93,8 +98,8 @@ interface CacheApiHostCacheOptions {
93
98
  *
94
99
  * @deprecated Prefer `createCacheAdapterHostCache` with `createCloudflareCache`
95
100
  * from `@authhero/cloudflare-adapter`. The adapter-based wrapper supports
96
- * stale-while-revalidate and works with any `CacheAdapter` (Cloudflare,
97
- * Redis, in-memory, …).
101
+ * stale-while-revalidate, stale-if-error, and works with any `CacheAdapter`
102
+ * (Cloudflare, Redis, in-memory, …).
98
103
  */
99
104
  declare function createCacheApiHostCache(options: CacheApiHostCacheOptions): HostResolverCache;
100
105
  declare function buildCacheApiKey(namespace: string, host: string): Request;
@@ -104,15 +109,19 @@ interface CacheAdapterHostCacheOptions {
104
109
  cache: CacheAdapter;
105
110
  freshTtlMs: number;
106
111
  staleTtlMs?: number;
112
+ staleIfErrorTtlMs?: number;
107
113
  negativeTtlMs?: number;
108
114
  keyPrefix?: string;
109
115
  waitUntil?: (promise: Promise<unknown>) => void;
116
+ cacheReadTimeoutMs?: number;
117
+ cacheWriteTimeoutMs?: number;
110
118
  }
111
119
  /**
112
120
  * Wraps an upstream `HostResolverCache` with a generic `CacheAdapter` layer.
113
- * Adds stale-while-revalidate semantics on top of any cache implementation
114
- * — Cloudflare Cache API (via `CloudflareCache` from `@authhero/cloudflare-adapter`),
115
- * Redis, in-memory, or anything else satisfying the `CacheAdapter` interface.
121
+ * Adds stale-while-revalidate and stale-if-error semantics on top of any
122
+ * cache implementation — Cloudflare Cache API (via `CloudflareCache` from
123
+ * `@authhero/cloudflare-adapter`), Redis, in-memory, or anything else
124
+ * satisfying the `CacheAdapter` interface.
116
125
  *
117
126
  * Typical use on Cloudflare Workers:
118
127
  *
@@ -126,6 +135,7 @@ interface CacheAdapterHostCacheOptions {
126
135
  * cache,
127
136
  * freshTtlMs: 60 * 60_000, // 1 hour fresh
128
137
  * staleTtlMs: 23 * 60 * 60_000, // SWR for 23 more hours (24h total)
138
+ * staleIfErrorTtlMs: 24 * 60 * 60_000, // serve last-known-good for one more day on upstream errors
129
139
  * waitUntil: (p) => ctx.waitUntil(p),
130
140
  * });
131
141
  * ```
@@ -187,6 +197,7 @@ declare const serviceBindingHandler: HandlerDefinition<{
187
197
  binding: string;
188
198
  preserve_host: boolean;
189
199
  upstream_url?: string | undefined;
200
+ timeout_ms?: number | undefined;
190
201
  }>;
191
202
 
192
203
  declare const dispatchNamespaceHandler: HandlerDefinition<{
@@ -194,6 +205,7 @@ declare const dispatchNamespaceHandler: HandlerDefinition<{
194
205
  script_name: string;
195
206
  cpu_ms?: number | undefined;
196
207
  subrequests?: number | undefined;
208
+ timeout_ms?: number | undefined;
197
209
  }>;
198
210
 
199
211
  declare const redirectHandler: HandlerDefinition<{