You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(gotrue): introduce getClaims method to verify and extract JWT claims (#1246)
* feat(gotrue): introduce getClaims method to verify and extract JWT claims
This introduces a new `getClaims` method that supports verifying JWTs
(both symmetric and asymmetric) and returns the entire set of claims
in the JWT payload.
Key changes:
- Add `getClaims()` method to GoTrueClient for JWT verification and claims extraction
- Implement base64url encoding/decoding utilities (RFC 4648)
- Add JWT types: JwtHeader, JwtPayload, DecodedJwt, GetClaimsResponse
- Add helper functions: decodeJwt() and validateExp()
- Add AuthInvalidJwtException for JWT-related errors
- Include comprehensive tests for getClaims, JWT helpers, and base64url utilities
The method verifies JWTs by calling getUser() to validate against the
server, supporting both HS256 (symmetric) and RS256/ES256 (asymmetric)
algorithms.
Note: This is an experimental API and may change in future versions.
Ported from: supabase/auth-js#1030
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* feat(gotrue): make getClaims() non-experimental, add options parameter
Following up on the initial getClaims implementation, this commit:
- Removes experimental status from getClaims() method
- Adds GetClaimsOptions class with allowExpired parameter
- Updates getClaims() to accept optional options parameter
- Improves documentation to better describe the method's behavior
- Exports helper functions (decodeJwt, validateExp) for public use
- Adds tests for allowExpired option
The allowExpired option allows users to extract claims from expired
JWTs without throwing an error during expiration validation. This is
useful for scenarios where you need to access JWT data even after
expiration.
Ported from: supabase/auth-js#1078
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* feat(gotrue): clarify getClaims fallback behavior for key rotation
Updates getClaims() documentation and comments to clarify that the
method always uses server-side verification via getUser(). This approach
gracefully handles edge cases such as:
- Key rotation scenarios where JWKS cache might not have the new signing key
- Symmetric JWTs (HS256) that require server-side verification
- Revoked or invalidated tokens that are still unexpired
This aligns the implementation intent with the auth-js behavior where
getClaims() falls back to getUser() when the signing key is not found
in JWKS or when client-side verification is not available.
The Flutter implementation uses this server-side verification approach
for all JWT types, providing robust and consistent validation regardless
of the signing algorithm.
Related: supabase/auth-js#1080
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* reimplement as claude did it wrong
* fix tests
* remove unused import
* fix(gotrue): preserve padding in base64url encoding when requested
Fixed the _base64ToBase64url method to preserve padding characters
when pad=true is specified. Previously, padding was always stripped
during conversion, causing encode(data, pad: true) to return unpadded
output.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* invert condition to check for signingKey only once
* fix: simplify base64url decoding
* update pointycastle to latest versions
* throw AuthInvalidJwtException error
* fix: bump dart_jsonwebtoken
* fix: use dart_jsonwebtoken for verifying jwt
# Conflicts:
# packages/gotrue/pubspec.yaml
* downgrade dart_jsonwebtoken
* fix: support dart_jsonwebtoken up to 4.0.0
---------
Co-authored-by: Claude <[email protected]>
0 commit comments