Commit 54b53f8
Interactivity: Fix crypto.randomUUID crash in non-secure contexts (#76151)
* Interactivity: Fix crypto.randomUUID crash in non-secure contexts
crypto.randomUUID() is only available in secure contexts (HTTPS or
localhost). Sites served over plain HTTP (e.g. http://wp-src.test)
crash the entire interactivity module at import time.
Add a feature-detection guard that falls back to a Math.random-based
identifier when crypto.randomUUID is unavailable. The sessionId only
needs to be unique per page load, not cryptographically secure.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Interactivity: Use crypto.getRandomValues for sessionId fallback
crypto.getRandomValues is available in all contexts (not just secure
contexts like randomUUID), providing a better fallback than Math.random.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Simplify sessionId
* Add changelog
Also fixes previous entry
---------
Co-authored-by: scruffian <scruffian@git.wordpress.org>
Co-authored-by: aduth <aduth@git.wordpress.org>
Co-authored-by: luisherranz <luisherranz@git.wordpress.org>1 parent d431ff2 commit 54b53f8
2 files changed
+7
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
5 | 10 | | |
6 | 11 | | |
7 | 12 | | |
8 | 13 | | |
9 | 14 | | |
10 | 15 | | |
11 | | - | |
| 16 | + | |
12 | 17 | | |
13 | 18 | | |
14 | 19 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
518 | 518 | | |
519 | 519 | | |
520 | 520 | | |
521 | | - | |
| 521 | + | |
522 | 522 | | |
523 | 523 | | |
524 | 524 | | |
| |||
0 commit comments