@testdriverai/agent 7.11.288-test → 7.11.289-test

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.
@@ -2,16 +2,16 @@
2
2
  "$schema": "./examples-manifest.schema.json",
3
3
  "examples": {
4
4
  "assert.test.mjs": {
5
- "url": "https://console-test.testdriver.ai/runs/6af65791a943ac17fbdd46c1/6af6579e30c7d45b69030f31",
6
- "lastUpdated": "2026-11-13T00:19:42.399Z"
5
+ "url": "https://console-test.testdriver.ai/runs/6af7a8f1517e7489f134536c/6af7a8fb517e7489f134537e",
6
+ "lastUpdated": "2026-11-14T00:19:07.357Z"
7
7
  },
8
8
  "drag-and-drop.test.mjs": {
9
9
  "url": "https://console.testdriver.ai/runs/69a62b3aaa712ecd3dea730a/69a62b42fc0ac3cc632a918b",
10
10
  "lastUpdated": "2026-03-03T00:32:25.275Z"
11
11
  },
12
12
  "exec-pwsh.test.mjs": {
13
- "url": "https://console-test.testdriver.ai/runs/6af65791a943ac17fbdd46c1/6af65793a943ac17fbdd46c4",
14
- "lastUpdated": "2026-11-13T00:19:45.197Z"
13
+ "url": "https://console-test.testdriver.ai/runs/6af7a8f1517e7489f134536c/6af7a8f2517e7489f134536e",
14
+ "lastUpdated": "2026-11-14T00:19:10.022Z"
15
15
  },
16
16
  "match-image.test.mjs": {
17
17
  "url": "https://console-test.testdriver.ai/runs/69c8738614b73310c7839412/69c8738c14b73310c783941d",
@@ -22,58 +22,58 @@
22
22
  "lastUpdated": "2026-03-03T00:32:25.282Z"
23
23
  },
24
24
  "windows-installer.test.mjs": {
25
- "url": "https://console-test.testdriver.ai/runs/6af65791a943ac17fbdd46c1/6af6579430c7d45b69030f26",
26
- "lastUpdated": "2026-11-13T00:20:07.323Z"
25
+ "url": "https://console-test.testdriver.ai/runs/6af7a8f1517e7489f134536c/6af7a8f2517e7489f134536f",
26
+ "lastUpdated": "2026-11-14T00:19:30.437Z"
27
27
  },
28
28
  "exec-output.test.mjs": {
29
- "url": "https://console-test.testdriver.ai/runs/6af65791a943ac17fbdd46c1/6af65795a943ac17fbdd46c9",
30
- "lastUpdated": "2026-11-13T00:19:57.925Z"
29
+ "url": "https://console-test.testdriver.ai/runs/6af7a8f1517e7489f134536c/6af7a8f4517e7489f1345370",
30
+ "lastUpdated": "2026-11-14T00:19:21.259Z"
31
31
  },
32
32
  "chrome-extension.test.mjs": {
33
33
  "url": "https://console-test.testdriver.ai/runs/6a87988fb7cddebeab9bfbea/6a8798913062df0fb9b85592",
34
34
  "lastUpdated": "2026-08-21T00:15:47.131Z"
35
35
  },
36
36
  "launch-vscode-linux.test.mjs": {
37
- "url": "https://console-test.testdriver.ai/runs/6af65791a943ac17fbdd46c1/6af6579f30c7d45b69030f32",
38
- "lastUpdated": "2026-11-13T00:20:05.285Z"
37
+ "url": "https://console-test.testdriver.ai/runs/6af7a8f1517e7489f134536c/6af7a8fc517e7489f134537f",
38
+ "lastUpdated": "2026-11-14T00:19:28.762Z"
39
39
  },
40
40
  "installer.test.mjs": {
41
- "url": "https://console-test.testdriver.ai/runs/6af65791a943ac17fbdd46c1/6af65796a943ac17fbdd46ca",
42
- "lastUpdated": "2026-11-13T00:19:33.578Z"
41
+ "url": "https://console-test.testdriver.ai/runs/6af7a8f1517e7489f134536c/6af7a8f5517e7489f1345373",
42
+ "lastUpdated": "2026-11-14T00:19:00.701Z"
43
43
  },
44
44
  "type.test.mjs": {
45
- "url": "https://console-test.testdriver.ai/runs/6af65791a943ac17fbdd46c1/6af65798a943ac17fbdd46cb",
46
- "lastUpdated": "2026-11-13T00:19:59.469Z"
45
+ "url": "https://console-test.testdriver.ai/runs/6af7a8f1517e7489f134536c/6af7a8f56d8d0ddc127125c2",
46
+ "lastUpdated": "2026-11-14T00:19:22.391Z"
47
47
  },
48
48
  "press-keys.test.mjs": {
49
- "url": "https://console-test.testdriver.ai/runs/6af65791a943ac17fbdd46c1/6af65799a943ac17fbdd46cc",
50
- "replayUrl": "https://console-test.testdriver.ai/replay/6af6588aa943ac17fbdd471b?share=mDc7vMPmEOcC1lR5Z3Aqlg",
51
- "embedUrl": "https://console-test.testdriver.ai/replay/6af6588aa943ac17fbdd471b?share=mDc7vMPmEOcC1lR5Z3Aqlg&embed=true",
52
- "lastUpdated": "2026-11-13T00:23:43.831Z"
49
+ "url": "https://console-test.testdriver.ai/runs/6af7a8f1517e7489f134536c/6af7a8f7517e7489f1345377",
50
+ "replayUrl": "https://console-test.testdriver.ai/replay/6af7a9df517e7489f13453c4?share=AMHWjmMTcgfYRw0KxMqA",
51
+ "embedUrl": "https://console-test.testdriver.ai/replay/6af7a9df517e7489f13453c4?share=AMHWjmMTcgfYRw0KxMqA&embed=true",
52
+ "lastUpdated": "2026-11-14T00:23:00.613Z"
53
53
  },
54
54
  "scroll.test.mjs": {
55
- "url": "https://console-test.testdriver.ai/runs/6af65791a943ac17fbdd46c1/6af6579d30c7d45b69030f2f",
56
- "lastUpdated": "2026-11-13T00:19:51.326Z"
55
+ "url": "https://console-test.testdriver.ai/runs/6af7a8f1517e7489f134536c/6af7a8fa517e7489f134537b",
56
+ "lastUpdated": "2026-11-14T00:19:16.273Z"
57
57
  },
58
58
  "scroll-until-image.test.mjs": {
59
- "url": "https://console-test.testdriver.ai/runs/6af65791a943ac17fbdd46c1/6af6579aa943ac17fbdd46cd",
60
- "lastUpdated": "2026-11-13T00:19:38.953Z"
59
+ "url": "https://console-test.testdriver.ai/runs/6af7a8f1517e7489f134536c/6af7a8f8517e7489f1345378",
60
+ "lastUpdated": "2026-11-14T00:19:04.855Z"
61
61
  },
62
62
  "prompt.test.mjs": {
63
- "url": "https://console-test.testdriver.ai/runs/6af65791a943ac17fbdd46c1/6af6579b30c7d45b69030f2c",
64
- "lastUpdated": "2026-11-13T00:20:01.757Z"
63
+ "url": "https://console-test.testdriver.ai/runs/6af7a8f1517e7489f134536c/6af7a8f8517e7489f1345379",
64
+ "lastUpdated": "2026-11-14T00:19:25.489Z"
65
65
  },
66
66
  "focus-window.test.mjs": {
67
- "url": "https://console-test.testdriver.ai/runs/6af65791a943ac17fbdd46c1/6af6579c30c7d45b69030f2d",
68
- "lastUpdated": "2026-11-13T00:20:02.346Z"
67
+ "url": "https://console-test.testdriver.ai/runs/6af7a8f1517e7489f134536c/6af7a8f9517e7489f134537a",
68
+ "lastUpdated": "2026-11-14T00:19:25.593Z"
69
69
  },
70
70
  "captcha-api.test.mjs": {
71
71
  "url": "https://console.testdriver.ai/runs/698f7df69e27ce1528d7d087/698f7fb0d3b320ad547d9d44",
72
72
  "lastUpdated": "2026-02-13T19:55:05.951Z"
73
73
  },
74
74
  "element-not-found.test.mjs": {
75
- "url": "https://console-test.testdriver.ai/runs/6af65791a943ac17fbdd46c1/6af6579e30c7d45b69030f30",
76
- "lastUpdated": "2026-11-13T00:19:53.331Z"
75
+ "url": "https://console-test.testdriver.ai/runs/6af7a8f1517e7489f134536c/6af7a8fa517e7489f134537c",
76
+ "lastUpdated": "2026-11-14T00:19:16.802Z"
77
77
  },
78
78
  "formatted-logging.test.mjs": {
79
79
  "url": "https://console-test.testdriver.ai/runs/69c8738614b73310c7839412/69c873a714b73310c7839450",
@@ -122,12 +122,12 @@
122
122
  "lastUpdated": "2026-02-13T19:55:05.953Z"
123
123
  },
124
124
  "findall-coffee-icons.test.mjs": {
125
- "url": "https://console-test.testdriver.ai/runs/6af65791a943ac17fbdd46c1/6af6579ba943ac17fbdd46ce",
126
- "lastUpdated": "2026-11-13T00:19:38.678Z"
125
+ "url": "https://console-test.testdriver.ai/runs/6af7a8f1517e7489f134536c/6af7a8f86d8d0ddc127125c3",
126
+ "lastUpdated": "2026-11-14T00:19:03.831Z"
127
127
  },
128
128
  "parse.test.mjs": {
129
- "url": "https://console-test.testdriver.ai/runs/6af65791a943ac17fbdd46c1/6af657a0a943ac17fbdd46cf",
130
- "lastUpdated": "2026-11-13T00:19:55.085Z"
129
+ "url": "https://console-test.testdriver.ai/runs/6af7a8f1517e7489f134536c/6af7a8fc517e7489f1345380",
130
+ "lastUpdated": "2026-11-14T00:19:18.240Z"
131
131
  },
132
132
  "flake-diffthreshold-001.test.mjs": {
133
133
  "url": "https://console.testdriver.ai/runs/69a62b3aaa712ecd3dea730a/69a62bcafc0ac3cc632a91aa",
@@ -166,24 +166,24 @@
166
166
  "lastUpdated": "2026-03-30T00:35:14.437Z"
167
167
  },
168
168
  "click-icon.test.mjs": {
169
- "url": "https://console-test.testdriver.ai/runs/6af65791a943ac17fbdd46c1/6af6579730c7d45b69030f28",
170
- "replayUrl": "https://console-test.testdriver.ai/replay/6af65856a943ac17fbdd4706?share=xMCI2xP4ULqEFS7dqPgd7Q",
171
- "embedUrl": "https://console-test.testdriver.ai/replay/6af65856a943ac17fbdd4706?share=xMCI2xP4ULqEFS7dqPgd7Q&embed=true",
172
- "lastUpdated": "2026-11-13T00:22:51.232Z"
169
+ "url": "https://console-test.testdriver.ai/runs/6af7a8f1517e7489f134536c/6af7a8f6517e7489f1345375",
170
+ "replayUrl": "https://console-test.testdriver.ai/replay/6af7a99c517e7489f13453b0?share=4YxCQsgwJiySqDQInd3EIA",
171
+ "embedUrl": "https://console-test.testdriver.ai/replay/6af7a99c517e7489f13453b0?share=4YxCQsgwJiySqDQInd3EIA&embed=true",
172
+ "lastUpdated": "2026-11-14T00:21:53.651Z"
173
173
  },
174
174
  "click-button.test.mjs": {
175
- "url": "https://console-test.testdriver.ai/runs/6af65791a943ac17fbdd46c1/6af6579d30c7d45b69030f2e",
176
- "lastUpdated": "2026-11-13T00:20:03.305Z"
175
+ "url": "https://console-test.testdriver.ai/runs/6af7a8f1517e7489f134536c/6af7a8fa517e7489f134537d",
176
+ "lastUpdated": "2026-11-14T00:19:27.093Z"
177
177
  },
178
178
  "add-to-cart.test.mjs": {
179
- "url": "https://console-test.testdriver.ai/runs/6af65791a943ac17fbdd46c1/6af65795a943ac17fbdd46c8",
180
- "lastUpdated": "2026-11-13T00:19:33.215Z"
179
+ "url": "https://console-test.testdriver.ai/runs/6af7a8f1517e7489f134536c/6af7a8f5517e7489f1345372",
180
+ "lastUpdated": "2026-11-14T00:19:00.684Z"
181
181
  },
182
182
  "navigate-and-scroll.test.mjs": {
183
- "url": "https://console-test.testdriver.ai/runs/6af65791a943ac17fbdd46c1/6af6579830c7d45b69030f2b",
184
- "replayUrl": "https://console-test.testdriver.ai/replay/6af6586ba943ac17fbdd470f?share=1j0Ic4Vs8FIxEpkm7Af0vg",
185
- "embedUrl": "https://console-test.testdriver.ai/replay/6af6586ba943ac17fbdd470f?share=1j0Ic4Vs8FIxEpkm7Af0vg&embed=true",
186
- "lastUpdated": "2026-11-13T00:23:13.623Z"
183
+ "url": "https://console-test.testdriver.ai/runs/6af7a8f1517e7489f134536c/6af7a8f7517e7489f1345376",
184
+ "replayUrl": "https://console-test.testdriver.ai/replay/6af7a9c66d8d0ddc127125f8?share=Z37FGGffLq3NezTpKUTaQ",
185
+ "embedUrl": "https://console-test.testdriver.ai/replay/6af7a9c66d8d0ddc127125f8?share=Z37FGGffLq3NezTpKUTaQ&embed=true",
186
+ "lastUpdated": "2026-11-14T00:22:35.505Z"
187
187
  }
188
188
  }
