fix: missing brace in users.js, ws double-increment, b64url stack overflow, docs storage
This commit is contained in:
@@ -166,7 +166,11 @@ function b64urlToArrayBuffer(b64url) {
|
||||
*/
|
||||
function arrayBufferToB64url(buffer) {
|
||||
const bytes = new Uint8Array(buffer);
|
||||
const bin = String.fromCharCode.apply(null, Array.from(bytes));
|
||||
const chunks = [];
|
||||
for (let i = 0; i < bytes.length; i += 0x8000) {
|
||||
chunks.push(String.fromCharCode.apply(null, bytes.slice(i, i + 0x8000)));
|
||||
}
|
||||
const bin = chunks.join('');
|
||||
return btoa(bin)
|
||||
.replace(/\+/g, '-')
|
||||
.replace(/\//g, '_')
|
||||
|
||||
@@ -13,6 +13,7 @@ let _wsConn = null;
|
||||
let _wsReconnectMs = 0;
|
||||
let _wsFailCount = 0;
|
||||
let _wsRefreshing = false;
|
||||
let _wsClosingHandled = false;
|
||||
|
||||
/** Direct onMessage handlers — { topics, handler, unsubscribed }[] */
|
||||
const _directHandlers = [];
|
||||
@@ -35,6 +36,7 @@ function _wsUrl() {
|
||||
function _wsConnect() {
|
||||
if (_wsConn && _wsConn.readyState <= 1) return;
|
||||
|
||||
_wsClosingHandled = false;
|
||||
const token = window.__auth_token__;
|
||||
if (token) {
|
||||
_wsConn = new WebSocket(_wsUrl(), ['Bearer ' + token]);
|
||||
@@ -46,9 +48,12 @@ function _wsConnect() {
|
||||
_wsReconnectMs = 0;
|
||||
_wsFailCount = 0;
|
||||
_wsRefreshing = false;
|
||||
_wsClosingHandled = false;
|
||||
};
|
||||
|
||||
_wsConn.onclose = () => {
|
||||
if (_wsClosingHandled) return;
|
||||
_wsClosingHandled = true;
|
||||
if (!window.__auth_token__) return;
|
||||
_wsFailCount++;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user