feat: hot-publish shared help independently in both products

This commit is contained in:
Nick Beckley 2026-11-27 21:39:26 +00:00
parent 43ff8f1513
commit a5d2af2356
37 changed files with 394 additions and 11 deletions

View File

@ -65,7 +65,8 @@ public pages and is omitted. Public brand assets have a versioned provenance man
Read-only public HTML/browser checks found no analytics/tracking script, advertising Read-only public HTML/browser checks found no analytics/tracking script, advertising
cookie or search-engine verification meta tag in the public layout. Source contains cookie or search-engine verification meta tag in the public layout. Source contains
no Google/Bing verification file. Public privacy copy says no analytics/tracking no Google/Bing verification file. Read-only DNS inspection found an existing search
verification TXT record on the unchanged apex; that verification remains in place. Public privacy copy says no analytics/tracking
cookies. Preserve any independent live Nginx verification location discovered during cookies. Preserve any independent live Nginx verification location discovered during
administrator cutover preflight; restricted receipt access cannot inspect arbitrary administrator cutover preflight; restricted receipt access cannot inspect arbitrary
root-owned Nginx files, so do not silently replace the live vhost with a template. root-owned Nginx files, so do not silently replace the live vhost with a template.
@ -98,6 +99,25 @@ No copy or design expansion is included.
| Infrastructure | Existing app retains service/port/releases/config/uploads/SQL/keys and signed compressed deploy process. Website gets independent identities, keys, port 5004 in Production, port 5051 in Development, release root and receipts. | | Infrastructure | Existing app retains service/port/releases/config/uploads/SQL/keys and signed compressed deploy process. Website gets independent identities, keys, port 5004 in Production, port 5051 in Development, release root and receipts. |
| Email/AI/background integrations | Support mailboxes/sender domain remain plotdirector.com. Do not change SMTP keys, held email/background workers, external-processing flags, acceptance fence or egress restrictions. Review pending old-host links before owner approval. | | Email/AI/background integrations | Support mailboxes/sender domain remain plotdirector.com. Do not change SMTP keys, held email/background workers, external-processing flags, acceptance fence or egress restrictions. Review pending old-host links before owner approval. |
The application HelpService preserves file-source fallback and additionally hot-reloads
an explicitly configured, independently installed approved content publication. Both
services keep separate artifact stores; neither reads the other's store/process.
`Evidence/domain-references.json` records concrete hard-coded origin locations. `Evidence/domain-references.json` records concrete hard-coded origin locations.
Dynamic URLs also depend on request/proxy host; a string search alone is insufficient. Dynamic URLs also depend on request/proxy host; a string search alone is insufficient.
No application projects, assemblies, namespaces, users, subscriptions or data are renamed. No application projects, assemblies, namespaces, users, subscriptions or data are renamed.
## Development operations findings
The installed routine code-only baseline still pointed at 9b1770d9 although the
running, already-qualified release was 9dcd29d4 with a complete 338-entry Development
history. Reconciled only the protected baseline files after verifying the existing
signed package, installed manifest/DLL/current pointer and complete live schema/history
under the deployment lock. Previous baseline retained; no SQL, backup/restore or
service operation occurred. Evidence: development-baseline-refresh.json. This restores
the routine guarded command rather than bypassing its schema fence.
`/srv` has about 1.1 GiB available after removing only this task's failed temporary
build outputs. Clean qualification builds now use the system volume under
`~/.local/share/plotdirector-development/worktrees`, with ample measured free space.
No unrelated checkouts, releases, backups or user files were deleted.

View File

@ -53,7 +53,12 @@ unchanged comparison. Do not modify that site, port 5002, reserved 5003 or any o
unrelated service. Verify port 5004 is free. The application stays on port 5001 with unrelated service. Verify port 5004 is free. The application stays on port 5001 with
its existing service, runtime identity, environment file, uploads, secrets, database, its existing service, runtime identity, environment file, uploads, secrets, database,
key ring/discriminator and acceptance/egress/worker controls. Never rotate or copy key ring/discriminator and acceptance/egress/worker controls. Never rotate or copy
Data Protection material into the website. Data Protection material into the website. Merge the prepared non-secret
`application-origin.env.example` values into the existing application configuration:
`Site__WebsiteBaseUrl=https://plotdirector.com` and an explicit AllowedHosts list for
app.plotdirector.com, the legacy apex bridge and loopback health. Set `HelpContent__Path=/srv/plotdirector/shared/help/current` after installing the
same approved Production help artifact into the application's own protected store.
Keep all other application environment values intact; do not replace its environment file.
## Independent website provisioning (web1) ## Independent website provisioning (web1)
@ -142,7 +147,9 @@ on app.plotdirector.com. Do not redirect every missing URL to a homepage. Review
new attribute routes against the compatibility template before activation. new attribute routes against the compatibility template before activation.
Legacy `/api`, `/hubs`, `/native-companion`, `/word-companion` and `/uploads` traffic Legacy `/api`, `/hubs`, `/native-companion`, `/word-companion` and `/uploads` traffic
is explicitly proxied to the existing application backend. Preserve request bodies, is explicitly proxied to the existing application backend. The taskpane-specific
JavaScript, notification CSS/JavaScript and legacy manifest icons are also proxied
explicitly, so the bridged taskpane does not lose its scripts or styling. Preserve request bodies,
Authorization/Stripe signatures, queries and websocket upgrade semantics. These Authorization/Stripe signatures, queries and websocket upgrade semantics. These
protocol clients cannot safely rely on ordinary browser redirects. The temporary protocol clients cannot safely rely on ordinary browser redirects. The temporary
bridge preserves endpoint availability, not a promise to migrate origin-bound cookie, bridge preserves endpoint availability, not a promise to migrate origin-bound cookie,

