Repository navigation
v0.2.6
π― New Feature: Session Token Access API
Added Session Token Access
- β
Added
sessionTokengetter - Preferred name for accessing the current user's session token - β
Added
getSessionToken()method - Method-based access for those who prefer method calls - β Enhanced API clarity - Clear naming for use in API authentication headers
- β
Full backward compatibility - Existing
authTokengetter continues to work unchanged
Use Cases
- β
API authentication - Use session token in
Authorization: Bearer <token>headers - β Proxy authentication - Pass token to Cloudflare Workers or other proxies for user validation
- β Cost tracking - Track API usage per user by validating tokens server-side
API Examples
// Getter-based access (preferred)
final token = db.auth.sessionToken;
if (token != null) {
headers['Authorization'] = 'Bearer $token';
}
// Method-based access
final token = db.auth.getSessionToken();
if (token != null) {
headers['Authorization'] = 'Bearer $token';
}
// Backward compatible - existing code still works
final token = db.auth.authToken; // Still availableTechnical Details
- β
Same underlying token - All three methods (
sessionToken,getSessionToken(),authToken) return the same JWT token - β
Null when not authenticated - Returns
nullwhen user is not signed in - β Comprehensive test coverage - Added 7 new tests for session token access
π Impact
This release addresses a common user request for accessing the session token for use in API authentication. The new API provides clearer naming while maintaining full backward compatibility with the existing authToken getter.