2016-09-05 04:39:59 +00:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
const crypto = require('crypto');
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal Authentication
|
|
|
|
*/
|
|
|
|
module.exports = {
|
|
|
|
|
|
|
|
_curKey: false,
|
|
|
|
|
|
|
|
init(inKey) {
|
|
|
|
|
|
|
|
this._curKey = inKey;
|
|
|
|
|
|
|
|
return this;
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
generateKey() {
|
|
|
|
|
2016-10-17 23:52:04 +00:00
|
|
|
return crypto.randomBytes(20).toString('hex');
|
2016-09-05 04:39:59 +00:00
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
validateKey(inKey) {
|
|
|
|
|
|
|
|
return inKey === this._curKey;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|