Skip to content

Commit 9594e92

Browse files
committed
fix: validate user token in setUserToken method
1 parent 568389e commit 9594e92

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/lib/api/oss-insight-client.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ class OSSInsightClient {
1414
private githubBaseUrl = 'https://api.github.com'
1515
private githubToken = process.env.NEXT_PUBLIC_GITHUB_TOKEN || ''
1616

17-
// Allow setting user token dynamically
18-
setUserToken(token: string) {
17+
setUserToken(token: string) {
18+
if (!token || typeof token !== 'string' || token.trim().length === 0) {
19+
throw new Error('Invalid GitHub token: must be a non-empty string')
20+
}
1921
this.githubToken = token
2022
}
2123

0 commit comments

Comments
 (0)