yakuza0 2.22.30-beta.2 → 2.22.30-beta.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yakuza0",
3
- "version": "2.22.30-beta.2",
3
+ "version": "2.22.30-beta.4",
4
4
  "description": "yakuza0 with nuxt",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -279,9 +279,18 @@ exports.default = function () {
279
279
  // crossOriginEmbedderPolicy: true,
280
280
  // crossOriginResourcePolicy: { policy: "cross-origin" },
281
281
  // crossOriginResourcePolicy: { policy: "same-origin" }
282
+ // contentSecurityPolicy: yConf.server.csp.decoration,
282
283
  };
283
284
 
284
285
 
286
+ if (_config2.default.server.csp.decoration === true) {
287
+ helmetOptions.contentSecurityPolicy = {
288
+ directives: _config2.default.server.csp.directives
289
+ };
290
+ } else {
291
+ helmetOptions.contentSecurityPolicy = false;
292
+ }
293
+
285
294
  if (!_config2.default.server.hm.crossOriginEmbedderPolicy) {
286
295
  // helmetOptions.crossOriginEmbedderPolicy = { policy: "credentialless" };
287
296
  helmetOptions.crossOriginEmbedderPolicy = false;
@@ -444,12 +453,6 @@ exports.default = function () {
444
453
  return _ref5.apply(this, arguments);
445
454
  };
446
455
  }());
447
- } else {
448
- if (_config2.default.server.csp.decoration === true) {
449
- app.use(_koaHelmet2.default.contentSecurityPolicy({
450
- directives: _config2.default.server.csp.directives
451
- }));
452
- }
453
456
  }
454
457
  }
455
458
 
@@ -4,6 +4,18 @@ import {shtml} from 'yakuza1/lib/xss';
4
4
  import yConf from 'yakuza0/config';
5
5
  import {connect, req} from 'yakuza1/lib/ws';
6
6
 
7
+ const oToStr = (obj) => {
8
+ if (obj && typeof obj !== "string") {
9
+ try {
10
+ return JSON.stringify(obj);
11
+ } catch (e) {
12
+ return obj
13
+ }
14
+ }
15
+
16
+ return obj
17
+ }
18
+
7
19
  export default async (ctx, inject) => {
8
20
  const { $http, $utils, $yk } = ctx;
9
21
  const event = {
@@ -51,7 +63,7 @@ export default async (ctx, inject) => {
51
63
  })
52
64
 
53
65
  if ($yk.security.stupid) {
54
- return shtml(result && result.data);
66
+ return shtml(oToStr(result && result.data));
55
67
  }
56
68
 
57
69
  return result && result.data
@@ -108,7 +120,7 @@ export default async (ctx, inject) => {
108
120
  })
109
121
 
110
122
  if ($yk.security.stupid) {
111
- return shtml(data);
123
+ return shtml(oToStr(data));
112
124
  }
113
125
 
114
126
  return data;