@tollbooth-dpyc/web 1.8.1 → 1.8.2

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.
@@ -11,8 +11,15 @@
11
11
  *
12
12
  * Only the headers MCP needs are forwarded upstream. Cookies and anything else
13
13
  * the browser attached stay behind.
14
+ *
15
+ * Every request upstream carries a bearer. An operator with holder bearer on
16
+ * refuses a request without one; a page that holds no holder token is an
17
+ * anonymous caller, so the proxy says so with `Bearer anonymous` and the page
18
+ * proves itself with `dpop_token` as before. A page that does hold a token
19
+ * sends it, and it is forwarded untouched.
14
20
  */
15
21
  export declare const CORS_HEADERS: Record<string, string>;
22
+ export declare const ANONYMOUS_BEARER = "Bearer anonymous";
16
23
  type Fetch = (input: string, init: RequestInit & {
17
24
  duplex?: string;
18
25
  }) => Promise<Response>;
@@ -11,14 +11,21 @@
11
11
  *
12
12
  * Only the headers MCP needs are forwarded upstream. Cookies and anything else
13
13
  * the browser attached stay behind.
14
+ *
15
+ * Every request upstream carries a bearer. An operator with holder bearer on
16
+ * refuses a request without one; a page that holds no holder token is an
17
+ * anonymous caller, so the proxy says so with `Bearer anonymous` and the page
18
+ * proves itself with `dpop_token` as before. A page that does hold a token
19
+ * sends it, and it is forwarded untouched.
14
20
  */
15
21
  export const CORS_HEADERS = {
16
22
  "Access-Control-Allow-Origin": "*",
17
23
  "Access-Control-Allow-Methods": "GET, POST, DELETE, OPTIONS",
18
- "Access-Control-Allow-Headers": "content-type, mcp-session-id, accept, last-event-id",
19
- "Access-Control-Expose-Headers": "mcp-session-id",
24
+ "Access-Control-Allow-Headers": "content-type, mcp-session-id, accept, last-event-id, authorization",
25
+ "Access-Control-Expose-Headers": "mcp-session-id, www-authenticate",
20
26
  };
21
- const FORWARDED = new Set(["content-type", "accept", "mcp-session-id", "last-event-id"]);
27
+ const FORWARDED = new Set(["content-type", "accept", "mcp-session-id", "last-event-id", "authorization"]);
28
+ export const ANONYMOUS_BEARER = "Bearer anonymous";
22
29
  export function makeMcpProxy(upstream, fetchImpl = fetch) {
23
30
  const host = new URL(upstream).host;
24
31
  return async function onRequest(context) {
@@ -31,6 +38,8 @@ export function makeMcpProxy(upstream, fetchImpl = fetch) {
31
38
  if (FORWARDED.has(k.toLowerCase()))
32
39
  headers.set(k, v);
33
40
  }
41
+ if (!headers.has("authorization"))
42
+ headers.set("Authorization", ANONYMOUS_BEARER);
34
43
  headers.set("Host", host);
35
44
  const init = { method: req.method, headers };
36
45
  if (req.method !== "GET" && req.method !== "HEAD" && req.method !== "DELETE") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tollbooth-dpyc/web",
3
- "version": "1.8.1",
3
+ "version": "1.8.2",
4
4
  "description": "Shared browser SDK for Tollbooth DPYC operator front ends: npub sign-in, proofs, MCP client, profile and wallet",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Lonnie VanZandt",