@next-nest-auth/nestauth 1.2.6 → 1.2.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/dist/src/http-exception.filter.d.ts +4 -0
- package/dist/src/http-exception.filter.js +65 -0
- package/dist/src/http-exception.filter.js.map +1 -0
- package/dist/src/index.d.ts +5 -0
- package/dist/src/index.js +22 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/nestauth-facebook.guard.d.ts +7 -0
- package/dist/src/nestauth-facebook.guard.js +29 -0
- package/dist/src/nestauth-facebook.guard.js.map +1 -0
- package/dist/src/nestauth-facebook.strategy.d.ts +9 -0
- package/dist/src/nestauth-facebook.strategy.js +45 -0
- package/dist/src/nestauth-facebook.strategy.js.map +1 -0
- package/dist/src/nestauth-google.guard.d.ts +7 -0
- package/dist/src/nestauth-google.guard.js +29 -0
- package/dist/src/nestauth-google.guard.js.map +1 -0
- package/dist/src/nestauth-google.strategy.d.ts +9 -0
- package/dist/src/nestauth-google.strategy.js +44 -0
- package/dist/src/nestauth-google.strategy.js.map +1 -0
- package/dist/src/nestauth-jwt.guard.d.ts +7 -0
- package/dist/src/nestauth-jwt.guard.js +40 -0
- package/dist/src/nestauth-jwt.guard.js.map +1 -0
- package/dist/src/nestauth-jwt.strategy.d.ts +10 -0
- package/dist/src/nestauth-jwt.strategy.js +51 -0
- package/dist/src/nestauth-jwt.strategy.js.map +1 -0
- package/dist/src/nestauth-local.guard.d.ts +20 -0
- package/dist/src/nestauth-local.guard.js +20 -0
- package/dist/src/nestauth-local.guard.js.map +1 -0
- package/dist/src/nestauth-local.strategy.d.ts +14 -0
- package/dist/src/nestauth-local.strategy.js +42 -0
- package/dist/src/nestauth-local.strategy.js.map +1 -0
- package/dist/src/nestauth.controller.d.ts +16 -0
- package/dist/src/nestauth.controller.js +126 -0
- package/dist/src/nestauth.controller.js.map +1 -0
- package/dist/src/nestauth.interface.d.ts +36 -0
- package/dist/src/nestauth.interface.js +3 -0
- package/dist/src/nestauth.interface.js.map +1 -0
- package/dist/src/nestauth.module.d.ts +5 -0
- package/dist/src/nestauth.module.js +96 -0
- package/dist/src/nestauth.module.js.map +1 -0
- package/dist/src/nestauth.service.d.ts +14 -0
- package/dist/src/nestauth.service.js +72 -0
- package/dist/src/nestauth.service.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +61 -61
- package/src/nestauth-jwt.guard.ts +25 -27
- package/src/nestauth.controller.ts +69 -73
- package/src/nestauth.module.ts +91 -96
|
@@ -0,0 +1,65 @@
|
|
|
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
|
+
let status = 500;
|
|
17
|
+
let message = "Internal Server Error";
|
|
18
|
+
if (exception instanceof common_1.HttpException ||
|
|
19
|
+
(exception?.status && exception?.response)) {
|
|
20
|
+
status = exception.status ?? 500;
|
|
21
|
+
const exceptionResponse = exception.response ?? exception.getResponse?.();
|
|
22
|
+
if (typeof exceptionResponse === "string") {
|
|
23
|
+
message = exceptionResponse;
|
|
24
|
+
}
|
|
25
|
+
else if (typeof exceptionResponse === "object" &&
|
|
26
|
+
exceptionResponse.message) {
|
|
27
|
+
message = exceptionResponse.message;
|
|
28
|
+
}
|
|
29
|
+
else if (typeof exceptionResponse === "object" &&
|
|
30
|
+
exceptionResponse.error) {
|
|
31
|
+
message = exceptionResponse.error;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
console.error("Unexpected error:", exception);
|
|
36
|
+
}
|
|
37
|
+
const responseBody = {
|
|
38
|
+
statusCode: status,
|
|
39
|
+
message,
|
|
40
|
+
path: request?.url,
|
|
41
|
+
app: "nestauth",
|
|
42
|
+
};
|
|
43
|
+
try {
|
|
44
|
+
if (typeof response.status === "function" &&
|
|
45
|
+
typeof response.json === "function") {
|
|
46
|
+
response.status(status).json(responseBody);
|
|
47
|
+
}
|
|
48
|
+
else if (typeof response.send === "function") {
|
|
49
|
+
response.code?.(status);
|
|
50
|
+
response.send(responseBody);
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
console.error("Unsupported response object:", response);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
catch (err) {
|
|
57
|
+
console.error("Error while sending error response:", err);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
exports.HttpExceptionFilter = HttpExceptionFilter;
|
|
62
|
+
exports.HttpExceptionFilter = HttpExceptionFilter = __decorate([
|
|
63
|
+
(0, common_1.Catch)()
|
|
64
|
+
], HttpExceptionFilter);
|
|
65
|
+
//# sourceMappingURL=http-exception.filter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-exception.filter.js","sourceRoot":"","sources":["../../src/http-exception.filter.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAKwB;AAGjB,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IAC5B,KAAK,CAAC,SAAc,EAAE,IAAmB;QACrC,MAAM,GAAG,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;QAChC,MAAM,QAAQ,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC;QACnC,MAAM,OAAO,GAAG,GAAG,CAAC,UAAU,EAAE,CAAC;QAEjC,IAAI,MAAM,GAAG,GAAG,CAAC;QACjB,IAAI,OAAO,GAAG,uBAAuB,CAAC;QAEtC,IACI,SAAS,YAAY,sBAAa;YAClC,CAAC,SAAS,EAAE,MAAM,IAAI,SAAS,EAAE,QAAQ,CAAC,EAC5C,CAAC;YACC,MAAM,GAAG,SAAS,CAAC,MAAM,IAAI,GAAG,CAAC;YACjC,MAAM,iBAAiB,GACnB,SAAS,CAAC,QAAQ,IAAI,SAAS,CAAC,WAAW,EAAE,EAAE,CAAC;YAEpD,IAAI,OAAO,iBAAiB,KAAK,QAAQ,EAAE,CAAC;gBACxC,OAAO,GAAG,iBAAiB,CAAC;YAChC,CAAC;iBAAM,IACH,OAAO,iBAAiB,KAAK,QAAQ;gBACpC,iBAAyB,CAAC,OAAO,EACpC,CAAC;gBACC,OAAO,GAAI,iBAAyB,CAAC,OAAO,CAAC;YACjD,CAAC;iBAAM,IACH,OAAO,iBAAiB,KAAK,QAAQ;gBACpC,iBAAyB,CAAC,KAAK,EAClC,CAAC;gBACC,OAAO,GAAI,iBAAyB,CAAC,KAAK,CAAC;YAC/C,CAAC;QACL,CAAC;aAAM,CAAC;YACJ,OAAO,CAAC,KAAK,CAAC,mBAAmB,EAAE,SAAS,CAAC,CAAC;QAClD,CAAC;QAED,MAAM,YAAY,GAAG;YACjB,UAAU,EAAE,MAAM;YAClB,OAAO;YACP,IAAI,EAAE,OAAO,EAAE,GAAG;YAClB,GAAG,EAAE,UAAU;SAClB,CAAC;QAGF,IAAI,CAAC;YACD,IACI,OAAO,QAAQ,CAAC,MAAM,KAAK,UAAU;gBACrC,OAAO,QAAQ,CAAC,IAAI,KAAK,UAAU,EACrC,CAAC;gBACC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;YAC/C,CAAC;iBAAM,IAAI,OAAO,QAAQ,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;gBAC7C,QAAQ,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC,CAAC;gBACxB,QAAQ,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;YAChC,CAAC;iBAAM,CAAC;gBACJ,OAAO,CAAC,KAAK,CAAC,8BAA8B,EAAE,QAAQ,CAAC,CAAC;YAC5D,CAAC;QACL,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACX,OAAO,CAAC,KAAK,CAAC,qCAAqC,EAAE,GAAG,CAAC,CAAC;QAC9D,CAAC;IACL,CAAC;CACJ,CAAA;AA1DY,kDAAmB;8BAAnB,mBAAmB;IAD/B,IAAA,cAAK,GAAE;GACK,mBAAmB,CA0D/B"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./nestauth.module"), exports);
|
|
18
|
+
__exportStar(require("./nestauth.service"), exports);
|
|
19
|
+
__exportStar(require("./nestauth.interface"), exports);
|
|
20
|
+
__exportStar(require("./nestauth-jwt.guard"), exports);
|
|
21
|
+
__exportStar(require("./nestauth-jwt.strategy"), exports);
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAkC;AAClC,qDAAmC;AACnC,uDAAqC;AACrC,uDAAqC;AAErC,0DAAwC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ConfigService } from "@nestjs/config";
|
|
2
|
+
declare const NestAuthFacebookGuard_base: import("@nestjs/passport").Type<import("@nestjs/passport").IAuthGuard>;
|
|
3
|
+
export declare class NestAuthFacebookGuard extends NestAuthFacebookGuard_base {
|
|
4
|
+
private configService;
|
|
5
|
+
constructor(configService: ConfigService);
|
|
6
|
+
}
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
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.NestAuthFacebookGuard = void 0;
|
|
13
|
+
const common_1 = require("@nestjs/common");
|
|
14
|
+
const config_1 = require("@nestjs/config");
|
|
15
|
+
const passport_1 = require("@nestjs/passport");
|
|
16
|
+
let NestAuthFacebookGuard = class NestAuthFacebookGuard extends (0, passport_1.AuthGuard)("facebook") {
|
|
17
|
+
constructor(configService) {
|
|
18
|
+
super({
|
|
19
|
+
accessType: "offline",
|
|
20
|
+
});
|
|
21
|
+
this.configService = configService;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
exports.NestAuthFacebookGuard = NestAuthFacebookGuard;
|
|
25
|
+
exports.NestAuthFacebookGuard = NestAuthFacebookGuard = __decorate([
|
|
26
|
+
(0, common_1.Injectable)(),
|
|
27
|
+
__metadata("design:paramtypes", [config_1.ConfigService])
|
|
28
|
+
], NestAuthFacebookGuard);
|
|
29
|
+
//# sourceMappingURL=nestauth-facebook.guard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nestauth-facebook.guard.js","sourceRoot":"","sources":["../../src/nestauth-facebook.guard.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,2CAA+C;AAC/C,+CAA6C;AAGtC,IAAM,qBAAqB,GAA3B,MAAM,qBAAsB,SAAQ,IAAA,oBAAS,EAAC,UAAU,CAAC;IAC5D,YAAoB,aAA4B;QAC5C,KAAK,CAAC;YACF,UAAU,EAAE,SAAS;SACxB,CAAC,CAAC;QAHa,kBAAa,GAAb,aAAa,CAAe;IAIhD,CAAC;CACJ,CAAA;AANY,sDAAqB;gCAArB,qBAAqB;IADjC,IAAA,mBAAU,GAAE;qCAE0B,sBAAa;GADvC,qBAAqB,CAMjC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Profile, Strategy } from "passport-facebook";
|
|
2
|
+
declare const NestAuthFacebookStrategy_base: new (...args: [options: import("passport-facebook").StrategyOptionsWithRequest] | [options: import("passport-facebook").StrategyOptions]) => Strategy & {
|
|
3
|
+
validate(...args: any[]): unknown;
|
|
4
|
+
};
|
|
5
|
+
export declare class NestAuthFacebookStrategy extends NestAuthFacebookStrategy_base {
|
|
6
|
+
constructor();
|
|
7
|
+
validate(accessToken: string, refreshToken: string, profile: Profile, done: (err: any, user: any, info?: any) => void): Promise<any>;
|
|
8
|
+
}
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
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.NestAuthFacebookStrategy = void 0;
|
|
13
|
+
const passport_1 = require("@nestjs/passport");
|
|
14
|
+
const passport_facebook_1 = require("passport-facebook");
|
|
15
|
+
const common_1 = require("@nestjs/common");
|
|
16
|
+
let NestAuthFacebookStrategy = class NestAuthFacebookStrategy extends (0, passport_1.PassportStrategy)(passport_facebook_1.Strategy, "facebook") {
|
|
17
|
+
constructor() {
|
|
18
|
+
super({
|
|
19
|
+
clientID: process.env.FACEBOOK_APP_ID || "your-app-id",
|
|
20
|
+
clientSecret: process.env.FACEBOOK_APP_SECRET || "your-app-secret",
|
|
21
|
+
callbackURL: process.env.BASE_URL + "/nestauth/facebook-redirect",
|
|
22
|
+
scope: ["email", "public_profile"],
|
|
23
|
+
profileFields: ["id", "displayName", "photos", "email"],
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
async validate(accessToken, refreshToken, profile, done) {
|
|
27
|
+
const { name, emails, photos } = profile;
|
|
28
|
+
const user = {
|
|
29
|
+
id: profile.id,
|
|
30
|
+
email: emails[0].value,
|
|
31
|
+
firstName: name.givenName,
|
|
32
|
+
lastName: name.familyName,
|
|
33
|
+
picture: photos[0].value,
|
|
34
|
+
accessToken,
|
|
35
|
+
refreshToken,
|
|
36
|
+
};
|
|
37
|
+
done(null, user);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
exports.NestAuthFacebookStrategy = NestAuthFacebookStrategy;
|
|
41
|
+
exports.NestAuthFacebookStrategy = NestAuthFacebookStrategy = __decorate([
|
|
42
|
+
(0, common_1.Injectable)(),
|
|
43
|
+
__metadata("design:paramtypes", [])
|
|
44
|
+
], NestAuthFacebookStrategy);
|
|
45
|
+
//# sourceMappingURL=nestauth-facebook.strategy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nestauth-facebook.strategy.js","sourceRoot":"","sources":["../../src/nestauth-facebook.strategy.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+CAAoD;AACpD,yDAAsD;AACtD,2CAA4C;AAIrC,IAAM,wBAAwB,GAA9B,MAAM,wBAAyB,SAAQ,IAAA,2BAAgB,EAC1D,4BAAQ,EACR,UAAU,CACb;IACG;QACI,KAAK,CAAC;YACF,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,aAAa;YACtD,YAAY,EAAE,OAAO,CAAC,GAAG,CAAC,mBAAmB,IAAI,iBAAiB;YAClE,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,QAAQ,GAAG,6BAA6B;YACjE,KAAK,EAAE,CAAC,OAAO,EAAE,gBAAgB,CAAC;YAClC,aAAa,EAAE,CAAC,IAAI,EAAE,aAAa,EAAE,QAAQ,EAAE,OAAO,CAAC;SAC1D,CAAC,CAAC;IACP,CAAC;IAED,KAAK,CAAC,QAAQ,CACV,WAAmB,EACnB,YAAoB,EACpB,OAAgB,EAChB,IAA+C;QAE/C,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;QACzC,MAAM,IAAI,GAAwB;YAC9B,EAAE,EAAE,OAAO,CAAC,EAAE;YACd,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK;YACtB,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,QAAQ,EAAE,IAAI,CAAC,UAAU;YACzB,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK;YACxB,WAAW;YACX,YAAY;SACf,CAAC;QACF,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACrB,CAAC;CACJ,CAAA;AAhCY,4DAAwB;mCAAxB,wBAAwB;IADpC,IAAA,mBAAU,GAAE;;GACA,wBAAwB,CAgCpC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ConfigService } from "@nestjs/config";
|
|
2
|
+
declare const NestAuthGoogleGuard_base: import("@nestjs/passport").Type<import("@nestjs/passport").IAuthGuard>;
|
|
3
|
+
export declare class NestAuthGoogleGuard extends NestAuthGoogleGuard_base {
|
|
4
|
+
private configService;
|
|
5
|
+
constructor(configService: ConfigService);
|
|
6
|
+
}
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
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.NestAuthGoogleGuard = void 0;
|
|
13
|
+
const common_1 = require("@nestjs/common");
|
|
14
|
+
const config_1 = require("@nestjs/config");
|
|
15
|
+
const passport_1 = require("@nestjs/passport");
|
|
16
|
+
let NestAuthGoogleGuard = class NestAuthGoogleGuard extends (0, passport_1.AuthGuard)("google") {
|
|
17
|
+
constructor(configService) {
|
|
18
|
+
super({
|
|
19
|
+
accessType: "offline",
|
|
20
|
+
});
|
|
21
|
+
this.configService = configService;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
exports.NestAuthGoogleGuard = NestAuthGoogleGuard;
|
|
25
|
+
exports.NestAuthGoogleGuard = NestAuthGoogleGuard = __decorate([
|
|
26
|
+
(0, common_1.Injectable)(),
|
|
27
|
+
__metadata("design:paramtypes", [config_1.ConfigService])
|
|
28
|
+
], NestAuthGoogleGuard);
|
|
29
|
+
//# sourceMappingURL=nestauth-google.guard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nestauth-google.guard.js","sourceRoot":"","sources":["../../src/nestauth-google.guard.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,2CAA+C;AAC/C,+CAA6C;AAGtC,IAAM,mBAAmB,GAAzB,MAAM,mBAAoB,SAAQ,IAAA,oBAAS,EAAC,QAAQ,CAAC;IACxD,YAAoB,aAA4B;QAC5C,KAAK,CAAC;YACF,UAAU,EAAE,SAAS;SACxB,CAAC,CAAC;QAHa,kBAAa,GAAb,aAAa,CAAe;IAIhD,CAAC;CACJ,CAAA;AANY,kDAAmB;8BAAnB,mBAAmB;IAD/B,IAAA,mBAAU,GAAE;qCAE0B,sBAAa;GADvC,mBAAmB,CAM/B"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Strategy, Profile, VerifyCallback } from "passport-google-oauth20";
|
|
2
|
+
declare const NestAuthGoogleStrategy_base: new (...args: [options: import("passport-google-oauth20").StrategyOptionsWithRequest] | [options: import("passport-google-oauth20").StrategyOptions] | [options: import("passport-google-oauth20").StrategyOptions] | [options: import("passport-google-oauth20").StrategyOptionsWithRequest]) => Strategy & {
|
|
3
|
+
validate(...args: any[]): unknown;
|
|
4
|
+
};
|
|
5
|
+
export declare class NestAuthGoogleStrategy extends NestAuthGoogleStrategy_base {
|
|
6
|
+
constructor();
|
|
7
|
+
validate(accessToken: string, refreshToken: string, profile: Profile, done: VerifyCallback): Promise<any>;
|
|
8
|
+
}
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
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.NestAuthGoogleStrategy = void 0;
|
|
13
|
+
const passport_1 = require("@nestjs/passport");
|
|
14
|
+
const passport_google_oauth20_1 = require("passport-google-oauth20");
|
|
15
|
+
const common_1 = require("@nestjs/common");
|
|
16
|
+
let NestAuthGoogleStrategy = class NestAuthGoogleStrategy extends (0, passport_1.PassportStrategy)(passport_google_oauth20_1.Strategy, "google") {
|
|
17
|
+
constructor() {
|
|
18
|
+
super({
|
|
19
|
+
clientID: process.env.GOOGLE_CLIENT_ID || "your-client-id",
|
|
20
|
+
clientSecret: process.env.GOOGLE_CLIENT_SECRET || "your-client-secret",
|
|
21
|
+
callbackURL: process.env.BASE_URL + "/nestauth/google-redirect",
|
|
22
|
+
scope: ["email", "profile"],
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
async validate(accessToken, refreshToken, profile, done) {
|
|
26
|
+
const { name, emails, photos } = profile;
|
|
27
|
+
const user = {
|
|
28
|
+
id: profile.id,
|
|
29
|
+
email: emails[0].value,
|
|
30
|
+
firstName: name.givenName,
|
|
31
|
+
lastName: name.familyName,
|
|
32
|
+
picture: photos[0].value,
|
|
33
|
+
accessToken,
|
|
34
|
+
refreshToken,
|
|
35
|
+
};
|
|
36
|
+
done(null, user);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
exports.NestAuthGoogleStrategy = NestAuthGoogleStrategy;
|
|
40
|
+
exports.NestAuthGoogleStrategy = NestAuthGoogleStrategy = __decorate([
|
|
41
|
+
(0, common_1.Injectable)(),
|
|
42
|
+
__metadata("design:paramtypes", [])
|
|
43
|
+
], NestAuthGoogleStrategy);
|
|
44
|
+
//# sourceMappingURL=nestauth-google.strategy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nestauth-google.strategy.js","sourceRoot":"","sources":["../../src/nestauth-google.strategy.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+CAAoD;AACpD,qEAA4E;AAC5E,2CAA4C;AAIrC,IAAM,sBAAsB,GAA5B,MAAM,sBAAuB,SAAQ,IAAA,2BAAgB,EACxD,kCAAQ,EACR,QAAQ,CACX;IACG;QACI,KAAK,CAAC;YACF,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,gBAAgB;YAC1D,YAAY,EACR,OAAO,CAAC,GAAG,CAAC,oBAAoB,IAAI,oBAAoB;YAC5D,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,QAAQ,GAAG,2BAA2B;YAC/D,KAAK,EAAE,CAAC,OAAO,EAAE,SAAS,CAAC;SAC9B,CAAC,CAAC;IACP,CAAC;IAED,KAAK,CAAC,QAAQ,CACV,WAAmB,EACnB,YAAoB,EACpB,OAAgB,EAChB,IAAoB;QAEpB,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;QACzC,MAAM,IAAI,GAAsB;YAC5B,EAAE,EAAE,OAAO,CAAC,EAAE;YACd,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK;YACtB,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,QAAQ,EAAE,IAAI,CAAC,UAAU;YACzB,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK;YACxB,WAAW;YACX,YAAY;SACf,CAAC;QACF,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACrB,CAAC;CACJ,CAAA;AAhCY,wDAAsB;iCAAtB,sBAAsB;IADlC,IAAA,mBAAU,GAAE;;GACA,sBAAsB,CAgClC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ExecutionContext } from "@nestjs/common";
|
|
2
|
+
declare const NestAuthJwtGuard_base: import("@nestjs/passport").Type<import("@nestjs/passport").IAuthGuard>;
|
|
3
|
+
export declare class NestAuthJwtGuard extends NestAuthJwtGuard_base {
|
|
4
|
+
handleRequest(err: any, user: any, info: any, context: ExecutionContext): any;
|
|
5
|
+
canActivate(context: ExecutionContext): Promise<boolean>;
|
|
6
|
+
}
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
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.NestAuthJwtGuard = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
const passport_1 = require("@nestjs/passport");
|
|
12
|
+
const macaddress = require("macaddress");
|
|
13
|
+
let NestAuthJwtGuard = class NestAuthJwtGuard extends (0, passport_1.AuthGuard)("jwt") {
|
|
14
|
+
handleRequest(err, user, info, context) {
|
|
15
|
+
if (err || !user) {
|
|
16
|
+
throw new common_1.UnauthorizedException("Unauthorized: Invalid or missing token");
|
|
17
|
+
}
|
|
18
|
+
return user;
|
|
19
|
+
}
|
|
20
|
+
async canActivate(context) {
|
|
21
|
+
const can = (await super.canActivate(context));
|
|
22
|
+
if (!can)
|
|
23
|
+
return false;
|
|
24
|
+
const request = context.switchToHttp().getRequest();
|
|
25
|
+
const user = request.user;
|
|
26
|
+
if (!user) {
|
|
27
|
+
throw new common_1.UnauthorizedException("Unauthorized: Invalid token");
|
|
28
|
+
}
|
|
29
|
+
const currentMacId = await macaddress.one();
|
|
30
|
+
if (user.macId !== currentMacId) {
|
|
31
|
+
throw new common_1.UnauthorizedException("Unauthorized: Device mismatch");
|
|
32
|
+
}
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
exports.NestAuthJwtGuard = NestAuthJwtGuard;
|
|
37
|
+
exports.NestAuthJwtGuard = NestAuthJwtGuard = __decorate([
|
|
38
|
+
(0, common_1.Injectable)()
|
|
39
|
+
], NestAuthJwtGuard);
|
|
40
|
+
//# sourceMappingURL=nestauth-jwt.guard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nestauth-jwt.guard.js","sourceRoot":"","sources":["../../src/nestauth-jwt.guard.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAIwB;AACxB,+CAA6C;AAC7C,yCAAyC;AAGlC,IAAM,gBAAgB,GAAtB,MAAM,gBAAiB,SAAQ,IAAA,oBAAS,EAAC,KAAK,CAAC;IAEpD,aAAa,CAAC,GAAQ,EAAE,IAAS,EAAE,IAAS,EAAE,OAAyB;QAErE,IAAI,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;YACjB,MAAM,IAAI,8BAAqB,CAAC,wCAAwC,CAAC,CAAC;QAC5E,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAGD,KAAK,CAAC,WAAW,CAAC,OAAyB;QACzC,MAAM,GAAG,GAAG,CAAC,MAAM,KAAK,CAAC,WAAW,CAAC,OAAO,CAAC,CAAY,CAAC;QAC1D,IAAI,CAAC,GAAG;YAAE,OAAO,KAAK,CAAC;QAEvB,MAAM,OAAO,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,CAAC;QACpD,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;QAE1B,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,MAAM,IAAI,8BAAqB,CAAC,6BAA6B,CAAC,CAAC;QACjE,CAAC;QAED,MAAM,YAAY,GAAG,MAAM,UAAU,CAAC,GAAG,EAAE,CAAC;QAC5C,IAAI,IAAI,CAAC,KAAK,KAAK,YAAY,EAAE,CAAC;YAChC,MAAM,IAAI,8BAAqB,CAAC,+BAA+B,CAAC,CAAC;QACnE,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF,CAAA;AA7BY,4CAAgB;2BAAhB,gBAAgB;IAD5B,IAAA,mBAAU,GAAE;GACA,gBAAgB,CA6B5B"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Strategy } from "passport-jwt";
|
|
2
|
+
import { JwtPayload } from "jsonwebtoken";
|
|
3
|
+
declare const NestAuthJwtStrategy_base: new (...args: [opt: import("passport-jwt").StrategyOptionsWithRequest] | [opt: import("passport-jwt").StrategyOptionsWithoutRequest]) => Strategy & {
|
|
4
|
+
validate(...args: any[]): unknown;
|
|
5
|
+
};
|
|
6
|
+
export declare class NestAuthJwtStrategy extends NestAuthJwtStrategy_base {
|
|
7
|
+
constructor(jwtSecret: string);
|
|
8
|
+
validate(payload: JwtPayload): Promise<Record<string, any>>;
|
|
9
|
+
}
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,51 @@
|
|
|
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.NestAuthJwtStrategy = 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
|
+
const macaddress = require("macaddress");
|
|
20
|
+
let NestAuthJwtStrategy = class NestAuthJwtStrategy extends (0, passport_1.PassportStrategy)(passport_jwt_1.Strategy) {
|
|
21
|
+
constructor(jwtSecret) {
|
|
22
|
+
super({
|
|
23
|
+
jwtFromRequest: passport_jwt_1.ExtractJwt.fromAuthHeaderAsBearerToken(),
|
|
24
|
+
ignoreExpiration: false,
|
|
25
|
+
secretOrKey: jwtSecret,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
async validate(payload) {
|
|
29
|
+
if (!payload) {
|
|
30
|
+
throw new common_1.UnauthorizedException("Invalid token payload");
|
|
31
|
+
}
|
|
32
|
+
const macId = payload.macId ?? (await macaddress.one());
|
|
33
|
+
const userData = {
|
|
34
|
+
sub: payload.sub,
|
|
35
|
+
macId,
|
|
36
|
+
};
|
|
37
|
+
for (const key of Object.keys(payload)) {
|
|
38
|
+
if (key !== "sub" && key !== "macId") {
|
|
39
|
+
userData[key] = payload[key];
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return userData;
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
exports.NestAuthJwtStrategy = NestAuthJwtStrategy;
|
|
46
|
+
exports.NestAuthJwtStrategy = NestAuthJwtStrategy = __decorate([
|
|
47
|
+
(0, common_1.Injectable)(),
|
|
48
|
+
__param(0, (0, common_1.Inject)("JWT_SECRET")),
|
|
49
|
+
__metadata("design:paramtypes", [String])
|
|
50
|
+
], NestAuthJwtStrategy);
|
|
51
|
+
//# sourceMappingURL=nestauth-jwt.strategy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nestauth-jwt.strategy.js","sourceRoot":"","sources":["../../src/nestauth-jwt.strategy.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+CAAoD;AACpD,+CAAoD;AACpD,2CAA2E;AAE3E,yCAAyC;AAGlC,IAAM,mBAAmB,GAAzB,MAAM,mBAAoB,SAAQ,IAAA,2BAAgB,EAAC,uBAAQ,CAAC;IAC/D,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,OAAmB;QAW9B,IAAI,CAAC,OAAO,EAAE,CAAC;YACX,MAAM,IAAI,8BAAqB,CAAC,uBAAuB,CAAC,CAAC;QAC7D,CAAC;QAED,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,CAAC,MAAM,UAAU,CAAC,GAAG,EAAE,CAAC,CAAC;QAExD,MAAM,QAAQ,GAAwB;YAClC,GAAG,EAAE,OAAO,CAAC,GAAG;YAChB,KAAK;SACR,CAAC;QAEF,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;YACrC,IAAI,GAAG,KAAK,KAAK,IAAI,GAAG,KAAK,OAAO,EAAE,CAAC;gBACnC,QAAQ,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;YACjC,CAAC;QACL,CAAC;QAED,OAAO,QAAQ,CAAC;IACpB,CAAC;CACJ,CAAA;AAvCY,kDAAmB;8BAAnB,mBAAmB;IAD/B,IAAA,mBAAU,GAAE;IAEI,WAAA,IAAA,eAAM,EAAC,YAAY,CAAC,CAAA;;GADxB,mBAAmB,CAuC/B"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export declare function createLocalGuard(strategyName: string): {
|
|
2
|
+
new (...args: any[]): {
|
|
3
|
+
canActivate(context: import("@nestjs/common").ExecutionContext): boolean | Promise<boolean> | import("rxjs").Observable<boolean>;
|
|
4
|
+
logIn<TRequest extends {
|
|
5
|
+
logIn: Function;
|
|
6
|
+
} = any>(request: TRequest): Promise<void>;
|
|
7
|
+
handleRequest<TUser = any>(err: any, user: any, info: any, context: import("@nestjs/common").ExecutionContext, status?: any): TUser;
|
|
8
|
+
getAuthenticateOptions(context: import("@nestjs/common").ExecutionContext): import("@nestjs/passport").IAuthModuleOptions | undefined;
|
|
9
|
+
getRequest(context: import("@nestjs/common").ExecutionContext): any;
|
|
10
|
+
};
|
|
11
|
+
apply(this: Function, thisArg: any, argArray?: any): any;
|
|
12
|
+
call(this: Function, thisArg: any, ...argArray: any[]): any;
|
|
13
|
+
bind(this: Function, thisArg: any, ...argArray: any[]): any;
|
|
14
|
+
toString(): string;
|
|
15
|
+
readonly length: number;
|
|
16
|
+
arguments: any;
|
|
17
|
+
caller: Function;
|
|
18
|
+
readonly name: string;
|
|
19
|
+
[Symbol.hasInstance](value: any): boolean;
|
|
20
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
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.createLocalGuard = createLocalGuard;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
const passport_1 = require("@nestjs/passport");
|
|
12
|
+
function createLocalGuard(strategyName) {
|
|
13
|
+
let NestAuthLocalGuard = class NestAuthLocalGuard extends (0, passport_1.AuthGuard)(strategyName) {
|
|
14
|
+
};
|
|
15
|
+
NestAuthLocalGuard = __decorate([
|
|
16
|
+
(0, common_1.Injectable)()
|
|
17
|
+
], NestAuthLocalGuard);
|
|
18
|
+
return NestAuthLocalGuard;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=nestauth-local.guard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nestauth-local.guard.js","sourceRoot":"","sources":["../../src/nestauth-local.guard.ts"],"names":[],"mappings":";;;;;;;;AAMA,4CAKC;AAXD,2CAA4C;AAC5C,+CAA6C;AAK7C,SAAgB,gBAAgB,CAAC,YAAoB;IAEjD,IAAM,kBAAkB,GAAxB,MAAM,kBAAmB,SAAQ,IAAA,oBAAS,EAAC,YAAY,CAAC;KAAG,CAAA;IAArD,kBAAkB;QADvB,IAAA,mBAAU,GAAE;OACP,kBAAkB,CAAmC;IAE3D,OAAO,kBAAkB,CAAC;AAC9B,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { NestAuthInterface } from "./nestauth.interface";
|
|
2
|
+
export declare function createLocalStrategy(strategyName: string, userServiceToken: string): {
|
|
3
|
+
new (userService: NestAuthInterface): {
|
|
4
|
+
readonly userService: NestAuthInterface;
|
|
5
|
+
validate(req: Request): Promise<any>;
|
|
6
|
+
authenticate(req: import("express").Request, options?: any): any;
|
|
7
|
+
success(user: any, info?: any): void;
|
|
8
|
+
fail(challenge: any, status: number): void;
|
|
9
|
+
fail(status: number): void;
|
|
10
|
+
redirect(url: string, status?: number): void;
|
|
11
|
+
pass(): void;
|
|
12
|
+
error(err: Error): void;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
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.createLocalStrategy = createLocalStrategy;
|
|
16
|
+
const passport_1 = require("@nestjs/passport");
|
|
17
|
+
const passport_custom_1 = require("passport-custom");
|
|
18
|
+
const common_1 = require("@nestjs/common");
|
|
19
|
+
const macaddress = require("macaddress");
|
|
20
|
+
function createLocalStrategy(strategyName, userServiceToken) {
|
|
21
|
+
let NestAuthLocalStrategy = class NestAuthLocalStrategy extends (0, passport_1.PassportStrategy)(passport_custom_1.Strategy, strategyName) {
|
|
22
|
+
constructor(userService) {
|
|
23
|
+
super();
|
|
24
|
+
this.userService = userService;
|
|
25
|
+
}
|
|
26
|
+
async validate(req) {
|
|
27
|
+
const user = await this.userService.validateUser(req.body);
|
|
28
|
+
if (!user) {
|
|
29
|
+
throw new common_1.UnauthorizedException("Invalid credentials");
|
|
30
|
+
}
|
|
31
|
+
user.macId = await macaddress.one();
|
|
32
|
+
return user;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
NestAuthLocalStrategy = __decorate([
|
|
36
|
+
(0, common_1.Injectable)(),
|
|
37
|
+
__param(0, (0, common_1.Inject)(userServiceToken)),
|
|
38
|
+
__metadata("design:paramtypes", [Object])
|
|
39
|
+
], NestAuthLocalStrategy);
|
|
40
|
+
return NestAuthLocalStrategy;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=nestauth-local.strategy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nestauth-local.strategy.js","sourceRoot":"","sources":["../../src/nestauth-local.strategy.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AA0BA,kDA2BC;AArDD,+CAAoD;AACpD,qDAA2C;AAC3C,2CAA2E;AAE3E,yCAAyC;AAsBzC,SAAgB,mBAAmB,CAC/B,YAAoB,EACpB,gBAAwB;IAExB,IACM,qBAAqB,GAD3B,MACM,qBAAsB,SAAQ,IAAA,2BAAgB,EAChD,0BAAQ,EACR,YAAY,CACf;QACG,YAEa,WAA8B;YAEvC,KAAK,EAAE,CAAC;YAFC,gBAAW,GAAX,WAAW,CAAmB;QAG3C,CAAC;QAED,KAAK,CAAC,QAAQ,CAAC,GAAY;YACvB,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YAC3D,IAAI,CAAC,IAAI,EAAE,CAAC;gBACR,MAAM,IAAI,8BAAqB,CAAC,qBAAqB,CAAC,CAAC;YAC3D,CAAC;YACD,IAAI,CAAC,KAAK,GAAG,MAAM,UAAU,CAAC,GAAG,EAAE,CAAC;YACpC,OAAO,IAAI,CAAC;QAChB,CAAC;KACJ,CAAA;IAnBK,qBAAqB;QAD1B,IAAA,mBAAU,GAAE;QAMJ,WAAA,IAAA,eAAM,EAAC,gBAAgB,CAAC,CAAA;;OAL3B,qBAAqB,CAmB1B;IAED,OAAO,qBAAqB,CAAC;AACjC,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { NestAuthService } from "./nestauth.service";
|
|
2
|
+
export declare function createDynamicController(prefix: string, nestAuthServiceToken: string, localGuard: any): {
|
|
3
|
+
new (nestAuthService: NestAuthService): {
|
|
4
|
+
readonly nestAuthService: NestAuthService;
|
|
5
|
+
greetings(): Promise<string>;
|
|
6
|
+
login(req: any): Promise<any>;
|
|
7
|
+
refreshToken(params: {
|
|
8
|
+
refresh_token: string;
|
|
9
|
+
}): Promise<any>;
|
|
10
|
+
googleAuth(req: any): Promise<any>;
|
|
11
|
+
googleAuthRedirect(req: any): Promise<any>;
|
|
12
|
+
facebookLogin(): Promise<any>;
|
|
13
|
+
facebookLoginRedirect(req: any): Promise<any>;
|
|
14
|
+
logout(req: any): Promise<any>;
|
|
15
|
+
};
|
|
16
|
+
};
|