@tomei/sso 0.15.10 → 0.16.2

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 (54) hide show
  1. package/.commitlintrc.json +22 -22
  2. package/.eslintrc +16 -16
  3. package/.eslintrc.js +35 -35
  4. package/.husky/commit-msg +15 -15
  5. package/.husky/pre-commit +7 -7
  6. package/.prettierrc +4 -4
  7. package/Jenkinsfile +57 -57
  8. package/README.md +23 -23
  9. package/__tests__/unit/components/login-user/login-user.spec.ts +742 -742
  10. package/__tests__/unit/components/password-hash/password-hash.service.spec.ts +31 -31
  11. package/__tests__/unit/redis-client/redis.service.spec.ts +23 -23
  12. package/__tests__/unit/session/session.service.spec.ts +47 -47
  13. package/__tests__/unit/system-privilege/system-privilage.spec.ts +91 -91
  14. package/create-sso-user.sql +39 -39
  15. package/dist/__tests__/unit/components/login-user/login-user.spec.js +15 -15
  16. package/dist/__tests__/unit/components/login-user/login-user.spec.js.map +1 -1
  17. package/dist/src/components/building/building.d.ts +10 -3
  18. package/dist/src/components/building/building.js +12 -1
  19. package/dist/src/components/building/building.js.map +1 -1
  20. package/dist/src/components/login-user/interfaces/user-info.interface.d.ts +19 -1
  21. package/dist/src/components/login-user/login-user.d.ts +54 -9
  22. package/dist/src/components/login-user/login-user.js +177 -29
  23. package/dist/src/components/login-user/login-user.js.map +1 -1
  24. package/dist/src/components/staff/staff.d.ts +1 -1
  25. package/dist/src/components/staff/staff.js +1 -1
  26. package/dist/src/components/staff/staff.js.map +1 -1
  27. package/dist/src/enum/index.d.ts +1 -0
  28. package/dist/src/enum/index.js +18 -0
  29. package/dist/src/enum/index.js.map +1 -0
  30. package/dist/src/enum/yn.enum.d.ts +4 -0
  31. package/dist/src/enum/yn.enum.js +9 -0
  32. package/dist/src/enum/yn.enum.js.map +1 -0
  33. package/dist/src/models/user.entity.d.ts +16 -6
  34. package/dist/src/models/user.entity.js +85 -25
  35. package/dist/src/models/user.entity.js.map +1 -1
  36. package/dist/tsconfig.tsbuildinfo +1 -1
  37. package/jest.config.js +13 -13
  38. package/migrations/01-alter-system-privilege-table.js +13 -13
  39. package/migrations/02-alter-user-group-table.js +78 -78
  40. package/migrations/03-alter-user-system-privilege-table.js +38 -38
  41. package/migrations/20240314080603-create-user-table.js +108 -0
  42. package/migrations/{04-create-user-user-group-table.js → 20240314080604-create-user-user-group-table.js} +55 -55
  43. package/migrations/{05-create-login-history-table.js → 20240314080605-create-login-history-table.js} +49 -49
  44. package/package.json +80 -79
  45. package/sampledotenv +7 -7
  46. package/src/components/building/building.ts +18 -3
  47. package/src/components/login-user/interfaces/user-info.interface.ts +29 -9
  48. package/src/components/login-user/login-user.ts +749 -557
  49. package/src/components/staff/staff.ts +4 -2
  50. package/src/enum/index.ts +1 -0
  51. package/src/enum/yn.enum.ts +4 -0
  52. package/src/models/user.entity.ts +160 -110
  53. package/tsconfig.build.json +5 -5
  54. package/tsconfig.json +23 -23
