Options
All
  • Public
  • Public/Protected
  • All
Menu

An EpubOcfResourceProvider is an implementation of the EPUB Open Container Format (OCF). https://www.w3.org/publishing/epub3/epub-ocf.html

The actual EPUB publication is contained in the OCF container. The OCF also specifies all encrypted resources within the container (see encryption.xml file).

Resources that are encrypted are decrypted using the DrmManager before it is returned. By default, the EpubOcfResourceProvider has support for the Resource Obfuscation Algorithm (https://www.w3.org/publishing/epub3/epub-ocf.html#sec-resource-obfuscation). In order to facilitate decryption for other algorithms you must provide the DrmManager with matching EncryptionMethod implementations.

See DrmManager for more information.

Hierarchy

Implemented by

Index

Methods

acceptsUrl

  • acceptsUrl(url: string | URL): boolean
  • Returns true if this resource provider accepts the given URL. Whether the URL is accepted or not is implementation specific. It could for example be that the specified URL must be relative to the Base URL, or that the protocol used is http. Note that this is not an "exists" check, calling fetch() with the given URL can still fail even if this method returns true.

    If this method returns false, the fetch() method will fail with the specified URL.

    Parameters

    • url: string | URL

    Returns boolean

destroy

  • destroy(): void
  • Unloads all loaded EpubPublications, releasing any used resources.

    Note: If ReaderPublications have been loaded using Publications from this instance, You must call readingSystemEngine.unloadPublication() or readingSystemEngine.destroy() before calling this method.

    Returns void

disableBuiltInEncryptionMethods

  • disableBuiltInEncryptionMethods(): void

enableBuiltInEncryptionMethods

  • enableBuiltInEncryptionMethods(): void

fetch

  • Starts fetching a resource from this ResourceProvider. The returned Promise is resolved once a successful response is available.

    The response includes both the metadata for the resource and methods for reading the resource body.

    If a relative URL is specified, it will be resolved against the base URL of this ResourceProvider. If this ResourceProvider does not have a base URL, relative URLs will cause the returned Promise to be rejected.

    Contrary to the browser Fetch API, this method MUST reject the returned Promise if the request is non-successful, such as if the resource could not be found.

    The options parameter can be used to configure how the resource should be fetched. If the options parameter is not defined, the fetch is performed using the default values specified in IResourceRequestOptions.

    Parameters

    • url: string | URL

      The absolute or relative URL to fetch.

    • Optional options: IResourceRequestOptions

      Options for how to perform the fetch request.

    Returns Promise<IResourceResponse>

fetchMetadata

  • Fetches metadata about a resource using the specified URL.

    If a relative URL is specified, it will be resolved against the base URL of this ResourceProvider. If this ResourceProvider does not have a base URL, relative URLs will cause the returned Promise to be rejected.

    The options parameter can be used to configure the request. If the options parameter is not defined, the request is performed using the default values specified in IResourceRequestOptions.

    Parameters

    • url: string | URL

      The absolute or relative URL to the resource.

    • Optional options: IResourceRequestOptions

      Options for how to perform the request.

    Returns Promise<IResourceMetadata>

getBaseUrl

  • getBaseUrl(): URL
  • Get the base URL for this ResourceProvider, if available. Relative URLs passed to fetch() or fetchMetadata() will be resolved using this base URL. The path component of the base URL SHOULD end with a forward slash.

    If null is returned, relative URLs cannot be used with fetch() or fetchMetadata().

    Returns URL

getDefaultPublication

  • An OCF container can host multiple EPUB publications. This method returns the default publication in the OCF which is the first one defined in the container.xml file.

    Returns IEpubPublication

getDrmManager

  • The DrmManager instance used for decrypting encrypted resources.

    Returns IDrmManager

getMimeType

  • getMimeType(): string
  • Get the mime-type of the EPUB OCF Container

    Returns string

getPublications

  • Get all EPUB publication instances defined in the OCF container.xml file. The first item in the array is the default EPUB publication for the OCF according to the specification.

    Returns IEpubPublication[]

getResourceManifest

  • Get a list of ResourceMetadata items for all resources that can be fetched from this ResourceProvider instance. Returns null if this resource provider does not have a resource manifest.

    For example, the ZipResourceProvider has a central directory containing metadata about all resources within the zip file, and would therefore return a resource manifest.

    As another example, An HttpResourceProvider can probably not know about all available resources and should therefore return null.

    Returns IResourceMetadata[]

isDestroyed

  • isDestroyed(): boolean
  • If destroy() has been called on this instance.

    Returns boolean

isUrlSupportedByBrowser

  • Returns true if acceptsUrl() returns true for the URL, and the URL can be used by the browser directly without being fetched from the ResourceProvider. For example: If true is returned, the URL can be assigned to the src attributes of ,

    Returns false otherwise.

    Parameters

    Returns boolean

Generated using TypeDoc