create-ailk 0.36.0 → 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/component-catalog.json +40 -1
- package/component-catalog.md +7 -5
- package/dist/surfaces.js +60 -19
- package/dist/update.d.ts +19 -1
- package/dist/update.js +293 -35
- package/package.json +3 -3
- package/templates/.env.example +17 -0
- package/templates/apps/api/.env.example +38 -0
- package/templates/apps/api/CLAUDE.md +3 -0
- package/templates/apps/api/src/lib/__mocks__/prisma.ts +7 -0
- package/templates/apps/mcp/CLAUDE.md +1 -1
- package/templates/apps/web/CLAUDE.md +28 -1
- 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]/(authed)/account/__tests__/billing.test.tsx +240 -76
- 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 +369 -196
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/item.test.tsx +26 -1
- 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 +19 -3
- 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 +309 -113
- package/templates/apps/web/app/[locale]/(authed)/account/billing-source.ts +192 -65
- package/templates/apps/web/app/[locale]/(authed)/account/components/request-quote.tsx +52 -7
- 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 +55 -58
- package/templates/apps/web/app/[locale]/(authed)/account/general/phone-verification.tsx +2 -1
- 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/layout.tsx +3 -2
- 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 +18 -21
- 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]/flows/[slug]/results/[payload]/ResultsClient.tsx +3 -2
- 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/hub-session/__tests__/routes.test.ts +263 -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/lib/__tests__/account-config.test.ts +129 -1
- package/templates/apps/web/lib/__tests__/offerings-pricing.test.ts +33 -0
- package/templates/apps/web/lib/account-config.ts +132 -8
- package/templates/apps/web/lib/auth-routes.ts +11 -6
- package/templates/apps/web/lib/offerings-pricing.ts +4 -1
- package/templates/apps/web/messages/en.json +156 -80
- 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
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* /[locale]/account/security — User settings › Security (#8339 D8; #8431 D3
|
|
2
|
+
* /[locale]/account/security — User settings › Security (#8339 D8; #8431 D3;
|
|
3
|
+
* #11162).
|
|
3
4
|
*
|
|
4
5
|
* RSC, outside the account layout's SignedInShell (#8430), in the member's
|
|
5
6
|
* four-tab settings frame (D7) — standalone, the Admin's shape. It shows how
|
|
@@ -9,8 +10,10 @@
|
|
|
9
10
|
* - a site or hub that can email a password link: the Password row, set
|
|
10
11
|
* or changed by an emailed link to the person's own address;
|
|
11
12
|
* - any other site: one sentence naming the deployment's methods;
|
|
12
|
-
* - a spoke that signs in through its hub:
|
|
13
|
-
*
|
|
13
|
+
* - a spoke that signs in through its hub: the SAME Password row (#11162),
|
|
14
|
+
* its state read from the hub for the signed-in person, its link mailed
|
|
15
|
+
* by the hub through the spoke's own `/api/hub-session/password` — no
|
|
16
|
+
* "managed at <hub>" sentence and no link to the hub's Security page.
|
|
14
17
|
*
|
|
15
18
|
* `security-source.ts` picks the variant; this page turns it into text.
|
|
16
19
|
*/
|
|
@@ -41,6 +44,9 @@ export async function generateMetadata({ params }: Props): Promise<Metadata> {
|
|
|
41
44
|
return { title: t("settings.security.title"), description: t("settings.signIn.lead") };
|
|
42
45
|
}
|
|
43
46
|
|
|
47
|
+
/** The spoke's same-origin route that asks the hub to mail a password link (#11162). */
|
|
48
|
+
const HUB_SESSION_PASSWORD_PATH = "/api/hub-session/password";
|
|
49
|
+
|
|
44
50
|
/** Each sign-in method's phrase in the sentence (C5). */
|
|
45
51
|
const METHOD_KEYS = {
|
|
46
52
|
google: "settings.security.methods.google",
|
|
@@ -57,12 +63,14 @@ export default async function AccountSecurityPage({ params }: Props): Promise<Re
|
|
|
57
63
|
const email = session?.ctx.user.email ?? "";
|
|
58
64
|
const name = session?.ctx.user.name || email;
|
|
59
65
|
|
|
60
|
-
const source = await securitySource(await headers());
|
|
66
|
+
const source = await securitySource(await headers(), session?.ctx.init);
|
|
61
67
|
|
|
62
68
|
let variant: SecurityPanelVariant | null;
|
|
63
|
-
if (source.kind
|
|
69
|
+
if (source.kind !== "sentence") {
|
|
70
|
+
// Both the password and the hub (#11162) sources are the Password row;
|
|
71
|
+
// `null` is its unavailable line — a failed read, or a hub with no state.
|
|
64
72
|
variant = source.hasPassword === null ? null : { kind: "password", hasPassword: source.hasPassword };
|
|
65
|
-
} else
|
|
73
|
+
} else {
|
|
66
74
|
const methods = source.methods.map((id) => t(METHOD_KEYS[id], { email }));
|
|
67
75
|
variant = {
|
|
68
76
|
kind: "sentence",
|
|
@@ -73,21 +81,6 @@ export default async function AccountSecurityPage({ params }: Props): Promise<Re
|
|
|
73
81
|
})
|
|
74
82
|
: t("settings.security.signedInAs", { email }),
|
|
75
83
|
};
|
|
76
|
-
} else {
|
|
77
|
-
variant = {
|
|
78
|
-
kind: "hub",
|
|
79
|
-
text:
|
|
80
|
-
source.hubHost !== null
|
|
81
|
-
? t("settings.security.managedAt", { hub: source.hubHost })
|
|
82
|
-
: t("settings.security.managedUnnamed"),
|
|
83
|
-
link:
|
|
84
|
-
source.hubHost !== null && source.hubOrigin !== null
|
|
85
|
-
? {
|
|
86
|
-
href: new URL("/account/security", source.hubOrigin).href,
|
|
87
|
-
label: t("settings.security.manageOnHub", { hub: source.hubHost }),
|
|
88
|
-
}
|
|
89
|
-
: null,
|
|
90
|
-
};
|
|
91
84
|
}
|
|
92
85
|
|
|
93
86
|
return (
|
|
@@ -106,6 +99,10 @@ export default async function AccountSecurityPage({ params }: Props): Promise<Re
|
|
|
106
99
|
// Absolute and same-origin, built here from BETTER_AUTH_URL — the
|
|
107
100
|
// `(auth)/forgot-password/page.tsx` derivation.
|
|
108
101
|
resetUrl={`${process.env.BETTER_AUTH_URL ?? ""}${localeHref(locale, "/reset-password")}`}
|
|
102
|
+
// On a spoke the hub mails the link, asked through this same-origin
|
|
103
|
+
// route (#11162); a site or hub asks Better Auth itself.
|
|
104
|
+
passwordEndpoint={source.kind === "hub" ? HUB_SESSION_PASSWORD_PATH : null}
|
|
105
|
+
locale={locale}
|
|
109
106
|
signOutEndpoint={SIGN_OUT_ENDPOINT}
|
|
110
107
|
// A hub-session sign-out lands home: the spoke's /account would sign
|
|
111
108
|
// the person straight back in (#11095 D4). A hub keeps /sign-in.
|
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
"use client"; // Better Auth's client calls (requestPasswordReset, signOut) and router navigation need the browser
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* SecurityPanel — the member's adapter over `SecuritySettings` (#8431 D3
|
|
4
|
+
* SecurityPanel — the member's adapter over `SecuritySettings` (#8431 D3;
|
|
5
|
+
* #11162).
|
|
5
6
|
*
|
|
6
7
|
* The page (RSC) resolves the variant, the strings, the person's own address,
|
|
7
8
|
* the reset link's absolute `redirectTo` and where Log out lands; this island
|
|
8
9
|
* supplies the two actions:
|
|
9
10
|
*
|
|
10
|
-
* - the Password row's request:
|
|
11
|
-
*
|
|
12
|
-
*
|
|
11
|
+
* - the Password row's request: on a spoke that signs in through its hub,
|
|
12
|
+
* one same-origin POST of `{ locale }` to the spoke's password route,
|
|
13
|
+
* which asks the hub to mail the signed-in person's own address (#11162);
|
|
14
|
+
* elsewhere Better Auth's `requestPasswordReset` for the person's OWN
|
|
15
|
+
* address, with the server-built `redirectTo` (never one derived from
|
|
16
|
+
* `window.location` — `forgot-password-card.tsx`'s rule). No address and
|
|
17
|
+
* no password ever leaves this island;
|
|
13
18
|
* - Log out: the spoke's same-origin sign-out endpoint when the page passes
|
|
14
19
|
* one, else Better Auth's `signOut`. Only a log-out that succeeded
|
|
15
20
|
* navigates (the `SignOutTrigger` rule).
|
|
@@ -33,8 +38,7 @@ const authClient = createAuthClient();
|
|
|
33
38
|
/** The variant as the page resolved it — serializable, no functions. */
|
|
34
39
|
export type SecurityPanelVariant =
|
|
35
40
|
| { kind: "password"; hasPassword: boolean }
|
|
36
|
-
| { kind: "sentence"; text: string }
|
|
37
|
-
| { kind: "hub"; text: string; link: { href: string; label: string } | null };
|
|
41
|
+
| { kind: "sentence"; text: string };
|
|
38
42
|
|
|
39
43
|
export interface SecurityPanelProps {
|
|
40
44
|
/** `null`: the accounts read failed; `failed` renders in its place. */
|
|
@@ -44,6 +48,13 @@ export interface SecurityPanelProps {
|
|
|
44
48
|
email: string;
|
|
45
49
|
/** The absolute reset page the emailed link returns to. */
|
|
46
50
|
resetUrl: string;
|
|
51
|
+
/**
|
|
52
|
+
* A spoke's same-origin password route (#11162), which asks the hub to mail
|
|
53
|
+
* the link; `null` asks Better Auth here.
|
|
54
|
+
*/
|
|
55
|
+
passwordEndpoint: string | null;
|
|
56
|
+
/** The locale the hub's set-password page renders in. */
|
|
57
|
+
locale: string;
|
|
47
58
|
/** A spoke's same-origin sign-out route; `null` signs out through Better Auth. */
|
|
48
59
|
signOutEndpoint: string | null;
|
|
49
60
|
/** The site's sign-in page, where Log out lands. */
|
|
@@ -56,6 +67,8 @@ export function SecurityPanel({
|
|
|
56
67
|
failed,
|
|
57
68
|
email,
|
|
58
69
|
resetUrl,
|
|
70
|
+
passwordEndpoint,
|
|
71
|
+
locale,
|
|
59
72
|
signOutEndpoint,
|
|
60
73
|
signInHref,
|
|
61
74
|
labels,
|
|
@@ -63,6 +76,21 @@ export function SecurityPanel({
|
|
|
63
76
|
const router = useRouter();
|
|
64
77
|
|
|
65
78
|
async function requestLink(): Promise<boolean> {
|
|
79
|
+
if (passwordEndpoint !== null) {
|
|
80
|
+
// The person is the sealed session's, never a body field; only the
|
|
81
|
+
// route's 202 is a sent link.
|
|
82
|
+
try {
|
|
83
|
+
const res = await fetch(passwordEndpoint, {
|
|
84
|
+
method: "POST",
|
|
85
|
+
credentials: "same-origin",
|
|
86
|
+
headers: { "content-type": "application/json" },
|
|
87
|
+
body: JSON.stringify({ locale }),
|
|
88
|
+
});
|
|
89
|
+
return res.status === 202;
|
|
90
|
+
} catch {
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
66
94
|
// A refusal (the rate limit, the method off) resolves with `{ error }`; a
|
|
67
95
|
// network failure rejects. Both read as not sent.
|
|
68
96
|
return authClient.requestPasswordReset({ email, redirectTo: resetUrl }).then(
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* account/security/security-source.ts (server code) — which sign-in variant
|
|
3
3
|
* the member's Security tab shows (#8431 D2, spec
|
|
4
|
-
* docs/specs/8431-account-security-tab-human-sign-spec.md).
|
|
4
|
+
* docs/specs/8431-account-security-tab-human-sign-spec.md; #11162).
|
|
5
5
|
*
|
|
6
|
-
* - hub — a spoke that signs in through its hub:
|
|
7
|
-
*
|
|
6
|
+
* - hub — a spoke that signs in through its hub: whether this person
|
|
7
|
+
* has a password, read live from the hub's
|
|
8
|
+
* `GET /v1/hub-sign-in/me` with the session's own credential
|
|
9
|
+
* (#11162). `null` when the hub answers no state — a hub
|
|
10
|
+
* older than #11162, a refusal, a failed read — and the tab
|
|
11
|
+
* shows its unavailable line, never a form.
|
|
8
12
|
* - password — a site or hub that can email a password link
|
|
9
13
|
* (`resetSendConfigured()`, C1): whether this person has a
|
|
10
14
|
* password, from the session's own accounts.
|
|
@@ -21,8 +25,9 @@
|
|
|
21
25
|
* shows the sentence — a retry cannot fix a stale seam (D2b).
|
|
22
26
|
*/
|
|
23
27
|
|
|
28
|
+
import { hubSignIn } from "@working-theory/api-client";
|
|
29
|
+
|
|
24
30
|
import { resetSendConfigured } from "../../../../../lib/auth-env";
|
|
25
|
-
import { hubSessionConfig } from "../../../../../lib/hub-session/config";
|
|
26
31
|
import * as seam from "../../../../../lib/topology.generated";
|
|
27
32
|
import { logReadFailure } from "../account-data";
|
|
28
33
|
import { signInMethod, type SignInMethodId } from "../sign-in-method";
|
|
@@ -31,20 +36,45 @@ export type SecuritySource =
|
|
|
31
36
|
/** `hasPassword: null` — the accounts read failed. */
|
|
32
37
|
| { kind: "password"; hasPassword: boolean | null }
|
|
33
38
|
| { kind: "sentence"; methods: SignInMethodId[] }
|
|
34
|
-
|
|
39
|
+
/** `hasPassword: null` — the hub answered no state (#11162). */
|
|
40
|
+
| { kind: "hub"; hasPassword: boolean | null };
|
|
35
41
|
|
|
36
42
|
type OwnAccountsReader = (headers: Headers) => Promise<ReadonlyArray<{ providerId: string }> | null>;
|
|
37
43
|
|
|
44
|
+
/** The account area's request init — on a hub-mode spoke, the credential as a Bearer header. */
|
|
45
|
+
type HubReadInit = Parameters<typeof hubSignIn.me>[0];
|
|
46
|
+
|
|
38
47
|
/** The seam's accounts reader (D2a), or `null` on a seam rendered before it existed. */
|
|
39
48
|
function ownAccountsReader(): OwnAccountsReader | null {
|
|
40
49
|
const reader: unknown = Reflect.get(seam, "readOwnAccounts");
|
|
41
50
|
return typeof reader === "function" ? (reader as OwnAccountsReader) : null;
|
|
42
51
|
}
|
|
43
52
|
|
|
44
|
-
|
|
53
|
+
/**
|
|
54
|
+
* Whether the hub's person has a password (#11162): `hasPassword` from the
|
|
55
|
+
* hub's `me` read with the session's credential. `null` when there is no
|
|
56
|
+
* credential to ask with, when the hub refuses it, when it answers without
|
|
57
|
+
* the field (a hub older than #11162), or when the read fails.
|
|
58
|
+
*/
|
|
59
|
+
async function hubPasswordState(init: HubReadInit | undefined): Promise<boolean | null> {
|
|
60
|
+
if (init === undefined) return null;
|
|
61
|
+
try {
|
|
62
|
+
const res = await hubSignIn.me(init);
|
|
63
|
+
if (!res.ok) return null;
|
|
64
|
+
return typeof res.body.hasPassword === "boolean" ? res.body.hasPassword : null;
|
|
65
|
+
} catch (err) {
|
|
66
|
+
logReadFailure("security-hub", err);
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export async function securitySource(
|
|
72
|
+
headers: Headers,
|
|
73
|
+
init: HubReadInit | undefined,
|
|
74
|
+
): Promise<SecuritySource> {
|
|
45
75
|
const signIn = signInMethod();
|
|
46
76
|
if (signIn.kind === "hub") {
|
|
47
|
-
return { kind: "hub",
|
|
77
|
+
return { kind: "hub", hasPassword: await hubPasswordState(init) };
|
|
48
78
|
}
|
|
49
79
|
if (!resetSendConfigured()) return { kind: "sentence", methods: signIn.methods };
|
|
50
80
|
|
|
@@ -9,8 +9,6 @@
|
|
|
9
9
|
* `BillingAnchor` sends it on to Billing; `#general` lands on General as it
|
|
10
10
|
* is. The hub's authorize step still sends an unverified person here
|
|
11
11
|
* (`VERIFY_EMAIL_PATH`), and this redirect carries them on.
|
|
12
|
-
*
|
|
13
|
-
* The directory keeps the one file General reuses unchanged: `theme-modes.ts`.
|
|
14
12
|
*/
|
|
15
13
|
|
|
16
14
|
import { localeHref } from "@working-theory/ui";
|
|
@@ -11,9 +11,10 @@
|
|
|
11
11
|
* via the shared `AccountSettings`) or directly (Security, Notifications,
|
|
12
12
|
* Billing).
|
|
13
13
|
*
|
|
14
|
-
* `SettingsSection`
|
|
15
|
-
* (`accountSettingsSections`, `accountBillingSections`)
|
|
16
|
-
*
|
|
14
|
+
* `SettingsSection` is the shape a contributed section
|
|
15
|
+
* (`accountSettingsSections`, `accountBillingSections`) and Billing's own
|
|
16
|
+
* trailing content take; since #11167 the pane draws every group as a card,
|
|
17
|
+
* so the section carries no top rule of its own.
|
|
17
18
|
*
|
|
18
19
|
* #8441 — `SETTINGS_ROUTES` is the ONE place the settings routes are named:
|
|
19
20
|
* the tabs here and `isSettingsPath` (which `account-frame.tsx` takes these
|
|
@@ -78,12 +79,14 @@ export function memberSettingsFrame(
|
|
|
78
79
|
back: { label: t("settings.back"), href: localeHref(locale, "/account") },
|
|
79
80
|
railLabel: t("settings.title"),
|
|
80
81
|
accountLabel: t("settings.account"),
|
|
82
|
+
menuLabel: t("settings.menu"),
|
|
83
|
+
closeMenuLabel: t("settings.closeMenu"),
|
|
81
84
|
tabs,
|
|
82
85
|
active,
|
|
83
86
|
};
|
|
84
87
|
}
|
|
85
88
|
|
|
86
|
-
/** The section role DESIGN.md §5.12 names: a title, a muted subtitle, then the fields. */
|
|
89
|
+
/** The section role DESIGN.md §5.12 names: a title, a muted subtitle, then the fields — one card of the pane (#11167). */
|
|
87
90
|
export function SettingsSection({
|
|
88
91
|
id,
|
|
89
92
|
title,
|
|
@@ -99,7 +102,7 @@ export function SettingsSection({
|
|
|
99
102
|
<section
|
|
100
103
|
id={id}
|
|
101
104
|
aria-labelledby={`${id}-title`}
|
|
102
|
-
className="flex scroll-mt-8 flex-col gap-4
|
|
105
|
+
className="flex scroll-mt-8 flex-col gap-4"
|
|
103
106
|
data-testid={`account-settings-${id}`}
|
|
104
107
|
>
|
|
105
108
|
<div>
|
|
@@ -83,6 +83,7 @@ import type {
|
|
|
83
83
|
import {
|
|
84
84
|
evaluateWaitlistScoring,
|
|
85
85
|
flowRecommendRegister,
|
|
86
|
+
lookupKeyPeriodSchema,
|
|
86
87
|
recommend,
|
|
87
88
|
resolveLocalizedString,
|
|
88
89
|
resultsPageAsksEmail,
|
|
@@ -323,8 +324,8 @@ export function ResultsClient({
|
|
|
323
324
|
/** #10827 — an offering's Price as `/pricing` words it. */
|
|
324
325
|
function offeringPriceLabel(price: NonNullable<ResultsOfferingCard["price"]>): string {
|
|
325
326
|
const amount = formatMinorUnits(price.amount, price.currency, locale);
|
|
326
|
-
if (price.period ===
|
|
327
|
-
if (price.period ===
|
|
327
|
+
if (price.period === lookupKeyPeriodSchema.enum.monthly) return tOfferings("monthly", { amount });
|
|
328
|
+
if (price.period === lookupKeyPeriodSchema.enum.yearly) return tOfferings("annual", { amount });
|
|
328
329
|
return tOfferings("oneTime", { amount });
|
|
329
330
|
}
|
|
330
331
|
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jest-environment node
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The sealed return a spoke's password link carries (#11162 AC-2): it opens
|
|
7
|
+
* only to the registered origin plus the Security path it was minted from,
|
|
8
|
+
* under its own name, within its life.
|
|
9
|
+
*/
|
|
10
|
+
import { mintContinuation } from "../../continuation";
|
|
11
|
+
import {
|
|
12
|
+
SECURITY_RETURN_NAME,
|
|
13
|
+
SECURITY_RETURN_TTL_SECONDS,
|
|
14
|
+
SPOKE_RETURN_PATH,
|
|
15
|
+
mintSecurityReturn,
|
|
16
|
+
openSecurityReturn,
|
|
17
|
+
} from "../return";
|
|
18
|
+
|
|
19
|
+
const SECRET = "k".repeat(43);
|
|
20
|
+
const SPOKE = "https://spoke.example";
|
|
21
|
+
|
|
22
|
+
/** Where a ref for `origin` + `path` lands: the spoke's return route, the tab as `next`. */
|
|
23
|
+
function landing(origin: string, path: string): string {
|
|
24
|
+
return `${origin}${SPOKE_RETURN_PATH}?next=${encodeURIComponent(path)}`;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
describe("mintSecurityReturn / openSecurityReturn", () => {
|
|
28
|
+
it("round-trips the origin and the Security path as the spoke's return route with the tab as next", () => {
|
|
29
|
+
const ref = mintSecurityReturn(SPOKE, "/account/security", SECRET);
|
|
30
|
+
expect(ref).toMatch(/^[A-Za-z0-9_-]+$/);
|
|
31
|
+
expect(openSecurityReturn(ref, SECRET)).toBe(landing(SPOKE, "/account/security"));
|
|
32
|
+
expect(SPOKE_RETURN_PATH).toBe("/api/hub-session/password/return");
|
|
33
|
+
expect(openSecurityReturn(mintSecurityReturn(SPOKE, "/fr/account/security", SECRET), SECRET)).toBe(
|
|
34
|
+
landing(SPOKE, "/fr/account/security"),
|
|
35
|
+
);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it("opens a loopback http origin, for a local spoke", () => {
|
|
39
|
+
const ref = mintSecurityReturn("http://127.0.0.1:3100", "/account/security", SECRET);
|
|
40
|
+
expect(openSecurityReturn(ref, SECRET)).toBe(landing("http://127.0.0.1:3100", "/account/security"));
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it("outlives the hour-long link, and no more than ten minutes past it", () => {
|
|
44
|
+
const now = Date.now();
|
|
45
|
+
const ref = mintSecurityReturn(SPOKE, "/account/security", SECRET, now);
|
|
46
|
+
expect(SECURITY_RETURN_TTL_SECONDS).toBe(3600 + 600);
|
|
47
|
+
expect(openSecurityReturn(ref, SECRET, now + 3600_000)).toBe(landing(SPOKE, "/account/security"));
|
|
48
|
+
expect(openSecurityReturn(ref, SECRET, now + SECURITY_RETURN_TTL_SECONDS * 1000)).toBeNull();
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it("never opens under another secret, nor a continuation or a purchase claim sealed under their names", () => {
|
|
52
|
+
const ref = mintSecurityReturn(SPOKE, "/account/security", SECRET);
|
|
53
|
+
expect(openSecurityReturn(ref, "x".repeat(43))).toBeNull();
|
|
54
|
+
const query = new URLSearchParams({ o: SPOKE, p: "/account/security" }).toString();
|
|
55
|
+
expect(openSecurityReturn(mintContinuation(query, SECRET), SECRET)).toBeNull();
|
|
56
|
+
expect(openSecurityReturn(mintContinuation(query, SECRET, Date.now(), "hub-purchase"), SECRET)).toBeNull();
|
|
57
|
+
expect(SECURITY_RETURN_NAME).not.toBe("hub-continue");
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it.each([
|
|
61
|
+
["an http origin off loopback", { o: "http://spoke.example", p: "/account/security" }],
|
|
62
|
+
["an origin with a path", { o: `${SPOKE}/x`, p: "/account/security" }],
|
|
63
|
+
["an origin that is not a URL", { o: "spoke.example", p: "/account/security" }],
|
|
64
|
+
["a javascript: scheme", { o: "javascript:alert(1)", p: "/account/security" }],
|
|
65
|
+
["a path off the Security tab", { o: SPOKE, p: "/account" }],
|
|
66
|
+
["a path with a query", { o: SPOKE, p: "/account/security?x=1" }],
|
|
67
|
+
["a third key", { o: SPOKE, p: "/account/security", q: "1" }],
|
|
68
|
+
["a missing path", { o: SPOKE }],
|
|
69
|
+
] as Array<[string, Record<string, string>]>)("refuses a forged payload holding %s", (_label, payload) => {
|
|
70
|
+
const forged = mintContinuation(
|
|
71
|
+
new URLSearchParams(payload).toString(),
|
|
72
|
+
SECRET,
|
|
73
|
+
Date.now(),
|
|
74
|
+
SECURITY_RETURN_NAME,
|
|
75
|
+
SECURITY_RETURN_TTL_SECONDS,
|
|
76
|
+
);
|
|
77
|
+
expect(openSecurityReturn(forged, SECRET)).toBeNull();
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it.each([["", ""], ["not base64url", "a.b/c"], ["too long", "a".repeat(5000)]])(
|
|
81
|
+
"refuses %s as a ref",
|
|
82
|
+
(_label, ref) => {
|
|
83
|
+
expect(openSecurityReturn(ref, SECRET)).toBeNull();
|
|
84
|
+
},
|
|
85
|
+
);
|
|
86
|
+
});
|