Skip to content

@clerk/[email protected]

Pre-release
Pre-release
Compare
Choose a tag to compare
@clerk-cookie clerk-cookie released this 11 Jan 17:21
· 1731 commits to main since this release
cdc4f51

Major Changes

  • Change SessionApi.getToken() to return consistent { data, errors } return value (#2539) by @dimkl

    and fix the getToken() from requestState to have the same return behavior as v4
    (return Promise or throw error).
    This change fixes issues with getToken() in @clerk/nextjs / @clerk/remix / @clerk/fastify / @clerk/sdk-node / gatsby-plugin-clerk:

    Example:

    import { getAuth } from '@clerk/nextjs/server';
    
    const { getToken } = await getAuth(...);
    const jwtString = await getToken(...);

    The change in SessionApi.getToken() return value is a breaking change, to keep the existing behavior use the following:

    import { ClerkAPIResponseError } from '@clerk/shared/error';
    
    const response = await clerkClient.sessions.getToken(...);
    
    if (response.errors) {
        const { status, statusText, clerkTraceId } = response;
        const error = new ClerkAPIResponseError(statusText || '', {
            data: [],
            status: Number(status || ''),
            clerkTraceId,
        });
        error.errors = response.errors;
    
        throw error;
    }
    
    // the value of the v4 `clerkClient.sessions.getToken(...)`
    const jwtString = response.data.jwt;

Minor Changes

  • Replace the Clerk-Backend-SDK header with User-Agent in BAPI requests and update it's value to contain both the package name and the package version of the clerk package (#2558) by @dimkl

    executing the request. Eg request from @clerk/nextjs to BAPI with append User-Agent: @clerk/[email protected] using the latest version.

    Miscellaneous changes: The backend test build changed to use tsup.

Patch Changes