How to use the did-jwt.verifyJWT function in did-jwt

To help you get started, we’ve selected a few did-jwt examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github 3box / 3box-js / src / utils / verifier.js View on Github external
export async function verifyTwitter (did, claim) {
  if (!claim) return null
  const verified = await didJWT.verifyJWT(claim)
  if (verified.payload.sub !== did) {
    throw new Error('Verification not valid for given user')
  }
  const claimData = verified.payload.claim
  if (!claimData.twitter_handle || !claimData.twitter_proof) {
    throw new Error('The claim for your twitter is not correct')
  }
  return {
    username: claimData.twitter_handle,
    proof: claimData.twitter_proof,
    verifiedBy: verified.payload.iss
  }
}
github 3box / muport-core-js / lib / muport.js View on Github external
return _regenerator2.default.wrap(function _callee6$(_context6) {
          while (1) {
            switch (_context6.prev = _context6.next) {
              case 0:
                return _context6.abrupt('return', didJWT.verifyJWT(jwt, { audience: audience }));

              case 1:
              case 'end':
                return _context6.stop();
            }
          }
        }, _callee6, this);
      }));
github uport-project / lambda-sensui / src / lib / authMgr.js View on Github external
async verifyDid(token){
        require('ethr-did-resolver')()
        return await verifyJWT(token)
    }
github uport-project / uport-credentials / src / Credentials.js View on Github external
async authenticateDisclosureResponse(token, callbackUrl = null) {
    const { payload, doc } = await verifyJWT(token, {
      audience: this.did,
      callbackUrl,
      auth: true,
    })

    if (payload.req) {
      const challenge = await verifyJWT(payload.req)
      if (challenge.payload.iss !== this.did) {
        throw new Error(`Challenge issuer does not match current identity: ${challenge.payload.iss} !== ${this.did}`)
      } else if (challenge.payload.type !== Types.DISCLOSURE_REQUEST) {
        throw new Error(`Challenge payload type invalid: ${challenge.payload.type}`)
      } else {
        return this.processDisclosurePayload({ payload, doc })
      }
    } else {
      throw new Error('Challenge was not included in response')
    }
  }
github uport-project / uport-credentials / src / Credentials.js View on Github external
      const verifying = verified.map(token => verifyJWT(token, {audience: this.did}).catch(() => {
        invalid.push(token)
        return Promise.resolve(null)
      }))
github 3box / muport-core-js / src / muport.js View on Github external
async verifyJWT (jwt, audience = this.did) {
    return didJWT.verifyJWT(jwt, {audience})
  }
github uport-project / uport-connect / src / Connect.js View on Github external
verifyResponse (token) {
    return verifyJWT(token, {audience: this.credentials.did}).then(res => {
      this.doc = res.doc
      return this.credentials.processDisclosurePayload(res)
    })
  }

did-jwt

Library for Signing and Verifying JWTs that use DIDs as issuers and JWEs that use DIDs as recipients

Apache-2.0
Latest version published 8 months ago

Package Health Score

80 / 100
Full package analysis

Similar packages