@nosecone/sveltekit 1.0.0-alpha.30 → 1.0.0-alpha.31

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/index.d.ts CHANGED
@@ -1,7 +1,76 @@
1
- import nosecone, { defaults } from "nosecone";
1
+ import nosecone from "nosecone";
2
2
  import type { CspDirectives, NoseconeOptions } from "nosecone";
3
3
  import type { Handle, KitConfig } from "@sveltejs/kit";
4
- export { defaults };
4
+ export declare const defaults: {
5
+ readonly directives: {
6
+ readonly scriptSrc: readonly ["'strict-dynamic'"];
7
+ readonly baseUri: readonly ["'none'"];
8
+ readonly childSrc: readonly ["'none'"];
9
+ readonly connectSrc: readonly ["'self'"];
10
+ readonly defaultSrc: readonly ["'self'"];
11
+ readonly fontSrc: readonly ["'self'"];
12
+ readonly formAction: readonly ["'self'"];
13
+ readonly frameAncestors: readonly ["'none'"];
14
+ readonly frameSrc: readonly ["'none'"];
15
+ readonly imgSrc: readonly ["'self'", "blob:", "data:"];
16
+ readonly manifestSrc: readonly ["'self'"];
17
+ readonly mediaSrc: readonly ["'self'"];
18
+ readonly objectSrc: readonly ["'none'"];
19
+ readonly styleSrc: readonly ["'self'"];
20
+ readonly workerSrc: readonly ["'self'"];
21
+ readonly upgradeInsecureRequests: true;
22
+ };
23
+ readonly contentSecurityPolicy: {
24
+ readonly directives: {
25
+ readonly baseUri: readonly ["'none'"];
26
+ readonly childSrc: readonly ["'none'"];
27
+ readonly connectSrc: readonly ["'self'"];
28
+ readonly defaultSrc: readonly ["'self'"];
29
+ readonly fontSrc: readonly ["'self'"];
30
+ readonly formAction: readonly ["'self'"];
31
+ readonly frameAncestors: readonly ["'none'"];
32
+ readonly frameSrc: readonly ["'none'"];
33
+ readonly imgSrc: readonly ["'self'", "blob:", "data:"];
34
+ readonly manifestSrc: readonly ["'self'"];
35
+ readonly mediaSrc: readonly ["'self'"];
36
+ readonly objectSrc: readonly ["'none'"];
37
+ readonly scriptSrc: readonly ["'self'"];
38
+ readonly styleSrc: readonly ["'self'"];
39
+ readonly workerSrc: readonly ["'self'"];
40
+ readonly upgradeInsecureRequests: true;
41
+ };
42
+ };
43
+ readonly crossOriginEmbedderPolicy: {
44
+ readonly policy: "require-corp";
45
+ };
46
+ readonly crossOriginOpenerPolicy: {
47
+ readonly policy: "same-origin";
48
+ };
49
+ readonly crossOriginResourcePolicy: {
50
+ readonly policy: "same-origin";
51
+ };
52
+ readonly originAgentCluster: true;
53
+ readonly referrerPolicy: {
54
+ readonly policy: readonly ["no-referrer"];
55
+ };
56
+ readonly strictTransportSecurity: {
57
+ readonly maxAge: number;
58
+ readonly includeSubDomains: true;
59
+ readonly preload: false;
60
+ };
61
+ readonly xContentTypeOptions: true;
62
+ readonly xDnsPrefetchControl: {
63
+ readonly allow: false;
64
+ };
65
+ readonly xDownloadOptions: true;
66
+ readonly xFrameOptions: {
67
+ readonly action: "sameorigin";
68
+ };
69
+ readonly xPermittedCrossDomainPolicies: {
70
+ readonly permittedPolicies: "none";
71
+ };
72
+ readonly xXssProtection: true;
73
+ };
5
74
  export default nosecone;