package/package.json CHANGED
@@ -1,79 +1,80 @@
1
- {
2
- "name": "@tomei/sso",
3
- "version": "0.15.10",
4
- "description": "Tomei SSO Package",
5
- "main": "dist/index.js",
6
- "scripts": {
7
- "start:dev": "tsc -w",
8
- "build": "tsc",
9
- "prepare": "husky install",
10
- "format": "prettier --write \"src/**/*.ts\"",
11
- "lint": "npx eslint . --fix",
12
- "test": "jest --forceExit --detectOpenHandles"
13
- },
14
- "repository": {
15
- "type": "git",
16
- "url": "git+ssh://git@gitlab.com/tomei-package/sso.git"
17
- },
18
- "keywords": [
19
- "tomei",
20
- "sso"
21
- ],
22
- "author": "Tomei",
23
- "license": "ISC",
24
- "bugs": {
25
- "url": "https://gitlab.com/tomei-package/sso/issues"
26
- },
27
- "homepage": "https://gitlab.com/tomei-package/sso#readme",
28
- "devDependencies": {
29
- "@commitlint/cli": "^17.6.3",
30
- "@commitlint/config-conventional": "^17.6.3",
31
- "@tsconfig/node18": "^2.0.1",
32
- "@types/bcrypt": "^5.0.0",
33
- "@types/jest": "^29.5.2",
34
- "@types/node": "^18.17.5",
35
- "@types/redis": "^4.0.11",
36
- "@types/validator": "^13.11.1",
37
- "@typescript-eslint/eslint-plugin": "^5.33.0",
38
- "dotenv": "^16.1.4",
39
- "eslint": "^8.40.0",
40
- "eslint-config-prettier": "^8.5.0",
41
- "eslint-plugin-prettier": "^4.2.1",
42
- "husky": "^8.0.3",
43
- "jest": "^29.5.0",
44
- "jest-mock-extended": "^3.0.4",
45
- "lint-staged": "^13.2.2",
46
- "prettier": "^2.7.1",
47
- "prisma": "^4.14.0",
48
- "redis-mock": "^0.56.3",
49
- "ts-jest": "^29.1.0",
50
- "ts-node": "^10.9.1",
51
- "tsc-watch": "^5.0.3",
52
- "tsconfig-paths": "^4.0.0",
53
- "tslint": "^6.1.3",
54
- "typescript": "^4.7.4"
55
- },
56
- "publishConfig": {
57
- "access": "public"
58
- },
59
- "peerDependencies": {
60
- "@tomei/config": "^0.3.9",
61
- "@tomei/general": "^0.10.4",
62
- "@tomei/mailer": "^0.5.11",
63
- "@types/jest": "^29.5.2",
64
- "argon2": "^0.30.3",
65
- "cls-hooked": "^4.2.2",
66
- "cuid": "^3.0.0",
67
- "nodemailer": "^6.9.3",
68
- "redis": "^4.6.7",
69
- "reflect-metadata": "^0.1.13",
70
- "sequelize": "^6.32.1",
71
- "sequelize-typescript": "^2.1.5"
72
- },
73
- "lint-staged": {
74
- "*/**/*.{js,ts,tsx}": [
75
- "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
76
- "eslint \"{src,apps,libs,test}/**/*.ts\" --fix"
77
- ]
78
- }
79
- }
1
+ {
2
+ "name": "@tomei/sso",
3
+ "version": "0.16.2",
4
+ "description": "Tomei SSO Package",
5
+ "main": "dist/index.js",
6
+ "scripts": {
7
+ "start:dev": "tsc -w",
8
+ "build": "tsc",
9
+ "prepare": "husky install",
10
+ "format": "prettier --write \"src/**/*.ts\"",
11
+ "lint": "npx eslint . --fix",
12
+ "test": "jest --forceExit --detectOpenHandles"
13
+ },
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+ssh://git@gitlab.com/tomei-package/sso.git"
17
+ },
18
+ "keywords": [
19
+ "tomei",
20
+ "sso"
21
+ ],
22
+ "author": "Tomei",
23
+ "license": "ISC",
24
+ "bugs": {
25
+ "url": "https://gitlab.com/tomei-package/sso/issues"
26
+ },
27
+ "homepage": "https://gitlab.com/tomei-package/sso#readme",
28
+ "devDependencies": {
29
+ "@commitlint/cli": "^17.6.3",
30
+ "@commitlint/config-conventional": "^17.6.3",
31
+ "@tsconfig/node18": "^2.0.1",
32
+ "@types/bcrypt": "^5.0.0",
33
+ "@types/jest": "^29.5.2",
34
+ "@types/node": "^18.17.5",
35
+ "@types/redis": "^4.0.11",
36
+ "@types/validator": "^13.11.1",
37
+ "@typescript-eslint/eslint-plugin": "^5.33.0",
38
+ "dotenv": "^16.1.4",
39
+ "eslint": "^8.40.0",
40
+ "eslint-config-prettier": "^8.5.0",
41
+ "eslint-plugin-prettier": "^4.2.1",
42
+ "husky": "^8.0.3",
43
+ "jest": "^29.5.0",
44
+ "jest-mock-extended": "^3.0.4",
45
+ "lint-staged": "^13.2.2",
46
+ "prettier": "^2.7.1",
47
+ "prisma": "^4.14.0",
48
+ "redis-mock": "^0.56.3",
49
+ "sequelize-cli": "^6.6.2",
50
+ "ts-jest": "^29.1.0",
51
+ "ts-node": "^10.9.1",
52
+ "tsc-watch": "^5.0.3",
53
+ "tsconfig-paths": "^4.0.0",
54
+ "tslint": "^6.1.3",
55
+ "typescript": "^4.7.4"
56
+ },
57
+ "publishConfig": {
58
+ "access": "public"
59
+ },
60
+ "peerDependencies": {
61
+ "@tomei/config": "^0.3.9",
62
+ "@tomei/general": "^0.10.6",
63
+ "@tomei/mailer": "^0.5.11",
64
+ "@types/jest": "^29.5.2",
65
+ "argon2": "^0.30.3",
66
+ "cls-hooked": "^4.2.2",
67
+ "cuid": "^3.0.0",
68
+ "nodemailer": "^6.9.3",
69
+ "redis": "^4.6.7",
70
+ "reflect-metadata": "^0.1.13",
71
+ "sequelize": "^6.32.1",
72
+ "sequelize-typescript": "^2.1.5"
73
+ },
74
+ "lint-staged": {
75
+ "*/**/*.{js,ts,tsx}": [
76
+ "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
77
+ "eslint \"{src,apps,libs,test}/**/*.ts\" --fix"
78
+ ]
79
+ }
80
+ }
package/sampledotenv CHANGED
@@ -1,8 +1,8 @@
1
- DATABASE_URL=
2
- SHADOW_DATABASE_URL=
3
- REDIS_URL=
4
- REDIS_PASSWORD=
5
- SMTP_HOST=
6
- SMTP_PORT=
7
- EMAIL_SENDER=
1
+ DATABASE_URL=
2
+ SHADOW_DATABASE_URL=
3
+ REDIS_URL=
4
+ REDIS_PASSWORD=
5
+ SMTP_HOST=
6
+ SMTP_PORT=
7
+ EMAIL_SENDER=
8
8
  EMAIL_PASSWORD=
