Files
directus/tests/e2e/setup/utils/generateHash.js
Jay Cammarano 00a838f020 Docs for testing the API (#10275)
* mock-knex

* test on the migrations run started.

* test passing for run.up()

* reorganize /tests/ to allow integration tests

* e2e setup changes

* e2e jest.config moved

* e2e paths fixed, integration config

* add nonadmin role and user seed+migration

* auth/login w/ documentation (docs will be moved)

* update user seed

* add postgres10 to the ci?

* argon2 saves the day

* items tests passing with postgres10 support

* removed comments

* move generateHash out of directus_users

Co-authored-by: Jay Cammarano <jaycammarano@gmail.com>
2021-12-10 14:58:51 -05:00

11 lines
622 B
JavaScript

const argon2 = require('argon2');
exports.hash = function (stringToHash) {
const buffer = 'string';
const argon2HashConfigOptions = { test: 'test', associatedData: buffer }; // Disallow the HASH_RAW option, see https://github.com/directus/directus/discussions/7670#discussioncomment-1255805
// test, if specified, must be passed as a Buffer to argon2.hash, see https://github.com/ranisalt/node-argon2/wiki/Options#test
if ('test' in argon2HashConfigOptions)
argon2HashConfigOptions.associatedData = Buffer.from(argon2HashConfigOptions.associatedData);
return argon2.hash(stringToHash, argon2HashConfigOptions);
};