Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeScript error in decodeJWTPayload blocking CI/CD TypeScript checks #1017

Closed
2 tasks done
ganeshrvel opened this issue Jan 4, 2025 · 1 comment · Fixed by #1018
Closed
2 tasks done

TypeScript error in decodeJWTPayload blocking CI/CD TypeScript checks #1017

ganeshrvel opened this issue Jan 4, 2025 · 1 comment · Fixed by #1018
Labels
bug Something isn't working

Comments

@ganeshrvel
Copy link

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

This is a duplicate of #967 which has been open since January 2024 without resolution. The TypeScript error in decodeJWTPayload function in auth-js is blocking our CI/CD pipeline as we cannot run TypeScript checks (tsc --noEmit --skipLibCheck --pretty) or ESLint validation before commits.

To Reproduce

Steps to reproduce:

  1. Install supabase-js v2.45.2
  2. Run TypeScript checks with tsc --noEmit --skipLibCheck --pretty
  3. Observe TypeScript compilation errors due to incorrect typing in decodeJWTPayload

Expected behavior

The decodeJWTPayload function should be properly typed as shown in the original issue #967:

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))
}

This issue is blocking our ability to maintain code quality through TypeScript and ESLint checks in our CI pipeline.

System information

  • OS: macOS
  • Browser: Chrome
  • Version of supabase-js: 2.45.2
  • Version of Node.js: 18.17.1
@ganeshrvel ganeshrvel added the bug Something isn't working label Jan 4, 2025
@j4w8n
Copy link
Contributor

j4w8n commented Jan 6, 2025

I submitted a PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants