verify function
Verifies a CWT's COSE signature and temporal validity, then returns the decoded claims.
When now is provided (Unix timestamp in seconds), temporal claims are
validated: nbf must be present and nbf <= now, and if exp is present
then now < exp. When now is null, temporal validation is skipped.
token: The serialized CWTverifier: The xDSA public key to verify againstdomain: Application-specific domain separatornow: Current Unix timestamp for temporal validation (null to skip)
Implementation
Claims verify({
required Uint8List token,
required xdsa.PublicKey verifier,
required Uint8List domain,
int? now,
}) {
if (now != null && now < 0) {
throw ArgumentError.value(
now,
'now',
'must be a non-negative Unix timestamp',
);
}
return Claims._decode(
ffi.cwtVerify(
token: token,
verifier: verifier.inner,
domain: domain,
now: now != null ? BigInt.from(now) : null,
),
);
}