@openeventkit/event-site 2.0.127 → 2.0.128

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/env.template CHANGED
@@ -34,3 +34,4 @@ GATSBY_CMS_BACKEND_REPO=
34
34
  GATSBY_CMS_BACKEND_BRANCH=
35
35
  GATSBY_SITE_URL=
36
36
  GATSBY_GOOGLE_TAGMANAGER_ID=
37
+ GATSBY_HASH_SANITIZE_TOKENS=
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@openeventkit/event-site",
3
3
  "description": "Event Site",
4
- "version": "2.0.127",
4
+ "version": "2.0.128",
5
5
  "author": "Tipit LLC",
6
6
  "dependencies": {
7
7
  "@fortawesome/fontawesome-svg-core": "^6.5.2",
@@ -1,24 +1,25 @@
1
- import { createAction } from 'openstack-uicore-foundation/lib/utils/actions';
1
+ import { createAction } from "openstack-uicore-foundation/lib/utils/actions";
2
+ import { PHASES, getSummitPhase, getEventPhase } from "@utils/phasesUtils";
3
+ import { updateVotingPeriodsPhase } from "../actions/presentation-actions";
4
+ import { sanitizeHash } from "../actions/security-actions";
2
5
 
3
- import { PHASES, getSummitPhase, getEventPhase } from '../utils/phasesUtils';
4
-
5
- import { updateVotingPeriodsPhase } from '../actions/presentation-actions';
6
-
7
- export const SUMMIT_PHASE_AFTER = 'SUMMIT_PHASE_AFTER';
8
- export const SUMMIT_PHASE_DURING = 'SUMMIT_PHASE_DURING';
9
- export const SUMMIT_PHASE_BEFORE = 'SUMMIT_PHASE_BEFORE';
10
- export const EVENT_PHASE_BEFORE = 'EVENT_PHASE_BEFORE';
11
- export const EVENT_PHASE_DURING = 'EVENT_PHASE_DURING';
12
- export const EVENT_PHASE_AFTER = 'EVENT_PHASE_AFTER';
13
- export const EVENT_PHASE_ADD = 'EVENT_PHASE_ADD';
14
- export const UPDATE_CLOCK = 'UPDATE_CLOCK';
6
+ export const SUMMIT_PHASE_AFTER = "SUMMIT_PHASE_AFTER";
7
+ export const SUMMIT_PHASE_DURING = "SUMMIT_PHASE_DURING";
8
+ export const SUMMIT_PHASE_BEFORE = "SUMMIT_PHASE_BEFORE";
9
+ export const EVENT_PHASE_BEFORE = "EVENT_PHASE_BEFORE";
10
+ export const EVENT_PHASE_DURING = "EVENT_PHASE_DURING";
11
+ export const EVENT_PHASE_AFTER = "EVENT_PHASE_AFTER";
12
+ export const EVENT_PHASE_ADD = "EVENT_PHASE_ADD";
13
+ export const UPDATE_CLOCK = "UPDATE_CLOCK";
15
14
 
16
15
  export const updateClock = (timestamp) => (dispatch) => {
17
-
18
16
  dispatch(createAction(UPDATE_CLOCK)({ timestamp }));
17
+
19
18
  dispatch(updateSummitPhase());
20
19
  dispatch(updateEventsPhase());
21
20
  dispatch(updateVotingPeriodsPhase());
21
+
22
+ dispatch(sanitizeHash());
22
23
  };
23
24
 
24
25
  export const updateSummitPhase = () => (dispatch, getState) => {
@@ -89,5 +90,5 @@ export const updateEventsPhase = () => (dispatch, getState) => {
89
90
  break;
90
91
  }
91
92
  }
92
- })
93
- };
93
+ });
94
+ };
@@ -0,0 +1,32 @@
1
+ import { getEnvVariable, HASH_SANITIZE_TOKENS } from "@utils/envVariables";
2
+
3
+ export const sanitizeHash = () => (dispatch, getState) => {
4
+ const { userState: { isAuthorized } } = getState();
5
+
6
+ if (!isAuthorized) {
7
+ const tokens = getEnvVariable(HASH_SANITIZE_TOKENS)?.split(",") ?? [];
8
+
9
+ if (tokens.length > 0) {
10
+ const url = new URL(window.location.href);
11
+ let fragment = url.hash;
12
+ let shouldUpdate = false;
13
+
14
+ tokens.forEach(token => {
15
+ if (fragment.includes(`${token}=`)) {
16
+ shouldUpdate = true;
17
+ fragment = fragment
18
+ .split("&")
19
+ .filter(fragmentToken => !fragmentToken.includes(`${token}=`))
20
+ .join("&")
21
+ .replace("#&", "#")
22
+ .replace("#?", "#")
23
+ .replace("#", "");
24
+ }
25
+ });
26
+
27
+ if (shouldUpdate) {
28
+ window.history.replaceState({}, "", `${url.pathname}${fragment ? `#${fragment}` : ""}`);
29
+ }
30
+ }
31
+ }
32
+ };
@@ -26,6 +26,7 @@ export const REAL_TIME_UPDATES_STRATEGY = "REAL_TIME_UPDATES_STRATEGY";
26
26
  export const TIMEINTERVALSINCE1970_API_URL = "TIMEINTERVALSINCE1970_API_URL";
27
27
  export const ABLY_API_KEY = "ABLY_API_KEY";
28
28
  export const GOOGLE_TAGMANAGER_ID = "GOOGLE_TAGMANAGER_ID";
29
+ export const HASH_SANITIZE_TOKENS = "HASH_SANITIZE_TOKENS";
29
30
 
30
31
  const processEnv = {
31
32
  /**
@@ -63,6 +64,7 @@ const processEnv = {
63
64
  TIMEINTERVALSINCE1970_API_URL: process.env.GATSBY_TIMEINTERVALSINCE1970_API_URL,
64
65
  ABLY_API_KEY: process.env.GATSBY_ABLY_API_KEY,
65
66
  GOOGLE_TAGMANAGER_ID: process.env.GATSBY_GOOGLE_TAGMANAGER_ID,
67
+ HASH_SANITIZE_TOKENS: process.env.GATSBY_HASH_SANITIZE_TOKENS
66
68
  }
67
69
 
68
70
  export const getEnvVariable = (name) => {