 (defn unsign
   "Given a signed message, verify it and return
   the decoded claims."
-  [input pkey & [{:keys [max-age] :as opts}]]
-  (let [[header claims signature] (str/split input #"\." 3)
-        {:keys [alg]} (parse-header header)
-        signature (codecs/safebase64->bytes signature)]
+  ([input pkey] (unsign input pkey {}))
+  ([input pkey opts]
+   (let [[header claims signature] (str/split input #"\." 3)
+         {:keys [alg]} (parse-header header opts)
+         signature (codecs/safebase64->bytes signature)]
     (when-not (verify-signature {:key pkey :signature signature
                                  :alg alg :header header :claims claims})
       (throw+ {:type :validation :cause :auth :message "Message seems corrupt or manipulated."}))
-    (let [claims (parse-claims claims)
-          now (util/timestamp)]
-      (cond
-        (and (:exp claims) (> now (:exp claims)))
-        (throw+ {:type :validation
-                 :cause :exp
-                 :message (format "Token is older than :exp (%s)" (:exp claims))})
-
-        (and (:nbf claims) (> now (:nbf claims)))
-        (throw+ {:type :validation
-                 :cause :nbf
-                 :message (format "Token is older than :nbf (%s)" (:nbf claims))})
-
-        (and (:iat claims) (number? max-age) (> (- now (:iat claims)) max-age))
-        (throw+ {:type :validation
-                 :cause :max-age
-                 :message (format "Token is older than max-age (%s)" max-age)})
-
-        :else claims))))
+    (parse-claims claims opts))))
 
 (defn encode
   "Sign arbitrary length string/byte array using

        (codecs/str->bytes)
        (codecs/bytes->safebase64))))

(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 :parse :cause :header :message "Missing `alg` key in header."}))
    (merge {:alg (keyword (str/lower-case alg))}
           (dissoc header :alg))))

(defn parse-claims
  "Parse jws claims"
  [^String claimsdata]
  (-> claimsdata
      (codecs/safebase64->bytes)
      (codecs/bytes->str)
      (json/parse-string true)))

(defn- calculate-signature
  "Given the bunch of bytes, a private key and algorithm,

(defn sign
  "Sign arbitrary length string/byte array using
  json web token/signature."
  ;; The exp nbf and iat keys in the options are deprecated
  ;; and will be removed in the next version.
  [claims pkey & [{:keys [alg typ] :or {alg :hs256 typ :jws} :as opts}]]
  {:pre [(map? claims)]}
  (let [header (encode-header alg typ)
        claims (encode-claims claims opts)
        signature (calculate-signature {:key pkey
                                        :alg alg
                                        :header header
