create-ailk 0.35.1 → 0.37.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 +51 -1
- package/component-catalog.md +8 -5
- package/dist/lib/env-catalog.js +8 -0
- package/dist/surfaces.js +66 -22
- package/dist/topology.d.ts +4 -4
- package/dist/topology.js +104 -60
- package/dist/update.d.ts +19 -1
- package/dist/update.js +293 -35
- package/package.json +3 -3
- package/templates/.env.example +38 -0
- package/templates/apps/api/.env.example +45 -0
- package/templates/apps/api/CLAUDE.md +12 -4
- package/templates/apps/api/src/lib/__mocks__/prisma.ts +7 -0
- package/templates/apps/mcp/CLAUDE.md +4 -2
- package/templates/apps/web/.env.example +16 -0
- package/templates/apps/web/CLAUDE.md +73 -5
- package/templates/apps/web/app/[locale]/(auth)/__tests__/password-reset.test.tsx +2 -0
- package/templates/apps/web/app/[locale]/(auth)/reset-password/__tests__/return.test.tsx +179 -0
- package/templates/apps/web/app/[locale]/(auth)/reset-password/page.tsx +22 -2
- package/templates/apps/web/app/[locale]/(auth)/reset-password/reset-password-card.tsx +9 -2
- 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 +241 -66
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/general.test.tsx +242 -28
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/hub-mode.test.tsx +377 -151
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/item.test.tsx +26 -1
- 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__/layout.test.tsx +17 -6
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/new-menu.test.tsx +51 -12
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/new-popups.test.tsx +17 -2
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/notifications.test.tsx +153 -2
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/page.test.tsx +206 -23
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/popups.test.tsx +150 -188
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/privacy.test.tsx +235 -177
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/rich-translator.ts +63 -0
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/security.test.tsx +0 -3
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/thread.test.tsx +340 -0
- package/templates/apps/web/app/[locale]/(authed)/account/account-data.ts +7 -5
- package/templates/apps/web/app/[locale]/(authed)/account/account-frame.tsx +20 -4
- package/templates/apps/web/app/[locale]/(authed)/account/actions.ts +8 -4
- package/templates/apps/web/app/[locale]/(authed)/account/appointments/[slug]/page.tsx +161 -0
- package/templates/apps/web/app/[locale]/(authed)/account/appointments/__tests__/page.test.tsx +426 -0
- package/templates/apps/web/app/[locale]/(authed)/account/appointments/appointments-data.ts +76 -0
- package/templates/apps/web/app/[locale]/(authed)/account/appointments/page.tsx +139 -0
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/page.tsx +92 -24
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/versions/[version]/file/route.ts +32 -1
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/file-route.test.ts +76 -3
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/page.test.tsx +290 -41
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/artifact-data.ts +109 -11
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/page.tsx +43 -44
- package/templates/apps/web/app/[locale]/(authed)/account/billing/__tests__/offerings.test.ts +99 -0
- package/templates/apps/web/app/[locale]/(authed)/account/billing/offerings.ts +123 -0
- package/templates/apps/web/app/[locale]/(authed)/account/billing/page.tsx +323 -73
- package/templates/apps/web/app/[locale]/(authed)/account/billing-source.ts +199 -43
- package/templates/apps/web/app/[locale]/(authed)/account/components/request-quote.tsx +52 -7
- 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/account-name.ts +36 -0
- package/templates/apps/web/app/[locale]/(authed)/account/general/contact-actions.ts +70 -2
- package/templates/apps/web/app/[locale]/(authed)/account/general/contact-details.tsx +42 -0
- package/templates/apps/web/app/[locale]/(authed)/account/general/page.tsx +97 -53
- 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 +215 -0
- package/templates/apps/web/app/[locale]/(authed)/account/general/photo-actions.ts +73 -0
- package/templates/apps/web/app/[locale]/(authed)/account/general/profile-form.tsx +12 -9
- package/templates/apps/web/app/[locale]/(authed)/account/general/profile-source.ts +18 -4
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/[kind]/[id]/page.tsx +20 -2
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/member-thread-composer.tsx +43 -0
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/page.tsx +125 -0
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/thread-data.ts +88 -0
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/thread-write.ts +31 -0
- 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 +9 -6
- package/templates/apps/web/app/[locale]/(authed)/account/new-menu.tsx +33 -8
- package/templates/apps/web/app/[locale]/(authed)/account/new-popups.tsx +31 -52
- package/templates/apps/web/app/[locale]/(authed)/account/notifications/page.tsx +44 -4
- package/templates/apps/web/app/[locale]/(authed)/account/page.tsx +69 -49
- package/templates/apps/web/app/[locale]/(authed)/account/privacy/__tests__/export-route.test.ts +173 -0
- package/templates/apps/web/app/[locale]/(authed)/account/privacy/actions.ts +42 -4
- package/templates/apps/web/app/[locale]/(authed)/account/privacy/export/route.ts +102 -0
- package/templates/apps/web/app/[locale]/(authed)/account/privacy/page.tsx +147 -137
- package/templates/apps/web/app/[locale]/(authed)/account/security/__tests__/hub-variant.test.tsx +258 -0
- package/templates/apps/web/app/[locale]/(authed)/account/security/page.tsx +21 -22
- package/templates/apps/web/app/[locale]/(authed)/account/security/security-panel.tsx +34 -6
- package/templates/apps/web/app/[locale]/(authed)/account/security/security-source.ts +37 -7
- package/templates/apps/web/app/[locale]/(authed)/account/settings/page.tsx +0 -2
- package/templates/apps/web/app/[locale]/(authed)/account/settings-frame.tsx +8 -5
- 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]/results/[payload]/ResultsClient.tsx +3 -2
- package/templates/apps/web/app/[locale]/layout.tsx +24 -75
- 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 +166 -7
- package/templates/apps/web/app/api/auth/hub/authorize/route.ts +96 -30
- 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/password/__tests__/return.test.ts +86 -0
- package/templates/apps/web/app/api/auth/hub/password/__tests__/route.test.ts +368 -0
- package/templates/apps/web/app/api/auth/hub/password/return.ts +86 -0
- package/templates/apps/web/app/api/auth/hub/password/route.ts +171 -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 +738 -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/password/return/route.ts +69 -0
- package/templates/apps/web/app/api/hub-session/password/route.ts +106 -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/auth.ts +133 -6
- package/templates/apps/web/components/sign-out-trigger.tsx +1 -1
- package/templates/apps/web/lib/__tests__/account-config.test.ts +129 -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__/offerings-pricing.test.ts +33 -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 +132 -8
- 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-routes.ts +11 -6
- 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/offerings-pricing.ts +4 -1
- package/templates/apps/web/lib/site-header.ts +14 -1
- 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 +264 -96
- package/templates/apps/web/middleware.ts +34 -2
- package/templates/apps/web/security-headers.config.ts +21 -0
- package/versions.json +48 -48
- package/templates/apps/web/app/[locale]/(authed)/account/components/schedule-service.tsx +0 -276
- package/templates/apps/web/app/[locale]/(authed)/account/components/send-message.tsx +0 -128
- package/templates/apps/web/app/[locale]/(authed)/account/settings/__tests__/theme-modes.test.ts +0 -42
- package/templates/apps/web/app/[locale]/(authed)/account/settings/theme-modes.ts +0 -40
- 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
|
@@ -3,17 +3,34 @@
|
|
|
3
3
|
* D6a, D9, D12; #8231 D3; DESIGN.md §5.4).
|
|
4
4
|
*
|
|
5
5
|
* RSC, rendered inside the account layout's SignedInShell. One filtered
|
|
6
|
-
* list: the tabs All ·
|
|
7
|
-
* selected, through the shared
|
|
6
|
+
* list: the tabs All · Messages · Orders · Scheduled (#11149, operator
|
|
7
|
+
* rulings 2026-11-08), each with a count, All selected, through the shared
|
|
8
|
+
* `InboxList` (`@working-theory/templates/account`). `?tab=<id>` opens
|
|
9
|
+
* another tab; any other value, the frame's own `?tab=for-you` included,
|
|
10
|
+
* opens All:
|
|
8
11
|
*
|
|
9
|
-
* - All — every loaded row, newest first
|
|
10
|
-
* `needs-you` (`result`,
|
|
11
|
-
*
|
|
12
|
-
*
|
|
12
|
+
* - All — every loaded row, newest first: the union of the other tabs,
|
|
13
|
+
* each row once, plus the kinds in `updates` or `needs-you` (`result`,
|
|
14
|
+
* `piece`), which show here only.
|
|
15
|
+
* - Messages (#11157) — the conversation kinds (`accountChatKinds`): the
|
|
16
|
+
* provider's messages and the member's own sent requests and messages,
|
|
17
|
+
* newest first, each the entry the member thread page opens. A request
|
|
18
|
+
* the member just posted is here and under All on the next render (the
|
|
19
|
+
* New menu refreshes the route after a post).
|
|
20
|
+
* - Orders — the kinds whose section is `purchases` (the `purchase` kind,
|
|
21
|
+
* and any a module adds), newest first. The tab keeps the contract's
|
|
22
|
+
* id, `purchases` (the section id, the `purchase` kind and
|
|
23
|
+
* `GET /v1/member/purchases` are unchanged); only its label — the key
|
|
24
|
+
* `inbox.tabs.purchases` — reads Orders, the Admin's word for the same
|
|
25
|
+
* records (#9170).
|
|
13
26
|
* - Scheduled — the kinds whose section is `upcoming` (`appointment`):
|
|
14
27
|
* first the items still upcoming, soonest first (no time last), then the
|
|
15
28
|
* rest, newest first. Each kind's own read decides which is upcoming.
|
|
16
29
|
*
|
|
30
|
+
* No lead line under the title (#11149): the Admin's Inbox has none, and
|
|
31
|
+
* the tabs say what the list holds. The tabs follow the title row at the
|
|
32
|
+
* list's own `mt-block-loose`, the token the Admin's list sits at.
|
|
33
|
+
*
|
|
17
34
|
* What needs the person is never an Inbox row: `email-unverified`,
|
|
18
35
|
* `payment-due` and "Add your name" are For-you items (D9 as amended). From
|
|
19
36
|
* `md` up they are the layout's aside.
|
|
@@ -27,7 +44,7 @@
|
|
|
27
44
|
* type tag, title, Open or View, and ✕; the empty line when none waits,
|
|
28
45
|
* and D12's error row above the list when a For-you source failed.
|
|
29
46
|
* The h1 sits above both panels, visually hidden below `md` (the phone has
|
|
30
|
-
* no large title). At `md`+ only the Inbox panel shows
|
|
47
|
+
* no large title). At `md`+ only the Inbox panel shows.
|
|
31
48
|
*
|
|
32
49
|
* D12 — any read that fails (a kind or a For-you source) renders an error
|
|
33
50
|
* row with Retry above the list; the list then holds what DID load, never a
|
|
@@ -52,7 +69,8 @@ import {
|
|
|
52
69
|
type AccountContext,
|
|
53
70
|
type InboxListRow,
|
|
54
71
|
} from "@working-theory/templates/account";
|
|
55
|
-
import {
|
|
72
|
+
import { localeHref } from "@working-theory/ui";
|
|
73
|
+
import { Heading, LocalTime } from "@working-theory/ui/primitives";
|
|
56
74
|
import {
|
|
57
75
|
CalendarClock,
|
|
58
76
|
ClipboardList,
|
|
@@ -62,9 +80,11 @@ import {
|
|
|
62
80
|
import type { Metadata } from "next";
|
|
63
81
|
import { headers } from "next/headers";
|
|
64
82
|
import { getTranslations } from "next-intl/server";
|
|
83
|
+
import type { ComponentType, ReactElement } from "react";
|
|
84
|
+
|
|
85
|
+
import { accountChatKinds } from "../../../../lib/account-config";
|
|
65
86
|
import { SITE_NAME } from "../../../../lib/site-brand";
|
|
66
87
|
import { readSession } from "../../../../lib/topology.generated";
|
|
67
|
-
import type { ComponentType, ReactElement } from "react";
|
|
68
88
|
|
|
69
89
|
import {
|
|
70
90
|
accountSession,
|
|
@@ -82,6 +102,8 @@ import { newActions } from "./new-popups";
|
|
|
82
102
|
|
|
83
103
|
interface Props {
|
|
84
104
|
params: Promise<{ locale: string }>;
|
|
105
|
+
/** `?tab=` — an Inbox tab id opens that tab (#11149); the frame reads the same key for the phone's For you tab. */
|
|
106
|
+
searchParams?: Promise<{ tab?: string | string[] }>;
|
|
85
107
|
}
|
|
86
108
|
|
|
87
109
|
export async function generateMetadata({ params }: Props): Promise<Metadata> {
|
|
@@ -132,7 +154,10 @@ async function loadNewActions(
|
|
|
132
154
|
actions.push({
|
|
133
155
|
id: action.id,
|
|
134
156
|
label: ctx.t(action.label),
|
|
135
|
-
popup
|
|
157
|
+
// #11154 — a link row navigates to its page; the rest open a popup.
|
|
158
|
+
...(action.href !== undefined
|
|
159
|
+
? { href: localeHref(ctx.locale, action.href) }
|
|
160
|
+
: { popup: action.renderPopup?.(ctx) }),
|
|
136
161
|
});
|
|
137
162
|
});
|
|
138
163
|
return {
|
|
@@ -149,8 +174,12 @@ function scheduledOrder(rows: readonly LoadedInboxItem[]): LoadedInboxItem[] {
|
|
|
149
174
|
return [...upcoming, ...rows.filter(({ item }) => item.upcoming !== true)];
|
|
150
175
|
}
|
|
151
176
|
|
|
152
|
-
export default async function AccountInboxPage({
|
|
177
|
+
export default async function AccountInboxPage({
|
|
178
|
+
params,
|
|
179
|
+
searchParams,
|
|
180
|
+
}: Props): Promise<ReactElement | null> {
|
|
153
181
|
const { locale } = await params;
|
|
182
|
+
const requestedTab = ((await searchParams) ?? {}).tab;
|
|
154
183
|
const t = await getTranslations({ locale, namespace: "account" });
|
|
155
184
|
const session = await accountSession(locale);
|
|
156
185
|
|
|
@@ -173,26 +202,36 @@ export default async function AccountInboxPage({ params }: Props): Promise<React
|
|
|
173
202
|
{ actions: [], failed: false },
|
|
174
203
|
];
|
|
175
204
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
timeZone: "UTC",
|
|
180
|
-
});
|
|
205
|
+
// #11175: the caption carries the day as a `LocalTime` node — the server
|
|
206
|
+
// fallback zone in this RSC's render, the viewer's own once the row
|
|
207
|
+
// hydrates.
|
|
181
208
|
const toRow = ({ kind, item }: LoadedInboxItem): InboxListRow => {
|
|
182
209
|
const label = translate(kind.label);
|
|
183
210
|
const icon = KIND_ICON[kind.kind];
|
|
184
211
|
return {
|
|
185
212
|
id: `${kind.kind}:${item.id}`,
|
|
186
213
|
...(icon ? { icon } : {}),
|
|
187
|
-
caption: item.at
|
|
188
|
-
|
|
189
|
-
|
|
214
|
+
caption: item.at ? (
|
|
215
|
+
<>
|
|
216
|
+
{label}
|
|
217
|
+
{" · "}
|
|
218
|
+
<LocalTime at={item.at} preset="month-day" locale={locale} />
|
|
219
|
+
</>
|
|
220
|
+
) : (
|
|
221
|
+
label
|
|
222
|
+
),
|
|
190
223
|
title: item.title,
|
|
191
224
|
href: inboxItemHref(locale, kind.kind, item.id),
|
|
192
225
|
};
|
|
193
226
|
};
|
|
194
227
|
|
|
195
228
|
const all = inbox.items.map(toRow);
|
|
229
|
+
// #11157 — the conversation kinds alone: the provider's messages and the
|
|
230
|
+
// member's own sent requests and messages, newest first as loaded.
|
|
231
|
+
const messages = inbox.items
|
|
232
|
+
.filter(({ kind }) => accountChatKinds.has(kind.kind))
|
|
233
|
+
.map(toRow);
|
|
234
|
+
// #11149 — the Orders tab: the kinds whose section is `purchases`.
|
|
196
235
|
const purchases = inbox.items
|
|
197
236
|
.filter(({ kind }) => kind.section === "purchases")
|
|
198
237
|
.map(toRow);
|
|
@@ -200,6 +239,13 @@ export default async function AccountInboxPage({ params }: Props): Promise<React
|
|
|
200
239
|
inbox.items.filter(({ kind }) => kind.section === "upcoming"),
|
|
201
240
|
).map(toRow);
|
|
202
241
|
const failed = inbox.failed || forYou.failed || newMenu.failed;
|
|
242
|
+
// The `purchases` tab is Orders: the contract's section id, the Admin's word (#11149).
|
|
243
|
+
const tabs = [
|
|
244
|
+
{ id: "all", label: t("inbox.tabs.all"), count: all.length, rows: all },
|
|
245
|
+
{ id: "messages", label: t("inbox.tabs.messages"), count: messages.length, rows: messages },
|
|
246
|
+
{ id: "purchases", label: t("inbox.tabs.purchases"), count: purchases.length, rows: purchases },
|
|
247
|
+
{ id: "scheduled", label: t("inbox.tabs.scheduled"), count: scheduled.length, rows: scheduled },
|
|
248
|
+
];
|
|
203
249
|
|
|
204
250
|
return (
|
|
205
251
|
// The phone's top bar already clears the canvas — no top inset there.
|
|
@@ -216,15 +262,6 @@ export default async function AccountInboxPage({ params }: Props): Promise<React
|
|
|
216
262
|
/>
|
|
217
263
|
</div>
|
|
218
264
|
<PhoneTabPanel tabs={["inbox"]} desktop data-testid="inbox-panel-inbox">
|
|
219
|
-
<Text
|
|
220
|
-
as="p"
|
|
221
|
-
variant="body-sm"
|
|
222
|
-
tone="muted"
|
|
223
|
-
className="mt-block-tight hidden md:block"
|
|
224
|
-
>
|
|
225
|
-
{t("inbox.lead")}
|
|
226
|
-
</Text>
|
|
227
|
-
|
|
228
265
|
{failed ? (
|
|
229
266
|
<ErrorRow
|
|
230
267
|
message={t("inbox.error")}
|
|
@@ -234,27 +271,10 @@ export default async function AccountInboxPage({ params }: Props): Promise<React
|
|
|
234
271
|
) : null}
|
|
235
272
|
|
|
236
273
|
<InboxList
|
|
237
|
-
tabs={
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
count: all.length,
|
|
242
|
-
rows: all,
|
|
243
|
-
},
|
|
244
|
-
{
|
|
245
|
-
id: "purchases",
|
|
246
|
-
label: t("inbox.tabs.purchases"),
|
|
247
|
-
count: purchases.length,
|
|
248
|
-
rows: purchases,
|
|
249
|
-
},
|
|
250
|
-
{
|
|
251
|
-
id: "scheduled",
|
|
252
|
-
label: t("inbox.tabs.scheduled"),
|
|
253
|
-
count: scheduled.length,
|
|
254
|
-
rows: scheduled,
|
|
255
|
-
},
|
|
256
|
-
]}
|
|
257
|
-
defaultTab="all"
|
|
274
|
+
tabs={tabs}
|
|
275
|
+
// #11149 — `?tab=<id>` opens that tab; anything else (a repeated
|
|
276
|
+
// value, the frame's `for-you`) opens All.
|
|
277
|
+
defaultTab={tabs.find((tab) => tab.id === requestedTab)?.id ?? "all"}
|
|
258
278
|
{...(failed ? {} : { emptyLine: t("inbox.empty") })}
|
|
259
279
|
/>
|
|
260
280
|
</PhoneTabPanel>
|
package/templates/apps/web/app/[locale]/(authed)/account/privacy/__tests__/export-route.test.ts
ADDED
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jest-environment node
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The person's data export, re-served (#11164 AC-3) —
|
|
7
|
+
* `GET /[locale]/account/privacy/export`.
|
|
8
|
+
*
|
|
9
|
+
* The api-client's `member.exportData` is the one external boundary mocked;
|
|
10
|
+
* `forwardedCookieInit()` and the route's decisions are real (the build's
|
|
11
|
+
* own sign-in, a single site: the caller's session cookie). Covers:
|
|
12
|
+
* - the read carries the caller's credential and the JSON comes back with
|
|
13
|
+
* all five hub headers unchanged;
|
|
14
|
+
* - a hub answer missing any of the five is refused 502, its stream
|
|
15
|
+
* cancelled — never bytes on this origin without them;
|
|
16
|
+
* - a cross-site navigation is refused 403 before any call;
|
|
17
|
+
* - refusals map to a status with no body and `private, no-store`: a 4xx
|
|
18
|
+
* keeps its status (the 429 when the person's hourly exports are spent),
|
|
19
|
+
* a 5xx or a throw is 502, no credential is 401.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
const mockExportData = jest.fn();
|
|
23
|
+
jest.mock("@working-theory/api-client", () => ({
|
|
24
|
+
__esModule: true,
|
|
25
|
+
member: { exportData: (...args: unknown[]) => mockExportData(...args) },
|
|
26
|
+
}));
|
|
27
|
+
|
|
28
|
+
const mockHeaders = jest.fn();
|
|
29
|
+
const mockCookies = jest.fn();
|
|
30
|
+
jest.mock("next/headers", () => ({
|
|
31
|
+
__esModule: true,
|
|
32
|
+
headers: (...args: unknown[]) => mockHeaders(...args),
|
|
33
|
+
cookies: (...args: unknown[]) => mockCookies(...args),
|
|
34
|
+
}));
|
|
35
|
+
|
|
36
|
+
import { GET as route } from "../export/route";
|
|
37
|
+
|
|
38
|
+
/** A same-origin navigation to the route, unless `site` says otherwise. */
|
|
39
|
+
const GET = (site: string | null = "same-origin") =>
|
|
40
|
+
route(
|
|
41
|
+
new Request("https://site.example.com/account/privacy/export", {
|
|
42
|
+
headers: site === null ? {} : { "sec-fetch-site": site },
|
|
43
|
+
}),
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
const FIVE = {
|
|
47
|
+
contentType: "application/json; charset=utf-8",
|
|
48
|
+
contentDisposition: 'attachment; filename="your-data.json"',
|
|
49
|
+
contentTypeOptions: "nosniff",
|
|
50
|
+
contentSecurityPolicy:
|
|
51
|
+
"default-src 'none'; sandbox; frame-ancestors 'none'; form-action 'none'; base-uri 'none'",
|
|
52
|
+
cacheControl: "private, no-store",
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
beforeEach(() => {
|
|
56
|
+
mockExportData.mockReset();
|
|
57
|
+
mockHeaders
|
|
58
|
+
.mockReset()
|
|
59
|
+
.mockResolvedValue(new Headers({ origin: "https://site.example.com" }));
|
|
60
|
+
mockCookies.mockReset().mockResolvedValue({ toString: () => "session=abc" });
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it("reads the export with the caller's own credential and re-serves it with all five headers unchanged", async () => {
|
|
64
|
+
const stream = new ReadableStream<Uint8Array>();
|
|
65
|
+
mockExportData.mockResolvedValue({
|
|
66
|
+
ok: true,
|
|
67
|
+
body: { stream, headers: FIVE },
|
|
68
|
+
});
|
|
69
|
+
const res = await GET();
|
|
70
|
+
expect(mockExportData).toHaveBeenCalledWith({
|
|
71
|
+
headers: { cookie: "session=abc", origin: "https://site.example.com" },
|
|
72
|
+
});
|
|
73
|
+
expect(res.status).toBe(200);
|
|
74
|
+
expect(res.body).toBe(stream);
|
|
75
|
+
expect(res.headers.get("Content-Type")).toBe(FIVE.contentType);
|
|
76
|
+
expect(res.headers.get("Content-Disposition")).toBe(FIVE.contentDisposition);
|
|
77
|
+
expect(res.headers.get("X-Content-Type-Options")).toBe("nosniff");
|
|
78
|
+
expect(res.headers.get("Content-Security-Policy")).toBe(
|
|
79
|
+
FIVE.contentSecurityPolicy,
|
|
80
|
+
);
|
|
81
|
+
expect(res.headers.get("Cache-Control")).toBe("private, no-store");
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it.each(Object.keys(FIVE) as (keyof typeof FIVE)[])(
|
|
85
|
+
"a hub answer missing %s is refused 502 with the stream cancelled",
|
|
86
|
+
async (missing) => {
|
|
87
|
+
const cancel = jest.fn().mockResolvedValue(undefined);
|
|
88
|
+
mockExportData.mockResolvedValue({
|
|
89
|
+
ok: true,
|
|
90
|
+
body: { stream: { cancel }, headers: { ...FIVE, [missing]: null } },
|
|
91
|
+
});
|
|
92
|
+
const res = await GET();
|
|
93
|
+
expect(res.status).toBe(502);
|
|
94
|
+
expect(res.body).toBeNull();
|
|
95
|
+
expect(res.headers.get("Cache-Control")).toBe("private, no-store");
|
|
96
|
+
expect(cancel).toHaveBeenCalledTimes(1);
|
|
97
|
+
},
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
const refusal = (status: number, code: string) => ({
|
|
101
|
+
ok: false,
|
|
102
|
+
status,
|
|
103
|
+
body: { ok: false, error: { code, message: code } },
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it.each([
|
|
107
|
+
[
|
|
108
|
+
"a 429 (the hourly budget spent) answers 429",
|
|
109
|
+
refusal(429, "rate_limited"),
|
|
110
|
+
429,
|
|
111
|
+
],
|
|
112
|
+
[
|
|
113
|
+
"a 403 (email unverified) answers 403",
|
|
114
|
+
refusal(403, "email_unverified"),
|
|
115
|
+
403,
|
|
116
|
+
],
|
|
117
|
+
[
|
|
118
|
+
"a 404 (an older hub with no export route) answers 404",
|
|
119
|
+
refusal(404, "not_found"),
|
|
120
|
+
404,
|
|
121
|
+
],
|
|
122
|
+
["a 503 from the hub answers 502", refusal(503, "tenant_unresolved"), 502],
|
|
123
|
+
["no credential (signed out) answers 401", refusal(0, "unauthorized"), 401],
|
|
124
|
+
[
|
|
125
|
+
"a transport the api-client refuses answers 502",
|
|
126
|
+
refusal(0, "insecure_transport"),
|
|
127
|
+
502,
|
|
128
|
+
],
|
|
129
|
+
])("%s with no body and private, no-store", async (_name, answer, status) => {
|
|
130
|
+
mockExportData.mockResolvedValue(answer);
|
|
131
|
+
const res = await GET();
|
|
132
|
+
expect(res.status).toBe(status);
|
|
133
|
+
expect(res.body).toBeNull();
|
|
134
|
+
expect(res.headers.get("Cache-Control")).toBe("private, no-store");
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
it("a 429 keeps the hub's retry hint as Retry-After, rebuilt from the refusal's retryAfterSeconds", async () => {
|
|
138
|
+
mockExportData.mockResolvedValue({
|
|
139
|
+
ok: false,
|
|
140
|
+
status: 429,
|
|
141
|
+
body: { error: "rate_limited", retryAfterSeconds: 1800 },
|
|
142
|
+
});
|
|
143
|
+
const res = await GET();
|
|
144
|
+
expect(res.status).toBe(429);
|
|
145
|
+
expect(res.headers.get("Retry-After")).toBe("1800");
|
|
146
|
+
expect(res.body).toBeNull();
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
it.each(["cross-site", "same-site"])(
|
|
150
|
+
"a %s navigation is refused 403 before any call",
|
|
151
|
+
async (site) => {
|
|
152
|
+
const res = await GET(site);
|
|
153
|
+
expect(res.status).toBe(403);
|
|
154
|
+
expect(res.body).toBeNull();
|
|
155
|
+
expect(mockExportData).not.toHaveBeenCalled();
|
|
156
|
+
},
|
|
157
|
+
);
|
|
158
|
+
|
|
159
|
+
it("a navigation with no Sec-Fetch-Site (an older browser) and a `none` one (the address bar) are served", async () => {
|
|
160
|
+
mockExportData.mockResolvedValue({
|
|
161
|
+
ok: true,
|
|
162
|
+
body: { stream: new ReadableStream<Uint8Array>(), headers: FIVE },
|
|
163
|
+
});
|
|
164
|
+
expect((await GET(null)).status).toBe(200);
|
|
165
|
+
expect((await GET("none")).status).toBe(200);
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
it("a hub call that throws is a 502, never Next's own 500", async () => {
|
|
169
|
+
mockExportData.mockRejectedValue(new Error("ECONNREFUSED"));
|
|
170
|
+
const res = await GET();
|
|
171
|
+
expect(res.status).toBe(502);
|
|
172
|
+
expect(res.body).toBeNull();
|
|
173
|
+
});
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
/**
|
|
4
4
|
* A/privacy/actions.ts — the member Privacy and Notifications tabs' one
|
|
5
5
|
* consent write path (#8438 D14, D15, spec
|
|
6
|
-
* docs/specs/8438-consent-registry-and-ledger-step-spec.md)
|
|
6
|
+
* docs/specs/8438-consent-registry-and-ledger-step-spec.md), and the Privacy
|
|
7
|
+
* tab's stored-sessions deletion (#11164 AC-3).
|
|
7
8
|
*
|
|
8
9
|
* `setConsentAction` posts one answer through `POST /v1/member/consents`
|
|
9
10
|
* (`member.setConsent`) and answers in `ConsentSwitchList`'s own shape, so
|
|
@@ -12,18 +13,36 @@
|
|
|
12
13
|
* when present, linking its cookie choices to the client record this write
|
|
13
14
|
* resolves or creates (D6, D11, D12) — never failing the write when it is
|
|
14
15
|
* absent or invalid.
|
|
16
|
+
*
|
|
17
|
+
* `deleteStoredSessionsAction` posts `POST /v1/member/stored-sessions/delete`
|
|
18
|
+
* (`member.deleteStoredSessions`) with the caller's own credential and
|
|
19
|
+
* answers in `AccountDataTable`'s shape: the line to show — the count, or
|
|
20
|
+
* that there was nothing to delete — or the failure message. The
|
|
21
|
+
* confirmation is the table's; this runs only after it.
|
|
15
22
|
*/
|
|
16
23
|
|
|
17
24
|
import { member } from "@working-theory/api-client";
|
|
18
|
-
import type {
|
|
25
|
+
import type {
|
|
26
|
+
AccountDataActionResult,
|
|
27
|
+
ConsentSwitchChangeResult,
|
|
28
|
+
} from "@working-theory/templates/account";
|
|
29
|
+
import {
|
|
30
|
+
formatLocalTime,
|
|
31
|
+
SERVER_TIME_ZONE,
|
|
32
|
+
} from "@working-theory/ui/primitives";
|
|
19
33
|
import { cookies } from "next/headers";
|
|
20
34
|
import { getLocale, getTranslations } from "next-intl/server";
|
|
21
35
|
|
|
22
|
-
import {
|
|
36
|
+
import {
|
|
37
|
+
consentVisitorHeader,
|
|
38
|
+
readConsentVisitor,
|
|
39
|
+
} from "../../../../../lib/consent-visitor";
|
|
23
40
|
import { forwardedCookieInit } from "../../../../../lib/server-api";
|
|
24
41
|
|
|
42
|
+
// #11159: the server fallback zone, never the host's, which the unpinned
|
|
43
|
+
// form read; the line is a `t()` string, so no node can carry the viewer's.
|
|
25
44
|
function formatDate(iso: string, locale: string): string {
|
|
26
|
-
return
|
|
45
|
+
return formatLocalTime(iso, "date", { timeZone: SERVER_TIME_ZONE, locale });
|
|
27
46
|
}
|
|
28
47
|
|
|
29
48
|
export async function setConsentAction(
|
|
@@ -63,3 +82,22 @@ export async function setConsentAction(
|
|
|
63
82
|
return { ok: false, message: t("settings.privacy.unavailable") };
|
|
64
83
|
}
|
|
65
84
|
}
|
|
85
|
+
|
|
86
|
+
export async function deleteStoredSessionsAction(): Promise<AccountDataActionResult> {
|
|
87
|
+
const t = await getTranslations("account");
|
|
88
|
+
try {
|
|
89
|
+
const res = await member.deleteStoredSessions(await forwardedCookieInit());
|
|
90
|
+
if (!res.ok) {
|
|
91
|
+
return {
|
|
92
|
+
ok: false,
|
|
93
|
+
message: t("settings.privacy.yourData.deleteFailed"),
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
return {
|
|
97
|
+
ok: true,
|
|
98
|
+
line: t("settings.privacy.yourData.deleted", { count: res.body.deleted }),
|
|
99
|
+
};
|
|
100
|
+
} catch {
|
|
101
|
+
return { ok: false, message: t("settings.privacy.yourData.deleteFailed") };
|
|
102
|
+
}
|
|
103
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The person's data export, re-served (#11164 AC-3) —
|
|
3
|
+
* `GET /[locale]/account/privacy/export`.
|
|
4
|
+
*
|
|
5
|
+
* The Privacy tab's "Export data" button links here. The browser holds
|
|
6
|
+
* neither the client's hub credential (sealed in the `hub-session` cookie)
|
|
7
|
+
* nor this site's spoke key, so this route reads `GET /v1/member/data-export`
|
|
8
|
+
* with `forwardedCookieInit()` — the caller's own credential, so a person
|
|
9
|
+
* only ever gets their own records — and streams the JSON back unread.
|
|
10
|
+
*
|
|
11
|
+
* The same contract as the member file reads (`inbox/message/[id]/file`):
|
|
12
|
+
* the bytes go out with all five hub headers UNCHANGED — `Content-Type`,
|
|
13
|
+
* `Content-Disposition` (attachment, `your-data.json`), `X-Content-Type-Options:
|
|
14
|
+
* nosniff`, the sandbox `Content-Security-Policy` and `Cache-Control: private,
|
|
15
|
+
* no-store` — so the file is never a document on this origin and never cached
|
|
16
|
+
* on the way. A hub answer missing any of the five is refused 502 rather than
|
|
17
|
+
* served without it.
|
|
18
|
+
*
|
|
19
|
+
* A refusal has no body: a cross-site navigation (`Sec-Fetch-Site` other
|
|
20
|
+
* than `same-origin` or `none` — a third-party link must not spend the
|
|
21
|
+
* person's hourly exports or drop a file on their disk) is a 403 before any
|
|
22
|
+
* call; no credential (signed out) is a 401, a hub 4xx keeps its status (a
|
|
23
|
+
* 429 when the person's hourly exports are spent), and a hub 5xx, a
|
|
24
|
+
* transport the api-client refuses or a hub call that throws is a 502.
|
|
25
|
+
*/
|
|
26
|
+
import { member, type MemberFileHeaders } from "@working-theory/api-client";
|
|
27
|
+
|
|
28
|
+
import { forwardedCookieInit } from "../../../../../../lib/server-api";
|
|
29
|
+
|
|
30
|
+
/** The response header each of the five hub headers goes out under. */
|
|
31
|
+
const FILE_HEADER_NAMES: Record<keyof MemberFileHeaders, string> = {
|
|
32
|
+
contentType: "Content-Type",
|
|
33
|
+
contentDisposition: "Content-Disposition",
|
|
34
|
+
contentTypeOptions: "X-Content-Type-Options",
|
|
35
|
+
contentSecurityPolicy: "Content-Security-Policy",
|
|
36
|
+
cacheControl: "Cache-Control",
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
function refusal(status: number, retryAfterSeconds?: number): Response {
|
|
40
|
+
return new Response(null, {
|
|
41
|
+
status,
|
|
42
|
+
headers: {
|
|
43
|
+
"Cache-Control": "private, no-store",
|
|
44
|
+
// A 429 keeps the hub's retry hint: the api-client answers the JSON
|
|
45
|
+
// body, not the headers, and the API's refusal names the seconds.
|
|
46
|
+
...(retryAfterSeconds === undefined
|
|
47
|
+
? {}
|
|
48
|
+
: { "Retry-After": String(retryAfterSeconds) }),
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** The API's `retryAfterSeconds`, when the refusal body carries one. */
|
|
54
|
+
function retryAfterOf(body: unknown): number | undefined {
|
|
55
|
+
const seconds = (body as { retryAfterSeconds?: unknown } | null)
|
|
56
|
+
?.retryAfterSeconds;
|
|
57
|
+
return typeof seconds === "number" && Number.isFinite(seconds)
|
|
58
|
+
? seconds
|
|
59
|
+
: undefined;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** The refusal's status, from the api-client's `{ ok: false, status, body }`. */
|
|
63
|
+
function refusalStatus(status: number, body: unknown): number {
|
|
64
|
+
if (status === 0) {
|
|
65
|
+
const code = (body as { error?: { code?: unknown } } | null)?.error?.code;
|
|
66
|
+
return code === "unauthorized" ? 401 : 502;
|
|
67
|
+
}
|
|
68
|
+
return status >= 500 ? 502 : status;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// platform-decisions-waiver: api-versioning — a page-scoped download link on the site's own account area, not an API contract; it re-serves the versioned hub route /v1/member/data-export
|
|
72
|
+
export async function GET(request: Request): Promise<Response> {
|
|
73
|
+
const site = request.headers.get("sec-fetch-site");
|
|
74
|
+
if (site !== null && site !== "same-origin" && site !== "none")
|
|
75
|
+
return refusal(403);
|
|
76
|
+
|
|
77
|
+
// The api-client throws, rather than answering `{ ok: false }`, on a
|
|
78
|
+
// network failure or a redirect — that is a 502 too, never Next's own 500.
|
|
79
|
+
let res: Awaited<ReturnType<typeof member.exportData>>;
|
|
80
|
+
try {
|
|
81
|
+
res = await member.exportData(await forwardedCookieInit());
|
|
82
|
+
} catch {
|
|
83
|
+
return refusal(502);
|
|
84
|
+
}
|
|
85
|
+
if (!res.ok)
|
|
86
|
+
return refusal(refusalStatus(res.status, res.body), retryAfterOf(res.body));
|
|
87
|
+
|
|
88
|
+
const { stream, headers } = res.body;
|
|
89
|
+
const out = new Headers();
|
|
90
|
+
for (const [key, name] of Object.entries(FILE_HEADER_NAMES) as [
|
|
91
|
+
keyof MemberFileHeaders,
|
|
92
|
+
string,
|
|
93
|
+
][]) {
|
|
94
|
+
const value = headers[key];
|
|
95
|
+
if (value === null) {
|
|
96
|
+
await stream.cancel();
|
|
97
|
+
return refusal(502);
|
|
98
|
+
}
|
|
99
|
+
out.set(name, value);
|
|
100
|
+
}
|
|
101
|
+
return new Response(stream, { status: 200, headers: out });
|
|
102
|
+
}
|