fedipod 1.57.0 → 1.57.5
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/gateway.md +12 -11
- package/lib/core/intake/group.mjs +5 -3
- package/lib/core/intake/index.mjs +8 -2
- package/lib/gateway/copy.mjs +23 -2
- package/lib/gateway/front-core.mjs +5 -5
- package/lib/gateway/gateway-core.mjs +15 -3
- package/lib/gateway/held-mail.mjs +56 -25
- package/lib/gateway/keeper-due.mjs +17 -4
- package/lib/gateway/quiet.mjs +11 -1
- package/lib/pod/inbox.mjs +5 -2
- package/package.json +3 -3
- package/scripts/check-netlify-bundles.mjs +7 -2
- package/scripts/forum-package.mjs +28 -6
- package/web/app/boot.mjs +21 -5
- package/web/app/dist/boot.js +88 -29
- package/web/app/dist/boot.js.map +2 -2
- package/web/app/dist/sw.js +99 -30
- package/web/app/dist/sw.js.map +3 -3
- package/web/app/sw-src.mjs +23 -2
package/web/app/sw-src.mjs
CHANGED
|
@@ -124,9 +124,16 @@ self.addEventListener('activate', (e) => e.waitUntil(self.clients.claim()));
|
|
|
124
124
|
// browsers kill an idle service worker and restart it fresh, and the client at
|
|
125
125
|
// /app/ never posts 'boot' — so without on-demand boot every request after a
|
|
126
126
|
// restart 503s. On a boot failure `booting` is cleared so the next request retries.
|
|
127
|
+
// With no sign-in to boot from, the error says so by its code ('signed-out'):
|
|
128
|
+
// nothing stored, or a stored sign-in the pod has ended. The pod is asked
|
|
129
|
+
// before the agent starts on it (the session's check), and only when the
|
|
130
|
+
// sign-in's time is up; a pod that cannot be asked is left for the agent's
|
|
131
|
+
// own start to report.
|
|
132
|
+
const signedOut = (message) => Object.assign(new Error(message), { code: 'signed-out' });
|
|
127
133
|
async function bootFromSession(frontOrigin, restart) {
|
|
128
134
|
const oidc = await getSession();
|
|
129
|
-
if (!oidc) throw
|
|
135
|
+
if (!oidc) throw signedOut('no session — sign in first');
|
|
136
|
+
if (await oidc.check().catch(() => true) === false) throw signedOut('the sign-in this browser was holding has ended — sign in again');
|
|
130
137
|
const a = new BrowserAgent({ log: agentLog });
|
|
131
138
|
a.recentLog = recentLog;
|
|
132
139
|
await a.boot({ oidc, frontOrigin: frontOrigin || self.location.origin, restart });
|
|
@@ -195,6 +202,20 @@ function stillWorking(first) {
|
|
|
195
202
|
return Promise.race([work, cap]).finally(() => clearTimeout(timer));
|
|
196
203
|
}
|
|
197
204
|
|
|
205
|
+
// The app's pages cannot sign anybody in, and with no sign-in every request
|
|
206
|
+
// of theirs is refused: they are taken to the front page, which can. Once in
|
|
207
|
+
// a while at most, however many requests find the same thing.
|
|
208
|
+
let sentToSignIn = 0;
|
|
209
|
+
async function toSignIn() {
|
|
210
|
+
if (Date.now() - sentToSignIn < 10_000) return;
|
|
211
|
+
sentToSignIn = Date.now();
|
|
212
|
+
const pages = await self.clients.matchAll({ type: 'window' }).catch(() => []);
|
|
213
|
+
for (const c of pages) {
|
|
214
|
+
const at = new URL(c.url).pathname;
|
|
215
|
+
if (c.frameType === 'top-level' && (at.startsWith('/app/') || at.startsWith('/admin/'))) c.navigate('/').catch(() => {});
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
198
219
|
async function serve(request, url) {
|
|
199
220
|
// Before anything is booted or read: is this caller allowed to be here at all?
|
|
200
221
|
const refuse = notAllowed(request, url);
|
|
@@ -204,7 +225,7 @@ async function serve(request, url) {
|
|
|
204
225
|
}
|
|
205
226
|
// Boot on demand from the stored session, so the client works even when the
|
|
206
227
|
// worker was restarted (idle-killed) and nobody posted 'boot' this time.
|
|
207
|
-
if (!agent) { try { await ensureBooting(undefined, { restart: true }); } catch {
|
|
228
|
+
if (!agent) { try { await ensureBooting(undefined, { restart: true }); } catch (e) { if (e.code === 'signed-out') await toSignIn(); } }
|
|
208
229
|
if (!agent) return json(503, { error: 'not signed in on this browser — sign in at the front page' });
|
|
209
230
|
const { req, res, bodyText, response } = await bridge(request, url, {
|
|
210
231
|
// notAllowed() above let this through, so it came from this origin.
|