@scalar/fastify-api-reference 1.57.5 → 1.59.0
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 +24 -0
- package/dist/fastifyApiReference.d.ts.map +1 -1
- package/dist/fastifyApiReference.js +5 -1
- package/dist/js/standalone.js +258 -255
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# @scalar/fastify-api-reference
|
|
2
2
|
|
|
3
|
+
## 1.59.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#9422](https://github.com/scalar/scalar/pull/9422): Add a `nonce` option for Content Security Policy support.
|
|
8
|
+
|
|
9
|
+
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`.
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
ApiReference({
|
|
13
|
+
url: '/openapi.json',
|
|
14
|
+
// Match this value in your `script-src` CSP directive.
|
|
15
|
+
nonce: 'r4nd0m',
|
|
16
|
+
})
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
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`.
|
|
20
|
+
|
|
21
|
+
## 1.58.0
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- [#9209](https://github.com/scalar/scalar/pull/9209): Fix intermittent TypeScript error when hook handlers are spread into route options. Annotating the internal `schemaToHideRoute` constant as `FastifySchema` prevents TypeScript from narrowing its type to `{ hide: boolean }`, which caused incompatible hook-handler types with Fastify 5's `NoInfer<SchemaCompiler>`-based route definitions.
|
|
26
|
+
|
|
3
27
|
## 1.57.5
|
|
4
28
|
|
|
5
29
|
## 1.57.4
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fastifyApiReference.d.ts","sourceRoot":"","sources":["../src/fastifyApiReference.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,iBAAiB,
|
|
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"}
|
|
@@ -15,6 +15,9 @@ const RELATIVE_JAVASCRIPT_PATH = 'js/scalar.js';
|
|
|
15
15
|
*
|
|
16
16
|
* @see https://github.com/fastify/fastify-swagger#hide-a-route
|
|
17
17
|
*/
|
|
18
|
+
// Typed as FastifySchema so route inference uses FastifySchema (not the narrow
|
|
19
|
+
// literal { hide: boolean }), keeping hook handler types compatible across
|
|
20
|
+
// Fastify v4 and v5 even when @fastify/swagger augments FastifySchema with `hide`.
|
|
18
21
|
const schemaToHideRoute = {
|
|
19
22
|
hide: true,
|
|
20
23
|
};
|
|
@@ -184,12 +187,13 @@ const fastifyApiReference = fp((fastify, options, next) => {
|
|
|
184
187
|
};
|
|
185
188
|
}
|
|
186
189
|
// Respond with the HTML document
|
|
187
|
-
const { cdn, pageTitle, ...config } = configuration;
|
|
190
|
+
const { cdn, pageTitle, nonce, ...config } = configuration;
|
|
188
191
|
return reply.header('Content-Type', 'text/html; charset=utf-8').send(renderApiReference({
|
|
189
192
|
config,
|
|
190
193
|
// We're using the bundled JS here by default, but the user can pass a CDN URL.
|
|
191
194
|
cdn: cdn ?? RELATIVE_JAVASCRIPT_PATH,
|
|
192
195
|
pageTitle,
|
|
196
|
+
nonce,
|
|
193
197
|
}));
|
|
194
198
|
},
|
|
195
199
|
});
|