fix(oura): audit credential deletes and trim integration vestiges

Deleting a user's stored Oura BYO credentials drops a live connection (a
token minted against the deleted app is orphaned), but the credentials
DELETE route skipped the auditLog + markDisconnected the disconnect route
performs, leaving the integration ledger parked at its last state with no
audit trail. Mirror the disconnect route when a token was present.

Drop two unused classifier type aliases and unexport the internal
invalid-grant helper, and refresh the stale 'full OAuth from env' headers on
the connect route and the env-credentials helper to the v1.17.1 DB-first
framing. Add the missing route tests for the BYO surface this release
touched: credentials GET/PUT/DELETE (422 reject, encrypt-on-write, the
audit/ledger branch) and the callback CSRF / cross-user / nocreds / success
paths.
This commit is contained in:
Marc-André Bombeck committed 2026-06-15 00:09:56 +02:00
1 parent c5e91c4cb6
commit a0662d1b20
5 files changed
+263 -10

No files matched your search

+5 -9
View File
@@ -19,20 +19,16 @@ import {
type IntegrationClassification,
} from "@/lib/integrations/http-status-classifier";
export type OuraClassification = IntegrationClassification;
export type ClassifiedOuraResponse = ClassifiedHttpResponse;
export function classifyOuraResponse(
httpStatus: number,
): ClassifiedOuraResponse {
): ClassifiedHttpResponse {
return classifyHttpStatus(httpStatus);
}
export class OuraApiError extends IntegrationApiError {
constructor(opts: {
verb: string;
classification: OuraClassification;
classification: IntegrationClassification;
httpStatus: number | undefined;
reason: string;
upstreamError?: string;
@@ -46,13 +42,13 @@ export class OuraApiError extends IntegrationApiError {
* True when a caught error is an OAuth `invalid_grant` on the token endpoint —
* the canonical revoked-refresh-token signal. Lifts a 400 carrying
* `invalid_grant` from `persistent` to `reauth_required` so the connection
* surfaces the reconnect prompt.
* surfaces the reconnect prompt. Internal to `classifyOuraError`.
*/
export function isInvalidGrant(err: unknown): boolean {
function isInvalidGrant(err: unknown): boolean {
return isOAuthInvalidGrant(err, "Oura");
}
export function classifyOuraError(err: unknown): OuraClassification {
export function classifyOuraError(err: unknown): IntegrationClassification {
if (isInvalidGrant(err)) return "reauth_required";
return classifyIntegrationError(err, "Oura");
}