Skip to content

Commit cbc83a0

Browse files
committed
feat(clerk-js): Send previous session token on /tokens requests
Send the current session JWT as `token` in the POST body when requesting a token refresh. This lets the FAPI Proxy forward it to Session Minter for claim cloning without a DB read. Uses conditional spread so the key is absent (not `token=`) when there's no previous token (first mint).
1 parent 07164c8 commit cbc83a0

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@clerk/clerk-js': patch
3+
---
4+
5+
Send previous session token on `/tokens` requests to support Session Minter edge token minting.

packages/clerk-js/src/core/resources/Session.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,12 @@ export class Session extends BaseResource implements SessionResource {
480480
): Promise<TokenResource> {
481481
const path = template ? `${this.path()}/tokens/${template}` : `${this.path()}/tokens`;
482482
// TODO: update template endpoint to accept organizationId
483-
const params: Record<string, string | null> = template ? {} : { organizationId: organizationId ?? null };
483+
const params: Record<string, string | null> = template
484+
? {}
485+
: {
486+
organizationId: organizationId ?? null,
487+
...(this.lastActiveToken ? { token: this.lastActiveToken.getRawString() } : {}),
488+
};
484489
const lastActiveToken = this.lastActiveToken?.getRawString();
485490

486491
const tokenResolver = Token.create(path, params, skipCache ? { debug: 'skip_cache' } : undefined).catch(e => {

0 commit comments

Comments
 (0)