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

refactor: onboarding after install #148

Closed
wants to merge 1 commit into from

Conversation

fbwoolf
Copy link
Contributor

@fbwoolf fbwoolf commented Jun 15, 2021

Description

This PR changes the onboarding flow so that now after install the user is directed back to their app tab and it reloads the page so the extension can be detected as installed. This will be paired with changes to the stacks-web-wallet.

For details refer to issue #44 and #98

Type of Change

  • New feature
  • Bug fix
  • API reference/documentation update
  • Other

Does this introduce a breaking change?

No.

Are documentation updates required?

No.

Testing information

Testing will be handled by devs.

Checklist

  • Code is commented where needed
  • Unit test coverage for new or modified code paths
  • yarn lerna run test passes
  • Changelog is updated
  • Tag 1 of @hstove or @kyranjamie or @aulneau for review

@changeset-bot
Copy link

changeset-bot bot commented Jun 15, 2021

🦋 Changeset detected

Latest commit: b3910e4

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@stacks/connect Minor
@stacks/connect-ui Minor
@stacks/connect-react Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@fbwoolf fbwoolf linked an issue Jun 15, 2021 that may be closed by this pull request
@fbwoolf
Copy link
Contributor Author

fbwoolf commented Jun 15, 2021

After looking at this closer, there is a redirectTo property on the AuthOptions, but we would be relying on the app dev to include it bc it is optional or we can force it like I am doing here.

@fbwoolf fbwoolf requested a review from aulneau June 16, 2021 01:23

@State()
hasOpenedInstall: boolean;
@Prop() appUrl: string;
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we should use the redirectUrl in place of appUrl

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you mean the redirectTo url set in the authOptions by the app? I wasn't sure if we could rely on that since it is optional? From comments in the wallet PR, maybe we should keep track of the specific tabId instead in case there are several tabs of the app open?

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah, I think keeping track of the tabId makes the most sense, but if possible we should try to implement any redirect behavior in a different PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

if we can scope this change to basically be "the app will update when the extension has been installed" or basically everything other than redirection, i think that would make our lives easier. things get tricky when trying to redirect, and it's a bigger project which i think requires some UX considerations

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure then that any of this work satisfies closing the 2 linked issues? Should I just make a third issue with that scope and leave those 2 open for the new design work?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

With this scope of just reloading, I should prob keep using the url (not a specific tabId) and reload any tabs open with the app url?

Copy link
Contributor

Choose a reason for hiding this comment

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

based on this issue: #144 we should not do any reloading, but instead give them two options: "Head back to App" or "close tab"

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 one is where I started and it mentions not wanting the user to have to manually refresh ...the first step was getting rid of that modal: #98 which prompted them to refresh after install. I thought the goal was to it for them.

// Save app url in the query params to be used in the ext
// background script after install to reload the app
const urlParams = new URLSearchParams();
urlParams.set('app', this.appUrl);
Copy link
Contributor

Choose a reason for hiding this comment

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

@kyranjamie does this need sanitation you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

Good spot. Yes, we should validate that this is a URL. What happens if the user enters: javascript:window.alert("lol") ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What is the best way to do this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't totally understand this, the user isn't entering anything here ...it is taken from window.location.href from where they launched the install modal.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

anytime we are taking a URL from some arbitrary location we should sanitize it, anything can be hijacked

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah indeed, the href could be set maliciously. We have a 1:1 later Fara, I'll run you through how one of the h1 exploit reports figured out an XSS ☠️

@@ -1,7 +1,3 @@
export function getStacksProvider() {
return window.StacksProvider || window.BlockstackProvider;
Copy link
Contributor

Choose a reason for hiding this comment

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

We are no longer injecting BlockstackProvider

Suggested change
return window.StacksProvider || window.BlockstackProvider;
return window.StacksProvider;

@fbwoolf fbwoolf changed the title refactor: onboarding after install refactor: reload app after install Jun 21, 2021
@fbwoolf fbwoolf linked an issue Jun 21, 2021 that may be closed by this pull request
@fbwoolf fbwoolf force-pushed the refactor/onboarding-after-install branch from cda7b12 to b3910e4 Compare June 21, 2021 19:57
@fbwoolf fbwoolf changed the title refactor: reload app after install refactor: onboarding after install Jun 21, 2021
@fbwoolf fbwoolf marked this pull request as draft June 21, 2021 20:52
@fbwoolf fbwoolf closed this Jun 24, 2021
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.

Reload the app after download/install
3 participants