Use ethers.js Mnemonic for real BIP-39 phrase generation
All checks were successful
check / check (push) Successful in 22s
All checks were successful
check / check (push) Successful in 22s
Replace stub wordlist with ethers.Mnemonic.fromEntropy() using crypto.getRandomValues(). Add esbuild to bundle popup JS so it can import ethers directly — no background messaging needed. Each die click now generates a valid, random BIP-39 mnemonic.
This commit is contained in:
72
build.js
72
build.js
@@ -1,6 +1,7 @@
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const { execSync } = require("child_process");
|
||||
const esbuild = require("esbuild");
|
||||
|
||||
const DIST_CHROME = path.join(__dirname, "dist", "chrome");
|
||||
const DIST_FIREFOX = path.join(__dirname, "dist", "firefox");
|
||||
@@ -10,24 +11,7 @@ function ensureDir(dir) {
|
||||
fs.mkdirSync(dir, { recursive: true });
|
||||
}
|
||||
|
||||
function copyDir(src, dest, opts = {}) {
|
||||
ensureDir(dest);
|
||||
const entries = fs.readdirSync(src, { withFileTypes: true });
|
||||
for (const entry of entries) {
|
||||
const srcPath = path.join(src, entry.name);
|
||||
const destPath = path.join(dest, entry.name);
|
||||
if (opts.skip && opts.skip.includes(entry.name)) {
|
||||
continue;
|
||||
}
|
||||
if (entry.isDirectory()) {
|
||||
copyDir(srcPath, destPath, opts);
|
||||
} else {
|
||||
fs.copyFileSync(srcPath, destPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function build() {
|
||||
async function build() {
|
||||
console.log("Building AutistMask extension...");
|
||||
|
||||
// compile tailwind CSS
|
||||
@@ -40,21 +24,49 @@ function build() {
|
||||
{ stdio: "inherit" },
|
||||
);
|
||||
|
||||
// copy source files (skip the styles dir, we compiled it)
|
||||
for (const distDir of [DIST_CHROME, DIST_FIREFOX]) {
|
||||
ensureDir(distDir);
|
||||
copyDir(path.join(SRC, "popup"), path.join(distDir, "src", "popup"), {
|
||||
skip: ["styles"],
|
||||
ensureDir(path.join(distDir, "src", "popup"));
|
||||
ensureDir(path.join(distDir, "src", "background"));
|
||||
ensureDir(path.join(distDir, "src", "content"));
|
||||
|
||||
// bundle popup JS with esbuild (inlines ethers, libsodium, etc.)
|
||||
await esbuild.build({
|
||||
entryPoints: [path.join(SRC, "popup", "index.js")],
|
||||
bundle: true,
|
||||
format: "iife",
|
||||
outfile: path.join(distDir, "src", "popup", "index.js"),
|
||||
platform: "browser",
|
||||
target: ["chrome110", "firefox110"],
|
||||
minify: true,
|
||||
});
|
||||
copyDir(
|
||||
path.join(SRC, "background"),
|
||||
path.join(distDir, "src", "background"),
|
||||
|
||||
// bundle background script
|
||||
await esbuild.build({
|
||||
entryPoints: [path.join(SRC, "background", "index.js")],
|
||||
bundle: true,
|
||||
format: "iife",
|
||||
outfile: path.join(distDir, "src", "background", "index.js"),
|
||||
platform: "browser",
|
||||
target: ["chrome110", "firefox110"],
|
||||
minify: true,
|
||||
});
|
||||
|
||||
// bundle content script
|
||||
await esbuild.build({
|
||||
entryPoints: [path.join(SRC, "content", "index.js")],
|
||||
bundle: true,
|
||||
format: "iife",
|
||||
outfile: path.join(distDir, "src", "content", "index.js"),
|
||||
platform: "browser",
|
||||
target: ["chrome110", "firefox110"],
|
||||
minify: true,
|
||||
});
|
||||
|
||||
// copy popup HTML
|
||||
fs.copyFileSync(
|
||||
path.join(SRC, "popup", "index.html"),
|
||||
path.join(distDir, "src", "popup", "index.html"),
|
||||
);
|
||||
copyDir(
|
||||
path.join(SRC, "content"),
|
||||
path.join(distDir, "src", "content"),
|
||||
);
|
||||
copyDir(path.join(SRC, "shared"), path.join(distDir, "src", "shared"));
|
||||
|
||||
// place compiled CSS next to popup HTML
|
||||
fs.copyFileSync(
|
||||
|
||||
Reference in New Issue
Block a user