Commit 407eaba
authored
feat: add com.atproto.server.getServiceAuth endpoint (#26)
* feat: add com.atproto.server.getServiceAuth endpoint
This endpoint is required for video uploads. Clients call it to get
a service JWT to authenticate with external services like the video
service (did:web:video.bsky.app).
The endpoint:
- Requires authentication
- Takes 'aud' (required) and 'lxm' (optional) query params
- Returns a signed service JWT with the requested audience and lxm claims
Adds 4 new tests for the endpoint.
* chore: add changeset for getServiceAuth endpoint
* fix: accept service JWTs for video upload auth
The video service (video.bsky.app) calls uploadBlob on the PDS using
a service JWT issued by getServiceAuth. The auth middleware now accepts
these ES256K-signed service JWTs in addition to HS256 session JWTs.
Auth flow:
1. Client gets service JWT via getServiceAuth(aud=PDS, lxm=uploadBlob)
2. Client sends video to video.bsky.app with this token
3. Video service calls uploadBlob on PDS using the same token
4. PDS verifies the service JWT signature and allows the upload
Adds verifyServiceJwt() function and integration test for the flow.
* refactor: restore keypair caching for service JWT verification
The actual fix was wrapping Buffer with Uint8Array, not removing caching.
Cloudflare Workers' Buffer polyfill doesn't work correctly with
@atproto/crypto's verifySignature() - it needs true Uint8Array instances.
Restores caching for better performance while keeping the Uint8Array fix.
* refactor: share keypair caching between modules
Extract keypair caching to a shared module (keypair.ts) used by both
service-auth.ts (for creating service JWTs) and session.ts (for verifying
them). This ensures consistent behavior and reduces code duplication.
* refactor: consolidate service auth code in service-auth.ts
Move keypair caching, verifyServiceJwt, and ServiceJwtPayload from
separate modules into service-auth.ts where they logically belong
alongside createServiceJwt.
* feat: add video embed and missing defs lexicons
Add app.bsky.embed.video schema for video post support, along with
all dependent defs schemas (embed.defs, actor.defs, feed.defs,
graph.defs, notification.defs) that are referenced by other lexicons.
* chore: add script to check for missing lexicon refs
Scans all lexicon JSON files for external references and verifies
that corresponding lexicon files exist. Useful for ensuring all
dependencies are satisfied when adding new schemas.
* ci: run lexicon ref check in update workflow
* fix: convert JSON to lexicon format before validating records
Use jsonToLex() to convert incoming JSON records to proper lexicon
format before validation. This handles $link -> CID conversion and
blob object -> BlobRef conversion, fixing video embed validation.1 parent 4ccba03 commit 407eaba
17 files changed
Lines changed: 1757 additions & 12 deletions
File tree
- .changeset
- .github/workflows
- packages/pds
- scripts
- src
- lexicons
- middleware
- xrpc
- test
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
| 19 | + | |
18 | 20 | | |
19 | 21 | | |
20 | 22 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
| 30 | + | |
29 | 31 | | |
30 | 32 | | |
31 | 33 | | |
32 | 34 | | |
33 | 35 | | |
34 | 36 | | |
| 37 | + | |
35 | 38 | | |
36 | 39 | | |
37 | 40 | | |
| |||
41 | 44 | | |
42 | 45 | | |
43 | 46 | | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
44 | 52 | | |
45 | 53 | | |
46 | 54 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
215 | 215 | | |
216 | 216 | | |
217 | 217 | | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
218 | 225 | | |
219 | 226 | | |
220 | 227 | | |
| |||
0 commit comments