Some checks failed
Main Confidence / confidence (push) Failing after 45s
## Summary - introduce surface-aware compressed governance outcomes and reuse the shared truth/explanation seams for operator-first summaries - apply the compressed outcome hierarchy across baseline, evidence, review, review-pack, canonical review/evidence, and artifact-oriented operation-run surfaces - expand spec 214 fixtures and Pest coverage, and fix tenant-panel route assertions by generating explicit tenant-panel URLs in the affected Filament tests ## Validation - `cd apps/platform && ./vendor/bin/sail bin pint --dirty --format agent` - focused governance compression suite from `specs/214-governance-outcome-compression/quickstart.md` passed (`68` tests, `445` assertions) - `cd apps/platform && ./vendor/bin/sail artisan test --compact tests/Feature/Filament/InventoryItemResourceTest.php tests/Feature/Filament/BackupSetUiEnforcementTest.php tests/Feature/Filament/RestoreRunUiEnforcementTest.php` passed (`18` tests, `81` assertions) Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de> Reviewed-on: #253
44 lines
1.2 KiB
Plaintext
44 lines
1.2 KiB
Plaintext
'use strict'
|
|
// This file contains crypto utility functions for versions of Node.js < 15.0.0,
|
|
// which does not support the WebCrypto.subtle API.
|
|
|
|
const nodeCrypto = require('crypto')
|
|
|
|
function md5(string) {
|
|
return nodeCrypto.createHash('md5').update(string, 'utf-8').digest('hex')
|
|
}
|
|
|
|
// See AuthenticationMD5Password at https://www.postgresql.org/docs/current/static/protocol-flow.html
|
|
function postgresMd5PasswordHash(user, password, salt) {
|
|
const inner = md5(password + user)
|
|
const outer = md5(Buffer.concat([Buffer.from(inner), salt]))
|
|
return 'md5' + outer
|
|
}
|
|
|
|
function sha256(text) {
|
|
return nodeCrypto.createHash('sha256').update(text).digest()
|
|
}
|
|
|
|
function hashByName(hashName, text) {
|
|
hashName = hashName.replace(/(\D)-/, '$1') // e.g. SHA-256 -> SHA256
|
|
return nodeCrypto.createHash(hashName).update(text).digest()
|
|
}
|
|
|
|
function hmacSha256(key, msg) {
|
|
return nodeCrypto.createHmac('sha256', key).update(msg).digest()
|
|
}
|
|
|
|
async function deriveKey(password, salt, iterations) {
|
|
return nodeCrypto.pbkdf2Sync(password, salt, iterations, 32, 'sha256')
|
|
}
|
|
|
|
module.exports = {
|
|
postgresMd5PasswordHash,
|
|
randomBytes: nodeCrypto.randomBytes,
|
|
deriveKey,
|
|
sha256,
|
|
hashByName,
|
|
hmacSha256,
|
|
md5,
|
|
}
|