diff --git a/.changeset/swagger-ui-6.md b/.changeset/swagger-ui-6.md new file mode 100644 index 0000000..89978b7 --- /dev/null +++ b/.changeset/swagger-ui-6.md @@ -0,0 +1,5 @@ +--- +'@crypt.fyi/server': patch +--- + +Upgrade `@fastify/swagger-ui` to v6, which depends on the patched `@fastify/static` 10 line directly. diff --git a/packages/server/package.json b/packages/server/package.json index 212c9b8..62b879b 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -54,7 +54,7 @@ "@fastify/helmet": "^13.0.1", "@fastify/rate-limit": "^10.3.0", "@fastify/swagger": "^9.5.1", - "@fastify/swagger-ui": "^5.2.3", + "@fastify/swagger-ui": "^6.1.1", "@opentelemetry/api": "^1.9.0", "@opentelemetry/auto-instrumentations-node": "^0.81.0", "@opentelemetry/exporter-trace-otlp-proto": "^0.223.0", diff --git a/packages/server/src/app.test.ts b/packages/server/src/app.test.ts index b596c51..89926d2 100644 --- a/packages/server/src/app.test.ts +++ b/packages/server/src/app.test.ts @@ -67,6 +67,31 @@ describe('app', () => { expect(response.statusCode).toBe(200); }); + it('serves the swagger UI, its assets and the OpenAPI document', async () => { + const get = (path: string) => testContext.client.request({ method: 'GET', path }); + const { swaggerUIPath } = testContext.config; + + const page = await get(swaggerUIPath); + expect(page.statusCode).toBe(200); + const html = await page.body.text(); + expect(html).toContain('swagger-ui'); + // helmet's default CSP blocks inline scripts, so the page only works if all of them are external. + expect(html).not.toMatch(/]*\bsrc=)[^>]*>/); + + const bundle = await get(`${swaggerUIPath}/static/swagger-ui-bundle.js`); + expect(bundle.statusCode).toBe(200); + await bundle.body.dump(); + + const initializer = await get(`${swaggerUIPath}/static/swagger-initializer.js`); + expect(initializer.statusCode).toBe(200); + await initializer.body.dump(); + + const spec = await get(`${swaggerUIPath}/json`); + expect(spec.statusCode).toBe(200); + const { paths } = (await spec.body.json()) as { paths: Record }; + expect(paths).toHaveProperty('/vault'); + }); + it('retrieves and burns vault entry', async () => { const createResponse = await testContext.client.request({ method: 'POST', diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b967327..dda0e82 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -13,7 +13,6 @@ overrides: '@opentelemetry/core': 2.12.0 '@opentelemetry/propagator-jaeger': 2.12.0 '@babel/core': 7.29.6 - '@fastify/static': 10.1.2 adm-zip: 0.6.1 uuid: 11.1.1 glob@>=9.0.0 <14.0.2: ^14.0.2 @@ -260,8 +259,8 @@ importers: specifier: ^9.5.1 version: 9.8.1(supports-color@10.2.2) '@fastify/swagger-ui': - specifier: ^5.2.3 - version: 5.2.6 + specifier: ^6.1.1 + version: 6.1.3 '@opentelemetry/api': specifier: ^1.9.0 version: 1.9.1 @@ -376,7 +375,7 @@ importers: version: 8.12.3 vitest: specifier: ^4.1.12 - version: 4.1.12(@opentelemetry/api@1.9.1)(@types/node@22.20.1)(@vitest/coverage-v8@4.1.12)(esbuild@0.25.0)(jiti@2.7.0)(vite@8.3.5(@types/node@22.20.1)(esbuild@0.25.0)(jiti@2.7.0)(yaml@2.9.0))(yaml@2.9.0) + version: 4.1.12(@opentelemetry/api@1.9.1)(@types/node@22.20.1)(@vitest/coverage-v8@4.1.12)(esbuild@0.25.0)(jiti@2.7.0)(yaml@2.9.0) packages/theme: dependencies: @@ -404,7 +403,7 @@ importers: version: 8.3.5(@types/node@22.20.1)(esbuild@0.25.0)(jiti@2.7.0)(yaml@2.9.0) vitest: specifier: 4.1.12 - version: 4.1.12(@opentelemetry/api@1.9.1)(@types/node@22.20.1)(@vitest/coverage-v8@4.1.12)(esbuild@0.25.0)(jiti@2.7.0)(vite@8.3.5(@types/node@22.20.1)(esbuild@0.25.0)(jiti@2.7.0)(yaml@2.9.0))(yaml@2.9.0) + version: 4.1.12(@opentelemetry/api@1.9.1)(@types/node@22.20.1)(@vitest/coverage-v8@4.1.12)(esbuild@0.25.0)(jiti@2.7.0)(yaml@2.9.0) packages/web: dependencies: @@ -573,7 +572,7 @@ importers: version: 8.3.5(@types/node@22.20.1)(esbuild@0.25.0)(jiti@2.7.0)(yaml@2.9.0) vitest: specifier: 4.1.12 - version: 4.1.12(@opentelemetry/api@1.9.1)(@types/node@22.20.1)(@vitest/coverage-v8@4.1.12)(esbuild@0.25.0)(jiti@2.7.0)(vite@8.3.5(@types/node@22.20.1)(esbuild@0.25.0)(jiti@2.7.0)(yaml@2.9.0))(yaml@2.9.0) + version: 4.1.12(@opentelemetry/api@1.9.1)(@types/node@22.20.1)(@vitest/coverage-v8@4.1.12)(esbuild@0.25.0)(jiti@2.7.0)(yaml@2.9.0) packages: @@ -1500,8 +1499,8 @@ packages: '@fastify/static@10.1.2': resolution: {integrity: sha512-G/g18cG9tLutT/OVyN1AIsHIl9L1UwmJ+S3dkyhVpplIx0nEMicd7RGQ+uJLyhKKF4a3tTcQydccn3Mop1fX+Q==} - '@fastify/swagger-ui@5.2.6': - resolution: {integrity: sha512-OMnms0O5s9wb6wis/K5nlrAMLsgUbr1GA8uphM41IasWe3AFdgxz6r/3bA9HTxlDNUYc2FGGKeqMp3ntxmSiNA==} + '@fastify/swagger-ui@6.1.3': + resolution: {integrity: sha512-gEV0wqNx9yBqTUAw0TOpVQRtHPxehk91rVRRTDrWVbi1FnV0R4Vb6qh7jYlqoEiL1/qSix/dhHzmeUbKbgrAGg==} '@fastify/swagger@9.8.1': resolution: {integrity: sha512-VpHMnqZTY8iBZYJE8WWkbKPrXIYWy2rDfIf5qLr6DzZSpQYZ+KxQVcJFiq/AMlvNwI4gCBd66++iUlxXXGT0IQ==} @@ -7001,7 +7000,6 @@ packages: '@vitest/ui': 4.1.12 happy-dom: '*' jsdom: '*' - vite: 8.3.5 peerDependenciesMeta: '@edge-runtime/vm': optional: true @@ -8342,10 +8340,10 @@ snapshots: fastq: 1.20.1 glob: 14.0.3 - '@fastify/swagger-ui@5.2.6': + '@fastify/swagger-ui@6.1.3': dependencies: '@fastify/static': 10.1.2 - fastify-plugin: 5.1.0 + fastify-plugin: 6.0.0 openapi-types: 12.1.3 rfdc: 1.4.1 yaml: 2.9.0 @@ -10677,7 +10675,7 @@ snapshots: obug: 2.1.4 std-env: 4.2.0 tinyrainbow: 3.1.0 - vitest: 4.1.12(@opentelemetry/api@1.9.1)(@types/node@22.20.1)(@vitest/coverage-v8@4.1.12)(esbuild@0.25.0)(jiti@2.7.0)(vite@8.3.5(@types/node@22.20.1)(esbuild@0.25.0)(jiti@2.7.0)(yaml@2.9.0))(yaml@2.9.0) + vitest: 4.1.12(@opentelemetry/api@1.9.1)(@types/node@22.20.1)(@vitest/coverage-v8@4.1.12)(esbuild@0.25.0)(jiti@2.7.0)(yaml@2.9.0) '@vitest/expect@4.1.12': dependencies: @@ -14033,7 +14031,7 @@ snapshots: jiti: 2.7.0 yaml: 2.9.0 - vitest@4.1.12(@opentelemetry/api@1.9.1)(@types/node@22.20.1)(@vitest/coverage-v8@4.1.12)(esbuild@0.25.0)(jiti@2.7.0)(vite@8.3.5(@types/node@22.20.1)(esbuild@0.25.0)(jiti@2.7.0)(yaml@2.9.0))(yaml@2.9.0): + vitest@4.1.12(@opentelemetry/api@1.9.1)(@types/node@22.20.1)(@vitest/coverage-v8@4.1.12)(esbuild@0.25.0)(jiti@2.7.0)(yaml@2.9.0): dependencies: '@vitest/expect': 4.1.12 '@vitest/mocker': 4.1.12(vite@8.3.5(@types/node@22.20.1)(esbuild@0.25.0)(jiti@2.7.0)(yaml@2.9.0)) diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index 3027048..02181a3 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -57,8 +57,6 @@ overrides: '@opentelemetry/core': 2.12.0 '@opentelemetry/propagator-jaeger': 2.12.0 '@babel/core': 7.29.6 - # swagger-ui still declares ^9.x; 10.1.2 is the first line with the path-bypass fixes - '@fastify/static': 10.1.2 adm-zip: 0.6.1 # node-notifier / web-ext-run still declare uuid@8; CJS named exports remain compatible uuid: 11.1.1