@nathapp/nestjs-auth 1.0.0 → 1.0.1

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.
Files changed (90) hide show
  1. package/README.md +9 -4
  2. package/dist/auth-provider.d.ts +19 -0
  3. package/dist/auth-provider.js +21 -0
  4. package/dist/auth-provider.js.map +1 -0
  5. package/dist/casl/casl-ability-factory.d.ts +12 -0
  6. package/dist/casl/casl-ability-factory.js +47 -0
  7. package/dist/casl/casl-ability-factory.js.map +1 -0
  8. package/dist/casl/index.d.ts +2 -0
  9. package/dist/casl/index.js +8 -0
  10. package/dist/casl/index.js.map +1 -0
  11. package/dist/constant/index.d.ts +3 -0
  12. package/dist/constant/index.js +15 -0
  13. package/dist/constant/index.js.map +1 -0
  14. package/dist/constant/jwt-constant.d.ts +5 -0
  15. package/dist/constant/jwt-constant.js +9 -0
  16. package/dist/constant/jwt-constant.js.map +1 -0
  17. package/dist/constant/module-constant.d.ts +4 -0
  18. package/dist/constant/module-constant.js +8 -0
  19. package/dist/constant/module-constant.js.map +1 -0
  20. package/dist/decorator/index.d.ts +5 -0
  21. package/dist/decorator/index.js +15 -0
  22. package/dist/decorator/index.js.map +1 -0
  23. package/dist/decorator/is-public.decorator.d.ts +2 -0
  24. package/dist/decorator/is-public.decorator.js +8 -0
  25. package/dist/decorator/is-public.decorator.js.map +1 -0
  26. package/dist/decorator/permission.decorator.d.ts +5 -0
  27. package/dist/decorator/permission.decorator.js +8 -0
  28. package/dist/decorator/permission.decorator.js.map +1 -0
  29. package/dist/decorator/principal.decorator.d.ts +1 -0
  30. package/dist/decorator/principal.decorator.js +13 -0
  31. package/dist/decorator/principal.decorator.js.map +1 -0
  32. package/dist/decorator/refresh-token.decorator.d.ts +2 -0
  33. package/dist/decorator/refresh-token.decorator.js +8 -0
  34. package/dist/decorator/refresh-token.decorator.js.map +1 -0
  35. package/dist/guard/index.d.ts +4 -0
  36. package/dist/guard/index.js +10 -0
  37. package/dist/guard/index.js.map +1 -0
  38. package/dist/guard/jwt-auth.guard.d.ts +11 -0
  39. package/dist/guard/jwt-auth.guard.js +59 -0
  40. package/dist/guard/jwt-auth.guard.js.map +1 -0
  41. package/dist/guard/jwt-refresh.guard.d.ts +5 -0
  42. package/dist/guard/jwt-refresh.guard.js +26 -0
  43. package/dist/guard/jwt-refresh.guard.js.map +1 -0
  44. package/dist/guard/permission-auth.guard.d.ts +11 -0
  45. package/dist/guard/permission-auth.guard.js +48 -0
  46. package/dist/guard/permission-auth.guard.js.map +1 -0
  47. package/dist/index.d.ts +9 -0
  48. package/dist/index.js +26 -0
  49. package/dist/index.js.map +1 -0
  50. package/dist/module/index.d.ts +2 -0
  51. package/dist/module/index.js +7 -0
  52. package/dist/module/index.js.map +1 -0
  53. package/dist/module/jwt-module.d.ts +49 -0
  54. package/dist/module/jwt-module.js +314 -0
  55. package/dist/module/jwt-module.js.map +1 -0
  56. package/dist/permission/index.d.ts +2 -0
  57. package/dist/permission/index.js +9 -0
  58. package/dist/permission/index.js.map +1 -0
  59. package/dist/permission/permission.provider.d.ts +45 -0
  60. package/dist/permission/permission.provider.js +98 -0
  61. package/dist/permission/permission.provider.js.map +1 -0
  62. package/dist/strategy/index.d.ts +7 -0
  63. package/dist/strategy/index.js +17 -0
  64. package/dist/strategy/index.js.map +1 -0
  65. package/dist/strategy/jwt-refresh-strategy-provider.d.ts +22 -0
  66. package/dist/strategy/jwt-refresh-strategy-provider.js +53 -0
  67. package/dist/strategy/jwt-refresh-strategy-provider.js.map +1 -0
  68. package/dist/strategy/jwt-refresh-strategy.d.ts +9 -0
  69. package/dist/strategy/jwt-refresh-strategy.js +39 -0
  70. package/dist/strategy/jwt-refresh-strategy.js.map +1 -0
  71. package/dist/strategy/jwt-strategy-provider.d.ts +28 -0
  72. package/dist/strategy/jwt-strategy-provider.js +89 -0
  73. package/dist/strategy/jwt-strategy-provider.js.map +1 -0
  74. package/dist/strategy/jwt-strategy.d.ts +9 -0
  75. package/dist/strategy/jwt-strategy.js +39 -0
  76. package/dist/strategy/jwt-strategy.js.map +1 -0
  77. package/dist/strategy/strategy-provider.d.ts +14 -0
  78. package/dist/strategy/strategy-provider.js +7 -0
  79. package/dist/strategy/strategy-provider.js.map +1 -0
  80. package/dist/strategy/type-interface.d.ts +15 -0
  81. package/dist/strategy/type-interface.js +3 -0
  82. package/dist/strategy/type-interface.js.map +1 -0
  83. package/dist/utils/index.d.ts +2 -0
  84. package/dist/utils/index.js +9 -0
  85. package/dist/utils/index.js.map +1 -0
  86. package/dist/utils/utils.d.ts +10 -0
  87. package/dist/utils/utils.js +56 -0
  88. package/dist/utils/utils.js.map +1 -0
  89. package/package.json +16 -22
  90. package/.eslintrc.js +0 -24
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jwt-refresh-strategy-provider.js","sourceRoot":"","sources":["../../lib/strategy/jwt-refresh-strategy-provider.ts"],"names":[],"mappings":";;;AAGA,+CAAkE;AAGlE,0CAAmD;AAEnD,MAAsB,0BAA0B;IAW9C,YAAY,UAAsB;QAChC,MAAM,YAAY,GAAG;YACnB,MAAM,EAAE,KAAK;YACb,mBAAmB,EAAE,KAAK;YAC1B,gBAAgB,EAAE,KAAK;YACvB,gBAAgB,EAAE,KAAK;YACvB,iBAAiB,EAAE,IAAI;YACvB,qBAAqB,EAAE,KAAK;YAC5B,UAAU,EAAE;gBACV,SAAS,EAAE,IAAI;aAChB;SACF,CAAA;QAED,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,YAAY,EAAE,UAAU,CAAC,CAAA;QAC7D,IAAI,CAAC,WAAW,GAAG,IAAA,yBAAiB,EAAC,UAAU,CAAC,CAAC;QACjD,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC,WAAW,CAAC,kBAAkB,CAAC;QAC9D,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC,WAAW,CAAC,iBAAiB,CAAC;QAC5D,IAAI,CAAC,sBAAsB,GAAG,IAAI,CAAC,UAAU,CAAC,sBAAsB,IAAI,yBAAU,CAAC,2BAA2B,EAAE,CAAC;QACjH,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,UAAU,CAAC,gBAAgB,CAAC;QACzD,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC,UAAU,CAAC,iBAAiB,CAAC;IAE7D,CAAC;IACD,IAAI,CAAC,OAAiC;QACpC,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACxC,CAAC;IACD,MAAM,CAAC,KAAa,EAAE,YAAgC;QACpD,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;IACtD,CAAC;CAIF;AA1CD,gEA0CC;AAED,MAAa,iCAAkC,SAAQ,0BAA0B;IAE/E,YAAY,UAAsB;QAChC,KAAK,CAAC,UAAU,CAAC,CAAC;IACpB,CAAC;IAED,QAAQ,CAAC,GAAQ,EAAE,OAAY;QAC7B,MAAM,YAAY,GAAG,IAAI,CAAC,sBAAsB,CAAC,GAAG,CAAC,CAAC;QACtD,OAAO,OAAO,CAAC,OAAO,CAAC;YACrB,EAAE,EAAE,OAAO,CAAC,GAAG;YACf,QAAQ,EAAE,OAAO,CAAC,QAAQ;YAC1B,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,WAAW,EAAE,KAAK;YAClB,OAAO,EAAE,KAAK;YACd,YAAY;YACZ,WAAW,EAAE,OAAO,CAAC,WAAW,IAAI,EAAE;SACvC,CAAC,CAAC;IACL,CAAC;CAEF;AAnBD,8EAmBC"}
@@ -0,0 +1,9 @@
1
+ import { Strategy } from 'passport-jwt';
2
+ import { JwtRefreshStrategyProvider } from './jwt-refresh-strategy-provider';
3
+ declare const JwtRefreshStrategy_base: new (...args: any[]) => Strategy;
4
+ export declare class JwtRefreshStrategy extends JwtRefreshStrategy_base {
5
+ private readonly strategyProvider;
6
+ constructor(strategyProvider: JwtRefreshStrategyProvider);
7
+ validate(arg1: any, arg2: any): Promise<import("..").IPrincipal>;
8
+ }
9
+ export {};
@@ -0,0 +1,39 @@
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.JwtRefreshStrategy = void 0;
13
+ const passport_1 = require("@nestjs/passport");
14
+ const passport_jwt_1 = require("passport-jwt");
15
+ const common_1 = require("@nestjs/common");
16
+ const jwt_constant_1 = require("../constant/jwt-constant");
17
+ const jwt_refresh_strategy_provider_1 = require("./jwt-refresh-strategy-provider");
18
+ let JwtRefreshStrategy = class JwtRefreshStrategy extends (0, passport_1.PassportStrategy)(passport_jwt_1.Strategy, jwt_constant_1.JWT_REFRESH_STRATEGY_NAME) {
19
+ constructor(strategyProvider) {
20
+ super({
21
+ jwtFromRequest: strategyProvider.jwtFromRequestFunction,
22
+ ignoreExpiration: strategyProvider.ignoreExpiration,
23
+ secretOrKey: strategyProvider.secretOrPublicKey,
24
+ passReqToCallback: strategyProvider.passReqToCallback,
25
+ });
26
+ this.strategyProvider = strategyProvider;
27
+ }
28
+ async validate(arg1, arg2) {
29
+ const req = this.strategyProvider.passReqToCallback ? arg1 : {};
30
+ const payload = this.strategyProvider.passReqToCallback ? arg2 : arg1;
31
+ return this.strategyProvider.validate(req, payload);
32
+ }
33
+ };
34
+ exports.JwtRefreshStrategy = JwtRefreshStrategy;
35
+ exports.JwtRefreshStrategy = JwtRefreshStrategy = __decorate([
36
+ (0, common_1.Injectable)(),
37
+ __metadata("design:paramtypes", [jwt_refresh_strategy_provider_1.JwtRefreshStrategyProvider])
38
+ ], JwtRefreshStrategy);
39
+ //# sourceMappingURL=jwt-refresh-strategy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jwt-refresh-strategy.js","sourceRoot":"","sources":["../../lib/strategy/jwt-refresh-strategy.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+CAAoD;AACpD,+CAAwC;AACxC,2CAA4C;AAC5C,2DAAqE;AACrE,mFAA6E;AAItE,IAAM,kBAAkB,GAAxB,MAAM,kBAAmB,SAAQ,IAAA,2BAAgB,EAAC,uBAAQ,EAAE,wCAAyB,CAAC;IAC3F,YAA6B,gBAA4C;QACvE,KAAK,CAAC;YACJ,cAAc,EAAE,gBAAgB,CAAC,sBAAsB;YACvD,gBAAgB,EAAE,gBAAgB,CAAC,gBAAgB;YACnD,WAAW,EAAE,gBAAgB,CAAC,iBAAiB;YAC/C,iBAAiB,EAAE,gBAAgB,CAAC,iBAAiB;SACtD,CAAC,CAAC;QANwB,qBAAgB,GAAhB,gBAAgB,CAA4B;IAOzE,CAAC;IASD,KAAK,CAAC,QAAQ,CAAC,IAAS,EAAE,IAAS;QACjC,MAAM,GAAG,GAAQ,IAAI,CAAC,gBAAgB,CAAC,iBAAiB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;QACrE,MAAM,OAAO,GAAQ,IAAI,CAAC,gBAAgB,CAAC,iBAAiB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;QAE3E,OAAO,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IACtD,CAAC;CACF,CAAA;AAvBY,gDAAkB;6BAAlB,kBAAkB;IAD9B,IAAA,mBAAU,GAAE;qCAEoC,0DAA0B;GAD9D,kBAAkB,CAuB9B"}
@@ -0,0 +1,28 @@
1
+ import { JwtFromRequestFunction } from "passport-jwt";
2
+ import { IPrincipal, AuthProvider } from "../auth-provider";
3
+ import { StrategyProvider } from "./strategy-provider";
4
+ import * as jwt from 'jsonwebtoken';
5
+ import { JwtOptions, Req } from "./type-interface";
6
+ export declare abstract class JwtStrategyProvider implements StrategyProvider {
7
+ protected readonly jwtOptions: JwtOptions;
8
+ private readonly jwtProvider;
9
+ readonly secretOrPrivateKey: jwt.Secret;
10
+ readonly secretOrPublicKey: jwt.Secret;
11
+ readonly jwtFromRequestFunction: JwtFromRequestFunction;
12
+ readonly ignoreExpiration: boolean;
13
+ readonly passReqToCallback: boolean;
14
+ constructor(jwtOptions: JwtOptions);
15
+ sign(payload: string | object | Buffer): string;
16
+ verify(token: string, verifyOption?: jwt.VerifyOptions): string | object;
17
+ abstract validate(req: Req, payload: any): IPrincipal | Promise<IPrincipal>;
18
+ abstract validate<T>(req: Req, payload: any): T | Promise<T>;
19
+ }
20
+ export declare class DefaultJwtStrategyProvider extends JwtStrategyProvider {
21
+ private readonly authProvider;
22
+ private readonly logger;
23
+ constructor(jwtOptions: JwtOptions, authProvider: AuthProvider);
24
+ validate(req: Req, payload: any): Promise<IPrincipal>;
25
+ }
26
+ export declare class SimpleJwtStrategyProvider extends DefaultJwtStrategyProvider {
27
+ constructor(jwtOptions: JwtOptions);
28
+ }
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SimpleJwtStrategyProvider = exports.DefaultJwtStrategyProvider = exports.JwtStrategyProvider = void 0;
4
+ const nestjs_common_1 = require("@nathapp/nestjs-common");
5
+ const common_1 = require("@nestjs/common");
6
+ const passport_jwt_1 = require("passport-jwt");
7
+ const auth_provider_1 = require("../auth-provider");
8
+ const utils_1 = require("../utils/utils");
9
+ class JwtStrategyProvider {
10
+ constructor(jwtOptions) {
11
+ const extraOptions = {
12
+ bindIp: false,
13
+ allowDuplicateLogin: true,
14
+ checkBlacklisted: true,
15
+ ignoreExpiration: false,
16
+ passReqToCallback: true,
17
+ isBase64AsymmetricKey: false
18
+ };
19
+ this.jwtOptions = Object.assign({}, extraOptions, jwtOptions);
20
+ this.jwtProvider = (0, utils_1.createJwtProvider)(jwtOptions);
21
+ this.secretOrPrivateKey = this.jwtProvider.secretOrPrivateKey;
22
+ this.secretOrPublicKey = this.jwtProvider.secretOrPublicKey;
23
+ this.jwtFromRequestFunction = this.jwtOptions.jwtFromRequestFunction || passport_jwt_1.ExtractJwt.fromAuthHeaderAsBearerToken();
24
+ this.ignoreExpiration = this.jwtOptions.ignoreExpiration;
25
+ this.passReqToCallback = this.jwtOptions.passReqToCallback;
26
+ }
27
+ sign(payload) {
28
+ return this.jwtProvider.sign(payload);
29
+ }
30
+ verify(token, verifyOption) {
31
+ return this.jwtProvider.verify(token, verifyOption);
32
+ }
33
+ }
34
+ exports.JwtStrategyProvider = JwtStrategyProvider;
35
+ class DefaultJwtStrategyProvider extends JwtStrategyProvider {
36
+ constructor(jwtOptions, authProvider) {
37
+ super(jwtOptions);
38
+ this.authProvider = authProvider;
39
+ this.logger = new common_1.Logger(DefaultJwtStrategyProvider.name);
40
+ }
41
+ async validate(req, payload) {
42
+ const { checkBlacklisted, bindIp, allowDuplicateLogin, passReqToCallback } = this.jwtOptions;
43
+ this.logger.debug(`validating Jwt request`);
44
+ this.logger.verbose(`payload: ${JSON.stringify(payload)}`);
45
+ const principal = await this.authProvider.getPrincipal(payload);
46
+ this.logger.verbose(`principal: ${JSON.stringify(principal)}`);
47
+ if (!principal) {
48
+ this.logger.debug(`principal: not found. payload: ${JSON.stringify(payload)}`);
49
+ throw new nestjs_common_1.AppException(nestjs_common_1.CommonExceptionCode.UNAUTHORIZED);
50
+ }
51
+ if (principal.revoked) {
52
+ this.logger.warn(`principal: ${principal.id} has revoked.`);
53
+ this.logger.debug(`principal: ${principal.id} has revoked. token: ${principal.hashToken}`);
54
+ throw new nestjs_common_1.AppException(nestjs_common_1.CommonExceptionCode.UNAUTHORIZED);
55
+ }
56
+ if (checkBlacklisted && principal.blacklisted) {
57
+ this.logger.warn(`principal: ${principal.id} was blacklisted.`);
58
+ throw new nestjs_common_1.AppException(nestjs_common_1.CommonExceptionCode.FORBIDDEN_BLACKLISTED);
59
+ }
60
+ if (bindIp) {
61
+ if (!req && !passReqToCallback) {
62
+ this.logger.warn(`req is undefined, please set passReqToCallback to true, bindIp check is ignored`);
63
+ }
64
+ else {
65
+ const reqIp = (0, nestjs_common_1.getClientIp)(req);
66
+ if (!principal.loginIP || principal.loginIP != reqIp) {
67
+ this.logger.debug(`principal: ${principal.id} is from different IP.`);
68
+ throw new nestjs_common_1.AppException(nestjs_common_1.CommonExceptionCode.FORBIDDEN_IP_NOT_MATCH);
69
+ }
70
+ }
71
+ }
72
+ if (!allowDuplicateLogin) {
73
+ const duplicated = await this.authProvider.isDuplicateLogin(principal, payload);
74
+ if (duplicated) {
75
+ this.logger.warn(`duplicate login was detected for principal: ${principal.id}`);
76
+ throw new nestjs_common_1.AppException(nestjs_common_1.CommonExceptionCode.UNAUTHORIZED);
77
+ }
78
+ }
79
+ return principal;
80
+ }
81
+ }
82
+ exports.DefaultJwtStrategyProvider = DefaultJwtStrategyProvider;
83
+ class SimpleJwtStrategyProvider extends DefaultJwtStrategyProvider {
84
+ constructor(jwtOptions) {
85
+ super(jwtOptions, new auth_provider_1.SimpleAuthProvider());
86
+ }
87
+ }
88
+ exports.SimpleJwtStrategyProvider = SimpleJwtStrategyProvider;
89
+ //# sourceMappingURL=jwt-strategy-provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jwt-strategy-provider.js","sourceRoot":"","sources":["../../lib/strategy/jwt-strategy-provider.ts"],"names":[],"mappings":";;;AACA,0DAAwF;AACxF,2CAAwC;AACxC,+CAAkE;AAClE,oDAAgF;AAIhF,0CAAmD;AAEnD,MAAsB,mBAAmB;IAWvC,YAAY,UAAsB;QAChC,MAAM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,CAAC,CAAC;QACpE,CAAC;QAGD,IAAI,MAAM,EAAE,CAAC;YACX,IAAI,CAAC,GAAG,IAAI,CAAC,iBAAiB,EAAE,CAAC;gBAC/B,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,iFAAiF,CAAC,CAAC;YACtG,CAAC;iBAAM,CAAC;gBACN,MAAM,KAAK,GAAG,IAAA,2BAAW,EAAC,GAAG,CAAC,CAAC;gBAC/B,IAAI,CAAC,SAAS,CAAC,OAAO,IAAI,SAAS,CAAC,OAAO,IAAI,KAAK,EAAE,CAAC;oBACrD,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,cAAc,SAAS,CAAC,EAAE,wBAAwB,CAAC,CAAC;oBACtE,MAAM,IAAI,4BAAY,CAAC,mCAAmB,CAAC,sBAAsB,CAAC,CAAC;gBACrE,CAAC;YACH,CAAC;QACH,CAAC;QAED,IAAI,CAAC,mBAAmB,EAAE,CAAC;YACzB,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,gBAAgB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;YAChF,IAAI,UAAU,EAAE,CAAC;gBACf,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,+CAA+C,SAAS,CAAC,EAAE,EAAE,CAAC,CAAC;gBAChF,MAAM,IAAI,4BAAY,CAAC,mCAAmB,CAAC,YAAY,CAAC,CAAC;YAC3D,CAAC;QACH,CAAC;QAGD,OAAO,SAAS,CAAC;IACnB,CAAC;CAEF;AAvDD,gEAuDC;AAGD,MAAa,yBAA0B,SAAQ,0BAA0B;IAEvE,YAAY,UAAsB;QAChC,KAAK,CAAC,UAAU,EAAE,IAAI,kCAAkB,EAAE,CAAC,CAAC;IAC9C,CAAC;CAEF;AAND,8DAMC"}
@@ -0,0 +1,9 @@
1
+ import { Strategy } from "passport-jwt";
2
+ import { JwtStrategyProvider } from "./jwt-strategy-provider";
3
+ declare const JwtStrategy_base: new (...args: any[]) => Strategy;
4
+ export declare class JwtStrategy extends JwtStrategy_base {
5
+ private readonly strategyProvider;
6
+ constructor(strategyProvider: JwtStrategyProvider);
7
+ validate(arg1: any, arg2: any): Promise<import("..").IPrincipal>;
8
+ }
9
+ export {};
@@ -0,0 +1,39 @@
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.JwtStrategy = void 0;
13
+ const passport_jwt_1 = require("passport-jwt");
14
+ const passport_1 = require("@nestjs/passport");
15
+ const common_1 = require("@nestjs/common");
16
+ const constant_1 = require("../constant");
17
+ const jwt_strategy_provider_1 = require("./jwt-strategy-provider");
18
+ let JwtStrategy = class JwtStrategy extends (0, passport_1.PassportStrategy)(passport_jwt_1.Strategy, constant_1.JWT_STRATEGY_NAME) {
19
+ constructor(strategyProvider) {
20
+ super({
21
+ jwtFromRequest: strategyProvider.jwtFromRequestFunction,
22
+ ignoreExpiration: strategyProvider.ignoreExpiration,
23
+ secretOrKey: strategyProvider.secretOrPublicKey,
24
+ passReqToCallback: strategyProvider.passReqToCallback,
25
+ });
26
+ this.strategyProvider = strategyProvider;
27
+ }
28
+ async validate(arg1, arg2) {
29
+ const req = this.strategyProvider.passReqToCallback ? arg1 : {};
30
+ const payload = this.strategyProvider.passReqToCallback ? arg2 : arg1;
31
+ return this.strategyProvider.validate(req, payload);
32
+ }
33
+ };
34
+ exports.JwtStrategy = JwtStrategy;
35
+ exports.JwtStrategy = JwtStrategy = __decorate([
36
+ (0, common_1.Injectable)(),
37
+ __metadata("design:paramtypes", [jwt_strategy_provider_1.JwtStrategyProvider])
38
+ ], JwtStrategy);
39
+ //# sourceMappingURL=jwt-strategy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jwt-strategy.js","sourceRoot":"","sources":["../../lib/strategy/jwt-strategy.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+CAAwC;AACxC,+CAAoD;AACpD,2CAA4C;AAC5C,0CAAgD;AAChD,mEAA8D;AAIvD,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQ,IAAA,2BAAgB,EAAC,uBAAQ,EAAE,4BAAiB,CAAC;IAC5E,YAA6B,gBAAqC;QAChE,KAAK,CAAC;YACJ,cAAc,EAAE,gBAAgB,CAAC,sBAAsB;YACvD,gBAAgB,EAAE,gBAAgB,CAAC,gBAAgB;YACnD,WAAW,EAAE,gBAAgB,CAAC,iBAAiB;YAC/C,iBAAiB,EAAE,gBAAgB,CAAC,iBAAiB;SACtD,CAAC,CAAC;QANwB,qBAAgB,GAAhB,gBAAgB,CAAqB;IAOlE,CAAC;IASD,KAAK,CAAC,QAAQ,CAAC,IAAS,EAAE,IAAS;QACjC,MAAM,GAAG,GAAQ,IAAI,CAAC,gBAAgB,CAAC,iBAAiB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;QACrE,MAAM,OAAO,GAAQ,IAAI,CAAC,gBAAgB,CAAC,iBAAiB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;QAE3E,OAAO,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IACtD,CAAC;CACF,CAAA;AAvBY,kCAAW;sBAAX,WAAW;IADvB,IAAA,mBAAU,GAAE;qCAEoC,2CAAmB;GADvD,WAAW,CAuBvB"}
@@ -0,0 +1,14 @@
1
+ import { IPrincipal } from "../auth-provider";
2
+ import { Req, VerifyOptions } from "./type-interface";
3
+ export interface IStrategyProvider {
4
+ validate(req: Req, payload: any): IPrincipal | Promise<IPrincipal>;
5
+ validate<T>(req: Req, payload: any): T | Promise<T>;
6
+ sign(payload: string | object | Buffer): string;
7
+ verify(token: string, verifyOption?: VerifyOptions): object | string;
8
+ }
9
+ export declare abstract class StrategyProvider implements IStrategyProvider {
10
+ abstract validate(req: Req, payload: any): IPrincipal | Promise<IPrincipal>;
11
+ abstract validate<T>(req: Req, payload: any): T | Promise<T>;
12
+ abstract sign(payload: string | object | Buffer): string;
13
+ abstract verify(token: string, verifyOption?: VerifyOptions): string | object;
14
+ }
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StrategyProvider = void 0;
4
+ class StrategyProvider {
5
+ }
6
+ exports.StrategyProvider = StrategyProvider;
7
+ //# sourceMappingURL=strategy-provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"strategy-provider.js","sourceRoot":"","sources":["../../lib/strategy/strategy-provider.ts"],"names":[],"mappings":";;;AAeA,MAAsB,gBAAgB;CAQrC;AARD,4CAQC"}
@@ -0,0 +1,15 @@
1
+ import * as jwt from 'jsonwebtoken';
2
+ import { JwtOptions as jOption } from "@nathapp/auth";
3
+ import { JwtFromRequestFunction } from "passport-jwt";
4
+ export interface JwtNestJsOptions {
5
+ bindIp?: boolean;
6
+ allowDuplicateLogin?: boolean;
7
+ checkBlacklisted?: boolean;
8
+ ignoreExpiration?: boolean;
9
+ passReqToCallback?: boolean;
10
+ jwtFromRequestFunction?: JwtFromRequestFunction;
11
+ isBase64AsymmetricKey?: boolean;
12
+ }
13
+ export declare type JwtOptions = JwtNestJsOptions & jOption;
14
+ export declare type VerifyOptions = jwt.VerifyOptions;
15
+ export declare type Req = any;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=type-interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type-interface.js","sourceRoot":"","sources":["../../lib/strategy/type-interface.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ import { isAuthority, isCaslPermission, isCaslPermissionAction, isRequiredCaslPermission } from "./utils";
2
+ export { isCaslPermission, isAuthority, isCaslPermissionAction, isRequiredCaslPermission };
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isRequiredCaslPermission = exports.isCaslPermissionAction = exports.isAuthority = exports.isCaslPermission = void 0;
4
+ const utils_1 = require("./utils");
5
+ Object.defineProperty(exports, "isAuthority", { enumerable: true, get: function () { return utils_1.isAuthority; } });
6
+ Object.defineProperty(exports, "isCaslPermission", { enumerable: true, get: function () { return utils_1.isCaslPermission; } });
7
+ Object.defineProperty(exports, "isCaslPermissionAction", { enumerable: true, get: function () { return utils_1.isCaslPermissionAction; } });
8
+ Object.defineProperty(exports, "isRequiredCaslPermission", { enumerable: true, get: function () { return utils_1.isRequiredCaslPermission; } });
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/utils/index.ts"],"names":[],"mappings":";;;AAAA,mCAA0G;AAIxG,4FAJO,mBAAW,OAIP;AADX,iGAHoB,wBAAgB,OAGpB;AAEhB,uGALsC,8BAAsB,OAKtC;AACtB,yGAN8D,gCAAwB,OAM9D"}
@@ -0,0 +1,10 @@
1
+ import { JwtProvider } from "@nathapp/auth";
2
+ import { Authority, CaslPermission, PermissionType } from "../permission";
3
+ import { JwtOptions } from "../strategy";
4
+ import { Algorithm } from "jsonwebtoken";
5
+ export declare const isCaslPermission: (val: any) => val is CaslPermission;
6
+ export declare const isAuthority: (val: any) => val is Authority;
7
+ export declare const isCaslPermissionAction: (val: any) => boolean;
8
+ export declare const isRequiredCaslPermission: (permission: PermissionType) => boolean;
9
+ export declare const createJwtProvider: (jwtOptions: JwtOptions) => JwtProvider;
10
+ export declare const isAysmmetricAlgo: (algo: string | Algorithm) => boolean;
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isAysmmetricAlgo = exports.createJwtProvider = exports.isRequiredCaslPermission = exports.isCaslPermissionAction = exports.isAuthority = exports.isCaslPermission = void 0;
4
+ const auth_1 = require("@nathapp/auth");
5
+ const permission_1 = require("../permission");
6
+ const isCaslPermission = (val) => {
7
+ return 'subject' in val && 'action' in val;
8
+ };
9
+ exports.isCaslPermission = isCaslPermission;
10
+ const isAuthority = (val) => {
11
+ return ('id' in val && typeof val.id === 'string' || typeof val.id === 'number') && 'name' in val && typeof val.name === 'string';
12
+ };
13
+ exports.isAuthority = isAuthority;
14
+ const isCaslPermissionAction = (val) => {
15
+ const actions = Object.values(permission_1.CaslPermissionAction);
16
+ return actions.includes(val);
17
+ };
18
+ exports.isCaslPermissionAction = isCaslPermissionAction;
19
+ const isRequiredCaslPermission = (permission) => {
20
+ return Array.isArray(permission) && permission.length > 0 && !Array.isArray(permission[0]) && (0, exports.isCaslPermissionAction)(permission[0]);
21
+ };
22
+ exports.isRequiredCaslPermission = isRequiredCaslPermission;
23
+ const createJwtProvider = (jwtOptions) => {
24
+ if (jwtOptions.isBase64AsymmetricKey && (0, exports.isAysmmetricAlgo)(jwtOptions.signOption.algorithm)) {
25
+ const privateKeyBuff = typeof jwtOptions.privateKey == 'string' ? Buffer.from(jwtOptions.privateKey, 'base64') : jwtOptions.privateKey;
26
+ const publicKeyBuff = typeof jwtOptions.publicKey == 'string' ? Buffer.from(jwtOptions.publicKey, 'base64') : jwtOptions.publicKey;
27
+ const privateKey = privateKeyBuff ? privateKeyBuff.toString('utf-8') : undefined;
28
+ const publicKey = publicKeyBuff ? publicKeyBuff.toString('utf-8') : undefined;
29
+ return new auth_1.JwtProvider({
30
+ ...jwtOptions,
31
+ privateKey,
32
+ publicKey,
33
+ });
34
+ }
35
+ else {
36
+ return new auth_1.JwtProvider(jwtOptions);
37
+ }
38
+ };
39
+ exports.createJwtProvider = createJwtProvider;
40
+ const isAysmmetricAlgo = (algo) => {
41
+ switch (algo) {
42
+ case "RS256":
43
+ case "RS384":
44
+ case "RS512":
45
+ case "PS256":
46
+ case "PS384":
47
+ case "PS512":
48
+ case "ES256":
49
+ case "ES384":
50
+ case "ES512":
51
+ return true;
52
+ default: return false;
53
+ }
54
+ };
55
+ exports.isAysmmetricAlgo = isAysmmetricAlgo;
56
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../lib/utils/utils.ts"],"names":[],"mappings":";;;AAAA,wCAA4C;AAC5C,8CAAgG;AAIzF,MAAO,gBAAgB,GAAG,CAAC,GAAQ,EAAyB,EAAE;IACnE,OAAO,SAAS,IAAI,GAAG,IAAI,QAAQ,IAAI,GAAG,CAAC;AAC7C,CAAC,CAAA;AAFa,QAAA,gBAAgB,oBAE7B;AAEM,MAAM,WAAW,GAAG,CAAC,GAAQ,EAAoB,EAAE;IACxD,OAAO,CAAC,IAAI,IAAI,GAAG,IAAI,OAAO,GAAG,CAAC,EAAE,KAAK,QAAQ,IAAI,OAAO,GAAG,CAAC,EAAE,KAAK,QAAQ,CAAC,IAAI,MAAM,IAAI,GAAG,IAAI,OAAO,GAAG,CAAC,IAAI,KAAK,QAAQ,CAAC;AACpI,CAAC,CAAA;AAFY,QAAA,WAAW,eAEvB;AAEM,MAAM,sBAAsB,GAAG,CAAC,GAAQ,EAAW,EAAE;IAC1D,MAAM,OAAO,GAAa,MAAM,CAAC,MAAM,CAAC,iCAAoB,CAAC,CAAC;IAChE,OAAO,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;AAC7B,CAAC,CAAA;AAHY,QAAA,sBAAsB,0BAGlC;AAEM,MAAM,wBAAwB,GAAG,CAAC,UAA0B,EAAW,EAAE;IAC9E,OA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M,MAAM,gBAAgB,GAAG,CAAC,IAAwB,EAAW,EAAE;IAClE,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,OAAO,CAAC;QACb,KAAK,OAAO,CAAC;QACb,KAAK,OAAO,CAAC;QACb,KAAK,OAAO,CAAC;QACb,KAAK,OAAO,CAAC;QACb,KAAK,OAAO,CAAC;QACb,KAAK,OAAO,CAAC;QACb,KAAK,OAAO,CAAC;QACb,KAAK,OAAO;YACV,OAAO,IAAI,CAAC;QACd,OAAO,CAAC,CAAC,OAAO,KAAK,CAAC;IACxB,CAAC;AACL,CAAC,CAAA;AAdY,QAAA,gBAAgB,oBAc5B"}
package/package.json CHANGED
@@ -1,30 +1,24 @@
1
1
  {
2
2
  "name": "@nathapp/nestjs-auth",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "nestjs-auth",
5
5
  "scripts": {
6
+ "clean": "rimraf dist/ .turbo/",
6
7
  "build": "rimraf dist && tsc -p tsconfig.json",
7
8
  "precommit": "lint-staged",
8
- "test": "jest",
9
- "test:watch": "jest --watch",
10
- "test:cov": "jest --coverage",
11
- "test:e2e": "jest --config ./test/jest-e2e.json",
9
+ "test": "jest --config ./test/jest-test.json",
10
+ "test:cov": "jest --config ./test/jest-test.json --coverage",
11
+ "test:watch": "jest --config ./test/jest-test.json --watch",
12
12
  "lint": "eslint -c .eslintrc.js"
13
13
  },
14
14
  "author": "",
15
15
  "license": "ISC",
16
16
  "devDependencies": {
17
- "@nestjs/platform-express": "^9.0.0",
18
- "@nestjs/platform-fastify": "^9.0.0",
19
- "@types/js-yaml": "^4.0.5",
20
- "@types/node": "^17.0.22",
21
- "@typescript-eslint/eslint-plugin": "^4",
22
- "@typescript-eslint/parser": "^4",
23
- "eslint": "*",
24
- "eslint-config-prettier": "^6",
25
- "eslint-plugin-prettier": "^3",
26
- "prettier": "^2",
27
- "typescript": "^4"
17
+ "@nathapp/eslint-config": "1.0.1",
18
+ "@nathapp/typescript-config": "1.0.1",
19
+ "@types/passport-jwt": "^3.0.8",
20
+ "eslint": "^8.57.0",
21
+ "typescript": "^5"
28
22
  },
29
23
  "types": "./index.d.ts",
30
24
  "main": "index.js",
@@ -32,13 +26,13 @@
32
26
  "lib": "lib"
33
27
  },
