Skip to content

Commit

Permalink
Include wildcard origin in postMessage calls. #454
Browse files Browse the repository at this point in the history
  • Loading branch information
mdirolf committed Dec 18, 2023
1 parent 0de9205 commit 5d46de3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 14 deletions.
35 changes: 22 additions & 13 deletions app/components/Puzzle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -392,10 +392,13 @@ export const Puzzle = ({
// Pause when page goes out of focus
function prodPause() {
if (process.env.NODE_ENV !== 'development') {
window.parent.postMessage({
type: 'pause',
elapsed: state.displaySeconds,
});
window.parent.postMessage(
{
type: 'pause',
elapsed: state.displaySeconds,
},
'*'
);
dispatch({ type: 'PAUSEACTION' });
writePlayToDBIfNeeded();
}
Expand Down Expand Up @@ -616,11 +619,14 @@ export const Puzzle = ({

useEffect(() => {
if (state.success) {
window.parent.postMessage({
type: 'complete',
elapsed: state.bankedSeconds,
didCheat: state.didCheat,
});
window.parent.postMessage(
{
type: 'complete',
elapsed: state.bankedSeconds,
didCheat: state.didCheat,
},
'*'
);
}
}, [state.success, state.bankedSeconds, state.didCheat]);

Expand Down Expand Up @@ -1283,10 +1289,13 @@ export const Puzzle = ({
: timeString(state.displaySeconds, true)
}
onClick={() => {
window.parent.postMessage({
type: 'pause',
elapsed: state.displaySeconds,
});
window.parent.postMessage(
{
type: 'pause',
elapsed: state.displaySeconds,
},
'*'
);
dispatch({ type: 'PAUSEACTION' });
writePlayToDBIfNeeded();
}}
Expand Down
2 changes: 1 addition & 1 deletion app/components/PuzzleOverlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ export const PuzzleOverlay = (props: SuccessOverlayProps | BeginPauseProps) => {
<div css={{ marginBottom: '1em' }}>{props.message}</div>
<Button
onClick={() => {
window.parent.postMessage({ type: 'resume' });
window.parent.postMessage({ type: 'resume' }, '*');
props.dispatch({ type: 'RESUMEACTION' });
}}
text={props.dismissMessage}
Expand Down

0 comments on commit 5d46de3

Please sign in to comment.