From ae8a86e47b7974a41d8aec96cd13d2713ca9eb46 Mon Sep 17 00:00:00 2001 From: Mathieu2301 <21021423+Mathieu2301@users.noreply.github.com> Date: Sat, 14 Nov 2026 23:44:59 +0100 Subject: [PATCH] fix(cli): accept /app/{home_id} and /h/{home_id} home links (4.3.1) The control plane now advertises https://www.miakapp.com/app/{home_id}; every CLI refused it as a contract error, so publish and status failed. --- packages/cli/package.json | 2 +- packages/cli/src/control-plane.ts | 18 ++++++++++++------ packages/cli/src/version.ts | 2 +- packages/cli/test/app-publication.test.ts | 9 ++++++++- 4 files changed, 22 insertions(+), 9 deletions(-) diff --git a/packages/cli/package.json b/packages/cli/package.json index 0c05770..57ef033 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@miakapp/cli", - "version": "4.3.0", + "version": "4.3.1", "description": "Agent-first Miakapp command line: check, build, publish, activate and roll back home interfaces", "type": "module", "engines": { diff --git a/packages/cli/src/control-plane.ts b/packages/cli/src/control-plane.ts index 51ea5b3..b269c7f 100644 --- a/packages/cli/src/control-plane.ts +++ b/packages/cli/src/control-plane.ts @@ -25,25 +25,31 @@ export interface Discovery { readonly pushAudience: string; readonly componentsAudience: string; /** - * `https:///app?home={home_id}` when the deployment + * `https:///app/{home_id}` (or `/h/{home_id}`, or the + * legacy `/app?home={home_id}`) when the deployment * declares where residents open homes. The only source of a `home_url`; the * artifact `url` is never a resident link. */ readonly homeUrlTemplate?: string; } -const HOME_URL_SUFFIX = '/app?home={home_id}'; +/** The home link shapes a Miakapp web app answers, newest first. */ +const HOME_URL_SUFFIXES = ['/app/{home_id}', '/h/{home_id}', '/app?home={home_id}'] as const; /** - * Accepts exactly `/app?home={home_id}`: no path, no + * Accepts exactly `` followed by one of + * HOME_URL_SUFFIXES: no other path, no * credentials, no port games, nothing a server could use to point residents * somewhere else under a plausible-looking link. */ export function parseHomeUrlTemplate(value: unknown): string { - if (typeof value !== 'string' || !value.endsWith(HOME_URL_SUFFIX)) { - throw contractError('home_url_template is not /app?home={home_id}'); + const suffix = typeof value === 'string' + ? HOME_URL_SUFFIXES.find((candidate) => value.endsWith(candidate)) + : undefined; + if (typeof value !== 'string' || suffix === undefined) { + throw contractError('home_url_template is not /app/{home_id}'); } - const origin = value.slice(0, -HOME_URL_SUFFIX.length); + const origin = value.slice(0, -suffix.length); canonicalHttpsUrl(origin, 'home_url_template origin'); if (new URL(origin).origin !== origin) { throw contractError('home_url_template must be rooted at a bare origin'); diff --git a/packages/cli/src/version.ts b/packages/cli/src/version.ts index 2cdf59c..b661538 100644 --- a/packages/cli/src/version.ts +++ b/packages/cli/src/version.ts @@ -12,4 +12,4 @@ */ export const PACKAGE_NAME = '@miakapp/cli'; -export const CLI_VERSION = '4.3.0'; +export const CLI_VERSION = '4.3.1'; diff --git a/packages/cli/test/app-publication.test.ts b/packages/cli/test/app-publication.test.ts index c292f90..7e97d96 100644 --- a/packages/cli/test/app-publication.test.ts +++ b/packages/cli/test/app-publication.test.ts @@ -56,8 +56,13 @@ describe('app manifest', () => { }); describe('discovery home link', () => { - test('accepts exactly /app?home={home_id}', () => { + test('accepts exactly /app/{home_id}, /h/{home_id} or the legacy ?home=', () => { expect(parseHomeUrlTemplate(TEMPLATE)).toBe(TEMPLATE); + for (const current of ['https://app.example.test/app/{home_id}', 'https://app.example.test/h/{home_id}']) { + expect(parseHomeUrlTemplate(current)).toBe(current); + } + expect(homeUrl({ homeUrlTemplate: 'https://app.example.test/app/{home_id}' }, 'maison-a')) + .toBe('https://app.example.test/app/maison-a'); expect(homeUrl({ homeUrlTemplate: TEMPLATE }, 'maison-a')).toBe('https://app.example.test/app?home=maison-a'); expect(homeUrl({}, 'maison-a')).toBeNull(); for (const bad of [ @@ -67,6 +72,8 @@ describe('discovery home link', () => { 'https://app.example.test/app?home={home_id}&next=https://evil.example', 'https://app.example.test/v1/components/{home_id}.js', 'https://app.example.test/app?home=fixed', + 'https://app.example.test/x/app/{home_id}', + 'https://app.example.test/app/{home_id}/extra', ]) { expect(() => parseHomeUrlTemplate(bad)).toThrow(); }