nestjs-authentication 0.2.1 → 0.3.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.
Files changed (90) hide show
  1. package/dist/classes/memory.user.d.ts +4 -5
  2. package/dist/classes/memory.user.d.ts.map +1 -1
  3. package/dist/classes/memory.user.js +0 -5
  4. package/dist/classes/memory.user.js.map +1 -1
  5. package/dist/constants.d.ts +3 -0
  6. package/dist/constants.d.ts.map +1 -0
  7. package/dist/constants.js +6 -0
  8. package/dist/constants.js.map +1 -0
  9. package/dist/encryptor.d.ts +7 -0
  10. package/dist/encryptor.d.ts.map +1 -0
  11. package/dist/encryptor.js +31 -0
  12. package/dist/encryptor.js.map +1 -0
  13. package/dist/guard.d.ts +16 -12
  14. package/dist/guard.d.ts.map +1 -1
  15. package/dist/guard.js +71 -52
  16. package/dist/guard.js.map +1 -1
  17. package/dist/index.d.ts +13 -13
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/index.js +13 -13
  20. package/dist/index.js.map +1 -1
  21. package/dist/interfaces/auth.user.d.ts +6 -0
  22. package/dist/interfaces/auth.user.d.ts.map +1 -0
  23. package/dist/interfaces/{jwt.payload.js → auth.user.js} +1 -1
  24. package/dist/interfaces/auth.user.js.map +1 -0
  25. package/dist/interfaces/encrypt.d.ts +2 -2
  26. package/dist/interfaces/encrypt.d.ts.map +1 -1
  27. package/dist/interfaces/options.d.ts +4 -2
  28. package/dist/interfaces/options.d.ts.map +1 -1
  29. package/dist/interfaces/provider.d.ts +4 -4
  30. package/dist/interfaces/provider.d.ts.map +1 -1
  31. package/dist/module.d.ts +14 -4
  32. package/dist/module.d.ts.map +1 -1
  33. package/dist/module.js +89 -29
  34. package/dist/module.js.map +1 -1
  35. package/dist/providers/auth.memory.user.provider.d.ts +17 -0
  36. package/dist/providers/auth.memory.user.provider.d.ts.map +1 -0
  37. package/dist/providers/auth.memory.user.provider.js +48 -0
  38. package/dist/providers/auth.memory.user.provider.js.map +1 -0
  39. package/dist/providers/auth.provider.d.ts +8 -11
  40. package/dist/providers/auth.provider.d.ts.map +1 -1
  41. package/dist/providers/auth.provider.js +12 -31
  42. package/dist/providers/auth.provider.js.map +1 -1
  43. package/dist/providers/{memory.provider.d.ts → memory.user.provider.d.ts} +1 -1
  44. package/dist/providers/memory.user.provider.d.ts.map +1 -0
  45. package/dist/providers/{memory.provider.js → memory.user.provider.js} +5 -5
  46. package/dist/providers/memory.user.provider.js.map +1 -0
  47. package/dist/service.d.ts +2 -10
  48. package/dist/service.d.ts.map +1 -1
  49. package/dist/service.js +2 -35
  50. package/dist/service.js.map +1 -1
  51. package/dist/strategies/emailpassword.d.ts +14 -0
  52. package/dist/strategies/emailpassword.d.ts.map +1 -0
  53. package/dist/strategies/{local.js → emailpassword.js} +18 -16
  54. package/dist/strategies/emailpassword.js.map +1 -0
  55. package/dist/strategies/jwt.d.ts +22 -0
  56. package/dist/strategies/jwt.d.ts.map +1 -0
  57. package/dist/strategies/jwt.js +40 -0
  58. package/dist/strategies/jwt.js.map +1 -0
  59. package/dist/user.serializer.d.ts +4 -8
  60. package/dist/user.serializer.d.ts.map +1 -1
  61. package/dist/user.serializer.js +4 -13
  62. package/dist/user.serializer.js.map +1 -1
  63. package/package.json +43 -40
  64. package/test/controller.ts +43 -0
  65. package/test/encryptor.spec.ts +20 -0
  66. package/test/module.spec.ts +261 -0
  67. package/dist/classes/user.d.ts +0 -8
  68. package/dist/classes/user.d.ts.map +0 -1
  69. package/dist/classes/user.js +0 -7
  70. package/dist/classes/user.js.map +0 -1
  71. package/dist/controller.d.ts +0 -8
  72. package/dist/controller.d.ts.map +0 -1
  73. package/dist/controller.js +0 -39
  74. package/dist/controller.js.map +0 -1
  75. package/dist/interfaces/emailpassword.d.ts +0 -5
  76. package/dist/interfaces/emailpassword.d.ts.map +0 -1
  77. package/dist/interfaces/emailpassword.js +0 -3
  78. package/dist/interfaces/emailpassword.js.map +0 -1
  79. package/dist/interfaces/jwt.payload.d.ts +0 -6
  80. package/dist/interfaces/jwt.payload.d.ts.map +0 -1
  81. package/dist/interfaces/jwt.payload.js.map +0 -1
  82. package/dist/interfaces/login.request.d.ts +0 -6
  83. package/dist/interfaces/login.request.d.ts.map +0 -1
  84. package/dist/interfaces/login.request.js +0 -3
  85. package/dist/interfaces/login.request.js.map +0 -1
  86. package/dist/providers/memory.provider.d.ts.map +0 -1
  87. package/dist/providers/memory.provider.js.map +0 -1
  88. package/dist/strategies/local.d.ts +0 -16
  89. package/dist/strategies/local.d.ts.map +0 -1
  90. package/dist/strategies/local.js.map +0 -1
