mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-15 06:52:04 +00:00
style: apply prettier across the tree
One-shot prettier pass so the new format:check gate starts from a clean baseline. Formatting only — no behaviour change. Generator-owned and vendored artifacts stay untouched via .prettierignore.
This commit is contained in:
1 parent
b3fea2ef59
commit
1f4ba5939d
1000 files changed
+12130
-8385
No files matched your search
@@ -123,9 +123,8 @@ describe("withings/callback atomic nonce consumption (M3)", () => {
|
||||
|
||||
// Stub the rest of the happy path for the winning request — code
|
||||
// exchange returns plausible tokens so the upsert + redirect run.
|
||||
const { getUserWithingsCredentials } = await import(
|
||||
"@/lib/withings/credentials"
|
||||
);
|
||||
const { getUserWithingsCredentials } =
|
||||
await import("@/lib/withings/credentials");
|
||||
vi.mocked(getUserWithingsCredentials).mockResolvedValue({
|
||||
clientId: "cid",
|
||||
clientSecret: "csec",
|
||||
@@ -155,13 +154,9 @@ describe("withings/callback atomic nonce consumption (M3)", () => {
|
||||
|
||||
// Exactly one leg landed on `withings=connected`, exactly one
|
||||
// landed on the replay branch (`withings=error&reason=replay`).
|
||||
const locations = [resA, resB]
|
||||
.map((r) => r.headers.get("location"))
|
||||
.sort();
|
||||
const locations = [resA, resB].map((r) => r.headers.get("location")).sort();
|
||||
expect(locations).toHaveLength(2);
|
||||
expect(
|
||||
locations.some((l) => l?.includes("withings=connected")),
|
||||
).toBe(true);
|
||||
expect(locations.some((l) => l?.includes("withings=connected"))).toBe(true);
|
||||
expect(
|
||||
locations.some((l) => l?.includes("withings=error&reason=replay")),
|
||||
).toBe(true);
|
||||
@@ -265,7 +260,9 @@ describe("withings/callback atomic nonce consumption (M3)", () => {
|
||||
"withings=error&reason=cross_user",
|
||||
);
|
||||
expect(exchangeCode).not.toHaveBeenCalled();
|
||||
expect(annotateMock).toHaveBeenCalledWith({ meta: { reason: "cross_user" } });
|
||||
expect(annotateMock).toHaveBeenCalledWith({
|
||||
meta: { reason: "cross_user" },
|
||||
});
|
||||
});
|
||||
|
||||
it("non-P2025 infra error branch annotates reason=state on the Wide Event (legacy fallback for unclassified DB failures)", async () => {
|
||||
@@ -295,7 +292,10 @@ describe("withings/callback atomic nonce consumption (M3)", () => {
|
||||
// CSRF leg 1 — must reject without touching the ledger so a
|
||||
// probe can't grief legitimate rows by issuing deletes for
|
||||
// nonces it doesn't legitimately hold the cookie for.
|
||||
const req = callbackRequest("aaaaaaaaaaaaaaaaaaaaaa", "bbbbbbbbbbbbbbbbbbbbbb");
|
||||
const req = callbackRequest(
|
||||
"aaaaaaaaaaaaaaaaaaaaaa",
|
||||
"bbbbbbbbbbbbbbbbbbbbbb",
|
||||
);
|
||||
const res = await GET(req);
|
||||
|
||||
expect(res.status).toBe(307);
|
||||
|
||||
@@ -42,7 +42,8 @@ vi.mock("@/lib/withings/credentials", () => ({
|
||||
|
||||
vi.mock("@/lib/withings/client", () => ({
|
||||
getAuthorizationUrl: vi.fn(
|
||||
() => "https://account.withings.com/oauth2_user/authorize2?state=nonce-stub",
|
||||
() =>
|
||||
"https://account.withings.com/oauth2_user/authorize2?state=nonce-stub",
|
||||
),
|
||||
}));
|
||||
|
||||
@@ -78,9 +79,7 @@ beforeEach(() => {
|
||||
resetAt: Date.now() + 60_000,
|
||||
} as never);
|
||||
vi.mocked(prisma.withingsOAuthState.create).mockReset();
|
||||
vi.mocked(prisma.withingsOAuthState.create).mockResolvedValue(
|
||||
{} as never,
|
||||
);
|
||||
vi.mocked(prisma.withingsOAuthState.create).mockResolvedValue({} as never);
|
||||
vi.mocked(getUserWithingsCredentials).mockResolvedValue({
|
||||
clientId: "client-id",
|
||||
clientSecret: "client-secret",
|
||||
|
||||
@@ -77,10 +77,7 @@ export const GET = apiHandler(async (req: NextRequest) => {
|
||||
getEvent()?.setError(err);
|
||||
annotate({ action: { name: "withings.connect.create_failed" } });
|
||||
return NextResponse.redirect(
|
||||
new URL(
|
||||
"/settings/integrations?withings=error&reason=connect",
|
||||
req.url,
|
||||
),
|
||||
new URL("/settings/integrations?withings=error&reason=connect", req.url),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -26,9 +26,7 @@ interface RouteContext {
|
||||
params: Promise<{ token: string }>;
|
||||
}
|
||||
|
||||
async function verifyTokenSegment(
|
||||
token: string | undefined,
|
||||
): Promise<boolean> {
|
||||
async function verifyTokenSegment(token: string | undefined): Promise<boolean> {
|
||||
const expected = process.env.WITHINGS_WEBHOOK_SECRET;
|
||||
if (!expected) {
|
||||
getEvent()?.addWarning("WITHINGS_WEBHOOK_SECRET not configured");
|
||||
|
||||
Reference in new issue
Block a user