@scalar/fastify-api-reference 1.58.0 → 1.59.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # @scalar/fastify-api-reference
2
2
 
3
+ ## 1.59.1
4
+
5
+ ## 1.59.0
6
+
7
+ ### Minor Changes
8
+
9
+ - [#9422](https://github.com/scalar/scalar/pull/9422): Add a `nonce` option for Content Security Policy support.
10
+
11
+ When you pass a `nonce`, the rendered HTML stamps it onto the inline `<script>` and the CDN `<script>` tag (and Scalar's own `<style>` tags, plus a matching `<meta property="csp-nonce">`). This lets the API Reference run under a strict `script-src` with no `unsafe-inline` and no `unsafe-eval`.
12
+
13
+ ```ts
14
+ ApiReference({
15
+ url: '/openapi.json',
16
+ // Match this value in your `script-src` CSP directive.
17
+ nonce: 'r4nd0m',
18
+ })
19
+ ```
20
+
21
+ Note: `style-src` still needs `'unsafe-inline'`. The reference renders inline `style="…"` attributes, which a CSP nonce can never authorize (nonces only apply to `<script>`, `<style>` and `<link>` elements), so a nonce-only `style-src` is not possible. The win is a fully strict `script-src`.
22
+
3
23
  ## 1.58.0
4
24
 
5
25
  ### Patch Changes
@@ -1 +1 @@
1
- {"version":3,"file":"fastifyApiReference.d.ts","sourceRoot":"","sources":["../src/fastifyApiReference.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,iBAAiB,EAAiB,0BAA0B,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAI7G,OAAO,KAAK,EAA8D,0BAA0B,EAAE,MAAM,SAAS,CAAA;AAoDrH,QAAA,MAAM,mBAAmB,sIAwMxB,CAAA;AAED,eAAe,mBAAmB,CAAA"}
1
+ {"version":3,"file":"fastifyApiReference.d.ts","sourceRoot":"","sources":["../src/fastifyApiReference.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,iBAAiB,EAAiB,0BAA0B,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAI7G,OAAO,KAAK,EAA8D,0BAA0B,EAAE,MAAM,SAAS,CAAA;AAoDrH,QAAA,MAAM,mBAAmB,sIAyMxB,CAAA;AAED,eAAe,mBAAmB,CAAA"}
@@ -187,12 +187,13 @@ const fastifyApiReference = fp((fastify, options, next) => {
187
187
  };
188
188
  }
189
189
  // Respond with the HTML document
190
- const { cdn, pageTitle, ...config } = configuration;
190
+ const { cdn, pageTitle, nonce, ...config } = configuration;
191
191
  return reply.header('Content-Type', 'text/html; charset=utf-8').send(renderApiReference({
192
192
  config,
193
193
  // We're using the bundled JS here by default, but the user can pass a CDN URL.
194
194
  cdn: cdn ?? RELATIVE_JAVASCRIPT_PATH,
195
195
  pageTitle,
196
+ nonce,
196
197
  }));
197
198
  },
198
199
  });