dip-dobit-shared-model 1.0.14 → 1.0.16

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.
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+
3
+ module.exports = {
4
+ up: async (queryInterface, Sequelize) => {
5
+ const tableDescription = await queryInterface.describeTable(
6
+ "BiometricCredentials",
7
+ );
8
+
9
+ if (!tableDescription.loginWithBiometrics) {
10
+ await queryInterface.addColumn(
11
+ "BiometricCredentials",
12
+ "loginWithBiometrics",
13
+ {
14
+ type: Sequelize.BOOLEAN,
15
+ allowNull: false,
16
+ defaultValue: false,
17
+ after: "biometricEnabled",
18
+ },
19
+ );
20
+ }
21
+
22
+ if (!tableDescription.confirmTransactionWithBiometrics) {
23
+ await queryInterface.addColumn(
24
+ "BiometricCredentials",
25
+ "confirmTransactionWithBiometrics",
26
+ {
27
+ type: Sequelize.BOOLEAN,
28
+ allowNull: false,
29
+ defaultValue: false,
30
+ after: "loginWithBiometrics",
31
+ },
32
+ );
33
+ }
34
+ },
35
+
36
+ down: async (queryInterface) => {
37
+ await queryInterface.removeColumn(
38
+ "BiometricCredentials",
39
+ "loginWithBiometrics",
40
+ );
41
+ await queryInterface.removeColumn(
42
+ "BiometricCredentials",
43
+ "confirmTransactionWithBiometrics",
44
+ );
45
+ },
46
+ };
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+
3
+ module.exports = {
4
+ up: async (queryInterface, Sequelize) => {
5
+ const tableDescription = await queryInterface.describeTable("DobitUsers");
6
+
7
+ if (!tableDescription.isPinSet) {
8
+ await queryInterface.addColumn("DobitUsers", "isPinSet", {
9
+ type: Sequelize.BOOLEAN,
10
+ defaultValue: false,
11
+ after: "pin",
12
+ });
13
+ }
14
+
15
+ if (!tableDescription.isTotpConfigured) {
16
+ await queryInterface.addColumn("DobitUsers", "isTotpConfigured", {
17
+ type: Sequelize.BOOLEAN,
18
+ defaultValue: false,
19
+ after: "totpEnabled",
20
+ });
21
+ }
22
+ },
23
+
24
+ down: async (queryInterface) => {
25
+ await queryInterface.removeColumn("DobitUsers", "isPinSet");
26
+ await queryInterface.removeColumn("DobitUsers", "isTotpConfigured");
27
+ },
28
+ };
@@ -4,7 +4,15 @@ const { Model, DataTypes } = require("sequelize");
4
4
  const { STATUS_ID } = require("../service/constants");
5
5
 
6
6
  module.exports = (sequelize) => {
7
- class BiometricChallenge extends Model {}
7
+ class BiometricChallenge extends Model {
8
+ static associate(models) {
9
+ BiometricChallenge.belongsTo(models.DobitUsers, {
10
+ as: "user",
11
+ foreignKey: "appUserId",
12
+ targetKey: "appUserId",
13
+ });
14
+ }
15
+ }
8
16
 
9
17
  BiometricChallenge.init(
10
18
  {
@@ -4,7 +4,15 @@ const { Model, DataTypes } = require("sequelize");
4
4
  const { STATUS_ID } = require("../service/constants");
5
5
 
6
6
  module.exports = (sequelize) => {
7
- class BiometricCredentials extends Model {}
7
+ class BiometricCredentials extends Model {
8
+ static associate(models) {
9
+ BiometricCredentials.belongsTo(models.DobitUsers, {
10
+ as: "user",
11
+ foreignKey: "appUserId",
12
+ targetKey: "appUserId",
13
+ });
14
+ }
15
+ }
8
16
 
9
17
  BiometricCredentials.init(
10
18
  {
@@ -38,6 +46,16 @@ module.exports = (sequelize) => {
38
46
  allowNull: false,
39
47
  defaultValue: false,
40
48
  },
49
+ loginWithBiometrics: {
50
+ type: DataTypes.BOOLEAN,
51
+ allowNull: false,
52
+ defaultValue: false,
53
+ },
54
+ confirmTransactionWithBiometrics: {
55
+ type: DataTypes.BOOLEAN,
56
+ allowNull: false,
57
+ defaultValue: false,
58
+ },
41
59
  lastUsedAt: {
42
60
  type: DataTypes.DATE,
43
61
  allowNull: true,
@@ -22,6 +22,16 @@ module.exports = (sequelize) => {
22
22
  as: "transactions",
23
23
  foreignKey: "dobitUserId",
24
24
  });
25
+ DobitUsers.hasMany(models.BiometricCredentials, {
26
+ as: "biometricCredentials",
27
+ foreignKey: "appUserId",
28
+ sourceKey: "appUserId",
29
+ });
30
+ DobitUsers.hasMany(models.BiometricChallenge, {
31
+ as: "biometricChallenges",
32
+ foreignKey: "appUserId",
33
+ sourceKey: "appUserId",
34
+ });
25
35
  }
26
36
  }
27
37
 
@@ -70,6 +80,10 @@ module.exports = (sequelize) => {
70
80
  type: DataTypes.STRING,
71
81
  allowNull: true,
72
82
  },
83
+ isPinSet: {
84
+ type: DataTypes.BOOLEAN,
85
+ defaultValue: false,
86
+ },
73
87
  nin: {
74
88
  type: DataTypes.STRING,
75
89
  allowNull: true,
@@ -88,16 +102,6 @@ module.exports = (sequelize) => {
88
102
  type: DataTypes.STRING,
89
103
  allowNull: true,
90
104
  },
91
- // biometrics: {
92
- // type: DataTypes.BOOLEAN,
93
- // allowNull: false,
94
- // defaultValue: false,
95
- // },
96
- // biometricPublicKey: {
97
- // type: DataTypes.TEXT,
98
- // allowNull: true,
99
- // unique: true,
100
- // },
101
105
  pushNotification: {
102
106
  type: DataTypes.BOOLEAN,
103
107
  allowNull: false,
@@ -135,6 +139,10 @@ module.exports = (sequelize) => {
135
139
  type: DataTypes.BOOLEAN,
136
140
  defaultValue: false,
137
141
  },
142
+ isTotpConfigured: {
143
+ type: DataTypes.BOOLEAN,
144
+ defaultValue: false,
145
+ },
138
146
  userCreatedby: {
139
147
  type: DataTypes.INTEGER.UNSIGNED,
140
148
  allowNull: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dip-dobit-shared-model",
3
- "version": "1.0.14",
3
+ "version": "1.0.16",
4
4
  "main": "models/index.js",
5
5
  "scripts": {
6
6
  "migrate:up": "npx sequelize-cli db:migrate",