@maka/maka-cli 4.0.84 → 4.0.87

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.
Files changed (109) hide show
  1. package/dist/command.js +1 -1
  2. package/dist/commands/_index.js +1 -1
  3. package/dist/commands/aws/_index.js +1 -1
  4. package/dist/commands/aws/aws.command.js +1 -1
  5. package/dist/commands/aws/ci.sub.cmd.js +1 -1
  6. package/dist/commands/aws/ckp.sub.cmd.js +1 -1
  7. package/dist/commands/aws/csg.sub.cmd.js +1 -1
  8. package/dist/commands/aws/di.sub.cmd.js +1 -1
  9. package/dist/commands/aws/dks.sub.cmd.js +1 -1
  10. package/dist/commands/aws/rbi.sub.cmd.js +1 -1
  11. package/dist/commands/aws/sth.sub.cmd.js +1 -1
  12. package/dist/commands/aws/ti.sub.cmd.js +1 -1
  13. package/dist/commands/build/_index.js +1 -1
  14. package/dist/commands/build/build.js +1 -1
  15. package/dist/commands/build/docker.sub.cmd.js +1 -1
  16. package/dist/commands/create.js +1 -1
  17. package/dist/commands/debug.js +1 -1
  18. package/dist/commands/deploy.js +1 -1
  19. package/dist/commands/game/_index.js +1 -1
  20. package/dist/commands/game/battleship.sub.cmd.js +1 -1
  21. package/dist/commands/game/play.command.js +1 -1
  22. package/dist/commands/game/pong.sub.cmd.js +1 -1
  23. package/dist/commands/game/snake.sub.cmd.js +1 -1
  24. package/dist/commands/game/tetris.sub.cmd.js +1 -1
  25. package/dist/commands/generate.js +1 -1
  26. package/dist/commands/get/_index.js +1 -1
  27. package/dist/commands/get/get.command.js +1 -1
  28. package/dist/commands/get/global.sub.cmd.js +1 -1
  29. package/dist/commands/get/local.sub.cmd.js +1 -1
  30. package/dist/commands/help.js +1 -1
  31. package/dist/commands/install.js +1 -1
  32. package/dist/commands/jsdoc.js +1 -1
  33. package/dist/commands/login.js +1 -1
  34. package/dist/commands/logout.js +1 -1
  35. package/dist/commands/logs.js +1 -1
  36. package/dist/commands/maka.cmd.js +1 -1
  37. package/dist/commands/murder.js +1 -1
  38. package/dist/commands/reconfig.js +1 -1
  39. package/dist/commands/run.js +1 -1
  40. package/dist/commands/set/_index.js +1 -1
  41. package/dist/commands/set/global.sub.cmd.js +1 -1
  42. package/dist/commands/set/local.sub.cmd.js +1 -1
  43. package/dist/commands/set/set.command.js +1 -1
  44. package/dist/commands/ssh.js +1 -1
  45. package/dist/commands/ssl.js +1 -1
  46. package/dist/commands/test.js +1 -1
  47. package/dist/commands/version.js +1 -1
  48. package/dist/error.js +1 -1
  49. package/dist/generator.js +1 -1
  50. package/dist/generators/_index.js +1 -1
  51. package/dist/generators/api.js +1 -1
  52. package/dist/generators/collection.js +1 -1
  53. package/dist/generators/component.js +1 -1
  54. package/dist/generators/config.js +1 -1
  55. package/dist/generators/dbc.js +1 -1
  56. package/dist/generators/dockerfile.js +1 -1
  57. package/dist/generators/hook.js +1 -1
  58. package/dist/generators/kit.js +1 -1
  59. package/dist/generators/layout.js +1 -1
  60. package/dist/generators/maka.gen.js +1 -1
  61. package/dist/generators/methods.js +1 -1
  62. package/dist/generators/package.js +1 -1
  63. package/dist/generators/page.js +1 -1
  64. package/dist/generators/publish.js +1 -1
  65. package/dist/generators/route.js +1 -1
  66. package/dist/generators/scaffold.js +1 -1
  67. package/dist/generators/service.js +1 -1
  68. package/dist/maka.js +1 -1
  69. package/dist/templates/meteor/app/client/head.html +0 -11
  70. package/dist/templates/meteor/app/client/main.js +12 -0
  71. package/dist/templates/meteor/app/client/main.js.jsx +12 -0
  72. package/dist/templates/meteor/app/client/main.js.ts +12 -0
  73. package/dist/templates/meteor/app/client/main.js.tsx +12 -0
  74. package/dist/templates/meteor/app/imports/startup/client/routes.js.jsx +2 -2
  75. package/dist/templates/meteor/app/imports/startup/client/routes.js.tsx +2 -2
  76. package/dist/templates/meteor/app/imports/startup/lib/routes.js.jsx +3 -3
  77. package/dist/templates/meteor/app/imports/startup/lib/routes.js.tsx +3 -3
  78. package/dist/templates/meteor/app/meteor.d.ts +13 -13
  79. package/dist/templates/meteor/app/server/helmet-csp.js +150 -0
  80. package/dist/templates/meteor/app/server/helmet-csp.js.jsx +150 -0
  81. package/dist/templates/meteor/app/server/helmet-csp.js.ts +150 -0
  82. package/dist/templates/meteor/app/server/helmet-csp.js.tsx +150 -0
  83. package/dist/templates/meteor/app/server/main.js +7 -2
  84. package/dist/templates/meteor/app/server/main.js.jsx +6 -1
  85. package/dist/templates/meteor/app/server/main.js.ts +6 -1
  86. package/dist/templates/meteor/app/server/main.js.tsx +5 -0
  87. package/dist/templates/meteor/app/tsconfig.json +3 -1
  88. package/dist/templates/meteor/config/settings.json +2 -1
  89. package/dist/templates/react/component/component.js.tsx +6 -5
  90. package/dist/templates/react/test/test.js.tsx +2 -1
  91. package/dist/tool.js +1 -1
  92. package/dist/tools/actions/actions.class.js +1 -1
  93. package/dist/tools/actions/actions.test.js +1 -1
  94. package/dist/tools/aws/aws.class.js +1 -1
  95. package/dist/tools/aws/aws.interfaces.js +1 -1
  96. package/dist/tools/docker/docker.class.js +1 -1
  97. package/dist/tools/docker/docker.interfaces.js +1 -1
  98. package/dist/tools/fsi/fsi.class.js +1 -1
  99. package/dist/tools/fsi/fsi.interfaces.js +1 -1
  100. package/dist/tools/https/https.class.js +1 -1
  101. package/dist/tools/https/https.interface.js +1 -1
  102. package/dist/tools/log/log.class.js +1 -1
  103. package/dist/tools/log/log.interfaces.js +1 -1
  104. package/dist/tools/spawn-async/spawn-async.class.js +1 -1
  105. package/dist/tools/spawn-async/spawn-async.interfaces.js +1 -1
  106. package/dist/tools/ssh/ssh.class.js +1 -1
  107. package/dist/tools/ssh/ssh.interfaces.js +1 -1
  108. package/dist/tools/ssl/ssl.class.js +1 -1
  109. package/package.json +4 -1
