validate()

in lib/token.js [19:43]


   validate(token) {
      let decoded;
      if (token) decoded = this.set(token);
      if (!decoded) return false;
      this.errors = [];
      if (this.isExpired) this.setError('TOKEN EXPIRED', {token});
      const nonce = getNonce(this.url);
      const mismatchedNonce = !nonce || nonce != this.payload.nonce;
      if (mismatchedNonce) this.setError('NONCE MISMATCH',{
         given: this.payload.nonce,
         actual: nonce
      });
      const mismatchedAud = !this.url || this.url != this.payload.aud;
      if (mismatchedAud) this.setError('AUD MISMATCH', {
         given: this.payload.aud,
         actual: this.url
      });
      const mismatchedIss = !this.provider || this.provider != this.payload.iss;
      if (mismatchedIss) this.setError('ISS MISMATCH', {
         given: this.payload.iss,
         actual: this.provider
      });
      const isValid = this.errors.length ? false : true;
      return isValid;
   }