@vynelix/nestjs-multi-auth 0.1.3 → 0.1.5
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/auth/core/jwt.strategy.d.ts +9 -3
- package/dist/auth/core/jwt.strategy.js +11 -5
- package/dist/auth/core/jwt.strategy.js.map +1 -1
- package/dist/auth/interfaces/signin-event-body.interface.d.ts +22 -0
- package/dist/auth/interfaces/signin-event-body.interface.js +3 -0
- package/dist/auth/interfaces/signin-event-body.interface.js.map +1 -0
- package/dist/auth/interfaces/signup-event-body.interface.d.ts +31 -0
- package/dist/auth/interfaces/signup-event-body.interface.js +3 -0
- package/dist/auth/interfaces/signup-event-body.interface.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -1
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
import { Strategy } from 'passport-jwt';
|
|
2
2
|
import { AuthModuleOptions } from '../interfaces/auth-module-options.interface';
|
|
3
3
|
import { JwtPayload } from '../interfaces/jwt-payload-interface';
|
|
4
|
-
|
|
4
|
+
import { AuthService } from '../auth.service';
|
|
5
|
+
declare const JwtStrategy_base: new (...args: [opt: import("passport-jwt").StrategyOptionsWithRequest] | [opt: import("passport-jwt").StrategyOptionsWithoutRequest]) => Strategy & {
|
|
5
6
|
validate(...args: any[]): unknown;
|
|
6
7
|
};
|
|
7
8
|
export declare class JwtStrategy extends JwtStrategy_base {
|
|
8
9
|
private options;
|
|
10
|
+
private readonly authService;
|
|
9
11
|
private readonly logger;
|
|
10
|
-
constructor(options: AuthModuleOptions);
|
|
11
|
-
validate(payload: JwtPayload): Promise<
|
|
12
|
+
constructor(options: AuthModuleOptions, authService: AuthService);
|
|
13
|
+
validate(payload: JwtPayload): Promise<{
|
|
14
|
+
uid: string;
|
|
15
|
+
sessionId: string;
|
|
16
|
+
user: import("../dto/responses/auth-response.dto").AuthResponseDto;
|
|
17
|
+
}>;
|
|
12
18
|
}
|
|
13
19
|
export {};
|
|
@@ -20,8 +20,9 @@ const passport_1 = require("@nestjs/passport");
|
|
|
20
20
|
const passport_jwt_1 = require("passport-jwt");
|
|
21
21
|
const auth_module_options_interface_1 = require("../interfaces/auth-module-options.interface");
|
|
22
22
|
const common_2 = require("@nestjs/common");
|
|
23
|
+
const auth_service_1 = require("../auth.service");
|
|
23
24
|
let JwtStrategy = JwtStrategy_1 = class JwtStrategy extends (0, passport_1.PassportStrategy)(passport_jwt_1.Strategy) {
|
|
24
|
-
constructor(options) {
|
|
25
|
+
constructor(options, authService) {
|
|
25
26
|
const cookieExtractor = (req) => {
|
|
26
27
|
if (!req || !req.cookies) {
|
|
27
28
|
return null;
|
|
@@ -39,14 +40,19 @@ let JwtStrategy = JwtStrategy_1 = class JwtStrategy extends (0, passport_1.Passp
|
|
|
39
40
|
secretOrKey: options.jwtSecret || process.env.JWT_SECRET || 'changeme',
|
|
40
41
|
});
|
|
41
42
|
this.options = options;
|
|
43
|
+
this.authService = authService;
|
|
42
44
|
this.logger = new common_1.Logger(JwtStrategy_1.name);
|
|
43
45
|
}
|
|
44
46
|
async validate(payload) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
+
const user = await this.authService.me(payload.sub);
|
|
48
|
+
if (!user) {
|
|
49
|
+
this.logger.error("User no longer exists");
|
|
50
|
+
throw new common_1.UnauthorizedException('User no longer exists');
|
|
51
|
+
}
|
|
47
52
|
return {
|
|
48
|
-
uid:
|
|
53
|
+
uid: user?.uid,
|
|
49
54
|
sessionId: payload.sessionId,
|
|
55
|
+
user,
|
|
50
56
|
};
|
|
51
57
|
}
|
|
52
58
|
};
|
|
@@ -54,6 +60,6 @@ exports.JwtStrategy = JwtStrategy;
|
|
|
54
60
|
exports.JwtStrategy = JwtStrategy = JwtStrategy_1 = __decorate([
|
|
55
61
|
(0, common_1.Injectable)(),
|
|
56
62
|
__param(0, (0, common_2.Inject)(auth_module_options_interface_1.AUTH_MODULE_OPTIONS)),
|
|
57
|
-
__metadata("design:paramtypes", [Object])
|
|
63
|
+
__metadata("design:paramtypes", [Object, auth_service_1.AuthService])
|
|
58
64
|
], JwtStrategy);
|
|
59
65
|
//# sourceMappingURL=jwt.strategy.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jwt.strategy.js","sourceRoot":"","sources":["../../../src/auth/core/jwt.strategy.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2BAA2B;AAC3B,
|
|
1
|
+
{"version":3,"file":"jwt.strategy.js","sourceRoot":"","sources":["../../../src/auth/core/jwt.strategy.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2BAA2B;AAC3B,2CAA2E;AAC3E,+CAAoD;AACpD,+CAAoD;AACpD,+FAAqG;AACrG,2CAAwC;AAGxC,kDAA8C;AAGvC,IAAM,WAAW,mBAAjB,MAAM,WAAY,SAAQ,IAAA,2BAAgB,EAAC,uBAAQ,CAAC;IAGzD,YAC+B,OAAkC,EAC9C,WAAwB;QAEzC,MAAM,eAAe,GAAG,CAAC,GAAY,EAAiB,EAAE;YACtD,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;gBACzB,OAAO,IAAI,CAAC;YACd,CAAC;YAED,MAAM,OAAO,GAAG,GAAG,CAAC,OAAwC,CAAC;YAC7D,MAAM,KAAK,GAAG,OAAO,EAAE,YAAY,IAAI,IAAI,CAAC;YAC5C,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;QAClD,CAAC,CAAC;QACF,KAAK,CAAC;YACJ,cAAc,EAAE,yBAAU,CAAC,cAAc,CAAC;gBACxC,eAAe;gBACf,yBAAU,CAAC,2BAA2B,EAAE;aACzC,CAAC;YACF,gBAAgB,EAAE,KAAK;YACvB,WAAW,EAAE,OAAO,CAAC,SAAS,IAAI,OAAO,CAAC,GAAG,CAAC,UAAU,IAAI,UAAU;SACvE,CAAC,CAAC;QAnBkC,YAAO,GAAP,OAAO,CAAmB;QAC9C,gBAAW,GAAX,WAAW,CAAa;QAJ1B,WAAM,GAAG,IAAI,eAAM,CAAC,aAAW,CAAC,IAAI,CAAC,CAAC;IAuBvD,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,OAAmB;QAChC,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAEpD,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAC;YAC3C,MAAM,IAAI,8BAAqB,CAAC,uBAAuB,CAAC,CAAC;QAC3D,CAAC;QAED,OAAO;YACL,GAAG,EAAE,IAAI,EAAE,GAAG;YACd,SAAS,EAAE,OAAO,CAAC,SAAS;YAC5B,IAAI;SACL,CAAC;IACJ,CAAC;CACF,CAAA;AAxCY,kCAAW;sBAAX,WAAW;IADvB,IAAA,mBAAU,GAAE;IAKR,WAAA,IAAA,eAAM,EAAC,mDAAmB,CAAC,CAAA;6CACE,0BAAW;GALhC,WAAW,CAwCvB"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { AuthStrategy } from "../enums/auth-type.enum";
|
|
2
|
+
export interface Tokens {
|
|
3
|
+
accessToken: string;
|
|
4
|
+
refreshToken: string;
|
|
5
|
+
}
|
|
6
|
+
export interface SigninEventBody {
|
|
7
|
+
auth: AuthDTO;
|
|
8
|
+
tokens: Tokens;
|
|
9
|
+
}
|
|
10
|
+
export interface AuthDTO {
|
|
11
|
+
id: string;
|
|
12
|
+
createdAt: string;
|
|
13
|
+
updatedAt: string;
|
|
14
|
+
deletedAt: string | null;
|
|
15
|
+
uid: string;
|
|
16
|
+
strategy: AuthStrategy;
|
|
17
|
+
isPrimary: boolean;
|
|
18
|
+
isVerified: boolean;
|
|
19
|
+
isActive: boolean;
|
|
20
|
+
meta: Record<string, any> | null;
|
|
21
|
+
lastUsedAt: string;
|
|
22
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signin-event-body.interface.js","sourceRoot":"","sources":["../../../src/auth/interfaces/signin-event-body.interface.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export type IdentifierType = "EMAIL" | string;
|
|
2
|
+
export type IdentifierSource = "LOCAL" | string;
|
|
3
|
+
export interface Identifier {
|
|
4
|
+
type: IdentifierType;
|
|
5
|
+
value: string;
|
|
6
|
+
verifiedBy: string | null;
|
|
7
|
+
id: string;
|
|
8
|
+
createdAt: string;
|
|
9
|
+
updatedAt: string;
|
|
10
|
+
deletedAt: string | null;
|
|
11
|
+
isVerified: boolean;
|
|
12
|
+
source: IdentifierSource;
|
|
13
|
+
}
|
|
14
|
+
export interface AuthDTO {
|
|
15
|
+
id: string;
|
|
16
|
+
uid: string;
|
|
17
|
+
strategy: "EMAIL" | string;
|
|
18
|
+
isPrimary: boolean;
|
|
19
|
+
isActive: boolean;
|
|
20
|
+
isVerified: boolean;
|
|
21
|
+
identifiers: Identifier[];
|
|
22
|
+
meta: Record<string, any> | null;
|
|
23
|
+
lastUsedAt: string | null;
|
|
24
|
+
createdAt: string;
|
|
25
|
+
updatedAt: string;
|
|
26
|
+
deletedAt: string | null;
|
|
27
|
+
}
|
|
28
|
+
export interface AuthWithIdentifierResponse {
|
|
29
|
+
auth: AuthDTO;
|
|
30
|
+
identifier: Identifier;
|
|
31
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signup-event-body.interface.js","sourceRoot":"","sources":["../../../src/auth/interfaces/signup-event-body.interface.ts"],"names":[],"mappings":""}
|
package/dist/index.d.ts
CHANGED
|
@@ -22,3 +22,4 @@ export * from './migrations/migration.service';
|
|
|
22
22
|
export * from './auth/enums/auth.events';
|
|
23
23
|
export * from './auth/entities/entities';
|
|
24
24
|
export * from './auth/interfaces/auth-notification-provider.interface';
|
|
25
|
+
export * from './auth/interfaces/signin-event-body.interface';
|
package/dist/index.js
CHANGED
|
@@ -39,4 +39,5 @@ __exportStar(require("./migrations/migration.service"), exports);
|
|
|
39
39
|
__exportStar(require("./auth/enums/auth.events"), exports);
|
|
40
40
|
__exportStar(require("./auth/entities/entities"), exports);
|
|
41
41
|
__exportStar(require("./auth/interfaces/auth-notification-provider.interface"), exports);
|
|
42
|
+
__exportStar(require("./auth/interfaces/signin-event-body.interface"), exports);
|
|
42
43
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,qDAAmC;AACnC,sDAAoC;AACpC,iGAAyG;AAAhG,oIAAA,mBAAmB,OAAA;AAC5B,0EAAwD;AAExD,oEAAkD;AAClD,sEAAoD;AACpD,8DAA4C;AAC5C,8DAA4C;AAC5C,iEAA+C;AAC/C,oEAAkD;AAClD,wEAAsD;AACtD,mEAAiD;AACjD,8DAA4C;AAC5C,gEAA8C;AAC9C,iEAA+C;AAC/C,wEAAsD;AACtD,+DAA6C;AAC7C,oEAAkD;AAClD,uEAAqD;AACrD,iEAA+C;AAC/C,2DAAyC;AACzC,2DAAyC;AACzC,yFAAuE"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,qDAAmC;AACnC,sDAAoC;AACpC,iGAAyG;AAAhG,oIAAA,mBAAmB,OAAA;AAC5B,0EAAwD;AAExD,oEAAkD;AAClD,sEAAoD;AACpD,8DAA4C;AAC5C,8DAA4C;AAC5C,iEAA+C;AAC/C,oEAAkD;AAClD,wEAAsD;AACtD,mEAAiD;AACjD,8DAA4C;AAC5C,gEAA8C;AAC9C,iEAA+C;AAC/C,wEAAsD;AACtD,+DAA6C;AAC7C,oEAAkD;AAClD,uEAAqD;AACrD,iEAA+C;AAC/C,2DAAyC;AACzC,2DAAyC;AACzC,yFAAuE;AACvE,gFAA6D"}
|