@plusscommunities/pluss-core-aws 2.0.8 → 2.0.9-auth.0

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.
@@ -0,0 +1,29 @@
1
+ const indexQuery = require("../common/indexQuery");
2
+ const deleteRef = require("../common/deleteRef");
3
+
4
+ module.exports = async (entityId, type = null, site = null) => {
5
+ const query = {
6
+ IndexName: "NotificationsIdIndex",
7
+ KeyConditionExpression: "Id = :entityId",
8
+ ExpressionAttributeValues: {
9
+ ":entityId": entityId,
10
+ },
11
+ };
12
+
13
+ let toDelete = [];
14
+ const { Items } = await indexQuery("notifications", query);
15
+ if (type || site) {
16
+ toDelete = Items.filter(
17
+ (i) => (!type || i.Type === type) && (!site || i.Site === site)
18
+ );
19
+ } else {
20
+ toDelete = Items;
21
+ }
22
+
23
+ const promises = [];
24
+ toDelete.forEach((i) => {
25
+ promises.push(deleteRef("notifications", "RowId", i.RowId));
26
+ });
27
+
28
+ return Promise.all(promises);
29
+ };
@@ -0,0 +1,50 @@
1
+ const Auth0Strategy = require("./auth0/Strategy");
2
+ const CognitoStrategy = require("./cognito/Strategy");
3
+ const BoltonClarkeStrategy = require("./boltonclarke/Strategy");
4
+ const { getConfig } = require("../../../config");
5
+
6
+ class AuthenticationContext {
7
+ static strategy = null;
8
+
9
+ static initialiseStrategy() {
10
+ switch (getConfig().authConfig.provider) {
11
+ case "auth0":
12
+ AuthenticationContext.strategy = new Auth0Strategy();
13
+ break;
14
+ case "boltonclarke":
15
+ AuthenticationContext.strategy = new BoltonClarkeStrategy();
16
+ break;
17
+ case "cognito":
18
+ AuthenticationContext.strategy = new CognitoStrategy();
19
+ break;
20
+ default:
21
+ throw new Error("Invalid authentication provider specified");
22
+ }
23
+ }
24
+
25
+ static getSessionUser = async (token) => {
26
+ if (!AuthenticationContext.strategy) {
27
+ AuthenticationContext.initialiseStrategy();
28
+ }
29
+ return AuthenticationContext.strategy.getSessionUser(token);
30
+ };
31
+
32
+ static populateUser = async (token) => {
33
+ if (!AuthenticationContext.strategy) {
34
+ AuthenticationContext.initialiseStrategy();
35
+ }
36
+ return AuthenticationContext.strategy.populateUser(token);
37
+ };
38
+
39
+ static updateIdentityAttributes = async (input, userId) => {
40
+ if (!AuthenticationContext.strategy) {
41
+ AuthenticationContext.initialiseStrategy();
42
+ }
43
+ return AuthenticationContext.strategy.updateIdentityAttributes(
44
+ input,
45
+ userId
46
+ );
47
+ };
48
+ }
49
+
50
+ module.exports = AuthenticationContext;
@@ -0,0 +1,20 @@
1
+ // Authentication Strategy Interface
2
+ class AuthenticationStrategy {
3
+ constructor() {}
4
+
5
+ getSessionUser(token) {
6
+ throw new Error("Method 'getSessionUser()' must be implemented.");
7
+ }
8
+
9
+ // optional function to populate user data based on a token
10
+ populateUser(token) {
11
+ return;
12
+ }
13
+
14
+ // optional function to save attributes to identity provider
15
+ updateIdentityAttributes = async (input, userId) => {
16
+ return;
17
+ };
18
+ }
19
+
20
+ module.exports = AuthenticationStrategy;
@@ -0,0 +1,12 @@
1
+ // auth0Strategy.js
2
+ const AuthenticationStrategy = require("../AuthenticationStrategy");
3
+ const getSessionUser = require("./functions/getSessionUser");
4
+
5
+ class Auth0Strategy extends AuthenticationStrategy {
6
+ constructor() {
7
+ super();
8
+ this.getSessionUser = getSessionUser;
9
+ }
10
+ }
11
+
12
+ module.exports = Auth0Strategy;
@@ -0,0 +1,45 @@
1
+ const jwt = require("jsonwebtoken");
2
+ const jwksClient = require("jwks-rsa");
3
+
4
+ const { getConfig } = require("../../../../../config");
5
+
6
+ // Function to retrieve the signing key from Auth0 JWKS
7
+ const getKey = (header, callback) => {
8
+ // Initialize JWKS client
9
+ const client = jwksClient({
10
+ jwksUri: `https://${getConfig().auth0Config.domain}/.well-known/jwks.json`,
11
+ });
12
+
13
+ client.getSigningKey(header.kid, (err, key) => {
14
+ if (err) {
15
+ callback(err, null);
16
+ } else {
17
+ const signingKey = key.publicKey || key.rsaPublicKey;
18
+ callback(null, signingKey);
19
+ }
20
+ });
21
+ };
22
+
23
+ // Function to validate the token and extract user information
24
+ const decodeAccessToken = async (token) => {
25
+ return new Promise((resolve, reject) => {
26
+ jwt.verify(
27
+ token,
28
+ getKey,
29
+ {
30
+ audience: getConfig().auth0Config.audience,
31
+ issuer: `https://${getConfig().auth0Config.domain}/`,
32
+ algorithms: ["RS256"],
33
+ },
34
+ (err, decoded) => {
35
+ if (err) {
36
+ reject(err);
37
+ } else {
38
+ resolve(decoded); // 'sub' contains the user ID
39
+ }
40
+ }
41
+ );
42
+ });
43
+ };
44
+
45
+ module.exports = decodeAccessToken;
@@ -0,0 +1,21 @@
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;
@@ -0,0 +1,10 @@
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;
@@ -0,0 +1,12 @@
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;
@@ -0,0 +1,76 @@
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
+ };
@@ -0,0 +1,6 @@
1
+ const getRef = require("../../db/common/getRef");
2
+
3
+ module.exports = async (event) => {
4
+ if (!event?.headers?.apikey) return null;
5
+ return await getRef("accesskeys", "Key", event.headers.apikey);
6
+ };
@@ -1,63 +1,90 @@
1
- const https = require("https");
2
- const jose = require("node-jose");
3
- const { getConfig } = require("../../config");
1
+ // const https = require("https");
2
+ // const jose = require("node-jose");
3
+ // const { app_client_id, keys_url } = require("../../../config");
4
+ // const isUserDisabled = require("./isUserDisabled");
5
+ const { log } = require("..");
6
+ const AuthenticationContext = require("./context/AuthenticationContext");
4
7
 
