lib/jwt.js
function sign (input, algorithm, secret) {
  const alg = algorithmMap[algorithm]

  if (!alg) {
    throw new Error(errorMap['002'].message)
  }

  const type = typeMap[algorithm]
  let signature

  switch (type) {
    case 'hmac':
      signature = hmacSign(input, alg, secret)
      break
    case 'sign':
      signature = rsaSign(input, alg, secret)
      break
    default:
      signature = hmacSign(input, alg, secret)
      break
  }

  return signature
}
function sign (input, algorithm, secret) {
  const alg = algorithmMap[algorithm]

  if (!alg) {
    throw new Error(errorMap['002'].message)
  }

  const type = typeMap[algorithm]
  let signature

  switch (type) {
    case 'hmac':
      signature = hmacSign(input, alg, secret)
      break
    case 'sign':
      signature = rsaSign(input, alg, secret)
      break
    default:
      signature = hmacSign(input, alg, secret)
      break
  }

  return signature
}
sign abstract method
@param  {String} input     sign input
@param  {String} algorithm sign algorithm
@param  {String} secret    sign secret
@return {String}           signature