@kawaiininja/fetch 1.0.53 → 1.0.54

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,8 +6,28 @@ const MAX_RETRIES = 3;
6
6
  /**
7
7
  * Helper to prepare headers with Auth and CSRF
8
8
  */
9
+ /**
10
+ * Polyfill for UUID generation to support environments where crypto.randomUUID is missing (e.g. Android WebView)
11
+ */
12
+ const getUUID = () => {
13
+ if (typeof crypto !== "undefined" &&
14
+ typeof crypto.randomUUID === "function") {
15
+ return crypto.randomUUID();
16
+ }
17
+ // Fallback: crypto.getRandomValues (Standard in most modern WebViews)
18
+ if (typeof crypto !== "undefined" && crypto.getRandomValues) {
19
+ return "10000000-1000-4000-8000-100000000000".replace(/[018]/g, (c) => (c ^
20
+ (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (c / 4)))).toString(16));
21
+ }
22
+ // Fallback: Math.random (Legacy support)
23
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
24
+ const r = (Math.random() * 16) | 0;
25
+ const v = c === "x" ? r : (r & 0x3) | 0x8;
26
+ return v.toString(16);
27
+ });
28
+ };
9
29
  const prepareHeaders = async (token, headers, isNative, isInternal, debug) => {
10
- const requestId = crypto.randomUUID();
30
+ const requestId = getUUID();
11
31
  const config = {
12
32
  "X-Request-ID": requestId,
13
33
  "Idempotency-Key": requestId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kawaiininja/fetch",
3
- "version": "1.0.53",
3
+ "version": "1.0.54",
4
4
  "description": "Core fetch utility for Onyx Framework",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",