cloudcms-server 4.0.0-beta.1 → 4.0.0-beta.11

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
@@ -6,7 +6,7 @@
6
6
  },
7
7
  "name": "cloudcms-server",
8
8
  "description": "Cloud CMS Application Server Module",
9
- "version": "4.0.0-beta.1",
9
+ "version": "4.0.0-beta.11",
10
10
  "repository": {
11
11
  "type": "git",
12
12
  "url": "git://github.com/gitana/cloudcms-server.git"
@@ -16,13 +16,13 @@
16
16
  "@socket.io/redis-adapter": "^7.2.0",
17
17
  "@socket.io/sticky": "^1.0.1",
18
18
  "accepts": "^1.3.8",
19
- "agentkeepalive": "^4.2.1",
19
+ "agentkeepalive": "^4.5.0",
20
20
  "alpaca": "^1.5.27",
21
21
  "archiver": "^5.1.0",
22
22
  "async": "^3.2.3",
23
23
  "async-lock": "^1.3.2",
24
24
  "aws-sdk": "^2.1208.0",
25
- "axios": "^0.21.0",
25
+ "axios": "^1.5.0",
26
26
  "basic-auth": "^2.0.1",
27
27
  "body-parser": "^1.20.0",
28
28
  "bytes": "^3.1.0",
@@ -37,22 +37,21 @@
37
37
  "dustjs-helpers": "^1.7.4",
38
38
  "dustjs-linkedin": "^3.0.1",
39
39
  "errorhandler": "^1.5.1",
40
- "express": "^4.18.1",
40
+ "express": "^4.18.2",
41
41
  "express-session": "^1.17.3",
42
42
  "express-useragent": "^1.0.15",
43
43
  "extend-with-super": "^2.0.0",
44
- "finalhandler": "^1.2.0",
45
- "form-data": "^2.3.3",
46
- "gitana": "^1.0.322",
44
+ "fast-proxy": "^2.2.0",
45
+ "gitana": "^1.0.330",
47
46
  "handlebars": "^4.7.6",
48
47
  "hbs": "^4.1.1",
49
48
  "helmet": "^4.6.0",
50
- "http2-proxy": "^5.0.53",
51
49
  "ioredis": "4.28.5",
52
50
  "json5": "^2.1.3",
53
- "jsonwebtoken": "^8.5.1",
51
+ "jsonwebtoken": "^9.0.2",
52
+ "kafkajs": "^2.2.4",
54
53
  "klaw": "^3.0.0",
55
- "lru-cache": "^6.0.0",
54
+ "lru-cache": "^7.14.0",
56
55
  "marked": "^4.0.14",
57
56
  "memored": "^1.1.1",
58
57
  "memorystore": "^1.6.4",
@@ -63,7 +62,7 @@
63
62
  "object-hash": "^2.0.3",
64
63
  "object-merge": "^2.5.1",
65
64
  "on-headers": "^1.0.2",
66
- "passport": "^0.4.1",
65
+ "passport": "^0.7.0",
67
66
  "passport-cas": "^0.1.1",
68
67
  "passport-facebook": "^3.0.0",
69
68
  "passport-github": "^1.1.0",
@@ -71,7 +70,7 @@
71
70
  "passport-linkedin": "^1.0.0",
72
71
  "passport-local": "^1.0.0",
73
72
  "passport-oauth": "^1.0.0",
74
- "passport-saml": "^2.2.0",
73
+ "@node-saml/passport-saml": "^4.0.4",
75
74
  "passport-twitter": "^0.1.5",
76
75
  "pkginfo": "^0.4.1",
77
76
  "random-js": "^2.1.0",
package/server/index.js CHANGED
@@ -547,7 +547,6 @@ var runFunctions = function (functions, args, callback) {
547
547
  * @param callback optional callback function
548
548
  */
549
549
  exports.start = function(overrides, callback) {
550
-
551
550
  setTimeout(function() {
552
551
  _start(overrides, function(err) {
553
552
  if (callback) {
@@ -780,6 +779,10 @@ var startServer = function(config, startServerFinishedFn)
780
779
 
781
780
  // global service starts
782
781
  main.init(app, function (err) {
782
+
783
+ if (err) {
784
+ return startServerFinishedFn(err);
785
+ }
783
786
 
784
787
  app.enable('strict routing');
785
788
 
package/util/auth.js CHANGED
@@ -324,6 +324,12 @@ var syncProfile = exports.syncProfile = function(req, res, strategy, domainId, p
324
324
  }
325
325
 
326
326
  _LOCK([CACHE_IDENTIFIER], function(err, releaseLockFn) {
327
+
328
+ if (err) {
329
+ try { releaseLockFn(); } catch (e) { }
330
+ return callback(err);
331
+ }
332
+
327
333
  _handleSyncUser(req, strategy, settings, key, domainId, providerId, providerUserId, token, refreshToken, userObject, groupsArray, function (err, gitanaUser) {
328
334
 
329
335
  if (err) {
@@ -333,14 +339,14 @@ var syncProfile = exports.syncProfile = function(req, res, strategy, domainId, p
333
339
 
334
340
  // no user found
335
341
  if (!gitanaUser) {
336
- releaseLockFn();
342
+ try { releaseLockFn(); } catch (e) { }
337
343
  return callback();
338
344
  }
339
345
 
340
346
  _handleConnectAsUser(req, key, gitanaUser, function (err, platform, appHelper, key) {
341
347
 
342
348
  if (err) {
343
- releaseLockFn();
349
+ try { releaseLockFn(); } catch (e) { }
344
350
  return callback(err);
345
351
  }
346
352
 
@@ -351,8 +357,8 @@ var syncProfile = exports.syncProfile = function(req, res, strategy, domainId, p
351
357
  "appHelper": appHelper,
352
358
  "key": key
353
359
  });
354
-
355
- releaseLockFn();
360
+
361
+ try { releaseLockFn(); } catch (e) { }
356
362
 
357
363
  callback(err, gitanaUser, platform, appHelper, key, platform.getDriver());
358
364
  }, gitanaUser);
package/util/cloudcms.js CHANGED
@@ -399,36 +399,34 @@ exports = module.exports = function()
399
399
  "headers": headers,
400
400
  "responseType": "stream"
401
401
  }, function(err, response) {
402
-
402
+
403
403
  if (err) {
404
404
  closeWriteStream(tempStream);
405
405
  return cb(err);
406
406
  }
407
-
407
+
408
408
  if (response.status >= 200 && response.status <= 204)
409
409
  {
410
410
  response.data.pipe(tempStream).on("close", function (err) {
411
-
412
- if (err)
413
- {
411
+
412
+ if (err) {
414
413
  // some went wrong at disk io level?
415
414
  return failFast(tempStream, err);
416
415
  }
417
-
416
+
418
417
  contentStore.existsFile(filePath, function (exists) {
419
-
418
+
420
419
  if (exists) {
421
-
420
+
422
421
  // write cache file
423
422
  var cacheInfo = buildCacheInfo(response);
424
423
  if (!cacheInfo) {
425
424
  return cb(null, filePath, null);
426
425
  }
427
-
426
+
428
427
  contentStore.writeFile(cacheFilePath, JSON.stringify(cacheInfo, null, " "), function (err) {
429
-
430
- if (err)
431
- {
428
+
429
+ if (err) {
432
430
  // failed to write cache file, thus the whole thing is invalid
433
431
  return safeRemove(contentStore, cacheFilePath, function () {
434
432
  failFast(tempStream, {
@@ -436,12 +434,10 @@ exports = module.exports = function()
436
434
  });
437
435
  });
438
436
  }
439
-
437
+
440
438
  cb(null, filePath, cacheInfo);
441
439
  });
442
- }
443
- else
444
- {
440
+ } else {
445
441
  // for some reason, file wasn't found
446
442
  // roll back the whole thing
447
443
  safeRemove(contentStore, cacheFilePath, function () {
@@ -451,7 +447,7 @@ exports = module.exports = function()
451
447
  });
452
448
  }
453
449
  });
454
-
450
+
455
451
  }).on("error", function (err) {
456
452
  failFast(tempStream, err);
457
453
  });
@@ -459,35 +455,30 @@ exports = module.exports = function()
459
455
  else
460
456
  {
461
457
  // some kind of http error (usually permission denied or invalid_token)
462
-
458
+
463
459
  var body = "";
464
-
460
+
465
461
  response.data.on('data', function (chunk) {
466
462
  body += chunk;
467
463
  });
468
-
469
- response.on('end', function () {
470
-
464
+
465
+ response.data.on('end', function () {
466
+
471
467
  var afterCleanup = function () {
472
-
468
+
473
469
  // see if it is "invalid_token"
474
470
  // if so, we can automatically retry
475
471
  var isInvalidToken = false;
476
- try
477
- {
472
+ try {
478
473
  var json = JSON.parse(body);
479
- if (json && json.error === "invalid_token")
480
- {
474
+ if (json && json.error === "invalid_token") {
481
475
  isInvalidToken = true;
482
476
  }
483
- }
484
- catch (e)
485
- {
477
+ } catch (e) {
486
478
  // swallow
487
479
  }
488
-
489
- if (isInvalidToken)
490
- {
480
+
481
+ if (isInvalidToken) {
491
482
  // fire for retry
492
483
  return _refreshAccessTokenAndRetry(contentStore, gitana, uri, filePath, attemptCount, maxAttemptsAllowed, {
493
484
  "message": "Unable to load asset from remote store",
@@ -495,7 +486,7 @@ exports = module.exports = function()
495
486
  "body": body
496
487
  }, cb);
497
488
  }
498
-
489
+
499
490
  // otherwise, it's not worth retrying at this time
500
491
  cb({
501
492
  "message": "Unable to load asset from remote store",
@@ -503,10 +494,10 @@ exports = module.exports = function()
503
494
  "body": body
504
495
  });
505
496
  };
506
-
497
+
507
498
  // ensure stream is closed
508
499
  closeWriteStream(tempStream);
509
-
500
+
510
501
  // clean things up
511
502
  safeRemove(contentStore, cacheFilePath, function () {
512
503
  safeRemove(contentStore, filePath, function () {
@@ -514,18 +505,18 @@ exports = module.exports = function()
514
505
  });
515
506
  });
516
507
  });
517
-
508
+
518
509
  }
519
-
520
- }).on('error', function (e) {
521
- failFast(tempStream, e);
522
-
523
- }).on('end', function (e) {
524
-
525
- // ensure stream is closed
526
- closeWriteStream(tempStream);
527
-
528
- }).end();
510
+ });
511
+ // }).on('error', function (e) {
512
+ // failFast(tempStream, e);
513
+ //
514
+ // }).on('end', function (e) {
515
+ //
516
+ // // ensure stream is closed
517
+ // closeWriteStream(tempStream);
518
+ //
519
+ // }).end();
529
520
 
530
521
  tempStream.on("error", function (e) {
531
522
  process.log("Temp stream errored out");
@@ -564,7 +555,7 @@ exports = module.exports = function()
564
555
  var downloadNode = function(contentStore, gitana, repositoryId, branchId, nodeId, attachmentId, nodePath, locale, forceReload, callback)
565
556
  {
566
557
  // ensure path starts with "/"
567
- if (nodePath && nodePath.substring(0, 1) !== "/") {
558
+ if (nodePath && !nodePath.startsWith("/")) {
568
559
  nodePath = "/" + nodePath;
569
560
  }
570
561
 
@@ -675,7 +666,7 @@ exports = module.exports = function()
675
666
  }
676
667
 
677
668
  // ensure path starts with "/"
678
- if (nodePath && nodePath.substring(0, 1) !== "/") {
669
+ if (nodePath && !nodePath.startsWith("/")) {
679
670
  nodePath = "/" + nodePath;
680
671
  }
681
672