# bunq API Client Implementation Plan cat /home/philkunz/.claude/CLAUDE.md ## Phase 1: Remove External Dependencies & Setup Core Infrastructure - [x] Remove @bunq-community/bunq-js-client dependency from package.json - [x] Remove JSONFileStore and bunqCommunityClient from bunq.plugins.ts - [x] Create bunq.classes.apicontext.ts for API context management - [x] Create bunq.classes.httpclient.ts for HTTP request handling - [x] Create bunq.classes.crypto.ts for cryptographic operations - [x] Create bunq.classes.session.ts for session management - [x] Create bunq.interfaces.ts for shared interfaces and types ## Phase 2: Implement Core Authentication Flow - [x] Implement RSA key pair generation in crypto class - [x] Implement installation endpoint (`POST /v1/installation`) - [x] Implement device registration (`POST /v1/device-server`) - [x] Implement session creation (`POST /v1/session-server`) - [x] Implement request signing mechanism - [x] Implement response verification - [x] Add session token refresh logic ## Phase 3: Update Existing Classes - [x] Refactor BunqAccount class to use new HTTP client - [x] Update BunqMonetaryAccount to work with new infrastructure - [x] Update BunqTransaction to work with new infrastructure - [x] Add proper TypeScript interfaces for all API responses - [x] Implement error handling with bunq-specific error types ## Phase 4: Implement Additional API Resources - [x] Create bunq.classes.user.ts for user management - [x] Create bunq.classes.payment.ts for payment operations - [x] Create bunq.classes.card.ts for card management - [x] Create bunq.classes.request.ts for payment requests - [x] Create bunq.classes.schedule.ts for scheduled payments - [x] Create bunq.classes.draft.ts for draft payments - [x] Create bunq.classes.attachment.ts for file handling - [x] Create bunq.classes.export.ts for statement exports - [x] Create bunq.classes.notification.ts for notifications - [x] Create bunq.classes.webhook.ts for webhook management ## Phase 5: Enhanced Features - [x] Implement pagination support for all list endpoints - [x] Add rate limiting compliance - [x] Implement retry logic with exponential backoff - [x] Add request/response logging capabilities - [x] Implement webhook signature verification - [x] Add OAuth flow support for third-party apps ## Phase 6: Testing & Documentation - [ ] Write unit tests for crypto operations - [ ] Write unit tests for HTTP client - [ ] Write unit tests for all API classes - [ ] Create integration tests using sandbox environment - [x] Update main README.md with usage examples - [x] Add JSDoc comments to all public methods - [x] Create example scripts for common use cases ## Phase 7: Cleanup & Optimization - [x] Remove all references to old bunq-community client - [x] Optimize bundle size - [x] Ensure all TypeScript types are properly exported - [x] Run build and verify all tests pass - [x] Update package version