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
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
"use client"; // owns renderFlowTrigger + navItems — functions that cannot cross the RSC boundary (#7402)
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* SignedInNav — the site Nav for a signed-in visitor (#7402).
|
|
5
|
-
*
|
|
6
|
-
* Signed in, the locale layout (RSC) authors two `kind: "flow"` Nav actions —
|
|
7
|
-
* the visitor's name and "Sign out" — and Nav hands their rendered triggers
|
|
8
|
-
* back through `renderFlowTrigger`. That composer is a function, and Nav
|
|
9
|
-
* forwards it into NavMobileMenu ("use client"), so a Server Component that
|
|
10
|
-
* passes it crashes every signed-in page with "Functions cannot be passed
|
|
11
|
-
* directly to Client Components". Composing Nav HERE keeps the function on the
|
|
12
|
-
* client side of the boundary.
|
|
13
|
-
*
|
|
14
|
-
* `navItems` is owned here for the same reason: a generated nav inventory
|
|
15
|
-
* carries Lucide icon components on its flyout entries, and a component is a
|
|
16
|
-
* function too. The layout passes only serializable props (labels, actions,
|
|
17
|
-
* the brand elements); everything callable is imported or defined below.
|
|
18
|
-
*
|
|
19
|
-
* Signed out, the layout keeps rendering Nav as a Server Component — it has
|
|
20
|
-
* no flow action, so nothing callable needs to cross.
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
import { Nav, type NavProps } from "@working-theory/ui/chrome";
|
|
24
|
-
import type { ReactElement } from "react";
|
|
25
|
-
|
|
26
|
-
import { withPublicDocsPaths } from "../lib/docs-path";
|
|
27
|
-
import { navItems } from "../lib/nav-config";
|
|
28
|
-
import { withPublicServicesPaths } from "../lib/services-path";
|
|
29
|
-
import { siteChrome } from "../lib/site-chrome";
|
|
30
|
-
|
|
31
|
-
import { SignOutTrigger } from "./sign-out-trigger";
|
|
32
|
-
|
|
33
|
-
// #10041 D10 — nav paths at `/docs` render at the site's docs path.
|
|
34
|
-
// `docs-path.ts` imports nothing, so it is safe on this side of the boundary.
|
|
35
|
-
// #10043 D9 — likewise nav paths at `/services`, from `services-path.ts`.
|
|
36
|
-
const publicNavItems = withPublicServicesPaths(withPublicDocsPaths(navItems));
|
|
37
|
-
|
|
38
|
-
/** Nav's props minus every function-typed one — this type IS the boundary. */
|
|
39
|
-
export type SignedInNavProps = Omit<
|
|
40
|
-
NavProps,
|
|
41
|
-
"navItems" | "renderFlowTrigger" | "translate" | "onSearchOpen"
|
|
42
|
-
> & {
|
|
43
|
-
/**
|
|
44
|
-
* Where "Sign out" POSTs, from the generated seam's `SIGN_OUT_ENDPOINT`
|
|
45
|
-
* (#7894 D10) — a spoke that signs in through its hub. Absent or `null`,
|
|
46
|
-
* Sign out goes through Better Auth's client, as on a hub.
|
|
47
|
-
*/
|
|
48
|
-
signOutEndpoint?: string | null;
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
export function SignedInNav({
|
|
52
|
-
signOutEndpoint,
|
|
53
|
-
...props
|
|
54
|
-
}: SignedInNavProps): ReactElement {
|
|
55
|
-
return (
|
|
56
|
-
<Nav
|
|
57
|
-
{...props}
|
|
58
|
-
navItems={siteChrome.nav === "mark-only" ? [] : publicNavItems}
|
|
59
|
-
// Both signed-in actions are flows with no lightbox: Sign out becomes a
|
|
60
|
-
// SignOutTrigger, the account action a non-navigating name label.
|
|
61
|
-
renderFlowTrigger={(action, trigger) =>
|
|
62
|
-
action.labelKey === "signOut" ? (
|
|
63
|
-
<SignOutTrigger
|
|
64
|
-
{...(signOutEndpoint ? { endpoint: signOutEndpoint } : {})}
|
|
65
|
-
>
|
|
66
|
-
{trigger}
|
|
67
|
-
</SignOutTrigger>
|
|
68
|
-
) : (
|
|
69
|
-
<span
|
|
70
|
-
className="text-body-sm text-(--color-text-muted)"
|
|
71
|
-
data-testid="nav-account-name"
|
|
72
|
-
>
|
|
73
|
-
{props.labels?.items.account}
|
|
74
|
-
</span>
|
|
75
|
-
)
|
|
76
|
-
}
|
|
77
|
-
/>
|
|
78
|
-
);
|
|
79
|
-
}
|
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* HubSignInGate (#7894 D10) as #8790 AC-1/AC-2 and #9662 shape it: the site's
|
|
3
|
-
* inner-page header (the back arrow), then the one hub sign-in action inside
|
|
4
|
-
* the one card's frame — the mark in the tile, "Sign in to <site>", the toggle
|
|
5
|
-
* line to the hub's /sign-up (or the site's own prospect line when its
|
|
6
|
-
* messages carry one), and the Terms + Privacy acknowledgement.
|
|
7
|
-
*
|
|
8
|
-
* #9912 D1: that toggle reaches the hub's /sign-up through the same round trip
|
|
9
|
-
* as Sign in — this site's own sign-in route with `prompt=create` and the
|
|
10
|
-
* same `next` — so completing sign-up returns the buyer here.
|
|
11
|
-
*/
|
|
12
|
-
import { render, screen, within } from "@testing-library/react";
|
|
13
|
-
import en from "../../../messages/en.json";
|
|
14
|
-
import { SITE_NAME } from "../../site-brand";
|
|
15
|
-
import { HubSignInGate } from "../sign-in-gate";
|
|
16
|
-
|
|
17
|
-
type Gate = Record<string, string>;
|
|
18
|
-
let gateMessages: Gate;
|
|
19
|
-
|
|
20
|
-
jest.mock("next-intl/server", () => ({
|
|
21
|
-
__esModule: true,
|
|
22
|
-
getTranslations: jest.fn(async ({ namespace }: { namespace: string }) => {
|
|
23
|
-
const messages: Gate =
|
|
24
|
-
namespace === "signIn" ? (en.signIn as Gate) : gateMessages;
|
|
25
|
-
const t = (key: string, values?: Record<string, string>) =>
|
|
26
|
-
(messages[key] ?? `copy:${key}`).replace(
|
|
27
|
-
/\{(\w+)\}/g,
|
|
28
|
-
(_match, name: string) => values?.[name] ?? `{${name}}`,
|
|
29
|
-
);
|
|
30
|
-
t.has = (key: string) => key in messages;
|
|
31
|
-
return t;
|
|
32
|
-
}),
|
|
33
|
-
}));
|
|
34
|
-
|
|
35
|
-
const mockConfig = jest.fn();
|
|
36
|
-
// eslint-disable-next-line no-restricted-syntax -- #507: mock-internal rewrite pending; hubSessionConfig() is a pure env read
|
|
37
|
-
jest.mock("../config", () => ({
|
|
38
|
-
__esModule: true,
|
|
39
|
-
hubSessionConfig: () => mockConfig(),
|
|
40
|
-
}));
|
|
41
|
-
|
|
42
|
-
// eslint-disable-next-line no-restricted-syntax -- #507: mock-internal rewrite pending; siteLogo() reads the site's brand files
|
|
43
|
-
jest.mock("../../site-logo", () => ({
|
|
44
|
-
__esModule: true,
|
|
45
|
-
siteLogo: () => (
|
|
46
|
-
<img src="/logomark.svg" alt="Site" data-testid="site-mark" />
|
|
47
|
-
),
|
|
48
|
-
}));
|
|
49
|
-
|
|
50
|
-
async function renderGate(pathname?: string): Promise<void> {
|
|
51
|
-
const requestHeaders = new Headers();
|
|
52
|
-
if (pathname) requestHeaders.set("x-pathname", pathname);
|
|
53
|
-
render(await HubSignInGate({ locale: "en", requestHeaders }));
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
beforeEach(() => {
|
|
57
|
-
gateMessages = { ...(en.account.gate as Gate) };
|
|
58
|
-
mockConfig
|
|
59
|
-
.mockReset()
|
|
60
|
-
.mockReturnValue({ clientId: "spoke_1", hubOrigin: "https://hub.example" });
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
describe("<HubSignInGate/> (#8790 AC-1; #9662)", () => {
|
|
64
|
-
it("wears the site's inner-page header: a back arrow to the home; the mark is the card's tile (#9662)", async () => {
|
|
65
|
-
await renderGate("/account");
|
|
66
|
-
const header = screen.getByTestId("account-sign-in-gate-header");
|
|
67
|
-
const back = screen.getByTestId("nav-back-link");
|
|
68
|
-
expect(header).toContainElement(back);
|
|
69
|
-
expect(back).toHaveAttribute("href", "/");
|
|
70
|
-
expect(back).toHaveAccessibleName(en.account.gate.homeLink);
|
|
71
|
-
expect(header).not.toContainElement(screen.getByTestId("site-mark"));
|
|
72
|
-
expect(screen.getByTestId("auth-card-logo")).toContainElement(
|
|
73
|
-
screen.getByTestId("site-mark"),
|
|
74
|
-
);
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
it("titles the card 'Sign in to <site>' from the deployment's own name and offers the one sign-in action inside it", async () => {
|
|
78
|
-
await renderGate("/account/settings");
|
|
79
|
-
// The gate is the whole page, so the card's heading is its one h1.
|
|
80
|
-
expect(
|
|
81
|
-
screen.getByRole("heading", {
|
|
82
|
-
level: 1,
|
|
83
|
-
name: `Sign in to ${SITE_NAME}`,
|
|
84
|
-
}),
|
|
85
|
-
).toBeInTheDocument();
|
|
86
|
-
const action = screen.getByTestId("account-hub-sign-in");
|
|
87
|
-
expect(screen.getByTestId("auth-card")).toContainElement(action);
|
|
88
|
-
expect(action).toHaveAttribute(
|
|
89
|
-
"href",
|
|
90
|
-
"/api/hub-session/sign-in?next=%2Faccount%2Fsettings",
|
|
91
|
-
);
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
it("carries the toggle line to the hub's /sign-up and the acknowledgement on this site's policy routes (#9662)", async () => {
|
|
95
|
-
await renderGate();
|
|
96
|
-
expect(screen.getByTestId("auth-card-prospect")).toHaveTextContent(
|
|
97
|
-
/^Don't have an account\? Sign up$/,
|
|
98
|
-
);
|
|
99
|
-
expect(screen.getByTestId("auth-card-prospect-link")).toHaveAttribute(
|
|
100
|
-
"href",
|
|
101
|
-
"/api/hub-session/sign-in?next=%2Faccount&prompt=create",
|
|
102
|
-
);
|
|
103
|
-
expect(screen.getByTestId("account-hub-sign-in")).toHaveAttribute(
|
|
104
|
-
"href",
|
|
105
|
-
"/api/hub-session/sign-in?next=%2Faccount",
|
|
106
|
-
);
|
|
107
|
-
const footnote = screen.getByTestId("auth-card-footnote");
|
|
108
|
-
expect(footnote).toHaveTextContent(
|
|
109
|
-
/^You acknowledge that you read, and agree to our Terms of Service and our Privacy Policy\.$/,
|
|
110
|
-
);
|
|
111
|
-
expect(
|
|
112
|
-
within(footnote).getByRole("link", { name: "Terms of Service" }),
|
|
113
|
-
).toHaveAttribute("href", "/terms");
|
|
114
|
-
expect(
|
|
115
|
-
within(footnote).getByRole("link", { name: "Privacy Policy" }),
|
|
116
|
-
).toHaveAttribute("href", "/privacy");
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
it("starts Sign up with the requested path as next, the Sign in button's own URL plus prompt=create (#9912 D1, AC-1)", async () => {
|
|
120
|
-
await renderGate("/account/billing");
|
|
121
|
-
expect(screen.getByTestId("auth-card-prospect-link")).toHaveAttribute(
|
|
122
|
-
"href",
|
|
123
|
-
"/api/hub-session/sign-in?next=%2Faccount%2Fbilling&prompt=create",
|
|
124
|
-
);
|
|
125
|
-
expect(screen.getByTestId("account-hub-sign-in")).toHaveAttribute(
|
|
126
|
-
"href",
|
|
127
|
-
"/api/hub-session/sign-in?next=%2Faccount%2Fbilling",
|
|
128
|
-
);
|
|
129
|
-
});
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
describe("<HubSignInGate/> prospect line (#8790 AC-2)", () => {
|
|
133
|
-
it("replaces the toggle line with the site's own when it fills all three keys", async () => {
|
|
134
|
-
gateMessages.prospectPrompt = "New here?";
|
|
135
|
-
gateMessages.prospectLink = "See if we fit";
|
|
136
|
-
gateMessages.prospectHref = "/fit";
|
|
137
|
-
await renderGate();
|
|
138
|
-
// The card's line ends on its link — no trailing period (#9662).
|
|
139
|
-
expect(screen.getByTestId("auth-card-prospect")).toHaveTextContent(
|
|
140
|
-
/^New here\? See if we fit$/,
|
|
141
|
-
);
|
|
142
|
-
expect(screen.getByRole("link", { name: "See if we fit" })).toHaveAttribute(
|
|
143
|
-
"href",
|
|
144
|
-
"/fit",
|
|
145
|
-
);
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
it("keeps the toggle line when any of the three keys is absent", async () => {
|
|
149
|
-
gateMessages.prospectPrompt = "New here?";
|
|
150
|
-
gateMessages.prospectLink = "See if we fit";
|
|
151
|
-
await renderGate();
|
|
152
|
-
expect(screen.getByTestId("auth-card-prospect-link")).toHaveAttribute(
|
|
153
|
-
"href",
|
|
154
|
-
"/api/hub-session/sign-in?next=%2Faccount&prompt=create",
|
|
155
|
-
);
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
it("draws no prospect line in the not-configured state, even with the site's three keys", async () => {
|
|
159
|
-
mockConfig.mockReturnValue(null);
|
|
160
|
-
gateMessages.prospectPrompt = "New here?";
|
|
161
|
-
gateMessages.prospectLink = "See if we fit";
|
|
162
|
-
gateMessages.prospectHref = "/fit";
|
|
163
|
-
await renderGate();
|
|
164
|
-
expect(screen.queryByTestId("auth-card-prospect")).toBeNull();
|
|
165
|
-
});
|
|
166
|
-
|
|
167
|
-
it("keeps the not-configured state when the hub is not configured", async () => {
|
|
168
|
-
mockConfig.mockReturnValue(null);
|
|
169
|
-
await renderGate();
|
|
170
|
-
expect(screen.getByRole("heading", { level: 1 })).toHaveTextContent(
|
|
171
|
-
en.account.gate.emptyHeadline,
|
|
172
|
-
);
|
|
173
|
-
expect(screen.queryByTestId("auth-card-prospect")).toBeNull();
|
|
174
|
-
expect(screen.getByTestId("account-sign-in-gate-home")).toHaveAttribute(
|
|
175
|
-
"href",
|
|
176
|
-
"/",
|
|
177
|
-
);
|
|
178
|
-
expect(screen.queryByTestId("account-hub-sign-in")).toBeNull();
|
|
179
|
-
});
|
|
180
|
-
});
|
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* HubSignInGate — the signed-out account gate of a spoke that signs in
|
|
3
|
-
* through its hub (#7894 D10; #8790 AC-1/AC-2).
|
|
4
|
-
*
|
|
5
|
-
* A Server Component, rendered by the `(authed)` layout through the generated
|
|
6
|
-
* gate seam (`signed-out-gate.generated.tsx`, its `signIn: "hub"` render). It
|
|
7
|
-
* offers ONE action: a link to this site's own `/api/hub-session/sign-in`,
|
|
8
|
-
* carrying the requested path as `next`, which starts the hub sign-in. The
|
|
9
|
-
* link is a plain anchor (the `Link` primitive), so nothing prefetches the
|
|
10
|
-
* route and starts a flow the visitor did not ask for.
|
|
11
|
-
*
|
|
12
|
-
* #8790 — the gate reads as one of the site's inner pages, not a bare
|
|
13
|
-
* full-height stop: the back arrow at the start edge (`NavBackLink`), then the
|
|
14
|
-
* card. The document title is the account page's job (`generateMetadata`
|
|
15
|
-
* there reads the session and names this state "Sign in · <site>").
|
|
16
|
-
*
|
|
17
|
-
* The one card (#9662, operator 2026-10-24): the single hub action sits in
|
|
18
|
-
* `AuthCard`'s frame — the site's mark in the 48px tile, "Sign in to <site>"
|
|
19
|
-
* (`SITE_NAME`, the deployment's own name, never the request's), the
|
|
20
|
-
* "Don't have an account? Sign up" line to this site's own sign-in route with
|
|
21
|
-
* `prompt=create`, which lands on the hub's sign-up screen and returns here
|
|
22
|
-
* (#9912 D1), and the Terms + Privacy acknowledgement on this site's own
|
|
23
|
-
* policy routes. A site that fills `account.gate.prospectPrompt` +
|
|
24
|
-
* `prospectLink` + `prospectHref` replaces the toggle line with its own. The
|
|
25
|
-
* acknowledgement is built here rather than from the `(auth)` group's
|
|
26
|
-
* builder: a spoke carries no `(auth)` group (create-ailk's
|
|
27
|
-
* `SPOKE_REMOVAL_SEEDS`).
|
|
28
|
-
*
|
|
29
|
-
* Not configured (`hubSessionConfig()` is `null`: a client id, secret or
|
|
30
|
-
* session secret missing), the card says "sign-in isn't available yet" and
|
|
31
|
-
* its one action leads back to the site.
|
|
32
|
-
*/
|
|
33
|
-
import { localeHref } from "@working-theory/ui";
|
|
34
|
-
import { AuthCard } from "@working-theory/ui/blocks";
|
|
35
|
-
import { NavBackLink } from "@working-theory/ui/chrome";
|
|
36
|
-
import { Button, Link, Text } from "@working-theory/ui/primitives";
|
|
37
|
-
import { getTranslations } from "next-intl/server";
|
|
38
|
-
import type { ReactElement } from "react";
|
|
39
|
-
|
|
40
|
-
import { SITE_NAME } from "../site-brand";
|
|
41
|
-
import { siteLogo } from "../site-logo";
|
|
42
|
-
|
|
43
|
-
import { hubSessionConfig } from "./config";
|
|
44
|
-
import { HUB_SESSION_FALLBACK_PATH } from "./session";
|
|
45
|
-
|
|
46
|
-
/** The route that starts the hub sign-in. */
|
|
47
|
-
const HUB_SIGN_IN_ROUTE = "/api/hub-session/sign-in";
|
|
48
|
-
|
|
49
|
-
export interface HubSignInGateProps {
|
|
50
|
-
locale: string;
|
|
51
|
-
/** The incoming request's headers; `x-pathname` is the page to return to. */
|
|
52
|
-
requestHeaders: Headers;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export async function HubSignInGate({
|
|
56
|
-
locale,
|
|
57
|
-
requestHeaders,
|
|
58
|
-
}: HubSignInGateProps): Promise<ReactElement> {
|
|
59
|
-
const t = await getTranslations({ locale, namespace: "account.gate" });
|
|
60
|
-
const signIn = await getTranslations({ locale, namespace: "signIn" });
|
|
61
|
-
const config = hubSessionConfig();
|
|
62
|
-
const next =
|
|
63
|
-
requestHeaders.get("x-pathname") ??
|
|
64
|
-
localeHref(locale, HUB_SESSION_FALLBACK_PATH);
|
|
65
|
-
const signInHref = `${HUB_SIGN_IN_ROUTE}?next=${encodeURIComponent(next)}`;
|
|
66
|
-
const home = localeHref(locale, "/");
|
|
67
|
-
// The three prospect keys are optional extensions of the typed catalog (the
|
|
68
|
-
// shipped en.json carries none — every leaf must be a non-empty string), so
|
|
69
|
-
// presence is the switch; hence the cast on `has`.
|
|
70
|
-
type Key = Parameters<typeof t.has>[0];
|
|
71
|
-
const has = (key: string): boolean => t.has(key as Key);
|
|
72
|
-
// Only a configured gate offers a way in; the not-configured state has none.
|
|
73
|
-
const prospect = !config
|
|
74
|
-
? undefined
|
|
75
|
-
: has("prospectPrompt") && has("prospectLink") && has("prospectHref")
|
|
76
|
-
? {
|
|
77
|
-
prompt: t("prospectPrompt" as Key),
|
|
78
|
-
linkLabel: t("prospectLink" as Key),
|
|
79
|
-
href: t("prospectHref" as Key),
|
|
80
|
-
}
|
|
81
|
-
: {
|
|
82
|
-
prompt: signIn("prospectPrompt"),
|
|
83
|
-
linkLabel: signIn("prospectLink"),
|
|
84
|
-
href: `${signInHref}&prompt=create`,
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
return (
|
|
88
|
-
<div
|
|
89
|
-
className="flex min-h-screen flex-col"
|
|
90
|
-
data-testid="account-sign-in-gate"
|
|
91
|
-
>
|
|
92
|
-
{/* The site's inner-page header: the back arrow at the start (#8790 AC-1); the card carries the mark (#9662). */}
|
|
93
|
-
<header
|
|
94
|
-
className="flex h-16 items-center px-5 md:px-8"
|
|
95
|
-
data-testid="account-sign-in-gate-header"
|
|
96
|
-
>
|
|
97
|
-
<NavBackLink href={home} label={t("homeLink")} />
|
|
98
|
-
</header>
|
|
99
|
-
<div className="flex flex-1 flex-col items-center md:justify-center md:py-section">
|
|
100
|
-
{/* AuthShell's 400px column: the cap sits on the wrapper, never on the card (AuthShell.tsx). */}
|
|
101
|
-
<div className="w-full max-w-100">
|
|
102
|
-
<AuthCard
|
|
103
|
-
intent="sign-in"
|
|
104
|
-
footer="none"
|
|
105
|
-
// The page's one heading (#7894): the gate is the whole page.
|
|
106
|
-
headingLevel={1}
|
|
107
|
-
logo={siteLogo()}
|
|
108
|
-
labels={{
|
|
109
|
-
signInHeading: config
|
|
110
|
-
? t("hubHeadline", { site: SITE_NAME })
|
|
111
|
-
: t("emptyHeadline"),
|
|
112
|
-
}}
|
|
113
|
-
subhead={config ? t("hubDescription") : t("emptyDescription")}
|
|
114
|
-
{...(prospect ? { prospect } : {})}
|
|
115
|
-
body={
|
|
116
|
-
config ? (
|
|
117
|
-
// The primary action: full width at `big` (44px).
|
|
118
|
-
<Button asChild size="big" className="w-full">
|
|
119
|
-
<Link
|
|
120
|
-
href={signInHref}
|
|
121
|
-
variant="bare"
|
|
122
|
-
data-testid="account-hub-sign-in"
|
|
123
|
-
>
|
|
124
|
-
{t("hubSignIn")}
|
|
125
|
-
</Link>
|
|
126
|
-
</Button>
|
|
127
|
-
) : (
|
|
128
|
-
<Button
|
|
129
|
-
asChild
|
|
130
|
-
variant="secondary"
|
|
131
|
-
size="big"
|
|
132
|
-
className="w-full"
|
|
133
|
-
>
|
|
134
|
-
<Link
|
|
135
|
-
href={home}
|
|
136
|
-
variant="bare"
|
|
137
|
-
data-testid="account-sign-in-gate-home"
|
|
138
|
-
>
|
|
139
|
-
{t("homeLink")}
|
|
140
|
-
</Link>
|
|
141
|
-
</Button>
|
|
142
|
-
)
|
|
143
|
-
}
|
|
144
|
-
footnote={
|
|
145
|
-
<Text as="p" variant="caption">
|
|
146
|
-
{signIn("acknowledgement")}{" "}
|
|
147
|
-
<Link variant="inline" href={localeHref(locale, "/terms")}>
|
|
148
|
-
{signIn("termsLink")}
|
|
149
|
-
</Link>{" "}
|
|
150
|
-
{signIn("acknowledgementAnd")}{" "}
|
|
151
|
-
<Link variant="inline" href={localeHref(locale, "/privacy")}>
|
|
152
|
-
{signIn("privacyLink")}
|
|
153
|
-
</Link>
|
|
154
|
-
{signIn("acknowledgementEnd")}
|
|
155
|
-
</Text>
|
|
156
|
-
}
|
|
157
|
-
/>
|
|
158
|
-
</div>
|
|
159
|
-
</div>
|
|
160
|
-
</div>
|
|
161
|
-
);
|
|
162
|
-
}
|