nitro-helmet
Advanced tools
Comparing version 0.1.0 to 0.2.0
/*****************************************************************************************************************/ | ||
/*****************************************************************************************************************/ | ||
export { type H3HelmetOptions, defineHelmetEventHandler } from './defineHelmetEventHandler'; | ||
export { helmetEventHandler } from './helmetEventHandler'; | ||
/*****************************************************************************************************************/ |
@@ -8,3 +8,3 @@ class S extends Error { | ||
message: this.message, | ||
statusCode: p(this.statusCode, 500) | ||
statusCode: h(this.statusCode, 500) | ||
}; | ||
@@ -19,9 +19,9 @@ return this.statusMessage && (e.statusMessage = X(this.statusMessage)), this.data !== void 0 && (e.data = this.data), e; | ||
} | ||
function p(t, e = 200) { | ||
function h(t, e = 200) { | ||
return !t || (typeof t == "string" && (t = Number.parseInt(t, 10)), t < 100 || t > 999) ? e : t; | ||
} | ||
function h(t, e, r) { | ||
function p(t, e, r) { | ||
t.node.res.setHeader(e, r); | ||
} | ||
const n = h; | ||
const n = p; | ||
function D(t) { | ||
@@ -100,6 +100,7 @@ return t.__is_handler__ = !0, t; | ||
return y(r, o.contentSecurityPolicy), x(r, o.crossOriginEmbedderPolicy), E(r, o.crossOriginOpenerPolicy), T(r, o.crossOriginResourcePolicy), _(r, o.originAgentCluster), R(r, o.referrerPolicy), A(r, o.strictTransportSecurity), H(r, o.xContentTypeOptions), N(r, o.xDNSPrefetchControl), I(r, o.xDownloadOptions), M(r, o.xFrameOptions), w(r, o.xPermittedCrossDomainPolicies), F(r, o.xXSSProtection), t(r); | ||
}); | ||
}), z = (t, e) => q(t, e); | ||
export { | ||
q as defineHelmetEventHandler | ||
q as defineHelmetEventHandler, | ||
z as helmetEventHandler | ||
}; | ||
//# sourceMappingURL=nitro-helmet.es.js.map |
@@ -1,16 +0,16 @@ | ||
(function(s,i){typeof exports=="object"&&typeof module<"u"?i(exports):typeof define=="function"&&define.amd?define(["exports"],i):(s=typeof globalThis<"u"?globalThis:s||self,i(s["@observerly/nitro-helmet"]={}))})(this,function(s){"use strict";class i extends Error{constructor(){super(...arguments),this.statusCode=500,this.fatal=!1,this.unhandled=!1,this.statusMessage=void 0}toJSON(){const e={message:this.message,statusCode:X(this.statusCode,500)};return this.statusMessage&&(e.statusMessage=h(this.statusMessage)),this.data!==void 0&&(e.data=this.data),e}}i.__h3_error__=!0;const p=/[^\u0009\u0020-\u007E]/g;function h(t=""){return t.replace(p,"")}function X(t,e=200){return!t||(typeof t=="string"&&(t=Number.parseInt(t,10)),t<100||t>999)?e:t}typeof setImmediate<"u"&&setImmediate;function y(t,e,r){t.node.res.setHeader(e,r)}const o=y;function D(t){return t.__is_handler__=!0,t}// @license Copyright © 2021-2023 observerly | ||
const f=" default-src 'self';base-uri 'self'; font-src 'self' https: data:; form-action 'self'; frame-ancestors 'self'; img-src 'self' data:; object-src 'none'; script-src 'self'; script-src-attr 'none'; style-src 'self' https: 'unsafe-inline'; upgrade-insecure-requests ".trim().replace(/\s/g,""),x=(t,e=f)=>{typeof e=="boolean"&&!e||(typeof e=="boolean"&&e&&(e=f),o(t,"Content-Security-Policy",e))};// @license Copyright © 2021-2023 observerly | ||
const a="require-corp",T=(t,e=a)=>{typeof e=="boolean"&&!e||(typeof e=="boolean"&&(e=a),o(t,"Cross-Origin-Embedder-Policy",e))};// @license Copyright © 2021-2023 observerly | ||
const u="same-origin",E=(t,e=u)=>{typeof e=="boolean"&&!e||(typeof e=="boolean"&&(e=u),o(t,"Cross-Origin-Opener-Policy",e))};// @license Copyright © 2021-2023 observerly | ||
const c="same-origin",_=(t,e=c)=>{typeof e=="boolean"&&!e||(typeof e=="boolean"&&(e=c),o(t,"Cross-Origin-Resource-Policy",e))};// @license Copyright © 2021-2023 observerly | ||
const d="?1",R=(t,e=d)=>{typeof e=="boolean"&&!e||(typeof e=="boolean"&&(e=d),o(t,"Origin-Agent-Cluster",e))};// @license Copyright © 2021-2023 observerly | ||
const l="no-referrer",H=(t,e=l)=>{typeof e=="boolean"&&!e||(typeof e=="boolean"&&(e=l),o(t,"Referrer-Policy",e))};// @license Copyright © 2021-2023 observerly | ||
const P="max-age=15552000; includeSubDomains",A=(t,e=P)=>{typeof e=="boolean"&&!e||(typeof e=="boolean"&&(e=P),o(t,"Strict-Transport-Security",e))};// @license Copyright © 2021-2023 observerly | ||
const g="nosniff",N=(t,e=g)=>{typeof e=="boolean"&&!e||(typeof e=="boolean"&&(e=g),o(t,"X-Content-Type-Options",e))};// @license Copyright © 2021-2023 observerly | ||
const m="off",M=(t,e=m)=>{typeof e=="boolean"&&!e||(typeof e=="boolean"&&(e=m),o(t,"X-DNS-Prefetch-Control",e))};// @license Copyright © 2021-2023 observerly | ||
const O="noopen",I=(t,e=O)=>{typeof e=="boolean"&&!e||(typeof e=="boolean"&&(e=O),o(t,"X-Download-Options",e))};// @license Copyright © 2021-2023 observerly | ||
const b="SAMEORIGIN",w=(t,e=b)=>{typeof e=="boolean"&&!e||(typeof e=="boolean"&&(e=b),o(t,"X-Frame-Options",e))};// @license Copyright © 2021-2023 observerly | ||
const S="none",F=(t,e=S)=>{typeof e=="boolean"&&!e||(typeof e=="boolean"&&(e=S),o(t,"X-Permitted-Cross-Domain-Policies",e))};// @license Copyright © 2021-2023 observerly | ||
const C="1; mode=block",j=(t,e=C)=>{typeof e=="boolean"&&!e||(typeof e=="boolean"&&(e=C),o(t,"X-XSS-Protection",e))},q={contentSecurityPolicy:f,crossOriginEmbedderPolicy:a,crossOriginOpenerPolicy:u,crossOriginResourcePolicy:c,originAgentCluster:d,referrerPolicy:l,strictTransportSecurity:P,xContentTypeOptions:g,xDNSPrefetchControl:m,xDownloadOptions:O,xFrameOptions:b,xPermittedCrossDomainPolicies:S,xXSSProtection:C};// @license Copyright © 2021-2023 observerly | ||
const z=(t,e)=>D(async r=>{const n={...q,...e};return x(r,n.contentSecurityPolicy),T(r,n.crossOriginEmbedderPolicy),E(r,n.crossOriginOpenerPolicy),_(r,n.crossOriginResourcePolicy),R(r,n.originAgentCluster),H(r,n.referrerPolicy),A(r,n.strictTransportSecurity),N(r,n.xContentTypeOptions),M(r,n.xDNSPrefetchControl),I(r,n.xDownloadOptions),w(r,n.xFrameOptions),F(r,n.xPermittedCrossDomainPolicies),j(r,n.xXSSProtection),t(r)});s.defineHelmetEventHandler=z,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})}); | ||
(function(s,i){typeof exports=="object"&&typeof module<"u"?i(exports):typeof define=="function"&&define.amd?define(["exports"],i):(s=typeof globalThis<"u"?globalThis:s||self,i(s["@observerly/nitro-helmet"]={}))})(this,function(s){"use strict";class i extends Error{constructor(){super(...arguments),this.statusCode=500,this.fatal=!1,this.unhandled=!1,this.statusMessage=void 0}toJSON(){const e={message:this.message,statusCode:y(this.statusCode,500)};return this.statusMessage&&(e.statusMessage=X(this.statusMessage)),this.data!==void 0&&(e.data=this.data),e}}i.__h3_error__=!0;const p=/[^\u0009\u0020-\u007E]/g;function X(t=""){return t.replace(p,"")}function y(t,e=200){return!t||(typeof t=="string"&&(t=Number.parseInt(t,10)),t<100||t>999)?e:t}typeof setImmediate<"u"&&setImmediate;function D(t,e,r){t.node.res.setHeader(e,r)}const n=D;function x(t){return t.__is_handler__=!0,t}// @license Copyright © 2021-2023 observerly | ||
const f=" default-src 'self';base-uri 'self'; font-src 'self' https: data:; form-action 'self'; frame-ancestors 'self'; img-src 'self' data:; object-src 'none'; script-src 'self'; script-src-attr 'none'; style-src 'self' https: 'unsafe-inline'; upgrade-insecure-requests ".trim().replace(/\s/g,""),E=(t,e=f)=>{typeof e=="boolean"&&!e||(typeof e=="boolean"&&e&&(e=f),n(t,"Content-Security-Policy",e))};// @license Copyright © 2021-2023 observerly | ||
const a="require-corp",T=(t,e=a)=>{typeof e=="boolean"&&!e||(typeof e=="boolean"&&(e=a),n(t,"Cross-Origin-Embedder-Policy",e))};// @license Copyright © 2021-2023 observerly | ||
const u="same-origin",H=(t,e=u)=>{typeof e=="boolean"&&!e||(typeof e=="boolean"&&(e=u),n(t,"Cross-Origin-Opener-Policy",e))};// @license Copyright © 2021-2023 observerly | ||
const c="same-origin",_=(t,e=c)=>{typeof e=="boolean"&&!e||(typeof e=="boolean"&&(e=c),n(t,"Cross-Origin-Resource-Policy",e))};// @license Copyright © 2021-2023 observerly | ||
const d="?1",R=(t,e=d)=>{typeof e=="boolean"&&!e||(typeof e=="boolean"&&(e=d),n(t,"Origin-Agent-Cluster",e))};// @license Copyright © 2021-2023 observerly | ||
const l="no-referrer",A=(t,e=l)=>{typeof e=="boolean"&&!e||(typeof e=="boolean"&&(e=l),n(t,"Referrer-Policy",e))};// @license Copyright © 2021-2023 observerly | ||
const P="max-age=15552000; includeSubDomains",N=(t,e=P)=>{typeof e=="boolean"&&!e||(typeof e=="boolean"&&(e=P),n(t,"Strict-Transport-Security",e))};// @license Copyright © 2021-2023 observerly | ||
const m="nosniff",M=(t,e=m)=>{typeof e=="boolean"&&!e||(typeof e=="boolean"&&(e=m),n(t,"X-Content-Type-Options",e))};// @license Copyright © 2021-2023 observerly | ||
const g="off",I=(t,e=g)=>{typeof e=="boolean"&&!e||(typeof e=="boolean"&&(e=g),n(t,"X-DNS-Prefetch-Control",e))};// @license Copyright © 2021-2023 observerly | ||
const O="noopen",w=(t,e=O)=>{typeof e=="boolean"&&!e||(typeof e=="boolean"&&(e=O),n(t,"X-Download-Options",e))};// @license Copyright © 2021-2023 observerly | ||
const b="SAMEORIGIN",F=(t,e=b)=>{typeof e=="boolean"&&!e||(typeof e=="boolean"&&(e=b),n(t,"X-Frame-Options",e))};// @license Copyright © 2021-2023 observerly | ||
const S="none",j=(t,e=S)=>{typeof e=="boolean"&&!e||(typeof e=="boolean"&&(e=S),n(t,"X-Permitted-Cross-Domain-Policies",e))};// @license Copyright © 2021-2023 observerly | ||
const C="1; mode=block",q=(t,e=C)=>{typeof e=="boolean"&&!e||(typeof e=="boolean"&&(e=C),n(t,"X-XSS-Protection",e))},z={contentSecurityPolicy:f,crossOriginEmbedderPolicy:a,crossOriginOpenerPolicy:u,crossOriginResourcePolicy:c,originAgentCluster:d,referrerPolicy:l,strictTransportSecurity:P,xContentTypeOptions:m,xDNSPrefetchControl:g,xDownloadOptions:O,xFrameOptions:b,xPermittedCrossDomainPolicies:S,xXSSProtection:C};// @license Copyright © 2021-2023 observerly | ||
const h=(t,e)=>x(async r=>{const o={...z,...e};return E(r,o.contentSecurityPolicy),T(r,o.crossOriginEmbedderPolicy),H(r,o.crossOriginOpenerPolicy),_(r,o.crossOriginResourcePolicy),R(r,o.originAgentCluster),A(r,o.referrerPolicy),N(r,o.strictTransportSecurity),M(r,o.xContentTypeOptions),I(r,o.xDNSPrefetchControl),w(r,o.xDownloadOptions),F(r,o.xFrameOptions),j(r,o.xPermittedCrossDomainPolicies),q(r,o.xXSSProtection),t(r)}),L=(t,e)=>h(t,e);s.defineHelmetEventHandler=h,s.helmetEventHandler=L,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})}); | ||
//# sourceMappingURL=nitro-helmet.umd.js.map |
{ | ||
"name": "nitro-helmet", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "observerly's Helemt (HTTP security headers) event handler for the Nitro web server", | ||
@@ -25,9 +25,9 @@ "private": false, | ||
], | ||
"main": "./dist/nitro-helment.umd.js", | ||
"module": "./dist/nitro-helment.es.js", | ||
"main": "./dist/nitro-helmet.umd.js", | ||
"module": "./dist/nitro-helmet.es.js", | ||
"types": "./dist/index.d.ts", | ||
"exports": { | ||
".": { | ||
"import": "./dist/nitro-helment.es.js", | ||
"require": "./dist/nitro-helment.umd.js" | ||
"import": "./dist/nitro-helmet.es.js", | ||
"require": "./dist/nitro-helmet.umd.js" | ||
} | ||
@@ -34,0 +34,0 @@ }, |
@@ -1,2 +0,2 @@ | ||
# Nitro Helmet-esque Security | ||
# nitro Helmet-esque Security Headers | ||
@@ -39,2 +39,14 @@ nitro native Helmet-esque security headers. | ||
...or... | ||
```ts | ||
import { helmetEventHandler } from 'nitro-helmet' | ||
const handler = eventHandler(async event => { | ||
// ... | ||
}) | ||
export default helmetEventHandler(handler) | ||
``` | ||
If you would like to override the default options, you can do so as follows: | ||
@@ -41,0 +53,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
128545
25
281
83