@authhero/proxy 0.8.5 → 0.9.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.
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Minimal shape of a Cloudflare service binding (a `Fetcher`). Declared
3
+ * locally so `@authhero/proxy` does not depend on `@cloudflare/workers-types`.
4
+ */
5
+ export interface ServiceBindingFetcher {
6
+ fetch(request: Request): Promise<Response>;
7
+ }
8
+ /**
9
+ * Wrap a Cloudflare service binding as a `fetch`-compatible function, suitable
10
+ * for the `fetch` override on {@link HttpProxyAdapterOptions}.
11
+ *
12
+ * When the proxy's control plane lives on a hostname that the proxy itself
13
+ * serves (e.g. the proxy owns `*.token.example.com/*` and the control plane
14
+ * resolves at `https://controlplane.token.example.com`), resolving it over the
15
+ * public edge loops the proxy's `resolveHost`/`/oauth/token` calls straight
16
+ * back into itself — a self-DoS. Routing those calls through a service binding
17
+ * to the control-plane worker keeps them off the public edge entirely, so the
18
+ * loop cannot form regardless of the configured `baseUrl`.
19
+ *
20
+ * ```ts
21
+ * const data = createHttpProxyAdapter({
22
+ * baseUrl: env.CONTROL_PLANE_URL,
23
+ * clientId: env.CONTROL_PLANE_CLIENT_ID,
24
+ * clientSecret: env.CONTROL_PLANE_CLIENT_SECRET,
25
+ * fetch: createServiceBindingFetch(env.AUTH2),
26
+ * });
27
+ * ```
28
+ */
29
+ export declare function createServiceBindingFetch(fetcher: ServiceBindingFetcher): typeof fetch;
@@ -19,6 +19,8 @@ export { createStaticProxyAdapter, httpRoute } from "./static";
19
19
  export type { StaticProxyAdapterOptions, StaticHostConfig, StaticRouteInput, } from "./static";
20
20
  export { createHttpProxyAdapter } from "./http-adapter";
21
21
  export type { HttpProxyAdapterOptions } from "./http-adapter";
22
+ export { createServiceBindingFetch } from "./http-adapter/service-binding-fetch";
23
+ export type { ServiceBindingFetcher } from "./http-adapter/service-binding-fetch";
22
24
  export { createKvProxyAdapter, buildKvHostKey, DEFAULT_KV_HOST_KEY_PREFIX, } from "./kv-adapter";
23
25
  export type { KvProxyAdapterOptions, KvNamespaceReader, KvNamespaceWriter, } from "./kv-adapter";
24
26
  export { PROXY_RESOLVE_HOST_SCOPE } from "./constants";
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.8.5",
14
+ "version": "0.9.0",
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.9.0"
43
+ "@authhero/adapter-interfaces": "3.10.0"
44
44
  },
45
45
  "scripts": {
46
46
  "build": "vite build && tsc -p tsconfig.types.json && rollup -c rollup.dts.config.mjs",