the config
Optional
csrfProtection: {(optional) If used, you must pass in a function that returns a CSRF query parameter for the user for who a URL is generated; the query parameter will be appended to URLs like this: "baseUrl/ajax/?name=value&action=..." You must specify which routes you want to be protected. If you don't pass in a csrfProtection object, no CSRF tokens will be added to URLs.
Generates a URL at which the resources of the content can be loaded. Should be undefined if the default content serving mechanism is used. You only have to return a URL here if you want to change the hostname of the route, e.g. if the content files can be requested directly from S3 or a CDN.
the URL or undefined (Example: http://127.0.0.1:9000/s3bucket/123`)
Generates a URL to which the user data can be sent.
the user who is currently accessing the h5p object
Optional
contextId: stringallows implementation to have multiple user data objects for one h5p content object
Optional
asUserId: stringOptional
options: { readonly?: boolean }Also adds a cache buster based on IH5PConfig.h5pVersion.
Also adds a cache buster based on IH5PConfig.h5pVersion.
Generates a URL by which the content can be globally identified (or accessed). The URL is used when generating ids for object in xAPI statements, so it could also be a fake URL that is only used to uniquely identify the content. It could also simply be the contentId. (default behavior) If you store the generated xAPI statement in a neutral LRS and users will see or be able to click the URL, you should customize the URL by overriding this method.
This class generates URLs for files based on the URLs set in the configuration.
It includes a basic cache buster that adds a parameter with the full version to core and library files (e.g. ?version=1.2.3). You can also implement other means of busting caches by implementing IUrlGenerator yourself. It would for example be possible to adding a generic cache buster string instead of adding the version. If you decide to do this, you must be aware of the fact that the JavaScript client generates URLs dynamically in two cases (at the time of writing), both in h5peditor.js:contentUpgrade. This function uses H5PIntegration.pluginCacheBuster, which can be customized by overriding H5PEditor.cacheBusterGenerator.
UrlGenerator requires these values to be set in config:
The UrlGenerator can also be used to inject CSRF tokens into URLs for POST requests that are sent by the H5P editor core (Joubel's code) over which you don't have any control. You can then check the CSRF tokens in your middleware to authenticate requests.