@bymax-one/nest-auth 1.0.1 → 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/CHANGELOG.md CHANGED
@@ -7,6 +7,74 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [1.0.3] - 2026-05-25
11
+
12
+ ### Fixed
13
+
14
+ - **OAuth callback accepts standard provider query parameters** ([`src/server/dto/oauth-callback-query.dto.ts`](src/server/dto/oauth-callback-query.dto.ts)). Previously the controller-level `ValidationPipe(forbidNonWhitelisted: true)` paired with a `code` + `state`-only DTO rejected real-world Google callbacks with `HTTP 400 — property iss should not exist` because Google appends `iss` (OAuth 2.0 Issuer Identification, RFC 9207), `scope` (RFC 6749 §3.3 echoed grants), `authuser` (Google Account-chooser index), `prompt` (which prompt was shown), and `hd` (Workspace hosted-domain) to the redirect. The DTO now declares all five as `@IsOptional()` strings with sensible `@MaxLength` bounds — the values are validated for shape and ignored by the service. Covered by a new e2e scenario in [`test/e2e/oauth-flow.e2e-spec.ts`](test/e2e/oauth-flow.e2e-spec.ts) that submits the exact param set Google sends. No breaking change — existing `code` + `state`-only callbacks continue to work.
15
+
16
+ ### Tests — E2E coverage (audit-driven, surface gaps closed)
17
+
18
+ A systematic audit of `test/e2e/` against the lib's HTTP surface identified
19
+ several uncovered scenarios. Each new spec exercises real routes via supertest
20
+ against a fully-bootstrapped NestJS app — no controller methods are called
21
+ directly, no network is touched (Google OAuth + email + Redis are mocked).
22
+ The full e2e count goes from **9 suites / 59 tests** to **14 suites / 89 tests**.
23
+
24
+ - **[`test/e2e/platform-auth-flow.e2e-spec.ts`](test/e2e/platform-auth-flow.e2e-spec.ts)** — closes
25
+ the entire platform admin HTTP surface (previously zero e2e coverage):
26
+ `/platform/login`, `/platform/me`, `/platform/refresh`, `/platform/logout`,
27
+ `DELETE /platform/sessions`, plus cross-context rejection (dashboard token →
28
+ `/platform/me` returns 401, and platform token → `/me` returns 401).
29
+ - **[`test/e2e/mfa-disable-flow.e2e-spec.ts`](test/e2e/mfa-disable-flow.e2e-spec.ts)** — closes
30
+ the MFA lifecycle's final transition. Asserts `/mfa/disable` returns 204
31
+ with a valid TOTP, flips `mfaEnabled` to false on the persisted user,
32
+ restores the no-challenge login path, and rejects with `MFA_INVALID_CODE` /
33
+ `MFA_NOT_ENABLED` on the negative paths.
34
+ - **[`test/e2e/email-verification-flow.e2e-spec.ts`](test/e2e/email-verification-flow.e2e-spec.ts)** —
35
+ closes `/verify-email` + `/resend-verification` (both previously untouched
36
+ by e2e). Verifies the OTP-driven happy path, OTP_INVALID rejection, fresh
37
+ OTP dispatch on resend, and anti-enumeration responses for unknown +
38
+ already-verified emails.
39
+ - **[`test/e2e/negative-paths.e2e-spec.ts`](test/e2e/negative-paths.e2e-spec.ts)** — bundles
40
+ eight negative-path scenarios that were silent gaps: unknown invitation
41
+ token, single-use invitation replay, foreign-user session revoke (auth-
42
+ bypass class), `DELETE /sessions/all` without a refresh token, unknown
43
+ password-reset token, wrong reset OTP, unknown OAuth provider, OAuth init
44
+ without `tenantId`.
45
+ - **[`test/e2e/hooks-lifecycle.e2e-spec.ts`](test/e2e/hooks-lifecycle.e2e-spec.ts)** — replaces
46
+ the implicit "if it works, the hook fired" assumption with explicit spy
47
+ assertions on `beforeRegister`, `afterRegister`, `beforeLogin`, `afterLogin`,
48
+ `afterLogout`, `afterMfaEnabled`, `afterEmailVerified`, and
49
+ `afterPasswordReset`. Each hook is verified to receive a `HookContext`
50
+ carrying `ip`, `userAgent`, and sanitized headers — a regression that drops
51
+ any single dispatch would fail the corresponding scenario.
52
+
53
+ ### Tests — Helpers
54
+
55
+ - **`MockPlatformUserRepository.seed(user)`** ([`test/e2e/setup.ts`](test/e2e/setup.ts)) — exposes
56
+ a deterministic seed entry-point that populates both the user map AND the
57
+ internal `emailIndex` so `findByEmail` resolves the row. Required for the
58
+ platform spec; useful for any future test that needs pre-existing platform
59
+ admins (the lib intentionally ships no `createPlatformUser` endpoint).
60
+
61
+ ## [1.0.2] - 2026-05-25
62
+
63
+ ### Security
64
+
65
+ - **Forced patched versions of four transitive dependencies via `pnpm.overrides`** to close GitHub Security Advisories surfaced by OpenSSF Scorecard's `Vulnerabilities` check. None of these affect runtime behavior of the published package — they live exclusively in the build/test dependency graph — but pinning them tightens our supply-chain posture and removes the warnings from any consumer running `npm audit` against a clone of the repo:
66
+ - `brace-expansion@>=5.0.6` ([GHSA-jxxr-4gwj-5jf2](https://github.com/advisories/GHSA-jxxr-4gwj-5jf2) — DoS via large numeric range bypassing `max` protection)
67
+ - `postcss@>=8.5.10` ([GHSA-qx2v-qp2m-jg93](https://github.com/advisories/GHSA-qx2v-qp2m-jg93) — XSS via unescaped `</style>` in CSS stringify output)
68
+ - `qs@>=6.15.2` ([GHSA-q8mj-m7cp-5q26](https://github.com/advisories/GHSA-q8mj-m7cp-5q26) — DoS via `TypeError` on null/undefined entries in comma-format arrays)
69
+ - `ws@>=8.20.1` ([GHSA-58qx-3vcg-4xpx](https://github.com/advisories/GHSA-58qx-3vcg-4xpx) — uninitialized memory disclosure)
70
+
71
+ ### Internal / CI
72
+
73
+ - **OpenSSF Scorecard pipeline** — added `.github/workflows/scorecard.yml` running on push to `main`, weekly schedule (Mondays 06:00 UTC), and manual dispatch. Results upload SARIF to the GitHub Security tab and publish publicly to [scorecard.dev](https://scorecard.dev/viewer/?uri=github.com/bymaxone/nest-auth). The OpenSSF Scorecard badge is now visible in the README alongside CI, coverage, mutation, and license badges.
74
+ - **Vulnerability disclosure policy** — added `SECURITY.md` covering supported versions, the GitHub Private Vulnerability Reporting flow, response timeline (acknowledgement < 72 h, coordinated fix for High/Critical < 90 days), and in/out-of-scope categories tuned for an authentication library. Issue templates now point to `support@bymax.one` for security questions.
75
+ - **Contact address consolidation** — every `contact@` / `security@bymax.one` reference across `package.json` author, README security note, `SECURITY.md`, and `.github/ISSUE_TEMPLATE/{config.yml,bug_report.md}` unified to **`support@bymax.one`**. Eliminates ambiguity for vulnerability reporters and aligns with the single-inbox routing on `bymax.one`.
76
+ - **Top-level workflow permissions** — `codeql.yml` and `release.yml` now declare `permissions: contents: read` at the workflow root, with the analyze/publish jobs widening only where necessary. Closes the OpenSSF Scorecard `Token-Permissions` gap (9/10 → 10/10) by ensuring every workflow has an explicit least-privilege default.
77
+
10
78
  ## [1.0.1] - 2026-05-25
11
79
 
12
80
  ### Fixed
@@ -22,6 +90,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
22
90
  ### Added
23
91
 
24
92
  **Next.js subpath (`@bymax-one/nest-auth/nextjs`)**
93
+
25
94
  - `createAuthProxy(config)` — Edge-Runtime factory that produces a Next.js 16 proxy function. Classifies routes (`/api/auth/*`, public, protected, unmatched), reads the access-cookie JWT (HS256 verify via Web Crypto when `jwtSecret` is provided; decode-only fallback otherwise), and dispatches to public / protected handlers. Strips client-spoofed identity headers on every response path and propagates trusted `x-user-id`, `x-user-role`, `x-tenant-id`, `x-tenant-domain` from the verified token via `NextResponse.next({ request: { headers } })`.
26
95
  - **Anti-redirect-loop defence-in-depth** — two guards must BOTH fail before the proxy issues a silent-refresh redirect: a `_r` query-param counter (clamped to `maxRefreshAttempts`, rides on the DESTINATION so it survives the handler round-trip) AND a `reason=expired` signal that the silent-refresh handler sets on its terminal fallback. Either guard alone stops the loop.
27
96
  - **RBAC + status blocking** — `protectedRoutes` patterns support exact, `:segment`, and trailing-wildcard matches. Role mismatch redirects to `getDefaultDashboard(role)?error=forbidden`; blocked `status` claim (case-insensitive against `blockedUserStatuses` via `toLocaleLowerCase('en-US')`) redirects to `loginPath?reason=<allowlist-entry>`. The `reason` value is pulled from the configured allowlist, never from the raw JWT claim.
@@ -35,6 +104,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
35
104
  - **Factory-time validation** — every factory validates its config at construction time: `apiBase` must be absolute HTTP(S); `loginPath` / `redirectPath` must be same-origin pathnames with no CR/LF/NUL/backslash; cookie names must match RFC 6265 token grammar; cookie paths must start with `/` and contain no attribute-smuggling characters; `logoutPath` / `refreshPath` must not contain `..`, `?`, `#`, or control bytes; protected-route patterns reject mid-pattern wildcards and segment-0 catch-alls.
36
105
 
37
106
  **React subpath (`@bymax-one/nest-auth/react`)**
107
+
38
108
  - `AuthProvider({ client, onSessionExpired?, revalidateInterval? })` — React 19 provider that owns the `loading → authenticated / unauthenticated` state machine, bridges a `createAuthClient` instance into the auth context, and schedules a best-effort revalidation loop (default 5 minutes) so long-lived UIs surface role/status changes without a manual refresh. `onSessionExpired` fires only on a live `authenticated → unauthenticated` transition (not on initial mount or explicit logout).
39
109
  - `useAuth()` — imperative API: `login`, `register`, `logout`, `forgotPassword`, and `resetPassword`, bound to the provider's client with stable identity. The MFA challenge is exposed through `AuthClient.mfaChallenge()`; session revalidation is exposed through `useSession().refresh()`.
40
110
  - `useSession()` — reactive snapshot: `{ user, status, isLoading, refresh, lastValidation }` read from context (the `refresh` method triggers an ad-hoc revalidation).
@@ -42,11 +112,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
42
112
  - `AuthContext`, `AuthContextValue`, `AuthStatus`, `AuthProviderProps` types exported from the subpath barrel.
43
113
 
44
114
  **Client subpath (`@bymax-one/nest-auth/client`)**
115
+
45
116
  - `createAuthFetch(config)` — fetch wrapper with cookie-mode defaults, single-flight 401 refresh interception, per-instance dedup, configurable timeout (`AbortController`-based), prototype-pollution-safe header merging, and `routePrefix` option for deployments mounted under non-default prefixes
46
117
  - `createAuthClient(config)` — typed `AuthClient` facade with `login`, `register`, `logout`, `refresh`, `getMe`, `mfaChallenge`, `forgotPassword`, and `resetPassword` methods; composes on top of `createAuthFetch` and supports a pre-built `authFetch` override for sharing dedup state across clients
47
118
  - `AuthFetch`, `AuthFetchConfig`, `AuthClient`, `AuthClientConfig`, `LoginInput`, `RegisterInput`, `ResetPasswordInput` types exported from the subpath barrel
48
119
 
49
120
  **Shared subpath (`@bymax-one/nest-auth/shared`)**
121
+
50
122
  - `buildAuthRefreshSkipSuffixes(routePrefix?)` — factory producing the pathname-suffix skip list used by the client's 401 refresh interception, parameterized by the NestJS `routePrefix`; backwards-compat `AUTH_REFRESH_SKIP_PATH_SUFFIXES` retained for the default `'auth'` prefix
51
123
  - `AuthResponseCode` type — `AuthErrorCode | (string & {})` union so consumers get autocomplete on known codes while preserving flexibility for non-auth Nest exceptions (e.g. `ValidationPipe` 400s)
52
124
 
@@ -86,6 +158,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
86
158
  #### Phase 1 — Foundation and Infrastructure (NEST-001 to NEST-042)
87
159
 
88
160
  **Scaffold and tooling**
161
+
89
162
  - `package.json` with scope `@bymax-one`, peer dependencies (NestJS 11, ioredis, class-validator), zero direct runtime dependencies
90
163
  - `tsconfig.json` and `tsconfig.build.json` with `strict: true`, ES2022 target, decorator support
91
164
  - `tsconfig.jest.json` for ts-jest compilation
@@ -97,6 +170,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
97
170
  - MIT License, `.gitignore`, `AGENTS.md`, `CLAUDE.md`
98
171
 
99
172
  **Interfaces**
173
+
100
174
  - `BymaxAuthModuleOptions` — full module configuration interface with 15 optional groups (jwt, password, tokenDelivery, cookies, mfa, sessions, bruteForce, passwordReset, emailVerification, platform, invitations, roles, blockedStatuses, oauth, controllers)
101
175
  - `AuthUser` and `SafeAuthUser` — user entity interfaces (15 fields) with credential-free safe variant
102
176
  - `IUserRepository` — data access interface with 11 methods (findById, findByEmail, create, updatePassword, updateMfa, updateLastLogin, updateStatus, updateEmailVerified, findByOAuthId, linkOAuth, createWithOAuth)
@@ -112,37 +186,44 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
112
186
  - `OAuthProfile` and `OAuthLoginResult` — OAuth profile and hook result types
113
187
 
114
188
  **Constants and configuration**
189
+
115
190
  - 6 Symbol-based DI injection tokens: `BYMAX_AUTH_OPTIONS`, `BYMAX_AUTH_USER_REPOSITORY`, `BYMAX_AUTH_PLATFORM_USER_REPOSITORY`, `BYMAX_AUTH_EMAIL_PROVIDER`, `BYMAX_AUTH_HOOKS`, `BYMAX_AUTH_REDIS_CLIENT`
116
191
  - `DEFAULT_OPTIONS` — all default values (jwt.accessExpiresIn `'15m'`, refreshExpiresInDays `7`, tokenDelivery `'cookie'`, bruteForce 5 attempts / 900s window, etc.)
117
192
  - `resolveOptions()` — startup function that merges consumer options with defaults, validates all security invariants, and produces `ResolvedOptions` with no optional fields
118
193
  - Throttle configurations (`THROTTLE_CONFIGS`) per endpoint category
119
194
 
120
195
  **Crypto utilities** (`src/server/crypto/`)
196
+
121
197
  - `sha256(input)` — deterministic SHA-256 hex digest via `node:crypto`
122
198
  - `hmacSha256(input, secret)` — keyed HMAC-SHA256 hex digest for low-entropy inputs (composite keys with email addresses)
123
199
  - `encrypt(plaintext, keyBase64)` / `decrypt(ciphertext, keyBase64)` — AES-256-GCM authenticated encryption using random 12-byte IV per call; wire format `base64(iv):base64(authTag):base64(ciphertext)`
124
200
  - `generateSecureToken()` — cryptographically random opaque token via `node:crypto.randomBytes`
125
201
 
126
202
  **Error handling** (`src/server/errors/`)
203
+
127
204
  - `AUTH_ERROR_CODES` — typed string union of all 30+ error codes with Portuguese end-user messages
128
205
  - `AuthException` — NestJS `HttpException` subclass carrying structured `{ code, message, details? }` response body
129
206
 
130
207
  **Redis layer** (`src/server/redis/`)
208
+
131
209
  - `AuthRedisService` — typed wrapper around ioredis with automatic namespace prefixing; exposes `get`, `set`, `del`, `setnx`, `incr`, `expire`, `ttl`, `sadd`, `srem`, `smembers`, `sismember`, `eval`, `getdel`, `incrWithFixedTtl`
132
210
  - `AuthRedisModule` — internal NestJS module registering `AuthRedisService`
133
211
 
134
212
  **Services** (`src/server/services/`)
213
+
135
214
  - `PasswordService` — scrypt-based password hashing and constant-time comparison; configurable cost factor, block size, and parallelization
136
215
  - `BruteForceService` — fixed-window rate limiting via atomic `incrWithFixedTtl` Lua script; lockout with `getRemainingLockoutSeconds`
137
216
  - `TokenManagerService` — JWT issuance (`issueTokens`, `issueMfaTempToken`), token rotation (`reissueTokens`), revocation blacklist via Redis `rv:{jti}` keys, raw refresh token storage via `rt:{sha256(token)}`
138
217
  - `TokenDeliveryService` — cookie/bearer/both delivery modes; multi-domain support via `resolveDomains` callback; `extractAccessToken`, `extractRefreshToken`, `clearAuthSession`
139
218
 
140
219
  **Utilities** (`src/server/utils/`)
220
+
141
221
  - `sanitizeHeaders()` — removes sensitive headers (authorization, cookie, x-api-key, x-auth-token, x-csrf-token, x-session-id, pattern `/^x-.*-token$/i`) before passing to hook context
142
222
  - `sleep(ms)` — Promise-based delay for timing normalization in anti-enumeration flows
143
223
  - `hasRole(userRole, requiredRole, hierarchy)` — recursive role hierarchy checker supporting denormalized role trees
144
224
 
145
225
  **NoOp fallback providers**
226
+
146
227
  - `NoOpEmailProvider` — silent no-op implementation of `IEmailProvider` (registered when consumer does not supply one)
147
228
  - `NoOpAuthHooks` — silent no-op implementation of `IAuthHooks` (registered when consumer does not supply one)
148
229
 
@@ -153,28 +234,34 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
153
234
  #### Phase 2 — Core Authentication (NEST-043 to NEST-064)
154
235
 
155
236
  **Guards** (`src/server/guards/`)
237
+
156
238
  - `JwtAuthGuard` — native NestJS guard (no Passport); verifies JWT via `@nestjs/jwt` `JwtService.verify()` with algorithm pinning from `ResolvedOptions.jwt.algorithm`; checks `rv:{jti}` revocation blacklist; skips public routes decorated with `@Public()`; asserts token type is `'dashboard'` via `assertTokenType` utility
157
239
  - `RolesGuard` — hierarchical role guard using denormalized `roles.hierarchy`; reads `@Roles()` metadata via `Reflector`; throws `INSUFFICIENT_ROLE` (403) on failure
158
240
  - `UserStatusGuard` — status-based access guard with Redis caching (`us:{userId}`, TTL from `userStatusCacheTtlSeconds`); maps blocked statuses to specific error codes (ACCOUNT_BANNED, ACCOUNT_INACTIVE, ACCOUNT_SUSPENDED, PENDING_APPROVAL) with ACCOUNT_INACTIVE as fallback
159
241
  - `assertTokenType` utility — reusable guard helper that throws `TOKEN_INVALID` when the JWT `type` claim does not match the expected value
160
242
 
161
243
  **Decorators** (`src/server/decorators/`)
244
+
162
245
  - `@CurrentUser(property?)` — param decorator extracting `request.user` or a specific property from it
163
246
  - `@Roles(...roles)` — metadata decorator setting `ROLES_KEY` for `RolesGuard`
164
247
  - `@Public()` — metadata decorator setting `IS_PUBLIC_KEY` to skip `JwtAuthGuard`
165
248
 
166
249
  **DTOs** (`src/server/dto/`)
250
+
167
251
  - `RegisterDto` — `email`, `password` (8–128 chars), `name` (2+ chars), `tenantId`; all with class-validator decorators
168
252
  - `LoginDto` — `email`, `password` (no `@MinLength` — deliberate anti-enumeration), `tenantId`
169
253
 
170
254
  **Services** (`src/server/services/`)
255
+
171
256
  - `OtpService` — `generate(length)` via `crypto.randomInt` with leading-zero padding; `store(purpose, identifier, code, ttl)` to Redis; `verify(purpose, identifier, code)` with constant-time comparison via `crypto.timingSafeEqual` (safe for different-length inputs), max-attempt enforcement (5), key deletion on exhaustion, and timing normalization (100ms floor); atomic attempt increment via Lua eval (single round-trip preserving TTL)
172
257
  - `AuthService` — full authentication lifecycle: `register`, `login`, `logout`, `refresh`, `getMe`, `verifyEmail`, `resendVerificationEmail`; `@Optional()` hooks with fire-and-forget error isolation; tenant resolution via `tenantIdResolver`; brute-force integration; MFA challenge path
173
258
 
174
259
  **Controllers** (`src/server/controllers/`)
260
+
175
261
  - `AuthController` — 7 endpoints: `POST /register`, `POST /login`, `POST /logout`, `POST /refresh`, `GET /me`, `POST /verify-email`, `POST /resend-verification`; `@UsePipes(new ValidationPipe({ whitelist: true }))` at class level; conditional registration via `controllers.auth` option
176
262
 
177
263
  **Module**
264
+
178
265
  - `BymaxAuthModule.registerAsync(options)` — dynamic NestJS module; wraps consumer factory with `resolveOptions()`; conditionally registers `AuthController`; registers NoOp fallback providers when consumer omits email/hooks tokens; class-shorthand provider detection in `hasProviderToken`; `JwtModule.registerAsync` reads `jwt.secret` directly (no double `resolveOptions` call)
179
266
 
180
267
  **Phase 2 barrel export** — adds `BymaxAuthModule`, `AuthService`, `JwtAuthGuard`, `RolesGuard`, `UserStatusGuard`, `CurrentUser`, `Roles`, `ROLES_KEY`, `Public`, `IS_PUBLIC_KEY`, `RegisterDto`, `LoginDto`
@@ -184,6 +271,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
184
271
  #### Phase 3 — Multi-Factor Authentication (TOTP)
185
272
 
186
273
  **Crypto utilities** (`src/server/crypto/totp.ts`)
274
+
187
275
  - `generateTotpSecret()` — generates a cryptographically random 20-byte TOTP secret via `node:crypto.randomBytes`; returns both raw `Buffer` and `base32`-encoded string
188
276
  - `buildTotpUri(secret, account, issuer)` — constructs a standard `otpauth://totp/` URI for QR code generation
189
277
  - `verifyTotp(secret, code, window)` — validates a 6-digit TOTP code within a configurable step window (±1 by default) using HMAC-SHA1 per RFC 6238
@@ -191,33 +279,40 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
191
279
  - `fromBase32(input)` / `toBase32(buf)` — pure Base32 encode/decode without external dependencies; `fromBase32` strips whitespace, hyphens, and padding before decoding
192
280
 
193
281
  **Services** (`src/server/services/mfa.service.ts`)
282
+
194
283
  - `MfaService.setup(userId)` — generates TOTP secret and recovery codes; uses atomic `setIfAbsent` to guarantee idempotency under concurrent requests; encrypts secret with AES-256-GCM; returns plain recovery codes once (then discarded)
195
284
  - `MfaService.verifyAndEnable(userId, code, ip, userAgent)` — validates the first TOTP code against the pending setup key; atomically consumes the setup key to prevent double-enable races; persists encrypted secret and hashed recovery codes to the user repository; invalidates all existing refresh sessions
196
285
  - `MfaService.challenge(tempToken, code, ip, userAgent)` — exchanges a short-lived MFA temp token for full auth tokens; accepts both TOTP codes and recovery codes; enforces anti-replay via 90-second `setnx` key; brute-force lockout with `challenge:`-namespaced counter; supports both `dashboard` and `platform` contexts
197
286
  - `MfaService.disable(userId, code, ip, userAgent, context)` — disables MFA after TOTP verification; only accepts TOTP (recovery codes cannot disable by design); invalidates all sessions; supports both dashboard and platform repositories via `context` parameter
198
287
 
199
288
  **Guards** (`src/server/guards/mfa-required.guard.ts`)
289
+
200
290
  - `MfaRequiredGuard` — enforces MFA verification on routes where the authenticated JWT has `mfaEnabled: true`; gates on `mfaVerified: true` claim; respects `@SkipMfa()` decorator to exclude specific endpoints (e.g. the challenge endpoint itself)
201
291
 
202
292
  **Decorators** (`src/server/decorators/skip-mfa.decorator.ts`)
293
+
203
294
  - `@SkipMfa()` — metadata decorator that marks an endpoint as exempt from `MfaRequiredGuard`; used on `POST /mfa/challenge` and any other pre-MFA routes
204
295
 
205
296
  **DTOs** (`src/server/dto/`)
297
+
206
298
  - `MfaChallengeDto` — `mfaTempToken` (string) + `code` (string); `@MaxLength(14)` as defence-in-depth before regex
207
299
  - `MfaVerifyDto` — 6-digit TOTP code; `@MaxLength(6)` + `@Matches(/^\d{6}$/)`
208
300
  - `MfaDisableDto` — 6-digit TOTP code; `@MaxLength(6)` + `@Matches(/^\d{6}$/)`; JSDoc explains why recovery codes are not accepted
209
301
 
210
302
  **Controllers** (`src/server/controllers/mfa.controller.ts`)
303
+
211
304
  - `POST /mfa/setup` — initiates TOTP setup; returns secret, QR URI, and plain recovery codes (shown once); idempotent within 10-minute window; dashboard users only
212
305
  - `POST /mfa/verify-enable` — submits the first TOTP code to permanently activate MFA; returns 204 No Content
213
306
  - `POST /mfa/challenge` — public endpoint (protected only by temp token); exchanges temp token + TOTP or recovery code for full auth tokens; returns cookie or bearer response for dashboard, plain JSON for platform
214
307
  - `POST /mfa/disable` — disables MFA for dashboard or platform users; derived `context` from `user.type` JWT claim; returns 204 No Content
215
308
 
216
309
  **Redis additions** (`src/server/redis/auth-redis.service.ts`)
310
+
217
311
  - `setIfAbsent(key, value, ttl)` — atomic `SET NX EX`; returns `true` if the key was newly created, `false` if it already existed; used for idempotent setup key reservation
218
312
  - `invalidateUserSessions(userId)` — Lua script that reads all members of `sess:{userId}`, deletes each session key (including grace pointers tracked in the SET), and removes the SET itself in a single round-trip
219
313
 
220
314
  **Module integration** (`src/server/bymax-auth.module.ts`)
315
+
221
316
  - `controllers.mfa: true` option conditionally registers `MfaController`; startup validation throws if `controllers.mfa: true` is set without the `mfa` configuration group
222
317
 
223
318
  ---
@@ -225,24 +320,29 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
225
320
  #### Phase 4 — Sessions & Password Reset
226
321
 
227
322
  **Services** (`src/server/services/`)
323
+
228
324
  - `SessionService` — full session lifecycle management: `createSession` records device/IP metadata and enforces concurrent session limit via FIFO eviction; `listSessions` returns sorted `SessionInfo[]` with `isCurrent` marked via timing-safe comparison; `revokeSession` atomically verifies ownership (SISMEMBER) before deletion; `revokeAllExceptCurrent` preserves the caller's session while revoking all others; `rotateSession` atomically renames session detail key on token rotation, preserving `createdAt`; device parsing is regex-only (no external libraries); two Lua scripts (`REVOKE_SESSION_LUA`, `ROTATE_SESSION_DETAIL_LUA`) prevent TOCTOU races
229
325
  - `PasswordResetService` — dual-flow password reset supporting `token` and `otp` modes (configured via `passwordReset.method`); `initiateReset` always returns success (anti-enumeration); `resetPassword` validates mutual exclusivity of proof fields and delegates to `resetWithToken`, `resetWithOtp`, or `resetWithVerifiedToken`; `verifyOtp` exchanges a validated OTP for a 5-minute `verifiedToken`; `resendOtp` subject to atomic 60-second cooldown via Redis NX key; all tokens consumed atomically via `getdel()` (single-use); `applyPasswordReset` hashes the new password and invalidates all sessions via Lua script; `initiateReset` and `resendOtp` apply a 300ms timing floor to prevent email-existence probing
230
326
 
231
327
  **Controllers** (`src/server/controllers/`)
328
+
232
329
  - `SessionController` — 3 endpoints: `GET /sessions` (list active sessions), `DELETE /sessions/all` (revoke all except current), `DELETE /sessions/:id` (revoke single session by 64-char hash); all require `JwtAuthGuard` + `UserStatusGuard`; current session identified by extracting refresh token via `TokenDeliveryService`
233
330
  - `PasswordResetController` — 4 endpoints: `POST /password/forgot-password`, `POST /password/reset-password`, `POST /password/verify-otp`, `POST /password/resend-otp`; all `@Public()`; all return 200/204 regardless of email existence; per-endpoint throttle configs
234
331
 
235
332
  **DTOs** (`src/server/dto/`)
333
+
236
334
  - `ForgotPasswordDto` — `email` (normalized lowercase) + `tenantId`
237
335
  - `ResetPasswordDto` — `email`, `newPassword` (8–128 chars), exactly one of `token` / `otp` / `verifiedToken`, `tenantId`
238
336
  - `VerifyOtpDto` — `email`, `otp` (4–8 chars), `tenantId`
239
337
  - `ResendOtpDto` — `email` + `tenantId`
240
338
 
241
339
  **Configuration** (`BymaxAuthModuleOptions`)
340
+
242
341
  - `sessions.enabled`, `sessions.defaultMaxSessions` (default 5), `sessions.maxSessionsResolver`, `sessions.evictionStrategy` (`'fifo'`)
243
342
  - `passwordReset.method` (`'token'` | `'otp'`, default `'token'`), `passwordReset.tokenTtlSeconds` (default 3600), `passwordReset.otpTtlSeconds` (default 600), `passwordReset.otpLength` (default 6)
244
343
 
245
344
  **Module integration** (`src/server/bymax-auth.module.ts`)
345
+
246
346
  - `controllers.sessions: true` opt-in gate with startup cross-validation: throws if `sessions.enabled` is not `true` in the factory return value
247
347
  - `controllers.passwordReset` opt-out gate (enabled by default); `PasswordResetService` only registered when controller is active
248
348
  - `SessionService` always registered unconditionally — `AuthService.login()` and `AuthService.refresh()` call session methods regardless of whether the sessions controller is exposed
@@ -254,23 +354,28 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
254
354
  #### Phase 5 — Platform Authentication, OAuth & Invitations
255
355
 
256
356
  **Services**
357
+
257
358
  - `PlatformAuthService` (`src/server/services/`) — operator/super-admin authentication layer backed by `IPlatformUserRepository`; `login` validates credentials, applies brute-force protection (HMAC-SHA-256 identifier, no PII in Redis), and returns `PlatformAuthResult` or `MfaChallengeResult`; `logout` blacklists JTI and deletes primary + grace session keys; `refresh` delegates to `TokenManagerService.reissuePlatformTokens()`; `getMe` returns `SafeAuthPlatformUser` (no credential fields); `revokeAllPlatformSessions` atomically deletes all session keys via `invalidateUserSessions()` Lua script; platform sessions are always bearer-mode (never cookies)
258
359
  - `OAuthService` (`src/server/oauth/`) — provider-agnostic Authorization Code flow; `initiateOAuth` validates provider name format, generates 64-char hex CSRF state nonce stored under `os:{sha256(state)}` (10-min TTL), and redirects to provider authorize URL; `handleCallback` atomically consumes state via `getdel()`, exchanges authorization code for access token, fetches normalized profile, calls required `hooks.onOAuthLogin` for account resolution (`'create'` / `'link'` / `'reject'`), and issues dashboard tokens; creates session if `sessions.enabled: true`; currently supports Google OAuth 2.0
259
360
  - `InvitationService` (`src/server/services/`) — `invite` validates the target role against the inviter's own role via `hasRole()` (cannot invite higher), stores `StoredInvitation` JSON under `inv:{sha256(token)}`, and emails the raw token; `acceptInvitation` atomically consumes the token via `getdel()`, re-validates role against the hierarchy (prevents Redis tampering), verifies email uniqueness, hashes password, creates the user with `emailVerified: true`, issues dashboard tokens, creates session if enabled, and fires `hooks.afterInvitationAccepted`
260
361
 
261
362
  **Guards** (`src/server/guards/`)
363
+
262
364
  - `JwtPlatformGuard` — validates HS256-signed JWTs for platform routes; reads token exclusively from Authorization Bearer header; enforces `type: 'platform'` claim; throws `PLATFORM_AUTH_REQUIRED` (not `TOKEN_INVALID`) when a dashboard token is submitted, enabling precise cross-context error detection; algorithm pinned from `options.jwt.algorithm`; checks `rv:{jti}` revocation blacklist; respects `@Public()`
263
365
  - `PlatformRolesGuard` — enforces role-based access on platform routes via `@PlatformRoles()` metadata; requires fully denormalized `roles.platformHierarchy`; denies access by default when hierarchy is missing
264
366
 
265
367
  **Decorators** (`src/server/decorators/`)
368
+
266
369
  - `@PlatformRoles(...roles)` — metadata decorator under `PLATFORM_ROLES_KEY` symbol; declares required platform role(s) for a route handler
267
370
 
268
371
  **Controllers**
372
+
269
373
  - `PlatformAuthController` (`src/server/controllers/`) — 6 endpoints: `POST /platform/login`, `POST /platform/mfa/challenge`, `GET /platform/me`, `POST /platform/logout`, `POST /platform/refresh`, `DELETE /platform/sessions`; all authenticated routes use `JwtPlatformGuard`; `mfa/challenge` cross-validates token context and throws `PLATFORM_AUTH_REQUIRED` on dashboard-context token submission
270
374
  - `OAuthController` (`src/server/oauth/`) — 2 endpoints: `GET /oauth/:provider` (initiate, 302 redirect) and `GET /oauth/:provider/callback` (handle, issues auth tokens); both `@Public()` + `@SkipMfa()`; per-endpoint throttle configs
271
375
  - `InvitationController` (`src/server/controllers/`) — 2 endpoints: `POST /invitations` (authenticated, `tenantId` extracted from JWT never from body) and `POST /invitations/accept` (public, returns 201 with auth response)
272
376
 
273
377
  **DTOs** (`src/server/dto/`)
378
+
274
379
  - `PlatformLoginDto` — `email` (normalized lowercase) + `password` (12–128 chars)
275
380
  - `CreateInvitationDto` — `email`, `role`, optional `tenantName` (max 128 chars)
276
381
  - `AcceptInvitationDto` — `token` (exactly 64 hex chars), `name` (2–100 chars), `password` (8–128 chars)
@@ -278,16 +383,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
278
383
  - `OAuthCallbackQueryDto` — `code` (32–2048 chars), `state` (max 128 chars)
279
384
 
280
385
  **OAuth module** (`src/server/oauth/`)
386
+
281
387
  - `OAuthModule` — exposes `getOAuthProviders()` and `getOAuthControllers()` static methods for inline inclusion in `BymaxAuthModule` providers/controllers arrays, avoiding sub-module circular dependency; `buildOAuthPlugins()` factory constructs registered provider plugins from `ResolvedOptions`
282
388
  - `OAUTH_PLUGINS` — Symbol injection token for the `OAuthProviderPlugin[]` array; internal to the library (not exported in public API)
283
389
 
284
390
  **Configuration** (`BymaxAuthModuleOptions`)
391
+
285
392
  - `platform.enabled` (default `false`); requires `roles.platformHierarchy`
286
393
  - `oauth.google` — `clientId`, `clientSecret`, `callbackUrl` (required), `scope` (optional, default `['openid', 'email', 'profile']`)
287
394
  - `invitations.enabled` (default `false`), `invitations.tokenTtlSeconds` (default 172800 — 48 hours)
288
395
  - `roles.platformHierarchy` — required when `platform.enabled: true`
289
396
 
290
397
  **Module integration** (`src/server/bymax-auth.module.ts`)
398
+
291
399
  - `controllers.platform: true` opt-in gate with three startup cross-validations: requires `platform.enabled: true`, the `mfa` config group, and `BYMAX_AUTH_PLATFORM_USER_REPOSITORY` in `extraProviders`
292
400
  - `controllers.oauth: true` opt-in gate with startup cross-validation: requires `oauth` config group; `OAUTH_PLUGINS` built lazily via factory provider after `BYMAX_AUTH_OPTIONS` resolves
293
401
  - `controllers.invitations: true` opt-in gate with startup cross-validation: requires `invitations.enabled: true`
@@ -300,11 +408,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
300
408
  #### Phase 6 — Integration, Polish, and Publication (NEST-122 to NEST-151)
301
409
 
302
410
  **Additional guards** (3)
411
+
303
412
  - `WsJwtGuard` — WebSocket dashboard JWT guard (header-only, soft peer-dep on `@nestjs/websockets`, runtime check via dynamic import)
304
413
  - `SelfOrAdminGuard` — self-access or admin override with strict SHA-256 session-hash validation; documents multi-tenant ownership limitation
305
414
  - `OptionalAuthGuard` — extends `JwtAuthGuard`, allows unauthenticated access while validating tokens when present
306
415
 
307
416
  **E2E test suite** (`test/e2e/`)
417
+
308
418
  - Full auth flow (bearer + cookie modes)
309
419
  - MFA flow (setup, verify, challenge with TOTP and recovery codes)
310
420
  - Sessions flow (3-device login, list, revoke single, revoke all-except-current)
@@ -316,15 +426,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
316
426
  - Security scenarios (brute-force lockout, blacklist, missing jti, MFA cross-context token rejection, OTP cooldown)
317
427
 
318
428
  **Security audits**
429
+
319
430
  - Password & crypto audit — scrypt parameters, AES-256-GCM, recovery code hashing, opaque refresh tokens, `crypto.timingSafeEqual` (PASS)
320
431
  - Token & session audit — refresh rotation grace window, blacklist, HttpOnly+SameSite cookies, algorithm pinning HS256, SHA-256 Redis keys (PASS)
321
432
  - Anti-enumeration & brute-force audit — per-tenant identifier (fixed prefix-collision in identifier separator), rate limiting on 15 sensitive endpoints, generic error responses, PII masking, TOTP anti-replay, OTP attempt limit, hook header sanitization
322
433
 
323
434
  **Documentation**
435
+
324
436
  - README.md — install, configuration, IUserRepository + IEmailProvider reference implementations with XSS warning, endpoints table, guards/decorators table, security checklist, throttler version note
325
437
  - JSDoc completion across all public services, guards, and decorators
326
438
 
327
439
  **Test infrastructure**
440
+
328
441
  - Jest E2E config (`jest.e2e.config.ts`)
329
442
  - ioredis-mock + supertest test harness
330
443
  - Shared bootstrap helper (`test/e2e/setup.ts`) with mock repositories, email capture, and in-memory Redis
@@ -334,6 +447,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
334
447
  ### Fixed
335
448
 
336
449
  #### Phase 6 — Bug fixes
450
+
337
451
  - `auth.service.ts` brute-force identifier separator: added explicit `:` between tenantId and email to prevent prefix-collision (e.g., tenant `'abc'` + email `'x@y.com'` no longer collides with tenant `'abcx'` + email `'@y.com'`)
338
452
  - `self-or-admin.guard.ts` (during initial implementation): replaced `ForbiddenException` wrapping `AuthException` with direct `AuthException` throw for correct error response shape
339
453
  - `ws-jwt.guard.ts` (during initial implementation): replaced `require.resolve` with dynamic `await import()` for ESM compatibility
@@ -346,7 +460,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
346
460
  - **Brute-force counter namespacing** — MFA challenge and disable endpoints use HMAC identifiers prefixed with `challenge:` and `disable:` respectively, preventing a pre-auth attacker from exhausting the disable counter via the public challenge endpoint
347
461
  - **`verifyAndEnable` re-entry guard** — added `MFA_ALREADY_ENABLED` check at entry so that a stale Redis setup key from a previous attempt cannot overwrite an active MFA secret and recovery codes
348
462
  - **`disable()` context-awareness** — the disable flow now accepts a `context` parameter (`'dashboard'` | `'platform'`) and dispatches to the correct repository, preventing platform admins from receiving `TOKEN_INVALID` when attempting to disable MFA
349
- - **HMAC keying for composite Redis keys** — all `sha256(tenantId + email)` call sites replaced with `hmacSha256(..., jwt.secret)` to prevent rainbow-table reversal of email addresses stored as Redis key segments
463
+ - **HMAC keying for composite Redis keys** — all `sha256(tenantId + email)` call sites replaced with `hmacSha256(..., jwt.secret)` to prevent rainbow-table reversal of email addresses stored as Redis key segments
350
464
  - **Atomic resend cooldown** — GET+SET TOCTOU race in `resendVerificationEmail` replaced with atomic `SET NX EX` (`setnx`) preventing duplicate OTP sends under concurrent requests
351
465
  - **Immutable DTO merging** — `Object.assign(dto, hookResult.modifiedData)` replaced with `dto = { ...dto, ...modifiedData }` preventing mutation of the class-validator–validated DTO and bypassing decorator constraints
352
466
  - **`secureCookies` resolved at startup** — `process.env.NODE_ENV === 'production'` check moved from per-request code inside `TokenDeliveryService` to `resolveOptions()`, eliminating an environment-variable read inside library service methods
package/README.md CHANGED
@@ -15,6 +15,7 @@
15
15
  <a href="https://github.com/bymaxone/nest-auth/actions/workflows/ci.yml"><img src="https://img.shields.io/github/actions/workflow/status/bymaxone/nest-auth/ci.yml?branch=main&style=flat-square&colorA=000000&label=CI" alt="CI status" /></a>
16
16
  <a href="https://github.com/bymaxone/nest-auth/actions/workflows/ci.yml"><img src="https://img.shields.io/badge/coverage-100%25-brightgreen?style=flat-square&colorA=000000" alt="coverage" /></a>
17
17
  <a href="https://github.com/bymaxone/nest-auth/blob/main/docs/mutation_testing_results.md"><img src="https://img.shields.io/badge/mutation-99.10%25-brightgreen?style=flat-square&colorA=000000" alt="mutation score" /></a>
18
+ <a href="https://scorecard.dev/viewer/?uri=github.com/bymaxone/nest-auth"><img src="https://api.scorecard.dev/projects/github.com/bymaxone/nest-auth/badge?style=flat-square" alt="OpenSSF Scorecard" /></a>
18
19
  <a href="https://github.com/bymaxone/nest-auth/blob/main/LICENSE"><img src="https://img.shields.io/github/license/bymaxone/nest-auth?style=flat-square&colorA=000000&colorB=000000" alt="license" /></a>
19
20
  <a href="https://www.typescriptlang.org/"><img src="https://img.shields.io/badge/TypeScript-strict-3178C6?style=flat-square&logo=typescript&logoColor=white" alt="TypeScript" /></a>
20
21
  <a href="https://nodejs.org/"><img src="https://img.shields.io/badge/Node.js-24%2B-339933?style=flat-square&logo=node.js&logoColor=white" alt="Node.js" /></a>
@@ -871,7 +872,7 @@ pnpm typecheck
871
872
 
872
873
  ## 🔒 Security Policy
873
874
 
874
- If you discover a security vulnerability, please **do not** open a public issue. Instead, email us at **security@bymax.one** with details. We take security seriously and will respond promptly.
875
+ If you discover a security vulnerability, please **do not** open a public issue. Instead, email us at **support@bymax.one** with details. We take security seriously and will respond promptly.
875
876
 
876
877
  ---
877
878
 
@@ -7152,6 +7152,38 @@ var OAuthCallbackQueryDto = class {
7152
7152
  * 128 is a generous upper bound for future provider variations.
7153
7153
  */
7154
7154
  state;
7155
+ /**
7156
+ * OIDC issuer identifier (RFC 9207). Echoed back by providers that advertise
7157
+ * their issuer in the discovery document — Google currently sends
7158
+ * `https://accounts.google.com`. Accepted but unused; the service derives
7159
+ * the provider from the URL path, not from this field.
7160
+ */
7161
+ iss;
7162
+ /**
7163
+ * Space-delimited list of scopes actually granted by the user, per RFC 6749
7164
+ * §3.3. The lib does not enforce minimum scopes here — the profile fetch
7165
+ * surfaces missing data via the `IUserRepository` mapping instead.
7166
+ */
7167
+ scope;
7168
+ /**
7169
+ * Google Account-chooser index (`0`, `1`, …). Identifies which of the
7170
+ * signed-in Google accounts in the user's browser authorised the request.
7171
+ * Accepted as a generic string to stay agnostic of Google-specific shape.
7172
+ */
7173
+ authuser;
7174
+ /**
7175
+ * Prompt that was shown to the user (`none`, `consent`, `select_account`,
7176
+ * or any combination thereof). Sent back by Google so SPAs can react to a
7177
+ * forced re-consent. Validation here is shape-only — semantics are the
7178
+ * provider's concern.
7179
+ */
7180
+ prompt;
7181
+ /**
7182
+ * Hosted-domain hint sent by Google Workspace — the email's domain when the
7183
+ * authorising account belongs to a managed organisation (e.g. `example.com`).
7184
+ * Useful for consumer apps that gate features by tenant; unused by the lib.
7185
+ */
7186
+ hd;
7155
7187
  };
7156
7188
  _ts_decorate41([
7157
7189
  classValidator.IsString(),
@@ -7165,6 +7197,36 @@ _ts_decorate41([
7165
7197
  classValidator.MaxLength(128),
7166
7198
  _ts_metadata40("design:type", String)
7167
7199
  ], OAuthCallbackQueryDto.prototype, "state", void 0);
7200
+ _ts_decorate41([
7201
+ classValidator.IsOptional(),
7202
+ classValidator.IsString(),
7203
+ classValidator.MaxLength(512),
7204
+ _ts_metadata40("design:type", String)
7205
+ ], OAuthCallbackQueryDto.prototype, "iss", void 0);
7206
+ _ts_decorate41([
7207
+ classValidator.IsOptional(),
7208
+ classValidator.IsString(),
7209
+ classValidator.MaxLength(2048),
7210
+ _ts_metadata40("design:type", String)
7211
+ ], OAuthCallbackQueryDto.prototype, "scope", void 0);
7212
+ _ts_decorate41([
7213
+ classValidator.IsOptional(),
7214
+ classValidator.IsString(),
7215
+ classValidator.MaxLength(16),
7216
+ _ts_metadata40("design:type", String)
7217
+ ], OAuthCallbackQueryDto.prototype, "authuser", void 0);
7218
+ _ts_decorate41([
7219
+ classValidator.IsOptional(),
7220
+ classValidator.IsString(),
7221
+ classValidator.MaxLength(64),
7222
+ _ts_metadata40("design:type", String)
7223
+ ], OAuthCallbackQueryDto.prototype, "prompt", void 0);
7224
+ _ts_decorate41([
7225
+ classValidator.IsOptional(),
7226
+ classValidator.IsString(),
7227
+ classValidator.MaxLength(253),
7228
+ _ts_metadata40("design:type", String)
7229
+ ], OAuthCallbackQueryDto.prototype, "hd", void 0);
7168
7230
  function _ts_decorate42(decorators, target, key, desc) {
7169
7231
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
7170
7232
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -7150,6 +7150,38 @@ var OAuthCallbackQueryDto = class {
7150
7150
  * 128 is a generous upper bound for future provider variations.
7151
7151
  */
7152
7152
  state;
7153
+ /**
7154
+ * OIDC issuer identifier (RFC 9207). Echoed back by providers that advertise
7155
+ * their issuer in the discovery document — Google currently sends
7156
+ * `https://accounts.google.com`. Accepted but unused; the service derives
7157
+ * the provider from the URL path, not from this field.
7158
+ */
7159
+ iss;
7160
+ /**
7161
+ * Space-delimited list of scopes actually granted by the user, per RFC 6749
7162
+ * §3.3. The lib does not enforce minimum scopes here — the profile fetch
7163
+ * surfaces missing data via the `IUserRepository` mapping instead.
7164
+ */
7165
+ scope;
7166
+ /**
7167
+ * Google Account-chooser index (`0`, `1`, …). Identifies which of the
7168
+ * signed-in Google accounts in the user's browser authorised the request.
7169
+ * Accepted as a generic string to stay agnostic of Google-specific shape.
7170
+ */
7171
+ authuser;
7172
+ /**
7173
+ * Prompt that was shown to the user (`none`, `consent`, `select_account`,
7174
+ * or any combination thereof). Sent back by Google so SPAs can react to a
7175
+ * forced re-consent. Validation here is shape-only — semantics are the
7176
+ * provider's concern.
7177
+ */
7178
+ prompt;
7179
+ /**
7180
+ * Hosted-domain hint sent by Google Workspace — the email's domain when the
7181
+ * authorising account belongs to a managed organisation (e.g. `example.com`).
7182
+ * Useful for consumer apps that gate features by tenant; unused by the lib.
7183
+ */
7184
+ hd;
7153
7185
  };
7154
7186
  _ts_decorate41([
7155
7187
  IsString(),
@@ -7163,6 +7195,36 @@ _ts_decorate41([
7163
7195
  MaxLength(128),
7164
7196
  _ts_metadata40("design:type", String)
7165
7197
  ], OAuthCallbackQueryDto.prototype, "state", void 0);
7198
+ _ts_decorate41([
7199
+ IsOptional(),
7200
+ IsString(),
7201
+ MaxLength(512),
7202
+ _ts_metadata40("design:type", String)
7203
+ ], OAuthCallbackQueryDto.prototype, "iss", void 0);
7204
+ _ts_decorate41([
7205
+ IsOptional(),
7206
+ IsString(),
7207
+ MaxLength(2048),
7208
+ _ts_metadata40("design:type", String)
7209
+ ], OAuthCallbackQueryDto.prototype, "scope", void 0);
7210
+ _ts_decorate41([
7211
+ IsOptional(),
7212
+ IsString(),
7213
+ MaxLength(16),
7214
+ _ts_metadata40("design:type", String)
7215
+ ], OAuthCallbackQueryDto.prototype, "authuser", void 0);
7216
+ _ts_decorate41([
7217
+ IsOptional(),
7218
+ IsString(),
7219
+ MaxLength(64),
7220
+ _ts_metadata40("design:type", String)
7221
+ ], OAuthCallbackQueryDto.prototype, "prompt", void 0);
7222
+ _ts_decorate41([
7223
+ IsOptional(),
7224
+ IsString(),
7225
+ MaxLength(253),
7226
+ _ts_metadata40("design:type", String)
7227
+ ], OAuthCallbackQueryDto.prototype, "hd", void 0);
7166
7228
  function _ts_decorate42(decorators, target, key, desc) {
7167
7229
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
7168
7230
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@bymax-one/nest-auth",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "Full-stack authentication and authorization package for NestJS, React and Next.js — JWT, MFA, OAuth, sessions, multi-tenant SaaS ready",
5
- "author": "Bymax One <contact@bymax.one>",
5
+ "author": "Bymax One <support@bymax.one>",
6
6
  "license": "MIT",
7
7
  "homepage": "https://github.com/bymaxone/nest-auth#readme",
8
8
  "repository": {