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

[Poll] do you use http or https? #90

Closed
jimmywarting opened this issue Mar 15, 2019 · 9 comments
Closed

[Poll] do you use http or https? #90

jimmywarting opened this issue Mar 15, 2019 · 9 comments

Comments

@jimmywarting
Copy link
Owner

jimmywarting commented Mar 15, 2019

As the tile says:

Do you use StreamSaver.js on secure (https) or insecure (http) in production websites?

  • click 🎉 for https (secure)
  • click 👀 for http (insecure)

I'm just curious if folks are using StreamSaver's popup hack that is required by insecure pages. I could include google analytics on gihub pages but i'm not going to do that as i value everyones privacy

▼Vote with reaction▼
(you can choose both)

@TexKiller
Copy link
Contributor

Quick information: Web Extensions on Firefox run as if they were http (insecure) pages, so, according to my tests, without the popup trick those extensions would be incapable of using the library.

@jimmywarting
Copy link
Owner Author

jimmywarting commented Mar 18, 2019

@TexKiller, hmm, i think FF web extension should be considered secure? Perhaps it can work with a iframe solution if we just detect it?

Current detection is:

  const secure = location.protocol === 'https:' ||
                 location.protocol === 'chrome-extension:' ||
                 location.hostname === 'localhost'

Maybe it will work in some background file (if it's a extension)

I don't know much about firefox extensions, perhaps it's possible to install the sw.js within a iframe or maybe it isn't

I found one list of secure origins

  • (https, *, *)
  • (wss, *, *)
  • (*, localhost, *)
  • (*, 127/8, *)
  • (*, ::1/128, *)
  • (file, *, —)
  • (chrome-extension, *, —)

And a chrome flag

  • --unsafely-treat-insecure-origin-as-secure="example.com"

@jimmywarting
Copy link
Owner Author

according to this spec a popup like mine should be considered insecure? therefore i should not be able to install a sw.js? but if i added "noopener" to my open command it's fine?

window.open("https://example.com/", "", "noopener")

@jimmywarting
Copy link
Owner Author

Oh, found something interesting in the spec 🙂

window.isSecureContext

@TexKiller
Copy link
Contributor

@jimmywarting, Web Extensions on Firefox run from the moz-extension protocol (in chrome they run from the chrome-extension protocol). In my tests I was incapable of getting a Service Worker to intercept any requests if it is created on an iframe there. I'll create an example extension and put here shortly.

@jimmywarting
Copy link
Owner Author

jimmywarting commented Mar 18, 2019

could you also test the isSecureContext if it 's a boolean and what the value is while you are at it?

@TexKiller
Copy link
Contributor

TexKiller commented Mar 18, 2019

Sure thing :)

Steps to test it:

  1. Download the sample extension here: https://texkiller.eu.org/StreamSaver/moz-extension/StreamSaver.js-moz-extension.zip
  2. Extract it to some folder
  3. Navigate to this URL in Firefox: about:debugging#addons
  4. Click on "Load Temporary Add-on..."
  5. Navigate to the folder where you extracted the files and choose manifest.json
  6. The extension is loaded. Now click on the green down arrow icon that has appeared on the toolbar to the upper right
  7. A test page is now open, with a button to test the behaviour of the library. The button label will tell the value of window.isSecureContext (it is true here on Firefox v65.0).

The included StreamSaver.js file is the same as in this repository, except for the following condition added to the secure context detection to make it run inside an iframe:
location.protocol === 'moz-extension:'

@TexKiller
Copy link
Contributor

TexKiller commented Mar 18, 2019

While running this sample extension here on Firefox v65.0 everything goes well until after I click the button: when it is time to navigate to the "intercept-me-nr" URL and start the download the Github 404 page is shown instead of the download.

You can modify the files on the extension folder and just reload the test page to try different things, if you want.

@TexKiller
Copy link
Contributor

TexKiller commented Mar 18, 2019

I didn't know this "noopener" parameter. While interesting, it seems pointless here since we won't have any way to communicate with the Service Worker from the insecure page and register the download (it "unsets" window.opener).

After tinkering a lot with the Web Extension on Firefox I have found one way that works, but it involves the Shared Worker from PR #86 and some other tweaks. I can make a sample extension for it too, but it should take some more time since I have to clean up my test code.

Repository owner deleted a comment from L00049485 Mar 27, 2019
Repository owner deleted a comment from L00049485 Mar 27, 2019
Repository owner deleted a comment from L00049485 Mar 27, 2019
Repository owner deleted a comment from L00049485 Mar 27, 2019
@jimmywarting jimmywarting pinned this issue Mar 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants