cloudcms-server 3.3.1-beta.8 → 4.0.0-beta.1

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/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 +26 -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 +63 -10
  42. package/middleware/proxy/proxy.js +8 -21
  43. package/middleware/stores/stores.js +48 -5
  44. package/middleware/themes/themes.js +49 -0
  45. package/middleware/virtual-config/virtual-config.js +11 -8
  46. package/middleware/wcm/wcm.js +4 -4
  47. package/notifications/notifications.js +27 -4
  48. package/package.json +30 -25
  49. package/server/index.js +508 -412
  50. package/server/standalone.js +9 -0
  51. package/temp/clusterlock/index.js +3 -3
  52. package/temp/clusterlock/package.json +1 -1
  53. package/temp/passport-saml/LICENSE +23 -0
  54. package/temp/passport-saml/README.md +406 -0
  55. package/temp/passport-saml/lib/node-saml/algorithms.d.ts +5 -0
  56. package/temp/passport-saml/lib/node-saml/algorithms.js +41 -0
  57. package/temp/passport-saml/lib/node-saml/algorithms.js.map +1 -0
  58. package/temp/passport-saml/lib/node-saml/index.d.ts +3 -0
  59. package/temp/passport-saml/lib/node-saml/index.js +6 -0
  60. package/temp/passport-saml/lib/node-saml/index.js.map +1 -0
  61. package/temp/passport-saml/lib/node-saml/inmemory-cache-provider.d.ts +45 -0
  62. package/temp/passport-saml/lib/node-saml/inmemory-cache-provider.js +86 -0
  63. package/temp/passport-saml/lib/node-saml/inmemory-cache-provider.js.map +1 -0
  64. package/temp/passport-saml/lib/node-saml/saml-post-signing.d.ts +3 -0
  65. package/temp/passport-saml/lib/node-saml/saml-post-signing.js +15 -0
  66. package/temp/passport-saml/lib/node-saml/saml-post-signing.js.map +1 -0
  67. package/temp/passport-saml/lib/node-saml/saml.d.ts +77 -0
  68. package/temp/passport-saml/lib/node-saml/saml.js +1170 -0
  69. package/temp/passport-saml/lib/node-saml/saml.js.map +1 -0
  70. package/temp/passport-saml/lib/node-saml/types.d.ts +95 -0
  71. package/temp/passport-saml/lib/node-saml/types.js +8 -0
  72. package/temp/passport-saml/lib/node-saml/types.js.map +1 -0
  73. package/temp/passport-saml/lib/node-saml/utility.d.ts +3 -0
  74. package/temp/passport-saml/lib/node-saml/utility.js +19 -0
  75. package/temp/passport-saml/lib/node-saml/utility.js.map +1 -0
  76. package/temp/passport-saml/lib/node-saml/xml.d.ts +21 -0
  77. package/temp/passport-saml/lib/node-saml/xml.js +140 -0
  78. package/temp/passport-saml/lib/node-saml/xml.js.map +1 -0
  79. package/temp/passport-saml/lib/passport-saml/index.d.ts +6 -0
  80. package/temp/passport-saml/lib/passport-saml/index.js +11 -0
  81. package/temp/passport-saml/lib/passport-saml/index.js.map +1 -0
  82. package/temp/passport-saml/lib/passport-saml/multiSamlStrategy.d.ts +13 -0
  83. package/temp/passport-saml/lib/passport-saml/multiSamlStrategy.js +63 -0
  84. package/temp/passport-saml/lib/passport-saml/multiSamlStrategy.js.map +1 -0
  85. package/temp/passport-saml/lib/passport-saml/strategy.d.ts +20 -0
  86. package/temp/passport-saml/lib/passport-saml/strategy.js +167 -0
  87. package/temp/passport-saml/lib/passport-saml/strategy.js.map +1 -0
  88. package/temp/passport-saml/lib/passport-saml/types.d.ts +51 -0
  89. package/temp/passport-saml/lib/passport-saml/types.js +11 -0
  90. package/temp/passport-saml/lib/passport-saml/types.js.map +1 -0
  91. package/temp/passport-saml/package.json +96 -0
  92. package/util/auth.js +6 -6
  93. package/util/cloudcms.js +85 -88
  94. package/util/proxy-factory.js +159 -268
  95. package/util/redis.js +113 -0
  96. package/util/renditions.js +12 -6
  97. package/util/request.js +48 -12
  98. package/util/util.js +16 -2
  99. package/launchpad/launchers/sticky-cluster.js +0 -43
  100. package/temp/memored/.jshintrc +0 -4
  101. package/temp/memored/README.md +0 -240
  102. package/temp/memored/demo/demo1.js +0 -37
  103. package/temp/memored/demo/demo2.js +0 -32
  104. package/temp/memored/gulpfile.js +0 -8
  105. package/temp/memored/index.js +0 -343
  106. package/temp/memored/package.json +0 -54
  107. package/temp/memored/spec/memored.spec.js +0 -265
  108. package/web/cms/ice.js +0 -109
  109. package/web/cms/preview.js +0 -106
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ /**
3
+ * Simple in memory cache provider. To be used to store state of requests that needs
4
+ * to be validated/checked when a response is received.
5
+ *
6
+ * This is the default implementation of a cache provider used by Passport-SAML. For
7
+ * multiple server instances/load balanced scenarios (I.e. the SAML request could have
8
+ * been generated from a different server/process handling the SAML response) this
9
+ * implementation will NOT be sufficient.
10
+ *
11
+ * The caller should provide their own implementation for a cache provider as defined
12
+ * in the config options for Passport-SAML.
13
+ * @param options
14
+ * @constructor
15
+ */
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.CacheProvider = void 0;
18
+ class CacheProvider {
19
+ constructor(options) {
20
+ var _a;
21
+ this.cacheKeys = {};
22
+ this.options = {
23
+ ...options,
24
+ keyExpirationPeriodMs: (_a = options === null || options === void 0 ? void 0 : options.keyExpirationPeriodMs) !== null && _a !== void 0 ? _a : 28800000, // 8 hours,
25
+ };
26
+ // Expire old cache keys
27
+ const expirationTimer = setInterval(() => {
28
+ const nowMs = new Date().getTime();
29
+ const keys = Object.keys(this.cacheKeys);
30
+ keys.forEach((key) => {
31
+ if (nowMs >=
32
+ new Date(this.cacheKeys[key].createdAt).getTime() + this.options.keyExpirationPeriodMs) {
33
+ this.removeAsync(key);
34
+ }
35
+ });
36
+ }, this.options.keyExpirationPeriodMs);
37
+ // we only want this to run if the process is still open; it shouldn't hold the process open (issue #68)
38
+ expirationTimer.unref();
39
+ }
40
+ /**
41
+ * Store an item in the cache, using the specified key and value.
42
+ * Internally will keep track of the time the item was added to the cache
43
+ * @param id
44
+ * @param value
45
+ */
46
+ async saveAsync(key, value) {
47
+ if (!this.cacheKeys[key]) {
48
+ this.cacheKeys[key] = {
49
+ createdAt: new Date().getTime(),
50
+ value: value,
51
+ };
52
+ return this.cacheKeys[key];
53
+ }
54
+ else {
55
+ return null;
56
+ }
57
+ }
58
+ /**
59
+ * Returns the value of the specified key in the cache
60
+ * @param id
61
+ * @returns {boolean}
62
+ */
63
+ async getAsync(key) {
64
+ if (this.cacheKeys[key]) {
65
+ return this.cacheKeys[key].value;
66
+ }
67
+ else {
68
+ return null;
69
+ }
70
+ }
71
+ /**
72
+ * Removes an item from the cache if it exists
73
+ * @param key
74
+ */
75
+ async removeAsync(key) {
76
+ if (this.cacheKeys[key]) {
77
+ delete this.cacheKeys[key];
78
+ return key;
79
+ }
80
+ else {
81
+ return null;
82
+ }
83
+ }
84
+ }
85
+ exports.CacheProvider = CacheProvider;
86
+ //# sourceMappingURL=inmemory-cache-provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inmemory-cache-provider.js","sourceRoot":"","sources":["../../src/node-saml/inmemory-cache-provider.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;GAaG;;;AAWH,MAAa,aAAa;IAIxB,YAAY,OAAsC;;QAChD,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;QAEpB,IAAI,CAAC,OAAO,GAAG;YACb,GAAG,OAAO;YACV,qBAAqB,EAAE,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,qBAAqB,mCAAI,QAAQ,EAAE,WAAW;SAC/E,CAAC;QAEF,wBAAwB;QACxB,MAAM,eAAe,GAAG,WAAW,CAAC,GAAG,EAAE;YACvC,MAAM,KAAK,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC;YACnC,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YACzC,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;gBACnB,IACE,KAAK;oBACL,IAAI,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,qBAAqB,EACtF;oBACA,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;iBACvB;YACH,CAAC,CAAC,CAAC;QACL,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC;QAEvC,wGAAwG;QACxG,eAAe,CAAC,KAAK,EAAE,CAAC;IAC1B,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,SAAS,CAAC,GAAW,EAAE,KAAa;QACxC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE;YACxB,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG;gBACpB,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE;gBAC/B,KAAK,EAAE,KAAK;aACb,CAAC;YACF,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;SAC5B;aAAM;YACL,OAAO,IAAI,CAAC;SACb;IACH,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,QAAQ,CAAC,GAAW;QACxB,IAAI,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE;YACvB,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC;SAClC;aAAM;YACL,OAAO,IAAI,CAAC;SACb;IACH,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,WAAW,CAAC,GAAW;QAC3B,IAAI,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE;YACvB,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;YAC3B,OAAO,GAAG,CAAC;SACZ;aAAM;YACL,OAAO,IAAI,CAAC;SACb;IACH,CAAC;CACF;AAzED,sCAyEC","sourcesContent":["/**\n * Simple in memory cache provider. To be used to store state of requests that needs\n * to be validated/checked when a response is received.\n *\n * This is the default implementation of a cache provider used by Passport-SAML. For\n * multiple server instances/load balanced scenarios (I.e. the SAML request could have\n * been generated from a different server/process handling the SAML response) this\n * implementation will NOT be sufficient.\n *\n * The caller should provide their own implementation for a cache provider as defined\n * in the config options for Passport-SAML.\n * @param options\n * @constructor\n */\n\nexport interface CacheItem {\n value: string;\n createdAt: number;\n}\n\ninterface CacheProviderOptions {\n keyExpirationPeriodMs: number;\n}\n\nexport class CacheProvider {\n cacheKeys: Record<string, CacheItem>;\n options: CacheProviderOptions;\n\n constructor(options: Partial<CacheProviderOptions>) {\n this.cacheKeys = {};\n\n this.options = {\n ...options,\n keyExpirationPeriodMs: options?.keyExpirationPeriodMs ?? 28800000, // 8 hours,\n };\n\n // Expire old cache keys\n const expirationTimer = setInterval(() => {\n const nowMs = new Date().getTime();\n const keys = Object.keys(this.cacheKeys);\n keys.forEach((key) => {\n if (\n nowMs >=\n new Date(this.cacheKeys[key].createdAt).getTime() + this.options.keyExpirationPeriodMs\n ) {\n this.removeAsync(key);\n }\n });\n }, this.options.keyExpirationPeriodMs);\n\n // we only want this to run if the process is still open; it shouldn't hold the process open (issue #68)\n expirationTimer.unref();\n }\n\n /**\n * Store an item in the cache, using the specified key and value.\n * Internally will keep track of the time the item was added to the cache\n * @param id\n * @param value\n */\n async saveAsync(key: string, value: string): Promise<CacheItem | null> {\n if (!this.cacheKeys[key]) {\n this.cacheKeys[key] = {\n createdAt: new Date().getTime(),\n value: value,\n };\n return this.cacheKeys[key];\n } else {\n return null;\n }\n }\n\n /**\n * Returns the value of the specified key in the cache\n * @param id\n * @returns {boolean}\n */\n async getAsync(key: string): Promise<string | null> {\n if (this.cacheKeys[key]) {\n return this.cacheKeys[key].value;\n } else {\n return null;\n }\n }\n\n /**\n * Removes an item from the cache if it exists\n * @param key\n */\n async removeAsync(key: string): Promise<string | null> {\n if (this.cacheKeys[key]) {\n delete this.cacheKeys[key];\n return key;\n } else {\n return null;\n }\n }\n}\n"]}
@@ -0,0 +1,3 @@
1
+ import { SamlSigningOptions } from "./types";
2
+ export declare function signSamlPost(samlMessage: string, xpath: string, options: SamlSigningOptions): string;
3
+ export declare function signAuthnRequestPost(authnRequest: string, options: SamlSigningOptions): string;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.signAuthnRequestPost = exports.signSamlPost = void 0;
4
+ const xml_1 = require("./xml");
5
+ const authnRequestXPath = '/*[local-name(.)="AuthnRequest" and namespace-uri(.)="urn:oasis:names:tc:SAML:2.0:protocol"]';
6
+ const issuerXPath = '/*[local-name(.)="Issuer" and namespace-uri(.)="urn:oasis:names:tc:SAML:2.0:assertion"]';
7
+ function signSamlPost(samlMessage, xpath, options) {
8
+ return (0, xml_1.signXml)(samlMessage, xpath, { reference: xpath + issuerXPath, action: "after" }, options);
9
+ }
10
+ exports.signSamlPost = signSamlPost;
11
+ function signAuthnRequestPost(authnRequest, options) {
12
+ return signSamlPost(authnRequest, authnRequestXPath, options);
13
+ }
14
+ exports.signAuthnRequestPost = signAuthnRequestPost;
15
+ //# sourceMappingURL=saml-post-signing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"saml-post-signing.js","sourceRoot":"","sources":["../../src/node-saml/saml-post-signing.ts"],"names":[],"mappings":";;;AACA,+BAAgC;AAEhC,MAAM,iBAAiB,GACrB,8FAA8F,CAAC;AACjG,MAAM,WAAW,GACf,yFAAyF,CAAC;AAE5F,SAAgB,YAAY,CAC1B,WAAmB,EACnB,KAAa,EACb,OAA2B;IAE3B,OAAO,IAAA,aAAO,EAAC,WAAW,EAAE,KAAK,EAAE,EAAE,SAAS,EAAE,KAAK,GAAG,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,OAAO,CAAC,CAAC;AACnG,CAAC;AAND,oCAMC;AAED,SAAgB,oBAAoB,CAAC,YAAoB,EAAE,OAA2B;IACpF,OAAO,YAAY,CAAC,YAAY,EAAE,iBAAiB,EAAE,OAAO,CAAC,CAAC;AAChE,CAAC;AAFD,oDAEC","sourcesContent":["import { SamlSigningOptions } from \"./types\";\nimport { signXml } from \"./xml\";\n\nconst authnRequestXPath =\n '/*[local-name(.)=\"AuthnRequest\" and namespace-uri(.)=\"urn:oasis:names:tc:SAML:2.0:protocol\"]';\nconst issuerXPath =\n '/*[local-name(.)=\"Issuer\" and namespace-uri(.)=\"urn:oasis:names:tc:SAML:2.0:assertion\"]';\n\nexport function signSamlPost(\n samlMessage: string,\n xpath: string,\n options: SamlSigningOptions\n): string {\n return signXml(samlMessage, xpath, { reference: xpath + issuerXPath, action: \"after\" }, options);\n}\n\nexport function signAuthnRequestPost(authnRequest: string, options: SamlSigningOptions): string {\n return signSamlPost(authnRequest, authnRequestXPath, options);\n}\n"]}
@@ -0,0 +1,77 @@
1
+ /// <reference types="node" />
2
+ import * as querystring from "querystring";
3
+ import { CacheProvider as InMemoryCacheProvider } from "./inmemory-cache-provider";
4
+ import { ParsedQs } from "qs";
5
+ import { SamlOptions } from "./types";
6
+ import { AuthenticateOptions, AuthorizeOptions, Profile, SamlConfig } from "../passport-saml/types";
7
+ interface NameID {
8
+ value: string | null;
9
+ format: string | null;
10
+ }
11
+ declare class SAML {
12
+ options: SamlOptions;
13
+ cacheProvider: InMemoryCacheProvider;
14
+ constructor(ctorOptions: SamlConfig);
15
+ initialize(ctorOptions: SamlConfig): SamlOptions;
16
+ private getCallbackUrl;
17
+ _generateUniqueID(): string;
18
+ private generateInstant;
19
+ private signRequest;
20
+ private generateAuthorizeRequestAsync;
21
+ _generateLogoutRequest(user: Profile): Promise<string>;
22
+ _generateLogoutResponse(logoutRequest: Profile): string;
23
+ _requestToUrlAsync(request: string | null | undefined, response: string | null, operation: string, additionalParameters: querystring.ParsedUrlQuery): Promise<string>;
24
+ _getAdditionalParams(RelayState: string, operation: string, overrideParams?: querystring.ParsedUrlQuery): querystring.ParsedUrlQuery;
25
+ getAuthorizeUrlAsync(RelayState: string, host: string | undefined, options: AuthorizeOptions): Promise<string>;
26
+ getAuthorizeFormAsync(RelayState: string, host?: string): Promise<string>;
27
+ getLogoutUrlAsync(user: Profile, RelayState: string, options: AuthenticateOptions & AuthorizeOptions): Promise<string>;
28
+ getLogoutResponseUrl(samlLogoutRequest: Profile, RelayState: string, options: AuthenticateOptions & AuthorizeOptions, callback: (err: Error | null, url?: string | null) => void): void;
29
+ private getLogoutResponseUrlAsync;
30
+ _certToPEM(cert: string): string;
31
+ private certsToCheck;
32
+ validateSignature(fullXml: string, currentNode: Element, certs: string[]): boolean;
33
+ validatePostResponseAsync(container: Record<string, string>): Promise<{
34
+ profile?: Profile | null;
35
+ loggedOut?: boolean;
36
+ }>;
37
+ private validateInResponseTo;
38
+ validateRedirectAsync(container: ParsedQs, originalQuery: string | null): Promise<{
39
+ profile?: Profile | null;
40
+ loggedOut?: boolean;
41
+ }>;
42
+ private hasValidSignatureForRedirect;
43
+ private validateSignatureForRedirect;
44
+ private verifyLogoutRequest;
45
+ private verifyLogoutResponse;
46
+ private verifyIssuer;
47
+ private processValidlySignedAssertionAsync;
48
+ private checkTimestampsValidityError;
49
+ private checkAudienceValidityError;
50
+ validatePostRequestAsync(container: Record<string, string>): Promise<{
51
+ profile?: Profile;
52
+ loggedOut?: boolean;
53
+ }>;
54
+ _getNameIdAsync(self: SAML, doc: Node): Promise<NameID>;
55
+ generateServiceProviderMetadata(decryptionCert: string | null, signingCert?: string | null): string;
56
+ _keyToPEM(key: string | Buffer): typeof key extends string | Buffer ? string | Buffer : Error;
57
+ /**
58
+ * Process max age assertion and use it if it is more restrictive than the NotOnOrAfter age
59
+ * assertion received in the SAMLResponse.
60
+ *
61
+ * @param maxAssertionAgeMs Max time after IssueInstant that we will accept assertion, in Ms.
62
+ * @param notOnOrAfter Expiration provided in response.
63
+ * @param issueInstant Time when response was issued.
64
+ * @returns {*} The expiration time to be used, in Ms.
65
+ */
66
+ private processMaxAgeAssertionTime;
67
+ /**
68
+ * Convert a date string to a timestamp (in milliseconds).
69
+ *
70
+ * @param dateString A string representation of a date
71
+ * @param label Descriptive name of the date being passed in, e.g. "NotOnOrAfter"
72
+ * @throws Will throw an error if parsing `dateString` returns `NaN`
73
+ * @returns {number} The timestamp (in milliseconds) representation of the given date
74
+ */
75
+ private dateStringToTimestamp;
76
+ }
77
+ export { SAML };