Skip to content
This repository was archived by the owner on Apr 13, 2025. It is now read-only.

Commit 74099d4

Browse files
committed
Get argon2-browser fork for node.js fix and fix test errors
1 parent f93a6fe commit 74099d4

File tree

5 files changed

+22
-42
lines changed

5 files changed

+22
-42
lines changed

nodecg-io-core/dashboard/esbuild.config.js

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -11,32 +11,6 @@ const fs = require("fs");
1111
const args = new Set(process.argv.slice(2));
1212
const prod = process.env.NODE_ENV === "production";
1313

14-
// esbuild plugin to bundle wasm modules as base64 encoded strings
15-
// inside the generate js bundle.
16-
// This is used for the argon2-browser wasm module.
17-
// This is documented here: https://github.com/evanw/esbuild/issues/408#issuecomment-757555771
18-
const wasmPlugin = {
19-
name: 'wasm',
20-
setup(build) {
21-
const namespace = "wasm-binary";
22-
23-
build.onResolve({ filter: /\.wasm$/ }, args => {
24-
if (args.resolveDir === '') {
25-
return // Ignore unresolvable paths
26-
}
27-
return {
28-
path: path.isAbsolute(args.path) ? args.path : path.join(args.resolveDir, args.path),
29-
namespace,
30-
}
31-
})
32-
33-
build.onLoad({ filter: /.*/, namespace }, async (args) => ({
34-
contents: await fs.promises.readFile(args.path),
35-
loader: 'base64',
36-
}))
37-
},
38-
};
39-
4014
const entryPoints = [
4115
"monaco-editor/esm/vs/language/json/json.worker.js",
4216
"monaco-editor/esm/vs/editor/editor.worker.js",
@@ -120,7 +94,6 @@ const BuildOptions = {
12094
// because these code paths aren't executed we can just ignore the error that they don't exist in browser environments.
12195
// See https://github.com/antelle/argon2-browser/issues/79 and https://github.com/antelle/argon2-browser/issues/26
12296
external: ["fs", "path"],
123-
plugins: [wasmPlugin],
12497
};
12598

12699
esbuild

nodecg-io-core/extension/__tests__/persistenceManager.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ describe("PersistenceManager", () => {
1717
const validPassword = "myPassword";
1818
const invalidPassword = "myInvalidPassword";
1919
const salt = crypto.lib.WordArray.random(128 / 8).toString();
20-
const validEncryptionKey = deriveEncryptionKey(validPassword, salt).toString();
21-
const invalidEncryptionKey = deriveEncryptionKey(invalidPassword, salt).toString();
20+
let validEncryptionKey = ""; // Generated in beforeEach
21+
let invalidEncryptionKey = "";
2222

2323
const nodecg = new MockNodeCG();
2424
const serviceManager = new ServiceManager(nodecg);
@@ -30,7 +30,12 @@ describe("PersistenceManager", () => {
3030
const encryptedDataReplicant = nodecg.Replicant<EncryptedData>("encryptedConfig");
3131
let persistenceManager: PersistenceManager;
3232

33-
beforeEach(() => {
33+
beforeEach(async () => {
34+
if (!validEncryptionKey || !invalidEncryptionKey) {
35+
validEncryptionKey = await deriveEncryptionKey(validPassword, salt);
36+
invalidEncryptionKey = await deriveEncryptionKey(invalidPassword, salt);
37+
}
38+
3439
encryptedDataReplicant.removeAllListeners();
3540
encryptedDataReplicant.value = {};
3641

@@ -310,6 +315,8 @@ describe("PersistenceManager", () => {
310315
else return error("encryption key invalid");
311316
});
312317
nodecgBundleReplicant.value = bundleRepValue ?? [nodecg.bundleName];
318+
// Wait for automatic login to trigger
319+
await new Promise((res) => setTimeout(res, 500));
313320
}
314321

315322
beforeEach(() => {

nodecg-io-core/extension/persistenceManager.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -459,15 +459,15 @@ export class PersistenceManager {
459459
throw new Error(loadResult.errorMessage);
460460
}
461461
} catch (err) {
462-
const logMesssage = `Failed to automatically login: ${err}`;
462+
const logMessage = `Failed to automatically login: ${err}`;
463463
if (this.isLoaded()) {
464464
// load() threw an error but nodecg-io is currently loaded nonetheless.
465465
// Anyway, nodecg-io is loaded which is what we wanted
466-
this.nodecg.log.warn(logMesssage);
466+
this.nodecg.log.warn(logMessage);
467467
} else {
468468
// Something went wrong and nodecg-io is not loaded.
469469
// This is a real error, the password might be wrong or some other issue.
470-
this.nodecg.log.error(logMesssage);
470+
this.nodecg.log.error(logMessage);
471471
}
472472
}
473473
}

nodecg-io-core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
},
5656
"dependencies": {
5757
"ajv": "^8.11.0",
58-
"argon2-browser": "^1.18.0",
58+
"argon2-browser": "https://github.com/daniel0611/argon2-browser/releases/download/1.19.0/argon2-browser-1.19.0.tgz",
5959
"crypto-js": "^4.1.1",
6060
"tslib": "^2.4.0"
6161
}

package-lock.json

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)