189
189
  }
@@ -12,7 +12,7 @@ This test logs in to a demo store, adds a product to the cart, and asserts that
12
12
 
13
13
  {/* add-to-cart.test.mjs output */}
14
14
  <iframe
15
- src="https://api-test.testdriver.ai/api/v1/testdriver/testcase/6af65795a943ac17fbdd46c8/replay"
15
+ src="https://api-test.testdriver.ai/api/v1/testdriver/testcase/6af7a8f5517e7489f1345372/replay"
16
16
  width="100%"
17
17
  height="600"
18
18
  style={{ border: "1px solid #333", borderRadius: "8px" }}
@@ -12,7 +12,7 @@ This test opens a login page in Chrome, saves a screenshot, and asserts that the
12
12
 
13
13
  {/* assert.test.mjs output */}
14
14
  <iframe
15
- src="https://api-test.testdriver.ai/api/v1/testdriver/testcase/6af6579e30c7d45b69030f31/replay"
15
+ src="https://api-test.testdriver.ai/api/v1/testdriver/testcase/6af7a8fb517e7489f134537e/replay"
16
16
  width="100%"
17
17
  height="390"
18
18
  style={{ border: "1px solid #333", borderRadius: "8px" }}
@@ -12,7 +12,7 @@ This test clicks **Sign In** on an empty login form and asserts that a "fields r
12
12
 
