diff --git a/src/platforms/slack/ensure-auth.ts b/src/platforms/slack/ensure-auth.ts index f389f7e..1bc398d 100644 --- a/src/platforms/slack/ensure-auth.ts +++ b/src/platforms/slack/ensure-auth.ts @@ -27,7 +27,9 @@ export async function ensureSlackAuth(): Promise { await credManager.setCurrentWorkspace(validWorkspaces[0].workspace_id) } } catch (error) { - if ((error as NodeJS.ErrnoException).code === 'EBUSY' || (error as Error).message.includes('locking the cookie')) { + const code = typeof error === 'object' && error !== null ? (error as NodeJS.ErrnoException).code : undefined + const message = error instanceof Error ? error.message : String(error) + if (code === 'EBUSY' || message.includes('locking the cookie')) { throw error } // Silently ignore other extraction errors (e.g. Slack not installed) diff --git a/src/platforms/slack/token-extractor.test.ts b/src/platforms/slack/token-extractor.test.ts index 190ba5b..24e5d70 100644 --- a/src/platforms/slack/token-extractor.test.ts +++ b/src/platforms/slack/token-extractor.test.ts @@ -153,10 +153,12 @@ describe('TokenExtractor Windows DPAPI', () => { }) // when — then - const extractor = new TokenExtractor('darwin', slackDir) - await expect(extractor.extract()).rejects.toThrow('Quit the Slack app completely and try again') - - copyFileSyncSpy.mockRestore() + try { + const extractor = new TokenExtractor('darwin', slackDir) + await expect(extractor.extract()).rejects.toThrow('Quit the Slack app completely and try again') + } finally { + copyFileSyncSpy.mockRestore() + } }) test('extract decrypts Windows v10 cookies end-to-end with mocked DPAPI', async () => {