@kumologica/sdk 3.1.0-alpha2 → 3.1.0-beta2

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 (49) hide show
  1. package/cli/.DS_Store +0 -0
  2. package/cli/KumologicaError.js +17 -0
  3. package/cli/cli.js +2 -1
  4. package/cli/commands/create-commands/create-project-iteratively.js +42 -0
  5. package/cli/commands/create-commands/index.js +5 -0
  6. package/cli/commands/create.js +55 -22
  7. package/cli/commands/list-templates.js +24 -0
  8. package/cli/commands/open.js +1 -1
  9. package/cli/commands/test-utils/TestSuiteController.js +0 -1
  10. package/cli/commands/test.js +3 -2
  11. package/cli/utils/download-template-from-repo.js +346 -0
  12. package/cli/utils/download-test.js +12 -0
  13. package/cli/utils/download.js +119 -0
  14. package/cli/utils/fs/copy-dir-contents-sync.js +15 -0
  15. package/cli/utils/fs/create-zip-file.js +39 -0
  16. package/cli/utils/fs/dir-exists-sync.js +14 -0
  17. package/cli/utils/fs/dir-exists.js +17 -0
  18. package/cli/utils/fs/file-exists-sync.js +14 -0
  19. package/cli/utils/fs/file-exists.js +12 -0
  20. package/cli/utils/fs/get-tmp-dir-path.js +22 -0
  21. package/cli/utils/fs/parse.js +40 -0
  22. package/cli/utils/fs/read-file-sync.js +11 -0
  23. package/cli/utils/fs/read-file.js +10 -0
  24. package/cli/utils/fs/safe-move-file.js +58 -0
  25. package/cli/utils/fs/walk-dir-sync.js +34 -0
  26. package/cli/utils/fs/write-file-sync.js +31 -0
  27. package/cli/utils/fs/write-file.js +32 -0
  28. package/cli/{commands/utils.js → utils/logger.js} +7 -1
  29. package/cli/utils/rename-service.js +49 -0
  30. package/package.json +18 -33
  31. package/src/app/ui/editor-api/lib/auth/index.js +75 -73
  32. package/src/app/ui/editor-api/lib/auth/strategies.js +132 -132
  33. package/src/app/ui/editor-api/lib/index.js +2 -2
  34. package/src/app/ui/editor-client/public/red/main-modals.min.js +1 -16
  35. package/src/app/ui/editor-client/public/red/main.min.js +1 -16
  36. package/src/app/ui/editor-client/public/red/red.js +64 -44
  37. package/src/app/ui/editor-client/public/red/red.min.js +19 -16
  38. package/src/app/ui/editor-client/public/red/style.min.css +1 -16
  39. package/src/app/ui/editor-client/public/vendor/ace/mode-jsonata.js +1 -1
  40. package/src/app/ui/editor-client/public/vendor/ace/snippets/jsonata.js +1 -1
  41. package/src/app/ui/editor-client/public/vendor/simplemde/simplemde.min.css +7 -0
  42. package/src/app/ui/editor-client/public/vendor/simplemde/simplemde.min.js +15 -0
  43. package/src/app/ui/editor-client/public/vendor/xterm/lib/xterm.js +2 -0
  44. package/src/app/ui/editor-client/src/js/ui/common/tabs.js +25 -17
  45. package/src/app/ui/editor-client/src/js/ui/palette-navigator.js +3 -2
  46. package/src/app/ui/editor-client/src/js/ui/search.js +21 -13
  47. package/src/app/ui/editor-client/src/js/ui/view.js +5 -3
  48. package/src/app/ui/editor-client/src/js/ui/workspaces.js +10 -9
  49. package/src/app/ui/editor-client/src/sass/palette.scss +1 -0
@@ -4,13 +4,12 @@
4
4
  * @mixin @kumologica-core/editor-api_auth
5
5
  */
6
6
 
7
- var passport = require('passport');
8
- var oauth2orize = require('oauth2orize');
9
-
10
- var strategies = require('./strategies');
7
+ // var passport = require('passport');
8
+ // var oauth2orize = require('oauth2orize');
9
+ // var strategies = require('./strategies');
11
10
  var Tokens = require('./tokens');
12
11
  var Users = require('./users');
13
- var permissions = require('./permissions');
12
+ // var permissions = require('./permissions');
14
13
 
15
14
  var theme = require('../editor/theme');
16
15
 
@@ -19,15 +18,15 @@ const { util: runtimeUtil } = require('../../../../lib/runtime-loader');
19
18
 
20
19
  const log = runtimeUtil.log;
