@tc-libs/authentication 1.12.0 → 1.14.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.14.0",
4
4
  "dependencies": {
5
- "@tc-libs/errors": "1.12.0",
6
- "@tc-libs/helper": "1.12.0"
5
+ "@tc-libs/errors": "1.14.0",
6
+ "@tc-libs/helper": "1.14.0"
7
7
  },
8
8
  "type": "commonjs",
9
9
  "main": "./src/index.js",
@@ -11,6 +11,8 @@ const providers = [
11
11
  auth_combined_guard_1.CombinedAuthGuard,
12
12
  guards_1.AuthJwtAccessGuard,
13
13
  guards_1.AuthJwtRefreshStrategy,
14
+ guards_1.GoogleStrategy,
15
+ guards_1.GoogleOAuthGuard,
14
16
  guards_1.AuthPermissionGuard,
15
17
  guards_1.AuthPayloadPermissionGuard,
16
18
  guards_1.AuthJwtRefreshGuard,
@@ -1 +1 @@
1
- {"version":3,"file":"authentication.module.js","sourceRoot":"","sources":["../../../../packages/authentication/src/authentication.module.ts"],"names":[],"mappings":";;;AACA,qCAQkB;AAClB,yCAAyC;AACzC,mFAGyC;AACzC,+EAA0E;AAE1E,MAAM,SAAS,GAAG;IAChB,sBAAW;IACX,8BAAqB;IACrB,uCAAiB;IACjB,2BAAkB;IAClB,+BAAsB;IACtB,4BAAmB;IACnB,mCAA0B;IAC1B,4BAAmB;IACnB,kCAAyB;CAC1B,CAAC;AAEF,MAAa,UAAU;IACrB,MAAM,CAAC,QAAQ,CACb,OAAoC,EACpC,QAAkB;QAElB,OAAO;YACL,MAAM,EAAE,UAAU;YAClB,OAAO,EAAE,EAAE;YACX,SAAS,EAAE;gBACT,EAAE,OAAO,EAAE,6DAA6B,EAAE,QAAQ,EAAE,OAAO,EAAE;gBAC7D,GAAG,SAAS;aACb;YACD,OAAO,EAAE,SAAS;YAClB,MAAM,EAAE,QAAQ;SACjB,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,aAAa,CAClB,OAAyC,EACzC,QAAkB;QAElB,OAAO;YACL,MAAM,EAAE,UAAU;YAClB,OAAO,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC;YACrC,SAAS,EAAE;gBACT;oBACE,OAAO,EAAE,6DAA6B;oBACtC,UAAU,EAAE,OAAO,CAAC,UAAU;oBAC9B,MAAM,EAAE,OAAO,CAAC,MAAM;iBACvB;gBACD,GAAG,SAAS;aACb;YACD,OAAO,EAAE,SAAS;YAClB,MAAM,EAAE,QAAQ;SACjB,CAAC;IACJ,CAAC;CACF;AApCD,gCAoCC"}
1
+ {"version":3,"file":"authentication.module.js","sourceRoot":"","sources":["../../../../packages/authentication/src/authentication.module.ts"],"names":[],"mappings":";;;AACA,qCAUkB;AAClB,yCAAyC;AACzC,mFAGyC;AACzC,+EAA0E;AAE1E,MAAM,SAAS,GAAG;IAChB,sBAAW;IACX,8BAAqB;IACrB,uCAAiB;IACjB,2BAAkB;IAClB,+BAAsB;IACtB,uBAAc;IACd,yBAAgB;IAChB,4BAAmB;IACnB,mCAA0B;IAC1B,4BAAmB;IACnB,kCAAyB;CAC1B,CAAC;AAEF,MAAa,UAAU;IACrB,MAAM,CAAC,QAAQ,CACb,OAAoC,EACpC,QAAkB;QAElB,OAAO;YACL,MAAM,EAAE,UAAU;YAClB,OAAO,EAAE,EAAE;YACX,SAAS,EAAE;gBACT,EAAE,OAAO,EAAE,6DAA6B,EAAE,QAAQ,EAAE,OAAO,EAAE;gBAC7D,GAAG,SAAS;aACb;YACD,OAAO,EAAE,SAAS;YAClB,MAAM,EAAE,QAAQ;SACjB,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,aAAa,CAClB,OAAyC,EACzC,QAAkB;QAElB,OAAO;YACL,MAAM,EAAE,UAAU;YAClB,OAAO,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC;YACrC,SAAS,EAAE;gBACT;oBACE,OAAO,EAAE,6DAA6B;oBACtC,UAAU,EAAE,OAAO,CAAC,UAAU;oBAC9B,MAAM,EAAE,OAAO,CAAC,MAAM;iBACvB;gBACD,GAAG,SAAS;aACb;YACD,OAAO,EAAE,SAAS;YAClB,MAAM,EAAE,QAAQ;SACjB,CAAC;IACJ,CAAC;CACF;AApCD,gCAoCC"}
@@ -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"}
@@ -5,3 +5,5 @@ export * from './jwt-refresh/auth.jwt-refresh.strategy';
5
5
  export * from './payload/auth.payload.access-for.guard';
6
6
  export * from './payload/auth.payload.permission.guard';
7
7
  export * from './permission/auth.permission.guard';
8
+ export * from './google-oauth/auth.google-oauth.guard';
9
+ export * from './google-oauth/auth.google-oauth.strategy';
@@ -8,4 +8,6 @@ tslib_1.__exportStar(require("./jwt-refresh/auth.jwt-refresh.strategy"), exports
8
8
  tslib_1.__exportStar(require("./payload/auth.payload.access-for.guard"), exports);
9
9
  tslib_1.__exportStar(require("./payload/auth.payload.permission.guard"), exports);
10
10
  tslib_1.__exportStar(require("./permission/auth.permission.guard"), exports);
11
+ tslib_1.__exportStar(require("./google-oauth/auth.google-oauth.guard"), exports);
12
+ tslib_1.__exportStar(require("./google-oauth/auth.google-oauth.strategy"), exports);
11
13
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/authentication/src/guards/index.ts"],"names":[],"mappings":";;;AAAA,6EAAmD;AACnD,gFAAsD;AACtD,+EAAqD;AACrD,kFAAwD;AACxD,kFAAwD;AACxD,kFAAwD;AACxD,6EAAmD"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/authentication/src/guards/index.ts"],"names":[],"mappings":";;;AAAA,6EAAmD;AACnD,gFAAsD;AACtD,+EAAqD;AACrD,kFAAwD;AACxD,kFAAwD;AACxD,kFAAwD;AACxD,6EAAmD;AACnD,iFAAuD;AACvD,oFAA0D"}