cloudcms-server 3.3.1-beta.9 → 4.0.0-beta.2

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 (108) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +1 -1
  3. package/broadcast/broadcast.js +6 -3
  4. package/broadcast/providers/redis.js +24 -49
  5. package/clients/nrp.js +117 -0
  6. package/clients/redis.js +64 -0
  7. package/d1/index.js +629 -0
  8. package/d1/index.js.works +203 -0
  9. package/d1/package.json +86 -0
  10. package/d1/package.json.works +14 -0
  11. package/duster/helpers/sample/nyt.js +2 -1
  12. package/framework/controllers.js +4 -4
  13. package/index.js +21 -14
  14. package/insight/insight.js +1 -1
  15. package/launchpad/index.js +203 -11
  16. package/launchpad/launchers/cluster.js +103 -110
  17. package/launchpad/launchers/redis.js +70 -0
  18. package/launchpad/launchers/single.js +36 -22
  19. package/locks/locks.js +63 -9
  20. package/locks/providers/cluster.js +3 -1
  21. package/locks/providers/memory.js +10 -7
  22. package/locks/providers/redis.js +62 -82
  23. package/middleware/admin/admin.js +3 -3
  24. package/middleware/authentication/adapters/session.js +11 -8
  25. package/middleware/authentication/authentication.js +28 -16
  26. package/middleware/authentication/authenticators/default.js +5 -2
  27. package/middleware/authentication/authenticators/session.js +5 -2
  28. package/middleware/authentication/providers/saml.js +1 -1
  29. package/middleware/authorization/authorization.js +11 -8
  30. package/middleware/awareness/awareness.js +55 -31
  31. package/middleware/awareness/plugins/editorial.js +4 -4
  32. package/middleware/awareness/providers/abstract-async.js +107 -84
  33. package/middleware/awareness/providers/abstract.js +1 -1
  34. package/middleware/awareness/providers/memory.js +0 -14
  35. package/middleware/awareness/providers/redis.js +186 -279
  36. package/middleware/cache/cache.js +4 -2
  37. package/middleware/cache/providers/redis.js +127 -89
  38. package/middleware/cache/providers/shared-memory.js +3 -3
  39. package/middleware/cloudcms/cloudcms.js +22 -16
  40. package/middleware/form/form.js +3 -3
  41. package/middleware/modules/modules.js +6 -3
  42. package/middleware/proxy/proxy.js +8 -21
  43. package/middleware/stores/stores.js +2 -2
  44. package/middleware/virtual-config/virtual-config.js +11 -8
  45. package/middleware/wcm/wcm.js +4 -4
  46. package/notifications/notifications.js +2 -2
  47. package/package.json +29 -25
  48. package/server/index.js +504 -415
  49. package/server/standalone.js +9 -0
  50. package/temp/clusterlock/index.js +3 -3
  51. package/temp/clusterlock/package.json +1 -1
  52. package/temp/passport-saml/LICENSE +23 -0
  53. package/temp/passport-saml/README.md +406 -0
  54. package/temp/passport-saml/lib/node-saml/algorithms.d.ts +5 -0
  55. package/temp/passport-saml/lib/node-saml/algorithms.js +41 -0
  56. package/temp/passport-saml/lib/node-saml/algorithms.js.map +1 -0
  57. package/temp/passport-saml/lib/node-saml/index.d.ts +3 -0
  58. package/temp/passport-saml/lib/node-saml/index.js +6 -0
  59. package/temp/passport-saml/lib/node-saml/index.js.map +1 -0
  60. package/temp/passport-saml/lib/node-saml/inmemory-cache-provider.d.ts +45 -0
  61. package/temp/passport-saml/lib/node-saml/inmemory-cache-provider.js +86 -0
  62. package/temp/passport-saml/lib/node-saml/inmemory-cache-provider.js.map +1 -0
  63. package/temp/passport-saml/lib/node-saml/saml-post-signing.d.ts +3 -0
  64. package/temp/passport-saml/lib/node-saml/saml-post-signing.js +15 -0
  65. package/temp/passport-saml/lib/node-saml/saml-post-signing.js.map +1 -0
  66. package/temp/passport-saml/lib/node-saml/saml.d.ts +77 -0
  67. package/temp/passport-saml/lib/node-saml/saml.js +1170 -0
  68. package/temp/passport-saml/lib/node-saml/saml.js.map +1 -0
  69. package/temp/passport-saml/lib/node-saml/types.d.ts +95 -0
  70. package/temp/passport-saml/lib/node-saml/types.js +8 -0
  71. package/temp/passport-saml/lib/node-saml/types.js.map +1 -0
  72. package/temp/passport-saml/lib/node-saml/utility.d.ts +3 -0
  73. package/temp/passport-saml/lib/node-saml/utility.js +19 -0
  74. package/temp/passport-saml/lib/node-saml/utility.js.map +1 -0
  75. package/temp/passport-saml/lib/node-saml/xml.d.ts +21 -0
  76. package/temp/passport-saml/lib/node-saml/xml.js +140 -0
  77. package/temp/passport-saml/lib/node-saml/xml.js.map +1 -0
  78. package/temp/passport-saml/lib/passport-saml/index.d.ts +6 -0
  79. package/temp/passport-saml/lib/passport-saml/index.js +11 -0
  80. package/temp/passport-saml/lib/passport-saml/index.js.map +1 -0
  81. package/temp/passport-saml/lib/passport-saml/multiSamlStrategy.d.ts +13 -0
  82. package/temp/passport-saml/lib/passport-saml/multiSamlStrategy.js +63 -0
  83. package/temp/passport-saml/lib/passport-saml/multiSamlStrategy.js.map +1 -0
  84. package/temp/passport-saml/lib/passport-saml/strategy.d.ts +20 -0
  85. package/temp/passport-saml/lib/passport-saml/strategy.js +167 -0
  86. package/temp/passport-saml/lib/passport-saml/strategy.js.map +1 -0
  87. package/temp/passport-saml/lib/passport-saml/types.d.ts +51 -0
  88. package/temp/passport-saml/lib/passport-saml/types.js +11 -0
  89. package/temp/passport-saml/lib/passport-saml/types.js.map +1 -0
  90. package/temp/passport-saml/package.json +96 -0
  91. package/util/auth.js +6 -6
  92. package/util/cloudcms.js +106 -118
  93. package/util/proxy-factory.js +159 -268
  94. package/util/redis.js +113 -0
  95. package/util/renditions.js +12 -6
  96. package/util/request.js +12 -6
  97. package/util/util.js +16 -2
  98. package/launchpad/launchers/sticky-cluster.js +0 -43
  99. package/temp/memored/.jshintrc +0 -4
  100. package/temp/memored/README.md +0 -240
  101. package/temp/memored/demo/demo1.js +0 -37
  102. package/temp/memored/demo/demo2.js +0 -32
  103. package/temp/memored/gulpfile.js +0 -8
  104. package/temp/memored/index.js +0 -343
  105. package/temp/memored/package.json +0 -54
  106. package/temp/memored/spec/memored.spec.js +0 -265
  107. package/web/cms/ice.js +0 -109
  108. package/web/cms/preview.js +0 -106
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  Cloud CMS Application Server Module
2
2
 
