UNPKG

@mangadex-pub/nuxt-security

Version:

๐Ÿ›ก๏ธ Security Module for Nuxt based on HTTP Headers and Middleware

256 lines (249 loc) โ€ข 9.67 kB
import * as _nuxt_schema from '@nuxt/schema'; import { ModuleOptions as ModuleOptions$1 } from 'nuxt-csurf'; import { Options } from 'unplugin-remove/types'; type CrossOriginResourcePolicyValue = 'same-site' | 'same-origin' | 'cross-origin'; type CrossOriginOpenerPolicyValue = 'unsafe-none' | 'same-origin-allow-popups' | 'same-origin'; type CrossOriginEmbedderPolicyValue = 'unsafe-none' | 'require-corp'; type ReferrerPolicyValue = 'no-referrer' | 'no-referrer-when-downgrade' | 'origin' | 'origin-when-cross-origin' | 'same-origin' | 'strict-origin' | 'strict-origin-when-cross-origin' | 'unsafe-url'; type XContentTypeOptionsValue = 'nosniff'; type XDnsPrefetchControlValue = 'on' | 'off'; type XDownloadOptionsValue = 'noopen'; type XFrameOptionsValue = 'DENY' | 'SAMEORIGIN'; type XPermittedCrossDomainPoliciesValue = 'none' | 'master-only' | 'by-content-type' | 'by-ftp-filename' | 'all'; type CSPSourceValue = "'self'" | "'unsafe-eval'" | "'wasm-unsafe-eval'" | "'unsafe-hashes'" | "'unsafe-inline'" | "'none'" | "'strict-dynamic'" | "'report-sample'" | "'nonce=<base64-value>'" | string; type CSPSandboxValue = 'allow-downloads' | 'allow-downloads-without-user-activation' | 'allow-forms' | 'allow-modals' | 'allow-orientation-lock' | 'allow-pointer-lock' | 'allow-popups' | 'allow-popups-to-escape-sandbox' | 'allow-presentation' | 'allow-same-origin' | 'allow-scripts' | 'allow-storage-access-by-user-activation' | 'allow-top-navigation' | 'allow-top-navigation-by-user-activation' | 'allow-top-navigation-to-custom-protocols'; type ContentSecurityPolicyValue = { 'child-src'?: CSPSourceValue[]; 'connect-src'?: CSPSourceValue[]; 'default-src'?: CSPSourceValue[]; 'font-src'?: CSPSourceValue[]; 'frame-src'?: CSPSourceValue[]; 'img-src'?: CSPSourceValue[]; 'manifest-src'?: CSPSourceValue[]; 'media-src'?: CSPSourceValue[]; 'object-src'?: CSPSourceValue[]; 'prefetch-src'?: CSPSourceValue[]; 'script-src'?: CSPSourceValue[]; 'script-src-elem'?: CSPSourceValue[]; 'script-src-attr'?: CSPSourceValue[]; 'style-src'?: CSPSourceValue[]; 'style-src-elem'?: CSPSourceValue[]; 'style-src-attr'?: CSPSourceValue[]; 'worker-src'?: CSPSourceValue[]; 'base-uri'?: CSPSourceValue[]; 'sandbox'?: CSPSandboxValue[]; 'form-action'?: CSPSourceValue[]; 'frame-ancestors'?: ("'self'" | "'none'" | string)[]; 'navigate-to'?: ("'self'" | "'none'" | "'unsafe-allow-redirects'" | string)[]; 'report-uri'?: string[]; 'report-to'?: string[]; 'upgrade-insecure-requests'?: boolean; }; type StrictTransportSecurityValue = { maxAge: number; includeSubdomains?: boolean; preload?: boolean; }; type PermissionsPolicyValue = { 'camera'?: string[]; 'display-capture'?: string[]; 'fullscreen'?: string[]; 'geolocation'?: string[]; 'microphone'?: string[]; /** * ๐Ÿงช Experimental. Expect browser behavior to change in the future. */ 'accelerometer'?: string[]; /** * ๐Ÿงช Experimental. Expect browser behavior to change in the future. */ 'ambient-light-sensor'?: string[]; /** * ๐Ÿงช Experimental. Expect browser behavior to change in the future. */ 'autoplay'?: string[]; /** * ๐Ÿงช Experimental. Expect browser behavior to change in the future. */ 'battery'?: string[]; /** * ๐Ÿงช Experimental. Expect browser behavior to change in the future. */ 'document-domain'?: string[]; /** * ๐Ÿงช Experimental. Expect browser behavior to change in the future. */ 'encrypted-media'?: string[]; /** * ๐Ÿงช Experimental. Expect browser behavior to change in the future. */ 'execution-while-not-rendered'?: string[]; /** * ๐Ÿงช Experimental. Expect browser behavior to change in the future. */ 'execution-while-out-of-viewport'?: string[]; /** * ๐Ÿงช Experimental. Expect browser behavior to change in the future. */ 'gamepad'?: string[]; /** * ๐Ÿงช Experimental. Expect browser behavior to change in the future. */ 'gyroscope'?: string[]; /** * ๐Ÿงช Experimental. Expect browser behavior to change in the future. */ 'hid'?: string[]; /** * ๐Ÿงช Experimental. Expect browser behavior to change in the future. */ 'idle-detection'?: string[]; /** * ๐Ÿงช Experimental. Expect browser behavior to change in the future. */ 'local-fonts'?: string[]; /** * ๐Ÿงช Experimental. Expect browser behavior to change in the future. */ 'magnetometer'?: string[]; /** * ๐Ÿงช Experimental. Expect browser behavior to change in the future. */ 'midi'?: string[]; /** * ๐Ÿงช Experimental. Expect browser behavior to change in the future. */ 'payment'?: string[]; /** * ๐Ÿงช Experimental. Expect browser behavior to change in the future. */ 'picture-in-picture'?: string[]; /** * ๐Ÿงช Experimental. Expect browser behavior to change in the future. */ 'publickey-credentials-get'?: string[]; /** * ๐Ÿงช Experimental. Expect browser behavior to change in the future. */ 'screen-wake-lock'?: string[]; /** * ๐Ÿงช Experimental. Expect browser behavior to change in the future. */ 'serial'?: string[]; /** * ๐Ÿงช Experimental. Expect browser behavior to change in the future. */ 'speaker-selection'?: string[]; /** * ๐Ÿงช Experimental. Expect browser behavior to change in the future. */ 'usb'?: string[]; 'web-share'?: string[]; /** * ๐Ÿงช Experimental. Expect browser behavior to change in the future. */ 'xr-spatial-tracking'?: string[]; }; type SecurityHeaders = { crossOriginResourcePolicy?: CrossOriginResourcePolicyValue | false; crossOriginOpenerPolicy?: CrossOriginOpenerPolicyValue | false; crossOriginEmbedderPolicy?: CrossOriginEmbedderPolicyValue | false; contentSecurityPolicy?: ContentSecurityPolicyValue | string | false; originAgentCluster?: '?1' | false; referrerPolicy?: ReferrerPolicyValue | false; strictTransportSecurity?: StrictTransportSecurityValue | string | false; xContentTypeOptions?: XContentTypeOptionsValue | false; xDNSPrefetchControl?: XDnsPrefetchControlValue | false; xDownloadOptions?: XDownloadOptionsValue | false; xFrameOptions?: XFrameOptionsValue | false; xPermittedCrossDomainPolicies?: XPermittedCrossDomainPoliciesValue | false; xXSSProtection?: string | false; permissionsPolicy?: PermissionsPolicyValue | string | false; }; type RequestSizeLimiter = { maxRequestSizeInBytes: number; maxUploadFileRequestInBytes: number; throwError?: boolean; }; type RateLimiter = { tokensPerInterval: number; interval: string | number; driver?: { name: string; options?: Record<string, any>; }; headers?: boolean; throwError?: boolean; }; type XssValidator = { whiteList: Record<string, any>; stripIgnoreTag: boolean; stripIgnoreTagBody: boolean; css: Record<string, any> | boolean; throwError?: boolean; } | {}; type BasicAuth = { exclude?: string[]; include?: string[]; name: string; pass: string; enabled?: boolean; message: string; }; type HTTPMethod = 'GET' | 'POST' | 'DELETE' | 'PATCH' | 'POST' | string; type CorsOptions = { origin?: '*' | 'null' | string | (string | RegExp)[] | ((origin: string) => boolean); methods?: '*' | HTTPMethod[]; allowHeaders?: '*' | string[]; exposeHeaders?: '*' | string[]; credentials?: boolean; maxAge?: string | false; preflight?: { statusCode?: number; }; }; type AllowedHTTPMethods = { methods: HTTPMethod[] | '*'; throwError?: boolean; }; type Ssg = { hashScripts?: boolean; }; interface ModuleOptions { headers: SecurityHeaders | false; requestSizeLimiter: RequestSizeLimiter | false; rateLimiter: RateLimiter | false; xssValidator: XssValidator | false; corsHandler: CorsOptions | false; allowedMethodsRestricter: AllowedHTTPMethods | false; hidePoweredBy: boolean; basicAuth: BasicAuth | false; enabled: boolean; csrf: ModuleOptions$1 | false; nonce: boolean; removeLoggers?: Options | false; ssg?: Ssg; } interface NuxtSecurityRouteRules { requestSizeLimiter?: RequestSizeLimiter | false; rateLimiter?: RateLimiter | false; xssValidator?: XssValidator | false; corsHandler?: CorsOptions | false; allowedMethodsRestricter?: AllowedHTTPMethods | false; nonce?: boolean; } declare module '@nuxt/schema' { interface NuxtOptions { security: ModuleOptions; } } declare module 'nitropack' { interface NitroRouteRules { security: NuxtSecurityRouteRules; } interface NitroRouteConfig { security: NuxtSecurityRouteRules; } } declare const _default: _nuxt_schema.NuxtModule<ModuleOptions>; export { type AllowedHTTPMethods, type BasicAuth, type CSPSandboxValue, type CSPSourceValue, type ContentSecurityPolicyValue, type CorsOptions, type CrossOriginEmbedderPolicyValue, type CrossOriginOpenerPolicyValue, type CrossOriginResourcePolicyValue, type HTTPMethod, type ModuleOptions, type NuxtSecurityRouteRules, type PermissionsPolicyValue, type RateLimiter, type ReferrerPolicyValue, type RequestSizeLimiter, type SecurityHeaders, type Ssg, type StrictTransportSecurityValue, type XContentTypeOptionsValue, type XDnsPrefetchControlValue, type XDownloadOptionsValue, type XFrameOptionsValue, type XPermittedCrossDomainPoliciesValue, type XssValidator, _default as default };