@fluojs/passport 1.0.2 → 1.0.3
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/README.ko.md +2 -0
- package/README.md +2 -0
- package/dist/cookie/cookie-manager.d.ts.map +1 -1
- package/dist/cookie/cookie-manager.js +25 -4
- package/package.json +6 -6
package/README.ko.md
CHANGED
|
@@ -144,6 +144,8 @@ export class AuthModule {}
|
|
|
144
144
|
|
|
145
145
|
Cookie access token은 비어 있지 않은 문자열이어야 합니다. `requireAccessToken: false`일 때만 누락된 cookie가 `{ authenticated: false }`로 resolve될 수 있으며, 존재하지만 malformed인 cookie 값은 JWT 검증 전에 항상 인증 실패로 처리됩니다.
|
|
146
146
|
|
|
147
|
+
`CookieManager`는 underlying adapter가 기존 header를 `set-cookie`처럼 다른 casing으로 저장했더라도, response에 이미 설정된 cookie를 덮어쓰지 않고 access-token 및 refresh-token `Set-Cookie` 값을 append합니다.
|
|
148
|
+
|
|
147
149
|
보호된 라우트는 계속 `@UseAuth(...)`를 사용해야 합니다. `requireAccessToken: false`를 설정해도 쿠키가 없을 때는 익명 principal이 아니라 명시적인 미인증 결과를 반환하므로, 보호된 라우트는 요청을 계속 거부합니다.
|
|
148
150
|
|
|
149
151
|
로그인 사용자와 게스트 호출자를 모두 허용하려는 라우트에서만 `@UseOptionalAuth(...)`를 사용하세요.
|
package/README.md
CHANGED
|
@@ -144,6 +144,8 @@ Import `CookieAuthModule.forRoot(...)`, `JwtModule.forRoot(...)`, and `PassportM
|
|
|
144
144
|
|
|
145
145
|
Cookie access tokens must be non-empty strings. Missing cookies can resolve to `{ authenticated: false }` only when `requireAccessToken: false`; malformed present cookie values always fail authentication before JWT verification.
|
|
146
146
|
|
|
147
|
+
`CookieManager` appends access-token and refresh-token `Set-Cookie` values without overwriting cookies that were already placed on the response, even when the underlying adapter stores the existing header with different casing such as `set-cookie`.
|
|
148
|
+
|
|
147
149
|
Protected routes must keep using `@UseAuth(...)`. If you configure `requireAccessToken: false`, a missing cookie resolves to an explicit unauthenticated result instead of an anonymous principal, so protected routes still reject the request.
|
|
148
150
|
|
|
149
151
|
Use `@UseOptionalAuth(...)` only on routes that intentionally support both signed-in and guest callers:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cookie-manager.d.ts","sourceRoot":"","sources":["../../src/cookie/cookie-manager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEtD,OAAO,
|
|
1
|
+
{"version":3,"file":"cookie-manager.d.ts","sourceRoot":"","sources":["../../src/cookie/cookie-manager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEtD,OAAO,EAAE,KAAK,iBAAiB,EAA8B,MAAM,kBAAkB,CAAC;AAEtF;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,QAAQ,GAAG,KAAK,GAAG,MAAM,CAAC;IACrC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAiB,SAAQ,aAAa;IACrD,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,sBAAsB,CAAC,EAAE,MAAM,CAAC;CACjC;AAED;;GAEG;AACH,MAAM,WAAW,mBAAoB,SAAQ,iBAAiB;IAC5D,aAAa,CAAC,EAAE,aAAa,CAAC;CAC/B;AAED,KAAK,uBAAuB,GAAG,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC,GAC/E,IAAI,CAAC,aAAa,EAAE,QAAQ,GAAG,QAAQ,CAAC,CAAC;AAE3C;;GAEG;AACH,eAAO,MAAM,sBAAsB,EAAE,uBAOpC,CAAC;AA4DF;;GAEG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA8B;IACtD,OAAO,CAAC,QAAQ,CAAC,aAAa,CAA0B;gBAE5C,MAAM,CAAC,EAAE,mBAAmB;IAYxC,oBAAoB,CAAC,QAAQ,EAAE,iBAAiB,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI;IAa3F,qBAAqB,CAAC,QAAQ,EAAE,iBAAiB,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI;IAa5F,sBAAsB,CAAC,QAAQ,EAAE,iBAAiB,GAAG,IAAI;IASzD,uBAAuB,CAAC,QAAQ,EAAE,iBAAiB,GAAG,IAAI;IAS1D,eAAe,CAAC,QAAQ,EAAE,iBAAiB,GAAG,IAAI;IAKlD,cAAc,CACZ,QAAQ,EAAE,iBAAiB,EAC3B,WAAW,EAAE,MAAM,EACnB,qBAAqB,CAAC,EAAE,MAAM,EAC9B,YAAY,CAAC,EAAE,MAAM,EACrB,sBAAsB,CAAC,EAAE,MAAM,GAC9B,IAAI;IAQP,OAAO,CAAC,eAAe;CAcxB;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,CAAC,EAAE,mBAAmB,GAAG,aAAa,CAE/E"}
|
|
@@ -51,6 +51,23 @@ function buildClearCookieHeader(name, options) {
|
|
|
51
51
|
maxAge: 0
|
|
52
52
|
});
|
|
53
53
|
}
|
|
54
|
+
function getHeaderCaseInsensitive(headers, name) {
|
|
55
|
+
for (const [headerName, value] of Object.entries(headers)) {
|
|
56
|
+
if (headerName.toLowerCase() === name.toLowerCase() && (typeof value === 'string' || Array.isArray(value))) {
|
|
57
|
+
return {
|
|
58
|
+
key: headerName,
|
|
59
|
+
value
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return undefined;
|
|
64
|
+
}
|
|
65
|
+
function toHeaderValues(value) {
|
|
66
|
+
if (Array.isArray(value)) {
|
|
67
|
+
return [...value];
|
|
68
|
+
}
|
|
69
|
+
return value ? [value] : [];
|
|
70
|
+
}
|
|
54
71
|
|
|
55
72
|
/**
|
|
56
73
|
* Represents the cookie manager.
|
|
@@ -102,10 +119,14 @@ export class CookieManager {
|
|
|
102
119
|
}
|
|
103
120
|
}
|
|
104
121
|
appendSetCookie(response, cookie) {
|
|
105
|
-
const
|
|
106
|
-
const cookies =
|
|
107
|
-
|
|
108
|
-
response.
|
|
122
|
+
const existingHeader = getHeaderCaseInsensitive(response.headers, 'Set-Cookie');
|
|
123
|
+
const cookies = [...toHeaderValues(existingHeader?.value), cookie];
|
|
124
|
+
response.setHeader('Set-Cookie', cookie);
|
|
125
|
+
const updatedHeader = getHeaderCaseInsensitive(response.headers, 'Set-Cookie');
|
|
126
|
+
if (updatedHeader?.key && updatedHeader.key !== 'Set-Cookie') {
|
|
127
|
+
delete response.headers[updatedHeader.key];
|
|
128
|
+
}
|
|
129
|
+
response.headers['Set-Cookie'] = cookies.length === 1 ? cookies[0] : cookies;
|
|
109
130
|
}
|
|
110
131
|
}
|
|
111
132
|
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"guard",
|
|
10
10
|
"strategy"
|
|
11
11
|
],
|
|
12
|
-
"version": "1.0.
|
|
12
|
+
"version": "1.0.3",
|
|
13
13
|
"private": false,
|
|
14
14
|
"license": "MIT",
|
|
15
15
|
"repository": {
|
|
@@ -36,11 +36,11 @@
|
|
|
36
36
|
"dist"
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@fluojs/
|
|
40
|
-
"@fluojs/
|
|
41
|
-
"@fluojs/http": "^1.
|
|
42
|
-
"@fluojs/jwt": "^1.0.
|
|
43
|
-
"@fluojs/runtime": "^1.1.
|
|
39
|
+
"@fluojs/di": "^1.0.3",
|
|
40
|
+
"@fluojs/core": "^1.0.3",
|
|
41
|
+
"@fluojs/http": "^1.1.0",
|
|
42
|
+
"@fluojs/jwt": "^1.0.1",
|
|
43
|
+
"@fluojs/runtime": "^1.1.1"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"vitest": "^3.2.4"
|