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
|
@@ -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,8 +99,14 @@ 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
|
|
108
|
+
// the person straight back in (#11095 D4). A hub keeps /sign-in.
|
|
109
|
+
signInHref={localeHref(locale, SIGN_OUT_ENDPOINT ? "/" : (SIGN_IN_PATH ?? "/"))}
|
|
111
110
|
labels={{
|
|
112
111
|
methodsHeading: t("settings.security.methodsHeading"),
|
|
113
112
|
passwordLabel: t("settings.security.passwordLabel"),
|
|
@@ -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>
|
|
@@ -4,18 +4,19 @@
|
|
|
4
4
|
* RSC: reads the session through the generated topology seam's `readSession`
|
|
5
5
|
* (#7894 D10) — Better Auth's `auth.api.getSession` on a hub, the sealed
|
|
6
6
|
* hub-session cookie on a spoke that signs in through its hub. With no
|
|
7
|
-
* session it
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
7
|
+
* session it returns the generated gate seam's `SignedOutGate`, which
|
|
8
|
+
* redirects with the requested path as `next` (#11095 D3; the in-place gate
|
|
9
|
+
* page of #4984 is retired). This guard reads no public-route
|
|
10
|
+
* auth-requirement flag (spec Clarifications) — that flag governs whether
|
|
11
|
+
* PUBLIC marketing routes redirect; tenant signup data is never public, so
|
|
12
|
+
* this gate always applies.
|
|
13
13
|
*
|
|
14
|
-
*
|
|
15
|
-
* hub,
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
14
|
+
* Where the gate sends a visitor is the seam's (`signed-out-gate.generated.tsx`):
|
|
15
|
+
* on a hub, `/sign-in?next=<path>` — or, on an account path with no sign-in
|
|
16
|
+
* method on, the "Sign-in isn't available yet" block in place (#7430); on a
|
|
17
|
+
* hub sign-in spoke, `/api/hub-session/sign-in?next=<path>`. This layout
|
|
18
|
+
* therefore imports neither `auth.ts` nor the `(auth)` group, so a spoke that
|
|
19
|
+
* keeps its account area keeps this layout too (spec 7894 D9).
|
|
19
20
|
*/
|
|
20
21
|
|
|
21
22
|
import { headers } from "next/headers";
|
|
@@ -38,8 +39,9 @@ export default async function AuthedLayout({
|
|
|
38
39
|
const requestHeaders = await headers();
|
|
39
40
|
const session = await readSession(requestHeaders);
|
|
40
41
|
|
|
41
|
-
//
|
|
42
|
-
// request
|
|
42
|
+
// Called, not rendered as an element: the gate is a server function of the
|
|
43
|
+
// request — its redirect throws from here, and its one in-place block is
|
|
44
|
+
// the element the layout returns.
|
|
43
45
|
if (!session) return SignedOutGate({ locale, requestHeaders });
|
|
44
46
|
|
|
45
47
|
// data-profile="app" puts the Pro-host editor surfaces in this group on
|
|
@@ -1,25 +1,22 @@
|
|
|
1
1
|
// signed-out-gate.generated.tsx — what the (authed) group shows a signed-out visitor.
|
|
2
2
|
//
|
|
3
3
|
// GENERATED by create-ailk for this site's topology and sign-in mode (#7894).
|
|
4
|
-
// Do not edit: every scaffold rewrites it. A hub
|
|
5
|
-
//
|
|
6
|
-
// through its hub (`--hub-sign-in`)
|
|
4
|
+
// Do not edit: every scaffold rewrites it. A hub redirects to its own
|
|
5
|
+
// /sign-in (an account path with no sign-in method on says so in place); a
|
|
6
|
+
// spoke that signs in through its hub (`--hub-sign-in`) redirects to its
|
|
7
|
+
// hub-session sign-in route.
|
|
7
8
|
import { localeHref } from "@working-theory/ui";
|
|
8
9
|
import { Button, Heading, Link, Text } from "@working-theory/ui/primitives";
|
|
9
|
-
import type { AuthPanelProvider } from "@working-theory/ui/sections";
|
|
10
10
|
import { readLocales } from "@working-theory/web-i18n";
|
|
11
|
+
import { redirect } from "next/navigation";
|
|
11
12
|
import { getTranslations } from "next-intl/server";
|
|
12
13
|
import type { ReactElement } from "react";
|
|
13
14
|
|
|
14
|
-
import { legalFootnote } from "../(auth)/legal-footnote";
|
|
15
|
-
import { resolveSignInCardText } from "../(auth)/sign-in/sign-in-text";
|
|
16
15
|
import { getActiveProviderIds } from "../../../lib/auth-env";
|
|
17
16
|
import { isAccountPath } from "../../../lib/auth-routes";
|
|
18
|
-
import { siteLogo } from "../../../lib/site-logo";
|
|
19
17
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const SUPPORTED_PROVIDERS: readonly AuthPanelProvider[] = ["google", "github"];
|
|
18
|
+
/** The methods a member signs in with on /sign-in's card. */
|
|
19
|
+
const MEMBER_METHODS: readonly string[] = ["google", "github", "magic-link"];
|
|
23
20
|
|
|
24
21
|
export interface SignedOutGateProps {
|
|
25
22
|
locale: string;
|
|
@@ -31,23 +28,17 @@ export async function SignedOutGate({
|
|
|
31
28
|
locale,
|
|
32
29
|
requestHeaders,
|
|
33
30
|
}: SignedOutGateProps): Promise<ReactElement> {
|
|
34
|
-
// No `x-pathname`, no locale read: a render outside the middleware
|
|
35
|
-
// the
|
|
31
|
+
// No `x-pathname`, no locale read: a render outside the middleware
|
|
32
|
+
// redirects to the bare /sign-in without touching the locale config.
|
|
36
33
|
const pathname = requestHeaders.get("x-pathname");
|
|
37
34
|
const isAccount =
|
|
38
35
|
pathname !== null && isAccountPath(pathname, readLocales());
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
namespace: isAccount ? "account.gate" : "waitlistDashboard.gate",
|
|
42
|
-
});
|
|
43
|
-
const active = getActiveProviderIds();
|
|
44
|
-
const emailLink = active.includes("magic-link");
|
|
45
|
-
const providers = active.filter((id): id is AuthPanelProvider =>
|
|
46
|
-
(SUPPORTED_PROVIDERS as readonly string[]).includes(id),
|
|
36
|
+
const hasMemberMethod = getActiveProviderIds().some((id) =>
|
|
37
|
+
MEMBER_METHODS.includes(id),
|
|
47
38
|
);
|
|
48
|
-
const signInPath = localeHref(locale, "/sign-in");
|
|
49
39
|
|
|
50
|
-
if (isAccount &&
|
|
40
|
+
if (isAccount && !hasMemberMethod) {
|
|
41
|
+
const t = await getTranslations({ locale, namespace: "account.gate" });
|
|
51
42
|
return (
|
|
52
43
|
<div
|
|
53
44
|
className="flex min-h-screen flex-col items-center justify-center gap-4 py-section text-center"
|
|
@@ -75,35 +66,12 @@ export async function SignedOutGate({
|
|
|
75
66
|
);
|
|
76
67
|
}
|
|
77
68
|
|
|
78
|
-
//
|
|
79
|
-
//
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
text,
|
|
86
|
-
emailLink,
|
|
87
|
-
...(isAccount
|
|
88
|
-
? {
|
|
89
|
-
logo: siteLogo(),
|
|
90
|
-
prospect: { ...text.prospect, href: localeHref(locale, "/sign-up") },
|
|
91
|
-
footnote: legalFootnote(locale, text.acknowledgement),
|
|
92
|
-
}
|
|
93
|
-
: {}),
|
|
94
|
-
}
|
|
95
|
-
: undefined;
|
|
96
|
-
|
|
97
|
-
return (
|
|
98
|
-
<SignInGate
|
|
99
|
-
labels={{
|
|
100
|
-
emptyHeadline: t("emptyHeadline"),
|
|
101
|
-
emptyDescription: t("emptyDescription"),
|
|
102
|
-
signInLinkLabel: t("signInLink"),
|
|
103
|
-
}}
|
|
104
|
-
signInPath={signInPath}
|
|
105
|
-
providers={providers}
|
|
106
|
-
{...(card ? { card } : {})}
|
|
107
|
-
/>
|
|
69
|
+
// Every other signed-out render is a redirect to the sign-in card, with the
|
|
70
|
+
// requested path as `next` (#11095 D3): `/sign-in` sanitizes it.
|
|
71
|
+
const signInPath = localeHref(locale, "/sign-in");
|
|
72
|
+
redirect(
|
|
73
|
+
pathname === null
|
|
74
|
+
? signInPath
|
|
75
|
+
: `${signInPath}?next=${encodeURIComponent(pathname)}`,
|
|
108
76
|
);
|
|
109
77
|
}
|
|
@@ -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
|
|