21
20
 
22
- passport.use(strategies.bearerStrategy.BearerStrategy);
23
- passport.use(strategies.clientPasswordStrategy.ClientPasswordStrategy);
24
- passport.use(strategies.anonymousStrategy);
21
+ // passport.use(strategies.bearerStrategy.BearerStrategy);
22
+ // passport.use(strategies.clientPasswordStrategy.ClientPasswordStrategy);
23
+ // passport.use(strategies.anonymousStrategy);
25
24
 
26
- var server = oauth2orize.createServer();
25
+ // var server = oauth2orize.createServer();
27
26
 
28
- server.exchange(
29
- oauth2orize.exchange.password(strategies.passwordTokenExchange)
30
- );
27
+ // server.exchange(
28
+ // oauth2orize.exchange.password(strategies.passwordTokenExchange)
29
+ // );
31
30
 
32
31
  function init(_settings, storage) {
33
32
  settings = _settings;
@@ -51,24 +50,25 @@ function init(_settings, storage) {
51
50
  */
52
51
  function needsPermission(permission) {
53
52
  return function(req, res, next) {
54
- if (settings && settings.adminAuth) {
55
- return passport.authenticate(['bearer', 'anon'], { session: false })(
56
- req,
57
- res,
58
- function() {
59
- if (!req.user) {
60
- return next();
61
- }
62
- if (permissions.hasPermission(req.authInfo.scope, permission)) {
63
- return next();
64
- }
65
- log.audit({ event: 'permission.fail', permissions: permission }, req);
66
- return res.status(401).end();
67
- }
68
- );
69
- } else {
70
- next();
71
- }
53
+ // if (settings && settings.adminAuth) {
54
+ // return passport.authenticate(['bearer', 'anon'], { session: false })(
55
+ // req,
56
+ // res,
57
+ // function() {
58
+ // if (!req.user) {
59
+ // return next();
60
+ // }
61
+ // if (permissions.hasPermission(req.authInfo.scope, permission)) {
62
+ // return next();
63
+ // }
64
+ // log.audit({ event: 'permission.fail', permissions: permission }, req);
65
+ // return res.status(401).end();
66
+ // }
67
+ // );
68
+ // } else {
69
+ // next();
70
+ // }
71
+ next();
72
72
  };
73
73
  }
74
74
 
@@ -79,11 +79,12 @@ function ensureClientSecret(req, res, next) {
79
79
  next();
80
80
  }
81
81
  function authenticateClient(req, res, next) {
82
- return passport.authenticate(['oauth2-client-password'], { session: false })(
83
- req,
84
- res,
85
- next
86
- );
82
+ next();
83
+ // return passport.authenticate(['oauth2-client-password'], { session: false })(
84
+ // req,
85
+ // res,
86
+ // next
87
+ // );
87
88
  }
88
89
  function getToken(req, res, next) {
89
90
  return server.token()(req, res, next);
@@ -194,53 +195,54 @@ function genericStrategy(adminApp, strategy) {
194
195
  })
195
196
  );
196
197
  //TODO: all passport references ought to be in ./auth
197
- adminApp.use(passport.initialize());
198
- adminApp.use(passport.session());
198
+ // adminApp.use(passport.initialize());
199
+ // adminApp.use(passport.session());
199
200
 
200
201
  var options = strategy.options;
201
202
 
202
- passport.use(
203
- new strategy.strategy(options, function() {
204
- var originalDone = arguments[arguments.length - 1];
205
- if (options.verify) {
206
- var args = Array.from(arguments);
207
- args[args.length - 1] = function(err, profile) {
208
- if (err) {
209
- return originalDone(err);
210
- } else {
211
- return completeVerify(profile, originalDone);
212
- }
213
- };
214
- options.verify.apply(null, args);
215
- } else {
216
- var profile = arguments[arguments.length - 2];
217
- return completeVerify(profile, originalDone);
218
- }
219
- })
220
- );
203
+ // passport.use(
204
+ // new strategy.strategy(options, function() {
205
+ // var originalDone = arguments[arguments.length - 1];
206
+ // if (options.verify) {
207
+ // var args = Array.from(arguments);
208
+ // args[args.length - 1] = function(err, profile) {
209
+ // if (err) {
210
+ // return originalDone(err);
211
+ // } else {
212
+ // return completeVerify(profile, originalDone);
213
+ // }
214
+ // };
215
+ // options.verify.apply(null, args);
216
+ // } else {
217
+ // var profile = arguments[arguments.length - 2];
218
+ // return completeVerify(profile, originalDone);
219
+ // }
220
+ // })
221
+ // );
221
222
 
222
- adminApp.get(
223
- '/auth/strategy',
224
- passport.authenticate(strategy.name, {
225
- session: false,
226
- failureRedirect: settings.httpAdminRoot
227
- }),
228
- completeGenerateStrategyAuth
229
- );
223
+ // adminApp.get(
224
+ // '/auth/strategy',
225
+ // passport.authenticate(strategy.name, {
226
+ // session: false,
227
+ // failureRedirect: settings.httpAdminRoot
228
+ // }),
229
+ // completeGenerateStrategyAuth
230
+ // );
230
231
 
231
232
  var callbackMethodFunc = adminApp.get;
232
233
  if (/^post$/i.test(options.callbackMethod)) {
233
234
  callbackMethodFunc = adminApp.post;
234
235
  }
235
- callbackMethodFunc.call(
236
- adminApp,
237
- '/auth/strategy/callback',
238
- passport.authenticate(strategy.name, {
239
- session: false,
240
- failureRedirect: settings.httpAdminRoot
241
- }),
242
- completeGenerateStrategyAuth
243
- );
236
+
237
+ // callbackMethodFunc.call(
238
+ // adminApp,
239
+ // '/auth/strategy/callback',
240
+ // passport.authenticate(strategy.name, {
241
+ // session: false,
242
+ // failureRedirect: settings.httpAdminRoot
243
+ // }),
244
+ // completeGenerateStrategyAuth
245
+ // );
244
246
  }
