Upload 3 files
Browse files- gss-sdk.js +6 -1
- sdk/gss-sdk.js +6 -1
gss-sdk.js
CHANGED
|
@@ -180,10 +180,15 @@ class GSSClient {
|
|
| 180 |
async _syncKeys() {
|
| 181 |
try {
|
| 182 |
const token = await this._getToken();
|
| 183 |
-
await fetch(`${this.cfWorkerUrl}/auth/keep-alive`, {
|
| 184 |
method: 'POST',
|
| 185 |
headers: { 'Authorization': `Bearer ${token}`, 'Content-Type': 'application/json' },
|
| 186 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 187 |
} catch (_) { /* silent — non-critical */ }
|
| 188 |
}
|
| 189 |
|
|
|
|
| 180 |
async _syncKeys() {
|
| 181 |
try {
|
| 182 |
const token = await this._getToken();
|
| 183 |
+
const res = await fetch(`${this.cfWorkerUrl}/auth/keep-alive`, {
|
| 184 |
method: 'POST',
|
| 185 |
headers: { 'Authorization': `Bearer ${token}`, 'Content-Type': 'application/json' },
|
| 186 |
});
|
| 187 |
+
// Token rejected — clear cache so next chat triggers a fresh lease
|
| 188 |
+
if (res.status === 401 || res.status === 403) {
|
| 189 |
+
localStorage.removeItem(this.storageKey);
|
| 190 |
+
this._token = null;
|
| 191 |
+
}
|
| 192 |
} catch (_) { /* silent — non-critical */ }
|
| 193 |
}
|
| 194 |
|
sdk/gss-sdk.js
CHANGED
|
@@ -180,10 +180,15 @@ class GSSClient {
|
|
| 180 |
async _syncKeys() {
|
| 181 |
try {
|
| 182 |
const token = await this._getToken();
|
| 183 |
-
await fetch(`${this.cfWorkerUrl}/auth/keep-alive`, {
|
| 184 |
method: 'POST',
|
| 185 |
headers: { 'Authorization': `Bearer ${token}`, 'Content-Type': 'application/json' },
|
| 186 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 187 |
} catch (_) { /* silent — non-critical */ }
|
| 188 |
}
|
| 189 |
|
|
|
|
| 180 |
async _syncKeys() {
|
| 181 |
try {
|
| 182 |
const token = await this._getToken();
|
| 183 |
+
const res = await fetch(`${this.cfWorkerUrl}/auth/keep-alive`, {
|
| 184 |
method: 'POST',
|
| 185 |
headers: { 'Authorization': `Bearer ${token}`, 'Content-Type': 'application/json' },
|
| 186 |
});
|
| 187 |
+
// Token rejected — clear cache so next chat triggers a fresh lease
|
| 188 |
+
if (res.status === 401 || res.status === 403) {
|
| 189 |
+
localStorage.removeItem(this.storageKey);
|
| 190 |
+
this._token = null;
|
| 191 |
+
}
|
| 192 |
} catch (_) { /* silent — non-critical */ }
|
| 193 |
}
|
| 194 |
|