Gaston895 commited on
Commit
08ba1b0
·
verified ·
1 Parent(s): 9fc97c7

Upload 3 files

Browse files
Files changed (2) hide show
  1. gss-sdk.js +6 -1
  2. 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