13
13
  {/* click-button.test.mjs output */}
14
14
  <iframe
15
- src="https://api-test.testdriver.ai/api/v1/testdriver/testcase/6af6579d30c7d45b69030f2e/replay"
15
+ src="https://api-test.testdriver.ai/api/v1/testdriver/testcase/6af7a8fa517e7489f134537d/replay"
16
16
  width="100%"
17
17
  height="390"
18
18
  style={{ border: "1px solid #333", borderRadius: "8px" }}
@@ -12,7 +12,7 @@ This test logs in to a demo store, clicks the shopping cart icon, and asserts th
12
12
 
13
13
  {/* click-icon.test.mjs output */}
14
14
  <iframe
15
- src="https://console-test.testdriver.ai/replay/6af65856a943ac17fbdd4706?share=xMCI2xP4ULqEFS7dqPgd7Q&embed=true"
15
+ src="https://console-test.testdriver.ai/replay/6af7a99c517e7489f13453b0?share=4YxCQsgwJiySqDQInd3EIA&embed=true"
16
16
  width="100%"
17
17
  height="390"
18
18
  style={{ border: "1px solid #333", borderRadius: "8px" }}
@@ -12,7 +12,7 @@ This test looks for an element that isn't on the page. Use this pattern when an
12
12
 
