najm-auth 1.1.44 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +765 -664
- package/dist/{NajmAuthClient-D08--i69.d.ts → NajmAuthClient-B9dGk9MH.d.ts} +12 -1
- package/dist/client/index.d.ts +2 -2
- package/dist/client/index.js +50 -1
- package/dist/client/react/index.d.ts +41 -2
- package/dist/client/react/index.js +129 -5
- package/dist/client/server/index.d.ts +1 -1
- package/dist/client/server/index.js +49 -0
- package/dist/index.d.ts +171 -14
- package/dist/index.js +1470 -589
- package/dist/schema/pg.d.ts +222 -1
- package/dist/schema/pg.js +13 -1
- package/dist/schema/sqlite.d.ts +246 -1
- package/dist/schema/sqlite.js +12 -0
- package/package.json +13 -10
package/dist/index.d.ts
CHANGED
|
@@ -2,11 +2,11 @@ import * as najm_core from 'najm-core';
|
|
|
2
2
|
import { Container } from 'najm-core';
|
|
3
3
|
import { ValidationPluginConfig } from 'najm-validation';
|
|
4
4
|
import { RateLimitPluginConfig } from 'najm-rate';
|
|
5
|
+
import { EmailPluginConfig, EmailService } from 'najm-email';
|
|
5
6
|
import { I18nService } from 'najm-i18n';
|
|
6
|
-
import { EmailService } from 'najm-email';
|
|
7
7
|
import { TDb, SeedEntry } from 'najm-database';
|
|
8
8
|
import { User, NewUser, RoleEntity, NewRoleEntity, Permission, NewPermission, RolePermission } from './schema/pg.js';
|
|
9
|
-
export { NewRolePermission, NewToken, Token, authSchema, baseFields, permissionsTable, rolePermissionsTable, rolesTable, tokenStatusEnum, tokenTypeEnum, tokensTable, userStatusEnum, usersTable } from './schema/pg.js';
|
|
9
|
+
export { NewOAuthAccount, NewRolePermission, NewToken, OAuthAccount, Token, authSchema, baseFields, oauthAccountsTable, permissionsTable, rolePermissionsTable, rolesTable, tokenStatusEnum, tokenTypeEnum, tokensTable, userStatusEnum, usersTable } from './schema/pg.js';
|
|
10
10
|
import { CacheService } from 'najm-cache';
|
|
11
11
|
import { z } from 'zod';
|
|
12
12
|
import { GuardResult } from 'najm-guard';
|
|
@@ -45,6 +45,48 @@ interface SessionCookieConfig {
|
|
|
45
45
|
/** Secret used to HMAC-sign the cookie. Defaults to jwt.accessSecret. */
|
|
46
46
|
secret?: string;
|
|
47
47
|
}
|
|
48
|
+
type OAuthProvider = 'google';
|
|
49
|
+
interface GoogleOAuthConfig {
|
|
50
|
+
/** Google OAuth web client ID. Falls back to GOOGLE_CLIENT_ID. */
|
|
51
|
+
clientId?: string;
|
|
52
|
+
/** Google OAuth web client secret. Falls back to GOOGLE_CLIENT_SECRET. */
|
|
53
|
+
clientSecret?: string;
|
|
54
|
+
/**
|
|
55
|
+
* Absolute backend callback URL registered in Google Cloud. Falls back to
|
|
56
|
+
* GOOGLE_CALLBACK_URL, then `${frontendUrl}/api/auth/oauth/google/callback`.
|
|
57
|
+
*/
|
|
58
|
+
callbackUrl?: string;
|
|
59
|
+
/** Frontend route that completes the Najm client session. */
|
|
60
|
+
frontendCallbackPath?: string;
|
|
61
|
+
/** Frontend route that receives stable OAuth errors. */
|
|
62
|
+
errorRedirectPath?: string;
|
|
63
|
+
/** Create a Najm user for a new Google identity (default: true). */
|
|
64
|
+
allowSignup?: boolean;
|
|
65
|
+
/** Link an existing user by verified email (default: false). */
|
|
66
|
+
autoLinkVerifiedEmail?: boolean;
|
|
67
|
+
/** Optional Google Workspace hosted-domain allowlist. */
|
|
68
|
+
allowedHostedDomains?: string[];
|
|
69
|
+
}
|
|
70
|
+
interface OAuthConfig {
|
|
71
|
+
/**
|
|
72
|
+
* Enable Google with environment defaults (`google: true`), or override
|
|
73
|
+
* individual settings for split-origin deployments and policy changes.
|
|
74
|
+
*/
|
|
75
|
+
google?: true | GoogleOAuthConfig;
|
|
76
|
+
}
|
|
77
|
+
interface ResolvedGoogleOAuthConfig {
|
|
78
|
+
clientId: string;
|
|
79
|
+
clientSecret: string;
|
|
80
|
+
callbackUrl: string;
|
|
81
|
+
frontendCallbackPath: string;
|
|
82
|
+
errorRedirectPath: string;
|
|
83
|
+
allowSignup: boolean;
|
|
84
|
+
autoLinkVerifiedEmail: boolean;
|
|
85
|
+
allowedHostedDomains: string[];
|
|
86
|
+
}
|
|
87
|
+
interface ResolvedOAuthConfig {
|
|
88
|
+
google?: ResolvedGoogleOAuthConfig;
|
|
89
|
+
}
|
|
48
90
|
/**
|
|
49
91
|
* Complete auth plugin configuration (internal)
|
|
50
92
|
*/
|
|
@@ -63,12 +105,18 @@ interface AuthConfig {
|
|
|
63
105
|
frontendUrl: string;
|
|
64
106
|
/** Registration mode: 'active' auto-activates, 'pending' requires admin approval (default: 'active') */
|
|
65
107
|
registrationMode: 'active' | 'pending';
|
|
108
|
+
/** When true, users with emailVerified=false are blocked from logging in (default: false) */
|
|
109
|
+
requireVerifiedEmail: boolean;
|
|
110
|
+
/** Cookie path for the refresh token. Scope to the refresh endpoint to limit exposure (default: '/') */
|
|
111
|
+
refreshCookiePath: string;
|
|
66
112
|
/** Per-account lockout settings */
|
|
67
113
|
lockout: LockoutConfig;
|
|
68
114
|
/** Bcrypt work factor (default: 10) */
|
|
69
115
|
bcryptRounds: number;
|
|
70
116
|
/** Session cookie cache settings */
|
|
71
117
|
session: SessionCookieConfig;
|
|
118
|
+
/** Resolved external identity-provider configuration. */
|
|
119
|
+
oauth?: ResolvedOAuthConfig;
|
|
72
120
|
}
|
|
73
121
|
/**
|
|
74
122
|
* Auth plugin configuration options
|
|
@@ -84,6 +132,8 @@ interface AuthSchema {
|
|
|
84
132
|
roles: any;
|
|
85
133
|
permissions: any;
|
|
86
134
|
rolePermissions: any;
|
|
135
|
+
/** Required when an OAuth provider is enabled. */
|
|
136
|
+
oauthAccounts?: any;
|
|
87
137
|
}
|
|
88
138
|
type AuthPluginConfig = {
|
|
89
139
|
/**
|
|
@@ -112,6 +162,10 @@ type AuthPluginConfig = {
|
|
|
112
162
|
frontendUrl?: string;
|
|
113
163
|
/** Registration mode: 'active' auto-activates new users, 'pending' requires admin approval (default: 'active') */
|
|
114
164
|
registrationMode?: 'active' | 'pending';
|
|
165
|
+
/** Block login for users whose email is not verified (default: false) */
|
|
166
|
+
requireVerifiedEmail?: boolean;
|
|
167
|
+
/** Cookie path for the refresh token (default: '/'). Set e.g. '/auth' to keep it off unrelated routes. */
|
|
168
|
+
refreshCookiePath?: string;
|
|
115
169
|
/** Per-account lockout settings */
|
|
116
170
|
lockout?: Partial<LockoutConfig>;
|
|
117
171
|
/** Bcrypt work factor (default: 10, valid range: 4-31) */
|
|
@@ -122,8 +176,12 @@ type AuthPluginConfig = {
|
|
|
122
176
|
validation?: ValidationPluginConfig;
|
|
123
177
|
/** Optional config forwarded to rateLimit() dependency */
|
|
124
178
|
rateLimit?: RateLimitPluginConfig;
|
|
179
|
+
/** Email transport used by password reset and verification flows. */
|
|
180
|
+
email?: EmailPluginConfig;
|
|
125
181
|
/** AES-256-GCM key for reversible encryption (e.g. API keys). Falls back to NAJM_ENCRYPTION_KEY env var. */
|
|
126
182
|
encryptionKey?: string;
|
|
183
|
+
/** External identity providers. */
|
|
184
|
+
oauth?: OAuthConfig;
|
|
127
185
|
};
|
|
128
186
|
/**
|
|
129
187
|
* JWT payload structure
|
|
@@ -199,7 +257,18 @@ var auth = {
|
|
|
199
257
|
unauthorized: "Unauthorized access",
|
|
200
258
|
sessionExpired: "Session has expired",
|
|
201
259
|
accountLocked: "Account is temporarily locked. Please try again later.",
|
|
202
|
-
accountInactive: "Account is inactive. Please contact support."
|
|
260
|
+
accountInactive: "Account is inactive. Please contact support.",
|
|
261
|
+
emailNotVerified: "Please verify your email address before signing in.",
|
|
262
|
+
oauthProviderDisabled: "Google sign-in is not configured.",
|
|
263
|
+
oauthStateInvalid: "The Google sign-in attempt is invalid or expired.",
|
|
264
|
+
oauthAccessDenied: "Google sign-in was cancelled.",
|
|
265
|
+
oauthProviderError: "Google sign-in could not be completed.",
|
|
266
|
+
oauthVerifiedEmailRequired: "Google must provide a verified email address.",
|
|
267
|
+
oauthAccountLinkRequired: "Sign in with your password and link Google from your account.",
|
|
268
|
+
oauthProviderAccountLinked: "This Google account is already linked.",
|
|
269
|
+
oauthSignupDisabled: "Registration with Google is disabled.",
|
|
270
|
+
oauthHostedDomainDenied: "This Google Workspace domain is not allowed.",
|
|
271
|
+
oauthLinkSessionExpired: "Your session changed before Google could be linked. Please try again."
|
|
203
272
|
},
|
|
204
273
|
success: {
|
|
205
274
|
login: "Login successful",
|
|
@@ -209,7 +278,9 @@ var auth = {
|
|
|
209
278
|
passwordResetSent: "If that email exists, a reset link has been sent",
|
|
210
279
|
passwordReset: "Password has been reset successfully",
|
|
211
280
|
accountInviteSent: "Invitation sent successfully",
|
|
212
|
-
tokenRefreshed: "Token refreshed successfully"
|
|
281
|
+
tokenRefreshed: "Token refreshed successfully",
|
|
282
|
+
oauthLogin: "Google sign-in successful",
|
|
283
|
+
oauthLinked: "Google account linked successfully"
|
|
213
284
|
},
|
|
214
285
|
emails: {
|
|
215
286
|
passwordReset: {
|
|
@@ -242,7 +313,9 @@ var roles = {
|
|
|
242
313
|
notFound: "Role not found",
|
|
243
314
|
exists: "Role already exists",
|
|
244
315
|
nameRequired: "Role name is required",
|
|
245
|
-
cannotDeleteSystem: "Cannot delete system role"
|
|
316
|
+
cannotDeleteSystem: "Cannot delete system role",
|
|
317
|
+
cannotRenameSystem: "Cannot rename the system admin role",
|
|
318
|
+
roleInUse: "Cannot delete a role that is assigned to users"
|
|
246
319
|
},
|
|
247
320
|
success: {
|
|
248
321
|
created: "Role created successfully",
|
|
@@ -302,6 +375,17 @@ declare const AUTH_LOCALES: {
|
|
|
302
375
|
sessionExpired: string;
|
|
303
376
|
accountLocked: string;
|
|
304
377
|
accountInactive: string;
|
|
378
|
+
emailNotVerified: string;
|
|
379
|
+
oauthProviderDisabled: string;
|
|
380
|
+
oauthStateInvalid: string;
|
|
381
|
+
oauthAccessDenied: string;
|
|
382
|
+
oauthProviderError: string;
|
|
383
|
+
oauthVerifiedEmailRequired: string;
|
|
384
|
+
oauthAccountLinkRequired: string;
|
|
385
|
+
oauthProviderAccountLinked: string;
|
|
386
|
+
oauthSignupDisabled: string;
|
|
387
|
+
oauthHostedDomainDenied: string;
|
|
388
|
+
oauthLinkSessionExpired: string;
|
|
305
389
|
};
|
|
306
390
|
success: {
|
|
307
391
|
login: string;
|
|
@@ -312,6 +396,8 @@ declare const AUTH_LOCALES: {
|
|
|
312
396
|
passwordReset: string;
|
|
313
397
|
accountInviteSent: string;
|
|
314
398
|
tokenRefreshed: string;
|
|
399
|
+
oauthLogin: string;
|
|
400
|
+
oauthLinked: string;
|
|
315
401
|
};
|
|
316
402
|
emails: {
|
|
317
403
|
passwordReset: {
|
|
@@ -345,6 +431,8 @@ declare const AUTH_LOCALES: {
|
|
|
345
431
|
exists: string;
|
|
346
432
|
nameRequired: string;
|
|
347
433
|
cannotDeleteSystem: string;
|
|
434
|
+
cannotRenameSystem: string;
|
|
435
|
+
roleInUse: string;
|
|
348
436
|
};
|
|
349
437
|
success: {
|
|
350
438
|
created: string;
|
|
@@ -406,6 +494,12 @@ interface SessionCookieData {
|
|
|
406
494
|
};
|
|
407
495
|
roles: string[];
|
|
408
496
|
permissions: string[];
|
|
497
|
+
/**
|
|
498
|
+
* Per-user session version captured when the cookie was written. Lets the
|
|
499
|
+
* fast-path reader reject a cookie whose session has since been invalidated
|
|
500
|
+
* (password change/reset, logout-all) without hitting the database.
|
|
501
|
+
*/
|
|
502
|
+
sessionVersion: number;
|
|
409
503
|
/** Epoch ms when the cookie was written */
|
|
410
504
|
iat: number;
|
|
411
505
|
}
|
|
@@ -413,6 +507,7 @@ declare class CookieManager {
|
|
|
413
507
|
private config;
|
|
414
508
|
private cookieService;
|
|
415
509
|
private get cookieName();
|
|
510
|
+
private get refreshCookiePath();
|
|
416
511
|
private get sessionCookieName();
|
|
417
512
|
private get sessionMaxAge();
|
|
418
513
|
private get sessionSecret();
|
|
@@ -457,6 +552,9 @@ declare class UserRepository {
|
|
|
457
552
|
getByEmail(email: string): Promise<(User & {
|
|
458
553
|
role?: string | null;
|
|
459
554
|
}) | undefined>;
|
|
555
|
+
getByEmailInsensitive(email: string): Promise<(User & {
|
|
556
|
+
role?: string | null;
|
|
557
|
+
}) | undefined>;
|
|
460
558
|
create(data: NewUser): Promise<User>;
|
|
461
559
|
update(id: string, data: Partial<NewUser>): Promise<User | undefined>;
|
|
462
560
|
updateLastLogin(id: string): Promise<User>;
|
|
@@ -565,6 +663,9 @@ declare class RoleRepository {
|
|
|
565
663
|
db: TDb;
|
|
566
664
|
private schema;
|
|
567
665
|
private get roles();
|
|
666
|
+
private get users();
|
|
667
|
+
/** True if any user currently references this role (blocks deletion). */
|
|
668
|
+
hasUsers(roleId: string): Promise<boolean>;
|
|
568
669
|
getAll(): Promise<RoleEntity[]>;
|
|
569
670
|
getById(id: string): Promise<RoleEntity | undefined>;
|
|
570
671
|
getByName(name: string): Promise<RoleEntity | undefined>;
|
|
@@ -625,6 +726,7 @@ declare class RoleValidator {
|
|
|
625
726
|
declare class RoleService {
|
|
626
727
|
private roleRepository;
|
|
627
728
|
private roleValidator;
|
|
729
|
+
private t;
|
|
628
730
|
constructor(roleRepository: RoleRepository, roleValidator: RoleValidator);
|
|
629
731
|
getAll(): Promise<{
|
|
630
732
|
id: string;
|
|
@@ -654,14 +756,17 @@ declare class RoleService {
|
|
|
654
756
|
createdAt: string;
|
|
655
757
|
updatedAt: string;
|
|
656
758
|
}>;
|
|
657
|
-
update(id:
|
|
759
|
+
update(id: string, data: {
|
|
760
|
+
name?: string;
|
|
761
|
+
description?: string;
|
|
762
|
+
}): Promise<{
|
|
658
763
|
id: string;
|
|
659
764
|
name: string;
|
|
660
765
|
description: string;
|
|
661
766
|
createdAt: string;
|
|
662
767
|
updatedAt: string;
|
|
663
768
|
}>;
|
|
664
|
-
delete(id:
|
|
769
|
+
delete(id: string): Promise<{
|
|
665
770
|
id: string;
|
|
666
771
|
name: string;
|
|
667
772
|
description: string;
|
|
@@ -709,6 +814,9 @@ declare class UserService {
|
|
|
709
814
|
findByEmail(email: string): Promise<(User & {
|
|
710
815
|
role?: string | null;
|
|
711
816
|
}) | undefined>;
|
|
817
|
+
findByEmailInsensitive(email: string): Promise<(User & {
|
|
818
|
+
role?: string | null;
|
|
819
|
+
}) | undefined>;
|
|
712
820
|
getAuthRecordById(id: string): Promise<User | undefined>;
|
|
713
821
|
create(data: Record<string, any>): Promise<SanitizedUser>;
|
|
714
822
|
update(id: string, data: Record<string, any>): Promise<SanitizedUser>;
|
|
@@ -831,6 +939,12 @@ declare class TokenService {
|
|
|
831
939
|
getTokenExpire(token: string): number | undefined;
|
|
832
940
|
decodeAccessToken(token: string): JwtPayload | null;
|
|
833
941
|
private signAccessToken;
|
|
942
|
+
/**
|
|
943
|
+
* Current per-user session version (0 when never invalidated). The signed
|
|
944
|
+
* session cookie stamps this so a fast-path reader can reject a cookie whose
|
|
945
|
+
* session was invalidated after it was written.
|
|
946
|
+
*/
|
|
947
|
+
getSessionVersion(userId: string): Promise<number>;
|
|
834
948
|
/**
|
|
835
949
|
* Generate access token with unique jti for blacklist support.
|
|
836
950
|
* Includes roles/permissions for client-side RBAC/PBAC.
|
|
@@ -855,6 +969,7 @@ declare class TokenService {
|
|
|
855
969
|
tokenFamily: string;
|
|
856
970
|
roles: string[];
|
|
857
971
|
permissions: string[];
|
|
972
|
+
sessionVersion: number;
|
|
858
973
|
accessToken: string;
|
|
859
974
|
refreshToken: string;
|
|
860
975
|
accessTokenExpiresAt: number;
|
|
@@ -888,6 +1003,7 @@ declare class TokenService {
|
|
|
888
1003
|
tokenFamily: string;
|
|
889
1004
|
roles: string[];
|
|
890
1005
|
permissions: string[];
|
|
1006
|
+
sessionVersion: number;
|
|
891
1007
|
accessToken: string;
|
|
892
1008
|
refreshToken: string;
|
|
893
1009
|
accessTokenExpiresAt: number;
|
|
@@ -995,6 +1111,12 @@ declare const updateUserDto: z.ZodObject<{
|
|
|
995
1111
|
inactive: "inactive";
|
|
996
1112
|
}>>>;
|
|
997
1113
|
}, z.core.$strip>;
|
|
1114
|
+
declare const registerDto: z.ZodObject<{
|
|
1115
|
+
name: z.ZodOptional<z.ZodString>;
|
|
1116
|
+
email: z.ZodString;
|
|
1117
|
+
password: z.ZodString;
|
|
1118
|
+
image: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1119
|
+
}, z.core.$strip>;
|
|
998
1120
|
declare const inviteUserDto: z.ZodObject<{
|
|
999
1121
|
name: z.ZodOptional<z.ZodString>;
|
|
1000
1122
|
email: z.ZodString;
|
|
@@ -1038,6 +1160,7 @@ declare const userListQuery: z.ZodObject<{
|
|
|
1038
1160
|
}, z.core.$strip>;
|
|
1039
1161
|
type CreateUserDto = z.infer<typeof createUserDto>;
|
|
1040
1162
|
type UpdateUserDto = z.infer<typeof updateUserDto>;
|
|
1163
|
+
type RegisterDto = z.infer<typeof registerDto>;
|
|
1041
1164
|
type InviteUserDto = z.infer<typeof inviteUserDto>;
|
|
1042
1165
|
type UserIdParam = z.infer<typeof userIdParam>;
|
|
1043
1166
|
type LoginDto = z.infer<typeof loginDto>;
|
|
@@ -1050,6 +1173,16 @@ type UserIdInParam = z.infer<typeof userIdInParam>;
|
|
|
1050
1173
|
type AssignRoleParams = z.infer<typeof assignRoleParams>;
|
|
1051
1174
|
type UserListQuery = z.infer<typeof userListQuery>;
|
|
1052
1175
|
|
|
1176
|
+
declare class AuthSessionService {
|
|
1177
|
+
private tokenService;
|
|
1178
|
+
private userService;
|
|
1179
|
+
private cookieManager;
|
|
1180
|
+
constructor(tokenService: TokenService, userService: UserService, cookieManager: CookieManager);
|
|
1181
|
+
establish(user: SanitizedUser): Promise<TokenPair & {
|
|
1182
|
+
user: SanitizedUser;
|
|
1183
|
+
}>;
|
|
1184
|
+
}
|
|
1185
|
+
|
|
1053
1186
|
/**
|
|
1054
1187
|
* Identity fields for creating a user behind a person record (parent, student,
|
|
1055
1188
|
* teacher, staff…). Role can be given by name (`role`) or id (`roleId`).
|
|
@@ -1071,16 +1204,17 @@ declare class AuthService {
|
|
|
1071
1204
|
private cookieManager;
|
|
1072
1205
|
private i18nService;
|
|
1073
1206
|
private emailService;
|
|
1207
|
+
private authSessionService?;
|
|
1074
1208
|
private config;
|
|
1075
1209
|
private t;
|
|
1076
1210
|
private logger;
|
|
1077
1211
|
private dummyHash?;
|
|
1078
|
-
constructor(tokenService: TokenService, userService: UserService, userValidator: UserValidator, encryptionService: EncryptionService, cookieManager: CookieManager, i18nService: I18nService, emailService: EmailService);
|
|
1212
|
+
constructor(tokenService: TokenService, userService: UserService, userValidator: UserValidator, encryptionService: EncryptionService, cookieManager: CookieManager, i18nService: I18nService, emailService: EmailService, authSessionService?: AuthSessionService);
|
|
1079
1213
|
private isLockoutActive;
|
|
1080
1214
|
private nextLockoutUntil;
|
|
1081
1215
|
private getDummyHash;
|
|
1082
1216
|
warmupPasswordHash(): Promise<void>;
|
|
1083
|
-
registerUser(body:
|
|
1217
|
+
registerUser(body: RegisterDto): Promise<SanitizedUser>;
|
|
1084
1218
|
/**
|
|
1085
1219
|
* Admin-initiated account creation. The user is created with a random,
|
|
1086
1220
|
* unusable password (the schema requires one) and then emailed a one-time
|
|
@@ -1090,7 +1224,9 @@ declare class AuthService {
|
|
|
1090
1224
|
* Email is best-effort: a send failure logs a warning but never rolls back
|
|
1091
1225
|
* account creation (and with the console provider, nothing is actually sent).
|
|
1092
1226
|
*/
|
|
1093
|
-
inviteUser(body: ProvisionUserInput): Promise<SanitizedUser
|
|
1227
|
+
inviteUser(body: ProvisionUserInput): Promise<SanitizedUser & {
|
|
1228
|
+
emailSent: boolean;
|
|
1229
|
+
}>;
|
|
1094
1230
|
/**
|
|
1095
1231
|
* Create a login for a person record. The branch is intentional and is the
|
|
1096
1232
|
* single rule callers rely on:
|
|
@@ -1147,11 +1283,32 @@ declare class AuthService {
|
|
|
1147
1283
|
declare class AuthController {
|
|
1148
1284
|
private authService;
|
|
1149
1285
|
constructor(authService: AuthService);
|
|
1150
|
-
registerUser(body:
|
|
1286
|
+
registerUser(body: RegisterDto): Promise<SanitizedUser>;
|
|
1151
1287
|
loginUser(body: LoginDto): Promise<TokenPair & {
|
|
1152
1288
|
user: SanitizedUser;
|
|
1153
1289
|
}>;
|
|
1154
|
-
inviteUser(body: InviteUserDto): Promise<
|
|
1290
|
+
inviteUser(body: InviteUserDto): Promise<Omit<{
|
|
1291
|
+
id: string;
|
|
1292
|
+
name: string;
|
|
1293
|
+
createdAt: string;
|
|
1294
|
+
updatedAt: string;
|
|
1295
|
+
email: string;
|
|
1296
|
+
emailVerified: boolean;
|
|
1297
|
+
phone: string;
|
|
1298
|
+
phoneVerified: boolean;
|
|
1299
|
+
password: string;
|
|
1300
|
+
image: string;
|
|
1301
|
+
status: "active" | "pending" | "inactive";
|
|
1302
|
+
roleId: string;
|
|
1303
|
+
lastLogin: string;
|
|
1304
|
+
failedLoginAttempts: number;
|
|
1305
|
+
lockoutUntil: string;
|
|
1306
|
+
}, "password" | "failedLoginAttempts" | "lockoutUntil"> & {
|
|
1307
|
+
role?: string | null;
|
|
1308
|
+
permissions?: string[];
|
|
1309
|
+
} & {
|
|
1310
|
+
emailSent: boolean;
|
|
1311
|
+
}>;
|
|
1155
1312
|
refreshTokens(): Promise<TokenPair>;
|
|
1156
1313
|
logoutUser(userId: string, authorization?: string): Promise<{
|
|
1157
1314
|
data: any;
|
|
@@ -1240,7 +1397,7 @@ interface RunAsUser {
|
|
|
1240
1397
|
}
|
|
1241
1398
|
declare function runAsUser<T>(container: Container, user: RunAsUser, fn: () => Promise<T> | T): Promise<T>;
|
|
1242
1399
|
|
|
1243
|
-
declare const AUTH_MODULE: readonly [typeof AuthService, typeof CookieManager, typeof EncryptionService, typeof AuthGuard, typeof AuthController, typeof AuthResolver];
|
|
1400
|
+
declare const AUTH_MODULE: readonly [typeof AuthService, typeof AuthSessionService, typeof CookieManager, typeof EncryptionService, typeof AuthGuard, typeof AuthController, typeof AuthResolver];
|
|
1244
1401
|
|
|
1245
1402
|
declare class PermissionRepository {
|
|
1246
1403
|
db: TDb;
|
|
@@ -2131,4 +2288,4 @@ declare const authSeed: (config: AuthSeedConfig) => Record<string, SeedEntry>;
|
|
|
2131
2288
|
*/
|
|
2132
2289
|
declare function seedAuthData(config: SeedAuthDataConfig): Promise<SeedAuthDataResult>;
|
|
2133
2290
|
|
|
2134
|
-
export { AUTH_CONFIG, en as AUTH_EN, AUTH_LOCALES, AUTH_MODULE, AUTH_PERMISSIONS, AUTH_ROLE, AUTH_SCHEMA, AUTH_SUPPORTED_LANGUAGES, AUTH_USER, type AssignPermissionDto, type AssignRoleDto, type AssignRoleParams, type AuthConfig, AuthController, AuthGuard, type AuthPluginConfig, AuthQueries, AuthResolver, type AuthSchema, type AuthSeedConfig, AuthService, type AuthUser, Can, CanCreate, CanDelete, CanList, CanRead, CanUpdate, type ChainableGuard, type ChangePasswordDto, type CheckPermissionDto, type ConfiguredOwnership, type ConfirmResetPasswordDto, CookieManager, type CreatePermissionDto, type CreateRoleDto, type CreateTokenDto, type CreateUserDto, type DefineRolesOptions, type EmailParam, EncryptionService, type InviteUserDto, type JwtConfig, type JwtPayload, type LanguageParam, type LoginDto, NewPermission, NewRoleEntity, NewUser, Owned, type OwnedMethods, type OwnershipConfig, type OwnershipProvider, type OwnershipRule, OwnershipToken, type OwnershipTokenOptions, Permission, PermissionController, PermissionGuard, type PermissionIdParam, PermissionRepository, PermissionService, PermissionValidator, Policy, type ProvisionUserInput, ROLES, ROLE_GROUPS, type RefreshTokenDto, type ResetPasswordDto, type ResourceAccessor, type ResourceGuards, type ResourceGuardsOptions, type RevokeTokenDto, Role, RoleController, RoleEntity, RoleGuard, type RoleIdParam, type RoleInput, RolePermission, RoleRepository, RoleService, type RoleType, RoleValidator, type RunAsUser, type SanitizedUser, ScopeContext, type ScopeResult, type SeedAuthDataConfig, type SeedAuthDataResult, type SeedUserConfig, type SessionCookieData, TOKEN_STATUS, TOKEN_TYPE, type TokenIdParam, type TokenPair, TokenRepository, TokenService, USER_STATUS, type UpdatePermissionDto, type UpdateRoleDto, type UpdateTokenDto, type UpdateUserDto, User, UserController, type UserIdInParam, type UserIdParam, type UserListQuery, UserRepository, UserService, UserValidator, type UserWithPermissions, type VerifyTokenDto, assignPermissionDto, assignRoleDto, assignRoleParams, auth$1 as auth, authSeed, avatarsPath, calculateAge, calculateYearsOfExperience, changePasswordDto, checkPermissionDto, clean, configureOwnership, confirmResetPasswordDto, createPermissionDto, createRoleDto, createTokenDto, createUserDto, defineRoles, emailParam, formatDate, getAuthLocale, getAvatarFile, inviteUserDto, isAdmin, isAdministrator, isAuth, isEmpty, isFile, isPath, join, languageParam, loginDto, own, parseSchema, permissionIdParam, pickProps, refreshTokenDto, resetPasswordDto, revokeTokenDto, roleIdParam, runAsUser, seedAuthData, tokenIdParam, updatePermissionDto, updateRoleDto, updateTokenDto, updateUserDto, userIdInParam, userIdParam, userListQuery, verifyTokenDto, where };
|
|
2291
|
+
export { AUTH_CONFIG, en as AUTH_EN, AUTH_LOCALES, AUTH_MODULE, AUTH_PERMISSIONS, AUTH_ROLE, AUTH_SCHEMA, AUTH_SUPPORTED_LANGUAGES, AUTH_USER, type AssignPermissionDto, type AssignRoleDto, type AssignRoleParams, type AuthConfig, AuthController, AuthGuard, type AuthPluginConfig, AuthQueries, AuthResolver, type AuthSchema, type AuthSeedConfig, AuthService, AuthSessionService, type AuthUser, Can, CanCreate, CanDelete, CanList, CanRead, CanUpdate, type ChainableGuard, type ChangePasswordDto, type CheckPermissionDto, type ConfiguredOwnership, type ConfirmResetPasswordDto, CookieManager, type CreatePermissionDto, type CreateRoleDto, type CreateTokenDto, type CreateUserDto, type DefineRolesOptions, type EmailParam, EncryptionService, type GoogleOAuthConfig, type InviteUserDto, type JwtConfig, type JwtPayload, type LanguageParam, type LoginDto, NewPermission, NewRoleEntity, NewUser, type OAuthConfig, type OAuthProvider, Owned, type OwnedMethods, type OwnershipConfig, type OwnershipProvider, type OwnershipRule, OwnershipToken, type OwnershipTokenOptions, Permission, PermissionController, PermissionGuard, type PermissionIdParam, PermissionRepository, PermissionService, PermissionValidator, Policy, type ProvisionUserInput, ROLES, ROLE_GROUPS, type RefreshTokenDto, type RegisterDto, type ResetPasswordDto, type ResourceAccessor, type ResourceGuards, type ResourceGuardsOptions, type RevokeTokenDto, Role, RoleController, RoleEntity, RoleGuard, type RoleIdParam, type RoleInput, RolePermission, RoleRepository, RoleService, type RoleType, RoleValidator, type RunAsUser, type SanitizedUser, ScopeContext, type ScopeResult, type SeedAuthDataConfig, type SeedAuthDataResult, type SeedUserConfig, type SessionCookieData, TOKEN_STATUS, TOKEN_TYPE, type TokenIdParam, type TokenPair, TokenRepository, TokenService, USER_STATUS, type UpdatePermissionDto, type UpdateRoleDto, type UpdateTokenDto, type UpdateUserDto, User, UserController, type UserIdInParam, type UserIdParam, type UserListQuery, UserRepository, UserService, UserValidator, type UserWithPermissions, type VerifyTokenDto, assignPermissionDto, assignRoleDto, assignRoleParams, auth$1 as auth, authSeed, avatarsPath, calculateAge, calculateYearsOfExperience, changePasswordDto, checkPermissionDto, clean, configureOwnership, confirmResetPasswordDto, createPermissionDto, createRoleDto, createTokenDto, createUserDto, defineRoles, emailParam, formatDate, getAuthLocale, getAvatarFile, inviteUserDto, isAdmin, isAdministrator, isAuth, isEmpty, isFile, isPath, join, languageParam, loginDto, own, parseSchema, permissionIdParam, pickProps, refreshTokenDto, registerDto, resetPasswordDto, revokeTokenDto, roleIdParam, runAsUser, seedAuthData, tokenIdParam, updatePermissionDto, updateRoleDto, updateTokenDto, updateUserDto, userIdInParam, userIdParam, userListQuery, verifyTokenDto, where };
|