@next-nest-auth/nestauth 0.0.6 → 0.0.8
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/LICENSE +1 -1
- package/README.md +1 -4
- package/dist/nestauth-facebook.strategy.d.ts +1 -1
- package/dist/nestauth-google.strategy.d.ts +1 -1
- package/dist/nestauth-jwt.guard.js +5 -0
- package/dist/nestauth-jwt.guard.js.map +1 -1
- package/dist/nestauth-jwt.strategy.d.ts +1 -1
- package/dist/nestauth.interface.d.ts +2 -2
- package/dist/nestauth.module.js +6 -0
- package/dist/nestauth.module.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -1
- package/src/nestauth-jwt.guard.ts +4 -4
- package/src/nestauth.interface.ts +2 -2
- package/src/nestauth.module.ts +4 -4
- package/dist/global-exception.filter.d.ts +0 -4
- package/dist/global-exception.filter.js +0 -30
- package/dist/global-exception.filter.js.map +0 -1
- package/dist/http.exception.filter.d.ts +0 -4
- package/dist/http.exception.filter.js +0 -29
- package/dist/http.exception.filter.js.map +0 -1
- package/dist/jwt-auth.guard.d.ts +0 -4
- package/dist/jwt-auth.guard.js +0 -18
- package/dist/jwt-auth.guard.js.map +0 -1
- package/dist/jwt.guard.d.ts +0 -4
- package/dist/jwt.guard.js +0 -18
- package/dist/jwt.guard.js.map +0 -1
- package/dist/jwt.strategy.d.ts +0 -12
- package/dist/jwt.strategy.js +0 -37
- package/dist/jwt.strategy.js.map +0 -1
- package/dist/local-auth.guard.d.ts +0 -4
- package/dist/local-auth.guard.js +0 -18
- package/dist/local-auth.guard.js.map +0 -1
- package/dist/local.srategy.d.ts +0 -9
- package/dist/local.srategy.js +0 -33
- package/dist/local.srategy.js.map +0 -1
- package/dist/local.strategy.d.ts +0 -11
- package/dist/local.strategy.js +0 -42
- package/dist/local.strategy.js.map +0 -1
- package/dist/nestauth/nestauth.controller.d.ts +0 -2
- package/dist/nestauth/nestauth.controller.js +0 -17
- package/dist/nestauth/nestauth.controller.js.map +0 -1
- package/dist/nestauth/nestauth.controller.spec.d.ts +0 -1
- package/dist/nestauth/nestauth.controller.spec.js +0 -17
- package/dist/nestauth/nestauth.controller.spec.js.map +0 -1
- package/dist/nestauth.guard.d.ts +0 -4
- package/dist/nestauth.guard.js +0 -18
- package/dist/nestauth.guard.js.map +0 -1
- package/dist/nestauth.strategy.d.ts +0 -11
- package/dist/nestauth.strategy.js +0 -38
- package/dist/nestauth.strategy.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@next-nest-auth/nestauth",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"scripts": {
|
|
@@ -26,6 +26,8 @@
|
|
|
26
26
|
"typescript"
|
|
27
27
|
],
|
|
28
28
|
"author": "Md Shafkat Hussain Tanvir <tanvir0604@gmail.com>",
|
|
29
|
+
"repository": "https://github.com/tanvir0604/nestauth",
|
|
30
|
+
"bugs": "https://github.com/tanvir0604/nestauth/issues",
|
|
29
31
|
"license": "MIT",
|
|
30
32
|
"type": "commonjs",
|
|
31
33
|
"description": "NestAuth is an authentication solution for NestJS applications, designed to handle user login, session management, and token-based authentication (JWT). It integrates seamlessly with Next.js and other frontends to provide a unified authentication system, supporting features like refresh tokens, secure cookie handling, and multi-provider authentication.",
|
|
@@ -15,10 +15,10 @@ export class NestAuthJwtGuard extends AuthGuard("jwt") {
|
|
|
15
15
|
if (!user) {
|
|
16
16
|
throw new UnauthorizedException("Unauthorized: Invalid token");
|
|
17
17
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
const currentMacId = await macaddress.one();
|
|
19
|
+
if (user.macId !== currentMacId) {
|
|
20
|
+
throw new UnauthorizedException("Unauthorized: Device mismatch");
|
|
21
|
+
}
|
|
22
22
|
return true;
|
|
23
23
|
}
|
|
24
24
|
}
|
|
@@ -33,6 +33,6 @@ export type FacebookProfileType = SocialProfileType;
|
|
|
33
33
|
export interface NestAuthInterface {
|
|
34
34
|
validateUser(params: any): Promise<JwtPayloadType>;
|
|
35
35
|
getUserById(id: number): Promise<JwtPayloadType>;
|
|
36
|
-
google(params: GoogleProfileType): Promise<JwtPayloadType>;
|
|
37
|
-
facebook(params: FacebookProfileType): Promise<JwtPayloadType>;
|
|
36
|
+
google?(params: GoogleProfileType): Promise<JwtPayloadType>;
|
|
37
|
+
facebook?(params: FacebookProfileType): Promise<JwtPayloadType>;
|
|
38
38
|
}
|
package/src/nestauth.module.ts
CHANGED
|
@@ -61,10 +61,10 @@ export class NestAuthModule {
|
|
|
61
61
|
JwtSecretProvider,
|
|
62
62
|
JwtExpiresInProvider,
|
|
63
63
|
JwtRefreshTokenExpiresInProvider,
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
64
|
+
{
|
|
65
|
+
provide: APP_FILTER,
|
|
66
|
+
useClass: HttpExceptionFilter,
|
|
67
|
+
},
|
|
68
68
|
],
|
|
69
69
|
exports: [NestAuthService],
|
|
70
70
|
controllers: [NestAuthController],
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.GlobalExceptionFilter = void 0;
|
|
10
|
-
const common_1 = require("@nestjs/common");
|
|
11
|
-
let GlobalExceptionFilter = class GlobalExceptionFilter {
|
|
12
|
-
catch(exception, host) {
|
|
13
|
-
const ctx = host.switchToHttp();
|
|
14
|
-
const response = ctx.getResponse();
|
|
15
|
-
const request = ctx.getRequest();
|
|
16
|
-
const status = exception instanceof common_1.HttpException ? exception.getStatus() : 500;
|
|
17
|
-
const message = exception.message;
|
|
18
|
-
response.status(status).json({
|
|
19
|
-
statusCode: status,
|
|
20
|
-
message: message,
|
|
21
|
-
path: request.url,
|
|
22
|
-
app: "nestauth",
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
exports.GlobalExceptionFilter = GlobalExceptionFilter;
|
|
27
|
-
exports.GlobalExceptionFilter = GlobalExceptionFilter = __decorate([
|
|
28
|
-
(0, common_1.Catch)()
|
|
29
|
-
], GlobalExceptionFilter);
|
|
30
|
-
//# sourceMappingURL=global-exception.filter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"global-exception.filter.js","sourceRoot":"","sources":["../src/global-exception.filter.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAKwB;AAIjB,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;IAC9B,KAAK,CAAC,SAAkB,EAAE,IAAmB;QACzC,MAAM,GAAG,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;QAChC,MAAM,QAAQ,GAAG,GAAG,CAAC,WAAW,EAAY,CAAC;QAC7C,MAAM,OAAO,GAAG,GAAG,CAAC,UAAU,EAAW,CAAC;QAC1C,MAAM,MAAM,GACR,SAAS,YAAY,sBAAa,CAAC,CAAC,CAAC,SAAS,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;QACrE,MAAM,OAAO,GAAG,SAAS,CAAC,OAAO,CAAC;QAElC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC;YACzB,UAAU,EAAE,MAAM;YAClB,OAAO,EAAE,OAAO;YAChB,IAAI,EAAE,OAAO,CAAC,GAAG;YACjB,GAAG,EAAE,UAAU;SAClB,CAAC,CAAC;IACP,CAAC;CACJ,CAAA;AAhBY,sDAAqB;gCAArB,qBAAqB;IADjC,IAAA,cAAK,GAAE;GACK,qBAAqB,CAgBjC"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.HttpExceptionFilter = void 0;
|
|
10
|
-
const common_1 = require("@nestjs/common");
|
|
11
|
-
let HttpExceptionFilter = class HttpExceptionFilter {
|
|
12
|
-
catch(exception, host) {
|
|
13
|
-
const ctx = host.switchToHttp();
|
|
14
|
-
const response = ctx.getResponse();
|
|
15
|
-
const request = ctx.getRequest();
|
|
16
|
-
const status = exception.getStatus();
|
|
17
|
-
const message = exception.getResponse();
|
|
18
|
-
response.status(status).json({
|
|
19
|
-
statusCode: status,
|
|
20
|
-
message: message,
|
|
21
|
-
path: request.url,
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
exports.HttpExceptionFilter = HttpExceptionFilter;
|
|
26
|
-
exports.HttpExceptionFilter = HttpExceptionFilter = __decorate([
|
|
27
|
-
(0, common_1.Catch)(common_1.HttpException)
|
|
28
|
-
], HttpExceptionFilter);
|
|
29
|
-
//# sourceMappingURL=http.exception.filter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"http.exception.filter.js","sourceRoot":"","sources":["../src/http.exception.filter.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAKwB;AAIjB,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IAC5B,KAAK,CAAC,SAAwB,EAAE,IAAmB;QAC/C,MAAM,GAAG,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;QAChC,MAAM,QAAQ,GAAG,GAAG,CAAC,WAAW,EAAY,CAAC;QAC7C,MAAM,OAAO,GAAG,GAAG,CAAC,UAAU,EAAW,CAAC;QAC1C,MAAM,MAAM,GAAG,SAAS,CAAC,SAAS,EAAE,CAAC;QACrC,MAAM,OAAO,GAAG,SAAS,CAAC,WAAW,EAAE,CAAC;QAExC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC;YACzB,UAAU,EAAE,MAAM;YAClB,OAAO,EAAE,OAAO;YAChB,IAAI,EAAE,OAAO,CAAC,GAAG;SACpB,CAAC,CAAC;IACP,CAAC;CACJ,CAAA;AAdY,kDAAmB;8BAAnB,mBAAmB;IAD/B,IAAA,cAAK,EAAC,sBAAa,CAAC;GACR,mBAAmB,CAc/B"}
|
package/dist/jwt-auth.guard.d.ts
DELETED
package/dist/jwt-auth.guard.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.JwtAuthGuard = void 0;
|
|
10
|
-
const common_1 = require("@nestjs/common");
|
|
11
|
-
const passport_1 = require("@nestjs/passport");
|
|
12
|
-
let JwtAuthGuard = class JwtAuthGuard extends (0, passport_1.AuthGuard)("jwt") {
|
|
13
|
-
};
|
|
14
|
-
exports.JwtAuthGuard = JwtAuthGuard;
|
|
15
|
-
exports.JwtAuthGuard = JwtAuthGuard = __decorate([
|
|
16
|
-
(0, common_1.Injectable)()
|
|
17
|
-
], JwtAuthGuard);
|
|
18
|
-
//# sourceMappingURL=jwt-auth.guard.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"jwt-auth.guard.js","sourceRoot":"","sources":["../src/jwt-auth.guard.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA4C;AAC5C,+CAA6C;AAGtC,IAAM,YAAY,GAAlB,MAAM,YAAa,SAAQ,IAAA,oBAAS,EAAC,KAAK,CAAC;CAAG,CAAA;AAAxC,oCAAY;uBAAZ,YAAY;IADxB,IAAA,mBAAU,GAAE;GACA,YAAY,CAA4B"}
|
package/dist/jwt.guard.d.ts
DELETED
package/dist/jwt.guard.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.NestAuthJwtAuthGuard = void 0;
|
|
10
|
-
const common_1 = require("@nestjs/common");
|
|
11
|
-
const passport_1 = require("@nestjs/passport");
|
|
12
|
-
let NestAuthJwtAuthGuard = class NestAuthJwtAuthGuard extends (0, passport_1.AuthGuard)("jwt") {
|
|
13
|
-
};
|
|
14
|
-
exports.NestAuthJwtAuthGuard = NestAuthJwtAuthGuard;
|
|
15
|
-
exports.NestAuthJwtAuthGuard = NestAuthJwtAuthGuard = __decorate([
|
|
16
|
-
(0, common_1.Injectable)()
|
|
17
|
-
], NestAuthJwtAuthGuard);
|
|
18
|
-
//# sourceMappingURL=jwt.guard.js.map
|
package/dist/jwt.guard.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"jwt.guard.js","sourceRoot":"","sources":["../src/jwt.guard.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA4C;AAC5C,+CAA6C;AAGtC,IAAM,oBAAoB,GAA1B,MAAM,oBAAqB,SAAQ,IAAA,oBAAS,EAAC,KAAK,CAAC;CAAG,CAAA;AAAhD,oDAAoB;+BAApB,oBAAoB;IADhC,IAAA,mBAAU,GAAE;GACA,oBAAoB,CAA4B"}
|
package/dist/jwt.strategy.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Strategy } from "passport-jwt";
|
|
2
|
-
declare const JwtStrategy_base: new (...args: [opt: import("passport-jwt").StrategyOptionsWithoutRequest] | [opt: import("passport-jwt").StrategyOptionsWithRequest]) => Strategy & {
|
|
3
|
-
validate(...args: any[]): unknown;
|
|
4
|
-
};
|
|
5
|
-
export declare class JwtStrategy extends JwtStrategy_base {
|
|
6
|
-
constructor(jwtSecret: string);
|
|
7
|
-
validate(payload: any): Promise<{
|
|
8
|
-
userId: any;
|
|
9
|
-
username: any;
|
|
10
|
-
}>;
|
|
11
|
-
}
|
|
12
|
-
export {};
|
package/dist/jwt.strategy.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
-
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.JwtStrategy = void 0;
|
|
16
|
-
const passport_jwt_1 = require("passport-jwt");
|
|
17
|
-
const passport_1 = require("@nestjs/passport");
|
|
18
|
-
const common_1 = require("@nestjs/common");
|
|
19
|
-
let JwtStrategy = class JwtStrategy extends (0, passport_1.PassportStrategy)(passport_jwt_1.Strategy) {
|
|
20
|
-
constructor(jwtSecret) {
|
|
21
|
-
super({
|
|
22
|
-
jwtFromRequest: passport_jwt_1.ExtractJwt.fromAuthHeaderAsBearerToken(),
|
|
23
|
-
ignoreExpiration: false,
|
|
24
|
-
secretOrKey: jwtSecret,
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
async validate(payload) {
|
|
28
|
-
return { userId: payload.sub, username: payload.username };
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
exports.JwtStrategy = JwtStrategy;
|
|
32
|
-
exports.JwtStrategy = JwtStrategy = __decorate([
|
|
33
|
-
(0, common_1.Injectable)(),
|
|
34
|
-
__param(0, (0, common_1.Inject)("JWT_SECRET")),
|
|
35
|
-
__metadata("design:paramtypes", [String])
|
|
36
|
-
], JwtStrategy);
|
|
37
|
-
//# sourceMappingURL=jwt.strategy.js.map
|
package/dist/jwt.strategy.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"jwt.strategy.js","sourceRoot":"","sources":["../src/jwt.strategy.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+CAAoD;AACpD,+CAAoD;AACpD,2CAAoD;AAG7C,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQ,IAAA,2BAAgB,EAAC,uBAAQ,CAAC;IACvD,YAAkC,SAAiB;QAC/C,KAAK,CAAC;YACF,cAAc,EAAE,yBAAU,CAAC,2BAA2B,EAAE;YACxD,gBAAgB,EAAE,KAAK;YACvB,WAAW,EAAE,SAAS;SACzB,CAAC,CAAC;IACP,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,OAAY;QACvB,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,CAAC;IAC/D,CAAC;CACJ,CAAA;AAZY,kCAAW;sBAAX,WAAW;IADvB,IAAA,mBAAU,GAAE;IAEI,WAAA,IAAA,eAAM,EAAC,YAAY,CAAC,CAAA;;GADxB,WAAW,CAYvB"}
|
package/dist/local-auth.guard.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.LocalAuthGuard = void 0;
|
|
10
|
-
const common_1 = require("@nestjs/common");
|
|
11
|
-
const passport_1 = require("@nestjs/passport");
|
|
12
|
-
let LocalAuthGuard = class LocalAuthGuard extends (0, passport_1.AuthGuard)("local") {
|
|
13
|
-
};
|
|
14
|
-
exports.LocalAuthGuard = LocalAuthGuard;
|
|
15
|
-
exports.LocalAuthGuard = LocalAuthGuard = __decorate([
|
|
16
|
-
(0, common_1.Injectable)()
|
|
17
|
-
], LocalAuthGuard);
|
|
18
|
-
//# sourceMappingURL=local-auth.guard.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"local-auth.guard.js","sourceRoot":"","sources":["../src/local-auth.guard.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA4C;AAC5C,+CAA6C;AAGtC,IAAM,cAAc,GAApB,MAAM,cAAe,SAAQ,IAAA,oBAAS,EAAC,OAAO,CAAC;CAAG,CAAA;AAA5C,wCAAc;yBAAd,cAAc;IAD1B,IAAA,mBAAU,GAAE;GACA,cAAc,CAA8B"}
|
package/dist/local.srategy.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Strategy } from "passport-local";
|
|
2
|
-
declare const LocalStrategy_base: new (...args: [options: import("passport-local").IStrategyOptionsWithRequest] | [options: import("passport-local").IStrategyOptions] | []) => Strategy & {
|
|
3
|
-
validate(...args: any[]): unknown;
|
|
4
|
-
};
|
|
5
|
-
export declare class LocalStrategy extends LocalStrategy_base {
|
|
6
|
-
constructor();
|
|
7
|
-
validate(validateUser: Function): Promise<any>;
|
|
8
|
-
}
|
|
9
|
-
export {};
|
package/dist/local.srategy.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.LocalStrategy = void 0;
|
|
13
|
-
const passport_local_1 = require("passport-local");
|
|
14
|
-
const passport_1 = require("@nestjs/passport");
|
|
15
|
-
const common_1 = require("@nestjs/common");
|
|
16
|
-
let LocalStrategy = class LocalStrategy extends (0, passport_1.PassportStrategy)(passport_local_1.Strategy) {
|
|
17
|
-
constructor() {
|
|
18
|
-
super();
|
|
19
|
-
}
|
|
20
|
-
async validate(validateUser) {
|
|
21
|
-
const user = await validateUser();
|
|
22
|
-
if (!user) {
|
|
23
|
-
throw new common_1.UnauthorizedException();
|
|
24
|
-
}
|
|
25
|
-
return user;
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
exports.LocalStrategy = LocalStrategy;
|
|
29
|
-
exports.LocalStrategy = LocalStrategy = __decorate([
|
|
30
|
-
(0, common_1.Injectable)(),
|
|
31
|
-
__metadata("design:paramtypes", [])
|
|
32
|
-
], LocalStrategy);
|
|
33
|
-
//# sourceMappingURL=local.srategy.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"local.srategy.js","sourceRoot":"","sources":["../src/local.srategy.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mDAA0C;AAC1C,+CAAoD;AACpD,2CAAmE;AAG5D,IAAM,aAAa,GAAnB,MAAM,aAAc,SAAQ,IAAA,2BAAgB,EAAC,yBAAQ,CAAC;IACzD;QACI,KAAK,EAAE,CAAC;IACZ,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,YAAsB;QACjC,MAAM,IAAI,GAAG,MAAM,YAAY,EAAE,CAAC;QAClC,IAAI,CAAC,IAAI,EAAE,CAAC;YACR,MAAM,IAAI,8BAAqB,EAAE,CAAC;QACtC,CAAC;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ,CAAA;AAZY,sCAAa;wBAAb,aAAa;IADzB,IAAA,mBAAU,GAAE;;GACA,aAAa,CAYzB"}
|
package/dist/local.strategy.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Strategy } from "passport-local";
|
|
2
|
-
import { NestAuthInterface } from "./nestauth.interface";
|
|
3
|
-
declare const LocalStrategy_base: new (...args: [options: import("passport-local").IStrategyOptionsWithRequest] | [options: import("passport-local").IStrategyOptions] | []) => Strategy & {
|
|
4
|
-
validate(...args: any[]): unknown;
|
|
5
|
-
};
|
|
6
|
-
export declare class LocalStrategy extends LocalStrategy_base {
|
|
7
|
-
private readonly userService;
|
|
8
|
-
constructor(userService: NestAuthInterface);
|
|
9
|
-
validate(username: string, password: string, mobile: string): Promise<any>;
|
|
10
|
-
}
|
|
11
|
-
export {};
|
package/dist/local.strategy.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
-
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.LocalStrategy = void 0;
|
|
16
|
-
const passport_local_1 = require("passport-local");
|
|
17
|
-
const passport_1 = require("@nestjs/passport");
|
|
18
|
-
const common_1 = require("@nestjs/common");
|
|
19
|
-
let LocalStrategy = class LocalStrategy extends (0, passport_1.PassportStrategy)(passport_local_1.Strategy) {
|
|
20
|
-
constructor(userService) {
|
|
21
|
-
super();
|
|
22
|
-
this.userService = userService;
|
|
23
|
-
}
|
|
24
|
-
async validate(username, password, mobile) {
|
|
25
|
-
const user = await this.userService.validateUser({
|
|
26
|
-
username,
|
|
27
|
-
password,
|
|
28
|
-
mobile,
|
|
29
|
-
});
|
|
30
|
-
if (!user) {
|
|
31
|
-
throw new common_1.UnauthorizedException();
|
|
32
|
-
}
|
|
33
|
-
return user;
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
exports.LocalStrategy = LocalStrategy;
|
|
37
|
-
exports.LocalStrategy = LocalStrategy = __decorate([
|
|
38
|
-
(0, common_1.Injectable)(),
|
|
39
|
-
__param(0, (0, common_1.Inject)("UserService")),
|
|
40
|
-
__metadata("design:paramtypes", [Object])
|
|
41
|
-
], LocalStrategy);
|
|
42
|
-
//# sourceMappingURL=local.strategy.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"local.strategy.js","sourceRoot":"","sources":["../src/local.strategy.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,mDAA0C;AAC1C,+CAAoD;AACpD,2CAA2E;AAIpE,IAAM,aAAa,GAAnB,MAAM,aAAc,SAAQ,IAAA,2BAAgB,EAAC,yBAAQ,CAAC;IACzD,YAC4C,WAA8B;QAEtE,KAAK,EAAE,CAAC;QAFgC,gBAAW,GAAX,WAAW,CAAmB;IAG1E,CAAC;IAED,KAAK,CAAC,QAAQ,CACV,QAAgB,EAChB,QAAgB,EAChB,MAAc;QAEd,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC;YAC7C,QAAQ;YACR,QAAQ;YACR,MAAM;SACT,CAAC,CAAC;QACH,IAAI,CAAC,IAAI,EAAE,CAAC;YACR,MAAM,IAAI,8BAAqB,EAAE,CAAC;QACtC,CAAC;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ,CAAA;AAtBY,sCAAa;wBAAb,aAAa;IADzB,IAAA,mBAAU,GAAE;IAGJ,WAAA,IAAA,eAAM,EAAC,aAAa,CAAC,CAAA;;GAFjB,aAAa,CAsBzB"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.NestauthController = void 0;
|
|
10
|
-
const common_1 = require("@nestjs/common");
|
|
11
|
-
let NestauthController = class NestauthController {
|
|
12
|
-
};
|
|
13
|
-
exports.NestauthController = NestauthController;
|
|
14
|
-
exports.NestauthController = NestauthController = __decorate([
|
|
15
|
-
(0, common_1.Controller)('nestauth')
|
|
16
|
-
], NestauthController);
|
|
17
|
-
//# sourceMappingURL=nestauth.controller.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"nestauth.controller.js","sourceRoot":"","sources":["../../src/nestauth/nestauth.controller.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA4C;AAGrC,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;CAAG,CAAA;AAArB,gDAAkB;6BAAlB,kBAAkB;IAD9B,IAAA,mBAAU,EAAC,UAAU,CAAC;GACV,kBAAkB,CAAG"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const testing_1 = require("@nestjs/testing");
|
|
4
|
-
const nestauth_controller_1 = require("../nestauth.controller");
|
|
5
|
-
describe("NestauthController", () => {
|
|
6
|
-
let controller;
|
|
7
|
-
beforeEach(async () => {
|
|
8
|
-
const module = await testing_1.Test.createTestingModule({
|
|
9
|
-
controllers: [nestauth_controller_1.NestauthController],
|
|
10
|
-
}).compile();
|
|
11
|
-
controller = module.get(nestauth_controller_1.NestauthController);
|
|
12
|
-
});
|
|
13
|
-
it("should be defined", () => {
|
|
14
|
-
expect(controller).toBeDefined();
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
//# sourceMappingURL=nestauth.controller.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"nestauth.controller.spec.js","sourceRoot":"","sources":["../../src/nestauth/nestauth.controller.spec.ts"],"names":[],"mappings":";;AAAA,6CAAsD;AACtD,gEAA4D;AAE5D,QAAQ,CAAC,oBAAoB,EAAE,GAAG,EAAE;IAChC,IAAI,UAA8B,CAAC;IAEnC,UAAU,CAAC,KAAK,IAAI,EAAE;QAClB,MAAM,MAAM,GAAkB,MAAM,cAAI,CAAC,mBAAmB,CAAC;YACzD,WAAW,EAAE,CAAC,wCAAkB,CAAC;SACpC,CAAC,CAAC,OAAO,EAAE,CAAC;QAEb,UAAU,GAAG,MAAM,CAAC,GAAG,CAAqB,wCAAkB,CAAC,CAAC;IACpE,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,mBAAmB,EAAE,GAAG,EAAE;QACzB,MAAM,CAAC,UAAU,CAAC,CAAC,WAAW,EAAE,CAAC;IACrC,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
package/dist/nestauth.guard.d.ts
DELETED
package/dist/nestauth.guard.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.NestAuthGuard = void 0;
|
|
10
|
-
const common_1 = require("@nestjs/common");
|
|
11
|
-
const passport_1 = require("@nestjs/passport");
|
|
12
|
-
let NestAuthGuard = class NestAuthGuard extends (0, passport_1.AuthGuard)("nestauth") {
|
|
13
|
-
};
|
|
14
|
-
exports.NestAuthGuard = NestAuthGuard;
|
|
15
|
-
exports.NestAuthGuard = NestAuthGuard = __decorate([
|
|
16
|
-
(0, common_1.Injectable)()
|
|
17
|
-
], NestAuthGuard);
|
|
18
|
-
//# sourceMappingURL=nestauth.guard.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"nestauth.guard.js","sourceRoot":"","sources":["../src/nestauth.guard.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA4C;AAC5C,+CAA6C;AAGtC,IAAM,aAAa,GAAnB,MAAM,aAAc,SAAQ,IAAA,oBAAS,EAAC,UAAU,CAAC;CAAG,CAAA;AAA9C,sCAAa;wBAAb,aAAa;IADzB,IAAA,mBAAU,GAAE;GACA,aAAa,CAAiC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Strategy } from "passport-custom";
|
|
2
|
-
import { NestAuthInterface } from "./nestauth.interface";
|
|
3
|
-
declare const NestAuthStrategy_base: new () => Strategy & {
|
|
4
|
-
validate(...args: any[]): unknown;
|
|
5
|
-
};
|
|
6
|
-
export declare class NestAuthStrategy extends NestAuthStrategy_base {
|
|
7
|
-
private readonly userService;
|
|
8
|
-
constructor(userService: NestAuthInterface);
|
|
9
|
-
validate(req: Request): Promise<any>;
|
|
10
|
-
}
|
|
11
|
-
export {};
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
-
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.NestAuthStrategy = void 0;
|
|
16
|
-
const passport_1 = require("@nestjs/passport");
|
|
17
|
-
const passport_custom_1 = require("passport-custom");
|
|
18
|
-
const common_1 = require("@nestjs/common");
|
|
19
|
-
let NestAuthStrategy = class NestAuthStrategy extends (0, passport_1.PassportStrategy)(passport_custom_1.Strategy, "nestauth") {
|
|
20
|
-
constructor(userService) {
|
|
21
|
-
super();
|
|
22
|
-
this.userService = userService;
|
|
23
|
-
}
|
|
24
|
-
async validate(req) {
|
|
25
|
-
const user = await this.userService.validateUser(req.body);
|
|
26
|
-
if (!user) {
|
|
27
|
-
throw new common_1.UnauthorizedException("Invalid credentials");
|
|
28
|
-
}
|
|
29
|
-
return user;
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
exports.NestAuthStrategy = NestAuthStrategy;
|
|
33
|
-
exports.NestAuthStrategy = NestAuthStrategy = __decorate([
|
|
34
|
-
(0, common_1.Injectable)(),
|
|
35
|
-
__param(0, (0, common_1.Inject)("UserService")),
|
|
36
|
-
__metadata("design:paramtypes", [Object])
|
|
37
|
-
], NestAuthStrategy);
|
|
38
|
-
//# sourceMappingURL=nestauth.strategy.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"nestauth.strategy.js","sourceRoot":"","sources":["../src/nestauth.strategy.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+CAAoD;AACpD,qDAA2C;AAC3C,2CAA2E;AAIpE,IAAM,gBAAgB,GAAtB,MAAM,gBAAiB,SAAQ,IAAA,2BAAgB,EAAC,0BAAQ,EAAE,UAAU,CAAC;IACxE,YAC4C,WAA8B;QAEtE,KAAK,EAAE,CAAC;QAFgC,gBAAW,GAAX,WAAW,CAAmB;IAG1E,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,GAAY;QAGvB,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAE3D,IAAI,CAAC,IAAI,EAAE,CAAC;YACR,MAAM,IAAI,8BAAqB,CAAC,qBAAqB,CAAC,CAAC;QAC3D,CAAC;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ,CAAA;AAlBY,4CAAgB;2BAAhB,gBAAgB;IAD5B,IAAA,mBAAU,GAAE;IAGJ,WAAA,IAAA,eAAM,EAAC,aAAa,CAAC,CAAA;;GAFjB,gBAAgB,CAkB5B"}
|