issue method
Implementation
String issue({
required String actionId,
required Map<String, String> values,
}) {
final action = actionId.trim();
if (!isValidSeoInteractionId(action)) {
throw ArgumentError.value(
actionId,
'actionId',
'is not a valid action id',
);
}
final canonical = _canonicalContext(values);
if (canonical == null) {
throw ArgumentError.value(values, 'values', 'is not a valid context map');
}
final lifetime = tokenLifetime;
final Map<String, Object> envelope;
if (lifetime == null) {
envelope = _unboundedEnvelope(action, canonical);
} else {
final issuedAt = _epochMilliseconds(_clock());
envelope = _expiringEnvelope(
action,
canonical,
issuedAt: issuedAt,
expiresAt: issuedAt + lifetime.inMilliseconds,
);
}
final payload = utf8.encode(jsonEncode(envelope));
final body = _withoutPadding(base64Url.encode(payload));
final signature = _signature(payload);
final token = '$body.$signature';
if (token.length > seoActionFormMaxContextTokenLength) {
throw ArgumentError.value(
values, 'values', 'produces an oversized token');
}
return token;
}