@@ -1 +1,13 @@
1
+ window.onbeforeunload = () => {
2
+ if (Meteor.settings.public.logoutOnClose === true && Meteor.logout) {
3
+ Meteor.logout();
4
+ }
5
+ return null;
6
+ }
7
+
8
+ // stop ios bounce and zoom
9
+ document.ontouchmove = event => {
10
+ event.preventDefault();
11
+ };
12
+
1
13
  import '/imports/startup/client/index.jsx';
@@ -1 +1,13 @@
1
+ window.onbeforeunload = () => {
2
+ if (Meteor.settings.public.logoutOnClose === true && Meteor.logout) {
3
+ Meteor.logout();
4
+ }
5
+ return null;
6
+ }
7
+
8
+ // stop ios bounce and zoom
9
+ document.ontouchmove = event => {
10
+ event.preventDefault();
11
+ };
12
+
1
13
  import '/imports/startup/client';
@@ -1 +1,13 @@
1
+ window.onbeforeunload = () => {
2
+ if (Meteor.settings.public.logoutOnClose === true && Meteor.logout) {
3
+ Meteor.logout();
4
+ }
5
+ return null;
6
+ }
7
+
8
+ // stop ios bounce and zoom
9
+ document.ontouchmove = event => {
10
+ event.preventDefault();
11
+ };
12
+
1
13
  import '/imports/startup/client/index';
@@ -22,8 +22,7 @@ const CatchAll = (
22
22
  );
23
23
 
24
24
  const privateRoutes = (<>
25
- {Root}
26
- {CatchAll}
25
+
27
26
  </>);
28
27
 
