The SDK uses branded types (via type-fest's Tagged) to distinguish between different types of JWTs at the type level. This prevents developers from accidentally using a RefreshToken where an AccessToken is required.
Available branded types:
AccessToken: A JWT used for authenticating requests.RefreshToken: A JWT used to obtain new access tokens.IdToken: A JWT containing user identity information.
Note: While the type definitions are public, the specific casting functions (like accessToken()) are marked as @internal and should generally be used via the generic compactJwt<T> utility if you need to manually cast a string to one of these specific types.
import { compactJwt, type AccessToken, type RefreshToken, type IdToken } from '@lens-protocol/types';
// Manually casting a string to a specific branded JWT type
const myAccessToken = compactJwt<AccessToken>("header.payload.signature");
const myRefreshToken = compactJwt<RefreshToken>("header.payload.signature");
const myIdToken = compactJwt<IdToken>("header.payload.signature");