13
13
  {/* element-not-found.test.mjs output */}
14
14
  <iframe
15
- src="https://api-test.testdriver.ai/api/v1/testdriver/testcase/6af6579e30c7d45b69030f30/replay"
15
+ src="https://api-test.testdriver.ai/api/v1/testdriver/testcase/6af7a8fa517e7489f134537c/replay"
16
16
  width="100%"
17
17
  height="390"
18
18
  style={{ border: "1px solid #333", borderRadius: "8px" }}
@@ -12,7 +12,7 @@ This test uses `findAll()` to find every coffee cup in an icon grid, clicks each
12
12
 
13
13
  {/* findall-coffee-icons.test.mjs output */}
14
14
  <iframe
15
- src="https://api-test.testdriver.ai/api/v1/testdriver/testcase/6af6579ba943ac17fbdd46ce/replay"
15
+ src="https://api-test.testdriver.ai/api/v1/testdriver/testcase/6af7a8f86d8d0ddc127125c3/replay"
16
16
  width="100%"
17
17
  height="600"
18
18
  style={{ border: "1px solid #333", borderRadius: "8px" }}
@@ -16,7 +16,7 @@ This file has three `provision.installer()` tests in a Linux sandbox:
16
16
 
17
17
  {/* installer.test.mjs output */}
