Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document on how to integrate in electron apps #37

Open
iongion opened this issue Aug 27, 2024 · 0 comments
Open

Document on how to integrate in electron apps #37

iongion opened this issue Aug 27, 2024 · 0 comments

Comments

@iongion
Copy link

iongion commented Aug 27, 2024

Leaving this as a guide for the next soul trying it.

const URLS_ALLOWED = [
  "https://stately.ai/inspect",
  "https://stately.ai/registry/inspect",
  "http://localhost",
];
const DOMAINS_ALLOW_LIST = ["localhost"];

applicationWindow.webContents.setWindowOpenHandler((event: any) => {
  const info = new URL(event.url);
  if (!URLS_ALLOWED.includes(event.url)) {
      if (!DOMAINS_ALLOW_LIST.includes(info.hostname)) {
        logger.error("Security issue - attempt to open a domain that is not allowed", info);
        return { action: "deny" };
      }
  }
  return { action: "allow" };
});
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

No branches or pull requests

1 participant