SeoActionFormContextCodec constructor

SeoActionFormContextCodec(
  1. List<int> secret, {
  2. Duration? tokenLifetime,
  3. DateTime clock()?,
})

Implementation

SeoActionFormContextCodec(
  List<int> secret, {
  this.tokenLifetime,
  DateTime Function()? clock,
})  : _secret = List<int>.unmodifiable(List<int>.of(secret)),
      _clock = clock ?? DateTime.now {
  if (_secret.length < 32 || _secret.length > 128) {
    throw RangeError.range(_secret.length, 32, 128, 'secret.length');
  }
  final lifetime = tokenLifetime;
  if (lifetime != null &&
      (lifetime < seoActionFormContextMinTokenLifetime ||
          lifetime > seoActionFormContextMaxTokenLifetime ||
          lifetime.inMicroseconds % Duration.microsecondsPerSecond != 0)) {
    throw ArgumentError.value(
      lifetime,
      'tokenLifetime',
      'must be a whole number of seconds between '
          '${seoActionFormContextMinTokenLifetime.inSeconds} and '
          '${seoActionFormContextMaxTokenLifetime.inSeconds}',
    );
  }
}