2018-06-11 08:38:32 +00:00
|
|
|
'use strict';
|
|
|
|
|
2018-06-27 11:21:49 +00:00
|
|
|
const Key = require('./keyRSA');
|
2018-06-11 08:38:32 +00:00
|
|
|
|
2018-06-20 09:20:03 +00:00
|
|
|
const keyOrNull = key => (key ? Key(key) : null);
|
2018-06-11 08:38:32 +00:00
|
|
|
|
|
|
|
module.exports = class Keys {
|
|
|
|
constructor({
|
|
|
|
A006,
|
|
|
|
E002,
|
|
|
|
X002,
|
|
|
|
bankX002,
|
|
|
|
bankE002,
|
|
|
|
}) {
|
|
|
|
this.keys = {
|
|
|
|
A006: keyOrNull(A006),
|
|
|
|
E002: keyOrNull(E002),
|
|
|
|
X002: keyOrNull(X002),
|
|
|
|
bankX002: keyOrNull(bankX002),
|
|
|
|
bankE002: keyOrNull(bankE002),
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
static generate() {
|
|
|
|
const keys = {};
|
|
|
|
|
|
|
|
Object.keys({ A006: '', X002: '', E002: '' }).forEach((key) => {
|
2018-06-27 11:21:49 +00:00
|
|
|
keys[key] = Key().generate();
|
2018-06-11 08:38:32 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
return new Keys(keys);
|
|
|
|
}
|
|
|
|
|
|
|
|
setBankKeys(bankKeys) {
|
2018-06-27 11:21:49 +00:00
|
|
|
this.keys.bankX002 = Key().importKey(bankKeys.bankX002);
|
|
|
|
this.keys.bankE002 = Key().importKey(bankKeys.bankE002);
|
2018-06-11 08:38:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
a() {
|
|
|
|
return this.keys.A006;
|
|
|
|
}
|
|
|
|
|
|
|
|
e() {
|
|
|
|
return this.keys.E002;
|
|
|
|
}
|
|
|
|
|
|
|
|
x() {
|
|
|
|
return this.keys.X002;
|
|
|
|
}
|
|
|
|
|
|
|
|
bankX() {
|
|
|
|
return this.keys.bankX002;
|
|
|
|
}
|
|
|
|
|
|
|
|
bankE() {
|
|
|
|
return this.keys.bankE002;
|
|
|
|
}
|
|
|
|
};
|