najm-auth 1.1.42 → 1.1.43
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/dist/index.d.ts +26 -2
- package/dist/index.js +27 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1050,6 +1050,19 @@ type UserIdInParam = z.infer<typeof userIdInParam>;
|
|
|
1050
1050
|
type AssignRoleParams = z.infer<typeof assignRoleParams>;
|
|
1051
1051
|
type UserListQuery = z.infer<typeof userListQuery>;
|
|
1052
1052
|
|
|
1053
|
+
/**
|
|
1054
|
+
* Identity fields for creating a user behind a person record (parent, student,
|
|
1055
|
+
* teacher, staff…). Role can be given by name (`role`) or id (`roleId`).
|
|
1056
|
+
*/
|
|
1057
|
+
type ProvisionUserInput = {
|
|
1058
|
+
id?: string;
|
|
1059
|
+
name?: string;
|
|
1060
|
+
email: string;
|
|
1061
|
+
role?: string;
|
|
1062
|
+
roleId?: string;
|
|
1063
|
+
image?: string | null;
|
|
1064
|
+
status?: 'active' | 'inactive' | 'pending';
|
|
1065
|
+
};
|
|
1053
1066
|
declare class AuthService {
|
|
1054
1067
|
private tokenService;
|
|
1055
1068
|
private userService;
|
|
@@ -1077,7 +1090,18 @@ declare class AuthService {
|
|
|
1077
1090
|
* Email is best-effort: a send failure logs a warning but never rolls back
|
|
1078
1091
|
* account creation (and with the console provider, nothing is actually sent).
|
|
1079
1092
|
*/
|
|
1080
|
-
inviteUser(body:
|
|
1093
|
+
inviteUser(body: ProvisionUserInput): Promise<SanitizedUser>;
|
|
1094
|
+
/**
|
|
1095
|
+
* Create a login for a person record. The branch is intentional and is the
|
|
1096
|
+
* single rule callers rely on:
|
|
1097
|
+
* - password provided → set it directly, NO email (seeding / imports)
|
|
1098
|
+
* - no password → random password + emailed set-password invite
|
|
1099
|
+
*
|
|
1100
|
+
* Returns the created (sanitized) user so the caller can link `userId`.
|
|
1101
|
+
*/
|
|
1102
|
+
provisionUser(body: ProvisionUserInput & {
|
|
1103
|
+
password?: string | null;
|
|
1104
|
+
}): Promise<SanitizedUser>;
|
|
1081
1105
|
loginUser(body: LoginDto): Promise<TokenPair & {
|
|
1082
1106
|
user: SanitizedUser;
|
|
1083
1107
|
}>;
|
|
@@ -2100,4 +2124,4 @@ declare const authSeed: (config: AuthSeedConfig) => Record<string, SeedEntry>;
|
|
|
2100
2124
|
*/
|
|
2101
2125
|
declare function seedAuthData(config: SeedAuthDataConfig): Promise<SeedAuthDataResult>;
|
|
2102
2126
|
|
|
2103
|
-
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, 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 };
|
|
2127
|
+
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 };
|
package/dist/index.js
CHANGED
|
@@ -2007,12 +2007,14 @@ var AuthService = class AuthService2 {
|
|
|
2007
2007
|
async inviteUser(body) {
|
|
2008
2008
|
const randomPassword = `${nanoid5(24)}Aa1!`;
|
|
2009
2009
|
const user = await this.userService.create({
|
|
2010
|
+
id: body.id,
|
|
2010
2011
|
name: body.name,
|
|
2011
2012
|
email: body.email,
|
|
2013
|
+
role: body.role,
|
|
2012
2014
|
roleId: body.roleId,
|
|
2013
2015
|
image: body.image,
|
|
2014
2016
|
password: randomPassword,
|
|
2015
|
-
status: "active",
|
|
2017
|
+
status: body.status ?? "active",
|
|
2016
2018
|
emailVerified: false
|
|
2017
2019
|
});
|
|
2018
2020
|
const { token } = await this.tokenService.generateInviteToken(user.id);
|
|
@@ -2027,6 +2029,30 @@ var AuthService = class AuthService2 {
|
|
|
2027
2029
|
}
|
|
2028
2030
|
return user;
|
|
2029
2031
|
}
|
|
2032
|
+
/**
|
|
2033
|
+
* Create a login for a person record. The branch is intentional and is the
|
|
2034
|
+
* single rule callers rely on:
|
|
2035
|
+
* - password provided → set it directly, NO email (seeding / imports)
|
|
2036
|
+
* - no password → random password + emailed set-password invite
|
|
2037
|
+
*
|
|
2038
|
+
* Returns the created (sanitized) user so the caller can link `userId`.
|
|
2039
|
+
*/
|
|
2040
|
+
async provisionUser(body) {
|
|
2041
|
+
const password = typeof body.password === "string" ? body.password.trim() : "";
|
|
2042
|
+
if (password) {
|
|
2043
|
+
return this.userService.create({
|
|
2044
|
+
id: body.id,
|
|
2045
|
+
name: body.name,
|
|
2046
|
+
email: body.email,
|
|
2047
|
+
role: body.role,
|
|
2048
|
+
roleId: body.roleId,
|
|
2049
|
+
image: body.image,
|
|
2050
|
+
password,
|
|
2051
|
+
status: body.status ?? "active"
|
|
2052
|
+
});
|
|
2053
|
+
}
|
|
2054
|
+
return this.inviteUser(body);
|
|
2055
|
+
}
|
|
2030
2056
|
async loginUser(body) {
|
|
2031
2057
|
const { email: email2, password } = body;
|
|
2032
2058
|
const user = await this.userService.findByEmail(email2);
|