Commit ac97d0e
fix(sdk): use sender's protocol version for HTTP signature verification (#171)
## Summary
`verifyHttpRequestHeaders` and `verifyHttpResponseHeaders` hardcoded the
local `PROTOCOL_VERSION` (derived from the SDK's own semver) when
reconstructing the signing input for verification. When the gateway (SDK
1.6, `v: "1.6"`) verified requests from worlds running SDK 1.5 (`v:
"1.5"`), the `v:` field in the reconstructed signing input mismatched
the one the sender actually signed, causing **every signature to fail
with 403**.
## Root Cause
`buildRequestSigningInput` and `buildResponseSigningInput` always used:
```ts
v: PROTOCOL_VERSION // local SDK version, e.g. "1.6"
```
But the sender signed with their own version (e.g. `"1.5"`), sent via
the `X-AgentWorld-Version` header. The verifier ignored that header.
## Fix
Both verify functions now:
1. Extract `X-AgentWorld-Version` from incoming headers
2. Pass it to the signing input builder as `v:`
3. Fall back to local `PROTOCOL_VERSION` when the header is absent
This ensures cross-version compatibility: a gateway on SDK 1.6 can
verify requests from worlds on SDK 1.5 (or any other version).
## Testing
- 203/203 tests pass
- Build succeeds for both root and SDK packages
Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>1 parent 0b02d8b commit ac97d0e
2 files changed
Lines changed: 13 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
160 | 160 | | |
161 | 161 | | |
162 | 162 | | |
| 163 | + | |
163 | 164 | | |
164 | 165 | | |
165 | | - | |
| 166 | + | |
166 | 167 | | |
167 | 168 | | |
168 | 169 | | |
| |||
232 | 233 | | |
233 | 234 | | |
234 | 235 | | |
| 236 | + | |
235 | 237 | | |
236 | 238 | | |
237 | 239 | | |
| |||
258 | 260 | | |
259 | 261 | | |
260 | 262 | | |
| 263 | + | |
261 | 264 | | |
262 | 265 | | |
263 | 266 | | |
| |||
287 | 290 | | |
288 | 291 | | |
289 | 292 | | |
| 293 | + | |
290 | 294 | | |
291 | 295 | | |
292 | | - | |
| 296 | + | |
293 | 297 | | |
294 | 298 | | |
295 | 299 | | |
| |||
351 | 355 | | |
352 | 356 | | |
353 | 357 | | |
| 358 | + | |
354 | 359 | | |
355 | 360 | | |
356 | 361 | | |
| |||
375 | 380 | | |
376 | 381 | | |
377 | 382 | | |
| 383 | + | |
378 | 384 | | |
379 | 385 | | |
380 | 386 | | |
| |||
0 commit comments