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

feat(space-nuxt-base): support app bridge #64

Merged
merged 21 commits into from
Jul 22, 2024
Merged

feat(space-nuxt-base): support app bridge #64

merged 21 commits into from
Jul 22, 2024

Conversation

eunjae-lee
Copy link
Contributor

@eunjae-lee eunjae-lee commented Jun 11, 2024

What?

This PR adds App Bridge support in nuxt-base project. It's turned off by default by appConfig.appBridge.enabled being false. Users can turn it on on their project level.

Why?

JIRA: SHAPE-5689

How to test? (optional)

https://www.loom.com/share/f3e501f581d844fcacac51681ca5e5ca

@eunjae-lee eunjae-lee changed the title feat: support app bridge WIP feat(space-nuxt-base): support app bridge WIP Jun 17, 2024
@eunjae-lee eunjae-lee changed the title feat(space-nuxt-base): support app bridge WIP feat(space-nuxt-base): support app bridge Jun 24, 2024
@eunjae-lee eunjae-lee marked this pull request as ready for review June 24, 2024 12:55
@eunjae-lee eunjae-lee requested a review from BibiSebi June 24, 2024 13:21
const appConfig = useAppConfig();
const { initOAuth } = await readBody(event);
if (initOAuth) {
setCookie(event, AUTH_COOKIE_NAME, '', {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a specific reason to set the cookie here ? I thought I would be set by the app-extension auth once it gets trough the flow.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is to clear the stale cookie in case a user re-installed the extension and needs to restart the whole oauth cookie. (do you remember the issue with the redirection the iframe)

Copy link
Contributor

@BibiSebi BibiSebi Jun 25, 2024

Choose a reason for hiding this comment

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

Oh yeah that makes sense. The question that I am asking myself/where I am torn, is if it makes more sense to somehow to handle this cookie reset inside app-extension-auth or in the backend, so that there are not many pieces floating around. Because when we decide to switch from the cookie approach and decide to store the cookie in a DB this behavior is loosely coupled with the rest so it might be harder to think of and consider then.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh I see what you mean. Yeah it makes sense. Let's do the work on app-extension-auth to allow adaptors, and then move this logic back to app-extension-auth.

@BibiSebi BibiSebi self-requested a review June 25, 2024 09:41
Copy link
Contributor

@BibiSebi BibiSebi left a comment

Choose a reason for hiding this comment

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

Huge work @eunjae-lee 👏

};
}

const appSession = await getAppSession(event);
Copy link
Contributor

Choose a reason for hiding this comment

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

Either here or inside getAppSession there should be new code to retrieve the session based on the result from session token.

@@ -81,15 +101,6 @@ const useAppBridgeMessages = () => {
}
};

onUnmounted(() => {
// @ts-ignore not sure how to solve this
document.removeEventListener('message', eventListener);
Copy link
Contributor

Choose a reason for hiding this comment

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

I changed this to window.removeEventListener('message', eventListener); is this ok? Or do you think it will affect something it shouldnt @eunjae-lee

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh, you're right. it's window.removeEventListener 🤦🏻‍♂️

@BibiSebi
Copy link
Contributor

I tested a little bit and there is an issue when reinstalling the plugin redirecting to 404.

@eunjae-lee
Copy link
Contributor Author

I tested a little bit and there is an issue when reinstalling the plugin redirecting to 404.

have you managed to fix it? or is it still a todo?

@eunjae-lee
Copy link
Contributor Author

eunjae-lee commented Jul 16, 2024

8f33127

Fixed the 401 issue, and also made some changes to initiate oauth outside the iframe. (refer to SHAPE-6131 ticket. It depends on a new change from Storyfront, which is in review at the moment)

@eunjae-lee
Copy link
Contributor Author

[NOTE]

After merging this PR, we should update all the projects that rely on nuxt-base to have the v2 of app-extension-auth. Otherwise, the build will fail for those projects. It's the limitation from Nuxt that it doesn't install dependencies from the base layer properly for you.

@eunjae-lee eunjae-lee merged commit f39b6a1 into main Jul 22, 2024
1 check passed
@eunjae-lee eunjae-lee deleted the feat/app-bridge branch July 22, 2024 14:02
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