6
75
  /**
7
76
  * Create a SvelteKit hook that sets secure headers on every request.
package/index.js CHANGED
@@ -1,6 +1,13 @@
1
- import nosecone, { defaults, CONTENT_SECURITY_POLICY_DIRECTIVES, NoseconeValidationError, QUOTED } from 'nosecone';
2
- export { default, defaults } from 'nosecone';
1
+ import nosecone, { defaults as defaults$1, CONTENT_SECURITY_POLICY_DIRECTIVES, NoseconeValidationError, QUOTED } from 'nosecone';
2
+ export { default } from 'nosecone';
3
3
 
4
+ const defaults = {
5
+ ...defaults$1,
6
+ directives: {
7
+ ...defaults$1.contentSecurityPolicy.directives,
8
+ scriptSrc: ["'strict-dynamic'"],
9
+ },
10
+ };
4
11
  /**
5
12
  * Create a SvelteKit hook that sets secure headers on every request.
6
13
  *
@@ -21,10 +28,6 @@ function createHook(options = defaults) {
21
28
  return response;
22
29
  };
23
30
  }
24
- const directives = {
25
- ...defaults.contentSecurityPolicy.directives,
26
- scriptSrc: ["'strict-dynamic'"],
27
- };
28
31
  function unquote(value) {
29
32
  for (const [unquoted, quoted] of QUOTED) {
30
33
  if (value === quoted) {
@@ -70,11 +73,11 @@ function directivesToSvelteKitConfig(directives) {
70
73
  }
71
74
  return sveltekitDirectives;
72
75
  }
73
- function csp(options = { mode: "auto", directives }) {
76
+ function csp(options = { mode: "auto" }) {
74
77
  return {
75
78
  mode: options.mode ? options.mode : "auto",
76
79
  directives: directivesToSvelteKitConfig(options.directives ?? defaults.contentSecurityPolicy.directives),
77
80
  };
78
81
  }
79
82
 
80
- export { createHook, csp };
83
+ export { createHook, csp, defaults };
package/index.ts CHANGED
@@ -1,14 +1,19 @@
1
1
  import nosecone, {
2
2
  CONTENT_SECURITY_POLICY_DIRECTIVES,
3
3
  QUOTED,
4
- defaults,
4
+ defaults as baseDefaults,
5
5
  NoseconeValidationError,
6
6
  } from "nosecone";
7
7
  import type { CspDirectives, NoseconeOptions } from "nosecone";
8
8
  import type { Handle, KitConfig } from "@sveltejs/kit";
9
9
 
10
- // Re-exports the defaults for easier overrides
11
- export { defaults };
10
+ export const defaults = {
11
+ ...baseDefaults,
12
+ directives: {
13
+ ...baseDefaults.contentSecurityPolicy.directives,
14
+ scriptSrc: ["'strict-dynamic'"],
15
+ },
16
+ } as const;
12
17
 
13
18
  // We export `nosecone` as the default so it can be used with `new Response()`
14
19
  export default nosecone;
@@ -44,11 +49,6 @@ export type ContentSecurityPolicyConfig = {
44
49
  // TODO: Support `reportOnly`
45
50
  };
46
51
 
47
- const directives: CspDirectives = {
48
- ...defaults.contentSecurityPolicy.directives,
49
- scriptSrc: ["'strict-dynamic'"],
50
- };
51
-
52
52
  function unquote(value?: string) {
53
53
  for (const [unquoted, quoted] of QUOTED) {
54
54
  if (value === quoted) {
@@ -108,7 +108,7 @@ function directivesToSvelteKitConfig(
108
108
  }
109
109
 
110
110
  export function csp(
111
- options: ContentSecurityPolicyConfig = { mode: "auto", directives },
111
+ options: ContentSecurityPolicyConfig = { mode: "auto" },
112
112
  ): SvelteKitCsp {
113
113
  return {
114
114
  mode: options.mode ? options.mode : "auto",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nosecone/sveltekit",
3
- "version": "1.0.0-alpha.30",
3
+ "version": "1.0.0-alpha.31",
4
4
  "description": "Protect your SvelteKit application with secure headers",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://arcjet.com",
@@ -40,15 +40,15 @@
40
40
  "test": "node --test"
41
41
  },
42
42
  "dependencies": {
43
- "nosecone": "1.0.0-alpha.30"
43
+ "nosecone": "1.0.0-alpha.31"
44
44
  },
45
45
  "peerDependencies": {
46
46
  "@sveltejs/kit": ">=2"
47
47
  },
48
48
  "devDependencies": {
49
- "@arcjet/eslint-config": "1.0.0-alpha.30",
50
- "@arcjet/rollup-config": "1.0.0-alpha.30",
51
- "@arcjet/tsconfig": "1.0.0-alpha.30",
49
+ "@arcjet/eslint-config": "1.0.0-alpha.31",
50
+ "@arcjet/rollup-config": "1.0.0-alpha.31",
51
+ "@arcjet/tsconfig": "1.0.0-alpha.31",
52
52
  "@rollup/wasm-node": "4.27.3",
53
53
  "@sveltejs/kit": "^2.8.0",
54
54
  "@types/node": "18.18.0",