@smartsoft001/auth-domain 1.1.91 → 2.68.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 (50) hide show
  1. package/.eslintrc.json +26 -0
  2. package/README.md +161 -2
  3. package/jest.config.ts +26 -0
  4. package/package.json +3 -32
  5. package/project.json +44 -0
  6. package/src/index.ts +9 -0
  7. package/src/lib/entities/user.entity.ts +34 -0
  8. package/src/lib/feature-create-token/interfaces.ts +51 -0
  9. package/src/lib/feature-create-token/token-payload.provider.ts +17 -0
  10. package/src/lib/feature-create-token/token-user.provider.ts +14 -0
  11. package/src/lib/feature-create-token/token-validation.provider.ts +13 -0
  12. package/src/lib/feature-create-token/token.config.ts +8 -0
  13. package/src/lib/feature-create-token/token.factory.spec.ts +193 -0
  14. package/src/lib/feature-create-token/token.factory.ts +199 -0
  15. package/tsconfig.json +13 -0
  16. package/tsconfig.lib.json +10 -0
  17. package/tsconfig.spec.json +20 -0
  18. package/src/index.d.ts +0 -6
  19. package/src/index.js +0 -15
  20. package/src/index.js.map +0 -1
  21. package/src/lib/entities/index.js +0 -5
  22. package/src/lib/entities/index.js.map +0 -1
  23. package/src/lib/entities/user.entity.d.ts +0 -13
  24. package/src/lib/entities/user.entity.js +0 -47
  25. package/src/lib/entities/user.entity.js.map +0 -1
  26. package/src/lib/feature-create-token/index.js +0 -10
  27. package/src/lib/feature-create-token/index.js.map +0 -1
  28. package/src/lib/feature-create-token/interfaces.d.ts +0 -39
  29. package/src/lib/feature-create-token/interfaces.js +0 -3
  30. package/src/lib/feature-create-token/interfaces.js.map +0 -1
  31. package/src/lib/feature-create-token/token-payload.provider.d.ts +0 -11
  32. package/src/lib/feature-create-token/token-payload.provider.js +0 -8
  33. package/src/lib/feature-create-token/token-payload.provider.js.map +0 -1
  34. package/src/lib/feature-create-token/token-user.provider.d.ts +0 -7
  35. package/src/lib/feature-create-token/token-user.provider.js +0 -8
  36. package/src/lib/feature-create-token/token-user.provider.js.map +0 -1
  37. package/src/lib/feature-create-token/token-validation.provider.d.ts +0 -10
  38. package/src/lib/feature-create-token/token-validation.provider.js +0 -8
  39. package/src/lib/feature-create-token/token-validation.provider.js.map +0 -1
  40. package/src/lib/feature-create-token/token.config.d.ts +0 -5
  41. package/src/lib/feature-create-token/token.config.js +0 -14
  42. package/src/lib/feature-create-token/token.config.js.map +0 -1
  43. package/src/lib/feature-create-token/token.factory.d.ts +0 -39
  44. package/src/lib/feature-create-token/token.factory.js +0 -158
  45. package/src/lib/feature-create-token/token.factory.js.map +0 -1
  46. package/test-setup.js +0 -1
  47. package/test-setup.js.map +0 -1
  48. /package/src/lib/entities/{index.d.ts → index.ts} +0 -0
  49. /package/src/lib/feature-create-token/{index.d.ts → index.ts} +0 -0
  50. /package/{test-setup.d.ts → test-setup.ts} +0 -0
