verifyCatalog method
Implementation
Future<VerifiedCatalog> verifyCatalog(
String jws, {
VerifiedCatalog? floor,
}) async {
final c = Catalog.fromJson(
await verification.signed(
jws,
config.trustedKeys,
DeliveryLimits.catalog,
),
);
if (c.projectId != config.projectId ||
c.distributionId != config.distributionId ||
c.channel != config.channel)
invalid('Incorrect catalog scope.');
final digest = await sha256Hex(utf8.encode(jws));
if (floor != null &&
(c.revision < floor.document.revision ||
(c.revision == floor.document.revision && digest != floor.digest)))
throw const LocalisyncException(
FailureCode.staleRevision,
'The catalog is older than the last verified decision or conflicts with it.',
);
return VerifiedCatalog(c, jws, digest);
}