@plusscommunities/pluss-core-aws 2.0.25-auth.0 → 2.0.25-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 (90) hide show
  1. package/aws/getDefaultEmailAddress.js +21 -21
  2. package/aws/getEmailService.js +16 -16
  3. package/aws/getEmailServiceInfo.js +26 -26
  4. package/aws/sendEmail.js +31 -31
  5. package/config.js +1 -1
  6. package/db/activity/publishActivity.js +22 -22
  7. package/db/analytics/checkActivityExists.js +15 -15
  8. package/db/analytics/logAnalyticsActivity.js +69 -37
  9. package/db/analytics/scheduleOldAggregation.js +14 -14
  10. package/db/auth/getSiteSetting.js +12 -12
  11. package/db/auth/getSiteUserTypes.js +16 -16
  12. package/db/auth/getUserAuth.js +13 -13
  13. package/db/automatedactions/getActionBySiteTrigger.js +9 -9
  14. package/db/common/deleteRef.js +21 -21
  15. package/db/common/editRef.js +36 -36
  16. package/db/common/getRef.js +23 -23
  17. package/db/common/getTableCount.js +18 -18
  18. package/db/common/indexQuery.js +17 -17
  19. package/db/common/indexQueryRecursive.js +20 -20
  20. package/db/common/scanRef.js +18 -18
  21. package/db/common/scanRefRecursive.js +20 -20
  22. package/db/common/updateAttribute.js +27 -27
  23. package/db/common/updateRef.js +20 -20
  24. package/db/linkedUsers/getLinkedBy.js +21 -21
  25. package/db/linkedUsers/getLinkedTo.js +21 -21
  26. package/db/notifications/deleteNotificationsByEntity.js +21 -21
  27. package/db/notifications/getNotificationSetting.js +14 -14
  28. package/db/notifications/publishNotifications.js +39 -39
  29. package/db/scheduledActions/deleteActionQueue.js +1 -1
  30. package/db/scheduledActions/getActionQueueByEntityId.js +10 -10
  31. package/db/scheduledActions/getActionQueueByEntityKey.js +9 -9
  32. package/db/scheduledActions/getActionQueueById.js +9 -9
  33. package/db/scheduledActions/getActionQueueByTriggerAt.js +14 -14
  34. package/db/scheduledActions/updateActionQueue.js +29 -29
  35. package/db/strings/getString.js +20 -20
  36. package/db/strings/logUpdate.js +18 -18
  37. package/db/templates/getTemplateById.js +1 -1
  38. package/db/templates/getTemplatesList.js +10 -10
  39. package/db/templates/updateTemplate.js +9 -9
  40. package/db/users/getRole.js +1 -1
  41. package/db/users/getUser.js +9 -9
  42. package/db/users/getUserByEmail.js +17 -17
  43. package/helper/audience/filterByAudienceType.js +27 -27
  44. package/helper/audience/filterOnAudienceType.js +26 -26
  45. package/helper/audience/getAudience.js +187 -187
  46. package/helper/audience/getMatchingAudienceTypes.js +21 -21
  47. package/helper/audience/getMatchingAudienceTypesFromPreview.js +60 -60
  48. package/helper/audience/getMatchingTags.js +15 -15
  49. package/helper/audience/isValidAudience.js +20 -20
  50. package/helper/auth/checkTokenBlacklist.js +17 -17
  51. package/helper/auth/getApiKeyFromReq.js +2 -2
  52. package/helper/auth/getSessionUser.js +70 -85
  53. package/helper/auth/getSessionUserFromReq.js +2 -2
  54. package/helper/auth/getSessionUserFromReqAuthKey.js +11 -11
  55. package/helper/auth/validateApiKey.js +32 -32
  56. package/helper/auth/validateMasterAuth.js +174 -174
  57. package/helper/auth/validateSiteAccess.js +12 -12
  58. package/helper/auth/validateSiteSetting.js +7 -7
  59. package/helper/auth/validateUserLoggedIn.js +19 -19
  60. package/helper/createGuid.js +5 -5
  61. package/helper/generateJsonResponse.js +27 -27
  62. package/helper/getUserPreview.js +57 -57
  63. package/helper/getUserPreviewFromHeader.js +17 -17
  64. package/helper/getUserPreviewFromReq.js +17 -17
  65. package/helper/hqPublishing.js +337 -0
  66. package/helper/index.js +28 -28
  67. package/helper/notifySiteConfigs.js +132 -0
  68. package/helper/opengraph/getOpenGraph.js +12 -12
  69. package/helper/rates/checkRateLimit.js +38 -38
  70. package/helper/requestToSource.js +10 -10
  71. package/helper/sendEmail.js +120 -120
  72. package/helper/templates/replacePlaceHolders.js +29 -29
  73. package/helper/time/getLocalTimestamp.js +18 -18
  74. package/helper/time/getSiteTimezone.js +11 -11
  75. package/helper/triggerAutomatedAction.js +25 -25
  76. package/helper/userToUserPreview.js +23 -23
  77. package/helper/users/getUserTypesByPermission.js +24 -24
  78. package/helper/users/getUsersByPermission.js +20 -20
  79. package/notification/prepNotification.js +144 -144
  80. package/notification/sendNotifications.js +166 -166
  81. package/package.json +35 -40
  82. package/templates/supportTicketEmails.js +8 -8
  83. package/helper/auth/context/AuthenticationContext.js +0 -50
  84. package/helper/auth/context/AuthenticationStrategy.js +0 -20
  85. package/helper/auth/context/auth0/Strategy.js +0 -12
  86. package/helper/auth/context/auth0/functions/decodeAccessToken.js +0 -102
  87. package/helper/auth/context/auth0/functions/getSessionUser.js +0 -21
  88. package/helper/auth/context/boltonclarke/Strategy.js +0 -10
  89. package/helper/auth/context/cognito/Strategy.js +0 -12
  90. package/helper/auth/context/cognito/functions/getSessionUser.js +0 -76
