Genesis commit

This commit is contained in:
Kgothatso
2019-11-23 22:34:59 +02:00
parent 9258d6f234
commit db36cb33cf
19 changed files with 2184 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
module.exports = function (sequelize, DataTypes, options) {
const model = sequelize.define("extendedPublicKey", {
id: {
type: DataTypes.STRING,
defaultValue: function() {
return options.generateUniqueId()
},
primaryKey: true,
unique: true
},
xpub: {
type: DataTypes.STRING,
// TODO add validation
allowNull: false,
unique: true
},
derivationPath: {
type: DataTypes.STRING,
// TODO add validation...
allowNull: false,
unique: true
},
name: {
type: DataTypes.STRING,
unique: true
}
}, {
comment: "Exteneded public keys."
});
model.associate = (db) => {
// TODO Update key to wallet...
model.Key = model.belongsTo(db.Key);
}
return model;
};

View File

@@ -0,0 +1,30 @@
module.exports = function (sequelize, DataTypes, options) {
const model = sequelize.define("key", { // TODO: Rename to wallet
id: {
type: DataTypes.STRING,
defaultValue: function() {
return options.generateUniqueId()
},
primaryKey: true,
unique: true
},
encryptedPrivateKey: {
type: DataTypes.STRING,
allowNull: false
},
name: {
type: DataTypes.STRING,
unique: true
}
// TODO: Add order to allow for user to set default keys
}, {
comment: "The keys we are using in our system (seedphrase)."
});
model.associate = (db) => {
model.Locks = model.hasMany(db.Lock);
model.ExtendedPublicKeys = model.hasMany(db.ExtendedPublicKey);
}
return model;
};

View File

@@ -0,0 +1,39 @@
module.exports = function (sequelize, DataTypes, options) {
const model = sequelize.define("lock", {
id: {
type: DataTypes.STRING,
defaultValue: function() {
return options.generateUniqueId()
},
primaryKey: true,
unique: true
},
userIdentifier: {
type: DataTypes.STRING,
allowNull: false
},
url: {
type: DataTypes.STRING,
allowNull: false
},
signature: {
// Derivation from the master key...
// TODO: Add validation...
type: DataTypes.STRING,
allowNull: false,
unique: true
},
message: {
type: DataTypes.STRING,
allowNull: false
}
}, {
comment: "lock which our keys has access to"
});
model.associate = (db) => {
model.ExtendedPublicKey = model.belongsTo(db.ExtendedPublicKey);
}
return model;
};