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