···455455456456 // Log detailed error information and store the response body text ONCE
457457 let responseText = '';
458458- let responseBody = {};
458458+ // Define responseBody with appropriate type that includes optional error fields
459459+ let responseBody: {
460460+ error?: string;
461461+ error_description?: string;
462462+ message?: string;
463463+ [key: string]: any
464464+ } = {};
459465460466 try {
461467 responseText = await response.text();
···488494 }
489495490496 // Check if this is a nonce error
491491- if (responseBody.error === 'use_dpop_nonce' ||
492492- (responseBody.error_description && responseBody.error_description.includes('nonce'))) {
497497+ if ((responseBody?.error === 'use_dpop_nonce') ||
498498+ (responseBody?.error_description && responseBody.error_description.includes('nonce'))) {
493499 console.log('[AUTH CHECK] DPoP nonce error detected, retrying with new nonce');
494500 }
495501