-
Notifications
You must be signed in to change notification settings - Fork 1
feat: add widget.mount(), use it in demo, add branding to DOM #17
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
139783c
wip
teallarson bd3e1b8
branding works too albeit not ideal
teallarson 367694a
fix test
teallarson 0bc6d4c
move demo to use `mount()` as shown in the docs
teallarson 3ec4b49
fix tests and demo to use mount()
teallarson ac0b823
add mount method and add branding to DOM
teallarson b8076f2
🧹
teallarson 47951ff
cleanup
teallarson 531260e
don't allow token to be optional
teallarson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,6 @@ CLIENT_ID= | |
CLIENT_SECRET= | ||
ORGANIZATION_ID= | ||
WORKSPACE_ID= | ||
ALLOWED_ORIGIN= | ||
BASE_URL= | ||
``` | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,12 +29,17 @@ const AIRBYTE_ACCESS_TOKEN_URL = `${BASE_URL}/v1/applications/token`; | |
const CLIENT_ID = process.env.CLIENT_ID; | ||
const CLIENT_SECRET = process.env.CLIENT_SECRET; | ||
const WORKSPACE_ID = process.env.WORKSPACE_ID; | ||
const ORGANIZATION_ID = process.env.ORGANIZATION_ID; | ||
const ALLOWED_ORIGIN = process.env.ALLOWED_ORIGIN || "http://localhost:3000"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can be inferred! |
||
|
||
// GET /api/widget → fetch widget token and return it | ||
app.get("/api/widget_token", async (req, res) => { | ||
try { | ||
// Determine the allowed origin from the request | ||
const origin = | ||
req.headers.origin || | ||
req.headers.referer?.replace(/\/$/, "") || | ||
process.env.ALLOWED_ORIGIN || | ||
"http://localhost:3000"; | ||
|
||
const access_token_body = JSON.stringify({ | ||
client_id: CLIENT_ID, | ||
client_secret: CLIENT_SECRET, | ||
|
@@ -66,8 +71,7 @@ app.get("/api/widget_token", async (req, res) => { | |
}, | ||
body: JSON.stringify({ | ||
workspaceId: WORKSPACE_ID, | ||
organizationId: ORGANIZATION_ID, | ||
allowedOrigin: ALLOWED_ORIGIN, | ||
allowedOrigin: origin, | ||
}), | ||
}); | ||
|
||
|
@@ -78,6 +82,7 @@ app.get("/api/widget_token", async (req, res) => { | |
} | ||
|
||
const widget_token = await widget_token_response.text(); | ||
|
||
res.json({ token: widget_token }); | ||
} catch (err) { | ||
console.error("Unexpected error:", err); | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
was not used