245
247
  function completeGenerateStrategyAuth(req, res) {
246
248
  var tokens = req.user.tokens;
@@ -1,144 +1,144 @@
1
1
 
2
2
 
3
- var BearerStrategy = require('passport-http-bearer').Strategy;
4
- var ClientPasswordStrategy = require('passport-oauth2-client-password')
5
- .Strategy;
3
+ // var BearerStrategy = require('passport-http-bearer').Strategy;
4
+ // var ClientPasswordStrategy = require('passport-oauth2-client-password')
5
+ // .Strategy;
6
6
 
7
- var passport = require('passport');
8
- var crypto = require('crypto');
9
- var util = require('util');
7
+ // var passport = require('passport');
8
+ // var crypto = require('crypto');
9
+ // var util = require('util');
10
10
 
11
- var Tokens = require('./tokens');
12
- var Users = require('./users');
13
- var Clients = require('./clients');
14
- var permissions = require('./permissions');
11
+ // var Tokens = require('./tokens');
12
+ // var Users = require('./users');
13
+ // var Clients = require('./clients');
14
+ // var permissions = require('./permissions');
15
15
 
16
- const { util: runtimeUtil } = require('../../../../lib/runtime-loader');
17
- const log = runtimeUtil.log;
16
+ // const { util: runtimeUtil } = require('../../../../lib/runtime-loader');
17
+ // const log = runtimeUtil.log;
18
18
 
19
- var bearerStrategy = function(accessToken, done) {
20
- // is this a valid token?
21
- Tokens.get(accessToken).then(function(token) {
22
- if (token) {
23
- Users.get(token.user).then(function(user) {
24
- if (user) {
25
- done(null, user, { scope: token.scope });
26
- } else {
27
- log.audit({ event: 'auth.invalid-token' });
28
- done(null, false);
29
- }
30
- });
31
- } else {
32
- log.audit({ event: 'auth.invalid-token' });
33
- done(null, false);
34
- }
35
- });
36
- };
37
- bearerStrategy.BearerStrategy = new BearerStrategy(bearerStrategy);
19
+ // var bearerStrategy = function(accessToken, done) {
20
+ // // is this a valid token?
21
+ // Tokens.get(accessToken).then(function(token) {
22
+ // if (token) {
23
+ // Users.get(token.user).then(function(user) {
24
+ // if (user) {
25
+ // done(null, user, { scope: token.scope });
26
+ // } else {
27
+ // log.audit({ event: 'auth.invalid-token' });
28
+ // done(null, false);
29
+ // }
30
+ // });
31
+ // } else {
32
+ // log.audit({ event: 'auth.invalid-token' });
33
+ // done(null, false);
34
+ // }
35
+ // });
36
+ // };
37
+ // bearerStrategy.BearerStrategy = new BearerStrategy(bearerStrategy);
38
38
 
39
- var clientPasswordStrategy = function(clientId, clientSecret, done) {
40
- Clients.get(clientId).then(function(client) {
41
- if (client && client.secret == clientSecret) {
42
- done(null, client);
43
- } else {
44
- log.audit({ event: 'auth.invalid-client', client: clientId });
45
- done(null, false);
46
- }
47
- });
48
- };
49
- clientPasswordStrategy.ClientPasswordStrategy = new ClientPasswordStrategy(
50
- clientPasswordStrategy
51
- );
39
+ // var clientPasswordStrategy = function(clientId, clientSecret, done) {
40
+ // Clients.get(clientId).then(function(client) {
41
+ // if (client && client.secret == clientSecret) {
42
+ // done(null, client);
43
+ // } else {
44
+ // log.audit({ event: 'auth.invalid-client', client: clientId });
45
+ // done(null, false);
46
+ // }
47
+ // });
48
+ // };
49
+ // clientPasswordStrategy.ClientPasswordStrategy = new ClientPasswordStrategy(
50
+ // clientPasswordStrategy
51
+ // );
52
52
 
53
- var loginAttempts = [];
54
- var loginSignInWindow = 600000; // 10 minutes
53
+ // var loginAttempts = [];
54
+ // var loginSignInWindow = 600000; // 10 minutes
55
55
 
56
- var passwordTokenExchange = function(client, username, password, scope, done) {
57
- var now = Date.now();
58
- loginAttempts = loginAttempts.filter(function(logEntry) {
59
- return logEntry.time + loginSignInWindow > now;
60
- });
61
- loginAttempts.push({ time: now, user: username });
62
- var attemptCount = 0;
63
- loginAttempts.forEach(function(logEntry) {
64
- /* istanbul ignore else */
65
- if (logEntry.user == username) {
66
- attemptCount++;
67
- }
68
- });
69
- if (attemptCount > 5) {
70
- log.audit({
71
- event: 'auth.login.fail.too-many-attempts',
72
- username: username,
73
- client: client.id
74
- });
75
- done(
76
- new Error('Too many login attempts. Wait 10 minutes and try again'),
77
- false
78
- );
79
- return;
80
- }
56
+ // var passwordTokenExchange = function(client, username, password, scope, done) {
57
+ // var now = Date.now();
58
+ // loginAttempts = loginAttempts.filter(function(logEntry) {
59
+ // return logEntry.time + loginSignInWindow > now;
60
+ // });
61
+ // loginAttempts.push({ time: now, user: username });
62
+ // var attemptCount = 0;
63
+ // loginAttempts.forEach(function(logEntry) {
64
+ // /* istanbul ignore else */
65
+ // if (logEntry.user == username) {
66
+ // attemptCount++;
67
+ // }
68
+ // });
69
+ // if (attemptCount > 5) {
70
+ // log.audit({
71
+ // event: 'auth.login.fail.too-many-attempts',
72
+ // username: username,
73
+ // client: client.id
74
+ // });
75
+ // done(
76
+ // new Error('Too many login attempts. Wait 10 minutes and try again'),
77
+ // false
78
+ // );
79
+ // return;
80
+ // }
81
81
 
82
- Users.authenticate(username, password).then(function(user) {
83
- if (user) {
84
- if (scope === '') {
85
- scope = user.permissions;
86
- }
87
- if (permissions.hasPermission(user.permissions, scope)) {
88
- loginAttempts = loginAttempts.filter(function(logEntry) {
89
- return logEntry.user !== username;
90
- });
91
- Tokens.create(username, client.id, scope).then(function(tokens) {
92
- log.audit({
93
- event: 'auth.login',
94
- username: username,
95
- client: client.id,
96
- scope: scope
97
- });
98
- done(null, tokens.accessToken, null, {
99
- expires_in: tokens.expires_in
100
- });
101
- });
102
- } else {
103
- log.audit({
104
- event: 'auth.login.fail.permissions',
105
- username: username,
106
- client: client.id,
107
- scope: scope
108
- });
109
- done(null, false);
110
- }
111
- } else {
112
- log.audit({
113
- event: 'auth.login.fail.credentials',
114
- username: username,
115
- client: client.id,
116
- scope: scope
117
- });
118
- done(null, false);
119
- }
120
- });
121
- };
82
+ // Users.authenticate(username, password).then(function(user) {
83
+ // if (user) {
84
+ // if (scope === '') {
85
+ // scope = user.permissions;
86
+ // }
87
+ // if (permissions.hasPermission(user.permissions, scope)) {
88
+ // loginAttempts = loginAttempts.filter(function(logEntry) {
89
+ // return logEntry.user !== username;
90
+ // });
91
+ // Tokens.create(username, client.id, scope).then(function(tokens) {
92
+ // log.audit({
93
+ // event: 'auth.login',
94
+ // username: username,
95
+ // client: client.id,
96
+ // scope: scope
97
+ // });
98
+ // done(null, tokens.accessToken, null, {
99
+ // expires_in: tokens.expires_in
100
+ // });
101
+ // });
102
+ // } else {
103
+ // log.audit({
104
+ // event: 'auth.login.fail.permissions',
105
+ // username: username,
106
+ // client: client.id,
107
+ // scope: scope
108
+ // });
109
+ // done(null, false);
110
+ // }
111
+ // } else {
112
+ // log.audit({
113
+ // event: 'auth.login.fail.credentials',
114
+ // username: username,
115
+ // client: client.id,
116
+ // scope: scope
117
+ // });
118
+ // done(null, false);
119
+ // }
120
+ // });
121
+ // };
122
122
 
123
- function AnonymousStrategy() {
124
- passport.Strategy.call(this);
125
- this.name = 'anon';
126
- }
127
- util.inherits(AnonymousStrategy, passport.Strategy);
128
- AnonymousStrategy.prototype.authenticate = function(req) {
129
- var self = this;
130
- Users.default().then(function(anon) {
131
- if (anon) {
132
- self.success(anon, { scope: anon.permissions });
133
- } else {
134
- self.fail(401);
135
- }
136
- });
137
- };
123
+ // function AnonymousStrategy() {
124
+ // passport.Strategy.call(this);
125
+ // this.name = 'anon';
126
+ // }
127
+ // util.inherits(AnonymousStrategy, passport.Strategy);
128
+ // AnonymousStrategy.prototype.authenticate = function(req) {
129
+ // var self = this;
130
+ // Users.default().then(function(anon) {
131
+ // if (anon) {
132
+ // self.success(anon, { scope: anon.permissions });
133
+ // } else {
134
+ // self.fail(401);
135
+ // }
136
+ // });
137
+ // };
138
138
 
139
- module.exports = {
140
- bearerStrategy: bearerStrategy,
141
- clientPasswordStrategy: clientPasswordStrategy,
142
- passwordTokenExchange: passwordTokenExchange,
143
- anonymousStrategy: new AnonymousStrategy()
144
- };
139
+ // module.exports = {
140
+ // bearerStrategy: bearerStrategy,
141
+ // clientPasswordStrategy: clientPasswordStrategy,
142
+ // passwordTokenExchange: passwordTokenExchange,
143
+ // anonymousStrategy: new AnonymousStrategy()
144
+ // };
@@ -12,7 +12,7 @@
12
12
  var express = require('express');
13
13
  var bodyParser = require('body-parser');
14
14
  var util = require('util');
15
- var passport = require('passport');
15
+ // var passport = require('passport');
16
16
  var when = require('when');
17
17
  var cors = require('cors');
18
18
 
@@ -58,7 +58,7 @@ function init(userSettings, _server, storage, runtimeAPI) {
58
58
  if (settings.adminAuth.type === 'strategy') {
59
59
  auth.genericStrategy(adminApp, settings.adminAuth.strategy);
60
60
  } else if (settings.adminAuth.type === 'credentials') {
61
- adminApp.use(passport.initialize());
61
+ // adminApp.use(passport.initialize());
62
62
  adminApp.post(
63
63
  '/auth/token',
64
64
  auth.ensureClientSecret,
@@ -1,16 +1 @@
1
- /**
2
- * Copyright JS Foundation and other contributors, http://js.foundation
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- **/
16
- $(function(){"localhost"!==window.location.hostname&&"127.0.0.1"!==window.location.hostname&&(document.title=document.title+" : "+window.location.hostname),RED.init({apiRootUrl:"..",disableComms:!0})});
1
+ $((function(){"localhost"!==window.location.hostname&&"127.0.0.1"!==window.location.hostname&&(document.title=document.title+" : "+window.location.hostname),RED.init({apiRootUrl:"..",disableComms:!0})}));
@@ -1,16 +1 @@
1
- /**
2
- * Copyright JS Foundation and other contributors, http://js.foundation
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- **/
16
- $(function(){"localhost"!==window.location.hostname&&"127.0.0.1"!==window.location.hostname&&(document.title=document.title+" : "+window.location.hostname),RED.init({apiRootUrl:""})});
1
+ $((function(){"localhost"!==window.location.hostname&&"127.0.0.1"!==window.location.hostname&&(document.title=document.title+" : "+window.location.hostname),RED.init({apiRootUrl:""})}));