34
28
  "dependencies": {
35
- "@nathapp/auth": "^1.0.0"
29
+ "@nathapp/nestjs-common": "^1.0.2-rc.0",
30
+ "passport-jwt": "^4.0.1"
36
31
  },
37
32
  "peerDependencies": {
38
- "@nestjs/common": "*",
39
- "@nestjs/core": "*",
40
- "class-transformer": "*",
41
- "class-validator": "*",
42
- "rxjs": "*"
33
+ "@nathapp/auth": "^1.0.2",
34
+ "@nathapp/nestjs-common": "^1.0.2",
35
+ "@nestjs/passport": "^8.0.0 || ^9.0.0 || ^10.0.0",
36
+ "@casl/ability": "^6.7.1"
43
37
  }
44
38
  }
package/.eslintrc.js DELETED
@@ -1,24 +0,0 @@
1
- module.exports = {
2
- parser: '@typescript-eslint/parser',
3
- parserOptions: {
4
- project: 'tsconfig.json',
5
- sourceType: 'module',
6
- },
7
- plugins: ['@typescript-eslint/eslint-plugin'],
8
- extends: [
9
- 'plugin:@typescript-eslint/recommended',
10
- 'plugin:prettier/recommended',
11
- ],
12
- root: true,
13
- env: {
14
- node: true,
15
- jest: true,
16
- },
17
- ignorePatterns: ['.eslintrc.js'],
18
- rules: {
19
- '@typescript-eslint/interface-name-prefix': 'off',
20
- '@typescript-eslint/explicit-function-return-type': 'off',
21
- '@typescript-eslint/explicit-module-boundary-types': 'off',
22
- '@typescript-eslint/no-explicit-any': 'off',
23
- },
24
- };