@mushi-mushi/core 1.22.0 → 1.22.1
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.
- package/dist/index.cjs +15 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +15 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1587,8 +1587,21 @@ function getSessionId() {
|
|
|
1587
1587
|
}
|
|
1588
1588
|
function generateSessionId() {
|
|
1589
1589
|
const timestamp = Date.now().toString(36);
|
|
1590
|
-
|
|
1591
|
-
|
|
1590
|
+
return `ms_${timestamp}_${randomSuffix()}`;
|
|
1591
|
+
}
|
|
1592
|
+
function randomSuffix() {
|
|
1593
|
+
const c = typeof crypto !== "undefined" ? crypto : void 0;
|
|
1594
|
+
const bytes = new Uint8Array(4);
|
|
1595
|
+
if (c?.getRandomValues) {
|
|
1596
|
+
c.getRandomValues(bytes);
|
|
1597
|
+
} else {
|
|
1598
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
1599
|
+
bytes[i] = Math.floor(Math.random() * 256);
|
|
1600
|
+
}
|
|
1601
|
+
}
|
|
1602
|
+
let n = 0;
|
|
1603
|
+
for (const b of bytes) n = n * 256 + b >>> 0;
|
|
1604
|
+
return n.toString(36).padStart(6, "0").slice(0, 6);
|
|
1592
1605
|
}
|
|
1593
1606
|
|
|
1594
1607
|
// src/rate-limiter.ts
|