@@ -1,21 +0,0 @@
1
- const decodeAccessToken = require("./decodeAccessToken");
2
- const { getConfig } = require("../../../../../config");
3
-
4
- // Function to validate the token and extract user information
5
- const getSessionUser = async (token) => {
6
- return new Promise((resolve, reject) => {
7
- decodeAccessToken(token)
8
- .then((claims) => {
9
- return resolve(
10
- claims[getConfig().auth0Config.residentIdClaim] ||
11
- claims[getConfig().auth0Config.staffIdClaim] ||
12
- claims[getConfig().auth0Config.userIdClaim]
13
- );
14
- })
15
- .catch((err) => {
16
- reject(err);
17
- });
18
- });
19
- };
20
-
21
- module.exports = getSessionUser;
@@ -1,10 +0,0 @@
1
- // auth0Strategy.js
2
- const Auth0Strategy = require("../auth0/Strategy");
3
-
4
- class BoltonClarkeStrategy extends Auth0Strategy {
5
- constructor() {
6
- super();
7
- }
8
- }
9
-
10
- module.exports = BoltonClarkeStrategy;
@@ -1,12 +0,0 @@
1
- // cognitoStrategy.js
2
- const AuthenticationStrategy = require("../AuthenticationStrategy");
3
- const getSessionUser = require("./functions/getSessionUser");
4
-
5
- class CognitoStrategy extends AuthenticationStrategy {
6
- constructor() {
7
- super();
8
- this.getSessionUser = getSessionUser;
9
- }
10
- }
11
-
12
- module.exports = CognitoStrategy;
@@ -1,76 +0,0 @@
1
- const https = require("https");
2
- const jose = require("node-jose");
3
-
4
- const { getConfig } = require("../../../../../config");
5
-
6
- module.exports = async (token) => {
7
- return new Promise((resolve, reject) => {
8
- if (!token) {
9
- return resolve(null);
10
- }
11
- var sections = token.split(".");
12
- // get the kid from the headers prior to verification
13
- var header = jose.util.base64url.decode(sections[0]);
14
- header = JSON.parse(header);
15
- var kid = header.kid;
16
- // download the public keys
17
- https.get(getConfig().keys_url, async (response) => {
18
- if (response.statusCode == 200) {
19
- response.on("data", async (body) => {
20
- var keys = JSON.parse(body)["keys"];
21
- // search for the kid in the downloaded public keys
22
- var key_index = -1;
23
- for (var i = 0; i < keys.length; i++) {
24
- if (kid == keys[i].kid) {
25
- key_index = i;
26
- break;
27
- }
28
- }
29
- if (key_index == -1) {
30
- reject();
31
- return;
32
- }
33
- // construct the public key
34
- jose.JWK.asKey(keys[key_index])
35
- .then(async (result) => {
36
- // verify the signature
37
- jose.JWS.createVerify(result)
38
- .verify(token)
39
- .then(async (result2) => {
40
- // now we can use the claims
41
- var claims = JSON.parse(result2.payload);
42
- // additionally we can verify the token expiration
43
- var current_ts = Math.floor(new Date() / 1000);
44
- if (current_ts > claims.exp) {
45
- console.log("Token is expired");
46
- reject("Token is expired");
47
- return;
48
- }
49
-
50
- // const isDisabled = await isUserDisabled(claims.username);
51
-
52
- // if (isDisabled) {
53
- // console.log("User is disabled");
54
- // reject("User is disabled");
55
- // return;
56
- // }
57
-
58
- resolve(claims.username);
59
- })
60
- .catch(async (error) => {
61
- console.log("Signature verification failed", error);
62
- reject("Signature verification failed");
63
- });
64
- })
65
- .catch(async (error) => {
66
- console.log("failed JWK.asKey", error);
67
- reject(error);
68
- });
69
- });
70
- } else {
71
- console.log("failed on response", response);
72
- reject(response);
73
- }
74
- });
75
- });
76
- };