@next-nest-auth/nestauth 0.0.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/LICENSE +21 -0
- package/README.md +166 -0
- package/dist/global-exception.filter.d.ts +4 -0
- package/dist/global-exception.filter.js +30 -0
- package/dist/global-exception.filter.js.map +1 -0
- package/dist/http-exception.filter.d.ts +4 -0
- package/dist/http-exception.filter.js +37 -0
- package/dist/http-exception.filter.js.map +1 -0
- package/dist/http.exception.filter.d.ts +4 -0
- package/dist/http.exception.filter.js +29 -0
- package/dist/http.exception.filter.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/jwt-auth.guard.d.ts +4 -0
- package/dist/jwt-auth.guard.js +18 -0
- package/dist/jwt-auth.guard.js.map +1 -0
- package/dist/jwt.guard.d.ts +4 -0
- package/dist/jwt.guard.js +18 -0
- package/dist/jwt.guard.js.map +1 -0
- package/dist/jwt.strategy.d.ts +12 -0
- package/dist/jwt.strategy.js +37 -0
- package/dist/jwt.strategy.js.map +1 -0
- package/dist/local-auth.guard.d.ts +4 -0
- package/dist/local-auth.guard.js +18 -0
- package/dist/local-auth.guard.js.map +1 -0
- package/dist/local.srategy.d.ts +9 -0
- package/dist/local.srategy.js +33 -0
- package/dist/local.srategy.js.map +1 -0
- package/dist/local.strategy.d.ts +11 -0
- package/dist/local.strategy.js +42 -0
- package/dist/local.strategy.js.map +1 -0
- package/dist/nestauth/nestauth.controller.d.ts +2 -0
- package/dist/nestauth/nestauth.controller.js +17 -0
- package/dist/nestauth/nestauth.controller.js.map +1 -0
- package/dist/nestauth/nestauth.controller.spec.d.ts +1 -0
- package/dist/nestauth/nestauth.controller.spec.js +17 -0
- package/dist/nestauth/nestauth.controller.spec.js.map +1 -0
- package/dist/nestauth-facebook.guard.d.ts +7 -0
- package/dist/nestauth-facebook.guard.js +29 -0
- package/dist/nestauth-facebook.guard.js.map +1 -0
- package/dist/nestauth-facebook.strategy.d.ts +9 -0
- package/dist/nestauth-facebook.strategy.js +45 -0
- package/dist/nestauth-facebook.strategy.js.map +1 -0
- package/dist/nestauth-google.guard.d.ts +7 -0
- package/dist/nestauth-google.guard.js +29 -0
- package/dist/nestauth-google.guard.js.map +1 -0
- package/dist/nestauth-google.strategy.d.ts +9 -0
- package/dist/nestauth-google.strategy.js +44 -0
- package/dist/nestauth-google.strategy.js.map +1 -0
- package/dist/nestauth-jwt.guard.d.ts +6 -0
- package/dist/nestauth-jwt.guard.js +32 -0
- package/dist/nestauth-jwt.guard.js.map +1 -0
- package/dist/nestauth-jwt.strategy.d.ts +18 -0
- package/dist/nestauth-jwt.strategy.js +45 -0
- package/dist/nestauth-jwt.strategy.js.map +1 -0
- package/dist/nestauth-local.guard.d.ts +4 -0
- package/dist/nestauth-local.guard.js +18 -0
- package/dist/nestauth-local.guard.js.map +1 -0
- package/dist/nestauth-local.strategy.d.ts +11 -0
- package/dist/nestauth-local.strategy.js +40 -0
- package/dist/nestauth-local.strategy.js.map +1 -0
- package/dist/nestauth.controller.d.ts +15 -0
- package/dist/nestauth.controller.js +119 -0
- package/dist/nestauth.controller.js.map +1 -0
- package/dist/nestauth.guard.d.ts +4 -0
- package/dist/nestauth.guard.js +18 -0
- package/dist/nestauth.guard.js.map +1 -0
- package/dist/nestauth.interface.d.ts +32 -0
- package/dist/nestauth.interface.js +3 -0
- package/dist/nestauth.interface.js.map +1 -0
- package/dist/nestauth.module.d.ts +5 -0
- package/dist/nestauth.module.js +81 -0
- package/dist/nestauth.module.js.map +1 -0
- package/dist/nestauth.service.d.ts +13 -0
- package/dist/nestauth.service.js +71 -0
- package/dist/nestauth.service.js.map +1 -0
- package/dist/nestauth.strategy.d.ts +11 -0
- package/dist/nestauth.strategy.js +38 -0
- package/dist/nestauth.strategy.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +61 -0
- package/src/http-exception.filter.ts +33 -0
- package/src/index.ts +4 -0
- package/src/nestauth-facebook.guard.ts +12 -0
- package/src/nestauth-facebook.strategy.ts +39 -0
- package/src/nestauth-google.guard.ts +12 -0
- package/src/nestauth-google.strategy.ts +39 -0
- package/src/nestauth-jwt.guard.ts +24 -0
- package/src/nestauth-jwt.strategy.ts +27 -0
- package/src/nestauth-local.guard.ts +5 -0
- package/src/nestauth-local.strategy.ts +26 -0
- package/src/nestauth.controller.ts +70 -0
- package/src/nestauth.interface.ts +37 -0
- package/src/nestauth.module.ts +73 -0
- package/src/nestauth.service.ts +65 -0
|
@@ -0,0 +1,17 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -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").StrategyOptions] | [options: import("passport-facebook").StrategyOptionsWithRequest]) => 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").StrategyOptions] | [options: import("passport-google-oauth20").StrategyOptions] | [options: import("passport-google-oauth20").StrategyOptionsWithRequest] | [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,6 @@
|
|
|
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
|
+
canActivate(context: ExecutionContext): Promise<boolean>;
|
|
5
|
+
}
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
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
|
+
async canActivate(context) {
|
|
15
|
+
const request = context.switchToHttp().getRequest();
|
|
16
|
+
await super.canActivate(context);
|
|
17
|
+
const user = request.user;
|
|
18
|
+
if (!user) {
|
|
19
|
+
throw new common_1.UnauthorizedException("Unauthorized: Invalid token");
|
|
20
|
+
}
|
|
21
|
+
const currentMacId = await macaddress.one();
|
|
22
|
+
if (user.macId !== currentMacId) {
|
|
23
|
+
throw new common_1.UnauthorizedException("Unauthorized: Device mismatch");
|
|
24
|
+
}
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
exports.NestAuthJwtGuard = NestAuthJwtGuard;
|
|
29
|
+
exports.NestAuthJwtGuard = NestAuthJwtGuard = __decorate([
|
|
30
|
+
(0, common_1.Injectable)()
|
|
31
|
+
], NestAuthJwtGuard);
|
|
32
|
+
//# 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;IAClD,KAAK,CAAC,WAAW,CAAC,OAAyB;QACvC,MAAM,OAAO,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,CAAC;QACpD,MAAM,KAAK,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;QACjC,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;QAC1B,IAAI,CAAC,IAAI,EAAE,CAAC;YACR,MAAM,IAAI,8BAAqB,CAAC,6BAA6B,CAAC,CAAC;QACnE,CAAC;QACD,MAAM,YAAY,GAAG,MAAM,UAAU,CAAC,GAAG,EAAE,CAAC;QAC5C,IAAI,IAAI,CAAC,KAAK,KAAK,YAAY,EAAE,CAAC;YAC9B,MAAM,IAAI,8BAAqB,CAAC,+BAA+B,CAAC,CAAC;QACrE,CAAC;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ,CAAA;AAdY,4CAAgB;2BAAhB,gBAAgB;IAD5B,IAAA,mBAAU,GAAE;GACA,gBAAgB,CAc5B"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Strategy } from "passport-jwt";
|
|
2
|
+
import { JwtPayload } from "jsonwebtoken";
|
|
3
|
+
declare const NestAuthJwtStrategy_base: new (...args: [opt: import("passport-jwt").StrategyOptionsWithoutRequest] | [opt: import("passport-jwt").StrategyOptionsWithRequest]) => Strategy & {
|
|
4
|
+
validate(...args: any[]): unknown;
|
|
5
|
+
};
|
|
6
|
+
export declare class NestAuthJwtStrategy extends NestAuthJwtStrategy_base {
|
|
7
|
+
constructor(jwtSecret: string);
|
|
8
|
+
validate(payload: JwtPayload): Promise<{
|
|
9
|
+
userId: string;
|
|
10
|
+
macId: any;
|
|
11
|
+
email: any;
|
|
12
|
+
role: any;
|
|
13
|
+
name: any;
|
|
14
|
+
username: any;
|
|
15
|
+
pic: any;
|
|
16
|
+
}>;
|
|
17
|
+
}
|
|
18
|
+
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
|
+
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
|
+
let NestAuthJwtStrategy = class NestAuthJwtStrategy 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 {
|
|
29
|
+
userId: payload.sub,
|
|
30
|
+
macId: payload.macId,
|
|
31
|
+
email: payload.email,
|
|
32
|
+
role: payload.role,
|
|
33
|
+
name: payload.name,
|
|
34
|
+
username: payload.username,
|
|
35
|
+
pic: payload.pic,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
exports.NestAuthJwtStrategy = NestAuthJwtStrategy;
|
|
40
|
+
exports.NestAuthJwtStrategy = NestAuthJwtStrategy = __decorate([
|
|
41
|
+
(0, common_1.Injectable)(),
|
|
42
|
+
__param(0, (0, common_1.Inject)("JWT_SECRET")),
|
|
43
|
+
__metadata("design:paramtypes", [String])
|
|
44
|
+
], NestAuthJwtStrategy);
|
|
45
|
+
//# 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,2CAAoD;AAI7C,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;QAC9B,OAAO;YACH,MAAM,EAAE,OAAO,CAAC,GAAG;YACnB,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,QAAQ,EAAE,OAAO,CAAC,QAAQ;YAC1B,GAAG,EAAE,OAAO,CAAC,GAAG;SACnB,CAAC;IACN,CAAC;CACJ,CAAA;AApBY,kDAAmB;8BAAnB,mBAAmB;IAD/B,IAAA,mBAAU,GAAE;IAEI,WAAA,IAAA,eAAM,EAAC,YAAY,CAAC,CAAA;;GADxB,mBAAmB,CAoB/B"}
|
|
@@ -0,0 +1,18 @@
|
|
|
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.NestAuthLocalGuard = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
const passport_1 = require("@nestjs/passport");
|
|
12
|
+
let NestAuthLocalGuard = class NestAuthLocalGuard extends (0, passport_1.AuthGuard)("nestauth-local") {
|
|
13
|
+
};
|
|
14
|
+
exports.NestAuthLocalGuard = NestAuthLocalGuard;
|
|
15
|
+
exports.NestAuthLocalGuard = NestAuthLocalGuard = __decorate([
|
|
16
|
+
(0, common_1.Injectable)()
|
|
17
|
+
], NestAuthLocalGuard);
|
|
18
|
+
//# 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":";;;;;;;;;AAAA,2CAA4C;AAC5C,+CAA6C;AAGtC,IAAM,kBAAkB,GAAxB,MAAM,kBAAmB,SAAQ,IAAA,oBAAS,EAAC,gBAAgB,CAAC;CAAG,CAAA;AAAzD,gDAAkB;6BAAlB,kBAAkB;IAD9B,IAAA,mBAAU,GAAE;GACA,kBAAkB,CAAuC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Strategy } from "passport-custom";
|
|
2
|
+
import { NestAuthInterface } from "./nestauth.interface";
|
|
3
|
+
declare const NestAuthLocalStrategy_base: new () => Strategy & {
|
|
4
|
+
validate(...args: any[]): unknown;
|
|
5
|
+
};
|
|
6
|
+
export declare class NestAuthLocalStrategy extends NestAuthLocalStrategy_base {
|
|
7
|
+
private readonly userService;
|
|
8
|
+
constructor(userService: NestAuthInterface);
|
|
9
|
+
validate(req: Request): Promise<any>;
|
|
10
|
+
}
|
|
11
|
+
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
|
+
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.NestAuthLocalStrategy = 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
|
+
const macaddress = require("macaddress");
|
|
20
|
+
let NestAuthLocalStrategy = class NestAuthLocalStrategy extends (0, passport_1.PassportStrategy)(passport_custom_1.Strategy, "nestauth-local") {
|
|
21
|
+
constructor(userService) {
|
|
22
|
+
super();
|
|
23
|
+
this.userService = userService;
|
|
24
|
+
}
|
|
25
|
+
async validate(req) {
|
|
26
|
+
const user = await this.userService.validateUser(req.body);
|
|
27
|
+
if (!user) {
|
|
28
|
+
throw new common_1.UnauthorizedException("Invalid credentials");
|
|
29
|
+
}
|
|
30
|
+
user.macId = await macaddress.one();
|
|
31
|
+
return user;
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
exports.NestAuthLocalStrategy = NestAuthLocalStrategy;
|
|
35
|
+
exports.NestAuthLocalStrategy = NestAuthLocalStrategy = __decorate([
|
|
36
|
+
(0, common_1.Injectable)(),
|
|
37
|
+
__param(0, (0, common_1.Inject)("UserService")),
|
|
38
|
+
__metadata("design:paramtypes", [Object])
|
|
39
|
+
], NestAuthLocalStrategy);
|
|
40
|
+
//# 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":";;;;;;;;;;;;;;;AAAA,+CAAoD;AACpD,qDAA2C;AAC3C,2CAA2E;AAE3E,yCAAyC;AAGlC,IAAM,qBAAqB,GAA3B,MAAM,qBAAsB,SAAQ,IAAA,2BAAgB,EACvD,0BAAQ,EACR,gBAAgB,CACnB;IACG,YAC4C,WAA8B;QAEtE,KAAK,EAAE,CAAC;QAFgC,gBAAW,GAAX,WAAW,CAAmB;IAG1E,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,GAAY;QACvB,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAC3D,IAAI,CAAC,IAAI,EAAE,CAAC;YACR,MAAM,IAAI,8BAAqB,CAAC,qBAAqB,CAAC,CAAC;QAC3D,CAAC;QACD,IAAI,CAAC,KAAK,GAAG,MAAM,UAAU,CAAC,GAAG,EAAE,CAAC;QACpC,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ,CAAA;AAlBY,sDAAqB;gCAArB,qBAAqB;IADjC,IAAA,mBAAU,GAAE;IAMJ,WAAA,IAAA,eAAM,EAAC,aAAa,CAAC,CAAA;;GALjB,qBAAqB,CAkBjC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { NestAuthService } from "./nestauth.service";
|
|
2
|
+
export declare class NestAuthController {
|
|
3
|
+
private readonly nestAuthService;
|
|
4
|
+
constructor(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
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
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.NestAuthController = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const nestauth_service_1 = require("./nestauth.service");
|
|
18
|
+
const nestauth_local_guard_1 = require("./nestauth-local.guard");
|
|
19
|
+
const nestauth_google_guard_1 = require("./nestauth-google.guard");
|
|
20
|
+
const nestauth_facebook_guard_1 = require("./nestauth-facebook.guard");
|
|
21
|
+
let NestAuthController = class NestAuthController {
|
|
22
|
+
constructor(nestAuthService) {
|
|
23
|
+
this.nestAuthService = nestAuthService;
|
|
24
|
+
}
|
|
25
|
+
async greetings() {
|
|
26
|
+
return "Welcome to NestAuth. Please check our documentation for more information.";
|
|
27
|
+
}
|
|
28
|
+
async login(req) {
|
|
29
|
+
return this.nestAuthService.login(req.user);
|
|
30
|
+
}
|
|
31
|
+
refreshToken(params) {
|
|
32
|
+
return this.nestAuthService.refreshToken(params.refresh_token);
|
|
33
|
+
}
|
|
34
|
+
async googleAuth(req) { }
|
|
35
|
+
googleAuthRedirect(req) {
|
|
36
|
+
if (!req.user) {
|
|
37
|
+
throw new common_1.UnauthorizedException("Unable to login with Google");
|
|
38
|
+
}
|
|
39
|
+
return this.nestAuthService.google(req.user);
|
|
40
|
+
}
|
|
41
|
+
async facebookLogin() {
|
|
42
|
+
return common_1.HttpStatus.OK;
|
|
43
|
+
}
|
|
44
|
+
async facebookLoginRedirect(req) {
|
|
45
|
+
if (!req.user) {
|
|
46
|
+
throw new common_1.UnauthorizedException("Unable to login with Facebook");
|
|
47
|
+
}
|
|
48
|
+
return this.nestAuthService.facebook(req.user);
|
|
49
|
+
}
|
|
50
|
+
async logout(req) {
|
|
51
|
+
return req.logout();
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
exports.NestAuthController = NestAuthController;
|
|
55
|
+
__decorate([
|
|
56
|
+
(0, common_1.All)(),
|
|
57
|
+
__metadata("design:type", Function),
|
|
58
|
+
__metadata("design:paramtypes", []),
|
|
59
|
+
__metadata("design:returntype", Promise)
|
|
60
|
+
], NestAuthController.prototype, "greetings", null);
|
|
61
|
+
__decorate([
|
|
62
|
+
(0, common_1.UseGuards)(nestauth_local_guard_1.NestAuthLocalGuard),
|
|
63
|
+
(0, common_1.Post)("login"),
|
|
64
|
+
__param(0, (0, common_1.Request)()),
|
|
65
|
+
__metadata("design:type", Function),
|
|
66
|
+
__metadata("design:paramtypes", [Object]),
|
|
67
|
+
__metadata("design:returntype", Promise)
|
|
68
|
+
], NestAuthController.prototype, "login", null);
|
|
69
|
+
__decorate([
|
|
70
|
+
(0, common_1.Get)("refresh-token"),
|
|
71
|
+
__param(0, (0, common_1.Body)()),
|
|
72
|
+
__metadata("design:type", Function),
|
|
73
|
+
__metadata("design:paramtypes", [Object]),
|
|
74
|
+
__metadata("design:returntype", Promise)
|
|
75
|
+
], NestAuthController.prototype, "refreshToken", null);
|
|
76
|
+
__decorate([
|
|
77
|
+
(0, common_1.UseGuards)(nestauth_google_guard_1.NestAuthGoogleGuard),
|
|
78
|
+
(0, common_1.Get)("google"),
|
|
79
|
+
__param(0, (0, common_1.Request)()),
|
|
80
|
+
__metadata("design:type", Function),
|
|
81
|
+
__metadata("design:paramtypes", [Object]),
|
|
82
|
+
__metadata("design:returntype", Promise)
|
|
83
|
+
], NestAuthController.prototype, "googleAuth", null);
|
|
84
|
+
__decorate([
|
|
85
|
+
(0, common_1.Get)("google-redirect"),
|
|
86
|
+
(0, common_1.UseGuards)(nestauth_google_guard_1.NestAuthGoogleGuard),
|
|
87
|
+
__param(0, (0, common_1.Request)()),
|
|
88
|
+
__metadata("design:type", Function),
|
|
89
|
+
__metadata("design:paramtypes", [Object]),
|
|
90
|
+
__metadata("design:returntype", void 0)
|
|
91
|
+
], NestAuthController.prototype, "googleAuthRedirect", null);
|
|
92
|
+
__decorate([
|
|
93
|
+
(0, common_1.Get)("/facebook"),
|
|
94
|
+
(0, common_1.UseGuards)(nestauth_facebook_guard_1.NestAuthFacebookGuard),
|
|
95
|
+
__metadata("design:type", Function),
|
|
96
|
+
__metadata("design:paramtypes", []),
|
|
97
|
+
__metadata("design:returntype", Promise)
|
|
98
|
+
], NestAuthController.prototype, "facebookLogin", null);
|
|
99
|
+
__decorate([
|
|
100
|
+
(0, common_1.Get)("/facebook-redirect"),
|
|
101
|
+
(0, common_1.UseGuards)(nestauth_facebook_guard_1.NestAuthFacebookGuard),
|
|
102
|
+
__param(0, (0, common_1.Request)()),
|
|
103
|
+
__metadata("design:type", Function),
|
|
104
|
+
__metadata("design:paramtypes", [Object]),
|
|
105
|
+
__metadata("design:returntype", Promise)
|
|
106
|
+
], NestAuthController.prototype, "facebookLoginRedirect", null);
|
|
107
|
+
__decorate([
|
|
108
|
+
(0, common_1.UseGuards)(nestauth_local_guard_1.NestAuthLocalGuard),
|
|
109
|
+
(0, common_1.Get)("logout"),
|
|
110
|
+
__param(0, (0, common_1.Request)()),
|
|
111
|
+
__metadata("design:type", Function),
|
|
112
|
+
__metadata("design:paramtypes", [Object]),
|
|
113
|
+
__metadata("design:returntype", Promise)
|
|
114
|
+
], NestAuthController.prototype, "logout", null);
|
|
115
|
+
exports.NestAuthController = NestAuthController = __decorate([
|
|
116
|
+
(0, common_1.Controller)("nestauth"),
|
|
117
|
+
__metadata("design:paramtypes", [nestauth_service_1.NestAuthService])
|
|
118
|
+
], NestAuthController);
|
|
119
|
+
//# sourceMappingURL=nestauth.controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nestauth.controller.js","sourceRoot":"","sources":["../src/nestauth.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAUwB;AACxB,yDAAqD;AACrD,iEAA4D;AAC5D,mEAA8D;AAC9D,uEAAkE;AAG3D,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IAC3B,YAA6B,eAAgC;QAAhC,oBAAe,GAAf,eAAe,CAAiB;IAAG,CAAC;IAG3D,AAAN,KAAK,CAAC,SAAS;QACX,OAAO,2EAA2E,CAAC;IACvF,CAAC;IAIK,AAAN,KAAK,CAAC,KAAK,CAAY,GAAG;QACtB,OAAO,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAChD,CAAC;IAGD,YAAY,CAAS,MAAiC;QAClD,OAAO,IAAI,CAAC,eAAe,CAAC,YAAY,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;IACnE,CAAC;IAIK,AAAN,KAAK,CAAC,UAAU,CAAY,GAAG,IAAiB,CAAC;IAIjD,kBAAkB,CAAY,GAAG;QAC7B,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;YACZ,MAAM,IAAI,8BAAqB,CAAC,6BAA6B,CAAC,CAAC;QACnE,CAAC;QACD,OAAO,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACjD,CAAC;IAIK,AAAN,KAAK,CAAC,aAAa;QACf,OAAO,mBAAU,CAAC,EAAE,CAAC;IACzB,CAAC;IAIK,AAAN,KAAK,CAAC,qBAAqB,CAAY,GAAG;QACtC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;YACZ,MAAM,IAAI,8BAAqB,CAAC,+BAA+B,CAAC,CAAC;QACrE,CAAC;QACD,OAAO,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACnD,CAAC;IAIK,AAAN,KAAK,CAAC,MAAM,CAAY,GAAG;QACvB,OAAO,GAAG,CAAC,MAAM,EAAE,CAAC;IACxB,CAAC;CACJ,CAAA;AApDY,gDAAkB;AAIrB;IADL,IAAA,YAAG,GAAE;;;;mDAGL;AAIK;IAFL,IAAA,kBAAS,EAAC,yCAAkB,CAAC;IAC7B,IAAA,aAAI,EAAC,OAAO,CAAC;IACD,WAAA,IAAA,gBAAO,GAAE,CAAA;;;;+CAErB;AAGD;IADC,IAAA,YAAG,EAAC,eAAe,CAAC;IACP,WAAA,IAAA,aAAI,GAAE,CAAA;;;;sDAEnB;AAIK;IAFL,IAAA,kBAAS,EAAC,2CAAmB,CAAC;IAC9B,IAAA,YAAG,EAAC,QAAQ,CAAC;IACI,WAAA,IAAA,gBAAO,GAAE,CAAA;;;;oDAAsB;AAIjD;IAFC,IAAA,YAAG,EAAC,iBAAiB,CAAC;IACtB,IAAA,kBAAS,EAAC,2CAAmB,CAAC;IACX,WAAA,IAAA,gBAAO,GAAE,CAAA;;;;4DAK5B;AAIK;IAFL,IAAA,YAAG,EAAC,WAAW,CAAC;IAChB,IAAA,kBAAS,EAAC,+CAAqB,CAAC;;;;uDAGhC;AAIK;IAFL,IAAA,YAAG,EAAC,oBAAoB,CAAC;IACzB,IAAA,kBAAS,EAAC,+CAAqB,CAAC;IACJ,WAAA,IAAA,gBAAO,GAAE,CAAA;;;;+DAKrC;AAIK;IAFL,IAAA,kBAAS,EAAC,yCAAkB,CAAC;IAC7B,IAAA,YAAG,EAAC,QAAQ,CAAC;IACA,WAAA,IAAA,gBAAO,GAAE,CAAA;;;;gDAEtB;6BAnDQ,kBAAkB;IAD9B,IAAA,mBAAU,EAAC,UAAU,CAAC;qCAE2B,kCAAe;GADpD,kBAAkB,CAoD9B"}
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|