@tomei/sso 0.16.1 → 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 (31) 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/src/components/building/building.d.ts +10 -3
  16. package/dist/src/components/staff/staff.js +1 -1
  17. package/dist/src/components/staff/staff.js.map +1 -1
  18. package/dist/src/models/user.entity.d.ts +16 -6
  19. package/dist/tsconfig.tsbuildinfo +1 -1
  20. package/jest.config.js +13 -13
  21. package/migrations/01-alter-system-privilege-table.js +13 -13
  22. package/migrations/02-alter-user-group-table.js +78 -78
  23. package/migrations/03-alter-user-system-privilege-table.js +38 -38
  24. package/migrations/20240314080603-create-user-table.js +108 -108
  25. package/migrations/20240314080604-create-user-user-group-table.js +55 -55
  26. package/migrations/20240314080605-create-login-history-table.js +49 -49
  27. package/package.json +80 -80
  28. package/sampledotenv +7 -7
  29. package/src/components/staff/staff.ts +3 -1
  30. package/tsconfig.build.json +5 -5
  31. package/tsconfig.json +23 -23
package/jest.config.js CHANGED
@@ -1,14 +1,14 @@
1
- /** @type {import('ts-jest').JestConfigWithTsJest} */
2
- module.exports = {
3
- clearMocks: true,
4
- preset: 'ts-jest',
5
- testTimeout: 20000,
6
- coverageDirectory: "coverage",
7
- testEnvironment: 'node',
8
- "modulePathIgnorePatterns": [
9
- "<rootDir>/dist"
10
- ],
11
- setupFilesAfterEnv: [
12
- '<rootDir>/src/redis-client/__mocks__/jest-initial-setup.ts',
13
- ]
1
+ /** @type {import('ts-jest').JestConfigWithTsJest} */
2
+ module.exports = {
3
+ clearMocks: true,
4
+ preset: 'ts-jest',
5
+ testTimeout: 20000,
6
+ coverageDirectory: "coverage",
7
+ testEnvironment: 'node',
8
+ "modulePathIgnorePatterns": [
9
+ "<rootDir>/dist"
10
+ ],
11
+ setupFilesAfterEnv: [
12
+ '<rootDir>/src/redis-client/__mocks__/jest-initial-setup.ts',
13
+ ]
14
14
  };
@@ -1,13 +1,13 @@
1
- 'use strict';
2
-
3
- module.exports = {
4
- async up(queryInterface, Sequelize) {
5
- await queryInterface.addColumn('sso_systemPrivilege','Module', {
6
- type: Sequelize.STRING(200),
7
- })
8
- },
9
-
10
- async down(queryInterface) {
11
- queryInterface.removeColumn('sso_systemPrivilege','Module')
12
- },
13
- };
1
+ 'use strict';
2
+
3
+ module.exports = {
4
+ async up(queryInterface, Sequelize) {
5
+ await queryInterface.addColumn('sso_systemPrivilege','Module', {
6
+ type: Sequelize.STRING(200),
7
+ })
8
+ },
9
+
10
+ async down(queryInterface) {
11
+ queryInterface.removeColumn('sso_systemPrivilege','Module')
12
+ },
13
+ };
@@ -1,78 +1,78 @@
1
- 'use strict';
2
-
3
- module.exports = {
4
- up: async (queryInterface, Sequelize) => {
5
- return queryInterface.sequelize.transaction(async (t) => {
6
- return await Promise.all([
7
- queryInterface.addColumn(
8
- 'sso_usergroup',
9
- 'AllowInheritFromParentYN',
10
- {
11
- type: Sequelize.ENUM(['Y', 'N']),
12
- defaultValue: 'N',
13
- },
14
- { transaction: t },
15
- ),
16
- queryInterface.addColumn(
17
- 'sso_usergroup',
18
- 'FullPath',
19
- {
20
- type: Sequelize.STRING(1000),
21
- allowNull: true,
22
- },
23
- { transaction: t },
24
- ),
25
- queryInterface.addColumn(
26
- 'sso_usergroup',
27
- 'GroupLevel',
28
- {
29
- type: Sequelize.INTEGER,
30
- allowNull: false,
31
- defaultValue: 0,
32
- },
33
- { transaction: t },
34
- ),
35
- queryInterface.addColumn(
36
- 'sso_usergroup',
37
- 'GroupType',
38
- {
39
- type: Sequelize.STRING(10),
40
- allowNull: true,
41
- },
42
- { transaction: t },
43
- ),
44
- queryInterface.addColumn(
45
- 'sso_usergroup',
46
- 'ParentGroupCode',
47
- {
48
- type: Sequelize.STRING(10),
49
- allowNull: true,
50
- },
51
- { transaction: t },
52
- ),
53
- queryInterface.addColumn(
54
- 'sso_usergroup',
55
- 'PersonInCharge',
56
- {
57
- type: Sequelize.STRING(100),
58
- allowNull: true,
59
- },
60
- { transaction: t },
61
- ),
62
- ]);
63
- });
64
- },
65
-
66
- down: async (queryInterface) => {
67
- return queryInterface.sequelize.transaction(async (t) => {
68
- return await Promise.all([
69
- queryInterface.removeColumn('sso_usergroup', 'AllowInheritFromParentYN', { transaction: t }),
70
- queryInterface.removeColumn('sso_usergroup', 'FullPath', { transaction: t }),
71
- queryInterface.removeColumn('sso_usergroup', 'GroupLevel', { transaction: t }),
72
- queryInterface.removeColumn('sso_usergroup', 'GroupType', { transaction: t }),
73
- queryInterface.removeColumn('sso_usergroup', 'ParentGroupCode', { transaction: t }),
74
- queryInterface.removeColumn('sso_usergroup', 'PersonInCharge', { transaction: t }),
75
- ]);
76
- });
77
- },
78
- };
1
+ 'use strict';
2
+
3
+ module.exports = {
4
+ up: async (queryInterface, Sequelize) => {
5
+ return queryInterface.sequelize.transaction(async (t) => {
6
+ return await Promise.all([
7
+ queryInterface.addColumn(
8
+ 'sso_usergroup',
9
+ 'AllowInheritFromParentYN',
10
+ {
11
+ type: Sequelize.ENUM(['Y', 'N']),
12
+ defaultValue: 'N',
13
+ },
14
+ { transaction: t },
15
+ ),
16
+ queryInterface.addColumn(
17
+ 'sso_usergroup',
18
+ 'FullPath',
19
+ {
20
+ type: Sequelize.STRING(1000),
21
+ allowNull: true,
22
+ },
23
+ { transaction: t },
24
+ ),
25
+ queryInterface.addColumn(
26
+ 'sso_usergroup',
27
+ 'GroupLevel',
28
+ {
29
+ type: Sequelize.INTEGER,
30
+ allowNull: false,
31
+ defaultValue: 0,
32
+ },
33
+ { transaction: t },
34
+ ),
35
+ queryInterface.addColumn(
36
+ 'sso_usergroup',
37
+ 'GroupType',
38
+ {
39
+ type: Sequelize.STRING(10),
40
+ allowNull: true,
41
+ },
42
+ { transaction: t },
43
+ ),
44
+ queryInterface.addColumn(
45
+ 'sso_usergroup',
46
+ 'ParentGroupCode',
47
+ {
48
+ type: Sequelize.STRING(10),
49
+ allowNull: true,
50
+ },
51
+ { transaction: t },
52
+ ),
53
+ queryInterface.addColumn(
54
+ 'sso_usergroup',
55
+ 'PersonInCharge',
56
+ {
57
+ type: Sequelize.STRING(100),
58
+ allowNull: true,
59
+ },
60
+ { transaction: t },
61
+ ),
62
+ ]);
63
+ });
64
+ },
65
+
66
+ down: async (queryInterface) => {
67
+ return queryInterface.sequelize.transaction(async (t) => {
68
+ return await Promise.all([
69
+ queryInterface.removeColumn('sso_usergroup', 'AllowInheritFromParentYN', { transaction: t }),
70
+ queryInterface.removeColumn('sso_usergroup', 'FullPath', { transaction: t }),
71
+ queryInterface.removeColumn('sso_usergroup', 'GroupLevel', { transaction: t }),
72
+ queryInterface.removeColumn('sso_usergroup', 'GroupType', { transaction: t }),
73
+ queryInterface.removeColumn('sso_usergroup', 'ParentGroupCode', { transaction: t }),
74
+ queryInterface.removeColumn('sso_usergroup', 'PersonInCharge', { transaction: t }),
75
+ ]);
76
+ });
77
+ },
78
+ };
@@ -1,38 +1,38 @@
1
- 'use strict';
2
-
3
- module.exports = {
4
- up: async (queryInterface, Sequelize) => {
5
- return queryInterface.sequelize.transaction(async (t) => {
6
- return await Promise.all([
7
- queryInterface.addColumn(
8
- 'sso_usersystemprivilege',
9
- 'IsInheritedYN',
10
- {
11
- type: Sequelize.ENUM(['Y', 'N']),
12
- defaultValue: 'N',
13
- },
14
- { transaction: t },
15
- ),
16
- queryInterface.addColumn(
17
- 'sso_usersystemprivilege',
18
- 'IsRevokedYN',
19
- {
20
- type: Sequelize.ENUM(['Y', 'N']),
21
- defaultValue: 'N',
22
- },
23
- { transaction: t },
24
- ),
25
- ]);
26
- });
27
- },
28
-
29
- down: async (queryInterface) => {
30
- return queryInterface.sequelize.transaction(async (t) => {
31
- return await Promise.all([
32
- queryInterface.removeColumn('sso_usersystemprivilege', 'IsInheritedYN', { transaction: t }),
33
- queryInterface.removeColumn('sso_usersystemprivilege', 'IsRevokedYN', { transaction: t }),
34
- ]);
35
- });
36
- },
37
- };
38
- 'use strict';
1
+ 'use strict';
2
+
3
+ module.exports = {
4
+ up: async (queryInterface, Sequelize) => {
5
+ return queryInterface.sequelize.transaction(async (t) => {
6
+ return await Promise.all([
7
+ queryInterface.addColumn(
8
+ 'sso_usersystemprivilege',
9
+ 'IsInheritedYN',
10
+ {
11
+ type: Sequelize.ENUM(['Y', 'N']),
12
+ defaultValue: 'N',
13
+ },
14
+ { transaction: t },
15
+ ),
16
+ queryInterface.addColumn(
17
+ 'sso_usersystemprivilege',
18
+ 'IsRevokedYN',
19
+ {
20
+ type: Sequelize.ENUM(['Y', 'N']),
21
+ defaultValue: 'N',
22
+ },
23
+ { transaction: t },
24
+ ),
25
+ ]);
26
+ });
27
+ },
28
+
29
+ down: async (queryInterface) => {
30
+ return queryInterface.sequelize.transaction(async (t) => {
31
+ return await Promise.all([
32
+ queryInterface.removeColumn('sso_usersystemprivilege', 'IsInheritedYN', { transaction: t }),
33
+ queryInterface.removeColumn('sso_usersystemprivilege', 'IsRevokedYN', { transaction: t }),
34
+ ]);
35
+ });
36
+ },
37
+ };
38
+ 'use strict';
@@ -1,108 +1,108 @@
1
- 'use strict';
2
-
3
- /** @type {import('sequelize-cli').Migration} */
4
- module.exports = {
5
- async up(queryInterface, Sequelize) {
6
- await queryInterface.createTable('sso_User', {
7
- UserId: {
8
- primaryKey: true,
9
- type: Sequelize.INTEGER,
10
- allowNull: false,
11
- autoIncrement: true,
12
- },
13
- Email: {
14
- type: Sequelize.STRING,
15
- allowNull: false,
16
- unique: true,
17
- },
18
- Password: {
19
- type: Sequelize.STRING,
20
- allowNull: false,
21
- },
22
- Status: {
23
- type: Sequelize.STRING,
24
- allowNull: false,
25
- },
26
- DefaultPasswordChangedYN: {
27
- type: Sequelize.CHAR(1),
28
- allowNull: true,
29
- },
30
- FirstLoginAt: {
31
- type: Sequelize.DATE,
32
- allowNull: true,
33
- },
34
- LastLoginAt: {
35
- type: Sequelize.DATE,
36
- allowNull: true,
37
- },
38
- MFAEnabled: {
39
- type: Sequelize.TINYINT,
40
- allowNull: true,
41
- },
42
- MFAConfig: {
43
- type: Sequelize.TEXT,
44
- allowNull: true,
45
- },
46
- RecoveryEmail: {
47
- type: Sequelize.STRING,
48
- allowNull: true,
49
- },
50
- FailedLoginAttemptCount: {
51
- type: Sequelize.INTEGER,
52
- allowNull: false,
53
- },
54
- LastFailedLoginAt: {
55
- type: Sequelize.DATE,
56
- allowNull: true,
57
- },
58
- LastPasswordChangedAt: {
59
- type: Sequelize.DATE,
60
- allowNull: true,
61
- },
62
- NeedToChangePasswordYN: {
63
- type: Sequelize.CHAR(1),
64
- allowNull: true,
65
- },
66
- CreatedAt: {
67
- allowNull: false,
68
- defaultValue: Sequelize.literal('CURRENT_TIMESTAMP(3)'),
69
- type: Sequelize.DATE,
70
- },
71
- CreatedById: {
72
- type: Sequelize.INTEGER,
73
- allowNull: true,
74
- references: {
75
- model: 'sso_User',
76
- key: 'UserId',
77
- },
78
- onDelete: 'CASCADE',
79
- onUpdate: 'CASCADE',
80
- },
81
- UpdatedAt: {
82
- allowNull: false,
83
- defaultValue: Sequelize.literal('CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)'),
84
- type: Sequelize.DATE,
85
- },
86
- UpdatedById: {
87
- type: Sequelize.INTEGER,
88
- allowNull: true,
89
- references: {
90
- model: 'sso_User',
91
- key: 'UserId',
92
- },
93
- onDelete: 'CASCADE',
94
- onUpdate: 'CASCADE',
95
- },
96
-
97
- });
98
- },
99
-
100
- async down(queryInterface, Sequelize) {
101
- /**
102
- * Add reverting commands here.
103
- *
104
- * Example:
105
- * await queryInterface.dropTable('users');
106
- */
107
- }
108
- };
1
+ 'use strict';
2
+
3
+ /** @type {import('sequelize-cli').Migration} */
4
+ module.exports = {
5
+ async up(queryInterface, Sequelize) {
6
+ await queryInterface.createTable('sso_User', {
7
+ UserId: {
8
+ primaryKey: true,
9
+ type: Sequelize.INTEGER,
10
+ allowNull: false,
11
+ autoIncrement: true,
12
+ },
13
+ Email: {
14
+ type: Sequelize.STRING,
15
+ allowNull: false,
16
+ unique: true,
17
+ },
18
+ Password: {
19
+ type: Sequelize.STRING,
20
+ allowNull: false,
21
+ },
22
+ Status: {
23
+ type: Sequelize.STRING,
24
+ allowNull: false,
25
+ },
26
+ DefaultPasswordChangedYN: {
27
+ type: Sequelize.CHAR(1),
28
+ allowNull: true,
29
+ },
30
+ FirstLoginAt: {
31
+ type: Sequelize.DATE,
32
+ allowNull: true,
33
+ },
34
+ LastLoginAt: {
35
+ type: Sequelize.DATE,
36
+ allowNull: true,
37
+ },
38
+ MFAEnabled: {
39
+ type: Sequelize.TINYINT,
40
+ allowNull: true,
41
+ },
42
+ MFAConfig: {
43
+ type: Sequelize.TEXT,
44
+ allowNull: true,
45
+ },
46
+ RecoveryEmail: {
47
+ type: Sequelize.STRING,
48
+ allowNull: true,
49
+ },
50
+ FailedLoginAttemptCount: {
51
+ type: Sequelize.INTEGER,
52
+ allowNull: false,
53
+ },
54
+ LastFailedLoginAt: {
55
+ type: Sequelize.DATE,
56
+ allowNull: true,
57
+ },
58
+ LastPasswordChangedAt: {
59
+ type: Sequelize.DATE,
60
+ allowNull: true,
61
+ },
62
+ NeedToChangePasswordYN: {
63
+ type: Sequelize.CHAR(1),
64
+ allowNull: true,
65
+ },
66
+ CreatedAt: {
67
+ allowNull: false,
68
+ defaultValue: Sequelize.literal('CURRENT_TIMESTAMP(3)'),
69
+ type: Sequelize.DATE,
70
+ },
71
+ CreatedById: {
72
+ type: Sequelize.INTEGER,
73
+ allowNull: true,
74
+ references: {
75
+ model: 'sso_User',
76
+ key: 'UserId',
77
+ },
78
+ onDelete: 'CASCADE',
79
+ onUpdate: 'CASCADE',
80
+ },
81
+ UpdatedAt: {
82
+ allowNull: false,
83
+ defaultValue: Sequelize.literal('CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)'),
84
+ type: Sequelize.DATE,
85
+ },
86
+ UpdatedById: {
87
+ type: Sequelize.INTEGER,
88
+ allowNull: true,
89
+ references: {
90
+ model: 'sso_User',
91
+ key: 'UserId',
92
+ },
93
+ onDelete: 'CASCADE',
94
+ onUpdate: 'CASCADE',
95
+ },
96
+
97
+ });
98
+ },
99
+
100
+ async down(queryInterface, Sequelize) {
101
+ /**
102
+ * Add reverting commands here.
103
+ *
104
+ * Example:
105
+ * await queryInterface.dropTable('users');
106
+ */
107
+ }
108
+ };
@@ -1,55 +1,55 @@
1
- 'use strict';
2
-
3
- module.exports = {
4
- up: async (queryInterface, Sequelize) => {
5
- queryInterface.createTable('sso_UserUserGroup', {
6
- UserId: {
7
- primaryKey: true,
8
- type: Sequelize.INTEGER,
9
- allowNull: false,
10
- references: {
11
- model: 'sso_User',
12
- key: 'id',
13
- },
14
- onDelete: 'CASCADE',
15
- onUpdate: 'CASCADE',
16
- },
17
- GroupCode: {
18
- primaryKey: true,
19
- type: Sequelize.STRING(191),
20
- allowNull: false,
21
- references: {
22
- model: 'sso_usergroup',
23
- key: 'GroupCode',
24
- },
25
- onDelete: 'CASCADE',
26
- onUpdate: 'CASCADE',
27
- },
28
- SystemId: {
29
- type: Sequelize.INTEGER,
30
- allowNull: true,
31
- references: {
32
- model: 'sso_systems',
33
- key: 'id',
34
- },
35
- onDelete: 'CASCADE',
36
- onUpdate: 'CASCADE',
37
- },
38
- CreatedAt: {
39
- allowNull: false,
40
- defaultValue: Sequelize.literal('CURRENT_TIMESTAMP(3)'),
41
- type: Sequelize.DATE,
42
- },
43
- UpdatedAt: {
44
- allowNull: false,
45
- defaultValue: Sequelize.literal('CURRENT_TIMESTAMP(3)'),
46
- type: Sequelize.DATE,
47
- },
48
- });
49
-
50
- },
51
-
52
- down: async (queryInterface) => {
53
- await queryInterface.dropTable('sso_UserUserGroup');
54
- },
55
- };
1
+ 'use strict';
2
+
3
+ module.exports = {
4
+ up: async (queryInterface, Sequelize) => {
5
+ queryInterface.createTable('sso_UserUserGroup', {
6
+ UserId: {
7
+ primaryKey: true,
8
+ type: Sequelize.INTEGER,
9
+ allowNull: false,
10
+ references: {
11
+ model: 'sso_User',
12
+ key: 'id',
13
+ },
14
+ onDelete: 'CASCADE',
15
+ onUpdate: 'CASCADE',
16
+ },
17
+ GroupCode: {
18
+ primaryKey: true,
19
+ type: Sequelize.STRING(191),
20
+ allowNull: false,
21
+ references: {
22
+ model: 'sso_usergroup',
23
+ key: 'GroupCode',
24
+ },
25
+ onDelete: 'CASCADE',
26
+ onUpdate: 'CASCADE',
27
+ },
28
+ SystemId: {
29
+ type: Sequelize.INTEGER,
30
+ allowNull: true,
31
+ references: {
32
+ model: 'sso_systems',
33
+ key: 'id',
34
+ },
35
+ onDelete: 'CASCADE',
36
+ onUpdate: 'CASCADE',
37
+ },
38
+ CreatedAt: {
39
+ allowNull: false,
40
+ defaultValue: Sequelize.literal('CURRENT_TIMESTAMP(3)'),
41
+ type: Sequelize.DATE,
42
+ },
43
+ UpdatedAt: {
44
+ allowNull: false,
45
+ defaultValue: Sequelize.literal('CURRENT_TIMESTAMP(3)'),
46
+ type: Sequelize.DATE,
47
+ },
48
+ });
49
+
50
+ },
51
+
52
+ down: async (queryInterface) => {
53
+ await queryInterface.dropTable('sso_UserUserGroup');
54
+ },
55
+ };