@bymax-one/nest-auth 1.4.1 → 1.4.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 +791 -1
- package/README.md +366 -41
- package/dist/client/index.cjs +26 -4
- package/dist/client/index.d.cts +30 -14
- package/dist/client/index.d.ts +30 -14
- package/dist/client/index.mjs +27 -5
- package/dist/server/index.cjs +642 -74
- package/dist/server/index.d.cts +124 -20
- package/dist/server/index.d.ts +124 -20
- package/dist/server/index.mjs +644 -76
- package/dist/shared/index.cjs +62 -10
- package/dist/shared/index.d.cts +112 -5
- package/dist/shared/index.d.ts +112 -5
- package/dist/shared/index.mjs +60 -11
- package/package.json +9 -2
package/dist/shared/index.cjs
CHANGED
|
@@ -19,8 +19,12 @@ var AUTH_ERROR_CODES = {
|
|
|
19
19
|
ACCOUNT_BANNED: "auth.account_banned",
|
|
20
20
|
PENDING_APPROVAL: "auth.pending_approval",
|
|
21
21
|
// Tokens and sessions
|
|
22
|
+
/** Internal-only: expiry. Never on the wire — collapsed onto TOKEN_INVALID, to deny an oracle
|
|
23
|
+
* separating a token that WAS valid from one that never was. */
|
|
22
24
|
TOKEN_EXPIRED: "auth.token_expired",
|
|
25
|
+
/** Internal-only: logout or epoch bump. Never on the wire — see TOKEN_EXPIRED. */
|
|
23
26
|
TOKEN_REVOKED: "auth.token_revoked",
|
|
27
|
+
/** What a client receives for EVERY unusable credential: expired, revoked, malformed, absent. */
|
|
24
28
|
TOKEN_INVALID: "auth.token_invalid",
|
|
25
29
|
/** Internal-only: the request carried no credential. Never on the wire — see TOKEN_INVALID. */
|
|
26
30
|
TOKEN_MISSING: "auth.token_missing",
|
|
@@ -100,6 +104,8 @@ var AUTH_DASHBOARD_ROUTES = {
|
|
|
100
104
|
refresh: "refresh",
|
|
101
105
|
/** GET — return the currently authenticated user. */
|
|
102
106
|
me: "me",
|
|
107
|
+
/** POST — mint a single-use ticket for a WebSocket upgrade. */
|
|
108
|
+
wsTicket: "ws-ticket",
|
|
103
109
|
/** POST — submit the email-verification token returned by the verification email. */
|
|
104
110
|
verifyEmail: "verify-email",
|
|
105
111
|
/** POST — request a fresh email-verification token. */
|
|
@@ -113,13 +119,22 @@ var AUTH_MFA_ROUTES = {
|
|
|
113
119
|
/** POST — exchange an MFA temp token + OTP for a full access token. */
|
|
114
120
|
challenge: "mfa/challenge",
|
|
115
121
|
/** POST — disable MFA after re-authenticating with a fresh OTP. */
|
|
116
|
-
disable: "mfa/disable"
|
|
122
|
+
disable: "mfa/disable",
|
|
123
|
+
/** POST — replace the recovery codes, re-authenticating with a fresh OTP. */
|
|
124
|
+
recoveryCodes: "mfa/recovery-codes"
|
|
117
125
|
};
|
|
118
126
|
var AUTH_PASSWORD_ROUTES = {
|
|
119
127
|
/** POST — request a password reset (email lookup is anti-enumeration). */
|
|
120
128
|
forgotPassword: "password/forgot-password",
|
|
121
129
|
/** POST — submit a new password using the reset token. */
|
|
122
130
|
resetPassword: "password/reset-password",
|
|
131
|
+
/**
|
|
132
|
+
* POST — change the password of the signed-in user, verifying the current one.
|
|
133
|
+
*
|
|
134
|
+
* The only route in this family behind the JWT guard: the rest are reached by a
|
|
135
|
+
* caller who has no session, which is what a reset is for.
|
|
136
|
+
*/
|
|
137
|
+
changePassword: "password/change",
|
|
123
138
|
/** POST — verify the reset OTP (when `passwordReset.method = 'otp'`). */
|
|
124
139
|
verifyOtp: "password/verify-otp",
|
|
125
140
|
/** POST — request a fresh OTP after the previous one expired. */
|
|
@@ -139,11 +154,29 @@ var AUTH_PLATFORM_ROUTES = {
|
|
|
139
154
|
/** DELETE — revoke every active session for the current platform admin. */
|
|
140
155
|
revokeAllSessions: "platform/sessions"
|
|
141
156
|
};
|
|
157
|
+
var AUTH_PLATFORM_MFA_ROUTES = {
|
|
158
|
+
/** POST — begin TOTP enrollment for a platform administrator. */
|
|
159
|
+
setup: "platform/mfa/setup",
|
|
160
|
+
/** POST — confirm enrollment by submitting the first valid code. */
|
|
161
|
+
verifyEnable: "platform/mfa/verify-enable",
|
|
162
|
+
/** POST — disable MFA after re-authenticating with a fresh OTP. */
|
|
163
|
+
disable: "platform/mfa/disable",
|
|
164
|
+
/** POST — replace the recovery codes, re-authenticating with a fresh OTP. */
|
|
165
|
+
recoveryCodes: "platform/mfa/recovery-codes"
|
|
166
|
+
};
|
|
142
167
|
var AUTH_SESSION_ROUTES = {
|
|
143
168
|
/** GET — list every active session for the current user. */
|
|
144
169
|
list: "sessions",
|
|
145
|
-
/**
|
|
146
|
-
|
|
170
|
+
/**
|
|
171
|
+
* POST — revoke every session belonging to the current user except the one
|
|
172
|
+
* making the call.
|
|
173
|
+
*
|
|
174
|
+
* POST rather than DELETE because the refresh token that names the current
|
|
175
|
+
* session travels in the body under `tokenDelivery: 'bearer'`, and OpenAPI 3.0.3
|
|
176
|
+
* defers to RFC 7231: a payload on DELETE has no defined semantics, so a
|
|
177
|
+
* generated client drops it.
|
|
178
|
+
*/
|
|
179
|
+
revokeAll: "sessions/revoke-all",
|
|
147
180
|
/**
|
|
148
181
|
* DELETE — revoke a single session by id. The `:id` placeholder must be
|
|
149
182
|
* substituted with the session identifier before the request is issued.
|
|
@@ -164,14 +197,22 @@ var AUTH_INVITATION_ROUTES = {
|
|
|
164
197
|
/** POST — withdraw a pending invitation before it is accepted (admin-only). */
|
|
165
198
|
revoke: "invitations/revoke"
|
|
166
199
|
};
|
|
200
|
+
var AUTH_OAUTH_ROUTES = {
|
|
201
|
+
/** GET — redirect the browser to the provider's consent screen. */
|
|
202
|
+
initiate: "oauth/:provider",
|
|
203
|
+
/** GET — the provider redirects back here with the authorization code. */
|
|
204
|
+
callback: "oauth/:provider/callback"
|
|
205
|
+
};
|
|
167
206
|
var AUTH_ROUTES = {
|
|
168
207
|
dashboard: AUTH_DASHBOARD_ROUTES,
|
|
169
208
|
mfa: AUTH_MFA_ROUTES,
|
|
170
209
|
password: AUTH_PASSWORD_ROUTES,
|
|
171
210
|
platform: AUTH_PLATFORM_ROUTES,
|
|
211
|
+
platformMfa: AUTH_PLATFORM_MFA_ROUTES,
|
|
172
212
|
sessions: AUTH_SESSION_ROUTES,
|
|
173
213
|
invitations: AUTH_INVITATION_ROUTES,
|
|
174
|
-
emailChange: AUTH_EMAIL_CHANGE_ROUTES
|
|
214
|
+
emailChange: AUTH_EMAIL_CHANGE_ROUTES,
|
|
215
|
+
oauth: AUTH_OAUTH_ROUTES
|
|
175
216
|
};
|
|
176
217
|
var AUTH_PROXY_ROUTES = {
|
|
177
218
|
/** POST — same-domain refresh entry point (server-to-server). */
|
|
@@ -194,22 +235,30 @@ var AUTH_REFRESH_SKIP_CONTROLLER_PATHS = [
|
|
|
194
235
|
"password/reset-password",
|
|
195
236
|
"password/verify-otp",
|
|
196
237
|
"password/resend-otp",
|
|
197
|
-
// MFA
|
|
198
|
-
|
|
199
|
-
|
|
238
|
+
// The MFA challenge issues the session — there is none to refresh. Its siblings
|
|
239
|
+
// (`mfa/setup`, `mfa/verify-enable`, `mfa/disable`) are NOT here: they are JWT-guarded, so a
|
|
240
|
+
// 401 there can be a genuine expiry, and their credential failures are recognised by code.
|
|
200
241
|
"mfa/challenge",
|
|
201
|
-
"mfa/disable",
|
|
202
242
|
// Invitation acceptance issues tokens
|
|
203
243
|
"invitations/accept",
|
|
204
244
|
// The address-change confirmation is public: the holder is proving control of a mailbox,
|
|
205
245
|
// not of a session.
|
|
206
246
|
"email/change/confirm",
|
|
207
|
-
//
|
|
247
|
+
// The platform surface, ALL of it. Every protected route here is JWT-PLATFORM-guarded, so an
|
|
248
|
+
// expired platform token answers `auth.token_invalid` — the code the client reads as "expired"
|
|
249
|
+
// — and a dashboard refresh cannot fix another plane's credential. Listing only some of them
|
|
250
|
+
// left the rest launching a refresh that spends the budget and can call `onSessionExpired` for
|
|
251
|
+
// a dashboard session that is perfectly healthy.
|
|
208
252
|
"platform/login",
|
|
209
253
|
"platform/refresh",
|
|
210
254
|
"platform/logout",
|
|
255
|
+
"platform/me",
|
|
256
|
+
"platform/sessions",
|
|
211
257
|
"platform/mfa/challenge",
|
|
212
|
-
"platform/
|
|
258
|
+
"platform/mfa/setup",
|
|
259
|
+
"platform/mfa/verify-enable",
|
|
260
|
+
"platform/mfa/disable",
|
|
261
|
+
"platform/mfa/recovery-codes"
|
|
213
262
|
];
|
|
214
263
|
var AUTH_REFRESH_SKIP_PROXY_PATHS = [
|
|
215
264
|
"/api/auth/client-refresh",
|
|
@@ -275,11 +324,14 @@ var AuthClientError = class extends Error {
|
|
|
275
324
|
|
|
276
325
|
exports.AUTH_ACCESS_COOKIE_NAME = AUTH_ACCESS_COOKIE_NAME;
|
|
277
326
|
exports.AUTH_DASHBOARD_ROUTES = AUTH_DASHBOARD_ROUTES;
|
|
327
|
+
exports.AUTH_EMAIL_CHANGE_ROUTES = AUTH_EMAIL_CHANGE_ROUTES;
|
|
278
328
|
exports.AUTH_ERROR_CODES = AUTH_ERROR_CODES;
|
|
279
329
|
exports.AUTH_HAS_SESSION_COOKIE_NAME = AUTH_HAS_SESSION_COOKIE_NAME;
|
|
280
330
|
exports.AUTH_INVITATION_ROUTES = AUTH_INVITATION_ROUTES;
|
|
281
331
|
exports.AUTH_MFA_ROUTES = AUTH_MFA_ROUTES;
|
|
332
|
+
exports.AUTH_OAUTH_ROUTES = AUTH_OAUTH_ROUTES;
|
|
282
333
|
exports.AUTH_PASSWORD_ROUTES = AUTH_PASSWORD_ROUTES;
|
|
334
|
+
exports.AUTH_PLATFORM_MFA_ROUTES = AUTH_PLATFORM_MFA_ROUTES;
|
|
283
335
|
exports.AUTH_PLATFORM_ROUTES = AUTH_PLATFORM_ROUTES;
|
|
284
336
|
exports.AUTH_PROXY_ROUTES = AUTH_PROXY_ROUTES;
|
|
285
337
|
exports.AUTH_REFRESH_COOKIE_NAME = AUTH_REFRESH_COOKIE_NAME;
|
package/dist/shared/index.d.cts
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";
|
|
@@ -175,6 +179,8 @@ declare const AUTH_DASHBOARD_ROUTES: {
|
|
|
175
179
|
readonly refresh: "refresh";
|
|
176
180
|
/** GET — return the currently authenticated user. */
|
|
177
181
|
readonly me: "me";
|
|
182
|
+
/** POST — mint a single-use ticket for a WebSocket upgrade. */
|
|
183
|
+
readonly wsTicket: "ws-ticket";
|
|
178
184
|
/** POST — submit the email-verification token returned by the verification email. */
|
|
179
185
|
readonly verifyEmail: "verify-email";
|
|
180
186
|
/** POST — request a fresh email-verification token. */
|
|
@@ -194,6 +200,8 @@ declare const AUTH_MFA_ROUTES: {
|
|
|
194
200
|
readonly challenge: "mfa/challenge";
|
|
195
201
|
/** POST — disable MFA after re-authenticating with a fresh OTP. */
|
|
196
202
|
readonly disable: "mfa/disable";
|
|
203
|
+
/** POST — replace the recovery codes, re-authenticating with a fresh OTP. */
|
|
204
|
+
readonly recoveryCodes: "mfa/recovery-codes";
|
|
197
205
|
};
|
|
198
206
|
/**
|
|
199
207
|
* Password reset routes.
|
|
@@ -206,6 +214,13 @@ declare const AUTH_PASSWORD_ROUTES: {
|
|
|
206
214
|
readonly forgotPassword: "password/forgot-password";
|
|
207
215
|
/** POST — submit a new password using the reset token. */
|
|
208
216
|
readonly resetPassword: "password/reset-password";
|
|
217
|
+
/**
|
|
218
|
+
* POST — change the password of the signed-in user, verifying the current one.
|
|
219
|
+
*
|
|
220
|
+
* The only route in this family behind the JWT guard: the rest are reached by a
|
|
221
|
+
* caller who has no session, which is what a reset is for.
|
|
222
|
+
*/
|
|
223
|
+
readonly changePassword: "password/change";
|
|
209
224
|
/** POST — verify the reset OTP (when `passwordReset.method = 'otp'`). */
|
|
210
225
|
readonly verifyOtp: "password/verify-otp";
|
|
211
226
|
/** POST — request a fresh OTP after the previous one expired. */
|
|
@@ -231,6 +246,31 @@ declare const AUTH_PLATFORM_ROUTES: {
|
|
|
231
246
|
/** DELETE — revoke every active session for the current platform admin. */
|
|
232
247
|
readonly revokeAllSessions: "platform/sessions";
|
|
233
248
|
};
|
|
249
|
+
/**
|
|
250
|
+
* Platform administrator MFA routes (`controllers.platform: true`).
|
|
251
|
+
*
|
|
252
|
+
* Mounted under `platform/mfa/`
|
|
253
|
+
* (`src/server/controllers/platform-mfa.controller.ts`). A separate family because the
|
|
254
|
+
* controller is separate, NOT because the switch is: `controllers.platform: true` mounts
|
|
255
|
+
* `PlatformAuthController` and `PlatformMfaController` together, and there is no
|
|
256
|
+
* `controllers.platformMfa` option to turn one on without the other. The platform plane requires
|
|
257
|
+
* MFA of its administrators, so a deployment that could mount the login surface without the
|
|
258
|
+
* enrollment surface would be one where an operator can be required to present a second factor
|
|
259
|
+
* they have no endpoint to set up.
|
|
260
|
+
*
|
|
261
|
+
* The challenge is NOT here — it belongs to the login flow on `PlatformAuthController`, which is
|
|
262
|
+
* why it sits with the routes that issue credentials rather than with the ones that manage them.
|
|
263
|
+
*/
|
|
264
|
+
declare const AUTH_PLATFORM_MFA_ROUTES: {
|
|
265
|
+
/** POST — begin TOTP enrollment for a platform administrator. */
|
|
266
|
+
readonly setup: "platform/mfa/setup";
|
|
267
|
+
/** POST — confirm enrollment by submitting the first valid code. */
|
|
268
|
+
readonly verifyEnable: "platform/mfa/verify-enable";
|
|
269
|
+
/** POST — disable MFA after re-authenticating with a fresh OTP. */
|
|
270
|
+
readonly disable: "platform/mfa/disable";
|
|
271
|
+
/** POST — replace the recovery codes, re-authenticating with a fresh OTP. */
|
|
272
|
+
readonly recoveryCodes: "platform/mfa/recovery-codes";
|
|
273
|
+
};
|
|
234
274
|
/**
|
|
235
275
|
* Session management routes (`controllers.sessions: true`).
|
|
236
276
|
*
|
|
@@ -240,14 +280,33 @@ declare const AUTH_PLATFORM_ROUTES: {
|
|
|
240
280
|
declare const AUTH_SESSION_ROUTES: {
|
|
241
281
|
/** GET — list every active session for the current user. */
|
|
242
282
|
readonly list: "sessions";
|
|
243
|
-
/**
|
|
244
|
-
|
|
283
|
+
/**
|
|
284
|
+
* POST — revoke every session belonging to the current user except the one
|
|
285
|
+
* making the call.
|
|
286
|
+
*
|
|
287
|
+
* POST rather than DELETE because the refresh token that names the current
|
|
288
|
+
* session travels in the body under `tokenDelivery: 'bearer'`, and OpenAPI 3.0.3
|
|
289
|
+
* defers to RFC 7231: a payload on DELETE has no defined semantics, so a
|
|
290
|
+
* generated client drops it.
|
|
291
|
+
*/
|
|
292
|
+
readonly revokeAll: "sessions/revoke-all";
|
|
245
293
|
/**
|
|
246
294
|
* DELETE — revoke a single session by id. The `:id` placeholder must be
|
|
247
295
|
* substituted with the session identifier before the request is issued.
|
|
248
296
|
*/
|
|
249
297
|
readonly revokeOne: "sessions/:id";
|
|
250
298
|
};
|
|
299
|
+
/**
|
|
300
|
+
* Address-change routes (`controllers.emailChange: true`).
|
|
301
|
+
*
|
|
302
|
+
* Mounted under `email/` (`src/server/controllers/email-change.controller.ts`).
|
|
303
|
+
*/
|
|
304
|
+
declare const AUTH_EMAIL_CHANGE_ROUTES: {
|
|
305
|
+
/** POST — request a change; mails a token to the new address. */
|
|
306
|
+
readonly request: "email/change";
|
|
307
|
+
/** POST — confirm the change with that token. */
|
|
308
|
+
readonly confirm: "email/change/confirm";
|
|
309
|
+
};
|
|
251
310
|
/**
|
|
252
311
|
* Invitation routes (`controllers.invitations: true`).
|
|
253
312
|
*
|
|
@@ -262,6 +321,19 @@ declare const AUTH_INVITATION_ROUTES: {
|
|
|
262
321
|
/** POST — withdraw a pending invitation before it is accepted (admin-only). */
|
|
263
322
|
readonly revoke: "invitations/revoke";
|
|
264
323
|
};
|
|
324
|
+
/**
|
|
325
|
+
* OAuth routes (`oauth.google` configured).
|
|
326
|
+
*
|
|
327
|
+
* Mounted under `oauth/` (`src/server/oauth/oauth.controller.ts`). Both carry a
|
|
328
|
+
* `:provider` segment that must be substituted before the request is issued —
|
|
329
|
+
* `'google'` is the only provider this library implements today.
|
|
330
|
+
*/
|
|
331
|
+
declare const AUTH_OAUTH_ROUTES: {
|
|
332
|
+
/** GET — redirect the browser to the provider's consent screen. */
|
|
333
|
+
readonly initiate: "oauth/:provider";
|
|
334
|
+
/** GET — the provider redirects back here with the authorization code. */
|
|
335
|
+
readonly callback: "oauth/:provider/callback";
|
|
336
|
+
};
|
|
265
337
|
/**
|
|
266
338
|
* Aggregated route map grouped by domain.
|
|
267
339
|
*
|
|
@@ -280,6 +352,8 @@ declare const AUTH_ROUTES: {
|
|
|
280
352
|
readonly refresh: "refresh";
|
|
281
353
|
/** GET — return the currently authenticated user. */
|
|
282
354
|
readonly me: "me";
|
|
355
|
+
/** POST — mint a single-use ticket for a WebSocket upgrade. */
|
|
356
|
+
readonly wsTicket: "ws-ticket";
|
|
283
357
|
/** POST — submit the email-verification token returned by the verification email. */
|
|
284
358
|
readonly verifyEmail: "verify-email";
|
|
285
359
|
/** POST — request a fresh email-verification token. */
|
|
@@ -294,12 +368,21 @@ declare const AUTH_ROUTES: {
|
|
|
294
368
|
readonly challenge: "mfa/challenge";
|
|
295
369
|
/** POST — disable MFA after re-authenticating with a fresh OTP. */
|
|
296
370
|
readonly disable: "mfa/disable";
|
|
371
|
+
/** POST — replace the recovery codes, re-authenticating with a fresh OTP. */
|
|
372
|
+
readonly recoveryCodes: "mfa/recovery-codes";
|
|
297
373
|
};
|
|
298
374
|
readonly password: {
|
|
299
375
|
/** POST — request a password reset (email lookup is anti-enumeration). */
|
|
300
376
|
readonly forgotPassword: "password/forgot-password";
|
|
301
377
|
/** POST — submit a new password using the reset token. */
|
|
302
378
|
readonly resetPassword: "password/reset-password";
|
|
379
|
+
/**
|
|
380
|
+
* POST — change the password of the signed-in user, verifying the current one.
|
|
381
|
+
*
|
|
382
|
+
* The only route in this family behind the JWT guard: the rest are reached by a
|
|
383
|
+
* caller who has no session, which is what a reset is for.
|
|
384
|
+
*/
|
|
385
|
+
readonly changePassword: "password/change";
|
|
303
386
|
/** POST — verify the reset OTP (when `passwordReset.method = 'otp'`). */
|
|
304
387
|
readonly verifyOtp: "password/verify-otp";
|
|
305
388
|
/** POST — request a fresh OTP after the previous one expired. */
|
|
@@ -319,11 +402,29 @@ declare const AUTH_ROUTES: {
|
|
|
319
402
|
/** DELETE — revoke every active session for the current platform admin. */
|
|
320
403
|
readonly revokeAllSessions: "platform/sessions";
|
|
321
404
|
};
|
|
405
|
+
readonly platformMfa: {
|
|
406
|
+
/** POST — begin TOTP enrollment for a platform administrator. */
|
|
407
|
+
readonly setup: "platform/mfa/setup";
|
|
408
|
+
/** POST — confirm enrollment by submitting the first valid code. */
|
|
409
|
+
readonly verifyEnable: "platform/mfa/verify-enable";
|
|
410
|
+
/** POST — disable MFA after re-authenticating with a fresh OTP. */
|
|
411
|
+
readonly disable: "platform/mfa/disable";
|
|
412
|
+
/** POST — replace the recovery codes, re-authenticating with a fresh OTP. */
|
|
413
|
+
readonly recoveryCodes: "platform/mfa/recovery-codes";
|
|
414
|
+
};
|
|
322
415
|
readonly sessions: {
|
|
323
416
|
/** GET — list every active session for the current user. */
|
|
324
417
|
readonly list: "sessions";
|
|
325
|
-
/**
|
|
326
|
-
|
|
418
|
+
/**
|
|
419
|
+
* POST — revoke every session belonging to the current user except the one
|
|
420
|
+
* making the call.
|
|
421
|
+
*
|
|
422
|
+
* POST rather than DELETE because the refresh token that names the current
|
|
423
|
+
* session travels in the body under `tokenDelivery: 'bearer'`, and OpenAPI 3.0.3
|
|
424
|
+
* defers to RFC 7231: a payload on DELETE has no defined semantics, so a
|
|
425
|
+
* generated client drops it.
|
|
426
|
+
*/
|
|
427
|
+
readonly revokeAll: "sessions/revoke-all";
|
|
327
428
|
/**
|
|
328
429
|
* DELETE — revoke a single session by id. The `:id` placeholder must be
|
|
329
430
|
* substituted with the session identifier before the request is issued.
|
|
@@ -344,6 +445,12 @@ declare const AUTH_ROUTES: {
|
|
|
344
445
|
/** POST — confirm the change with that token. */
|
|
345
446
|
readonly confirm: "email/change/confirm";
|
|
346
447
|
};
|
|
448
|
+
readonly oauth: {
|
|
449
|
+
/** GET — redirect the browser to the provider's consent screen. */
|
|
450
|
+
readonly initiate: "oauth/:provider";
|
|
451
|
+
/** GET — the provider redirects back here with the authorization code. */
|
|
452
|
+
readonly callback: "oauth/:provider/callback";
|
|
453
|
+
};
|
|
347
454
|
};
|
|
348
455
|
/**
|
|
349
456
|
* Default Next.js proxy endpoints used by `createAuthClient` and the
|
|
@@ -849,4 +956,4 @@ type AuthContextKind = 'dashboard' | 'platform';
|
|
|
849
956
|
*/
|
|
850
957
|
type TokenDeliveryMode = 'cookie' | 'bearer';
|
|
851
958
|
|
|
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 };
|
|
959
|
+
export { AUTH_ACCESS_COOKIE_NAME, AUTH_DASHBOARD_ROUTES, AUTH_EMAIL_CHANGE_ROUTES, AUTH_ERROR_CODES, 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.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";
|
|
@@ -175,6 +179,8 @@ declare const AUTH_DASHBOARD_ROUTES: {
|
|
|
175
179
|
readonly refresh: "refresh";
|
|
176
180
|
/** GET — return the currently authenticated user. */
|
|
177
181
|
readonly me: "me";
|
|
182
|
+
/** POST — mint a single-use ticket for a WebSocket upgrade. */
|
|
183
|
+
readonly wsTicket: "ws-ticket";
|
|
178
184
|
/** POST — submit the email-verification token returned by the verification email. */
|
|
179
185
|
readonly verifyEmail: "verify-email";
|
|
180
186
|
/** POST — request a fresh email-verification token. */
|
|
@@ -194,6 +200,8 @@ declare const AUTH_MFA_ROUTES: {
|
|
|
194
200
|
readonly challenge: "mfa/challenge";
|
|
195
201
|
/** POST — disable MFA after re-authenticating with a fresh OTP. */
|
|
196
202
|
readonly disable: "mfa/disable";
|
|
203
|
+
/** POST — replace the recovery codes, re-authenticating with a fresh OTP. */
|
|
204
|
+
readonly recoveryCodes: "mfa/recovery-codes";
|
|
197
205
|
};
|
|
198
206
|
/**
|
|
199
207
|
* Password reset routes.
|
|
@@ -206,6 +214,13 @@ declare const AUTH_PASSWORD_ROUTES: {
|
|
|
206
214
|
readonly forgotPassword: "password/forgot-password";
|
|
207
215
|
/** POST — submit a new password using the reset token. */
|
|
208
216
|
readonly resetPassword: "password/reset-password";
|
|
217
|
+
/**
|
|
218
|
+
* POST — change the password of the signed-in user, verifying the current one.
|
|
219
|
+
*
|
|
220
|
+
* The only route in this family behind the JWT guard: the rest are reached by a
|
|
221
|
+
* caller who has no session, which is what a reset is for.
|
|
222
|
+
*/
|
|
223
|
+
readonly changePassword: "password/change";
|
|
209
224
|
/** POST — verify the reset OTP (when `passwordReset.method = 'otp'`). */
|
|
210
225
|
readonly verifyOtp: "password/verify-otp";
|
|
211
226
|
/** POST — request a fresh OTP after the previous one expired. */
|
|
@@ -231,6 +246,31 @@ declare const AUTH_PLATFORM_ROUTES: {
|
|
|
231
246
|
/** DELETE — revoke every active session for the current platform admin. */
|
|
232
247
|
readonly revokeAllSessions: "platform/sessions";
|
|
233
248
|
};
|
|
249
|
+
/**
|
|
250
|
+
* Platform administrator MFA routes (`controllers.platform: true`).
|
|
251
|
+
*
|
|
252
|
+
* Mounted under `platform/mfa/`
|
|
253
|
+
* (`src/server/controllers/platform-mfa.controller.ts`). A separate family because the
|
|
254
|
+
* controller is separate, NOT because the switch is: `controllers.platform: true` mounts
|
|
255
|
+
* `PlatformAuthController` and `PlatformMfaController` together, and there is no
|
|
256
|
+
* `controllers.platformMfa` option to turn one on without the other. The platform plane requires
|
|
257
|
+
* MFA of its administrators, so a deployment that could mount the login surface without the
|
|
258
|
+
* enrollment surface would be one where an operator can be required to present a second factor
|
|
259
|
+
* they have no endpoint to set up.
|
|
260
|
+
*
|
|
261
|
+
* The challenge is NOT here — it belongs to the login flow on `PlatformAuthController`, which is
|
|
262
|
+
* why it sits with the routes that issue credentials rather than with the ones that manage them.
|
|
263
|
+
*/
|
|
264
|
+
declare const AUTH_PLATFORM_MFA_ROUTES: {
|
|
265
|
+
/** POST — begin TOTP enrollment for a platform administrator. */
|
|
266
|
+
readonly setup: "platform/mfa/setup";
|
|
267
|
+
/** POST — confirm enrollment by submitting the first valid code. */
|
|
268
|
+
readonly verifyEnable: "platform/mfa/verify-enable";
|
|
269
|
+
/** POST — disable MFA after re-authenticating with a fresh OTP. */
|
|
270
|
+
readonly disable: "platform/mfa/disable";
|
|
271
|
+
/** POST — replace the recovery codes, re-authenticating with a fresh OTP. */
|
|
272
|
+
readonly recoveryCodes: "platform/mfa/recovery-codes";
|
|
273
|
+
};
|
|
234
274
|
/**
|
|
235
275
|
* Session management routes (`controllers.sessions: true`).
|
|
236
276
|
*
|
|
@@ -240,14 +280,33 @@ declare const AUTH_PLATFORM_ROUTES: {
|
|
|
240
280
|
declare const AUTH_SESSION_ROUTES: {
|
|
241
281
|
/** GET — list every active session for the current user. */
|
|
242
282
|
readonly list: "sessions";
|
|
243
|
-
/**
|
|
244
|
-
|
|
283
|
+
/**
|
|
284
|
+
* POST — revoke every session belonging to the current user except the one
|
|
285
|
+
* making the call.
|
|
286
|
+
*
|
|
287
|
+
* POST rather than DELETE because the refresh token that names the current
|
|
288
|
+
* session travels in the body under `tokenDelivery: 'bearer'`, and OpenAPI 3.0.3
|
|
289
|
+
* defers to RFC 7231: a payload on DELETE has no defined semantics, so a
|
|
290
|
+
* generated client drops it.
|
|
291
|
+
*/
|
|
292
|
+
readonly revokeAll: "sessions/revoke-all";
|
|
245
293
|
/**
|
|
246
294
|
* DELETE — revoke a single session by id. The `:id` placeholder must be
|
|
247
295
|
* substituted with the session identifier before the request is issued.
|
|
248
296
|
*/
|
|
249
297
|
readonly revokeOne: "sessions/:id";
|
|
250
298
|
};
|
|
299
|
+
/**
|
|
300
|
+
* Address-change routes (`controllers.emailChange: true`).
|
|
301
|
+
*
|
|
302
|
+
* Mounted under `email/` (`src/server/controllers/email-change.controller.ts`).
|
|
303
|
+
*/
|
|
304
|
+
declare const AUTH_EMAIL_CHANGE_ROUTES: {
|
|
305
|
+
/** POST — request a change; mails a token to the new address. */
|
|
306
|
+
readonly request: "email/change";
|
|
307
|
+
/** POST — confirm the change with that token. */
|
|
308
|
+
readonly confirm: "email/change/confirm";
|
|
309
|
+
};
|
|
251
310
|
/**
|
|
252
311
|
* Invitation routes (`controllers.invitations: true`).
|
|
253
312
|
*
|
|
@@ -262,6 +321,19 @@ declare const AUTH_INVITATION_ROUTES: {
|
|
|
262
321
|
/** POST — withdraw a pending invitation before it is accepted (admin-only). */
|
|
263
322
|
readonly revoke: "invitations/revoke";
|
|
264
323
|
};
|
|
324
|
+
/**
|
|
325
|
+
* OAuth routes (`oauth.google` configured).
|
|
326
|
+
*
|
|
327
|
+
* Mounted under `oauth/` (`src/server/oauth/oauth.controller.ts`). Both carry a
|
|
328
|
+
* `:provider` segment that must be substituted before the request is issued —
|
|
329
|
+
* `'google'` is the only provider this library implements today.
|
|
330
|
+
*/
|
|
331
|
+
declare const AUTH_OAUTH_ROUTES: {
|
|
332
|
+
/** GET — redirect the browser to the provider's consent screen. */
|
|
333
|
+
readonly initiate: "oauth/:provider";
|
|
334
|
+
/** GET — the provider redirects back here with the authorization code. */
|
|
335
|
+
readonly callback: "oauth/:provider/callback";
|
|
336
|
+
};
|
|
265
337
|
/**
|
|
266
338
|
* Aggregated route map grouped by domain.
|
|
267
339
|
*
|
|
@@ -280,6 +352,8 @@ declare const AUTH_ROUTES: {
|
|
|
280
352
|
readonly refresh: "refresh";
|
|
281
353
|
/** GET — return the currently authenticated user. */
|
|
282
354
|
readonly me: "me";
|
|
355
|
+
/** POST — mint a single-use ticket for a WebSocket upgrade. */
|
|
356
|
+
readonly wsTicket: "ws-ticket";
|
|
283
357
|
/** POST — submit the email-verification token returned by the verification email. */
|
|
284
358
|
readonly verifyEmail: "verify-email";
|
|
285
359
|
/** POST — request a fresh email-verification token. */
|
|
@@ -294,12 +368,21 @@ declare const AUTH_ROUTES: {
|
|
|
294
368
|
readonly challenge: "mfa/challenge";
|
|
295
369
|
/** POST — disable MFA after re-authenticating with a fresh OTP. */
|
|
296
370
|
readonly disable: "mfa/disable";
|
|
371
|
+
/** POST — replace the recovery codes, re-authenticating with a fresh OTP. */
|
|
372
|
+
readonly recoveryCodes: "mfa/recovery-codes";
|
|
297
373
|
};
|
|
298
374
|
readonly password: {
|
|
299
375
|
/** POST — request a password reset (email lookup is anti-enumeration). */
|
|
300
376
|
readonly forgotPassword: "password/forgot-password";
|
|
301
377
|
/** POST — submit a new password using the reset token. */
|
|
302
378
|
readonly resetPassword: "password/reset-password";
|
|
379
|
+
/**
|
|
380
|
+
* POST — change the password of the signed-in user, verifying the current one.
|
|
381
|
+
*
|
|
382
|
+
* The only route in this family behind the JWT guard: the rest are reached by a
|
|
383
|
+
* caller who has no session, which is what a reset is for.
|
|
384
|
+
*/
|
|
385
|
+
readonly changePassword: "password/change";
|
|
303
386
|
/** POST — verify the reset OTP (when `passwordReset.method = 'otp'`). */
|
|
304
387
|
readonly verifyOtp: "password/verify-otp";
|
|
305
388
|
/** POST — request a fresh OTP after the previous one expired. */
|
|
@@ -319,11 +402,29 @@ declare const AUTH_ROUTES: {
|
|
|
319
402
|
/** DELETE — revoke every active session for the current platform admin. */
|
|
320
403
|
readonly revokeAllSessions: "platform/sessions";
|
|
321
404
|
};
|
|
405
|
+
readonly platformMfa: {
|
|
406
|
+
/** POST — begin TOTP enrollment for a platform administrator. */
|
|
407
|
+
readonly setup: "platform/mfa/setup";
|
|
408
|
+
/** POST — confirm enrollment by submitting the first valid code. */
|
|
409
|
+
readonly verifyEnable: "platform/mfa/verify-enable";
|
|
410
|
+
/** POST — disable MFA after re-authenticating with a fresh OTP. */
|
|
411
|
+
readonly disable: "platform/mfa/disable";
|
|
412
|
+
/** POST — replace the recovery codes, re-authenticating with a fresh OTP. */
|
|
413
|
+
readonly recoveryCodes: "platform/mfa/recovery-codes";
|
|
414
|
+
};
|
|
322
415
|
readonly sessions: {
|
|
323
416
|
/** GET — list every active session for the current user. */
|
|
324
417
|
readonly list: "sessions";
|
|
325
|
-
/**
|
|
326
|
-
|
|
418
|
+
/**
|
|
419
|
+
* POST — revoke every session belonging to the current user except the one
|
|
420
|
+
* making the call.
|
|
421
|
+
*
|
|
422
|
+
* POST rather than DELETE because the refresh token that names the current
|
|
423
|
+
* session travels in the body under `tokenDelivery: 'bearer'`, and OpenAPI 3.0.3
|
|
424
|
+
* defers to RFC 7231: a payload on DELETE has no defined semantics, so a
|
|
425
|
+
* generated client drops it.
|
|
426
|
+
*/
|
|
427
|
+
readonly revokeAll: "sessions/revoke-all";
|
|
327
428
|
/**
|
|
328
429
|
* DELETE — revoke a single session by id. The `:id` placeholder must be
|
|
329
430
|
* substituted with the session identifier before the request is issued.
|
|
@@ -344,6 +445,12 @@ declare const AUTH_ROUTES: {
|
|
|
344
445
|
/** POST — confirm the change with that token. */
|
|
345
446
|
readonly confirm: "email/change/confirm";
|
|
346
447
|
};
|
|
448
|
+
readonly oauth: {
|
|
449
|
+
/** GET — redirect the browser to the provider's consent screen. */
|
|
450
|
+
readonly initiate: "oauth/:provider";
|
|
451
|
+
/** GET — the provider redirects back here with the authorization code. */
|
|
452
|
+
readonly callback: "oauth/:provider/callback";
|
|
453
|
+
};
|
|
347
454
|
};
|
|
348
455
|
/**
|
|
349
456
|
* Default Next.js proxy endpoints used by `createAuthClient` and the
|
|
@@ -849,4 +956,4 @@ type AuthContextKind = 'dashboard' | 'platform';
|
|
|
849
956
|
*/
|
|
850
957
|
type TokenDeliveryMode = 'cookie' | 'bearer';
|
|
851
958
|
|
|
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 };
|
|
959
|
+
export { AUTH_ACCESS_COOKIE_NAME, AUTH_DASHBOARD_ROUTES, AUTH_EMAIL_CHANGE_ROUTES, AUTH_ERROR_CODES, 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 };
|