@@ -0,0 +1,199 @@
1
+ import { Injectable } from '@nestjs/common';
2
+ import { JwtService } from '@nestjs/jwt';
3
+ import { InjectRepository } from '@nestjs/typeorm';
4
+ import { DomainValidationError, IFactory } from '@smartsoft001/domain-core';
5
+ import { FbService } from '@smartsoft001/fb';
6
+ import { GoogleService } from '@smartsoft001/google';
7
+ import { PasswordService } from '@smartsoft001/utils';
8
+ import { Request } from 'express';
9
+ import { Guid } from 'guid-typescript';
10
+ import { Repository } from 'typeorm';
11
+
12
+ import { User } from '../entities';
13
+ import { IAuthToken, IAuthTokenRequest } from './interfaces';
14
+ import { ITokenPayloadProvider } from './token-payload.provider';
15
+ import { ITokenUserProvider } from './token-user.provider';
16
+ import { ITokenValidationProvider } from './token-validation.provider';
17
+ import { TokenConfig } from './token.config';
18
+
19
+ @Injectable()
20
+ export class TokenFactory
21
+ implements
22
+ IFactory<
23
+ IAuthToken,
24
+ {
25
+ httpReq?: Request;
26
+ request: IAuthTokenRequest;
27
+ payloadProvider?: ITokenPayloadProvider;
28
+ validationProvider?: ITokenValidationProvider;
29
+ userProvider?: ITokenUserProvider;
30
+ }
31
+ >
32
+ {
33
+ private _invalidUsernameOrPasswordMessage = 'Invalid username or password';
34
+
35
+ constructor(
36
+ private config: TokenConfig,
37
+ @InjectRepository(User) private repository: Repository<User>,
38
+ private jwtService: JwtService,
39
+ private fbService: FbService,
40
+ private googleService: GoogleService,
41
+ ) {}
42
+
43
+ static getQuery(
44
+ config: IAuthTokenRequest,
45
+ customProvider = false,
46
+ ): Partial<User> {
47
+ switch (config.grant_type) {
48
+ case 'fb':
49
+ return { facebookUserId: config.fb_user_id };
50
+ case 'google':
51
+ return { googleUserId: config.google_user_id };
52
+ case 'password':
53
+ return { username: config.username };
54
+ case 'refresh_token':
55
+ return { authRefreshToken: config.refresh_token };
56
+ default:
57
+ if (!customProvider) {
58
+ throw new DomainValidationError('Invalid grand type');
59
+ }
60
+ return null;
61
+ }
62
+ }
63
+
64
+ static checkDisabled(user: User) {
65
+ if (user.disabled) throw new DomainValidationError('user disabled');
66
+ }
67
+
68
+ async create(options: {
69
+ httpReq?: Request;
70
+ request: IAuthTokenRequest;
71
+ payloadProvider?: ITokenPayloadProvider;
72
+ validationProvider?: ITokenValidationProvider;
73
+ userProvider?: ITokenUserProvider;
74
+ }): Promise<IAuthToken> {
75
+ if (options.request.grant_type === 'fb') {
76
+ options.request.fb_user_id = await this.fbService.getUserId(
77
+ options.request.fb_token,
78
+ );
79
+ }
80
+
81
+ if (options.request.grant_type === 'google') {
82
+ options.request.google_user_id = await this.googleService.getUserId(
83
+ options.request.google_token,
84
+ );
85
+ }
86
+
87
+ this.valid(options.request);
88
+
89
+ const query = TokenFactory.getQuery(
90
+ options.request,
91
+ !!options.userProvider,
92
+ );
93
+
94
+ const user = options.userProvider
95
+ ? await options.userProvider.get(query, options.request, options.httpReq)
96
+ : await this.repository.findOne(query as any);
97
+
98
+ if (!options.validationProvider || !options.validationProvider.replace) {
99
+ this.checkUser(options.request, user);
100
+ TokenFactory.checkDisabled(user);
101
+ await this.checkPassword(options.request, user);
102
+ }
103
+
104
+ if (options.validationProvider) {
105
+ await options.validationProvider.check({
106
+ request: options.request,
107
+ user,
108
+ });
109
+ }
110
+
111
+ const refreshToken = Guid.raw();
112
+ await this.repository.update(
113
+ {
114
+ ...query,
115
+ disabled: { $ne: true },
116
+ } as any,
117
+ {
118
+ lastLoginDate: new Date(),
119
+ authRefreshToken: refreshToken,
120
+ },
121
+ );
122
+
123
+ const payload = {
124
+ permissions: user.permissions,
125
+ scope: options.request.scope,
126
+ };
127
+
128
+ if (options.payloadProvider) {
129
+ await options.payloadProvider.change(payload, {
130
+ user,
131
+ request: options.request,
132
+ httpReq: options.httpReq,
133
+ });
134
+ }
135
+
136
+ return {
137
+ expired_in: this.config.expiredIn,
138
+ token_type: 'bearer',
139
+ access_token: this.jwtService.sign(payload, {
140
+ expiresIn: this.config.expiredIn,
141
+ subject: user.username,
142
+ }),
143
+ refresh_token: refreshToken,
144
+ username: user.username,
145
+ };
146
+ }
147
+
148
+ private checkUser(config: IAuthTokenRequest, user: User): void {
149
+ if (!user)
150
+ throw new DomainValidationError(
151
+ config.grant_type === 'password'
152
+ ? this._invalidUsernameOrPasswordMessage
153
+ : 'Invalid token',
154
+ );
155
+ }
156
+
157
+ private async checkPassword(
158
+ config: IAuthTokenRequest,
159
+ user: User,
160
+ ): Promise<void> {
161
+ if (
162
+ config.grant_type === 'password' &&
163
+ !(await PasswordService.compare(config.password, user.password))
164
+ )
165
+ throw new DomainValidationError(this._invalidUsernameOrPasswordMessage);
166
+ }
167
+
168
+ private valid(req: NonNullable<IAuthTokenRequest>): void {
169
+ if (!req) throw new DomainValidationError('config is empty');
170
+ if (!req.grant_type) throw new DomainValidationError('grant_type is empty');
171
+
172
+ // password
173
+ if (req.grant_type === 'password') {
174
+ if (!req.username) throw new DomainValidationError('username is empty');
175
+ if (!req.password) throw new DomainValidationError('password is empty');
176
+ if (!req.client_id) throw new DomainValidationError('client_id is empty');
177
+ if (!this.config.clients.some((c) => c === req.client_id))
178
+ throw new DomainValidationError('client_id is incorrect');
179
+
180
+ // refres token
181
+ } else if (req.grant_type === 'refresh_token') {
182
+ if (!req.refresh_token)
183
+ throw new DomainValidationError('refresh_token is empty');
184
+
185
+ // fb token
186
+ } else if (req.grant_type === 'fb') {
187
+ if (!req.fb_token) throw new DomainValidationError('fb_token is empty');
188
+
189
+ if (!req.fb_user_id)
190
+ throw new DomainValidationError('fb_user_id is empty');
191
+ } else if (req.grant_type === 'google') {
192
+ if (!req.google_token)
193
+ throw new DomainValidationError('google_token is empty');
194
+
195
+ if (!req.google_user_id)
196
+ throw new DomainValidationError('google_user_id is empty');
197
+ }
198
+ }
199
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,13 @@
1
+ {
2
+ "extends": "../../../tsconfig.base.json",
3
+ "files": [],
4
+ "include": [],
5
+ "references": [
6
+ {
7
+ "path": "./tsconfig.lib.json"
8
+ },
9
+ {
10
+ "path": "./tsconfig.spec.json"
11
+ }
12
+ ]
13
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "../../../dist/out-tsc",
5
+ "declaration": true,
6
+ "types": ["node"]
7
+ },
8
+ "exclude": ["**/*.spec.ts", "**/*.test.ts", "jest.config.ts"],
9
+ "include": ["**/*.ts"]
10
+ }
@@ -0,0 +1,20 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "../../../dist/out-tsc",
5
+ "module": "commonjs",
6
+ "types": ["jest", "node"]
7
+ },
8
+ "include": [
9
+ "**/*.spec.ts",
10
+ "**/*.test.ts",
11
+ "**/*.spec.tsx",
12
+ "**/*.test.tsx",
13
+ "**/*.spec.js",
14
+ "**/*.test.js",
15
+ "**/*.spec.jsx",
16
+ "**/*.test.jsx",
17
+ "**/*.d.ts",
18
+ "jest.config.ts"
19
+ ]
20
+ }
package/src/index.d.ts DELETED
@@ -1,6 +0,0 @@
1
- import { TokenFactory } from "./lib/feature-create-token/token.factory";
2
- import { User } from "./lib/entities/user.entity";
3
- export * from './lib/entities';
4
- export * from './lib/feature-create-token';
5
- export declare const DOMAIN_SERVICES: (typeof TokenFactory)[];
6
- export declare const ENTITIES: (typeof User)[];
package/src/index.js DELETED
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ENTITIES = exports.DOMAIN_SERVICES = void 0;
4
- const tslib_1 = require("tslib");
5
- const token_factory_1 = require("./lib/feature-create-token/token.factory");
6
- const user_entity_1 = require("./lib/entities/user.entity");
7
- tslib_1.__exportStar(require("./lib/entities"), exports);
8
- tslib_1.__exportStar(require("./lib/feature-create-token"), exports);
9
- exports.DOMAIN_SERVICES = [
10
- token_factory_1.TokenFactory
11
- ];
12
- exports.ENTITIES = [
13
- user_entity_1.User
14
- ];
15
- //# sourceMappingURL=index.js.map
package/src/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../libs/auth/domain/src/index.ts"],"names":[],"mappings":";;;;AAAA,4EAAsE;AACtE,4DAAgD;AAEhD,yDAA+B;AAC/B,qEAA2C;AAE9B,QAAA,eAAe,GAAG;IAC3B,4BAAY;CACf,CAAC;AAEW,QAAA,QAAQ,GAAG;IACpB,kBAAI;CACP,CAAC"}
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./user.entity"), exports);
5
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../libs/auth/domain/src/lib/entities/index.ts"],"names":[],"mappings":";;;AAAA,wDAA8B"}
@@ -1,13 +0,0 @@
1
- import { IEntity } from "@smartsoft001/domain-core";
2
- import { IUser, IUserCredentials } from "@smartsoft001/users";
3
- export declare class User implements IEntity<string>, IUser, IUserCredentials {
4
- id: string;
5
- permissions: Array<string>;
6
- username: string;
7
- password: string;
8
- disabled: boolean;
9
- lastLoginDate: Date;
10
- authRefreshToken: string;
11
- facebookUserId?: string;
12
- googleUserId?: string;
13
- }
@@ -1,47 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.User = void 0;
4
- const tslib_1 = require("tslib");
5
- const typeorm_1 = require("typeorm");
6
- let User = exports.User = class User {
7
- };
8
- tslib_1.__decorate([
9
- (0, typeorm_1.PrimaryGeneratedColumn)(),
10
- tslib_1.__metadata("design:type", String)
11
- ], User.prototype, "id", void 0);
12
- tslib_1.__decorate([
13
- (0, typeorm_1.Column)("permissions"),
14
- tslib_1.__metadata("design:type", Array)
15
- ], User.prototype, "permissions", void 0);
16
- tslib_1.__decorate([
17
- (0, typeorm_1.Column)("username"),
18
- tslib_1.__metadata("design:type", String)
19
- ], User.prototype, "username", void 0);
20
- tslib_1.__decorate([
21
- (0, typeorm_1.Column)("password"),
22
- tslib_1.__metadata("design:type", String)
23
- ], User.prototype, "password", void 0);
24
- tslib_1.__decorate([
25
- (0, typeorm_1.Column)("disabled"),
26
- tslib_1.__metadata("design:type", Boolean)
27
- ], User.prototype, "disabled", void 0);
28
- tslib_1.__decorate([
29
- (0, typeorm_1.Column)("lastLoginDate"),
30
- tslib_1.__metadata("design:type", Date)
31
- ], User.prototype, "lastLoginDate", void 0);
32
- tslib_1.__decorate([
33
- (0, typeorm_1.Column)("authRefreshToken"),
34
- tslib_1.__metadata("design:type", String)
35
- ], User.prototype, "authRefreshToken", void 0);
36
- tslib_1.__decorate([
37
- (0, typeorm_1.Column)("facebookUserId"),
38
- tslib_1.__metadata("design:type", String)
39
- ], User.prototype, "facebookUserId", void 0);
40
- tslib_1.__decorate([
41
- (0, typeorm_1.Column)("googleUserId"),
42
- tslib_1.__metadata("design:type", String)
43
- ], User.prototype, "googleUserId", void 0);
44
- exports.User = User = tslib_1.__decorate([
45
- (0, typeorm_1.Entity)('users')
46
- ], User);
47
- //# sourceMappingURL=user.entity.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"user.entity.js","sourceRoot":"","sources":["../../../../../../../libs/auth/domain/src/lib/entities/user.entity.ts"],"names":[],"mappings":";;;;AAAA,qCAA+D;AAMxD,IAAM,IAAI,kBAAV,MAAM,IAAI;CA6BhB,CAAA;AA1BG;IADC,IAAA,gCAAsB,GAAE;;gCACd;AAGX;IADC,IAAA,gBAAM,EAAC,aAAa,CAAC;sCACT,KAAK;yCAAS;AAG3B;IADC,IAAA,gBAAM,EAAC,UAAU,CAAC;;sCACF;AAGjB;IADC,IAAA,gBAAM,EAAC,UAAU,CAAC;;sCACF;AAGjB;IADC,IAAA,gBAAM,EAAC,UAAU,CAAC;;sCACD;AAGlB;IADC,IAAA,gBAAM,EAAC,eAAe,CAAC;sCACT,IAAI;2CAAC;AAGpB;IADC,IAAA,gBAAM,EAAC,kBAAkB,CAAC;;8CACF;AAGzB;IADC,IAAA,gBAAM,EAAC,gBAAgB,CAAC;;4CACD;AAGxB;IADC,IAAA,gBAAM,EAAC,cAAc,CAAC;;0CACD;eA3Bb,IAAI;IADhB,IAAA,gBAAM,EAAC,OAAO,CAAC;GACH,IAAI,CA6BhB"}
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./interfaces"), exports);
5
- tslib_1.__exportStar(require("./token.factory"), exports);
6
- tslib_1.__exportStar(require("./token.config"), exports);
7
- tslib_1.__exportStar(require("./token-payload.provider"), exports);
8
- tslib_1.__exportStar(require("./token-validation.provider"), exports);
9
- tslib_1.__exportStar(require("./token-user.provider"), exports);
10
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../libs/auth/domain/src/lib/feature-create-token/index.ts"],"names":[],"mappings":";;;AAAA,uDAA6B;AAC7B,0DAAgC;AAChC,yDAA+B;AAC/B,mEAAyC;AACzC,sEAA4C;AAC5C,gEAAsC"}
@@ -1,39 +0,0 @@
1
- import { IUserCredentials } from "@smartsoft001/users";
2
- export type IAuthTokenRequest = IAuthTokenRequestPassword | IAuthTokenRequestRefreshToken | IAuthTokenRequestCustom | IAuthTokenRequestFb | IAuthTokenRequestGoogle;
3
- export interface IAuthTokenRequestFb extends IUserCredentials {
4
- grant_type: "fb";
5
- fb_token: string;
6
- fb_user_id?: string;
7
- scope?: string;
8
- client_id: string;
9
- }
10
- export interface IAuthTokenRequestGoogle extends IUserCredentials {
11
- grant_type: "google";
12
- google_token: string;
13
- google_user_id?: string;
14
- scope?: string;
15
- client_id: string;
16
- }
17
- export interface IAuthTokenRequestPassword extends IUserCredentials {
18
- grant_type: "password";
19
- username: string;
20
- password: string;
21
- scope?: string;
22
- client_id: string;
23
- }
24
- export interface IAuthTokenRequestRefreshToken {
25
- grant_type: "refresh_token";
26
- refresh_token: string;
27
- scope?: string;
28
- }
29
- export interface IAuthToken {
30
- access_token: string;
31
- refresh_token: string;
32
- expired_in: number;
33
- token_type: 'bearer';
34
- username?: string;
35
- }
36
- export interface IAuthTokenRequestCustom {
37
- grant_type: string;
38
- [key: string]: string;
39
- }
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=interfaces.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../../../../../libs/auth/domain/src/lib/feature-create-token/interfaces.ts"],"names":[],"mappings":""}
@@ -1,11 +0,0 @@
1
- import { Request } from "express";
2
- import { IAuthTokenRequest } from "./interfaces";
3
- import { User } from "../entities/user.entity";
4
- export declare const AUTH_TOKEN_PAYLOAD_PROVIDER = "AUTH_TOKEN_PAYLOAD_PROVIDER";
5
- export declare abstract class ITokenPayloadProvider {
6
- abstract change(basePayload: any, data: {
7
- request?: IAuthTokenRequest;
8
- user?: User;
9
- httpReq?: Request;
10
- }): Promise<void>;
11
- }
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ITokenPayloadProvider = exports.AUTH_TOKEN_PAYLOAD_PROVIDER = void 0;
4
- exports.AUTH_TOKEN_PAYLOAD_PROVIDER = "AUTH_TOKEN_PAYLOAD_PROVIDER";
5
- class ITokenPayloadProvider {
6
- }
7
- exports.ITokenPayloadProvider = ITokenPayloadProvider;
8
- //# sourceMappingURL=token-payload.provider.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"token-payload.provider.js","sourceRoot":"","sources":["../../../../../../../libs/auth/domain/src/lib/feature-create-token/token-payload.provider.ts"],"names":[],"mappings":";;;AAKa,QAAA,2BAA2B,GAAG,6BAA6B,CAAC;AAEzE,MAAsB,qBAAqB;CAS1C;AATD,sDASC"}
@@ -1,7 +0,0 @@
1
- import { Request } from "express";
2
- import { User } from "../entities/user.entity";
3
- import { IAuthTokenRequest } from "./interfaces";
4
- export declare const AUTH_TOKEN_USER_PROVIDER = "AUTH_TOKEN_USER_PROVIDER";
5
- export declare abstract class ITokenUserProvider {
6
- abstract get(baseQuery: Partial<User>, request: IAuthTokenRequest, httpReq?: Request): Promise<User>;
7
- }
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ITokenUserProvider = exports.AUTH_TOKEN_USER_PROVIDER = void 0;
4
- exports.AUTH_TOKEN_USER_PROVIDER = "AUTH_TOKEN_USER_PROVIDER";
5
- class ITokenUserProvider {
6
- }
7
- exports.ITokenUserProvider = ITokenUserProvider;
8
- //# sourceMappingURL=token-user.provider.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"token-user.provider.js","sourceRoot":"","sources":["../../../../../../../libs/auth/domain/src/lib/feature-create-token/token-user.provider.ts"],"names":[],"mappings":";;;AAKa,QAAA,wBAAwB,GAAG,0BAA0B,CAAC;AAEnE,MAAsB,kBAAkB;CAEvC;AAFD,gDAEC"}
@@ -1,10 +0,0 @@
1
- import { IAuthTokenRequest } from "./interfaces";
2
- import { User } from "../entities/user.entity";
3
- export declare const AUTH_TOKEN_VALIDATION_PROVIDER = "AUTH_TOKEN_VALIDATION_PROVIDER";
4
- export declare abstract class ITokenValidationProvider {
5
- abstract replace?: boolean;
6
- abstract check(data: {
7
- request?: IAuthTokenRequest;
8
- user?: User;
9
- }): Promise<void>;
10
- }
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ITokenValidationProvider = exports.AUTH_TOKEN_VALIDATION_PROVIDER = void 0;
4
- exports.AUTH_TOKEN_VALIDATION_PROVIDER = "AUTH_TOKEN_VALIDATION_PROVIDER";
5
- class ITokenValidationProvider {
6
- }
7
- exports.ITokenValidationProvider = ITokenValidationProvider;
8
- //# sourceMappingURL=token-validation.provider.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"token-validation.provider.js","sourceRoot":"","sources":["../../../../../../../libs/auth/domain/src/lib/feature-create-token/token-validation.provider.ts"],"names":[],"mappings":";;;AAGa,QAAA,8BAA8B,GAAG,gCAAgC,CAAC;AAE/E,MAAsB,wBAAwB;CAS7C;AATD,4DASC"}
@@ -1,5 +0,0 @@
1
- export declare class TokenConfig {
2
- expiredIn: number;
3
- clients: Array<string>;
4
- secretOrPrivateKey: string;
5
- }
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TokenConfig = void 0;
4
- const tslib_1 = require("tslib");
5
- const common_1 = require("@nestjs/common");
6
- let TokenConfig = exports.TokenConfig = class TokenConfig {
7
- constructor() {
8
- this.clients = [];
9
- }
10
- };
11
- exports.TokenConfig = TokenConfig = tslib_1.__decorate([
12
- (0, common_1.Injectable)()
13
- ], TokenConfig);
14
- //# sourceMappingURL=token.config.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"token.config.js","sourceRoot":"","sources":["../../../../../../../libs/auth/domain/src/lib/feature-create-token/token.config.ts"],"names":[],"mappings":";;;;AAAA,2CAA0C;AAGnC,IAAM,WAAW,yBAAjB,MAAM,WAAW;IAAjB;QAEH,YAAO,GAAkB,EAAE,CAAC;IAEhC,CAAC;CAAA,CAAA;sBAJY,WAAW;IADvB,IAAA,mBAAU,GAAE;GACA,WAAW,CAIvB"}
@@ -1,39 +0,0 @@
1
- import { Repository } from "typeorm";
2
- import { JwtService } from "@nestjs/jwt";
3
- import { Request } from "express";
4
- import { IFactory } from "@smartsoft001/domain-core";
5
- import { FbService } from "@smartsoft001/fb";
6
- import { GoogleService } from "@smartsoft001/google";
7
- import { User } from "../entities/user.entity";
8
- import { TokenConfig } from "./token.config";
9
- import { IAuthToken, IAuthTokenRequest } from "./interfaces";
10
- import { ITokenPayloadProvider } from "./token-payload.provider";
11
- import { ITokenValidationProvider } from "./token-validation.provider";
12
- import { ITokenUserProvider } from "./token-user.provider";
13
- export declare class TokenFactory implements IFactory<IAuthToken, {
14
- httpReq?: Request;
15
- request: IAuthTokenRequest;
16
- payloadProvider?: ITokenPayloadProvider;
17
- validationProvider?: ITokenValidationProvider;
18
- userProvider?: ITokenUserProvider;
19
- }> {
20
- private config;
21
- private repository;
22
- private jwtService;
23
- private fbService;
24
- private googleService;
25
- private _invalidUsernameOrPasswordMessage;
26
- constructor(config: TokenConfig, repository: Repository<User>, jwtService: JwtService, fbService: FbService, googleService: GoogleService);
27
- static getQuery(config: IAuthTokenRequest, customProvider?: boolean): Partial<User>;
28
- static checkDisabled(user: User): void;
29
- create(options: {
30
- httpReq?: Request;
31
- request: IAuthTokenRequest;
32
- payloadProvider?: ITokenPayloadProvider;
33
- validationProvider?: ITokenValidationProvider;
34
- userProvider?: ITokenUserProvider;
35
- }): Promise<IAuthToken>;
36
- private checkUser;
37
- private checkPassword;
38
- private valid;
39
- }