Genesis commit
This commit is contained in:
37
lib/core/persistence/models/extendedPublicKey.js
Normal file
37
lib/core/persistence/models/extendedPublicKey.js
Normal 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;
|
||||
};
|
||||
30
lib/core/persistence/models/key.js
Normal file
30
lib/core/persistence/models/key.js
Normal 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;
|
||||
};
|
||||
39
lib/core/persistence/models/lock.js
Normal file
39
lib/core/persistence/models/lock.js
Normal 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;
|
||||
};
|
||||
Reference in New Issue
Block a user