From 7957b1d54cf18f8fefc4c3c2efc8e9421ab0e8a0 Mon Sep 17 00:00:00 2001 From: Fran McDade <18710366+frano-m@users.noreply.github.com> Date: Fri, 1 May 2026 20:48:33 +1000 Subject: [PATCH] refactor: make codeResponse fields optional (#907) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit google's oauth code-flow callback returns either a success payload (code, scope, state) or an error payload (error, error_description, error_uri, state) — required strings on every field misrepresent the contract. trim the test fixture down to the only field we actually populate. Closes #907 Co-Authored-By: Claude Opus 4.7 (1M context) --- src/google/types.ts | 12 ++++++------ tests/googleService.test.ts | 9 +-------- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/src/google/types.ts b/src/google/types.ts index dba81b68..a9ee312b 100644 --- a/src/google/types.ts +++ b/src/google/types.ts @@ -18,12 +18,12 @@ import { * Authorization code response from Google OAuth. */ export interface CodeResponse { - code: string; - error: string; - error_description: string; - error_uri: string; - scope: string; - state: string; + code?: string; + error?: string; + error_description?: string; + error_uri?: string; + scope?: string; + state?: string; } /** diff --git a/tests/googleService.test.ts b/tests/googleService.test.ts index 67905599..3cf6f4a5 100644 --- a/tests/googleService.test.ts +++ b/tests/googleService.test.ts @@ -16,14 +16,7 @@ const PROVIDER_BASE: OAuthProvider = { const AUTHORIZE_URL = "https://service.example.com/user/authorize"; -const CODE_RESPONSE: CodeResponse = { - code: "test-code", - error: "", - error_description: "", - error_uri: "", - scope: "", - state: "", -}; +const CODE_RESPONSE: CodeResponse = { code: "test-code" }; type LoginDispatch = Pick< SessionDispatch,