Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ NEXT_PUBLIC_EXTENSION_API_BASE_URL=
# Example: https://linkiving.com
NEXT_PUBLIC_EXTENSION_AUTH_BASE_URL=

# Website opened by the login button. Defaults to https://linkiving.com.
# For local review, set this and the auth URL above to http://localhost:3000.
NEXT_PUBLIC_EXTENSION_APP_URL=

# Optional local-development fallback used only when NODE_ENV is not production.
# Never use a privileged or long-lived secret; NEXT_PUBLIC_* is included in client bundles.
NEXT_PUBLIC_EXTENSION_API_TOKEN=
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,25 @@

### 추가

- 미로그인·로그아웃·세션 만료 상태를 구분하는 로그인 안내 화면과 링카이빙 웹사이트로 이동하는 로그인 버튼을 추가했습니다.
- 로그인 상태 확인 중에는 로딩 화면을, 서버·네트워크 오류에는 다시 시도할 수 있는 안내를 표시합니다.
- 익스텐션 링크 저장 요청에 설치별 GA client ID와 `extension` source를 전달합니다.
- 핵심 URL·인증·분석 로직과 확장 빌드 산출물 검증을 CI 및 릴리스에 추가했습니다.
- package, manifest, 릴리스 태그의 버전을 동기화하고 검증하는 도구를 추가했습니다.

### 변경

- 인증 확인 후 링크 입력 폼을 표시하며, 로그인 쿠키 변경이나 확장 프로그램 복귀 시 인증 상태를 다시 확인합니다. 사용 중 세션이 만료되면 로그인 안내로 전환합니다.
- 로그인 안내와 링크 추가 패널 높이를 내용에 맞게 조절하고, 입력 영역의 여백과 메모 표시 높이를 줄였습니다.
- 링크 추가 화면의 상단은 홈 아이콘과 `내 홈으로 이동`으로 표시하고, 로그인 안내에서는 `링카이빙 바로가기`를 표시합니다.
- Linkiving 운영 도메인과 사용자 동작에 필요한 범위로 확장 권한과 웹 접근 범위를 축소했습니다.
- 작은 viewport에서도 사용할 수 있도록 오버레이 레이아웃과 토스트 접근성을 개선했습니다.

### 보안

- 정적 API 토큰 fallback은 로컬 개발에서만 허용하며 프로덕션 빌드에 설정되면 실패합니다.
- 오버레이와 토스트 메시지의 발신자, origin 및 iframe URL을 검증합니다.
- 로컬·별도 인증 사이트를 지정한 경우 해당 사이트의 로그인 쿠키만 사용하도록 제한했습니다.

## [0.1.0] - 2026-05-06

Expand Down
12 changes: 7 additions & 5 deletions extension/linkiving-overlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
const LINKIVING_OVERLAY_ID = `linkiving-extension-overlay-root-${chrome.runtime.id}`;
const LINKIVING_OVERLAY_MESSAGE_TYPE = 'LINKIVING_TOGGLE_OVERLAY';
const LINKIVING_CLOSE_MESSAGE_TYPE = 'LINKIVING_CLOSE_OVERLAY';
const LINKIVING_RESIZE_MESSAGE_TYPE = 'LINKIVING_RESIZE_OVERLAY';
const EXTENSION_ORIGIN = new URL(chrome.runtime.getURL('/')).origin;
let activeIframe = null;

Expand Down Expand Up @@ -73,12 +74,13 @@
});

window.addEventListener('message', event => {
if (
event.origin === EXTENSION_ORIGIN &&
event.source === activeIframe?.contentWindow &&
event.data?.type === LINKIVING_CLOSE_MESSAGE_TYPE
) {
if (event.origin !== EXTENSION_ORIGIN || event.source !== activeIframe?.contentWindow) return;
if (event.data?.type === LINKIVING_CLOSE_MESSAGE_TYPE) {
removeLinkivingOverlay();
} else if (event.data?.type === LINKIVING_RESIZE_MESSAGE_TYPE && Number.isFinite(event.data.height)) {
const height = Math.min(660, Math.max(160, Math.ceil(event.data.height)));
const root = document.getElementById(LINKIVING_OVERLAY_ID);
if (root) root.style.height = `min(${height}px, calc(100vh - 8px))`;
}
});
}
Expand Down
1 change: 0 additions & 1 deletion src/app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
html,
body {
margin: 0;
min-width: 400px;
background: var(--color-gray50);
}

