*Add crypto subtle polyfill

This commit is contained in:
Derrick Hammer 2023-04-04 06:08:30 -04:00
parent c31eedd40d
commit 21feb9fa17
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
3 changed files with 13 additions and 1 deletions

View File

@ -10,5 +10,5 @@ esbuild.buildSync({
define: {
global: "self",
},
inject: ["process.js"],
inject: ["process.js", "polyfill.js"],
});

View File

@ -15,6 +15,7 @@
"dependencies": {
"@lumeweb/hyperswarm-web": "git+https://git.lumeweb.com/LumeWeb/hyperswarm-web.git",
"@noble/ed25519": "^1.7.3",
"@peculiar/webcrypto": "^1.4.3",
"b4a": "^1.6.3",
"eventemitter2": "^6.4.9",
"hyperswarm": "^4.4.0",

11
polyfill.js Normal file
View File

@ -0,0 +1,11 @@
import { Crypto } from "@peculiar/webcrypto";
let globalCrypto = self.crypto;
if (!globalCrypto.subtle) {
let subtleCrypto = new Crypto().subtle;
Object.defineProperty(globalCrypto, "subtle", {
get() {
return subtleCrypto;
},
});
}