@tokenoftrust/storefront-runner 1.4.1 → 1.4.2-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/apps/storefront/astro.config.mjs +17 -1
- package/apps/storefront/integrations/materialize-guard.mjs +56 -0
- package/apps/storefront/migrations-apps/0002_good_switch.sql +26 -0
- package/apps/storefront/migrations-apps/0003_mute_marauders.sql +12 -0
- package/apps/storefront/migrations-apps/meta/0002_snapshot.json +1160 -0
- package/apps/storefront/migrations-apps/meta/0003_snapshot.json +1235 -0
- package/apps/storefront/migrations-apps/meta/_journal.json +14 -0
- package/apps/storefront/public/js/dashboard-team.js +38 -2
- package/apps/storefront/src/components/Seo.astro +65 -1
- package/apps/storefront/src/components/admin/AdminBlogDetailRail.astro +878 -0
- package/apps/storefront/src/components/admin/AdminBlogTab.astro +1432 -0
- package/apps/storefront/src/components/admin/AdminCustomersTab.astro +3 -7
- package/apps/storefront/src/components/admin/AdminPublishTab.astro +1105 -2334
- package/apps/storefront/src/components/admin/AdminSubscriptionsTab.astro +1 -3
- package/apps/storefront/src/components/blog/BlogPaywall.astro +87 -0
- package/apps/storefront/src/components/blog/PostAccessBadge.astro +43 -0
- package/apps/storefront/src/components/blog/PostGrid.astro +57 -0
- package/apps/storefront/src/components/blog/ReactionBar.astro +214 -0
- package/apps/storefront/src/layouts/Layout.astro +48 -3
- package/apps/storefront/src/lib/activity/alerts.ts +17 -19
- package/apps/storefront/src/lib/activity/changeActorAttribution.ts +3 -3
- package/apps/storefront/src/lib/activity/deployVersion.ts +19 -26
- package/apps/storefront/src/lib/activity/ingest.ts +8 -8
- package/apps/storefront/src/lib/activity/ingestAuth.ts +1 -1
- package/apps/storefront/src/lib/activity/killSwitch.ts +6 -6
- package/apps/storefront/src/lib/activity/query.ts +9 -9
- package/apps/storefront/src/lib/activity/recordActivity.ts +11 -15
- package/apps/storefront/src/lib/activity/store.ts +4 -6
- package/apps/storefront/src/lib/activity/uiActor.ts +12 -12
- package/apps/storefront/src/lib/activity/workerCommit.ts +6 -6
- package/apps/storefront/src/lib/admin/adminShell.ts +290 -0
- package/apps/storefront/src/lib/admin/ai/approvalMode.ts +2 -3
- package/apps/storefront/src/lib/admin/ai/audit.ts +3 -5
- package/apps/storefront/src/lib/admin/checkoutStyleInput.ts +7 -7
- package/apps/storefront/src/lib/admin/checkoutStyleTarget.ts +3 -3
- package/apps/storefront/src/lib/admin/orderClient.ts +3 -5
- package/apps/storefront/src/lib/admin/services/orders.ts +17 -19
- package/apps/storefront/src/lib/admin/viewmodels/aiWorkflows.ts +4 -6
- package/apps/storefront/src/lib/admin/viewmodels/settings.ts +1 -1
- package/apps/storefront/src/lib/apps/adminService.ts +4 -4
- package/apps/storefront/src/lib/apps/adminSession.ts +53 -44
- package/apps/storefront/src/lib/apps/apiAuth.ts +2 -2
- package/apps/storefront/src/lib/apps/apiRoute.ts +2 -2
- package/apps/storefront/src/lib/apps/catalogMapper.ts +1 -1
- package/apps/storefront/src/lib/apps/credentials.ts +2 -2
- package/apps/storefront/src/lib/apps/gatewayKeys.ts +4 -4
- package/apps/storefront/src/lib/apps/healthAggregate.ts +5 -5
- package/apps/storefront/src/lib/apps/orders/attributionService.ts +2 -2
- package/apps/storefront/src/lib/apps/orders/customerHash.ts +1 -1
- package/apps/storefront/src/lib/apps/orders/foxyOrderClient.ts +12 -12
- package/apps/storefront/src/lib/apps/orders/idempotency.ts +7 -7
- package/apps/storefront/src/lib/apps/orders/orderForwardReceiver.ts +1 -1
- package/apps/storefront/src/lib/apps/orders/orderMapper.ts +2 -2
- package/apps/storefront/src/lib/apps/orders/ordersStore.ts +6 -6
- package/apps/storefront/src/lib/apps/registryService.ts +6 -6
- package/apps/storefront/src/lib/apps/scopes.ts +2 -2
- package/apps/storefront/src/lib/apps/tokenIssuer.ts +4 -4
- package/apps/storefront/src/lib/apps/tokenVerifier.ts +6 -6
- package/apps/storefront/src/lib/apps/widgets/eligibility.ts +2 -2
- package/apps/storefront/src/lib/apps/widgets/frameProps.ts +3 -3
- package/apps/storefront/src/lib/apps/widgets/launchToken.ts +4 -4
- package/apps/storefront/src/lib/apps/widgets/placements.ts +2 -2
- package/apps/storefront/src/lib/apps/widgets/renderSlot.ts +1 -1
- package/apps/storefront/src/lib/auth/adminEntry.ts +9 -9
- package/apps/storefront/src/lib/auth/identityToken.ts +6 -14
- package/apps/storefront/src/lib/auth/loginGate.ts +75 -13
- package/apps/storefront/src/lib/auth/mcpClientAssertion.ts +2 -4
- package/apps/storefront/src/lib/auth/operatorSession.ts +113 -0
- package/apps/storefront/src/lib/auth/session.ts +7 -8
- package/apps/storefront/src/lib/auth/totAccessClient.ts +8 -18
- package/apps/storefront/src/lib/basePath.ts +9 -2
- package/apps/storefront/src/lib/blog/access.ts +29 -0
- package/apps/storefront/src/lib/blog/collection.ts +313 -0
- package/apps/storefront/src/lib/blog/markdown.ts +174 -0
- package/apps/storefront/src/lib/blog/provider.ts +5 -0
- package/apps/storefront/src/lib/blog/reactions.ts +87 -0
- package/apps/storefront/src/lib/blog/rss.ts +92 -0
- package/apps/storefront/src/lib/blog/teaser.ts +83 -0
- package/apps/storefront/src/lib/blog/types.ts +34 -0
- package/apps/storefront/src/lib/blog/viewCounts.ts +243 -0
- package/apps/storefront/src/lib/d1/catalog.ts +2 -2
- package/apps/storefront/src/lib/d1/schema-apps.ts +96 -17
- package/apps/storefront/src/lib/dev/activityIngestToken.ts +2 -4
- package/apps/storefront/src/lib/dev/activityStore.ts +3 -5
- package/apps/storefront/src/lib/dev/apiBase.ts +1 -4
- package/apps/storefront/src/lib/dev/cockpitStore.ts +1 -9
- package/apps/storefront/src/lib/dev/devDraft.ts +1 -1
- package/apps/storefront/src/lib/dev/previewStatus.ts +9 -21
- package/apps/storefront/src/lib/dev/rendezvousBroker.ts +9 -24
- package/apps/storefront/src/lib/edgeCache.ts +17 -0
- package/apps/storefront/src/lib/http/fetchTransport.ts +63 -0
- package/apps/storefront/src/lib/i18n.ts +25 -0
- package/apps/storefront/src/lib/jsonld.ts +118 -0
- package/apps/storefront/src/lib/monitoring/manifest.ts +11 -11
- package/apps/storefront/src/lib/newsletter/confirmationEmail.ts +30 -0
- package/apps/storefront/src/lib/newsletter/consent.ts +23 -0
- package/apps/storefront/src/lib/newsletter/digest.ts +117 -0
- package/apps/storefront/src/lib/newsletter/resendClient.ts +79 -0
- package/apps/storefront/src/lib/newsletter/send.ts +265 -0
- package/apps/storefront/src/lib/newsletter/subscribers.ts +156 -0
- package/apps/storefront/src/lib/publish/adminPublishTab.ts +3519 -0
- package/apps/storefront/src/lib/publish/apex-readiness.ts +41 -18
- package/apps/storefront/src/lib/publish/dispatchHealth.ts +5 -7
- package/apps/storefront/src/lib/publish/domainState.ts +22 -13
- package/apps/storefront/src/lib/publish/panelPolling.ts +78 -0
- package/apps/storefront/src/lib/publish/shipWorkspace.ts +100 -49
- package/apps/storefront/src/lib/publish/stageBundleUpload.ts +215 -0
- package/apps/storefront/src/lib/rate/kvWindow.ts +53 -0
- package/apps/storefront/src/lib/search/index.ts +2 -2
- package/apps/storefront/src/lib/seo/alternates.ts +42 -0
- package/apps/storefront/src/lib/seo/meta.ts +65 -0
- package/apps/storefront/src/lib/social/golive.ts +212 -0
- package/apps/storefront/src/lib/social/notify.ts +32 -0
- package/apps/storefront/src/lib/social/tokenStore.ts +171 -0
- package/apps/storefront/src/lib/the-build/provider.ts +27 -0
- package/apps/storefront/src/lib/the-build/readingTime.ts +35 -0
- package/apps/storefront/src/lib/the-build/toc.ts +95 -0
- package/apps/storefront/src/lib/tot/ToTClient.ts +1 -1
- package/apps/storefront/src/lib/tot/d1Client.ts +2 -2
- package/apps/storefront/src/lib/tot/totClientInterface.ts +3 -4
- package/apps/storefront/src/lib/webhooks/deliveryStore.ts +16 -17
- package/apps/storefront/src/middleware/index.ts +113 -2
- package/apps/storefront/src/pages/admin.astro +10 -1312
- package/apps/storefront/src/pages/api/blog/[collection]/[slug]/react.ts +104 -0
- package/apps/storefront/src/pages/api/newsletter/[collection]/subscribe.ts +146 -0
- package/apps/storefront/src/pages/api/newsletter/confirm.ts +75 -0
- package/apps/storefront/src/pages/api/newsletter/unsubscribe.ts +90 -0
- package/apps/storefront/src/pages/api/publish/stage-bundle.ts +70 -0
- package/apps/storefront/src/pages/api/rum/vitals.ts +21 -2
- package/apps/storefront/src/pages/blog/[slug].astro +96 -16
- package/apps/storefront/src/pages/blog/author/[author].astro +140 -0
- package/apps/storefront/src/pages/blog/category/[category].astro +67 -0
- package/apps/storefront/src/pages/blog/index.astro +2 -0
- package/apps/storefront/src/pages/blog/tag/[tag].astro +65 -0
- package/apps/storefront/src/pages/cockpit.astro +37 -12
- package/apps/storefront/src/pages/dashboard/[appDomain]/team.astro +15 -11
- package/apps/storefront/src/pages/search.astro +1 -1
- package/apps/storefront/src/pages/sitemap.xml.ts +20 -0
- package/apps/storefront/src/pages/the-build/[slug].astro +129 -0
- package/apps/storefront/src/pages/the-build/index.astro +146 -0
- package/apps/storefront/src/pages/the-build/rss.xml.ts +33 -0
- package/apps/storefront/src/styles/admin.css +1080 -0
- package/apps/storefront/tsconfig.json +5 -0
- package/package.json +1 -1
- package/packages/public-runtime/package.json +1 -0
- package/packages/public-runtime/src/activity/catalog.ts +52 -0
- package/packages/public-runtime/src/catalog-d1.ts +1 -1
- package/packages/public-runtime/src/customization-preview.ts +25 -2
- package/packages/public-runtime/src/customization-runtime.ts +125 -3
- package/packages/public-runtime/src/customization-versioning.ts +10 -0
- package/packages/public-runtime/src/index.ts +1 -0
- package/packages/public-runtime/src/static-bundle.ts +357 -0
- package/packages/public-runtime/src/tenant.ts +36 -8
- package/scripts/build/copy-tenant-assets.mjs +14 -4
- package/scripts/dev/ai-edit.mjs +1 -1
- package/scripts/dev/checkout-watch.mjs +2 -2
- package/scripts/dev/file-browser.mjs +2 -4
- package/scripts/dev/file-writer.mjs +1 -1
- package/scripts/dev/git-status.mjs +2 -2
- package/scripts/dev/locate-handler.mjs +3 -3
- package/scripts/dev/port-check.mjs +3 -3
- package/scripts/dev/publish.mjs +5 -9
- package/scripts/dev/shot.mjs +1 -1
- package/scripts/dev/unified-diff.mjs +8 -3
- package/scripts/tot-dev.mjs +6 -9
- package/apps/storefront/src/lib/dev/vcBinding.ts +0 -80
package/scripts/tot-dev.mjs
CHANGED
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
* Vite trusts) and run a recursive `fs.watch` on the checkout that re-syncs each
|
|
32
32
|
* changed file back into the in-tree copy on save — which is what fires Vite HMR.
|
|
33
33
|
*
|
|
34
|
-
* Two things
|
|
34
|
+
* Two things to know (see the two-liners below):
|
|
35
35
|
* - Tenant is selected by the URL path-prefix (`/<appDomain>/`), NOT by
|
|
36
36
|
* DEFAULT_TENANT_ID — the @astrojs/cloudflare dev runtime (workerd) reads env
|
|
37
37
|
* from .dev.vars/bindings, so a spawned process.env var never reaches it, and
|
|
@@ -76,9 +76,8 @@ const flag = (name, def) => {
|
|
|
76
76
|
|
|
77
77
|
// `--version` / `-v` / `version` → print the runner's PUBLISHED version and exit.
|
|
78
78
|
// Reads the emitted root package.json (build-runner.mjs stamps RUNNER_VERSION in
|
|
79
|
-
// PUBLISH mode)
|
|
80
|
-
// runner
|
|
81
|
-
// so making it directly checkable (npm bin `storefront-runner`) is part of the fix.
|
|
79
|
+
// PUBLISH mode), so the runner's version is directly checkable (npm bin
|
|
80
|
+
// `storefront-runner`).
|
|
82
81
|
if (argv[0] === "--version" || argv[0] === "-v" || argv[0] === "version") {
|
|
83
82
|
let v = "0.0.0";
|
|
84
83
|
try {
|
|
@@ -165,7 +164,7 @@ if (!domain) {
|
|
|
165
164
|
// Records let us undo everything on exit (leave the tree exactly as found).
|
|
166
165
|
/** @type {{ target: string, backup: string|null }[]} */
|
|
167
166
|
const grafts = [];
|
|
168
|
-
/** @type {
|
|
167
|
+
/** @type {Array<{ close: () => void }>} */
|
|
169
168
|
const watchers = [];
|
|
170
169
|
let cleanedUp = false;
|
|
171
170
|
|
|
@@ -295,8 +294,7 @@ if (workspacePath) {
|
|
|
295
294
|
|
|
296
295
|
// Resolve the port BEFORE printing a URL or booting astro. Vite's `strictPort`
|
|
297
296
|
// defaults off, so a taken port makes astro SILENTLY drift to the next free one —
|
|
298
|
-
// which then mismatches the URL we (and the CLI's liveness poll) advertise
|
|
299
|
-
// stale server on the original port produced a false "You're live" (2026-07-14).
|
|
297
|
+
// which then mismatches the URL we (and the CLI's liveness poll) advertise.
|
|
300
298
|
// Instead we pick the first free port ourselves and PRINT it, so a busy default
|
|
301
299
|
// port "just works" (better UX than failing). See port-check.mjs.
|
|
302
300
|
const requestedPort = Number(flag("port", "4321"));
|
|
@@ -362,8 +360,7 @@ const spawnEnv = workspacePath
|
|
|
362
360
|
// require pnpm at RUNTIME), so resolve astro's real entry through Node's own
|
|
363
361
|
// resolver from the app package and exec it with our Node. No package-manager
|
|
364
362
|
// binary, no .bin shims, and no coupling to the package's name (the build
|
|
365
|
-
// renames @tot/storefront → @tot/storefront-runner in the shipped tree
|
|
366
|
-
// the old `pnpm --filter <name> exec` had to track).
|
|
363
|
+
// renames @tot/storefront → @tot/storefront-runner in the shipped tree).
|
|
367
364
|
const appDir = resolve(repoRoot, "apps/storefront");
|
|
368
365
|
const astroEntry = resolve(
|
|
369
366
|
dirname(createRequire(join(appDir, "package.json")).resolve("astro/package.json")),
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Cockpit safety-net for the 08-18 vc-app-binding gap (§5): ensure the signed-in
|
|
3
|
-
* developer is bound to storefront's version-control app so their `tot start`
|
|
4
|
-
* checkout (`tenant_checkout`) and the repo tools stop 403-ing "No version-control
|
|
5
|
-
* app is bound to your session."
|
|
6
|
-
*
|
|
7
|
-
* WHY a net at all: the ROOT fix binds every entitled human at the authority seams
|
|
8
|
-
* the MCP owns — grant issuance, rendezvous `/approve`, native OAuth token issuance
|
|
9
|
-
* — plus a one-shot backfill. Those cover the terminal path. This net covers the
|
|
10
|
-
* BROWSER-FIRST developer who reached /cockpit via the storefront's own tot20
|
|
11
|
-
* sign-in (a `tot_session` cookie) WITHOUT ever crossing an MCP binding seam, so
|
|
12
|
-
* they'd otherwise land at cockpit with a `tot start` command that 403s.
|
|
13
|
-
*
|
|
14
|
-
* HOW (mirrors cli-signin-approve): there is NO per-human MCP session server-side —
|
|
15
|
-
* the cockpit reaches the MCP only as the APP (private_key_jwt). So we re-issue a
|
|
16
|
-
* FRESH tot20-signed id_token for the VERIFIED session email (via the storefront's
|
|
17
|
-
* core credential — {@link reissueSubjectToken}, the same proof `/approve` sends)
|
|
18
|
-
* and pass it as the `subject_token` the MCP binds the enrollment to. The app can't
|
|
19
|
-
* assert an arbitrary subject; the MCP verifies the proof + the subject's LIVE
|
|
20
|
-
* entitlement and authors the binding under its own forge authority (ADR-0001).
|
|
21
|
-
*
|
|
22
|
-
* ALWAYS FAIL-OPEN: any gap (proof re-issue failed, MCP cold/unreachable, the
|
|
23
|
-
* endpoint not yet deployed) returns a typed `{ ok:false }` and NEVER throws — the
|
|
24
|
-
* cockpit must render regardless, and the authority-seam binding + backfill are the
|
|
25
|
-
* real guarantees. This is strictly a best-effort accelerator.
|
|
26
|
-
*/
|
|
27
|
-
import { createForgeClient } from "@/lib/forge";
|
|
28
|
-
import { reissueSubjectToken } from "@/lib/dev/subjectReissue";
|
|
29
|
-
|
|
30
|
-
export type EnsureCockpitBindingResult =
|
|
31
|
-
| { ok: true; bound: boolean; created: boolean }
|
|
32
|
-
| { ok: false; reason: string };
|
|
33
|
-
|
|
34
|
-
export interface EnsureCockpitBindingDeps {
|
|
35
|
-
/** Override the subject-proof minter (tests). */
|
|
36
|
-
reissue?: typeof reissueSubjectToken;
|
|
37
|
-
/** Override the forge-client factory (tests) — returns something with ensureVcAppBinding. */
|
|
38
|
-
makeForgeClient?: () => Promise<{
|
|
39
|
-
ensureVcAppBinding(opts: {
|
|
40
|
-
subjectToken?: string;
|
|
41
|
-
}): Promise<{ bound: boolean; created: boolean }>;
|
|
42
|
-
}>;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Ensure the developer identified by their VERIFIED session `email` is bound to the
|
|
47
|
-
* storefront VC app. Best-effort + fail-closed-to-typed-error: never throws.
|
|
48
|
-
*/
|
|
49
|
-
export async function ensureCockpitVcBinding(
|
|
50
|
-
email: string,
|
|
51
|
-
deps: EnsureCockpitBindingDeps = {},
|
|
52
|
-
): Promise<EnsureCockpitBindingResult> {
|
|
53
|
-
if (!email) return { ok: false, reason: "missing-identity" };
|
|
54
|
-
|
|
55
|
-
const reissue = deps.reissue ?? reissueSubjectToken;
|
|
56
|
-
let subjectToken: string;
|
|
57
|
-
try {
|
|
58
|
-
const proof = await reissue(email);
|
|
59
|
-
if (!proof.ok) return { ok: false, reason: `reissue-${proof.reason}` };
|
|
60
|
-
subjectToken = proof.idToken;
|
|
61
|
-
} catch {
|
|
62
|
-
// A re-issue fault must not surface as a cockpit 500.
|
|
63
|
-
return { ok: false, reason: "reissue-threw" };
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
try {
|
|
67
|
-
const client = deps.makeForgeClient
|
|
68
|
-
? await deps.makeForgeClient()
|
|
69
|
-
: await createForgeClient();
|
|
70
|
-
const res = await client.ensureVcAppBinding({ subjectToken });
|
|
71
|
-
return { ok: true, bound: res.bound, created: res.created };
|
|
72
|
-
} catch (cause) {
|
|
73
|
-
// Fail-open: the ensure endpoint may not be deployed yet, or the MCP may be
|
|
74
|
-
// cold/unreachable. The proof itself is never logged; the reason is a terse code.
|
|
75
|
-
return {
|
|
76
|
-
ok: false,
|
|
77
|
-
reason: "mcp-" + (cause instanceof Error ? cause.name : "error"),
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
}
|