Compare commits
2 Commits
develop
...
43b4c4be54
| Author | SHA1 | Date | |
|---|---|---|---|
| 43b4c4be54 | |||
| e2cdf63e81 |
@@ -1,4 +1,3 @@
|
|||||||
NEXT_PUBLIC_ENV=development
|
NEXT_PUBLIC_ENV=development
|
||||||
ENV=development
|
ENV=development
|
||||||
API_SERVER=http://127.0.0.1:4015/api/v1
|
API_SERVER=http://127.0.0.1:4015/api/v1
|
||||||
AUTH_COOKIE_DOMAIN=kric.com
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
NEXT_PUBLIC_ENV=local
|
NEXT_PUBLIC_ENV=local
|
||||||
ENV=local
|
ENV=local
|
||||||
API_SERVER=http://localhost:4015/api/v1
|
API_SERVER=http://localhost:4015/api/v1
|
||||||
AUTH_COOKIE_DOMAIN=
|
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
NEXT_PUBLIC_ENV=production
|
NEXT_PUBLIC_ENV=production
|
||||||
ENV=prod
|
ENV=production
|
||||||
API_SERVER=http://127.0.0.1:4015/api/v1
|
API_SERVER=http://127.0.0.1:4015/api/v1
|
||||||
AUTH_COOKIE_DOMAIN=kric.com
|
|
||||||
|
|||||||
@@ -229,7 +229,6 @@ When implementation is complete, report in Korean:
|
|||||||
- Treat the current React version, component style, state management, routing, styling, and test approach as authoritative.
|
- 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.
|
- 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.
|
- 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.
|
- 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.
|
- 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.
|
- Preserve public component props and shared UI contracts unless a coordinated breaking change is explicitly approved.
|
||||||
|
|||||||
335
package-lock.json
generated
335
package-lock.json
generated
@@ -11,7 +11,7 @@
|
|||||||
"@dnd-kit/core": "^6.3.1",
|
"@dnd-kit/core": "^6.3.1",
|
||||||
"@dnd-kit/sortable": "^10.0.0",
|
"@dnd-kit/sortable": "^10.0.0",
|
||||||
"@dnd-kit/utilities": "^3.2.2",
|
"@dnd-kit/utilities": "^3.2.2",
|
||||||
"@kri/common": "^0.20.0",
|
"@kri/common": "^0.19.1",
|
||||||
"@tanstack/react-query": "latest",
|
"@tanstack/react-query": "latest",
|
||||||
"@tanstack/react-table": "^8.21.3",
|
"@tanstack/react-table": "^8.21.3",
|
||||||
"@tiptap/extension-color": "^3.31.4",
|
"@tiptap/extension-color": "^3.31.4",
|
||||||
@@ -30,34 +30,36 @@
|
|||||||
"@tiptap/react": "^3.31.4",
|
"@tiptap/react": "^3.31.4",
|
||||||
"@tiptap/starter-kit": "^3.31.4",
|
"@tiptap/starter-kit": "^3.31.4",
|
||||||
"class-variance-authority": "latest",
|
"class-variance-authority": "latest",
|
||||||
|
"clsx": "latest",
|
||||||
"cmdk": "^1.1.1",
|
"cmdk": "^1.1.1",
|
||||||
"cn": "0.5.2",
|
"cn": "^0.4.0",
|
||||||
"d3-cloud": "^1.2.9",
|
"d3-cloud": "^1.2.9",
|
||||||
"date-fns": "^4.4.0",
|
"date-fns": "^4.4.0",
|
||||||
"dompurify": "^3.4.18",
|
"dompurify": "^3.4.16",
|
||||||
"echarts": "^6.1.0",
|
"echarts": "^6.1.0",
|
||||||
"echarts-for-react": "^3.0.6",
|
"echarts-for-react": "^3.0.6",
|
||||||
"embla-carousel-react": "^8.6.0",
|
"embla-carousel-react": "^8.6.0",
|
||||||
"jotai": "latest",
|
"jotai": "latest",
|
||||||
"lucide-react": "latest",
|
"lucide-react": "latest",
|
||||||
"next": "~16.4.6",
|
"next": "~16.4.1",
|
||||||
"prettier": "^3.9.10",
|
"prettier": "^3.9.10",
|
||||||
"radix-ui": "^1.8.0",
|
"radix-ui": "^1.8.0",
|
||||||
"react": "latest",
|
"react": "latest",
|
||||||
"react-day-picker": "^10.0.2",
|
"react-day-picker": "^10.0.2",
|
||||||
"react-dom": "latest",
|
"react-dom": "latest",
|
||||||
"server-only": "latest",
|
"server-only": "latest",
|
||||||
"sonner": "latest"
|
"sonner": "latest",
|
||||||
|
"tailwind-merge": "latest"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@tailwindcss/postcss": "latest",
|
"@tailwindcss/postcss": "latest",
|
||||||
"@types/d3-cloud": "^1.2.9",
|
"@types/d3-cloud": "^1.2.9",
|
||||||
"@types/node": "^24.19.2",
|
"@types/node": "latest",
|
||||||
"@types/react": "latest",
|
"@types/react": "latest",
|
||||||
"@types/react-dom": "latest",
|
"@types/react-dom": "latest",
|
||||||
"babel-plugin-react-compiler": "latest",
|
"babel-plugin-react-compiler": "latest",
|
||||||
"eslint": "^9",
|
"eslint": "^9",
|
||||||
"eslint-config-next": "~16.4.6",
|
"eslint-config-next": "~16.4.1",
|
||||||
"playwright": "^1.64.1",
|
"playwright": "^1.64.1",
|
||||||
"tailwindcss": "latest",
|
"tailwindcss": "latest",
|
||||||
"tw-animate-css": "latest",
|
"tw-animate-css": "latest",
|
||||||
@@ -1158,13 +1160,6 @@
|
|||||||
"url": "https://opencollective.com/libvips"
|
"url": "https://opencollective.com/libvips"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@isaacs/nonrecursive-glob-match": {
|
|
||||||
"version": "1.1.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/@isaacs/nonrecursive-glob-match/-/nonrecursive-glob-match-1.1.0.tgz",
|
|
||||||
"integrity": "sha512-GPm/Dbvk5RLmhRnxXIa7nTpK0xtl4E0wj0MslsuNiJ1FIROU+2+9lgUC/dgF7Ey4QCWhfEsgxilMRMCdHPfDfw==",
|
|
||||||
"dev": true,
|
|
||||||
"license": "BlueOak-1.0.0"
|
|
||||||
},
|
|
||||||
"node_modules/@jridgewell/gen-mapping": {
|
"node_modules/@jridgewell/gen-mapping": {
|
||||||
"version": "0.3.13",
|
"version": "0.3.13",
|
||||||
"resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz",
|
"resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz",
|
||||||
@@ -1216,13 +1211,14 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@kri/common": {
|
"node_modules/@kri/common": {
|
||||||
"version": "0.20.0",
|
"version": "0.19.1",
|
||||||
"resolved": "https://gitea.kric.com/api/packages/KRi/npm/%40kri%2Fcommon/-/0.20.0/common-0.20.0.tgz",
|
"resolved": "https://gitea.kric.com/api/packages/KRi/npm/%40kri%2Fcommon/-/0.19.1/common-0.19.1.tgz",
|
||||||
"integrity": "sha512-v6pLvFxePWmdSqG5cK63XwFNrmu4aiZQ1WprKktKVz9CQLpKAKPauQ2mvlQkSn70HXRaJmdwQXUpZHQBFZoE0Q==",
|
"integrity": "sha512-AbCeomCvzF3CoogRNvM2eBT3AgL0SR5a3PS1W4MHh0W9gs/J5Fkt44/uXRc2ouiyT1xhjOmOwp9JJSp1vDVRnQ==",
|
||||||
"license": "UNLICENSED",
|
"license": "UNLICENSED",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"cn": "0.5.2",
|
"clsx": "^2.1.1",
|
||||||
"crypto-js": "^4.2.0"
|
"crypto-js": "^4.2.0",
|
||||||
|
"tailwind-merge": "^3.4.0"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@tanstack/react-query": ">=5 <6",
|
"@tanstack/react-query": ">=5 <6",
|
||||||
@@ -1264,15 +1260,15 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@next/env": {
|
"node_modules/@next/env": {
|
||||||
"version": "16.4.6",
|
"version": "16.4.3",
|
||||||
"resolved": "https://registry.npmjs.org/@next/env/-/env-16.4.6.tgz",
|
"resolved": "https://registry.npmjs.org/@next/env/-/env-16.4.3.tgz",
|
||||||
"integrity": "sha512-SunBjJ6t+oBtecS3dTjdVuMhUogP5wD/vrGL5EVuQYM1iS4O5ilL51HkiJ3sPjMzRHiCChvr4dbaSJbR7F3lxA==",
|
"integrity": "sha512-a7tz1QCcWWkwC/rPJcPMJk/UNRu9CFhDd3OHYE5hddbJrs8BqRTalxI6GlKCWEGzRLHN+S/B7a4PAHCtm25aBQ==",
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/@next/eslint-plugin-next": {
|
"node_modules/@next/eslint-plugin-next": {
|
||||||
"version": "16.4.6",
|
"version": "16.4.3",
|
||||||
"resolved": "https://registry.npmjs.org/@next/eslint-plugin-next/-/eslint-plugin-next-16.4.6.tgz",
|
"resolved": "https://registry.npmjs.org/@next/eslint-plugin-next/-/eslint-plugin-next-16.4.3.tgz",
|
||||||
"integrity": "sha512-HdqERVOafOD8JaUSAkwf9aSu/1rsHlkN8C5GcXYBH3C/z1MxBhZFxB5rz/xqMMRiIj7r9tIv8OCLQ9JWUxCvWA==",
|
"integrity": "sha512-oxuC06wt/71h6ACYCV9GbKOfnf5a7VlRe/p80YHTut15TNgDEmynDnaq8t/xhy5rlvk7dhItIPs6H3rvIM4kyw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -1313,9 +1309,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@next/swc-darwin-arm64": {
|
"node_modules/@next/swc-darwin-arm64": {
|
||||||
"version": "16.4.6",
|
"version": "16.4.3",
|
||||||
"resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-16.4.6.tgz",
|
"resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-16.4.3.tgz",
|
||||||
"integrity": "sha512-kJ4VVZkley17xKaJx72QN2IBqjrj7zenCQZaUF0l9ShS/1Mt2kW4+Z5KGG6vgr3L/J562xTOizVyM1iA/u5nlg==",
|
"integrity": "sha512-4yq5EXBt+VDtAZwTyfijaFp5D2C5oz3Ikw5a2kiX2K9nw72vrZX2q5UuAlkPtUMO1tQz6JTKpaKWjS7OOefTDQ==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"arm64"
|
"arm64"
|
||||||
],
|
],
|
||||||
@@ -1329,9 +1325,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@next/swc-darwin-x64": {
|
"node_modules/@next/swc-darwin-x64": {
|
||||||
"version": "16.4.6",
|
"version": "16.4.3",
|
||||||
"resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-16.4.6.tgz",
|
"resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-16.4.3.tgz",
|
||||||
"integrity": "sha512-eIPGZIqC+8JKaeZmvnCANJQF4xWkkHqSnAAajtFxgwDMAOnCgxNvP52SeWZ41PyVwoe+Le/NQuZSaQ8j7YshSA==",
|
"integrity": "sha512-1Rvkn/LUhnEF8WxnRkOrqGhbwXui1bkWFxONKIbN+r7C+9KHDSZ+iUoj4CzymVMWUyZIyx9szcb9+kbKhD500A==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"x64"
|
"x64"
|
||||||
],
|
],
|
||||||
@@ -1345,15 +1341,12 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@next/swc-linux-arm64-gnu": {
|
"node_modules/@next/swc-linux-arm64-gnu": {
|
||||||
"version": "16.4.6",
|
"version": "16.4.3",
|
||||||
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-16.4.6.tgz",
|
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-16.4.3.tgz",
|
||||||
"integrity": "sha512-9nI6O8vvczH2D9ZNdMGqb/3NuT15T9ksOZnAmx9/gjF2cOi74+xxyf1Hk96uIMfm14c9y6wHeBq6SH8g6udvcA==",
|
"integrity": "sha512-dCKpXErGg3abUM6t5JTJV/ottVBTStJB5lRJTbgdUdQaQ+jNHiK56Hsc0YAEg/rinSh42hYG3HWiYmEMdilnxg==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"arm64"
|
"arm64"
|
||||||
],
|
],
|
||||||
"libc": [
|
|
||||||
"glibc"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"os": [
|
"os": [
|
||||||
@@ -1364,15 +1357,12 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@next/swc-linux-arm64-musl": {
|
"node_modules/@next/swc-linux-arm64-musl": {
|
||||||
"version": "16.4.6",
|
"version": "16.4.3",
|
||||||
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-16.4.6.tgz",
|
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-16.4.3.tgz",
|
||||||
"integrity": "sha512-7/qPhTxDp2ScluOJOhLuhWmlA17o1yZ0SIgpISBCpBxXgtnK4+KGywBpFkfLPiU1rnSM1faFGzYkH6i7JdTrqA==",
|
"integrity": "sha512-WwYbhWkhYBvBtib1K4W0kL8MW2snBD2A5b3SN4vPpqalZbZs5+bQ1yzAdepVoOqrFfEW3dmREy4Zs1MrWcrFbw==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"arm64"
|
"arm64"
|
||||||
],
|
],
|
||||||
"libc": [
|
|
||||||
"musl"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"os": [
|
"os": [
|
||||||
@@ -1383,15 +1373,12 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@next/swc-linux-x64-gnu": {
|
"node_modules/@next/swc-linux-x64-gnu": {
|
||||||
"version": "16.4.6",
|
"version": "16.4.3",
|
||||||
"resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-16.4.6.tgz",
|
"resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-16.4.3.tgz",
|
||||||
"integrity": "sha512-oOpbNa8XOW1qCGd9VvzC4fbkkRxEls7/WI6tz+YHC0xRA7KpV1U7DrAnCPjzVyOk/karzWEepCOcTIDmwK8FwQ==",
|
"integrity": "sha512-QymWvfUwDEC5/lpJOsxX5VAbyoR2D13+2Jsjz4be7gT4LPqEgdpkeLIR/HFfCLgKzoMhpJbp6I/JnogyNZHcaA==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"x64"
|
"x64"
|
||||||
],
|
],
|
||||||
"libc": [
|
|
||||||
"glibc"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"os": [
|
"os": [
|
||||||
@@ -1402,15 +1389,12 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@next/swc-linux-x64-musl": {
|
"node_modules/@next/swc-linux-x64-musl": {
|
||||||
"version": "16.4.6",
|
"version": "16.4.3",
|
||||||
"resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-16.4.6.tgz",
|
"resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-16.4.3.tgz",
|
||||||
"integrity": "sha512-aM8CZ+OR2EwXaAYw7KGkW2GDmNDsLBIRe1MMRZCJPTdw/xhTD0IMUVO4sf3KqrzuRouGzwwLZn34+gFeVXiUQA==",
|
"integrity": "sha512-Vmjd9D7DpA4Vv3cUlr82QWgJD/BQZmns801vtC5VWHg6jCIA4a5vMKpQnfrM2pyCrp2eV0ENdUg4PlN3bAc2Yw==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"x64"
|
"x64"
|
||||||
],
|
],
|
||||||
"libc": [
|
|
||||||
"musl"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"os": [
|
"os": [
|
||||||
@@ -1421,9 +1405,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@next/swc-win32-arm64-msvc": {
|
"node_modules/@next/swc-win32-arm64-msvc": {
|
||||||
"version": "16.4.6",
|
"version": "16.4.3",
|
||||||
"resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-16.4.6.tgz",
|
"resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-16.4.3.tgz",
|
||||||
"integrity": "sha512-U0p7/tEtqvHX2crhd841CDwKtp5CFkKXVjOhmfccR3Pvp64sj8KBwRqsvltqLOwVBbj0NtkxwXSDpEHYGbxeXQ==",
|
"integrity": "sha512-lG1pPdPLk7gTyGb00n5JIMLdBJgjb+UEhSdZvFbhUMg0DyC6z4B7RnpSKF9VCd4imkLObVbXOFA0kFCpw7yFow==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"arm64"
|
"arm64"
|
||||||
],
|
],
|
||||||
@@ -1437,9 +1421,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@next/swc-win32-x64-msvc": {
|
"node_modules/@next/swc-win32-x64-msvc": {
|
||||||
"version": "16.4.6",
|
"version": "16.4.3",
|
||||||
"resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-16.4.6.tgz",
|
"resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-16.4.3.tgz",
|
||||||
"integrity": "sha512-3ZG15/5WIdlTQsIEvc9sPTTSL5XFrlLklIKmfF4fwsDnoAhu6NcBDXsk3mbGxNyo6aVLEGex+fHCv2MahY7a9g==",
|
"integrity": "sha512-NmQC9RkJdnPXRaMxtkCzobB3teVjqF33oSOnwDfi+XYGWWYpt+xlGK3mtktSKLbdjwaWbJu2OkkMiRFGUUncKg==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"x64"
|
"x64"
|
||||||
],
|
],
|
||||||
@@ -3973,13 +3957,13 @@
|
|||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/@types/node": {
|
"node_modules/@types/node": {
|
||||||
"version": "24.19.2",
|
"version": "26.6.5",
|
||||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-24.19.2.tgz",
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-26.6.5.tgz",
|
||||||
"integrity": "sha512-93d49wCWJkCyN87MxLpNN6KXPCwFw7bVUg79mGUV1OS40JGWwVCr8n61DXCSqz7CV6/VfPkb7xec7uP2M+QHWQ==",
|
"integrity": "sha512-uMzsv9stDdofIZBx4UGh4Z9ZgXnGC9seRDscilBcTHAeOFk67MZg/k9bWVfO+bk4qZmG+l52hRnLwUiH2LnJTg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"undici-types": ">=7.24.0 <7.24.7"
|
"undici-types": "~8.9.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@types/react": {
|
"node_modules/@types/react": {
|
||||||
@@ -4014,17 +3998,17 @@
|
|||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/@typescript-eslint/eslint-plugin": {
|
"node_modules/@typescript-eslint/eslint-plugin": {
|
||||||
"version": "8.73.0",
|
"version": "8.71.1",
|
||||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.73.0.tgz",
|
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.71.1.tgz",
|
||||||
"integrity": "sha512-UkygMFer53Yzn29MCYFTHf34hGXf5KJhiDWfIm1tXtXRrym1CS6l5H9Y3yCtPWChpC0/f93H88gdj8tN0dd4kw==",
|
"integrity": "sha512-nNlBf6HuotqMgZvSkWD5hNdemiBIxQ2NmrlgfcUIeZRs+BbakjscCQRq/Hb74EFVnFiSWWdL12JruqwBy3ERDw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@eslint-community/regexpp": "^4.12.2",
|
"@eslint-community/regexpp": "^4.12.2",
|
||||||
"@typescript-eslint/scope-manager": "8.73.0",
|
"@typescript-eslint/scope-manager": "8.71.1",
|
||||||
"@typescript-eslint/type-utils": "8.73.0",
|
"@typescript-eslint/type-utils": "8.71.1",
|
||||||
"@typescript-eslint/utils": "8.73.0",
|
"@typescript-eslint/utils": "8.71.1",
|
||||||
"@typescript-eslint/visitor-keys": "8.73.0",
|
"@typescript-eslint/visitor-keys": "8.71.1",
|
||||||
"ignore": "^7.0.5",
|
"ignore": "^7.0.5",
|
||||||
"natural-compare": "^1.4.0",
|
"natural-compare": "^1.4.0",
|
||||||
"ts-api-utils": "^2.5.0"
|
"ts-api-utils": "^2.5.0"
|
||||||
@@ -4037,15 +4021,15 @@
|
|||||||
"url": "https://opencollective.com/typescript-eslint"
|
"url": "https://opencollective.com/typescript-eslint"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@typescript-eslint/parser": "^8.73.0",
|
"@typescript-eslint/parser": "^8.71.1",
|
||||||
"eslint": "^8.57.0 || ^9.0.0 || ^10.0.0",
|
"eslint": "^8.57.0 || ^9.0.0 || ^10.0.0",
|
||||||
"typescript": ">=4.8.4 <6.1.0"
|
"typescript": ">=4.8.4 <6.1.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@typescript-eslint/eslint-plugin/node_modules/ignore": {
|
"node_modules/@typescript-eslint/eslint-plugin/node_modules/ignore": {
|
||||||
"version": "7.0.14",
|
"version": "7.0.12",
|
||||||
"resolved": "https://registry.npmjs.org/ignore/-/ignore-7.0.14.tgz",
|
"resolved": "https://registry.npmjs.org/ignore/-/ignore-7.0.12.tgz",
|
||||||
"integrity": "sha512-wCBiZ77u1tuWde6G/nfOtLaCTYcFDU5yCzARzK10y+rLhzYoL7a7yEemcopcc2Mzow7gZOIjnV2ym1NYmdiJOQ==",
|
"integrity": "sha512-/8UvqAPU9DGTI9k4mxtf49U37Isfwr8Uts96+SBHIkFxPJnHS0Ew4f00sM4Scd8V8EjM0jUNtVDdv1kPdt35lg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"engines": {
|
"engines": {
|
||||||
@@ -4053,16 +4037,16 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@typescript-eslint/parser": {
|
"node_modules/@typescript-eslint/parser": {
|
||||||
"version": "8.73.0",
|
"version": "8.71.1",
|
||||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.73.0.tgz",
|
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.71.1.tgz",
|
||||||
"integrity": "sha512-AuL45bVcmssHfZ3Di3cs9Q0l4gBm4ZFVrJOQEE7VpqW+PVgQaEwSwazz4TVIiFabXkk6U51EprYDwqw+HR8ePw==",
|
"integrity": "sha512-oM/5sAqz/l1v/zYK1qTOPrn2+JIrBGC1V6uNYucRO5gh6eT9vWJ/RhPbGE59byvZEUQ4VP6XkLBaS5Jti5jpvw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@typescript-eslint/scope-manager": "8.73.0",
|
"@typescript-eslint/scope-manager": "8.71.1",
|
||||||
"@typescript-eslint/types": "8.73.0",
|
"@typescript-eslint/types": "8.71.1",
|
||||||
"@typescript-eslint/typescript-estree": "8.73.0",
|
"@typescript-eslint/typescript-estree": "8.71.1",
|
||||||
"@typescript-eslint/visitor-keys": "8.73.0",
|
"@typescript-eslint/visitor-keys": "8.71.1",
|
||||||
"debug": "^4.4.3"
|
"debug": "^4.4.3"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
@@ -4078,14 +4062,14 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@typescript-eslint/project-service": {
|
"node_modules/@typescript-eslint/project-service": {
|
||||||
"version": "8.73.0",
|
"version": "8.71.1",
|
||||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/project-service/-/project-service-8.73.0.tgz",
|
"resolved": "https://registry.npmjs.org/@typescript-eslint/project-service/-/project-service-8.71.1.tgz",
|
||||||
"integrity": "sha512-/pEf8Rc4Mjk+qJnY0uO1+Gadeal8uv50xpuic+srG2vIVatA0XxvWMUeMtFvs6OCHqftiQ7/+qH4aehG5stzIA==",
|
"integrity": "sha512-Oijc9RUsohHjncg6iGi7gCtjnEjYt9FWv9u6ygK8uKcHK5eLjLAkqERQ9BaytbpceOFdk6kifPCS/zAZE+A99g==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@typescript-eslint/tsconfig-utils": "^8.73.0",
|
"@typescript-eslint/tsconfig-utils": "^8.71.1",
|
||||||
"@typescript-eslint/types": "^8.73.0",
|
"@typescript-eslint/types": "^8.71.1",
|
||||||
"debug": "^4.4.3"
|
"debug": "^4.4.3"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
@@ -4100,14 +4084,14 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@typescript-eslint/scope-manager": {
|
"node_modules/@typescript-eslint/scope-manager": {
|
||||||
"version": "8.73.0",
|
"version": "8.71.1",
|
||||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.73.0.tgz",
|
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.71.1.tgz",
|
||||||
"integrity": "sha512-/TjD738Iq2rzj5z0ixVOi+TsvgjAzZPLPaH1yWdDBytR/HTR5gMpyYWZeCe5WTQZLwk3ho8AV7U3muoQCRtXBQ==",
|
"integrity": "sha512-1YUDZXdTnXLlob03SFHBipdyMBsDVm7zoSz0ytTJ39dk5J1TgsTK03VlR/dLXG/RLLUrPcYbD4rp23BmHxHP0w==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@typescript-eslint/types": "8.73.0",
|
"@typescript-eslint/types": "8.71.1",
|
||||||
"@typescript-eslint/visitor-keys": "8.73.0"
|
"@typescript-eslint/visitor-keys": "8.71.1"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||||
@@ -4118,9 +4102,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@typescript-eslint/tsconfig-utils": {
|
"node_modules/@typescript-eslint/tsconfig-utils": {
|
||||||
"version": "8.73.0",
|
"version": "8.71.1",
|
||||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/tsconfig-utils/-/tsconfig-utils-8.73.0.tgz",
|
"resolved": "https://registry.npmjs.org/@typescript-eslint/tsconfig-utils/-/tsconfig-utils-8.71.1.tgz",
|
||||||
"integrity": "sha512-lmtCFOfYaJfpqZywGuXi4FpNtE+NQ+YLe3T0K9rtEDcW8ZuGWvfI++pj8r05sYMI8vWT2CYK4rWyedmD6Rp4og==",
|
"integrity": "sha512-oTvkml5SxXhgg+WWKhod5qWQICDXtOB+/Hi9VdPKFAANJ2b7YOgMffgvzXuqog7R6A/JtrzRf128dsxummyWhg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"engines": {
|
"engines": {
|
||||||
@@ -4135,15 +4119,15 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@typescript-eslint/type-utils": {
|
"node_modules/@typescript-eslint/type-utils": {
|
||||||
"version": "8.73.0",
|
"version": "8.71.1",
|
||||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.73.0.tgz",
|
"resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.71.1.tgz",
|
||||||
"integrity": "sha512-MOC9i4xy1F7KcDde7Ip8jf1SrRiALb2Km4UWxGNjUE2YlhjIEo1ayE27GHIwIQyfWuHTmEonQT14uyurlyC6aA==",
|
"integrity": "sha512-kH3t3jZCYv2PZSBEWPKTariLrCaoF1CLoPitYFBJOhAGEwWnSRAtGEifrfrpBa4K9JlwWNZotgA5w3/wLSk/FQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@typescript-eslint/types": "8.73.0",
|
"@typescript-eslint/types": "8.71.1",
|
||||||
"@typescript-eslint/typescript-estree": "8.73.0",
|
"@typescript-eslint/typescript-estree": "8.71.1",
|
||||||
"@typescript-eslint/utils": "8.73.0",
|
"@typescript-eslint/utils": "8.71.1",
|
||||||
"debug": "^4.4.3",
|
"debug": "^4.4.3",
|
||||||
"ts-api-utils": "^2.5.0"
|
"ts-api-utils": "^2.5.0"
|
||||||
},
|
},
|
||||||
@@ -4160,9 +4144,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@typescript-eslint/types": {
|
"node_modules/@typescript-eslint/types": {
|
||||||
"version": "8.73.0",
|
"version": "8.71.1",
|
||||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.73.0.tgz",
|
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.71.1.tgz",
|
||||||
"integrity": "sha512-O/1ytYzflF16QDKXx4/qOXg1IuZp+n7hr9t+S0nv7N/2Tl8rJiNCshztV1gcSUvHbPtoX3+zmNbtSAyVbzxVfw==",
|
"integrity": "sha512-ybYnPTUwg3VQQOFEiBPLs8Jxl1ry2vXdn1kVKguomBbvxpetdu3MKTNDqFNUrlG8ylP9MpZosmXMFYlGQHk1oQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"engines": {
|
"engines": {
|
||||||
@@ -4174,18 +4158,18 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@typescript-eslint/typescript-estree": {
|
"node_modules/@typescript-eslint/typescript-estree": {
|
||||||
"version": "8.73.0",
|
"version": "8.71.1",
|
||||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.73.0.tgz",
|
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.71.1.tgz",
|
||||||
"integrity": "sha512-InjlBkSdWceIwIBWSwS3ENUp+i0O02PGX3Zv2wnihWJC1WDVGvG7mTHuf8b57uAaITj94d6tRPDH+sUEtXdRQQ==",
|
"integrity": "sha512-pSKSEK1JJpHs6KiKVtABCE4iJK5d7FLFzDXQNBQ2oRY7LEd3UwOt3TZemTgu9syTIf56dJWlTn/pdmrO9oKUXQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@typescript-eslint/project-service": "8.73.0",
|
"@typescript-eslint/project-service": "8.71.1",
|
||||||
"@typescript-eslint/tsconfig-utils": "8.73.0",
|
"@typescript-eslint/tsconfig-utils": "8.71.1",
|
||||||
"@typescript-eslint/types": "8.73.0",
|
"@typescript-eslint/types": "8.71.1",
|
||||||
"@typescript-eslint/visitor-keys": "8.73.0",
|
"@typescript-eslint/visitor-keys": "8.71.1",
|
||||||
"debug": "^4.4.3",
|
"debug": "^4.4.3",
|
||||||
"minimatch": "^11.0.1",
|
"minimatch": "^10.2.2",
|
||||||
"semver": "^7.7.3",
|
"semver": "^7.7.3",
|
||||||
"tinyglobby": "^0.2.15",
|
"tinyglobby": "^0.2.15",
|
||||||
"ts-api-utils": "^2.5.0"
|
"ts-api-utils": "^2.5.0"
|
||||||
@@ -4198,13 +4182,7 @@
|
|||||||
"url": "https://opencollective.com/typescript-eslint"
|
"url": "https://opencollective.com/typescript-eslint"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@typescript/native": "npm:typescript@>=7.1.0-dev.20261009.1 || >=7.1.0-beta <7.1.0-dev",
|
|
||||||
"typescript": ">=4.8.4 <6.1.0"
|
"typescript": ">=4.8.4 <6.1.0"
|
||||||
},
|
|
||||||
"peerDependenciesMeta": {
|
|
||||||
"@typescript/native": {
|
|
||||||
"optional": true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@typescript-eslint/typescript-estree/node_modules/balanced-match": {
|
"node_modules/@typescript-eslint/typescript-estree/node_modules/balanced-match": {
|
||||||
@@ -4218,9 +4196,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@typescript-eslint/typescript-estree/node_modules/brace-expansion": {
|
"node_modules/@typescript-eslint/typescript-estree/node_modules/brace-expansion": {
|
||||||
"version": "5.0.13",
|
"version": "5.0.12",
|
||||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.13.tgz",
|
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.12.tgz",
|
||||||
"integrity": "sha512-Vh3dmFbc4wZeox7M9I/0L9GfFd83Su4+yCck/OF9Gi/P/dAHn0RT7X4K9R7gMNMhDck3DvhR6QXsnQdjjgwNvQ==",
|
"integrity": "sha512-YovQ3rzhaLMIrDjNDMkNS01tea93qhEhG5xy8f6+R0l+dw3Ki+5sCoIoI942iuLZTHWogWktgwVDhU09iNEimQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -4231,26 +4209,25 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@typescript-eslint/typescript-estree/node_modules/minimatch": {
|
"node_modules/@typescript-eslint/typescript-estree/node_modules/minimatch": {
|
||||||
"version": "11.0.9",
|
"version": "10.2.6",
|
||||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-11.0.9.tgz",
|
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.2.6.tgz",
|
||||||
"integrity": "sha512-KCFkfyjqerNlSstjlhIGNXIKZGA/6O4V4RlhZ+Dsr621SPPw0mzlypE9D9ZOoPiVefHID+j7/XuMMlqfD/F60Q==",
|
"integrity": "sha512-vpLQEs+VLCr1nU0BXS07maYoFwlDAH0gngQuuttxIwutDFEMHq2blX+8vpgxDdK3J1PwjCJiep77OitTZ4Ll1A==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "BlueOak-1.0.0",
|
"license": "BlueOak-1.0.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@isaacs/nonrecursive-glob-match": "^1.1.0",
|
"brace-expansion": "^5.0.8"
|
||||||
"brace-expansion": "^5.0.12"
|
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "20 || >=22"
|
"node": "18 || 20 || >=22"
|
||||||
},
|
},
|
||||||
"funding": {
|
"funding": {
|
||||||
"url": "https://github.com/sponsors/isaacs"
|
"url": "https://github.com/sponsors/isaacs"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@typescript-eslint/typescript-estree/node_modules/semver": {
|
"node_modules/@typescript-eslint/typescript-estree/node_modules/semver": {
|
||||||
"version": "7.8.6",
|
"version": "7.8.5",
|
||||||
"resolved": "https://registry.npmjs.org/semver/-/semver-7.8.6.tgz",
|
"resolved": "https://registry.npmjs.org/semver/-/semver-7.8.5.tgz",
|
||||||
"integrity": "sha512-9lpSSU4Mly3mrtruwLs1eLK6+gzbzqeBFwRNjIjE+9LuDpWdYctrQlQ3ej1Ilgi7gknpsTRnPoLP8DpCHqHIJw==",
|
"integrity": "sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"bin": {
|
"bin": {
|
||||||
@@ -4261,16 +4238,16 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@typescript-eslint/utils": {
|
"node_modules/@typescript-eslint/utils": {
|
||||||
"version": "8.73.0",
|
"version": "8.71.1",
|
||||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.73.0.tgz",
|
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.71.1.tgz",
|
||||||
"integrity": "sha512-j2SVJJvVkXdUL0WcEzo4vEH1mO1vIi8KlVukcYA2MgMZvYN2LlZR4PmsW+GTSxSW24j6Q/EP7+MOifLtg5hmsA==",
|
"integrity": "sha512-CBjT6gfAz3DW2j9Q4moFnqt208Aq+506sVGXfpRcyAeqn0EpayL0mjdWoCO2t3RC7GewNrFxdeehuEaPg6DMzQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@eslint-community/eslint-utils": "^4.9.1",
|
"@eslint-community/eslint-utils": "^4.9.1",
|
||||||
"@typescript-eslint/scope-manager": "8.73.0",
|
"@typescript-eslint/scope-manager": "8.71.1",
|
||||||
"@typescript-eslint/types": "8.73.0",
|
"@typescript-eslint/types": "8.71.1",
|
||||||
"@typescript-eslint/typescript-estree": "8.73.0"
|
"@typescript-eslint/typescript-estree": "8.71.1"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||||
@@ -4285,13 +4262,13 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@typescript-eslint/visitor-keys": {
|
"node_modules/@typescript-eslint/visitor-keys": {
|
||||||
"version": "8.73.0",
|
"version": "8.71.1",
|
||||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.73.0.tgz",
|
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.71.1.tgz",
|
||||||
"integrity": "sha512-k4lsFVpRZICbltkIEEH4hZRkwXkqDF1GHBpClKQOHQY+RkoZAAuyc1ci3I6p+CB6v3U4jaHIUshc4RzzQXZWLg==",
|
"integrity": "sha512-0GxiUGqMU0qXJt58cBsiG3DP8lUmBaFo2vChtUX+CT7PnR3v/VGLLrzVP4K9r1lNiZXjHYefMBbPunplr09v6w==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@typescript-eslint/types": "8.73.0",
|
"@typescript-eslint/types": "8.71.1",
|
||||||
"eslint-visitor-keys": "^5.0.0"
|
"eslint-visitor-keys": "^5.0.0"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
@@ -5165,15 +5142,15 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/cn": {
|
"node_modules/cn": {
|
||||||
"version": "0.5.2",
|
"version": "0.4.0",
|
||||||
"resolved": "https://registry.npmjs.org/cn/-/cn-0.5.2.tgz",
|
"resolved": "https://registry.npmjs.org/cn/-/cn-0.4.0.tgz",
|
||||||
"integrity": "sha512-wm10E6iuJ37rALOw3D+3cfaXXZSLNMh2uxpQn3dNICqfJM59yXqgbA9/9Iiz155j5kYNLdK6WreNdW3NQtx3OQ==",
|
"integrity": "sha512-qOAeUhPwPzBxx6jaeQdo646XIKliKHc2j1ZF7Ngb1o0pJZKH5gq8FkA0aVdUdPFUDXNXyUCXpCtoJISo6dhizg==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"bin": {
|
"bin": {
|
||||||
"cn": "bin/cn.mjs"
|
"cn": "bin/cn.mjs"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=22"
|
"node": ">=20"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/color-convert": {
|
"node_modules/color-convert": {
|
||||||
@@ -5415,9 +5392,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/dompurify": {
|
"node_modules/dompurify": {
|
||||||
"version": "3.4.18",
|
"version": "3.4.16",
|
||||||
"resolved": "https://registry.npmjs.org/dompurify/-/dompurify-3.4.18.tgz",
|
"resolved": "https://registry.npmjs.org/dompurify/-/dompurify-3.4.16.tgz",
|
||||||
"integrity": "sha512-ofe3wI/uNm68HInABYFJYqQxRw1EaKAjNdrFVKqjUY+UZurvNd2L/HuQe097s/4RivWiZyP6tT7aoT8atjfhwg==",
|
"integrity": "sha512-sqo+pNp3qRhCIpbgRi1y8Tgk27Bo2Ry7w0dC1NBeNTdZChWjz9Xb/KOoZbRP/R6pQZ80Qw8YhXw13hWWBbMRnQ==",
|
||||||
"license": "(MPL-2.0 OR Apache-2.0)",
|
"license": "(MPL-2.0 OR Apache-2.0)",
|
||||||
"optionalDependencies": {
|
"optionalDependencies": {
|
||||||
"@types/trusted-types": "^2.0.7"
|
"@types/trusted-types": "^2.0.7"
|
||||||
@@ -5808,13 +5785,13 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/eslint-config-next": {
|
"node_modules/eslint-config-next": {
|
||||||
"version": "16.4.6",
|
"version": "16.4.3",
|
||||||
"resolved": "https://registry.npmjs.org/eslint-config-next/-/eslint-config-next-16.4.6.tgz",
|
"resolved": "https://registry.npmjs.org/eslint-config-next/-/eslint-config-next-16.4.3.tgz",
|
||||||
"integrity": "sha512-IBGGrVf9E6pL0NGL0hmeicVGeSyv1VEzIWq6IecDqkw+YFByhEtDJS9u1r6s6a1VxK6rssh69KyNFQUgfaacqw==",
|
"integrity": "sha512-j9IqBma6abp800frdUURaizYMgXOK+jNGyq6CsYcM9AxpSJs5D/TgMNGeAmRUilZvA7g9V1Tr71gNg9/SVTuMQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@next/eslint-plugin-next": "16.4.6",
|
"@next/eslint-plugin-next": "16.4.3",
|
||||||
"eslint-import-resolver-node": "^0.3.6",
|
"eslint-import-resolver-node": "^0.3.6",
|
||||||
"eslint-import-resolver-typescript": "^3.5.2",
|
"eslint-import-resolver-typescript": "^3.5.2",
|
||||||
"eslint-plugin-import": "^2.32.0",
|
"eslint-plugin-import": "^2.32.0",
|
||||||
@@ -7746,12 +7723,12 @@
|
|||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/next": {
|
"node_modules/next": {
|
||||||
"version": "16.4.6",
|
"version": "16.4.3",
|
||||||
"resolved": "https://registry.npmjs.org/next/-/next-16.4.6.tgz",
|
"resolved": "https://registry.npmjs.org/next/-/next-16.4.3.tgz",
|
||||||
"integrity": "sha512-QZJiYhaZLJMo2KpkQGQIwvmd79WVsAWeYIU554a8d7zArS3si/IRy3lBNV/rtYhE70oLwdLYhPAXLPx8HwcwtA==",
|
"integrity": "sha512-OqxKTGi9u80FydydsMNYNjnuje9Au+kvHlt2GZ//ftdpDHm1dxKqAaENoOOTX5wKzn+9vaKUNIfZeyZUuLhCnA==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@next/env": "16.4.6",
|
"@next/env": "16.4.3",
|
||||||
"@swc/helpers": "0.5.23",
|
"@swc/helpers": "0.5.23",
|
||||||
"baseline-browser-mapping": "^2.9.19",
|
"baseline-browser-mapping": "^2.9.19",
|
||||||
"caniuse-lite": "^1.0.30001579",
|
"caniuse-lite": "^1.0.30001579",
|
||||||
@@ -7765,14 +7742,14 @@
|
|||||||
"node": ">=20.9.0"
|
"node": ">=20.9.0"
|
||||||
},
|
},
|
||||||
"optionalDependencies": {
|
"optionalDependencies": {
|
||||||
"@next/swc-darwin-arm64": "16.4.6",
|
"@next/swc-darwin-arm64": "16.4.3",
|
||||||
"@next/swc-darwin-x64": "16.4.6",
|
"@next/swc-darwin-x64": "16.4.3",
|
||||||
"@next/swc-linux-arm64-gnu": "16.4.6",
|
"@next/swc-linux-arm64-gnu": "16.4.3",
|
||||||
"@next/swc-linux-arm64-musl": "16.4.6",
|
"@next/swc-linux-arm64-musl": "16.4.3",
|
||||||
"@next/swc-linux-x64-gnu": "16.4.6",
|
"@next/swc-linux-x64-gnu": "16.4.3",
|
||||||
"@next/swc-linux-x64-musl": "16.4.6",
|
"@next/swc-linux-x64-musl": "16.4.3",
|
||||||
"@next/swc-win32-arm64-msvc": "16.4.6",
|
"@next/swc-win32-arm64-msvc": "16.4.3",
|
||||||
"@next/swc-win32-x64-msvc": "16.4.6",
|
"@next/swc-win32-x64-msvc": "16.4.3",
|
||||||
"sharp": "^0.35.5"
|
"sharp": "^0.35.5"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
@@ -9242,6 +9219,16 @@
|
|||||||
"url": "https://github.com/sponsors/ljharb"
|
"url": "https://github.com/sponsors/ljharb"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/tailwind-merge": {
|
||||||
|
"version": "3.7.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/tailwind-merge/-/tailwind-merge-3.7.0.tgz",
|
||||||
|
"integrity": "sha512-XPPUyAc+cvspz3lHTcR/QgPfW2A0lv/xQNIjX3HGhLR+Nq2lHaLq5MtTesHn8GUr3W3DguT2KT5x3NVgRtYwmA==",
|
||||||
|
"license": "MIT",
|
||||||
|
"funding": {
|
||||||
|
"type": "github",
|
||||||
|
"url": "https://github.com/sponsors/dcastil"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/tailwindcss": {
|
"node_modules/tailwindcss": {
|
||||||
"version": "4.3.3",
|
"version": "4.3.3",
|
||||||
"resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-4.3.3.tgz",
|
"resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-4.3.3.tgz",
|
||||||
@@ -9484,16 +9471,16 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/typescript-eslint": {
|
"node_modules/typescript-eslint": {
|
||||||
"version": "8.73.0",
|
"version": "8.71.1",
|
||||||
"resolved": "https://registry.npmjs.org/typescript-eslint/-/typescript-eslint-8.73.0.tgz",
|
"resolved": "https://registry.npmjs.org/typescript-eslint/-/typescript-eslint-8.71.1.tgz",
|
||||||
"integrity": "sha512-+EnKy9rkYPun4l+kG2bDuYWQ6y1tGVgdR/tY1U9AC6h21CjEwOoc7gsjwe0FXB8uWFzk4QiCFbuRWgX758PiAg==",
|
"integrity": "sha512-oiNVPC3/NbV1FpaHU07l8O6ynqG9v4PAiW2WvTrAmZdR0f2HI/gE668ElMLCK7Xbsu5k2fK5C4fXNiq05j7/nQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@typescript-eslint/eslint-plugin": "8.73.0",
|
"@typescript-eslint/eslint-plugin": "8.71.1",
|
||||||
"@typescript-eslint/parser": "8.73.0",
|
"@typescript-eslint/parser": "8.71.1",
|
||||||
"@typescript-eslint/typescript-estree": "8.73.0",
|
"@typescript-eslint/typescript-estree": "8.71.1",
|
||||||
"@typescript-eslint/utils": "8.73.0"
|
"@typescript-eslint/utils": "8.71.1"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||||
@@ -9527,9 +9514,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/undici-types": {
|
"node_modules/undici-types": {
|
||||||
"version": "7.24.6",
|
"version": "8.9.0",
|
||||||
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.24.6.tgz",
|
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-8.9.0.tgz",
|
||||||
"integrity": "sha512-WRNW+sJgj5OBN4/0JpHFqtqzhpbnV0GuB+OozA9gCL7a993SmU+1JBZCzLNxYsbMfIeDL+lTsphD5jN5N+n0zg==",
|
"integrity": "sha512-KTDyRTYX8sWmKXAikPHHSyc63CRPETMctyjKFupcC6OBLXT3xsN0e9aF7m+mIXutFWpUXuedtowG7iLOzp0kQg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
|
|||||||
16
package.json
16
package.json
@@ -13,7 +13,7 @@
|
|||||||
"@dnd-kit/core": "^6.3.1",
|
"@dnd-kit/core": "^6.3.1",
|
||||||
"@dnd-kit/sortable": "^10.0.0",
|
"@dnd-kit/sortable": "^10.0.0",
|
||||||
"@dnd-kit/utilities": "^3.2.2",
|
"@dnd-kit/utilities": "^3.2.2",
|
||||||
"@kri/common": "^0.20.0",
|
"@kri/common": "^0.19.1",
|
||||||
"@tanstack/react-query": "latest",
|
"@tanstack/react-query": "latest",
|
||||||
"@tanstack/react-table": "^8.21.3",
|
"@tanstack/react-table": "^8.21.3",
|
||||||
"@tiptap/extension-color": "^3.31.4",
|
"@tiptap/extension-color": "^3.31.4",
|
||||||
@@ -32,34 +32,36 @@
|
|||||||
"@tiptap/react": "^3.31.4",
|
"@tiptap/react": "^3.31.4",
|
||||||
"@tiptap/starter-kit": "^3.31.4",
|
"@tiptap/starter-kit": "^3.31.4",
|
||||||
"class-variance-authority": "latest",
|
"class-variance-authority": "latest",
|
||||||
|
"clsx": "latest",
|
||||||
"cmdk": "^1.1.1",
|
"cmdk": "^1.1.1",
|
||||||
"cn": "0.5.2",
|
"cn": "^0.4.0",
|
||||||
"d3-cloud": "^1.2.9",
|
"d3-cloud": "^1.2.9",
|
||||||
"date-fns": "^4.4.0",
|
"date-fns": "^4.4.0",
|
||||||
"dompurify": "^3.4.18",
|
"dompurify": "^3.4.16",
|
||||||
"echarts": "^6.1.0",
|
"echarts": "^6.1.0",
|
||||||
"echarts-for-react": "^3.0.6",
|
"echarts-for-react": "^3.0.6",
|
||||||
"embla-carousel-react": "^8.6.0",
|
"embla-carousel-react": "^8.6.0",
|
||||||
"jotai": "latest",
|
"jotai": "latest",
|
||||||
"lucide-react": "latest",
|
"lucide-react": "latest",
|
||||||
"next": "~16.4.6",
|
"next": "~16.4.1",
|
||||||
"prettier": "^3.9.10",
|
"prettier": "^3.9.10",
|
||||||
"radix-ui": "^1.8.0",
|
"radix-ui": "^1.8.0",
|
||||||
"react": "latest",
|
"react": "latest",
|
||||||
"react-day-picker": "^10.0.2",
|
"react-day-picker": "^10.0.2",
|
||||||
"react-dom": "latest",
|
"react-dom": "latest",
|
||||||
"server-only": "latest",
|
"server-only": "latest",
|
||||||
"sonner": "latest"
|
"sonner": "latest",
|
||||||
|
"tailwind-merge": "latest"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@tailwindcss/postcss": "latest",
|
"@tailwindcss/postcss": "latest",
|
||||||
"@types/d3-cloud": "^1.2.9",
|
"@types/d3-cloud": "^1.2.9",
|
||||||
"@types/node": "^24.19.2",
|
"@types/node": "latest",
|
||||||
"@types/react": "latest",
|
"@types/react": "latest",
|
||||||
"@types/react-dom": "latest",
|
"@types/react-dom": "latest",
|
||||||
"babel-plugin-react-compiler": "latest",
|
"babel-plugin-react-compiler": "latest",
|
||||||
"eslint": "^9",
|
"eslint": "^9",
|
||||||
"eslint-config-next": "~16.4.6",
|
"eslint-config-next": "~16.4.1",
|
||||||
"playwright": "^1.64.1",
|
"playwright": "^1.64.1",
|
||||||
"tailwindcss": "latest",
|
"tailwindcss": "latest",
|
||||||
"tw-animate-css": "latest",
|
"tw-animate-css": "latest",
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
import { AuthSessionGate } from "@/components/app-shell/AuthSessionGate";
|
import { cookies } from "next/headers";
|
||||||
|
import { redirect } from "next/navigation";
|
||||||
import { AppMainLayout } from "@/components/app-shell/AppMainLayout";
|
import { AppMainLayout } from "@/components/app-shell/AppMainLayout";
|
||||||
|
import { CookieKeys } from "@/store/cookie/cookie-keys";
|
||||||
|
|
||||||
export const dynamic = "force-dynamic";
|
export default async function MainLayout({ children }: Readonly<{ children: React.ReactNode }>) {
|
||||||
|
const cookieStore = await cookies();
|
||||||
export default function MainLayout({ children }: Readonly<{ children: React.ReactNode }>) {
|
const accessToken = cookieStore.get(CookieKeys.AuthToken)?.value;
|
||||||
// External JWTs live in this tab, so authentication is checked after hydration.
|
if (!accessToken) redirect("/logout");
|
||||||
// Every BFF/API request still enforces verified server authentication and scope.
|
return <AppMainLayout>{children}</AppMainLayout>;
|
||||||
return <AuthSessionGate><AppMainLayout>{children}</AppMainLayout></AuthSessionGate>;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,20 +3,18 @@
|
|||||||
import { useEffect, useRef } from "react";
|
import { useEffect, useRef } from "react";
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import { useLogoutMutation } from "@/query/auth";
|
import { useLogoutMutation } from "@/query/auth";
|
||||||
import { useAuth } from "@/hooks/useAuth";
|
|
||||||
import { LoadingOverlayAdapter } from "@/components/app-shell/LoadingOverlayAdapter";
|
import { LoadingOverlayAdapter } from "@/components/app-shell/LoadingOverlayAdapter";
|
||||||
|
|
||||||
export default function LogoutPage() {
|
export default function LogoutPage() {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { hydrated } = useAuth();
|
|
||||||
const logoutMutation = useLogoutMutation();
|
const logoutMutation = useLogoutMutation();
|
||||||
const started = useRef(false);
|
const started = useRef(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!hydrated || started.current) return;
|
if (started.current) return;
|
||||||
started.current = true;
|
started.current = true;
|
||||||
void logoutMutation.mutateAsync().finally(() => router.replace("/login"));
|
void logoutMutation.mutateAsync().finally(() => router.replace("/login"));
|
||||||
}, [hydrated, logoutMutation, router]);
|
}, [logoutMutation, router]);
|
||||||
|
|
||||||
return <LoadingOverlayAdapter force label="로그아웃 중" />;
|
return <LoadingOverlayAdapter force label="로그아웃 중" />;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,22 +0,0 @@
|
|||||||
import { NextResponse } from "next/server";
|
|
||||||
import { errorToResponse } from "@kri/common/http";
|
|
||||||
import { createServerApi } from "@/lib/http-server";
|
|
||||||
import { isLoginUser } from "@/types/kart";
|
|
||||||
|
|
||||||
export async function GET(_request: Request, context: { params: Promise<{ slug?: string[] }> }) {
|
|
||||||
const { slug = [] } = await context.params;
|
|
||||||
if (slug.length !== 1 || slug[0] !== "my-info")
|
|
||||||
return NextResponse.json({ message: "Not found" }, { status: 404, headers: { "Cache-Control": "no-store" } });
|
|
||||||
try {
|
|
||||||
const api = await createServerApi();
|
|
||||||
const user = await api.get<unknown>("/auth/my-info", { cache: "no-store" });
|
|
||||||
if (!isLoginUser(user)) {
|
|
||||||
return NextResponse.json({ message: "Invalid user response" }, { status: 502, headers: { "Cache-Control": "no-store" } });
|
|
||||||
}
|
|
||||||
return NextResponse.json({ userId: user.userId, userName: user.userName, userCmpn: user.userCmpn, userTeam: user.userTeam, userRole: user.userRole }, { headers: { "Cache-Control": "no-store" } });
|
|
||||||
} catch (error) {
|
|
||||||
const response = errorToResponse(error);
|
|
||||||
response.headers.set("Cache-Control", "no-store");
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
import { NextRequest, NextResponse } from "next/server";
|
import { NextRequest, NextResponse } from "next/server";
|
||||||
|
import { cookies } from "next/headers";
|
||||||
import { errorToResponse } from "@kri/common/http";
|
import { errorToResponse } from "@kri/common/http";
|
||||||
import { createServerApi, getServerAccessToken } from "@/lib/http-server";
|
import { createServerApi } from "@/lib/http-server";
|
||||||
import {
|
import {
|
||||||
bookmarkUpstreamPath,
|
bookmarkUpstreamPath,
|
||||||
isBookmarkCreatePath,
|
isBookmarkCreatePath,
|
||||||
@@ -8,6 +9,7 @@ import {
|
|||||||
isBookmarkListPath,
|
isBookmarkListPath,
|
||||||
} from "@/lib/project-proxy-policy";
|
} from "@/lib/project-proxy-policy";
|
||||||
import { isBookmarkPage, readBookmarkSaveRequest } from "@/types/bookmark";
|
import { isBookmarkPage, readBookmarkSaveRequest } from "@/types/bookmark";
|
||||||
|
import { CookieKeys } from "@/store/cookie/cookie-keys";
|
||||||
import type { RouteContext } from "@/types/common";
|
import type { RouteContext } from "@/types/common";
|
||||||
|
|
||||||
const notFound = () =>
|
const notFound = () =>
|
||||||
@@ -17,7 +19,7 @@ const unauthorized = () =>
|
|||||||
const badRequest = () =>
|
const badRequest = () =>
|
||||||
NextResponse.json({ message: "북마크 저장 내용을 확인해 주세요." }, { status: 400 });
|
NextResponse.json({ message: "북마크 저장 내용을 확인해 주세요." }, { status: 400 });
|
||||||
const noStore = { headers: { "Cache-Control": "no-store" } };
|
const noStore = { headers: { "Cache-Control": "no-store" } };
|
||||||
const loggedIn = async () => !!(await getServerAccessToken());
|
const loggedIn = async () => !!(await cookies()).get(CookieKeys.AuthToken)?.value;
|
||||||
|
|
||||||
export async function GET(request: NextRequest, context: RouteContext) {
|
export async function GET(request: NextRequest, context: RouteContext) {
|
||||||
const { slug = [] } = await context.params;
|
const { slug = [] } = await context.params;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { NextRequest, NextResponse } from "next/server";
|
import { NextRequest, NextResponse } from "next/server";
|
||||||
|
import { cookies } from "next/headers";
|
||||||
import { errorToResponse } from "@kri/common/http";
|
import { errorToResponse } from "@kri/common/http";
|
||||||
import { createServerApi, getServerAccessToken } from "@/lib/http-server";
|
import { createServerApi } from "@/lib/http-server";
|
||||||
import {
|
import {
|
||||||
derivedUpstreamPath,
|
derivedUpstreamPath,
|
||||||
isDerivedCreatePath,
|
isDerivedCreatePath,
|
||||||
@@ -8,6 +9,7 @@ import {
|
|||||||
isDerivedListPath,
|
isDerivedListPath,
|
||||||
} from "@/lib/project-proxy-policy";
|
} from "@/lib/project-proxy-policy";
|
||||||
import { readDerivedSaveRequest } from "@/types/derived";
|
import { readDerivedSaveRequest } from "@/types/derived";
|
||||||
|
import { CookieKeys } from "@/store/cookie/cookie-keys";
|
||||||
import type { RouteContext } from "@/types/common";
|
import type { RouteContext } from "@/types/common";
|
||||||
|
|
||||||
const notFound = () =>
|
const notFound = () =>
|
||||||
@@ -15,7 +17,7 @@ const notFound = () =>
|
|||||||
const unauthorized = () =>
|
const unauthorized = () =>
|
||||||
NextResponse.json({ message: "로그인이 필요합니다." }, { status: 401 });
|
NextResponse.json({ message: "로그인이 필요합니다." }, { status: 401 });
|
||||||
const noStore = { headers: { "Cache-Control": "no-store" } };
|
const noStore = { headers: { "Cache-Control": "no-store" } };
|
||||||
const loggedIn = async () => !!(await getServerAccessToken());
|
const loggedIn = async () => !!(await cookies()).get(CookieKeys.AuthToken)?.value;
|
||||||
|
|
||||||
export async function GET(_request: NextRequest, context: RouteContext) {
|
export async function GET(_request: NextRequest, context: RouteContext) {
|
||||||
const { slug = [] } = await context.params;
|
const { slug = [] } = await context.params;
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
import { NextRequest, NextResponse } from "next/server";
|
import { NextRequest, NextResponse } from "next/server";
|
||||||
|
import { cookies } from "next/headers";
|
||||||
import { errorToResponse } from "@kri/common/http";
|
import { errorToResponse } from "@kri/common/http";
|
||||||
import { createServerApi, getServerAccessToken } from "@/lib/http-server";
|
import { createServerApi } from "@/lib/http-server";
|
||||||
import { exportTarget } from "@/lib/project-proxy-policy";
|
import { exportTarget } from "@/lib/project-proxy-policy";
|
||||||
import { readExcelRequest, readRawDataRequest } from "@/types/export";
|
import { readExcelRequest, readRawDataRequest } from "@/types/export";
|
||||||
|
import { CookieKeys } from "@/store/cookie/cookie-keys";
|
||||||
import type { RouteContext } from "@/types/common";
|
import type { RouteContext } from "@/types/common";
|
||||||
|
|
||||||
// Workbooks for large projects take a while to build on the server.
|
// Workbooks for large projects take a while to build on the server.
|
||||||
@@ -18,7 +20,7 @@ async function download(request: NextRequest, context: RouteContext, method: "GE
|
|||||||
const target = exportTarget(method, slug);
|
const target = exportTarget(method, slug);
|
||||||
if (!target)
|
if (!target)
|
||||||
return NextResponse.json({ message: "지원하지 않는 경로입니다." }, { status: 404 });
|
return NextResponse.json({ message: "지원하지 않는 경로입니다." }, { status: 404 });
|
||||||
if (!(await getServerAccessToken()))
|
if (!(await cookies()).get(CookieKeys.AuthToken)?.value)
|
||||||
return NextResponse.json({ message: "로그인이 필요합니다." }, { status: 401 });
|
return NextResponse.json({ message: "로그인이 필요합니다." }, { status: 401 });
|
||||||
let body: unknown;
|
let body: unknown;
|
||||||
if (target.body !== "none") {
|
if (target.body !== "none") {
|
||||||
|
|||||||
13
src/app/api/external/[urlkey]/login/route.ts
vendored
13
src/app/api/external/[urlkey]/login/route.ts
vendored
@@ -1,17 +1,21 @@
|
|||||||
import { NextRequest, NextResponse } from "next/server";
|
import { NextRequest, NextResponse } from "next/server";
|
||||||
import { errorToResponse } from "@kri/common/http";
|
import { errorToResponse } from "@kri/common/http";
|
||||||
|
import { AUTH_COOKIE_MAX_AGE } from "@/const/common.const";
|
||||||
|
import { serverEnv } from "@/lib/env.server";
|
||||||
import { createServerApi } from "@/lib/http-server";
|
import { createServerApi } from "@/lib/http-server";
|
||||||
|
import { CookieKeys } from "@/store/cookie/cookie-keys";
|
||||||
import { isRecord } from "@/types/kart";
|
import { isRecord } from "@/types/kart";
|
||||||
import { isExternalSession, isUrlKey } from "@/types/share";
|
import { isExternalSession, isUrlKey } from "@/types/share";
|
||||||
|
|
||||||
export async function POST(_request: NextRequest, context: { params: Promise<{ urlkey: string }> }) {
|
export async function POST(_request: NextRequest, context: { params: Promise<{ urlkey: string }> }) {
|
||||||
const { urlkey } = await context.params;
|
const { urlkey } = await context.params;
|
||||||
let response: NextResponse;
|
let response: NextResponse;
|
||||||
|
let token = "";
|
||||||
try {
|
try {
|
||||||
if (!isUrlKey(urlkey)) {
|
if (!isUrlKey(urlkey)) {
|
||||||
response = NextResponse.json({ message: "공유 링크를 찾을 수 없습니다." }, { status: 404 });
|
response = NextResponse.json({ message: "공유 링크를 찾을 수 없습니다." }, { status: 404 });
|
||||||
} else {
|
} else {
|
||||||
// A link login issues a tab-scoped credential without touching normal-login cookies.
|
// Link login replaces the previous identity, including an expired credential cookie.
|
||||||
const api = await createServerApi(false);
|
const api = await createServerApi(false);
|
||||||
const result = await api.post<unknown>(`/external/${urlkey}/login`, null, { cache: "no-store" });
|
const result = await api.post<unknown>(`/external/${urlkey}/login`, null, { cache: "no-store" });
|
||||||
const accessToken = isRecord(result) ? result.accessToken : null;
|
const accessToken = isRecord(result) ? result.accessToken : null;
|
||||||
@@ -19,7 +23,8 @@ export async function POST(_request: NextRequest, context: { params: Promise<{ u
|
|||||||
typeof accessToken !== "string" || !accessToken) {
|
typeof accessToken !== "string" || !accessToken) {
|
||||||
response = NextResponse.json({ message: "공유 링크 로그인 응답을 확인해 주세요." }, { status: 502 });
|
response = NextResponse.json({ message: "공유 링크 로그인 응답을 확인해 주세요." }, { status: 502 });
|
||||||
} else {
|
} else {
|
||||||
response = NextResponse.json({ user: result.user, link: result.link, accessToken });
|
token = accessToken;
|
||||||
|
response = NextResponse.json({ user: result.user, link: result.link });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -27,5 +32,9 @@ export async function POST(_request: NextRequest, context: { params: Promise<{ u
|
|||||||
response = new NextResponse(failure.body, { status: failure.status, headers: failure.headers });
|
response = new NextResponse(failure.body, { status: failure.status, headers: failure.headers });
|
||||||
}
|
}
|
||||||
response.headers.set("Cache-Control", "no-store");
|
response.headers.set("Cache-Control", "no-store");
|
||||||
|
response.cookies.set(CookieKeys.AuthToken, token, {
|
||||||
|
httpOnly: true, secure: ["prod", "production"].includes(serverEnv.ENV),
|
||||||
|
sameSite: "lax", path: "/", maxAge: token ? AUTH_COOKIE_MAX_AGE : 0,
|
||||||
|
});
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
import { NextRequest, NextResponse } from "next/server";
|
import { NextRequest, NextResponse } from "next/server";
|
||||||
|
import { cookies } from "next/headers";
|
||||||
import { errorToResponse } from "@kri/common/http";
|
import { errorToResponse } from "@kri/common/http";
|
||||||
import { createServerApi, getServerAccessToken } from "@/lib/http-server";
|
import { createServerApi } from "@/lib/http-server";
|
||||||
import { isImportPath } from "@/lib/project-proxy-policy";
|
import { isImportPath } from "@/lib/project-proxy-policy";
|
||||||
import { readImportResult } from "@/types/export";
|
import { readImportResult } from "@/types/export";
|
||||||
|
import { CookieKeys } from "@/store/cookie/cookie-keys";
|
||||||
import type { RouteContext } from "@/types/common";
|
import type { RouteContext } from "@/types/common";
|
||||||
|
|
||||||
// Imports replace project data on the server and may run for minutes.
|
// Imports replace project data on the server and may run for minutes.
|
||||||
@@ -13,7 +15,7 @@ export async function POST(request: NextRequest, context: RouteContext) {
|
|||||||
const { slug = [] } = await context.params;
|
const { slug = [] } = await context.params;
|
||||||
if (!isImportPath(slug))
|
if (!isImportPath(slug))
|
||||||
return NextResponse.json({ message: "지원하지 않는 경로입니다." }, { status: 404 });
|
return NextResponse.json({ message: "지원하지 않는 경로입니다." }, { status: 404 });
|
||||||
if (!(await getServerAccessToken()))
|
if (!(await cookies()).get(CookieKeys.AuthToken)?.value)
|
||||||
return NextResponse.json({ message: "로그인이 필요합니다." }, { status: 401 });
|
return NextResponse.json({ message: "로그인이 필요합니다." }, { status: 401 });
|
||||||
let file: File;
|
let file: File;
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import { errorToResponse } from "@kri/common/http";
|
|||||||
import { createServerApiWithApiKey } from "@/lib/http-server";
|
import { createServerApiWithApiKey } from "@/lib/http-server";
|
||||||
import {
|
import {
|
||||||
internalTarget,
|
internalTarget,
|
||||||
readInternalProjectListQuery,
|
|
||||||
readInternalQuotaRequest,
|
readInternalQuotaRequest,
|
||||||
readInternalReportBatch,
|
readInternalReportBatch,
|
||||||
readInternalShareRequest,
|
readInternalShareRequest,
|
||||||
@@ -26,33 +25,26 @@ async function handle(request: NextRequest, context: RouteContext) {
|
|||||||
if (!apiKey) return jsonError("X-API-Key는 필수입니다.", 401);
|
if (!apiKey) return jsonError("X-API-Key는 필수입니다.", 401);
|
||||||
|
|
||||||
let body: unknown;
|
let body: unknown;
|
||||||
let query: Record<string, string> = {};
|
if (target.kind !== "list" && target.kind !== "respondent") {
|
||||||
if (target.kind === "projects") {
|
|
||||||
try {
|
|
||||||
query = readInternalProjectListQuery(request.nextUrl.searchParams);
|
|
||||||
} catch (error) {
|
|
||||||
return jsonError(error instanceof Error ? error.message : "조회 조건을 확인해 주세요.", 400);
|
|
||||||
}
|
|
||||||
} else if (target.kind !== "list" && target.kind !== "respondent") {
|
|
||||||
try {
|
try {
|
||||||
const input: unknown = await request.json();
|
const input: unknown = await request.json();
|
||||||
if (target.kind === "report") {
|
body =
|
||||||
body = readInternalReportBatch(input);
|
target.kind === "report"
|
||||||
} else if (target.kind === "quota") {
|
? readInternalReportBatch(input)
|
||||||
body = readInternalQuotaRequest(input);
|
: target.kind === "quota"
|
||||||
} else if (target.kind === "share") {
|
? readInternalQuotaRequest(input)
|
||||||
body = readInternalShareRequest(input);
|
: target.kind === "share"
|
||||||
} else {
|
? readInternalShareRequest(input)
|
||||||
body = readExcelRequest(input);
|
: readExcelRequest(input);
|
||||||
}
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
let message = "요청 내용을 확인해 주세요.";
|
return jsonError(
|
||||||
if (error instanceof SyntaxError) {
|
error instanceof SyntaxError
|
||||||
message = "요청 JSON을 확인해 주세요.";
|
? "요청 JSON을 확인해 주세요."
|
||||||
} else if (error instanceof Error) {
|
: error instanceof Error
|
||||||
message = error.message;
|
? error.message
|
||||||
}
|
: "요청 내용을 확인해 주세요.",
|
||||||
return jsonError(message, 400);
|
400,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,19 +53,14 @@ async function handle(request: NextRequest, context: RouteContext) {
|
|||||||
const options = { signal: request.signal, cache: "no-store" as const };
|
const options = { signal: request.signal, cache: "no-store" as const };
|
||||||
if (
|
if (
|
||||||
target.kind === "list" ||
|
target.kind === "list" ||
|
||||||
target.kind === "projects" ||
|
|
||||||
target.kind === "quota" ||
|
target.kind === "quota" ||
|
||||||
target.kind === "respondent" ||
|
target.kind === "respondent" ||
|
||||||
target.kind === "share"
|
target.kind === "share"
|
||||||
) {
|
) {
|
||||||
let result: unknown;
|
const result =
|
||||||
if (target.kind === "list") {
|
target.kind === "list"
|
||||||
result = await api.get<unknown>(target.path, options);
|
? await api.get<unknown>(target.path, options)
|
||||||
} else if (target.kind === "projects") {
|
: await api.post<unknown>(target.path, body, options);
|
||||||
result = await api.get<unknown>(target.path, { ...options, query });
|
|
||||||
} else {
|
|
||||||
result = await api.post<unknown>(target.path, body, options);
|
|
||||||
}
|
|
||||||
if (
|
if (
|
||||||
target.kind === "share" &&
|
target.kind === "share" &&
|
||||||
(!isShareLink(result) ||
|
(!isShareLink(result) ||
|
||||||
@@ -106,16 +93,17 @@ async function handle(request: NextRequest, context: RouteContext) {
|
|||||||
await upstream.body?.cancel();
|
await upstream.body?.cancel();
|
||||||
return jsonError("서버 응답 형식을 확인해 주세요.", 502);
|
return jsonError("서버 응답 형식을 확인해 주세요.", 502);
|
||||||
}
|
}
|
||||||
const headers: Record<string, string> = {
|
return new Response(upstream.body, {
|
||||||
|
headers: {
|
||||||
...noStore,
|
...noStore,
|
||||||
"Content-Type": contentType,
|
"Content-Type": contentType,
|
||||||
};
|
...(target.kind === "report"
|
||||||
if (target.kind === "report") {
|
? { "X-Accel-Buffering": "no" }
|
||||||
headers["X-Accel-Buffering"] = "no";
|
: disposition
|
||||||
} else if (disposition) {
|
? { "Content-Disposition": disposition }
|
||||||
headers["Content-Disposition"] = disposition;
|
: {}),
|
||||||
}
|
},
|
||||||
return new Response(upstream.body, { headers });
|
});
|
||||||
} catch (error: unknown) {
|
} catch (error: unknown) {
|
||||||
const response = errorToResponse(error);
|
const response = errorToResponse(error);
|
||||||
response.headers.set("Cache-Control", "no-store");
|
response.headers.set("Cache-Control", "no-store");
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
import { NextRequest, NextResponse } from "next/server";
|
import { NextRequest, NextResponse } from "next/server";
|
||||||
|
import { cookies } from "next/headers";
|
||||||
import { errorToResponse } from "@kri/common/http";
|
import { errorToResponse } from "@kri/common/http";
|
||||||
import { createServerApi, getServerAccessToken } from "@/lib/http-server";
|
import { createServerApi } from "@/lib/http-server";
|
||||||
|
import { CookieKeys } from "@/store/cookie/cookie-keys";
|
||||||
import { isProjectRef, isRecord } from "@/types/kart";
|
import { isProjectRef, isRecord } from "@/types/kart";
|
||||||
|
|
||||||
export async function POST(request: NextRequest) {
|
export async function POST(request: NextRequest) {
|
||||||
if (!(await getServerAccessToken()))
|
if (!(await cookies()).get(CookieKeys.AuthToken)?.value)
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ message: "로그인이 필요합니다." },
|
{ message: "로그인이 필요합니다." },
|
||||||
{ status: 401 },
|
{ status: 401 },
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
import { NextRequest, NextResponse } from "next/server";
|
import { NextRequest, NextResponse } from "next/server";
|
||||||
import { errorToResponse } from "@kri/common/http";
|
import { errorToResponse } from "@kri/common/http";
|
||||||
import { setAuthCookie } from "@/lib/auth-cookie";
|
import { AUTH_COOKIE_MAX_AGE } from "@/const/common.const";
|
||||||
|
import { serverEnv } from "@/lib/env.server";
|
||||||
import { createServerApi } from "@/lib/http-server";
|
import { createServerApi } from "@/lib/http-server";
|
||||||
|
import { CookieKeys } from "@/store/cookie/cookie-keys";
|
||||||
import { isLoginUser, isRecord } from "@/types/kart";
|
import { isLoginUser, isRecord } from "@/types/kart";
|
||||||
import type { RouteContext } from "@/types/common";
|
import type { RouteContext } from "@/types/common";
|
||||||
|
|
||||||
@@ -26,7 +28,7 @@ export async function POST(request: NextRequest, context: RouteContext) {
|
|||||||
{ status: 400 },
|
{ status: 400 },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
const serverApi = await createServerApi(false);
|
const serverApi = await createServerApi();
|
||||||
const result = await serverApi.post<unknown>(
|
const result = await serverApi.post<unknown>(
|
||||||
"/auth/login",
|
"/auth/login",
|
||||||
{ userId: body.userId.trim(), userPw: body.userPw },
|
{ userId: body.userId.trim(), userPw: body.userPw },
|
||||||
@@ -46,7 +48,13 @@ export async function POST(request: NextRequest, context: RouteContext) {
|
|||||||
const response = NextResponse.json(result.user, {
|
const response = NextResponse.json(result.user, {
|
||||||
headers: { "Cache-Control": "no-store" },
|
headers: { "Cache-Control": "no-store" },
|
||||||
});
|
});
|
||||||
setAuthCookie(response, result.accessToken);
|
response.cookies.set(CookieKeys.AuthToken, result.accessToken, {
|
||||||
|
httpOnly: true,
|
||||||
|
secure: ["prod", "production"].includes(serverEnv.ENV),
|
||||||
|
sameSite: "lax",
|
||||||
|
path: "/",
|
||||||
|
maxAge: AUTH_COOKIE_MAX_AGE,
|
||||||
|
});
|
||||||
return response;
|
return response;
|
||||||
} catch (error: unknown) {
|
} catch (error: unknown) {
|
||||||
if (error instanceof SyntaxError)
|
if (error instanceof SyntaxError)
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
import { setAuthCookie } from "@/lib/auth-cookie";
|
import { serverEnv } from "@/lib/env.server";
|
||||||
|
import { CookieKeys } from "@/store/cookie/cookie-keys";
|
||||||
|
|
||||||
/** Stateless backend authentication has no logout API; discard the frontend session cookie. */
|
/** Stateless backend authentication has no logout API; discard the frontend session cookie. */
|
||||||
export async function POST() {
|
export async function POST() {
|
||||||
@@ -7,6 +8,12 @@ export async function POST() {
|
|||||||
{ ok: true },
|
{ ok: true },
|
||||||
{ headers: { "Cache-Control": "no-store" } },
|
{ headers: { "Cache-Control": "no-store" } },
|
||||||
);
|
);
|
||||||
setAuthCookie(response, "");
|
response.cookies.set(CookieKeys.AuthToken, "", {
|
||||||
|
httpOnly: true,
|
||||||
|
secure: ["prod", "production"].includes(serverEnv.ENV),
|
||||||
|
sameSite: "lax",
|
||||||
|
path: "/",
|
||||||
|
maxAge: 0,
|
||||||
|
});
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,14 @@
|
|||||||
import { NextRequest, NextResponse } from "next/server";
|
import { NextRequest, NextResponse } from "next/server";
|
||||||
|
import { cookies } from "next/headers";
|
||||||
import { errorToResponse } from "@kri/common/http";
|
import { errorToResponse } from "@kri/common/http";
|
||||||
import { createServerApi, getServerAccessToken } from "@/lib/http-server";
|
import { createServerApi } from "@/lib/http-server";
|
||||||
import { readReportBatch } from "@/lib/report-contract";
|
import { readReportBatch } from "@/lib/report-contract";
|
||||||
import {
|
import {
|
||||||
isProjectReadPath,
|
isProjectReadPath,
|
||||||
projectReadQuery,
|
projectReadQuery,
|
||||||
isReportStreamPath,
|
isReportStreamPath,
|
||||||
} from "@/lib/project-proxy-policy";
|
} from "@/lib/project-proxy-policy";
|
||||||
|
import { CookieKeys } from "@/store/cookie/cookie-keys";
|
||||||
import type { RouteContext } from "@/types/common";
|
import type { RouteContext } from "@/types/common";
|
||||||
|
|
||||||
export async function GET(request: NextRequest, context: RouteContext) {
|
export async function GET(request: NextRequest, context: RouteContext) {
|
||||||
@@ -16,7 +18,7 @@ export async function GET(request: NextRequest, context: RouteContext) {
|
|||||||
{ message: "지원하지 않는 경로입니다." },
|
{ message: "지원하지 않는 경로입니다." },
|
||||||
{ status: 404 },
|
{ status: 404 },
|
||||||
);
|
);
|
||||||
if (!(await getServerAccessToken()))
|
if (!(await cookies()).get(CookieKeys.AuthToken)?.value)
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ message: "로그인이 필요합니다." },
|
{ message: "로그인이 필요합니다." },
|
||||||
{ status: 401 },
|
{ status: 401 },
|
||||||
@@ -47,7 +49,7 @@ export async function POST(request: NextRequest, context: RouteContext) {
|
|||||||
{ message: "지원하지 않는 경로입니다." },
|
{ message: "지원하지 않는 경로입니다." },
|
||||||
{ status: 404 },
|
{ status: 404 },
|
||||||
);
|
);
|
||||||
if (!(await getServerAccessToken()))
|
if (!(await cookies()).get(CookieKeys.AuthToken)?.value)
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ message: "로그인이 필요합니다." },
|
{ message: "로그인이 필요합니다." },
|
||||||
{ status: 401 },
|
{ status: 401 },
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
import { NextRequest, NextResponse } from "next/server";
|
import { NextRequest, NextResponse } from "next/server";
|
||||||
|
import { cookies } from "next/headers";
|
||||||
import { errorToResponse } from "@kri/common/http";
|
import { errorToResponse } from "@kri/common/http";
|
||||||
import { createServerApi, getServerAccessToken } from "@/lib/http-server";
|
import { createServerApi } from "@/lib/http-server";
|
||||||
import { isQuotaListPath, isQuotaResultPath } from "@/lib/project-proxy-policy";
|
import { isQuotaListPath, isQuotaResultPath } from "@/lib/project-proxy-policy";
|
||||||
import { readQuotaRequest } from "@/types/quota";
|
import { readQuotaRequest } from "@/types/quota";
|
||||||
|
import { CookieKeys } from "@/store/cookie/cookie-keys";
|
||||||
import type { RouteContext } from "@/types/common";
|
import type { RouteContext } from "@/types/common";
|
||||||
|
|
||||||
const notFound = () =>
|
const notFound = () =>
|
||||||
@@ -13,7 +15,7 @@ const unauthorized = () =>
|
|||||||
export async function GET(_request: NextRequest, context: RouteContext) {
|
export async function GET(_request: NextRequest, context: RouteContext) {
|
||||||
const { slug = [] } = await context.params;
|
const { slug = [] } = await context.params;
|
||||||
if (!isQuotaListPath(slug)) return notFound();
|
if (!isQuotaListPath(slug)) return notFound();
|
||||||
if (!(await getServerAccessToken())) return unauthorized();
|
if (!(await cookies()).get(CookieKeys.AuthToken)?.value) return unauthorized();
|
||||||
try {
|
try {
|
||||||
const serverApi = await createServerApi();
|
const serverApi = await createServerApi();
|
||||||
const result = await serverApi.get<unknown>(
|
const result = await serverApi.get<unknown>(
|
||||||
@@ -29,7 +31,7 @@ export async function GET(_request: NextRequest, context: RouteContext) {
|
|||||||
export async function POST(request: NextRequest, context: RouteContext) {
|
export async function POST(request: NextRequest, context: RouteContext) {
|
||||||
const { slug = [] } = await context.params;
|
const { slug = [] } = await context.params;
|
||||||
if (!isQuotaResultPath(slug)) return notFound();
|
if (!isQuotaResultPath(slug)) return notFound();
|
||||||
if (!(await getServerAccessToken())) return unauthorized();
|
if (!(await cookies()).get(CookieKeys.AuthToken)?.value) return unauthorized();
|
||||||
let body;
|
let body;
|
||||||
try {
|
try {
|
||||||
body = readQuotaRequest(await request.json());
|
body = readQuotaRequest(await request.json());
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
|
import { cookies } from "next/headers";
|
||||||
import { NextRequest, NextResponse } from "next/server";
|
import { NextRequest, NextResponse } from "next/server";
|
||||||
import { errorToResponse } from "@kri/common/http";
|
import { errorToResponse } from "@kri/common/http";
|
||||||
import { createServerApi, getServerAccessToken } from "@/lib/http-server";
|
import { createServerApi } from "@/lib/http-server";
|
||||||
|
import { CookieKeys } from "@/store/cookie/cookie-keys";
|
||||||
import { isProjectRef, isRecord } from "@/types/kart";
|
import { isProjectRef, isRecord } from "@/types/kart";
|
||||||
import { isShareLink } from "@/types/share";
|
import { isShareLink } from "@/types/share";
|
||||||
|
|
||||||
@@ -10,7 +12,7 @@ export async function POST(request: NextRequest, context: {
|
|||||||
const params = await context.params;
|
const params = await context.params;
|
||||||
const project = { projectType: params.projectType === "0" ? 0 : params.projectType === "1" ? 1 : null, pkey: params.pkey };
|
const project = { projectType: params.projectType === "0" ? 0 : params.projectType === "1" ? 1 : null, pkey: params.pkey };
|
||||||
if (!isProjectRef(project)) return NextResponse.json({ message: "프로젝트를 확인해 주세요." }, { status: 400 });
|
if (!isProjectRef(project)) return NextResponse.json({ message: "프로젝트를 확인해 주세요." }, { status: 400 });
|
||||||
if (!(await getServerAccessToken()))
|
if (!(await cookies()).get(CookieKeys.AuthToken)?.value)
|
||||||
return NextResponse.json({ message: "로그인이 필요합니다." }, { status: 401 });
|
return NextResponse.json({ message: "로그인이 필요합니다." }, { status: 401 });
|
||||||
let body: unknown;
|
let body: unknown;
|
||||||
try { body = await request.json(); } catch { body = null; }
|
try { body = await request.json(); } catch { body = null; }
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import { Fragment, Suspense, useEffect, useState, type ReactNode } from "react";
|
|||||||
import { usePathname, useRouter } from "next/navigation";
|
import { usePathname, useRouter } from "next/navigation";
|
||||||
import { KriMainLayout } from "@/components/layout/KriMainLayout";
|
import { KriMainLayout } from "@/components/layout/KriMainLayout";
|
||||||
import { AppHeader } from "./AppHeader";
|
import { AppHeader } from "./AppHeader";
|
||||||
import { ProjectEntry } from "@/components/project/ProjectEntry";
|
|
||||||
import { AppSidebar } from "./AppSidebar";
|
import { AppSidebar } from "./AppSidebar";
|
||||||
import { sideMenus } from "@/config/menu.data";
|
import { sideMenus } from "@/config/menu.data";
|
||||||
import { useAuth } from "@/hooks/useAuth";
|
import { useAuth } from "@/hooks/useAuth";
|
||||||
@@ -20,18 +19,22 @@ export function AppMainLayout({ children }: { children: ReactNode }) {
|
|||||||
const externalAllowed = !external || (!!auth.external && externalPageAllowed(auth.external, pathname));
|
const externalAllowed = !external || (!!auth.external && externalPageAllowed(auth.external, pathname));
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (hydrated && !auth.user) router.replace("/logout");
|
if (hydrated && !auth.user) router.replace("/logout");
|
||||||
else if (hydrated && external && !auth.accessToken) router.replace("/logout");
|
|
||||||
// Legacy Main sends shared-link users (isAdmin > 8) to Logout, ending the External session.
|
// Legacy Main sends shared-link users (isAdmin > 8) to Logout, ending the External session.
|
||||||
else if (hydrated && external && pathname === "/") router.replace("/logout");
|
else if (hydrated && external && pathname === "/") router.replace("/logout");
|
||||||
else if (hydrated && !externalAllowed)
|
else if (hydrated && !externalAllowed)
|
||||||
router.replace((auth.external ? reportUrl(auth.external.realUrl) : "/logout") as Route);
|
router.replace((auth.external ? reportUrl(auth.external.realUrl) : "/logout") as Route);
|
||||||
}, [hydrated, auth.user, auth.external, auth.accessToken, external, externalAllowed, pathname, router]);
|
}, [hydrated, auth.user, auth.external, external, externalAllowed, pathname, router]);
|
||||||
const hasSidebar = sideMenus.length > 0;
|
const hasSidebar = sideMenus.length > 0;
|
||||||
if (!hydrated || !auth.user || !externalAllowed || (external && !auth.accessToken))
|
if (!hydrated || !auth.user || !externalAllowed)
|
||||||
return null;
|
return (
|
||||||
|
<p
|
||||||
|
role="status"
|
||||||
|
className="p-8 text-center text-sm text-muted-foreground"
|
||||||
|
>
|
||||||
|
로그인 정보를 확인하는 중입니다.
|
||||||
|
</p>
|
||||||
|
);
|
||||||
return (
|
return (
|
||||||
<Suspense fallback={null}>
|
|
||||||
<ProjectEntry>
|
|
||||||
<KriMainLayout
|
<KriMainLayout
|
||||||
className="bg-kart-bg text-kart-text"
|
className="bg-kart-bg text-kart-text"
|
||||||
sidebarOpen={hasSidebar && menuOpen}
|
sidebarOpen={hasSidebar && menuOpen}
|
||||||
@@ -53,11 +56,7 @@ export function AppMainLayout({ children }: { children: ReactNode }) {
|
|||||||
}
|
}
|
||||||
mainClassName="bg-kart-bg px-[1.0416vw] pt-2.5 pb-6"
|
mainClassName="bg-kart-bg px-[1.0416vw] pt-2.5 pb-6"
|
||||||
>
|
>
|
||||||
<Fragment key={auth.user.userId + ":" + auth.user.userRole}>
|
<Fragment key={auth.user.userId + ":" + auth.user.userRole}>{children}</Fragment>
|
||||||
{children}
|
|
||||||
</Fragment>
|
|
||||||
</KriMainLayout>
|
</KriMainLayout>
|
||||||
</ProjectEntry>
|
|
||||||
</Suspense>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,19 +0,0 @@
|
|||||||
"use client";
|
|
||||||
|
|
||||||
import type { ReactNode } from "react";
|
|
||||||
import { useAuthSession } from "@/hooks/useAuthSession";
|
|
||||||
|
|
||||||
export function AuthSessionGate({ children }: { children: ReactNode }) {
|
|
||||||
const session = useAuthSession();
|
|
||||||
const user = session.data;
|
|
||||||
const checking = session.isPending || session.isFetching;
|
|
||||||
const identity = user && JSON.stringify([user.userId, user.userRole, user.userTeam, user.userCmpn]);
|
|
||||||
|
|
||||||
return <>
|
|
||||||
{session.isError && !checking && <div role="alert" className="p-8 text-center text-sm">
|
|
||||||
<p>로그인 정보를 확인하지 못했습니다.</p>
|
|
||||||
<button type="button" onClick={() => { void session.refetch(); }}>다시 시도</button>
|
|
||||||
</div>}
|
|
||||||
{user && <div key={identity} hidden={session.isError}>{children}</div>}
|
|
||||||
</>;
|
|
||||||
}
|
|
||||||
@@ -65,6 +65,7 @@ export function KriEditorHtmlOnly({
|
|||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
applyExternalValue(value || '')
|
applyExternalValue(value || '')
|
||||||
// 최초 마운트 시 1회만 실행 — 이후 value 변경은 아래 effect가 처리한다.
|
// 최초 마운트 시 1회만 실행 — 이후 value 변경은 아래 effect가 처리한다.
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
|
|||||||
@@ -8,23 +8,8 @@ import { useTextareaInsert } from './hooks/useTextareaInsert'
|
|||||||
|
|
||||||
type SmsEditorProps = Omit<KriEditorProps, 'mode'> & { mode: 'sms' }
|
type SmsEditorProps = Omit<KriEditorProps, 'mode'> & { mode: 'sms' }
|
||||||
|
|
||||||
type SmsMessageType = 'SMS' | 'LMS' | 'MMS'
|
|
||||||
|
|
||||||
function calculateBytes(value: string): number {
|
function calculateBytes(value: string): number {
|
||||||
return new TextEncoder().encode(value).byteLength
|
return Array.from(value).reduce((total, character) => total + (character.charCodeAt(0) > 127 ? 2 : 1), 0)
|
||||||
}
|
|
||||||
|
|
||||||
// 첨부파일이 있으면 MMS, 제목이 있거나 smsMaxBytes 이상이면 LMS, 나머지는 SMS로 미리보기 판정한다.
|
|
||||||
function getSmsMessageType(hasAttachment: boolean, byteSize: number, smsMaxBytes: number, title: string): SmsMessageType {
|
|
||||||
if (hasAttachment) return 'MMS'
|
|
||||||
if (byteSize >= smsMaxBytes || Boolean(title)) return 'LMS'
|
|
||||||
return 'SMS'
|
|
||||||
}
|
|
||||||
|
|
||||||
function getTextareaMinHeight(hasImages: boolean, hasTitle: boolean): string {
|
|
||||||
if (hasImages) return '160px'
|
|
||||||
if (hasTitle) return '320px'
|
|
||||||
return '360px'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function KriEditorSms({
|
export function KriEditorSms({
|
||||||
@@ -44,30 +29,18 @@ export function KriEditorSms({
|
|||||||
smsPreviewSuffix = '',
|
smsPreviewSuffix = '',
|
||||||
smsHasAttachment = false,
|
smsHasAttachment = false,
|
||||||
smsImages = [],
|
smsImages = [],
|
||||||
smsFrameClassName,
|
|
||||||
}: SmsEditorProps) {
|
}: SmsEditorProps) {
|
||||||
const [text, setText] = React.useState(value || '')
|
const [text, setText] = React.useState(value || '')
|
||||||
const textareaRef = React.useRef<HTMLTextAreaElement | null>(null)
|
const textareaRef = React.useRef<HTMLTextAreaElement | null>(null)
|
||||||
const latestTextRef = React.useRef(text)
|
const latestTextRef = React.useRef(text)
|
||||||
const lastTypeRef = React.useRef<SmsMessageType | null>(null)
|
const lastTypeRef = React.useRef<'SMS' | 'LMS' | null>(null)
|
||||||
const { scheduleChange, flushChange } = useDebouncedChange(onChange, debounceMs)
|
const { scheduleChange, flushChange } = useDebouncedChange(onChange, debounceMs)
|
||||||
const textareaInsert = useTextareaInsert(textareaRef)
|
const textareaInsert = useTextareaInsert(textareaRef)
|
||||||
const previewText = smsPreviewSuffix ? `${text}\n${smsPreviewSuffix}` : text
|
const previewText = smsPreviewSuffix ? `${text}\n${smsPreviewSuffix}` : text
|
||||||
const byteSize = React.useMemo(() => calculateBytes(previewText), [previewText])
|
const byteSize = React.useMemo(() => calculateBytes(previewText), [previewText])
|
||||||
const messageType = getSmsMessageType(smsHasAttachment, byteSize, smsMaxBytes, smsTitle)
|
const messageType: 'SMS' | 'LMS' = byteSize > smsMaxBytes || Boolean(smsTitle) || smsHasAttachment ? 'LMS' : 'SMS'
|
||||||
const maxBytes = messageType === 'SMS' ? smsMaxBytes : lmsMaxBytes
|
const maxBytes = messageType === 'SMS' ? smsMaxBytes : lmsMaxBytes
|
||||||
|
|
||||||
function getBadgeColor(): string {
|
|
||||||
switch (messageType) {
|
|
||||||
case 'SMS':
|
|
||||||
return 'bg-red-500'
|
|
||||||
case 'LMS':
|
|
||||||
return 'bg-blue-500'
|
|
||||||
case 'MMS':
|
|
||||||
return 'bg-green-500'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const commitText = React.useCallback((next: string, immediate = false) => {
|
const commitText = React.useCallback((next: string, immediate = false) => {
|
||||||
setText(next)
|
setText(next)
|
||||||
latestTextRef.current = next
|
latestTextRef.current = next
|
||||||
@@ -111,13 +84,13 @@ export function KriEditorSms({
|
|||||||
return (
|
return (
|
||||||
<div className={cn('mx-auto w-full max-w-[320px]', className)}>
|
<div className={cn('mx-auto w-full max-w-[320px]', className)}>
|
||||||
{label ? <div className="mb-2 text-sm font-semibold">{label}</div> : null}
|
{label ? <div className="mb-2 text-sm font-semibold">{label}</div> : null}
|
||||||
<div className={cn('relative h-[600px] w-full overflow-hidden rounded-[40px] border-8 border-gray-800 bg-white shadow-2xl', smsFrameClassName)}>
|
<div className="relative h-[600px] w-full overflow-hidden rounded-[40px] border-8 border-gray-800 bg-white shadow-2xl">
|
||||||
<div className="absolute top-0 left-1/2 z-10 h-6 w-32 -translate-x-1/2 rounded-b-2xl bg-gray-800" />
|
<div className="absolute top-0 left-1/2 z-10 h-6 w-32 -translate-x-1/2 rounded-b-2xl bg-gray-800" />
|
||||||
<div className="flex h-full flex-col bg-gray-50 px-4 pt-8 pb-4">
|
<div className="flex h-full flex-col bg-gray-50 px-4 pt-8 pb-4">
|
||||||
<div className="mb-3 flex items-center justify-between px-2">
|
<div className="mb-3 flex items-center justify-between px-2">
|
||||||
<span className="text-xs font-medium text-gray-600">{byteSize}/{maxBytes}byte</span>
|
<span className="text-xs font-medium text-gray-600">{byteSize}/{maxBytes}byte</span>
|
||||||
<span className={cn('rounded-md px-3 py-1 text-xs font-bold text-white', getBadgeColor())}>
|
<span className={cn('rounded-md px-3 py-1 text-xs font-bold text-white', messageType === 'LMS' ? 'bg-blue-500' : 'bg-red-500')}>
|
||||||
{messageType}
|
{messageType === 'LMS' ? 'LMS/MMS' : 'SMS'}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div className={cn('flex flex-1 flex-col rounded-2xl bg-white shadow-sm', smsImages.length > 0 ? 'overflow-y-auto' : 'overflow-hidden')}>
|
<div className={cn('flex flex-1 flex-col rounded-2xl bg-white shadow-sm', smsImages.length > 0 ? 'overflow-y-auto' : 'overflow-hidden')}>
|
||||||
@@ -142,7 +115,7 @@ export function KriEditorSms({
|
|||||||
onBlur={() => flushChange(latestTextRef.current)}
|
onBlur={() => flushChange(latestTextRef.current)}
|
||||||
placeholder={placeholder}
|
placeholder={placeholder}
|
||||||
readOnly={isSmsReadOnly}
|
readOnly={isSmsReadOnly}
|
||||||
style={{ minHeight: getTextareaMinHeight(smsImages.length > 0, Boolean(smsTitle)) }}
|
style={{ minHeight: smsImages.length > 0 ? '160px' : smsTitle ? '320px' : '360px' }}
|
||||||
{...textareaInsert.bindSelectionHandlers}
|
{...textareaInsert.bindSelectionHandlers}
|
||||||
/>
|
/>
|
||||||
{smsPreviewSuffix ? (
|
{smsPreviewSuffix ? (
|
||||||
|
|||||||
@@ -35,62 +35,9 @@ import { applyLinkPreviewClass, KRI_EDITOR_LINK_CLASS } from "./utils/linkPrevie
|
|||||||
import { Toolbar } from "./toolbar/Toolbar";
|
import { Toolbar } from "./toolbar/Toolbar";
|
||||||
import { useDebouncedChange } from "./hooks/useDebouncedChange";
|
import { useDebouncedChange } from "./hooks/useDebouncedChange";
|
||||||
import { useTextareaInsert } from "./hooks/useTextareaInsert";
|
import { useTextareaInsert } from "./hooks/useTextareaInsert";
|
||||||
import { useImageMapOverlay } from "./hooks/useImageMapOverlay";
|
|
||||||
|
|
||||||
type ViewMode = "wysiwyg" | "html";
|
type ViewMode = "wysiwyg" | "html";
|
||||||
|
|
||||||
type ToolbarEndSlotProps = Pick<KriEditorProps, "renderToolbarEnd"> & {
|
|
||||||
editor: Editor;
|
|
||||||
command: KriEditorCommand;
|
|
||||||
view: ViewMode;
|
|
||||||
};
|
|
||||||
|
|
||||||
// command는 ref를 사용하는 함수 묶음이라, 렌더 중 외부 함수에 직접 넘기면 React Compiler가
|
|
||||||
// ref 접근으로 판단한다. 별도 컴포넌트의 props로 전달해 렌더 범위를 분리한다(동작 동일).
|
|
||||||
function ToolbarEndSlot({ renderToolbarEnd, editor, command, view }: Readonly<ToolbarEndSlotProps>) {
|
|
||||||
return <>{renderToolbarEnd?.({ editor, command, view })}</>;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 주입된 정제 함수가 우선이고, 없으면 sanitizeHtml 옵션에 따라 기본 정제기를 사용한다.
|
|
||||||
function sanitizeEditorHtml(
|
|
||||||
html: string,
|
|
||||||
htmlSanitizer: KriEditorProps["htmlSanitizer"],
|
|
||||||
sanitizeEnabled: boolean,
|
|
||||||
allowedCustomHtml: KriEditorProps["allowedCustomHtml"],
|
|
||||||
): string {
|
|
||||||
if (htmlSanitizer) return htmlSanitizer(html);
|
|
||||||
if (sanitizeEnabled) return sanitizeHtml(html, allowedCustomHtml);
|
|
||||||
return html;
|
|
||||||
}
|
|
||||||
|
|
||||||
function writeHtmlDraft(
|
|
||||||
draftRef: { current: string },
|
|
||||||
textareaRef: { current: HTMLTextAreaElement | null },
|
|
||||||
html: string,
|
|
||||||
): void {
|
|
||||||
draftRef.current = html;
|
|
||||||
if (textareaRef.current) textareaRef.current.value = html;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 외부에서 본문이 변경된 경우에만 기존 editor 문서를 갱신한다.
|
|
||||||
function syncEditorContent(editor: Editor, value: string, optimisticHtml: string): void {
|
|
||||||
// 빈 문자열("")은 ProseMirror 스키마상 유효한 문서가 아니라 setContent가 조용히 실패해
|
|
||||||
// 이전 템플릿 본문이 그대로 남는 문제가 있었음 -> 빈 값은 빈 문단으로 정규화해서 비교/설정.
|
|
||||||
const normalizedValue = value || "<p></p>";
|
|
||||||
if (normalizedValue === editor.getHTML() || normalizedValue === optimisticHtml) return;
|
|
||||||
|
|
||||||
editor.commands.setContent(normalizedValue, {
|
|
||||||
emitUpdate: false,
|
|
||||||
parseOptions: { preserveWhitespace: "full" },
|
|
||||||
});
|
|
||||||
|
|
||||||
// resize가 활성화된 TipTap 이미지 NodeView는 노드의 src 변경을 기존 DOM에 반영하지 않는다.
|
|
||||||
// editor 전체 대신 NodeView만 다시 생성해 이미지를 갱신하고 편집 포커스는 유지한다.
|
|
||||||
if (normalizedValue.includes("<img")) {
|
|
||||||
editor.createNodeViews();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function getToolbarState(editor: Editor): ToolbarState {
|
function getToolbarState(editor: Editor): ToolbarState {
|
||||||
const ts = editor.getAttributes("textStyle") as { fontSize?: string | null; fontFamily?: string | null; color?: string | null };
|
const ts = editor.getAttributes("textStyle") as { fontSize?: string | null; fontFamily?: string | null; color?: string | null };
|
||||||
const hl = editor.getAttributes("highlight") as { color?: string | null };
|
const hl = editor.getAttributes("highlight") as { color?: string | null };
|
||||||
@@ -122,7 +69,7 @@ function getToolbarState(editor: Editor): ToolbarState {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function KriEditorWysiwyg(props: Readonly<KriEditorProps>) {
|
export function KriEditorWysiwyg(props: KriEditorProps) {
|
||||||
const {
|
const {
|
||||||
|
|
||||||
label,
|
label,
|
||||||
@@ -167,7 +114,6 @@ export function KriEditorWysiwyg(props: Readonly<KriEditorProps>) {
|
|||||||
const { scheduleChange, flushChange, optimisticHtmlRef } = useDebouncedChange(onChange, debounceMs);
|
const { scheduleChange, flushChange, optimisticHtmlRef } = useDebouncedChange(onChange, debounceMs);
|
||||||
|
|
||||||
const fileRef = useRef<HTMLInputElement | null>(null);
|
const fileRef = useRef<HTMLInputElement | null>(null);
|
||||||
const previewContainerRef = useRef<HTMLDivElement | null>(null);
|
|
||||||
const htmlTextareaRef = useRef<HTMLTextAreaElement | null>(null);
|
const htmlTextareaRef = useRef<HTMLTextAreaElement | null>(null);
|
||||||
const htmlTi = useTextareaInsert(htmlTextareaRef);
|
const htmlTi = useTextareaInsert(htmlTextareaRef);
|
||||||
const { insertText: insertTextareaText } = htmlTi;
|
const { insertText: insertTextareaText } = htmlTi;
|
||||||
@@ -186,9 +132,6 @@ export function KriEditorWysiwyg(props: Readonly<KriEditorProps>) {
|
|||||||
}, [view]);
|
}, [view]);
|
||||||
|
|
||||||
const htmlDraftRef = useRef<string>(value ?? "");
|
const htmlDraftRef = useRef<string>(value ?? "");
|
||||||
// HTML textarea는 비제어 컴포넌트다. 렌더 중 ref를 읽지 않도록, HTML 보기로 전환하는 시점의
|
|
||||||
// 초안을 state로 보관해 textarea가 마운트될 때의 초기값(defaultValue)으로만 사용한다.
|
|
||||||
const [htmlTextareaSeed, setHtmlTextareaSeed] = useState<string>(value ?? "");
|
|
||||||
const canImageUpload = Boolean(onImageUpload);
|
const canImageUpload = Boolean(onImageUpload);
|
||||||
|
|
||||||
const selectionRef = useRef<{ from: number; to: number } | null>(null);
|
const selectionRef = useRef<{ from: number; to: number } | null>(null);
|
||||||
@@ -526,7 +469,6 @@ export function KriEditorWysiwyg(props: Readonly<KriEditorProps>) {
|
|||||||
if (viewRef.current === "wysiwyg") {
|
if (viewRef.current === "wysiwyg") {
|
||||||
const raw = editor.getHTML();
|
const raw = editor.getHTML();
|
||||||
htmlDraftRef.current = raw;
|
htmlDraftRef.current = raw;
|
||||||
setHtmlTextareaSeed(raw);
|
|
||||||
setView("html");
|
setView("html");
|
||||||
|
|
||||||
// WYSIWYG에서 막 넘어온, 사용자가 직접 타이핑하지 않은 HTML이므로
|
// WYSIWYG에서 막 넘어온, 사용자가 직접 타이핑하지 않은 HTML이므로
|
||||||
@@ -548,12 +490,14 @@ export function KriEditorWysiwyg(props: Readonly<KriEditorProps>) {
|
|||||||
toast.message(compatibility.reason ?? "현재 HTML은 WYSIWYG로 전환할 수 없습니다.");
|
toast.message(compatibility.reason ?? "현재 HTML은 WYSIWYG로 전환할 수 없습니다.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const safe = sanitizeEditorHtml(raw, htmlSanitizer, sanitizeHtmlOpt, allowedCustomHtml);
|
const safe = htmlSanitizer
|
||||||
|
? htmlSanitizer(raw)
|
||||||
|
: sanitizeHtmlOpt ? sanitizeHtml(raw, allowedCustomHtml) : raw;
|
||||||
|
|
||||||
editor.commands.setContent(safe, { emitUpdate: false, parseOptions: { preserveWhitespace: "full" } });
|
editor.commands.setContent(safe, { emitUpdate: false, parseOptions: { preserveWhitespace: "full" } });
|
||||||
flushChange(preserveEmptyParagraphs(editor.getHTML()));
|
flushChange(preserveEmptyParagraphs(editor.getHTML()));
|
||||||
setView("wysiwyg");
|
setView("wysiwyg");
|
||||||
}, [allowedCustomHtml, editor, flushChange, getCompatibility, htmlSanitizer, sanitizeHtmlOpt, setView, setPreviewSource, setHtmlTextareaSeed]);
|
}, [allowedCustomHtml, editor, flushChange, getCompatibility, htmlSanitizer, sanitizeHtmlOpt]);
|
||||||
|
|
||||||
const formatHtmlView = useCallback(async () => {
|
const formatHtmlView = useCallback(async () => {
|
||||||
try {
|
try {
|
||||||
@@ -566,7 +510,7 @@ export function KriEditorWysiwyg(props: Readonly<KriEditorProps>) {
|
|||||||
toast.error("HTML 정렬에 실패했습니다.");
|
toast.error("HTML 정렬에 실패했습니다.");
|
||||||
console.error(err);
|
console.error(err);
|
||||||
}
|
}
|
||||||
}, [scheduleChange, setPreviewSource]);
|
}, [scheduleChange]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!editor) return;
|
if (!editor) return;
|
||||||
@@ -598,28 +542,46 @@ export function KriEditorWysiwyg(props: Readonly<KriEditorProps>) {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setPreviewSource(value ?? "");
|
setPreviewSource(value ?? "");
|
||||||
if (!editor || value == null) return;
|
if (!editor) return;
|
||||||
|
if (value == null) return;
|
||||||
|
|
||||||
// WYSIWYG로 손실 없이 편집할 수 없는 값은 HTML 보기로 전환해 원문을 유지한다.
|
const compatibility = getCompatibility(value);
|
||||||
if (showHtmlToggle && !getCompatibility(value).compatible) {
|
if (showHtmlToggle && !compatibility.compatible) {
|
||||||
writeHtmlDraft(htmlDraftRef, htmlTextareaRef, value);
|
htmlDraftRef.current = value;
|
||||||
|
if (htmlTextareaRef.current) htmlTextareaRef.current.value = value;
|
||||||
if (viewRef.current !== "html") {
|
if (viewRef.current !== "html") {
|
||||||
viewRef.current = "html";
|
viewRef.current = "html";
|
||||||
setHtmlTextareaSeed(value);
|
|
||||||
setView("html");
|
setView("html");
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (viewRef.current === "html") {
|
if (viewRef.current === "html") {
|
||||||
const isExternalChange = value !== optimisticHtmlRef.current && value !== htmlDraftRef.current;
|
if (getWysiwygCompatibility && value !== optimisticHtmlRef.current && value !== htmlDraftRef.current) {
|
||||||
if (getWysiwygCompatibility && isExternalChange) {
|
htmlDraftRef.current = value;
|
||||||
writeHtmlDraft(htmlDraftRef, htmlTextareaRef, value);
|
if (htmlTextareaRef.current) htmlTextareaRef.current.value = value;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
syncEditorContent(editor, value, optimisticHtmlRef.current);
|
// 빈 문자열("")은 ProseMirror 스키마상 유효한 문서가 아니라 setContent가 조용히 실패해
|
||||||
|
// 이전 템플릿 본문이 그대로 남는 문제가 있었음 -> 빈 값은 빈 문단으로 정규화해서 비교/설정.
|
||||||
|
const normalizedValue = value || "<p></p>";
|
||||||
|
const current = editor.getHTML();
|
||||||
|
|
||||||
|
if (normalizedValue !== current && normalizedValue !== optimisticHtmlRef.current) {
|
||||||
|
// 외부에서 본문이 변경된 경우에만 기존 editor 문서를 갱신한다.
|
||||||
|
editor.commands.setContent(normalizedValue, {
|
||||||
|
emitUpdate: false,
|
||||||
|
parseOptions: {preserveWhitespace: "full"},
|
||||||
|
});
|
||||||
|
|
||||||
|
// resize가 활성화된 TipTap 이미지 NodeView는 노드의 src 변경을 기존 DOM에 반영하지 않는다.
|
||||||
|
// editor 전체 대신 NodeView만 다시 생성해 이미지를 갱신하고 편집 포커스는 유지한다.
|
||||||
|
if (normalizedValue.includes("<img")) {
|
||||||
|
editor.createNodeViews();
|
||||||
|
}
|
||||||
|
}
|
||||||
}, [value, editor, view, getCompatibility, getWysiwygCompatibility, showHtmlToggle]);
|
}, [value, editor, view, getCompatibility, getWysiwygCompatibility, showHtmlToggle]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -684,14 +646,13 @@ export function KriEditorWysiwyg(props: Readonly<KriEditorProps>) {
|
|||||||
|
|
||||||
const previewHtml = useMemo(() => {
|
const previewHtml = useMemo(() => {
|
||||||
const preserved = preserveEmptyParagraphs(previewSource);
|
const preserved = preserveEmptyParagraphs(previewSource);
|
||||||
const sanitized = sanitizeEditorHtml(preserved, htmlSanitizer, sanitizeHtmlOpt, allowedCustomHtml);
|
const sanitized = htmlSanitizer
|
||||||
|
? htmlSanitizer(preserved)
|
||||||
|
: sanitizeHtmlOpt ? sanitizeHtml(preserved, allowedCustomHtml) : preserved;
|
||||||
const withLinkStyle = applyLinkPreviewClass(sanitized);
|
const withLinkStyle = applyLinkPreviewClass(sanitized);
|
||||||
return transformPreviewHtml ? transformPreviewHtml(withLinkStyle) : withLinkStyle;
|
return transformPreviewHtml ? transformPreviewHtml(withLinkStyle) : withLinkStyle;
|
||||||
}, [allowedCustomHtml, htmlSanitizer, previewSource, sanitizeHtmlOpt, transformPreviewHtml]);
|
}, [allowedCustomHtml, htmlSanitizer, previewSource, sanitizeHtmlOpt, transformPreviewHtml]);
|
||||||
|
|
||||||
// 이미지맵을 사용할 때만 미리보기에 <area> 영역을 표시한다.
|
|
||||||
const imageMapOverlayBoxes = useImageMapOverlay(previewContainerRef, previewHtml, enableImageMap && showPreview);
|
|
||||||
|
|
||||||
const wysiwygCompatibility = useMemo(
|
const wysiwygCompatibility = useMemo(
|
||||||
() => getCompatibility(view === "html" ? previewSource : (editor?.getHTML() ?? previewSource)),
|
() => getCompatibility(view === "html" ? previewSource : (editor?.getHTML() ?? previewSource)),
|
||||||
[editor, getCompatibility, previewSource, view],
|
[editor, getCompatibility, previewSource, view],
|
||||||
@@ -739,11 +700,7 @@ export function KriEditorWysiwyg(props: Readonly<KriEditorProps>) {
|
|||||||
onAddRow={addRow}
|
onAddRow={addRow}
|
||||||
onAddColumn={addColumn}
|
onAddColumn={addColumn}
|
||||||
onDeleteTable={deleteTable}
|
onDeleteTable={deleteTable}
|
||||||
customContent={
|
customContent={props.renderToolbarEnd?.({ editor, command, view })}
|
||||||
props.renderToolbarEnd ? (
|
|
||||||
<ToolbarEndSlot renderToolbarEnd={props.renderToolbarEnd} editor={editor} command={command} view={view} />
|
|
||||||
) : undefined
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
@@ -757,7 +714,7 @@ export function KriEditorWysiwyg(props: Readonly<KriEditorProps>) {
|
|||||||
<textarea
|
<textarea
|
||||||
ref={htmlTextareaRef}
|
ref={htmlTextareaRef}
|
||||||
className="h-[220px] w-full resize-y rounded-md border bg-background p-3 font-mono text-sm outline-none"
|
className="h-[220px] w-full resize-y rounded-md border bg-background p-3 font-mono text-sm outline-none"
|
||||||
defaultValue={htmlTextareaSeed}
|
defaultValue={htmlDraftRef.current}
|
||||||
onMouseDown={(e) => e.stopPropagation()}
|
onMouseDown={(e) => e.stopPropagation()}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
htmlDraftRef.current = e.target.value;
|
htmlDraftRef.current = e.target.value;
|
||||||
@@ -769,9 +726,9 @@ export function KriEditorWysiwyg(props: Readonly<KriEditorProps>) {
|
|||||||
{...htmlTi.bindSelectionHandlers}
|
{...htmlTi.bindSelectionHandlers}
|
||||||
/>
|
/>
|
||||||
{!wysiwygCompatibility.compatible ? (
|
{!wysiwygCompatibility.compatible ? (
|
||||||
<output className="mt-2 block text-xs text-amber-700">
|
<p className="mt-2 text-xs text-amber-700" role="status">
|
||||||
{wysiwygCompatibility.reason ?? "현재 HTML은 WYSIWYG에서 손실 없이 편집할 수 없습니다."}
|
{wysiwygCompatibility.reason ?? "현재 HTML은 WYSIWYG에서 손실 없이 편집할 수 없습니다."}
|
||||||
</output>
|
</p>
|
||||||
) : null}
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
@@ -779,19 +736,8 @@ export function KriEditorWysiwyg(props: Readonly<KriEditorProps>) {
|
|||||||
{showPreview && (
|
{showPreview && (
|
||||||
<div className={cn("border-t p-3", previewClassName)}>
|
<div className={cn("border-t p-3", previewClassName)}>
|
||||||
<div className="mb-2 text-sm font-semibold">미리보기</div>
|
<div className="mb-2 text-sm font-semibold">미리보기</div>
|
||||||
<div ref={previewContainerRef} className="relative rounded-md border bg-muted/30 p-3">
|
<div className="rounded-md border bg-muted/30 p-3">
|
||||||
<div dangerouslySetInnerHTML={{ __html: previewHtml }} />
|
<div dangerouslySetInnerHTML={{ __html: previewHtml }} />
|
||||||
{imageMapOverlayBoxes.length > 0 && (
|
|
||||||
<div className="pointer-events-none absolute inset-0" aria-hidden="true">
|
|
||||||
{imageMapOverlayBoxes.map((box) => (
|
|
||||||
<div
|
|
||||||
key={box.key}
|
|
||||||
className="absolute border-2 border-sky-500 bg-sky-500/30"
|
|
||||||
style={box.style}
|
|
||||||
/>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -1,48 +0,0 @@
|
|||||||
import { useLayoutEffect, useRef, useState } from "react"
|
|
||||||
import { computeImageMapOverlayBoxes, type ImageMapOverlayBox } from "../utils/imageMapOverlay"
|
|
||||||
|
|
||||||
// previewHtml이 바뀔 때마다(이미지 로드/리사이즈 포함) <map>/<area> 오버레이 위치를 다시 계산한다.
|
|
||||||
// enabled가 false이면 계산·관찰하지 않는다.
|
|
||||||
export function useImageMapOverlay(
|
|
||||||
containerRef: React.RefObject<HTMLElement | null>,
|
|
||||||
previewHtml: string,
|
|
||||||
enabled = true,
|
|
||||||
): ImageMapOverlayBox[] {
|
|
||||||
const [boxes, setBoxes] = useState<ImageMapOverlayBox[]>([])
|
|
||||||
const frameRef = useRef<number | null>(null)
|
|
||||||
|
|
||||||
useLayoutEffect(() => {
|
|
||||||
const container = containerRef.current
|
|
||||||
if (!enabled || !container) {
|
|
||||||
setBoxes([])
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
const recompute = () => setBoxes(computeImageMapOverlayBoxes(container))
|
|
||||||
|
|
||||||
const scheduleRecompute = () => {
|
|
||||||
if (frameRef.current !== null) cancelAnimationFrame(frameRef.current)
|
|
||||||
frameRef.current = requestAnimationFrame(recompute)
|
|
||||||
}
|
|
||||||
|
|
||||||
scheduleRecompute()
|
|
||||||
|
|
||||||
const images = Array.from(container.querySelectorAll<HTMLImageElement>("img[usemap]"))
|
|
||||||
images.forEach((img) => {
|
|
||||||
if (!img.complete) img.addEventListener("load", scheduleRecompute)
|
|
||||||
})
|
|
||||||
|
|
||||||
const resizeObserver = new ResizeObserver(scheduleRecompute)
|
|
||||||
resizeObserver.observe(container)
|
|
||||||
window.addEventListener("resize", scheduleRecompute)
|
|
||||||
|
|
||||||
return () => {
|
|
||||||
if (frameRef.current !== null) cancelAnimationFrame(frameRef.current)
|
|
||||||
images.forEach((img) => img.removeEventListener("load", scheduleRecompute))
|
|
||||||
resizeObserver.disconnect()
|
|
||||||
window.removeEventListener("resize", scheduleRecompute)
|
|
||||||
}
|
|
||||||
}, [containerRef, previewHtml, enabled])
|
|
||||||
|
|
||||||
return boxes
|
|
||||||
}
|
|
||||||
@@ -80,18 +80,15 @@ export type KriEditorProps = {
|
|||||||
onImageUploadError?: (error: unknown) => void
|
onImageUploadError?: (error: unknown) => void
|
||||||
debounceMs?: number
|
debounceMs?: number
|
||||||
smsTitle?: string
|
smsTitle?: string
|
||||||
/** Preview only; consumers must handle MMS. Actual delivery type is determined by the server. */
|
changeSmsType?: (type: 'SMS' | 'LMS') => void
|
||||||
changeSmsType?: (type: 'SMS' | 'LMS' | 'MMS') => void
|
|
||||||
isSmsReadOnly?: boolean
|
isSmsReadOnly?: boolean
|
||||||
smsMaxBytes?: number
|
smsMaxBytes?: number
|
||||||
lmsMaxBytes?: number
|
lmsMaxBytes?: number
|
||||||
smsPreviewSuffix?: string
|
smsPreviewSuffix?: string
|
||||||
/** 첨부파일이 있으면 길이·제목과 무관하게 MMS로 판정한다. */
|
/** 첨부파일이 있으면 길이·제목과 무관하게 LMS/MMS로 판정한다. */
|
||||||
smsHasAttachment?: boolean
|
smsHasAttachment?: boolean
|
||||||
/** 문자 미리보기의 제목과 본문 사이에 표시할 첨부 이미지 */
|
/** 문자 미리보기의 제목과 본문 사이에 표시할 첨부 이미지 */
|
||||||
smsImages?: KriEditorSmsImage[]
|
smsImages?: KriEditorSmsImage[]
|
||||||
/** 휴대폰 프레임 class (기본 높이 h-[600px] 조정 등) */
|
|
||||||
smsFrameClassName?: string
|
|
||||||
/** 알림톡 미리보기의 강조 제목. 없으면 표시하지 않는다. */
|
/** 알림톡 미리보기의 강조 제목. 없으면 표시하지 않는다. */
|
||||||
kkoTitle?: string
|
kkoTitle?: string
|
||||||
/** 알림톡 미리보기의 채널명·발신 프로필 이름. 없으면 표시하지 않는다. */
|
/** 알림톡 미리보기의 채널명·발신 프로필 이름. 없으면 표시하지 않는다. */
|
||||||
|
|||||||
@@ -1,112 +0,0 @@
|
|||||||
export type ImageMapOverlayBox = {
|
|
||||||
key: string
|
|
||||||
style: {
|
|
||||||
left: number
|
|
||||||
top: number
|
|
||||||
width: number
|
|
||||||
height: number
|
|
||||||
borderRadius?: string
|
|
||||||
clipPath?: string
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const parseCoords = (raw: string | null): number[] =>
|
|
||||||
(raw ?? "")
|
|
||||||
.split(",")
|
|
||||||
.map((value) => Number(value.trim()))
|
|
||||||
.filter((value) => Number.isFinite(value))
|
|
||||||
|
|
||||||
// coords는 <img>의 원본(naturalWidth/Height) 기준이라, 미리보기에서 이미지가
|
|
||||||
// 리사이즈되어 렌더링된 크기에 맞춰 스케일 변환한 뒤 컨테이너 기준 좌표로 옮겨야 한다.
|
|
||||||
export function computeImageMapOverlayBoxes(container: HTMLElement): ImageMapOverlayBox[] {
|
|
||||||
const boxes: ImageMapOverlayBox[] = []
|
|
||||||
const containerRect = container.getBoundingClientRect()
|
|
||||||
const images = container.querySelectorAll<HTMLImageElement>("img[usemap]")
|
|
||||||
|
|
||||||
images.forEach((img, imageIndex) => {
|
|
||||||
if (!img.complete || img.naturalWidth === 0 || img.naturalHeight === 0) return
|
|
||||||
|
|
||||||
const mapName = img.getAttribute("usemap")?.replace(/^#/, "")
|
|
||||||
if (!mapName) return
|
|
||||||
|
|
||||||
const map = container.querySelector<HTMLMapElement>(`map[name="${CSS.escape(mapName)}"]`)
|
|
||||||
if (!map) return
|
|
||||||
|
|
||||||
const imgRect = img.getBoundingClientRect()
|
|
||||||
if (imgRect.width === 0 || imgRect.height === 0) return
|
|
||||||
|
|
||||||
const scaleX = imgRect.width / img.naturalWidth
|
|
||||||
const scaleY = imgRect.height / img.naturalHeight
|
|
||||||
const offsetX = imgRect.left - containerRect.left
|
|
||||||
const offsetY = imgRect.top - containerRect.top
|
|
||||||
|
|
||||||
map.querySelectorAll("area").forEach((area, areaIndex) => {
|
|
||||||
const shape = (area.getAttribute("shape") || "rect").toLowerCase()
|
|
||||||
const coords = parseCoords(area.getAttribute("coords"))
|
|
||||||
const key = `${imageIndex}-${areaIndex}`
|
|
||||||
|
|
||||||
if (shape === "rect" && coords.length >= 4) {
|
|
||||||
const [x1, y1, x2, y2] = coords
|
|
||||||
boxes.push({
|
|
||||||
key,
|
|
||||||
style: {
|
|
||||||
left: offsetX + Math.min(x1, x2) * scaleX,
|
|
||||||
top: offsetY + Math.min(y1, y2) * scaleY,
|
|
||||||
width: Math.abs(x2 - x1) * scaleX,
|
|
||||||
height: Math.abs(y2 - y1) * scaleY,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if (shape === "circle" && coords.length >= 3) {
|
|
||||||
const [cx, cy, r] = coords
|
|
||||||
boxes.push({
|
|
||||||
key,
|
|
||||||
style: {
|
|
||||||
left: offsetX + (cx - r) * scaleX,
|
|
||||||
top: offsetY + (cy - r) * scaleY,
|
|
||||||
width: r * 2 * scaleX,
|
|
||||||
height: r * 2 * scaleY,
|
|
||||||
borderRadius: "9999px",
|
|
||||||
},
|
|
||||||
})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if (shape === "poly" && coords.length >= 6 && coords.length % 2 === 0) {
|
|
||||||
const xs = coords.filter((_, i) => i % 2 === 0)
|
|
||||||
const ys = coords.filter((_, i) => i % 2 === 1)
|
|
||||||
const minX = Math.min(...xs)
|
|
||||||
const maxX = Math.max(...xs)
|
|
||||||
const minY = Math.min(...ys)
|
|
||||||
const maxY = Math.max(...ys)
|
|
||||||
const width = maxX - minX
|
|
||||||
const height = maxY - minY
|
|
||||||
if (width <= 0 || height <= 0) return
|
|
||||||
|
|
||||||
const points: string[] = []
|
|
||||||
for (let i = 0; i < coords.length; i += 2) {
|
|
||||||
const px = ((coords[i] - minX) / width) * 100
|
|
||||||
const py = ((coords[i + 1] - minY) / height) * 100
|
|
||||||
points.push(`${px}% ${py}%`)
|
|
||||||
}
|
|
||||||
|
|
||||||
boxes.push({
|
|
||||||
key,
|
|
||||||
style: {
|
|
||||||
left: offsetX + minX * scaleX,
|
|
||||||
top: offsetY + minY * scaleY,
|
|
||||||
width: width * scaleX,
|
|
||||||
height: height * scaleY,
|
|
||||||
clipPath: `polygon(${points.join(", ")})`,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// shape="default"(이미지 전체)는 별도 오버레이 없이 그대로 둔다.
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
return boxes
|
|
||||||
}
|
|
||||||
@@ -4,31 +4,33 @@ import { useEffect, useRef, useState } from "react";
|
|||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import type { Route } from "next";
|
import type { Route } from "next";
|
||||||
import { useSetAtom } from "jotai";
|
import { useSetAtom } from "jotai";
|
||||||
|
import { useQueryClient } from "@tanstack/react-query";
|
||||||
import { apiError } from "@kri/common/http";
|
import { apiError } from "@kri/common/http";
|
||||||
import { useAuth } from "@/hooks/useAuth";
|
import { useAuth } from "@/hooks/useAuth";
|
||||||
import { useResetSession } from "@/hooks/useResetSession";
|
|
||||||
import { selectedProjectAtom } from "@/hooks/useSelectedProject";
|
import { selectedProjectAtom } from "@/hooks/useSelectedProject";
|
||||||
import { authApi } from "@/lib/http-client";
|
import { nextApi } from "@/lib/http-client";
|
||||||
import { isExternalLoginResponse, reportUrl, type ExternalLoginResponse } from "@/types/share";
|
import { isExternalSession, reportUrl, type ExternalSession } from "@/types/share";
|
||||||
import { LoadingOverlayAdapter } from "@/components/app-shell/LoadingOverlayAdapter";
|
import { LoadingOverlayAdapter } from "@/components/app-shell/LoadingOverlayAdapter";
|
||||||
|
|
||||||
export function ExternalEntry({ urlKey }: { urlKey: string }) {
|
export function ExternalEntry({ urlKey }: { urlKey: string }) {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { hydrated, setAuth } = useAuth();
|
const { hydrated, setAuth, logout } = useAuth();
|
||||||
const setProject = useSetAtom(selectedProjectAtom);
|
const setProject = useSetAtom(selectedProjectAtom);
|
||||||
const resetSession = useResetSession();
|
const queryClient = useQueryClient();
|
||||||
const pending = useRef<Promise<ExternalLoginResponse> | null>(null);
|
const pending = useRef<Promise<ExternalSession> | null>(null);
|
||||||
const [error, setError] = useState("");
|
const [error, setError] = useState("");
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!hydrated) return;
|
if (!hydrated) return;
|
||||||
let active = true;
|
let active = true;
|
||||||
const enter = async () => {
|
const enter = async () => {
|
||||||
setAuth({ mode: "external", user: null });
|
logout();
|
||||||
await resetSession();
|
setProject(null);
|
||||||
const result = await authApi.post<unknown>(`/external/${encodeURIComponent(urlKey)}/login`, null, {
|
await queryClient.cancelQueries();
|
||||||
|
queryClient.clear();
|
||||||
|
const result = await nextApi.post<unknown>(`/external/${encodeURIComponent(urlKey)}/login`, null, {
|
||||||
skipUnauthorizedHandler: true, skipForbiddenHandler: true, skipResponseErrorHandler: true,
|
skipUnauthorizedHandler: true, skipForbiddenHandler: true, skipResponseErrorHandler: true,
|
||||||
});
|
});
|
||||||
if (!isExternalLoginResponse(result)) throw new Error("공유 링크 로그인 응답을 확인해 주세요.");
|
if (!isExternalSession(result)) throw new Error("공유 링크 로그인 응답을 확인해 주세요.");
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
// Reuse the request during StrictMode effect replay; each entry records one landing.
|
// Reuse the request during StrictMode effect replay; each entry records one landing.
|
||||||
@@ -36,15 +38,13 @@ export function ExternalEntry({ urlKey }: { urlKey: string }) {
|
|||||||
void pending.current.then((result) => {
|
void pending.current.then((result) => {
|
||||||
if (!active) return;
|
if (!active) return;
|
||||||
setProject({ userId: result.user.userId, project: { projectType: result.link.projectType, pkey: result.link.pkey } });
|
setProject({ userId: result.user.userId, project: { projectType: result.link.projectType, pkey: result.link.pkey } });
|
||||||
setAuth({ mode: "external", user: result.user, external: result.link, accessToken: result.accessToken });
|
setAuth({ user: result.user, external: result.link });
|
||||||
router.replace(reportUrl(result.link.realUrl) as Route);
|
router.replace(reportUrl(result.link.realUrl) as Route);
|
||||||
}).catch((reason: unknown) => {
|
}).catch((reason: unknown) => {
|
||||||
if (active) {
|
if (active) setError(apiError(reason, { fallbackMessage: "공유 링크를 확인해 주세요." }).message);
|
||||||
setError(apiError(reason, { fallbackMessage: "공유 링크를 확인해 주세요." }).message);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
return () => { active = false; };
|
return () => { active = false; };
|
||||||
}, [hydrated, setAuth, setProject, resetSession, router, urlKey]);
|
}, [hydrated, logout, setAuth, setProject, queryClient, router, urlKey]);
|
||||||
if (error) return <p role="alert" className="p-8 text-center text-sm">{error}</p>;
|
if (error) return <p role="alert" className="p-8 text-center text-sm">{error}</p>;
|
||||||
return <LoadingOverlayAdapter force label="공유 링크를 확인하는 중입니다." />;
|
return <LoadingOverlayAdapter force label="공유 링크를 확인하는 중입니다." />;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,118 +0,0 @@
|
|||||||
"use client";
|
|
||||||
|
|
||||||
import { useEffect, useState, type ReactNode } from "react";
|
|
||||||
import { usePathname, useRouter, useSearchParams } from "next/navigation";
|
|
||||||
import type { Route } from "next";
|
|
||||||
import { useStore } from "jotai";
|
|
||||||
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
|
||||||
import { authStateAtom, useAuth } from "@/hooks/useAuth";
|
|
||||||
import { selectedProjectAtom, useSelectedProject } from "@/hooks/useSelectedProject";
|
|
||||||
import { projectSelectionAtom } from "@/hooks/useProjectNavigation";
|
|
||||||
import { cancelPreviousProjectQueries, checkProjectAccess } from "@/query/project";
|
|
||||||
import { isProjectPage } from "@/lib/report-navigation";
|
|
||||||
import {
|
|
||||||
announceProjectAccess, PROJECT_ACCESS_EVENT, projectFromSearch,
|
|
||||||
type ProjectAccessEvent,
|
|
||||||
} from "@/lib/project-access";
|
|
||||||
import { isExternalUser } from "@/types/share";
|
|
||||||
import { projectKey } from "@/types/kart";
|
|
||||||
|
|
||||||
/** Resolve incoming project parameters before mounting any project data consumers. */
|
|
||||||
export function ProjectEntry({ children }: { children: ReactNode }) {
|
|
||||||
const pathname = usePathname();
|
|
||||||
const search = useSearchParams().toString();
|
|
||||||
const router = useRouter();
|
|
||||||
const store = useStore();
|
|
||||||
const queryClient = useQueryClient();
|
|
||||||
const { auth } = useAuth();
|
|
||||||
const { project, select } = useSelectedProject();
|
|
||||||
const external = isExternalUser(auth.user);
|
|
||||||
const hasParams = isProjectPage(pathname) &&
|
|
||||||
(new URLSearchParams(search).has("projectType") || new URLSearchParams(search).has("pkey"));
|
|
||||||
const [denied, setDenied] = useState<ProjectAccessEvent | null>(null);
|
|
||||||
const candidate = hasParams ? projectFromSearch(new URLSearchParams(search)) : project;
|
|
||||||
const projectType = candidate?.projectType;
|
|
||||||
const pkey = candidate?.pkey;
|
|
||||||
const needsAccess = isProjectPage(pathname) && !external && !!candidate;
|
|
||||||
const access = useQuery({
|
|
||||||
queryKey: ["kart", auth.user?.userId, auth.user?.userRole, auth.user?.userTeam,
|
|
||||||
"project-access", projectType, pkey],
|
|
||||||
enabled: needsAccess,
|
|
||||||
queryFn: async () => {
|
|
||||||
if (!candidate) throw new Error("Project required");
|
|
||||||
await checkProjectAccess(candidate);
|
|
||||||
return true;
|
|
||||||
},
|
|
||||||
staleTime: 0,
|
|
||||||
retry: false,
|
|
||||||
refetchOnWindowFocus: false,
|
|
||||||
meta: { ignoreGlobalLoading: true },
|
|
||||||
});
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (!hasParams || (!external && (!access.isSuccess || access.isFetching))) return;
|
|
||||||
let active = true;
|
|
||||||
const id = store.get(projectSelectionAtom).id + 1;
|
|
||||||
store.set(projectSelectionAtom, { id, pending: true });
|
|
||||||
const current = () => active && store.get(projectSelectionAtom).id === id &&
|
|
||||||
store.get(authStateAtom) === auth;
|
|
||||||
const enter = async () => {
|
|
||||||
// External scope always comes from the verified link, never address parameters.
|
|
||||||
if (!external) {
|
|
||||||
if (projectType === undefined || !pkey || !auth.user) return;
|
|
||||||
const incoming = { projectType, pkey };
|
|
||||||
await cancelPreviousProjectQueries(queryClient, auth.user, store.get(selectedProjectAtom), incoming);
|
|
||||||
if (!current()) return;
|
|
||||||
select(incoming);
|
|
||||||
announceProjectAccess({ project: incoming, allowed: true });
|
|
||||||
}
|
|
||||||
if (!current()) return;
|
|
||||||
const params = new URLSearchParams(search);
|
|
||||||
params.delete("projectType");
|
|
||||||
params.delete("pkey");
|
|
||||||
const clean = pathname + (params.size ? "?" + params : "") + window.location.hash;
|
|
||||||
router.replace(clean as Route, { scroll: false });
|
|
||||||
};
|
|
||||||
void Promise.resolve().then(enter).catch(() => {
|
|
||||||
if (current()) router.replace("/");
|
|
||||||
}).finally(() => {
|
|
||||||
if (store.get(projectSelectionAtom).id === id)
|
|
||||||
store.set(projectSelectionAtom, { id, pending: false });
|
|
||||||
});
|
|
||||||
return () => {
|
|
||||||
active = false;
|
|
||||||
if (store.get(projectSelectionAtom).id === id)
|
|
||||||
store.set(projectSelectionAtom, { id: id + 1, pending: false });
|
|
||||||
};
|
|
||||||
}, [hasParams, search, pathname, projectType, pkey, access.isSuccess, access.isFetching,
|
|
||||||
auth, external, select, router, store, queryClient]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const onAccess = (event: Event) => {
|
|
||||||
const detail = (event as CustomEvent<ProjectAccessEvent>).detail;
|
|
||||||
if (!project || projectKey(detail.project) !== projectKey(project)) return;
|
|
||||||
setDenied(detail.allowed ? null : detail);
|
|
||||||
if (!detail.allowed) {
|
|
||||||
const predicate = (query: { queryKey: readonly unknown[] }) =>
|
|
||||||
query.queryKey[0] === "kart" && query.queryKey[1] === auth.user?.userId &&
|
|
||||||
query.queryKey.some((part, index, key) =>
|
|
||||||
part === project.projectType && key[index + 1] === project.pkey);
|
|
||||||
void queryClient.cancelQueries({ predicate }).then(() => queryClient.removeQueries({ predicate }));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
window.addEventListener(PROJECT_ACCESS_EVENT, onAccess);
|
|
||||||
return () => window.removeEventListener(PROJECT_ACCESS_EVENT, onAccess);
|
|
||||||
}, [project, auth.user?.userId, queryClient]);
|
|
||||||
|
|
||||||
const failed = isProjectPage(pathname) && (
|
|
||||||
(needsAccess && access.isError) ||
|
|
||||||
(hasParams && !external && !candidate) ||
|
|
||||||
(!hasParams && !!project && !!denied && !denied.allowed && projectKey(denied.project) === projectKey(project))
|
|
||||||
);
|
|
||||||
useEffect(() => {
|
|
||||||
if (failed) router.replace("/");
|
|
||||||
}, [failed, router]);
|
|
||||||
|
|
||||||
if (hasParams || failed || (needsAccess && !access.isSuccess)) return null;
|
|
||||||
return children;
|
|
||||||
}
|
|
||||||
@@ -2,9 +2,6 @@
|
|||||||
|
|
||||||
import Image from "next/image";
|
import Image from "next/image";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import type { Route } from "next";
|
|
||||||
import { useProjectNavigation } from "@/hooks/useProjectNavigation";
|
|
||||||
import { projectPageUrl } from "@/lib/project-access";
|
|
||||||
import { useEffect } from "react";
|
import { useEffect } from "react";
|
||||||
import { KriPieChart } from "@/components/chart";
|
import { KriPieChart } from "@/components/chart";
|
||||||
import { useProjectSummaryQuery } from "@/query/project";
|
import { useProjectSummaryQuery } from "@/query/project";
|
||||||
@@ -24,8 +21,7 @@ export function ProjectOverview() {
|
|||||||
const { auth } = useAuth();
|
const { auth } = useAuth();
|
||||||
const summary = useProjectSummaryQuery();
|
const summary = useProjectSummaryQuery();
|
||||||
const fontReady = useChartFontReady(labels.join("") + "0123456789");
|
const fontReady = useChartFontReady(labels.join("") + "0123456789");
|
||||||
const { hydrated, clear } = useSelectedProject();
|
const { hydrated, select, clear } = useSelectedProject();
|
||||||
const { navigate, pending } = useProjectNavigation();
|
|
||||||
useVisitLog("/");
|
useVisitLog("/");
|
||||||
// Legacy Main.js resets the selected project whenever the overview opens.
|
// Legacy Main.js resets the selected project whenever the overview opens.
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -51,14 +47,8 @@ export function ProjectOverview() {
|
|||||||
className="relative h-[420px] rounded-[15px] border border-kart-line bg-white"
|
className="relative h-[420px] rounded-[15px] border border-kart-line bg-white"
|
||||||
>
|
>
|
||||||
<Link
|
<Link
|
||||||
href={projectPageUrl("/Report/Current", project) as Route}
|
href="/Report/Current"
|
||||||
prefetch={false}
|
onClick={() => select(project)}
|
||||||
aria-disabled={pending}
|
|
||||||
onClick={(event) => {
|
|
||||||
if (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) return;
|
|
||||||
event.preventDefault();
|
|
||||||
if (!pending) void navigate(project, "/Report/Current");
|
|
||||||
}}
|
|
||||||
title={project.title ?? project.pkey}
|
title={project.title ?? project.pkey}
|
||||||
className="-m-px flex h-[55px] items-center justify-between rounded-[15px] border border-kart-line bg-kart-soft p-4"
|
className="-m-px flex h-[55px] items-center justify-between rounded-[15px] border border-kart-line bg-kart-soft p-4"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -1,26 +1,18 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { usePathname } from "next/navigation";
|
import { useRouter, usePathname } from "next/navigation";
|
||||||
import { KriSingleSelect } from "@/components/common/KriAutoComplete";
|
import { KriSingleSelect } from "@/components/common/KriAutoComplete";
|
||||||
import { useProjectListQuery } from "@/query/project";
|
import { useProjectListQuery } from "@/query/project";
|
||||||
import { useProjectNavigation } from "@/hooks/useProjectNavigation";
|
|
||||||
import { useSelectedProject } from "@/hooks/useSelectedProject";
|
import { useSelectedProject } from "@/hooks/useSelectedProject";
|
||||||
import { projectKey } from "@/types/kart";
|
import { projectKey } from "@/types/kart";
|
||||||
import { projectPagePath } from "@/lib/report-navigation";
|
import { projectPagePath } from "@/lib/report-navigation";
|
||||||
import { QueryState } from "./QueryState";
|
import { QueryState } from "./QueryState";
|
||||||
|
|
||||||
function getProjectPlaceholder(checkingAccess: boolean, loading: boolean, projectCount: number): string {
|
|
||||||
if (checkingAccess) return "접근 권한을 확인하는 중...";
|
|
||||||
if (loading) return "목록을 불러오는 중...";
|
|
||||||
if (projectCount > 0) return "프로젝트 선택";
|
|
||||||
return "조회 가능한 프로젝트가 없습니다.";
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Legacy ProjectSelect: search dropdown that always reads "프로젝트 선택". */
|
/** Legacy ProjectSelect: search dropdown that always reads "프로젝트 선택". */
|
||||||
export function ProjectSelector() {
|
export function ProjectSelector() {
|
||||||
|
const router = useRouter();
|
||||||
const pathname = usePathname();
|
const pathname = usePathname();
|
||||||
const { project: selected } = useSelectedProject();
|
const { project: selected, select } = useSelectedProject();
|
||||||
const { navigate, pending } = useProjectNavigation();
|
|
||||||
const projects = useProjectListQuery();
|
const projects = useProjectListQuery();
|
||||||
if (projects.isError)
|
if (projects.isError)
|
||||||
return (
|
return (
|
||||||
@@ -43,9 +35,16 @@ export function ProjectSelector() {
|
|||||||
);
|
);
|
||||||
if (!project) return;
|
if (!project) return;
|
||||||
// Same page for the new project (legacy keeps the current menu), progress from home.
|
// Same page for the new project (legacy keeps the current menu), progress from home.
|
||||||
void navigate(project, projectPagePath(pathname));
|
select(project);
|
||||||
|
router.push(projectPagePath(pathname));
|
||||||
}}
|
}}
|
||||||
placeholder={getProjectPlaceholder(pending, projects.isPending, projects.data?.length ?? 0)}
|
placeholder={
|
||||||
|
projects.isPending
|
||||||
|
? "목록을 불러오는 중..."
|
||||||
|
: projects.data?.length
|
||||||
|
? "프로젝트 선택"
|
||||||
|
: "조회 가능한 프로젝트가 없습니다."
|
||||||
|
}
|
||||||
widthClassName="w-full"
|
widthClassName="w-full"
|
||||||
className="h-8 min-h-8 rounded-[39px] border-[#d0d0d0] bg-kart-soft px-[22px] py-0 text-sm shadow-none"
|
className="h-8 min-h-8 rounded-[39px] border-[#d0d0d0] bg-kart-soft px-[22px] py-0 text-sm shadow-none"
|
||||||
spanClassName="text-sm [&_span]:text-kart-text"
|
spanClassName="text-sm [&_span]:text-kart-text"
|
||||||
@@ -58,7 +57,7 @@ export function ProjectSelector() {
|
|||||||
optionTooltipClassName="opacity-65"
|
optionTooltipClassName="opacity-65"
|
||||||
preventDeselect
|
preventDeselect
|
||||||
hideOptionCheck
|
hideOptionCheck
|
||||||
disabled={projects.isPending || pending}
|
disabled={projects.isPending}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,11 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { useEffect } from "react";
|
|
||||||
import { Provider as JotaiProvider } from "jotai";
|
import { Provider as JotaiProvider } from "jotai";
|
||||||
import { QueryProvider } from "@kri/common/query";
|
import { QueryProvider } from "@kri/common/query";
|
||||||
import { LoadingOverlayAdapter } from "@/components/app-shell/LoadingOverlayAdapter";
|
import { LoadingOverlayAdapter } from "@/components/app-shell/LoadingOverlayAdapter";
|
||||||
import { QueryLoadingSync } from "./QueryLoadingSync";
|
import { QueryLoadingSync } from "./QueryLoadingSync";
|
||||||
import { subscribeToAuthChanges } from "@/lib/auth-change";
|
|
||||||
|
|
||||||
export function AppProvider({ children }: { children: React.ReactNode }) {
|
export function AppProvider({ children }: { children: React.ReactNode }) {
|
||||||
useEffect(() => subscribeToAuthChanges(), []);
|
|
||||||
return (
|
return (
|
||||||
<JotaiProvider>
|
<JotaiProvider>
|
||||||
<QueryProvider>
|
<QueryProvider>
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { useCallback } from "react";
|
import { useCallback } from "react";
|
||||||
import { atom, useAtom, useAtomValue } from "jotai";
|
import { useAtom, useAtomValue } from "jotai";
|
||||||
import type { SetStateAction } from "react";
|
|
||||||
import type { LoginUser } from "@kri/common";
|
import type { LoginUser } from "@kri/common";
|
||||||
import { isRecord, isLoginUser } from "@/types/kart";
|
import { isRecord, isLoginUser } from "@/types/kart";
|
||||||
import type { AuthState as CommonAuthState } from "@kri/common/hooks";
|
import type { AuthState as CommonAuthState } from "@kri/common/hooks";
|
||||||
@@ -11,27 +10,25 @@ import {
|
|||||||
getLocalStorage,
|
getLocalStorage,
|
||||||
removeLocalStorage,
|
removeLocalStorage,
|
||||||
setLocalStorage,
|
setLocalStorage,
|
||||||
getSessionStorage,
|
|
||||||
setSessionStorage,
|
|
||||||
removeSessionStorage,
|
|
||||||
} from "@/store/storage/secure-storage";
|
} from "@/store/storage/secure-storage";
|
||||||
import { StorageKeys } from "@/store/storage/storage-keys";
|
import { StorageKeys } from "@/store/storage/storage-keys";
|
||||||
import { isExternalUser, type ShareLink } from "@/types/share";
|
import { isExternalSession, isExternalUser, type ShareLink } from "@/types/share";
|
||||||
import { isExternalAuth, type ExternalAuth } from "@/lib/external-auth";
|
|
||||||
|
|
||||||
export type AuthState = CommonAuthState<LoginUser> & { external?: ShareLink; accessToken?: string; mode?: "external" };
|
export type AuthState = CommonAuthState<LoginUser> & { external?: ShareLink };
|
||||||
const initialAuthState: AuthState = { user: null };
|
const initialAuthState: AuthState = { user: null };
|
||||||
|
|
||||||
const isPersistedAuthState = (value: unknown): value is AuthState =>
|
const isPersistedAuthState = (value: unknown): value is AuthState =>
|
||||||
isRecord(value) && isLoginUser(value.user) && !isExternalUser(value.user) &&
|
isRecord(value) && isLoginUser(value.user) &&
|
||||||
value.accessToken === undefined && value.external === undefined;
|
(isExternalUser(value.user)
|
||||||
|
? isExternalSession({ user: value.user, link: value.external })
|
||||||
|
: value.external === undefined);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* atom은 서버·클라이언트 최초 렌더 모두 initialAuthState로 시작한다.
|
* atom은 서버·클라이언트 최초 렌더 모두 initialAuthState로 시작한다.
|
||||||
* 저장소 값은 onMount(마운트 이후 시점)에만 반영되므로
|
* 저장소 값은 onMount(마운트 이후 시점)에만 반영되므로
|
||||||
* 서버 HTML과 클라이언트 최초 렌더가 항상 일치해 하이드레이션 오류가 발생하지 않는다.
|
* 서버 HTML과 클라이언트 최초 렌더가 항상 일치해 하이드레이션 오류가 발생하지 않는다.
|
||||||
*/
|
*/
|
||||||
const normalAuthStateAtom = createPersistentAtom<AuthState>(
|
export const authStateAtom = createPersistentAtom<AuthState>(
|
||||||
StorageKeys.AuthState,
|
StorageKeys.AuthState,
|
||||||
initialAuthState,
|
initialAuthState,
|
||||||
{
|
{
|
||||||
@@ -46,48 +43,6 @@ const normalAuthStateAtom = createPersistentAtom<AuthState>(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
const sessionStorage = { get: getSessionStorage, set: setSessionStorage, remove: removeSessionStorage };
|
|
||||||
const authModeAtom = createPersistentAtom<"normal" | "external">(StorageKeys.AuthMode, "normal", {
|
|
||||||
storage: sessionStorage,
|
|
||||||
validate: (value): value is "normal" | "external" => value === "normal" || value === "external",
|
|
||||||
shouldRemove: (value) => value === "normal",
|
|
||||||
});
|
|
||||||
const externalAuthStateAtom = createPersistentAtom<ExternalAuth | null>(StorageKeys.ExternalAuth, null, {
|
|
||||||
storage: sessionStorage,
|
|
||||||
validate: (value): value is ExternalAuth | null => value === null || isExternalAuth(value),
|
|
||||||
});
|
|
||||||
const emptyExternalAuth: ExternalAuth = { mode: "external", user: null };
|
|
||||||
|
|
||||||
export const authStateAtom = Object.assign(atom(
|
|
||||||
(get): AuthState => {
|
|
||||||
const normal = get(normalAuthStateAtom);
|
|
||||||
const mode = get(authModeAtom);
|
|
||||||
const external = get(externalAuthStateAtom);
|
|
||||||
if (mode === "external") return external ?? emptyExternalAuth;
|
|
||||||
return normal;
|
|
||||||
},
|
|
||||||
(get, set, action: SetStateAction<AuthState>) => {
|
|
||||||
const previous = get(authStateAtom);
|
|
||||||
const next = typeof action === "function" ? action(previous) : action;
|
|
||||||
if (next.mode === "external" || isExternalUser(next.user)) {
|
|
||||||
set(authModeAtom, "external");
|
|
||||||
set(externalAuthStateAtom, { ...next, mode: "external" });
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!next.user && previous.mode === "external") {
|
|
||||||
set(authModeAtom, "external");
|
|
||||||
set(externalAuthStateAtom, null);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
set(authModeAtom, "normal");
|
|
||||||
set(externalAuthStateAtom, null);
|
|
||||||
set(normalAuthStateAtom, { user: next.user });
|
|
||||||
},
|
|
||||||
), {
|
|
||||||
hydratedAtom: atom((get) => get(normalAuthStateAtom.hydratedAtom) &&
|
|
||||||
get(authModeAtom.hydratedAtom) && get(externalAuthStateAtom.hydratedAtom)),
|
|
||||||
});
|
|
||||||
|
|
||||||
export function useAuth() {
|
export function useAuth() {
|
||||||
const [auth, setAuth] = useAtom(authStateAtom);
|
const [auth, setAuth] = useAtom(authStateAtom);
|
||||||
const hydrated = useAtomValue(authStateAtom.hydratedAtom);
|
const hydrated = useAtomValue(authStateAtom.hydratedAtom);
|
||||||
|
|||||||
@@ -1,85 +0,0 @@
|
|||||||
"use client";
|
|
||||||
|
|
||||||
import { useEffect } from "react";
|
|
||||||
import { useAtomValue, useStore } from "jotai";
|
|
||||||
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
|
||||||
import { useRouter } from "next/navigation";
|
|
||||||
import { apiError } from "@kri/common/http";
|
|
||||||
import { authStateAtom, useAuth } from "@/hooks/useAuth";
|
|
||||||
import { selectedProjectAtom } from "@/hooks/useSelectedProject";
|
|
||||||
import { authApi } from "@/lib/http-client";
|
|
||||||
import { isLoginUser } from "@/types/kart";
|
|
||||||
import { isExternalSession, isExternalUser } from "@/types/share";
|
|
||||||
|
|
||||||
const SESSION_QUERY_KEY = ["auth-session"] as const;
|
|
||||||
|
|
||||||
export function useAuthSession() {
|
|
||||||
const store = useStore();
|
|
||||||
const queryClient = useQueryClient();
|
|
||||||
const router = useRouter();
|
|
||||||
const { setAuth, hydrated } = useAuth();
|
|
||||||
useAtomValue(selectedProjectAtom);
|
|
||||||
const projectHydrated = useAtomValue(selectedProjectAtom.hydratedAtom);
|
|
||||||
const otherQueries = { predicate: (query: { queryKey: readonly unknown[] }) => query.queryKey[0] !== SESSION_QUERY_KEY[0] };
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const refresh = () => {
|
|
||||||
void queryClient.refetchQueries({ queryKey: SESSION_QUERY_KEY, exact: true, type: "active" }, { cancelRefetch: false });
|
|
||||||
};
|
|
||||||
window.addEventListener("focus", refresh);
|
|
||||||
return () => window.removeEventListener("focus", refresh);
|
|
||||||
}, [queryClient]);
|
|
||||||
|
|
||||||
return useQuery({
|
|
||||||
queryKey: SESSION_QUERY_KEY,
|
|
||||||
enabled: hydrated && projectHydrated,
|
|
||||||
staleTime: 0,
|
|
||||||
gcTime: 0,
|
|
||||||
retry: false,
|
|
||||||
refetchOnMount: "always",
|
|
||||||
refetchOnWindowFocus: "always",
|
|
||||||
meta: { ignoreGlobalLoading: true },
|
|
||||||
queryFn: async ({ signal }) => {
|
|
||||||
const previous = store.get(authStateAtom);
|
|
||||||
try {
|
|
||||||
const user = await authApi.get<unknown>("/auth/my-info", {
|
|
||||||
cache: "no-store",
|
|
||||||
skipUnauthorizedHandler: true, skipForbiddenHandler: true, skipResponseErrorHandler: true,
|
|
||||||
headers: previous.mode === "external" ? { Authorization: `Bearer ${previous.accessToken ?? ""}` } : undefined,
|
|
||||||
});
|
|
||||||
signal.throwIfAborted();
|
|
||||||
if (!isLoginUser(user)) throw new Error("Invalid user response");
|
|
||||||
if (previous.mode === "external" && !isExternalSession({ user, link: previous.external })) throw new Error("Invalid link session");
|
|
||||||
if (previous.mode !== "external" && isExternalUser(user)) throw new Error("Invalid normal session");
|
|
||||||
const before = previous.user;
|
|
||||||
const changed = !before || before.userId !== user.userId || before.userRole !== user.userRole ||
|
|
||||||
before.userTeam !== user.userTeam || before.userCmpn !== user.userCmpn;
|
|
||||||
if (changed) {
|
|
||||||
await queryClient.cancelQueries(otherQueries);
|
|
||||||
signal.throwIfAborted();
|
|
||||||
queryClient.removeQueries(otherQueries);
|
|
||||||
queryClient.getMutationCache().clear();
|
|
||||||
if (previous.mode !== "external") {
|
|
||||||
const selected = store.get(selectedProjectAtom);
|
|
||||||
if (selected) store.set(selectedProjectAtom, { ...selected, userId: user.userId });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (changed || before?.userName !== user.userName) setAuth(previous.mode === "external" ? { ...previous, user } : { user });
|
|
||||||
return user;
|
|
||||||
} catch (reason) {
|
|
||||||
signal.throwIfAborted();
|
|
||||||
const status = apiError(reason).status;
|
|
||||||
if (status === 401 || status === 403) {
|
|
||||||
await queryClient.cancelQueries(otherQueries);
|
|
||||||
signal.throwIfAborted();
|
|
||||||
queryClient.removeQueries(otherQueries);
|
|
||||||
queryClient.getMutationCache().clear();
|
|
||||||
store.set(selectedProjectAtom, null);
|
|
||||||
setAuth({ user: null });
|
|
||||||
router.replace(previous.mode === "external" ? "/logout" : "/login");
|
|
||||||
}
|
|
||||||
throw reason;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
"use client";
|
|
||||||
|
|
||||||
import { useCallback, useEffect, useRef } from "react";
|
|
||||||
import { atom, useAtomValue, useStore } from "jotai";
|
|
||||||
import { useRouter } from "next/navigation";
|
|
||||||
import type { Route } from "next";
|
|
||||||
import { toast } from "sonner";
|
|
||||||
import { useQueryClient } from "@tanstack/react-query";
|
|
||||||
import { authStateAtom } from "@/hooks/useAuth";
|
|
||||||
import { selectedProjectAtom } from "@/hooks/useSelectedProject";
|
|
||||||
import { cancelPreviousProjectQueries, checkProjectAccess } from "@/query/project";
|
|
||||||
import { announceProjectAccess, projectAccessMessage } from "@/lib/project-access";
|
|
||||||
import { isExternalUser } from "@/types/share";
|
|
||||||
import type { ProjectRef } from "@/types/kart";
|
|
||||||
|
|
||||||
// Both the overview and header share one selection lock in this Jotai provider.
|
|
||||||
export const projectSelectionAtom = atom({ id: 0, pending: false });
|
|
||||||
|
|
||||||
export function useProjectNavigation() {
|
|
||||||
const store = useStore();
|
|
||||||
const router = useRouter();
|
|
||||||
const queryClient = useQueryClient();
|
|
||||||
const selection = useAtomValue(projectSelectionAtom);
|
|
||||||
const request = useRef<number | null>(null);
|
|
||||||
useEffect(() => () => {
|
|
||||||
if (request.current === store.get(projectSelectionAtom).id)
|
|
||||||
store.set(projectSelectionAtom, (value) => ({ id: value.id + 1, pending: false }));
|
|
||||||
}, [store]);
|
|
||||||
|
|
||||||
const navigate = useCallback(async (project: ProjectRef, path: Route) => {
|
|
||||||
const auth = store.get(authStateAtom);
|
|
||||||
if (!auth.user || isExternalUser(auth.user) || store.get(projectSelectionAtom).pending) return;
|
|
||||||
const id = store.get(projectSelectionAtom).id + 1;
|
|
||||||
request.current = id;
|
|
||||||
store.set(projectSelectionAtom, { id, pending: true });
|
|
||||||
const current = () => store.get(projectSelectionAtom).id === id && store.get(authStateAtom) === auth;
|
|
||||||
try {
|
|
||||||
await checkProjectAccess(project);
|
|
||||||
if (!current()) return;
|
|
||||||
await cancelPreviousProjectQueries(queryClient, auth.user, store.get(selectedProjectAtom), project);
|
|
||||||
if (!current()) return;
|
|
||||||
store.set(selectedProjectAtom, { userId: auth.user.userId, project: { projectType: project.projectType, pkey: project.pkey } });
|
|
||||||
announceProjectAccess({ project, allowed: true });
|
|
||||||
router.push(path);
|
|
||||||
} catch (error: unknown) {
|
|
||||||
if (current()) toast.error(projectAccessMessage(error));
|
|
||||||
} finally {
|
|
||||||
if (store.get(projectSelectionAtom).id === id)
|
|
||||||
store.set(projectSelectionAtom, { id, pending: false });
|
|
||||||
}
|
|
||||||
}, [store, router, queryClient]);
|
|
||||||
|
|
||||||
return { navigate, pending: selection.pending };
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
"use client";
|
|
||||||
|
|
||||||
import { useCallback } from "react";
|
|
||||||
import { useSetAtom } from "jotai";
|
|
||||||
import { useQueryClient } from "@tanstack/react-query";
|
|
||||||
import { selectedProjectAtom } from "@/hooks/useSelectedProject";
|
|
||||||
|
|
||||||
/** Clear cached queries and the selected project before applying a new identity. */
|
|
||||||
export function useResetSession() {
|
|
||||||
const queryClient = useQueryClient();
|
|
||||||
const setProject = useSetAtom(selectedProjectAtom);
|
|
||||||
return useCallback(async () => {
|
|
||||||
await queryClient.cancelQueries();
|
|
||||||
queryClient.clear();
|
|
||||||
setProject(null);
|
|
||||||
}, [queryClient, setProject]);
|
|
||||||
}
|
|
||||||
@@ -6,9 +6,9 @@ import { createPersistentAtom } from "@kri/common/jotai";
|
|||||||
import { useAuth } from "@/hooks/useAuth";
|
import { useAuth } from "@/hooks/useAuth";
|
||||||
import { isExternalUser } from "@/types/share";
|
import { isExternalUser } from "@/types/share";
|
||||||
import {
|
import {
|
||||||
getSessionStorage,
|
getLocalStorage,
|
||||||
removeSessionStorage,
|
removeLocalStorage,
|
||||||
setSessionStorage,
|
setLocalStorage,
|
||||||
} from "@/store/storage/secure-storage";
|
} from "@/store/storage/secure-storage";
|
||||||
import { StorageKeys } from "@/store/storage/storage-keys";
|
import { StorageKeys } from "@/store/storage/storage-keys";
|
||||||
import { isProjectRef, isRecord, type ProjectRef } from "@/types/kart";
|
import { isProjectRef, isRecord, type ProjectRef } from "@/types/kart";
|
||||||
@@ -23,15 +23,19 @@ const isSelectedProject = (value: unknown): value is SelectedProject =>
|
|||||||
value.userId !== "" &&
|
value.userId !== "" &&
|
||||||
isProjectRef(value.project));
|
isProjectRef(value.project));
|
||||||
|
|
||||||
/** Each tab owns its selection. */
|
/**
|
||||||
|
* Legacy KART kept the selected project in ptokenState (recoil-persist, localStorage) instead of
|
||||||
|
* the URL. Like authStateAtom, the stored value is applied after mount, so server and first
|
||||||
|
* client renders agree.
|
||||||
|
*/
|
||||||
export const selectedProjectAtom = createPersistentAtom<SelectedProject>(
|
export const selectedProjectAtom = createPersistentAtom<SelectedProject>(
|
||||||
StorageKeys.SelectedProject,
|
StorageKeys.SelectedProject,
|
||||||
null,
|
null,
|
||||||
{
|
{
|
||||||
storage: {
|
storage: {
|
||||||
get: getSessionStorage,
|
get: getLocalStorage,
|
||||||
set: setSessionStorage,
|
set: setLocalStorage,
|
||||||
remove: removeSessionStorage,
|
remove: removeLocalStorage,
|
||||||
},
|
},
|
||||||
validate: isSelectedProject,
|
validate: isSelectedProject,
|
||||||
shouldRemove: (value) => value === null,
|
shouldRemove: (value) => value === null,
|
||||||
@@ -40,8 +44,8 @@ export const selectedProjectAtom = createPersistentAtom<SelectedProject>(
|
|||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Current project for the signed-in user. Incoming address parameters are applied only
|
* Current project for the signed-in user. Address parameters (old `?projectType=&pkey=` links)
|
||||||
* after ProjectEntry verifies normal-user access; External scope comes from the link.
|
* never select a project; links are shared only through generated Page Copy / URL Copy links.
|
||||||
*/
|
*/
|
||||||
export function useSelectedProject() {
|
export function useSelectedProject() {
|
||||||
const { auth, hydrated: authHydrated } = useAuth();
|
const { auth, hydrated: authHydrated } = useAuth();
|
||||||
|
|||||||
@@ -1,36 +0,0 @@
|
|||||||
import { readExternalAuth } from "@/lib/external-auth";
|
|
||||||
|
|
||||||
// Set false to disable only cross-tab notifications and their listener.
|
|
||||||
const AUTH_CHANGE_SYNC_ENABLED = true;
|
|
||||||
const CHANNEL = "kart:internal-auth-change";
|
|
||||||
let channel: BroadcastChannel | undefined;
|
|
||||||
|
|
||||||
function authChannel() {
|
|
||||||
if (!AUTH_CHANGE_SYNC_ENABLED || typeof BroadcastChannel === "undefined") return;
|
|
||||||
try {
|
|
||||||
return channel ??= new BroadcastChannel(CHANNEL);
|
|
||||||
} catch {
|
|
||||||
// Cross-tab sync is optional when the browser disallows messaging.
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export function notifyAuthChange(path: "/" | "/login") {
|
|
||||||
authChannel()?.postMessage(path);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function subscribeToAuthChanges() {
|
|
||||||
const listener = authChannel();
|
|
||||||
if (!listener) return;
|
|
||||||
listener.onmessage = (event: MessageEvent<unknown>) => {
|
|
||||||
// A normal-login change must not navigate an independently authenticated link tab.
|
|
||||||
if (readExternalAuth()) return;
|
|
||||||
if (event.data !== "/" && event.data !== "/login") return;
|
|
||||||
// A full navigation discards this tab's cache/state without clearing the new cookie.
|
|
||||||
window.location.replace(event.data);
|
|
||||||
};
|
|
||||||
return () => {
|
|
||||||
listener.close();
|
|
||||||
channel = undefined;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
import "server-only";
|
|
||||||
import { NextResponse } from "next/server";
|
|
||||||
import { AUTH_COOKIE_MAX_AGE } from "@/const/common.const";
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
@@ -4,8 +4,4 @@ import { createEnv, env } from "@kri/common/config";
|
|||||||
export const serverEnv = createEnv({
|
export const serverEnv = createEnv({
|
||||||
ENV: env.required("ENV", process.env.ENV),
|
ENV: env.required("ENV", process.env.ENV),
|
||||||
API_SERVER: env.required("API_SERVER", process.env.API_SERVER),
|
API_SERVER: env.required("API_SERVER", process.env.API_SERVER),
|
||||||
AUTH_COOKIE_DOMAIN: env.optional(
|
|
||||||
"AUTH_COOKIE_DOMAIN",
|
|
||||||
process.env.AUTH_COOKIE_DOMAIN,
|
|
||||||
),
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,29 +0,0 @@
|
|||||||
"use client";
|
|
||||||
|
|
||||||
import type { LoginUser } from "@kri/common";
|
|
||||||
import { getSessionStorage } from "@/store/storage/secure-storage";
|
|
||||||
import { StorageKeys } from "@/store/storage/storage-keys";
|
|
||||||
import { isRecord } from "@/types/kart";
|
|
||||||
import { isExternalSession, type ShareLink } from "@/types/share";
|
|
||||||
|
|
||||||
export type ExternalAuth = {
|
|
||||||
mode: "external";
|
|
||||||
user: LoginUser | null;
|
|
||||||
external?: ShareLink;
|
|
||||||
accessToken?: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
export function isExternalAuth(value: unknown): value is ExternalAuth {
|
|
||||||
if (!isRecord(value) || value.mode !== "external") return false;
|
|
||||||
if (value.user === null) return value.external === undefined && value.accessToken === undefined;
|
|
||||||
return isExternalSession({ user: value.user, link: value.external }) &&
|
|
||||||
(value.accessToken === undefined || typeof value.accessToken === "string");
|
|
||||||
}
|
|
||||||
|
|
||||||
/** The mode survives missing/invalid token data so requests never fall back to the normal cookie. */
|
|
||||||
export function readExternalAuth(): ExternalAuth | null {
|
|
||||||
if (getSessionStorage(StorageKeys.AuthMode) !== "external") return null;
|
|
||||||
const value = getSessionStorage(StorageKeys.ExternalAuth);
|
|
||||||
if (isExternalAuth(value)) return value;
|
|
||||||
return { mode: "external", user: null };
|
|
||||||
}
|
|
||||||
@@ -1,7 +1,5 @@
|
|||||||
import { apiError, createHttpClient, HttpError, redirectToLogout } from "@kri/common/http";
|
import { createHttpClient } from "@kri/common/http";
|
||||||
import { clientEnv } from "@/lib/env.client";
|
import { clientEnv } from "@/lib/env.client";
|
||||||
import { announceProjectAccess, projectFromRequest } from "@/lib/project-access";
|
|
||||||
import { readExternalAuth } from "@/lib/external-auth";
|
|
||||||
|
|
||||||
const resolveBaseUrl = () =>
|
const resolveBaseUrl = () =>
|
||||||
typeof window === "undefined"
|
typeof window === "undefined"
|
||||||
@@ -9,31 +7,6 @@ const resolveBaseUrl = () =>
|
|||||||
: new URL(clientEnv.API_BASE, window.location.origin).toString();
|
: new URL(clientEnv.API_BASE, window.location.origin).toString();
|
||||||
|
|
||||||
export const nextApi = createHttpClient(resolveBaseUrl(), {
|
export const nextApi = createHttpClient(resolveBaseUrl(), {
|
||||||
getToken: () => {
|
|
||||||
const external = readExternalAuth();
|
|
||||||
if (!external) return null;
|
|
||||||
if (!external.accessToken) {
|
|
||||||
redirectToLogout();
|
|
||||||
throw new HttpError(401, { message: "공유 링크 인증이 필요합니다." }, "");
|
|
||||||
}
|
|
||||||
return external.accessToken;
|
|
||||||
},
|
|
||||||
onForbidden: (error) => {
|
|
||||||
const info = apiError(error);
|
|
||||||
if (readExternalAuth() || info.code === "EXTERNAL_SCOPE_DENIED" || info.code === "PROJECT_IDENTITY_REQUIRED") {
|
|
||||||
redirectToLogout();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const project = projectFromRequest(error.url);
|
|
||||||
if (info.code === "PROJECT_ACCESS_DENIED" && project && !new URL(error.url).pathname.endsWith("/access"))
|
|
||||||
announceProjectAccess({ project, allowed: false, message: info.message });
|
|
||||||
},
|
|
||||||
onResponseError: false,
|
|
||||||
});
|
|
||||||
|
|
||||||
// Login/logout BFF operations must also work before an External JWT is available.
|
|
||||||
export const authApi = createHttpClient(resolveBaseUrl(), {
|
|
||||||
onUnauthorized: false,
|
|
||||||
onForbidden: false,
|
onForbidden: false,
|
||||||
onResponseError: false,
|
onResponseError: false,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,19 +1,11 @@
|
|||||||
import { cookies, headers } from "next/headers";
|
import { cookies } from "next/headers";
|
||||||
import { createHttpClient } from "@kri/common/http";
|
import { createHttpClient } from "@kri/common/http";
|
||||||
import { serverEnv } from "@/lib/env.server";
|
import { serverEnv } from "@/lib/env.server";
|
||||||
import { CookieKeys } from "@/store/cookie/cookie-keys";
|
import { CookieKeys } from "@/store/cookie/cookie-keys";
|
||||||
|
|
||||||
export async function getServerAccessToken(): Promise<string | null> {
|
|
||||||
const authorization = (await headers()).get("authorization");
|
|
||||||
// Explicit credentials take precedence even when malformed; never use the normal
|
|
||||||
// cookie as a fallback for an External request. The backend verifies the JWT.
|
|
||||||
if (authorization !== null) return /^Bearer ([^\s]+)$/i.exec(authorization)?.[1] ?? null;
|
|
||||||
return (await cookies()).get(CookieKeys.AuthToken)?.value ?? null;
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function createServerApi(authenticated = true) {
|
export async function createServerApi(authenticated = true) {
|
||||||
let accessToken: string | null = null;
|
const cookieStore = await cookies();
|
||||||
if (authenticated) accessToken = await getServerAccessToken();
|
const accessToken = authenticated ? cookieStore.get(CookieKeys.AuthToken)?.value ?? null : null;
|
||||||
return createHttpClient(serverEnv.API_SERVER, {
|
return createHttpClient(serverEnv.API_SERVER, {
|
||||||
getToken: () => accessToken,
|
getToken: () => accessToken,
|
||||||
defaultHeaders: { "content-type": "application/json" },
|
defaultHeaders: { "content-type": "application/json" },
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import {
|
|||||||
isQuotaResultPath,
|
isQuotaResultPath,
|
||||||
isReportStreamPath,
|
isReportStreamPath,
|
||||||
isProjectReadPath,
|
isProjectReadPath,
|
||||||
projectReadQuery,
|
|
||||||
} from "@/lib/project-proxy-policy";
|
} from "@/lib/project-proxy-policy";
|
||||||
import { isRecord, validDateRange } from "@/types/kart";
|
import { isRecord, validDateRange } from "@/types/kart";
|
||||||
import { readReportBatch } from "@/lib/report-contract";
|
import { readReportBatch } from "@/lib/report-contract";
|
||||||
@@ -13,21 +12,9 @@ import { reportUrl } from "@/types/share";
|
|||||||
|
|
||||||
type Target = {
|
type Target = {
|
||||||
path: string;
|
path: string;
|
||||||
kind: "list" | "projects" | "quota" | "report" | "excel" | "respondent" | "share";
|
kind: "list" | "quota" | "report" | "excel" | "respondent" | "share";
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Linked lookup only: without all three keys the server would list the API key owner's projects. */
|
|
||||||
export function readInternalProjectListQuery(search: URLSearchParams) {
|
|
||||||
const query = projectReadQuery(["list"], search);
|
|
||||||
if (
|
|
||||||
!["0", "1"].includes(query.projectType ?? "") ||
|
|
||||||
!query.intranetCode?.trim() ||
|
|
||||||
!query.userTeam?.trim()
|
|
||||||
)
|
|
||||||
throw new Error("projectType(0|1), intranetCode, userTeam을 함께 입력해 주세요.");
|
|
||||||
return query;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** URL Copy only: the server resolves the project from the authenticated path. */
|
/** URL Copy only: the server resolves the project from the authenticated path. */
|
||||||
export function readInternalShareRequest(value: unknown) {
|
export function readInternalShareRequest(value: unknown) {
|
||||||
if (!isRecord(value) || value.mode !== "U")
|
if (!isRecord(value) || value.mode !== "U")
|
||||||
@@ -52,8 +39,6 @@ export function internalTarget(method: string, slug: string[]): Target | null {
|
|||||||
const path = "/" + slug.map(encodeURIComponent).join("/");
|
const path = "/" + slug.map(encodeURIComponent).join("/");
|
||||||
if (method === "GET" && area === "quota" && isQuotaListPath(parts))
|
if (method === "GET" && area === "quota" && isQuotaListPath(parts))
|
||||||
return { path, kind: "list" };
|
return { path, kind: "list" };
|
||||||
if (method === "GET" && area === "project" && parts.length === 1 && parts[0] === "list")
|
|
||||||
return { path, kind: "projects" };
|
|
||||||
if (method !== "POST") return null;
|
if (method !== "POST") return null;
|
||||||
if (
|
if (
|
||||||
area === "project" &&
|
area === "project" &&
|
||||||
|
|||||||
@@ -1,47 +0,0 @@
|
|||||||
import { apiError } from "@kri/common/http";
|
|
||||||
import { isProjectRef, type ProjectRef } from "@/types/kart";
|
|
||||||
|
|
||||||
export const PROJECT_ACCESS_EVENT = "kart:project-access";
|
|
||||||
export type ProjectAccessEvent = {
|
|
||||||
project: ProjectRef;
|
|
||||||
allowed: boolean;
|
|
||||||
message?: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
export function announceProjectAccess(detail: ProjectAccessEvent) {
|
|
||||||
if (typeof window !== "undefined")
|
|
||||||
window.dispatchEvent(new CustomEvent(PROJECT_ACCESS_EVENT, { detail }));
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Match the project in a BFF request, not whichever project is selected later. */
|
|
||||||
export function projectFromRequest(url: string): ProjectRef | null {
|
|
||||||
try {
|
|
||||||
const path = new URL(url, "https://kart.invalid").pathname;
|
|
||||||
const match = path.match(/\/(?:project|quota|derived|bookmark|export|import|share)\/([01])\/([^/]+)(?:\/|$)/);
|
|
||||||
if (!match) return null;
|
|
||||||
const project = { projectType: Number(match[1]), pkey: decodeURIComponent(match[2]) };
|
|
||||||
return isProjectRef(project) ? project : null;
|
|
||||||
} catch {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export function projectAccessMessage(error: unknown): string {
|
|
||||||
const info = apiError(error, { fallbackMessage: "프로젝트 접근 권한을 확인하지 못했습니다. 다시 시도해 주세요." });
|
|
||||||
return info.code === "PROJECT_ACCESS_DENIED"
|
|
||||||
? "프로젝트에 접근할 권한이 없습니다."
|
|
||||||
: info.message;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function projectFromSearch(search: URLSearchParams): ProjectRef | null {
|
|
||||||
const type = search.get("projectType");
|
|
||||||
if (search.getAll("projectType").length !== 1 || search.getAll("pkey").length !== 1 ||
|
|
||||||
(type !== "0" && type !== "1")) return null;
|
|
||||||
const project = { projectType: Number(type), pkey: search.get("pkey") };
|
|
||||||
return isProjectRef(project) ? project : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function projectPageUrl(pathname: string, project: ProjectRef): string {
|
|
||||||
const search = new URLSearchParams({ projectType: String(project.projectType), pkey: project.pkey });
|
|
||||||
return pathname + "?" + search;
|
|
||||||
}
|
|
||||||
@@ -2,8 +2,6 @@ const progress = new Set(["day", "type", "loi", "screen"]);
|
|||||||
/** Browser inputs select only these implemented read operations, never an arbitrary upstream URL. */
|
/** Browser inputs select only these implemented read operations, never an arbitrary upstream URL. */
|
||||||
export function isProjectReadPath(slug: string[]): boolean {
|
export function isProjectReadPath(slug: string[]): boolean {
|
||||||
if (slug.length === 1) return slug[0] === "list" || slug[0] === "summary";
|
if (slug.length === 1) return slug[0] === "list" || slug[0] === "summary";
|
||||||
if (slug.length === 3 && slug[2] === "access")
|
|
||||||
return isProjectReadPath([slug[0], slug[1], "question", "list"]);
|
|
||||||
return (
|
return (
|
||||||
slug.length === 4 &&
|
slug.length === 4 &&
|
||||||
(slug[0] === "0" || slug[0] === "1") &&
|
(slug[0] === "0" || slug[0] === "1") &&
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ export function isProjectPage(path: string): boolean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ProjectEntry verifies and consumes incoming project parameters. Subsequent navigation
|
* Project pages carry no project in the address (legacy KART kept it in client state); the
|
||||||
* uses the tab's selected project; other paths open the progress page.
|
* selected project lives in useSelectedProject. Other paths open the progress page.
|
||||||
*/
|
*/
|
||||||
export function projectPagePath(path: string): Route {
|
export function projectPagePath(path: string): Route {
|
||||||
return (isProjectPage(path) ? path : "/Report/Current") as Route;
|
return (isProjectPage(path) ? path : "/Report/Current") as Route;
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import type { LoginRequest } from "@kri/common";
|
import type { LoginRequest } from "@kri/common";
|
||||||
import { useMutation } from "@tanstack/react-query";
|
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
||||||
|
import { useSetAtom } from "jotai";
|
||||||
import { useAuth } from "@/hooks/useAuth";
|
import { useAuth } from "@/hooks/useAuth";
|
||||||
import { useResetSession } from "@/hooks/useResetSession";
|
import { selectedProjectAtom } from "@/hooks/useSelectedProject";
|
||||||
import { notifyAuthChange } from "@/lib/auth-change";
|
import { nextApi } from "@/lib/http-client";
|
||||||
import { authApi } from "@/lib/http-client";
|
|
||||||
import { isLoginUser } from "@/types/kart";
|
import { isLoginUser } from "@/types/kart";
|
||||||
import { readExternalAuth } from "@/lib/external-auth";
|
|
||||||
|
|
||||||
export function useLoginMutation() {
|
export function useLoginMutation() {
|
||||||
const { setFromLoginResponse } = useAuth();
|
const { setFromLoginResponse } = useAuth();
|
||||||
const resetSession = useResetSession();
|
const setSelectedProject = useSetAtom(selectedProjectAtom);
|
||||||
|
const queryClient = useQueryClient();
|
||||||
return useMutation({
|
return useMutation({
|
||||||
mutationFn: async (request: LoginRequest) => {
|
mutationFn: async (request: LoginRequest) => {
|
||||||
const user = await authApi.post<unknown>("/login", request, {
|
const user = await nextApi.post<unknown>("/login", request, {
|
||||||
skipUnauthorizedHandler: true,
|
skipUnauthorizedHandler: true,
|
||||||
skipForbiddenHandler: true,
|
skipForbiddenHandler: true,
|
||||||
skipResponseErrorHandler: true,
|
skipResponseErrorHandler: true,
|
||||||
@@ -22,32 +22,29 @@ export function useLoginMutation() {
|
|||||||
if (!isLoginUser(user)) throw new Error("로그인 응답을 확인해 주세요.");
|
if (!isLoginUser(user)) throw new Error("로그인 응답을 확인해 주세요.");
|
||||||
return user;
|
return user;
|
||||||
},
|
},
|
||||||
onSuccess: async (user) => {
|
onSuccess: (user) => {
|
||||||
|
queryClient.clear();
|
||||||
// Legacy Login.js starts every session without a selected project.
|
// Legacy Login.js starts every session without a selected project.
|
||||||
await resetSession();
|
setSelectedProject(null);
|
||||||
setFromLoginResponse(user);
|
setFromLoginResponse(user);
|
||||||
notifyAuthChange("/");
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
export function useLogoutMutation() {
|
export function useLogoutMutation() {
|
||||||
|
const queryClient = useQueryClient();
|
||||||
const { logout } = useAuth();
|
const { logout } = useAuth();
|
||||||
const resetSession = useResetSession();
|
const setSelectedProject = useSetAtom(selectedProjectAtom);
|
||||||
const externalSession = () => !!readExternalAuth();
|
|
||||||
return useMutation({
|
return useMutation({
|
||||||
onMutate: () => ({ external: externalSession() }),
|
mutationFn: () =>
|
||||||
mutationFn: async () => {
|
nextApi.post("/logout", null, {
|
||||||
if (externalSession()) return;
|
|
||||||
await authApi.post("/logout", null, {
|
|
||||||
skipUnauthorizedHandler: true,
|
skipUnauthorizedHandler: true,
|
||||||
skipForbiddenHandler: true,
|
skipForbiddenHandler: true,
|
||||||
skipResponseErrorHandler: true,
|
skipResponseErrorHandler: true,
|
||||||
});
|
}),
|
||||||
},
|
onSettled: () => {
|
||||||
onSettled: async (_data, _error, _variables, context) => {
|
|
||||||
await resetSession();
|
|
||||||
logout();
|
logout();
|
||||||
if (!context?.external) notifyAuthChange("/login");
|
setSelectedProject(null);
|
||||||
|
queryClient.clear();
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,12 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { useQuery, type QueryClient } from "@tanstack/react-query";
|
import { useQuery } from "@tanstack/react-query";
|
||||||
import type { LoginUser } from "@kri/common";
|
|
||||||
import type { SelectedProject } from "@/hooks/useSelectedProject";
|
|
||||||
import { HttpError } from "@kri/common/http";
|
import { HttpError } from "@kri/common/http";
|
||||||
import { useAuth } from "@/hooks/useAuth";
|
import { useAuth } from "@/hooks/useAuth";
|
||||||
import { isExternalUser } from "@/types/share";
|
import { isExternalUser } from "@/types/share";
|
||||||
import { nextApi } from "@/lib/http-client";
|
import { nextApi } from "@/lib/http-client";
|
||||||
import { queryKeys } from "@/query/key/keys";
|
import { queryKeys } from "@/query/key/keys";
|
||||||
import {
|
import {
|
||||||
isRecord,
|
|
||||||
isProject,
|
isProject,
|
||||||
isProjectSummary,
|
isProjectSummary,
|
||||||
isProgressDay,
|
isProgressDay,
|
||||||
@@ -21,37 +18,6 @@ import {
|
|||||||
type DateRange,
|
type DateRange,
|
||||||
} from "@/types/kart";
|
} from "@/types/kart";
|
||||||
|
|
||||||
export async function cancelPreviousProjectQueries(
|
|
||||||
queryClient: QueryClient,
|
|
||||||
user: LoginUser,
|
|
||||||
selected: SelectedProject,
|
|
||||||
next: ProjectRef,
|
|
||||||
): Promise<void> {
|
|
||||||
if (!selected || selected.userId !== user.userId) return;
|
|
||||||
const previous = selected.project;
|
|
||||||
if (previous.projectType === next.projectType && previous.pkey === next.pkey) return;
|
|
||||||
|
|
||||||
await queryClient.cancelQueries({
|
|
||||||
predicate: ({ queryKey }) => {
|
|
||||||
if (queryKey[0] !== "kart" || queryKey[1] !== user.userId ||
|
|
||||||
queryKey[2] !== user.userRole || queryKey[3] !== user.userTeam) return false;
|
|
||||||
// Project-scoped keys put type/pkey at positions 4/5 or 5/6.
|
|
||||||
return (queryKey[4] === previous.projectType && queryKey[5] === previous.pkey) ||
|
|
||||||
(queryKey[5] === previous.projectType && queryKey[6] === previous.pkey);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Always check the server; a cached permission is not an authorization decision. */
|
|
||||||
export async function checkProjectAccess(project: ProjectRef): Promise<void> {
|
|
||||||
const result = await nextApi.get<unknown>(
|
|
||||||
"/project/" + project.projectType + "/" + encodeURIComponent(project.pkey) + "/access",
|
|
||||||
{ cache: "no-store" },
|
|
||||||
);
|
|
||||||
if (!isRecord(result) || result.allowed !== true)
|
|
||||||
throw new Error("프로젝트 접근 권한 응답을 확인해 주세요.");
|
|
||||||
}
|
|
||||||
|
|
||||||
export function useProjectListQuery() {
|
export function useProjectListQuery() {
|
||||||
const { auth, hydrated } = useAuth();
|
const { auth, hydrated } = useAuth();
|
||||||
const user = auth.user;
|
const user = auth.user;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
export const CookieKeys = {
|
export const CookieKeys = {
|
||||||
AuthToken: "kri_internal_authToken",
|
AuthToken: "kri_authToken",
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
export type CookieKey = (typeof CookieKeys)[keyof typeof CookieKeys];
|
export type CookieKey = (typeof CookieKeys)[keyof typeof CookieKeys];
|
||||||
|
|||||||
@@ -1,14 +1,10 @@
|
|||||||
export const StorageKeys = {
|
export const StorageKeys = {
|
||||||
AuthState: "kri:authState",
|
AuthState: "kri:authState",
|
||||||
AuthMode: "kart:authMode",
|
|
||||||
ExternalAuth: "kart:externalAuth",
|
|
||||||
SelectedProject: "kart:selectedProject",
|
SelectedProject: "kart:selectedProject",
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
export type StorageKey = (typeof StorageKeys)[keyof typeof StorageKeys];
|
export type StorageKey = (typeof StorageKeys)[keyof typeof StorageKeys];
|
||||||
export const StorageType: Record<StorageKey, "local" | "session"> = {
|
export const StorageType: Record<StorageKey, "local" | "session"> = {
|
||||||
[StorageKeys.AuthState]: "local",
|
[StorageKeys.AuthState]: "local",
|
||||||
[StorageKeys.AuthMode]: "session",
|
[StorageKeys.SelectedProject]: "local",
|
||||||
[StorageKeys.ExternalAuth]: "session",
|
|
||||||
[StorageKeys.SelectedProject]: "session",
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -15,12 +15,6 @@ export type ShareLink = ProjectRef & {
|
|||||||
pageOnly: boolean;
|
pageOnly: boolean;
|
||||||
};
|
};
|
||||||
export type ExternalSession = { user: LoginUser; link: ShareLink };
|
export type ExternalSession = { user: LoginUser; link: ShareLink };
|
||||||
export type ExternalLoginResponse = ExternalSession & { accessToken: string };
|
|
||||||
|
|
||||||
export function isExternalLoginResponse(value: unknown): value is ExternalLoginResponse {
|
|
||||||
return isRecord(value) && typeof value.accessToken === "string" &&
|
|
||||||
value.accessToken.length > 0 && isExternalSession(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function isExternalUser(user: LoginUser | null | undefined): boolean {
|
export function isExternalUser(user: LoginUser | null | undefined): boolean {
|
||||||
return !!user && (user.userRole === EXTERNAL_URL_COPY_ROLE ||
|
return !!user && (user.userRole === EXTERNAL_URL_COPY_ROLE ||
|
||||||
|
|||||||
Reference in New Issue
Block a user