develop #69

Merged
gitadmin merged 9 commits from develop into master 2026-11-02 18:35:34 +09:00
20 changed files with 633 additions and 566 deletions

View File

@@ -1,7 +1,9 @@
NEXT_PUBLIC_ENV=dev
NEXT_PUBLIC_API_BASE=https://test-contact.kric.com/api
NEXT_PUBLIC_KART_URL=https://test-kart.kric.com
ENV=dev
CONTACT_SERVER=http://127.0.0.1:4001
API_CONTACT_SERVER=http://127.0.0.1:4001/api/v1
API_INTRANET_SERVER=https://intranet-ext.kric.com/api/v1
AUTH_COOKIE_DOMAIN=kric.com

View File

@@ -1,7 +1,9 @@
NEXT_PUBLIC_ENV=local
NEXT_PUBLIC_API_BASE=http://localhost:4000/api
NEXT_PUBLIC_KART_URL=https://test-kart.kric.com
ENV=local
CONTACT_SERVER=http://localhost:4001
API_CONTACT_SERVER=http://localhost:4001/api/v1
API_INTRANET_SERVER=https://intranet-ext.kric.com/api/v1
AUTH_COOKIE_DOMAIN=

View File

@@ -1,7 +1,9 @@
NEXT_PUBLIC_ENV=prod
NEXT_PUBLIC_API_BASE=https://contact.kric.com/api
NEXT_PUBLIC_KART_URL=https://kart.kric.com
ENV=prod
CONTACT_SERVER=http://127.0.0.1:4001
API_CONTACT_SERVER=http://127.0.0.1:4001/api/v1
API_INTRANET_SERVER=https://intranet-ext.kric.com/api/v1
AUTH_COOKIE_DOMAIN=kric.com

View File

