Skip to content

Commit 3f91f4d

Browse files
authored
feat: Implement Request Interceptor Plugin (#14)
## Summary Implements Request Interceptor Plugin wrapping Chrome's `declarativeNetRequest` API. **Closes #3** ## What's Changed ### Request Interceptor Plugin - `enable()` - Apply auth rules as Chrome rules - `disable()` - Remove all rules - `updateRules()` - Refresh from storage - `getRuleCount()` / `isAtLimit()` - Rule management - Auto-enables on SDK ready - Auto-updates when storage changes - Event emission for observability ### Design - `xmlhttprequest` resource type only (API calls) - Rule IDs = array index + 1 (simple, predictable) - `set` operation (replaces existing auth header) - All rules priority 1 - Rejects >300 rules with clear error ## Dependencies - Chrome Storage Plugin (#1) - Pattern Matcher Plugin (#2) - Chrome's `declarativeNetRequest` API ## Testing - ✅ Linter: No errors (except expected `any` in SDK Kit plugin signature) - ✅ TypeScript: Compiles cleanly - ⏭️ Manual testing: Will test in background worker (Issue #4) ## Next Steps After merge: - Issue #4: Background Service Worker (wire all 3 plugins together!) - Then test the full extension!
1 parent 3ef059e commit 3f91f4d

File tree

13 files changed

+4069
-31
lines changed

13 files changed

+4069
-31
lines changed

.husky/commit-msg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
pnpm exec commitlint --edit "$1"
2+

.husky/pre-commit

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Get staged files
2+
files=$(git diff --cached --name-only --diff-filter=ACMR "*.ts" "*.tsx" "*.js" "*.jsx" | xargs)
3+
4+
if [ -n "$files" ]; then
5+
echo "Running Biome on staged files: $files"
6+
pnpm lint-staged $files
7+
git add $files
8+
fi
9+
10+
# Run TypeScript type check
11+
pnpm type-check

biome.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,3 @@
3838
}
3939
}
4040
}
41-

commitlint.config.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export default {
2+
extends: ['@commitlint/config-conventional'],
3+
rules: {
4+
'body-max-line-length': [2, 'always', 100],
5+
'subject-case': [2, 'never', ['start-case', 'pascal-case', 'upper-case']],
6+
},
7+
};

package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
"type-check": "tsc --noEmit",
1111
"lint": "biome check .",
1212
"lint:fix": "biome check --write .",
13-
"format": "biome format --write ."
13+
"format": "biome format --write .",
14+
"prepare": "husky",
15+
"lint-staged": "biome check --write --no-errors-on-unmatched"
1416
},
1517
"keywords": [
1618
"chrome-extension",
@@ -29,11 +31,14 @@
2931
},
3032
"devDependencies": {
3133
"@biomejs/biome": "^1.9.4",
34+
"@commitlint/cli": "^20.2.0",
35+
"@commitlint/config-conventional": "^20.2.0",
3236
"@types/chrome": "^0.0.278",
3337
"@types/react": "^19.0.2",
3438
"@types/react-dom": "^19.0.2",
3539
"@vitejs/plugin-react": "^4.3.4",
3640
"autoprefixer": "^10.4.20",
41+
"husky": "^9.1.7",
3742
"postcss": "^8.4.49",
3843
"tailwindcss": "^3.4.17",
3944
"typescript": "^5.7.3",

0 commit comments

Comments
 (0)