Trung0246 / ComfyUI-0246

Random nodes for ComfyUI
MIT License
93 stars 10 forks source link

Error using Webinterface without HTTPS/TLS: crypto.subtle is undefined #8

Closed zierf closed 7 months ago

zierf commented 7 months ago

Adding a Highway Node to comfy workflow prevents new images from being added to the queue if the webinterface was not opened in a secure context (HTTPS).

Reproducable using commit #d9d8702 (2023-11-19) for ComfyUI and commit #b7d64ce (2023-11-16) for this extension.


Following error will be reported under Settings ➜ View Logs:

TypeError
can't access property "digest", crypto.subtle is undefined
randomSHA256@http://[HOSTNAME]:8188/extensions/ComfyUI-0246/js/nodes.js:41:21

There is no output in command line.


According to MDN: SubtleCrypto, the browser interface crypto.subtle is not usable from a website without TLS.

Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

So I tested this again using the webinterface behind a reverse proxy with TLS encryption, which prevented the error from being thrown.


For TLS support I found this related open Issue #1105 and Pull Request #1481 (not provided in aforementioned commit) in ComfyUI repository.

Even if these could solve the current problem, I don't think enabling TLS should be a requirement, especially if ComfyUI isn't exposed to the outside world. Maybe the usage of crypto.subtle for generating SHA-256 hashes should be replaced by a library. However, I'm not sure which one would be best for this. It's a shame that the Crypto API cannot be used for HTTP pages, even for such small use cases.

Trung0246 commented 7 months ago

I guess I totally forgot about the crypto.subtle api thing only available for https. Woops. Guess I'll pick something else.

Trung0246 commented 7 months ago

Just pushed update.