Expand Down
37 changes: 34 additions & 3 deletions src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,43 @@
'use client';

import AddLinkPanel from '@/components/layout/SideNavigation/components/MenuSection/AddLink';
import ExtensionAuthPanel from '@/components/wrappers/ExtensionAuthPanel';
import ExtensionHeader from '@/components/wrappers/ExtensionHeader';
import { useExtensionAuth } from '@/hooks/useExtensionAuth';
import { useEffect, useRef } from 'react';

export default function Page() {
const { status, refresh } = useExtensionAuth();
const panelRef = useRef<HTMLDivElement>(null);
const authenticated = status === 'authenticated';

useEffect(() => {
const panel = panelRef.current;
if (!panel || window.parent === window) return;
const resize = () => {
window.parent.postMessage({
type: 'LINKIVING_RESIZE_OVERLAY',
height: Math.ceil(panel.getBoundingClientRect().height),
}, '*');
};
const observer = new ResizeObserver(resize);
observer.observe(panel);
resize();
return () => observer.disconnect();
}, []);

return (
<main className="min-h-screen bg-transparent">
<div className="mx-auto flex h-[min(42.5rem,100dvh)] w-full max-w-[40rem] flex-col overflow-hidden rounded-2xl border border-gray100 bg-gray50 shadow-lg">
<AddLinkPanel />
<main className="max-h-dvh overflow-y-auto bg-transparent">
<div
ref={panelRef}
className="mx-auto flex w-full max-w-[40rem] flex-col rounded-2xl border border-gray100 bg-gray50"
>
<ExtensionHeader authenticated={authenticated} />
{authenticated ? (
<AddLinkPanel />
) : (
<ExtensionAuthPanel status={status} onRetry={() => void refresh()} />
)}
</div>
</main>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ export default function LinkThumbnailTitleSection({
label = '링크 정보',
}: Props) {
return (
<section className="border-gray100 border-b px-6 py-6">
<Label textSize="sm" className="mb-3 block text-gray900">
<section className="border-gray100 border-b px-6 py-4">
<Label textSize="sm" className="mb-2 block text-gray900">
{label}
</Label>
<div className="grid grid-cols-[10rem_minmax(0,1fr)] gap-2">
<div className="grid grid-cols-[minmax(5rem,1fr)_minmax(0,3fr)] gap-2">
<div
className={`border-gray100 relative h-[5rem] overflow-hidden rounded-lg border bg-white ${
shouldDisableDetails ? 'opacity-60' : ''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ import { useQueryClient } from '@tanstack/react-query';

import { updateLink } from '@/apis/linkApi';
import Button from '@/components/basics/Button/Button';
import SVGIcon from '@/components/Icons/SVGIcon';
import Label from '@/components/basics/Label/Label';
import TextArea from '@/components/basics/TextArea/TextArea';
import { usePostLinks } from '@/hooks/usePostLinks';
import { appUrl, closeExtensionPanel } from '@/lib/chrome/navigation';
import { FetchError } from '@/lib/api/errors';
import { showCurrentPageToast } from '@/lib/chrome/pageToast';
import { MAX_MEMO_LENGTH } from '@/lib/constants/link';
import { getUnsupportedTabReason, normalizeHttpUrl } from '@/lib/url';
Expand All @@ -22,13 +23,6 @@ import { useCreateLinkError } from './hooks/useCreateLinkError';
import { useDuplicateCheck } from './hooks/useDuplicateCheck';
import LinkThumbnailTitleSection from './LinkThumbnailTitleSection';

const DEFAULT_APP_URL = 'https://linkiving.com';
const APP_BASE_URL = process.env.NEXT_PUBLIC_EXTENSION_APP_URL ?? DEFAULT_APP_URL;

function appUrl(path = '') {
return `${APP_BASE_URL.replace(/\/$/, '')}${path}`;
}

function getPopupSourceTab() {
if (typeof window === 'undefined') {
return { sourceTabUrl: null, sourceTabId: null };
Expand All @@ -45,19 +39,6 @@ function getPopupSourceTab() {
};
}

function closeExtensionPanel() {
if (typeof window === 'undefined') {
return;
}

if (window.parent && window.parent !== window) {
window.parent.postMessage({ type: 'LINKIVING_CLOSE_OVERLAY' }, '*');
return;
}

window.close();
}

function getHttpTabUrl(tab: chrome.tabs.Tab | undefined) {
const tabUrl = tab?.url?.trim();
if (!tabUrl || getUnsupportedTabReason(tabUrl)) {
Expand Down Expand Up @@ -314,7 +295,8 @@ export default function AddLinkPanel() {
});
await qc.invalidateQueries({ queryKey: ['links'], exact: false });
await handleSaveSuccess('링크가 저장되었습니다. 요약 생성을 시작합니다.');
} catch {
} catch (error) {
if (error instanceof FetchError && error.status === 401) return;
showToast({
message: '링크 덮어쓰기에 실패했습니다. 다시 시도해 주세요.',
variant: 'error',
Expand Down Expand Up @@ -352,44 +334,18 @@ export default function AddLinkPanel() {
});
};

const handleOpenHome = () => {
window.open(appUrl(), '_blank', 'noopener,noreferrer');
};

const handleClose = () => {
closeExtensionPanel();
};

return (
<div className="flex flex-col overflow-hidden bg-gray50">
<header className="border-gray100 flex h-16 items-center justify-between border-b px-6">
<button
type="button"
className="font-label-sm text-gray500 flex items-center gap-2"
onClick={handleOpenHome}
>
<SVGIcon icon="IC_Home" size="xxs" aria-hidden />
<span>내 홈으로 이동</span>
</button>
<button
type="button"
className="text-gray500 hover:text-gray800 flex h-10 w-10 items-center justify-center rounded-lg"
aria-label="닫기"
onClick={handleClose}
>
<SVGIcon icon="IC_Close" size="xs" aria-hidden />
</button>
</header>
<div className="flex shrink-0 flex-col bg-gray50">
<form
onSubmit={handleSubmit(onSubmit, onInvalidSubmit)}
className={`flex flex-col ${hasSubmitError ? 'border-red500' : 'border-transparent'}`}
>
{isDuplicate ? (
<DuplicateBanner />
) : (
<section className="border-gray100 border-b px-6 py-7">
<h1 className="font-title-md mb-7 text-[1.375rem] text-gray900">새 링크 추가</h1>
<div className="flex flex-col gap-3">
<section className="border-gray100 border-b px-6 py-4">
<h1 className="font-title-md mb-4 text-[1.375rem] text-gray900">새 링크 추가</h1>
<div className="flex flex-col gap-2">
<Label htmlFor="url-input" textSize="sm" className="text-gray900">
링크 주소
</Label>
Expand Down Expand Up @@ -438,8 +394,8 @@ export default function AddLinkPanel() {
label={isDuplicate ? '기존 링크 정보' : '링크 정보'}
/>

<section className="px-6 py-6">
<Label htmlFor="memo-input" textSize="sm" className="mb-3 block text-gray900">
<section className="px-6 py-4">
<Label htmlFor="memo-input" textSize="sm" className="mb-2 block text-gray900">
메모
</Label>
<Controller
Expand All @@ -450,19 +406,20 @@ export default function AddLinkPanel() {
{...field}
id="memo-input"
placeholder="메모를 입력해 주세요."
heightLines={3}
heightLines={2}
maxHeightLines={2}
maxLength={MAX_MEMO_LENGTH}
isLoading={displayMetaLoading && isValidUrl}
disabled={displayShouldDisableDetails}
value={field.value ?? ''}
onChange={e => field.onChange(e)}
className="border-gray100 min-h-[5rem] bg-white"
className="border-gray100 min-h-[4rem] bg-white"
/>
)}
/>
</section>

<div className={`px-6 pb-6 ${isDuplicate && duplicateLinkId ? 'grid grid-cols-2 gap-2' : ''}`}>
<div className={`px-6 pb-4 ${isDuplicate && duplicateLinkId ? 'grid grid-cols-2 gap-2' : ''}`}>
{isDuplicate && duplicateLinkId ? (
<Button
type="button"
Expand Down
60 changes: 60 additions & 0 deletions src/components/wrappers/ExtensionAuthPanel.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import Button from '@/components/basics/Button/Button';
import Spinner from '@/components/basics/Spinner/Spinner';
import { openLinkiving } from '@/lib/chrome/navigation';
import type { ExtensionAuthStatus } from '@/stores/extensionAuthStore';

const messages = {
'signed-out': {
title: '로그인이 필요합니다.',
description: '링카이빙 웹사이트에서 로그인한 뒤\n원하는 링크를 저장해 보세요.',
},
'logged-out': {
title: '로그아웃 되었습니다.',
description: '링크를 저장하려면 다시 로그인해 주세요.\n링카이빙 웹사이트에서 로그인할 수 있습니다.',
},
expired: {
title: '로그아웃 되었습니다.',
description: '로그인 세션이 만료되어 로그아웃 되었습니다.\n링크를 저장하려면 다시 로그인해 주세요.',
},
unavailable: {
title: '로그인 상태를 확인하지 못했습니다.',
description: '연결 상태를 확인한 뒤 다시 시도해 주세요.',
},
};

export default function ExtensionAuthPanel({
status,
onRetry,
}: {
status: Exclude<ExtensionAuthStatus, 'authenticated'>;
onRetry: () => void;
}) {
if (status === 'checking') {
return (
<div className="text-gray600 flex min-h-48 items-center justify-center gap-3 px-6">
<Spinner ariaLabel="로그인 상태 확인 중" />
<span className="font-body-md">로그인 상태 확인 중...</span>
</div>
);
}

const { title, description } = messages[status];
return (
<section aria-labelledby="auth-heading">
<div className="border-gray100 border-b px-6 py-6 text-center" aria-live="polite">
<h1 id="auth-heading" className="font-title-md text-gray900 mb-4">
{title}
</h1>
<p className="font-body-md text-gray700 whitespace-pre-line">{description}</p>
</div>
<div className="px-6 py-4">
<Button
label={status === 'unavailable' ? '다시 시도' : '로그인하러 가기'}
onClick={status === 'unavailable' ? onRetry : openLinkiving}
className="w-full rounded-lg bg-gray900 text-white hover:bg-gray800 focus-visible:outline-2 focus-visible:outline-offset-4"
size="lg"
/>
</div>
</section>
);
}
25 changes: 25 additions & 0 deletions src/components/wrappers/ExtensionHeader.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import SVGIcon from '@/components/Icons/SVGIcon';
import { closeExtensionPanel, openLinkiving } from '@/lib/chrome/navigation';

export default function ExtensionHeader({ authenticated = false }: { authenticated?: boolean }) {
return (
<header className="border-gray100 flex h-14 shrink-0 items-center justify-between border-b px-6">
<button
type="button"
className="font-label-md text-gray500 flex items-center gap-2 rounded-sm focus-visible:outline-2 focus-visible:outline-offset-4"
onClick={openLinkiving}
>
<SVGIcon icon={authenticated ? 'IC_Home' : 'IC_LinkOpen'} size="xs" aria-hidden />
<span>{authenticated ? '내 홈으로 이동' : '링카이빙 바로가기'}</span>
</button>
<button
type="button"
className="text-gray500 hover:text-gray800 flex h-10 w-10 items-center justify-center rounded-lg focus-visible:outline-2"
aria-label="닫기"
onClick={closeExtensionPanel}
>
<SVGIcon icon="IC_Close" size="xs" aria-hidden />
</button>
</header>
);
}
Loading
Loading