@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.
- package/aws/getDefaultEmailAddress.js +21 -21
- package/aws/getEmailService.js +16 -16
- package/aws/getEmailServiceInfo.js +26 -26
- package/aws/sendEmail.js +31 -31
- package/config.js +1 -1
- package/db/activity/publishActivity.js +22 -22
- package/db/analytics/checkActivityExists.js +15 -15
- package/db/analytics/logAnalyticsActivity.js +69 -37
- package/db/analytics/scheduleOldAggregation.js +14 -14
- package/db/auth/getSiteSetting.js +12 -12
- package/db/auth/getSiteUserTypes.js +16 -16
- package/db/auth/getUserAuth.js +13 -13
- package/db/automatedactions/getActionBySiteTrigger.js +9 -9
- package/db/common/deleteRef.js +21 -21
- package/db/common/editRef.js +36 -36
- package/db/common/getRef.js +23 -23
- package/db/common/getTableCount.js +18 -18
- package/db/common/indexQuery.js +17 -17
- package/db/common/indexQueryRecursive.js +20 -20
- package/db/common/scanRef.js +18 -18
- package/db/common/scanRefRecursive.js +20 -20
- package/db/common/updateAttribute.js +27 -27
- package/db/common/updateRef.js +20 -20
- package/db/linkedUsers/getLinkedBy.js +21 -21
- package/db/linkedUsers/getLinkedTo.js +21 -21
- package/db/notifications/deleteNotificationsByEntity.js +21 -21
- package/db/notifications/getNotificationSetting.js +14 -14
- package/db/notifications/publishNotifications.js +39 -39
- package/db/scheduledActions/deleteActionQueue.js +1 -1
- package/db/scheduledActions/getActionQueueByEntityId.js +10 -10
- package/db/scheduledActions/getActionQueueByEntityKey.js +9 -9
- package/db/scheduledActions/getActionQueueById.js +9 -9
- package/db/scheduledActions/getActionQueueByTriggerAt.js +14 -14
- package/db/scheduledActions/updateActionQueue.js +29 -29
- package/db/strings/getString.js +20 -20
- package/db/strings/logUpdate.js +18 -18
- package/db/templates/getTemplateById.js +1 -1
- package/db/templates/getTemplatesList.js +10 -10
- package/db/templates/updateTemplate.js +9 -9
- package/db/users/getRole.js +1 -1
- package/db/users/getUser.js +9 -9
- package/db/users/getUserByEmail.js +17 -17
- package/helper/audience/filterByAudienceType.js +27 -27
- package/helper/audience/filterOnAudienceType.js +26 -26
- package/helper/audience/getAudience.js +187 -187
- package/helper/audience/getMatchingAudienceTypes.js +21 -21
- package/helper/audience/getMatchingAudienceTypesFromPreview.js +60 -60
- package/helper/audience/getMatchingTags.js +15 -15
- package/helper/audience/isValidAudience.js +20 -20
- package/helper/auth/checkTokenBlacklist.js +17 -17
- package/helper/auth/getApiKeyFromReq.js +2 -2
- package/helper/auth/getSessionUser.js +70 -85
- package/helper/auth/getSessionUserFromReq.js +2 -2
- package/helper/auth/getSessionUserFromReqAuthKey.js +11 -11
- package/helper/auth/validateApiKey.js +32 -32
- package/helper/auth/validateMasterAuth.js +174 -174
- package/helper/auth/validateSiteAccess.js +12 -12
- package/helper/auth/validateSiteSetting.js +7 -7
- package/helper/auth/validateUserLoggedIn.js +19 -19
- package/helper/createGuid.js +5 -5
- package/helper/generateJsonResponse.js +27 -27
- package/helper/getUserPreview.js +57 -57
- package/helper/getUserPreviewFromHeader.js +17 -17
- package/helper/getUserPreviewFromReq.js +17 -17
- package/helper/hqPublishing.js +337 -0
- package/helper/index.js +28 -28
- package/helper/notifySiteConfigs.js +132 -0
- package/helper/opengraph/getOpenGraph.js +12 -12
- package/helper/rates/checkRateLimit.js +38 -38
- package/helper/requestToSource.js +10 -10
- package/helper/sendEmail.js +120 -120
- package/helper/templates/replacePlaceHolders.js +29 -29
- package/helper/time/getLocalTimestamp.js +18 -18
- package/helper/time/getSiteTimezone.js +11 -11
- package/helper/triggerAutomatedAction.js +25 -25
- package/helper/userToUserPreview.js +23 -23
- package/helper/users/getUserTypesByPermission.js +24 -24
- package/helper/users/getUsersByPermission.js +20 -20
- package/notification/prepNotification.js +144 -144
- package/notification/sendNotifications.js +166 -166
- package/package.json +35 -40
- package/templates/supportTicketEmails.js +8 -8
- package/helper/auth/context/AuthenticationContext.js +0 -50
- package/helper/auth/context/AuthenticationStrategy.js +0 -20
- package/helper/auth/context/auth0/Strategy.js +0 -12
- package/helper/auth/context/auth0/functions/decodeAccessToken.js +0 -102
- package/helper/auth/context/auth0/functions/getSessionUser.js +0 -21
- package/helper/auth/context/boltonclarke/Strategy.js +0 -10
- package/helper/auth/context/cognito/Strategy.js +0 -12
- 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,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
|
-
};
|