mirror of
https://github.com/profullstack/logicsrc.git
synced 2026-11-29 15:51:52 +00:00
Profullstack footer on the app.logicsrc.com sign-in page (webring + built.indie + pwamart badges)
Server-rendered @profullstack/footer (clearnet template) under the LogicSRC footer on the public sign-in page (/), bundled at boot and refreshed from the @latest template every 15 min. Serves /.well-known/openwebring.json for the Profullstack ring. Lockfile footer 0.2.1 -> 0.2.6 (checked with bun 1.4.2 --frozen-lockfile). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
580817b06f
commit
58827b3e2a
6 changed files with 65 additions and 2 deletions
|
|
@ -11,6 +11,7 @@
|
|||
"test": "node --test"
|
||||
},
|
||||
"dependencies": {
|
||||
"@profullstack/footer": "latest",
|
||||
"@profullstack/libsql-pg": "^0.1.2",
|
||||
"@simplewebauthn/browser": "^13.3.0",
|
||||
"@simplewebauthn/server": "^13.1.0",
|
||||
|
|
|
|||
33
apps/pwa/src/lib/ring-footer.mjs
Normal file
33
apps/pwa/src/lib/ring-footer.mjs
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
// The Profullstack footer (links, copyright, the << Profullstack >> webring row and
|
||||
// the built.indie + pwamart badges) from @profullstack/footer, on the public
|
||||
// sign-in page. It is rendered into the HTML on the server because rssamplifier's
|
||||
// ring verifier reads the page and never runs script.
|
||||
//
|
||||
// Pages render synchronously, so the footer is kept as a string: the bundled
|
||||
// template at boot, then the @latest template from the CDN, refreshed every 15
|
||||
// minutes (a footer release reaches us with no redeploy). A failed refresh keeps
|
||||
// the last good copy. No CSP on this app, so the footer brings its own styles.
|
||||
import { footerHtml, footerHtmlSync } from "@profullstack/footer";
|
||||
|
||||
export const RING_FOOTER_OPTIONS = { site: "https://app.logicsrc.com/" };
|
||||
|
||||
let html = footerHtmlSync(RING_FOOTER_OPTIONS);
|
||||
|
||||
/** The footer markup; never empty. */
|
||||
export const ringFooter = () => html;
|
||||
|
||||
/** Accept a rendered footer only when it still links the ring. */
|
||||
export function setRingFooter(next) {
|
||||
if (typeof next !== "string" || !next.includes("/ring/profullstack") || next.length > 64_000) return false;
|
||||
html = next;
|
||||
return true;
|
||||
}
|
||||
|
||||
export function startRingFooterRefresh(everyMs = 15 * 60_000) {
|
||||
if (process.env.PROFULLSTACK_FOOTER_OFFLINE === "1") return () => {};
|
||||
const run = () => footerHtml(RING_FOOTER_OPTIONS).then(setRingFooter, () => {});
|
||||
run();
|
||||
const timer = setInterval(run, everyMs);
|
||||
timer.unref?.();
|
||||
return () => clearInterval(timer);
|
||||
}
|
||||
|
|
@ -6,6 +6,7 @@ import { hashPassword, verifyPassword } from "../lib/crypto.mjs";
|
|||
import { createUserWithPassword, userByEmail } from "../lib/users.mjs";
|
||||
import { dashboardHandler } from "./pages.mjs";
|
||||
import { config } from "../config.mjs";
|
||||
import { ringFooter } from "../lib/ring-footer.mjs";
|
||||
|
||||
export const authRouter = Router();
|
||||
|
||||
|
|
@ -38,7 +39,7 @@ function authPage(req, { error = "", mode = "in" } = {}) {
|
|||
: `<button class="btn block" type="button" disabled title="Set COINPAY_OAUTH_* to enable">◆ Continue with CoinPay</button>`}
|
||||
<p id="passkey-msg" class="mono faint" style="font-size:.72rem;text-align:center;margin:12px 0 0"></p>
|
||||
</div></div>
|
||||
</main>${footer}
|
||||
</main>${footer}${ringFooter()}
|
||||
<script src="/vendor/simplewebauthn-browser.umd.js"></script>
|
||||
<script src="/passkey.js"></script>`;
|
||||
return page({ title: "LogicSRC ▸ sign in", body });
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@ import { apiKeysRouter } from "./routes/apikeys.mjs";
|
|||
import { opencredsRouter } from "./routes/opencreds.mjs";
|
||||
import { cliRouter } from "./routes/cli.mjs";
|
||||
import { pagesRouter } from "./routes/pages.mjs";
|
||||
import { descriptor } from "@profullstack/footer";
|
||||
import { RING_FOOTER_OPTIONS, startRingFooterRefresh } from "./lib/ring-footer.mjs";
|
||||
|
||||
const app = express();
|
||||
app.disable("x-powered-by");
|
||||
|
|
@ -48,6 +50,10 @@ const sodiumCore = createRequire(sodiumWrappers).resolve("libsodium");
|
|||
app.get("/vendor/libsodium.js", (_req, res) => res.sendFile(sodiumCore));
|
||||
app.get("/vendor/libsodium-wrappers.js", (_req, res) => res.sendFile(sodiumWrappers));
|
||||
|
||||
// The Profullstack webring descriptor (the ring footer is on the sign-in page, /).
|
||||
app.get("/.well-known/openwebring.json", (_req, res) =>
|
||||
res.json(descriptor({ site: RING_FOOTER_OPTIONS.site, name: "LogicSRC credentials" })));
|
||||
|
||||
app.get("/healthz", (_req, res) => res.json({ ok: true, env: config.env }));
|
||||
|
||||
app.use(sessionMiddleware);
|
||||
|
|
@ -74,6 +80,7 @@ app.use((err, _req, res, _next) => {
|
|||
|
||||
async function main() {
|
||||
await migrate();
|
||||
startRingFooterRefresh();
|
||||
app.listen(config.port, () => console.log(`🔐 logicsrc credentials on :${config.port} (${config.env}) — ${config.origin}`));
|
||||
}
|
||||
main().catch((e) => { console.error("boot failed:", e); process.exit(1); });
|
||||
|
|
|
|||
20
apps/pwa/test/ring-footer.test.mjs
Normal file
20
apps/pwa/test/ring-footer.test.mjs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
// The sign-in page carries the Profullstack footer (webring row + badges), and
|
||||
// the refresh only ever swaps in a footer that still links the ring.
|
||||
import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
|
||||
import { ringFooter, setRingFooter } from "../src/lib/ring-footer.mjs";
|
||||
|
||||
test("the bundled footer links the ring and both badges for app.logicsrc.com", () => {
|
||||
const html = ringFooter();
|
||||
assert.match(html, /rssamplifier\.com\/ring\/profullstack/);
|
||||
assert.match(html, /built\.indie\.pit\.world/);
|
||||
assert.match(html, /pwamart\.com\/for\.svg\?site=https%3A%2F%2Fapp\.logicsrc\.com%2F|pwamart\.com\/for\.svg\?site=https:\/\/app\.logicsrc\.com\//);
|
||||
});
|
||||
|
||||
test("a refresh without the ring row is ignored", () => {
|
||||
const before = ringFooter();
|
||||
assert.equal(setRingFooter("<footer>nope</footer>"), false);
|
||||
assert.equal(setRingFooter(undefined), false);
|
||||
assert.equal(ringFooter(), before);
|
||||
});
|
||||
3
bun.lock
3
bun.lock
|
|
@ -82,6 +82,7 @@
|
|||
"name": "@logicsrc/pwa",
|
||||
"version": "0.1.1",
|
||||
"dependencies": {
|
||||
"@profullstack/footer": "latest",
|
||||
"@profullstack/libsql-pg": "^0.1.2",
|
||||
"@simplewebauthn/browser": "^13.3.0",
|
||||
"@simplewebauthn/server": "^13.1.0",
|
||||
|
|
@ -802,7 +803,7 @@
|
|||
|
||||
"@profullstack/emailer": ["@profullstack/emailer@1.0.1", "", {}, "sha512-/uhHJJGH+1xSSz3mJn6X+m6aruYjMD3JOaRp/d4R/YWlzpy07H9z0/JUleIyRyBPNmaANSIwjTZ7aVjaukOEpg=="],
|
||||
|
||||
"@profullstack/footer": ["@profullstack/footer@0.2.1", "", { "peerDependencies": { "react": ">=18" }, "optionalPeers": ["react"], "bin": { "profullstack-footer": "bin/profullstack-footer.js" } }, "sha512-KHmKVwrlzCBrSAAJ4zobNFCxTg8VF0gvNMeAut00dX3+gbWCtk6eOwIR2AaqEC7smj6Aio6cIexzt/dUnv1McA=="],
|
||||
"@profullstack/footer": ["@profullstack/footer@0.2.6", "", { "peerDependencies": { "react": ">=18" }, "optionalPeers": ["react"], "bin": { "profullstack-footer": "bin/profullstack-footer.js" } }, "sha512-BKwbDszAc7e0mYIBiPjgr/5WS8WyDt8IW718s/zW/8pCWOIB1BGwSNs6fmImRSo5kqIjQKUVbXp22jZQ5GEipA=="],
|
||||
|
||||
"@profullstack/hqtui": ["@profullstack/hqtui@0.5.0", "", { "bin": { "hqtui": "bin/hqtui.mjs" } }, "sha512-jDwILBmdQx8pQA0ao/tzzty8u5nFNS4XhvU9xXhZvdIaMeiF3HBJIVtP6cS6kigS4lXmHR7sztbb9QJpaWwhig=="],
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue