feat: add interceptor#4
Conversation
WalkthroughThis pull request introduces HTTP request interception capabilities to the Enkryptify SDK. It adds a new Estimated code review effort🎯 4 (Complex) | ⏱️ ~90 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/enkryptify.ts`:
- Around line 134-135: The code reads interceptorConfig.rules.length without
validating rules' shape; update the guard so you only access .length when rules
is an array (e.g., use Array.isArray(interceptorConfig.rules) or coerce to an
array) and handle bad shapes by either treating rules as empty or throwing a
controlled SDK error; change the condition around interceptorConfig (the block
that checks interceptorConfig.enabled and currently reads
interceptorConfig.rules.length) to validate interceptorConfig.rules before using
.length and keep the rest of the block (including usage of this.#proxy._ctx)
unchanged.
In `@src/internal/template.ts`:
- Around line 59-67: mergeHeaders currently strips hop-by-hop headers from input
but then applies overrides which can reintroduce them; update the overrides loop
in mergeHeaders to ignore any override whose lower-cased key is in the
hop-by-hop set (e.g. HOP_BY_HOP_HEADERS) so that overrides cannot add those
headers back, and still allow deletes (value === undefined) to remove headers
but never re-add a hop-by-hop header to out.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 9c8c514c-1f63-494f-9fb8-19004e7d62da
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (9)
package.jsonsrc/enkryptify.tssrc/errors.tssrc/index.tssrc/interceptor.tssrc/internal/template.tssrc/proxy.tssrc/types.tstests/interceptor.test.ts

Summary by CodeRabbit
Release Notes
New Features
Chores
Tests