Skip to content

Commit 2db9c0e

Browse files
authored
fix: GitHub token stored in client-side localStorage for API calls — tok... (JhaSourav07#2022)
## Description Fixes JhaSourav07#2017 — GitHub token stored in client-side localStorage for API calls — token can be exfiltrated via XSS. Add server-only import guard to ensure GITHUB_PAT / GITHUB_TOKEN are never bundled into browser JavaScript. ## Pillar - [ ] 🎨 Pillar 1 — New Theme Design - [ ] 📐 Pillar 2 — Geometric SVG Improvement - [ ] 🕐 Pillar 3 — Timezone Logic Optimization - [x] 🛠️ Other (Bug fix, refactoring, docs) ## Visual Preview _This is a logic/security fix — no visual changes expected._ ## Checklist before requesting a review: - [ ] I have read the `CONTRIBUTING.md` file. - [ ] I have tested these changes locally. - [ ] I have run `npm run format` and `npm run lint` locally and resolved all errors. - [ ] I have run `npm run test` and all tests pass locally. - [ ] I have run `npm run test:coverage` and branch coverage is at or above 70%. - [ ] My commits follow the Conventional Commits format. - [ ] I have started the repo. - [ ] I have made sure that i have only one commit to merge in this PR. - [ ] The SVG output matches the CommitPulse "premium quality" aesthetic standard. ## Related Issue Closes JhaSourav07#2017
2 parents 3599231 + 3f0c1ff commit 2db9c0e

4 files changed

Lines changed: 12 additions & 0 deletions

File tree

lib/github.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ import {
2424
} from './github';
2525
import type { ContributionCalendar } from '../types';
2626

27+
vi.mock('server-only', () => ({}));
28+
2729
const mockCalendar: ContributionCalendar = {
2830
totalContributions: 42,
2931
weeks: [

lib/github.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import { DistributedCache } from '@/lib/cache';
1212
import { LANGUAGE_COLORS } from '@/lib/svg/languageColors';
1313
import { CONTRIBUTION_MILESTONES, STREAK_MILESTONES } from './svg/constants';
1414

15+
import 'server-only';
16+
1517
interface GitHubRepo {
1618
name: string;
1719
stargazers_count: number;

package-lock.json

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
"react-force-graph-2d": "^1.29.1",
4343
"react-hot-toast": "^2.6.0",
4444
"react-icons": "^5.6.0",
45+
"server-only": "^0.0.1",
4546
"sonner": "^2.0.7",
4647
"zod": "^4.4.3"
4748
},

0 commit comments

Comments
 (0)