Skip to content

Commit f532cb4

Browse files
committed
ts: lib/csp.js
1 parent 4267f45 commit f532cb4

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

lib/csp.js renamed to lib/csp.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
var config = require('./config')
2-
var uuid = require('uuid')
1+
import * as config from "./config";
2+
import * as uuid from "uuid";
33

44
var CspStrategy = {}
55

@@ -52,7 +52,7 @@ CspStrategy.computeDirectives = function () {
5252
return directives
5353
}
5454

55-
function mergeDirectives (existingDirectives, newDirectives) {
55+
function mergeDirectives(existingDirectives, newDirectives) {
5656
for (var propertyName in newDirectives) {
5757
var newDirective = newDirectives[propertyName]
5858
if (newDirective) {
@@ -62,36 +62,36 @@ function mergeDirectives (existingDirectives, newDirectives) {
6262
}
6363
}
6464

65-
function mergeDirectivesIf (condition, existingDirectives, newDirectives) {
65+
function mergeDirectivesIf(condition, existingDirectives, newDirectives) {
6666
if (condition) {
6767
mergeDirectives(existingDirectives, newDirectives)
6868
}
6969
}
7070

71-
function areAllInlineScriptsAllowed (directives) {
71+
function areAllInlineScriptsAllowed(directives) {
7272
return directives.scriptSrc.indexOf('\'unsafe-inline\'') !== -1
7373
}
7474

75-
function addInlineScriptExceptions (directives) {
75+
function addInlineScriptExceptions(directives) {
7676
directives.scriptSrc.push(getCspNonce)
7777
// TODO: This is the SHA-256 hash of the inline script in build/reveal.js/plugins/notes/notes.html
7878
// Any more clean solution appreciated.
7979
directives.scriptSrc.push('\'sha256-81acLZNZISnyGYZrSuoYhpzwDTTxi7vC1YM4uNxqWaM=\'')
8080
}
8181

82-
function getCspNonce (req, res) {
82+
function getCspNonce(req, res) {
8383
return "'nonce-" + res.locals.nonce + "'"
8484
}
8585

86-
function addUpgradeUnsafeRequestsOptionTo (directives) {
86+
function addUpgradeUnsafeRequestsOptionTo(directives) {
8787
if (config.csp.upgradeInsecureRequests === 'auto' && config.useSSL) {
8888
directives.upgradeInsecureRequests = true
8989
} else if (config.csp.upgradeInsecureRequests === true) {
9090
directives.upgradeInsecureRequests = true
9191
}
9292
}
9393

94-
function addReportURI (directives) {
94+
function addReportURI(directives) {
9595
if (config.csp.reportURI) {
9696
directives.reportUri = config.csp.reportURI
9797
}
@@ -102,4 +102,4 @@ CspStrategy.addNonceToLocals = function (req, res, next) {
102102
next()
103103
}
104104

105-
module.exports = CspStrategy
105+
export = CspStrategy

0 commit comments

Comments
 (0)