Extract livekit-token from livekit-api - #1344
Conversation
Changeset ✓This PR includes a changeset covering all affected packages:
|
bf1d1e6 to
b041fc7
Compare
livekit-token (and an unexpected side effect, livekit-region) from livekit-apilivekit-token from livekit-api
24adcc4 to
58887f0
Compare
Moves access_token.rs, jwt_provider.rs and the test_token.txt fixture, plus the get_env_keys helper, into a new livekit-token crate. livekit-api re-exports it as `access_token`, which stays the documented path, so no consumer changes. Also fixes services-tokio and services-async, which used the access-token types without declaring the access-token feature: building with --no-default-features --features services-tokio failed to compile. The extraction forces the fix, since services/ can no longer reach the types any other way. Adds livekit-api/tests/backcompat_paths.rs, a compile-only guard on the re-export paths, since nothing else in the workspace imports them. Also records in the implementation plan that test_token.txt has to move with the token code; the plan had missed it, and cargo test -p livekit-token fails without it.
The test suites in livekit and livekit-ffi were the last places reaching access tokens through livekit-api. Both now use livekit-token directly. livekit takes livekit-token as a dev-dependency rather than livekit-api: a member-level default-features override is ignored for an inherited workspace dep, so a livekit-api dev-dep would pull reqwest and the whole Twirp stack into test builds. No functional change; livekit_api::access_token is a re-export of these same types.
202290c to
d7ac776
Compare
ladvoc
left a comment
There was a problem hiding this comment.
LGTM, a few optional follow-ups that might be good to include here but feel free to ignore:
- Add an initial change log entry for
livekit-tokendocumenting that it used to live inlivekit-api - Update examples that depend on
livekit-apijust for token generation to depend onlivekit-tokeninstead
|
Note: since this PR adds a new crate, it will need to be published manually the first time (due to trusted publishing). This should be done before the release since, in order to publish a new version of |
|
@ladvoc In regards to:
I was thinking that these crates would be an internal abstraction only - ie, examples would still keep using If you are thinking otherwise, definitely interested in hearing more, but I think this is a fairly important point to be agreement on since it possibly influences further refactoring efforts. For now I'll keep moving under the assumption this is an internal only refactor. |
|
Created a new |
…region`) from `livekit-api` (#1345) ### Project Overview Right now, `livekit-api` is a crate that is an amalgamation of many things: - Signaling code - Server focused apis which allow users to issue commands via twirp / etc - Access token generation - Webhook management / smaller server focused utilities / etc We've discussed on the client team that it would be good to start to split this up. Larger, monolithic crates are harder to build and require larger numbers of features (which can interact in unexpected ways) than smaller ones, and ideally once this migration is complete, `livekit` will be able to depend on a handful of relevant smaller constituent crates rather than the monolithic `livekit-api`. ### Description This pull request builds on #1344 and extracts out a new `livekit-signaling` crate from `livekit-api`, which contains all signaling code. Arguably this being in `livekit-api` in the first place (given `livekit-api` is meant to be "serverside apis") was a little weird, though that was where the http infrastructure lived so I guess it made a certain amount of sense. Now though, all the client focused http infrastructure has been moved to `livekit-net` in #1258, so there's very little forcing them to be in the same crate. One small hiccup I did encounter: both existing serverside apis and signaling code both depend on [region selection code](https://github.com/livekit/rust-sdks/blob/main/livekit-api/src/region.rs), so in order to break out signaling, this needs to get moved to a "third thing" - I briefly considered `livekit-common`, but as `livekit-api` and `livekit-signaling` are likely to be the only dependents, I made a new `livekit-region` crate which I relocated this region selection code into. This pull request will likely conflict with the signaling refactoring / state machine work lukas is working on. The actual code changes here are a "lift and shift", so lukas's updates should be able to be rebased on top of this into place without a ton of effort. ## TODO - [x] Publish initial `livekit-signaling` and `livekit-region` crates to crates.io --------- Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Project Overview
Right now,
livekit-apiis a crate that is an amalgamation of many things:We've discussed on the client team that it would be good to start to split this up. Larger, monolithic crates are harder to build and require larger numbers of features (which can interact in unexpected ways) than smaller ones, and ideally once this migration is complete,
livekitwill be able to depend on the smaller constituent crates rather than the monolithiclivekit-api.Description
This initial pull request is focused on extracting out a new
livekit-tokencrate fromlivekit-api. This new crate will contain all access token generation code and be depended on bylivekit-uniffi(for exposing via uniffi) andlivekit-api(so it can be re-exported under its old path for downstream consumption).This should NOT be a breaking change and is largely scoped as a lift and shift effort right now. The expectation is that from this point forward, all livekit packages will consume
livekit-tokendirectly, and any external packages will be expected to consumelivekit-api.TODO
livekit-tokento crates.io