3
- Copyright 2019 Gitana Software, Inc.
3
+ Copyright 2022 Gitana Software, Inc.
4
4
 
5
5
  Licensed under the Apache License, Version 2.0 (the "License");
6
6
  you may not use this file except in compliance with the License.
package/README.md CHANGED
@@ -13,7 +13,7 @@ This looks like:
13
13
 
14
14
  ````
15
15
  {
16
- "setup": "single", // single, cluster, sticky-cluster
16
+ "setup": "single", // single, cluster, redis
17
17
  "name": "Cloud CMS Application Server",
18
18
  "socketFunctions": [],
19
19
  "routeFunctions": [],
@@ -11,10 +11,13 @@ module.exports = function()
11
11
  var self = this;
12
12
 
13
13
  // set up defaults
14
- if (!process.env.CLOUDCMS_BROADCAST_TYPE) {
14
+ if (!process.env.CLOUDCMS_BROADCAST_TYPE)
15
+ {
15
16
  process.env.CLOUDCMS_BROADCAST_TYPE = "local";
16
-
17
- if (process.configuration.setup !== "single") {
17
+
18
+ // auto-configure
19
+ if (process.env.CLOUDCMS_LAUNCHPAD_SETUP === "redis")
20
+ {
18
21
  process.env.CLOUDCMS_BROADCAST_TYPE = "redis";
19
22
  }
20
23
  }
@@ -1,8 +1,7 @@
1
- var path = require("path");
1
+ var redisClientFactory = require("../../clients/redis");
2
+ var redisHelper = require("../../util/redis");
2
3
 
3
- var NRP = require('node-redis-pubsub');
4
-
5
- var logFactory = require("../../util/logger");
4
+ var NRP = require("../../clients/nrp");
6
5
 
7
6
  /**
8
7
  * Redis broadcast provider.
@@ -12,55 +11,31 @@ var logFactory = require("../../util/logger");
12
11
  exports = module.exports = function(broadcastConfig)
13
12
  {
14
13
  var nrp = null;
15
-
16
- var logger = logFactory("REDIS BROADCAST");
17
- logger.setLevel("error");
18
-
19
- // allow for global redis default
20
- // allow for redis broadcast specific
21
- // otherwise default to "error"
22
- if (typeof(process.env.CLOUDCMS_REDIS_DEBUG_LEVEL) !== "undefined") {
23
- logger.setLevel(("" + process.env.CLOUDCMS_REDIS_DEBUG_LEVEL).toLowerCase(), true);
24
- }
25
- else if (typeof(process.env.CLOUDCMS_BROADCAST_REDIS_DEBUG_LEVEL) !== "undefined") {
26
- logger.setLevel(("" + process.env.CLOUDCMS_BROADCAST_REDIS_DEBUG_LEVEL).toLowerCase(), true);
27
- }
28
-
14
+
15
+ var logger = redisHelper.redisLogger("REDIS_BROADCAST", "CLOUDCMS_BROADCAST_", "error")
16
+
29
17
  var r = {};
30
18
 
31
19
  r.start = function(callback)
32
20
  {
33
- var redisPort = broadcastConfig.port;
34
- if (typeof(redisPort) === "undefined" || !redisPort)
35
- {
36
- redisPort = process.env.CLOUDCMS_BROADCAST_REDIS_PORT;
37
- }
38
- if (typeof(redisPort) === "undefined" || !redisPort)
39
- {
40
- redisPort = process.env.CLOUDCMS_REDIS_PORT;
41
- }
42
-
43
- var redisEndpoint = broadcastConfig.endpoint;
44
- if (typeof(redisEndpoint) === "undefined" || !redisEndpoint)
45
- {
46
- redisEndpoint = process.env.CLOUDCMS_BROADCAST_REDIS_ENDPOINT;
47
- }
48
- if (typeof(redisEndpoint) === "undefined" || !redisEndpoint)
49
- {
50
- redisEndpoint = process.env.CLOUDCMS_REDIS_ENDPOINT;
51
- }
52
-
53
- var nrpConfig = {
54
- "port": redisPort,
55
- "host": redisEndpoint,
56
- "scope": "broadcast_cache"
57
- };
58
-
59
- logger.info("using config = " + nrpConfig);
60
-
61
- nrp = new NRP(nrpConfig);
62
-
63
- callback();
21
+ redisClientFactory.create(broadcastConfig, function(err, client) {
22
+
23
+ if (err) {
24
+ return callback(err);
25
+ }
26
+
27
+ var nrpConfig = {
28
+ "client": client,
29
+ "scope": "broadcast_cache"
30
+ };
31
+
32
+ //logger.info("using config = " + nrpConfig);
33
+
34
+ nrp = new NRP(nrpConfig);
35
+ nrp.connect(function(err) {
36
+ callback(err);
37
+ });
38
+ });
64
39
  };
65
40
 
66
41
  r.publish = function(topic, message, callback)
package/clients/nrp.js ADDED
@@ -0,0 +1,117 @@
1
+ // a revision of
2
+ // https://raw.githubusercontent.com/louischatriot/node-redis-pubsub/master/lib/node-redis-pubsub.js
3
+ // that works with Redis 6+
4
+
5
+ "use strict";
6
+ var redis = require('redis');
7
+
8
+ /**
9
+ * Create a new NodeRedisPubsub instance that can subscribe to channels and publish messages
10
+ * @param {Object} options Options for the client creations:
11
+ * client - a connected Redis client
12
+ * scope - Optional, two NodeRedisPubsubs with different scopes will not share messages
13
+ */
14
+ function NodeRedisPubsub(options)
15
+ {
16
+ if (!(this instanceof NodeRedisPubsub)){ return new NodeRedisPubsub(options); }
17
+
18
+ options || (options = {});
19
+
20
+ this.emitter = options.client.duplicate();
21
+ this.emitter.setMaxListeners(0);
22
+ this.receiver = options.client.duplicate();
23
+ this.receiver.setMaxListeners(0);
24
+
25
+ this.prefix = options.scope ? options.scope + ':' : '';
26
+ }
27
+
28
+ NodeRedisPubsub.prototype.connect = function(callback)
29
+ {
30
+ var self = this;
31
+
32
+ (async function() {
33
+ await self.emitter.connect();
34
+ await self.receiver.connect();
35
+ callback();
36
+ })();
37
+ };
38
+
39
+ /**
40
+ * Subscribe to a channel
41
+ * @param {String} channel The channel to subscribe to, can be a pattern e.g. 'user.*'
42
+ * @param {Function} handler Function to call with the received message.
43
+ * @param {Function} cb Optional callback to call once the handler is registered.
44
+ */
45
+ NodeRedisPubsub.prototype.on = NodeRedisPubsub.prototype.subscribe = function(channel, handler, callback)
46
+ {
47
+ if (!callback)
48
+ {
49
+ callback = function(){};
50
+ }
51
+
52
+ var self = this;
53
+
54
+ if (channel === "error")
55
+ {
56
+ self.errorHandler = handler;
57
+ self.emitter.on("error", handler);
58
+ self.receiver.on("error", handler);
59
+ return callback();
60
+ }
61
+
62
+ var listener = function(self, handler)
63
+ {
64
+ return function(message, channel) {
65
+
66
+ var jsonmsg = message;
67
+ try{
68
+ jsonmsg = JSON.parse(message);
69
+ } catch (ex){
70
+ if(typeof self.errorHandler === 'function'){
71
+ return self.errorHandler("Invalid JSON received! Channel: " + self.prefix + channel + " Message: " + message);
72
+ }
73
+ }
74
+ return handler(jsonmsg, channel);
75
+ }
76
+ }(self, handler);
77
+
78
+ (async function() {
79
+ await self.receiver.pSubscribe(self.prefix + channel, listener);
80
+ })();
81
+
82
+ callback();
83
+ };
84
+
85
+ /**
86
+ * Emit an event
87
+ * @param {String} channel Channel on which to emit the message
88
+ * @param {Object} message
89
+ */
90
+ NodeRedisPubsub.prototype.emit = NodeRedisPubsub.prototype.publish = function (channel, message)
91
+ {
92
+ var self = this;
93
+
94
+ (async function() {
95
+ return await self.emitter.publish(self.prefix + channel, JSON.stringify(message));
96
+ })();
97
+ };
98
+
99
+ /**
100
+ * Safely close the redis connections 'soon'
101
+ */
102
+ NodeRedisPubsub.prototype.quit = function()
103
+ {
104
+ this.emitter.quit();
105
+ this.receiver.quit();
106
+ };
107
+
108
+ /**
109
+ * Dangerously close the redis connections immediately
110
+ */
111
+ NodeRedisPubsub.prototype.end = function()
112
+ {
113
+ this.emitter.end(true);
114
+ this.receiver.end(true);
115
+ };
116
+
117
+ module.exports = NodeRedisPubsub;
@@ -0,0 +1,64 @@
1
+ //var redis = require("redis");
2
+ var redisHelper = require("../util/redis");
3
+
4
+ var clients = {};
5
+
6
+ /**
7
+ * Redis client factory.
8
+ *
9
+ * @type {*}
10
+ */
11
+ exports = module.exports = {};
12
+
13
+ var create = exports.create = function(config, baseOptions, callback)
14
+ {
15
+ if (typeof(config) === "function") {
16
+ callback = config;
17
+ config = {};
18
+ baseOptions = {};
19
+ }
20
+
21
+ if (typeof(baseOptions) === "function") {
22
+ callback = baseOptions;
23
+ baseOptions = {};
24
+ }
25
+
26
+ if (!config) {
27
+ config = {};
28
+ }
29
+
30
+ if (!baseOptions) {
31
+ baseOptions = {};
32
+ }
33
+
34
+ var redisOptions = redisHelper.redisOptions(config);
35
+ if (baseOptions) {
36
+ for (var k in baseOptions) {
37
+ redisOptions[k] = baseOptions[k];
38
+ }
39
+ }
40
+
41
+ var url = redisOptions.url;
42
+
43
+ // cached client?
44
+ var client = clients[url];
45
+ if (client) {
46
+ return callback(null, client);
47
+ }
48
+
49
+ // connect
50
+ (async function() {
51
+ await redisHelper.createAndConnect(redisOptions, function(err, client) {
52
+
53
+ if (err) {
54
+ return callback(err);
55
+ }
56
+
57
+ // cache it
58
+ clients[url] = client;
59
+
60
+ // return
61
+ return callback(null, client);
62
+ });
63
+ })();
64
+ };