-
Notifications
You must be signed in to change notification settings - Fork 0
/
csp.js
36 lines (35 loc) · 899 Bytes
/
csp.js
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
const policies = {
'default-src': ["'self'"],
'script-src': [
"'self'",
"'unsafe-inline'",
"'unsafe-eval'",
'https://checkout.stripe.com',
'https://js.stripe.com',
'https://maps.googleapis.com',
],
'child-src': ["'self'"],
'style-src': ["'self'", "'unsafe-inline'", 'https://fonts.googleapis.com'],
'img-src': ["'self'", 'https://*.stripe.com', 'https://raw.githubusercontent.com'],
'font-src': ["'self'"],
'frame-src': [
"'self'",
'https://checkout.stripe.com',
'https://js.stripe.com',
'https://hooks.stripe.com',
],
'connect-src': [
"'self'",
'https://checkout.stripe.com',
'https://api.stripe.com',
'https://maps.googleapis.com',
],
}
module.exports = Object.entries(policies)
.map(([key, value]) => {
if (Array.isArray(value)) {
return `${key} ${value.join(' ')}`
}
return ''
})
.join('; ')