skip to content

libraries.dorianmarie.com · version 1

small projects.
one shared foundation.

javascript libraries for a consistent architecture, account, presentation, and installable web app. black and white. publicly documented. built for cloudflare workers.

every project, one family.

architecture

the project registry supports explicit hostname and directory values for the apex site. the optional shell array lists additional public routes to precache for offline use; never include personalized or authenticated routes.

each project is an independent cloudflare module worker. product behavior and data stay in the project. libraries provides common request handling, navigation, design tokens, icons, pwa routes, account integration, and build and deployment tooling.

filepurpose
AGENTS.mdproject rules and resource identity
package.jsonbuild, test, deploy
cloudflare.config.jsJavaScript Worker configuration
src/application and Worker code
public/optional browser assets
scripts/project-specific asset preparation
dist/worker.jsgenerated deployment artifact
auth.jshost-only project sessions and PKCE
platform.jsshared shell, responses, assets, PWA
projects.jsproject and Worker registry
icons.jswhite SVG glyphs on black
service-worker.jspublic shell cache and offline fallback

the shared implementation is bundled into each worker and served from that project's own origin under /_dm/. a documentation outage cannot break another project's ui. no runtime cdn or cross-origin script dependency is required. existing product-specific renderers remain responsible for their screens.

server rendering

Workers render the initial application interface, navigation, language, and authenticated data in HTML. Browser JavaScript adds interactions without an initial data-loading screen. Device-only weight records stay on the device and enhance the public offline interface. Personalized HTML uses no-store and is never put in an offline cache.

design

every app offers auto, français, and english language choices, plus system, light, and dark themes. auto follows the first supported browser language; system follows the device color scheme. preferences stay on the current origin in local storage, work offline, and fall back to in-memory settings when storage is unavailable. only interface copy is translated; user content, identifiers, and code examples remain unchanged.

author interface copy in lowercase at the source, without emojis or css case conversion. preserve user-entered case, identifiers, source examples, and proxied content. every app uses the shared install app control; installed apps hide it.

light mode uses white surfaces and black text; dark mode uses black surfaces and white text. system fonts. square controls, visible keyboard focus, responsive spacing, and reduced-motion support. icons use a black background with a white foreground, including png install icons and svg favicons. no emojis.

tokenvalue
--dm-black#000000
--dm-white#ffffff
--dm-fontsystem-ui and platform fallbacks
--dm-width1120px
--dm-space24px
--dm-radius0

common navigation includes projects, documentation, login, register, the signed-in account, sign out, and an install app button with native installation or browser instructions. secondary app navigation and settings also live in the folded menu, while primary actions stay in the page. navigation spans the viewport on every app, with the brand at left and a folded menu at the top right on desktop, tablet, and mobile. the menu contains all shared links, account actions, install controls, language, and theme settings. it opens with a keyboard or pointer and closes with escape or a click outside. controls have a minimum 44px touch target. content uses the shared 1120px width and 24px gutters (20px on mobile); focused tools may use a narrower content column.

account settings and API keys

Manage passkeys, language, theme, time format (24h/12h), weight units (kg/lb), temperature units, and API keys at account. Signed-in apps read account preferences through /sso/preferences. Language and theme changes in the shared menu save to the account; device preferences remain available offline. Every app exposes /api, /api/docs, /api/openapi.json, and authenticated /api/identity. Account keys are hashed, shown once on creation, and revoked at account. Send Authorization: Bearer YOUR_KEY and the application’s own Origin header for mutations. All product APIs retain owner isolation. Account management requires a browser session.

One shared top-right menu contains application actions, account, language, theme, installation, fullscreen, and documentation. Content uses one font size with bold emphasis; clocks retain large digits. Dialogs stay within the viewport.

The native browser install banner remains enabled; the menu also provides installation and platform-specific instructions.

one account

account.dorianmarie.com owns registration, email verification, password sign in, password recovery, and passkeys. applications never collect account passwords.

  1. link to /sso/login or /sso/register on the current project.
  2. the worker creates a random state and pkce verifier in a secure, http-only, host-only flow cookie.
  3. the account service validates the registered callback and issues a short-lived, single-use authorization code.
  4. the project exchanges the code through its ACCOUNT service binding and stores a host-only session cookie.
  5. authenticated apis call ssoUser(request, env). identity stays server-side; tokens never enter local storage.
import {wrap, ssoUser} from '../../libraries.dorianmarie.com/src/auth.js';

const worker = {
  async fetch(request, env) {
    const user = await ssoUser(request, env);
    if (!user) return Response.json({error: 'sign in required'}, {status: 401});
    return Response.json({email: user.email}, {headers: {'Cache-Control': 'no-store'}});
  }
};
export default wrap(worker);

set ACCOUNT to the account worker. add new callback origins explicitly to the account service allowlist. project sign out revokes the parent session and uses a same-origin post to /sso/logout. sign out of all projects and password recovery revoke parent sessions at the account service. the existing sso/client.js entrypoint re-exports this implementation for compatibility.

authenticated requests fail closed if the account service is unavailable. the library does not cache api responses or authorization redirects.

installable, with a deliberate offline policy

every project exposes a standalone manifest, 192px and 512px png icons, a root service worker, and an accessible offline page. the public apex directory, time, weights, workout, and libraries shells work offline. weight entries and workout state retain the existing device storage behavior. account, habits, heartbeats, and proxy show a reconnect page rather than cache personalized html.

only allowlisted, same-origin public assets and shells enter the cache. api routes, sso routes, authorization, query urls, non-get requests, and session responses never enter it. install icon urls include a content version, and ios receives an explicit 180px apple touch icon so new installations can refresh older artwork. releases are content-versioned. activation removes only this project's caches. installing a pwa depends on browser support and may require “add to home screen” on ios.

shared interface

export or routepurpose
wrap(worker, options)sso routes plus shared presentation; scheduled and named exports remain project-owned
ssoUser(request, env)verified user or null; service failures throw
standardize(worker, options)shared assets, manifest, icons, navigation, and html presentation
withAssets(worker, files, release)embedded public assets and content-versioned offline shell
json(body, status)json response with no-store and nosniff
escapeHtml(value)escape text for generated html
/_dm/platform.csssame-origin design tokens and common components
/_dm/platform.jsaccount navigation and pwa registration
/_dm/manifest.webmanifestper-project install metadata
/sw.jsshared service worker with project-specific release
/_dm/icon.svg, /_dm/icon-192.pngproject-specific monochrome icons
/healthdeployment health, where supported by the application

browse and download the javascript source. source modules are served as text for inspection and vendoring. import the checked-in modules at build time; do not load worker modules in a browser.

build, verify, deploy

# From ~/dorianmariecom:
npm install
npm run build
npm test
npm run deploy

# Work on one project:
node scripts/build.mjs weights
node scripts/deploy.mjs weights

# Each project also exposes:
npm run build
npm run deploy

the workspace registry maps project domains to existing worker names. shared build tooling bundles javascript and embeds public assets. project preparation retains existing app asset pipelines. deployment reads existing remote settings, retains bindings and secrets, and updates the worker code. it does not run database migrations or recreate databases. new domains are configured explicitly. credentials stay in the local cloudflare profile and never enter public documentation.

cloudflare configuration uses javascript. logs and traces are enabled. tests cover account and session isolation, shared rendering, pwa cache exclusions, and product behavior. see the workspace and each project's agents.md before changing code.