LibWeb: Support SRI for import maps

See:
- b2fdca1
This commit is contained in:
Jamie Mansfield 2024-06-01 11:25:58 +01:00 committed by Tim Ledbetter
commit bab086694a
Notes: github-actions[bot] 2024-08-14 20:07:19 +00:00
6 changed files with 127 additions and 17 deletions

View file

@ -14,6 +14,7 @@
namespace Web::HTML {
using ModuleSpecifierMap = HashMap<ByteString, Optional<URL::URL>>;
using ModuleIntegrityMap = HashMap<URL::URL, ByteString>;
// https://html.spec.whatwg.org/multipage/webappapis.html#import-map
class ImportMap {
@ -28,14 +29,20 @@ public:
HashMap<URL::URL, ModuleSpecifierMap>& scopes() { return m_scopes; }
void set_scopes(HashMap<URL::URL, ModuleSpecifierMap> const& scopes) { m_scopes = scopes; }
ModuleIntegrityMap const& integrity() const { return m_integrity; }
ModuleIntegrityMap integrity() { return m_integrity; }
void set_integrity(ModuleIntegrityMap const& integrity) { m_integrity = integrity; }
private:
ModuleSpecifierMap m_imports;
HashMap<URL::URL, ModuleSpecifierMap> m_scopes;
ModuleIntegrityMap m_integrity;
};
WebIDL::ExceptionOr<ImportMap> parse_import_map_string(JS::Realm& realm, ByteString const& input, URL::URL base_url);
WebIDL::ExceptionOr<Optional<DeprecatedFlyString>> normalise_specifier_key(JS::Realm& realm, DeprecatedFlyString specifier_key, URL::URL base_url);
WebIDL::ExceptionOr<ModuleSpecifierMap> sort_and_normalise_module_specifier_map(JS::Realm& realm, JS::Object& original_map, URL::URL base_url);
WebIDL::ExceptionOr<HashMap<URL::URL, ModuleSpecifierMap>> sort_and_normalise_scopes(JS::Realm& realm, JS::Object& original_map, URL::URL base_url);
WebIDL::ExceptionOr<ModuleIntegrityMap> normalize_module_integrity_map(JS::Realm& realm, JS::Object& original_map, URL::URL base_url);
}