old_contents: /**
   * Dependencies
   */
  const base64url = require('base64url')
  const JWA = require('./JWA')
  
  /**
   * JWS
   */
  class JWS {
  
    /**
     * decode
     *
     * @description
     * Decode a JSON Web Token
     *
     * @param {string} token
     * @param {CryptoKey} key
     *
     * @returns {Promise}
     */
    static decode (token, key) {
      let header, payload, algorithm, signature, data
  
      try {
        let components = JWS.extractComponents(token)
        header = JSON.parse(base64url.decode(components[0]))
        payload = JSON.parse(base64url.decode(components[0]))
        algorithm = header.alg
        signature = components[2]
        data = components.slice(0,2).join('.')
      } catch (error) {
        return Promise.reject(error)
      }
  
      return JWA.verify(algorithm, key, signature, data).then(verified => {
        let jws = null
  
        if (verified) {
          let extendedJWS = this
          jws = new extendedJWS(header, payload, signature)
        }
  
        return jws
      })
    }
  
    /**
     * encode
     *
     * @description
     * Encode a JSON Web Token
     *
     * @param {Object} header
     * @param {Object} payload
     * @param {CryptoKey} key
     *
     * @returns {Promise}
     */
    static encode (header, payload, key) {
      let jws = new JWS(header, payload)
      return jws.encode(key)
    }
  
    /**
     * sign
     *
     * @description
     * Encode a JWT instance
     *
     * @param {Object} token
     * @returns {Promise}
     */
    static sign (token) {
      let payload = base64url(JSON.stringify(token.payload))
  
      // compact serialization
      if (token.serialization === 'compact') {
        let {key, header: {alg}} = token
        let header = base64url(JSON.stringify(token.header))
        let data = `${header}.${payload}`
  
        return JWA.sign(alg, key, data).then(signature => `${data}.${signature}`)
      }
  
      // JSON serialization
      if (token.serialization === 'json') {
  
      }
  
      // Flattened serialization
      if (token.serialization === 'flattened') {
  
      }
  
      throw new DataError('Unsupported serialization')
    }
  }
  
  /**
   * Export
   */
  module.exports = JWS
  
new_contents: /**
   * Dependencies
   */
  const base64url = require('base64url')
  const JWA = require('./JWA')
  
  /**
   * JWS
   */
  class JWS {
  
    /**
     * sign
     *
     * @description
     * Encode a JWT instance
     *
     * @param {Object} token
     * @returns {Promise}
     */
    static sign (token) {
      let payload = base64url(JSON.stringify(token.payload))
  
      // compact serialization
      if (token.serialization === 'compact') {
        let {key, header: {alg}} = token
        let header = base64url(JSON.stringify(token.header))
        let data = `${header}.${payload}`
  
        return JWA.sign(alg, key, data).then(signature => `${data}.${signature}`)
      }
  
      // JSON serialization
      if (token.serialization === 'json') {
  
      }
  
      // Flattened serialization
      if (token.serialization === 'flattened') {
  
      }
  
      throw new DataError('Unsupported serialization')
    }
  
    /**
     * verify
     */
    static verify (jwt) {
      // multiple signatures
      if (jwt.signatures) {
        // ...
      }
  
      // one signature
      if (jwt.signature) {
        let header = base64url(JSON.stringify(jwt.header))
        let payload = base64url(JSON.stringify(jwt.payload))
        let data = `${header}.${payload}`
        let {key, signature, header: {alg}} = jwt
  
        return JWA.verify(alg, key, signature, data)
      }
  
      // no signatures to verify
      return Promise.reject(new DataError('Missing signature(s)'))
    }
  }
  
  /**
   * Export
   */
  module.exports = JWS
  
subject: verify method (compact serialization)