verify static method

bool verify({
  1. required String secret,
  2. required String signature,
  3. required String appKey,
  4. required String userToken,
  5. required int timestamp,
  6. Map<String, dynamic>? raw,
  7. bool? isPaying,
  8. String? plan,
  9. num? mrr,
  10. String? currency,
  11. int? currentEpochSeconds,
})

Verifies a signature against expected input and freshness window.

Implementation

static bool verify({
  required String secret,
  required String signature,
  required String appKey,
  required String userToken,
  required int timestamp,
  Map<String, dynamic>? raw,
  bool? isPaying,
  String? plan,
  num? mrr,
  String? currency,
  int? currentEpochSeconds,
}) {
  final now = currentEpochSeconds ??
      (DateTime.now().toUtc().millisecondsSinceEpoch ~/ 1000);
  if ((now - timestamp).abs() > freshnessSeconds) {
    return false;
  }
  final expected = sign(
    secret: secret,
    appKey: appKey,
    userToken: userToken,
    timestamp: timestamp,
    raw: raw,
    isPaying: isPaying,
    plan: plan,
    mrr: mrr,
    currency: currency,
  );
  return _constantTimeEquals(expected, signature.toLowerCase());
}