Skip to content

Commit a93fcb3

Browse files
authored
Allow components to support the req component parameter in Typescript (cloudflare#67)
`http-message-sig` package is currently not compliant with the spec - in particular, it returns `@authority` as a derived component in the response, when in reality it should be returning `"@authority";req`. This makes it impossible to write a compliant HTTP message directory, for instance. To support this, I've made several changes: 1. I've defined a new type called `ComponentParameters`, which can store arbitrary parameters attached to components. This allows us to expose `req`, `bs`, `sf`, etc. and even `key`. I've added it as a variant of `Component`. 2. I've replaced the handwritten parser with `structured-headers` library, which does the parsing for us. I've done my best to preserve the error cases we had in the past, but I've removed cases that assumed an unknown parameter meant invalid parsing - unknown list parameters are fine to keep and do not imply invalid parsing. 3. I've defined a new type called `ResponseRequestPair`, which bundles both request and response together, and written a resolver that inspects whether or not a component needs the pair, or can make do with just the raw message.
1 parent e3d7684 commit a93fcb3

16 files changed

Lines changed: 6649 additions & 4025 deletions

File tree

.prettierignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
examples/signature-agent-card-and-registry/target/*
2+
examples/signature-agent-card-and-registry/build/*

examples/httpie-web-bot-auth/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ HTTPIE_WBA_KEY="/path/to/jwk.json" http 'http+wba://example.com'
4242

4343
### Requirements
4444

45-
* [Python 3.13](https://www.python.org/downloads/)
46-
* [uv](https://docs.astral.sh/uv/getting-started/installation/) - Python package manager
45+
- [Python 3.13](https://www.python.org/downloads/)
46+
- [uv](https://docs.astral.sh/uv/getting-started/installation/) - Python package manager
4747

4848
### Build
4949

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Example Signature Agent Card and Registry on Cloudflare Workers
1+
# Example Signature Agent Card and Registry on Cloudflare Workers
22

33
This deploys a registry and a signature agent card on the same host: a Cloudflare worker.
44

@@ -8,8 +8,8 @@ Instructions:
88
- Navigate to `http://localhost:8787/.well-known/http-message-signatures-directory` to view a generated signature agent card with an example directory.
99
- Navigate to `http://localhost:8787` to view a registry containing this host. Note: this will not be generated until after you've visited `/.well-known/http-message-signatures-directory`, since the card will not exist until then.
1010

11-
This configuration allows you to attach multiple routes and generate an SAC for each one, all viewable in the registry.
11+
This configuration allows you to attach multiple routes and generate an SAC for each one, all viewable in the registry.
1212

1313
## Warning
1414

15-
The JSON web keys produced by this worker are *not cryptographically secure*. You should not use any of the private or public keys generated for message signing or verifying outside of this host. This example is only suitable for insecure use.
15+
The JSON web keys produced by this worker are _not cryptographically secure_. You should not use any of the private or public keys generated for message signing or verifying outside of this host. This example is only suitable for insecure use.

0 commit comments

Comments
 (0)