class StytchB2B::Sessions
def authenticate_jwt_local(session_jwt)
function to get the JWK
Uses the cached value to get the JWK but if it is unavailable, it calls the get_jwks()
Parse a JWT and verify the signature locally (without calling /authenticate in the API)
def authenticate_jwt_local(session_jwt) issuer = 'stytch.com/' + @project_id begin decoded_token = JWT.decode session_jwt, nil, true, { jwks: @jwks_loader, iss: issuer, verify_iss: true, aud: @project_id, verify_aud: true, algorithms: ['RS256'] } decoded_token[0] rescue JWT::InvalidIssuerError raise JWTInvalidIssuerError rescue JWT::InvalidAudError raise JWTInvalidAudienceError rescue JWT::ExpiredSignature raise JWTExpiredSignatureError rescue JWT::IncorrectAlgorithm raise JWTIncorrectAlgorithmError end end