dip-dobit-shared-model 1.0.14 → 1.0.15

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
+ };
@@ -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
 
@@ -88,16 +98,6 @@ module.exports = (sequelize) => {
88
98
  type: DataTypes.STRING,
89
99
  allowNull: true,
90
100
  },
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
101
  pushNotification: {
102
102
  type: DataTypes.BOOLEAN,
103
103
  allowNull: false,
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.15",
4
4
  "main": "models/index.js",
5
5
  "scripts": {
6
6
  "migrate:up": "npx sequelize-cli db:migrate",