Skip to content

fix(server-sdk): keep canPublishSources intact when encoding a token - #737

Closed
RaphaelFakhri wants to merge 1 commit into
livekit:mainfrom
RaphaelFakhri:fix/access-token-reencode
Closed

RaphaelFakhri wants to merge 1 commit into
livekit:mainfrom
RaphaelFakhri:fix/access-token-reencode

Conversation

@RaphaelFakhri

Copy link
Copy Markdown

Description

claimsToJwtPayload shallow-copies the claims and then assigns the converted canPublishSources onto the shared video object. After the first toJwt(), the token's grants hold strings such as 'camera' instead of TrackSource values, and the second toJwt() throws Cannot convert TrackSource camera to string.

This change builds a new video object for the payload so the token's grants are left as they were.

Testing

Added a test in grants.test.ts that converts the same claims twice and checks the input is unchanged, and a test in AccessToken.test.ts that calls toJwt() twice and verifies canPublishSources in both tokens.

  • Without the change: 2 failed, 11 passed.
  • With the change: 13 passed.

Command: pnpm prebuild && npx vitest run src/grants.test.ts src/AccessToken.test.ts in packages/livekit-server-sdk.

A patch changeset for livekit-server-sdk is included.

@changeset-bot

changeset-bot Bot commented Sep 29, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: aeab982

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
livekit-server-sdk Patch
agent-dispatch Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@CLAassistant

CLAassistant commented Sep 29, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@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.

Devin Review

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