@clerk/backend
3.29.0 · 14 Nov 2026MIT8.4M / weekRepositoryHomepagenpmAtom feed
3.31.4 is the newest release of 3.x.
In short
1 new1 internal
Release note
Minor Changes
Add an experimental
clerkClient.oauthApplications.__experimental_exchangeToken()method for performing an OAuth 2.0 Token Exchange (RFC 8693) on behalf of an OAuth application. Pass your publishable key, the application's client ID and client secret, a user's OAuth access token, and the targetresourceto receive a new access token for that resource, for example to call a downstream API on a user's behalf. The request goes to your instance's token endpoint, derived from the publishable key (or fromproxyUrlwhen set), so it does not require a secret key. AproxyUrlmust be an absolute HTTPS URL without a query or fragment, including for loopback hosts. Token exchange requests do not follow redirects, so credentials and tokens are never forwarded to another endpoint; a redirect response throws anOAuthTokenExchangeErrorwith codeinvalid_response.The method checks its inputs before making any request:
resourcemust be an absolute URI without a fragment that useshttps(orhttponlocalhost,127.0.0.1or[::1]), and eachscopeelement must be a single scope token, without spaces,",\or non-ASCII characters. Invalid input throws anOAuthTokenExchangeErrorwith codeinvalid_requestand nostatus. Only a200response with a well-formed token response counts as success; any other success status, or a response with missing or mistyped members, throws anOAuthTokenExchangeErrorwith codeinvalid_response. If the token endpoint rejects the exchange, the error carries the OAuth error code incode(also available aserror),errorDescription, and HTTPstatus.OAuthTokenExchangeErroris exported from@clerk/backend/errors. Network failures fromfetchare not wrapped.
A whole project to check? Paste its package.json in the dependency check: every deprecated, outdated or vulnerable dependency, with what to upgrade to. Free, no account.