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,14 +3,23 @@
|
|
|
3
3
|
* docs/specs/8234-member-artifacts-account-artifacts-and-spec.md D4).
|
|
4
4
|
*
|
|
5
5
|
* RSC, inside the account layout's SignedInShell, through the shared
|
|
6
|
-
* `InboxItemFrame`: back to Artifacts, the title, the
|
|
6
|
+
* `InboxItemFrame`: back to Artifacts, the title, the piece's stage as its
|
|
7
|
+
* status (#11161 — the provider's own pipeline, read as on the list), the
|
|
8
|
+
* review of the latest version as a tag beside it when there is one, and —
|
|
7
9
|
* once approved — "Approved <date>". The body lists every served version in
|
|
8
10
|
* the read's order, newest first: its number, its delivery date, its note,
|
|
9
|
-
* the member's own review when there is one
|
|
10
|
-
* file (re-served by
|
|
11
|
-
*
|
|
12
|
-
* that is not https renders no action. The read serves no
|
|
13
|
-
* D6), so none is shown.
|
|
11
|
+
* the member's own review when there is one (a tag and the dated line), and
|
|
12
|
+
* its action — Download for a file (re-served by
|
|
13
|
+
* `versions/[version]/file/route.ts`) or View for an https link, opened in a
|
|
14
|
+
* new tab. A link that is not https renders no action. The read serves no
|
|
15
|
+
* deliverer (8169 D6), so none is shown.
|
|
16
|
+
*
|
|
17
|
+
* #11161 — an image or a PDF version renders INLINE above its Download
|
|
18
|
+
* (`ArtifactVersionPreview`: the AssetLightbox for an image, the
|
|
19
|
+
* document-viewer section for a PDF), from the same route asked to answer
|
|
20
|
+
* inline (`?inline=1`), which it does for those two types only, under the
|
|
21
|
+
* hub's sandbox CSP and `nosniff` (docs/security/member-artifact-preview.md).
|
|
22
|
+
* Every other file keeps Download alone.
|
|
14
23
|
*
|
|
15
24
|
* Inside the latest version only: the review form while it is reviewable
|
|
16
25
|
* (not approved, no review yet — `isReviewable`), else the waiting line once
|
|
@@ -34,9 +43,21 @@
|
|
|
34
43
|
* no `kind`, renders exactly as before.
|
|
35
44
|
*/
|
|
36
45
|
|
|
37
|
-
import {
|
|
46
|
+
import {
|
|
47
|
+
ArtifactVersionPreview,
|
|
48
|
+
InboxItemFrame,
|
|
49
|
+
previewKind,
|
|
50
|
+
type ArtifactVersionPreviewLabels,
|
|
51
|
+
} from "@working-theory/templates/account";
|
|
38
52
|
import { localeHref } from "@working-theory/ui";
|
|
39
|
-
import {
|
|
53
|
+
import {
|
|
54
|
+
Badge,
|
|
55
|
+
Button,
|
|
56
|
+
Heading,
|
|
57
|
+
Link,
|
|
58
|
+
LocalTime,
|
|
59
|
+
Text,
|
|
60
|
+
} from "@working-theory/ui/primitives";
|
|
40
61
|
import {
|
|
41
62
|
isHttpsLink,
|
|
42
63
|
type MemberArtifact,
|
|
@@ -50,6 +71,7 @@ import type { ReactElement } from "react";
|
|
|
50
71
|
import { accountSession, logReadFailure } from "../../account-data";
|
|
51
72
|
import { ErrorRow } from "../../error-row";
|
|
52
73
|
import {
|
|
74
|
+
artifactStageLabel,
|
|
53
75
|
artifactState,
|
|
54
76
|
isProposal,
|
|
55
77
|
isReviewable,
|
|
@@ -57,6 +79,8 @@ import {
|
|
|
57
79
|
paymentDue,
|
|
58
80
|
STATE_KEYS,
|
|
59
81
|
versionFileHref,
|
|
82
|
+
versionPreviewHref,
|
|
83
|
+
versionTypeKey,
|
|
60
84
|
} from "../artifact-data";
|
|
61
85
|
|
|
62
86
|
import { PayForm, type PayFormLabels } from "./pay-form";
|
|
@@ -115,7 +139,7 @@ export default async function AccountArtifactPage({
|
|
|
115
139
|
|
|
116
140
|
let artifacts: MemberArtifact[];
|
|
117
141
|
try {
|
|
118
|
-
artifacts = await loadArtifacts(session.ctx);
|
|
142
|
+
artifacts = (await loadArtifacts(session.ctx)).items;
|
|
119
143
|
} catch (err) {
|
|
120
144
|
logReadFailure("artifacts", err);
|
|
121
145
|
return (
|
|
@@ -134,12 +158,14 @@ export default async function AccountArtifactPage({
|
|
|
134
158
|
);
|
|
135
159
|
if (!artifact) notFound();
|
|
136
160
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
161
|
+
// #11175: every dated message carries a `<date>` tag, rendered through
|
|
162
|
+
// `t.rich` as a `LocalTime` node — the server fallback zone in this RSC's
|
|
163
|
+
// render, the viewer's own once the page hydrates.
|
|
164
|
+
const dateTag = (iso: string): { date: () => ReactElement } => ({
|
|
165
|
+
date: () => <LocalTime at={iso} preset="date" locale={locale} />,
|
|
166
|
+
});
|
|
142
167
|
const state = artifactState(artifact);
|
|
168
|
+
const reviewTag = state === "ready" ? null : t(STATE_KEYS[state]);
|
|
143
169
|
const reviewable = isReviewable(artifact);
|
|
144
170
|
const latest = artifact.versions[0]!.version;
|
|
145
171
|
const proposal = isProposal(artifact);
|
|
@@ -180,6 +206,33 @@ export default async function AccountArtifactPage({
|
|
|
180
206
|
},
|
|
181
207
|
};
|
|
182
208
|
|
|
209
|
+
const previewLabels = (filename: string): ArtifactVersionPreviewLabels => ({
|
|
210
|
+
open: t("artifacts.preview.open", { filename }),
|
|
211
|
+
details: t("artifacts.preview.details"),
|
|
212
|
+
filename: t("artifacts.preview.filename"),
|
|
213
|
+
type: t("artifacts.preview.type"),
|
|
214
|
+
zoomIn: t("artifacts.preview.zoomIn"),
|
|
215
|
+
zoomOut: t("artifacts.preview.zoomOut"),
|
|
216
|
+
copyLink: t("artifacts.preview.copyLink"),
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
// An image or a PDF version, inline (#11161); any other file has none.
|
|
220
|
+
const versionPreview = (v: MemberPieceVersion): ReactElement | null => {
|
|
221
|
+
if (v.file === null) return null;
|
|
222
|
+
const kind = previewKind(v.file.contentType);
|
|
223
|
+
if (kind === null) return null;
|
|
224
|
+
return (
|
|
225
|
+
<ArtifactVersionPreview
|
|
226
|
+
kind={kind}
|
|
227
|
+
src={versionPreviewHref(locale, artifact.id, v.version)}
|
|
228
|
+
filename={v.file.filename}
|
|
229
|
+
typeLabel={t(versionTypeKey(v))}
|
|
230
|
+
labels={previewLabels(v.file.filename)}
|
|
231
|
+
testIdPrefix={`artifact-version-${v.version}-preview`}
|
|
232
|
+
/>
|
|
233
|
+
);
|
|
234
|
+
};
|
|
235
|
+
|
|
183
236
|
// The one action of a version: Download a file, View an https link, else none.
|
|
184
237
|
const versionAction = (v: MemberPieceVersion): ReactElement | null => {
|
|
185
238
|
if (v.file !== null) {
|
|
@@ -222,10 +275,12 @@ export default async function AccountArtifactPage({
|
|
|
222
275
|
proposal ? t("artifacts.proposal.caption") : t("artifacts.caption")
|
|
223
276
|
}
|
|
224
277
|
title={artifact.title}
|
|
225
|
-
|
|
278
|
+
// An older hub serves no stage; the review tag alone then.
|
|
279
|
+
status={artifactStageLabel(artifact) ?? undefined}
|
|
280
|
+
tags={reviewTag === null ? [] : [reviewTag]}
|
|
226
281
|
lead={
|
|
227
282
|
artifact.approvedAt !== null
|
|
228
|
-
? t("artifacts.approvedOn",
|
|
283
|
+
? t.rich("artifacts.approvedOn", dateTag(artifact.approvedAt))
|
|
229
284
|
: null
|
|
230
285
|
}
|
|
231
286
|
testIdPrefix="artifact"
|
|
@@ -244,6 +299,7 @@ export default async function AccountArtifactPage({
|
|
|
244
299
|
<div className="mt-block-tight flex flex-col gap-4">
|
|
245
300
|
{artifact.versions.map((v) => {
|
|
246
301
|
const action = versionAction(v);
|
|
302
|
+
const preview = versionPreview(v);
|
|
247
303
|
return (
|
|
248
304
|
<div
|
|
249
305
|
key={v.version}
|
|
@@ -254,7 +310,7 @@ export default async function AccountArtifactPage({
|
|
|
254
310
|
{t("artifacts.version", { version: v.version })}
|
|
255
311
|
</Text>
|
|
256
312
|
<Text as="p" variant="body-sm" tone="muted">
|
|
257
|
-
{t("artifacts.deliveredOn",
|
|
313
|
+
{t.rich("artifacts.deliveredOn", dateTag(v.deliveredAt))}
|
|
258
314
|
</Text>
|
|
259
315
|
{v.note !== null ? (
|
|
260
316
|
<Text
|
|
@@ -267,14 +323,23 @@ export default async function AccountArtifactPage({
|
|
|
267
323
|
) : null}
|
|
268
324
|
{v.review !== null && v.reviewedAt !== null ? (
|
|
269
325
|
<div className="mt-2">
|
|
326
|
+
<Badge
|
|
327
|
+
variant="outline"
|
|
328
|
+
size="sm"
|
|
329
|
+
className="mb-1"
|
|
330
|
+
data-testid={`artifact-version-${v.version}-review`}
|
|
331
|
+
>
|
|
332
|
+
{v.review === "approved"
|
|
333
|
+
? t("artifacts.states.approved")
|
|
334
|
+
: t("artifacts.states.changesRequested")}
|
|
335
|
+
</Badge>
|
|
270
336
|
<Text as="p" variant="body-sm" tone="muted">
|
|
271
337
|
{v.review === "approved"
|
|
272
|
-
? t("artifacts.reviewApproved",
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
})}
|
|
338
|
+
? t.rich("artifacts.reviewApproved", dateTag(v.reviewedAt))
|
|
339
|
+
: t.rich(
|
|
340
|
+
"artifacts.reviewChangesRequested",
|
|
341
|
+
dateTag(v.reviewedAt),
|
|
342
|
+
)}
|
|
278
343
|
</Text>
|
|
279
344
|
{v.reviewComment !== null ? (
|
|
280
345
|
<Text
|
|
@@ -287,6 +352,9 @@ export default async function AccountArtifactPage({
|
|
|
287
352
|
) : null}
|
|
288
353
|
</div>
|
|
289
354
|
) : null}
|
|
355
|
+
{preview !== null ? (
|
|
356
|
+
<div className="mt-block-tight">{preview}</div>
|
|
357
|
+
) : null}
|
|
290
358
|
{action !== null ? (
|
|
291
359
|
<div className="mt-block-tight">{action}</div>
|
|
292
360
|
) : null}
|
|
@@ -314,7 +382,7 @@ export default async function AccountArtifactPage({
|
|
|
314
382
|
{v.version === latest && paidAt !== null ? (
|
|
315
383
|
<div className="mt-block-tight" data-testid="artifact-paid">
|
|
316
384
|
<Text as="p" variant="body-sm">
|
|
317
|
-
{t("artifacts.proposal.paid",
|
|
385
|
+
{t.rich("artifacts.proposal.paid", dateTag(paidAt))}
|
|
318
386
|
</Text>
|
|
319
387
|
</div>
|
|
320
388
|
) : null}
|
|
@@ -20,6 +20,17 @@
|
|
|
20
20
|
* without it — and so is one whose safety headers carry the wrong value
|
|
21
21
|
* (#8320, #9965 D8): presence alone is not the hub's promise.
|
|
22
22
|
*
|
|
23
|
+
* #11161 — the preview mode, the one amendment to that obligation (recorded
|
|
24
|
+
* in `docs/security/member-artifact-preview.md`): `?inline=1` asks for the
|
|
25
|
+
* bytes as a document the artifact page can render in place. The route
|
|
26
|
+
* answers `Content-Disposition: inline` ONLY when the hub's `Content-Type`
|
|
27
|
+
* is `image/*` (never SVG) or `application/pdf`, with the download name the
|
|
28
|
+
* hub pinned and the other four headers still unchanged — so the document
|
|
29
|
+
* renders inside the sandbox CSP's opaque origin (no script, no cookie, no
|
|
30
|
+
* same-origin access) and `nosniff` holds the type. Any other type, and
|
|
31
|
+
* every request without the flag, is `attachment` exactly as the hub sent
|
|
32
|
+
* it. The hub itself never answers inline.
|
|
33
|
+
*
|
|
23
34
|
* The params are shape-checked before any call (a malformed piece id or a
|
|
24
35
|
* version that is not a whole number from 1 is a 404 with no call). A
|
|
25
36
|
* refusal has no body: no credential (signed out) is a 401, a hub 4xx keeps
|
|
@@ -52,6 +63,16 @@ const FILE_HEADER_NAMES: Record<keyof MemberFileHeaders, string> = {
|
|
|
52
63
|
const HTTP_VALUE = /^[\t\x20-\x7e]*$/;
|
|
53
64
|
const httpTrim = (value: string) => value.replace(/^[ \t]+|[ \t]+$/g, "");
|
|
54
65
|
|
|
66
|
+
/**
|
|
67
|
+
* #11161 — the two type families a preview may render inline: raster images
|
|
68
|
+
* and PDF. SVG is refused by name (it is not attachable either, SEC-7877-D),
|
|
69
|
+
* so a hub that ever stored one still serves it as an attachment.
|
|
70
|
+
*/
|
|
71
|
+
export function isInlinePreviewType(contentType: string): boolean {
|
|
72
|
+
const type = httpTrim(contentType.split(";")[0] ?? "").toLowerCase();
|
|
73
|
+
return type === "application/pdf" || (type.startsWith("image/") && type !== "image/svg+xml");
|
|
74
|
+
}
|
|
75
|
+
|
|
55
76
|
/**
|
|
56
77
|
* The CSP's directives by name, or `null` for two policies joined or a
|
|
57
78
|
* directive named twice — a browser enforces the first copy, so a check that
|
|
@@ -115,11 +136,12 @@ function refusalStatus(status: number, body: unknown): number {
|
|
|
115
136
|
|
|
116
137
|
// 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/artifacts/:pieceId/versions/:version/file
|
|
117
138
|
export async function GET(
|
|
118
|
-
|
|
139
|
+
request: Request,
|
|
119
140
|
{ params }: Context,
|
|
120
141
|
): Promise<Response> {
|
|
121
142
|
// Exactly the two segments the strict schema takes — `params` also carries `locale`.
|
|
122
143
|
const { pieceId, version } = await params;
|
|
144
|
+
const inline = new URL(request.url).searchParams.get("inline") === "1";
|
|
123
145
|
const parsed = memberArtifactFileParamsSchema.safeParse({ pieceId, version });
|
|
124
146
|
if (!parsed.success) return refusal(404);
|
|
125
147
|
|
|
@@ -155,5 +177,14 @@ export async function GET(
|
|
|
155
177
|
}
|
|
156
178
|
out.set(name, value);
|
|
157
179
|
}
|
|
180
|
+
// #11161 — the preview mode: inline for an image or a PDF, the hub's
|
|
181
|
+
// attachment disposition (already checked above) rewritten in place with
|
|
182
|
+
// the same pinned filename; everything else stays an attachment.
|
|
183
|
+
if (inline && headers.contentType !== null && isInlinePreviewType(headers.contentType)) {
|
|
184
|
+
out.set(
|
|
185
|
+
"Content-Disposition",
|
|
186
|
+
(out.get("Content-Disposition") ?? "").replace(/^[ \t]*attachment/i, "inline"),
|
|
187
|
+
);
|
|
188
|
+
}
|
|
158
189
|
return new Response(stream, { status: 200, headers: out });
|
|
159
190
|
}
|
package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/file-route.test.ts
CHANGED
|
@@ -19,6 +19,9 @@
|
|
|
19
19
|
* - malformed params are a 404 with no call — and `locale`, which Next
|
|
20
20
|
* always passes, never makes a real request fail;
|
|
21
21
|
* - refusals map to a status with no body and `private, no-store`;
|
|
22
|
+
* - the preview mode (#11161 AC-4): `?inline=1` answers `inline` for an
|
|
23
|
+
* image or a PDF only — the other four headers unchanged — and
|
|
24
|
+
* `attachment` for every other type, and without the flag always;
|
|
22
25
|
* - the route reads no topology constant.
|
|
23
26
|
*/
|
|
24
27
|
|
|
@@ -39,7 +42,9 @@ jest.mock("next/headers", () => ({
|
|
|
39
42
|
cookies: (...args: unknown[]) => mockCookies(...args),
|
|
40
43
|
}));
|
|
41
44
|
|
|
42
|
-
import {
|
|
45
|
+
import { previewKind } from "@working-theory/templates/account";
|
|
46
|
+
|
|
47
|
+
import { GET, isInlinePreviewType } from "../[pieceId]/versions/[version]/file/route";
|
|
43
48
|
|
|
44
49
|
const SITE = "https://site.example.com";
|
|
45
50
|
const PIECE = "piece_01920000-0000-7000-8000-000000000001";
|
|
@@ -73,10 +78,10 @@ function fileResult(
|
|
|
73
78
|
};
|
|
74
79
|
}
|
|
75
80
|
|
|
76
|
-
function get(pieceId = PIECE, version = "2"): Promise<Response> {
|
|
81
|
+
function get(pieceId = PIECE, version = "2", query = ""): Promise<Response> {
|
|
77
82
|
return GET(
|
|
78
83
|
new Request(
|
|
79
|
-
`${SITE}/account/artifacts/${pieceId}/versions/${version}/file`,
|
|
84
|
+
`${SITE}/account/artifacts/${pieceId}/versions/${version}/file${query}`,
|
|
80
85
|
),
|
|
81
86
|
{
|
|
82
87
|
params: Promise.resolve({ locale: "en", pieceId, version }),
|
|
@@ -252,6 +257,74 @@ describe("the version file read", () => {
|
|
|
252
257
|
await expectBodylessRefusal(await get(), 502);
|
|
253
258
|
});
|
|
254
259
|
|
|
260
|
+
describe("the preview mode (#11161 AC-4)", () => {
|
|
261
|
+
it.each([
|
|
262
|
+
["a PDF", "application/pdf"],
|
|
263
|
+
["a PNG", "image/png"],
|
|
264
|
+
["a JPEG with a parameter", "image/jpeg; charset=binary"],
|
|
265
|
+
])("?inline=1 answers %s inline, the pinned filename and the other four headers unchanged", async (_case, contentType) => {
|
|
266
|
+
mockArtifactFile.mockResolvedValue(fileResult({ contentType }));
|
|
267
|
+
const res = await get(PIECE, "2", "?inline=1");
|
|
268
|
+
expect(res.status).toBe(200);
|
|
269
|
+
expect(res.headers.get("content-type")).toBe(contentType);
|
|
270
|
+
expect(res.headers.get("content-disposition")).toBe('inline; filename="brief-v2.pdf"');
|
|
271
|
+
expect(res.headers.get("x-content-type-options")).toBe("nosniff");
|
|
272
|
+
expect(res.headers.get("content-security-policy")).toBe(FILE_HEADERS.contentSecurityPolicy);
|
|
273
|
+
expect(res.headers.get("cache-control")).toBe("private, no-store");
|
|
274
|
+
await expect(res.text()).resolves.toBe("%PDF-1.7 bytes");
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
it.each([
|
|
278
|
+
["SVG", "image/svg+xml"],
|
|
279
|
+
["HTML", "text/html"],
|
|
280
|
+
["a zip", "application/zip"],
|
|
281
|
+
["an octet stream", "application/octet-stream"],
|
|
282
|
+
])("?inline=1 keeps %s an attachment", async (_case, contentType) => {
|
|
283
|
+
mockArtifactFile.mockResolvedValue(fileResult({ contentType }));
|
|
284
|
+
const res = await get(PIECE, "2", "?inline=1");
|
|
285
|
+
expect(res.status).toBe(200);
|
|
286
|
+
expect(res.headers.get("content-disposition")).toBe(FILE_HEADERS.contentDisposition);
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
it("without the flag, a PDF stays an attachment; another value of the flag is no flag", async () => {
|
|
290
|
+
expect((await get()).headers.get("content-disposition")).toBe(FILE_HEADERS.contentDisposition);
|
|
291
|
+
expect((await get(PIECE, "2", "?inline=true")).headers.get("content-disposition")).toBe(
|
|
292
|
+
FILE_HEADERS.contentDisposition,
|
|
293
|
+
);
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
it("the preview mode still refuses a hub answer that is not an attachment — it rewrites the checked value, never trusts an inline one", async () => {
|
|
297
|
+
const result = fileResult({ contentDisposition: "inline; filename=a.pdf" });
|
|
298
|
+
mockArtifactFile.mockResolvedValue(result);
|
|
299
|
+
await expectBodylessRefusal(await get(PIECE, "2", "?inline=1"), 502);
|
|
300
|
+
});
|
|
301
|
+
|
|
302
|
+
it.each([
|
|
303
|
+
"application/pdf",
|
|
304
|
+
"Application/PDF",
|
|
305
|
+
" image/png ",
|
|
306
|
+
"image/jpeg; charset=binary",
|
|
307
|
+
"image/webp",
|
|
308
|
+
"image/svg+xml",
|
|
309
|
+
"image/svg+xml;charset=utf-8",
|
|
310
|
+
"text/html",
|
|
311
|
+
"application/pdfx",
|
|
312
|
+
"application/zip",
|
|
313
|
+
"",
|
|
314
|
+
])("the page's previewKind agrees with the route's inline predicate on %j", (contentType) => {
|
|
315
|
+
expect(previewKind(contentType) !== null).toBe(isInlinePreviewType(contentType));
|
|
316
|
+
});
|
|
317
|
+
|
|
318
|
+
it("isInlinePreviewType admits image/* but SVG and application/pdf, case-insensitively, and nothing else", () => {
|
|
319
|
+
expect(isInlinePreviewType("application/pdf")).toBe(true);
|
|
320
|
+
expect(isInlinePreviewType("Application/PDF")).toBe(true);
|
|
321
|
+
expect(isInlinePreviewType("image/webp")).toBe(true);
|
|
322
|
+
expect(isInlinePreviewType("image/svg+xml")).toBe(false);
|
|
323
|
+
expect(isInlinePreviewType("text/html")).toBe(false);
|
|
324
|
+
expect(isInlinePreviewType("application/pdfx")).toBe(false);
|
|
325
|
+
});
|
|
326
|
+
});
|
|
327
|
+
|
|
255
328
|
it("reads no topology constant", () => {
|
|
256
329
|
expect(readFileSync(ROUTE_FILE, "utf8")).not.toContain(
|
|
257
330
|
"topology.generated",
|