getJSModules static method
Implementation
static Future<String> getJSModules() async {
if (_libCache != null && _coreCache != null) {
return _buildScript(_libCache!, _coreCache!);
}
final lib = ejs.modules['lib']!;
final core = ejs.modules['core']!;
final libReq = (await http.get(Uri.parse(lib['url']!)));
final libHash = sha256.convert(libReq.bodyBytes).toString();
if (libHash != lib['hash']) {
throw Exception('Lib module hash mismatch');
}
final coreReq = (await http.get(Uri.parse(core['url']!)));
final coreHash = sha256.convert(coreReq.bodyBytes).toString();
if (coreHash != core['hash']) {
throw Exception('Core module hash mismatch');
}
_libCache = libReq.body;
_coreCache = coreReq.body;
return _buildScript(_libCache!, _coreCache!);
}