18
18
  <iframe
19
- src="https://api-test.testdriver.ai/api/v1/testdriver/testcase/6af65796a943ac17fbdd46ca/replay"
19
+ src="https://api-test.testdriver.ai/api/v1/testdriver/testcase/6af7a8f5517e7489f1345373/replay"
20
20
  width="100%"
21
21
  height="390"
22
22
  style={{ border: "1px solid #333", borderRadius: "8px" }}
@@ -12,7 +12,7 @@ This test launches VS Code with `provision.vscode()` and waits for its window to
12
12
 
13
13
  {/* launch-vscode-linux.test.mjs output */}
14
14
  <iframe
15
- src="https://api-test.testdriver.ai/api/v1/testdriver/testcase/6af6579f30c7d45b69030f32/replay"
15
+ src="https://api-test.testdriver.ai/api/v1/testdriver/testcase/6af7a8fc517e7489f134537f/replay"
16
16
  width="100%"
17
17
  height="390"
18
18
  style={{ border: "1px solid #333", borderRadius: "8px" }}
@@ -12,7 +12,7 @@ This test types a URL into Chrome's address bar, scrolls down, and asserts that
12
12
 
13
13
  {/* navigate-and-scroll.test.mjs output */}
14
14
  <iframe
15
- src="https://console-test.testdriver.ai/replay/6af6586ba943ac17fbdd470f?share=1j0Ic4Vs8FIxEpkm7Af0vg&embed=true"
15
+ src="https://console-test.testdriver.ai/replay/6af7a9c66d8d0ddc127125f8?share=Z37FGGffLq3NezTpKUTaQ&embed=true"
16
16
  width="100%"
17
17
  height="390"
18
18
  style={{ border: "1px solid #333", borderRadius: "8px" }}
@@ -12,7 +12,7 @@ This test opens Airbnb in Chrome and calls `parse()` to detect every UI element
12
12
 
13
13
  {/* parse.test.mjs output */}
14
14
  <iframe
15
- src="https://api-test.testdriver.ai/api/v1/testdriver/testcase/6af657a0a943ac17fbdd46cf/replay"
15
+ src="https://api-test.testdriver.ai/api/v1/testdriver/testcase/6af7a8fc517e7489f1345380/replay"
16
16
  width="100%"
17
17
  height="600"
18
18
  style={{ border: "1px solid #333", borderRadius: "8px" }}
@@ -12,7 +12,7 @@ This test drives Chrome with keyboard shortcuts to open tabs and DevTools, then
12
12
 
