nuxt-security-module 4.3.1 → 4.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +0 -2
- package/dist/index.js +1 -2
- package/dist/models/AllowedMethodsRestricterOptions.d.ts +1 -3
- package/dist/models/BasicAuthOptions.d.ts +1 -3
- package/dist/models/ContentSecurityPolicy.d.ts +1 -3
- package/dist/models/CorsHandlerOptions.d.ts +1 -3
- package/dist/models/CrossOriginEmbedderPolicy.d.ts +1 -3
- package/dist/models/CrossOriginEmbedderPolicy.js +1 -2
- package/dist/models/CsrfOptions.d.ts +1 -3
- package/dist/models/ModuleOptions.d.ts +1 -3
- package/dist/models/PermissionsPolicy.d.ts +1 -3
- package/dist/models/RateLimitWindow.d.ts +1 -3
- package/dist/models/RateLimiterOptions.d.ts +1 -3
- package/dist/models/RateLimiterStore.d.ts +1 -3
- package/dist/models/RequestSizeLimiterOptions.d.ts +1 -3
- package/dist/models/SecurityHeaders.d.ts +1 -3
- package/dist/models/SecurityRouteRules.d.ts +1 -3
- package/dist/models/SecurityRules.d.ts +1 -3
- package/dist/models/SsgOptions.d.ts +1 -3
- package/dist/models/StrictTransportSecurity.d.ts +1 -3
- package/dist/models/XFrameOptions.d.ts +1 -3
- package/dist/models/XFrameOptions.js +1 -2
- package/dist/runtime/constants.d.ts +1 -3
- package/dist/runtime/constants.js +1 -2
- package/dist/runtime/nitro/plugins/hidePoweredBy.d.ts +0 -2
- package/dist/runtime/nitro/plugins/hidePoweredBy.js +1 -2
- package/dist/runtime/nitro/plugins/nonce.d.ts +0 -2
- package/dist/runtime/nitro/plugins/nonce.js +1 -2
- package/dist/runtime/nitro/plugins/routeRules.d.ts +1 -3
- package/dist/runtime/nitro/plugins/routeRules.js +1 -2
- package/dist/runtime/nitro/plugins/securityHeaders.d.ts +0 -2
- package/dist/runtime/nitro/plugins/securityHeaders.js +1 -2
- package/dist/runtime/nitro/plugins/ssgHashes.d.ts +0 -2
- package/dist/runtime/nitro/plugins/ssgHashes.js +1 -2
- package/dist/runtime/nitro/plugins/subresourceIntegrity.d.ts +1 -3
- package/dist/runtime/nitro/plugins/subresourceIntegrity.js +1 -2
- package/dist/runtime/server/middleware/allowedMethodsRestricter.d.ts +0 -2
- package/dist/runtime/server/middleware/allowedMethodsRestricter.js +1 -2
- package/dist/runtime/server/middleware/basicAuth.d.ts +0 -2
- package/dist/runtime/server/middleware/basicAuth.js +1 -2
- package/dist/runtime/server/middleware/corsHandler.d.ts +0 -2
- package/dist/runtime/server/middleware/corsHandler.js +1 -2
- package/dist/runtime/server/middleware/csrf.d.ts +0 -2
- package/dist/runtime/server/middleware/csrf.js +1 -2
- package/dist/runtime/server/middleware/rateLimiter.d.ts +0 -2
- package/dist/runtime/server/middleware/rateLimiter.js +1 -2
- package/dist/runtime/server/middleware/requestSizeLimiter.d.ts +0 -2
- package/dist/runtime/server/middleware/requestSizeLimiter.js +1 -2
- package/dist/runtime/services/checkIsBasicAuthorized.d.ts +1 -3
- package/dist/runtime/services/checkIsBasicAuthorized.js +1 -2
- package/dist/runtime/services/checkIsChallenged.d.ts +1 -3
- package/dist/runtime/services/checkIsChallenged.js +1 -2
- package/dist/runtime/services/checkIsCsrfTokenValid.d.ts +1 -3
- package/dist/runtime/services/checkIsCsrfTokenValid.js +1 -2
- package/dist/runtime/services/checkIsEqualInConstantTime.d.ts +1 -3
- package/dist/runtime/services/checkIsEqualInConstantTime.js +1 -2
- package/dist/runtime/services/checkIsMethodAllowed.d.ts +1 -3
- package/dist/runtime/services/checkIsMethodAllowed.js +1 -2
- package/dist/runtime/services/checkIsRecord.d.ts +1 -3
- package/dist/runtime/services/checkIsRecord.js +1 -2
- package/dist/runtime/services/checkIsRequestTooLarge.d.ts +1 -3
- package/dist/runtime/services/checkIsRequestTooLarge.js +1 -2
- package/dist/runtime/services/collectSsgHashes.d.ts +1 -3
- package/dist/runtime/services/collectSsgHashes.js +1 -2
- package/dist/runtime/services/createInMemoryRateLimiterStore.d.ts +1 -3
- package/dist/runtime/services/createInMemoryRateLimiterStore.js +1 -2
- package/dist/runtime/services/generateHash.d.ts +1 -3
- package/dist/runtime/services/generateHash.js +1 -2
- package/dist/runtime/services/generateNonce.d.ts +1 -3
- package/dist/runtime/services/generateNonce.js +1 -2
- package/dist/runtime/services/generateRandomToken.d.ts +1 -3
- package/dist/runtime/services/generateRandomToken.js +1 -2
- package/dist/runtime/services/getBasicAuthCredentials.d.ts +1 -3
- package/dist/runtime/services/getBasicAuthCredentials.js +1 -2
- package/dist/runtime/services/getBasicAuthOptions.d.ts +1 -3
- package/dist/runtime/services/getBasicAuthOptions.js +1 -2
- package/dist/runtime/services/getRetryAfterSeconds.d.ts +1 -3
- package/dist/runtime/services/getRetryAfterSeconds.js +1 -2
- package/dist/runtime/services/getSecurityRules.d.ts +1 -3
- package/dist/runtime/services/getSecurityRules.js +1 -2
- package/dist/runtime/services/getSecurityState.d.ts +1 -3
- package/dist/runtime/services/getSecurityState.js +1 -2
- package/dist/runtime/services/injectNonce.d.ts +1 -3
- package/dist/runtime/services/injectNonce.js +1 -2
- package/dist/runtime/services/injectSubresourceIntegrity.d.ts +1 -3
- package/dist/runtime/services/injectSubresourceIntegrity.js +1 -2
- package/dist/runtime/services/insertContentSecurityPolicyMeta.d.ts +1 -3
- package/dist/runtime/services/insertContentSecurityPolicyMeta.js +1 -2
- package/dist/runtime/services/mergeSecurityRules.d.ts +1 -3
- package/dist/runtime/services/mergeSecurityRules.js +1 -2
- package/dist/runtime/services/readHtmlTagAttribute.d.ts +1 -3
- package/dist/runtime/services/readHtmlTagAttribute.js +1 -2
- package/dist/runtime/services/rewriteHtmlTags.d.ts +1 -3
- package/dist/runtime/services/rewriteHtmlTags.js +1 -2
- package/dist/runtime/services/securityRouteMatcher.d.ts +1 -3
- package/dist/runtime/services/securityRouteMatcher.js +1 -2
- package/dist/runtime/services/serializeBasicAuthChallenge.d.ts +1 -3
- package/dist/runtime/services/serializeBasicAuthChallenge.js +1 -2
- package/dist/runtime/services/serializeContentSecurityPolicy.d.ts +1 -3
- package/dist/runtime/services/serializeContentSecurityPolicy.js +1 -2
- package/dist/runtime/services/serializePermissionsPolicy.d.ts +1 -3
- package/dist/runtime/services/serializePermissionsPolicy.js +1 -2
- package/dist/runtime/services/serializeSecurityHeaders.d.ts +1 -3
- package/dist/runtime/services/serializeSecurityHeaders.js +1 -2
- package/dist/runtime/services/serializeStrictTransportSecurity.d.ts +1 -3
- package/dist/runtime/services/serializeStrictTransportSecurity.js +1 -2
- package/dist/runtime/services/stripHtmlTagAttribute.d.ts +1 -3
- package/dist/runtime/services/stripHtmlTagAttribute.js +1 -2
- package/dist/runtime/services/updateContentSecurityPolicy.d.ts +1 -3
- package/dist/runtime/services/updateContentSecurityPolicy.js +1 -2
- package/dist/schemas/allowedMethodsRestricterOptionsSchema.js +1 -2
- package/dist/schemas/basicAuthOptionsSchema.js +1 -2
- package/dist/schemas/contentSecurityPolicySchema.js +1 -2
- package/dist/schemas/corsHandlerOptionsSchema.js +1 -2
- package/dist/schemas/csrfOptionsSchema.js +1 -2
- package/dist/schemas/moduleOptionsSchema.js +1 -2
- package/dist/schemas/permissionsPolicySchema.js +1 -2
- package/dist/schemas/rateLimiterOptionsSchema.js +1 -2
- package/dist/schemas/requestSizeLimiterOptionsSchema.js +1 -2
- package/dist/schemas/securityHeadersSchema.js +1 -2
- package/dist/schemas/ssgOptionsSchema.js +1 -2
- package/dist/schemas/strictTransportSecurityOptionsSchema.js +1 -2
- package/dist/services/computeSubresourceIntegrityHashes.js +1 -2
- package/dist/services/formatZodIssues.js +1 -2
- package/dist/services/getDefaultModuleOptions.js +1 -2
- package/dist/services/getDefaultSecurityHeaders.js +1 -2
- package/dist/services/getPluginTemplate.js +1 -2
- package/dist/services/getRemoveLoggersViteConfig.js +1 -2
- package/dist/services/getRouteRulesTemplate.js +1 -2
- package/dist/services/getRouteSecurityRules.js +1 -2
- package/dist/services/getStaticResourceHeaders.js +1 -2
- package/dist/services/getTypeTemplate.js +1 -2
- package/dist/services/mergeModuleOptions.js +1 -2
- package/dist/services/parseModuleOptions.js +1 -2
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { ModuleOptions } from "./models/ModuleOptions.js";
|
|
2
2
|
import { SecurityRouteRules } from "./models/SecurityRouteRules.js";
|
|
3
3
|
import { NuxtModule } from "@nuxt/schema";
|
|
4
|
-
//#region src/module.d.ts
|
|
5
4
|
declare module "@nuxt/schema" {
|
|
6
5
|
interface NuxtConfig {
|
|
7
6
|
security?: Partial<ModuleOptions>;
|
|
@@ -13,5 +12,4 @@ declare module "h3/rules" {
|
|
|
13
12
|
}
|
|
14
13
|
}
|
|
15
14
|
declare const securityModule: NuxtModule<Partial<ModuleOptions>>;
|
|
16
|
-
//#endregion
|
|
17
15
|
export { type ModuleOptions, securityModule as default };
|
package/dist/index.js
CHANGED
|
@@ -12,7 +12,7 @@ import { getTypeTemplate } from "./services/getTypeTemplate.js";
|
|
|
12
12
|
import { parseModuleOptions } from "./services/parseModuleOptions.js";
|
|
13
13
|
import { defu } from "defu";
|
|
14
14
|
import { addNitroPlugin, addServerHandler, addServerTemplate, addTypeTemplate, createResolver, defineNuxtModule } from "@nuxt/kit";
|
|
15
|
-
|
|
15
|
+
// src/module.ts
|
|
16
16
|
const ROUTE_RULES_TEMPLATE_FILENAME = `#${MODULE_NAME}/route-rules.mjs`;
|
|
17
17
|
const SRI_HASHES_TEMPLATE_FILENAME = `#${MODULE_NAME}/sri-hashes.mjs`;
|
|
18
18
|
const ROUTE_RULES_PLUGIN_FILENAME = `#${MODULE_NAME}/route-rules-plugin.mjs`;
|
|
@@ -101,5 +101,4 @@ const securityModule = defineNuxtModule({
|
|
|
101
101
|
});
|
|
102
102
|
}
|
|
103
103
|
});
|
|
104
|
-
//#endregion
|
|
105
104
|
export { securityModule as default };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/models/CorsHandlerOptions.d.ts
|
|
2
1
|
export interface CorsHandlerOptions {
|
|
3
2
|
allowHeaders?: string[];
|
|
4
3
|
credentials?: boolean;
|
|
@@ -9,5 +8,4 @@ export interface CorsHandlerOptions {
|
|
|
9
8
|
preflight?: {
|
|
10
9
|
statusCode: number;
|
|
11
10
|
};
|
|
12
|
-
}
|
|
13
|
-
//#endregion
|
|
11
|
+
}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
//#region src/models/CrossOriginEmbedderPolicy.d.ts
|
|
2
1
|
export declare const CrossOriginEmbedderPolicy: {
|
|
3
2
|
readonly Credentialless: "credentialless";
|
|
4
3
|
readonly RequireCorp: "require-corp";
|
|
5
4
|
readonly UnsafeNone: "unsafe-none";
|
|
6
5
|
};
|
|
7
|
-
export type CrossOriginEmbedderPolicy = (typeof CrossOriginEmbedderPolicy)[keyof typeof CrossOriginEmbedderPolicy];
|
|
8
|
-
//#endregion
|
|
6
|
+
export type CrossOriginEmbedderPolicy = (typeof CrossOriginEmbedderPolicy)[keyof typeof CrossOriginEmbedderPolicy];
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
// src/models/CrossOriginEmbedderPolicy.ts
|
|
2
2
|
const CrossOriginEmbedderPolicy = {
|
|
3
3
|
Credentialless: "credentialless",
|
|
4
4
|
RequireCorp: "require-corp",
|
|
5
5
|
UnsafeNone: "unsafe-none"
|
|
6
6
|
};
|
|
7
|
-
//#endregion
|
|
8
7
|
export { CrossOriginEmbedderPolicy };
|
|
@@ -6,7 +6,6 @@ import { RateLimiterOptions } from "./RateLimiterOptions.js";
|
|
|
6
6
|
import { RequestSizeLimiterOptions } from "./RequestSizeLimiterOptions.js";
|
|
7
7
|
import { SecurityHeaders } from "./SecurityHeaders.js";
|
|
8
8
|
import { SsgOptions } from "./SsgOptions.js";
|
|
9
|
-
//#region src/models/ModuleOptions.d.ts
|
|
10
9
|
export interface ModuleOptions {
|
|
11
10
|
allowedMethodsRestricter: AllowedMethodsRestricterOptions | false;
|
|
12
11
|
basicAuth: BasicAuthOptions | false;
|
|
@@ -23,5 +22,4 @@ export interface ModuleOptions {
|
|
|
23
22
|
sri: boolean;
|
|
24
23
|
ssg: false | SsgOptions;
|
|
25
24
|
strict: boolean;
|
|
26
|
-
}
|
|
27
|
-
//#endregion
|
|
25
|
+
}
|
|
@@ -3,7 +3,6 @@ import { CrossOriginEmbedderPolicy } from "./CrossOriginEmbedderPolicy.js";
|
|
|
3
3
|
import { PermissionsPolicy } from "./PermissionsPolicy.js";
|
|
4
4
|
import { StrictTransportSecurity } from "./StrictTransportSecurity.js";
|
|
5
5
|
import { XFrameOptions } from "./XFrameOptions.js";
|
|
6
|
-
//#region src/models/SecurityHeaders.d.ts
|
|
7
6
|
export interface SecurityHeaders {
|
|
8
7
|
contentSecurityPolicy?: ContentSecurityPolicy | false;
|
|
9
8
|
crossOriginEmbedderPolicy?: CrossOriginEmbedderPolicy | false;
|
|
@@ -18,5 +17,4 @@ export interface SecurityHeaders {
|
|
|
18
17
|
xDownloadOptions?: false | string;
|
|
19
18
|
xFrameOptions?: false | XFrameOptions;
|
|
20
19
|
xPermittedCrossDomainPolicies?: false | string;
|
|
21
|
-
}
|
|
22
|
-
//#endregion
|
|
20
|
+
}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
//#region src/models/XFrameOptions.d.ts
|
|
2
1
|
export declare const XFrameOptions: {
|
|
3
2
|
readonly Deny: "DENY";
|
|
4
3
|
readonly SameOrigin: "SAMEORIGIN";
|
|
5
4
|
};
|
|
6
|
-
export type XFrameOptions = (typeof XFrameOptions)[keyof typeof XFrameOptions];
|
|
7
|
-
//#endregion
|
|
5
|
+
export type XFrameOptions = (typeof XFrameOptions)[keyof typeof XFrameOptions];
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { SecurityHeaders } from "../models/SecurityHeaders.js";
|
|
2
|
-
//#region src/runtime/constants.d.ts
|
|
3
2
|
export declare const MODULE_NAME = "nuxt-security-module";
|
|
4
3
|
export declare const ROUTE_RULES_HOOK: `${typeof MODULE_NAME}:routeRules`;
|
|
5
4
|
export declare const SECURITY_HEADER_NAMES: Readonly<Record<keyof SecurityHeaders, string>>;
|
|
@@ -20,5 +19,4 @@ export declare const NONCE_TAG_NAMES: readonly string[];
|
|
|
20
19
|
export declare const FILE_UPLOAD_CONTENT_TYPE = "multipart/form-data";
|
|
21
20
|
export declare const SIZE_LIMITED_METHODS: readonly string[];
|
|
22
21
|
export declare const DEFAULT_BASIC_AUTH_REALM = "Please enter username and password";
|
|
23
|
-
export declare const BASIC_AUTHORIZATION_SCHEME = "Basic";
|
|
24
|
-
//#endregion
|
|
22
|
+
export declare const BASIC_AUTHORIZATION_SCHEME = "Basic";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/runtime/constants.ts
|
|
2
2
|
const MODULE_NAME = "nuxt-security-module";
|
|
3
3
|
const ROUTE_RULES_HOOK = `${MODULE_NAME}:routeRules`;
|
|
4
4
|
const SECURITY_HEADER_NAMES = {
|
|
@@ -48,5 +48,4 @@ const SIZE_LIMITED_METHODS = [
|
|
|
48
48
|
];
|
|
49
49
|
const DEFAULT_BASIC_AUTH_REALM = "Please enter username and password";
|
|
50
50
|
const BASIC_AUTHORIZATION_SCHEME = "Basic";
|
|
51
|
-
//#endregion
|
|
52
51
|
export { BASIC_AUTHORIZATION_SCHEME, CONTENT_SECURITY_POLICY_REPORT_ONLY_HEADER_NAME, CSP_HASH_ALGORITHM, CSRF_TOKEN_BYTE_LENGTH, CSRF_UNSAFE_METHODS, DEFAULT_BASIC_AUTH_REALM, FILE_UPLOAD_CONTENT_TYPE, HTML_ATTRIBUTE_REGEX, HTML_TAG_REGEX, MAX_RATE_LIMIT_ENTRIES, MODULE_NAME, NONCE_BYTE_LENGTH, NONCE_PLACEHOLDER, NONCE_TAG_NAMES, PRERENDERED_HEADERS_DIRECTORY_NAME, PRERENDERED_HEADERS_FILE_NAME, ROUTE_RULES_HOOK, SECURITY_HEADER_NAMES, SIZE_LIMITED_METHODS, SRI_HASH_ALGORITHM, UNKNOWN_CLIENT_KEY };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getSecurityRules } from "../../services/getSecurityRules.js";
|
|
2
2
|
import { definePlugin } from "nitro";
|
|
3
3
|
import { isEvent } from "nitro/h3";
|
|
4
|
-
|
|
4
|
+
// src/runtime/nitro/plugins/hidePoweredBy.ts
|
|
5
5
|
const hidePoweredBy = definePlugin((nitroApp) => {
|
|
6
6
|
nitroApp.hooks.hook("response", (_response, event) => {
|
|
7
7
|
if (!isEvent(event)) return;
|
|
@@ -9,5 +9,4 @@ const hidePoweredBy = definePlugin((nitroApp) => {
|
|
|
9
9
|
if (rules?.enabled && rules.hidePoweredBy) event.res.headers.delete("x-powered-by");
|
|
10
10
|
});
|
|
11
11
|
});
|
|
12
|
-
//#endregion
|
|
13
12
|
export { hidePoweredBy as default };
|
|
@@ -3,7 +3,7 @@ import { getSecurityRules } from "../../services/getSecurityRules.js";
|
|
|
3
3
|
import { getSecurityState } from "../../services/getSecurityState.js";
|
|
4
4
|
import { injectNonce } from "../../services/injectNonce.js";
|
|
5
5
|
import { definePlugin } from "nitro";
|
|
6
|
-
|
|
6
|
+
// src/runtime/nitro/plugins/nonce.ts
|
|
7
7
|
const HTML_SECTIONS = [
|
|
8
8
|
"body",
|
|
9
9
|
"bodyAppend",
|
|
@@ -23,5 +23,4 @@ const noncePlugin = definePlugin((nitroApp) => {
|
|
|
23
23
|
for (const section of HTML_SECTIONS) html[section] = html[section].map((element) => injectNonce(element, nonce));
|
|
24
24
|
});
|
|
25
25
|
});
|
|
26
|
-
//#endregion
|
|
27
26
|
export { noncePlugin as default };
|
|
@@ -1,5 +1,3 @@
|
|
|
1
1
|
import { SecurityRules } from "../../../models/SecurityRules.js";
|
|
2
2
|
import { NitroAppPlugin } from "nitro/types";
|
|
3
|
-
|
|
4
|
-
export declare const createRouteRulesPlugin: (routeRules: Record<string, SecurityRules>) => NitroAppPlugin;
|
|
5
|
-
//#endregion
|
|
3
|
+
export declare const createRouteRulesPlugin: (routeRules: Record<string, SecurityRules>) => NitroAppPlugin;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ROUTE_RULES_HOOK } from "../../constants.js";
|
|
2
2
|
import { setSecurityRouteMatcher } from "../../services/securityRouteMatcher.js";
|
|
3
3
|
import { definePlugin } from "nitro";
|
|
4
|
-
|
|
4
|
+
// src/runtime/nitro/plugins/routeRules.ts
|
|
5
5
|
const createRouteRulesPlugin = (routeRules) => definePlugin((nitroApp) => {
|
|
6
6
|
let routesResolved;
|
|
7
7
|
nitroApp.hooks.hook("request", () => {
|
|
@@ -13,5 +13,4 @@ const createRouteRulesPlugin = (routeRules) => definePlugin((nitroApp) => {
|
|
|
13
13
|
return routesResolved;
|
|
14
14
|
});
|
|
15
15
|
});
|
|
16
|
-
//#endregion
|
|
17
16
|
export { createRouteRulesPlugin };
|
|
@@ -4,7 +4,7 @@ import { getSecurityState } from "../../services/getSecurityState.js";
|
|
|
4
4
|
import { serializeSecurityHeaders } from "../../services/serializeSecurityHeaders.js";
|
|
5
5
|
import { updateContentSecurityPolicy } from "../../services/updateContentSecurityPolicy.js";
|
|
6
6
|
import { definePlugin } from "nitro";
|
|
7
|
-
|
|
7
|
+
// src/runtime/nitro/plugins/securityHeaders.ts
|
|
8
8
|
const CONTENT_SECURITY_POLICY_HEADER_NAME = SECURITY_HEADER_NAMES.contentSecurityPolicy;
|
|
9
9
|
const securityHeaders = definePlugin((nitroApp) => {
|
|
10
10
|
nitroApp.hooks.hook("render:route", (_context, { event }) => {
|
|
@@ -21,5 +21,4 @@ const securityHeaders = definePlugin((nitroApp) => {
|
|
|
21
21
|
}
|
|
22
22
|
});
|
|
23
23
|
});
|
|
24
|
-
//#endregion
|
|
25
24
|
export { securityHeaders as default };
|
|
@@ -4,7 +4,7 @@ import { getSecurityState } from "../../services/getSecurityState.js";
|
|
|
4
4
|
import { insertContentSecurityPolicyMeta } from "../../services/insertContentSecurityPolicyMeta.js";
|
|
5
5
|
import { updateContentSecurityPolicy } from "../../services/updateContentSecurityPolicy.js";
|
|
6
6
|
import { definePlugin } from "nitro";
|
|
7
|
-
|
|
7
|
+
// src/runtime/nitro/plugins/ssgHashes.ts
|
|
8
8
|
const HTML_SECTIONS = [
|
|
9
9
|
"head",
|
|
10
10
|
"bodyPrepend",
|
|
@@ -23,5 +23,4 @@ const ssgHashes = definePlugin((nitroApp) => {
|
|
|
23
23
|
html.head = [insertContentSecurityPolicyMeta(html.head.join(""), policy)];
|
|
24
24
|
});
|
|
25
25
|
});
|
|
26
|
-
//#endregion
|
|
27
26
|
export { ssgHashes as default };
|
|
@@ -1,4 +1,2 @@
|
|
|
1
1
|
import { NitroAppPlugin } from "nitro/types";
|
|
2
|
-
|
|
3
|
-
export declare const createSubresourceIntegrityPlugin: (sriHashes: Record<string, string>) => NitroAppPlugin;
|
|
4
|
-
//#endregion
|
|
2
|
+
export declare const createSubresourceIntegrityPlugin: (sriHashes: Record<string, string>) => NitroAppPlugin;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getSecurityRules } from "../../services/getSecurityRules.js";
|
|
2
2
|
import { injectSubresourceIntegrity } from "../../services/injectSubresourceIntegrity.js";
|
|
3
3
|
import { definePlugin } from "nitro";
|
|
4
|
-
|
|
4
|
+
// src/runtime/nitro/plugins/subresourceIntegrity.ts
|
|
5
5
|
const HTML_SECTIONS = [
|
|
6
6
|
"body",
|
|
7
7
|
"bodyAppend",
|
|
@@ -15,5 +15,4 @@ const createSubresourceIntegrityPlugin = (sriHashes) => definePlugin((nitroApp)
|
|
|
15
15
|
for (const section of HTML_SECTIONS) html[section] = html[section].map((element) => injectSubresourceIntegrity(element, sriHashes));
|
|
16
16
|
});
|
|
17
17
|
});
|
|
18
|
-
//#endregion
|
|
19
18
|
export { createSubresourceIntegrityPlugin };
|
|
@@ -2,7 +2,7 @@ import { checkIsMethodAllowed } from "../../services/checkIsMethodAllowed.js";
|
|
|
2
2
|
import { getSecurityRules } from "../../services/getSecurityRules.js";
|
|
3
3
|
import { defineMiddleware } from "nitro";
|
|
4
4
|
import { HTTPError } from "nitro/h3";
|
|
5
|
-
|
|
5
|
+
// src/runtime/server/middleware/allowedMethodsRestricter.ts
|
|
6
6
|
const allowedMethodsRestricter = defineMiddleware((event) => {
|
|
7
7
|
const rules = getSecurityRules(event);
|
|
8
8
|
if (!rules?.enabled || !rules.allowedMethodsRestricter) return;
|
|
@@ -11,5 +11,4 @@ const allowedMethodsRestricter = defineMiddleware((event) => {
|
|
|
11
11
|
statusText: "Method not allowed"
|
|
12
12
|
});
|
|
13
13
|
});
|
|
14
|
-
//#endregion
|
|
15
14
|
export { allowedMethodsRestricter as default };
|
|
@@ -6,7 +6,7 @@ import { serializeBasicAuthChallenge } from "../../services/serializeBasicAuthCh
|
|
|
6
6
|
import { defineMiddleware } from "nitro";
|
|
7
7
|
import { HTTPError } from "nitro/h3";
|
|
8
8
|
import { useRuntimeConfig } from "nuxt/server";
|
|
9
|
-
|
|
9
|
+
// src/runtime/server/middleware/basicAuth.ts
|
|
10
10
|
const basicAuthMiddleware = defineMiddleware((event) => {
|
|
11
11
|
const basicAuth = getBasicAuthOptions(useRuntimeConfig().private);
|
|
12
12
|
if (!basicAuth) return;
|
|
@@ -19,5 +19,4 @@ const basicAuthMiddleware = defineMiddleware((event) => {
|
|
|
19
19
|
statusText: "Access denied"
|
|
20
20
|
});
|
|
21
21
|
});
|
|
22
|
-
//#endregion
|
|
23
22
|
export { basicAuthMiddleware as default };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getSecurityRules } from "../../services/getSecurityRules.js";
|
|
2
2
|
import { defineMiddleware } from "nitro";
|
|
3
3
|
import { handleCors } from "nitro/h3";
|
|
4
|
-
|
|
4
|
+
// src/runtime/server/middleware/corsHandler.ts
|
|
5
5
|
const corsHandler = defineMiddleware((event) => {
|
|
6
6
|
const rules = getSecurityRules(event);
|
|
7
7
|
if (!rules?.enabled || !rules.corsHandler) return;
|
|
@@ -16,5 +16,4 @@ const corsHandler = defineMiddleware((event) => {
|
|
|
16
16
|
preflight
|
|
17
17
|
});
|
|
18
18
|
});
|
|
19
|
-
//#endregion
|
|
20
19
|
export { corsHandler as default };
|
|
@@ -4,7 +4,7 @@ import { generateRandomToken } from "../../services/generateRandomToken.js";
|
|
|
4
4
|
import { getSecurityRules } from "../../services/getSecurityRules.js";
|
|
5
5
|
import { defineMiddleware } from "nitro";
|
|
6
6
|
import { HTTPError, getCookie, setCookie } from "nitro/h3";
|
|
7
|
-
|
|
7
|
+
// src/runtime/server/middleware/csrf.ts
|
|
8
8
|
const csrf = defineMiddleware((event) => {
|
|
9
9
|
const rules = getSecurityRules(event);
|
|
10
10
|
if (!rules?.enabled || !rules.csrf) return;
|
|
@@ -24,5 +24,4 @@ const csrf = defineMiddleware((event) => {
|
|
|
24
24
|
statusText: "Forbidden"
|
|
25
25
|
});
|
|
26
26
|
});
|
|
27
|
-
//#endregion
|
|
28
27
|
export { csrf as default };
|
|
@@ -4,7 +4,7 @@ import { getRetryAfterSeconds } from "../../services/getRetryAfterSeconds.js";
|
|
|
4
4
|
import { getSecurityRules } from "../../services/getSecurityRules.js";
|
|
5
5
|
import { defineMiddleware } from "nitro";
|
|
6
6
|
import { HTTPError, getRequestIP } from "nitro/h3";
|
|
7
|
-
|
|
7
|
+
// src/runtime/server/middleware/rateLimiter.ts
|
|
8
8
|
const rateLimiterStore = createInMemoryRateLimiterStore(MAX_RATE_LIMIT_ENTRIES);
|
|
9
9
|
const rateLimiter = defineMiddleware(async (event) => {
|
|
10
10
|
const rules = getSecurityRules(event);
|
|
@@ -18,5 +18,4 @@ const rateLimiter = defineMiddleware(async (event) => {
|
|
|
18
18
|
statusText: "Too Many Requests"
|
|
19
19
|
});
|
|
20
20
|
});
|
|
21
|
-
//#endregion
|
|
22
21
|
export { rateLimiter as default };
|
|
@@ -2,7 +2,7 @@ import { checkIsRequestTooLarge } from "../../services/checkIsRequestTooLarge.js
|
|
|
2
2
|
import { getSecurityRules } from "../../services/getSecurityRules.js";
|
|
3
3
|
import { defineMiddleware } from "nitro";
|
|
4
4
|
import { HTTPError } from "nitro/h3";
|
|
5
|
-
|
|
5
|
+
// src/runtime/server/middleware/requestSizeLimiter.ts
|
|
6
6
|
const requestSizeLimiter = defineMiddleware((event) => {
|
|
7
7
|
const rules = getSecurityRules(event);
|
|
8
8
|
if (!rules?.enabled || !rules.requestSizeLimiter) return;
|
|
@@ -13,5 +13,4 @@ const requestSizeLimiter = defineMiddleware((event) => {
|
|
|
13
13
|
statusText: "Payload Too Large"
|
|
14
14
|
});
|
|
15
15
|
});
|
|
16
|
-
//#endregion
|
|
17
16
|
export { requestSizeLimiter as default };
|
|
@@ -1,4 +1,2 @@
|
|
|
1
1
|
import { BasicAuthOptions } from "../../models/BasicAuthOptions.js";
|
|
2
|
-
|
|
3
|
-
export declare const checkIsBasicAuthorized: (authorization: null | string, { name, pass }: BasicAuthOptions) => boolean;
|
|
4
|
-
//#endregion
|
|
2
|
+
export declare const checkIsBasicAuthorized: (authorization: null | string, { name, pass }: BasicAuthOptions) => boolean;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { checkIsEqualInConstantTime } from "./checkIsEqualInConstantTime.js";
|
|
2
2
|
import { getBasicAuthCredentials } from "./getBasicAuthCredentials.js";
|
|
3
|
-
|
|
3
|
+
// src/runtime/services/checkIsBasicAuthorized.ts
|
|
4
4
|
const checkIsBasicAuthorized = (authorization, { name, pass }) => {
|
|
5
5
|
const credentials = getBasicAuthCredentials(authorization);
|
|
6
6
|
if (!credentials) return false;
|
|
@@ -8,5 +8,4 @@ const checkIsBasicAuthorized = (authorization, { name, pass }) => {
|
|
|
8
8
|
const isPassEqual = checkIsEqualInConstantTime(credentials.pass, pass);
|
|
9
9
|
return isNameEqual && isPassEqual;
|
|
10
10
|
};
|
|
11
|
-
//#endregion
|
|
12
11
|
export { checkIsBasicAuthorized };
|
|
@@ -1,4 +1,2 @@
|
|
|
1
1
|
import { BasicAuthOptions } from "../../models/BasicAuthOptions.js";
|
|
2
|
-
|
|
3
|
-
export declare const checkIsChallenged: (path: string, { exclude, include }: BasicAuthOptions) => boolean;
|
|
4
|
-
//#endregion
|
|
2
|
+
export declare const checkIsChallenged: (path: string, { exclude, include }: BasicAuthOptions) => boolean;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
// src/runtime/services/checkIsChallenged.ts
|
|
2
2
|
const checkIsChallenged = (path, { exclude = [], include = [] }) => {
|
|
3
3
|
const isIncluded = include.some((prefix) => path.startsWith(prefix));
|
|
4
4
|
const isExcluded = exclude.some((prefix) => path.startsWith(prefix));
|
|
5
5
|
return isIncluded || !isExcluded;
|
|
6
6
|
};
|
|
7
|
-
//#endregion
|
|
8
7
|
export { checkIsChallenged };
|
|
@@ -1,3 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const checkIsCsrfTokenValid: (cookieToken: string | undefined, headerToken: null | string) => boolean;
|
|
3
|
-
//#endregion
|
|
1
|
+
export declare const checkIsCsrfTokenValid: (cookieToken: string | undefined, headerToken: null | string) => boolean;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { checkIsEqualInConstantTime } from "./checkIsEqualInConstantTime.js";
|
|
2
|
-
|
|
2
|
+
// src/runtime/services/checkIsCsrfTokenValid.ts
|
|
3
3
|
const checkIsCsrfTokenValid = (cookieToken, headerToken) => {
|
|
4
4
|
if (!cookieToken || !headerToken) return false;
|
|
5
5
|
return checkIsEqualInConstantTime(cookieToken, headerToken);
|
|
6
6
|
};
|
|
7
|
-
//#endregion
|
|
8
7
|
export { checkIsCsrfTokenValid };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/runtime/services/checkIsEqualInConstantTime.ts
|
|
2
2
|
const checkIsEqualInConstantTime = (first, second) => {
|
|
3
3
|
const firstBytes = new TextEncoder().encode(first);
|
|
4
4
|
const secondBytes = new TextEncoder().encode(second);
|
|
@@ -7,5 +7,4 @@ const checkIsEqualInConstantTime = (first, second) => {
|
|
|
7
7
|
for (const [index, byte] of firstBytes.entries()) difference |= byte ^ (secondBytes[index] ?? 0);
|
|
8
8
|
return difference === 0;
|
|
9
9
|
};
|
|
10
|
-
//#endregion
|
|
11
10
|
export { checkIsEqualInConstantTime };
|