-
Notifications
You must be signed in to change notification settings - Fork 1
Feat(extension, client): separate extension send token environment #319
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
constantly-dev
merged 9 commits into
develop
from
feat/#315/separate-extension-send-token-environment
Mar 19, 2026
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
ed47404
feat: VITE_GOOGLE_REDIRECT_URI ํ๋๋ก ํตํฉ
constantly-dev cf4b2fd
feat: extension build dev์ prod ํ๊ฒฝ ๋ถ๋ฆฌํ๋๋ก script, turbo.json ์ค์
constantly-dev 63aa58c
feat: extension build ์์ ์ dev, prod๊ฐ name env ๊ธฐ์ค์ผ๋ก ๋๋๋๋ก ์ฑ ๋ถ๋ฆฌ ์ค์
constantly-dev f132130
feat: extension login popup ์ฐฝ ์ด๋ฆด ๋ dev, prod ํ๊ฒฝ ๋ถ๋ฆฌ๋๋๋ก ๋์ url ๋ณ์ ์ค์
constantly-dev c1e56ac
feat: extension background webUrl ์ค์ ์ ๋์ ์ผ๋ก ๋ถ๊ธฐ๋ก์ง ์ถ๊ฐ
constantly-dev d5def08
setting: update extension version to 1.0.3
constantly-dev 01f8933
fix: build script ํจํค์ง ๋งค๋์ yarn์์ pnpm์ผ๋ก ์์
constantly-dev 823c4a6
refactor: ALLOWED_ORIGINS ์๋ ๊ฒฝ์ฐ ์์ธ์ฒ๋ฆฌ ์ถ๊ฐ
constantly-dev de53079
refactor: split(,)์ ๋ฐ๋ผ [] ๋ฐฐ์ด ์์ฑ์ผ๋ก ์ธํ ์ฃ์ง ์ผ์ด์ค ์๋ฌ ๋ฐฉ์ง ๋ก์ง ์ถ๊ฐ
constantly-dev 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
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
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 |
|---|---|---|
| @@ -1,23 +1,35 @@ | ||
| import { EXTENSION_MESSAGE_TYPE } from '@pinback/contracts/extension-messages'; | ||
|
|
||
| const ALLOWED_ORIGINS = __ALLOWED_ORIGINS__; | ||
|
|
||
| if (ALLOWED_ORIGINS.length === 0) { | ||
| console.warn( | ||
| '[Pinback] ํ์ฉ๋ ๋๋ฉ์ธ(ALLOWED_ORIGINS) ์ค์ ์ด ๋น์ด ์์ต๋๋ค. ํ ํฐ ๋๊ธฐํ๊ฐ ์๋ํ์ง ์์ผ๋ .env ํ์ผ์ ํ์ธํด์ฃผ์ธ์.' | ||
| ); | ||
| } | ||
|
|
||
| window.addEventListener('message', (event) => { | ||
| if (event.source !== window) return; | ||
| if (event.data.type === EXTENSION_MESSAGE_TYPE.setToken) { | ||
|
|
||
| if (!ALLOWED_ORIGINS.includes(event.origin)) return; | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| const { type, token } = event.data; | ||
|
|
||
| if (type === EXTENSION_MESSAGE_TYPE.setToken) { | ||
| chrome.runtime.sendMessage({ | ||
| type: EXTENSION_MESSAGE_TYPE.setToken, | ||
| token: event.data.token, | ||
| token, | ||
| }); | ||
| chrome.storage.local.set({ token: event.data.token }, () => { | ||
| console.log('Token saved!'); | ||
|
|
||
| chrome.storage.local.set({ token }, () => { | ||
| console.log(`[${event.origin}] Token saved!`); | ||
| }); | ||
| } | ||
| }); | ||
|
|
||
| window.addEventListener('message', (event) => { | ||
| if (event.source !== window) return; | ||
| if (event.data.type === EXTENSION_MESSAGE_TYPE.logout) { | ||
| // ํ ํฐ ์ญ์ (๋ก๊ทธ์์) | ||
| if (type === EXTENSION_MESSAGE_TYPE.logout) { | ||
| chrome.storage.local.remove('token', () => { | ||
| console.log('Token removed!'); | ||
| console.log(`[${event.origin}] Token removed!`); | ||
| }); | ||
| } | ||
| }); | ||
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,3 @@ | ||
| /// <reference types="vite/client" /> | ||
|
|
||
| declare const __ALLOWED_ORIGINS__: string[]; |
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 |
|---|---|---|
| @@ -1,36 +1,50 @@ | ||
| // vite.config.ts | ||
| import { defineConfig } from 'vite'; | ||
| import { crx } from '@crxjs/vite-plugin'; | ||
| import svgSpritePlugin from '@pivanov/vite-plugin-svg-sprite'; | ||
| import tailwindcss from '@tailwindcss/vite'; | ||
| import react from '@vitejs/plugin-react-swc'; | ||
| import tsconfigPaths from 'vite-tsconfig-paths'; | ||
| import { resolve } from 'path'; | ||
| import { crx } from '@crxjs/vite-plugin'; | ||
| import { defineConfig, loadEnv } from 'vite'; | ||
| import tsconfigPaths from 'vite-tsconfig-paths'; | ||
| import manifest from './manifest.json'; | ||
| import svgSpritePlugin from '@pivanov/vite-plugin-svg-sprite'; | ||
|
|
||
| export default defineConfig({ | ||
| plugins: [ | ||
| react(), | ||
| tsconfigPaths({ | ||
| projects: [resolve(__dirname, './tsconfig.json')], | ||
| }), | ||
| tailwindcss(), | ||
| crx({ manifest }), | ||
| svgSpritePlugin({ | ||
| iconDirs: ['../../packages/design-system/src/icons/source'], | ||
| symbolId: 'icon-[name]', | ||
| inject: 'body-last', | ||
| }), | ||
| ], | ||
| export default defineConfig(({ mode }) => { | ||
| const env = loadEnv(mode, process.cwd()); | ||
|
|
||
| const dynamicManifest = { | ||
| ...manifest, | ||
| name: env.VITE_EXTENSION_NAME || manifest.name, | ||
| }; | ||
|
|
||
| return { | ||
| define: { | ||
| __ALLOWED_ORIGINS__: JSON.stringify( | ||
| env.VITE_ALLOWED_ORIGINS?.split(',').filter(Boolean) || [] | ||
| ), | ||
| }, | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| plugins: [ | ||
| react(), | ||
| tsconfigPaths({ | ||
| projects: [resolve(__dirname, './tsconfig.json')], | ||
| }), | ||
| tailwindcss(), | ||
| crx({ manifest: dynamicManifest }), | ||
| svgSpritePlugin({ | ||
| iconDirs: ['../../packages/design-system/src/icons/source'], | ||
| symbolId: 'icon-[name]', | ||
| inject: 'body-last', | ||
| }), | ||
| ], | ||
|
|
||
| build: { | ||
| outDir: 'dist', | ||
| copyPublicDir: true, | ||
| }, | ||
| publicDir: 'public', | ||
| build: { | ||
| outDir: 'dist', | ||
| copyPublicDir: true, | ||
| }, | ||
| publicDir: 'public', | ||
|
|
||
| server: { | ||
| port: 5175, | ||
| strictPort: true, | ||
| }, | ||
| server: { | ||
| port: 5175, | ||
| strictPort: true, | ||
| }, | ||
| }; | ||
| }); | ||
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
build๊ฐ 10 ๋ฒ์จฐ ์ค build:prod์ ๋ค๋ฅผ๊ฒ ์๋๊ฑฐ ๊ฐ์๋ฐ ์ค๋ณต๋์ด ์๋ ์ด์ ๊ฐ ์๋์?