-
-
Notifications
You must be signed in to change notification settings - Fork 0
fix: critical security issue, where PAT was exposed #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 9 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
bcf6f2c
fix: critical security vulnerabilities
webbertakken 65d682d
fix: security issue
webbertakken da03e0a
feat: implement split architecture for security
webbertakken 2158ace
feat: accept personalAccessToken from options for cleaner API
webbertakken 7feb53a
feat: use webpack DefinePlugin to exclude sensitive data from client …
webbertakken c853a12
revert: use environment variable approach for security
webbertakken a34113b
chore: fail if env variable is not provided
webbertakken ea58d37
feat: add proper description for people that upgrade
webbertakken eab1509
docs: update README for v4.0.0 security changes
webbertakken c1ac143
chore: formatting
webbertakken File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import React, { createContext, useContext, ReactNode } from 'react' | ||
import { GistsClient, RuntimeConfig } from './index' | ||
|
||
interface GistsContextType { | ||
client: GistsClient | ||
config: RuntimeConfig | ||
} | ||
|
||
const GistsContext = createContext<GistsContextType | undefined>(undefined) | ||
|
||
interface GistsProviderProps { | ||
children: ReactNode | ||
config: RuntimeConfig | ||
} | ||
|
||
export function GistsProvider({ children, config }: GistsProviderProps) { | ||
const client = new GistsClient(config) | ||
|
||
return ( | ||
<GistsContext.Provider value={{ client, config }}> | ||
{children} | ||
</GistsContext.Provider> | ||
) | ||
} | ||
|
||
export function useGists() { | ||
const context = useContext(GistsContext) | ||
if (context === undefined) { | ||
throw new Error('useGists must be used within a GistsProvider') | ||
} | ||
return context | ||
} | ||
|
||
export function useGistsClient() { | ||
const { client } = useGists() | ||
return client | ||
} | ||
|
||
export function useGistsConfig() { | ||
const { config } = useGists() | ||
return config | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/** | ||
* Client-side plugin component | ||
* This runs in the browser and has access to runtime configuration only | ||
*/ | ||
|
||
interface RuntimeConfig { | ||
enabled: boolean | ||
verbose: boolean | ||
gistListPageComponent: string | ||
gistPageComponent: string | ||
} | ||
|
||
class GistsClient { | ||
private config: RuntimeConfig | ||
|
||
constructor(config: RuntimeConfig) { | ||
this.config = config | ||
} | ||
|
||
// Client-side utility methods | ||
isEnabled(): boolean { | ||
return this.config.enabled | ||
} | ||
|
||
isVerbose(): boolean { | ||
return this.config.verbose | ||
} | ||
|
||
getGistListComponent(): string { | ||
return this.config.gistListPageComponent | ||
} | ||
|
||
getGistPageComponent(): string { | ||
return this.config.gistPageComponent | ||
} | ||
|
||
// Client-side analytics or tracking | ||
trackGistView(gistId: string): void { | ||
if (this.config.verbose) { | ||
console.log(`Viewing gist: ${gistId}`) | ||
} | ||
|
||
// Could send analytics events here | ||
// Note: No access to GitHub API tokens - this is client-side only | ||
} | ||
|
||
// Client-side URL helpers | ||
getGistUrl(gistId: string): string { | ||
return `/gists/${gistId}` | ||
} | ||
|
||
getGistListUrl(): string { | ||
return '/gists' | ||
} | ||
|
||
// Client-side search/filtering (if needed) | ||
filterGists(gists: any[], searchTerm: string): any[] { | ||
if (!searchTerm) return gists | ||
|
||
return gists.filter(gist => | ||
gist.description?.toLowerCase().includes(searchTerm.toLowerCase()) || | ||
Object.values(gist.files || {}).some((file: any) => | ||
file.filename?.toLowerCase().includes(searchTerm.toLowerCase()) | ||
) | ||
) | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Replace Using - filterGists(gists: any[], searchTerm: string): any[] {
+ filterGists(gists: Gist[], searchTerm: string): Gist[] { You'll need to import the import type { Gist } from '../types' 🤖 Prompt for AI Agents
|
||
} | ||
|
||
// Export factory function | ||
export function createGistsClient(config: RuntimeConfig): GistsClient { | ||
return new GistsClient(config) | ||
} | ||
|
||
// Export types for theme components | ||
export type { RuntimeConfig } | ||
export { GistsClient } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.