From 8f517f1b20596b3165e9f6ef7ff44d0ed1591f20 Mon Sep 17 00:00:00 2001 From: Ambroise Leclerc <6860842+ambroise-leclerc@users.noreply.github.com> Date: Mon, 2 Nov 2026 10:05:49 +0100 Subject: [PATCH 1/3] Serve the developer distribution from dist.webfront.fr and write the Pages CNAME (#478) The base URL moves to the custom domain and the sources advance to 0.6.5, which is not published yet: the pin stays on 0.6.4. site.mjs writes the CNAME file of the Pages branch from the base URL and the workflow versions it. wf run pin fetches the pinned archive where the distribution is served now, since the former github.io address redirects without CORS headers. --- .github/workflows/DeveloperDistribution.yml | 2 ++ docs/CHANGELOG.md | 7 +++++ docs/DEVELOPER_ENVIRONMENT.md | 2 ++ js/developer/environment/bundles.json | 6 ++-- js/developer/scripts/pin.mjs | 13 ++++++--- js/developer/scripts/site.mjs | 11 +++++++- js/developer/tools/distribution.json | 4 +-- js/developer/tools/distribution.mjs | 12 ++++++++ js/developer/webfront.project.json | 3 +- test/developer/specs/distribution-specs.mjs | 31 ++++++++++++++++++++- 10 files changed, 79 insertions(+), 12 deletions(-) diff --git a/.github/workflows/DeveloperDistribution.yml b/.github/workflows/DeveloperDistribution.yml index 78c0e83d..642f0614 100644 --- a/.github/workflows/DeveloperDistribution.yml +++ b/.github/workflows/DeveloperDistribution.yml @@ -147,6 +147,8 @@ jobs: git -C "$site" config user.name "$GITHUB_ACTOR" git -C "$site" config user.email "$GITHUB_ACTOR@users.noreply.github.com" git -C "$site" add .nojekyll index.html developer + # The custom domain of the base URL, when it has one. + if [ -e "$site/CNAME" ]; then git -C "$site" add CNAME; fi if ! git -C "$site" diff --cached --quiet; then version=$(jq -r .version js/developer/tools/distribution.json) git -C "$site" commit -m "Publish developer packages $version [#288]" diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 45df2f5a..70749846 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -2,6 +2,13 @@ ## Unreleased +- Developer environment: the distribution is served from `https://dist.webfront.fr/` (#478, ADR-021). The sources advance to 0.6.5, the + first version published under that address; `site.mjs` writes the `CNAME` file of the Pages branch and `wf run pin` + checks the pinned archive where it is served now. Libraries and environments up to 0.6.4 pin the former + `ambroise-leclerc.github.io/WebFront/` address, which redirects to the new domain without the CORS headers a browser + needs: their developer bootstrap no longer starts and they must be rebuilt with a pin on `dist.webfront.fr`. The pin + stays on 0.6.4 until 0.6.5 is published. + ## 0.8.0 - 2026-11-01 - Run authorized native programs from the specs of `webfront_add_jasmine_test` (#445): `PROGRAMS` is the owner's grant and diff --git a/docs/DEVELOPER_ENVIRONMENT.md b/docs/DEVELOPER_ENVIRONMENT.md index a09bb523..f320908a 100644 --- a/docs/DEVELOPER_ENVIRONMENT.md +++ b/docs/DEVELOPER_ENVIRONMENT.md @@ -70,6 +70,8 @@ an exact versioned environment URL and the trusted digest. The 0.6.4 release pin `https://ambroise-leclerc.github.io/WebFront/developer/0.6.4/environment.tgz`; the [publication gate](validation/developer-0.6.4-release.md) requires deployed verification before that pin is merged (the 0.6.3 gate is kept in [its report](validation/developer-0.6.3-release.md)). +The sources advance to 0.6.5, which is served from `https://dist.webfront.fr/` (ADR-021); it is not published yet and the pin +stays on 0.6.4, whose former address redirects to the new domain without CORS headers, so a browser cannot follow it. Published 0.6.2 introduced installation of the archives of `@types` packages and the manifest directory; 0.6.1, 0.6.0, 0.5.0 and 0.4.1 stay immutable, while 0.4.0 and earlier target the former include layout. The configuration pins one version and its SHA-512 rather than resolving a mutable `latest` channel. An explicit diff --git a/js/developer/environment/bundles.json b/js/developer/environment/bundles.json index 7aa3edc9..389c2189 100644 --- a/js/developer/environment/bundles.json +++ b/js/developer/environment/bundles.json @@ -39,11 +39,11 @@ "js/developer/environment/embed.mjs": "3e6bc10200939fa30d5f60a96f01eb33ddf3da87661390ad433a18366bf52547", "examples/life/ui/main.tsx": "7b1ff285d2a6b8f897ef12df872886e61ef4b24e2358a9423b76b38ab75c85d3", "examples/life/ui/style.css": "9bb55eb0f0a3287e5b7dc78af9d69608b87ff42c4d9c8a653bc83a52fe293c44", - "js/developer/tools/distribution.json": "35b7806b2d47841f7e01715b9338fb0a55c164fec77260d2267c7d433073354b", + "js/developer/tools/distribution.json": "783e75ba3bc01513e2497a0c6d4d54dbc4fd3e160989916eebcb6d378a9e4180", "js/developer/tools/archive.mjs": "da63bb9d796ddfd24ed945b15c53f66a0400eb177886fd4f1c8fd10cafb5a91b", - "js/developer/tools/distribution.mjs": "1108b61bc659dd945ba1417aa84337bca03039842d342c95815b5463d87a136e", + "js/developer/tools/distribution.mjs": "43dfdccc912693db46fd095fd78ae79325abab672d99f89fd569914ef3499cad", "js/developer/scripts/build.mjs": "7aa0358dbd8555ab83bf0380f67892e96b7e9806d4968de18e1a8eaf6e91c080", - "js/developer/webfront.project.json": "2acbc698cf93d66c4da29030179151211d8d313632dac421683c018a296b5c05", + "js/developer/webfront.project.json": "8984debb97ec09ffa768e910567adb2f642de99088549c6bfaa16287568ed1b8", "js/core/bootstrap/bootstrap.bundle.mjs": "536831257f0fc92e31911841750e1e59247f7c64e756b0fcb878efd9860a741f", "js/developer/environment/packages.bundle.mjs": "2d62f3fcdece8e898f15814d7e80fc3a27ea062f45514cf8e5c3ae32fd9d26c5", "include/webfront/system/DeveloperReleaseData.hpp": "aec3b6ce948861fce49a481784cf61ef1bc7d30e3fbb23f2d41d3a561cb3a241" diff --git a/js/developer/scripts/pin.mjs b/js/developer/scripts/pin.mjs index afdce187..cb2c4395 100644 --- a/js/developer/scripts/pin.mjs +++ b/js/developer/scripts/pin.mjs @@ -4,7 +4,7 @@ // wf run js/developer/scripts/pin.mjs // // The header must be exactly the one generated for its version, and the archive at its URL must have its integrity. -import {bootstrapHeader, sriOf} from '../tools/distribution.mjs'; +import {baseUrl, bootstrapHeader, sriOf} from '../tools/distribution.mjs'; export default async function (context) { const {project} = context; @@ -17,9 +17,14 @@ export default async function (context) { const marker = `developer/${version}/environment.tgz`; if (!url.endsWith('/' + marker) || header !== bootstrapHeader(version, url.slice(0, -marker.length), integrity)) throw new Error(`DeveloperReleaseData.hpp is not the header generated for the published ${version}`); - const response = await context.fetch(url, {signal: context.signal}); - if (!response.ok) throw new Error(`The pinned environment ${url} is not published (${response.status})`); + // The archive is fetched where the distribution is served now. A version pinned under a previous address (the + // github.io one, which redirects to the custom domain without CORS headers, so that a browser cannot follow it) is the + // same file there: the pinned integrity is what proves it. + const current = baseUrl(JSON.parse(await project.readText('js/developer/tools/distribution.json')).baseUrl); + const served = new URL(marker, current).href; + const response = await context.fetch(served, {signal: context.signal}); + if (!response.ok) throw new Error(`The pinned environment ${served} is not published (${response.status})`); if (await sriOf(new Uint8Array(await response.arrayBuffer())) !== integrity) - throw new Error(`The published ${url} does not have the pinned integrity`); + throw new Error(`The published ${served} does not have the pinned integrity`); context.console.log(`DeveloperReleaseData.hpp pins the published ${version}.`); } diff --git a/js/developer/scripts/site.mjs b/js/developer/scripts/site.mjs index 9b026280..65d429d8 100644 --- a/js/developer/scripts/site.mjs +++ b/js/developer/scripts/site.mjs @@ -4,7 +4,7 @@ // // A published version is immutable: staging may only repeat identical bytes. Nothing is modified before every byte of // an existing version has been compared. -import {versionName, versionPath, distributionFiles, sriOf} from '../tools/distribution.mjs'; +import {baseUrl, customDomain, versionName, versionPath, distributionFiles, sriOf} from '../tools/distribution.mjs'; const same = (a, b) => a.length === b.length && a.every((byte, index) => byte === b[index]); @@ -52,9 +52,18 @@ async function versionRow(project, site, version) { return `
  • ${version}: ${links}
  • `; } +// The custom domain of the base URL, written as the CNAME file of the Pages branch so that no publication depends on a +// setting made once in the repository's Pages page. A project site served at the github.io address has none. +async function writeDomain(project, site) { + const distribution = JSON.parse(await project.readText('js/developer/tools/distribution.json')); + const domain = customDomain(baseUrl(distribution.baseUrl)); + if (domain) await project.write(`${site}/CNAME`, `${domain}\n`); +} + async function writeIndex(project, site) { const versions = (await entries(project, `${site}/developer`)).filter(name => versionName.test(name)).sort(); await project.write(`${site}/.nojekyll`, ''); + await writeDomain(project, site); const rows = []; for (const version of versions) rows.push(await versionRow(project, site, version)); await project.write(`${site}/index.html`, `\nWebFront developer packages

    WebFront developer packages

    Use a version-pinned bootstrap header and SHA-512. React and its dependencies are downloaded separately from npm.

    \n`); diff --git a/js/developer/tools/distribution.json b/js/developer/tools/distribution.json index e19c7bee..e872a01e 100644 --- a/js/developer/tools/distribution.json +++ b/js/developer/tools/distribution.json @@ -1,4 +1,4 @@ { - "version": "0.6.4", - "baseUrl": "https://ambroise-leclerc.github.io/WebFront/" + "version": "0.6.5", + "baseUrl": "https://dist.webfront.fr/" } diff --git a/js/developer/tools/distribution.mjs b/js/developer/tools/distribution.mjs index 716bfa81..57ee2cb3 100644 --- a/js/developer/tools/distribution.mjs +++ b/js/developer/tools/distribution.mjs @@ -14,6 +14,18 @@ export function baseUrl(value) { return url.href; } +/** + * The custom domain a base URL is served from, or '' for a github.io project address. A custom domain is the root of the + * Pages site, so the base URL must be that root: a path would be a directory of the site, not of the domain. + */ +export function customDomain(base) { + const url = new URL(baseUrl(base)); + if (url.hostname.endsWith('.github.io')) return ''; + if (url.port) throw new Error('A distribution custom domain cannot have a port'); + if (url.pathname !== '/') throw new Error('A distribution custom domain must serve the site root'); + return url.hostname; +} + export const versionName = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/; export function versionPath(version) { diff --git a/js/developer/webfront.project.json b/js/developer/webfront.project.json index 82572607..84b37aff 100644 --- a/js/developer/webfront.project.json +++ b/js/developer/webfront.project.json @@ -63,7 +63,8 @@ "include/webfront/system/DeveloperReleaseData.hpp" ], "fetch": [ - "https://ambroise-leclerc.github.io" + "https://ambroise-leclerc.github.io", + "https://dist.webfront.fr" ] } } diff --git a/test/developer/specs/distribution-specs.mjs b/test/developer/specs/distribution-specs.mjs index d9805c9e..57bd7274 100644 --- a/test/developer/specs/distribution-specs.mjs +++ b/test/developer/specs/distribution-specs.mjs @@ -1,6 +1,6 @@ // Specs of the developer distribution: the starters, the Pages staging and the pinned bootstrap header. import {tar} from '../../../js/developer/tools/archive.mjs'; -import {bootstrapHeader, versionPath, distributionFiles} from '../../../js/developer/tools/distribution.mjs'; +import {bootstrapHeader, versionPath, distributionFiles, customDomain} from '../../../js/developer/tools/distribution.mjs'; import stageSite from '../../../js/developer/scripts/site.mjs'; import {compress} from '../../../js/developer/environment/embed.mjs'; import {createStarter} from '../../../js/developer/environment/starter.mjs'; @@ -75,6 +75,7 @@ describe('The developer distribution', () => { it('Pages staging retains older versions and refuses different bytes under an existing version', async () => { const project = memoryProject(); + await project.write('js/developer/tools/distribution.json', JSON.stringify({version: '0.1.0', baseUrl: 'https://owner.github.io/WebFront/'})); const environment = encode('environment'); const starterBytes = encode('starter'); const write = async version => { @@ -93,6 +94,7 @@ describe('The developer distribution', () => { await write('0.2.0'); await stage(); expect(await project.readText('site/developer/0.1.0/environment.tgz')).toBe('environment'); + expect(project.storage.has('site/CNAME')).toBe(false); expect(await project.readText('site/index.html')).toMatch(/developer\/0.2.0\/life-starter.tgz/); expect(await project.readText('site/developer/0.2.0/life-starter.tgz')).toBe('starter'); await write('0.3.0'); @@ -111,6 +113,33 @@ describe('The developer distribution', () => { await rejects(stage(), /checksum mismatch/); }); + it('Pages staging writes the CNAME file of a custom domain on every publication', async () => { + const project = memoryProject(); + await project.write('js/developer/tools/distribution.json', JSON.stringify({version: '0.1.0', baseUrl: 'https://dist.example.test/'})); + const environment = encode('environment'); + const starterBytes = encode('starter'); + const manifest = {version: '0.1.0', integrity: await integrity(environment), starters: {life: {archive: 'life-starter.tgz', integrity: await integrity(starterBytes)}}}; + await project.write('distribution/environment.tgz', environment); + await project.write('distribution/life-starter.tgz', starterBytes); + await project.write('distribution/provision.json', JSON.stringify(manifest)); + await project.write('distribution/DeveloperReleaseData.hpp', bootstrapHeader('0.1.0', 'https://dist.example.test/', manifest.integrity)); + const stage = () => stageSite({args: ['distribution', 'site'], project, console: {log() {}}}); + await stage(); + expect(await project.readText('site/CNAME')).toBe('dist.example.test\n'); + // A publication from a checkout that lost the file restores it. + project.storage.delete('site/CNAME'); + await stage(); + expect(await project.readText('site/CNAME')).toBe('dist.example.test\n'); + }); + + it('a custom domain is the root of the site and a github.io address has none', () => { + expect(customDomain('https://dist.example.test')).toBe('dist.example.test'); + expect(customDomain('https://owner.github.io/WebFront/')).toBe(''); + throws(() => customDomain('https://dist.example.test/developer/')); + throws(() => customDomain('https://dist.example.test:8443/')); + throws(() => customDomain('http://dist.example.test/')); + }); + it('bootstrap configuration is pinned and rejects unsafe version/base inputs', async () => { const digest = await integrity(encode('environment')); const header = bootstrapHeader('0.1.0', 'https://owner.github.io/WebFront/', digest); From 754689dffb0ca6c3d794276f7141e95eec4d70c0 Mon Sep 17 00:00:00 2001 From: Ambroise Leclerc <6860842+ambroise-leclerc@users.noreply.github.com> Date: Mon, 2 Nov 2026 10:21:18 +0100 Subject: [PATCH 2/3] Remove a former custom domain's CNAME when the base URL returns to github.io (#478) A script cannot delete a file, so site.mjs refuses a site that still has a CNAME without a custom domain, and the workflow removes it before staging so that the Pages commit records the deletion. --- .github/workflows/DeveloperDistribution.yml | 4 ++++ js/developer/scripts/site.mjs | 11 +++++++++-- test/developer/specs/distribution-specs.mjs | 18 ++++++++++++++++++ 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/.github/workflows/DeveloperDistribution.yml b/.github/workflows/DeveloperDistribution.yml index 642f0614..912011c5 100644 --- a/.github/workflows/DeveloperDistribution.yml +++ b/.github/workflows/DeveloperDistribution.yml @@ -143,6 +143,10 @@ jobs: elif [ "$result" != 2 ]; then exit "$result" fi + # A CNAME left over from a custom domain must not outlive a base URL that returns to github.io: remove it, which the + # commit below records as a deletion. The script refuses a site that still has one. + host=$(jq -r '.baseUrl | sub("^https://"; "") | sub("[/:].*$"; "")' js/developer/tools/distribution.json) + case "$host" in *.github.io) git -C "$site" rm -q --ignore-unmatch CNAME ;; esac wf run site build-distribution "$site" git -C "$site" config user.name "$GITHUB_ACTOR" git -C "$site" config user.email "$GITHUB_ACTOR@users.noreply.github.com" diff --git a/js/developer/scripts/site.mjs b/js/developer/scripts/site.mjs index 65d429d8..58f97d31 100644 --- a/js/developer/scripts/site.mjs +++ b/js/developer/scripts/site.mjs @@ -53,11 +53,18 @@ async function versionRow(project, site, version) { } // The custom domain of the base URL, written as the CNAME file of the Pages branch so that no publication depends on a -// setting made once in the repository's Pages page. A project site served at the github.io address has none. +// setting made once in the repository's Pages page. A project site served at the github.io address has none. A script +// cannot delete a file, so a CNAME left over from a custom domain is refused: the workflow removes it before staging +// (a Pages site that keeps it would still redirect to the former domain). async function writeDomain(project, site) { const distribution = JSON.parse(await project.readText('js/developer/tools/distribution.json')); const domain = customDomain(baseUrl(distribution.baseUrl)); - if (domain) await project.write(`${site}/CNAME`, `${domain}\n`); + if (domain) { + await project.write(`${site}/CNAME`, `${domain}\n`); + return; + } + if ((await entries(project, site)).includes('CNAME')) + throw new Error('The base URL has no custom domain but the site still has a CNAME file: remove it from the Pages branch'); } async function writeIndex(project, site) { diff --git a/test/developer/specs/distribution-specs.mjs b/test/developer/specs/distribution-specs.mjs index 57bd7274..f7138a0b 100644 --- a/test/developer/specs/distribution-specs.mjs +++ b/test/developer/specs/distribution-specs.mjs @@ -132,6 +132,24 @@ describe('The developer distribution', () => { expect(await project.readText('site/CNAME')).toBe('dist.example.test\n'); }); + it('Pages staging refuses to keep the CNAME of a former custom domain when the base URL returns to github.io', async () => { + const project = memoryProject(); + await project.write('js/developer/tools/distribution.json', JSON.stringify({version: '0.1.0', baseUrl: 'https://owner.github.io/WebFront/'})); + const environment = encode('environment'); + const starterBytes = encode('starter'); + const manifest = {version: '0.1.0', integrity: await integrity(environment), starters: {life: {archive: 'life-starter.tgz', integrity: await integrity(starterBytes)}}}; + await project.write('distribution/environment.tgz', environment); + await project.write('distribution/life-starter.tgz', starterBytes); + await project.write('distribution/provision.json', JSON.stringify(manifest)); + await project.write('distribution/DeveloperReleaseData.hpp', bootstrapHeader('0.1.0', 'https://owner.github.io/WebFront/', manifest.integrity)); + await project.write('site/CNAME', 'dist.example.test\n'); + const stage = () => stageSite({args: ['distribution', 'site'], project, console: {log() {}}}); + await rejects(stage(), /still has a CNAME file/); + project.storage.delete('site/CNAME'); + await stage(); + expect(project.storage.has('site/CNAME')).toBe(false); + }); + it('a custom domain is the root of the site and a github.io address has none', () => { expect(customDomain('https://dist.example.test')).toBe('dist.example.test'); expect(customDomain('https://owner.github.io/WebFront/')).toBe(''); From 4009c471ae0b4744a382add63b92c322bf018c4f Mon Sep 17 00:00:00 2001 From: Ambroise Leclerc <6860842+ambroise-leclerc@users.noreply.github.com> Date: Mon, 2 Nov 2026 10:26:46 +0100 Subject: [PATCH 3/3] Warn when the pinned address is not the one the distribution is served from (#478) --- js/developer/scripts/pin.mjs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/js/developer/scripts/pin.mjs b/js/developer/scripts/pin.mjs index cb2c4395..8ce95967 100644 --- a/js/developer/scripts/pin.mjs +++ b/js/developer/scripts/pin.mjs @@ -27,4 +27,9 @@ export default async function (context) { if (await sriOf(new Uint8Array(await response.arrayBuffer())) !== integrity) throw new Error(`The published ${served} does not have the pinned integrity`); context.console.log(`DeveloperReleaseData.hpp pins the published ${version}.`); + // The check above proves the bytes, not that a browser can start from the pinned address: when that address is not + // the one the distribution is served from, the pinned URL redirects without CORS headers and an application built with + // this header cannot start its developer environment until a version pinned on the current address is published. + if (new URL(url).origin !== new URL(current).origin) + context.console.log(`WARNING: the pinned ${url} is not on ${new URL(current).origin}; its redirect carries no CORS headers, so a browser cannot start the developer environment from this pin.`); }