Front end of the Slack clone application.

1234567891011121314151617181920212223242526272829303132
  1. var checkParameters = require('./lib/precondition')
  2. var native = require('crypto')
  3. function nativePBKDF2 (password, salt, iterations, keylen, digest, callback) {
  4. checkParameters(password, salt, iterations, keylen)
  5. if (typeof digest === 'function') {
  6. callback = digest
  7. digest = 'sha1'
  8. }
  9. if (typeof callback !== 'function') throw new Error('No callback provided to pbkdf2')
  10. return native.pbkdf2(password, salt, iterations, keylen, digest, callback)
  11. }
  12. function nativePBKDF2Sync (password, salt, iterations, keylen, digest) {
  13. checkParameters(password, salt, iterations, keylen)
  14. digest = digest || 'sha1'
  15. return native.pbkdf2Sync(password, salt, iterations, keylen, digest)
  16. }
  17. /* istanbul ignore next */
  18. if (!native.pbkdf2Sync || native.pbkdf2Sync.toString().indexOf('keylen, digest') === -1) {
  19. exports.pbkdf2Sync = require('./lib/sync')
  20. exports.pbkdf2 = require('./lib/async')
  21. // native
  22. } else {
  23. exports.pbkdf2Sync = nativePBKDF2Sync
  24. exports.pbkdf2 = nativePBKDF2
  25. }