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
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
* `/api/hub-session/callback` — never derived from the request's `Host`.
|
|
9
9
|
*
|
|
10
10
|
* - not a hub-mode spoke (`SIGN_IN_PROVIDER` is not `"hub"`): 404;
|
|
11
|
-
* - hub mode but not configured: 303 to
|
|
11
|
+
* - hub mode but not configured: 303 to the site's home (#11095 D4) —
|
|
12
|
+
* `/account` would redirect straight back here.
|
|
12
13
|
*
|
|
13
14
|
* Hinted email (#8757 D9): a single `?email=` that `accountEmailHintSchema`
|
|
14
15
|
* accepts rides to the hub as `login_hint`, so its sign-in form opens with
|
|
@@ -21,38 +22,27 @@
|
|
|
21
22
|
* same. Any other value, an empty or a repeated one adds nothing, and the hint
|
|
22
23
|
* never enters the flow cookie.
|
|
23
24
|
*
|
|
25
|
+
* Google (#11096 D4): exactly one `?provider=google` (the spoke form's
|
|
26
|
+
* "Continue with Google") rides to the hub as `provider_hint=google`, which
|
|
27
|
+
* sends a visitor with no hub session straight to Google, with no sign-in
|
|
28
|
+
* card. Any other value, an empty or a repeated one adds nothing, and the
|
|
29
|
+
* hint never enters the flow cookie.
|
|
30
|
+
*
|
|
24
31
|
* Nothing here logs the state, the verifier or the challenge.
|
|
25
32
|
*/
|
|
26
|
-
import { createHash, randomBytes } from "node:crypto";
|
|
27
|
-
|
|
28
33
|
import { accountEmailHintSchema } from "@working-theory/validation";
|
|
29
34
|
|
|
30
35
|
import { hubSessionConfig } from "../../../../lib/hub-session/config";
|
|
31
|
-
import { seal } from "../../../../lib/hub-session/seal";
|
|
32
36
|
import {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
hubNextPath,
|
|
37
|
+
HUB_SESSION_HOME_PATH,
|
|
38
|
+
seeOther,
|
|
39
|
+
startHubFlow,
|
|
37
40
|
} from "../../../../lib/hub-session/session";
|
|
38
41
|
import { SIGN_IN_PROVIDER } from "../../../../lib/topology.generated";
|
|
39
42
|
|
|
40
|
-
/** How long a sign-in may take on the hub before the flow cookie expires. */
|
|
41
|
-
const FLOW_TTL_SECONDS = 600;
|
|
42
|
-
|
|
43
43
|
/** The hub's browser step (spec 7894 D4). */
|
|
44
44
|
const AUTHORIZE_PATH = "/api/auth/hub/authorize";
|
|
45
45
|
|
|
46
|
-
function see(location: string, setCookie?: string): Response {
|
|
47
|
-
const headers = new Headers({
|
|
48
|
-
Location: location,
|
|
49
|
-
"Cache-Control": "no-store",
|
|
50
|
-
"Referrer-Policy": "no-referrer",
|
|
51
|
-
});
|
|
52
|
-
if (setCookie !== undefined) headers.append("Set-Cookie", setCookie);
|
|
53
|
-
return new Response(null, { status: 303, headers });
|
|
54
|
-
}
|
|
55
|
-
|
|
56
46
|
/** #8757 D9 — the one `email` the hint schema accepts; repeated or refused → none. */
|
|
57
47
|
function emailHint(params: URLSearchParams): string | undefined {
|
|
58
48
|
const values = params.getAll("email");
|
|
@@ -67,42 +57,35 @@ function signUpHint(params: URLSearchParams): "create" | undefined {
|
|
|
67
57
|
return values.length === 1 && values[0] === "create" ? "create" : undefined;
|
|
68
58
|
}
|
|
69
59
|
|
|
60
|
+
/** #11096 D4 — `"google"` when the one `provider` is exactly that, else none. */
|
|
61
|
+
function providerHint(params: URLSearchParams): "google" | undefined {
|
|
62
|
+
const values = params.getAll("provider");
|
|
63
|
+
return values.length === 1 && values[0] === "google" ? "google" : undefined;
|
|
64
|
+
}
|
|
65
|
+
|
|
70
66
|
// platform-decisions-waiver: api-versioning — sign-in redirect endpoint, not a versioned API contract (spec 7894 §7)
|
|
71
67
|
export function GET(request: Request): Response {
|
|
72
68
|
if (SIGN_IN_PROVIDER !== "hub") return new Response(null, { status: 404 });
|
|
73
69
|
const config = hubSessionConfig();
|
|
74
|
-
if (config === null) return
|
|
70
|
+
if (config === null) return seeOther(HUB_SESSION_HOME_PATH);
|
|
75
71
|
|
|
76
72
|
const params = new URL(request.url).searchParams;
|
|
77
|
-
const
|
|
78
|
-
const state = randomBytes(32).toString("base64url");
|
|
79
|
-
const verifier = randomBytes(32).toString("base64url");
|
|
80
|
-
const challenge = createHash("sha256").update(verifier).digest("base64url");
|
|
81
|
-
|
|
82
|
-
const name = flowCookieName(config);
|
|
83
|
-
const flow = seal(
|
|
84
|
-
{ v: 1, state, verifier, next, expiresAt: Date.now() + FLOW_TTL_SECONDS * 1000 },
|
|
85
|
-
config.sessionSecret,
|
|
86
|
-
"flow",
|
|
87
|
-
name,
|
|
88
|
-
);
|
|
73
|
+
const flow = startHubFlow(config, params.get("next"));
|
|
89
74
|
|
|
90
75
|
const authorize = new URL(AUTHORIZE_PATH, config.hubOrigin);
|
|
91
76
|
const query = new URLSearchParams({
|
|
92
77
|
response_type: "code",
|
|
93
78
|
client_id: config.clientId,
|
|
94
79
|
redirect_uri: config.redirectUri,
|
|
95
|
-
state,
|
|
96
|
-
code_challenge: challenge,
|
|
80
|
+
state: flow.state,
|
|
81
|
+
code_challenge: flow.challenge,
|
|
97
82
|
code_challenge_method: "S256",
|
|
98
83
|
});
|
|
99
84
|
if (signUpHint(params) !== undefined) query.set("prompt", "create");
|
|
100
85
|
const loginHint = emailHint(params);
|
|
101
86
|
if (loginHint !== undefined) query.set("login_hint", loginHint);
|
|
87
|
+
if (providerHint(params) !== undefined) query.set("provider_hint", "google");
|
|
102
88
|
authorize.search = query.toString();
|
|
103
89
|
|
|
104
|
-
return
|
|
105
|
-
authorize.toString(),
|
|
106
|
-
cookieHeader(name, flow, FLOW_TTL_SECONDS, config),
|
|
107
|
-
);
|
|
90
|
+
return seeOther(authorize.toString(), [flow.cookie]);
|
|
108
91
|
}
|
|
@@ -16,21 +16,12 @@ import { hubSignIn } from "@working-theory/api-client";
|
|
|
16
16
|
import { hubSessionConfig } from "../../../../lib/hub-session/config";
|
|
17
17
|
import {
|
|
18
18
|
cookieHeader,
|
|
19
|
+
isSameOrigin,
|
|
19
20
|
readHubSessionPayload,
|
|
20
21
|
sessionCookieName,
|
|
21
22
|
} from "../../../../lib/hub-session/session";
|
|
22
23
|
import { SIGN_IN_PROVIDER } from "../../../../lib/topology.generated";
|
|
23
24
|
|
|
24
|
-
/** Whether `request` comes from a page on `siteOrigin`. */
|
|
25
|
-
function isSameOrigin(request: Request, siteOrigin: string | null): boolean {
|
|
26
|
-
const fetchSite = request.headers.get("sec-fetch-site");
|
|
27
|
-
const origin = request.headers.get("origin");
|
|
28
|
-
if (fetchSite === null && origin === null) return false;
|
|
29
|
-
if (fetchSite !== null && fetchSite !== "same-origin") return false;
|
|
30
|
-
if (origin !== null && origin !== siteOrigin) return false;
|
|
31
|
-
return true;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
25
|
// platform-decisions-waiver: api-versioning — sign-in redirect endpoint, not a versioned API contract (spec 7894 §7)
|
|
35
26
|
export async function POST(request: Request): Promise<Response> {
|
|
36
27
|
if (SIGN_IN_PROVIDER !== "hub") return new Response(null, { status: 404 });
|
|
@@ -31,7 +31,7 @@ import { type BetterAuthPlugin, betterAuth } from "better-auth";
|
|
|
31
31
|
import { prismaAdapter } from "better-auth/adapters/prisma";
|
|
32
32
|
import type { AuthMiddleware } from "better-auth/api";
|
|
33
33
|
import { nextCookies } from "better-auth/next-js";
|
|
34
|
-
import { magicLink, mcp } from "better-auth/plugins";
|
|
34
|
+
import { magicLink, mcp, phoneNumber } from "better-auth/plugins";
|
|
35
35
|
|
|
36
36
|
import { sealMcpCallbacks } from "./app/api/auth/mcp/continuation";
|
|
37
37
|
import {
|
|
@@ -44,15 +44,18 @@ import {
|
|
|
44
44
|
import {
|
|
45
45
|
getActiveProviderIds,
|
|
46
46
|
isSignUpOpen,
|
|
47
|
+
phoneVerificationConfigured,
|
|
47
48
|
resetSendConfigured,
|
|
48
49
|
} from "./lib/auth-env";
|
|
49
50
|
import { resolveSecret } from "./lib/auth-secret";
|
|
51
|
+
import { isAllowedPhoneNumber, makeSendPhoneOtp } from "./lib/auth-sms";
|
|
50
52
|
import { type McpMembership, type McpOAuthDeps, mcpOAuthPlugin } from "./lib/mcp-oauth";
|
|
51
53
|
import {
|
|
52
54
|
signUpAgreementHooks,
|
|
53
55
|
signUpAgreementsPlugin,
|
|
54
56
|
withAuthTransactionCapture,
|
|
55
57
|
} from "./lib/sign-up-agreements";
|
|
58
|
+
import { TOPOLOGY } from "./lib/topology.generated";
|
|
56
59
|
|
|
57
60
|
/**
|
|
58
61
|
* Reset-token lifetime (#5962 § D11). One hour — the library's own default,
|
|
@@ -80,6 +83,97 @@ const VERIFY_TOKEN_TTL_SECONDS = 86_400;
|
|
|
80
83
|
*/
|
|
81
84
|
const VERIFY_EMAIL_DISABLED_PATHS = ["/verify-email"];
|
|
82
85
|
|
|
86
|
+
/**
|
|
87
|
+
* The phone plugin's paths AILK turns off whenever it is installed (#11106
|
|
88
|
+
* D9): phone is never a sign-in method or a password-reset channel, only a
|
|
89
|
+
* verified contact a signed-in person sets for themselves.
|
|
90
|
+
*/
|
|
91
|
+
export const PHONE_DISABLED_PATHS = [
|
|
92
|
+
"/sign-in/phone-number",
|
|
93
|
+
"/phone-number/request-password-reset",
|
|
94
|
+
"/phone-number/reset-password",
|
|
95
|
+
];
|
|
96
|
+
|
|
97
|
+
/** The code's shape and life (#11106 D9), set explicitly so they are reviewable. */
|
|
98
|
+
const PHONE_OTP_LENGTH = 6;
|
|
99
|
+
const PHONE_OTP_TTL_SECONDS = 300;
|
|
100
|
+
const PHONE_OTP_ATTEMPTS = 3;
|
|
101
|
+
|
|
102
|
+
let guardPhoneStep: AuthMiddleware | undefined;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* The phone step's guard (#11106 D9, SEC-11106-2). `/phone-number/send-otp`
|
|
106
|
+
* and `/phone-number/verify` answer only a session whose user's email is
|
|
107
|
+
* verified — 401 signed out, 403 unverified — so a throwaway account cannot
|
|
108
|
+
* text anyone. `/phone-number/verify` also needs `updatePhoneNumber: true`:
|
|
109
|
+
* without it the plugin signs the phone's owner in (it creates a session),
|
|
110
|
+
* which would make phone a sign-in method after all.
|
|
111
|
+
*/
|
|
112
|
+
export const phoneVerificationGuard = {
|
|
113
|
+
id: "ailk-phone-verification-guard",
|
|
114
|
+
hooks: {
|
|
115
|
+
before: [
|
|
116
|
+
{
|
|
117
|
+
matcher: (ctx) =>
|
|
118
|
+
ctx.path === "/phone-number/send-otp" || ctx.path === "/phone-number/verify",
|
|
119
|
+
// `better-auth/api` is ESM-only (#507): imported when the hook first runs.
|
|
120
|
+
handler: async (ctx) => {
|
|
121
|
+
const { APIError, createAuthMiddleware, getSessionFromCtx } = await import(
|
|
122
|
+
"better-auth/api"
|
|
123
|
+
);
|
|
124
|
+
guardPhoneStep ??= createAuthMiddleware(async (inner) => {
|
|
125
|
+
const session = await getSessionFromCtx(inner);
|
|
126
|
+
if (!session) {
|
|
127
|
+
throw new APIError("UNAUTHORIZED", { code: "SESSION_REQUIRED", message: "SESSION_REQUIRED" });
|
|
128
|
+
}
|
|
129
|
+
if (session.user.emailVerified !== true) {
|
|
130
|
+
throw new APIError("FORBIDDEN", { code: "EMAIL_NOT_VERIFIED", message: "EMAIL_NOT_VERIFIED" });
|
|
131
|
+
}
|
|
132
|
+
const body = inner.body as Record<string, unknown> | undefined;
|
|
133
|
+
if (inner.path === "/phone-number/verify" && body?.updatePhoneNumber !== true) {
|
|
134
|
+
throw new APIError("BAD_REQUEST", {
|
|
135
|
+
code: "UPDATE_PHONE_NUMBER_REQUIRED",
|
|
136
|
+
message: "UPDATE_PHONE_NUMBER_REQUIRED",
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
return undefined;
|
|
140
|
+
});
|
|
141
|
+
return guardPhoneStep(ctx);
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
],
|
|
145
|
+
},
|
|
146
|
+
} satisfies BetterAuthPlugin;
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Whether this build carries the phone step (#11106 D9): on a hub (never a
|
|
150
|
+
* spoke, which keeps no users) whose relay secret and origin are set. The
|
|
151
|
+
* Account page offers the step on the same predicate.
|
|
152
|
+
*/
|
|
153
|
+
export function phoneStepActive(): boolean {
|
|
154
|
+
return phoneVerificationConfigured() && TOPOLOGY !== "spoke";
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/** The phone plugin and its guard, as `createAuth` installs them. */
|
|
158
|
+
export function phoneVerificationPlugins() {
|
|
159
|
+
return [
|
|
160
|
+
phoneNumber({
|
|
161
|
+
sendOTP: makeSendPhoneOtp({
|
|
162
|
+
sessionUserId: async (ctx) => {
|
|
163
|
+
const { getSessionFromCtx } = await import("better-auth/api");
|
|
164
|
+
const session = await getSessionFromCtx(ctx as Parameters<typeof getSessionFromCtx>[0]);
|
|
165
|
+
return session?.user.id ?? null;
|
|
166
|
+
},
|
|
167
|
+
}),
|
|
168
|
+
otpLength: PHONE_OTP_LENGTH,
|
|
169
|
+
expiresIn: PHONE_OTP_TTL_SECONDS,
|
|
170
|
+
allowedAttempts: PHONE_OTP_ATTEMPTS,
|
|
171
|
+
phoneNumberValidator: isAllowedPhoneNumber,
|
|
172
|
+
}),
|
|
173
|
+
phoneVerificationGuard,
|
|
174
|
+
];
|
|
175
|
+
}
|
|
176
|
+
|
|
83
177
|
// mcp-oauth:begin
|
|
84
178
|
/**
|
|
85
179
|
* The site's MCP authorization server (#10357 D4): better-auth's `mcp` plugin
|
|
@@ -374,10 +468,26 @@ async function rejectNonHttpImage(user: { image?: unknown }): Promise<void> {
|
|
|
374
468
|
throw new APIError("BAD_REQUEST", { code: "INVALID_IMAGE_URL", message: "INVALID_IMAGE_URL" });
|
|
375
469
|
}
|
|
376
470
|
|
|
471
|
+
/**
|
|
472
|
+
* The phone fields a user create may carry, nulled (#11106 D7, SEC-11106-1).
|
|
473
|
+
* The phone plugin leaves `phoneNumber` input-able on create, so a
|
|
474
|
+
* `/sign-up/email`, magic-link or social sign-up could otherwise claim a
|
|
475
|
+
* number — squatting a victim's under the unique index, or probing which are
|
|
476
|
+
* registered with no text sent. Only the plugin's verify step writes either.
|
|
477
|
+
* A hook's `data` is merged over the row, so a key is dropped by nulling it.
|
|
478
|
+
*/
|
|
479
|
+
function phoneFieldsCleared(user: Record<string, unknown>): Record<string, null> {
|
|
480
|
+
const cleared: Record<string, null> = {};
|
|
481
|
+
for (const key of ["phoneNumber", "phoneNumberVerified"]) {
|
|
482
|
+
if (key in user) cleared[key] = null;
|
|
483
|
+
}
|
|
484
|
+
return cleared;
|
|
485
|
+
}
|
|
486
|
+
|
|
377
487
|
/**
|
|
378
488
|
* The sign-up hooks, with the image check on every user write: on update, and
|
|
379
489
|
* on create (the sign-up endpoint accepts `image` too) ahead of the agreement
|
|
380
|
-
* hook.
|
|
490
|
+
* hook. Every create also drops the phone fields (#11106 D7).
|
|
381
491
|
*/
|
|
382
492
|
function databaseHooks(): ReturnType<typeof signUpAgreementHooks> {
|
|
383
493
|
const hooks = signUpAgreementHooks();
|
|
@@ -388,7 +498,12 @@ function databaseHooks(): ReturnType<typeof signUpAgreementHooks> {
|
|
|
388
498
|
create: {
|
|
389
499
|
before: async (user, context) => {
|
|
390
500
|
await rejectNonHttpImage(user);
|
|
391
|
-
|
|
501
|
+
const cleared = phoneFieldsCleared(user);
|
|
502
|
+
const result = await createBefore?.({ ...user, ...cleared }, context);
|
|
503
|
+
if (Object.keys(cleared).length === 0 || result === false) return result;
|
|
504
|
+
return result && typeof result === "object" && "data" in result
|
|
505
|
+
? { ...result, data: { ...result.data, ...cleared } }
|
|
506
|
+
: { data: cleared };
|
|
392
507
|
},
|
|
393
508
|
},
|
|
394
509
|
update: { before: rejectNonHttpImage },
|
|
@@ -654,9 +769,14 @@ export function createAuth(deps: CreateAuthDeps = {}) {
|
|
|
654
769
|
* (#10357 D4): `listTenancy`'s rule — every workspace of every organization
|
|
655
770
|
* they belong to, with that membership's role.
|
|
656
771
|
*/
|
|
772
|
+
/**
|
|
773
|
+
* A deactivated membership counts as none (#11106 D6): its organization's
|
|
774
|
+
* workspaces leave the consent list and the token self-check, and return on
|
|
775
|
+
* reactivation.
|
|
776
|
+
*/
|
|
657
777
|
const readMemberships = async (userId: string): Promise<McpMembership[]> => {
|
|
658
778
|
const memberships = await prisma.membership.findMany({
|
|
659
|
-
where: { userId },
|
|
779
|
+
where: { userId, deactivatedAt: null },
|
|
660
780
|
select: {
|
|
661
781
|
role: true,
|
|
662
782
|
organization: {
|
|
@@ -679,6 +799,10 @@ export function createAuth(deps: CreateAuthDeps = {}) {
|
|
|
679
799
|
};
|
|
680
800
|
const mcpServer = baseURL ? mcpAuthorizationServer({ readMemberships }) : [];
|
|
681
801
|
|
|
802
|
+
/** The phone step (#11106 D9); its sign-in and reset paths close with it. */
|
|
803
|
+
const phoneActive = phoneStepActive();
|
|
804
|
+
const phonePlugins = phoneActive ? phoneVerificationPlugins() : [];
|
|
805
|
+
|
|
682
806
|
const instance = betterAuth({
|
|
683
807
|
/**
|
|
684
808
|
* `transaction: true` (#8765 D4): Better Auth opens one `$transaction` for
|
|
@@ -725,6 +849,7 @@ export function createAuth(deps: CreateAuthDeps = {}) {
|
|
|
725
849
|
disabledPaths: [
|
|
726
850
|
...VERIFY_EMAIL_DISABLED_PATHS,
|
|
727
851
|
...(baseURL ? MCP_DISABLED_PATHS : []),
|
|
852
|
+
...(phoneActive ? PHONE_DISABLED_PATHS : []),
|
|
728
853
|
],
|
|
729
854
|
emailAndPassword: {
|
|
730
855
|
enabled: passwordMethodActive,
|
|
@@ -925,7 +1050,8 @@ export function createAuth(deps: CreateAuthDeps = {}) {
|
|
|
925
1050
|
* `/sign-up/email` without every sign-up agreement is refused before the
|
|
926
1051
|
* handler looks the address up.
|
|
927
1052
|
*
|
|
928
|
-
* The MCP authorization server whenever `baseURL` is pinned (#10357 D4)
|
|
1053
|
+
* The MCP authorization server whenever `baseURL` is pinned (#10357 D4),
|
|
1054
|
+
* and the phone step under its predicate (#11106 D9).
|
|
929
1055
|
*/
|
|
930
1056
|
plugins: magicLinkActive
|
|
931
1057
|
? [
|
|
@@ -933,8 +1059,9 @@ export function createAuth(deps: CreateAuthDeps = {}) {
|
|
|
933
1059
|
signUpAgreementsPlugin(),
|
|
934
1060
|
magicLink(makeMagicLinkOptions({ send: authEmailTransport })),
|
|
935
1061
|
...mcpServer,
|
|
1062
|
+
...phonePlugins,
|
|
936
1063
|
]
|
|
937
|
-
: [nextCookies(), signUpAgreementsPlugin(), ...mcpServer],
|
|
1064
|
+
: [nextCookies(), signUpAgreementsPlugin(), ...mcpServer, ...phonePlugins],
|
|
938
1065
|
});
|
|
939
1066
|
return instance;
|
|
940
1067
|
}
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
*
|
|
11
11
|
* The locale layout (RSC) reads the session and authors the "Sign out" nav
|
|
12
12
|
* action as `kind: "flow"`; Nav hands the rendered trigger `<Button>` back
|
|
13
|
-
* through `renderFlowTrigger` — composed in
|
|
13
|
+
* through `renderFlowTrigger` — composed in a client Nav until #11095 D6, on the client side
|
|
14
14
|
* of the RSC boundary (#7402) — and this component clones it with the real
|
|
15
15
|
* sign-out handler. Same `createAuthClient()` idiom as `SignInGate`.
|
|
16
16
|
*/
|
|
@@ -35,11 +35,13 @@ const mockCheckoutsMe = jest.fn();
|
|
|
35
35
|
const mockSubscriptionMe = jest.fn();
|
|
36
36
|
const mockMemberPieces = jest.fn();
|
|
37
37
|
const mockMemberMessages = jest.fn();
|
|
38
|
+
const mockMemberRequests = jest.fn();
|
|
38
39
|
const mockMemberPurchases = jest.fn();
|
|
39
40
|
const mockMemberResults = jest.fn();
|
|
40
41
|
const mockMemberAppointments = jest.fn();
|
|
41
42
|
const mockMemberMeetingTypes = jest.fn();
|
|
42
43
|
const mockMemberRequestForm = jest.fn();
|
|
44
|
+
const mockMemberWelcome = jest.fn();
|
|
43
45
|
jest.mock("@working-theory/api-client", () => ({
|
|
44
46
|
__esModule: true,
|
|
45
47
|
waitlistSignups: { me: (...args: unknown[]) => mockSignupMe(...args) },
|
|
@@ -48,11 +50,13 @@ jest.mock("@working-theory/api-client", () => ({
|
|
|
48
50
|
member: {
|
|
49
51
|
pieces: (...args: unknown[]) => mockMemberPieces(...args),
|
|
50
52
|
messages: (...args: unknown[]) => mockMemberMessages(...args),
|
|
53
|
+
requests: (...args: unknown[]) => mockMemberRequests(...args),
|
|
51
54
|
purchases: (...args: unknown[]) => mockMemberPurchases(...args),
|
|
52
55
|
results: (...args: unknown[]) => mockMemberResults(...args),
|
|
53
56
|
appointments: (...args: unknown[]) => mockMemberAppointments(...args),
|
|
54
57
|
meetingTypes: (...args: unknown[]) => mockMemberMeetingTypes(...args),
|
|
55
58
|
requestForm: (...args: unknown[]) => mockMemberRequestForm(...args),
|
|
59
|
+
welcome: (...args: unknown[]) => mockMemberWelcome(...args),
|
|
56
60
|
},
|
|
57
61
|
}));
|
|
58
62
|
|
|
@@ -147,6 +151,15 @@ const MESSAGE = {
|
|
|
147
151
|
readAt: null,
|
|
148
152
|
};
|
|
149
153
|
|
|
154
|
+
/** #11157 — a quote request the member sent; a quote's body is empty. */
|
|
155
|
+
const SENT_REQUEST = {
|
|
156
|
+
id: "intx_2",
|
|
157
|
+
kind: "quote" as const,
|
|
158
|
+
subject: "Request quote",
|
|
159
|
+
body: "",
|
|
160
|
+
createdAt: "2026-09-05T10:00:00.000Z",
|
|
161
|
+
};
|
|
162
|
+
|
|
150
163
|
const ok = <T>(body: T) => ({ ok: true as const, body });
|
|
151
164
|
const fail = (status: number) => ({ ok: false as const, status, body: null });
|
|
152
165
|
|
|
@@ -186,17 +199,19 @@ describe("account-config exports (AC-6)", () => {
|
|
|
186
199
|
["purchase", "purchases"],
|
|
187
200
|
["piece", "updates"],
|
|
188
201
|
["message", "updates"],
|
|
202
|
+
["request", "updates"],
|
|
189
203
|
["appointment", "upcoming"],
|
|
190
204
|
]);
|
|
191
205
|
// No Inbox row asks for a decision — that is the For-you panel's job.
|
|
192
206
|
expect(accountInboxKinds.some((k) => k.section === "needs-you")).toBe(false);
|
|
193
207
|
});
|
|
194
208
|
|
|
195
|
-
it("ships email-unverified, payment-due
|
|
209
|
+
it("ships email-unverified, payment-due, piece-needs-client (#7920) and onboarding-steps (#11150) as For-you sources, not Inbox kinds (D9 as amended)", () => {
|
|
196
210
|
expect(accountForYouSources.map((s) => s.id)).toEqual([
|
|
197
211
|
"email-unverified",
|
|
198
212
|
"payment-due",
|
|
199
213
|
"piece-needs-client",
|
|
214
|
+
"onboarding-steps",
|
|
200
215
|
]);
|
|
201
216
|
const kinds = accountInboxKinds.map((k) => k.kind);
|
|
202
217
|
expect(kinds).not.toContain("email-unverified");
|
|
@@ -458,9 +473,35 @@ describe("member kinds on a cookie-session site — no gate (#8231 D7)", () => {
|
|
|
458
473
|
expect(items.map((i) => i.id)).toEqual(["piece:piece_1"]);
|
|
459
474
|
});
|
|
460
475
|
|
|
476
|
+
it("request reads member.requests with the cookie init and returns the sent rows, titled by subject (#11157)", async () => {
|
|
477
|
+
mockMemberRequests.mockResolvedValue(ok({ items: [SENT_REQUEST] }));
|
|
478
|
+
const items = await kind("request").load(ctx());
|
|
479
|
+
expect(mockMemberRequests).toHaveBeenCalledWith(INIT);
|
|
480
|
+
expect(items.map((i) => [i.id, i.title, i.at])).toEqual([
|
|
481
|
+
["intx_2", "Request quote", "2026-09-05T10:00:00.000Z"],
|
|
482
|
+
]);
|
|
483
|
+
});
|
|
484
|
+
|
|
485
|
+
it("request is a conversation kind: its detail is the member's own bubble, the sent line for a quote's empty body (#11157)", () => {
|
|
486
|
+
const item = { id: "intx_2", title: "Request quote", at: SENT_REQUEST.createdAt, data: SENT_REQUEST };
|
|
487
|
+
const detail = kind("request").renderDetail(item, ctx());
|
|
488
|
+
expect(detail.actions).toBeUndefined();
|
|
489
|
+
expect(detail.fields).toBeUndefined();
|
|
490
|
+
const bubble = detail.body as { props: { side: string; caption: string; children: { props: { children: string } } } };
|
|
491
|
+
expect(bubble.props.side).toBe("end");
|
|
492
|
+
expect(bubble.props.caption).toContain("t:requests.sentAt · ");
|
|
493
|
+
expect(bubble.props.children.props.children).toBe("t:requests.quoteSent");
|
|
494
|
+
const withBody = kind("request").renderDetail(
|
|
495
|
+
{ ...item, data: { ...SENT_REQUEST, kind: "message" as const, body: "Hello\nthere" } },
|
|
496
|
+
ctx(),
|
|
497
|
+
).body as { props: { children: { props: { children: string } } } };
|
|
498
|
+
expect(withBody.props.children.props.children).toBe("Hello\nthere");
|
|
499
|
+
});
|
|
500
|
+
|
|
461
501
|
it.each([
|
|
462
502
|
["piece", mockMemberPieces],
|
|
463
503
|
["message", mockMemberMessages],
|
|
504
|
+
["request", mockMemberRequests],
|
|
464
505
|
] as const)("%s loads [] on a 404 and rejects on a 500", async (id, mock) => {
|
|
465
506
|
mock.mockResolvedValue(fail(404));
|
|
466
507
|
await expect(kind(id).load(ctx())).resolves.toEqual([]);
|
|
@@ -507,6 +548,87 @@ describe("payment-due — a For-you item from subscription.me's actionRequired",
|
|
|
507
548
|
});
|
|
508
549
|
});
|
|
509
550
|
|
|
551
|
+
// ── #11150 — the onboarding steps ────────────────────────────────────────────
|
|
552
|
+
|
|
553
|
+
describe("onboarding-steps — a welcomed member's steps left, from member.welcome (#11150 AC-3)", () => {
|
|
554
|
+
const WELCOMED_AT = "2026-11-08T09:00:00.000Z";
|
|
555
|
+
const WELCOME = {
|
|
556
|
+
welcomedAt: WELCOMED_AT,
|
|
557
|
+
steps: [
|
|
558
|
+
{ id: "name", done: false },
|
|
559
|
+
{ id: "onboarding", done: false },
|
|
560
|
+
{ id: "email", done: true },
|
|
561
|
+
{ id: "booking", done: false },
|
|
562
|
+
],
|
|
563
|
+
};
|
|
564
|
+
|
|
565
|
+
it("is one item per step not done, each linking to its page, none dismissible, timed at the welcome", async () => {
|
|
566
|
+
mockMemberWelcome.mockResolvedValue(ok(WELCOME));
|
|
567
|
+
const items = await source("onboarding-steps").load(ctx());
|
|
568
|
+
expect(mockMemberWelcome).toHaveBeenCalledWith(INIT);
|
|
569
|
+
expect(items.map((item) => item.id)).toEqual([
|
|
570
|
+
"onboarding:name",
|
|
571
|
+
"onboarding:onboarding",
|
|
572
|
+
"onboarding:booking",
|
|
573
|
+
]);
|
|
574
|
+
expect(items[0]).toEqual({
|
|
575
|
+
id: "onboarding:name",
|
|
576
|
+
type: { id: "onboarding", label: "t:forYou.types.onboarding", tone: "neutral" },
|
|
577
|
+
// The area's own "Add your name" string — the item it replaces (account-data.ts).
|
|
578
|
+
title: "t:forYou.addName",
|
|
579
|
+
time: { kind: "at", at: WELCOMED_AT },
|
|
580
|
+
action: { kind: "open", href: "/account/general" },
|
|
581
|
+
dismissible: false,
|
|
582
|
+
});
|
|
583
|
+
expect(items.map((item) => (item.action as { href: string }).href)).toEqual([
|
|
584
|
+
"/account/general",
|
|
585
|
+
"/account/onboarding",
|
|
586
|
+
"/account/appointments",
|
|
587
|
+
]);
|
|
588
|
+
expect(items.every((item) => item.dismissible === false)).toBe(true);
|
|
589
|
+
});
|
|
590
|
+
|
|
591
|
+
it("links the email step to General and the booking step to Appointments", async () => {
|
|
592
|
+
mockMemberWelcome.mockResolvedValue(
|
|
593
|
+
ok({
|
|
594
|
+
welcomedAt: WELCOMED_AT,
|
|
595
|
+
steps: [
|
|
596
|
+
{ id: "email", done: false },
|
|
597
|
+
{ id: "booking", done: false },
|
|
598
|
+
],
|
|
599
|
+
}),
|
|
600
|
+
);
|
|
601
|
+
const items = await source("onboarding-steps").load(ctx({ emailVerified: false }));
|
|
602
|
+
expect(items.map((item) => [item.title, (item.action as { href: string }).href])).toEqual([
|
|
603
|
+
["t:forYou.onboarding.email", "/account/general"],
|
|
604
|
+
["t:forYou.onboarding.booking", "/account/appointments"],
|
|
605
|
+
]);
|
|
606
|
+
});
|
|
607
|
+
|
|
608
|
+
it("is empty once every step is done, so the panel's empty-hides rule holds", async () => {
|
|
609
|
+
mockMemberWelcome.mockResolvedValue(
|
|
610
|
+
ok({ welcomedAt: WELCOMED_AT, steps: WELCOME.steps.map((step) => ({ ...step, done: true })) }),
|
|
611
|
+
);
|
|
612
|
+
await expect(source("onboarding-steps").load(ctx())).resolves.toEqual([]);
|
|
613
|
+
});
|
|
614
|
+
|
|
615
|
+
it("is empty with no marker (no Person could be made), on a 404, and on an unverified 401/403", async () => {
|
|
616
|
+
mockMemberWelcome.mockResolvedValueOnce(ok({ welcomedAt: null, steps: [] }));
|
|
617
|
+
await expect(source("onboarding-steps").load(ctx())).resolves.toEqual([]);
|
|
618
|
+
mockMemberWelcome.mockResolvedValueOnce(fail(404));
|
|
619
|
+
await expect(source("onboarding-steps").load(ctx())).resolves.toEqual([]);
|
|
620
|
+
mockMemberWelcome.mockResolvedValueOnce(fail(403));
|
|
621
|
+
await expect(source("onboarding-steps").load(ctx({ emailVerified: false }))).resolves.toEqual([]);
|
|
622
|
+
});
|
|
623
|
+
|
|
624
|
+
it("rejects on a failed read, a 403 for a verified email included (D12)", async () => {
|
|
625
|
+
mockMemberWelcome.mockResolvedValueOnce(fail(500));
|
|
626
|
+
await expect(source("onboarding-steps").load(ctx())).rejects.toThrow();
|
|
627
|
+
mockMemberWelcome.mockResolvedValueOnce(fail(403));
|
|
628
|
+
await expect(source("onboarding-steps").load(ctx())).rejects.toThrow();
|
|
629
|
+
});
|
|
630
|
+
});
|
|
631
|
+
|
|
510
632
|
// ── #8233 — the New actions ──────────────────────────────────────────────────
|
|
511
633
|
|
|
512
634
|
describe("New actions — offered while their member read answers (#8233 D1, D2)", () => {
|
|
@@ -550,6 +672,12 @@ describe("New actions — offered while their member read answers (#8233 D1, D2)
|
|
|
550
672
|
expect(mockMemberRequestForm).toHaveBeenCalledWith(INIT);
|
|
551
673
|
});
|
|
552
674
|
|
|
675
|
+
it("send-message is a link row to the member thread page (#11152)", () => {
|
|
676
|
+
expect(action("send-message").href).toBe("/account/inbox/thread");
|
|
677
|
+
expect(action("schedule-service").href).toBe("/account/appointments");
|
|
678
|
+
expect(action("request-quote").href).toBeUndefined();
|
|
679
|
+
});
|
|
680
|
+
|
|
553
681
|
it("send-message: a messages 200 → true, read with ctx.init", async () => {
|
|
554
682
|
mockMemberMessages.mockResolvedValue(ok({ items: [] }));
|
|
555
683
|
await expect(action("send-message").available(ctx())).resolves.toBe(true);
|