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
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file auth-sms.test.ts — the phone plugin's outbound text (#11106 D9).
|
|
3
|
+
*
|
|
4
|
+
* - one serialization: the exact string signed is the string sent, and its
|
|
5
|
+
* `ts` is the signed timestamp;
|
|
6
|
+
* - the signature is the relay's domain-separated base string, never the
|
|
7
|
+
* email relay's;
|
|
8
|
+
* - the validator takes E.164 on `AILK_SMS_COUNTRY_CODES` only (default `1`);
|
|
9
|
+
* - nothing throws, and no log line carries the number or the code.
|
|
10
|
+
*/
|
|
11
|
+
import { createHmac } from "node:crypto";
|
|
12
|
+
|
|
13
|
+
import {
|
|
14
|
+
SMS_SIGNATURE_DOMAIN,
|
|
15
|
+
buildAuthSmsRequest,
|
|
16
|
+
isAllowedPhoneNumber,
|
|
17
|
+
makeSendPhoneOtp,
|
|
18
|
+
smsCountryCodes,
|
|
19
|
+
type AuthSmsLog,
|
|
20
|
+
} from "../auth-sms";
|
|
21
|
+
|
|
22
|
+
const SECRET = "test-webhook-secret";
|
|
23
|
+
const NUMBER = "+15555550123";
|
|
24
|
+
const CODE = "482913";
|
|
25
|
+
const ORIGINAL_ENV = { ...process.env };
|
|
26
|
+
|
|
27
|
+
afterEach(() => {
|
|
28
|
+
process.env = { ...ORIGINAL_ENV };
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
function recorder(): { log: AuthSmsLog; lines: string[] } {
|
|
32
|
+
const lines: string[] = [];
|
|
33
|
+
return {
|
|
34
|
+
lines,
|
|
35
|
+
log: {
|
|
36
|
+
warn: (fields) => lines.push(JSON.stringify(fields)),
|
|
37
|
+
info: (fields) => lines.push(JSON.stringify(fields)),
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
describe("buildAuthSmsRequest", () => {
|
|
43
|
+
it("signs the exact bytes it returns, with the relay's own domain", () => {
|
|
44
|
+
const { rawBody, headers } = buildAuthSmsRequest(
|
|
45
|
+
{ kind: "phone-verification", userId: "user_1", to: NUMBER, code: CODE },
|
|
46
|
+
SECRET,
|
|
47
|
+
1_700_000_000,
|
|
48
|
+
);
|
|
49
|
+
expect(JSON.parse(rawBody)).toEqual({
|
|
50
|
+
kind: "phone-verification",
|
|
51
|
+
userId: "user_1",
|
|
52
|
+
to: NUMBER,
|
|
53
|
+
code: CODE,
|
|
54
|
+
ts: 1_700_000_000,
|
|
55
|
+
});
|
|
56
|
+
expect(headers["x-ailk-auth-sms-timestamp"]).toBe("1700000000");
|
|
57
|
+
const expected = `sha256=${createHmac("sha256", SECRET)
|
|
58
|
+
.update(`${SMS_SIGNATURE_DOMAIN}1700000000.${rawBody}`, "utf8")
|
|
59
|
+
.digest("hex")}`;
|
|
60
|
+
expect(headers["x-ailk-auth-sms-signature"]).toBe(expected);
|
|
61
|
+
const emailShaped = `sha256=${createHmac("sha256", SECRET)
|
|
62
|
+
.update(`1700000000.${rawBody}`, "utf8")
|
|
63
|
+
.digest("hex")}`;
|
|
64
|
+
expect(headers["x-ailk-auth-sms-signature"]).not.toBe(emailShaped);
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
describe("isAllowedPhoneNumber (SEC-11106-2)", () => {
|
|
69
|
+
it("takes E.164 on the default list (1) only", () => {
|
|
70
|
+
delete process.env.AILK_SMS_COUNTRY_CODES;
|
|
71
|
+
expect(smsCountryCodes()).toEqual(["1"]);
|
|
72
|
+
expect(isAllowedPhoneNumber(NUMBER)).toBe(true);
|
|
73
|
+
expect(isAllowedPhoneNumber("+447700900123")).toBe(false);
|
|
74
|
+
expect(isAllowedPhoneNumber("15555550123")).toBe(false);
|
|
75
|
+
expect(isAllowedPhoneNumber("+1 555 555 0123")).toBe(false);
|
|
76
|
+
expect(isAllowedPhoneNumber("+0123456789")).toBe(false);
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it("reads AILK_SMS_COUNTRY_CODES as a comma list", () => {
|
|
80
|
+
process.env.AILK_SMS_COUNTRY_CODES = "1, 44";
|
|
81
|
+
expect(isAllowedPhoneNumber("+447700900123")).toBe(true);
|
|
82
|
+
expect(isAllowedPhoneNumber("+33612345678")).toBe(false);
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
describe("makeSendPhoneOtp", () => {
|
|
87
|
+
it("posts one signed body for the session's user, and logs neither the number nor the code", async () => {
|
|
88
|
+
process.env.AUTH_EMAIL_WEBHOOK_SECRET = SECRET;
|
|
89
|
+
const { log, lines } = recorder();
|
|
90
|
+
const send = jest.fn().mockResolvedValue({ status: 202 });
|
|
91
|
+
const sendOtp = makeSendPhoneOtp({ send, log, sessionUserId: async () => "user_1" });
|
|
92
|
+
await sendOtp({ phoneNumber: NUMBER, code: CODE });
|
|
93
|
+
expect(send).toHaveBeenCalledTimes(1);
|
|
94
|
+
const [rawBody] = send.mock.calls[0] as [string, Record<string, string>];
|
|
95
|
+
expect(JSON.parse(rawBody)).toMatchObject({ userId: "user_1", to: NUMBER, code: CODE });
|
|
96
|
+
expect(lines).toHaveLength(1);
|
|
97
|
+
expect(JSON.parse(lines[0]!)).toEqual({ kind: "phone-verification", userId: "user_1", reason: "sent" });
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it.each([
|
|
101
|
+
["the relay refuses", { status: 429 }, "send_failed"],
|
|
102
|
+
["the relay is unreachable", { status: 0 }, "send_failed"],
|
|
103
|
+
])("never throws when %s, and logs the status only", async (_label, answer, reason) => {
|
|
104
|
+
process.env.AUTH_EMAIL_WEBHOOK_SECRET = SECRET;
|
|
105
|
+
const { log, lines } = recorder();
|
|
106
|
+
const sendOtp = makeSendPhoneOtp({
|
|
107
|
+
send: jest.fn().mockResolvedValue(answer),
|
|
108
|
+
log,
|
|
109
|
+
sessionUserId: async () => "user_1",
|
|
110
|
+
});
|
|
111
|
+
await expect(sendOtp({ phoneNumber: NUMBER, code: CODE })).resolves.toBeUndefined();
|
|
112
|
+
expect(JSON.parse(lines[0]!)).toMatchObject({ reason, status: answer.status });
|
|
113
|
+
for (const line of lines) {
|
|
114
|
+
expect(line).not.toContain(NUMBER.slice(1));
|
|
115
|
+
expect(line).not.toContain(CODE);
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
it("sends nothing without the secret or without a session", async () => {
|
|
120
|
+
const send = jest.fn();
|
|
121
|
+
const { log, lines } = recorder();
|
|
122
|
+
delete process.env.AUTH_EMAIL_WEBHOOK_SECRET;
|
|
123
|
+
await makeSendPhoneOtp({ send, log, sessionUserId: async () => "user_1" })({ phoneNumber: NUMBER, code: CODE });
|
|
124
|
+
process.env.AUTH_EMAIL_WEBHOOK_SECRET = SECRET;
|
|
125
|
+
await makeSendPhoneOtp({ send, log, sessionUserId: async () => null })({ phoneNumber: NUMBER, code: CODE });
|
|
126
|
+
await makeSendPhoneOtp({
|
|
127
|
+
send,
|
|
128
|
+
log,
|
|
129
|
+
sessionUserId: async () => {
|
|
130
|
+
throw new Error("boom");
|
|
131
|
+
},
|
|
132
|
+
})({ phoneNumber: NUMBER, code: CODE });
|
|
133
|
+
expect(send).not.toHaveBeenCalled();
|
|
134
|
+
expect(lines.map((l) => (JSON.parse(l) as { reason: string }).reason)).toEqual([
|
|
135
|
+
"not_configured",
|
|
136
|
+
"no_session",
|
|
137
|
+
"no_session",
|
|
138
|
+
]);
|
|
139
|
+
});
|
|
140
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"//": "Resolution for the auth-phone child process only (#11141): `lib/__tests__/auth-phone.test.ts` runs itself under `node --import tsx` with TSX_TSCONFIG_PATH pointing here, so in this monorepo `@working-theory/api-client` and `@working-theory/validation` resolve to their source rather than an unbuilt dist/. It sits beside the test, not under `__tests__/auth/fixtures/`, because `apps/web/__tests__` never reaches a scaffold; there the mapped paths do not exist and tsx falls back to the installed packages.",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"target": "ES2022",
|
|
5
|
+
"module": "ESNext",
|
|
6
|
+
"moduleResolution": "bundler",
|
|
7
|
+
"strict": true,
|
|
8
|
+
"baseUrl": ".",
|
|
9
|
+
"paths": {
|
|
10
|
+
"@working-theory/api-client": [
|
|
11
|
+
"../../../../../packages/api-client/src/index.ts"
|
|
12
|
+
],
|
|
13
|
+
"@working-theory/validation": [
|
|
14
|
+
"../../../../../packages/validation/src/index.ts"
|
|
15
|
+
]
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -511,6 +511,39 @@ describe("offeringsPricing — a bundled plan links its required product (#10028
|
|
|
511
511
|
});
|
|
512
512
|
});
|
|
513
513
|
|
|
514
|
+
describe("offeringsPricing — an offer is listed by neither fragment (#11166 AC-2)", () => {
|
|
515
|
+
const withOffer = (edit: (set: WorkspaceShownSet) => void = () => {}) =>
|
|
516
|
+
shownSet((set) => {
|
|
517
|
+
const welcome = product("welcome", "offer", [price("welcome", "once", 9900, "usd")], {
|
|
518
|
+
name: "Welcome offer",
|
|
519
|
+
recommended: true,
|
|
520
|
+
});
|
|
521
|
+
set.offerings.push(welcome);
|
|
522
|
+
set.productIds.push(welcome.productId);
|
|
523
|
+
edit(set);
|
|
524
|
+
});
|
|
525
|
+
|
|
526
|
+
it("maps the plans and add-ons exactly as without it; the offer gets no card and no tile", () => {
|
|
527
|
+
const result = mapped(withOffer());
|
|
528
|
+
expect(plansOf(result).map((c) => c.key)).toEqual(plansOf(mapped()).map((c) => c.key));
|
|
529
|
+
expect(addonsOf(result).map((t) => t.key)).toEqual(addonsOf(mapped()).map((t) => t.key));
|
|
530
|
+
expect(JSON.stringify(result)).not.toContain("welcome");
|
|
531
|
+
});
|
|
532
|
+
|
|
533
|
+
it("an offer alone, or an offer listed in `plans`, maps to two null fragments", () => {
|
|
534
|
+
const alone = withOffer((set) => {
|
|
535
|
+
set.offerings = set.offerings.filter((o) => o.ailkGroup === "offer");
|
|
536
|
+
set.productIds = set.offerings.map((o) => o.productId);
|
|
537
|
+
set.recommended = { plan: null, addon: null };
|
|
538
|
+
});
|
|
539
|
+
expect(offeringsPricing(alone, OPTIONS)).toEqual({ plans: null, addons: null });
|
|
540
|
+
expect(offeringsPricing(withOffer(), { ...OPTIONS, plans: ["welcome"] })).toEqual({
|
|
541
|
+
plans: null,
|
|
542
|
+
addons: null,
|
|
543
|
+
});
|
|
544
|
+
});
|
|
545
|
+
});
|
|
546
|
+
|
|
514
547
|
describe("offeringsPricing — Stripe text stays text; every link is ours (AC-3)", () => {
|
|
515
548
|
const HOSTILE_DESCRIPTION = "Fast <b>bold</b> javascript:alert(1) \u202Eevil";
|
|
516
549
|
|
|
@@ -149,3 +149,16 @@ describe("signedOutHeaderActions (#10046 AC-3)", () => {
|
|
|
149
149
|
expect(mod.HEADER_CTA_LABEL_KEY).toBe("headerCta");
|
|
150
150
|
});
|
|
151
151
|
});
|
|
152
|
+
|
|
153
|
+
describe("signedInHeaderActions (#11095 AC-5)", () => {
|
|
154
|
+
it("is one outline-strong Your account link to /account", () => {
|
|
155
|
+
expect(mod.signedInHeaderActions()).toEqual([
|
|
156
|
+
{ labelKey: "yourAccount", path: "/account", variant: "outline-strong" },
|
|
157
|
+
]);
|
|
158
|
+
expect(mod.ACCOUNT_LABEL_KEY).toBe("yourAccount");
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
it("answers a fresh list each call", () => {
|
|
162
|
+
expect(mod.signedInHeaderActions()).not.toBe(mod.signedInHeaderActions());
|
|
163
|
+
});
|
|
164
|
+
});
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// server-side, is redacted before a URL reaches Sentry. The query-param scrub
|
|
4
4
|
// has its own suite, `__tests__/telemetry-scrub.test.ts`.
|
|
5
5
|
|
|
6
|
-
import { scrubTelemetryUrl } from "../telemetry-scrub";
|
|
6
|
+
import { scrubTelemetryQuery, scrubTelemetryUrl } from "../telemetry-scrub";
|
|
7
7
|
|
|
8
8
|
const GRANT = "dgrant_01920000-0000-7000-8000-000000000001";
|
|
9
9
|
|
|
@@ -102,3 +102,21 @@ describe("scrubTelemetryUrl — the email-verification nonce (#10820 D2)", () =>
|
|
|
102
102
|
expect(scrubbed).toBe("https://site.example/flows/growth-check/verify");
|
|
103
103
|
});
|
|
104
104
|
});
|
|
105
|
+
|
|
106
|
+
describe("scrubTelemetryUrl — the purchase link's claim (#11096 D9, SEC-11096-4)", () => {
|
|
107
|
+
it("strips claim=<sealed> from a spoke's /account link", () => {
|
|
108
|
+
const claim = "C".repeat(120);
|
|
109
|
+
const scrubbed = scrubTelemetryUrl(`https://spoke.example/account?claim=${claim}`);
|
|
110
|
+
expect(scrubbed).not.toContain(claim);
|
|
111
|
+
expect(scrubbed).toBe("https://spoke.example/account");
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
describe("scrubTelemetryUrl — the phone step's number and code (#11106 D9)", () => {
|
|
116
|
+
it("strips phoneNumber and code from a URL and a query", () => {
|
|
117
|
+
expect(
|
|
118
|
+
scrubTelemetryUrl("https://site.example/api/auth/phone-number/verify?phoneNumber=%2B15555550123&code=482913&x=1"),
|
|
119
|
+
).toBe("https://site.example/api/auth/phone-number/verify?x=1");
|
|
120
|
+
expect(scrubTelemetryQuery("?phoneNumber=%2B15555550123&code=482913")).toBe("");
|
|
121
|
+
});
|
|
122
|
+
});
|
|
@@ -43,8 +43,9 @@
|
|
|
43
43
|
// `ctx.init` already carries the right one (`forwardedCookieInit()`), so no
|
|
44
44
|
// kind here tests the topology:
|
|
45
45
|
//
|
|
46
|
-
// - Inbox kind `purchase` (`GET /v1/member/purchases`) — the
|
|
47
|
-
//
|
|
46
|
+
// - Inbox kind `purchase` (`GET /v1/member/purchases`) — the Orders tab
|
|
47
|
+
// (#11149; the tab keeps the section id `purchases`). Only a purchase
|
|
48
|
+
// linked by the verified-email rule shows (roadmap D3).
|
|
48
49
|
// - Inbox kind `appointment` (`GET /v1/member/appointments`) — the
|
|
49
50
|
// Scheduled tab, upcoming first, each item flagged by the read's own split.
|
|
50
51
|
// - Inbox kinds `piece` (`GET /v1/member/pieces`) and `message`
|
|
@@ -54,8 +55,20 @@
|
|
|
54
55
|
// browser holds no hub credential. A message whose `action` is
|
|
55
56
|
// `onboarding` (#8515 D6) has an Open onboarding action to this site's
|
|
56
57
|
// own `/account/onboarding`.
|
|
58
|
+
// - Inbox kind `request` (`GET /v1/member/requests`, #11157) — the member's
|
|
59
|
+
// OWN sent quote requests and messages, the inbound rows the two New
|
|
60
|
+
// writes put on their Person. With `message` it makes the Messages tab
|
|
61
|
+
// (`accountChatKinds`): a request the member just posted is read again
|
|
62
|
+
// on the next render, so it appears under Messages and All without a
|
|
63
|
+
// reload (the New menu refreshes the route after a post).
|
|
57
64
|
// - For-you source `piece-needs-client` — each piece waiting on the client,
|
|
58
65
|
// with an Open action to its Inbox row. It shares the pieces read.
|
|
66
|
+
// - For-you source `onboarding-steps` (#11150) — the steps a welcomed
|
|
67
|
+
// member has left (`GET /v1/member/welcome`): name, the onboarding form,
|
|
68
|
+
// email verification and a first booking, each linking to its page and
|
|
69
|
+
// none dismissible. The read also writes the first-sign-in marker and
|
|
70
|
+
// sends the welcome email the first time, so a member's first `/account`
|
|
71
|
+
// render IS the first sign-in, on a spoke and on the hub alike.
|
|
59
72
|
//
|
|
60
73
|
// A build with no tenancy module registers no member route, so each of these
|
|
61
74
|
// 404s and loads `[]`. A site whose workspace does not resolve gets a 503
|
|
@@ -68,12 +81,18 @@
|
|
|
68
81
|
// on click:
|
|
69
82
|
//
|
|
70
83
|
// - `schedule-service` — while `GET /v1/member/meeting-types` answers
|
|
71
|
-
// (registered with `scheduling` on), `{ items: [] }` included
|
|
72
|
-
//
|
|
84
|
+
// (registered with `scheduling` on), `{ items: [] }` included. Since
|
|
85
|
+
// #11154 the row navigates to `/account/appointments` (the member's
|
|
86
|
+
// Appointments page, which lists the offered types and opens each
|
|
87
|
+
// type's booking page) rather than opening a popup; an empty offer
|
|
88
|
+
// shows that page's empty line.
|
|
73
89
|
// - `request-quote` — while `GET /v1/member/request-form` answers a form;
|
|
74
90
|
// `{ form: null }` (switched off) leaves it out like a 404.
|
|
75
91
|
// - `send-message` — while `GET /v1/member/messages` answers; the `message`
|
|
76
|
-
// kind shares that read (`memberMessages`), one call per request.
|
|
92
|
+
// kind shares that read (`memberMessages`), one call per request. Since
|
|
93
|
+
// #11152 the row navigates to `/account/inbox/thread` (the member's
|
|
94
|
+
// thread page: every message between them and the workspace, the
|
|
95
|
+
// composer at the foot) rather than opening a lightbox.
|
|
77
96
|
//
|
|
78
97
|
// A Free build registers none of the three, so it shows no New button; a
|
|
79
98
|
// failed read rejects, so the Inbox shows its error row. The popups, the
|
|
@@ -112,8 +131,10 @@ import { Text } from "@working-theory/ui/primitives";
|
|
|
112
131
|
import type {
|
|
113
132
|
MemberAppointment,
|
|
114
133
|
MemberMessage,
|
|
134
|
+
MemberOnboardingStepId,
|
|
115
135
|
MemberPiece,
|
|
116
136
|
MemberPurchase,
|
|
137
|
+
MemberRequest,
|
|
117
138
|
MemberResult,
|
|
118
139
|
} from "@working-theory/validation";
|
|
119
140
|
import { formatMoney, formatNumber } from "@working-theory/web-i18n";
|
|
@@ -372,12 +393,53 @@ const message: AccountInboxKind<MemberMessage> = {
|
|
|
372
393
|
},
|
|
373
394
|
};
|
|
374
395
|
|
|
396
|
+
/**
|
|
397
|
+
* #11157 — the member's own sent rows: the inbound `message` and `quote`
|
|
398
|
+
* Interactions the New menu's Send message and Request quote wrote on their
|
|
399
|
+
* Person, newest first. The row's title is the subject (a quote request's is
|
|
400
|
+
* the form's title); the detail is the member's own bubble, on the end side,
|
|
401
|
+
* captioned with when it was sent — a quote request, whose body is empty,
|
|
402
|
+
* reads the one sent line. The member thread page (#11152,
|
|
403
|
+
* `account/inbox/thread`) lists these beside the provider's messages, oldest
|
|
404
|
+
* first.
|
|
405
|
+
*/
|
|
406
|
+
const request: AccountInboxKind<MemberRequest> = {
|
|
407
|
+
kind: "request",
|
|
408
|
+
label: "requests.heading",
|
|
409
|
+
section: "updates",
|
|
410
|
+
async load({ init, user }) {
|
|
411
|
+
const rows = (await read(member.requests(init), user))?.items ?? [];
|
|
412
|
+
return rows.map((r) => ({
|
|
413
|
+
id: r.id,
|
|
414
|
+
title: r.subject,
|
|
415
|
+
at: r.createdAt,
|
|
416
|
+
data: r,
|
|
417
|
+
}));
|
|
418
|
+
},
|
|
419
|
+
renderDetail({ data }, { locale, t }) {
|
|
420
|
+
const caption = `${t("requests.sentAt")} · ${formatWhen(data.createdAt, locale)}`;
|
|
421
|
+
return {
|
|
422
|
+
body: createElement(MessageBubble, {
|
|
423
|
+
side: "end",
|
|
424
|
+
caption,
|
|
425
|
+
"data-testid": "account-item-request",
|
|
426
|
+
children: createElement(
|
|
427
|
+
Text,
|
|
428
|
+
{ as: "p", className: "whitespace-pre-wrap" },
|
|
429
|
+
data.body === "" ? t("requests.quoteSent") : data.body,
|
|
430
|
+
),
|
|
431
|
+
}),
|
|
432
|
+
};
|
|
433
|
+
},
|
|
434
|
+
};
|
|
435
|
+
|
|
375
436
|
/**
|
|
376
437
|
* #11007 — the kinds whose detail is a conversation, rendered through
|
|
377
438
|
* `InboxItemFrame`'s `layout="chat"`; every other kind keeps the stacked
|
|
378
|
-
* head and fields.
|
|
439
|
+
* head and fields. #11157 — the same kinds are the Inbox's Messages tab: the
|
|
440
|
+
* provider's messages and the member's own sent requests and messages.
|
|
379
441
|
*/
|
|
380
|
-
export const accountChatKinds: ReadonlySet<string> = new Set([message.kind]);
|
|
442
|
+
export const accountChatKinds: ReadonlySet<string> = new Set([message.kind, request.kind]);
|
|
381
443
|
|
|
382
444
|
/** Each appointment status's message key — a new status is a type error, never a raw key. */
|
|
383
445
|
const APPOINTMENT_STATUS_KEY = {
|
|
@@ -481,6 +543,61 @@ const pieceNeedsClient: AccountForYouSource = {
|
|
|
481
543
|
},
|
|
482
544
|
};
|
|
483
545
|
|
|
546
|
+
// ── Onboarding-steps For-you source (#11150) ─────────────────────────────────
|
|
547
|
+
|
|
548
|
+
/** Each step's page — where the member does it (AC-3). */
|
|
549
|
+
const ONBOARDING_STEP_HREF = {
|
|
550
|
+
name: "/account/general",
|
|
551
|
+
onboarding: "/account/onboarding",
|
|
552
|
+
email: "/account/general",
|
|
553
|
+
booking: "/account/appointments",
|
|
554
|
+
} satisfies Record<MemberOnboardingStepId, string>;
|
|
555
|
+
|
|
556
|
+
/** Each step's title key. The name step is the area's own "Add your name" (`account-data.ts`), which yields to it. */
|
|
557
|
+
const ONBOARDING_STEP_TITLE = {
|
|
558
|
+
name: "forYou.addName",
|
|
559
|
+
onboarding: "forYou.onboarding.onboarding",
|
|
560
|
+
email: "forYou.onboarding.email",
|
|
561
|
+
booking: "forYou.onboarding.booking",
|
|
562
|
+
} satisfies Record<MemberOnboardingStepId, string>;
|
|
563
|
+
|
|
564
|
+
/**
|
|
565
|
+
* The steps a welcomed member has left (#11150 AC-3). One read,
|
|
566
|
+
* `GET /v1/member/welcome`, which the API also uses to write the
|
|
567
|
+
* first-sign-in marker (and send the welcome email) the first time this
|
|
568
|
+
* caller reads it on this workspace — so the source IS the first sign-in's
|
|
569
|
+
* trigger, on a spoke through the hub or on the hub itself alike, through
|
|
570
|
+
* `ctx.init`. Each step is read from server state, links to its page and
|
|
571
|
+
* cannot be dismissed; a done step disappears, and with every step done the
|
|
572
|
+
* source is empty, so the panel's empty-hides rule is unchanged. No marker
|
|
573
|
+
* (no Person could be made for the caller) is no steps. The area's own
|
|
574
|
+
* "Add your name" item yields to the `name` step when both would show
|
|
575
|
+
* (`account-data.ts`), so one fact has one row; the `email-unverified`
|
|
576
|
+
* source never meets the `email` step, because this read answers a verified
|
|
577
|
+
* caller only.
|
|
578
|
+
*/
|
|
579
|
+
const onboardingSteps: AccountForYouSource = {
|
|
580
|
+
id: "onboarding-steps",
|
|
581
|
+
async load({ init, locale, t, user }) {
|
|
582
|
+
const welcome = await read(member.welcome(init), user);
|
|
583
|
+
if (welcome === null || welcome.welcomedAt === null) return [];
|
|
584
|
+
const at = welcome.welcomedAt;
|
|
585
|
+
return welcome.steps
|
|
586
|
+
.filter((step) => !step.done)
|
|
587
|
+
.map((step) => ({
|
|
588
|
+
id: `onboarding:${step.id}`,
|
|
589
|
+
type: { id: "onboarding", label: t("forYou.types.onboarding"), tone: "neutral" as const },
|
|
590
|
+
title: t(ONBOARDING_STEP_TITLE[step.id]),
|
|
591
|
+
time: { kind: "at" as const, at },
|
|
592
|
+
action: {
|
|
593
|
+
kind: "open" as const,
|
|
594
|
+
href: localeHref(locale, ONBOARDING_STEP_HREF[step.id]),
|
|
595
|
+
},
|
|
596
|
+
dismissible: false,
|
|
597
|
+
}));
|
|
598
|
+
},
|
|
599
|
+
};
|
|
600
|
+
|
|
484
601
|
// ── New actions (#8233) ──────────────────────────────────────────────────────
|
|
485
602
|
|
|
486
603
|
/**
|
|
@@ -493,6 +610,8 @@ export type AccountNewRead = Omit<AccountNewAction, "renderPopup">;
|
|
|
493
610
|
const scheduleService = {
|
|
494
611
|
id: "schedule-service",
|
|
495
612
|
label: "new.actions.scheduleService",
|
|
613
|
+
// #11154 — a link row: the page localizes the path, and no popup binds to it.
|
|
614
|
+
href: "/account/appointments",
|
|
496
615
|
async available({ init, user }) {
|
|
497
616
|
return (await read(member.meetingTypes(init), user)) !== null;
|
|
498
617
|
},
|
|
@@ -510,6 +629,8 @@ const requestQuote = {
|
|
|
510
629
|
const sendMessage = {
|
|
511
630
|
id: "send-message",
|
|
512
631
|
label: "new.actions.sendMessage",
|
|
632
|
+
// #11152 — a link row: the member thread page, where the composer posts.
|
|
633
|
+
href: "/account/inbox/thread",
|
|
513
634
|
async available({ init, user }) {
|
|
514
635
|
return (await read(memberMessages(init), user)) !== null;
|
|
515
636
|
},
|
|
@@ -523,6 +644,7 @@ export const accountInboxKinds: AccountInboxKind[] = [
|
|
|
523
644
|
purchase,
|
|
524
645
|
piece,
|
|
525
646
|
message,
|
|
647
|
+
request,
|
|
526
648
|
appointment,
|
|
527
649
|
];
|
|
528
650
|
|
|
@@ -532,7 +654,8 @@ export const accountSettingsSections: AccountSettingsSection[] = [];
|
|
|
532
654
|
/**
|
|
533
655
|
* New-menu actions' server halves, in menu order (#8233 D2). A module appends
|
|
534
656
|
* its own read here and binds its popup in `account/new-popups.tsx`, keyed on
|
|
535
|
-
* the id — `AccountNewActionId` makes a read with no popup a type error.
|
|
657
|
+
* the id — `AccountNewActionId` makes a read with no popup a type error. A
|
|
658
|
+
* read carrying `href` is a link row (#11154) and binds no popup.
|
|
536
659
|
*/
|
|
537
660
|
export const accountNewActions = [
|
|
538
661
|
scheduleService,
|
|
@@ -551,4 +674,5 @@ export const accountForYouSources: AccountForYouSource[] = [
|
|
|
551
674
|
emailUnverified,
|
|
552
675
|
paymentDue,
|
|
553
676
|
pieceNeedsClient,
|
|
677
|
+
onboardingSteps,
|
|
554
678
|
];
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
* change it reports.
|
|
34
34
|
*/
|
|
35
35
|
|
|
36
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
36
37
|
import { createHmac } from "node:crypto";
|
|
37
38
|
|
|
38
39
|
import { authEmail } from "@working-theory/api-client";
|
|
@@ -46,15 +47,17 @@ import {
|
|
|
46
47
|
} from "./sign-up-agreements";
|
|
47
48
|
|
|
48
49
|
/**
|
|
49
|
-
* The
|
|
50
|
+
* The six fixed kinds the relay will send. A caller picks no copy: a sign-up
|
|
50
51
|
* link sends agreement ids and a locale, which the API names itself (#9720).
|
|
52
|
+
* `account-open` is a paid buyer's "Open your account" link (#11096 D9).
|
|
51
53
|
*/
|
|
52
54
|
export type AuthEmailKind =
|
|
53
55
|
| "password-reset"
|
|
54
56
|
| "email-verification"
|
|
55
57
|
| "password-changed"
|
|
56
58
|
| "magic-link"
|
|
57
|
-
| "magic-link-sign-up"
|
|
59
|
+
| "magic-link-sign-up"
|
|
60
|
+
| "account-open";
|
|
58
61
|
|
|
59
62
|
export interface AuthEmailPayload {
|
|
60
63
|
kind: AuthEmailKind;
|
|
@@ -164,7 +167,7 @@ interface DispatchDeps {
|
|
|
164
167
|
async function dispatch(
|
|
165
168
|
payload: AuthEmailPayload,
|
|
166
169
|
{ send, log }: { send: AuthEmailTransport; log: AuthEmailLog },
|
|
167
|
-
): Promise<
|
|
170
|
+
): Promise<boolean> {
|
|
168
171
|
const secret = process.env.AUTH_EMAIL_WEBHOOK_SECRET;
|
|
169
172
|
const base = { userId: payload.userId, kind: payload.kind };
|
|
170
173
|
|
|
@@ -172,7 +175,7 @@ async function dispatch(
|
|
|
172
175
|
// Never sign with an empty key: the relay would reject every delivery and
|
|
173
176
|
// the deployment would have no local signal at all.
|
|
174
177
|
log.warn({ ...base, reason: "not_configured" });
|
|
175
|
-
return;
|
|
178
|
+
return false;
|
|
176
179
|
}
|
|
177
180
|
|
|
178
181
|
/**
|
|
@@ -196,7 +199,7 @@ async function dispatch(
|
|
|
196
199
|
} catch {
|
|
197
200
|
// The KIND only — see this file's PII boundary note.
|
|
198
201
|
log.warn({ ...base, reason: "send_failed", errorKind: "signing_failed" });
|
|
199
|
-
return;
|
|
202
|
+
return false;
|
|
200
203
|
}
|
|
201
204
|
|
|
202
205
|
try {
|
|
@@ -207,12 +210,14 @@ async function dispatch(
|
|
|
207
210
|
// The STATUS, never the response body — the relay's own error text is
|
|
208
211
|
// not guaranteed free of the address it was given.
|
|
209
212
|
log.warn({ ...base, reason: "send_failed", errorKind: "relay_rejected" });
|
|
210
|
-
return;
|
|
213
|
+
return false;
|
|
211
214
|
}
|
|
212
215
|
log.info({ ...base, reason: "sent" });
|
|
216
|
+
return true;
|
|
213
217
|
} catch {
|
|
214
218
|
// The error's NAME would be safe; its message is not guaranteed to be.
|
|
215
219
|
log.warn({ ...base, reason: "send_failed", errorKind: "transport_error" });
|
|
220
|
+
return false;
|
|
216
221
|
}
|
|
217
222
|
}
|
|
218
223
|
|
|
@@ -449,6 +454,48 @@ export function makeSendPasswordChangedNotice(deps: DispatchDeps) {
|
|
|
449
454
|
};
|
|
450
455
|
}
|
|
451
456
|
|
|
457
|
+
/**
|
|
458
|
+
* The paid buyer's "Open your account" email (#11096 D9): one link to the
|
|
459
|
+
* spoke's `/account?claim=…`. It carries no agreement copy and signs no one
|
|
460
|
+
* in; the relay only logs `userId`, so it is the fixed sentinel `"purchase"`.
|
|
461
|
+
* Never throws.
|
|
462
|
+
*/
|
|
463
|
+
export function makeSendAccountOpen(deps: DispatchDeps) {
|
|
464
|
+
const { send } = deps;
|
|
465
|
+
const log = deps.log ?? defaultLog;
|
|
466
|
+
/** Whether the relay accepted the mail. */
|
|
467
|
+
return async function sendAccountOpen(input: {
|
|
468
|
+
to: string;
|
|
469
|
+
url: string;
|
|
470
|
+
}): Promise<boolean> {
|
|
471
|
+
return dispatch(
|
|
472
|
+
{
|
|
473
|
+
kind: "account-open",
|
|
474
|
+
userId: "purchase",
|
|
475
|
+
to: input.to,
|
|
476
|
+
url: input.url,
|
|
477
|
+
},
|
|
478
|
+
{ send, log },
|
|
479
|
+
);
|
|
480
|
+
};
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
/** What one purchase spend gets back from `sendMagicLink` (#11096 D9). */
|
|
484
|
+
export interface PurchaseCaptureStore {
|
|
485
|
+
token: string | null;
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
/**
|
|
489
|
+
* The purchase route's capture (#11096 D9). A `sendMagicLink` call inside
|
|
490
|
+
* `purchaseCapture.run(store, …)` binds a sign-up request's agreements as
|
|
491
|
+
* any sign-up request does, then hands the token to `store` instead of
|
|
492
|
+
* mailing it — so the route can return the hub's own verify URL to the spoke
|
|
493
|
+
* that spent the claim. It captures only a new address with a written
|
|
494
|
+
* binding: an existing account, or a failed binding, leaves `token` null.
|
|
495
|
+
* Outside a capture nothing changes.
|
|
496
|
+
*/
|
|
497
|
+
export const purchaseCapture = new AsyncLocalStorage<PurchaseCaptureStore>();
|
|
498
|
+
|
|
452
499
|
/**
|
|
453
500
|
* Magic-link token lifetime (#7435 § D2). Five minutes — the library default,
|
|
454
501
|
* and the number `packages/email`'s magic-link template already promises ("This
|
|
@@ -554,6 +601,15 @@ function makeSendMagicLink(deps: MagicLinkDeps) {
|
|
|
554
601
|
}
|
|
555
602
|
}
|
|
556
603
|
|
|
604
|
+
// #11096 D9 — inside a purchase capture nothing is mailed: the token of
|
|
605
|
+
// a new address's bound sign-up request goes to the capture.
|
|
606
|
+
const capture = purchaseCapture.getStore();
|
|
607
|
+
if (capture) {
|
|
608
|
+
if (!found && binding) capture.token = data.token;
|
|
609
|
+
log.info({ kind: "magic-link", reason: "captured" });
|
|
610
|
+
return;
|
|
611
|
+
}
|
|
612
|
+
|
|
557
613
|
// A new address has no user yet; the relay only logs `userId`, so a
|
|
558
614
|
// sign-up link carries the fixed sentinel and the binding's ids, never
|
|
559
615
|
// the request's (#9720 D6).
|
|
@@ -181,3 +181,16 @@ export function resetSendConfigured(): boolean {
|
|
|
181
181
|
if (!process.env.BETTER_AUTH_URL) return false;
|
|
182
182
|
return Boolean(process.env.BETTER_AUTH_SECRET);
|
|
183
183
|
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* True when this deployment can verify a person's phone (#11106 D9): the
|
|
187
|
+
* signed relay's secret (`AUTH_EMAIL_WEBHOOK_SECRET`, which the apps/api SMS
|
|
188
|
+
* relay checks too) and `BETTER_AUTH_URL` (the pinned origin every auth
|
|
189
|
+
* callback rides on). `auth.ts` installs the phone plugin only under this
|
|
190
|
+
* predicate and never on a spoke, and the Account page offers the step only
|
|
191
|
+
* when the plugin is installed. Whether apps/api holds a text provider is
|
|
192
|
+
* apps/api's to say: its relay answers 503 without one.
|
|
193
|
+
*/
|
|
194
|
+
export function phoneVerificationConfigured(): boolean {
|
|
195
|
+
return Boolean(process.env.AUTH_EMAIL_WEBHOOK_SECRET && process.env.BETTER_AUTH_URL);
|
|
196
|
+
}
|
|
@@ -14,9 +14,11 @@
|
|
|
14
14
|
*
|
|
15
15
|
* `isBookingPath()` (#8843 D10) is the same predicate for the scheduling
|
|
16
16
|
* module's booking pages — `/meet`, `/meet/<slug>` and `/private`, never
|
|
17
|
-
* `/meet/confirmed
|
|
18
|
-
*
|
|
19
|
-
*
|
|
17
|
+
* `/meet/confirmed`, plus the member's own booking page
|
|
18
|
+
* `/account/appointments/<slug>` (#11154) — which the layout renders
|
|
19
|
+
* chrome-free only where the module is installed (`lib/modules.generated.ts`)
|
|
20
|
+
* and the middleware grants the scheduling CSP. This module imports nothing,
|
|
21
|
+
* so edge code can import it too.
|
|
20
22
|
*
|
|
21
23
|
* No Next.js import — pure functions, asserted directly by their own suite.
|
|
22
24
|
*/
|
|
@@ -73,15 +75,18 @@ export function isAccountPath(
|
|
|
73
75
|
/**
|
|
74
76
|
* Whether `pathname` addresses a booking page: `/private`, `/meet`, or
|
|
75
77
|
* `/meet/<slug>` for any slug but `confirmed` (the booker's confirmation
|
|
76
|
-
* page, which keeps the marketing chrome)
|
|
77
|
-
*
|
|
78
|
+
* page, which keeps the marketing chrome), or the member's booking page
|
|
79
|
+
* `/account/appointments/<slug>` (#11154) — never the Appointments list
|
|
80
|
+
* itself, which embeds nothing. The same prefix rule and the same fail-safe
|
|
81
|
+
* direction as `isAuthPath()`.
|
|
78
82
|
*/
|
|
79
83
|
export function isBookingPath(
|
|
80
84
|
pathname: string | undefined | null,
|
|
81
85
|
locales: readonly string[],
|
|
82
86
|
): boolean {
|
|
83
|
-
const [first, second] = segments(pathname, locales);
|
|
87
|
+
const [first, second, third] = segments(pathname, locales);
|
|
84
88
|
if (first === "private") return true;
|
|
89
|
+
if (first === "account") return second === "appointments" && third !== undefined;
|
|
85
90
|
return first === "meet" && second !== "confirmed";
|
|
86
91
|
}
|
|
87
92
|
|