13
13
  {/* press-keys.test.mjs output */}
14
14
  <iframe
15
- src="https://console-test.testdriver.ai/replay/6af6588aa943ac17fbdd471b?share=mDc7vMPmEOcC1lR5Z3Aqlg&embed=true"
15
+ src="https://console-test.testdriver.ai/replay/6af7a9df517e7489f13453c4?share=AMHWjmMTcgfYRw0KxMqA&embed=true"
16
16
  width="100%"
17
17
  height="390"
18
18
  style={{ border: "1px solid #333", borderRadius: "8px" }}
@@ -12,7 +12,7 @@ This test opens a page, scrolls down, and asserts that the page heading is no lo
12
12
 
13
13
  {/* scroll.test.mjs output */}
14
14
  <iframe
15
- src="https://api-test.testdriver.ai/api/v1/testdriver/testcase/6af6579d30c7d45b69030f2f/replay"
15
+ src="https://api-test.testdriver.ai/api/v1/testdriver/testcase/6af7a8fa517e7489f134537b/replay"
16
16
  width="100%"
17
17
  height="390"
18
18
  style={{ border: "1px solid #333", borderRadius: "8px" }}
@@ -12,7 +12,7 @@ This file has two login form tests. One types a username and checks the field. T
12
12
 
13
13
  {/* type.test.mjs output */}
14
14
  <iframe
15
- src="https://api-test.testdriver.ai/api/v1/testdriver/testcase/6af65798a943ac17fbdd46cb/replay"
15
+ src="https://api-test.testdriver.ai/api/v1/testdriver/testcase/6af7a8f56d8d0ddc127125c2/replay"
16
16
  width="100%"
17
17
  height="390"
18
18
  style={{ border: "1px solid #333", borderRadius: "8px" }}
@@ -89,13 +89,16 @@ function publicOrigin(req) {
89
89
  const host = req.headers["x-forwarded-host"] || req.headers.host;
90
90
  return `${requestScheme(req)}://${host}`;
91
91
  }
92
- /** The public URL clients use to reach this server's MCP endpoint. */
92
+ /**
93
+ * The public URL clients use to reach this server's MCP endpoint — the RFC 9728
94
+ * `resource`. Clients refuse the OAuth flow unless it matches the URL they were
95
+ * configured with, so it is always derived from the same origin as the
96
+ * authorization server above and never pinned separately: one app answers on
97
+ * several hosts (its `*.fly.dev` name and a custom domain such as
98
+ * mcp.testdriver.ai), and a pinned value is wrong on all but one of them.
99
+ */
93
100
  function resourceUrl(req, mcpPath) {
94
- if (process.env.TD_MCP_RESOURCE) {
95
- return process.env.TD_MCP_RESOURCE;
96
- }
97
- const host = req.headers["x-forwarded-host"] || req.headers.host;
98
- return `${requestScheme(req)}://${host}${mcpPath}`;
101
+ return `${publicOrigin(req)}${mcpPath}`;
99
102
  }
100
103
  /**
101
104
  * RFC 9728 protected resource metadata document.
@@ -165,8 +168,7 @@ export function authorizeRedirectUrl(requestUrl) {
165
168
  }
166
169
  /** Build the `WWW-Authenticate` challenge header value. */
167
170
  export function wwwAuthenticate(req, opts) {
168
- const host = req.headers["x-forwarded-host"] || req.headers.host;
169
- const metadataUrl = `${requestScheme(req)}://${host}/.well-known/oauth-protected-resource`;
171
+ const metadataUrl = `${publicOrigin(req)}/.well-known/oauth-protected-resource`;
170
172
  let challenge = `Bearer resource_metadata="${metadataUrl}"`;
171
173
  if (opts?.error) {
172
174
  challenge += `, error="${opts.error}"`;
@@ -18,6 +18,7 @@ import {
18
18
  authorizationServerMetadata,
19
19
  authorizeRedirectUrl,
20
20
  protectedResourceMetadata,
21
+ wwwAuthenticate,
21
22
  } from "./http-auth.js";
22
23
 
23
24
  const AUTH0 = "https://replayable.us.auth0.com";
@@ -90,6 +91,31 @@ describe("protectedResourceMetadata", () => {
90
91
  "https://td-test-mcp-server.fly.dev",
91
92
  ]);
92
93
  });
