najm-auth 0.1.3 → 0.1.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.
Potentially problematic release.
This version of najm-auth might be problematic. Click here for more details.
- package/dist/auth/AuthController.d.ts +48 -0
- package/dist/auth/AuthService.d.ts +29 -0
- package/dist/{services → auth}/CookieService.d.ts +1 -1
- package/dist/auth/EncryptionService.d.ts +5 -0
- package/dist/auth/index.d.ts +4 -0
- package/dist/database/db.d.ts +32 -0
- package/dist/database/index.d.ts +2 -0
- package/dist/database/schema/PgEnum.d.ts +4 -0
- package/dist/database/{schemas → schema}/index.d.ts +21 -22
- package/dist/index.d.ts +8 -19
- package/dist/index.js +11 -3
- package/dist/index.mjs +11 -3
- package/dist/lib/ENUMS.d.ts +224 -0
- package/dist/lib/ZodEnum.d.ts +163 -0
- package/dist/lib/index.d.ts +3 -0
- package/dist/lib/validations.d.ts +744 -0
- package/dist/permissions/PermissionController.d.ts +55 -0
- package/dist/permissions/PermissionGuards.d.ts +9 -0
- package/dist/permissions/PermissionRepository.d.ts +16 -0
- package/dist/permissions/PermissionService.d.ts +23 -0
- package/dist/permissions/PermissionValidator.d.ts +16 -0
- package/dist/permissions/index.d.ts +5 -0
- package/dist/plugin.d.ts +28 -0
- package/dist/plugin.js +4 -0
- package/dist/plugin.mjs +4 -0
- package/dist/roles/RoleController.d.ts +30 -0
- package/dist/{guards → roles}/RoleGuards.d.ts +11 -11
- package/dist/roles/RoleRepository.d.ts +10 -0
- package/dist/roles/RoleService.d.ts +15 -0
- package/dist/roles/RoleValidator.d.ts +12 -0
- package/dist/roles/index.d.ts +5 -0
- package/dist/shared/index.d.ts +15 -0
- package/dist/shared/logger.d.ts +3 -0
- package/dist/tokens/TokenRepository.d.ts +15 -0
- package/dist/tokens/TokenService.d.ts +44 -0
- package/dist/tokens/index.d.ts +2 -0
- package/dist/users/UserController.d.ts +65 -0
- package/dist/users/UserRepository.d.ts +15 -0
- package/dist/users/UserService.d.ts +29 -0
- package/dist/users/UserValidator.d.ts +19 -0
- package/dist/users/index.d.ts +4 -0
- package/dist/users/utils.d.ts +1 -0
- package/package.json +17 -8
- package/dist/database/enums/index.d.ts +0 -10
- package/dist/guards/PermissionGuards.d.ts +0 -9
- package/dist/repositories/PermissionRepository.d.ts +0 -25
- package/dist/repositories/RoleRepository.d.ts +0 -19
- package/dist/repositories/TokenRepository.d.ts +0 -24
- package/dist/repositories/UserRepository.d.ts +0 -20
- package/dist/services/AuthService.d.ts +0 -27
- package/dist/services/EncryptionService.d.ts +0 -5
- package/dist/services/PermissionService.d.ts +0 -23
- package/dist/services/RoleService.d.ts +0 -15
- package/dist/services/TokenService.d.ts +0 -24
- package/dist/services/UserService.d.ts +0 -28
- package/dist/types/index.d.ts +0 -94
- package/dist/validators/PermissionValidator.d.ts +0 -15
- package/dist/validators/RoleValidator.d.ts +0 -11
- package/dist/validators/UserValidator.d.ts +0 -22
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { AuthService } from './AuthService';
|
|
2
|
+
export declare class AuthController {
|
|
3
|
+
private authService;
|
|
4
|
+
constructor(authService: AuthService);
|
|
5
|
+
registerUser(body: any): Promise<{
|
|
6
|
+
data: any;
|
|
7
|
+
message: string;
|
|
8
|
+
status: string;
|
|
9
|
+
}>;
|
|
10
|
+
loginUser(body: any): Promise<{
|
|
11
|
+
data: {
|
|
12
|
+
accessToken: string;
|
|
13
|
+
refreshToken: string;
|
|
14
|
+
accessTokenExpiresAt: number;
|
|
15
|
+
refreshTokenExpiresAt: number;
|
|
16
|
+
};
|
|
17
|
+
message: string;
|
|
18
|
+
status: string;
|
|
19
|
+
}>;
|
|
20
|
+
refreshTokens(): Promise<{
|
|
21
|
+
data: {
|
|
22
|
+
accessToken: string;
|
|
23
|
+
refreshToken: string;
|
|
24
|
+
accessTokenExpiresAt: number;
|
|
25
|
+
refreshTokenExpiresAt: number;
|
|
26
|
+
};
|
|
27
|
+
message: string;
|
|
28
|
+
status: string;
|
|
29
|
+
}>;
|
|
30
|
+
logoutUser(id: any): Promise<{
|
|
31
|
+
data: {
|
|
32
|
+
data: any;
|
|
33
|
+
message: string;
|
|
34
|
+
};
|
|
35
|
+
message: string;
|
|
36
|
+
status: string;
|
|
37
|
+
}>;
|
|
38
|
+
userProfile(user: any): Promise<{
|
|
39
|
+
data: any;
|
|
40
|
+
message: string;
|
|
41
|
+
status: string;
|
|
42
|
+
}>;
|
|
43
|
+
forgotPassword(body: any): Promise<{
|
|
44
|
+
data: void;
|
|
45
|
+
message: string;
|
|
46
|
+
status: string;
|
|
47
|
+
}>;
|
|
48
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { UserService, UserValidator } from '../users';
|
|
2
|
+
import { TokenService } from '../tokens';
|
|
3
|
+
import { CookieService } from './CookieService';
|
|
4
|
+
export declare class AuthService {
|
|
5
|
+
private tokenService;
|
|
6
|
+
private userService;
|
|
7
|
+
private userValidator;
|
|
8
|
+
private cookieService;
|
|
9
|
+
constructor(tokenService: TokenService, userService: UserService, userValidator: UserValidator, cookieService: CookieService);
|
|
10
|
+
registerUser(body: any): Promise<any>;
|
|
11
|
+
loginUser(body: any): Promise<{
|
|
12
|
+
accessToken: string;
|
|
13
|
+
refreshToken: string;
|
|
14
|
+
accessTokenExpiresAt: number;
|
|
15
|
+
refreshTokenExpiresAt: number;
|
|
16
|
+
}>;
|
|
17
|
+
refreshTokens(): Promise<{
|
|
18
|
+
accessToken: string;
|
|
19
|
+
refreshToken: string;
|
|
20
|
+
accessTokenExpiresAt: number;
|
|
21
|
+
refreshTokenExpiresAt: number;
|
|
22
|
+
}>;
|
|
23
|
+
logoutUser(userId: any): Promise<{
|
|
24
|
+
data: any;
|
|
25
|
+
message: string;
|
|
26
|
+
}>;
|
|
27
|
+
getUserProfile(userData: any): Promise<any>;
|
|
28
|
+
forgotPassword(email: any): Promise<void>;
|
|
29
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { PostgresJsDatabase } from 'drizzle-orm/postgres-js';
|
|
2
|
+
import * as schema from './schema';
|
|
3
|
+
import { DB as GenericDB } from 'najm-api';
|
|
4
|
+
export type DB = PostgresJsDatabase<typeof schema>;
|
|
5
|
+
/**
|
|
6
|
+
* ⚠️ IMPORTANT: Development-Only Database Instance
|
|
7
|
+
*
|
|
8
|
+
* This DB instance is ONLY for standalone development and testing.
|
|
9
|
+
* When used as a plugin in production, the database will be injected
|
|
10
|
+
* automatically by the najm-api plugin system.
|
|
11
|
+
*
|
|
12
|
+
* DO NOT use this in production - it creates a duplicate connection!
|
|
13
|
+
*
|
|
14
|
+
* In production:
|
|
15
|
+
* - Use najm-auth as a plugin: `import { AuthPlugin } from 'najm-auth/plugin'`
|
|
16
|
+
* - The main app registers the database in DatabaseRegistry
|
|
17
|
+
* - Repositories get the DB automatically injected via dependency injection
|
|
18
|
+
*
|
|
19
|
+
* @example Production Usage
|
|
20
|
+
* ```typescript
|
|
21
|
+
* import { Server, DatabaseRegistry } from 'najm-api';
|
|
22
|
+
* import { AuthPlugin } from 'najm-auth/plugin';
|
|
23
|
+
*
|
|
24
|
+
* const app = await Server({
|
|
25
|
+
* databases: {
|
|
26
|
+
* auth: myDbInstance // Single source of truth
|
|
27
|
+
* },
|
|
28
|
+
* plugins: [AuthPlugin]
|
|
29
|
+
* });
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export declare const db: DB | GenericDB;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const userStatusEnum: import("drizzle-orm/pg-core").PgEnum<any>;
|
|
2
|
+
export declare const tokenStatusEnum: import("drizzle-orm/pg-core").PgEnum<any>;
|
|
3
|
+
export declare const tokenTypeEnum: import("drizzle-orm/pg-core").PgEnum<any>;
|
|
4
|
+
export declare const studentStatusEnum: import("drizzle-orm/pg-core").PgEnum<any>;
|
|
@@ -3,7 +3,7 @@ export declare const timestamps: {
|
|
|
3
3
|
updatedAt: import("drizzle-orm").HasDefault<import("drizzle-orm").HasDefault<import("drizzle-orm/pg-core").PgTimestampStringBuilderInitial<"updated_at">>>;
|
|
4
4
|
};
|
|
5
5
|
export declare const idField: (length?: number) => import("drizzle-orm").HasRuntimeDefault<import("drizzle-orm").HasDefault<import("drizzle-orm").NotNull<import("drizzle-orm").IsPrimaryKey<import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgTextBuilderInitial<"id", [string, ...string[]]>>>>>>;
|
|
6
|
-
export declare const
|
|
6
|
+
export declare const rolesTable: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
7
7
|
name: "roles";
|
|
8
8
|
schema: undefined;
|
|
9
9
|
columns: {
|
|
@@ -61,7 +61,7 @@ export declare const roles: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
|
61
61
|
};
|
|
62
62
|
dialect: "pg";
|
|
63
63
|
}>;
|
|
64
|
-
export declare const
|
|
64
|
+
export declare const usersTable: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
65
65
|
name: "users";
|
|
66
66
|
schema: undefined;
|
|
67
67
|
columns: {
|
|
@@ -189,14 +189,14 @@ export declare const users: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
|
189
189
|
tableName: "users";
|
|
190
190
|
dataType: "string";
|
|
191
191
|
columnType: "PgEnumColumn";
|
|
192
|
-
data:
|
|
192
|
+
data: any;
|
|
193
193
|
driverParam: string;
|
|
194
194
|
notNull: false;
|
|
195
195
|
hasDefault: true;
|
|
196
196
|
isPrimaryKey: false;
|
|
197
197
|
isAutoincrement: false;
|
|
198
198
|
hasRuntimeDefault: false;
|
|
199
|
-
enumValues:
|
|
199
|
+
enumValues: any;
|
|
200
200
|
baseColumn: never;
|
|
201
201
|
identity: undefined;
|
|
202
202
|
generated: undefined;
|
|
@@ -238,7 +238,7 @@ export declare const users: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
|
238
238
|
};
|
|
239
239
|
dialect: "pg";
|
|
240
240
|
}>;
|
|
241
|
-
export declare const
|
|
241
|
+
export declare const tokensTable: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
242
242
|
name: "tokens";
|
|
243
243
|
schema: undefined;
|
|
244
244
|
columns: {
|
|
@@ -332,14 +332,14 @@ export declare const tokens: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
|
332
332
|
tableName: "tokens";
|
|
333
333
|
dataType: "string";
|
|
334
334
|
columnType: "PgEnumColumn";
|
|
335
|
-
data:
|
|
335
|
+
data: any;
|
|
336
336
|
driverParam: string;
|
|
337
337
|
notNull: false;
|
|
338
338
|
hasDefault: true;
|
|
339
339
|
isPrimaryKey: false;
|
|
340
340
|
isAutoincrement: false;
|
|
341
341
|
hasRuntimeDefault: false;
|
|
342
|
-
enumValues:
|
|
342
|
+
enumValues: any;
|
|
343
343
|
baseColumn: never;
|
|
344
344
|
identity: undefined;
|
|
345
345
|
generated: undefined;
|
|
@@ -349,14 +349,14 @@ export declare const tokens: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
|
349
349
|
tableName: "tokens";
|
|
350
350
|
dataType: "string";
|
|
351
351
|
columnType: "PgEnumColumn";
|
|
352
|
-
data:
|
|
352
|
+
data: any;
|
|
353
353
|
driverParam: string;
|
|
354
354
|
notNull: false;
|
|
355
355
|
hasDefault: true;
|
|
356
356
|
isPrimaryKey: false;
|
|
357
357
|
isAutoincrement: false;
|
|
358
358
|
hasRuntimeDefault: false;
|
|
359
|
-
enumValues:
|
|
359
|
+
enumValues: any;
|
|
360
360
|
baseColumn: never;
|
|
361
361
|
identity: undefined;
|
|
362
362
|
generated: undefined;
|
|
@@ -381,7 +381,7 @@ export declare const tokens: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
|
381
381
|
};
|
|
382
382
|
dialect: "pg";
|
|
383
383
|
}>;
|
|
384
|
-
export declare const
|
|
384
|
+
export declare const permissionsTable: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
385
385
|
name: "permissions";
|
|
386
386
|
schema: undefined;
|
|
387
387
|
columns: {
|
|
@@ -507,7 +507,7 @@ export declare const permissions: import("drizzle-orm/pg-core").PgTableWithColum
|
|
|
507
507
|
};
|
|
508
508
|
dialect: "pg";
|
|
509
509
|
}>;
|
|
510
|
-
export declare const
|
|
510
|
+
export declare const rolePermissionsTable: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
511
511
|
name: "role_permissions";
|
|
512
512
|
schema: undefined;
|
|
513
513
|
columns: {
|
|
@@ -599,14 +599,13 @@ export declare const rolePermissions: import("drizzle-orm/pg-core").PgTableWithC
|
|
|
599
599
|
};
|
|
600
600
|
dialect: "pg";
|
|
601
601
|
}>;
|
|
602
|
-
export type User = typeof
|
|
603
|
-
export type NewUser = typeof
|
|
604
|
-
export type Token = typeof
|
|
605
|
-
export type NewToken = typeof
|
|
606
|
-
export type Role = typeof
|
|
607
|
-
export type NewRole = typeof
|
|
608
|
-
export type Permission = typeof
|
|
609
|
-
export type NewPermission = typeof
|
|
610
|
-
export type RolePermission = typeof
|
|
611
|
-
export type NewRolePermission = typeof
|
|
612
|
-
export * from '../enums';
|
|
602
|
+
export type User = typeof usersTable.$inferSelect;
|
|
603
|
+
export type NewUser = typeof usersTable.$inferInsert;
|
|
604
|
+
export type Token = typeof tokensTable.$inferSelect;
|
|
605
|
+
export type NewToken = typeof tokensTable.$inferInsert;
|
|
606
|
+
export type Role = typeof rolesTable.$inferSelect;
|
|
607
|
+
export type NewRole = typeof rolesTable.$inferInsert;
|
|
608
|
+
export type Permission = typeof permissionsTable.$inferSelect;
|
|
609
|
+
export type NewPermission = typeof permissionsTable.$inferInsert;
|
|
610
|
+
export type RolePermission = typeof rolePermissionsTable.$inferSelect;
|
|
611
|
+
export type NewRolePermission = typeof rolePermissionsTable.$inferInsert;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,19 +1,8 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
export {
|
|
9
|
-
export { PermissionGuards, Permission } from './guards/PermissionGuards';
|
|
10
|
-
export { RoleValidator } from './validators/RoleValidator';
|
|
11
|
-
export { PermissionValidator } from './validators/PermissionValidator';
|
|
12
|
-
export { UserValidator } from './validators/UserValidator';
|
|
13
|
-
export { TokenRepository } from './repositories/TokenRepository';
|
|
14
|
-
export { RoleRepository } from './repositories/RoleRepository';
|
|
15
|
-
export { PermissionRepository } from './repositories/PermissionRepository';
|
|
16
|
-
export { UserRepository } from './repositories/UserRepository';
|
|
17
|
-
export type { AuthUser, JWTPayload, JWTConfig, SessionConfig, HashConfig, TokenData, TokenPair, ITokenRepository, IRoleRepository, IPermissionRepository, AuthStrategy, AuthGuardOptions, AuthGuardFunction, } from './types';
|
|
18
|
-
export type { Role as RoleType, RoleGroup } from './guards/RoleGuards';
|
|
19
|
-
export * from './database/schemas';
|
|
1
|
+
export * from './auth';
|
|
2
|
+
export * from './lib';
|
|
3
|
+
export * from './permissions';
|
|
4
|
+
export * from './roles';
|
|
5
|
+
export * from './shared';
|
|
6
|
+
export * from './tokens';
|
|
7
|
+
export * from './users';
|
|
8
|
+
export { db, usersTable, rolesTable, tokensTable, permissionsTable, rolePermissionsTable, idField, } from './database';
|