Skip to content

Conversation

@1egoman
Copy link
Contributor

@1egoman 1egoman commented Oct 8, 2025

Added a section to the readme about the TokenSource and how to use it currently.

I'll admit I'm not sure if all this really should be in the README - it might make more sense to move most of this to docs pages and just link to it directly. But I'll leave thoughts about exactly how this is formatted up to the docs team!

@changeset-bot
Copy link

changeset-bot bot commented Oct 8, 2025

⚠️ No Changeset found

Latest commit: 9f4e2f4

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@github-actions
Copy link
Contributor

github-actions bot commented Oct 8, 2025

size-limit report 📦

Path Size
dist/livekit-client.esm.mjs 82.96 KB (0%)
dist/livekit-client.umd.js 91.46 KB (0%)

Comment on lines +335 to +340

|Mechanism: | using pre-generated credentials | via a http request to a url | via fully custom logic |
|-------------|--|--|--|
|Fixed | [`TokenSource.literal`](#tokensourceliteral) | — | [`TokenSource.literal(async () => { /* ... */ })`](#tokensourceliteral) |
|Configurable | — | [`TokenSource.endpoint`](#tokensourceendpoint) or [`TokenSource.sandboxTokenServer`](#tokensourceendpoint) | [`TokenSource.custom`](#tokensourcecustom) |

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just wanted to call out this table - not sure if it's in the right place exactly in the flow of the broader content, but IMO it's super useful to visualize them all like this and it would be great to have this in the final docs pages as well!

@1egoman 1egoman requested a review from bcherry October 8, 2025 19:30
@1egoman 1egoman marked this pull request as ready for review October 8, 2025 19:30
Comment on lines 356 to 359
default, a `POST` request with a `Content-Type: application/json` header is made, and the request
body is expected to follow the [standard token format](FIXME: add docs link here!). If
credentials generation is successful, the endpoints returns a 2xx status code with a body following
the [standard token response format](FIXME: add docs link here!).
Copy link
Contributor Author

@1egoman 1egoman Oct 8, 2025

Choose a reason for hiding this comment

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

Wanted to call out: there are some placeholder links that I think would be good to point to a docs page talking about the standard token format.

In effect I think this could contain a more wordsmithed version of https://github.com/livekit-examples/token-server-status/pull/33, probably also linking to https://cloud.livekit.io/projects/p_/sandbox/templates/token-server somewhere in there too.

I can take a pass at this if desired but I think it's probably pretty self explanatory (the content in the pull request body plus maybe an example or two). One small detail not in the pull request that would be good to include is that there are typescript types that can be used if writing a node server endpoint here and it would be good to make those known.

README.md Outdated

There are two types of `TokenSource`'s - fixed and configurable. Configurable token sources can be
passed options as part of the generation process, allowing your to customize the token that they
generate. Fixed token sources generate their credentials fully indepentantly and don't allow for
Copy link
Contributor

Choose a reason for hiding this comment

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

indepentantly -> independently

Copy link
Contributor

Choose a reason for hiding this comment

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

I also wonder if this will be slightly more clear:
Fixed token sources generate static or pre-generated credentials and do not accept parameters when fetching

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, I went for something somewhere in between.

A pre-implemented set of credentials fetching utilities. Once one is constructed, call `fetch` on
to generate a new set of credentials.

There are two types of `TokenSource`'s - fixed and configurable. Configurable token sources can be
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if that makes sense to mention which use cases fixed tokenSources and configurable tokenSource are used for ? assuming they should be used by different use cases.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was kinda thinking the table would accomplish that, but maybe it would be worth having an explicit paragraph / callout with some examples?

```

|Mechanism: | using pre-generated credentials | via a http request to a url | via fully custom logic |
|-------------|--|--|--|
Copy link
Contributor

Choose a reason for hiding this comment

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

remove this line ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It has to be there for the markdown table formatting to work properly. I'll make myself a note before merging to add the proper number of dashes though (not important for markdown to parse it properly, but I think this might be what you are getting at)

Copy link
Contributor

Choose a reason for hiding this comment

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

I am ok with either option.

README.md Outdated

#### TokenSource.Literal
A fixed token source which returns a static set of credentials or a computed set of credentials
with no external input on each call.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit, with no external input required on each call

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Made the change, but reading it through I'm still not super pleased with the wording on this one, I'l going to think some more about it.

Copy link
Contributor

@bcherry bcherry left a comment

Choose a reason for hiding this comment

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

lgtm

@xianshijing-lk
Copy link
Contributor

lgtm again. thanks for addressing the comments.

@1egoman
Copy link
Contributor Author

1egoman commented Oct 10, 2025

Note that right now, there are a few link placeholders still in here expecting to point to docs pages: #1681 (comment)

I think either I need to extract these out or some docs pages need to be put together before this is merged.

@xianshijing-lk
Copy link
Contributor

Any update on this PR?

@1egoman
Copy link
Contributor Author

1egoman commented Oct 28, 2025

@xianshijing-lk I left a note a the comment above:

Note that right now, there are a few link placeholders still in here expecting to point to docs pages: #1681 (comment)

I think either I need to extract these out or some docs pages need to be put together before this is merged.

That is the only blocker remaining.

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.

4 participants