clerk / javascript

Official Javascript repository for Clerk authentication
https://clerk.com
MIT License
1.09k stars 241 forks source link

Not a valid protocol: 'chrome-extension:' #3583

Closed tomasmenezes closed 3 months ago

tomasmenezes commented 3 months ago

Preliminary Checks

Reproduction

n/a

Publishable key

n/a

Description

I was trying to get through the initial auth setup on a chrome extension popup with @clerk/chrome-extension but it seems that, much like #3545, the protocol check prevents routing redirects from chrome-extension:.

This also breaks the starter code found in clerk-chrome-extension-starter/v5. Additionally, it seems none of the SSO sign-in account popups are shown with the popup as the origin (also noted in clerk-chrome-extension-starter#1).

Environment

Binaries:
    Node: 22.0.0 - /usr/local/bin/node
    pnpm: 9.4.0 - ~/Library/pnpm/pnpm
Browsers:
    Chrome: 126.0.6478.61
npmPackages:
    @clerk/chrome-extension: ^1.0.18 => 1.0.18
tomasmenezes commented 3 months ago

@LekoArts This is still problematic after #3584 due to /core/clerk.ts#L785

// clerk.ts#L785 - navigate
if (toURL.protocol !== 'http:' && toURL.protocol !== 'https:') {
      console.warn('Clerk: Not a valid protocol. Redirecting to /');
      toURL = new URL('/', window.location.href);
}

The hard protocol check automatically redirects to '/'.

LekoArts commented 3 months ago

You're right 👍 Put up a PR: https://github.com/clerk/javascript/pull/3605