@unbrained/pm-web 2026.8.29 → 2026.9.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/CHANGELOG.md +16 -2
- package/README.md +6 -3
- package/dist/csrf.d.ts +14 -18
- package/dist/csrf.js +49 -57
- package/dist/csrf.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/routes/auth.js +1 -1
- package/dist/routes/auth.js.map +1 -1
- package/dist/routes/github.js +29 -12
- package/dist/routes/github.js.map +1 -1
- package/dist/services/pm-runner.d.ts +16 -7
- package/dist/services/pm-runner.js +16 -43
- package/dist/services/pm-runner.js.map +1 -1
- package/manifest.json +2 -2
- package/package.json +3 -3
- package/public/src/api.js +25 -1
- package/public/src/api.js.map +1 -1
- package/public/src/api.ts +25 -2
- package/public/src/app.js +6 -2
- package/public/src/app.js.map +1 -1
- package/public/src/app.ts +6 -2
- package/public/src/sw.ts +27 -3
- package/public/sw.js +21 -1
package/public/sw.js
CHANGED
|
@@ -213,12 +213,32 @@ async function flushMutationQueue() {
|
|
|
213
213
|
const mutations = read.mutations;
|
|
214
214
|
if (mutations.length === 0)
|
|
215
215
|
return;
|
|
216
|
+
let replayCsrfToken;
|
|
217
|
+
try {
|
|
218
|
+
const bootstrap = await fetch('/api/auth/me', {
|
|
219
|
+
method: 'GET',
|
|
220
|
+
credentials: 'include',
|
|
221
|
+
cache: 'no-store',
|
|
222
|
+
});
|
|
223
|
+
replayCsrfToken = bootstrap.headers.get('x-csrf-token');
|
|
224
|
+
if (!replayCsrfToken) {
|
|
225
|
+
console.warn('Cannot replay offline mutations without a CSRF bootstrap token');
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
catch {
|
|
230
|
+
// The network failed during token bootstrap; preserve the entire queue.
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
216
233
|
let replayed = 0;
|
|
217
234
|
for (const mut of mutations) {
|
|
218
235
|
try {
|
|
219
236
|
const opts = {
|
|
220
237
|
method: mut.method,
|
|
221
|
-
headers: {
|
|
238
|
+
headers: {
|
|
239
|
+
'Content-Type': 'application/json',
|
|
240
|
+
'X-CSRF-Token': replayCsrfToken,
|
|
241
|
+
},
|
|
222
242
|
credentials: 'include',
|
|
223
243
|
};
|
|
224
244
|
if (mut.body !== null)
|