| | |
| | | this.nonces = {}; |
| | | |
| | | this.subscribers = new Set(); |
| | | this.storageKey = 'jvb_auth_state'; |
| | | this.cacheMetaKey = 'jvb_auth_meta'; |
| | | this.storageKey = `${jvbBase.base}auth_state`; |
| | | this.cacheMetaKey = `${jvbBase.base}auth_meta`; |
| | | this.cacheExpiry = 5 * 60 * 1000; // 5 minutes |
| | | |
| | | this.init(); |
| | |
| | | headers |
| | | }); |
| | | |
| | | // If auth failed and we haven't retried yet, refresh and try once more |
| | | if ((response.status === 403 || response.status === 401) && retryCount === 0) { |
| | | const result = await response.clone().json(); |
| | | if (resconsole.logult.code === 'rest_cookie_invalid_nonce' || result.message?.includes('Cookie check')) { |
| | | ('Nonce invalid, refreshing auth...'); |
| | | if (result.code === 'rest_cookie_invalid_nonce' || result.message?.includes('Cookie check')) { |
| | | console.log('Nonce invalid, refreshing auth...'); |
| | | await this.refresh(); |
| | | return attempt(1); // Retry once |
| | | return attempt(1); |
| | | } |
| | | } |
| | | |