29
28
  const publicRoutes = (<>
@@ -34,6 +33,7 @@ const publicRoutes = (<>
34
33
  const PrivateRoutes = ({ history }) => (
35
34
  <Router history={ history }>
36
35
  {privateRoutes}
36
+ {publicRoutes}
37
37
  </Router>
38
38
  );
39
39
  const PublicRoutes = ({ history }) => (
@@ -22,8 +22,7 @@ const CatchAll = (
22
22
  );
23
23
 
24
24
  const privateRoutes = (<>
25
- {Root}
26
- {CatchAll}
25
+
27
26
  </>);
28
27
 
29
28
  const publicRoutes = (<>
@@ -34,6 +33,7 @@ const publicRoutes = (<>
34
33
  const PrivateRoutes = ({ history }) => (
35
34
  <Router history={ history }>
36
35
  {privateRoutes}
36
+ {publicRoutes}
37
37
  </Router>
38
38
  );
39
39
  const PublicRoutes = ({ history }) => (
@@ -22,8 +22,7 @@ const CatchAll = (
22
22
  );
23
23
 
24
24
  const privateRoutes = (<>
25
- {Root}
26
- {CatchAll}
25
+
27
26
  </>);
28
27
 
29
28
  const publicRoutes = (<>
@@ -34,6 +33,7 @@ const publicRoutes = (<>
34
33
  const PrivateRoutes = ({ history }) => (
35
34
  <Router history={ history }>
36
35
  {privateRoutes}
36
+ {publicRoutes}
37
37
  </Router>
38
38
  );
39
39
  const PublicRoutes = ({ history }) => (
@@ -42,7 +42,7 @@ const PublicRoutes = ({ history }) => (
42
42
  </Router>
43
43
  );
44
44
  const Routes = ({ user = {}, history }) => (
45
- (user._id) ? <PublicRoutes history={history}/> : <PublicRoutes history={history}/>
45
+ (user._id) ? <PrivateRoutes history={history}/> : <PublicRoutes history={history}/>
46
46
  );
47
47
 
48
48
  export default Routes;
@@ -22,8 +22,7 @@ const CatchAll = (
22
22
  );
23
23
 
24
24
  const privateRoutes = (<>
25
- {Root}
26
- {CatchAll}
25
+
27
26
  </>);
28
27
 
29
28
  const publicRoutes = (<>
@@ -34,6 +33,7 @@ const publicRoutes = (<>
34
33
  const PrivateRoutes = ({ history }) => (
35
34
  <Router history={ history }>
36
35
  {privateRoutes}
36
+ {publicRoutes}
37
37
  </Router>
38
38
  );
39
39
  const PublicRoutes = ({ history }) => (
@@ -42,7 +42,7 @@ const PublicRoutes = ({ history }) => (
42
42
  </Router>
43
43
  );
44
44
  const Routes = ({ user = {}, history }) => (
45
- (user._id) ? <PublicRoutes history={history}/> : <PublicRoutes history={history}/>
45
+ (user._id) ? <PrivateRoutes history={history}/> : <PublicRoutes history={history}/>
46
46
  );
47
47
 
48
48
  export default Routes;
@@ -10,19 +10,19 @@ declare var it: Function;
10
10
  declare var describe: Function;
11
11
  declare var assert: any;
12
12
  declare var equal: any;
13
- declare var Map: any;
13
+ declare var Map: MapConstructor;
14
14
  declare var Meteor: any;
15
15
 
16
16
  // TODO: These should be worked out ...
17
- declare module 'meteor/react-meteor-data': any;
18
- declare module 'meteor/maka:rest': any;
19
- declare module 'meteor/mdg:validated-method': any;
20
- declare module 'meteor/apollo': any;
21
- declare module 'meteor/server-render': any;
22
- declare module 'meteor/underscore': any;
17
+ declare module 'meteor/react-meteor-data';
18
+ declare module 'meteor/maka:rest';
19
+ declare module 'meteor/mdg:validated-method';
20
+ declare module 'meteor/apollo';
21
+ declare module 'meteor/server-render';
22
+ declare module 'meteor/underscore';
23
23
  declare module 'meteor/ddp-rate-limiter';
24
- declare module 'meteor/check': any;
25
- declare module 'meteor/webapp': any;
24
+ declare module 'meteor/check';
25
+ declare module 'meteor/webapp';
26
26
 
27
27
  interface EJSONable {
28
28
  [key: string]: number | string | boolean | Object | number[] | string[] | Object[] | Date | Uint8Array | EJSON.CustomType;
@@ -54,7 +54,7 @@ declare module "meteor/meteor" {
54
54
  export var isDevelopment: any;
55
55
  export var isServer: any;
56
56
  export var isClient: any;
57
-
57
+
58
58
  interface UserEmail {
59
59
  address: string;
60
60
  verified: boolean;
@@ -169,7 +169,7 @@ declare module "meteor/random" {
169
169
 
170
170
  declare module "meteor/meteor" {
171
171
  import { Blaze } from "meteor/blaze";
172
-
172
+
173
173
  export module Meteor {
174
174
  /** Start definitions for Template **/
175
175
  interface Event {
@@ -607,9 +607,9 @@ declare module "meteor/meteor" {
607
607
  function clearInterval(id: number): void;
608
608
  function clearTimeout(id: number): void;
609
609
  function disconnect(): void;
610
- var isClient: boolean;
610
+ var isClient: any;
611
611
  var isCordova: boolean;
612
- var isServer: boolean;
612
+ var isServer: any;
613
613
  function loggingIn(): boolean;
614
614
  function loginWith<ExternalService>(options?: {
615
615
  requestPermissions?: string[];
@@ -0,0 +1,150 @@
1
+ /*
2
+ * Content Security Policy (CSP)
3
+ * https://guide.meteor.com/security.html#httpheaders
4
+ */
5
+
6
+ /* global __meteor_runtime_config__ */
7
+ import { Meteor } from 'meteor/meteor'
8
+ import { WebApp } from 'meteor/webapp'
9
+ import { Autoupdate } from 'meteor/autoupdate'
10
+ import crypto from 'crypto'
11
+
12
+ const self = '\'self\''
13
+ const data = 'data:'
14
+ const unsafeEval = '\'unsafe-eval\''
15
+ const unsafeInline = '\'unsafe-inline\''
16
+ const allowedOrigins = Meteor.settings.extraAllowedOrigins;
17
+
18
+ // create the default connect source for our current domain in
19
+ // a multi-protocol compatible way (http/ws or https/wss)
20
+ const url = Meteor.absoluteUrl()
21
+ const domain = url.replace(/http(s)*:\/\//, '').replace(/\/$/, '')
22
+ const s = url.match(/(?!=http)s(?=:\/\/)/) ? 's' : ''
23
+ const usesHttps = s.length > 0
24
+ const connectSrc = [
25
+ self,
26
+ `http${s}://${domain}`,
27
+ `ws${s}://${domain}`
28
+ ]
29
+
30
+ // Prepare runtime config for generating the sha256 hash
31
+ // It is important, that the hash meets exactly the hash of the
32
+ // script in the client bundle.
33
+ // Otherwise the app would not be able to start, since the runtimeConfigScript
34
+ // is rejected __meteor_runtime_config__ is not available, causing
35
+ // a cascade of follow-up errors.
36
+ const runtimeConfig = Object.assign(__meteor_runtime_config__, Autoupdate, {
37
+ // the following lines may depend on, whether you called Accounts.config
38
+ // and whether your Meteor app is a "newer" version
39
+ accountsConfigCalled: true,
40
+ isModern: true
41
+ })
42
+
43
+ // add client versions to __meteor_runtime_config__
44
+ Object.keys(WebApp.clientPrograms).forEach(arch => {
45
+ __meteor_runtime_config__.versions[arch] = {
46
+ version: Autoupdate.autoupdateVersion || WebApp.clientPrograms[arch].version(),
47
+ versionRefreshable: Autoupdate.autoupdateVersion || WebApp.clientPrograms[arch].versionRefreshable(),
48
+ versionNonRefreshable: Autoupdate.autoupdateVersion || WebApp.clientPrograms[arch].versionNonRefreshable(),
49
+ // comment the following line if you use Meteor < 2.0
50
+ versionReplaceable: Autoupdate.autoupdateVersion || WebApp.clientPrograms[arch].versionReplaceable()
51
+ }
52
+ })
53
+
54
+ const runtimeConfigScript = `__meteor_runtime_config__ = JSON.parse(decodeURIComponent("${encodeURIComponent(JSON.stringify(runtimeConfig))}"))`
55
+ const runtimeConfigHash = crypto.createHash('sha256').update(runtimeConfigScript).digest('base64')
56
+
57
+ const helmetOptions = {
58
+ crossOriginResourcePolicy: { policy: "cross-origin" },
59
+ crossOriginOpenerPolicy: { policy: "same-origin-allow-popups" },
60
+ crossOriginResourcePolicy: { policy: "cross-origin" },
61
+ //If you want to embed something like an iframe, set to false
62
+ crossOriginEmbedderPolicy: true,
63
+ contentSecurityPolicy: {
64
+ blockAllMixedContent: false,
65
+ directives: {
66
+ defaultSrc: [self].concat(allowedOrigins),
67
+ scriptSrc: [
68
+ self,
69
+ // Remove / comment out unsafeEval if you do not use dynamic imports
70
+ // to tighten security. However, if you use dynamic imports this line
71
+ // must be kept in order to make them work.
72
+ unsafeEval,
73
+ `'sha256-${runtimeConfigHash}'`
74
+ ].concat(allowedOrigins),
75
+ childSrc: [self].concat(allowedOrigins),
76
+ // If you have external apps, that should be allowed as sources for
77
+ // connections or images, your should add them here
78
+ // Call helmetOptions() without args if you have no external sources
79
+ // Note, that this is just an example and you may configure this to your needs
80
+ connectSrc: connectSrc.concat(allowedOrigins),
81
+ fontSrc: [self, data].concat(allowedOrigins),
82
+ formAction: [self].concat(allowedOrigins),
83
+ frameAncestors: [self].concat(allowedOrigins),
84
+ frameSrc: [self].concat(allowedOrigins),
85
+ // This is an example to show, that we can define to show images only
86
+ // from our self, browser data/blob and a defined set of hosts.
87
+ // Configure to your needs.
88
+ imgSrc: [self, data, 'blob:'].concat(allowedOrigins),
89
+ manifestSrc: [self].concat(allowedOrigins),
90
+ mediaSrc: [self].concat(allowedOrigins),
91
+ objectSrc: [self].concat(allowedOrigins),
92
+ // these are just examples, configure to your needs, see
93
+ // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/sandbox
94
+ sandbox: [
95
+ // allow-downloads-without-user-activation // experimental
96
+ 'allow-forms',
97
+ 'allow-modals',
98
+ // 'allow-orientation-lock',
99
+ // 'allow-pointer-lock',
100
+ // 'allow-popups',
101
+ // 'allow-popups-to-escape-sandbox',
102
+ // 'allow-presentation',
103
+ 'allow-same-origin',
104
+ 'allow-scripts',
105
+ // 'allow-storage-access-by-user-activation ', // experimental
106
+ // 'allow-top-navigation',
107
+ // 'allow-top-navigation-by-user-activation'
108
+ ],
109
+ styleSrc: [self, unsafeInline].concat(allowedOrigins),
110
+ workerSrc: [self, 'blob:'].concat(allowedOrigins)
111
+ }
112
+ },
113
+ // see the helmet documentation to get a better understanding of
114
+ // the following configurations and settings
115
+ strictTransportSecurity: {
116
+ maxAge: 15552000,
117
+ includeSubDomains: true,
118
+ preload: false
119
+ },
120
+ referrerPolicy: {
121
+ policy: 'no-referrer'
122
+ },
123
+ expectCt: {
124
+ enforce: true,
125
+ maxAge: 604800
126
+ },
127
+ frameguard: {
128
+ action: 'sameorigin'
129
+ },
130
+ dnsPrefetchControl: {
131
+ allow: false
132
+ },
133
+ permittedCrossDomainPolicies: {
134
+ permittedPolicies: 'none'
135
+ }
136
+ };
137
+
138
+ // We assume, that we are working on a localhost when there is no https
139
+ // connection available.
140
+ // Run your project with --production flag to simulate script-src hashing
141
+ if (!usesHttps && Meteor.isDevelopment) {
142
+ delete helmetOptions.contentSecurityPolicy.blockAllMixedContent;
143
+ helmetOptions.contentSecurityPolicy.directives.scriptSrc = [
144
+ self,
145
+ unsafeEval,
146
+ unsafeInline,
147
+ ];
148
+ }
149
+
150
+ export default helmetOptions;
@@ -0,0 +1,150 @@
1
+ /*
2
+ * Content Security Policy (CSP)
3
+ * https://guide.meteor.com/security.html#httpheaders
4
+ */
5
+
6
+ /* global __meteor_runtime_config__ */
7
+ import { Meteor } from 'meteor/meteor'
8
+ import { WebApp } from 'meteor/webapp'
9
+ import { Autoupdate } from 'meteor/autoupdate'
10
+ import crypto from 'crypto'
11
+
12
+ const self = '\'self\''
13
+ const data = 'data:'
14
+ const unsafeEval = '\'unsafe-eval\''
15
+ const unsafeInline = '\'unsafe-inline\''
16
+ const allowedOrigins = Meteor.settings.extraAllowedOrigins;
17
+
18
+ // create the default connect source for our current domain in
19
+ // a multi-protocol compatible way (http/ws or https/wss)
20
+ const url = Meteor.absoluteUrl()
21
+ const domain = url.replace(/http(s)*:\/\//, '').replace(/\/$/, '')
22
+ const s = url.match(/(?!=http)s(?=:\/\/)/) ? 's' : ''
23
+ const usesHttps = s.length > 0
24
+ const connectSrc = [
25
+ self,
26
+ `http${s}://${domain}`,
27
+ `ws${s}://${domain}`
28
+ ]
29
+
30
+ // Prepare runtime config for generating the sha256 hash
31
+ // It is important, that the hash meets exactly the hash of the
32
+ // script in the client bundle.
33
+ // Otherwise the app would not be able to start, since the runtimeConfigScript
34
+ // is rejected __meteor_runtime_config__ is not available, causing
35
+ // a cascade of follow-up errors.
36
+ const runtimeConfig = Object.assign(__meteor_runtime_config__, Autoupdate, {
37
+ // the following lines may depend on, whether you called Accounts.config
38
+ // and whether your Meteor app is a "newer" version
39
+ accountsConfigCalled: true,
40
+ isModern: true
41
+ })
42
+
43
+ // add client versions to __meteor_runtime_config__
44
+ Object.keys(WebApp.clientPrograms).forEach(arch => {
45
+ __meteor_runtime_config__.versions[arch] = {
46
+ version: Autoupdate.autoupdateVersion || WebApp.clientPrograms[arch].version(),
47
+ versionRefreshable: Autoupdate.autoupdateVersion || WebApp.clientPrograms[arch].versionRefreshable(),
48
+ versionNonRefreshable: Autoupdate.autoupdateVersion || WebApp.clientPrograms[arch].versionNonRefreshable(),
49
+ // comment the following line if you use Meteor < 2.0
50
+ versionReplaceable: Autoupdate.autoupdateVersion || WebApp.clientPrograms[arch].versionReplaceable()
51
+ }
52
+ })
53
+
54
+ const runtimeConfigScript = `__meteor_runtime_config__ = JSON.parse(decodeURIComponent("${encodeURIComponent(JSON.stringify(runtimeConfig))}"))`
55
+ const runtimeConfigHash = crypto.createHash('sha256').update(runtimeConfigScript).digest('base64')
56
+
57
+ const helmetOptions = {
58
+ crossOriginResourcePolicy: { policy: "cross-origin" },
59
+ crossOriginOpenerPolicy: { policy: "same-origin-allow-popups" },
60
+ crossOriginResourcePolicy: { policy: "cross-origin" },
61
+ //If you want to embed something like an iframe, set to false
62
+ crossOriginEmbedderPolicy: true,
63
+ contentSecurityPolicy: {
64
+ blockAllMixedContent: false,
65
+ directives: {
66
+ defaultSrc: [self].concat(allowedOrigins),
67
+ scriptSrc: [
68
+ self,
69
+ // Remove / comment out unsafeEval if you do not use dynamic imports
70
+ // to tighten security. However, if you use dynamic imports this line
71
+ // must be kept in order to make them work.
72
+ unsafeEval,
73
+ `'sha256-${runtimeConfigHash}'`
74
+ ].concat(allowedOrigins),
75
+ childSrc: [self].concat(allowedOrigins),
76
+ // If you have external apps, that should be allowed as sources for
77
+ // connections or images, your should add them here
78
+ // Call helmetOptions() without args if you have no external sources
79
+ // Note, that this is just an example and you may configure this to your needs
80
+ connectSrc: connectSrc.concat(allowedOrigins),
81
+ fontSrc: [self, data].concat(allowedOrigins),
82
+ formAction: [self].concat(allowedOrigins),
83
+ frameAncestors: [self].concat(allowedOrigins),
84
+ frameSrc: [self].concat(allowedOrigins),
85
+ // This is an example to show, that we can define to show images only
86
+ // from our self, browser data/blob and a defined set of hosts.
87
+ // Configure to your needs.
88
+ imgSrc: [self, data, 'blob:'].concat(allowedOrigins),
89
+ manifestSrc: [self].concat(allowedOrigins),
90
+ mediaSrc: [self].concat(allowedOrigins),
91
+ objectSrc: [self].concat(allowedOrigins),
92
+ // these are just examples, configure to your needs, see
93
+ // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/sandbox
94
+ sandbox: [
95
+ // allow-downloads-without-user-activation // experimental
96
+ 'allow-forms',
97
+ 'allow-modals',
98
+ // 'allow-orientation-lock',
99
+ // 'allow-pointer-lock',
100
+ // 'allow-popups',
101
+ // 'allow-popups-to-escape-sandbox',
102
+ // 'allow-presentation',
103
+ 'allow-same-origin',
104
+ 'allow-scripts',
105
+ // 'allow-storage-access-by-user-activation ', // experimental
106
+ // 'allow-top-navigation',
107
+ // 'allow-top-navigation-by-user-activation'
108
+ ],
109
+ styleSrc: [self, unsafeInline].concat(allowedOrigins),
110
+ workerSrc: [self, 'blob:'].concat(allowedOrigins)
111
+ }
112
+ },
113
+ // see the helmet documentation to get a better understanding of
114
+ // the following configurations and settings
115
+ strictTransportSecurity: {
116
+ maxAge: 15552000,
117
+ includeSubDomains: true,
118
+ preload: false
119
+ },
120
+ referrerPolicy: {
121
+ policy: 'no-referrer'
122
+ },
123
+ expectCt: {
124
+ enforce: true,
125
+ maxAge: 604800
126
+ },
127
+ frameguard: {
128
+ action: 'sameorigin'
129
+ },
130
+ dnsPrefetchControl: {
131
+ allow: false
132
+ },
133
+ permittedCrossDomainPolicies: {
134
+ permittedPolicies: 'none'
135
+ }
136
+ };
137
+
138
+ // We assume, that we are working on a localhost when there is no https
139
+ // connection available.
140
+ // Run your project with --production flag to simulate script-src hashing
141
+ if (!usesHttps && Meteor.isDevelopment) {
142
+ delete helmetOptions.contentSecurityPolicy.blockAllMixedContent;
143
+ helmetOptions.contentSecurityPolicy.directives.scriptSrc = [
144
+ self,
145
+ unsafeEval,
146
+ unsafeInline,
147
+ ];
148
+ }
149
+
150
+ export default helmetOptions;
@@ -0,0 +1,150 @@
1
+ /*
2
+ * Content Security Policy (CSP)
3
+ * https://guide.meteor.com/security.html#httpheaders
4
+ */
5
+
6
+ /* global __meteor_runtime_config__ */
7
+ import { Meteor } from 'meteor/meteor'
8
+ import { WebApp } from 'meteor/webapp'
9
+ import { Autoupdate } from 'meteor/autoupdate'
10
+ import crypto from 'crypto'
11
+
12
+ const self = '\'self\''
13
+ const data = 'data:'
14
+ const unsafeEval = '\'unsafe-eval\''
15
+ const unsafeInline = '\'unsafe-inline\''
16
+ const allowedOrigins = Meteor.settings.extraAllowedOrigins;
17
+
18
+ // create the default connect source for our current domain in
19
+ // a multi-protocol compatible way (http/ws or https/wss)
20
+ const url = Meteor.absoluteUrl()
21
+ const domain = url.replace(/http(s)*:\/\//, '').replace(/\/$/, '')
22
+ const s = url.match(/(?!=http)s(?=:\/\/)/) ? 's' : ''
23
+ const usesHttps = s.length > 0
24
+ const connectSrc = [
25
+ self,
26
+ `http${s}://${domain}`,
27
+ `ws${s}://${domain}`
28
+ ]
29
+
30
+ // Prepare runtime config for generating the sha256 hash
31
+ // It is important, that the hash meets exactly the hash of the
32
+ // script in the client bundle.
33
+ // Otherwise the app would not be able to start, since the runtimeConfigScript
34
+ // is rejected __meteor_runtime_config__ is not available, causing
35
+ // a cascade of follow-up errors.
36
+ const runtimeConfig = Object.assign(__meteor_runtime_config__, Autoupdate, {
37
+ // the following lines may depend on, whether you called Accounts.config
38
+ // and whether your Meteor app is a "newer" version
39
+ accountsConfigCalled: true,
40
+ isModern: true
41
+ })
42
+
43
+ // add client versions to __meteor_runtime_config__
44
+ Object.keys(WebApp.clientPrograms).forEach(arch => {
45
+ __meteor_runtime_config__.versions[arch] = {
46
+ version: Autoupdate.autoupdateVersion || WebApp.clientPrograms[arch].version(),
47
+ versionRefreshable: Autoupdate.autoupdateVersion || WebApp.clientPrograms[arch].versionRefreshable(),
48
+ versionNonRefreshable: Autoupdate.autoupdateVersion || WebApp.clientPrograms[arch].versionNonRefreshable(),
49
+ // comment the following line if you use Meteor < 2.0
50
+ versionReplaceable: Autoupdate.autoupdateVersion || WebApp.clientPrograms[arch].versionReplaceable()
51
+ }
52
+ })
53
+
54
+ const runtimeConfigScript = `__meteor_runtime_config__ = JSON.parse(decodeURIComponent("${encodeURIComponent(JSON.stringify(runtimeConfig))}"))`
55
+ const runtimeConfigHash = crypto.createHash('sha256').update(runtimeConfigScript).digest('base64')
56
+
57
+ const helmetOptions = {
58
+ crossOriginResourcePolicy: { policy: "cross-origin" },
59
+ crossOriginOpenerPolicy: { policy: "same-origin-allow-popups" },
60
+ crossOriginResourcePolicy: { policy: "cross-origin" },
61
+ //If you want to embed something like an iframe, set to false
62
+ crossOriginEmbedderPolicy: true,
63
+ contentSecurityPolicy: {
64
+ blockAllMixedContent: false,
65
+ directives: {
66
+ defaultSrc: [self].concat(allowedOrigins),
67
+ scriptSrc: [
68
+ self,
69
+ // Remove / comment out unsafeEval if you do not use dynamic imports
70
+ // to tighten security. However, if you use dynamic imports this line
71
+ // must be kept in order to make them work.
72
+ unsafeEval,
73
+ `'sha256-${runtimeConfigHash}'`
74
+ ].concat(allowedOrigins),
75
+ childSrc: [self].concat(allowedOrigins),
76
+ // If you have external apps, that should be allowed as sources for
77
+ // connections or images, your should add them here
78
+ // Call helmetOptions() without args if you have no external sources
79
+ // Note, that this is just an example and you may configure this to your needs
80
+ connectSrc: connectSrc.concat(allowedOrigins),
81
+ fontSrc: [self, data].concat(allowedOrigins),
82
+ formAction: [self].concat(allowedOrigins),
83
+ frameAncestors: [self].concat(allowedOrigins),
84
+ frameSrc: [self].concat(allowedOrigins),
85
+ // This is an example to show, that we can define to show images only
86
+ // from our self, browser data/blob and a defined set of hosts.
87
+ // Configure to your needs.
88
+ imgSrc: [self, data, 'blob:'].concat(allowedOrigins),
89
+ manifestSrc: [self].concat(allowedOrigins),
90
+ mediaSrc: [self].concat(allowedOrigins),
91
+ objectSrc: [self].concat(allowedOrigins),
92
+ // these are just examples, configure to your needs, see
93
+ // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/sandbox
94
+ sandbox: [
95
+ // allow-downloads-without-user-activation // experimental
96
+ 'allow-forms',
97
+ 'allow-modals',
98
+ // 'allow-orientation-lock',
99
+ // 'allow-pointer-lock',
100
+ // 'allow-popups',
101
+ // 'allow-popups-to-escape-sandbox',
102
+ // 'allow-presentation',
103
+ 'allow-same-origin',
104
+ 'allow-scripts',
105
+ // 'allow-storage-access-by-user-activation ', // experimental
106
+ // 'allow-top-navigation',
107
+ // 'allow-top-navigation-by-user-activation'
108
+ ],
109
+ styleSrc: [self, unsafeInline].concat(allowedOrigins),
110
+ workerSrc: [self, 'blob:'].concat(allowedOrigins)
111
+ }
112
+ },
113
+ // see the helmet documentation to get a better understanding of
114
+ // the following configurations and settings
115
+ strictTransportSecurity: {
116
+ maxAge: 15552000,
117
+ includeSubDomains: true,
118
+ preload: false
119
+ },
120
+ referrerPolicy: {
121
+ policy: 'no-referrer'
122
+ },
123
+ expectCt: {
124
+ enforce: true,
125
+ maxAge: 604800
126
+ },
127
+ frameguard: {
128
+ action: 'sameorigin'
129
+ },
130
+ dnsPrefetchControl: {
131
+ allow: false
132
+ },
133
+ permittedCrossDomainPolicies: {
134
+ permittedPolicies: 'none'
135
+ }
136
+ };
137
+
138
+ // We assume, that we are working on a localhost when there is no https
139
+ // connection available.
140
+ // Run your project with --production flag to simulate script-src hashing
141
+ if (!usesHttps && Meteor.isDevelopment) {
142
+ delete helmetOptions.contentSecurityPolicy.blockAllMixedContent;
143
+ helmetOptions.contentSecurityPolicy.directives.scriptSrc = [
144
+ self,
145
+ unsafeEval,
146
+ unsafeInline,
147
+ ];
148
+ }
149
+
150
+ export default helmetOptions;