Skip to content

Every analytics tool wants a subscription. And your data. I built Twiligent instead. YouTube stats. Instagram stats. One dashboard. Runs locally on your machine.

test(auth): fix the flaky nonce length check

spacesdrive271f21beecce
diff --git a/eslint.config.mjs b/eslint.config.mjs
index 2773ea0..7bb66c6 100644
--- a/eslint.config.mjs
+++ b/eslint.config.mjs
@@ -40,7 +40,7 @@ export default defineConfig([
},
},
{
- files: ['backend/tests/**/*.js', 'backend/**/*.test.js', 'scripts/**/*.js', '*.js', '*.mjs'],
+ files: ['backend/tests/**/*.js', 'scripts/**/*.js', '*.js', '*.mjs'],
extends: [js.configs.recommended],
languageOptions: {
ecmaVersion: 'latest',
diff --git a/frontend/tests/lib/googleIdentity.test.js b/frontend/tests/lib/googleIdentity.test.js
index a58adad..bc0a704 100644
--- a/frontend/tests/lib/googleIdentity.test.js
+++ b/frontend/tests/lib/googleIdentity.test.js
@@ -8,11 +8,12 @@ test('sha256Hex matches the known digest', async () => {
test('createNonce returns a raw nonce and its SHA-256 hash', async () => {
const { raw, hashed } = await createNonce();
- assert.match(raw, /^[A-Za-z0-9]{40,}$/);
+ // 32 random bytes in base64 minus + / =, so the length varies around 42
+ assert.match(raw, /^[A-Za-z0-9]{30,44}$/);
assert.equal(hashed, await sha256Hex(raw));
});
test('each nonce is different', async () => {
- const [a, b] = await Promise.all([createNonce(), createNonce()]);
- assert.notEqual(a.raw, b.raw);
+ const [first, second] = await Promise.all([createNonce(), createNonce()]);
+ assert.notEqual(first.raw, second.raw);
});