@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.
- package/.commitlintrc.json +22 -22
- package/.eslintrc +16 -16
- package/.eslintrc.js +35 -35
- package/.husky/commit-msg +15 -15
- package/.husky/pre-commit +7 -7
- package/.prettierrc +4 -4
- package/Jenkinsfile +57 -57
- package/README.md +23 -23
- package/__tests__/unit/components/login-user/login-user.spec.ts +742 -742
- package/__tests__/unit/components/password-hash/password-hash.service.spec.ts +31 -31
- package/__tests__/unit/redis-client/redis.service.spec.ts +23 -23
- package/__tests__/unit/session/session.service.spec.ts +47 -47
- package/__tests__/unit/system-privilege/system-privilage.spec.ts +91 -91
- package/create-sso-user.sql +39 -39
- package/dist/__tests__/unit/components/login-user/login-user.spec.js +15 -15
- package/dist/__tests__/unit/components/login-user/login-user.spec.js.map +1 -1
- package/dist/src/components/building/building.d.ts +10 -3
- package/dist/src/components/building/building.js +12 -1
- package/dist/src/components/building/building.js.map +1 -1
- package/dist/src/components/login-user/interfaces/user-info.interface.d.ts +19 -1
- package/dist/src/components/login-user/login-user.d.ts +54 -9
- package/dist/src/components/login-user/login-user.js +177 -29
- package/dist/src/components/login-user/login-user.js.map +1 -1
- package/dist/src/components/staff/staff.d.ts +1 -1
- package/dist/src/components/staff/staff.js +1 -1
- package/dist/src/components/staff/staff.js.map +1 -1
- package/dist/src/enum/index.d.ts +1 -0
- package/dist/src/enum/index.js +18 -0
- package/dist/src/enum/index.js.map +1 -0
- package/dist/src/enum/yn.enum.d.ts +4 -0
- package/dist/src/enum/yn.enum.js +9 -0
- package/dist/src/enum/yn.enum.js.map +1 -0
- package/dist/src/models/user.entity.d.ts +16 -6
- package/dist/src/models/user.entity.js +85 -25
- package/dist/src/models/user.entity.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/jest.config.js +13 -13
- package/migrations/01-alter-system-privilege-table.js +13 -13
- package/migrations/02-alter-user-group-table.js +78 -78
- package/migrations/03-alter-user-system-privilege-table.js +38 -38
- package/migrations/20240314080603-create-user-table.js +108 -0
- package/migrations/{04-create-user-user-group-table.js → 20240314080604-create-user-user-group-table.js} +55 -55
- package/migrations/{05-create-login-history-table.js → 20240314080605-create-login-history-table.js} +49 -49
- package/package.json +80 -79
- package/sampledotenv +7 -7
- package/src/components/building/building.ts +18 -3
- package/src/components/login-user/interfaces/user-info.interface.ts +29 -9
- package/src/components/login-user/login-user.ts +749 -557
- package/src/components/staff/staff.ts +4 -2
- package/src/enum/index.ts +1 -0
- package/src/enum/yn.enum.ts +4 -0
- package/src/models/user.entity.ts +160 -110
- package/tsconfig.build.json +5 -5
- package/tsconfig.json +23 -23
package/package.json
CHANGED
@@ -1,79 +1,80 @@
|
|
1
|
-
{
|
2
|
-
"name": "@tomei/sso",
|
3
|
-
"version": "0.
|
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
|
-
"
|
50
|
-
"ts-
|
51
|
-
"
|
52
|
-
"
|
53
|
-
"
|
54
|
-
"
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
"@tomei/
|
62
|
-
"@tomei/
|
63
|
-
"@
|
64
|
-
"
|
65
|
-
"
|
66
|
-
"
|
67
|
-
"
|
68
|
-
"
|
69
|
-
"
|
70
|
-
"
|
71
|
-
"sequelize
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
"
|
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
|
-
|
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
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
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
|
+
}
|