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

chore: when app runs without iframe, connect fails #55

Merged
merged 1 commit into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/neat-apples-complain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@crowdstrike/foundry-js': minor
---

Connect message can be undefined, if app runs without iframe. If that happens, we'll gracefully ignore failure and allow application to continue to work.
17 changes: 11 additions & 6 deletions src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,20 @@ export default class FalconApi<DATA extends LocalData = LocalData> {
* This establishes a connection to send messages between the extension and the Falcon Console. Only when established you will be able to call other APIs.
*/
public async connect(): Promise<void> {
const { origin, data } = await this.bridge.postMessage({ type: 'connect' });
const response = await this.bridge.postMessage({ type: 'connect' });

this.bridge.setOrigin(origin);
this.data = data;
if (response !== undefined) {
const { origin, data } = response;

this.updateTheme(data?.theme);
this.resizeTracker = new ResizeTracker(this.bridge);
this.bridge.setOrigin(origin);
this.data = data;

this.updateTheme(data?.theme);

this.isConnected = true;
this.isConnected = true;
}

this.resizeTracker = new ResizeTracker(this.bridge);
}

/**
Expand Down