transform method

Resource transform(
  1. Resource resource
)

Implementation

Resource transform(Resource resource) => LazyResource(() async {
      // Checks if the resource is encrypted and whether the encryption schemes of the resource
      // and the DRM license are the same.
      pub.Link link = await resource.link();
      pub.Encryption? encryption = link.properties.encryption;
      if (encryption == null ||
          encryption.scheme != "http://readium.org/2014/01/lcp") {
        return resource;
      }

      if (license == null) {
        return FailureResource(link, ResourceException.forbidden);
      }
      if (link.isDeflated || !link.isCbcEncrypted) {
        return FullLcpResource(resource, license!);
      }
      return CbcLcpResource(resource, license!);
    });