mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-18 16:12:11 +00:00
feat(cycle): add the calendar-feed credential table
A record's cycle calendar subscription is a URL credential: one row per feed, only the HMAC of the raw hlf_ token stored, and at most one live feed per record through a partial unique index on user_id where revoked_at is null. Both foreign keys cascade, so deleting the record or the carrier who minted the feed ends it. The row is a credential everywhere else too. It stays out of the backup (a restore would bring back a revoked link), Delete All Data takes it on both sides, a credential remediation revokes the feeds on the record and the ones the account minted elsewhere, and a managed-profile handover claim revokes any feed a guardian minted. backupVerdict moves beside the plan into its own module so the plan stays the lists and their reasons.
This commit is contained in:
1 parent
c0470df14c
commit
2480a0138d
9 files changed
+235
-18
No files matched your search
@@ -52,6 +52,7 @@ vi.mock("@/lib/db", () => ({
|
||||
trustedDevice: { deleteMany: vi.fn() },
|
||||
mcpOAuthConnection: { updateMany: vi.fn() },
|
||||
clinicianShareLink: { updateMany: vi.fn() },
|
||||
cycleCalendarFeed: { updateMany: vi.fn() },
|
||||
stepUpElevation: { deleteMany: vi.fn() },
|
||||
$transaction: vi.fn(async (ops: Promise<unknown>[]) => Promise.all(ops)),
|
||||
},
|
||||
@@ -584,6 +585,15 @@ describe("destroyAllSessions", () => {
|
||||
where: { userId: "user-rotated", revokedAt: null },
|
||||
data: { revokedAt: expect.any(Date) },
|
||||
});
|
||||
// The calendar feeds on the record and the ones this account minted on a
|
||||
// record it manages are both URL credentials, and both end here.
|
||||
expect(prisma.cycleCalendarFeed.updateMany).toHaveBeenCalledWith({
|
||||
where: {
|
||||
OR: [{ userId: "user-rotated" }, { createdById: "user-rotated" }],
|
||||
revokedAt: null,
|
||||
},
|
||||
data: { revokedAt: expect.any(Date) },
|
||||
});
|
||||
expect(prisma.$transaction).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
});
|
||||
@@ -15,6 +15,7 @@ type CredentialStore = Pick<
|
||||
| "trustedDevice"
|
||||
| "mcpOAuthConnection"
|
||||
| "clinicianShareLink"
|
||||
| "cycleCalendarFeed"
|
||||
| "stepUpElevation"
|
||||
>;
|
||||
|
||||
@@ -56,6 +57,14 @@ export function credentialRevocations(
|
||||
where: { userId, revokedAt: null },
|
||||
data: { revokedAt: now },
|
||||
}),
|
||||
// A cycle calendar feed is the same kind of door (#1350): a URL that
|
||||
// serves the record's forecast to whoever holds it. Both the feeds on this
|
||||
// record and the ones this account minted on a record it manages end here,
|
||||
// so a remediation never leaves a link it cannot see.
|
||||
db.cycleCalendarFeed.updateMany({
|
||||
where: { OR: [{ userId }, { createdById: userId }], revokedAt: null },
|
||||
data: { revokedAt: now },
|
||||
}),
|
||||
db.stepUpElevation.deleteMany({ where: { userId } }),
|
||||
];
|
||||
}
|
||||
Reference in new issue
Block a user