@fluojs/passport 1.0.0-beta.4 → 1.0.0-beta.6
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 +16 -2
- package/README.md +16 -2
- package/dist/decorators.d.ts.map +1 -1
- package/dist/decorators.js +2 -0
- package/dist/module.d.ts.map +1 -1
- package/dist/module.js +1 -0
- package/dist/types.d.ts +2 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +6 -6
package/README.ko.md
CHANGED
|
@@ -114,7 +114,7 @@ export class AuthModule {}
|
|
|
114
114
|
|
|
115
115
|
`CookieAuthStrategy`는 `@fluojs/jwt`가 정규화한 JWT principal 계약을 보존하며, `subject`, `claims`, `issuer`, `audience`, `roles`, `scopes`를 그대로 전달합니다.
|
|
116
116
|
|
|
117
|
-
보호된 라우트는 계속 `@UseAuth(...)`를 사용해야 합니다. `requireAccessToken: false`를 설정해도 쿠키가 없을 때는
|
|
117
|
+
보호된 라우트는 계속 `@UseAuth(...)`를 사용해야 합니다. `requireAccessToken: false`를 설정해도 쿠키가 없을 때는 익명 principal이 아니라 명시적인 미인증 결과를 반환하므로, 보호된 라우트는 요청을 계속 거부합니다.
|
|
118
118
|
|
|
119
119
|
로그인 사용자와 게스트 호출자를 모두 허용하려는 라우트에서만 `@UseOptionalAuth(...)`를 사용하세요.
|
|
120
120
|
|
|
@@ -134,7 +134,7 @@ export class SessionController {
|
|
|
134
134
|
|
|
135
135
|
### 리프레시 토큰 수명 주기
|
|
136
136
|
|
|
137
|
-
|
|
137
|
+
패키지는 안전한 토큰 rotation과 revocation을 위해 built-in `RefreshTokenStrategy`, `RefreshTokenModule`, `RefreshTokenService` contract를 제공합니다.
|
|
138
138
|
|
|
139
139
|
```typescript
|
|
140
140
|
import { Module } from '@fluojs/core';
|
|
@@ -171,6 +171,14 @@ export class AuthController {
|
|
|
171
171
|
|
|
172
172
|
`RefreshTokenModule.forRoot(...)`를 `PassportModule.forRoot(...)`와 함께 import 하여 refresh-token 전략과 공유 `REFRESH_TOKEN_SERVICE` alias를 같은 모듈 wiring에서 사용하세요.
|
|
173
173
|
|
|
174
|
+
`RefreshTokenStrategy`는 `body.refreshToken`, `Authorization: Bearer ...`, `x-refresh-token`에서 token을 읽습니다. Malformed non-string token은 인증 실패로 처리됩니다. `JwtRefreshTokenAdapter`는 `secret`과 backing store가 필요하며, `store: 'memory'`는 development 및 single-instance deployment용입니다.
|
|
175
|
+
|
|
176
|
+
### Account linking과 status
|
|
177
|
+
|
|
178
|
+
Identity-link 결정을 모델링하려면 `createConservativeAccountLinkPolicy(...)`와 `resolveAccountLinking(...)`을 사용합니다. 기본 conservative policy는 명시적인 existing link 또는 user-confirmed match만 연결하고, 그 외에는 create/skip/reject/conflict를 결정적으로 처리합니다.
|
|
179
|
+
|
|
180
|
+
`createPassportPlatformStatusSnapshot(...)`와 `createPassportPlatformDiagnosticIssues(...)`는 등록된 strategy, default strategy 설정, preset, refresh-token store readiness에 대한 readiness/health diagnostic을 노출합니다.
|
|
181
|
+
|
|
174
182
|
## 공개 API 개요
|
|
175
183
|
|
|
176
184
|
### 데코레이터
|
|
@@ -185,11 +193,17 @@ export class AuthController {
|
|
|
185
193
|
- `CookieManager`: HttpOnly 인증 쿠키 관리를 위한 유틸리티입니다.
|
|
186
194
|
- `RefreshTokenModule`: 내장 refresh-token 프리셋의 모듈 진입점입니다.
|
|
187
195
|
- `JwtRefreshTokenAdapter`: `@fluojs/jwt`의 리프레시 로직을 패스포트 인터페이스로 연결합니다.
|
|
196
|
+
- `createPassportJsStrategyBridge(...)`: Passport.js strategy를 fluo `AuthStrategy`로 변환합니다.
|
|
197
|
+
- Cookie helper: `createCookieAuthPreset`, `createCookieAuthStrategyRegistration`, `createCookieManager`, `normalizeCookieAuthOptions`.
|
|
198
|
+
- Refresh helper: `createRefreshTokenStrategyRegistration`.
|
|
199
|
+
- Status/diagnostics helper: `createPassportPlatformStatusSnapshot`, `createPassportPlatformDiagnosticIssues`.
|
|
188
200
|
|
|
189
201
|
### 인터페이스
|
|
190
202
|
- `AuthStrategy`: 커스텀 인증 로직 구현을 위한 계약입니다.
|
|
191
203
|
- `AccountLinkPolicy`: 계정 연결 결정 로직을 위한 확장 지점입니다.
|
|
192
204
|
|
|
205
|
+
`UseOptionalAuth`는 scope가 필요 없는 route에서만 credential 누락을 우회합니다. Scoped route에는 여전히 principal이 필요합니다. Passport.js bridge의 `redirect()`는 response를 commit하고 protected handler를 건너뛰며, `pass()`와 Passport action 없이 완료된 strategy는 인증 실패입니다.
|
|
206
|
+
|
|
193
207
|
## 관련 패키지
|
|
194
208
|
|
|
195
209
|
- `@fluojs/jwt`: JWT 기반 전략을 위한 하위 토큰 코어 패키지입니다.
|
package/README.md
CHANGED
|
@@ -114,7 +114,7 @@ Import `CookieAuthModule.forRoot(...)` alongside `PassportModule.forRoot(...)` w
|
|
|
114
114
|
|
|
115
115
|
`CookieAuthStrategy` preserves the normalized JWT principal contract from `@fluojs/jwt`, including `subject`, `claims`, `issuer`, `audience`, `roles`, and `scopes`.
|
|
116
116
|
|
|
117
|
-
Protected routes must keep using `@UseAuth(...)`. If you configure `requireAccessToken: false`, a missing cookie
|
|
117
|
+
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.
|
|
118
118
|
|
|
119
119
|
Use `@UseOptionalAuth(...)` only on routes that intentionally support both signed-in and guest callers:
|
|
120
120
|
|
|
@@ -134,7 +134,7 @@ export class SessionController {
|
|
|
134
134
|
|
|
135
135
|
### Refresh Token Lifecycle
|
|
136
136
|
|
|
137
|
-
The package provides a built-in `RefreshTokenStrategy` and `RefreshTokenService`
|
|
137
|
+
The package provides a built-in `RefreshTokenStrategy` plus the `RefreshTokenModule` and `RefreshTokenService` contract for secure token rotation and revocation.
|
|
138
138
|
|
|
139
139
|
```typescript
|
|
140
140
|
import { Module } from '@fluojs/core';
|
|
@@ -171,6 +171,14 @@ export class AuthController {
|
|
|
171
171
|
|
|
172
172
|
Import `RefreshTokenModule.forRoot(...)` alongside `PassportModule.forRoot(...)` so the refresh-token strategy and shared `REFRESH_TOKEN_SERVICE` alias are available in the same module wiring.
|
|
173
173
|
|
|
174
|
+
`RefreshTokenStrategy` reads tokens from `body.refreshToken`, `Authorization: Bearer ...`, or `x-refresh-token`; malformed non-string tokens fail authentication. `JwtRefreshTokenAdapter` requires a `secret` and a backing store; `store: 'memory'` is for development and single-instance deployments only.
|
|
175
|
+
|
|
176
|
+
### Account Linking and Status
|
|
177
|
+
|
|
178
|
+
Use `createConservativeAccountLinkPolicy(...)` and `resolveAccountLinking(...)` to model identity-link decisions. The default conservative policy links explicit existing links or user-confirmed matches, and otherwise creates, skips, rejects, or reports conflicts deterministically.
|
|
179
|
+
|
|
180
|
+
`createPassportPlatformStatusSnapshot(...)` and `createPassportPlatformDiagnosticIssues(...)` expose readiness/health diagnostics for registered strategies, default strategy configuration, presets, and refresh-token store readiness.
|
|
181
|
+
|
|
174
182
|
## Public API Overview
|
|
175
183
|
|
|
176
184
|
### Decorators
|
|
@@ -185,11 +193,17 @@ Import `RefreshTokenModule.forRoot(...)` alongside `PassportModule.forRoot(...)`
|
|
|
185
193
|
- `CookieManager`: Utility for managing HttpOnly auth cookies.
|
|
186
194
|
- `RefreshTokenModule`: Module entry point for the built-in refresh-token preset.
|
|
187
195
|
- `JwtRefreshTokenAdapter`: Bridges `@fluojs/jwt` refresh logic to the passport interface.
|
|
196
|
+
- `createPassportJsStrategyBridge(...)`: Adapts Passport.js strategies to fluo `AuthStrategy`.
|
|
197
|
+
- Cookie helpers: `createCookieAuthPreset`, `createCookieAuthStrategyRegistration`, `createCookieManager`, `normalizeCookieAuthOptions`.
|
|
198
|
+
- Refresh helpers: `createRefreshTokenStrategyRegistration`.
|
|
199
|
+
- Status/diagnostics helpers: `createPassportPlatformStatusSnapshot`, `createPassportPlatformDiagnosticIssues`.
|
|
188
200
|
|
|
189
201
|
### Interfaces
|
|
190
202
|
- `AuthStrategy`: The contract for implementing custom authentication logic.
|
|
191
203
|
- `AccountLinkPolicy`: Extension point for identity-linking decisions.
|
|
192
204
|
|
|
205
|
+
`UseOptionalAuth` only bypasses missing credentials when no scopes are required; scoped routes still need a principal. Passport.js bridge `redirect()` commits the response and skips the protected handler, while `pass()` and strategy completion without a Passport action are authentication failures.
|
|
206
|
+
|
|
193
207
|
## Related Packages
|
|
194
208
|
|
|
195
209
|
- `@fluojs/jwt`: The underlying token core for JWT-based strategies.
|
package/dist/decorators.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decorators.d.ts","sourceRoot":"","sources":["../src/decorators.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"decorators.d.ts","sourceRoot":"","sources":["../src/decorators.ts"],"names":[],"mappings":"AASA,KAAK,wBAAwB,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,qBAAqB,KAAK,IAAI,CAAC;AAC1F,KAAK,yBAAyB,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,2BAA2B,KAAK,IAAI,CAAC;AACjG,KAAK,0BAA0B,GAAG,wBAAwB,GAAG,yBAAyB,CAAC;AAyEvF;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,0BAA0B,CAEpE;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,0BAA0B,CAE5E;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,aAAa,CAAC,GAAG,MAAM,EAAE,MAAM,EAAE,GAAG,0BAA0B,CAE7E"}
|
package/dist/decorators.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import { ensureMetadataSymbol } from '@fluojs/core/internal';
|
|
1
2
|
import { UseGuards } from '@fluojs/http';
|
|
2
3
|
import { AuthGuard } from './guard.js';
|
|
3
4
|
import { getOwnAuthRequirement } from './metadata.js';
|
|
4
5
|
import { mergeAuthRequirements } from './scope.js';
|
|
5
6
|
const standardClassRequirementKey = Symbol.for('fluo.passport.standard.class-auth');
|
|
6
7
|
const standardMethodRequirementKey = Symbol.for('fluo.passport.standard.method-auth');
|
|
8
|
+
ensureMetadataSymbol();
|
|
7
9
|
function isStandardClassContext(context) {
|
|
8
10
|
return typeof context === 'object' && context !== null && 'kind' in context && context.kind === 'class';
|
|
9
11
|
}
|
package/dist/module.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AACA,OAAO,EAAgB,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAKhE,OAAO,KAAK,EACV,wBAAwB,EAExB,qBAAqB,EACtB,MAAM,YAAY,CAAC;AAgBpB,KAAK,kBAAkB,GAAG,UAAU,CAAC;AAmBrC;;GAEG;AACH,qBAAa,cAAc;IACzB;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,MAAM,CAAC,OAAO,CACZ,OAAO,GAAE,qBAA0B,EACnC,UAAU,GAAE,wBAAwB,EAAO,GAC1C,kBAAkB;
|
|
1
|
+
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AACA,OAAO,EAAgB,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAKhE,OAAO,KAAK,EACV,wBAAwB,EAExB,qBAAqB,EACtB,MAAM,YAAY,CAAC;AAgBpB,KAAK,kBAAkB,GAAG,UAAU,CAAC;AAmBrC;;GAEG;AACH,qBAAa,cAAc;IACzB;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,MAAM,CAAC,OAAO,CACZ,OAAO,GAAE,qBAA0B,EACnC,UAAU,GAAE,wBAAwB,EAAO,GAC1C,kBAAkB;CAStB"}
|
package/dist/module.js
CHANGED
|
@@ -57,6 +57,7 @@ export class PassportModule {
|
|
|
57
57
|
class PassportRootModule extends PassportModule {}
|
|
58
58
|
return defineModule(PassportRootModule, {
|
|
59
59
|
exports: [AuthGuard],
|
|
60
|
+
global: options.global ?? false,
|
|
60
61
|
providers: createPassportModuleProviders(options, strategies)
|
|
61
62
|
});
|
|
62
63
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -34,6 +34,8 @@ export type AuthStrategyRegistry = Readonly<Record<string, Token<AuthStrategy>>>
|
|
|
34
34
|
/** Module-level options for passport strategy wiring. */
|
|
35
35
|
export interface PassportModuleOptions {
|
|
36
36
|
defaultStrategy?: string;
|
|
37
|
+
/** Whether passport guard providers should be visible globally. Defaults to `false`. */
|
|
38
|
+
global?: boolean;
|
|
37
39
|
}
|
|
38
40
|
/** Contract for the public `AuthGuard` behavior. */
|
|
39
41
|
export interface AuthGuardContract extends Guard {
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,KAAK,EAAE,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEnE,uDAAuD;AACvD,MAAM,WAAW,eAAe;IAC9B,4DAA4D;IAC5D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,mEAAmE;IACnE,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,sEAAsE;IACtE,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,6FAA6F;AAC7F,MAAM,WAAW,kBAAkB;IACjC,aAAa,EAAE,KAAK,CAAC;CACtB;AAED,qFAAqF;AACrF,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,IAAI,CAAC;IACd,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB;AAED,+DAA+D;AAC/D,MAAM,MA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MAAM,WAAW,YAAY;IAC3B,YAAY,CAAC,OAAO,EAAE,YAAY,GAAG,YAAY,CAAC,kBAAkB,CAAC,CAAC;CACvE;AAED,gEAAgE;AAChE,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC;CAC5B;AAED,4DAA4D;AAC5D,MAAM,MAAM,oBAAoB,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;AAEjF,yDAAyD;AACzD,MAAM,WAAW,qBAAqB;IACpC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,wFAAwF;IACxF,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,oDAAoD;AACpD,MAAM,WAAW,iBAAkB,SAAQ,KAAK;IAC9C,WAAW,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACnD"}
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"guard",
|
|
10
10
|
"strategy"
|
|
11
11
|
],
|
|
12
|
-
"version": "1.0.0-beta.
|
|
12
|
+
"version": "1.0.0-beta.6",
|
|
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/core": "^1.0.0-beta.
|
|
40
|
-
"@fluojs/di": "^1.0.0-beta.
|
|
41
|
-
"@fluojs/http": "^1.0.0-beta.
|
|
42
|
-
"@fluojs/jwt": "^1.0.0-beta.
|
|
43
|
-
"@fluojs/runtime": "^1.0.0-beta.
|
|
39
|
+
"@fluojs/core": "^1.0.0-beta.4",
|
|
40
|
+
"@fluojs/di": "^1.0.0-beta.6",
|
|
41
|
+
"@fluojs/http": "^1.0.0-beta.10",
|
|
42
|
+
"@fluojs/jwt": "^1.0.0-beta.3",
|
|
43
|
+
"@fluojs/runtime": "^1.0.0-beta.11"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"vitest": "^3.2.4"
|