@sasjs/server 3.6.1 → 3.7.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.
@@ -0,0 +1,27 @@
1
+ // Starts the Swagger UI on the page served from this folder.
2
+ //
3
+ // A file of its own, never an inline script: the default Content-Security-Policy
4
+ // is `script-src 'self'`, which refuses an inline init.
5
+ window.onload = function () {
6
+ window.ui = SwaggerUIBundle({
7
+ url: '/swagger.yaml',
8
+ dom_id: '#swagger-ui',
9
+ deepLinking: true,
10
+ presets: [SwaggerUIBundle.presets.apis, SwaggerUIStandalonePreset],
11
+ plugins: [SwaggerUIBundle.plugins.DownloadUrl],
12
+ layout: 'StandaloneLayout',
13
+ // null, not the default: the online validator posts the spec URL to
14
+ // validator.swagger.io, and nothing on this page talks to a third party.
15
+ validatorUrl: null,
16
+ // the API's own calls carry the session cookie and the CSRF header
17
+ requestInterceptor: function (request) {
18
+ request.credentials = 'include'
19
+
20
+ const cookie = document.cookie
21
+ const startIndex = cookie.indexOf('XSRF-TOKEN')
22
+ const csrf = cookie.slice(startIndex + 11).split('; ')[0]
23
+ request.headers['X-XSRF-TOKEN'] = csrf
24
+ return request
25
+ }
26
+ })
27
+ }