Packages

@clerk/backend

3.29.0 · 14 Nov 2026MIT8.4M / weekRepositoryHomepagenpmAtom feed

Your version

2.0.0

major4 Jun 2025Where it was published

2.33.9 is the newest release of 2.x.

In short

1 breaking2 new2 fixed2 internal

  • Breaking

    Introduces machine authentication, supporting four token types: api_key, oauth_token, machine_token, and session_token. For backwards compatibility, session_token remains the default when no token type is specified. This enables machine-to-machine authentication and use cases such as API keys and OAuth integrations. Existing applications continue to work without modification.

Security

2 advisories affect 2.0.0; 2.33.3 fixes them

Release note

Major Changes

  • Breaking

    Introduces machine authentication, supporting four token types: api_key, oauth_token, machine_token, and session_token. For backwards compatibility, session_token remains the default when no token type is specified. This enables machine-to-machine authentication and use cases such as API keys and OAuth integrations. Existing applications continue to work without modification.

    You can specify which token types are allowed by using the acceptsToken option in the authenticateRequest() function. This option can be set to a specific type, an array of types, or 'any' to accept all supported tokens.

    Example usage:

    import express from 'express';
    import { createClerkClient } from '@clerk/backend';
    
    const app = express();
    const clerkClient = createClerkClient({ secretKey: 'sk_xxx', publishableKey: 'pk_xxx' });
    
    app.use(async (req, res, next) => {
      const requestState = await clerkClient.authenticateRequest(req, {
        acceptsToken: 'any',
      });
    
      if (!requestState.isAuthenticated) {
        // do something for unauthenticated requests
      }
    
      const authObject = requestState.toAuth();
    
      if (authObject.tokenType === 'session_token') {
        console.log('this is session token from a user');
      } else {
        console.log('this is some other type of machine token');
        console.log('more specifically, a ' + authObject.tokenType);
      }
    
      // Attach the auth object to locals so downstream handlers
      // and middleware can access it
      res.locals.auth = authObject;
      next();
    });

Minor Changes

  • The svix dependency is no longer needed when using the verifyWebhook() function. verifyWebhook() was refactored to not rely on svix anymore while keeping the same functionality and behavior.

    If you previously installed svix to use verifyWebhook() you can uninstall it now:

    npm uninstall svix

Patch Changes

  • Improve JSDoc comments for verifyWebhook and verifyToken

  • Improve JSDoc comments

  • Introduce getAuthObjectFromJwt as internal utility function that centralizes the logic for generating auth objects from session JWTs.

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.