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

Argument of type 'string | undefined' is not assignable to parameter of type 'string' in @supabase/auth-js #967

Open
2 tasks done
thewhalermelon opened this issue Oct 2, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@thewhalermelon
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

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:

  1. Go to 'https://github.com/supabase/auth-js/blob/master/src/lib/helpers.ts'
  2. Click on line 208
  3. 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

image

System information

  • OS: macOS
  • Browser: chrome
  • Version of supabase-js: 2.45.2
  • Version of Node.js: 18.17.1
@thewhalermelon thewhalermelon added the bug Something isn't working label Oct 2, 2024
@ganeshrvel
Copy link

@thewhalermelon I am facing the same issue, I am unable to run typescript checks.
tsc --noEmit --skipLibCheck --pretty

Any fixes?

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

No branches or pull requests

2 participants