-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
88 changed files
with
804 additions
and
584 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
dist | ||
node_modules | ||
src/base/ui | ||
src/base/components |
This file contains 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 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 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 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 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 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 |
---|---|---|
@@ -1,12 +1,11 @@ | ||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; | ||
import { Loading } from '~/contexts/loading'; | ||
import UserSettingPage from '~/pages/user-setting'; | ||
|
||
const queryClient = new QueryClient(); | ||
|
||
export default function App() { | ||
return ( | ||
<QueryClientProvider client={queryClient}> | ||
<> | ||
<UserSettingPage /> | ||
</QueryClientProvider> | ||
<Loading /> | ||
</> | ||
); | ||
} |
This file contains 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 |
---|---|---|
@@ -1,12 +1,33 @@ | ||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; | ||
import { createRoot } from 'react-dom/client'; | ||
import App from './App'; | ||
import '../index.css'; | ||
import { accessTokenStorage } from '~/features/auth'; | ||
import { createAuthProvider } from '~/features/auth/context'; | ||
import App from './App'; | ||
|
||
const queryClient = new QueryClient(); | ||
|
||
export function runApp() { | ||
const $app = document.getElementById('app'); | ||
if (!$app) { | ||
throw new Error('No element with "id=app"'); | ||
} | ||
const root = createRoot($app); | ||
root.render(<App />); | ||
|
||
accessTokenStorage.retrieve().then((accessToken) => { | ||
const authInfo = { | ||
isLoggedIn: accessToken !== null, | ||
accessToken: accessToken || ('' as AccessToken), | ||
}; | ||
|
||
const AuthProvider = createAuthProvider(authInfo); | ||
|
||
root.render( | ||
<QueryClientProvider client={queryClient}> | ||
<AuthProvider> | ||
<App /> | ||
</AuthProvider> | ||
</QueryClientProvider>, | ||
); | ||
}); | ||
} |
This file contains 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 |
---|---|---|
|
@@ -2,8 +2,8 @@ | |
"manifest_version": 3, | ||
"name": "Code-Vault", | ||
"description": "Code-Vault에서 제공하는 크롬 확장도구입니다.", | ||
"version": "1.0.0.1", | ||
"version_name": "1.0.0-beta.1", | ||
"version": "1.0.0.2", | ||
"version_name": "1.0.0-beta.2", | ||
"author": "[email protected]", | ||
"homepage_url": "https://github.com/woong-jae/code-vault", | ||
"action": {}, | ||
|
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
src/base/ui/Avatar/index.tsx → src/base/components/Avatar/index.tsx
This file contains 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
File renamed without changes.
File renamed without changes.
This file contains 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,24 @@ | ||
import * as React from 'react'; | ||
import { cn } from '../utils'; | ||
|
||
export interface InputProps | ||
extends React.InputHTMLAttributes<HTMLInputElement> {} | ||
|
||
const Input = React.forwardRef<HTMLInputElement, InputProps>( | ||
({ className, type, ...props }, ref) => { | ||
return ( | ||
<input | ||
type={type} | ||
className={cn( | ||
'flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50', | ||
className, | ||
)} | ||
ref={ref} | ||
{...props} | ||
/> | ||
); | ||
}, | ||
); | ||
Input.displayName = 'Input'; | ||
|
||
export { Input }; |
This file contains 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
File renamed without changes.
This file contains 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
File renamed without changes.
File renamed without changes.
This file contains 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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
const SETTING_PAGE = `chrome-extension://${chrome.runtime.id}/setting.html`; | ||
|
||
export default { | ||
export const url = { | ||
SETTING_PAGE, | ||
GITHUB_OAUTH_CODE: `https://github.com/login/oauth/authorize?client_id=e1f73f73ee1f2865bcd5&scope=user,repo&redirect_uri=${SETTING_PAGE}`, | ||
}; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains 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 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
File renamed without changes.
This file contains 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,47 @@ | ||
export function createStorageKey(key: string) { | ||
return `code-vault:${key}`; | ||
} | ||
|
||
export function defineBrowserStorage<T>({ | ||
storage, | ||
key, | ||
}: { | ||
storage: Storage; | ||
key: string; | ||
}) { | ||
const enrichedKey = createStorageKey(key); | ||
return { | ||
persist(data: T) { | ||
storage.setItem(enrichedKey, JSON.stringify(data)); | ||
}, | ||
retrieve() { | ||
return storage.getItem(enrichedKey); | ||
}, | ||
clear() { | ||
storage.removeItem(enrichedKey); | ||
}, | ||
}; | ||
} | ||
|
||
export function defineChromeExtensionStorage<T>({ | ||
storage, | ||
key, | ||
}: { | ||
storage: chrome.storage.StorageArea; | ||
key: string; | ||
}) { | ||
const enrichedKey = createStorageKey(key); | ||
return { | ||
async persist(data: T) { | ||
await storage.set({ [enrichedKey]: JSON.stringify(data) }); | ||
}, | ||
async retrieve(): Promise<T | null> { | ||
const res = await storage.get(enrichedKey); | ||
const value = res?.[enrichedKey]; | ||
return value === undefined || value === null ? null : JSON.parse(value); | ||
}, | ||
async clear() { | ||
await storage.remove(enrichedKey); | ||
}, | ||
}; | ||
} |
This file contains 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,22 @@ | ||
import { ReloadIcon } from '@radix-ui/react-icons'; | ||
import { useIsMutating } from '@tanstack/react-query'; | ||
import { createPortal } from 'react-dom'; | ||
|
||
export function Loading() { | ||
const isMutating = useIsMutating(); | ||
|
||
return ( | ||
<div> | ||
{isMutating && | ||
createPortal( | ||
<div className="fixed inset-0 z-50 flex items-center justify-center"> | ||
<div className="flex flex-col items-center space-y-2 pb-3"> | ||
<ReloadIcon className="h-5 w-5 animate-spin" /> | ||
<p className="text-muted-foreground">잠시만 기다려주세요</p> | ||
</div> | ||
</div>, | ||
document.body, | ||
)} | ||
</div> | ||
); | ||
} |
This file contains 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,33 @@ | ||
import { Github } from '@base/services/github'; | ||
import { defineChromeExtensionStorage } from '@base/utils/storage'; | ||
|
||
const accessTokenStorage = defineChromeExtensionStorage<AccessToken>({ | ||
storage: chrome.storage.local, | ||
key: 'access-token', | ||
}); | ||
|
||
async function getAccessTokenFromSearchParams() { | ||
const code = new URLSearchParams(location.search).get('code'); | ||
if (!code) return null; | ||
|
||
history.replaceState('', '', location.pathname); | ||
|
||
const accessToken = await Github.getAccessToken(code); | ||
return accessToken as AccessToken; | ||
} | ||
|
||
async function login() { | ||
const token = await getAccessTokenFromSearchParams(); | ||
if (!token) return undefined; | ||
|
||
await accessTokenStorage.persist(token); | ||
|
||
return token; | ||
} | ||
|
||
async function logout() { | ||
await accessTokenStorage.clear(); | ||
return true; | ||
} | ||
|
||
export { login, logout, accessTokenStorage }; |
Oops, something went wrong.