5
8
  module.exports = async (token) => {
6
- return new Promise((resolve, reject) => {
7
- var sections = token.split(".");
8
- // get the kid from the headers prior to verification
9
- var header = jose.util.base64url.decode(sections[0]);
10
- header = JSON.parse(header);
11
- var kid = header.kid;
12
- // download the public keys
13
- https.get(getConfig().keys_url, function (response) {
14
- if (response.statusCode == 200) {
15
- response.on("data", function (body) {
16
- var keys = JSON.parse(body)["keys"];
17
- // search for the kid in the downloaded public keys
18
- var key_index = -1;
19
- for (var i = 0; i < keys.length; i++) {
20
- if (kid == keys[i].kid) {
21
- key_index = i;
22
- break;
23
- }
24
- }
25
- if (key_index == -1) {
26
- reject();
27
- return;
28
- }
29
- // construct the public key
30
- jose.JWK.asKey(keys[key_index])
31
- .then(function (result) {
32
- // verify the signature
33
- jose.JWS.createVerify(result)
34
- .verify(token)
35
- .then(function (result2) {
36
- // now we can use the claims
37
- var claims = JSON.parse(result2.payload);
38
- // additionally we can verify the token expiration
39
- var current_ts = Math.floor(new Date() / 1000);
40
- if (current_ts > claims.exp) {
41
- console.log("Token is expired");
42
- reject("Token is expired");
43
- return;
44
- }
45
- resolve(claims.username);
46
- })
47
- .catch(function (error) {
48
- console.log("Signature verification failed", error);
49
- reject("Signature verification failed");
50
- });
51
- })
52
- .catch(function (error) {
53
- console.log("failed JWK.asKey", error);
54
- reject(error);
55
- });
56
- });
57
- } else {
58
- console.log("failed on response", response);
59
- reject(response);
60
- }
61
- });
62
- });
9
+ const logId = log("getSessionUser", "Start", true);
10
+ const userId = await AuthenticationContext.getSessionUser(token);
11
+ log("getSessionUser", "Result", userId, logId);
12
+ return userId;
13
+ // return new Promise((resolve, reject) => {
14
+ // if (!token) {
15
+ // return resolve(null);
16
+ // }
17
+ // var sections = token.split(".");
18
+ // // get the kid from the headers prior to verification
19
+ // var header = jose.util.base64url.decode(sections[0]);
20
+ // header = JSON.parse(header);
21
+ // var kid = header.kid;
22
+ // // download the public keys
23
+ // https.get(keys_url, async (response) => {
24
+ // if (response.statusCode == 200) {
25
+ // response.on("data", async (body) => {
26
+ // var keys = JSON.parse(body)["keys"];
27
+ // // search for the kid in the downloaded public keys
28
+ // var key_index = -1;
29
+ // for (var i = 0; i < keys.length; i++) {
30
+ // if (kid == keys[i].kid) {
31
+ // key_index = i;
32
+ // break;
33
+ // }
34
+ // }
35
+ // if (key_index == -1) {
36
+ // reject();
37
+ // return;
38
+ // }
39
+ // // construct the public key
40
+ // jose.JWK.asKey(keys[key_index])
41
+ // .then(async (result) => {
42
+ // // verify the signature
43
+ // jose.JWS.createVerify(result)
44
+ // .verify(token)
45
+ // .then(async (result2) => {
46
+ // // now we can use the claims
47
+ // var claims = JSON.parse(result2.payload);
48
+ // // additionally we can verify the token expiration
49
+ // var current_ts = Math.floor(new Date() / 1000);
50
+ // if (current_ts > claims.exp) {
51
+ // console.log("Token is expired");
52
+ // reject("Token is expired");
53
+ // return;
54
+ // }
55
+
56
+ // /* --=- Optional audience stuff we dont use.
57
+ // // and the Audience (use claims.client_id if verifying an access token)
58
+ // if (claims.aud != app_client_id) {
59
+ // console.log('Token was not issued for this audience')
60
+ // return;
61
+ // }
62
+ // */
63
+
64
+ // const isDisabled = await isUserDisabled(claims.username);
65
+
66
+ // if (isDisabled) {
67
+ // console.log("User is disabled");
68
+ // reject("User is disabled");
69
+ // return;
70
+ // }
71
+
72
+ // resolve(claims.username);
73
+ // })
74
+ // .catch(async (error) => {
75
+ // console.log("Signature verification failed", error);
76
+ // reject("Signature verification failed");
77
+ // });
78
+ // })
79
+ // .catch(async (error) => {
80
+ // console.log("failed JWK.asKey", error);
81
+ // reject(error);
82
+ // });
83
+ // });
84
+ // } else {
85
+ // console.log("failed on response", response);
86
+ // reject(response);
87
+ // }
88
+ // });
89
+ // });
63
90
  };
