Skip to content

Extract livekit-token from livekit-api - #1344

Merged
1egoman merged 7 commits into
mainfrom
break-apart-livekit-api
Aug 25, 2026
Merged

1egoman merged 7 commits into
mainfrom
break-apart-livekit-api

Conversation

@1egoman

@1egoman 1egoman commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

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 the smaller constituent crates rather than the monolithic livekit-api.

Description

This initial pull request is focused on extracting out a new livekit-token crate from livekit-api. This new crate will contain all access token generation code and be depended on by livekit-uniffi (for exposing via uniffi) and livekit-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-token directly, and any external packages will be expected to consume livekit-api.

TODO

  • Publish initial livekit-token to crates.io

@github-actions

github-actions Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Changeset ✓

This PR includes a changeset covering all affected packages:

Package Bump
livekit patch
livekit-api patch
livekit-ffi patch
livekit-token patch
livekit-uniffi patch

@1egoman
1egoman force-pushed the break-apart-livekit-api branch from bf1d1e6 to b041fc7 Compare August 21, 2026 19:14
@1egoman 1egoman changed the title Extract livekit-token (and an unexpected side effect, livekit-region) from livekit-api Extract livekit-token from livekit-api Aug 21, 2026
@1egoman
1egoman force-pushed the break-apart-livekit-api branch from 24adcc4 to 58887f0 Compare August 21, 2026 19:18
@1egoman
1egoman marked this pull request as ready for review August 21, 2026 19:38
@1egoman
1egoman requested a review from ladvoc as a code owner August 21, 2026 19:38

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Open in Devin Review

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.
@1egoman
1egoman force-pushed the break-apart-livekit-api branch from 202290c to d7ac776 Compare August 24, 2026 15:31

@ladvoc ladvoc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-token documenting that it used to live in livekit-api
  • Update examples that depend on livekit-api just for token generation to depend on livekit-token instead

Comment thread livekit-api/src/lib.rs
@ladvoc

ladvoc commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

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 livekit-api, it will need to already exist on crates.io.

@1egoman

1egoman commented Aug 25, 2026

Copy link
Copy Markdown
Contributor Author

@ladvoc In regards to:

Update examples that depend on livekit-api just for token generation to depend on livekit-token instead

I was thinking that these crates would be an internal abstraction only - ie, examples would still keep using livekit-api, docs would still recommend this pattern, etc. The only difference would be organization and the resulting build time / feature flag simplification for internal uses.

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.

@1egoman

1egoman commented Aug 25, 2026

Copy link
Copy Markdown
Contributor Author

Created a new livekit-token stub release on crates.io: https://crates.io/crates/livekit-token

@1egoman
1egoman merged commit dde6aad into main Aug 25, 2026
26 of 29 checks passed
@1egoman
1egoman deleted the break-apart-livekit-api branch August 25, 2026 15:36
1egoman added a commit that referenced this pull request Aug 27, 2026
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants