dip-dobit-shared-model 1.0.13 → 1.0.14
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/migrations/20260609113729-change-biometric-public-key-to-text.js +29 -0
- package/migrations/20260609130000-create-BiometricCredentials-table.js +60 -0
- package/migrations/20260609131300-remove-biometrics-from-DobitUsers-table.js +34 -0
- package/migrations/20260609141000-add-deviceId-to-BiometricChallenge-table.js +21 -0
- package/migrations/20260609161000-add-index-to-BiometricCredentials-table.js +26 -0
- package/models/biometricChallenge.js +7 -0
- package/models/biometricCredentials.js +63 -0
- package/models/dobitUser.js +10 -10
- package/package.json +1 -1
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
async up(queryInterface, Sequelize) {
|
|
3
|
+
const indexes = await queryInterface.showIndex("DobitUsers");
|
|
4
|
+
|
|
5
|
+
const biometricIndex = indexes.find((index) =>
|
|
6
|
+
index.fields.some((field) => field.attribute === "biometricPublicKey"),
|
|
7
|
+
);
|
|
8
|
+
|
|
9
|
+
if (biometricIndex) {
|
|
10
|
+
await queryInterface.removeIndex("DobitUsers", biometricIndex.name);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
await queryInterface.changeColumn("DobitUsers", "biometricPublicKey", {
|
|
14
|
+
type: Sequelize.TEXT,
|
|
15
|
+
allowNull: true,
|
|
16
|
+
});
|
|
17
|
+
},
|
|
18
|
+
|
|
19
|
+
async down(queryInterface, Sequelize) {
|
|
20
|
+
await queryInterface.changeColumn("DobitUsers", "biometricPublicKey", {
|
|
21
|
+
type: Sequelize.STRING(700),
|
|
22
|
+
allowNull: true,
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
await queryInterface.addIndex("DobitUsers", ["biometricPublicKey"], {
|
|
26
|
+
unique: true,
|
|
27
|
+
});
|
|
28
|
+
},
|
|
29
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const { STATUS_ID } = require("../service/constants");
|
|
4
|
+
|
|
5
|
+
module.exports = {
|
|
6
|
+
async up(queryInterface, Sequelize) {
|
|
7
|
+
await queryInterface.createTable("BiometricCredentials", {
|
|
8
|
+
biometricCredentialId: {
|
|
9
|
+
type: Sequelize.INTEGER.UNSIGNED,
|
|
10
|
+
primaryKey: true,
|
|
11
|
+
autoIncrement: true,
|
|
12
|
+
},
|
|
13
|
+
appUserId: {
|
|
14
|
+
type: Sequelize.BIGINT.UNSIGNED,
|
|
15
|
+
allowNull: false,
|
|
16
|
+
},
|
|
17
|
+
deviceId: {
|
|
18
|
+
type: Sequelize.STRING(255),
|
|
19
|
+
allowNull: false,
|
|
20
|
+
},
|
|
21
|
+
deviceType: {
|
|
22
|
+
type: Sequelize.STRING(50),
|
|
23
|
+
allowNull: true,
|
|
24
|
+
},
|
|
25
|
+
deviceName: {
|
|
26
|
+
type: Sequelize.STRING(255),
|
|
27
|
+
allowNull: true,
|
|
28
|
+
},
|
|
29
|
+
biometricPublicKey: {
|
|
30
|
+
type: Sequelize.TEXT,
|
|
31
|
+
allowNull: false,
|
|
32
|
+
},
|
|
33
|
+
biometricEnabled: {
|
|
34
|
+
type: Sequelize.BOOLEAN,
|
|
35
|
+
allowNull: false,
|
|
36
|
+
defaultValue: false,
|
|
37
|
+
},
|
|
38
|
+
lastUsedAt: {
|
|
39
|
+
type: Sequelize.DATE,
|
|
40
|
+
allowNull: true,
|
|
41
|
+
},
|
|
42
|
+
createdAt: {
|
|
43
|
+
allowNull: false,
|
|
44
|
+
type: Sequelize.DATE,
|
|
45
|
+
},
|
|
46
|
+
updatedAt: {
|
|
47
|
+
allowNull: false,
|
|
48
|
+
type: Sequelize.DATE,
|
|
49
|
+
},
|
|
50
|
+
deletedAt: {
|
|
51
|
+
type: Sequelize.DATE,
|
|
52
|
+
allowNull: true,
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
},
|
|
56
|
+
|
|
57
|
+
async down(queryInterface, Sequelize) {
|
|
58
|
+
await queryInterface.dropTable("BiometricCredentials");
|
|
59
|
+
},
|
|
60
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
async up(queryInterface) {
|
|
5
|
+
const tableDescription = await queryInterface.describeTable("DobitUsers");
|
|
6
|
+
|
|
7
|
+
if (tableDescription.biometrics) {
|
|
8
|
+
await queryInterface.removeColumn("DobitUsers", "biometrics");
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
if (tableDescription.biometricPublicKey) {
|
|
12
|
+
await queryInterface.removeColumn("DobitUsers", "biometricPublicKey");
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
|
|
16
|
+
async down(queryInterface, Sequelize) {
|
|
17
|
+
const tableDescription = await queryInterface.describeTable("DobitUsers");
|
|
18
|
+
|
|
19
|
+
if (!tableDescription.biometrics) {
|
|
20
|
+
await queryInterface.addColumn("DobitUsers", "biometrics", {
|
|
21
|
+
type: Sequelize.BOOLEAN,
|
|
22
|
+
allowNull: false,
|
|
23
|
+
defaultValue: false,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (!tableDescription.biometricPublicKey) {
|
|
28
|
+
await queryInterface.addColumn("DobitUsers", "biometricPublicKey", {
|
|
29
|
+
type: Sequelize.TEXT,
|
|
30
|
+
allowNull: true,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
up: async (queryInterface, Sequelize) => {
|
|
5
|
+
const tableDescription = await queryInterface.describeTable(
|
|
6
|
+
"BiometricChallenges",
|
|
7
|
+
);
|
|
8
|
+
|
|
9
|
+
if (!tableDescription.deviceId) {
|
|
10
|
+
await queryInterface.addColumn("BiometricChallenges", "deviceId", {
|
|
11
|
+
type: Sequelize.STRING,
|
|
12
|
+
allowNull: false,
|
|
13
|
+
after: "appUserId",
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
|
|
18
|
+
down: async (queryInterface) => {
|
|
19
|
+
await queryInterface.removeColumn("BiometricChallenges", "deviceId");
|
|
20
|
+
},
|
|
21
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
up: async (queryInterface, Sequelize) => {
|
|
5
|
+
try {
|
|
6
|
+
await queryInterface.addConstraint("BiometricCredentials", {
|
|
7
|
+
fields: ["appUserId", "deviceId"],
|
|
8
|
+
type: "unique",
|
|
9
|
+
name: "BiometricCredentials_appUserId_deviceId_unique",
|
|
10
|
+
});
|
|
11
|
+
} catch (e) {
|
|
12
|
+
console.log("Constraint already exists, skipping:", e.message);
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
|
|
16
|
+
down: async (queryInterface) => {
|
|
17
|
+
try {
|
|
18
|
+
await queryInterface.removeConstraint(
|
|
19
|
+
"BiometricCredentials",
|
|
20
|
+
"BiometricCredentials_appUserId_deviceId_unique",
|
|
21
|
+
);
|
|
22
|
+
} catch (e) {
|
|
23
|
+
console.log("Constraint not found, skipping:", e.message);
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
};
|
|
@@ -17,6 +17,10 @@ module.exports = (sequelize) => {
|
|
|
17
17
|
type: DataTypes.BIGINT.UNSIGNED,
|
|
18
18
|
allowNull: false,
|
|
19
19
|
},
|
|
20
|
+
deviceId: {
|
|
21
|
+
type: DataTypes.STRING,
|
|
22
|
+
allowNull: false,
|
|
23
|
+
},
|
|
20
24
|
challenge: {
|
|
21
25
|
type: DataTypes.STRING(64),
|
|
22
26
|
allowNull: false,
|
|
@@ -35,4 +39,7 @@ module.exports = (sequelize) => {
|
|
|
35
39
|
paranoid: false,
|
|
36
40
|
},
|
|
37
41
|
);
|
|
42
|
+
|
|
43
|
+
BiometricChallenge.removeAttribute("id");
|
|
44
|
+
return BiometricChallenge;
|
|
38
45
|
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const { Model, DataTypes } = require("sequelize");
|
|
4
|
+
const { STATUS_ID } = require("../service/constants");
|
|
5
|
+
|
|
6
|
+
module.exports = (sequelize) => {
|
|
7
|
+
class BiometricCredentials extends Model {}
|
|
8
|
+
|
|
9
|
+
BiometricCredentials.init(
|
|
10
|
+
{
|
|
11
|
+
biometricCredentialId: {
|
|
12
|
+
type: DataTypes.INTEGER.UNSIGNED,
|
|
13
|
+
primaryKey: true,
|
|
14
|
+
autoIncrement: true,
|
|
15
|
+
},
|
|
16
|
+
appUserId: {
|
|
17
|
+
type: DataTypes.BIGINT.UNSIGNED,
|
|
18
|
+
allowNull: false,
|
|
19
|
+
},
|
|
20
|
+
deviceId: {
|
|
21
|
+
type: DataTypes.STRING(255),
|
|
22
|
+
allowNull: false,
|
|
23
|
+
},
|
|
24
|
+
deviceType: {
|
|
25
|
+
type: DataTypes.STRING(50),
|
|
26
|
+
allowNull: true,
|
|
27
|
+
},
|
|
28
|
+
deviceName: {
|
|
29
|
+
type: DataTypes.STRING(255),
|
|
30
|
+
allowNull: true,
|
|
31
|
+
},
|
|
32
|
+
biometricPublicKey: {
|
|
33
|
+
type: DataTypes.TEXT,
|
|
34
|
+
allowNull: false,
|
|
35
|
+
},
|
|
36
|
+
biometricEnabled: {
|
|
37
|
+
type: DataTypes.BOOLEAN,
|
|
38
|
+
allowNull: false,
|
|
39
|
+
defaultValue: false,
|
|
40
|
+
},
|
|
41
|
+
lastUsedAt: {
|
|
42
|
+
type: DataTypes.DATE,
|
|
43
|
+
allowNull: true,
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
sequelize,
|
|
48
|
+
modelName: "BiometricCredentials",
|
|
49
|
+
tableName: "BiometricCredentials",
|
|
50
|
+
timestamps: true,
|
|
51
|
+
paranoid: true,
|
|
52
|
+
indexes: [
|
|
53
|
+
{
|
|
54
|
+
unique: true,
|
|
55
|
+
fields: ["appUserId", "deviceId"],
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
},
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
BiometricCredentials.removeAttribute("id");
|
|
62
|
+
return BiometricCredentials;
|
|
63
|
+
};
|
package/models/dobitUser.js
CHANGED
|
@@ -88,16 +88,16 @@ module.exports = (sequelize) => {
|
|
|
88
88
|
type: DataTypes.STRING,
|
|
89
89
|
allowNull: true,
|
|
90
90
|
},
|
|
91
|
-
biometrics: {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
},
|
|
96
|
-
biometricPublicKey: {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
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,
|