Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | 1x 1x 1x 1x 1x 1209x 1209x 1209x 1x 1x 119x 119x 119x 119x 119x 1x 1x 88x 88x 88x 1x 1x 354x 354x 354x 354x 354x 354x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | import crypto from 'node:crypto';
import {library} from '@feasibleone/blong';
/** Convert a UUID string to a BINARY(16) Buffer for MySQL. */
function uuidBuf(uuid: string): Buffer {
return Buffer.from(uuid.replace(/-/g, ''), 'hex');
}
/** Read a BINARY(16) value from MySQL and return a hex string. */
function bufToUuid(buf: Buffer | string): string {
if (typeof buf === 'string') return buf;
const hex = buf.toString('hex');
return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
}
/** Generate a random UUID v4 string. */
function newUuid(): string {
return crypto.randomUUID();
}
/** Split a comma-separated string of names, trimming whitespace and filtering empty entries. */
function splitNames(value: string): string[] {
return value
.split(',')
.map(s => s.trim())
.filter(Boolean);
}
/**
* Shared account helpers for the `access.db` group — UUID conversion and
* role-name splitting.
*
* Injected library functions: every handler of the group receives them from
* `lib` and takes the type from here, so the call sites stay typed even though
* the runtime members are `LibFn`s:
*
* handler(({lib}) => {
* const account = lib as unknown as AccountLib;
* …
* });
*
* Password hashing lives in `password.ts` (a config-driven library of the same
* group), and the ACL/UI model helpers in `accessModel.ts`.
*/
export type AccountLib = {
uuidBuf: typeof uuidBuf;
bufToUuid: typeof bufToUuid;
newUuid: typeof newUuid;
splitNames: typeof splitNames;
};
export default library((): AccountLib => ({uuidBuf, bufToUuid, newUuid, splitNames}));
|