@bymax-one/nest-auth 1.4.2 → 1.4.4
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 +1840 -1
- package/README.md +706 -74
- package/dist/client/index.cjs +108 -35
- package/dist/client/index.d.cts +90 -15
- package/dist/client/index.d.ts +90 -15
- package/dist/client/index.mjs +109 -36
- package/dist/server/index.cjs +1832 -441
- package/dist/server/index.d.cts +1051 -136
- package/dist/server/index.d.ts +1051 -136
- package/dist/server/index.mjs +1828 -443
- package/dist/shared/index.cjs +103 -10
- package/dist/shared/index.d.cts +128 -5
- package/dist/shared/index.d.ts +128 -5
- package/dist/shared/index.mjs +100 -11
- package/package.json +12 -6
package/dist/shared/index.d.ts
CHANGED
|
@@ -75,8 +75,12 @@ declare const AUTH_ERROR_CODES: {
|
|
|
75
75
|
readonly ACCOUNT_SUSPENDED: "auth.account_suspended";
|
|
76
76
|
readonly ACCOUNT_BANNED: "auth.account_banned";
|
|
77
77
|
readonly PENDING_APPROVAL: "auth.pending_approval";
|
|
78
|
+
/** Internal-only: expiry. Never on the wire — collapsed onto TOKEN_INVALID, to deny an oracle
|
|
79
|
+
* separating a token that WAS valid from one that never was. */
|
|
78
80
|
readonly TOKEN_EXPIRED: "auth.token_expired";
|
|
81
|
+
/** Internal-only: logout or epoch bump. Never on the wire — see TOKEN_EXPIRED. */
|
|
79
82
|
readonly TOKEN_REVOKED: "auth.token_revoked";
|
|
83
|
+
/** What a client receives for EVERY unusable credential: expired, revoked, malformed, absent. */
|
|
80
84
|
readonly TOKEN_INVALID: "auth.token_invalid";
|
|
81
85
|
/** Internal-only: the request carried no credential. Never on the wire — see TOKEN_INVALID. */
|
|
82
86
|
readonly TOKEN_MISSING: "auth.token_missing";
|
|
@@ -143,6 +147,22 @@ declare const AUTH_ERROR_CODES: {
|
|
|
143
147
|
* compile time.
|
|
144
148
|
*/
|
|
145
149
|
type AuthErrorCode = (typeof AUTH_ERROR_CODES)[keyof typeof AUTH_ERROR_CODES];
|
|
150
|
+
/**
|
|
151
|
+
* HTTP status each error code answers with, mirrored from the server declaration.
|
|
152
|
+
*
|
|
153
|
+
* Duplicated rather than imported for the same reason {@link AUTH_ERROR_CODES} is: this subpath
|
|
154
|
+
* must compile in a browser, and the server entry carries the NestJS peer dependencies. The
|
|
155
|
+
* drift-guard spec beside this file is the only place the two declarations meet.
|
|
156
|
+
*
|
|
157
|
+
* It lives here because the three uses the README invites — a typed client, an API document, a
|
|
158
|
+
* test asserting against the mapping — are exactly the ones that must not pull the server entry.
|
|
159
|
+
* It shipped only from there, next to a paragraph correctly saying `AUTH_ERROR_CODES` comes from
|
|
160
|
+
* `/shared`, so the adjacency invited the assumption that this did too.
|
|
161
|
+
*
|
|
162
|
+
* These are WIRE statuses: an internal-only code carries the status of the public code it
|
|
163
|
+
* collapses onto, not one of its own.
|
|
164
|
+
*/
|
|
165
|
+
declare const AUTH_ERROR_STATUS: Readonly<Record<AuthErrorCode, number>>;
|
|
146
166
|
|
|
147
167
|
/**
|
|
148
168
|
* HTTP route paths exposed by the @bymax-one/nest-auth server controllers.
|
|
@@ -175,6 +195,8 @@ declare const AUTH_DASHBOARD_ROUTES: {
|
|
|
175
195
|
readonly refresh: "refresh";
|
|
176
196
|
/** GET — return the currently authenticated user. */
|
|
177
197
|
readonly me: "me";
|
|
198
|
+
/** POST — mint a single-use ticket for a WebSocket upgrade. */
|
|
199
|
+
readonly wsTicket: "ws-ticket";
|
|
178
200
|
/** POST — submit the email-verification token returned by the verification email. */
|
|
179
201
|
readonly verifyEmail: "verify-email";
|
|
180
202
|
/** POST — request a fresh email-verification token. */
|
|
@@ -194,6 +216,8 @@ declare const AUTH_MFA_ROUTES: {
|
|
|
194
216
|
readonly challenge: "mfa/challenge";
|
|
195
217
|
/** POST — disable MFA after re-authenticating with a fresh OTP. */
|
|
196
218
|
readonly disable: "mfa/disable";
|
|
219
|
+
/** POST — replace the recovery codes, re-authenticating with a fresh OTP. */
|
|
220
|
+
readonly recoveryCodes: "mfa/recovery-codes";
|
|
197
221
|
};
|
|
198
222
|
/**
|
|
199
223
|
* Password reset routes.
|
|
@@ -206,6 +230,13 @@ declare const AUTH_PASSWORD_ROUTES: {
|
|
|
206
230
|
readonly forgotPassword: "password/forgot-password";
|
|
207
231
|
/** POST — submit a new password using the reset token. */
|
|
208
232
|
readonly resetPassword: "password/reset-password";
|
|
233
|
+
/**
|
|
234
|
+
* POST — change the password of the signed-in user, verifying the current one.
|
|
235
|
+
*
|
|
236
|
+
* The only route in this family behind the JWT guard: the rest are reached by a
|
|
237
|
+
* caller who has no session, which is what a reset is for.
|
|
238
|
+
*/
|
|
239
|
+
readonly changePassword: "password/change";
|
|
209
240
|
/** POST — verify the reset OTP (when `passwordReset.method = 'otp'`). */
|
|
210
241
|
readonly verifyOtp: "password/verify-otp";
|
|
211
242
|
/** POST — request a fresh OTP after the previous one expired. */
|
|
@@ -231,6 +262,31 @@ declare const AUTH_PLATFORM_ROUTES: {
|
|
|
231
262
|
/** DELETE — revoke every active session for the current platform admin. */
|
|
232
263
|
readonly revokeAllSessions: "platform/sessions";
|
|
233
264
|
};
|
|
265
|
+
/**
|
|
266
|
+
* Platform administrator MFA routes (`controllers.platform: true`).
|
|
267
|
+
*
|
|
268
|
+
* Mounted under `platform/mfa/`
|
|
269
|
+
* (`src/server/controllers/platform-mfa.controller.ts`). A separate family because the
|
|
270
|
+
* controller is separate, NOT because the switch is: `controllers.platform: true` mounts
|
|
271
|
+
* `PlatformAuthController` and `PlatformMfaController` together, and there is no
|
|
272
|
+
* `controllers.platformMfa` option to turn one on without the other. The platform plane requires
|
|
273
|
+
* MFA of its administrators, so a deployment that could mount the login surface without the
|
|
274
|
+
* enrollment surface would be one where an operator can be required to present a second factor
|
|
275
|
+
* they have no endpoint to set up.
|
|
276
|
+
*
|
|
277
|
+
* The challenge is NOT here — it belongs to the login flow on `PlatformAuthController`, which is
|
|
278
|
+
* why it sits with the routes that issue credentials rather than with the ones that manage them.
|
|
279
|
+
*/
|
|
280
|
+
declare const AUTH_PLATFORM_MFA_ROUTES: {
|
|
281
|
+
/** POST — begin TOTP enrollment for a platform administrator. */
|
|
282
|
+
readonly setup: "platform/mfa/setup";
|
|
283
|
+
/** POST — confirm enrollment by submitting the first valid code. */
|
|
284
|
+
readonly verifyEnable: "platform/mfa/verify-enable";
|
|
285
|
+
/** POST — disable MFA after re-authenticating with a fresh OTP. */
|
|
286
|
+
readonly disable: "platform/mfa/disable";
|
|
287
|
+
/** POST — replace the recovery codes, re-authenticating with a fresh OTP. */
|
|
288
|
+
readonly recoveryCodes: "platform/mfa/recovery-codes";
|
|
289
|
+
};
|
|
234
290
|
/**
|
|
235
291
|
* Session management routes (`controllers.sessions: true`).
|
|
236
292
|
*
|
|
@@ -240,14 +296,33 @@ declare const AUTH_PLATFORM_ROUTES: {
|
|
|
240
296
|
declare const AUTH_SESSION_ROUTES: {
|
|
241
297
|
/** GET — list every active session for the current user. */
|
|
242
298
|
readonly list: "sessions";
|
|
243
|
-
/**
|
|
244
|
-
|
|
299
|
+
/**
|
|
300
|
+
* POST — revoke every session belonging to the current user except the one
|
|
301
|
+
* making the call.
|
|
302
|
+
*
|
|
303
|
+
* POST rather than DELETE because the refresh token that names the current
|
|
304
|
+
* session travels in the body under `tokenDelivery: 'bearer'`, and OpenAPI 3.0.3
|
|
305
|
+
* defers to RFC 7231: a payload on DELETE has no defined semantics, so a
|
|
306
|
+
* generated client drops it.
|
|
307
|
+
*/
|
|
308
|
+
readonly revokeAll: "sessions/revoke-all";
|
|
245
309
|
/**
|
|
246
310
|
* DELETE — revoke a single session by id. The `:id` placeholder must be
|
|
247
311
|
* substituted with the session identifier before the request is issued.
|
|
248
312
|
*/
|
|
249
313
|
readonly revokeOne: "sessions/:id";
|
|
250
314
|
};
|
|
315
|
+
/**
|
|
316
|
+
* Address-change routes (`controllers.emailChange: true`).
|
|
317
|
+
*
|
|
318
|
+
* Mounted under `email/` (`src/server/controllers/email-change.controller.ts`).
|
|
319
|
+
*/
|
|
320
|
+
declare const AUTH_EMAIL_CHANGE_ROUTES: {
|
|
321
|
+
/** POST — request a change; mails a token to the new address. */
|
|
322
|
+
readonly request: "email/change";
|
|
323
|
+
/** POST — confirm the change with that token. */
|
|
324
|
+
readonly confirm: "email/change/confirm";
|
|
325
|
+
};
|
|
251
326
|
/**
|
|
252
327
|
* Invitation routes (`controllers.invitations: true`).
|
|
253
328
|
*
|
|
@@ -262,6 +337,19 @@ declare const AUTH_INVITATION_ROUTES: {
|
|
|
262
337
|
/** POST — withdraw a pending invitation before it is accepted (admin-only). */
|
|
263
338
|
readonly revoke: "invitations/revoke";
|
|
264
339
|
};
|
|
340
|
+
/**
|
|
341
|
+
* OAuth routes (`oauth.google` configured).
|
|
342
|
+
*
|
|
343
|
+
* Mounted under `oauth/` (`src/server/oauth/oauth.controller.ts`). Both carry a
|
|
344
|
+
* `:provider` segment that must be substituted before the request is issued —
|
|
345
|
+
* `'google'` is the only provider this library implements today.
|
|
346
|
+
*/
|
|
347
|
+
declare const AUTH_OAUTH_ROUTES: {
|
|
348
|
+
/** GET — redirect the browser to the provider's consent screen. */
|
|
349
|
+
readonly initiate: "oauth/:provider";
|
|
350
|
+
/** GET — the provider redirects back here with the authorization code. */
|
|
351
|
+
readonly callback: "oauth/:provider/callback";
|
|
352
|
+
};
|
|
265
353
|
/**
|
|
266
354
|
* Aggregated route map grouped by domain.
|
|
267
355
|
*
|
|
@@ -280,6 +368,8 @@ declare const AUTH_ROUTES: {
|
|
|
280
368
|
readonly refresh: "refresh";
|
|
281
369
|
/** GET — return the currently authenticated user. */
|
|
282
370
|
readonly me: "me";
|
|
371
|
+
/** POST — mint a single-use ticket for a WebSocket upgrade. */
|
|
372
|
+
readonly wsTicket: "ws-ticket";
|
|
283
373
|
/** POST — submit the email-verification token returned by the verification email. */
|
|
284
374
|
readonly verifyEmail: "verify-email";
|
|
285
375
|
/** POST — request a fresh email-verification token. */
|
|
@@ -294,12 +384,21 @@ declare const AUTH_ROUTES: {
|
|
|
294
384
|
readonly challenge: "mfa/challenge";
|
|
295
385
|
/** POST — disable MFA after re-authenticating with a fresh OTP. */
|
|
296
386
|
readonly disable: "mfa/disable";
|
|
387
|
+
/** POST — replace the recovery codes, re-authenticating with a fresh OTP. */
|
|
388
|
+
readonly recoveryCodes: "mfa/recovery-codes";
|
|
297
389
|
};
|
|
298
390
|
readonly password: {
|
|
299
391
|
/** POST — request a password reset (email lookup is anti-enumeration). */
|
|
300
392
|
readonly forgotPassword: "password/forgot-password";
|
|
301
393
|
/** POST — submit a new password using the reset token. */
|
|
302
394
|
readonly resetPassword: "password/reset-password";
|
|
395
|
+
/**
|
|
396
|
+
* POST — change the password of the signed-in user, verifying the current one.
|
|
397
|
+
*
|
|
398
|
+
* The only route in this family behind the JWT guard: the rest are reached by a
|
|
399
|
+
* caller who has no session, which is what a reset is for.
|
|
400
|
+
*/
|
|
401
|
+
readonly changePassword: "password/change";
|
|
303
402
|
/** POST — verify the reset OTP (when `passwordReset.method = 'otp'`). */
|
|
304
403
|
readonly verifyOtp: "password/verify-otp";
|
|
305
404
|
/** POST — request a fresh OTP after the previous one expired. */
|
|
@@ -319,11 +418,29 @@ declare const AUTH_ROUTES: {
|
|
|
319
418
|
/** DELETE — revoke every active session for the current platform admin. */
|
|
320
419
|
readonly revokeAllSessions: "platform/sessions";
|
|
321
420
|
};
|
|
421
|
+
readonly platformMfa: {
|
|
422
|
+
/** POST — begin TOTP enrollment for a platform administrator. */
|
|
423
|
+
readonly setup: "platform/mfa/setup";
|
|
424
|
+
/** POST — confirm enrollment by submitting the first valid code. */
|
|
425
|
+
readonly verifyEnable: "platform/mfa/verify-enable";
|
|
426
|
+
/** POST — disable MFA after re-authenticating with a fresh OTP. */
|
|
427
|
+
readonly disable: "platform/mfa/disable";
|
|
428
|
+
/** POST — replace the recovery codes, re-authenticating with a fresh OTP. */
|
|
429
|
+
readonly recoveryCodes: "platform/mfa/recovery-codes";
|
|
430
|
+
};
|
|
322
431
|
readonly sessions: {
|
|
323
432
|
/** GET — list every active session for the current user. */
|
|
324
433
|
readonly list: "sessions";
|
|
325
|
-
/**
|
|
326
|
-
|
|
434
|
+
/**
|
|
435
|
+
* POST — revoke every session belonging to the current user except the one
|
|
436
|
+
* making the call.
|
|
437
|
+
*
|
|
438
|
+
* POST rather than DELETE because the refresh token that names the current
|
|
439
|
+
* session travels in the body under `tokenDelivery: 'bearer'`, and OpenAPI 3.0.3
|
|
440
|
+
* defers to RFC 7231: a payload on DELETE has no defined semantics, so a
|
|
441
|
+
* generated client drops it.
|
|
442
|
+
*/
|
|
443
|
+
readonly revokeAll: "sessions/revoke-all";
|
|
327
444
|
/**
|
|
328
445
|
* DELETE — revoke a single session by id. The `:id` placeholder must be
|
|
329
446
|
* substituted with the session identifier before the request is issued.
|
|
@@ -344,6 +461,12 @@ declare const AUTH_ROUTES: {
|
|
|
344
461
|
/** POST — confirm the change with that token. */
|
|
345
462
|
readonly confirm: "email/change/confirm";
|
|
346
463
|
};
|
|
464
|
+
readonly oauth: {
|
|
465
|
+
/** GET — redirect the browser to the provider's consent screen. */
|
|
466
|
+
readonly initiate: "oauth/:provider";
|
|
467
|
+
/** GET — the provider redirects back here with the authorization code. */
|
|
468
|
+
readonly callback: "oauth/:provider/callback";
|
|
469
|
+
};
|
|
347
470
|
};
|
|
348
471
|
/**
|
|
349
472
|
* Default Next.js proxy endpoints used by `createAuthClient` and the
|
|
@@ -849,4 +972,4 @@ type AuthContextKind = 'dashboard' | 'platform';
|
|
|
849
972
|
*/
|
|
850
973
|
type TokenDeliveryMode = 'cookie' | 'bearer';
|
|
851
974
|
|
|
852
|
-
export { AUTH_ACCESS_COOKIE_NAME, AUTH_DASHBOARD_ROUTES, AUTH_ERROR_CODES, AUTH_HAS_SESSION_COOKIE_NAME, AUTH_INVITATION_ROUTES, AUTH_MFA_ROUTES, AUTH_PASSWORD_ROUTES, AUTH_PLATFORM_ROUTES, AUTH_PROXY_ROUTES, AUTH_REFRESH_COOKIE_NAME, AUTH_REFRESH_COOKIE_PATH, AUTH_REFRESH_SKIP_PATH_SUFFIXES, AUTH_ROUTES, AUTH_SESSION_ROUTES, AuthClientError, type AuthContextKind, type AuthCookieNames, type AuthErrorCode, type AuthErrorResponse, type AuthJwtPayload, type AuthPlatformUserClient, type AuthResponseCode, type AuthResult, type AuthUserClient, type DashboardJwtPayload, type LoginResult, type MfaChallengeResult, type MfaTempPayload, type PlatformAuthResult, type PlatformJwtPayload, type PlatformLoginResult, type TokenDeliveryMode, buildAuthRefreshSkipSuffixes };
|
|
975
|
+
export { AUTH_ACCESS_COOKIE_NAME, AUTH_DASHBOARD_ROUTES, AUTH_EMAIL_CHANGE_ROUTES, AUTH_ERROR_CODES, AUTH_ERROR_STATUS, AUTH_HAS_SESSION_COOKIE_NAME, AUTH_INVITATION_ROUTES, AUTH_MFA_ROUTES, AUTH_OAUTH_ROUTES, AUTH_PASSWORD_ROUTES, AUTH_PLATFORM_MFA_ROUTES, AUTH_PLATFORM_ROUTES, AUTH_PROXY_ROUTES, AUTH_REFRESH_COOKIE_NAME, AUTH_REFRESH_COOKIE_PATH, AUTH_REFRESH_SKIP_PATH_SUFFIXES, AUTH_ROUTES, AUTH_SESSION_ROUTES, AuthClientError, type AuthContextKind, type AuthCookieNames, type AuthErrorCode, type AuthErrorResponse, type AuthJwtPayload, type AuthPlatformUserClient, type AuthResponseCode, type AuthResult, type AuthUserClient, type DashboardJwtPayload, type LoginResult, type MfaChallengeResult, type MfaTempPayload, type PlatformAuthResult, type PlatformJwtPayload, type PlatformLoginResult, type TokenDeliveryMode, buildAuthRefreshSkipSuffixes };
|
package/dist/shared/index.mjs
CHANGED
|
@@ -17,8 +17,12 @@ var AUTH_ERROR_CODES = {
|
|
|
17
17
|
ACCOUNT_BANNED: "auth.account_banned",
|
|
18
18
|
PENDING_APPROVAL: "auth.pending_approval",
|
|
19
19
|
// Tokens and sessions
|
|
20
|
+
/** Internal-only: expiry. Never on the wire — collapsed onto TOKEN_INVALID, to deny an oracle
|
|
21
|
+
* separating a token that WAS valid from one that never was. */
|
|
20
22
|
TOKEN_EXPIRED: "auth.token_expired",
|
|
23
|
+
/** Internal-only: logout or epoch bump. Never on the wire — see TOKEN_EXPIRED. */
|
|
21
24
|
TOKEN_REVOKED: "auth.token_revoked",
|
|
25
|
+
/** What a client receives for EVERY unusable credential: expired, revoked, malformed, absent. */
|
|
22
26
|
TOKEN_INVALID: "auth.token_invalid",
|
|
23
27
|
/** Internal-only: the request carried no credential. Never on the wire — see TOKEN_INVALID. */
|
|
24
28
|
TOKEN_MISSING: "auth.token_missing",
|
|
@@ -85,6 +89,46 @@ var AUTH_ERROR_CODES = {
|
|
|
85
89
|
*/
|
|
86
90
|
INTERNAL: "auth.internal"
|
|
87
91
|
};
|
|
92
|
+
var AUTH_ERROR_STATUS = {
|
|
93
|
+
"auth.invalid_credentials": 401,
|
|
94
|
+
"auth.account_locked": 429,
|
|
95
|
+
"auth.account_inactive": 403,
|
|
96
|
+
"auth.account_suspended": 403,
|
|
97
|
+
"auth.account_banned": 403,
|
|
98
|
+
"auth.pending_approval": 403,
|
|
99
|
+
"auth.token_expired": 401,
|
|
100
|
+
"auth.token_revoked": 401,
|
|
101
|
+
"auth.token_invalid": 401,
|
|
102
|
+
"auth.token_missing": 401,
|
|
103
|
+
"auth.refresh_token_invalid": 401,
|
|
104
|
+
"auth.session_not_found": 404,
|
|
105
|
+
"auth.email_already_exists": 409,
|
|
106
|
+
"auth.email_not_verified": 403,
|
|
107
|
+
"auth.email_change_token_invalid": 400,
|
|
108
|
+
"auth.mfa_required": 403,
|
|
109
|
+
"auth.mfa_invalid_code": 401,
|
|
110
|
+
"auth.mfa_already_enabled": 409,
|
|
111
|
+
"auth.mfa_not_enabled": 400,
|
|
112
|
+
"auth.mfa_setup_required": 400,
|
|
113
|
+
"auth.mfa_temp_token_invalid": 401,
|
|
114
|
+
"auth.mfa_state_conflict": 409,
|
|
115
|
+
"auth.password_compromised": 400,
|
|
116
|
+
"auth.password_reset_token_invalid": 400,
|
|
117
|
+
"auth.otp_invalid": 401,
|
|
118
|
+
"auth.otp_expired": 401,
|
|
119
|
+
"auth.otp_max_attempts": 401,
|
|
120
|
+
"auth.insufficient_role": 403,
|
|
121
|
+
"auth.forbidden": 403,
|
|
122
|
+
"auth.validation": 400,
|
|
123
|
+
"auth.too_many_requests": 429,
|
|
124
|
+
"auth.untrusted_origin": 403,
|
|
125
|
+
"auth.reauthentication_required": 403,
|
|
126
|
+
"auth.invalid_invitation_token": 400,
|
|
127
|
+
"auth.oauth_failed": 401,
|
|
128
|
+
"auth.oauth_email_mismatch": 409,
|
|
129
|
+
"auth.platform_auth_required": 401,
|
|
130
|
+
"auth.internal": 500
|
|
131
|
+
};
|
|
88
132
|
|
|
89
133
|
// src/shared/constants/routes.ts
|
|
90
134
|
var AUTH_DASHBOARD_ROUTES = {
|
|
@@ -98,6 +142,8 @@ var AUTH_DASHBOARD_ROUTES = {
|
|
|
98
142
|
refresh: "refresh",
|
|
99
143
|
/** GET — return the currently authenticated user. */
|
|
100
144
|
me: "me",
|
|
145
|
+
/** POST — mint a single-use ticket for a WebSocket upgrade. */
|
|
146
|
+
wsTicket: "ws-ticket",
|
|
101
147
|
/** POST — submit the email-verification token returned by the verification email. */
|
|
102
148
|
verifyEmail: "verify-email",
|
|
103
149
|
/** POST — request a fresh email-verification token. */
|
|
@@ -111,13 +157,22 @@ var AUTH_MFA_ROUTES = {
|
|
|
111
157
|
/** POST — exchange an MFA temp token + OTP for a full access token. */
|
|
112
158
|
challenge: "mfa/challenge",
|
|
113
159
|
/** POST — disable MFA after re-authenticating with a fresh OTP. */
|
|
114
|
-
disable: "mfa/disable"
|
|
160
|
+
disable: "mfa/disable",
|
|
161
|
+
/** POST — replace the recovery codes, re-authenticating with a fresh OTP. */
|
|
162
|
+
recoveryCodes: "mfa/recovery-codes"
|
|
115
163
|
};
|
|
116
164
|
var AUTH_PASSWORD_ROUTES = {
|
|
117
165
|
/** POST — request a password reset (email lookup is anti-enumeration). */
|
|
118
166
|
forgotPassword: "password/forgot-password",
|
|
119
167
|
/** POST — submit a new password using the reset token. */
|
|
120
168
|
resetPassword: "password/reset-password",
|
|
169
|
+
/**
|
|
170
|
+
* POST — change the password of the signed-in user, verifying the current one.
|
|
171
|
+
*
|
|
172
|
+
* The only route in this family behind the JWT guard: the rest are reached by a
|
|
173
|
+
* caller who has no session, which is what a reset is for.
|
|
174
|
+
*/
|
|
175
|
+
changePassword: "password/change",
|
|
121
176
|
/** POST — verify the reset OTP (when `passwordReset.method = 'otp'`). */
|
|
122
177
|
verifyOtp: "password/verify-otp",
|
|
123
178
|
/** POST — request a fresh OTP after the previous one expired. */
|
|
@@ -137,11 +192,29 @@ var AUTH_PLATFORM_ROUTES = {
|
|
|
137
192
|
/** DELETE — revoke every active session for the current platform admin. */
|
|
138
193
|
revokeAllSessions: "platform/sessions"
|
|
139
194
|
};
|
|
195
|
+
var AUTH_PLATFORM_MFA_ROUTES = {
|
|
196
|
+
/** POST — begin TOTP enrollment for a platform administrator. */
|
|
197
|
+
setup: "platform/mfa/setup",
|
|
198
|
+
/** POST — confirm enrollment by submitting the first valid code. */
|
|
199
|
+
verifyEnable: "platform/mfa/verify-enable",
|
|
200
|
+
/** POST — disable MFA after re-authenticating with a fresh OTP. */
|
|
201
|
+
disable: "platform/mfa/disable",
|
|
202
|
+
/** POST — replace the recovery codes, re-authenticating with a fresh OTP. */
|
|
203
|
+
recoveryCodes: "platform/mfa/recovery-codes"
|
|
204
|
+
};
|
|
140
205
|
var AUTH_SESSION_ROUTES = {
|
|
141
206
|
/** GET — list every active session for the current user. */
|
|
142
207
|
list: "sessions",
|
|
143
|
-
/**
|
|
144
|
-
|
|
208
|
+
/**
|
|
209
|
+
* POST — revoke every session belonging to the current user except the one
|
|
210
|
+
* making the call.
|
|
211
|
+
*
|
|
212
|
+
* POST rather than DELETE because the refresh token that names the current
|
|
213
|
+
* session travels in the body under `tokenDelivery: 'bearer'`, and OpenAPI 3.0.3
|
|
214
|
+
* defers to RFC 7231: a payload on DELETE has no defined semantics, so a
|
|
215
|
+
* generated client drops it.
|
|
216
|
+
*/
|
|
217
|
+
revokeAll: "sessions/revoke-all",
|
|
145
218
|
/**
|
|
146
219
|
* DELETE — revoke a single session by id. The `:id` placeholder must be
|
|
147
220
|
* substituted with the session identifier before the request is issued.
|
|
@@ -162,14 +235,22 @@ var AUTH_INVITATION_ROUTES = {
|
|
|
162
235
|
/** POST — withdraw a pending invitation before it is accepted (admin-only). */
|
|
163
236
|
revoke: "invitations/revoke"
|
|
164
237
|
};
|
|
238
|
+
var AUTH_OAUTH_ROUTES = {
|
|
239
|
+
/** GET — redirect the browser to the provider's consent screen. */
|
|
240
|
+
initiate: "oauth/:provider",
|
|
241
|
+
/** GET — the provider redirects back here with the authorization code. */
|
|
242
|
+
callback: "oauth/:provider/callback"
|
|
243
|
+
};
|
|
165
244
|
var AUTH_ROUTES = {
|
|
166
245
|
dashboard: AUTH_DASHBOARD_ROUTES,
|
|
167
246
|
mfa: AUTH_MFA_ROUTES,
|
|
168
247
|
password: AUTH_PASSWORD_ROUTES,
|
|
169
248
|
platform: AUTH_PLATFORM_ROUTES,
|
|
249
|
+
platformMfa: AUTH_PLATFORM_MFA_ROUTES,
|
|
170
250
|
sessions: AUTH_SESSION_ROUTES,
|
|
171
251
|
invitations: AUTH_INVITATION_ROUTES,
|
|
172
|
-
emailChange: AUTH_EMAIL_CHANGE_ROUTES
|
|
252
|
+
emailChange: AUTH_EMAIL_CHANGE_ROUTES,
|
|
253
|
+
oauth: AUTH_OAUTH_ROUTES
|
|
173
254
|
};
|
|
174
255
|
var AUTH_PROXY_ROUTES = {
|
|
175
256
|
/** POST — same-domain refresh entry point (server-to-server). */
|
|
@@ -192,22 +273,30 @@ var AUTH_REFRESH_SKIP_CONTROLLER_PATHS = [
|
|
|
192
273
|
"password/reset-password",
|
|
193
274
|
"password/verify-otp",
|
|
194
275
|
"password/resend-otp",
|
|
195
|
-
// MFA
|
|
196
|
-
|
|
197
|
-
|
|
276
|
+
// The MFA challenge issues the session — there is none to refresh. Its siblings
|
|
277
|
+
// (`mfa/setup`, `mfa/verify-enable`, `mfa/disable`) are NOT here: they are JWT-guarded, so a
|
|
278
|
+
// 401 there can be a genuine expiry, and their credential failures are recognised by code.
|
|
198
279
|
"mfa/challenge",
|
|
199
|
-
"mfa/disable",
|
|
200
280
|
// Invitation acceptance issues tokens
|
|
201
281
|
"invitations/accept",
|
|
202
282
|
// The address-change confirmation is public: the holder is proving control of a mailbox,
|
|
203
283
|
// not of a session.
|
|
204
284
|
"email/change/confirm",
|
|
205
|
-
//
|
|
285
|
+
// The platform surface, ALL of it. Every protected route here is JWT-PLATFORM-guarded, so an
|
|
286
|
+
// expired platform token answers `auth.token_invalid` — the code the client reads as "expired"
|
|
287
|
+
// — and a dashboard refresh cannot fix another plane's credential. Listing only some of them
|
|
288
|
+
// left the rest launching a refresh that spends the budget and can call `onSessionExpired` for
|
|
289
|
+
// a dashboard session that is perfectly healthy.
|
|
206
290
|
"platform/login",
|
|
207
291
|
"platform/refresh",
|
|
208
292
|
"platform/logout",
|
|
293
|
+
"platform/me",
|
|
294
|
+
"platform/sessions",
|
|
209
295
|
"platform/mfa/challenge",
|
|
210
|
-
"platform/
|
|
296
|
+
"platform/mfa/setup",
|
|
297
|
+
"platform/mfa/verify-enable",
|
|
298
|
+
"platform/mfa/disable",
|
|
299
|
+
"platform/mfa/recovery-codes"
|
|
211
300
|
];
|
|
212
301
|
var AUTH_REFRESH_SKIP_PROXY_PATHS = [
|
|
213
302
|
"/api/auth/client-refresh",
|
|
@@ -271,4 +360,4 @@ var AuthClientError = class extends Error {
|
|
|
271
360
|
}
|
|
272
361
|
};
|
|
273
362
|
|
|
274
|
-
export { AUTH_ACCESS_COOKIE_NAME, AUTH_DASHBOARD_ROUTES, AUTH_ERROR_CODES, AUTH_HAS_SESSION_COOKIE_NAME, AUTH_INVITATION_ROUTES, AUTH_MFA_ROUTES, AUTH_PASSWORD_ROUTES, AUTH_PLATFORM_ROUTES, AUTH_PROXY_ROUTES, AUTH_REFRESH_COOKIE_NAME, AUTH_REFRESH_COOKIE_PATH, AUTH_REFRESH_SKIP_PATH_SUFFIXES, AUTH_ROUTES, AUTH_SESSION_ROUTES, AuthClientError, buildAuthRefreshSkipSuffixes };
|
|
363
|
+
export { AUTH_ACCESS_COOKIE_NAME, AUTH_DASHBOARD_ROUTES, AUTH_EMAIL_CHANGE_ROUTES, AUTH_ERROR_CODES, AUTH_ERROR_STATUS, AUTH_HAS_SESSION_COOKIE_NAME, AUTH_INVITATION_ROUTES, AUTH_MFA_ROUTES, AUTH_OAUTH_ROUTES, AUTH_PASSWORD_ROUTES, AUTH_PLATFORM_MFA_ROUTES, AUTH_PLATFORM_ROUTES, AUTH_PROXY_ROUTES, AUTH_REFRESH_COOKIE_NAME, AUTH_REFRESH_COOKIE_PATH, AUTH_REFRESH_SKIP_PATH_SUFFIXES, AUTH_ROUTES, AUTH_SESSION_ROUTES, AuthClientError, buildAuthRefreshSkipSuffixes };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bymax-one/nest-auth",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.4",
|
|
4
4
|
"description": "Full-stack authentication and authorization package for NestJS, React and Next.js — JWT, MFA, OAuth, sessions, multi-tenant SaaS ready",
|
|
5
5
|
"author": "Bymax One <support@bymax.one>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -177,13 +177,15 @@
|
|
|
177
177
|
"@nestjs/core": "^11.1.20",
|
|
178
178
|
"@nestjs/jwt": "^11.0.2",
|
|
179
179
|
"@nestjs/platform-express": "^11.1.20",
|
|
180
|
+
"@nestjs/platform-socket.io": "^11.1.29",
|
|
181
|
+
"@nestjs/platform-ws": "^11.1.29",
|
|
180
182
|
"@nestjs/testing": "^11.1.20",
|
|
181
183
|
"@nestjs/throttler": "^6.5.0",
|
|
182
184
|
"@nestjs/websockets": "^11.1.20",
|
|
183
|
-
"@stryker-mutator/core": "^
|
|
184
|
-
"@stryker-mutator/jest-runner": "^
|
|
185
|
-
"@stryker-mutator/typescript-checker": "^
|
|
186
|
-
"@swc/core": "1.
|
|
185
|
+
"@stryker-mutator/core": "^10.0.0",
|
|
186
|
+
"@stryker-mutator/jest-runner": "^10.0.0",
|
|
187
|
+
"@stryker-mutator/typescript-checker": "^10.0.0",
|
|
188
|
+
"@swc/core": "1.16.0",
|
|
187
189
|
"@testing-library/react": "^16.3.2",
|
|
188
190
|
"@types/express": "^5.0.6",
|
|
189
191
|
"@types/jest": "^30.0.0",
|
|
@@ -191,6 +193,7 @@
|
|
|
191
193
|
"@types/react": "^19.2.14",
|
|
192
194
|
"@types/react-dom": "^19.2.3",
|
|
193
195
|
"@types/supertest": "^7.2.0",
|
|
196
|
+
"@types/ws": "^8.18.1",
|
|
194
197
|
"@typescript-eslint/eslint-plugin": "^8.59.3",
|
|
195
198
|
"@typescript-eslint/parser": "^8.59.3",
|
|
196
199
|
"class-transformer": "^0.5.1",
|
|
@@ -214,11 +217,14 @@
|
|
|
214
217
|
"react": "^19.2.6",
|
|
215
218
|
"react-dom": "^19.2.6",
|
|
216
219
|
"reflect-metadata": "^0.2.2",
|
|
220
|
+
"socket.io": "^4.8.3",
|
|
221
|
+
"socket.io-client": "^4.8.3",
|
|
217
222
|
"supertest": "^7.2.2",
|
|
218
223
|
"ts-jest": "^29.4.9",
|
|
219
224
|
"ts-node": "^10.9.2",
|
|
220
225
|
"tsup": "^8.5.1",
|
|
221
|
-
"typescript": "^5.9.3"
|
|
226
|
+
"typescript": "^5.9.3",
|
|
227
|
+
"ws": "^8.21.3"
|
|
222
228
|
},
|
|
223
229
|
"keywords": [
|
|
224
230
|
"nestjs",
|