jwtEmailClaim function
The email claim of a JWT payload's middle segment, or null when the
token is not a three-segment JWT, the payload is not a JSON object, or
the claim is absent/empty/non-string. The ONE claim reader behind the
account-identity entry naming (ChatGPT hosts via ChatGptOAuthCredentials.idToken,
AIIN via aiinJwtEmail, fa_ui's SSO bundle) — a single parser so the
copies cannot drift (issue #1326 review, thread 10).
Implementation
String? jwtEmailClaim(String idToken) {
final email = jwtPayloadClaims(idToken)?['email'];
return email is String && email.isNotEmpty ? email : null;
}