@ultimat3/pwa 27.11.0 → 27.13.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ultimat3/pwa",
3
- "version": "27.11.0",
3
+ "version": "27.13.0",
4
4
  "description": "Generated service worker, web manifest, icons, push and version-skew handling.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -34,10 +34,10 @@
34
34
  "test": "bun test"
35
35
  },
36
36
  "dependencies": {
37
- "@ultimat3/action": "27.11.0",
38
- "@ultimat3/core": "27.11.0",
39
- "@ultimat3/i18n": "27.11.0",
40
- "@ultimat3/policy": "27.11.0",
41
- "@ultimat3/schema": "27.11.0"
37
+ "@ultimat3/action": "27.13.0",
38
+ "@ultimat3/core": "27.13.0",
39
+ "@ultimat3/i18n": "27.13.0",
40
+ "@ultimat3/policy": "27.13.0",
41
+ "@ultimat3/schema": "27.13.0"
42
42
  }
43
43
  }
@@ -369,11 +369,11 @@ self.addEventListener('fetch',(event)=>{
369
369
  if(req.method!=='GET')return;
370
370
  const url=new URL(req.url);
371
371
  if(url.origin!==self.location.origin)return;
372
- if(NEVER_CACHE.some((p)=>url.pathname.startsWith(p)))return;
372
+ if(NEVER_CACHE.some((p)=>url.pathname.startsWith(p)))return passThrough(event);
373
373
  const rule=ruleFor(url);
374
- if(!rule)return;
374
+ if(!rule)return passThrough(event);
375
375
  const fn=STRATEGIES[rule.s];
376
- if(!fn)return;
376
+ if(!fn)return passThrough(event);
377
377
  // Every proxied DOCUMENT carries the client's build id so the server can detect skew. An asset
378
378
  // goes as the browser asked: a no-cors request's headers cannot be extended.
379
379
  const tagged=rule.a?req:new Request(req,{headers:withBuild(req.headers)});
@@ -382,6 +382,14 @@ self.addEventListener('fetch',(event)=>{
382
382
  const pre=req.mode==='navigate'&&event.preloadResponse?Promise.resolve(event.preloadResponse).then((r)=>{if(r)seenBuild(r);return r}):undefined;
383
383
  event.respondWith(fn(tagged,cacheName(rule.c),fallbackFor(rule,req),(p)=>event.waitUntil(p),pre).then((res)=>healSkew(req,res)));
384
384
  });
385
+ // Preload is on for EVERY navigation, so one this worker has no rule for was preloaded too. Left
386
+ // unanswered, the browser cancels that preload and requests the URL again: the server sees it
387
+ // twice, and a one-time OAuth callback exchanges its code twice — the second exchange fails the
388
+ // sign-in. Answer from the preload (net: an empty or failed one is the single fetch instead).
389
+ function passThrough(event){
390
+ if(event.request.mode!=='navigate'||!event.preloadResponse)return;
391
+ event.respondWith(net(event.request,event.preloadResponse));
392
+ }
385
393
  function seenBuild(res){
386
394
  const server=res.headers.get(BUILD_HEADER);
387
395
  if(SKEWED||server===null||server===BUILD_ID)return;