@tc-libs/authentication 1.12.0 → 1.13.0

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/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@tc-libs/authentication",
3
- "version": "1.12.0",
3
+ "version": "1.13.0",
4
4
  "dependencies": {
5
- "@tc-libs/errors": "1.12.0",
6
- "@tc-libs/helper": "1.12.0"
5
+ "@tc-libs/errors": "1.13.0",
6
+ "@tc-libs/helper": "1.13.0"
7
7
  },
8
8
  "type": "commonjs",
9
9
  "main": "./src/index.js",
@@ -6,6 +6,12 @@ export interface AuthenticationModuleOptions {
6
6
  defaultSecretKey: string;
7
7
  defaultExpirationTime: number;
8
8
  };
9
+ google: {
10
+ clientID: string;
11
+ clientSecret: string;
12
+ callbackURL: string;
13
+ scope: string[];
14
+ };
9
15
  auth: {
10
16
  prefixAuthorization: string;
11
17
  subject: string;
@@ -0,0 +1,5 @@
1
+ declare const GoogleOAuthGuard_base: import("@nestjs/passport").Type<import("@nestjs/passport").IAuthGuard>;
2
+ export declare class GoogleOAuthGuard extends GoogleOAuthGuard_base {
3
+ constructor();
4
+ }
5
+ export {};
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GoogleOAuthGuard = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const common_1 = require("@nestjs/common");
6
+ const passport_1 = require("@nestjs/passport");
7
+ let GoogleOAuthGuard = class GoogleOAuthGuard extends (0, passport_1.AuthGuard)('google') {
8
+ constructor() {
9
+ super({
10
+ accessType: 'offline',
11
+ });
12
+ }
13
+ };
14
+ exports.GoogleOAuthGuard = GoogleOAuthGuard;
15
+ exports.GoogleOAuthGuard = GoogleOAuthGuard = tslib_1.__decorate([
16
+ (0, common_1.Injectable)(),
17
+ tslib_1.__metadata("design:paramtypes", [])
18
+ ], GoogleOAuthGuard);
19
+ //# sourceMappingURL=auth.google-oauth.guard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.google-oauth.guard.js","sourceRoot":"","sources":["../../../../../../packages/authentication/src/guards/google-oauth/auth.google-oauth.guard.ts"],"names":[],"mappings":";;;;AAAA,2CAA4C;AAC5C,+CAA6C;AAGtC,IAAM,gBAAgB,GAAtB,MAAM,gBAAiB,SAAQ,IAAA,oBAAS,EAAC,QAAQ,CAAC;IACvD;QACE,KAAK,CAAC;YACJ,UAAU,EAAE,SAAS;SACtB,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AANY,4CAAgB;2BAAhB,gBAAgB;IAD5B,IAAA,mBAAU,GAAE;;GACA,gBAAgB,CAM5B"}
@@ -0,0 +1,20 @@
1
+ import { Profile, Strategy } from 'passport-google-oauth20';
2
+ import { AuthenticationModuleOptions } from '../../authentication.module.options';
3
+ declare const GoogleStrategy_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 & {
4
+ validate(...args: any[]): unknown;
5
+ };
6
+ export declare class GoogleStrategy extends GoogleStrategy_base {
7
+ readonly _options: AuthenticationModuleOptions;
8
+ constructor(_options: AuthenticationModuleOptions);
9
+ validate(accessToken: string, refreshToken: string, profile: Profile): Promise<{
10
+ provider: string;
11
+ providerId: string;
12
+ email: string | null;
13
+ firstName: string | null;
14
+ lastName: string | null;
15
+ avatar: string | null;
16
+ accessToken: string;
17
+ refreshToken: string;
18
+ }>;
19
+ }
20
+ export {};
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GoogleStrategy = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const common_1 = require("@nestjs/common");
6
+ const passport_1 = require("@nestjs/passport");
7
+ const passport_google_oauth20_1 = require("passport-google-oauth20");
8
+ const authentication_module_options_1 = require("../../authentication.module.options");
9
+ let GoogleStrategy = class GoogleStrategy extends (0, passport_1.PassportStrategy)(passport_google_oauth20_1.Strategy, 'google') {
10
+ constructor(_options) {
11
+ super({
12
+ clientID: _options.google.clientID,
13
+ clientSecret: _options.google.clientSecret,
14
+ callbackURL: _options.google.callbackURL,
15
+ scope: _options.google.scope,
16
+ });
17
+ this._options = _options;
18
+ }
19
+ async validate(accessToken, refreshToken, profile) {
20
+ const { id, emails, name, photos } = profile;
21
+ const data = {
22
+ provider: 'google',
23
+ providerId: id,
24
+ email: emails?.[0]?.value ?? null,
25
+ firstName: name?.givenName ?? null,
26
+ lastName: name?.familyName ?? null,
27
+ avatar: photos?.[0]?.value ?? null,
28
+ accessToken,
29
+ refreshToken,
30
+ };
31
+ return data;
32
+ }
33
+ };
34
+ exports.GoogleStrategy = GoogleStrategy;
35
+ exports.GoogleStrategy = GoogleStrategy = tslib_1.__decorate([
36
+ (0, common_1.Injectable)(),
37
+ tslib_1.__param(0, (0, common_1.Inject)(authentication_module_options_1.AUTHENTICATION_CONFIG_OPTIONS)),
38
+ tslib_1.__metadata("design:paramtypes", [Object])
39
+ ], GoogleStrategy);
40
+ //# sourceMappingURL=auth.google-oauth.strategy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.google-oauth.strategy.js","sourceRoot":"","sources":["../../../../../../packages/authentication/src/guards/google-oauth/auth.google-oauth.strategy.ts"],"names":[],"mappings":";;;;AAAA,2CAAoD;AACpD,+CAAoD;AACpD,qEAA4D;AAC5D,uFAG6C;AAGtC,IAAM,cAAc,GAApB,MAAM,cAAe,SAAQ,IAAA,2BAAgB,EAAC,kCAAQ,EAAE,QAAQ,CAAC;IACtE,YAEW,QAAqC;QAE9C,KAAK,CAAC;YACJ,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,QAAQ;YAClC,YAAY,EAAE,QAAQ,CAAC,MAAM,CAAC,YAAY;YAC1C,WAAW,EAAE,QAAQ,CAAC,MAAM,CAAC,WAAW;YACxC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,KAAK;SAC7B,CAAC,CAAC;QAPM,aAAQ,GAAR,QAAQ,CAA6B;IAQhD,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,WAAmB,EAAE,YAAoB,EAAE,OAAgB;QACxE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;QAC7C,MAAM,IAAI,GAAG;YACX,QAAQ,EAAE,QAAQ;YAClB,UAAU,EAAE,EAAE;YACd,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,IAAI,IAAI;YACjC,SAAS,EAAE,IAAI,EAAE,SAAS,IAAI,IAAI;YAClC,QAAQ,EAAE,IAAI,EAAE,UAAU,IAAI,IAAI;YAClC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,IAAI,IAAI;YAClC,WAAW;YACX,YAAY;SACb,CAAC;QACF,OAAO,IAAI,CAAC;IACd,CAAC;CACF,CAAA;AA3BY,wCAAc;yBAAd,cAAc;IAD1B,IAAA,mBAAU,GAAE;IAGR,mBAAA,IAAA,eAAM,EAAC,6DAA6B,CAAC,CAAA;;GAF7B,cAAc,CA2B1B"}