94
+
95
+ // One Fly app answers on its *.fly.dev name and on a custom domain. A
96
+ // resource pinned to either host makes clients abort on the other one:
97
+ // "Protected resource … does not match expected …".
98
+ it.each(["mcp.testdriver.ai", "td-canary-mcp-server.fly.dev"])(
99
+ "names the host it was fetched from as the resource (%s)",
100
+ (host) => {
101
+ // A leftover pin from an earlier deploy must not leak into the document.
102
+ process.env.TD_MCP_RESOURCE = "https://td-canary-mcp-server.fly.dev/mcp";
103
+ const req = fakeReq({ host, "x-forwarded-proto": "https" });
104
+ const doc = protectedResourceMetadata(req, "/mcp");
105
+ expect(doc.resource).toBe(`https://${host}/mcp`);
106
+ expect(doc.authorization_servers).toEqual([`https://${host}`]);
107
+ expect(wwwAuthenticate(req)).toContain(
108
+ `resource_metadata="https://${host}/.well-known/oauth-protected-resource"`,
109
+ );
110
+ },
111
+ );
112
+
113
+ it("moves resource and authorization server together under TD_MCP_PUBLIC_URL", () => {
114
+ process.env.TD_MCP_PUBLIC_URL = "https://mcp.testdriver.ai/";
115
+ const doc = protectedResourceMetadata(fakeReq(), "/mcp");
116
+ expect(doc.resource).toBe("https://mcp.testdriver.ai/mcp");
117
+ expect(doc.authorization_servers).toEqual(["https://mcp.testdriver.ai"]);
118
+ });
93
119
  });
94
120
 
95
121
  // ---------------------------------------------------------------------------
@@ -109,13 +109,16 @@ function publicOrigin(req: IncomingMessage): string {
109
109
  return `${requestScheme(req)}://${host}`;
110
110
  }
111
111
 
112
- /** The public URL clients use to reach this server's MCP endpoint. */
112
+ /**
113
+ * The public URL clients use to reach this server's MCP endpoint — the RFC 9728
114
+ * `resource`. Clients refuse the OAuth flow unless it matches the URL they were
115
+ * configured with, so it is always derived from the same origin as the
116
+ * authorization server above and never pinned separately: one app answers on
117
+ * several hosts (its `*.fly.dev` name and a custom domain such as
118
+ * mcp.testdriver.ai), and a pinned value is wrong on all but one of them.
119
+ */
113
120
  function resourceUrl(req: IncomingMessage, mcpPath: string): string {
114
- if (process.env.TD_MCP_RESOURCE) {
115
- return process.env.TD_MCP_RESOURCE;
116
- }
117
- const host = req.headers["x-forwarded-host"] || req.headers.host;
118
- return `${requestScheme(req)}://${host}${mcpPath}`;
121
+ return `${publicOrigin(req)}${mcpPath}`;
119
122
  }
120
123
 
121
124
  /**
@@ -197,8 +200,7 @@ export function wwwAuthenticate(
197
200
  req: IncomingMessage,
198
201
  opts?: { error?: string; description?: string },
199
202
  ): string {
200
- const host = req.headers["x-forwarded-host"] || req.headers.host;
201
- const metadataUrl = `${requestScheme(req)}://${host}/.well-known/oauth-protected-resource`;
203
+ const metadataUrl = `${publicOrigin(req)}/.well-known/oauth-protected-resource`;
202
204
  let challenge = `Bearer resource_metadata="${metadataUrl}"`;
203
205
  if (opts?.error) {
204
206
  challenge += `, error="${opts.error}"`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testdriverai/agent",
3
- "version": "7.11.288-test",
3
+ "version": "7.11.289-test",
4
4
  "description": "Next generation autonomous AI agent for end-to-end testing of web & desktop",
5
5
  "main": "sdk.js",
6
6
  "types": "sdk.d.ts",