@appxdigital/appx-core 0.1.75 → 0.1.77
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/modules/auth/auth.controller.d.ts +1 -1
- package/dist/modules/auth/auth.service.d.ts +2 -1
- package/dist/modules/auth/auth.service.d.ts.map +1 -1
- package/dist/modules/auth/auth.service.js +12 -0
- package/dist/modules/auth/session/session-store.d.ts +5 -1
- package/dist/modules/auth/session/session-store.d.ts.map +1 -1
- package/dist/modules/auth/session/session-store.js +10 -2
- package/dist/modules/user/user.service.d.ts +2 -1
- package/dist/modules/user/user.service.d.ts.map +1 -1
- package/dist/prisma/prisma.service.js +1 -1
- package/package.json +1 -1
|
@@ -6,7 +6,7 @@ export declare class AuthController {
|
|
|
6
6
|
constructor(authService: AuthService);
|
|
7
7
|
register(registerDto: RegisterDto): Promise<{
|
|
8
8
|
message: string;
|
|
9
|
-
user:
|
|
9
|
+
user: Omit<User, "password">;
|
|
10
10
|
}>;
|
|
11
11
|
login(req: Request, res: Response): Promise<void>;
|
|
12
12
|
logout(req: Request, res: Response): Promise<void>;
|
|
@@ -4,6 +4,7 @@ import { PrismaService } from '../../prisma/prisma.service';
|
|
|
4
4
|
import { ConfigService } from '@nestjs/config';
|
|
5
5
|
import { Request, Response } from 'express';
|
|
6
6
|
import { JwtService } from "@nestjs/jwt";
|
|
7
|
+
import { User } from "@prisma/client";
|
|
7
8
|
export declare class AuthService {
|
|
8
9
|
private readonly userService;
|
|
9
10
|
private prisma;
|
|
@@ -13,7 +14,7 @@ export declare class AuthService {
|
|
|
13
14
|
constructor(userService: UserService, prisma: PrismaService, jwtService: JwtService, configService: ConfigService);
|
|
14
15
|
register(registerDto: RegisterDto): Promise<{
|
|
15
16
|
message: string;
|
|
16
|
-
user:
|
|
17
|
+
user: Omit<User, "password">;
|
|
17
18
|
}>;
|
|
18
19
|
login(req: Request): Promise<{
|
|
19
20
|
message: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.service.d.ts","sourceRoot":"","sources":["../../../src/modules/auth/auth.service.ts"],"names":[],"mappings":"AAOA,OAAO,EAAC,WAAW,EAAC,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAC,WAAW,EAAC,MAAM,oBAAoB,CAAC;AAE/C,OAAO,EAAC,aAAa,EAAC,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAC,aAAa,EAAC,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAC,OAAO,EAAE,QAAQ,EAAC,MAAM,SAAS,CAAC;AAC1C,OAAO,EAAC,UAAU,EAAC,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"auth.service.d.ts","sourceRoot":"","sources":["../../../src/modules/auth/auth.service.ts"],"names":[],"mappings":"AAOA,OAAO,EAAC,WAAW,EAAC,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAC,WAAW,EAAC,MAAM,oBAAoB,CAAC;AAE/C,OAAO,EAAC,aAAa,EAAC,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAC,aAAa,EAAC,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAC,OAAO,EAAE,QAAQ,EAAC,MAAM,SAAS,CAAC;AAC1C,OAAO,EAAC,UAAU,EAAC,MAAM,aAAa,CAAC;AAGvC,OAAO,EAAC,IAAI,EAAC,MAAM,gBAAgB,CAAC;AAEpC,qBACa,WAAW;IAIhB,OAAO,CAAC,QAAQ,CAAC,WAAW;IAC5B,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,aAAa;IANzB,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAS;gBAGtB,WAAW,EAAE,WAAW,EACjC,MAAM,EAAE,aAAa,EACZ,UAAU,EAAE,UAAU,EAC/B,aAAa,EAAE,aAAa;IAKlC,QAAQ,CAAC,WAAW,EAAE,WAAW;;cAaE,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC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|
|
223
227
|
});
|
|
224
228
|
return { access_token: accessToken, refresh_token: refreshTokenString };
|
|
225
229
|
}
|
|
@@ -231,6 +235,10 @@ let AuthService = class AuthService {
|
|
|
231
235
|
await this.prisma.userRefreshToken.update({
|
|
232
236
|
where: { id: currentTokenId },
|
|
233
237
|
data: { revokedAt: new Date() },
|
|
238
|
+
},
|
|
239
|
+
// @ts-ignore
|
|
240
|
+
{
|
|
241
|
+
BYPASS_FILTERING: true,
|
|
234
242
|
});
|
|
235
243
|
const user = await this.userService.findByField("id", userId);
|
|
236
244
|
if (!user) {
|
|
@@ -262,6 +270,10 @@ let AuthService = class AuthService {
|
|
|
262
270
|
await this.prisma.userRefreshToken.updateMany({
|
|
263
271
|
where: { userId: userId, revokedAt: null },
|
|
264
272
|
data: { revokedAt: new Date() },
|
|
273
|
+
},
|
|
274
|
+
// @ts-ignore
|
|
275
|
+
{
|
|
276
|
+
BYPASS_FILTERING: true,
|
|
265
277
|
});
|
|
266
278
|
}
|
|
267
279
|
};
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { Store } from 'express-session';
|
|
2
2
|
import { PrismaService } from '../../../prisma/prisma.service';
|
|
3
|
+
export type Options = {
|
|
4
|
+
ttl: number;
|
|
5
|
+
};
|
|
3
6
|
export declare class CorePrismaSessionStore extends Store {
|
|
4
7
|
private prisma;
|
|
5
|
-
|
|
8
|
+
private options;
|
|
9
|
+
constructor(prismaService: PrismaService, options?: Options);
|
|
6
10
|
get: (sid: string, callback: (err: any, session?: any | null) => void) => Promise<void>;
|
|
7
11
|
set: (sid: string, session: any, callback?: (err?: any) => void) => Promise<void>;
|
|
8
12
|
destroy: (sid: string, callback?: (err?: any) => void) => Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-store.d.ts","sourceRoot":"","sources":["../../../../src/modules/auth/session/session-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,iBAAiB,CAAC;AAGtC,OAAO,EAAC,aAAa,EAAC,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"session-store.d.ts","sourceRoot":"","sources":["../../../../src/modules/auth/session/session-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,iBAAiB,CAAC;AAGtC,OAAO,EAAC,aAAa,EAAC,MAAM,gCAAgC,CAAC;AAG7D,MAAM,MAAM,OAAO,GAAG;IAClB,GAAG,EAAE,MAAM,CAAC;CACf,CAAA;AAED,qBAAa,sBAAuB,SAAQ,KAAK;IAC7C,OAAO,CAAC,MAAM,CAAe;IAC7B,OAAO,CAAC,OAAO,CAAU;gBAEb,aAAa,EAAE,aAAa,EAAE,OAAO,CAAC,EAAE,OAAO;IAYpD,GAAG,GACN,KAAK,MAAM,EACX,UAAU,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,GAAG,GAAG,IAAI,KAAK,IAAI,mBAgBpD;IAEK,GAAG,GACN,KAAK,MAAM,EACX,SAAS,GAAG,EACZ,WAAW,CAAC,GAAG,CAAC,EAAE,GAAG,KAAK,IAAI,mBAmChC;IAEK,OAAO,GAAU,KAAK,MAAM,EAAE,WAAW,CAAC,GAAG,CAAC,EAAE,GAAG,KAAK,IAAI,mBAcjE;IAEK,KAAK,GACR,KAAK,MAAM,EACX,SAAS,GAAG,EACZ,WAAW,CAAC,GAAG,CAAC,EAAE,GAAG,KAAK,IAAI,mBAiBhC;CACL"}
|
|
@@ -5,7 +5,7 @@ const express_session_1 = require("express-session");
|
|
|
5
5
|
const library_1 = require("@prisma/client/runtime/library");
|
|
6
6
|
const cuid2_1 = require("@paralleldrive/cuid2");
|
|
7
7
|
class CorePrismaSessionStore extends express_session_1.Store {
|
|
8
|
-
constructor(prismaService) {
|
|
8
|
+
constructor(prismaService, options) {
|
|
9
9
|
super();
|
|
10
10
|
this.get = async (sid, callback) => {
|
|
11
11
|
try {
|
|
@@ -33,7 +33,7 @@ class CorePrismaSessionStore extends express_session_1.Store {
|
|
|
33
33
|
const data = JSON.stringify(session);
|
|
34
34
|
const expiresAt = session.cookie && session.cookie.expires
|
|
35
35
|
? new Date(session.cookie.expires)
|
|
36
|
-
:
|
|
36
|
+
: new Date(Date.now() + this.options.ttl * 1000);
|
|
37
37
|
await this.prisma.session.upsert({
|
|
38
38
|
where: { sid },
|
|
39
39
|
create: {
|
|
@@ -79,6 +79,9 @@ class CorePrismaSessionStore extends express_session_1.Store {
|
|
|
79
79
|
if (session.cookie && session.cookie.maxAge) {
|
|
80
80
|
expiresAt = new Date(Date.now() + session.cookie.maxAge);
|
|
81
81
|
}
|
|
82
|
+
else {
|
|
83
|
+
expiresAt = new Date(Date.now() + this.options.ttl * 1000);
|
|
84
|
+
}
|
|
82
85
|
await this.prisma.session.update({
|
|
83
86
|
where: { sid },
|
|
84
87
|
data: { expiresAt },
|
|
@@ -91,6 +94,11 @@ class CorePrismaSessionStore extends express_session_1.Store {
|
|
|
91
94
|
callback(err);
|
|
92
95
|
}
|
|
93
96
|
};
|
|
97
|
+
// Merge default options with provided options
|
|
98
|
+
const defaultOptions = {
|
|
99
|
+
ttl: 3600 * 24, // Default to 1 day
|
|
100
|
+
};
|
|
101
|
+
this.options = { ...defaultOptions, ...(options || {}) };
|
|
94
102
|
this.prisma = prismaService.prismaClient;
|
|
95
103
|
}
|
|
96
104
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { PrismaService } from '../../prisma/prisma.service';
|
|
2
2
|
import { UserCreateInput } from '../../common/interfaces/user.interface';
|
|
3
|
+
import { User } from '@prisma/client';
|
|
3
4
|
export declare class UserService {
|
|
4
5
|
private prisma;
|
|
5
6
|
constructor(prisma: PrismaService);
|
|
6
|
-
createUser(createUserInput: UserCreateInput): Promise<
|
|
7
|
+
createUser(createUserInput: UserCreateInput): Promise<User>;
|
|
7
8
|
findByField(field: string, value: any): Promise<any>;
|
|
8
9
|
findByEmail(email: string): Promise<any>;
|
|
9
10
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user.service.d.ts","sourceRoot":"","sources":["../../../src/modules/user/user.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,aAAa,EAAC,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAC,eAAe,EAAC,MAAM,wCAAwC,CAAC;AAEvE,qBACa,WAAW;IACR,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,aAAa;IAEnC,UAAU,CAAC,eAAe,EAAE,eAAe;
|
|
1
|
+
{"version":3,"file":"user.service.d.ts","sourceRoot":"","sources":["../../../src/modules/user/user.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,aAAa,EAAC,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAC,eAAe,EAAC,MAAM,wCAAwC,CAAC;AAEvE,OAAO,EAAC,IAAI,EAAC,MAAM,gBAAgB,CAAC;AAEpC,qBACa,WAAW;IACR,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,aAAa;IAEnC,UAAU,CAAC,eAAe,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAM3D,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;IAUpD,WAAW,CAAC,KAAK,EAAE,MAAM;CAYlC"}
|
|
@@ -78,7 +78,7 @@ let PrismaService = class PrismaService {
|
|
|
78
78
|
const contextModel = nestjs_request_context_1.RequestContext.currentContext?.req.prisma?.[propKey] || model;
|
|
79
79
|
return async (params, options) => {
|
|
80
80
|
// delete, deleteMany, update and updateMany methods should not apply field omission because they are not selecting fields
|
|
81
|
-
if (!options?.BYPASS_OMISSION && !['delete', 'deleteMany', 'update', 'updateMany'].includes(methodKey.toString()))
|
|
81
|
+
if (!options?.BYPASS_OMISSION && !['delete', 'deleteMany', 'update', 'updateMany', 'create'].includes(methodKey.toString()))
|
|
82
82
|
params = this.applyFieldOmission(String(propKey), userRole, params);
|
|
83
83
|
if (!options?.BYPASS_FILTERING) {
|
|
84
84
|
params = this.applyWhereConditions(String(propKey), userRole, params, user, methodKey);
|
package/package.json
CHANGED