# Migration Plan: @push.rocks/smartrequest To re-read CLAUDE.md: `cat ~/.claude/CLAUDE.md` ## Objective Migrate the Bunq HTTP client from native `fetch` to `@push.rocks/smartrequest` to leverage built-in rate limiting, better error handling, and improved maintainability. ## Tasks ### 1. Setup - [x] Install @push.rocks/smartrequest dependency using pnpm - [x] Update ts/bunq.plugins.ts to import smartrequest ### 2. Refactor BunqHttpClient - [x] Replace fetch-based makeRequest method with SmartRequest implementation - [x] Preserve all custom headers (X-Bunq-*) - [x] Maintain request signing functionality - [x] Keep response signature verification - [x] Map LIST method to GET (SmartRequest doesn't have LIST) - [x] Replace manual retry logic with built-in handle429Backoff() ### 3. Error Handling - [x] Ensure BunqApiError is still thrown for API errors - [x] Map SmartRequest errors to appropriate error messages - [x] Preserve error message format for backward compatibility ### 4. Testing - [x] Run existing tests to ensure no regression (tests passing) - [x] Verify rate limiting behavior works correctly - [x] Test signature creation and verification - [x] Ensure all HTTP methods (GET, POST, PUT, DELETE, LIST) work ### 5. Cleanup - [x] Remove unused code from the old implementation (manual retry logic removed) - [x] Update any relevant documentation or comments ## Implementation Notes ### Key Changes 1. Replace native fetch with SmartRequest fluent API 2. Use built-in handle429Backoff() instead of manual retry logic 3. Leverage SmartRequest's response methods (.json(), .text()) 4. Maintain all Bunq-specific behavior (signatures, custom headers) ### Risk Mitigation - All Bunq-specific logic remains unchanged - Public API of BunqHttpClient stays the same - Error handling maintains same format