klembot / twinejs

Twine, a tool for telling interactive, nonlinear stories
https://twinery.org
GNU General Public License v3.0
2.05k stars 308 forks source link

Intranet Twine Error with Firefox/Chrome Browser: window.crypto.randomUUID is not a function #1544

Closed LeeThompson closed 4 months ago

LeeThompson commented 4 months ago

Describe the bug.

Starting with Twine 2.9.1, if you use Firefox browser on an intranet webserver without using https Twine will fail to load. The console for Firefox will show: window.crypto.randomUUID is not a function

Uncaught TypeError: window.crypto.randomUUID is not a function
    IW http://(localurl)/twine/assets/index-CXvDOX45.js:37
    <anonymous> http://(localurl)/twine/assets/index-CXvDOX45.js:37

In my case, the web server is Apache 2.4 running in a Docker container on a Synology NAS. The browser (Firefox) is running on Windows 10 Enterprise edition

Steps to reproduce:

  1. Install Twine 2.9.1 on an intranet web server
  2. Access Twine with Firefox or Chrome browser using http

Expected behavior:

It shouldn't require https, but apparently randomUUID on Firefox, Chrome (and possibly other browsers) requires https.

Additional context on this problem.

No response

Twine version number

2.9.1

Does this problem occur with the web version of Twine or the desktop app?

Web

What operating system does this problem occur on?

Other

If this problem is occurring with the web version of Twine, what browser does it occur on?

Firefox Chrome (Possibly Others)

Presubmission checklist

klembot commented 4 months ago

This is more-or-less by design. 2.9.1 replaced the tiny-uuid module with a built-in browser equivalent that has good support across browsers, but requires either running on localhost or in an HTTPS context. I think your best bet here will be to use a self-signed cert if you want to serve the app locally.

LeeThompson commented 4 months ago

I hope this doesn't affect playing games produced with TWINE as it will introduce hurdles for players to overcome just to play a local copy.

greyelf commented 4 months ago

I hope this doesn't affect playing games produced with TWINE

As far as I know none of the major Story Formats runtime engines need to generate UUIDs while a Story HTML file is being viewed. And if they are doing so I know that the crypto.randomUUID() function specifically isn't currently being used in the engine code of SugarCube, Harlowe, or Chapbook.

klembot commented 4 months ago

Discussion on intfiction.org reminded me that some users are still using the HTTP version of the online editor, so https://github.com/klembot/twinejs/pull/1545 backs out the change we've been discussing.