@fluojs/passport 1.0.0-beta.4 → 1.0.0-beta.5

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 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`를 설정해도 쿠키가 없을 때는 이제 익명 principal이 아니라 명시적인 미인증 결과를 반환하므로, 보호된 라우트는 요청을 계속 거부합니다.
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
- 패키지에서 제공하는 `RefreshTokenStrategy`와 `RefreshTokenService`를 사용하여 안전한 토큰 로테이션 폐기 기능을 구현할 수 있습니다.
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 now resolves to an explicit unauthenticated result instead of an anonymous principal, so protected routes still reject the request.
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` to handle secure token rotation and revocation.
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.
@@ -1 +1 @@
1
- {"version":3,"file":"decorators.d.ts","sourceRoot":"","sources":["../src/decorators.ts"],"names":[],"mappings":"AAQA,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;AAuEvF;;;;;;;;;;;;;;;;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"}
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"}
@@ -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/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "guard",
10
10
  "strategy"
11
11
  ],
12
- "version": "1.0.0-beta.4",
12
+ "version": "1.0.0-beta.5",
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.2",
40
- "@fluojs/di": "^1.0.0-beta.4",
41
- "@fluojs/http": "^1.0.0-beta.3",
39
+ "@fluojs/di": "^1.0.0-beta.6",
40
+ "@fluojs/http": "^1.0.0-beta.10",
42
41
  "@fluojs/jwt": "^1.0.0-beta.2",
43
- "@fluojs/runtime": "^1.0.0-beta.4"
42
+ "@fluojs/core": "^1.0.0-beta.4",
43
+ "@fluojs/runtime": "^1.0.0-beta.11"
44
44
  },
45
45
  "devDependencies": {
46
46
  "vitest": "^3.2.4"