index.cjs 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588
  1. "use strict"
  2. Object.defineProperties(exports, {__esModule: {value: true}, [Symbol.toStringTag]: {value: "Module"}})
  3. const dangerouslyDisableDefaultSrc = Symbol("dangerouslyDisableDefaultSrc")
  4. const SHOULD_BE_QUOTED = new Set(["none", "self", "strict-dynamic", "report-sample", "inline-speculation-rules", "unsafe-inline", "unsafe-eval", "unsafe-hashes", "wasm-unsafe-eval"])
  5. const getDefaultDirectives = () => ({
  6. "default-src": ["'self'"],
  7. "base-uri": ["'self'"],
  8. "font-src": ["'self'", "https:", "data:"],
  9. "form-action": ["'self'"],
  10. "frame-ancestors": ["'self'"],
  11. "img-src": ["'self'", "data:"],
  12. "object-src": ["'none'"],
  13. "script-src": ["'self'"],
  14. "script-src-attr": ["'none'"],
  15. "style-src": ["'self'", "https:", "'unsafe-inline'"],
  16. "upgrade-insecure-requests": []
  17. })
  18. const dashify = str => str.replace(/[A-Z]/g, capitalLetter => "-" + capitalLetter.toLowerCase())
  19. const assertDirectiveValueIsValid = (directiveName, directiveValue) => {
  20. if (/;|,/.test(directiveValue)) {
  21. throw new Error(`Content-Security-Policy received an invalid directive value for ${JSON.stringify(directiveName)}`)
  22. }
  23. }
  24. const assertDirectiveValueEntryIsValid = (directiveName, directiveValueEntry) => {
  25. if (SHOULD_BE_QUOTED.has(directiveValueEntry) || directiveValueEntry.startsWith("nonce-") || directiveValueEntry.startsWith("sha256-") || directiveValueEntry.startsWith("sha384-") || directiveValueEntry.startsWith("sha512-")) {
  26. throw new Error(`Content-Security-Policy received an invalid directive value for ${JSON.stringify(directiveName)}. ${JSON.stringify(directiveValueEntry)} should be quoted`)
  27. }
  28. }
  29. function normalizeDirectives(options) {
  30. const defaultDirectives = getDefaultDirectives()
  31. const {useDefaults = true, directives: rawDirectives = defaultDirectives} = options
  32. const result = new Map()
  33. const directiveNamesSeen = new Set()
  34. const directivesExplicitlyDisabled = new Set()
  35. for (const rawDirectiveName in rawDirectives) {
  36. if (!Object.hasOwn(rawDirectives, rawDirectiveName)) {
  37. continue
  38. }
  39. if (rawDirectiveName.length === 0 || /[^a-zA-Z0-9-]/.test(rawDirectiveName)) {
  40. throw new Error(`Content-Security-Policy received an invalid directive name ${JSON.stringify(rawDirectiveName)}`)
  41. }
  42. const directiveName = dashify(rawDirectiveName)
  43. if (directiveNamesSeen.has(directiveName)) {
  44. throw new Error(`Content-Security-Policy received a duplicate directive ${JSON.stringify(directiveName)}`)
  45. }
  46. directiveNamesSeen.add(directiveName)
  47. const rawDirectiveValue = rawDirectives[rawDirectiveName]
  48. let directiveValue
  49. if (rawDirectiveValue === null) {
  50. if (directiveName === "default-src") {
  51. throw new Error("Content-Security-Policy needs a default-src but it was set to `null`. If you really want to disable it, set it to `contentSecurityPolicy.dangerouslyDisableDefaultSrc`.")
  52. }
  53. directivesExplicitlyDisabled.add(directiveName)
  54. continue
  55. } else if (typeof rawDirectiveValue === "string") {
  56. directiveValue = [rawDirectiveValue]
  57. } else if (!rawDirectiveValue) {
  58. throw new Error(`Content-Security-Policy received an invalid directive value for ${JSON.stringify(directiveName)}`)
  59. } else if (rawDirectiveValue === dangerouslyDisableDefaultSrc) {
  60. if (directiveName === "default-src") {
  61. directivesExplicitlyDisabled.add("default-src")
  62. continue
  63. } else {
  64. throw new Error(`Content-Security-Policy: tried to disable ${JSON.stringify(directiveName)} as if it were default-src; simply omit the key`)
  65. }
  66. } else {
  67. directiveValue = rawDirectiveValue
  68. }
  69. for (const element of directiveValue) {
  70. if (typeof element !== "string") continue
  71. assertDirectiveValueIsValid(directiveName, element)
  72. assertDirectiveValueEntryIsValid(directiveName, element)
  73. }
  74. result.set(directiveName, directiveValue)
  75. }
  76. if (useDefaults) {
  77. Object.entries(defaultDirectives).forEach(([defaultDirectiveName, defaultDirectiveValue]) => {
  78. if (!result.has(defaultDirectiveName) && !directivesExplicitlyDisabled.has(defaultDirectiveName)) {
  79. result.set(defaultDirectiveName, defaultDirectiveValue)
  80. }
  81. })
  82. }
  83. if (!result.size) {
  84. throw new Error("Content-Security-Policy has no directives. Either set some or disable the header")
  85. }
  86. if (!result.has("default-src") && !directivesExplicitlyDisabled.has("default-src")) {
  87. throw new Error("Content-Security-Policy needs a default-src but none was provided. If you really want to disable it, set it to `contentSecurityPolicy.dangerouslyDisableDefaultSrc`.")
  88. }
  89. return result
  90. }
  91. function getHeaderValue(req, res, normalizedDirectives) {
  92. const result = []
  93. for (const [directiveName, rawDirectiveValue] of normalizedDirectives) {
  94. let directiveValue = ""
  95. for (const element of rawDirectiveValue) {
  96. if (typeof element === "function") {
  97. const newElement = element(req, res)
  98. assertDirectiveValueEntryIsValid(directiveName, newElement)
  99. directiveValue += " " + newElement
  100. } else {
  101. directiveValue += " " + element
  102. }
  103. }
  104. if (directiveValue) {
  105. assertDirectiveValueIsValid(directiveName, directiveValue)
  106. result.push(`${directiveName}${directiveValue}`)
  107. } else {
  108. result.push(directiveName)
  109. }
  110. }
  111. return result.join(";")
  112. }
  113. const contentSecurityPolicy = function contentSecurityPolicy(options = {}) {
  114. const headerName = options.reportOnly ? "Content-Security-Policy-Report-Only" : "Content-Security-Policy"
  115. const normalizedDirectives = normalizeDirectives(options)
  116. return function contentSecurityPolicyMiddleware(req, res, next) {
  117. const result = getHeaderValue(req, res, normalizedDirectives)
  118. if (result instanceof Error) {
  119. next(result)
  120. } else {
  121. res.setHeader(headerName, result)
  122. next()
  123. }
  124. }
  125. }
  126. contentSecurityPolicy.getDefaultDirectives = getDefaultDirectives
  127. contentSecurityPolicy.dangerouslyDisableDefaultSrc = dangerouslyDisableDefaultSrc
  128. const ALLOWED_POLICIES$2 = new Set(["require-corp", "credentialless", "unsafe-none"])
  129. function getHeaderValueFromOptions$6({policy = "require-corp"}) {
  130. if (ALLOWED_POLICIES$2.has(policy)) {
  131. return policy
  132. } else {
  133. throw new Error(`Cross-Origin-Embedder-Policy does not support the ${JSON.stringify(policy)} policy`)
  134. }
  135. }
  136. function crossOriginEmbedderPolicy(options = {}) {
  137. const headerValue = getHeaderValueFromOptions$6(options)
  138. return function crossOriginEmbedderPolicyMiddleware(_req, res, next) {
  139. res.setHeader("Cross-Origin-Embedder-Policy", headerValue)
  140. next()
  141. }
  142. }
  143. const ALLOWED_POLICIES$1 = new Set(["same-origin", "same-origin-allow-popups", "unsafe-none"])
  144. function getHeaderValueFromOptions$5({policy = "same-origin"}) {
  145. if (ALLOWED_POLICIES$1.has(policy)) {
  146. return policy
  147. } else {
  148. throw new Error(`Cross-Origin-Opener-Policy does not support the ${JSON.stringify(policy)} policy`)
  149. }
  150. }
  151. function crossOriginOpenerPolicy(options = {}) {
  152. const headerValue = getHeaderValueFromOptions$5(options)
  153. return function crossOriginOpenerPolicyMiddleware(_req, res, next) {
  154. res.setHeader("Cross-Origin-Opener-Policy", headerValue)
  155. next()
  156. }
  157. }
  158. const ALLOWED_POLICIES = new Set(["same-origin", "same-site", "cross-origin"])
  159. function getHeaderValueFromOptions$4({policy = "same-origin"}) {
  160. if (ALLOWED_POLICIES.has(policy)) {
  161. return policy
  162. } else {
  163. throw new Error(`Cross-Origin-Resource-Policy does not support the ${JSON.stringify(policy)} policy`)
  164. }
  165. }
  166. function crossOriginResourcePolicy(options = {}) {
  167. const headerValue = getHeaderValueFromOptions$4(options)
  168. return function crossOriginResourcePolicyMiddleware(_req, res, next) {
  169. res.setHeader("Cross-Origin-Resource-Policy", headerValue)
  170. next()
  171. }
  172. }
  173. function originAgentCluster() {
  174. return function originAgentClusterMiddleware(_req, res, next) {
  175. res.setHeader("Origin-Agent-Cluster", "?1")
  176. next()
  177. }
  178. }
  179. const ALLOWED_TOKENS = new Set(["no-referrer", "no-referrer-when-downgrade", "same-origin", "origin", "strict-origin", "origin-when-cross-origin", "strict-origin-when-cross-origin", "unsafe-url", ""])
  180. function getHeaderValueFromOptions$3({policy = ["no-referrer"]}) {
  181. const tokens = typeof policy === "string" ? [policy] : policy
  182. if (tokens.length === 0) {
  183. throw new Error("Referrer-Policy received no policy tokens")
  184. }
  185. const tokensSeen = new Set()
  186. tokens.forEach(token => {
  187. if (!ALLOWED_TOKENS.has(token)) {
  188. throw new Error(`Referrer-Policy received an unexpected policy token ${JSON.stringify(token)}`)
  189. } else if (tokensSeen.has(token)) {
  190. throw new Error(`Referrer-Policy received a duplicate policy token ${JSON.stringify(token)}`)
  191. }
  192. tokensSeen.add(token)
  193. })
  194. return tokens.join(",")
  195. }
  196. function referrerPolicy(options = {}) {
  197. const headerValue = getHeaderValueFromOptions$3(options)
  198. return function referrerPolicyMiddleware(_req, res, next) {
  199. res.setHeader("Referrer-Policy", headerValue)
  200. next()
  201. }
  202. }
  203. const DEFAULT_MAX_AGE = 365 * 24 * 60 * 60
  204. function parseMaxAge(value = DEFAULT_MAX_AGE) {
  205. if (value >= 0 && Number.isFinite(value)) {
  206. return Math.floor(value)
  207. } else {
  208. throw new Error(`Strict-Transport-Security: ${JSON.stringify(value)} is not a valid value for maxAge. Please choose a positive integer.`)
  209. }
  210. }
  211. function getHeaderValueFromOptions$2(options) {
  212. if ("maxage" in options) {
  213. throw new Error("Strict-Transport-Security received an unsupported property, `maxage`. Did you mean to pass `maxAge`?")
  214. }
  215. if ("includeSubdomains" in options) {
  216. throw new Error('Strict-Transport-Security middleware should use `includeSubDomains` instead of `includeSubdomains`. (The correct one has an uppercase "D".)')
  217. }
  218. const directives = [`max-age=${parseMaxAge(options.maxAge)}`]
  219. if (options.includeSubDomains === undefined || options.includeSubDomains) {
  220. directives.push("includeSubDomains")
  221. }
  222. if (options.preload) {
  223. directives.push("preload")
  224. }
  225. return directives.join("; ")
  226. }
  227. function strictTransportSecurity(options = {}) {
  228. const headerValue = getHeaderValueFromOptions$2(options)
  229. return function strictTransportSecurityMiddleware(_req, res, next) {
  230. res.setHeader("Strict-Transport-Security", headerValue)
  231. next()
  232. }
  233. }
  234. function xContentTypeOptions() {
  235. return function xContentTypeOptionsMiddleware(_req, res, next) {
  236. res.setHeader("X-Content-Type-Options", "nosniff")
  237. next()
  238. }
  239. }
  240. function xDnsPrefetchControl(options = {}) {
  241. const headerValue = options.allow ? "on" : "off"
  242. return function xDnsPrefetchControlMiddleware(_req, res, next) {
  243. res.setHeader("X-DNS-Prefetch-Control", headerValue)
  244. next()
  245. }
  246. }
  247. function xDownloadOptions() {
  248. return function xDownloadOptionsMiddleware(_req, res, next) {
  249. res.setHeader("X-Download-Options", "noopen")
  250. next()
  251. }
  252. }
  253. function getHeaderValueFromOptions$1({action = "sameorigin"}) {
  254. const normalizedAction = typeof action === "string" ? action.toUpperCase() : action
  255. switch (normalizedAction) {
  256. case "SAME-ORIGIN":
  257. return "SAMEORIGIN"
  258. case "DENY":
  259. case "SAMEORIGIN":
  260. return normalizedAction
  261. default:
  262. throw new Error(`X-Frame-Options received an invalid action ${JSON.stringify(action)}`)
  263. }
  264. }
  265. function xFrameOptions(options = {}) {
  266. const headerValue = getHeaderValueFromOptions$1(options)
  267. return function xFrameOptionsMiddleware(_req, res, next) {
  268. res.setHeader("X-Frame-Options", headerValue)
  269. next()
  270. }
  271. }
  272. const ALLOWED_PERMITTED_POLICIES = new Set(["none", "master-only", "by-content-type", "all"])
  273. function getHeaderValueFromOptions({permittedPolicies = "none"}) {
  274. if (ALLOWED_PERMITTED_POLICIES.has(permittedPolicies)) {
  275. return permittedPolicies
  276. } else {
  277. throw new Error(`X-Permitted-Cross-Domain-Policies does not support ${JSON.stringify(permittedPolicies)}`)
  278. }
  279. }
  280. function xPermittedCrossDomainPolicies(options = {}) {
  281. const headerValue = getHeaderValueFromOptions(options)
  282. return function xPermittedCrossDomainPoliciesMiddleware(_req, res, next) {
  283. res.setHeader("X-Permitted-Cross-Domain-Policies", headerValue)
  284. next()
  285. }
  286. }
  287. function xPoweredBy() {
  288. return function xPoweredByMiddleware(_req, res, next) {
  289. res.removeHeader("X-Powered-By")
  290. next()
  291. }
  292. }
  293. function xXssProtection() {
  294. return function xXssProtectionMiddleware(_req, res, next) {
  295. res.setHeader("X-XSS-Protection", "0")
  296. next()
  297. }
  298. }
  299. function getMiddlewareFunctionsFromOptions(options) {
  300. const result = []
  301. switch (options.contentSecurityPolicy) {
  302. case undefined:
  303. case true:
  304. result.push(contentSecurityPolicy())
  305. break
  306. case false:
  307. break
  308. default:
  309. result.push(contentSecurityPolicy(options.contentSecurityPolicy))
  310. break
  311. }
  312. switch (options.crossOriginEmbedderPolicy) {
  313. case undefined:
  314. case false:
  315. break
  316. case true:
  317. result.push(crossOriginEmbedderPolicy())
  318. break
  319. default:
  320. result.push(crossOriginEmbedderPolicy(options.crossOriginEmbedderPolicy))
  321. break
  322. }
  323. switch (options.crossOriginOpenerPolicy) {
  324. case undefined:
  325. case true:
  326. result.push(crossOriginOpenerPolicy())
  327. break
  328. case false:
  329. break
  330. default:
  331. result.push(crossOriginOpenerPolicy(options.crossOriginOpenerPolicy))
  332. break
  333. }
  334. switch (options.crossOriginResourcePolicy) {
  335. case undefined:
  336. case true:
  337. result.push(crossOriginResourcePolicy())
  338. break
  339. case false:
  340. break
  341. default:
  342. result.push(crossOriginResourcePolicy(options.crossOriginResourcePolicy))
  343. break
  344. }
  345. switch (options.originAgentCluster) {
  346. case undefined:
  347. case true:
  348. result.push(originAgentCluster())
  349. break
  350. case false:
  351. break
  352. default:
  353. console.warn("Origin-Agent-Cluster does not take options. Remove the property to silence this warning.")
  354. result.push(originAgentCluster())
  355. break
  356. }
  357. switch (options.referrerPolicy) {
  358. case undefined:
  359. case true:
  360. result.push(referrerPolicy())
  361. break
  362. case false:
  363. break
  364. default:
  365. result.push(referrerPolicy(options.referrerPolicy))
  366. break
  367. }
  368. if ("strictTransportSecurity" in options && "hsts" in options) {
  369. throw new Error("Strict-Transport-Security option was specified twice. Remove `hsts` to silence this warning.")
  370. }
  371. const strictTransportSecurityOption = options.strictTransportSecurity ?? options.hsts
  372. switch (strictTransportSecurityOption) {
  373. case undefined:
  374. case true:
  375. result.push(strictTransportSecurity())
  376. break
  377. case false:
  378. break
  379. default:
  380. result.push(strictTransportSecurity(strictTransportSecurityOption))
  381. break
  382. }
  383. if ("xContentTypeOptions" in options && "noSniff" in options) {
  384. throw new Error("X-Content-Type-Options option was specified twice. Remove `noSniff` to silence this warning.")
  385. }
  386. const xContentTypeOptionsOption = options.xContentTypeOptions ?? options.noSniff
  387. switch (xContentTypeOptionsOption) {
  388. case undefined:
  389. case true:
  390. result.push(xContentTypeOptions())
  391. break
  392. case false:
  393. break
  394. default:
  395. console.warn("X-Content-Type-Options does not take options. Remove the property to silence this warning.")
  396. result.push(xContentTypeOptions())
  397. break
  398. }
  399. if ("xDnsPrefetchControl" in options && "dnsPrefetchControl" in options) {
  400. throw new Error("X-DNS-Prefetch-Control option was specified twice. Remove `dnsPrefetchControl` to silence this warning.")
  401. }
  402. const xDnsPrefetchControlOption = options.xDnsPrefetchControl ?? options.dnsPrefetchControl
  403. switch (xDnsPrefetchControlOption) {
  404. case undefined:
  405. case true:
  406. result.push(xDnsPrefetchControl())
  407. break
  408. case false:
  409. break
  410. default:
  411. result.push(xDnsPrefetchControl(xDnsPrefetchControlOption))
  412. break
  413. }
  414. if ("xDownloadOptions" in options && "ieNoOpen" in options) {
  415. throw new Error("X-Download-Options option was specified twice. Remove `ieNoOpen` to silence this warning.")
  416. }
  417. const xDownloadOptionsOption = options.xDownloadOptions ?? options.ieNoOpen
  418. switch (xDownloadOptionsOption) {
  419. case undefined:
  420. case true:
  421. result.push(xDownloadOptions())
  422. break
  423. case false:
  424. break
  425. default:
  426. console.warn("X-Download-Options does not take options. Remove the property to silence this warning.")
  427. result.push(xDownloadOptions())
  428. break
  429. }
  430. if ("xFrameOptions" in options && "frameguard" in options) {
  431. throw new Error("X-Frame-Options option was specified twice. Remove `frameguard` to silence this warning.")
  432. }
  433. const xFrameOptionsOption = options.xFrameOptions ?? options.frameguard
  434. switch (xFrameOptionsOption) {
  435. case undefined:
  436. case true:
  437. result.push(xFrameOptions())
  438. break
  439. case false:
  440. break
  441. default:
  442. result.push(xFrameOptions(xFrameOptionsOption))
  443. break
  444. }
  445. if ("xPermittedCrossDomainPolicies" in options && "permittedCrossDomainPolicies" in options) {
  446. throw new Error("X-Permitted-Cross-Domain-Policies option was specified twice. Remove `permittedCrossDomainPolicies` to silence this warning.")
  447. }
  448. const xPermittedCrossDomainPoliciesOption = options.xPermittedCrossDomainPolicies ?? options.permittedCrossDomainPolicies
  449. switch (xPermittedCrossDomainPoliciesOption) {
  450. case undefined:
  451. case true:
  452. result.push(xPermittedCrossDomainPolicies())
  453. break
  454. case false:
  455. break
  456. default:
  457. result.push(xPermittedCrossDomainPolicies(xPermittedCrossDomainPoliciesOption))
  458. break
  459. }
  460. if ("xPoweredBy" in options && "hidePoweredBy" in options) {
  461. throw new Error("X-Powered-By option was specified twice. Remove `hidePoweredBy` to silence this warning.")
  462. }
  463. const xPoweredByOption = options.xPoweredBy ?? options.hidePoweredBy
  464. switch (xPoweredByOption) {
  465. case undefined:
  466. case true:
  467. result.push(xPoweredBy())
  468. break
  469. case false:
  470. break
  471. default:
  472. console.warn("X-Powered-By does not take options. Remove the property to silence this warning.")
  473. result.push(xPoweredBy())
  474. break
  475. }
  476. if ("xXssProtection" in options && "xssFilter" in options) {
  477. throw new Error("X-XSS-Protection option was specified twice. Remove `xssFilter` to silence this warning.")
  478. }
  479. const xXssProtectionOption = options.xXssProtection ?? options.xssFilter
  480. switch (xXssProtectionOption) {
  481. case undefined:
  482. case true:
  483. result.push(xXssProtection())
  484. break
  485. case false:
  486. break
  487. default:
  488. console.warn("X-XSS-Protection does not take options. Remove the property to silence this warning.")
  489. result.push(xXssProtection())
  490. break
  491. }
  492. return result
  493. }
  494. const helmet = Object.assign(
  495. function helmet(options = {}) {
  496. // People should be able to pass an options object with no prototype,
  497. // so we want this optional chaining.
  498. // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
  499. if (options.constructor?.name === "IncomingMessage") {
  500. throw new Error("It appears you have done something like `app.use(helmet)`, but it should be `app.use(helmet())`.")
  501. }
  502. const middlewareFunctions = getMiddlewareFunctionsFromOptions(options)
  503. return function helmetMiddleware(req, res, next) {
  504. let middlewareIndex = 0
  505. ;(function internalNext(err) {
  506. if (err) {
  507. next(err)
  508. return
  509. }
  510. const middlewareFunction = middlewareFunctions[middlewareIndex]
  511. if (middlewareFunction) {
  512. middlewareIndex++
  513. middlewareFunction(req, res, internalNext)
  514. } else {
  515. next()
  516. }
  517. })()
  518. }
  519. },
  520. {
  521. contentSecurityPolicy,
  522. crossOriginEmbedderPolicy,
  523. crossOriginOpenerPolicy,
  524. crossOriginResourcePolicy,
  525. originAgentCluster,
  526. referrerPolicy,
  527. strictTransportSecurity,
  528. xContentTypeOptions,
  529. xDnsPrefetchControl,
  530. xDownloadOptions,
  531. xFrameOptions,
  532. xPermittedCrossDomainPolicies,
  533. xPoweredBy,
  534. xXssProtection,
  535. // Legacy aliases
  536. dnsPrefetchControl: xDnsPrefetchControl,
  537. xssFilter: xXssProtection,
  538. permittedCrossDomainPolicies: xPermittedCrossDomainPolicies,
  539. ieNoOpen: xDownloadOptions,
  540. noSniff: xContentTypeOptions,
  541. frameguard: xFrameOptions,
  542. hidePoweredBy: xPoweredBy,
  543. hsts: strictTransportSecurity
  544. }
  545. )
  546. exports.contentSecurityPolicy = contentSecurityPolicy
  547. exports.crossOriginEmbedderPolicy = crossOriginEmbedderPolicy
  548. exports.crossOriginOpenerPolicy = crossOriginOpenerPolicy
  549. exports.crossOriginResourcePolicy = crossOriginResourcePolicy
  550. exports.default = helmet
  551. exports.dnsPrefetchControl = xDnsPrefetchControl
  552. exports.frameguard = xFrameOptions
  553. exports.hidePoweredBy = xPoweredBy
  554. exports.hsts = strictTransportSecurity
  555. exports.ieNoOpen = xDownloadOptions
  556. exports.noSniff = xContentTypeOptions
  557. exports.originAgentCluster = originAgentCluster
  558. exports.permittedCrossDomainPolicies = xPermittedCrossDomainPolicies
  559. exports.referrerPolicy = referrerPolicy
  560. exports.strictTransportSecurity = strictTransportSecurity
  561. exports.xContentTypeOptions = xContentTypeOptions
  562. exports.xDnsPrefetchControl = xDnsPrefetchControl
  563. exports.xDownloadOptions = xDownloadOptions
  564. exports.xFrameOptions = xFrameOptions
  565. exports.xPermittedCrossDomainPolicies = xPermittedCrossDomainPolicies
  566. exports.xPoweredBy = xPoweredBy
  567. exports.xXssProtection = xXssProtection
  568. exports.xssFilter = xXssProtection
  569. module.exports = exports.default
  570. module.exports.default = module.exports