Closed
Description
Bug report
- I confirm this is a bug with Supabase, not with my own application.
- I confirm I have searched the Docs, GitHub Discussions, and Discord.
Describe the bug
I found the TypeScript error in decodeJWTPayload function in https://github.com/supabase/auth-js/blob/master/src/lib/helpers.ts
To Reproduce
Steps to reproduce the behavior, please provide code snippets or a repository:
- Go to 'https://github.com/supabase/auth-js/blob/master/src/lib/helpers.ts'
- Click on line 208
- See error
Expected behavior
The decodeJWTPayload function should be like this:
export function decodeJWTPayload(token: string) {
// Regex checks for base64url format
const base64UrlRegex = /^([a-z0-9_-]{4})*($|[a-z0-9_-]{3}=?$|[a-z0-9_-]{2}(==)?$)$/i
const parts = token.split('.')
if (parts.length !== 3) {
throw new Error('JWT is not valid: not a JWT structure')
}
if (!base64UrlRegex.test(parts[1] as string)) {
throw new Error('JWT is not valid: payload is not in base64url format')
}
const base64Url = parts[1] as string;
return JSON.parse(decodeBase64URL(base64Url))
}
Screenshots
System information
- OS: macOS
- Browser: chrome
- Version of supabase-js: 2.45.2
- Version of Node.js: 18.17.1