internalAuth.js 327 B

1234567891011121314151617181920212223242526
  1. 'use strict'
  2. const crypto = require('crypto')
  3. /**
  4. * Internal Authentication
  5. */
  6. module.exports = {
  7. _curKey: false,
  8. init (inKey) {
  9. this._curKey = inKey
  10. return this
  11. },
  12. generateKey () {
  13. return crypto.randomBytes(20).toString('hex')
  14. },
  15. validateKey (inKey) {
  16. return inKey === this._curKey
  17. }
  18. }