@maka/maka-cli 4.0.83 → 4.0.86

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 (107) 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/lib/routes.js.jsx +1 -1
  75. package/dist/templates/meteor/app/imports/startup/lib/routes.js.tsx +1 -1
  76. package/dist/templates/meteor/app/meteor.d.ts +13 -13
  77. package/dist/templates/meteor/app/server/helmet-csp.js +145 -0
  78. package/dist/templates/meteor/app/server/helmet-csp.js.jsx +145 -0
  79. package/dist/templates/meteor/app/server/helmet-csp.js.ts +145 -0
  80. package/dist/templates/meteor/app/server/helmet-csp.js.tsx +145 -0
  81. package/dist/templates/meteor/app/server/main.js +7 -2
  82. package/dist/templates/meteor/app/server/main.js.jsx +6 -1
  83. package/dist/templates/meteor/app/server/main.js.ts +6 -1
  84. package/dist/templates/meteor/app/server/main.js.tsx +5 -0
  85. package/dist/templates/meteor/app/tsconfig.json +3 -1
  86. package/dist/templates/meteor/config/settings.json +2 -1
  87. package/dist/templates/react/component/component.js.tsx +6 -5
  88. package/dist/templates/react/test/test.js.tsx +2 -1
  89. package/dist/tool.js +1 -1
  90. package/dist/tools/actions/actions.class.js +1 -1
  91. package/dist/tools/actions/actions.test.js +1 -1
  92. package/dist/tools/aws/aws.class.js +1 -1
  93. package/dist/tools/aws/aws.interfaces.js +1 -1
  94. package/dist/tools/docker/docker.class.js +1 -1
  95. package/dist/tools/docker/docker.interfaces.js +1 -1
  96. package/dist/tools/fsi/fsi.class.js +1 -1
  97. package/dist/tools/fsi/fsi.interfaces.js +1 -1
  98. package/dist/tools/https/https.class.js +1 -1
  99. package/dist/tools/https/https.interface.js +1 -1
  100. package/dist/tools/log/log.class.js +1 -1
  101. package/dist/tools/log/log.interfaces.js +1 -1
  102. package/dist/tools/spawn-async/spawn-async.class.js +1 -1
  103. package/dist/tools/spawn-async/spawn-async.interfaces.js +1 -1
  104. package/dist/tools/ssh/ssh.class.js +1 -1
  105. package/dist/tools/ssh/ssh.interfaces.js +1 -1
  106. package/dist/tools/ssl/ssl.class.js +1 -1
  107. package/package.json +4 -1