@@ -1,8 +1,7 @@
1
- import { User } from './user';
2
- export declare class MemoryUser extends User {
1
+ import { IAuthUser } from '../interfaces/auth.user';
2
+ export interface MemoryUser extends IAuthUser {
3
3
  _id: any;
4
- firstName: string;
5
- lastName: string;
6
- roles: string[];
4
+ email: string;
5
+ passwordEncrypted: string;
7
6
  }
8
7
  //# sourceMappingURL=memory.user.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"memory.user.d.ts","sourceRoot":"","sources":["../../src/classes/memory.user.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,qBAAa,UAAW,SAAQ,IAAI;IAChC,GAAG,EAAE,GAAG,CAAC;IACT,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,EAAE,CAAC;CACnB"}
1
+ {"version":3,"file":"memory.user.d.ts","sourceRoot":"","sources":["../../src/classes/memory.user.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEpD,MAAM,WAAW,UAAW,SAAQ,SAAS;IACzC,GAAG,EAAE,GAAG,CAAC;IACT,KAAK,EAAE,MAAM,CAAC;IACd,iBAAiB,EAAE,MAAM,CAAC;CAC7B"}
@@ -1,8 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MemoryUser = void 0;
4
- const user_1 = require("./user");
5
- class MemoryUser extends user_1.User {
6
- }
7
- exports.MemoryUser = MemoryUser;
8
3
  //# sourceMappingURL=memory.user.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"memory.user.js","sourceRoot":"","sources":["../../src/classes/memory.user.ts"],"names":[],"mappings":";;;AAAA,iCAA8B;AAE9B,MAAa,UAAW,SAAQ,WAAI;CAKnC;AALD,gCAKC"}
1
+ {"version":3,"file":"memory.user.js","sourceRoot":"","sources":["../../src/classes/memory.user.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ export declare const MODULE_OPTIONS_TOKEN = "nestjs-authentication:options";
2
+ export declare const MODULE_PROVIDER_REGISTER = "nestjs-authentication:provider.register";
3
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB,kCAAkC,CAAC;AACpE,eAAO,MAAM,wBAAwB,4CAA4C,CAAC"}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MODULE_PROVIDER_REGISTER = exports.MODULE_OPTIONS_TOKEN = void 0;
4
+ exports.MODULE_OPTIONS_TOKEN = 'nestjs-authentication:options';
5
+ exports.MODULE_PROVIDER_REGISTER = 'nestjs-authentication:provider.register';
6
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,oBAAoB,GAAG,+BAA+B,CAAC;AACvD,QAAA,wBAAwB,GAAG,yCAAyC,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { IEncryptor, IEncryptorOptions } from './interfaces/encrypt';
2
+ export declare class Encryptor implements IEncryptor {
3
+ protected options: IEncryptorOptions;
4
+ constructor(options: IEncryptorOptions);
5
+ encrypt(value: string): string;
6
+ }
7
+ //# sourceMappingURL=encryptor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"encryptor.d.ts","sourceRoot":"","sources":["../src/encryptor.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAErE,qBACa,SAAU,YAAW,UAAU;IAC5B,SAAS,CAAC,OAAO,EAAE,iBAAiB;gBAA1B,OAAO,EAAE,iBAAiB;IAEhD,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;CAUjC"}
@@ -0,0 +1,31 @@
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.Encryptor = void 0;
13
+ const common_1 = require("@nestjs/common");
14
+ const crypto_1 = require("crypto");
15
+ let Encryptor = class Encryptor {
16
+ constructor(options) {
17
+ this.options = options;
18
+ }
19
+ encrypt(value) {
20
+ const cipher = (0, crypto_1.createCipheriv)('aes-256-ctr', Buffer.from(this.options.key, 'hex'), Buffer.from(this.options.iv, 'hex'));
21
+ let crypted = cipher.update(value, 'utf8', 'hex');
22
+ crypted += cipher.final('hex');
23
+ return crypted;
24
+ }
25
+ };
26
+ Encryptor = __decorate([
27
+ (0, common_1.Injectable)(),
28
+ __metadata("design:paramtypes", [Object])
29
+ ], Encryptor);
30
+ exports.Encryptor = Encryptor;
31
+ //# sourceMappingURL=encryptor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"encryptor.js","sourceRoot":"","sources":["../src/encryptor.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,mCAAwC;AAKxC,IAAa,SAAS,GAAtB,MAAa,SAAS;IAClB,YAAsB,OAA0B;QAA1B,YAAO,GAAP,OAAO,CAAmB;IAAG,CAAC;IAEpD,OAAO,CAAC,KAAa;QACjB,MAAM,MAAM,GAAG,IAAA,uBAAc,EACzB,aAAa,EACb,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,EACpC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,EAAE,KAAK,CAAC,CACtC,CAAC;QACF,IAAI,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;QAClD,OAAO,IAAI,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC/B,OAAO,OAAO,CAAC;IACnB,CAAC;CACJ,CAAA;AAbY,SAAS;IADrB,IAAA,mBAAU,GAAE;;GACA,SAAS,CAarB;AAbY,8BAAS"}
package/dist/guard.d.ts CHANGED
@@ -1,18 +1,22 @@
1
1
  import { CanActivate, ExecutionContext } from '@nestjs/common';
2
2
  import { Request } from 'express';
3
- import * as passport from 'passport';
4
- import { User } from './classes/user';
5
- export declare const scopes: Map<any, any>;
6
- export interface IAuthGuardOptions extends passport.AuthenticateOptions {
7
- isAuth?: boolean;
8
- strategy: string | string[];
9
- }
3
+ import { AuthenticateOptions } from 'passport';
10
4
  export declare class AuthGuard implements CanActivate {
11
- protected readonly options: IAuthGuardOptions;
12
- constructor(options: IAuthGuardOptions & {
13
- [key: string]: any;
14
- });
5
+ protected readonly strategies: {
6
+ [strategyName: string]: AuthenticateOptions;
7
+ };
8
+ protected readonly isAuthRequired?: boolean | undefined;
9
+ static scopes: Map<any, any>;
10
+ static registerScopes(_scopes: AuthenticateOptions['scope']): void;
11
+ constructor(strategies: {
12
+ [strategyName: string]: AuthenticateOptions;
13
+ }, isAuthRequired?: boolean | undefined);
14
+ getRequestReponse(context: ExecutionContext): {
15
+ request: any;
16
+ response: any;
17
+ next: any;
18
+ };
15
19
  canActivate(context: ExecutionContext): Promise<boolean>;
16
- login(user: User, request: Request): Promise<User>;
20
+ login(user: Record<string, unknown>, options: AuthenticateOptions, request: Request): Promise<Record<string, unknown>>;
17
21
  }
18
22
  //# sourceMappingURL=guard.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"guard.d.ts","sourceRoot":"","sources":["../src/guard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAyB,MAAM,gBAAgB,CAAC;AACtF,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,KAAK,QAAQ,MAAM,UAAU,CAAC;AAErC,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAEtC,eAAO,MAAM,MAAM,eAAY,CAAC;AAEhC,MAAM,WAAW,iBAAkB,SAAQ,QAAQ,CAAC,mBAAmB;IACnE,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CAC/B;AAED,qBAAa,SAAU,YAAW,WAAW;IACzC,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,iBAAiB,CAAC;gBAElC,OAAO,EAAE,iBAAiB,GAAG;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE;IAezD,WAAW,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC;IAgDxD,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;CAY3D"}
1
+ {"version":3,"file":"guard.d.ts","sourceRoot":"","sources":["../src/guard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAC/D,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAiB,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAEzD,qBAAa,SAAU,YAAW,WAAW;IAmBrC,SAAS,CAAC,QAAQ,CAAC,UAAU,EAAE;QAAE,CAAC,YAAY,EAAE,MAAM,GAAG,mBAAmB,CAAA;KAAE;IAC9E,SAAS,CAAC,QAAQ,CAAC,cAAc,CAAC;IAhBtC,MAAM,CAAC,MAAM,gBAAa;IAC1B,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,mBAAmB,CAAC,OAAO,CAAC;gBAcpC,UAAU,EAAE;QAAE,CAAC,YAAY,EAAE,MAAM,GAAG,mBAAmB,CAAA;KAAE,EAC3D,cAAc,CAAC,qBAAS;IAa/C,iBAAiB,CAAC,OAAO,EAAE,gBAAgB;;;;;IAmBrC,WAAW,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC;IAmCxD,KAAK,CACP,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,OAAO,EAAE,mBAAmB,EAC5B,OAAO,EAAE,OAAO,GACjB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAUtC"}
package/dist/guard.js CHANGED
@@ -8,79 +8,98 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
11
14
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.AuthGuard = exports.scopes = void 0;
13
- const common_1 = require("@nestjs/common");
14
- const passport = require("passport");
15
- exports.scopes = new Map();
15
+ exports.AuthGuard = void 0;
16
+ const passport_1 = __importDefault(require("passport"));
16
17
  class AuthGuard {
17
- constructor(options) {
18
- this.options = Object.assign(Object.assign({}, options), { authInfo: true });
19
- if (typeof this.options.scope === 'string') {
20
- this.options.scope = [this.options.scope];
18
+ constructor(strategies, isAuthRequired) {
19
+ var _a;
20
+ this.strategies = strategies;
21
+ this.isAuthRequired = isAuthRequired;
22
+ for (const strategy in this.strategies) {
23
+ const options = this.strategies[strategy];
24
+ options.authInfo = (_a = options === null || options === void 0 ? void 0 : options.authInfo) !== null && _a !== void 0 ? _a : true;
25
+ AuthGuard.registerScopes(options === null || options === void 0 ? void 0 : options.scope);
21
26
  }
22
- if (Array.isArray(this.options.scope)) {
23
- for (const scope of this.options.scope) {
24
- exports.scopes.set(scope, scope);
25
- }
27
+ }
28
+ static registerScopes(_scopes) {
29
+ if (_scopes === undefined) {
30
+ return;
31
+ }
32
+ let arrayScopes;
33
+ if (!Array.isArray(_scopes)) {
34
+ arrayScopes = _scopes.split(' ');
35
+ }
36
+ else {
37
+ arrayScopes = _scopes;
38
+ }
39
+ arrayScopes.forEach((s) => AuthGuard.scopes.set(s, s));
40
+ }
41
+ getRequestReponse(context) {
42
+ let request;
43
+ let response;
44
+ let next;
45
+ if (context.getType() === 'http') {
46
+ const ctx = context.switchToHttp();
47
+ [request, response, next] = [ctx.getRequest(), ctx.getResponse(), ctx.getNext()];
26
48
  }
27
- if (typeof this.options.strategy === 'string') {
28
- this.options.strategy = [this.options.strategy];
49
+ else if (context.getType() === 'graphql') {
50
+ const ctx = context.getArgByIndex(2);
51
+ request = ctx.req;
52
+ response = ctx.res;
53
+ next = (err) => {
54
+ throw err;
55
+ };
29
56
  }
57
+ return { request, response, next };
30
58
  }
31
59
  canActivate(context) {
32
60
  return __awaiter(this, void 0, void 0, function* () {
33
- const httpCtx = context.switchToHttp();
34
- let [request, response, next] = [httpCtx.getRequest(), httpCtx.getResponse(), httpCtx.getNext()];
35
- if (typeof request !== 'object') {
36
- request = context.getArgByIndex(2).request;
37
- response = request.res;
38
- next = (err) => {
39
- throw err;
40
- };
41
- }
42
- for (const strategy of this.options.strategy) {
43
- if (strategy === 'local' && request.isAuthenticated() === true) {
44
- return true;
45
- }
46
- else {
47
- yield new Promise((resolve, reject) => passport.authenticate(strategy, this.options, (err, user, info) => __awaiter(this, void 0, void 0, function* () {
48
- request.authInfo = info;
49
- try {
50
- if (err !== undefined && err !== null) {
51
- throw err;
52
- }
53
- if (typeof user !== 'object' && this.options.isAuth) {
54
- throw new Error('User not found');
55
- }
56
- if (typeof user === 'object') {
57
- yield this.login(user, request);
58
- }
59
- resolve(true);
61
+ const { request, response, next } = this.getRequestReponse(context);
62
+ for (const strategy in this.strategies) {
63
+ const options = this.strategies[strategy];
64
+ const success = yield new Promise((resolve, reject) => passport_1.default.authenticate(strategy, options !== null && options !== void 0 ? options : {}, (err, user, authInfo) => __awaiter(this, void 0, void 0, function* () {
65
+ if (request.authInfo === undefined) {
66
+ request.authInfo = [];
67
+ }
68
+ request.authInfo[strategy] = authInfo;
69
+ try {
70
+ if (err !== undefined && err !== null) {
71
+ return reject(err);
60
72
  }
61
- catch (e) {
62
- reject(new common_1.UnauthorizedException(typeof (e === null || e === void 0 ? void 0 : e.message) === 'string' ? e.message : 'Uncaught error'));
73
+ if (typeof user === 'object' && typeof user !== null) {
74
+ yield this.login(user, options, request);
75
+ return resolve(true);
63
76
  }
64
- }))(request, response, next));
77
+ return resolve(false);
78
+ }
79
+ catch (e) {
80
+ return reject(e);
81
+ }
82
+ }))(request, response, next));
83
+ if (success === true) {
84
+ return success;
65
85
  }
66
86
  }
67
- return true;
87
+ return this.isAuthRequired ? request.isAuthenticated() : true;
68
88
  });
69
89
  }
70
- login(user, request) {
90
+ login(user, options, request) {
71
91
  return __awaiter(this, void 0, void 0, function* () {
72
- request.oauth2Scope = this.options.scope;
73
- yield new Promise((resolve, reject) => {
74
- request.logIn(user, (loginErr) => {
75
- if (loginErr instanceof Error) {
76
- return reject(loginErr);
92
+ return yield new Promise((resolve, reject) => {
93
+ request.logIn(user, options, (e) => {
94
+ if (e !== undefined && e !== null) {
95
+ return reject(e);
77
96
  }
78
97
  resolve(user);
79
98
  });
80
99
  });
81
- return user;
82
100
  });
83
101
  }
84
102
  }
85
103
  exports.AuthGuard = AuthGuard;
104
+ AuthGuard.scopes = new Map();
86
105
  //# sourceMappingURL=guard.js.map
package/dist/guard.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"guard.js","sourceRoot":"","sources":["../src/guard.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAsF;AAEtF,qCAAqC;AAIxB,QAAA,MAAM,GAAG,IAAI,GAAG,EAAE,CAAC;AAOhC,MAAa,SAAS;IAGlB,YAAY,OAAmD;QAC3D,IAAI,CAAC,OAAO,mCAAQ,OAAO,KAAE,QAAQ,EAAE,IAAI,GAAE,CAAC;QAC9C,IAAI,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,KAAK,QAAQ,EAAE;YACxC,IAAI,CAAC,OAAO,CAAC,KAAK,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;SAC7C;QACD,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;YACnC,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE;gBACpC,cAAM,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;aAC5B;SACJ;QACD,IAAI,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,KAAK,QAAQ,EAAE;YAC3C,IAAI,CAAC,OAAO,CAAC,QAAQ,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;SACnD;IACL,CAAC;IAEK,WAAW,CAAC,OAAyB;;YACvC,MAAM,OAAO,GAAG,OAAO,CAAC,YAAY,EAAE,C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,CAAC,OAAO,EAAE,QAAQ,EAAE,IAAI,CAAC,CAC7B,CAAC;gBACF,IAAI,OAAO,KAAK,IAAI,EAAE;oBAClB,OAAO,OAAO,CAAC;iBAClB;aACJ;YACD,OAAO,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,OAAO,CAAC,eAAe,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;QAClE,CAAC;KAAA;IAEK,KAAK,CACP,IAA6B,EAC7B,OAA4B,EAC5B,OAAgB;;YAEhB,OAAO,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;gBACzC,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC,CAAQ,EAAE,EAAE;oBACtC,IAAI,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,IAAI,EAAE;wBAC/B,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC;qBACpB;oBACD,OAAO,CAAC,IAAI,CAAC,CAAC;gBAClB,CAAC,CAAC,CAAC;YACP,CAAC,CAAC,CAAC;QACP,CAAC;KAAA;;AApGL,8BAqGC;AAjGU,gBAAM,GAAG,IAAI,GAAG,EAAE,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,16 +1,16 @@
1
- export * from './module';
2
- export * from './service';
3
- export * from './controller';
4
- export * from './providers/auth.provider';
5
- export * from './providers/memory.provider';
6
- export * from './interfaces/emailpassword';
7
- export * from './interfaces/encrypt';
8
- export * from './interfaces/jwt.payload';
9
- export * from './interfaces/provider';
10
- export * from './interfaces/options';
11
- export * from './interfaces/login.request';
12
- export * from './strategies/local';
13
1
  export * from './classes/memory.user';
14
- export * from './classes/user';
2
+ export * from './constants';
3
+ export * from './encryptor';
15
4
  export * from './guard';
5
+ export * from './interfaces/auth.user';
6
+ export * from './interfaces/encrypt';
7
+ export * from './interfaces/options';
8
+ export * from './interfaces/provider';
9
+ export * from './module';
10
+ export * from './providers/auth.memory.user.provider';
11
+ export * from './providers/auth.provider';
12
+ export * from './providers/memory.user.provider';
13
+ export * from './service';
14
+ export * from './strategies/emailpassword';
15
+ export * from './strategies/jwt';
16
16
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,UAAU,CAAC;AACzB,cAAc,uCAAuC,CAAC;AACtD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kCAAkC,CAAC;AACjD,cAAc,WAAW,CAAC;AAC1B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,kBAAkB,CAAC"}
package/dist/index.js CHANGED
@@ -10,19 +10,19 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
10
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
11
  };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
- __exportStar(require("./module"), exports);
14
- __exportStar(require("./service"), exports);
15
- __exportStar(require("./controller"), exports);
16
- __exportStar(require("./providers/auth.provider"), exports);
17
- __exportStar(require("./providers/memory.provider"), exports);
18
- __exportStar(require("./interfaces/emailpassword"), exports);
19
- __exportStar(require("./interfaces/encrypt"), exports);
20
- __exportStar(require("./interfaces/jwt.payload"), exports);
21
- __exportStar(require("./interfaces/provider"), exports);
22
- __exportStar(require("./interfaces/options"), exports);
23
- __exportStar(require("./interfaces/login.request"), exports);
24
- __exportStar(require("./strategies/local"), exports);
25
13
  __exportStar(require("./classes/memory.user"), exports);
26
- __exportStar(require("./classes/user"), exports);
14
+ __exportStar(require("./constants"), exports);
15
+ __exportStar(require("./encryptor"), exports);
27
16
  __exportStar(require("./guard"), exports);
17
+ __exportStar(require("./interfaces/auth.user"), exports);
18
+ __exportStar(require("./interfaces/encrypt"), exports);
19
+ __exportStar(require("./interfaces/options"), exports);
20
+ __exportStar(require("./interfaces/provider"), exports);
21
+ __exportStar(require("./module"), exports);
22
+ __exportStar(require("./providers/auth.memory.user.provider"), exports);
23
+ __exportStar(require("./providers/auth.provider"), exports);
24
+ __exportStar(require("./providers/memory.user.provider"), exports);
25
+ __exportStar(require("./service"), exports);
26
+ __exportStar(require("./strategies/emailpassword"), exports);
27
+ __exportStar(require("./strategies/jwt"), exports);
28
28
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAyB;AACzB,4CAA0B;AAC1B,+CAA6B;AAC7B,4DAA0C;AAC1C,8DAA4C;AAC5C,6DAA2C;AAC3C,uDAAqC;AACrC,2DAAyC;AACzC,wDAAsC;AACtC,uDAAqC;AACrC,6DAA2C;AAC3C,qDAAmC;AACnC,wDAAsC;AACtC,iDAA+B;AAC/B,0CAAwB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,wDAAsC;AACtC,8CAA4B;AAC5B,8CAA4B;AAC5B,0CAAwB;AACxB,yDAAuC;AACvC,uDAAqC;AACrC,uDAAqC;AACrC,wDAAsC;AACtC,2CAAyB;AACzB,wEAAsD;AACtD,4DAA0C;AAC1C,mEAAiD;AACjD,4CAA0B;AAC1B,6DAA2C;AAC3C,mDAAiC"}
@@ -0,0 +1,6 @@
1
+ export interface IAuthUser {
2
+ authSerialize(): Record<string, unknown> & {
3
+ namespace?: string;
4
+ };
5
+ }
6
+ //# sourceMappingURL=auth.user.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.user.d.ts","sourceRoot":"","sources":["../../src/interfaces/auth.user.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,SAAS;IACtB,aAAa,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CACrE"}
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=jwt.payload.js.map
3
+ //# sourceMappingURL=auth.user.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.user.js","sourceRoot":"","sources":["../../src/interfaces/auth.user.ts"],"names":[],"mappings":""}
@@ -1,7 +1,7 @@
1
- export interface IEncrypt {
1
+ export interface IEncryptor {
2
2
  encrypt: (value: string) => string;
3
3
  }
4
- export interface IEncryptOptions {
4
+ export interface IEncryptorOptions {
5
5
  iv: string;
6
6
  key: string;
7
7
  }
@@ -1 +1 @@
1
- {"version":3,"file":"encrypt.d.ts","sourceRoot":"","sources":["../../src/interfaces/encrypt.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,QAAQ;IACrB,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;CACtC;AACD,MAAM,WAAW,eAAe;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;CACf"}
1
+ {"version":3,"file":"encrypt.d.ts","sourceRoot":"","sources":["../../src/interfaces/encrypt.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,UAAU;IACvB,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;CACtC;AACD,MAAM,WAAW,iBAAiB;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;CACf"}
@@ -1,7 +1,9 @@
1
1
  import { ModuleMetadata } from '@nestjs/common/interfaces';
2
- import { IEncryptOptions } from './encrypt';
2
+ import { StrategyOptions as JWTOptions } from 'passport-jwt';
3
+ import { IEncryptorOptions } from './encrypt';
3
4
  export interface IAuthModuleOptions {
4
- encrypt: IEncryptOptions;
5
+ encrypt?: IEncryptorOptions;
6
+ jwt?: JWTOptions;
5
7
  }
6
8
  export interface IAuthModuleAsyncOptions extends Pick<ModuleMetadata, 'imports'> {
7
9
  useFactory: (...args: any[]) => Promise<IAuthModuleOptions> | IAuthModuleOptions;
@@ -1 +1 @@
1
- {"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../src/interfaces/options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAE3D,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAE5C,MAAM,WAAW,kBAAkB;IAC/B,OAAO,EAAE,eAAe,CAAC;CAC5B;AAED,MAAM,WAAW,uBAAwB,SAAQ,IAAI,CAAC,cAAc,EAAE,SAAS,CAAC;IAC5E,UAAU,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,kBAAkB,CAAC,GAAG,kBAAkB,CAAC;IACjF,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC;CAClB"}
1
+ {"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../src/interfaces/options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,eAAe,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AAE7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAE9C,MAAM,WAAW,kBAAkB;IAC/B,OAAO,CAAC,EAAE,iBAAiB,CAAC;IAC5B,GAAG,CAAC,EAAE,UAAU,CAAC;CACpB;AAED,MAAM,WAAW,uBAAwB,SAAQ,IAAI,CAAC,cAAc,EAAE,SAAS,CAAC;IAC5E,UAAU,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,kBAAkB,CAAC,GAAG,kBAAkB,CAAC;IACjF,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC;CAClB"}
@@ -1,8 +1,8 @@
1
- export interface IUserProvider<U = any> {
2
- findOne: (data: any) => Promise<U | undefined>;
1
+ export interface IUserProvider<User = any> {
2
+ findOne: (data: Record<string, unknown>) => Promise<User | undefined>;
3
3
  }
4
- export interface IAuthProvider<U = any> {
5
- loadUser: (data: any) => (U | undefined) | Promise<U | undefined>;
4
+ export interface IAuthProvider<User = any> {
5
+ loadUser: (data: Record<string, unknown>) => (User | undefined) | Promise<User | undefined>;
6
6
  getName: () => string;
7
7
  }
8
8
  //# sourceMappingURL=provider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../src/interfaces/provider.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa,CAAC,CAAC,GAAG,GAAG;IAClC,OAAO,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC;CAClD;AAED,MAAM,WAAW,aAAa,CAAC,CAAC,GAAG,GAAG;IAClC,QAAQ,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,CAAC,CAAC,GAAG,SAAS,CAAC,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC;IAClE,OAAO,EAAE,MAAM,MAAM,CAAC;CACzB"}
1
+ {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../src/interfaces/provider.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa,CAAC,IAAI,GAAG,GAAG;IACrC,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,IAAI,GAAG,SAAS,CAAC,CAAC;CACzE;AAED,MAAM,WAAW,aAAa,CAAC,IAAI,GAAG,GAAG;IACrC,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,CAAC,IAAI,GAAG,SAAS,CAAC,GAAG,OAAO,CAAC,IAAI,GAAG,SAAS,CAAC,CAAC;IAC5F,OAAO,EAAE,MAAM,MAAM,CAAC;CACzB"}
package/dist/module.d.ts CHANGED
@@ -1,10 +1,20 @@
1
- import { DynamicModule, MiddlewareConsumer, NestModule } from '@nestjs/common';
1
+ import { DynamicModule, MiddlewareConsumer, NestModule, Provider } from '@nestjs/common';
2
+ import { Encryptor } from './encryptor';
2
3
  import { IAuthModuleAsyncOptions, IAuthModuleOptions } from './interfaces/options';
3
4
  import { AuthService } from './service';
5
+ import { EmailPasswordStrategy } from './strategies/emailpassword';
6
+ import { JwtStrategy } from './strategies/jwt';
4
7
  export declare class AuthModule implements NestModule {
5
8
  configure(consumer: MiddlewareConsumer): any;
6
- protected static createAuthService(opts: IAuthModuleOptions): AuthService;
7
- static register(options: IAuthModuleOptions): DynamicModule;
8
- static registerAsync(options: IAuthModuleAsyncOptions): DynamicModule;
9
+ protected static createOptionsProvider(options: IAuthModuleOptions): Provider<IAuthModuleOptions>;
10
+ protected static createAsyncOptionsProvider(options: IAuthModuleAsyncOptions): Provider<Promise<IAuthModuleOptions> | IAuthModuleOptions>;
11
+ protected static createAuthServiceProvider(): Provider<AuthService>;
12
+ protected static createEncryptorProvider(): Provider<Encryptor | undefined>;
13
+ protected static createLocalEmailPasswordStrategyProvider(): Provider<EmailPasswordStrategy>;
14
+ protected static createJWTStrategyProvider(): Provider<JwtStrategy | undefined>;
15
+ static createModule(optionsProvider: Provider): DynamicModule;
16
+ static forRoot(options: IAuthModuleOptions): DynamicModule;
17
+ static forRootAsync(options: IAuthModuleAsyncOptions): DynamicModule;
18
+ static registerAuthProviders(providers: Provider[]): DynamicModule;
9
19
  }
10
20
  //# sourceMappingURL=module.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAU,kBAAkB,EAAU,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAI/F,OAAO,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AACnF,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAIxC,qBAEa,UAAW,YAAW,UAAU;IACzC,SAAS,CAAC,QAAQ,EAAE,kBAAkB,GAAG,GAAG;IAM5C,SAAS,CAAC,MAAM,CAAC,iBAAiB,CAAC,IAAI,EAAE,kBAAkB,GAAG,WAAW;IAIzE,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAE,kBAAkB,GAAG,aAAa;IAkB3D,MAAM,CAAC,aAAa,CAAC,OAAO,EAAE,uBAAuB,GAAG,aAAa;CAkBxE"}
1
+ {"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAU,kBAAkB,EAAU,UAAU,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAIzG,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AACnF,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,qBAAqB,EAAE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