*add webcrypto polyfill fork

This commit is contained in:
Derrick Hammer 2023-04-04 06:30:22 -04:00
parent 4dd54a4f8b
commit 6cc15997f8
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
3 changed files with 15 additions and 1 deletions

View File

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

View File

@ -27,6 +27,7 @@
"@libp2p/utils": "^3.0.6", "@libp2p/utils": "^3.0.6",
"@lumeweb/kernel-swarm-client": "git+https://git.lumeweb.com/LumeWeb/kernel-swarm-client.git", "@lumeweb/kernel-swarm-client": "git+https://git.lumeweb.com/LumeWeb/kernel-swarm-client.git",
"@multiformats/mafmt": "^11.1.2", "@multiformats/mafmt": "^11.1.2",
"@peculiar/webcrypto": "git+https://git.lumeweb.com/LumeWeb/webcrypto.git",
"b4a": "^1.6.3", "b4a": "^1.6.3",
"blockstore-idb": "^1.1.0", "blockstore-idb": "^1.1.0",
"buffer": "^6.0.3", "buffer": "^6.0.3",

13
polyfill.js Normal file
View File

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