View File

@ -0,0 +1,39 @@
{
"passed": true,
"checks": [
"unauthenticated root challenges with Projects return",
"branded /Account/Login",
"branded /Account/Register",
"branded /Account/ForgotPassword",
"branded /Account/ResendVerificationEmail",
"branded /Account/VerifyEmailConfirmation",
"branded /Account/ResetPassword",
"branded /Account/VerifyEmail",
"branded /Account/AccessDenied",
"branded /Account/Login",
"normal login returns requested Projects",
"authenticated root lands on Projects",
"authenticated sign-in honors safe deep link",
"external return URL rejected",
"persisted theme plotdirector",
"persisted theme warm-light",
"persisted theme warm-dark",
"persisted theme modern-light",
"persisted theme modern-dark",
"persisted theme rose-pink",
"persisted theme baby-blue",
"existing synthetic project",
"existing synthetic book/manuscript workspace",
"real authenticated Context Workspace",
"real SignalR connection established",
"Word taskpane route (browser only)",
"existing subscription page; no payment initiated",
"application-owned Projects PWA manifest",
"logout returns branded application sign-in",
"unauthenticated deep-link login returns requested project"
],
"errors": [],
"physicalWordTested": false,
"externalPaymentsTested": false,
"realEmailDeliveryTested": false
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

View File

@ -0,0 +1,6 @@
{
"passed": true,
"websitePidBefore": "984560",
"websitePidAfter": "984560",
"applicationSourceCommit": "43ff8f15132f03e3abc36c943bfc3916da3a14da"
}

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 167 KiB

View File

@ -0,0 +1,13 @@
{
"passed": true,
"checks": [
"enabled MFA on dedicated synthetic account",
"real pending MFA challenge uses public brand",
"real recovery challenge uses public brand",
"real TOTP verification returns requested protected deep link",
"original disabled MFA state restored"
],
"fixtureMfaRestored": true,
"failedStep": null,
"noSecretsOrRecoveryCodesRecorded": true
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 188 KiB

View File

@ -0,0 +1,13 @@
{
"passed": true,
"installedChromium": true,
"checks": [
"real installed PWA launches authenticated Projects by default",
"all authenticated themes retained",
"offline requests fail honestly; no cached authenticated response",
"installed signed-out authentication keeps public brand",
"installed sign-in returns Projects"
],
"ownerPwaMigrated": false,
"physicalWordTested": false
}

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,9 @@
{
"passed": true,
"websitePidBefore": "984560",
"websitePidAfter": "984560",
"applicationRollbackSource": "9dcd29d423b20e373e49fb28180d993c40aa165d",
"applicationRestoredSource": "43ff8f15132f03e3abc36c943bfc3916da3a14da",
"signedCompressedPackages": true,
"sqlExecuted": 0
}

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,7 @@
{
"passed": true,
"version": "public-brand-v1",
"websiteSourceCommit": "376b0bfab9dd5244d695f3fc3108d9e577a7b807",
"sharedFiles": 114,
"applicationSourceContentMatches": true
}

View File

@ -0,0 +1 @@
{"completeLiveHistory":true,"databaseWrites":false,"historyEntries":338,"passed":true,"previousBaselineRetained":"/var/lib/plotdirector-dev-deployment/baseline-before-separation-20261127T211501Z","previousSource":"9b1770d96d17b7b2cc4f42efb936d822d20fe31e","schema":"3d6e163f7cb8fff6bd17834ae8097dcf68be03894ce644844621dc191336cb7a","serviceRestarted":false,"signedPackageVerified":true,"sourceCommit":"9dcd29d423b20e373e49fb28180d993c40aa165d"}

View File

@ -0,0 +1,8 @@
{
"channel": "Development",
"version": "2026.11.27-separation-development",
"manifestSha256": "de91a5e48252e3b0ababecac84d84758554de9686dddd7da8860fe1b46b8772e",
"articles": 409,
"sourceCommit": "43ff8f15132f03e3abc36c943bfc3916da3a14da",
"serviceRestarted": false
}

View File

@ -0,0 +1,14 @@
{
"plotdirector.com": [
"85.190.124.132"
],
"app.plotdirector.com": [
"plotdirector.com.",
"85.190.124.132"
],
"dev.plotdirector.com": [
"77.104.168.236"
],
"website-dev.plotdirector.com": [],
"apexVerificationTxtPresent": true
}

View File

@ -0,0 +1,16 @@
{
"passed": true,
"developmentPublicationConsumed": true,
"wrongProductionChannelRejected": true,
"articleIdentifiersPreserved": true,
"hotReloadVerified": true,
"previousPublicationRestored": true,
"servicePidsBefore": {
"plotdirector-dev": "963308",
"plotdirector-website-dev": "984560"
},
"servicePidsAfter": {
"plotdirector-dev": "963308",
"plotdirector-website-dev": "984560"
}
}

View File

@ -0,0 +1,17 @@
{
"passed": true,
"sandboxOnly": true,
"checks": [
"both prepared vhosts pass nginx -t",
"public root goes to independent website",
"legacy browser path/query /Projects/Details/123",
"legacy browser path/query /Account/ResetPassword",
"legacy browser path/query /problem-solver/workspace/characters",
"legacy browser path/query /admin/writing-solver",
"legacy browser path/query /onboarding",
"legacy API preserves POST body query and bearer header",
"legacy websocket upgrade reaches application",
"application host and noindex isolated",
"health endpoint denied on both public hosts"
]
}

View File

@ -1,5 +1,5 @@
{ {
"passed": false, "passed": true,
"pages": [ "pages": [
{ {
"path": "/", "path": "/",
@ -15,15 +15,15 @@
}, },
{ {
"path": "/pricing", "path": "/pricing",
"samePublicText": false, "samePublicText": true,
"oldCharacters": 3661, "oldCharacters": 3661,
"newCharacters": 3662 "newCharacters": 3661
}, },
{ {
"path": "/help", "path": "/help",
"samePublicText": false, "samePublicText": true,
"oldCharacters": 1897, "oldCharacters": 1897,
"newCharacters": 1895 "newCharacters": 1897
}, },
{ {
"path": "/about", "path": "/about",

View File

@ -538,7 +538,9 @@
"GET /Help/Article/{contextKey}", "GET /Help/Article/{contextKey}",
"* /writing-problems/{**path} => 308 /problem-solver/{**path}", "* /writing-problems/{**path} => 308 /problem-solver/{**path}",
"POST /problem-solver/answer", "POST /problem-solver/answer",
"GET /problem-solver?state={protectedHistory}" "GET /problem-solver?state={protectedHistory}",
"GET /HelpDrawer/Article?key={publishedContextKey}",
"GET /HelpDrawer/Image?file={publishedAsset}"
], ],
"crawlerFiles": [ "crawlerFiles": [
"/robots.txt", "/robots.txt",

View File

@ -0,0 +1,34 @@
{
"passed": true,
"origin": "http://192.168.10.10:5051",
"checks": [
"1440 /",
"1440 /features",
"1440 /pricing",
"1440 /problem-solver",
"1440 /problem-solver/browse",
"1440 /help",
"1440 /about",
"1440 /contact",
"1440 /privacy",
"1440 /terms",
"390 /",
"390 /features",
"390 /pricing",
"390 /problem-solver",
"390 /problem-solver/browse",
"390 /help",
"390 /about",
"390 /contact",
"390 /privacy",
"390 /terms",
"mobile navigation",
"server-rendered help search",
"published help article",
"Problem Solver completed 5 answers",
"no website PWA installation",
"application account links"
],
"errors": [],
"failed": []
}

View File

@ -0,0 +1 @@
{"operation": "6fa8d162-8bea-4cbf-bc6d-2b2d4c51bfe4", "release": "website-separation-dev-2", "kind": "deploy", "startedUtc": "2026-11-27T21:14:11Z", "status": "activated", "sourceCommit": "376b0bfab9dd5244d695f3fc3108d9e577a7b807", "packageSha256": "0778827a54a8a4150e793e0c74400831031d588036a84d69ecccd21ca5759775", "manifestSha256": "2ffe8b12c95e0cb3f72d5d935b6ba6996f1bcee7269d3e706cff7dec5116997a", "previous": "/opt/plotdirector-website-dev/releases/website-separation-dev-1/app", "health": {"healthy": true, "product": "PlotDirector.Website", "sourceCommit": "376b0bfab9dd5244d695f3fc3108d9e577a7b807"}, "completedUtc": "2026-11-27T21:14:12Z"}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 MiB

View File

@ -0,0 +1,10 @@
{
"origin": "http://192.168.10.10:5051",
"productionPolicy": false,
"baselineUrls": 449,
"renderedPages": 527,
"internalPaths": 554,
"assets": 42,
"errors": [],
"passed": true
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 299 KiB

View File

@ -0,0 +1,10 @@
{
"origin": "http://127.0.0.1:5053",
"productionPolicy": true,
"baselineUrls": 449,
"renderedPages": 527,
"internalPaths": 554,
"assets": 42,
"errors": [],
"passed": true
}

View File

@ -0,0 +1 @@
{"operation": "f7f6e2a4-e08e-4f29-bc95-e6c521766d0b", "release": "website-separation-dev-2", "kind": "rollback", "startedUtc": "2026-11-27T21:14:14Z", "status": "activated", "sourceCommit": "376b0bfab9dd5244d695f3fc3108d9e577a7b807", "packageSha256": "0778827a54a8a4150e793e0c74400831031d588036a84d69ecccd21ca5759775", "manifestSha256": "2ffe8b12c95e0cb3f72d5d935b6ba6996f1bcee7269d3e706cff7dec5116997a", "previous": "/opt/plotdirector-website-dev/releases/website-separation-dev-1/app", "health": {"healthy": true, "product": "PlotDirector.Website", "sourceCommit": "376b0bfab9dd5244d695f3fc3108d9e577a7b807"}, "completedUtc": "2026-11-27T21:14:15Z"}

View File

@ -0,0 +1 @@
{"operation": "80264e72-3ba3-4ee7-8080-188237d0deb7", "release": "website-separation-dev-1", "kind": "rollback", "startedUtc": "2026-11-27T21:14:12Z", "status": "activated", "sourceCommit": "72a384af8839b7685e99cf50f7ac2824790caaf6", "packageSha256": "d7ffce7500180be5e60126050f94684ffacaa76cb1525b69fec00a2682785fb1", "manifestSha256": "8984124423051e2021fff0c429e842f5a7d74afef9af86b15c2677b6c523b288", "previous": "/opt/plotdirector-website-dev/releases/website-separation-dev-2/app", "health": {"healthy": true, "product": "PlotDirector.Website", "sourceCommit": "72a384af8839b7685e99cf50f7ac2824790caaf6"}, "completedUtc": "2026-11-27T21:14:13Z"}

View File

@ -0,0 +1,41 @@
{
"passed": true,
"checks": [
{
"route": "/",
"status": 200,
"bytes": 33802,
"applicationBefore": "inactive",
"applicationAfter": "inactive"
},
{
"route": "/pricing",
"status": 200,
"bytes": 19821,
"applicationBefore": "inactive",
"applicationAfter": "inactive"
},
{
"route": "/help",
"status": 200,
"bytes": 15605,
"applicationBefore": "inactive",
"applicationAfter": "inactive"
},
{
"route": "/problem-solver",
"status": 200,
"bytes": 10868,
"applicationBefore": "inactive",
"applicationAfter": "inactive"
},
{
"route": "/sitemap.xml",
"status": 200,
"bytes": 87342,
"applicationBefore": "inactive",
"applicationAfter": "inactive"
}
],
"method": "Observed guarded Development application activation while its service was stopped"
}

View File

@ -28,7 +28,41 @@ internal static class ApplicationDomainBoundaryTests
Check(controller.Login() is RedirectToActionResult {ControllerName:"Projects"},"Authenticated sign in opens Projects"); Check(controller.Login() is RedirectToActionResult {ControllerName:"Projects"},"Authenticated sign in opens Projects");
Check(controller.Login("/Books/Details/123") is LocalRedirectResult {Url:"/Books/Details/123"},"Safe deep link survives"); Check(controller.Login("/Books/Details/123") is LocalRedirectResult {Url:"/Books/Details/123"},"Safe deep link survives");
foreach(var url in new[]{"https://example.com/","//example.com/","/\\example.com/"})Check(controller.Login(url) is RedirectToActionResult {ControllerName:"Projects"},"Reject open redirect"); foreach(var url in new[]{"https://example.com/","//example.com/","/\\example.com/"})Check(controller.Login(url) is RedirectToActionResult {ControllerName:"Projects"},"Reject open redirect");
var publication = Path.Combine(Path.GetTempPath(), "pd-help-publication-" + Guid.NewGuid().ToString("N"));
Directory.CreateDirectory(publication);
try
{
File.WriteAllText(Path.Combine(publication, "manifest.json"), "{\"version\":\"first\"}");
var article = new PlotLine.Models.HelpArticle { Title="Approved help",Category="Projects",CategorySlug="projects",Slug="overview",ContextKey="projects.overview",MarkdownContent="# Approved" };
File.WriteAllText(Path.Combine(publication,"articles.json"),System.Text.Json.JsonSerializer.Serialize(new[]{article}));
var contentConfig=new ConfigurationBuilder().AddInMemoryCollection(new Dictionary<string,string?> { ["HelpContent:Path"]=publication }).Build();
var help=new HelpService(null!,contentConfig);
Check(help.GetByContextKey("projects.overview")?.Title=="Approved help", "Application consumes approved help artifact");
article.Title="Updated approved help";
File.WriteAllText(Path.Combine(publication,"articles.json"),System.Text.Json.JsonSerializer.Serialize(new[]{article}));
File.WriteAllText(Path.Combine(publication,"manifest.json"),"{\"version\":\"second\"}");
Check(help.GetBySlugs("projects","overview")?.Title=="Updated approved help", "Application help publication hot reload preserves identifiers");
}
finally { Directory.Delete(publication,true); }
var queue = new EmailCapture();
http.Request.Host = new HostString("app.plotdirector.com");
var email = new EmailService(Microsoft.Extensions.Options.Options.Create(new PlotLine.Models.EmailSettings()),
services.GetRequiredService<IConfiguration>(), queue, new HttpContextAccessor { HttpContext = http },
Microsoft.Extensions.Logging.Abstractions.NullLogger<EmailService>.Instance);
email.SendVerificationEmailAsync("domain-fixture@example.invalid", "Synthetic", Guid.NewGuid()).GetAwaiter().GetResult();
email.SendPasswordResetEmailAsync("domain-fixture@example.invalid", "Synthetic", Guid.NewGuid()).GetAwaiter().GetResult();
Check(queue.Items.Count == 2 && queue.Items[0].PlainTextBody!.Contains("https://app.plotdirector.com/Account/VerifyEmail?")
&& queue.Items[1].PlainTextBody!.Contains("https://app.plotdirector.com/Account/ResetPassword?"), "Verification/reset emails use app origin");
Console.WriteLine("PASS Application domain boundary, Projects landing, authenticated sign in and safe deep links"); Console.WriteLine("PASS Application domain boundary, Projects landing, authenticated sign in and safe deep links");
} }
private sealed class EmailCapture : PlotLine.Data.IEmailQueueRepository
{
public List<PlotLine.Models.EmailQueueItem> Items {get;}=[];
public Task<long> CreateAsync(PlotLine.Models.EmailQueueItem item){Items.Add(item);return Task.FromResult((long)Items.Count);}
public Task<IReadOnlyList<PlotLine.Models.EmailQueueItem>> DequeueBatchAsync(int size)=>throw new NotSupportedException();
public Task MarkSentAsync(long id)=>throw new NotSupportedException();
public Task MarkFailedAsync(long id,string error)=>throw new NotSupportedException();
public Task ResetStuckSendingAsync()=>throw new NotSupportedException();
}
private static void Check(bool ok,string message){if(!ok)throw new InvalidOperationException(message);} private static void Check(bool ok,string message){if(!ok)throw new InvalidOperationException(message);}
} }

View File

@ -0,0 +1,31 @@
// Normal Development login with an existing dedicated synthetic identity; no owner credentials.
const {chromium}=require('playwright'),fs=require('node:fs'),assert=require('node:assert/strict');
const file=process.argv[2];assert(file?.startsWith('/tmp/pd-dev-browser-'));const identity=JSON.parse(fs.readFileSync(file));assert.equal(identity.Database,'PlotDirector_Development');assert(identity.Email.startsWith('pwa-browser-'));
const base='https://dev.plotdirector.com',out=process.env.DOMAIN_EVIDENCE_DIR||'/tmp/plotdirector-app-domain-browser';fs.mkdirSync(out,{recursive:true});
(async()=>{const browser=await chromium.launch();const checks=[],errors=[];let page,originalTheme;const login=async()=>{await page.locator('#Email').fill(identity.Email);await page.locator('#Password').fill(identity.Password);await Promise.all([page.waitForNavigation(),page.locator('form button[type=submit]').click()]);};
try{const context=await browser.newContext({viewport:{width:1440,height:1000}});page=await context.newPage();await page.addInitScript(()=>document.addEventListener('context-connection-ready',()=>window.__qualificationSignalRConnected=true,true));page.on('pageerror',e=>errors.push(e.message));
await page.goto(base+'/');assert.equal(new URL(page.url()).pathname,'/Account/Login');assert(new URL(page.url()).searchParams.get('ReturnUrl')?.toLowerCase().startsWith('/projects')||new URL(page.url()).searchParams.get('returnUrl')?.toLowerCase().startsWith('/projects'));checks.push('unauthenticated root challenges with Projects return');
for(const route of ['/Account/Login','/Account/Register','/Account/ForgotPassword','/Account/ResendVerificationEmail','/Account/VerifyEmailConfirmation','/Account/ResetPassword?token=00000000-0000-0000-0000-000000000000','/Account/VerifyEmail?token=00000000-0000-0000-0000-000000000000','/Account/AccessDenied','/Account/Login?companion=true&returnUrl=/word-companion']){
const r=await page.goto(base+route);assert(r.status()<500,route);assert.equal(await page.locator('html').getAttribute('data-site-theme'),'public',route);assert.equal(await page.locator('html').getAttribute('data-theme'),'light',route);checks.push('branded '+route.split('?')[0]);
}
await page.goto(base+'/Projects');await login();assert.equal(new URL(page.url()).pathname,'/Projects');checks.push('normal login returns requested Projects');
await page.goto(base+'/');assert.equal(new URL(page.url()).pathname,'/Projects');checks.push('authenticated root lands on Projects');
const projectLink=await page.locator('a[href^="/Projects/Details/"]').first().getAttribute('href');assert(projectLink);const project=Number(projectLink.split('/').pop());
await page.goto(base+'/Account/Login?returnUrl='+encodeURIComponent(projectLink));assert.equal(new URL(page.url()).pathname,projectLink);checks.push('authenticated sign-in honors safe deep link');
await page.goto(base+'/Account/Login?returnUrl=https://example.invalid/');assert.equal(new URL(page.url()).pathname,'/Projects');checks.push('external return URL rejected');
originalTheme=await page.locator('html').getAttribute('data-app-theme');assert(originalTheme);
const setTheme=async theme=>{const token=await page.locator('[data-appearance-form] input[name="__RequestVerificationToken"]').inputValue();const r=await page.request.post(base+'/Appearance/Theme',{form:{themeKey:theme,__RequestVerificationToken:token}});assert.equal(r.status(),200);await page.reload();assert.equal(await page.locator('html').getAttribute('data-app-theme'),theme);};
for(const theme of ['plotdirector','warm-light','warm-dark','modern-light','modern-dark','rose-pink','baby-blue']){await setTheme(theme);checks.push('persisted theme '+theme);if(['modern-dark','warm-light'].includes(theme))await page.screenshot({path:out+'/projects-'+theme+'.png',fullPage:true});}
await setTheme(originalTheme);originalTheme=null;
await page.goto(base+projectLink);assert((await page.locator('main').innerText()).length>50);checks.push('existing synthetic project');
const bookLink=await page.locator('a[href^="/Books/Details/"]').first().getAttribute('href');assert(bookLink,'fixture book required');const book=Number(bookLink.split('/').pop());await page.goto(base+bookLink);assert((await page.locator('main').innerText()).length>50);checks.push('existing synthetic book/manuscript workspace');
const hub=[];page.on('request',r=>{if(r.url().includes('/hubs/'))hub.push(r.url().split('?')[0]);});
await page.goto(base+`/Writing/Context?projectId=${project}&bookId=${book}`);await page.locator('[data-context-workspace]').waitFor();await page.waitForFunction(()=>window.__qualificationSignalRConnected===true,null,{timeout:20000});await page.screenshot({path:out+'/context-workspace.png',fullPage:true});checks.push('real authenticated Context Workspace');assert(hub.length>0,'real SignalR negotiation');checks.push('real SignalR connection established');
await page.goto(base+'/word-companion');assert.equal(new URL(page.url()).pathname,'/word-companion');checks.push('Word taskpane route (browser only)');
await page.goto(base+'/ManageAccount/Subscription');assert.equal(new URL(page.url()).pathname,'/ManageAccount/Subscription');assert((await page.locator('main').innerText()).length>50);checks.push('existing subscription page; no payment initiated');
const manifest=await (await page.request.get(base+'/site.webmanifest')).json();assert.equal(manifest.start_url,'/Projects');assert.equal(manifest.scope,'/');assert.equal(manifest.id,'/Projects');checks.push('application-owned Projects PWA manifest');
const logout=page.locator('form[action="/Account/Logout"]').first();await Promise.all([page.waitForNavigation(),logout.evaluate(f=>f.requestSubmit())]);assert.equal(new URL(page.url()).pathname,'/Account/Login');assert.equal(await page.locator('html').getAttribute('data-site-theme'),'public');checks.push('logout returns branded application sign-in');
await page.goto(base+projectLink);assert.equal(new URL(page.url()).pathname,'/Account/Login');await login();assert.equal(new URL(page.url()).pathname,projectLink);checks.push('unauthenticated deep-link login returns requested project');
assert.deepEqual(errors,[]);fs.writeFileSync(out+'/results.json',JSON.stringify({passed:true,checks,errors,physicalWordTested:false,externalPaymentsTested:false,realEmailDeliveryTested:false},null,2));console.log(JSON.stringify({passed:true,checks:checks.length,out}));
}catch(e){fs.writeFileSync(out+'/results.json',JSON.stringify({passed:false,checks,errors,error:String(e)},null,2));throw e;}
finally{if(originalTheme&&page){try{const token=await page.locator('[data-appearance-form] input[name="__RequestVerificationToken"]').inputValue();await page.request.post(base+'/Appearance/Theme',{form:{themeKey:originalTheme,__RequestVerificationToken:token}});}catch{}}await browser.close();}})().catch(e=>{console.error(e);process.exitCode=1;});

View File

@ -0,0 +1,11 @@
// Dedicated synthetic account only. Restore its initially-disabled MFA in finally.
const {chromium}=require('playwright'),fs=require('node:fs'),crypto=require('node:crypto'),assert=require('node:assert/strict');const file=process.argv[2];assert(file?.startsWith('/tmp/pd-dev-browser-'));const i=JSON.parse(fs.readFileSync(file));assert.equal(i.Database,'PlotDirector_Development');assert(i.Email.startsWith('pwa-browser-'));const base='https://dev.plotdirector.com',out='/tmp/plotdirector-app-domain-mfa';fs.mkdirSync(out,{recursive:true});
function totp(secret,stepOffset=0){let bits='';for(const c of secret.replace(/[=\s]/g,'').toUpperCase()){const n='ABCDEFGHIJKLMNOPQRSTUVWXYZ234567'.indexOf(c);assert(n>=0);bits+=n.toString(2).padStart(5,'0');}const bytes=[];for(let n=0;n+8<=bits.length;n+=8)bytes.push(parseInt(bits.slice(n,n+8),2));const counter=Buffer.alloc(8);counter.writeBigUInt64BE(BigInt(Math.floor(Date.now()/30000)+stepOffset));const hash=crypto.createHmac('sha1',Buffer.from(bytes)).update(counter).digest(),offset=hash.at(-1)&15;return ((hash.readUInt32BE(offset)&0x7fffffff)%1000000).toString().padStart(6,'0');}
(async()=>{const b=await chromium.launch();let admin,enabled=false,step='initial login';const checks=[];const login=async p=>{await p.locator('#Email').fill(i.Email);await p.locator('#Password').fill(i.Password);await Promise.all([p.waitForNavigation(),p.locator('form button[type=submit]').click()]);};try{
admin=await (await b.newContext()).newPage();await admin.goto(base+'/Account/Login');await login(admin);assert.equal(new URL(admin.url()).pathname,'/Projects','fixture MFA must initially be disabled');
const deep=await admin.locator('a[href^="/Projects/Details/"]').first().getAttribute('href');assert(deep);step='enable synthetic MFA';await admin.goto(base+'/ManageAccount/EnableTwoFactor');const secret=await admin.locator('#SecretKey').inputValue();await admin.locator('#Code').fill(totp(secret));enabled=true;await Promise.all([admin.waitForNavigation(),admin.locator('form[action="/ManageAccount/EnableTwoFactor"] button[type=submit]').click()]);assert(['/ManageAccount/RecoveryCodes','/Account/Login'].includes(new URL(admin.url()).pathname));checks.push('enabled MFA on dedicated synthetic account');
const p=await (await b.newContext()).newPage();await p.goto(base+'/Account/Login?returnUrl='+encodeURIComponent(deep));step='password then MFA challenge';await login(p);assert.equal(new URL(p.url()).pathname,'/Account/TwoFactor');assert.equal(await p.locator('html').getAttribute('data-site-theme'),'public');checks.push('real pending MFA challenge uses public brand');
await p.goto(base+'/Account/TwoFactorRecovery?returnUrl='+encodeURIComponent(deep));assert.equal(new URL(p.url()).pathname,'/Account/TwoFactorRecovery');assert.equal(await p.locator('html').getAttribute('data-site-theme'),'public');checks.push('real recovery challenge uses public brand');
await p.goto(base+'/Account/TwoFactor?returnUrl='+encodeURIComponent(deep));step='verify authenticator and deep link';const code=totp(secret,1);const returned=p.waitForURL('**'+deep);for(let n=0;n<6;n++)await p.locator('[data-two-factor-digit]').nth(n).fill(code[n]);await returned;assert.equal(new URL(p.url()).pathname,deep);checks.push('real TOTP verification returns requested protected deep link');admin=p;
}catch(e){console.log(JSON.stringify({errorType:e.name,step,path:admin?new URL(admin.url()).pathname:null}));process.exitCode=1;}
finally{if(enabled&&admin){try{await admin.goto(base+'/ManageAccount/DisableTwoFactor');await admin.locator('#CurrentPassword').fill(i.Password);await Promise.all([admin.waitForNavigation(),admin.locator('form[action="/ManageAccount/DisableTwoFactor"] button[type=submit]').click()]);assert.notEqual(new URL(admin.url()).pathname,'/ManageAccount/DisableTwoFactor');enabled=false;checks.push('original disabled MFA state restored');}catch(e){console.log(JSON.stringify({errorType:e.name,step,path:admin?new URL(admin.url()).pathname:null}));process.exitCode=1;}}fs.writeFileSync(out+'/results.json',JSON.stringify({passed:!process.exitCode,checks,fixtureMfaRestored:!enabled,failedStep:process.exitCode?step:null,noSecretsOrRecoveryCodesRecorded:true},null,2));await b.close();console.log(JSON.stringify({passed:!process.exitCode,checks:checks.length,fixtureMfaRestored:!enabled}));}})().catch(()=>{console.error('MFA acceptance failed; no credentials recorded.');process.exitCode=1;});

View File

@ -0,0 +1,14 @@
// Real installed Chromium PWA against Development, with only a dedicated synthetic account.
const {chromium}=require('playwright'),fs=require('node:fs'),assert=require('node:assert/strict');const file=process.argv[2];assert(file?.startsWith('/tmp/pd-dev-browser-'));const i=JSON.parse(fs.readFileSync(file));assert.equal(i.Database,'PlotDirector_Development');assert(i.Email.startsWith('pwa-browser-'));
const base='https://dev.plotdirector.com',out=process.env.DOMAIN_EVIDENCE_DIR||'/tmp/plotdirector-app-domain-pwa';fs.mkdirSync(out,{recursive:true});
(async()=>{const profile=fs.mkdtempSync('/tmp/pd-domain-pwa-');const context=await chromium.launchPersistentContext(profile,{headless:false,viewport:{width:1440,height:1000}}),cdp=await context.browser().newBrowserCDPSession(),manifestId=base+'/Projects';const checks=[];let installed=false;try{
const tab=context.pages()[0];await tab.goto(base+'/Projects');await tab.locator('#Email').fill(i.Email);await tab.locator('#Password').fill(i.Password);await Promise.all([tab.waitForNavigation(),tab.locator('form button[type=submit]').click()]);assert.equal(new URL(tab.url()).pathname,'/Projects');
await cdp.send('PWA.install',{manifestId,installUrlOrBundleUrl:base+'/Projects'});installed=true;await cdp.send('PWA.changeAppUserSettings',{manifestId,displayMode:'standalone'});
const opened=context.waitForEvent('page');await cdp.send('PWA.launch',{manifestId});const app=await opened;await app.waitForLoadState();assert.equal(new URL(app.url()).pathname,'/Projects');assert(await app.evaluate(()=>matchMedia('(display-mode: standalone)').matches));checks.push('real installed PWA launches authenticated Projects by default');
assert.equal(await app.locator('[data-app-theme-choice]').count(),7);checks.push('all authenticated themes retained');await app.screenshot({path:out+'/installed-projects.png',fullPage:true});
await context.setOffline(true);const offline=await app.evaluate(async()=>{try{await fetch('/Projects?offline-acceptance=1',{cache:'no-store'});return false;}catch{return true;}});assert(offline,'no authenticated offline cached response');await context.setOffline(false);checks.push('offline requests fail honestly; no cached authenticated response');
const logout=app.locator('form[action="/Account/Logout"]').first();await Promise.all([app.waitForNavigation(),logout.evaluate(f=>f.requestSubmit())]);assert.equal(new URL(app.url()).pathname,'/Account/Login');assert.equal(await app.locator('html').getAttribute('data-site-theme'),'public');assert.equal(await app.locator('html').getAttribute('data-theme'),'light');checks.push('installed signed-out authentication keeps public brand');
await app.locator('#Email').fill(i.Email);await app.locator('#Password').fill(i.Password);await Promise.all([app.waitForNavigation(),app.locator('form button[type=submit]').click()]);assert.equal(new URL(app.url()).pathname,'/Projects');checks.push('installed sign-in returns Projects');
fs.writeFileSync(out+'/results.json',JSON.stringify({passed:true,installedChromium:true,checks,ownerPwaMigrated:false,physicalWordTested:false},null,2));console.log(JSON.stringify({passed:true,checks:checks.length,out}));
}catch(e){fs.writeFileSync(out+'/results.json',JSON.stringify({passed:false,checks,error:String(e)},null,2));throw e;}
finally{await context.setOffline(false).catch(()=>{});if(installed)await cdp.send('PWA.uninstall',{manifestId}).catch(()=>{});await context.close();fs.rmSync(profile,{recursive:true,force:true});}})().catch(e=>{console.error(e);process.exitCode=1;});

View File

@ -20,13 +20,31 @@ public interface IHelpService
IReadOnlyList<HelpCoverageItem> GetCoverage(); IReadOnlyList<HelpCoverageItem> GetCoverage();
} }
public sealed class HelpService(IWebHostEnvironment environment) : IHelpService public sealed class HelpService(IWebHostEnvironment environment, IConfiguration? configuration = null) : IHelpService
{ {
private readonly object cacheLock = new(); private readonly object cacheLock = new();
private IReadOnlyList<HelpArticle>? cachedArticles; private IReadOnlyList<HelpArticle>? cachedArticles;
private string? publishedIdentity;
public IReadOnlyList<HelpArticle> GetAllArticles() public IReadOnlyList<HelpArticle> GetAllArticles()
{ {
if (configuration?["HelpContent:Path"] is { Length: > 0 } publishedRoot)
{
var directory = new DirectoryInfo(publishedRoot);
var root = directory.LinkTarget is null ? publishedRoot : directory.ResolveLinkTarget(true)!.FullName;
var identity = File.ReadAllText(Path.Combine(root, "manifest.json"));
lock (cacheLock)
{
if (cachedArticles is null || identity != publishedIdentity)
{
cachedArticles = System.Text.Json.JsonSerializer.Deserialize<List<HelpArticle>>(
File.ReadAllText(Path.Combine(root, "articles.json")))
?? throw new InvalidDataException("Empty approved help publication.");
publishedIdentity = identity;
}
return cachedArticles;
}
}
if (cachedArticles is not null) if (cachedArticles is not null)
{ {
return cachedArticles; return cachedArticles;

View File

@ -26,4 +26,6 @@ digest with release evidence, and transfer that artifact for consumption by
PlotDirector.Website/Tools/consume_help.py. Full operator procedures are in that PlotDirector.Website/Tools/consume_help.py. Full operator procedures are in that
repository's Docs/Content.md. Publication and atomic content activation do not deploy repository's Docs/Content.md. Publication and atomic content activation do not deploy
or restart the application. Website renders from its local immutable publication; or restart the application. Website renders from its local immutable publication;
application contextual help keeps its current source/renderer and needs no website. application contextual help keeps its current renderer and needs no website. Both
products can independently consume the same publication into their own content store,
selected by HelpContent__Path, with manifest-driven hot reload and no restart.