Build MerchantFlow onboarding CRM foundation

This commit is contained in:
Oleksandr Prokhorenko
2026-09-24 16:43:22 +03:00
commit 3aa47d825f
78 changed files with 10739 additions and 0 deletions
+21
View File
@@ -0,0 +1,21 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import { merchantScope } from '../dist/access.js';
import { hashPassword, verifyPassword } from '@merchantflow/database';
test('passwords use distinct salts and reject incorrect values', () => {
const hash = hashPassword('example-password');
assert.notEqual(hash, hashPassword('example-password'));
assert.equal(verifyPassword('example-password', hash), true);
assert.equal(verifyPassword('wrong', hash), false);
assert.equal(verifyPassword('wrong', 'broken'), false);
});
test('every role receives its exact merchant scope', () => {
assert.deepEqual(merchantScope({ role: 'HEAD_OF_SALES' }), {});
assert.deepEqual(merchantScope({ role: 'ACCOUNT_MANAGER', id: 'manager-1' }), {
ownerId: 'manager-1',
});
assert.deepEqual(merchantScope({ role: 'COMPLIANCE_OFFICER' }), {
status: { in: ['KYB', 'COMPLIANCE_REVIEW'] },
});
assert.deepEqual(merchantScope({ role: 'unexpected' }), { id: '__no_access__' });
});