-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patha.js
More file actions
32 lines (26 loc) · 654 Bytes
/
a.js
File metadata and controls
32 lines (26 loc) · 654 Bytes
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
/*
* Copyright (c) 2026 Varad Dnyaneshwar Modhekar
* Licensed under the GNU Affero General Public License v3.0
*/
import http from "http";
import crypto from "crypto";
const server = http.createServer((req, res) => {
const nonce = crypto.randomBytes(16).toString("base64");
// Set CSP header with nonce
res.setHeader(
"Content-Security-Policy",
`script-src 'self' 'nonce-${nonce}'`
);
// Send HTML with same nonce
res.end(`
<html>
<body>
<h1>Hello</h1>
<script nonce="${nonce}">
console.log("SAFE script running");
</script>
</body>
</html>
`);
});
server.listen(3002);