User information to encode in both tokens containing userId, email, and role properties
Object containing both accessToken and refreshToken
// Generate complete token pair for user login
const payload = {
userId: 'user-uuid-123',
email: 'user@example.com',
role: 'content_creator'
};
const tokens = generateTokenPair(payload);
console.log(tokens.accessToken); // Short-lived token for API requests
console.log(tokens.refreshToken); // Long-lived token for renewal
Generate both access and refresh tokens as a pair
Convenience function that creates both access and refresh tokens simultaneously using the same user payload. This is the primary function used during user authentication and token renewal operations to provide a complete token set.
The function combines generateAccessToken and generateRefreshToken to create a TokenPair object containing both tokens, ensuring consistency in token generation and simplifying authentication workflows.