wasm-rquickjs-cli 0.2.4

Tool for wrapping JavaScript modules as WebAssembly components using the QuickJS engine
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import assert from 'assert';
import bcrypt from 'bcryptjs';

export const run = () => {
  const password = 'correct horse battery staple';
  const salt = bcrypt.genSaltSync(4);

  assert.ok(salt.startsWith('$2b$04$'));

  const hash = bcrypt.hashSync(password, salt);
  assert.strictEqual(hash.length, 60);
  assert.ok(bcrypt.compareSync(password, hash));
  assert.ok(!bcrypt.compareSync('wrong-password', hash));

  return 'PASS: sync salt/hash/compare roundtrip works';
};