@@ -1,14 +1,19 @@
1
1
  import { BuildingTypeRepository } from '../building-type/building-type.repository';
2
2
  import { BuildingRepository } from './building.repository';
3
- import { LoginUser } from '../../..';
3
+ import { LoginUser } from '../login-user/login-user';
4
4
  import { ApplicationConfig } from '@tomei/config';
5
5
  import { Op } from 'sequelize';
6
6
  import BuildingType from '../../models/building-type.entity';
7
7
  import Country from '../../models/country.entity';
8
+ import { ObjectBase } from '@tomei/general';
8
9
 
9
- export class Building {
10
+ export class Building extends ObjectBase {
10
11
  // implement all attributes from sso_buildings table
11
- id: number;
12
+ ObjectId: string;
13
+ ObjectName: string;
14
+ ObjectType = 'Building';
15
+ TableName = 'sso_buildings';
16
+ private _id: number;
12
17
  name: string;
13
18
  code: string;
14
19
  building_type_id: number;
@@ -39,7 +44,17 @@ export class Building {
39
44
  private static _Repo = new BuildingRepository();
40
45
  private _RepoBuildingType = new BuildingTypeRepository();
41
46
 
47
+ set id(id: number) {
48
+ this._id = id;
49
+ this.ObjectId = id.toString();
50
+ }
51
+
52
+ get id() {
53
+ return this._id;
54
+ }
55
+
42
56
  private constructor(buildingInfo) {
57
+ super();
43
58
  if (buildingInfo) {
44
59
  this.id = buildingInfo.id;
45
60
  this.name = buildingInfo.Name;
@@ -1,9 +1,29 @@
1
- export interface IUserInfo {
2
- FullName: string;
3
- IDNo: string;
4
- Email: string;
5
- ContactNo: string;
6
- ObjectId: string;
7
- Password: string;
8
- staffs?: any;
9
- }
1
+ import { YN } from '../../../enum/yn.enum';
2
+
3
+ export interface IUserInfo {
4
+ FullName: string;
5
+ IDNo: string;
6
+ Email: string;
7
+ ContactNo: string;
8
+ UserId: number;
9
+ Password: string;
10
+ staffs?: any;
11
+ }
12
+
13
+ export interface IUserAttr extends IUserInfo {
14
+ Status: string;
15
+ DefaultPasswordChangedYN: YN;
16
+ FirstLoginAt: Date;
17
+ LastLoginAt: Date;
18
+ MFAEnabled: number;
19
+ MFAConfig: string;
20
+ RecoveryEmail: string;
21
+ FailedLoginAttemptCount: number;
22
+ LastFailedLoginAt: Date;
23
+ LastPasswordChangedAt: Date;
24
+ NeedToChangePasswordYN: YN;
25
+ CreatedById: number;
26
+ CreatedAt: Date;
27
+ UpdatedById: number;
28
+ UpdatedAt: Date;
29
+ }