e2ed
Version:
E2E testing framework over Playwright
15 lines (14 loc) • 465 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getCspHash = void 0;
const node_crypto_1 = require("node:crypto");
const algorithm = 'sha256';
/**
* Get CSP `sha256`-hash for source file by source text.
* @internal
*/
const getCspHash = (source) => {
const hashed = (0, node_crypto_1.createHash)(algorithm).update(source, 'utf8').digest('base64');
return `${algorithm}-${hashed}`;
};
exports.getCspHash = getCspHash;