@@ -1,13 +1,13 @@
1
- const getRef = require("../../db/common/getRef");
2
1
  const getSessionUser = require("./getSessionUser");
2
+ const getApiKeyFromReq = require("./getApiKeyFromReq");
3
3
 
4
4
  module.exports = async (event) => {
5
5
  if (!event.headers) {
6
6
  return null;
7
7
  }
8
8
  if (event.headers.apikey) {
9
- const key = await getRef("accesskeys", "Key", event.headers.apikey);
10
- return key.UserId;
9
+ const key = await getApiKeyFromReq(event);
10
+ return key?.UserId;
11
11
  }
12
12
  if (!event.headers.authkey) {
13
13
  return null;
@@ -1,12 +1,12 @@
1
1
  const _ = require("lodash");
2
2
  const { log, generateLogId } = require("../");
3
- const getRef = require("../../db/common/getRef");
3
+ const getApiKeyFromReq = require("./getApiKeyFromReq");
4
4
 
5
5
  module.exports = async (req, actionType, site) => {
6
6
  const logId = generateLogId();
7
7
  try {
8
8
  log("ApiKey", "Input", req.headers.apikey, logId);
9
- const key = await getRef("accesskeys", "Key", req.headers.apikey);
9
+ const key = await getApiKeyFromReq(req);
10
10
  log("ApiKey", "Key", key, logId);
11
11
 
12
12
  if (key.UserId) {
@@ -3,155 +3,125 @@ const { getConfig } = require("../config");
3
3
 
4
4
  module.exports = (noti) => {
5
5
  const thisNoti = { ...noti };
6
- switch (noti.Type) {
7
- case "MaintenanceJobStatusChanged":
8
- thisNoti.Text = `Your request is ${noti.Data.status}`;
9
- thisNoti.Subtext = noti.Data.title || noti.Data.description;
10
- thisNoti.Icon = "wrench";
11
- break;
12
- case "MaintenanceJobAssigned":
13
- thisNoti.Text = `You have been assigned a request`;
14
- thisNoti.Subtext = noti.Data.title || noti.Data.description;
15
- thisNoti.Icon = "wrench";
16
- break;
17
- case "MaintenanceJobUnassigned":
18
- thisNoti.Text = `A request you were assigned has been reassigned`;
19
- thisNoti.Subtext = noti.Data.title || noti.Data.description;
20
- thisNoti.Icon = "wrench";
21
- break;
22
- case "MaintenanceJobCommented":
23
- thisNoti.Text = noti.Data.comment;
24
- thisNoti.Subtext = noti.Data.title || noti.Data.description;
25
- thisNoti.Icon = "wrench";
26
- break;
27
- case "EntityCommented":
28
- thisNoti.Text = noti.Data.comment;
29
- thisNoti.Subtext = noti.Data.title || noti.Data.description;
30
- thisNoti.Icon = "commenting";
31
- break;
32
- case "EventRepChange":
33
- let eventChangeText = "";
34
- if (noti.Data.LocationChanged && noti.Data.TimeChanged) {
35
- eventChangeText = "time and location";
36
- } else if (noti.Data.LocationChanged) {
37
- eventChangeText = "location";
38
- } else if (noti.Data.TimeChanged) {
39
- eventChangeText = "time";
40
- }
41
- thisNoti.Text = `An event you are attending has changed ${eventChangeText}`;
42
- thisNoti.Subtext = noti.Data.Title;
43
- thisNoti.Icon = "calendar";
44
- break;
45
- case "EventRepRemoved":
46
- thisNoti.Text = "An event you are attending has been cancelled";
47
- thisNoti.Subtext = noti.Data.Title;
48
- thisNoti.TimeText = noti.Data.Time;
49
- thisNoti.Icon = "calendar-times-o";
50
- break;
51
- case "ApproveNewsSubmission":
52
- thisNoti.Text = "A story you submitted has been approved";
53
- thisNoti.Subtext = noti.Data.Title;
54
- thisNoti.Icon = "newspaper-o";
55
- break;
56
- case "ApproveEventSubmission":
57
- thisNoti.Text = "An event you submitted has been approved";
58
- thisNoti.Subtext = noti.Data.Title;
59
- thisNoti.Icon = "calendar-check-o";
60
- break;
61
- case "EventRegisterFromWaitlist":
62
- thisNoti.Text =
63
- "A spot has opened up on an event you were on the waitlist for";
64
- thisNoti.Subtext = noti.Data.Title;
65
- thisNoti.Icon = "calendar-plus-o";
66
- break;
67
- case "NewsletterPublished":
68
- thisNoti.Text = `News: ${noti.Data.Title}`;
69
- thisNoti.Subtext =
70
- !_.isEmpty(noti.Data.Text) && noti.Data.Text.length > 100
71
- ? `${noti.Data.Text.substring(0, 100)}...`
72
- : noti.Data.Text;
73
- thisNoti.Icon = "newspaper-o";
74
- break;
75
- case "FormLockoutFailure":
76
- thisNoti.Text =
77
- "Someone answered yes to a question on the kiosk and was denied access";
78
- thisNoti.Icon = "exclamation-triangle";
79
- break;
80
- case "FormLockoutSuccess":
81
- thisNoti.Text =
82
- "Someone answered no to all questions on the kiosk and was granted access";
83
- thisNoti.Icon = "check";
84
- break;
85
- case "InformationAdded":
86
- thisNoti.Text = `There is new important information available: ${noti.Data.title}`;
87
- thisNoti.Icon = "info";
88
- break;
89
- case "InformationUpdated":
90
- thisNoti.Text = `Important information updated: ${noti.Data.title}`;
91
- thisNoti.Icon = "info";
92
- break;
93
- case "PollAdded":
94
- thisNoti.Text = `There is a new survey available: ${noti.Data.Title}`;
95
- thisNoti.Icon = "pie-chart";
96
- break;
97
- case "OfferAdded":
98
- thisNoti.Text = `There is a new offer available: ${noti.Data.Title}`;
99
- thisNoti.Icon = "shopping-bag";
100
- break;
101
- case "ServiceAdded":
102
- thisNoti.Text = `There is a new service available: ${noti.Data.Title}`;
103
- thisNoti.Icon = "stethoscope";
104
- break;
105
- case "EventAdded":
106
- thisNoti.Text = `There is a new event: ${noti.Data.Title}`;
107
- thisNoti.Icon = "calendar-plus-o";
108
- break;
109
- case "FacilityAdded":
110
- thisNoti.Text = `There is a new ${getConfig().strings.FACILITY}: ${
111
- noti.Data.Title
112
- }`;
113
- thisNoti.Icon = "building";
114
- break;
115
- case "MapAdded":
116
- thisNoti.Text = `There is a new map: ${noti.Data.title}`;
117
- thisNoti.Icon = "map-marker";
118
- break;
119
- case "ImportantContactAdded":
120
- thisNoti.Text = `There is a new contact: ${noti.Data.title}`;
121
- thisNoti.Icon = "address-card-o";
122
- break;
123
- case "PersonalDocumentAdded":
124
- thisNoti.Text = `There is a new document: ${noti.Data.Name}`;
125
- thisNoti.Icon = "file-o";
126
- break;
127
- case "AppointmentAdded":
128
- thisNoti.Text = noti.Data.message;
129
- thisNoti.Icon = "calendar-plus-o";
130
- break;
131
- case "AppointmentUpdated":
132
- thisNoti.Text = noti.Data.message;
133
- thisNoti.Icon = "calendar-check-o";
134
- break;
135
- case "AppointmentCancelled":
136
- thisNoti.Text = noti.Data.message;
137
- thisNoti.Icon = "calendar-times-o";
138
- break;
139
- case "AppointmentReminder":
140
- thisNoti.Text = noti.Data.message;
141
- thisNoti.Icon = "bell-o";
142
- break;
143
- case "AppointmentFollowup":
144
- thisNoti.Text = noti.Data.message;
145
- thisNoti.Icon = "calendar-check-o";
146
- break;
147
- case "ScheduledAction":
148
- thisNoti.Text = noti.Data.message;
149
- thisNoti.Icon = "bell-o";
150
- break;
151
- default:
152
- thisNoti.Text = "You have received a notification";
153
- thisNoti.Icon = "bell-o";
154
- break;
6
+ const type = noti.Type ?? "";
7
+ if (type.startsWith("MaintenanceJobStatusChanged")) {
8
+ thisNoti.Text = `Your request is ${noti.Data.status}`;
9
+ thisNoti.Subtext = noti.Data.title || noti.Data.description;
10
+ thisNoti.Icon = "wrench";
11
+ } else if (type.startsWith("MaintenanceJobAssigned")) {
12
+ thisNoti.Text = `You have been assigned a request`;
13
+ thisNoti.Subtext = noti.Data.title || noti.Data.description;
14
+ thisNoti.Icon = "wrench";
15
+ } else if (type.startsWith("MaintenanceJobUnassigned")) {
16
+ thisNoti.Text = `A request you were assigned has been reassigned`;
17
+ thisNoti.Subtext = noti.Data.title || noti.Data.description;
18
+ thisNoti.Icon = "wrench";
19
+ } else if (type.startsWith("MaintenanceJobCommented")) {
20
+ thisNoti.Text = noti.Data.comment;
21
+ thisNoti.Subtext = noti.Data.title || noti.Data.description;
22
+ thisNoti.Icon = "wrench";
23
+ } else if (type.startsWith("EntityCommented")) {
24
+ thisNoti.Text = noti.Data.comment;
25
+ thisNoti.Subtext = noti.Data.title || noti.Data.description;
26
+ thisNoti.Icon = "commenting";
27
+ } else if (type.startsWith("EventRepChange")) {
28
+ let eventChangeText = "";
29
+ if (noti.Data.LocationChanged && noti.Data.TimeChanged) {
30
+ eventChangeText = "time and location";
31
+ } else if (noti.Data.LocationChanged) {
32
+ eventChangeText = "location";
33
+ } else if (noti.Data.TimeChanged) {
34
+ eventChangeText = "time";
35
+ }
36
+ thisNoti.Text = `An event you are attending has changed ${eventChangeText}`;
37
+ thisNoti.Subtext = noti.Data.Title;
38
+ thisNoti.Icon = "calendar";
39
+ } else if (type.startsWith("EventRepRemoved")) {
40
+ thisNoti.Text = "An event you are attending has been cancelled";
41
+ thisNoti.Subtext = noti.Data.Title;
42
+ thisNoti.TimeText = noti.Data.Time;
43
+ thisNoti.Icon = "calendar-times-o";
44
+ } else if (type.startsWith("ApproveNewsSubmission")) {
45
+ thisNoti.Text = "A story you submitted has been approved";
46
+ thisNoti.Subtext = noti.Data.Title;
47
+ thisNoti.Icon = "newspaper-o";
48
+ } else if (type.startsWith("ApproveEventSubmission")) {
49
+ thisNoti.Text = "An event you submitted has been approved";
50
+ thisNoti.Subtext = noti.Data.Title;
51
+ thisNoti.Icon = "calendar-check-o";
52
+ } else if (type.startsWith("EventRegisterFromWaitlist")) {
53
+ thisNoti.Text =
54
+ "A spot has opened up on an event you were on the waitlist for";
55
+ thisNoti.Subtext = noti.Data.Title;
56
+ thisNoti.Icon = "calendar-plus-o";
57
+ } else if (type.startsWith("NewsletterPublished")) {
58
+ thisNoti.Text = `News: ${noti.Data.Title}`;
59
+ thisNoti.Subtext =
60
+ !_.isEmpty(noti.Data.Text) && noti.Data.Text.length > 100
61
+ ? `${noti.Data.Text.substring(0, 100)}...`
62
+ : noti.Data.Text;
63
+ thisNoti.Icon = "newspaper-o";
64
+ } else if (type.startsWith("FormLockoutFailure")) {
65
+ thisNoti.Text =
66
+ "Someone answered yes to a question on the kiosk and was denied access";
67
+ thisNoti.Icon = "exclamation-triangle";
68
+ } else if (type.startsWith("FormLockoutSuccess")) {
69
+ thisNoti.Text =
70
+ "Someone answered no to all questions on the kiosk and was granted access";
71
+ thisNoti.Icon = "check";
72
+ } else if (type.startsWith("InformationAdded")) {
73
+ thisNoti.Text = `There is new important information available: ${noti.Data.title}`;
74
+ thisNoti.Icon = "info";
75
+ } else if (type.startsWith("InformationUpdated")) {
76
+ thisNoti.Text = `Important information updated: ${noti.Data.title}`;
77
+ thisNoti.Icon = "info";
78
+ } else if (type.startsWith("PollAdded")) {
79
+ thisNoti.Text = `There is a new survey available: ${noti.Data.Title}`;
80
+ thisNoti.Icon = "pie-chart";
81
+ } else if (type.startsWith("OfferAdded")) {
82
+ thisNoti.Text = `There is a new offer available: ${noti.Data.Title}`;
83
+ thisNoti.Icon = "shopping-bag";
84
+ } else if (type.startsWith("ServiceAdded")) {
85
+ thisNoti.Text = `There is a new service available: ${noti.Data.Title}`;
86
+ thisNoti.Icon = "stethoscope";
87
+ } else if (type.startsWith("EventAdded")) {
88
+ thisNoti.Text = `There is a new event: ${noti.Data.Title}`;
89
+ thisNoti.Icon = "calendar-plus-o";
90
+ } else if (type.startsWith("FacilityAdded")) {
91
+ thisNoti.Text = `There is a new ${getConfig().strings.FACILITY}: ${
92
+ noti.Data.Title
93
+ }`;
94
+ thisNoti.Icon = "building";
95
+ } else if (type.startsWith("MapAdded")) {
96
+ thisNoti.Text = `There is a new map: ${noti.Data.title}`;
97
+ thisNoti.Icon = "map-marker";
98
+ } else if (type.startsWith("ImportantContactAdded")) {
99
+ thisNoti.Text = `There is a new contact: ${noti.Data.title}`;
100
+ thisNoti.Icon = "address-card-o";
101
+ } else if (type.startsWith("PersonalDocumentAdded")) {
102
+ thisNoti.Text = `There is a new document: ${noti.Data.Name}`;
103
+ thisNoti.Icon = "file-o";
104
+ } else if (type.startsWith("AppointmentAdded")) {
105
+ thisNoti.Text = noti.Data.message;
106
+ thisNoti.Icon = "calendar-plus-o";
107
+ } else if (type.startsWith("AppointmentUpdated")) {
108
+ thisNoti.Text = noti.Data.message;
109
+ thisNoti.Icon = "calendar-check-o";
110
+ } else if (type.startsWith("AppointmentCancelled")) {
111
+ thisNoti.Text = noti.Data.message;
112
+ thisNoti.Icon = "calendar-times-o";
113
+ } else if (type.startsWith("AppointmentReminder")) {
114
+ thisNoti.Text = noti.Data.message;
115
+ thisNoti.Icon = "bell-o";
116
+ } else if (type.startsWith("AppointmentFollowup")) {
117
+ thisNoti.Text = noti.Data.message;
118
+ thisNoti.Icon = "calendar-check-o";
119
+ } else if (type.startsWith("ScheduledAction")) {
120
+ thisNoti.Text = noti.Data.message;
121
+ thisNoti.Icon = "bell-o";
122
+ } else {
123
+ thisNoti.Text = "You have received a notification";
124
+ thisNoti.Icon = "bell-o";
155
125
  }
156
126
  return thisNoti;
157
127
  };
package/package.json CHANGED
@@ -1,12 +1,15 @@
1
1
  {
2
2
  "name": "@plusscommunities/pluss-core-aws",
3
- "version": "2.0.8",
3
+ "version": "2.0.9-auth.0",
4
4
  "description": "Core extension package for Pluss Communities platform",
5
5
  "scripts": {
6
6
  "betapatch": "npm version prepatch --preid=beta",
7
7
  "patch": "npm version patch",
8
8
  "betaupload": "npm i && npm i && npm publish --access public --tag beta",
9
9
  "betaupload:p": "npm run betapatch && npm run betaupload",
10
+ "authpatch": "npm version prepatch --preid=auth",
11
+ "authupload": "npm i && npm i && npm publish --access public --tag auth",
12
+ "authupload:p": "npm run authpatch && npm run authupload",
10
13
  "upload": "npm i && npm i && npm publish --access public",
11
14
  "upload:p": "npm run patch && npm run upload"
12
15
  },
@@ -20,6 +23,8 @@
20
23
  "expo-server-sdk": "^3.0.1",
21
24
  "html-entities": "^2.3.2",
22
25
  "https": "^1.0.0",
26
+ "jsonwebtoken": "^9.0.2",
27
+ "jwks-rsa": "^3.1.0",
23
28
  "lodash": "^4.17.10",
24
29
  "moment": "^2.30.1",
25
30
  "node-fetch": "^2.2.0",