@@ -229,6 +229,7 @@ When implementation is complete, report in Korean:
- Treat the current React version, component style, state management, routing, styling, and test approach as authoritative.
- Do not perform unrelated class-to-hook, JavaScript-to-TypeScript, state-library, styling-system, or React-to-Next.js migrations.
- Keep components focused and follow the repository's established split between presentation, state, data access, and side effects.
- Do not use nested ternary expressions. Use clear `if`/`else` branches, early returns, or well-named intermediate variables instead; a single, non-nested ternary is acceptable only when it remains immediately readable.
- Keep effects dependency-correct and clean up subscriptions, timers, listeners, and in-flight work where applicable.
- Use stable semantic keys and preserve accessibility, loading, empty, error, disabled, and success states.
- Preserve public component props and shared UI contracts unless a coordinated breaking change is explicitly approved.
@@ -265,6 +266,35 @@ Before each related task, read the current contents of every matching reference,
If a task spans multiple scopes, read every matching reference. Generated files under `.agent-harness/references/` are read-only copies; edit KriFrontCommon's `.agent/consumer.md` or `.agent/consumer-references/` and recompose instead.
## Noti-hub SMS Types
- `MessageType.SMS = 21`, `LMS = 22`, `MMS = 23`; `ChannelType.SMS = 2` is unchanged. `SMS_TYPE_ARRAY` and `SmsType` include all three.
- `LMS_MMS = 22` remains a deprecated source-compatibility alias for LMS only. It does not represent MMS. Enum reverse lookup for 22 returns LMS. Use numeric bulk-list paths; the server no longer accepts LMS_MMS in paths. Numeric 21/22/23 bulk-list requests all return the entire SMS channel, not type-filtered lists.
- Requests retain their existing URLs/body shapes. The server chooses the actual type per recipient after substitution: attachment -> MMS; otherwise title or UTF-8 body >= 90 bytes -> LMS; otherwise SMS.
- Refresh templates from the save response (`tmplatTy`); display actual delivery types from `sendTy`, not the template or result code. A bulk can contain multiple SMS types. LMS/MMS share result codes; use existing server result labels.
- SMS, LMS, MMS and KKO use cancellation code 9998. Verify with `npm run typecheck`, `npm run build`, and `node --test tests/noti-hub-sms.test.mjs`.
## Noti-hub Reservation Cancellation
- Import cancellation types, constants, and helpers from `@kri/common/noti-hub` only. They are runtime-neutral and require no optional peers.
- Individual current cancellation state is determined by resultCode via isReserveCanceledResult; bulk current state is cancellationStatus (NONE/PARTIAL/ALL). These describe current cancellation state, not cancellation eligibility. cancelDt and cancelUser are request history, not current state.
- SendResultInfo, SendInfo, and BulkSendInfo expose optional cancelable. Use isSendCancelable(item), which returns true only for cancelable === true, for cancellation eligibility; missing values from older responses are treated as false. Never infer eligibility from cancelDt, result labels, or result codes.
- cancelable reflects query-time state and may change before cancellation. Determine the final outcome from SendCancelResponse counts.
- sendIdx is the single-cancel identifier, not cmid. It is absent from the latest abbreviated report (/api/v1/report/last/send/...). Request sendIdx must be a positive integer; bulkSendKey is required and at most 32 characters.
- EMAIL_RESERVE_CANCELED_RESULT_CODE is 108 for EMAIL. SMS_KKO_RESERVE_CANCELED_RESULT_CODE is 9998 for SMS, LMS, MMS, and KKO. Unknown message types are not recognized as canceled.
- Display the server's resultViewLabel/resultLabel ("예약 취소"). There is no separate result-code list API.
- HTTP 200 can contain notCancelableCount. parseSendCancelResponse validates nonnegative integer counts and targetCount = canceledCount + alreadyCanceledCount + notCancelableCount, throwing TypeError on invalid data. Bulk targetCount counts currently registered detail rows; response canceledCount counts only cancellations made by that request.
- Existing response fields are unchanged; all added fields on existing types are optional. Verify with npm run typecheck and npm run build.
## HTTP Streaming
- `@kri/common/http` HTTP clients expose streamGet/streamPost/streamPut/streamPatch/streamDel, returning HttpStreamResponse (status, statusText, headers, url, nullable body).
- Streaming shares ordinary authentication, URL, body and HTTP-error policy. Read body incrementally; no automatic JSON/NDJSON/SSE parsing or reconnect is performed.
- Streaming options accept an external AbortSignal. Caller cancellation raises AbortError without an HTTP error notification. Cancel the body when it will not be consumed.
- timeoutMs covers connection/headers (and an HTTP error body); idleTimeoutMs covers inactivity after successful headers and resets on consumed chunks. Both default to the client's defaultTimeoutMs (60 seconds by default), and 0 disables that timer for streaming only.
- Mid-stream transport/time-out errors reach the body reader. HTTP error statuses use existing HttpError handlers before a stream is returned. A 204 response has body=null.
- See HTTP_STREAMING.md for examples and node --test tests/http-stream.test.mjs for focused validation after npm run build.
## KriUiRegistry Consumer Contract
When implementing or changing frontend UI, use this order:
@@ -274,6 +304,28 @@ When implementing or changing frontend UI, use this order:
3. Otherwise, prefer a suitable shadcn/ui component.
4. Create a custom component only when the preceding options cannot meet the requirement safely.
### KriAutoComplete Search Scroll
- `kri-auto-complete` exposes `resetScrollOnSearch?: boolean` on `KriSingleSelect`, `KriMultiSelect`, and `MultiSelect`. It defaults to `false`, preserving existing behavior.
- When enabled, a search value change (including clearing it) resets the option list scroll to the top on the next animation frame in both `filter` and `inputOnly` modes. Async result updates alone do not trigger another reset.
### KriAutoComplete Option Tooltip
- `kri-auto-complete` exposes `optionTooltip?: 'singleLine' | 'wrap'` and `optionTooltipClassName?: string` on `KriSingleSelect`, `KriMultiSelect`, and `MultiSelect`. It is off by default, preserving existing behavior.
- When enabled, hovering an option shows its full `label` in a right-side tooltip. `singleLine` stays on one line until the available viewport width; `wrap` wraps at 28rem. The item depends on the shadcn `tooltip` component and provides its own `TooltipProvider`.
### KriAutoComplete Search Match
- `kri-auto-complete` exposes `searchMatch?: 'fuzzy' | 'contains'` on `KriSingleSelect`, `KriMultiSelect`, and `MultiSelect`. It defaults to `fuzzy` (cmdk's default subsequence scoring), preserving existing behavior.
- `contains` keeps only options whose label or value contains the search text as a case-insensitive substring, in the original option order. It applies only when `searchMode` is `filter`.
### KriEditor SMS Preview
- `changeSmsType` reports `SMS | LMS | MMS`. Update consumer callbacks to handle `MMS`; this widens the previous callback contract.
- Attachment presence (`smsHasAttachment`) takes priority and reports MMS. Otherwise a title or UTF-8 preview size >= `smsMaxBytes` (default 90) reports LMS; the remainder reports SMS. LMS/MMS share `lmsMaxBytes` (default 2000).
- UTF-8 byte counting includes `smsPreviewSuffix` and its separating newline, without storing the suffix in the body.
- This is a preview. Use the template-save response for saved `tmplatTy` and delivery-result `sendTy` for actual per-recipient type after server substitution. Registry updates require updating installed consumer copies.
### Required Shared References
Before each related task, read the current contents of every matching reference, even if it was read earlier in the session.

View File

@@ -1,6 +1,6 @@
'use client'
import { Suspense, useEffect, useMemo, useState } from "react";
import { Suspense, useEffect, useMemo, useRef, useState } from "react";
import { useRouter, useSearchParams } from "next/navigation";
import { ArrowLeft, RefreshCw } from "lucide-react";
import { useMounted } from "@kri/common/hooks";
@@ -37,6 +37,7 @@ const ListContactPageContent = () => {
const userRole = auth?.user?.userRole ?? 0;
const ctiCallPhase = useCtiCallPhase();
const shouldBlockNavigation = CTI_CALL_PHASE.includes(ctiCallPhase);
const hasObservedCall = useRef(false);
const queriesEnabled = mounted && prjctIdx > 0;
const enabled = queriesEnabled && !!sid;
@@ -74,10 +75,12 @@ const ListContactPageContent = () => {
const hasGuardEntry = window.history.state?.[CALL_NAVIGATION_GUARD_KEY] === true;
if (!shouldBlockNavigation) {
if (hasGuardEntry) window.history.back();
if (hasGuardEntry && hasObservedCall.current) window.history.back();
hasObservedCall.current = false;
return;
}
hasObservedCall.current = true;
let isRestoringHistory = false;
if (!hasGuardEntry) {

View File

@@ -1,19 +1,18 @@
'use client'
import { useEffect, useRef, useState } from "react";
import { useMounted } from "@kri/common/hooks";
import AppPageTitle from "@/components/app-shell/AppPageTitle";
import { LoadingOverlayAdapter } from "@/components/app-shell/LoadingOverlayAdapter";
import { Button } from "@/components/ui/button";
import { useSelectedProject } from "@/hooks/useSelectedProject";
import { useProjectInfoQuery, useSurveyRedirectUrlQuery } from "@/query/project";
import { useProjectInfoQuery } from "@/query/project";
import { clientEnv } from "@/lib/env.client";
import { SurveyType } from "@/types/project";
import { SURVEY_TYPE_LABEL } from "@/const/projectConst";
const SurveyProgressPage = () => {
const mounted = useMounted();
const { selectedProject } = useSelectedProject();
const openedForRef = useRef<string | null>(null);
const prjctIdx = selectedProject?.prjctIdx ?? 0;
const enabled = mounted && prjctIdx > 0;
@@ -21,35 +20,7 @@ const SurveyProgressPage = () => {
const projectInfoQuery = useProjectInfoQuery(prjctIdx, enabled);
const surveys = projectInfoQuery.data?.surveys ?? [];
const [activeSurveyIdx, setActiveSurveyIdx] = useState<number | null>(null);
const [openedUrl, setOpenedUrl] = useState<string | null>(null);
const selectedSurvey = surveys.find((s) => s.prjctSurveyIdx === activeSurveyIdx) ?? null;
const surveyTy = selectedSurvey?.surveyTy ?? SurveyType.NONE;
const isKonKiwi = surveyTy === SurveyType.KON || surveyTy === SurveyType.KIWI;
const isKiwi = surveyTy === SurveyType.KIWI ? 1 : 0;
const pkey = selectedSurvey?.surveyPrjctCd ?? "";
const redirectUrlEnabled = enabled && !!selectedSurvey && isKonKiwi && !!pkey;
const redirectUrlQuery = useSurveyRedirectUrlQuery(isKiwi, pkey, redirectUrlEnabled);
const targetUrl = !selectedSurvey
? null
: isKonKiwi
? (redirectUrlQuery.data ?? null)
: surveyTy === SurveyType.EXTERNAL
? (selectedSurvey.surveyDashboardUrl || null)
: null;
useEffect(() => {
if (!targetUrl || openedForRef.current === targetUrl) return;
openedForRef.current = targetUrl;
window.open(targetUrl, "_blank");
setOpenedUrl(targetUrl);
}, [targetUrl]);
const isLoading = !mounted || projectInfoQuery.isLoading || (redirectUrlEnabled && redirectUrlQuery.isLoading);
const isLoading = !mounted || projectInfoQuery.isLoading;
if (isLoading) return <LoadingOverlayAdapter force />;
@@ -62,7 +33,14 @@ const SurveyProgressPage = () => {
) : (
<div className="max-w-[600px] space-y-2">
{surveys.map((survey) => {
const hasReport = survey.surveyTy !== SurveyType.NONE;
const isKonKiwi = survey.surveyTy === SurveyType.KON || survey.surveyTy === SurveyType.KIWI;
let targetUrl: string | null = null;
if (isKonKiwi && survey.surveyPrjctCd) {
const projectType = survey.surveyTy === SurveyType.KIWI ? 1 : 0;
targetUrl = `${clientEnv.KART_URL}/Report/Current?projectType=${projectType}&pkey=${encodeURIComponent(survey.surveyPrjctCd)}`;
} else if (survey.surveyTy === SurveyType.EXTERNAL) {
targetUrl = survey.surveyDashboardUrl || null;
}
return (
<div
key={survey.prjctSurveyIdx ?? survey.surveyOrder}
@@ -72,37 +50,21 @@ const SurveyProgressPage = () => {
<p className="font-semibold">{survey.surveyName}</p>
<p className="text-xs text-muted-foreground">{SURVEY_TYPE_LABEL[survey.surveyTy]}</p>
</div>
<Button
type="button"
disabled={!hasReport}
onClick={() => setActiveSurveyIdx(survey.prjctSurveyIdx ?? null)}
>
바로가기
</Button>
{targetUrl ? (
<Button asChild>
<a href={targetUrl} target="_blank" rel="noopener noreferrer">
바로가기
</a>
</Button>
) : (
<Button type="button" disabled>바로가기</Button>
)}
</div>
);
})}
</div>
)}
{redirectUrlEnabled && redirectUrlQuery.isError ? (
<div role="alert" className="flex items-center gap-2 text-destructive">
<span>설문 현황 링크를 불러오지 못했습니다.</span>
<Button type="button" variant="outline" onClick={() => void redirectUrlQuery.refetch()}>
다시 시도
</Button>
</div>
) : null}
{openedUrl ? (
<p>
새 창에서 열립니다. 열리지 않았다면{" "}
<a href={openedUrl} target="_blank" rel="noreferrer" className="text-blue-600 underline">
여기
</a>
를 클릭해 주세요.
</p>
) : null}
</div>
);
};

View File

@@ -24,28 +24,6 @@ export const GET = async (req: NextRequest, context: RouteContext) => {
return NextResponse.json(result, { status: 200 });
}
if(action === "survey-redirect-url" && slug.length === 3){
const [, isKiwi, pkey] = slug;
if (!["0", "1"].includes(isKiwi)) {
return NextResponse.json({ message: "프로젝트 정보를 확인해 주세요." }, { status: 400 });
}
// Contact backend를 거쳐 KON/KIWI 현황 공유 링크를 발급한다.
const result = await contactApi.post<unknown>(
`/kart/project/${isKiwi}/${encodeURIComponent(pkey)}/share`,
{},
{ expectText: true },
);
const shortUrl = typeof result === "string" && /^https?:\/\//.test(result)
? result
: null;
if (!shortUrl) {
return NextResponse.json({ message: "KART 공유 링크 응답을 확인해 주세요." }, { status: 502 });
}
return NextResponse.json(shortUrl, { status: 200 });
}
return NextResponse.json({ message: "Not found" }, { status: 404 });
} catch (error: unknown) {
return errorToResponse(error);

View File

@@ -1,9 +1,8 @@
import { NextRequest, NextResponse } from "next/server";
import type { LoginRequest, LoginUser } from "@kri/common";
import {serverEnv} from "@/lib/env.server";
import {setAuthCookie} from "@/lib/auth-cookie";
import {createContactApi} from "@/lib/http-server";
import {errorToResponse} from "@kri/common/http";
import {CookieKeys} from "@/store/cookie/cookie-keys";
//?ㅼ젣 Backend
type LoginResponse = {
@@ -19,13 +18,7 @@ export const POST = async (req: NextRequest) => {
const result = await contactApi.post<LoginResponse>("/auth/login", body);
const res = NextResponse.json(result.user, { status: 200 });
res.cookies.set(CookieKeys.AuthToken, result.accessToken, {
httpOnly: true,
secure: serverEnv.ENV === "prod",
sameSite: "lax",
path: "/",
maxAge: 24 * 60 * 60, // 24?쒓컙
});
setAuthCookie(res, result.accessToken);
return res;
} catch (error : unknown) {

View File

@@ -1,9 +1,8 @@
import { NextRequest, NextResponse } from "next/server";
import {serverEnv} from "@/lib/env.server";
import {setAuthCookie} from "@/lib/auth-cookie";
import {createContactApi} from "@/lib/http-server";
import {errorToResponse} from "@kri/common/http";
import {RouteContext} from "@/types/common";
import {CookieKeys} from "@/store/cookie/cookie-keys";
export async function POST(
_req: NextRequest,
@@ -22,13 +21,7 @@ export async function POST(
await contactApi.post<boolean>(url);
const res = NextResponse.json({ ok: true });
res.cookies.set(CookieKeys.AuthToken, "", {
httpOnly: true,
secure: serverEnv.ENV === "prod",
sameSite: "lax",
path: "/",
maxAge: 0,
});
setAuthCookie(res, "");
return res;
} catch (error: unknown) {

View File

@@ -63,15 +63,17 @@ const disabledContrastClass = 'bg-white disabled:opacity-100 disabled:text-foreg
// disabled는 공용 Input 컴포넌트의 disabled:pointer-events-none 때문에 마우스 이벤트 자체를 못 받는다.
const readOnlyContrastClass = 'bg-white read-only:text-foreground read-only:bg-muted/60'
const getCallButtonLabel = (isDialing: boolean, isOnCall: boolean) => {
const getCallButtonLabel = (isDialing: boolean, isOnCall: boolean, isEnding: boolean) => {
if (isEnding) return '종료 요청 중'
if (isDialing) return '거는 중'
if (isOnCall) return '전화 끊기'
return '전화'
}
const getCallButtonTitle = (isCtiReady: boolean, isDialing: boolean) => {
const getCallButtonTitle = (isCtiReady: boolean, isDialing: boolean, isEnding: boolean) => {
if (!isCtiReady) return '전화 시스템에 연결되어 있지 않습니다.'
if (isDialing) return '전화를 거는 중입니다.'
if (isEnding) return '통화 종료를 확인하고 있습니다.'
return undefined
}
@@ -115,7 +117,8 @@ const ListContactInfoPanel = ({
const isCtiReady = ctiConnectionStatus === 'open'
const ctiCallPhase = useCtiCallPhase()
const isDialing = ctiCallPhase === 'dialing'
const isOnCall = ctiCallPhase === 'active'
const isEnding = ctiCallPhase === 'ending'
const isOnCall = ctiCallPhase === 'active' || isEnding
const visibleHeaders = listHeaders
.filter((header) => isListFieldVisibleForContact(header))
@@ -148,8 +151,7 @@ const ListContactInfoPanel = ({
}
const handleCall = (telNum: string, listHderId: number) => {
if (!isCtiReady || isDialing) return
// CTI_HANGUP_PENDING_VENDOR: 외주사 Hangup 명령 동작 확인 후 통화 중 버튼을 활성화하면 즉시 사용할 수 있다.
if (!isCtiReady || isDialing || isEnding) return
if (isOnCall) {
ctiClient.hangup()
return
@@ -229,12 +231,12 @@ const ListContactInfoPanel = ({
type="button"
variant="outline"
className={cn('shrink-0 gap-2', isOnCall && 'bg-accent text-accent-foreground')}
disabled={isEditing || !isCtiReady || isDialing}
title={getCallButtonTitle(isCtiReady, isDialing)}
disabled={isEditing || !isCtiReady || isDialing || isEnding}
title={getCallButtonTitle(isCtiReady, isDialing, isEnding)}
onClick={() => handleCall(value, header.listHderId)}
>
<Phone className="h-4 w-4" />
{getCallButtonLabel(isDialing, isOnCall)}
{getCallButtonLabel(isDialing, isOnCall, isEnding)}
</Button>
<Button
type="button"

View File

@@ -34,7 +34,7 @@ import { downloadFile } from "@kri/common/browser";
import {cn} from "@/lib/utils";
import {ProjectMainTemplateUpdateRequest, ProjectSurvey} from "@/types/project";
import type { DataVerification } from "@kri/common";
import {COMMON_TEXT_REGEX, EMAIL_REGEX} from "@/const/validationConst";
import {COMMON_TEXT_REGEX, EMAIL_REGEX, TEMPLATE_TEXT_REGEX} from "@/const/validationConst";
import {formatKoreanPhoneNumber} from "@/utils/phone";
import {
getTemplateAttachmentNames,
@@ -244,15 +244,15 @@ const MessageTemplate = ({ pageTitle, defaultTemplate }: MessageTemplateProps) =
if (isBlank(tpl.itrntPrjctCd)) return fail("itrntPrjctCd", "인트라넷 프로젝트 코드가 없습니다.");
if (isBlank(tpl.tmplatNm)) return fail("tmplatNm", "템플릿명을 입력해 주세요.");
if (tpl.tmplatNm.length > 32) return fail("tmplatNm", "템플릿명은 32자 이하로 입력해주세요.");
if (!COMMON_TEXT_REGEX.test(tpl.tmplatNm)) return fail("tmplatNm", "템플릿명에 허용되지 않는 문자가 포함되어 있습니다.");
if (!TEMPLATE_TEXT_REGEX.test(tpl.tmplatNm)) return fail("tmplatNm", "템플릿명에 허용되지 않는 문자가 포함되어 있습니다.");
if (isBlank(tpl.tmplatBody)) return fail("tmplatBody", "본문을 입력해 주세요.");
if (isBlank(tpl.sendNm)) return fail("sendNm", "발신자명을 입력해 주세요.");
if (tpl.sendNm.length > 32) return fail("sendNm", "발신자명은 32자 이하로 입력해주세요.");
if (!COMMON_TEXT_REGEX.test(tpl.sendNm)) return fail("sendNm", "발신자명에 허용되지 않는 문자가 포함되어 있습니다.");
if (!TEMPLATE_TEXT_REGEX.test(tpl.sendNm)) return fail("sendNm", "발신자명에 허용되지 않는 문자가 포함되어 있습니다.");
if (!isBlank(tpl.tmplatTitle)) {
if (tpl.tmplatTitle!.length > 128) return fail("tmplatTitle", "제목은 128자 이하로 입력해주세요.");
if (!COMMON_TEXT_REGEX.test(tpl.tmplatTitle!)) return fail("tmplatTitle", "제목에 허용되지 않는 문자가 포함되어 있습니다.");
if (!TEMPLATE_TEXT_REGEX.test(tpl.tmplatTitle!)) return fail("tmplatTitle", "제목에 허용되지 않는 문자가 포함되어 있습니다.");
}
if (tpl.tmplatTy === MessageType.EMAIL) {

View File

@@ -5,3 +5,5 @@ export const FONT_SIZE = {
} as const;
export const ALLOW_REDIRECT = new Set(["complete", "screen", "quota"]);
export const AUTH_COOKIE_MAX_AGE = 24 * 60 * 60;

View File

@@ -4,11 +4,12 @@ export const CTI_AGENT_GROUP = "KRI_CONTACT";
export const CTI_CALL_PHASE: CtiCallPhase[] = [
'dialing',
'active'
'active',
'ending'
] as const;
// WS 서버가 보내는 CTIAgentStatus 값 중 통화 중 또는 통화 중 재로그인 대기로 간주할 값들
export const CTI_ON_CALL_STATUSES = ["0", "2", "3"] as const;
// WS 서버가 보내는 발신·통화 중 상태. None(0)은 통화 중 상태가 아니다.
export const CTI_ON_CALL_STATUSES = ["2", "3", "8"] as const;
// localStorage에 저장한 CTI 상태의 만료 시간. 마지막 저장(updatedAt) 기준이며 복원 시점에만 검사한다.
export const CTI_STATE_TTL_MS = 2 * 60 * 60 * 1000;
@@ -26,3 +27,8 @@ export const CTI_AUTO_RECONNECT_BASE_MS = 1000;
export const CTI_AUTO_RECONNECT_MAX_MS = 15 * 1000;
export const CTI_AUTO_RECONNECT_JITTER_MS = 1000;
// 종료 명령의 응답이 없으면 재요청할 수 있게 하되, 실제 종료로 판정하지 않는다.
export const CTI_HANGUP_TIMEOUT_MS = 10 * 1000;
export const CTI_LOGIN_TIMEOUT_MS = 15 * 1000;
export const CTI_HISTORY_RETRY_MS = 5 * 1000;

View File

@@ -6,6 +6,14 @@
// 그 외 문자(이모지, 다른 언어 문자, 제어문자 등)는 전부 거부한다.
export const COMMON_TEXT_REGEX = /^[가-힣A-Za-z0-9 !@#$%^&*()_+\-={}\[\]:;"'<>,.?/·~]+$/
// 메시지 템플릿의 제목·템플릿명·발신자명용. 다국어(스페인어, 일본어 등)와 기호는 허용하고
// 제어·서식 문자, 줄/문단 구분자, 이모지만 거부한다.
// tsconfig target(ES2017)에서 \p{...} 리터럴 대신 RegExp 생성자로 만든다.
export const TEMPLATE_TEXT_REGEX = new RegExp(
"^[^\\p{C}\\p{Zl}\\p{Zp}\\p{Emoji_Presentation}\\u{FE0F}\\u{20E3}]+$",
"u",
)
// 이메일 기본 형식(로컬@도메인.최상위도메인)만 확인한다. 세부 규칙은 백엔드 검증을 따른다.
export const EMAIL_REGEX = /^[^\s@]+@[^\s@]+\.[^\s@]+$/

33
src/lib/auth-cookie.ts Normal file
View File

@@ -0,0 +1,33 @@
import "server-only";
import { NextResponse } from "next/server";
import { AUTH_COOKIE_MAX_AGE } from "@/const/commonConst";
import { serverEnv } from "@/lib/env.server";
import { CookieKeys } from "@/store/cookie/cookie-keys";
/** Issue/renew the normal-login cookie, or expire it when the token is empty. */
export function setAuthCookie(response: NextResponse, token: string): void {
const production = serverEnv.ENV === "prod";
const domain = serverEnv.AUTH_COOKIE_DOMAIN;
const options = {
httpOnly: true,
secure: production,
sameSite: "lax" as const,
path: "/",
};
// Serialize each cookie separately: ResponseCookies indexes cookies by name,
// so setting the shared and host-only variants on one instance loses a header.
const append = (value: string, cookieDomain: string | undefined, maxAge: number) => {
const cookieResponse = new NextResponse(null);
cookieResponse.cookies.set(CookieKeys.AuthToken, value, {
...options,
...(cookieDomain ? { domain: cookieDomain } : {}),
maxAge,
});
for (const header of cookieResponse.headers.getSetCookie())
response.headers.append("Set-Cookie", header);
};
if (domain) append("", undefined, 0);
append(token, domain, token ? AUTH_COOKIE_MAX_AGE : 0);
}

File diff suppressed because it is too large Load Diff

View File

@@ -3,6 +3,8 @@ import { createEnv, env } from "@kri/common/config";
export const clientEnv = createEnv({
ENV: env.required("NEXT_PUBLIC_ENV", process.env.NEXT_PUBLIC_ENV),
KART_URL: env.required("NEXT_PUBLIC_KART_URL", process.env.NEXT_PUBLIC_KART_URL),
API_BASE: env.required("NEXT_PUBLIC_API_BASE", process.env.NEXT_PUBLIC_API_BASE),
API_INTERNAL: env.required("NEXT_PUBLIC_API_INTERNAL", process.env.NEXT_PUBLIC_API_INTERNAL),

View File

@@ -5,6 +5,8 @@ import { createEnv, env } from "@kri/common/config";
export const serverEnv = createEnv({
ENV: env.required("ENV", process.env.ENV),
AUTH_COOKIE_DOMAIN: env.optional("AUTH_COOKIE_DOMAIN", process.env.AUTH_COOKIE_DOMAIN),
CONTACT_SERVER: env.required("CONTACT_SERVER", process.env.CONTACT_SERVER),
API_CONTACT_SERVER: env.required("API_CONTACT_SERVER", process.env.API_CONTACT_SERVER),

View File

@@ -38,8 +38,6 @@ export const qk = {
/********** KON, KIWI 프로젝트 관련 KART에서 받아옴 **********/
kartProjectList: (itrntPrjctCd: string, userTeam: string, isKiwi: number, keyword: string) =>
["kart", "project-list", itrntPrjctCd, userTeam, isKiwi, keyword] as const,
surveyRedirectUrl: (isKiwi: number, pkey: string) =>
["kart", "survey-redirect-url", isKiwi, pkey] as const,
/********** KON, KIWI 프로젝트 관련 KART에서 받아옴 **********/
/********** 찐 인트라넷 관련 **********/

View File

@@ -131,19 +131,6 @@ export function useKartProjectListQuery(args: {
});
}
/**
* KON/KIWI 설문 현황(리포트) 바로가기 URL
*/
export function useSurveyRedirectUrlQuery(isKiwi: number, pkey: string, enabled: boolean) {
return useQuery({
queryKey: qk.surveyRedirectUrl(isKiwi, pkey),
queryFn: () => nextApi.get<string>(`/kart/survey-redirect-url/${isKiwi}/${encodeURIComponent(pkey)}`, { skipForbiddenHandler: true }),
enabled: enabled && !!pkey,
staleTime: 0,
meta: { ignoreGlobalLoading: true },
});
}
/**
* 프로젝트에 배정된 회사 ID 목록
*/