create-ailk 0.34.1 → 0.36.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/README.md +1 -1
- package/component-catalog.json +37 -4
- package/component-catalog.md +11 -9
- package/dist/add-module.js +7 -2
- package/dist/derive-architecture.js +2 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/lib/env-catalog.js +8 -0
- package/dist/module-architecture.js +9 -0
- package/dist/programmatic.js +5 -2
- package/dist/site-listing-path.d.ts +8 -0
- package/dist/site-listing-path.js +8 -0
- package/dist/surfaces.d.ts +20 -0
- package/dist/surfaces.js +32 -3
- package/dist/template-record.js +2 -0
- package/dist/topology.d.ts +4 -4
- package/dist/topology.js +104 -60
- package/dist/update.js +11 -0
- package/package.json +3 -3
- package/templates/.env.example +21 -0
- package/templates/apps/api/.env.example +7 -0
- package/templates/apps/api/CLAUDE.md +14 -9
- package/templates/apps/mcp/CLAUDE.md +18 -7
- package/templates/apps/web/.env.example +16 -0
- package/templates/apps/web/CLAUDE.md +46 -5
- package/templates/apps/web/app/[locale]/(auth)/__tests__/password-reset.test.tsx +2 -0
- package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/page.test.tsx +52 -1
- package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/remembered-method.test.ts +43 -0
- package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/sign-in-card.test.tsx +108 -1
- package/templates/apps/web/app/[locale]/(auth)/sign-in/page.tsx +36 -3
- package/templates/apps/web/app/[locale]/(auth)/sign-in/remembered-method.ts +37 -0
- package/templates/apps/web/app/[locale]/(auth)/sign-in/sign-in-card.tsx +90 -33
- package/templates/apps/web/app/[locale]/(auth)/sign-in/sign-in-text.ts +9 -4
- package/templates/apps/web/app/[locale]/(authed)/__tests__/gate.test.tsx +79 -348
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/billing.test.tsx +12 -1
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/hub-mode.test.tsx +55 -2
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/item.test.tsx +43 -0
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/layout-sign-out.test.tsx +10 -5
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/page.test.tsx +6 -5
- package/templates/apps/web/app/[locale]/(authed)/account/account-frame.tsx +1 -1
- package/templates/apps/web/app/[locale]/(authed)/account/billing/page.tsx +60 -6
- package/templates/apps/web/app/[locale]/(authed)/account/billing-source.ts +32 -3
- package/templates/apps/web/app/[locale]/(authed)/account/connect/__tests__/page.test.tsx +8 -1
- package/templates/apps/web/app/[locale]/(authed)/account/connect/page.tsx +7 -3
- package/templates/apps/web/app/[locale]/(authed)/account/general/__tests__/phone-verification.test.tsx +215 -0
- package/templates/apps/web/app/[locale]/(authed)/account/general/__tests__/seam-imports.test.ts +65 -0
- package/templates/apps/web/app/[locale]/(authed)/account/general/page.tsx +47 -0
- package/templates/apps/web/app/[locale]/(authed)/account/general/phone-actions.ts +122 -0
- package/templates/apps/web/app/[locale]/(authed)/account/general/phone-verification.tsx +214 -0
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/[kind]/[id]/page.tsx +6 -1
- package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/__tests__/invitation-id.test.ts +35 -0
- package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/__tests__/page.test.tsx +266 -0
- package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/actions.ts +116 -0
- package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/invitation-id.ts +12 -0
- package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/page.tsx +154 -0
- package/templates/apps/web/app/[locale]/(authed)/account/layout.tsx +6 -4
- package/templates/apps/web/app/[locale]/(authed)/account/security/page.tsx +3 -1
- package/templates/apps/web/app/[locale]/(authed)/layout.tsx +15 -13
- package/templates/apps/web/app/[locale]/(authed)/signed-out-gate.generated.tsx +20 -52
- package/templates/apps/web/app/[locale]/flows/[slug]/FlowStepperClient.tsx +43 -4
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.deliverable.test.tsx +23 -9
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.invite.test.tsx +15 -0
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.permalink.test.tsx +74 -0
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.test.tsx +34 -1
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/magnet-page.test.tsx +257 -4
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/save.actions.test.ts +72 -92
- package/templates/apps/web/app/[locale]/flows/[slug]/email-moment.ts +2 -2
- package/templates/apps/web/app/[locale]/flows/[slug]/magnet-page.tsx +164 -65
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/LevelChart.tsx +100 -0
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsCard.tsx +99 -0
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsClient.tsx +415 -253
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsEmailStep.tsx +113 -32
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/ResultsClient.no-commerce.test.tsx +16 -17
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/ResultsClient.report.test.tsx +284 -0
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/by-result.test.tsx +52 -19
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/cards.test.tsx +402 -0
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/page.test.tsx +100 -12
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/score.test.tsx +153 -101
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/meeting-seam.ts +36 -0
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/page.tsx +121 -33
- package/templates/apps/web/app/[locale]/flows/[slug]/save.actions.ts +27 -17
- package/templates/apps/web/app/[locale]/flows/[slug]/served-flow.ts +91 -0
- package/templates/apps/web/app/[locale]/layout.tsx +42 -76
- package/templates/apps/web/app/[locale]/purchase/__tests__/success.test.tsx +50 -0
- package/templates/apps/web/app/[locale]/purchase/success/page.tsx +48 -7
- package/templates/apps/web/app/api/auth/hub/__tests__/entry-routes.test.ts +749 -0
- package/templates/apps/web/app/api/auth/hub/authorize/__tests__/route.test.ts +189 -6
- package/templates/apps/web/app/api/auth/hub/authorize/route.ts +101 -31
- package/templates/apps/web/app/api/auth/hub/continuation.ts +51 -2
- package/templates/apps/web/app/api/auth/hub/email/route.ts +111 -0
- package/templates/apps/web/app/api/auth/hub/entry-shared.ts +163 -0
- package/templates/apps/web/app/api/auth/hub/purchase/route.ts +230 -0
- package/templates/apps/web/app/api/auth/hub/purchase-link/route.ts +174 -0
- package/templates/apps/web/app/api/auth/hub/sign-up/route.ts +60 -0
- package/templates/apps/web/app/api/auth/hub/sign-up-evidence.ts +97 -0
- package/templates/apps/web/app/api/hub-session/__tests__/routes.test.ts +475 -7
- package/templates/apps/web/app/api/hub-session/callback/route.ts +13 -47
- package/templates/apps/web/app/api/hub-session/email/route.ts +125 -0
- package/templates/apps/web/app/api/hub-session/one-tap/nonce/route.ts +49 -0
- package/templates/apps/web/app/api/hub-session/one-tap/route.ts +106 -0
- package/templates/apps/web/app/api/hub-session/open/route.ts +111 -0
- package/templates/apps/web/app/api/hub-session/sign-in/route.ts +23 -40
- package/templates/apps/web/app/api/hub-session/sign-out/route.ts +1 -10
- package/templates/apps/web/app/llms.txt/__tests__/site-listing.test.ts +122 -0
- package/templates/apps/web/app/llms.txt/route.ts +14 -2
- package/templates/apps/web/app/sitemap.xml/__tests__/site-listing.test.ts +98 -0
- package/templates/apps/web/app/sitemap.xml/route.ts +13 -2
- package/templates/apps/web/auth.ts +133 -6
- package/templates/apps/web/components/sign-out-trigger.tsx +1 -1
- package/templates/apps/web/lib/__tests__/auth-email.test.ts +141 -0
- package/templates/apps/web/lib/__tests__/auth-phone.test.ts +445 -0
- package/templates/apps/web/lib/__tests__/auth-sms.test.ts +140 -0
- package/templates/apps/web/lib/__tests__/fixtures/tsconfig.flow.json +18 -0
- package/templates/apps/web/lib/__tests__/site-header.test.ts +13 -0
- package/templates/apps/web/lib/__tests__/telemetry-scrub.test.ts +19 -1
- package/templates/apps/web/lib/account-config.ts +24 -9
- package/templates/apps/web/lib/auth-email.ts +62 -6
- package/templates/apps/web/lib/auth-env.ts +13 -0
- package/templates/apps/web/lib/auth-sms.ts +180 -0
- package/templates/apps/web/lib/hub-session/__tests__/hub-session.test.ts +28 -0
- package/templates/apps/web/lib/hub-session/__tests__/spoke-sign-in.test.tsx +332 -0
- package/templates/apps/web/lib/hub-session/config.ts +7 -1
- package/templates/apps/web/lib/hub-session/entry.ts +238 -0
- package/templates/apps/web/lib/hub-session/index.ts +1 -4
- package/templates/apps/web/lib/hub-session/one-tap.tsx +148 -0
- package/templates/apps/web/lib/hub-session/session.ts +120 -2
- package/templates/apps/web/lib/hub-session/spoke-sign-in.tsx +277 -0
- package/templates/apps/web/lib/site-header.ts +14 -1
- package/templates/apps/web/lib/site-listing.ts +7 -0
- package/templates/apps/web/lib/telemetry-scrub.ts +11 -0
- package/templates/apps/web/lib/topology.generated.ts +39 -0
- package/templates/apps/web/messages/en.json +125 -21
- package/templates/apps/web/middleware.ts +34 -2
- package/templates/apps/web/security-headers.config.ts +21 -0
- package/versions.json +47 -47
- package/templates/apps/web/app/[locale]/(authed)/sign-in-gate.tsx +0 -162
- package/templates/apps/web/components/signed-in-nav.tsx +0 -79
- package/templates/apps/web/lib/hub-session/__tests__/sign-in-gate.test.tsx +0 -180
- package/templates/apps/web/lib/hub-session/sign-in-gate.tsx +0 -162
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jest-environment node
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* #10940 D3 — both llms routes (the base route and the docs-blog variant)
|
|
7
|
+
* read the site listing and skip `ThankYouPage` rows.
|
|
8
|
+
*
|
|
9
|
+
* AC-1: on a database-backed site each public page is listed once, at the
|
|
10
|
+
* route that serves it. AC-3: with the empty listing (the default dep) the
|
|
11
|
+
* output is today's convention listing, apart from the ThankYouPage skip.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import type { ContentAdapter } from "@working-theory/content-adapters";
|
|
15
|
+
import type { SiteListing } from "@working-theory/page-renderer";
|
|
16
|
+
|
|
17
|
+
type Route = typeof import("../route");
|
|
18
|
+
|
|
19
|
+
const BASE = "https://example.com";
|
|
20
|
+
// The docs-blog variant is that module's ownedFile, so a scaffold without
|
|
21
|
+
// docs-blog carries no copy — only the routes that resolve here are run (#11085).
|
|
22
|
+
const ROUTES = ["../route", "../../../lib/slices/docs-blog/llms-route"].filter((path) => {
|
|
23
|
+
try {
|
|
24
|
+
require.resolve(path);
|
|
25
|
+
return true;
|
|
26
|
+
} catch {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
const PUBLIC_ROWS: Record<string, Array<{ type: string; slug: string; title: string }>> = {
|
|
32
|
+
AboutPage: [{ type: "AboutPage", slug: "about", title: "About" }],
|
|
33
|
+
LandingPage: [
|
|
34
|
+
{ type: "LandingPage", slug: "private-convo", title: "Private" },
|
|
35
|
+
{ type: "LandingPage", slug: "projects-apply", title: "Apply" },
|
|
36
|
+
],
|
|
37
|
+
BookCall: [{ type: "BookCall", slug: "meet-discovery", title: "Discovery" }],
|
|
38
|
+
};
|
|
39
|
+
const THANKS = {
|
|
40
|
+
ThankYouPage: [{ type: "ThankYouPage", slug: "projects-approved", title: "Thanks" }],
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
function stubAdapter(rows: Record<string, unknown[]>): ContentAdapter {
|
|
44
|
+
// eslint-disable-next-line no-restricted-syntax -- partial stub; the routes read listPages only
|
|
45
|
+
return {
|
|
46
|
+
listPages: jest.fn(async (type: string) => rows[type] ?? []),
|
|
47
|
+
} as unknown as ContentAdapter;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const LISTING: SiteListing = {
|
|
51
|
+
"LandingPage/private-convo": { listed: false },
|
|
52
|
+
"LandingPage/projects-apply": { path: "/projects/apply" },
|
|
53
|
+
"BookCall/meet-discovery": { path: "/meet/discovery" },
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
function loadRoute(path: string): Route {
|
|
57
|
+
let route: Route | undefined;
|
|
58
|
+
jest.isolateModules(() => {
|
|
59
|
+
route = jest.requireActual<Route>(path);
|
|
60
|
+
});
|
|
61
|
+
return route!;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
async function llms(
|
|
65
|
+
path: string,
|
|
66
|
+
rows: Record<string, unknown[]>,
|
|
67
|
+
listing?: SiteListing,
|
|
68
|
+
): Promise<string> {
|
|
69
|
+
const { createLlmsHandler } = loadRoute(path);
|
|
70
|
+
const GET = createLlmsHandler({
|
|
71
|
+
getContentAdapter: () => stubAdapter(rows),
|
|
72
|
+
getBlogPages: () => [],
|
|
73
|
+
getDocsPages: () => [],
|
|
74
|
+
discoverable: async () => true,
|
|
75
|
+
...(listing === undefined ? {} : { getSiteListing: () => listing }),
|
|
76
|
+
});
|
|
77
|
+
return (await GET()).text();
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const urls = (text: string): string[] =>
|
|
81
|
+
[...text.matchAll(/^ {2}URL: (.+)$/gm)].map((m) => m[1]!);
|
|
82
|
+
|
|
83
|
+
describe.each(ROUTES)("GET /llms.txt (%s) — the site listing (#10940)", (path) => {
|
|
84
|
+
beforeEach(() => {
|
|
85
|
+
process.env.CONTENT_ADAPTER = "database";
|
|
86
|
+
process.env.NEXT_PUBLIC_ENABLED_LOCALES = "en,es";
|
|
87
|
+
process.env.NEXT_PUBLIC_BASE_URL = BASE;
|
|
88
|
+
});
|
|
89
|
+
afterEach(() => {
|
|
90
|
+
delete process.env.CONTENT_ADAPTER;
|
|
91
|
+
delete process.env.NEXT_PUBLIC_ENABLED_LOCALES;
|
|
92
|
+
delete process.env.NEXT_PUBLIC_BASE_URL;
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it("AC-1: lists each public page once, at its served route", async () => {
|
|
96
|
+
const text = await llms(path, { ...PUBLIC_ROWS, ...THANKS }, LISTING);
|
|
97
|
+
expect(new Set(urls(text))).toEqual(
|
|
98
|
+
new Set(["/about", "/projects/apply", "/meet/discovery"].map((p) => `${BASE}${p}`)),
|
|
99
|
+
);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it("AC-1: ignores an invalid listing path", async () => {
|
|
103
|
+
const text = await llms(path, PUBLIC_ROWS, {
|
|
104
|
+
"AboutPage/about": { path: "https://evil.example/x" },
|
|
105
|
+
});
|
|
106
|
+
expect(urls(text)).toContain(`${BASE}/about`);
|
|
107
|
+
expect(text).not.toContain("evil.example");
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it("AC-3: the default listing is the empty one — today's convention listing", async () => {
|
|
111
|
+
const byDefault = await llms(path, PUBLIC_ROWS);
|
|
112
|
+
expect(byDefault).toBe(await llms(path, PUBLIC_ROWS, {}));
|
|
113
|
+
for (const p of ["/projects-apply", "/meet/meet-discovery", "/private-convo"]) {
|
|
114
|
+
expect(byDefault).toContain(`URL: ${BASE}${p}`);
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
it("AC-3: never lists a ThankYouPage, even with an empty listing", async () => {
|
|
119
|
+
const text = await llms(path, { ...PUBLIC_ROWS, ...THANKS }, {});
|
|
120
|
+
expect(text).not.toContain("/thanks/projects-approved");
|
|
121
|
+
});
|
|
122
|
+
});
|
|
@@ -36,7 +36,11 @@ import {
|
|
|
36
36
|
resolvedAdapterKind,
|
|
37
37
|
} from "@working-theory/content-adapters";
|
|
38
38
|
import type { ContentAdapter, SchemaOrgType } from "@working-theory/content-adapters";
|
|
39
|
-
import {
|
|
39
|
+
import {
|
|
40
|
+
getContentAdapter as defaultGetContentAdapter,
|
|
41
|
+
listedPath,
|
|
42
|
+
type SiteListing,
|
|
43
|
+
} from "@working-theory/page-renderer";
|
|
40
44
|
|
|
41
45
|
import {
|
|
42
46
|
adapterDocsUrl,
|
|
@@ -46,6 +50,7 @@ import {
|
|
|
46
50
|
} from "../../lib/docs-index";
|
|
47
51
|
import { PUBLIC_PAGES } from "../../lib/modules.generated";
|
|
48
52
|
import { SITE_NAME } from "../../lib/site-brand";
|
|
53
|
+
import { SITE_LISTING } from "../../lib/site-listing";
|
|
49
54
|
import { pagePathFor, resolveBaseUrl } from "../../src/lib/routes";
|
|
50
55
|
|
|
51
56
|
// #10510 D4 — read per request: the owner's discovery switch is a runtime
|
|
@@ -70,6 +75,8 @@ export interface LlmsHandlerDeps {
|
|
|
70
75
|
getDocsPages?: () => DocsIndexPage[];
|
|
71
76
|
/** The owner's discovery switch (#10510 D4). Defaults to `siteDiscoverable`. */
|
|
72
77
|
discoverable?: () => Promise<boolean>;
|
|
78
|
+
/** The site's own listing (#10940 D3). Defaults to `SITE_LISTING`. */
|
|
79
|
+
getSiteListing?: () => SiteListing;
|
|
73
80
|
}
|
|
74
81
|
|
|
75
82
|
/**
|
|
@@ -81,6 +88,7 @@ export function createLlmsHandler(deps: LlmsHandlerDeps = {}) {
|
|
|
81
88
|
const resolveBlogPages = deps.getBlogPages ?? (() => []);
|
|
82
89
|
const resolveDocsPages = deps.getDocsPages ?? listDocsPages;
|
|
83
90
|
const isDiscoverable = deps.discoverable ?? siteDiscoverable;
|
|
91
|
+
const resolveSiteListing = deps.getSiteListing ?? (() => SITE_LISTING);
|
|
84
92
|
|
|
85
93
|
return async function llmsGET(): Promise<Response> {
|
|
86
94
|
// #10040 decision 7 — no public page, no content index: 404 before the adapter.
|
|
@@ -103,12 +111,16 @@ export function createLlmsHandler(deps: LlmsHandlerDeps = {}) {
|
|
|
103
111
|
);
|
|
104
112
|
|
|
105
113
|
const databaseCorpus = resolvedAdapterKind() === "database";
|
|
114
|
+
const listing = resolveSiteListing();
|
|
106
115
|
for (const pages of pageLists) {
|
|
107
116
|
for (const page of pages) {
|
|
108
117
|
if (isDocsType(page.type) && !databaseCorpus) continue;
|
|
118
|
+
// #10617 — a flow's completion target is noindex, so never listed.
|
|
119
|
+
if (page.type === "ThankYouPage") continue;
|
|
109
120
|
const path = isDocsType(page.type)
|
|
110
121
|
? adapterDocsUrl(page.type, page.slug)
|
|
111
|
-
:
|
|
122
|
+
: listedPath(listing, page, pagePathFor);
|
|
123
|
+
if (path === null) continue;
|
|
112
124
|
const url = `${baseUrl}${path}`;
|
|
113
125
|
lines.push(`- Title: ${page.title}`);
|
|
114
126
|
lines.push(` URL: ${url}`);
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jest-environment node
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* AC-1 (sitemap half) — #10940 D3. On a database-backed site the sitemap
|
|
7
|
+
* lists each public page once, at the route that serves it: a `listed: false`
|
|
8
|
+
* row is left out, a moved row is listed (and its alternates point) at its
|
|
9
|
+
* served path, and an invalid listing path is ignored.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import type { ContentAdapter } from "@working-theory/content-adapters";
|
|
13
|
+
import type { SiteListing } from "@working-theory/page-renderer";
|
|
14
|
+
|
|
15
|
+
import { createSitemapHandler } from "../route";
|
|
16
|
+
|
|
17
|
+
const BASE = "https://example.com";
|
|
18
|
+
|
|
19
|
+
const ROWS: Record<string, Array<{ type: string; slug: string; title: string }>> = {
|
|
20
|
+
AboutPage: [{ type: "AboutPage", slug: "about", title: "About" }],
|
|
21
|
+
LandingPage: [
|
|
22
|
+
{ type: "LandingPage", slug: "private-convo", title: "Private" },
|
|
23
|
+
{ type: "LandingPage", slug: "projects-apply", title: "Apply" },
|
|
24
|
+
],
|
|
25
|
+
BookCall: [{ type: "BookCall", slug: "meet-discovery", title: "Discovery" }],
|
|
26
|
+
ThankYouPage: [{ type: "ThankYouPage", slug: "projects-approved", title: "Thanks" }],
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
function stubAdapter(): ContentAdapter {
|
|
30
|
+
// eslint-disable-next-line no-restricted-syntax -- partial stub; the routes read listPages only
|
|
31
|
+
return {
|
|
32
|
+
listPages: jest.fn(async (type: string) => ROWS[type] ?? []),
|
|
33
|
+
} as unknown as ContentAdapter;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const LISTING: SiteListing = {
|
|
37
|
+
"LandingPage/private-convo": { listed: false },
|
|
38
|
+
"LandingPage/projects-apply": { path: "/projects/apply" },
|
|
39
|
+
"BookCall/meet-discovery": { path: "/meet/discovery" },
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
async function sitemap(listing: SiteListing): Promise<string> {
|
|
43
|
+
const GET = createSitemapHandler({
|
|
44
|
+
getContentAdapter: stubAdapter,
|
|
45
|
+
getDocsPages: () => [],
|
|
46
|
+
discoverable: async () => true,
|
|
47
|
+
getSiteListing: () => listing,
|
|
48
|
+
});
|
|
49
|
+
return (await GET()).text();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const locs = (xml: string): string[] =>
|
|
53
|
+
[...xml.matchAll(/<loc>([^<]+)<\/loc>/g)].map((m) => m[1]!);
|
|
54
|
+
|
|
55
|
+
describe("GET /sitemap.xml — the site listing (#10940)", () => {
|
|
56
|
+
beforeEach(() => {
|
|
57
|
+
process.env.CONTENT_ADAPTER = "database";
|
|
58
|
+
process.env.NEXT_PUBLIC_ENABLED_LOCALES = "en,es";
|
|
59
|
+
process.env.NEXT_PUBLIC_BASE_URL = BASE;
|
|
60
|
+
});
|
|
61
|
+
afterEach(() => {
|
|
62
|
+
delete process.env.CONTENT_ADAPTER;
|
|
63
|
+
delete process.env.NEXT_PUBLIC_ENABLED_LOCALES;
|
|
64
|
+
delete process.env.NEXT_PUBLIC_BASE_URL;
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it("lists each public page once, at its served route, in every locale", async () => {
|
|
68
|
+
const xml = await sitemap(LISTING);
|
|
69
|
+
expect(new Set(locs(xml))).toEqual(
|
|
70
|
+
new Set(
|
|
71
|
+
[
|
|
72
|
+
"/about",
|
|
73
|
+
"/projects/apply",
|
|
74
|
+
"/meet/discovery",
|
|
75
|
+
"/es/about",
|
|
76
|
+
"/es/projects/apply",
|
|
77
|
+
"/es/meet/discovery",
|
|
78
|
+
].map((p) => `${BASE}${p}`),
|
|
79
|
+
),
|
|
80
|
+
);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it("never names a convention path, a private row or a thank-you page in any href", async () => {
|
|
84
|
+
const xml = await sitemap(LISTING);
|
|
85
|
+
const hrefs = [...xml.matchAll(/href="([^"]+)"/g)].map((m) => m[1]!);
|
|
86
|
+
expect(hrefs.length).toBeGreaterThan(0);
|
|
87
|
+
for (const needle of ["meet-discovery", "projects-apply", "private-convo", "/thanks/"]) {
|
|
88
|
+
expect(xml).not.toContain(needle);
|
|
89
|
+
}
|
|
90
|
+
expect(hrefs).toContain(`${BASE}/es/projects/apply`);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it("ignores an invalid listing path and lists the row at its convention path", async () => {
|
|
94
|
+
const xml = await sitemap({ "AboutPage/about": { path: "https://evil.example/x" } });
|
|
95
|
+
expect(locs(xml)).toContain(`${BASE}/about`);
|
|
96
|
+
expect(xml).not.toContain("evil.example");
|
|
97
|
+
});
|
|
98
|
+
});
|
|
@@ -43,7 +43,11 @@ import {
|
|
|
43
43
|
resolvedAdapterKind,
|
|
44
44
|
} from "@working-theory/content-adapters";
|
|
45
45
|
import type { ContentAdapter, SchemaOrgType } from "@working-theory/content-adapters";
|
|
46
|
-
import {
|
|
46
|
+
import {
|
|
47
|
+
getContentAdapter as defaultGetContentAdapter,
|
|
48
|
+
listedPath,
|
|
49
|
+
type SiteListing,
|
|
50
|
+
} from "@working-theory/page-renderer";
|
|
47
51
|
|
|
48
52
|
import {
|
|
49
53
|
adapterDocsUrl,
|
|
@@ -52,6 +56,7 @@ import {
|
|
|
52
56
|
type DocsIndexPage,
|
|
53
57
|
} from "../../lib/docs-index";
|
|
54
58
|
import { PUBLIC_PAGES } from "../../lib/modules.generated";
|
|
59
|
+
import { SITE_LISTING } from "../../lib/site-listing";
|
|
55
60
|
import { pagePathFor, resolveBaseUrl } from "../../src/lib/routes";
|
|
56
61
|
|
|
57
62
|
// #10510 D4 — read per request: the owner's discovery switch is a runtime
|
|
@@ -68,6 +73,8 @@ export interface SitemapHandlerDeps {
|
|
|
68
73
|
getDocsPages?: () => DocsIndexPage[];
|
|
69
74
|
/** The owner's discovery switch (#10510 D4). Defaults to `siteDiscoverable`. */
|
|
70
75
|
discoverable?: () => Promise<boolean>;
|
|
76
|
+
/** The site's own listing (#10940 D3). Defaults to `SITE_LISTING`. */
|
|
77
|
+
getSiteListing?: () => SiteListing;
|
|
71
78
|
}
|
|
72
79
|
|
|
73
80
|
function escapeXml(value: string): string {
|
|
@@ -104,6 +111,7 @@ export function createSitemapHandler(deps: SitemapHandlerDeps = {}) {
|
|
|
104
111
|
const resolveAdapter = deps.getContentAdapter ?? defaultGetContentAdapter;
|
|
105
112
|
const resolveDocsPages = deps.getDocsPages ?? listDocsPages;
|
|
106
113
|
const isDiscoverable = deps.discoverable ?? siteDiscoverable;
|
|
114
|
+
const resolveSiteListing = deps.getSiteListing ?? (() => SITE_LISTING);
|
|
107
115
|
return async function sitemapGET(): Promise<Response> {
|
|
108
116
|
// #10040 decision 7 — no public page, no sitemap: 404 before the adapter.
|
|
109
117
|
if (!PUBLIC_PAGES) return new Response(null, { status: 404 });
|
|
@@ -126,6 +134,7 @@ export function createSitemapHandler(deps: SitemapHandlerDeps = {}) {
|
|
|
126
134
|
);
|
|
127
135
|
};
|
|
128
136
|
const databaseDocs = resolvedAdapterKind() === "database";
|
|
137
|
+
const listing = resolveSiteListing();
|
|
129
138
|
|
|
130
139
|
const types = SCHEMA_ORG_TYPES as readonly SchemaOrgType[];
|
|
131
140
|
|
|
@@ -155,7 +164,9 @@ export function createSitemapHandler(deps: SitemapHandlerDeps = {}) {
|
|
|
155
164
|
// #10617 — a flow's completion target renders `robots: noindex`
|
|
156
165
|
// (`renderPageMetadata`), so it is never listed, in any locale.
|
|
157
166
|
if (page.type === "ThankYouPage") continue;
|
|
158
|
-
|
|
167
|
+
// #10940 D3 — the site's listing: not listed, or listed at its served path.
|
|
168
|
+
const path = listedPath(listing, page, pagePathFor);
|
|
169
|
+
if (path === null) continue;
|
|
159
170
|
const lastmod = page.publishedAt ?? today;
|
|
160
171
|
|
|
161
172
|
const defaultUrl = `${baseUrl}${path}`;
|
|
@@ -31,7 +31,7 @@ import { type BetterAuthPlugin, betterAuth } from "better-auth";
|
|
|
31
31
|
import { prismaAdapter } from "better-auth/adapters/prisma";
|
|
32
32
|
import type { AuthMiddleware } from "better-auth/api";
|
|
33
33
|
import { nextCookies } from "better-auth/next-js";
|
|
34
|
-
import { magicLink, mcp } from "better-auth/plugins";
|
|
34
|
+
import { magicLink, mcp, phoneNumber } from "better-auth/plugins";
|
|
35
35
|
|
|
36
36
|
import { sealMcpCallbacks } from "./app/api/auth/mcp/continuation";
|
|
37
37
|
import {
|
|
@@ -44,15 +44,18 @@ import {
|
|
|
44
44
|
import {
|
|
45
45
|
getActiveProviderIds,
|
|
46
46
|
isSignUpOpen,
|
|
47
|
+
phoneVerificationConfigured,
|
|
47
48
|
resetSendConfigured,
|
|
48
49
|
} from "./lib/auth-env";
|
|
49
50
|
import { resolveSecret } from "./lib/auth-secret";
|
|
51
|
+
import { isAllowedPhoneNumber, makeSendPhoneOtp } from "./lib/auth-sms";
|
|
50
52
|
import { type McpMembership, type McpOAuthDeps, mcpOAuthPlugin } from "./lib/mcp-oauth";
|
|
51
53
|
import {
|
|
52
54
|
signUpAgreementHooks,
|
|
53
55
|
signUpAgreementsPlugin,
|
|
54
56
|
withAuthTransactionCapture,
|
|
55
57
|
} from "./lib/sign-up-agreements";
|
|
58
|
+
import { TOPOLOGY } from "./lib/topology.generated";
|
|
56
59
|
|
|
57
60
|
/**
|
|
58
61
|
* Reset-token lifetime (#5962 § D11). One hour — the library's own default,
|
|
@@ -80,6 +83,97 @@ const VERIFY_TOKEN_TTL_SECONDS = 86_400;
|
|
|
80
83
|
*/
|
|
81
84
|
const VERIFY_EMAIL_DISABLED_PATHS = ["/verify-email"];
|
|
82
85
|
|
|
86
|
+
/**
|
|
87
|
+
* The phone plugin's paths AILK turns off whenever it is installed (#11106
|
|
88
|
+
* D9): phone is never a sign-in method or a password-reset channel, only a
|
|
89
|
+
* verified contact a signed-in person sets for themselves.
|
|
90
|
+
*/
|
|
91
|
+
export const PHONE_DISABLED_PATHS = [
|
|
92
|
+
"/sign-in/phone-number",
|
|
93
|
+
"/phone-number/request-password-reset",
|
|
94
|
+
"/phone-number/reset-password",
|
|
95
|
+
];
|
|
96
|
+
|
|
97
|
+
/** The code's shape and life (#11106 D9), set explicitly so they are reviewable. */
|
|
98
|
+
const PHONE_OTP_LENGTH = 6;
|
|
99
|
+
const PHONE_OTP_TTL_SECONDS = 300;
|
|
100
|
+
const PHONE_OTP_ATTEMPTS = 3;
|
|
101
|
+
|
|
102
|
+
let guardPhoneStep: AuthMiddleware | undefined;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* The phone step's guard (#11106 D9, SEC-11106-2). `/phone-number/send-otp`
|
|
106
|
+
* and `/phone-number/verify` answer only a session whose user's email is
|
|
107
|
+
* verified — 401 signed out, 403 unverified — so a throwaway account cannot
|
|
108
|
+
* text anyone. `/phone-number/verify` also needs `updatePhoneNumber: true`:
|
|
109
|
+
* without it the plugin signs the phone's owner in (it creates a session),
|
|
110
|
+
* which would make phone a sign-in method after all.
|
|
111
|
+
*/
|
|
112
|
+
export const phoneVerificationGuard = {
|
|
113
|
+
id: "ailk-phone-verification-guard",
|
|
114
|
+
hooks: {
|
|
115
|
+
before: [
|
|
116
|
+
{
|
|
117
|
+
matcher: (ctx) =>
|
|
118
|
+
ctx.path === "/phone-number/send-otp" || ctx.path === "/phone-number/verify",
|
|
119
|
+
// `better-auth/api` is ESM-only (#507): imported when the hook first runs.
|
|
120
|
+
handler: async (ctx) => {
|
|
121
|
+
const { APIError, createAuthMiddleware, getSessionFromCtx } = await import(
|
|
122
|
+
"better-auth/api"
|
|
123
|
+
);
|
|
124
|
+
guardPhoneStep ??= createAuthMiddleware(async (inner) => {
|
|
125
|
+
const session = await getSessionFromCtx(inner);
|
|
126
|
+
if (!session) {
|
|
127
|
+
throw new APIError("UNAUTHORIZED", { code: "SESSION_REQUIRED", message: "SESSION_REQUIRED" });
|
|
128
|
+
}
|
|
129
|
+
if (session.user.emailVerified !== true) {
|
|
130
|
+
throw new APIError("FORBIDDEN", { code: "EMAIL_NOT_VERIFIED", message: "EMAIL_NOT_VERIFIED" });
|
|
131
|
+
}
|
|
132
|
+
const body = inner.body as Record<string, unknown> | undefined;
|
|
133
|
+
if (inner.path === "/phone-number/verify" && body?.updatePhoneNumber !== true) {
|
|
134
|
+
throw new APIError("BAD_REQUEST", {
|
|
135
|
+
code: "UPDATE_PHONE_NUMBER_REQUIRED",
|
|
136
|
+
message: "UPDATE_PHONE_NUMBER_REQUIRED",
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
return undefined;
|
|
140
|
+
});
|
|
141
|
+
return guardPhoneStep(ctx);
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
],
|
|
145
|
+
},
|
|
146
|
+
} satisfies BetterAuthPlugin;
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Whether this build carries the phone step (#11106 D9): on a hub (never a
|
|
150
|
+
* spoke, which keeps no users) whose relay secret and origin are set. The
|
|
151
|
+
* Account page offers the step on the same predicate.
|
|
152
|
+
*/
|
|
153
|
+
export function phoneStepActive(): boolean {
|
|
154
|
+
return phoneVerificationConfigured() && TOPOLOGY !== "spoke";
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/** The phone plugin and its guard, as `createAuth` installs them. */
|
|
158
|
+
export function phoneVerificationPlugins() {
|
|
159
|
+
return [
|
|
160
|
+
phoneNumber({
|
|
161
|
+
sendOTP: makeSendPhoneOtp({
|
|
162
|
+
sessionUserId: async (ctx) => {
|
|
163
|
+
const { getSessionFromCtx } = await import("better-auth/api");
|
|
164
|
+
const session = await getSessionFromCtx(ctx as Parameters<typeof getSessionFromCtx>[0]);
|
|
165
|
+
return session?.user.id ?? null;
|
|
166
|
+
},
|
|
167
|
+
}),
|
|
168
|
+
otpLength: PHONE_OTP_LENGTH,
|
|
169
|
+
expiresIn: PHONE_OTP_TTL_SECONDS,
|
|
170
|
+
allowedAttempts: PHONE_OTP_ATTEMPTS,
|
|
171
|
+
phoneNumberValidator: isAllowedPhoneNumber,
|
|
172
|
+
}),
|
|
173
|
+
phoneVerificationGuard,
|
|
174
|
+
];
|
|
175
|
+
}
|
|
176
|
+
|
|
83
177
|
// mcp-oauth:begin
|
|
84
178
|
/**
|
|
85
179
|
* The site's MCP authorization server (#10357 D4): better-auth's `mcp` plugin
|
|
@@ -374,10 +468,26 @@ async function rejectNonHttpImage(user: { image?: unknown }): Promise<void> {
|
|
|
374
468
|
throw new APIError("BAD_REQUEST", { code: "INVALID_IMAGE_URL", message: "INVALID_IMAGE_URL" });
|
|
375
469
|
}
|
|
376
470
|
|
|
471
|
+
/**
|
|
472
|
+
* The phone fields a user create may carry, nulled (#11106 D7, SEC-11106-1).
|
|
473
|
+
* The phone plugin leaves `phoneNumber` input-able on create, so a
|
|
474
|
+
* `/sign-up/email`, magic-link or social sign-up could otherwise claim a
|
|
475
|
+
* number — squatting a victim's under the unique index, or probing which are
|
|
476
|
+
* registered with no text sent. Only the plugin's verify step writes either.
|
|
477
|
+
* A hook's `data` is merged over the row, so a key is dropped by nulling it.
|
|
478
|
+
*/
|
|
479
|
+
function phoneFieldsCleared(user: Record<string, unknown>): Record<string, null> {
|
|
480
|
+
const cleared: Record<string, null> = {};
|
|
481
|
+
for (const key of ["phoneNumber", "phoneNumberVerified"]) {
|
|
482
|
+
if (key in user) cleared[key] = null;
|
|
483
|
+
}
|
|
484
|
+
return cleared;
|
|
485
|
+
}
|
|
486
|
+
|
|
377
487
|
/**
|
|
378
488
|
* The sign-up hooks, with the image check on every user write: on update, and
|
|
379
489
|
* on create (the sign-up endpoint accepts `image` too) ahead of the agreement
|
|
380
|
-
* hook.
|
|
490
|
+
* hook. Every create also drops the phone fields (#11106 D7).
|
|
381
491
|
*/
|
|
382
492
|
function databaseHooks(): ReturnType<typeof signUpAgreementHooks> {
|
|
383
493
|
const hooks = signUpAgreementHooks();
|
|
@@ -388,7 +498,12 @@ function databaseHooks(): ReturnType<typeof signUpAgreementHooks> {
|
|
|
388
498
|
create: {
|
|
389
499
|
before: async (user, context) => {
|
|
390
500
|
await rejectNonHttpImage(user);
|
|
391
|
-
|
|
501
|
+
const cleared = phoneFieldsCleared(user);
|
|
502
|
+
const result = await createBefore?.({ ...user, ...cleared }, context);
|
|
503
|
+
if (Object.keys(cleared).length === 0 || result === false) return result;
|
|
504
|
+
return result && typeof result === "object" && "data" in result
|
|
505
|
+
? { ...result, data: { ...result.data, ...cleared } }
|
|
506
|
+
: { data: cleared };
|
|
392
507
|
},
|
|
393
508
|
},
|
|
394
509
|
update: { before: rejectNonHttpImage },
|
|
@@ -654,9 +769,14 @@ export function createAuth(deps: CreateAuthDeps = {}) {
|
|
|
654
769
|
* (#10357 D4): `listTenancy`'s rule — every workspace of every organization
|
|
655
770
|
* they belong to, with that membership's role.
|
|
656
771
|
*/
|
|
772
|
+
/**
|
|
773
|
+
* A deactivated membership counts as none (#11106 D6): its organization's
|
|
774
|
+
* workspaces leave the consent list and the token self-check, and return on
|
|
775
|
+
* reactivation.
|
|
776
|
+
*/
|
|
657
777
|
const readMemberships = async (userId: string): Promise<McpMembership[]> => {
|
|
658
778
|
const memberships = await prisma.membership.findMany({
|
|
659
|
-
where: { userId },
|
|
779
|
+
where: { userId, deactivatedAt: null },
|
|
660
780
|
select: {
|
|
661
781
|
role: true,
|
|
662
782
|
organization: {
|
|
@@ -679,6 +799,10 @@ export function createAuth(deps: CreateAuthDeps = {}) {
|
|
|
679
799
|
};
|
|
680
800
|
const mcpServer = baseURL ? mcpAuthorizationServer({ readMemberships }) : [];
|
|
681
801
|
|
|
802
|
+
/** The phone step (#11106 D9); its sign-in and reset paths close with it. */
|
|
803
|
+
const phoneActive = phoneStepActive();
|
|
804
|
+
const phonePlugins = phoneActive ? phoneVerificationPlugins() : [];
|
|
805
|
+
|
|
682
806
|
const instance = betterAuth({
|
|
683
807
|
/**
|
|
684
808
|
* `transaction: true` (#8765 D4): Better Auth opens one `$transaction` for
|
|
@@ -725,6 +849,7 @@ export function createAuth(deps: CreateAuthDeps = {}) {
|
|
|
725
849
|
disabledPaths: [
|
|
726
850
|
...VERIFY_EMAIL_DISABLED_PATHS,
|
|
727
851
|
...(baseURL ? MCP_DISABLED_PATHS : []),
|
|
852
|
+
...(phoneActive ? PHONE_DISABLED_PATHS : []),
|
|
728
853
|
],
|
|
729
854
|
emailAndPassword: {
|
|
730
855
|
enabled: passwordMethodActive,
|
|
@@ -925,7 +1050,8 @@ export function createAuth(deps: CreateAuthDeps = {}) {
|
|
|
925
1050
|
* `/sign-up/email` without every sign-up agreement is refused before the
|
|
926
1051
|
* handler looks the address up.
|
|
927
1052
|
*
|
|
928
|
-
* The MCP authorization server whenever `baseURL` is pinned (#10357 D4)
|
|
1053
|
+
* The MCP authorization server whenever `baseURL` is pinned (#10357 D4),
|
|
1054
|
+
* and the phone step under its predicate (#11106 D9).
|
|
929
1055
|
*/
|
|
930
1056
|
plugins: magicLinkActive
|
|
931
1057
|
? [
|
|
@@ -933,8 +1059,9 @@ export function createAuth(deps: CreateAuthDeps = {}) {
|
|
|
933
1059
|
signUpAgreementsPlugin(),
|
|
934
1060
|
magicLink(makeMagicLinkOptions({ send: authEmailTransport })),
|
|
935
1061
|
...mcpServer,
|
|
1062
|
+
...phonePlugins,
|
|
936
1063
|
]
|
|
937
|
-
: [nextCookies(), signUpAgreementsPlugin(), ...mcpServer],
|
|
1064
|
+
: [nextCookies(), signUpAgreementsPlugin(), ...mcpServer, ...phonePlugins],
|
|
938
1065
|
});
|
|
939
1066
|
return instance;
|
|
940
1067
|
}
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
*
|
|
11
11
|
* The locale layout (RSC) reads the session and authors the "Sign out" nav
|
|
12
12
|
* action as `kind: "flow"`; Nav hands the rendered trigger `<Button>` back
|
|
13
|
-
* through `renderFlowTrigger` — composed in
|
|
13
|
+
* through `renderFlowTrigger` — composed in a client Nav until #11095 D6, on the client side
|
|
14
14
|
* of the RSC boundary (#7402) — and this component clones it with the real
|
|
15
15
|
* sign-out handler. Same `createAuthClient()` idiom as `SignInGate`.
|
|
16
16
|
*/
|