package/dist/maka.js CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node --experimental-modules --no-warnings --experimental-json-modules
2
- const a67C=a67d;(function(a,b){const z=a67d,c=a();while(!![]){try{const d=-parseInt(z(0xdb))/0x1*(-parseInt(z(0xd4))/0x2)+parseInt(z(0xe2))/0x3*(parseInt(z(0xcd))/0x4)+parseInt(z(0xdd))/0x5*(-parseInt(z(0xd2))/0x6)+parseInt(z(0xde))/0x7+-parseInt(z(0xe0))/0x8*(parseInt(z(0xdc))/0x9)+-parseInt(z(0xd6))/0xa+parseInt(z(0xd8))/0xb*(parseInt(z(0xce))/0xc);if(d===b)break;else c['push'](c['shift']());}catch(e){c['push'](c['shift']());}}}(a67c,0x6afe4));const a67b=(function(){let a=!![];return function(b,c){const d=a?function(){const A=a67d;if(c){const e=c[A(0xe3)](b,arguments);return c=null,e;}}:function(){};return a=![],d;};}()),a67a=a67b(this,function(){const B=a67d;return a67a[B(0xda)]()[B(0xe5)](B(0xd5))[B(0xda)]()[B(0xcf)](a67a)[B(0xe5)](B(0xd5));});a67a();import a67u from'minimist';import a67v from'os';import a67w from'path';import a67x from'humps';import a67y from'./commands/maka.cmd.js';import'./commands/_index.js';function a67d(a,b){const c=a67c();return a67d=function(d,e){d=d-0xcd;let f=c[d];return f;},a67d(a,b);}import'./generators/_index.js';import{fileURLToPath}from'url';const __filename=fileURLToPath(import.meta['url']),__dirname=a67w[a67C(0xd9)](__filename);global[a67C(0xe1)]=__dirname;let total_memory=a67v[a67C(0xd1)](),total_mem_in_kb=total_memory/0x400,total_mem_in_mb=total_mem_in_kb/0x400;total_mem_in_mb=Math[a67C(0xd3)](total_mem_in_mb),process[a67C(0xe4)][a67C(0xdf)]='--max-old-space-size='+total_mem_in_mb;const argv=a67u(process[a67C(0xe6)][a67C(0xd7)](0x2)),args=argv['_'],deepCopyArgv=JSON[a67C(0xe8)](JSON[a67C(0xd0)](argv));delete deepCopyArgv['_'];const opts=a67x[a67C(0xe7)](deepCopyArgv);function a67c(){const D=['MAKA_COMMAND_PATH','3MxdIPG','apply','env','search','argv','camelizeKeys','parse','728756cPHYKE','5708856jyUWKF','constructor','stringify','totalmem','16140mBvJJP','floor','3878MViULu','(((.+)+)+)+$','4787900kOJQAC','slice','22nYgwei','dirname','toString','172JftLAO','9wzJuQz','1170EHiERc','4415649KnqGsE','TOOL_NODE_FLAGS','4411888cnDkko'];a67c=function(){return D;};return a67c();}a67y['run'](args,opts);
2
+ const a67B=a67d;(function(a,b){const z=a67d,c=a();while(!![]){try{const d=-parseInt(z(0xd7))/0x1+-parseInt(z(0xc7))/0x2*(parseInt(z(0xd8))/0x3)+-parseInt(z(0xc8))/0x4*(parseInt(z(0xcc))/0x5)+parseInt(z(0xc2))/0x6*(-parseInt(z(0xbf))/0x7)+parseInt(z(0xd4))/0x8*(parseInt(z(0xd6))/0x9)+parseInt(z(0xce))/0xa+-parseInt(z(0xcb))/0xb*(-parseInt(z(0xd1))/0xc);if(d===b)break;else c['push'](c['shift']());}catch(e){c['push'](c['shift']());}}}(a67c,0xe8b94));const a67b=(function(){let a=!![];return function(b,c){const d=a?function(){if(c){const e=c['apply'](b,arguments);return c=null,e;}}:function(){};return a=![],d;};}()),a67a=a67b(this,function(){const A=a67d;return a67a[A(0xcd)]()[A(0xc1)](A(0xd0))[A(0xcd)]()['constructor'](a67a)[A(0xc1)](A(0xd0));});function a67d(a,b){const c=a67c();return a67d=function(d,e){d=d-0xbd;let f=c[d];return f;},a67d(a,b);}a67a();import a67u from'minimist';function a67c(){const C=['url','2pjBoeC','3088SeFgcg','env','argv','10276145elHtka','8705HuiJJi','toString','15127410xRubpF','--max-old-space-size=','(((.+)+)+)+$','24YBxoMC','MAKA_COMMAND_PATH','slice','8ZXajcj','totalmem','2921733dIjyRU','816580LjqyKZ','933174epGQAS','dirname','parse','982947byroyh','camelizeKeys','search','12tJedLW','floor','TOOL_NODE_FLAGS','run'];a67c=function(){return C;};return a67c();}import a67v from'os';import a67w from'path';import a67x from'humps';import a67y from'./commands/maka.cmd.js';import'./commands/_index.js';import'./generators/_index.js';import{fileURLToPath}from'url';const __filename=fileURLToPath(import.meta[a67B(0xc6)]),__dirname=a67w[a67B(0xbd)](__filename);global[a67B(0xd2)]=__dirname;let total_memory=a67v[a67B(0xd5)](),total_mem_in_kb=total_memory/0x400,total_mem_in_mb=total_mem_in_kb/0x400;total_mem_in_mb=Math[a67B(0xc3)](total_mem_in_mb),process[a67B(0xc9)][a67B(0xc4)]=a67B(0xcf)+total_mem_in_mb;const argv=a67u(process[a67B(0xca)][a67B(0xd3)](0x2)),args=argv['_'],deepCopyArgv=JSON[a67B(0xbe)](JSON['stringify'](argv));delete deepCopyArgv['_'];const opts=a67x[a67B(0xc0)](deepCopyArgv);a67y[a67B(0xc5)](args,opts);
@@ -11,15 +11,4 @@
11
11
  <noscript>
