Socket
Socket
Sign inDemoInstall

@fastify/swagger-ui

Package Overview
Dependencies
Maintainers
17
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@fastify/swagger-ui - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

static/csp.json

2

index.js

@@ -6,3 +6,3 @@ 'use strict'

function fastifySwaggerUi (fastify, opts, next) {
fastify.decorate('swaggerCSP', require('./dist/csp.json'))
fastify.decorate('swaggerCSP', require('./static/csp.json'))

@@ -9,0 +9,0 @@ const baseDir = opts.baseDir

@@ -25,3 +25,3 @@ 'use strict'

if (opts.staticCSP === true) {
const csp = require('../dist/csp.json')
const csp = require('../static/csp.json')
staticCSP = `default-src 'self'; base-uri 'self'; font-src 'self' https: data:; frame-ancestors 'self'; img-src 'self' data: validator.swagger.io; object-src 'none'; script-src 'self' ${csp.script.join(' ')}; script-src-attr 'none'; style-src 'self' https: ${csp.style.join(' ')}; upgrade-insecure-requests;`

@@ -120,3 +120,3 @@ }

fastify.register(fastifyStatic, {
root: path.join(__dirname, '..', 'dist'),
root: path.join(__dirname, '..', 'static'),
prefix: staticPrefix,

@@ -123,0 +123,0 @@ decorateReply: false

{
"name": "@fastify/swagger-ui",
"version": "1.0.2",
"version": "1.0.3",
"description": "Serve Swagger-ui for Fastify",

@@ -22,3 +22,3 @@ "main": "index.js",

"type": "git",
"url": "git+https://github.com/fastify/fastify-swagger.git"
"url": "git+https://github.com/fastify/fastify-swagger-ui.git"
},

@@ -42,5 +42,5 @@ "keywords": [

"bugs": {
"url": "https://github.com/fastify/fastify-swagger/issues"
"url": "https://github.com/fastify/fastify-swagger-ui/issues"
},
"homepage": "https://github.com/fastify/fastify-swagger#readme",
"homepage": "https://github.com/fastify/fastify-swagger-ui#readme",
"devDependencies": {

@@ -47,0 +47,0 @@ "@apidevtools/swagger-parser": "^10.1.0",

@@ -7,4 +7,6 @@ const fs = require('fs')

fse.emptyDirSync(resolve('./dist'))
const folderName = 'static'
fse.emptyDirSync(resolve(`./${folderName}`))
// since the original swagger-ui-dist folder contains non UI files

@@ -28,6 +30,6 @@ const filesToCopy = [

filesToCopy.forEach(filename => {
fse.copySync(`${swaggerUiAssetPath}/${filename}`, resolve(`./dist/${filename}`))
fse.copySync(`${swaggerUiAssetPath}/${filename}`, resolve(`./static/${filename}`))
})
fse.writeFileSync(resolve('./dist/swagger-initializer.js'), `window.onload = function () {
fse.writeFileSync(resolve(`./${folderName}/swagger-initializer.js`), `window.onload = function () {
function resolveUrl (url) {

@@ -41,3 +43,3 @@ const anchor = document.createElement('a')

return fetch(
resolveUrl('./uiConfig').replace('dist/uiConfig', 'uiConfig')
resolveUrl('./uiConfig').replace('${folderName}/uiConfig', 'uiConfig')
)

@@ -58,3 +60,3 @@ .then(res => res.json())

}, config, {
url: resolveUrl('./json').replace('dist/json', 'json'),
url: resolveUrl('./json').replace('${folderName}/json', 'json'),
oauth2RedirectUrl: resolveUrl('./oauth2-redirect.html')

@@ -71,3 +73,3 @@ });

fetch(resolveUrl('./initOAuth').replace('dist/initOAuth', 'initOAuth'))
fetch(resolveUrl('./initOAuth').replace('${folderName}/initOAuth', 'initOAuth'))
.then(res => res.json())

@@ -107,4 +109,4 @@ .then((config) => {

}
computeCSPHashes('./dist/index.html')
computeCSPHashes('./dist/oauth2-redirect.html')
fse.writeFileSync(resolve('./dist/csp.json'), JSON.stringify(sha))
computeCSPHashes(`./${folderName}/index.html`)
computeCSPHashes(`./${folderName}/oauth2-redirect.html`)
fse.writeFileSync(resolve(`./${folderName}/csp.json`), JSON.stringify(sha))

@@ -15,3 +15,3 @@ 'use strict'

} = require('../examples/options')
const csp = require('../dist/csp.json')
const csp = require('../static/csp.json')

@@ -18,0 +18,0 @@ test('staticCSP = undefined', async (t) => {

@@ -8,3 +8,3 @@ 'use strict'

const fastifySwaggerUi = require('../index')
const swaggerCSP = require('../dist/csp.json')
const swaggerCSP = require('../static/csp.json')

@@ -11,0 +11,0 @@ test('fastify will response swagger csp', async (t) => {

@@ -349,3 +349,3 @@ 'use strict'

readFileSync(
resolve(__dirname, '..', 'dist', 'index.html'),
resolve(__dirname, '..', 'static', 'index.html'),
'utf8'

@@ -367,3 +367,3 @@ ),

readFileSync(
resolve(__dirname, '..', 'dist', 'swagger-initializer.js'),
resolve(__dirname, '..', 'static', 'swagger-initializer.js'),
'utf8'

@@ -385,3 +385,3 @@ ),

readFileSync(
resolve(__dirname, '..', 'dist', 'oauth2-redirect.html'),
resolve(__dirname, '..', 'static', 'oauth2-redirect.html'),
'utf8'

@@ -402,3 +402,3 @@ ),

readFileSync(
resolve(__dirname, '..', 'dist', 'swagger-ui.css'),
resolve(__dirname, '..', 'static', 'swagger-ui.css'),
'utf8'

@@ -419,3 +419,3 @@ ),

readFileSync(
resolve(__dirname, '..', 'dist', 'swagger-ui-bundle.js'),
resolve(__dirname, '..', 'static', 'swagger-ui-bundle.js'),
'utf8'

@@ -436,3 +436,3 @@ ),

readFileSync(
resolve(__dirname, '..', 'dist', 'swagger-ui-standalone-preset.js'),
resolve(__dirname, '..', 'static', 'swagger-ui-standalone-preset.js'),
'utf8'

@@ -439,0 +439,0 @@ ),

@@ -203,3 +203,3 @@ 'use strict'

path: './examples/example-static-specification.yaml',
baseDir: resolve(__dirname, '..', 'dist')
baseDir: resolve(__dirname, '..', 'static')
}

@@ -209,3 +209,3 @@ }

const uiConfig = {
baseDir: resolve(__dirname, '..', 'dist')
baseDir: resolve(__dirname, '..', 'static')
}

@@ -223,3 +223,3 @@

const fileContent = readFileSync(resolve(__dirname, '..', 'dist', 'oauth2-redirect.html'), 'utf8')
const fileContent = readFileSync(resolve(__dirname, '..', 'static', 'oauth2-redirect.html'), 'utf8')
t.equal(res.statusCode, 200)

@@ -241,3 +241,3 @@ t.equal(

const uiConfig = {
baseDir: resolve(__dirname, '..', 'dist') + '/'
baseDir: resolve(__dirname, '..', 'static') + '/'
}

@@ -257,3 +257,3 @@

t.equal(
readFileSync(resolve(__dirname, '..', 'dist', 'oauth2-redirect.html'), 'utf8'),
readFileSync(resolve(__dirname, '..', 'static', 'oauth2-redirect.html'), 'utf8'),
res.payload

@@ -260,0 +260,0 @@ )

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc