Compare commits

...

3 Commits

Author SHA1 Message Date
Derrick Hammer cba2a126ae
*switch to iife 2023-04-04 06:30:49 -04:00
Derrick Hammer 6f5e0765d6
*add crypto-browserify 2023-04-04 06:30:35 -04:00
Derrick Hammer 6cc15997f8
*add webcrypto polyfill fork 2023-04-04 06:30:22 -04:00
3 changed files with 20 additions and 3 deletions

View File

@ -3,12 +3,12 @@ import esbuild from "esbuild";
esbuild.buildSync({ esbuild.buildSync({
entryPoints: ["src/index.ts"], entryPoints: ["src/index.ts"],
outfile: "dist/index.js", outfile: "dist/index.js",
format: "esm", format: "iife",
bundle: true, bundle: true,
legalComments: "external", legalComments: "external",
// minify: true // minify: true
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",
@ -72,6 +73,7 @@
"@types/streamx": "^2.9.1", "@types/streamx": "^2.9.1",
"@types/ws": "^8.5.4", "@types/ws": "^8.5.4",
"cli-progress": "^3.12.0", "cli-progress": "^3.12.0",
"crypto-browserify": "^3.12.0",
"esbuild": "^0.14.54", "esbuild": "^0.14.54",
"http-browserify": "^1.7.0", "http-browserify": "^1.7.0",
"hyperswarm": "^4.4.0", "hyperswarm": "^4.4.0",
@ -98,6 +100,8 @@
"timers": "timers-browserify", "timers": "timers-browserify",
"path": "path-browserify", "path": "path-browserify",
"os": "os-browserify", "os": "os-browserify",
"net": "./src/net.ts" "net": "./src/net.ts",
"crypto": "crypto-browserify",
"stream": "stream-browserify"
} }
} }

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 };