12
12
  Please enable JavaScript
13
13
  </noscript>
14
- <script type="text/javascript">
15
- window.onbeforeunload = closingCode;
16
- function closingCode(){
17
- if (Meteor.settings.public.logoutOnClose === true && Meteor.logout) Meteor.logout();
18
- return null;
19
- }
20
- // stop ios bounce and zoom
21
- document.ontouchmove = event => {
22
- event.preventDefault();
23
- };
24
- </script>
25
14
  </head>
@@ -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.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';
@@ -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;
@@ -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,145 @@
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
+ contentSecurityPolicy: {
59
+ blockAllMixedContent: true,
60
+ directives: {
61
+ defaultSrc: [self],
62
+ scriptSrc: [
63
+ self,
64
+ // Remove / comment out unsafeEval if you do not use dynamic imports
65
+ // to tighten security. However, if you use dynamic imports this line
66
+ // must be kept in order to make them work.
67
+ unsafeEval,
68
+ `'sha256-${runtimeConfigHash}'`
69
+ ],
70
+ childSrc: [self],
71
+ // If you have external apps, that should be allowed as sources for
72
+ // connections or images, your should add them here
73
+ // Call helmetOptions() without args if you have no external sources
74
+ // Note, that this is just an example and you may configure this to your needs
75
+ connectSrc: connectSrc.concat(allowedOrigins),
76
+ fontSrc: [self, data],
77
+ formAction: [self],
78
+ frameAncestors: [self],
79
+ frameSrc: ['*'],
80
+ // This is an example to show, that we can define to show images only
81
+ // from our self, browser data/blob and a defined set of hosts.
82
+ // Configure to your needs.
83
+ imgSrc: [self, data, 'blob:'].concat(allowedOrigins),
84
+ manifestSrc: [self],
85
+ mediaSrc: [self],
86
+ objectSrc: [self],
87
+ // these are just examples, configure to your needs, see
88
+ // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/sandbox
89
+ sandbox: [
90
+ // allow-downloads-without-user-activation // experimental
91
+ 'allow-forms',
92
+ 'allow-modals',
93
+ // 'allow-orientation-lock',
94
+ // 'allow-pointer-lock',
95
+ // 'allow-popups',
96
+ // 'allow-popups-to-escape-sandbox',
97
+ // 'allow-presentation',
98
+ 'allow-same-origin',
99
+ 'allow-scripts',
100
+ // 'allow-storage-access-by-user-activation ', // experimental
101
+ // 'allow-top-navigation',
102
+ // 'allow-top-navigation-by-user-activation'
103
+ ],
104
+ styleSrc: [self, unsafeInline],
105
+ workerSrc: [self, 'blob:']
106
+ }
107
+ },
108
+ // see the helmet documentation to get a better understanding of
109
+ // the following configurations and settings
110
+ strictTransportSecurity: {
111
+ maxAge: 15552000,
112
+ includeSubDomains: true,
113
+ preload: false
114
+ },
115
+ referrerPolicy: {
116
+ policy: 'no-referrer'
117
+ },
118
+ expectCt: {
119
+ enforce: true,
120
+ maxAge: 604800
121
+ },
122
+ frameguard: {
123
+ action: 'sameorigin'
124
+ },
125
+ dnsPrefetchControl: {
126
+ allow: false
127
+ },
128
+ permittedCrossDomainPolicies: {
129
+ permittedPolicies: 'none'
130
+ }
131
+ }
132
+
133
+ // We assume, that we are working on a localhost when there is no https
134
+ // connection available.
135
+ // Run your project with --production flag to simulate script-src hashing
136
+ if (!usesHttps && Meteor.isDevelopment) {
137
+ delete helmetOptions.contentSecurityPolicy.blockAllMixedContent;
138
+ helmetOptions.contentSecurityPolicy.directives.scriptSrc = [
139
+ self,
140
+ unsafeEval,
141
+ unsafeInline,
142
+ ];
143
+ }
144
+
145
+ export default helmetOptions;
@@ -0,0 +1,145 @@
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
+ contentSecurityPolicy: {
59
+ blockAllMixedContent: true,
60
+ directives: {
61
+ defaultSrc: [self],
62
+ scriptSrc: [
63
+ self,
64
+ // Remove / comment out unsafeEval if you do not use dynamic imports
65
+ // to tighten security. However, if you use dynamic imports this line
66
+ // must be kept in order to make them work.
67
+ unsafeEval,
68
+ `'sha256-${runtimeConfigHash}'`
69
+ ],
70
+ childSrc: [self],
71
+ // If you have external apps, that should be allowed as sources for
72
+ // connections or images, your should add them here
73
+ // Call helmetOptions() without args if you have no external sources
74
+ // Note, that this is just an example and you may configure this to your needs
75
+ connectSrc: connectSrc.concat(allowedOrigins),
76
+ fontSrc: [self, data],
77
+ formAction: [self],
78
+ frameAncestors: [self],
79
+ frameSrc: ['*'],
80
+ // This is an example to show, that we can define to show images only
81
+ // from our self, browser data/blob and a defined set of hosts.
82
+ // Configure to your needs.
83
+ imgSrc: [self, data, 'blob:'].concat(allowedOrigins),
84
+ manifestSrc: [self],
85
+ mediaSrc: [self],
86
+ objectSrc: [self],
87
+ // these are just examples, configure to your needs, see
88
+ // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/sandbox
89
+ sandbox: [
90
+ // allow-downloads-without-user-activation // experimental
91
+ 'allow-forms',
92
+ 'allow-modals',
93
+ // 'allow-orientation-lock',
94
+ // 'allow-pointer-lock',
95
+ // 'allow-popups',
96
+ // 'allow-popups-to-escape-sandbox',
97
+ // 'allow-presentation',
98
+ 'allow-same-origin',
99
+ 'allow-scripts',
100
+ // 'allow-storage-access-by-user-activation ', // experimental
101
+ // 'allow-top-navigation',
102
+ // 'allow-top-navigation-by-user-activation'
103
+ ],
104
+ styleSrc: [self, unsafeInline],
105
+ workerSrc: [self, 'blob:']
106
+ }
107
+ },
108
+ // see the helmet documentation to get a better understanding of
109
+ // the following configurations and settings
110
+ strictTransportSecurity: {
111
+ maxAge: 15552000,
112
+ includeSubDomains: true,
113
+ preload: false
114
+ },
115
+ referrerPolicy: {
116
+ policy: 'no-referrer'
117
+ },
118
+ expectCt: {
119
+ enforce: true,
120
+ maxAge: 604800
121
+ },
122
+ frameguard: {
123
+ action: 'sameorigin'
124
+ },
125
+ dnsPrefetchControl: {
126
+ allow: false
127
+ },
128
+ permittedCrossDomainPolicies: {
129
+ permittedPolicies: 'none'
130
+ }
131
+ }
132
+
133
+ // We assume, that we are working on a localhost when there is no https
134
+ // connection available.
135
+ // Run your project with --production flag to simulate script-src hashing
136
+ if (!usesHttps && Meteor.isDevelopment) {
137
+ delete helmetOptions.contentSecurityPolicy.blockAllMixedContent;
138
+ helmetOptions.contentSecurityPolicy.directives.scriptSrc = [
139
+ self,
140
+ unsafeEval,
141
+ unsafeInline,
142
+ ];
143
+ }
144
+
145
+ export default helmetOptions;
@@ -0,0 +1,145 @@
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
+ contentSecurityPolicy: {
59
+ blockAllMixedContent: true,
60
+ directives: {
61
+ defaultSrc: [self],
62
+ scriptSrc: [
63
+ self,
64
+ // Remove / comment out unsafeEval if you do not use dynamic imports
65
+ // to tighten security. However, if you use dynamic imports this line
66
+ // must be kept in order to make them work.
67
+ unsafeEval,
68
+ `'sha256-${runtimeConfigHash}'`
69
+ ],
70
+ childSrc: [self],
71
+ // If you have external apps, that should be allowed as sources for
72
+ // connections or images, your should add them here
73
+ // Call helmetOptions() without args if you have no external sources
74
+ // Note, that this is just an example and you may configure this to your needs
75
+ connectSrc: connectSrc.concat(allowedOrigins),
76
+ fontSrc: [self, data],
77
+ formAction: [self],
78
+ frameAncestors: [self],
79
+ frameSrc: ['*'],
80
+ // This is an example to show, that we can define to show images only
81
+ // from our self, browser data/blob and a defined set of hosts.
82
+ // Configure to your needs.
83
+ imgSrc: [self, data, 'blob:'].concat(allowedOrigins),
84
+ manifestSrc: [self],
85
+ mediaSrc: [self],
86
+ objectSrc: [self],
87
+ // these are just examples, configure to your needs, see
88
+ // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/sandbox
89
+ sandbox: [
90
+ // allow-downloads-without-user-activation // experimental
91
+ 'allow-forms',
92
+ 'allow-modals',
93
+ // 'allow-orientation-lock',
94
+ // 'allow-pointer-lock',
95
+ // 'allow-popups',
96
+ // 'allow-popups-to-escape-sandbox',
97
+ // 'allow-presentation',
98
+ 'allow-same-origin',
99
+ 'allow-scripts',
100
+ // 'allow-storage-access-by-user-activation ', // experimental
101
+ // 'allow-top-navigation',
102
+ // 'allow-top-navigation-by-user-activation'
103
+ ],
104
+ styleSrc: [self, unsafeInline],
105
+ workerSrc: [self, 'blob:']
106
+ }
107
+ },
108
+ // see the helmet documentation to get a better understanding of
109
+ // the following configurations and settings
110
+ strictTransportSecurity: {
111
+ maxAge: 15552000,
112
+ includeSubDomains: true,
113
+ preload: false
114
+ },
115
+ referrerPolicy: {
116
+ policy: 'no-referrer'
117
+ },
118
+ expectCt: {
119
+ enforce: true,
120
+ maxAge: 604800
121
+ },
122
+ frameguard: {
123
+ action: 'sameorigin'
124
+ },
125
+ dnsPrefetchControl: {
126
+ allow: false
127
+ },
128
+ permittedCrossDomainPolicies: {
129
+ permittedPolicies: 'none'
130
+ }
131
+ }
132
+
133
+ // We assume, that we are working on a localhost when there is no https
134
+ // connection available.
135
+ // Run your project with --production flag to simulate script-src hashing
136
+ if (!usesHttps && Meteor.isDevelopment) {
137
+ delete helmetOptions.contentSecurityPolicy.blockAllMixedContent;
138
+ helmetOptions.contentSecurityPolicy.directives.scriptSrc = [
139
+ self,
140
+ unsafeEval,
141
+ unsafeInline,
142
+ ];
143
+ }
144
+
145
+ export default helmetOptions;