@nodus-lib/nodus 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +52 -0
- package/dist/nodus-config.d.ts +6 -0
- package/dist/nodus-config.js +25 -0
- package/package.json +55 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 next-session-inspector contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# next-session-inspector
|
|
2
|
+
|
|
3
|
+
Next.js **미들웨어**에서 세션 쿠키(`nodus_session`)를 발급·유지하는 경량 패키지입니다.
|
|
4
|
+
|
|
5
|
+
## 요구 사항
|
|
6
|
+
|
|
7
|
+
- Node.js `>=18.18.0`
|
|
8
|
+
- Next.js `>=14` (peer dependency)
|
|
9
|
+
|
|
10
|
+
## 설치
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm install next-session-inspector
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## 사용법
|
|
17
|
+
|
|
18
|
+
앱 루트의 `middleware.ts`에서 그대로 재보냅니다.
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
export { middleware, config } from "next-session-inspector";
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
또는 한 파일에 옮겨 적어도 됩니다.
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
import type { NextRequest } from "next/server";
|
|
28
|
+
import { NextResponse } from "next/server";
|
|
29
|
+
import { middleware as baseMiddleware } from "next-session-inspector";
|
|
30
|
+
|
|
31
|
+
export function middleware(request: NextRequest) {
|
|
32
|
+
const res = baseMiddleware(request);
|
|
33
|
+
// 추가 로직
|
|
34
|
+
return res;
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
(패키지가보내는 `middleware` 시그니처에 맞춰 호출하세요.)
|
|
39
|
+
|
|
40
|
+
## 동작
|
|
41
|
+
|
|
42
|
+
- 쿠키 이름: `nodus_session`
|
|
43
|
+
- 없으면 `crypto.randomUUID()`로 생성 후 설정
|
|
44
|
+
- `httpOnly`, `sameSite: "lax"`, `secure: true`, `path: "/"`, 최대 수명 1년
|
|
45
|
+
|
|
46
|
+
## `config.matcher`
|
|
47
|
+
|
|
48
|
+
기본 matcher는 정적 자산·`api`·favicon 등을 제외한 페이지 위주 경로입니다. 필요하면 앱 쪽 `middleware.ts`에서 `config`만 덮어쓰면 됩니다.
|
|
49
|
+
|
|
50
|
+
## 라이선스
|
|
51
|
+
|
|
52
|
+
MIT — `LICENSE` 파일 참고.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.config = void 0;
|
|
4
|
+
exports.middleware = middleware;
|
|
5
|
+
const server_1 = require("next/server");
|
|
6
|
+
const COOKIE_NAME = "nodus_session";
|
|
7
|
+
const COOKIE_MAX_AGE_SECONDS = 60 * 60 * 24 * 365;
|
|
8
|
+
function middleware(request) {
|
|
9
|
+
const response = server_1.NextResponse.next();
|
|
10
|
+
const existingSession = request.cookies.get(COOKIE_NAME)?.value;
|
|
11
|
+
const cookieValue = existingSession ?? crypto.randomUUID();
|
|
12
|
+
response.cookies.set(COOKIE_NAME, cookieValue, {
|
|
13
|
+
httpOnly: true,
|
|
14
|
+
sameSite: "lax",
|
|
15
|
+
secure: true,
|
|
16
|
+
path: "/",
|
|
17
|
+
maxAge: COOKIE_MAX_AGE_SECONDS,
|
|
18
|
+
});
|
|
19
|
+
return response;
|
|
20
|
+
}
|
|
21
|
+
exports.config = {
|
|
22
|
+
matcher: [
|
|
23
|
+
"/((?!api|_next/static|_next/image|favicon.ico|sitemap.xml|robots.txt).*)",
|
|
24
|
+
],
|
|
25
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nodus-lib/nodus",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"publishConfig": {
|
|
5
|
+
"access": "public"
|
|
6
|
+
},
|
|
7
|
+
"description": "Next.js middleware that issues and persists a nodus_session cookie.",
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"author": "",
|
|
10
|
+
"keywords": [
|
|
11
|
+
"nextjs",
|
|
12
|
+
"session",
|
|
13
|
+
"analytics",
|
|
14
|
+
"server",
|
|
15
|
+
"middleware"
|
|
16
|
+
],
|
|
17
|
+
"sideEffects": false,
|
|
18
|
+
"main": "dist/nodus-config.js",
|
|
19
|
+
"types": "dist/nodus-config.d.ts",
|
|
20
|
+
"exports": {
|
|
21
|
+
".": {
|
|
22
|
+
"types": "./dist/nodus-config.d.ts",
|
|
23
|
+
"default": "./dist/nodus-config.js"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"files": [
|
|
27
|
+
"dist",
|
|
28
|
+
"README.md",
|
|
29
|
+
"LICENSE"
|
|
30
|
+
],
|
|
31
|
+
"engines": {
|
|
32
|
+
"node": ">=18.18.0"
|
|
33
|
+
},
|
|
34
|
+
"scripts": {
|
|
35
|
+
"build": "tsc -p tsconfig.json",
|
|
36
|
+
"check": "tsc --noEmit -p tsconfig.json",
|
|
37
|
+
"prepublishOnly": "npm run build"
|
|
38
|
+
},
|
|
39
|
+
"peerDependencies": {
|
|
40
|
+
"next": ">=14.0.0"
|
|
41
|
+
},
|
|
42
|
+
"peerDependenciesMeta": {
|
|
43
|
+
"next": {
|
|
44
|
+
"optional": false
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"@types/node": "^24.7.2",
|
|
49
|
+
"@types/react": "^18.3.12",
|
|
50
|
+
"next": "^14.2.18",
|
|
51
|
+
"react": "^18.3.1",
|
|
52
|
+
"react-dom": "^18.3.1",
|
|
53
|
+
"typescript": "^5.9.3"
|
|
54
|
+
}
|
|
55
|
+
}
|