Skip to content

fix(ENG-12199): extend allowed origins and set default mode#103

Merged
adefreitas merged 3 commits intoStackOneHQ:mainfrom
adefreitas:ENG-12199/bamboo-hr-hub-fix
Feb 24, 2026
Merged

fix(ENG-12199): extend allowed origins and set default mode#103
adefreitas merged 3 commits intoStackOneHQ:mainfrom
adefreitas:ENG-12199/bamboo-hr-hub-fix

Conversation

@adefreitas
Copy link
Copy Markdown
Collaborator

No description provided.

Copilot AI review requested due to automatic review settings February 24, 2026 17:40
@adefreitas adefreitas enabled auto-merge (squash) February 24, 2026 17:40
@adefreitas adefreitas changed the title [ENG-12199] fix: extend allowed origins and set default mode fix(ENG-12199): extend allowed origins and set default mode Feb 24, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends origin validation for cross-origin messaging in the integration picker and sets a default mode when none is provided. The changes address ENG-12199 by allowing messages from both the current window origin and the dashboard URL origin, and by defaulting to 'integration-picker' mode when no mode is specified.

Changes:

  • Extended allowedOrigins to include both window.location.origin and the dashboardUrl origin for message validation
  • Removed the "No mode selected" error UI and defaulted mode to 'integration-picker' when undefined
  • Updated origin validation from single-origin check to Set-based multiple origins check

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
src/modules/integration-picker/hooks/useIntegrationPicker.ts Added allowedOrigins memoized Set to validate incoming messages from multiple origins (current origin and dashboard URL)
src/StackOneHub.tsx Removed "no mode selected" validation and set default mode to 'integration-picker' when undefined

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 104 to 139
const processMessageCallback = useCallback(
(event: MessageEvent) => {
if (event.origin !== window.location.origin) {
if (!allowedOrigins.has(event.origin)) {
return;
}

if (!event.data?.type) {
return;
}
if (event.data.type === EventType.AccountConnected) {
handleSuccess({ id: event.data.account.id, provider: event.data.account.provider });
parent.postMessage(event.data, '*');
} else if (event.data.type === EventType.CloseOAuth2) {
if (event.data.error) {
setConnectionState({
loading: false,
success: false,
error: {
message: event.data.error,
provider_response: event.data.errorDescription || 'No description',
},
});
} else {
setConnectionState({ loading: false, success: false, error: undefined });
}
}

if (connectWindow.current) {
connectWindow.current.close();
connectWindow.current = null;
}

window.removeEventListener('message', processMessageCallback, false);
},
[handleSuccess],
);
Copy link

Copilot AI Feb 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The processMessageCallback dependency array is missing allowedOrigins. Since allowedOrigins is a memoized Set that changes when dashboardUrl changes, the callback should include it in its dependencies to ensure it always uses the latest allowed origins for validation. Without this, the callback will continue using stale origin validation if dashboardUrl changes.

Copilot uses AI. Check for mistakes.
adefreitas and others added 2 commits February 24, 2026 17:53
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@adefreitas adefreitas disabled auto-merge February 24, 2026 17:58
@adefreitas adefreitas merged commit 418e133 into StackOneHQ:main Feb 24, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants