   [data]
   (into {} (map (fn [[key val]]
                   (if (satisfies? util/ITimestamp val)
-                    [key (to-timestamp val)]
+                    [key (util/to-timestamp val)]
                     [key val])) data)))
 
 (defn normalize-nil-claims

  and verification, it will be reported in an
  either/left instance."
  [input pkey & [{:keys [max-age] :as opts}]]
  {:pre [(string? input)]}
  (let [[header claims signature] (str/split input #"\." 3)
        candidate (str/join "." [header claims])
        header (parse-header header)
        claims (parse-claims claims)
        algorithm (parse-algorithm header)
        signature (codecs/safebase64->bytes signature)
        verifier (get-verifier-for-algorithm algorithm)
        result (verifier candidate signature pkey)]
    (if (false? result)
      (either/left "Invalid token.")
      (let [now (timestamp)]
        (cond
          (and (:exp claims) (> now (:exp claims)))
          (either/left (format "Token is older than :exp (%s)" (:exp claims)))

          (and (:nbf claims) (> now (:nbf claims)))
          (either/left (format "Token is older than :nbf (%s)" (:nbf claims)))

          (and (:iat claims) (number? max-age) (> (- now (:iat claims)) max-age))
          (either/left (format "Token is older than max-age (%s)" max-age))

          :else
          (either/right claims))))))

(defn sign
  "Not monadic version of encode."
  [& args]
  (either/from-either (apply encode args)))

(defn unsign
  "Not monadic version of decode."
  [& args]
  (let [result (apply decode args)]
    (when (either/right? result)
      (either/from-either result))))


(defn parse-header
  "Parse jws header."
  [^String header]
  (let [header (codecs/safebase64->str header)
        {:keys [alg] :as header} (json/parse-string header true)]
    (when (nil? alg)
      (throw+ {:type :validation
               :cause :header
               :message "Missing `alg` key in header."}))
    (merge {:alg (keyword (str/lower-case alg))}
           (dissoc header :alg))))

(defn parse-claims
  "Parse jws claims"
