prepareToSend method
Returns the JSON-encoded sso value, exactly as the Java/Rust/Go SDKs do
in their prepareToSend() helpers. The caller is responsible for
URL-encoding when placing it on a query string.
Implementation
String prepareToSend() {
if (_secureUser != null) {
final apiKey = _apiKey;
if (apiKey == null) {
throw StateError('Secure SSO requires apiKey');
}
final timestamp = DateTime.now().millisecondsSinceEpoch;
final userDataJsonBase64 = _secureUser!.asJsonBase64();
final verificationHash = _hmacHex(apiKey, '$timestamp$userDataJsonBase64');
return jsonEncode({
'userDataJSONBase64': userDataJsonBase64,
'verificationHash': verificationHash,
'timestamp': timestamp,
});
}
if (_simpleUser != null) {
return jsonEncode({
'simpleSSOUser': _simpleUser!.toJson(),
});
}
throw StateError('FastCommentsSSO has neither secure nor simple user data');
}