rastrillo / pwa Public

Keep PWA registration assets outside sign-in redirects

Worker installation must receive JavaScript even before sign-in; an authentication redirect prevents registration and offline fallback.
Paul Campbell pushed by paul@keymail.dev 8bd2d14e0c088ebbd53a8041b862e90962dc6bdd parent 321666c
2 files changed, +3 −1
  • README.md +2 −1
  • SKILL.md +1 −0

CI passed — run details

CI log
=== go ===
go build ./...
go: downloading go1.25.0 (darwin/arm64)
go vet ./...
go test ./... -count=1
ok  	amadan.net/rastrillo/pwa	0.265s
=== js ===
node --test test/*.test.mjs
✔ unsupported browsers retain the ordinary web app (0.5875ms)
✔ waiting updates are announced without activating or reloading (0.967083ms)
✔ offline navigation returns a public, non-cacheable fallback (15.538458ms)
✔ HTTP authentication and server errors remain visible (1.615584ms)
✔ API calls, writes, external and out-of-scope navigations are untouched (0.357875ms)
✔ activation requires an explicit message from a controlled-scope page (0.595125ms)
ℹ tests 6
ℹ suites 0
ℹ pass 6
ℹ fail 0
ℹ cancelled 0
ℹ skipped 0
ℹ todo 0
ℹ duration_ms 70.763167
=== example ===
cd examples/basic && go build -o ../../.build/basic . && go vet ./... && go test ./... -count=1
go: downloading amadan.net/rastrillo/aviso v0.1.0
go: downloading amadan.net/rastrillo/rastrillo v0.26.0
go: downloading github.com/SherClockHolmes/webpush-go v1.4.0
go: downloading golang.org/x/crypto v0.31.0
go: downloading github.com/golang-jwt/jwt/v5 v5.2.1
go: downloading gorm.io/gorm v1.31.2
go: downloading modernc.org/sqlite v1.55.0
go: downloading gorm.io/plugin/dbresolver v1.6.2
go: downloading github.com/jinzhu/now v1.1.5
go: downloading golang.org/x/text v0.21.0
go: downloading github.com/jinzhu/inflection v1.0.0
go: downloading modernc.org/libc v1.74.1
go: downloading golang.org/x/sys v0.46.0
go: downloading github.com/mattn/go-isatty v0.0.20
go: downloading github.com/google/uuid v1.6.0
go: downloading github.com/ncruces/go-strftime v1.0.0
go: downloading github.com/dustin/go-humanize v1.0.1
go: downloading modernc.org/mathutil v1.7.1
go: downloading modernc.org/memory v1.11.0
go: downloading github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec
?   	example.com/pwa-basic	[no test files]
=== browser ===
npm ci --ignore-scripts

added 3 packages, and audited 4 packages in 947ms

found 0 vulnerabilities
node test/browser.mjs
chromium: offline navigation, network errors, no data cache, two-tab updates and worker composition passed
webkit: offline navigation, network errors, no data cache, two-tab updates and worker composition passed
diff --git a/README.md b/README.md
index 042183d..f2b7176 100644
--- a/README.md
+++ b/README.md
@@ -32,7 +32,8 @@ skill to provision its server and browser enrolment.
Read [SKILL.md](SKILL.md). Install a reviewed version of
`amadan.net/rastrillo/pwa`. Create `pwa.Manifest` with a permanent ID,
name, start URL, scope ending in `/`, and your icons. Call `.Handler()` at
-boot and handle its error. Mount the returned handler at
+boot and handle its error. Serve the manifest and worker assets without
+authentication redirects. Mount the returned handler at
`/manifest.webmanifest`. Mount assets with:
```go
diff --git a/SKILL.md b/SKILL.md
index d47c29a..9f1588d 100644
--- a/SKILL.md
+++ b/SKILL.md
@@ -24,6 +24,7 @@ separate Go module, so read it from the repository, not a module-cache zip.
`Cache-Control: no-cache`. It imports `/pwa/worker.js` and calls
`RastrilloPWA.install()` once. For `/app/` scope, use `/app/sw.js` and
matching manifest scope/start paths; asset helpers may live elsewhere.
+ Serve the manifest and worker assets without authentication redirects.
- Import `register` from `/pwa/client.mjs`. It returns a registration or
`null` when unsupported. It reports waiting updates through `onUpdate`;
it never reloads or asks for permission. Without `clients.claim`, the