How to use the did-jwt.decodeJWT 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 gluon-project / gluon-rxp / src / Sagas / ClaimsSaga.ts View on Github external
forEach(json.claims, (jwt: string) => {
        try {
          const decodedClaim = decodeJWT(jwt)
          if (decodedClaim) {
            const signedClaim: VerifiableClaim = {
              ...decodedClaim.payload,
              jwt,
              source: {
                type: 'matrix',
                id: roomId,
              },
            }
            result.push(signedClaim)
          }
        } catch (e) {
          // invalid jwt
        }

      })
github uport-project / uport-connect / src / Connect.js View on Github external
const parseResponse = (res) => {
      if (res.error) return Promise.reject(Object.assign({id}, res))
      if (message.util.isJWT(res.payload)) {
        const jwt = res.payload
        const decoded = decodeJWT(jwt)
        if (decoded.payload.claim){
          return Promise.resolve(Object.assign({id}, res))
        }
        return this.verifyResponse(jwt).then(parsedRes => {
          // Set identifiers present in the response
          // TODO maybe just change name in uport-js
          if (parsedRes.boxPub) parsedRes.publicEncKey = parsedRes.boxPub
          this.setState(parsedRes)
          return {id, payload: parsedRes, data: res.data}
        })
      } else {
        return Promise.resolve(Object.assign({id}, res))
      }
    }
github uport-project / uport-connect / src / Connect.js View on Github external
const parseResponse = (res) => {
      if (res.error) return Promise.reject(Object.assign({id}, res))
      if (message.util.isJWT(res.payload)) {
        const jwt = res.payload
        const decoded = decodeJWT(jwt)
        if (decoded.payload.claim){
          return Promise.resolve(Object.assign({id}, res))
        }
        return this.verifyResponse(jwt).then(parsedRes => {
          // Set identifiers present in the response
          // TODO maybe just change name in uport-js
          if (parsedRes.boxPub) parsedRes.publicEncKey = parsedRes.boxPub
          this.setState(parsedRes)
          return {id, payload: parsedRes, data: res.data}
        })
      } else {
        return Promise.resolve(Object.assign({id}, res))
      }
    }
github uport-project / uport-connect / test / unit / Connect.js View on Github external
const transport = (uri, opts) => {
        const jwt = message.util.getURLJWT(uri)
        const decoded = didjwt.decodeJWT(jwt)
        expect(/chasqui/.test(decoded.payload.callback)).to.be.true
        done()
      }
      const uport = new Connect('testApp', { transport, vc })
github uport-project / uport-connect / test / unit / Connect.js View on Github external
const send = (uri) => {
        const jwt = getURLJWT(uri)
        const decoded = didjwt.decodeJWT(jwt)
        expect(decoded.payload.to).to.equal('2ooE3vLGYi9vHmfYSc3ZxABfN5p8756sgi6')
        done()
      }
      const uport = new Connect('testApp', { vc })
github gluon-project / gluon-rxp / src / Selectors / ContactsSelectors.ts View on Github external
const claims = _.map(encodedClaims, (jwt: string) => {
    let result: VerifiableClaim = null
    try {
      const decodedClaim = decodeJWT(jwt)
      result = {
        ...decodedClaim.payload,
        jwt,
      }
    } catch (e) {
      console.log(e)
    }
    return result
  })
github uport-project / uport-credentials / examples / createcredential.js View on Github external
}).then(att => {
      messageLogger(att, 'Encoded Attestation Sent to User (Signed JWT)')
      messageLogger(decodeJWT(att), 'Decoded Attestation Payload of Above')
      return push(att)
    }).then(res => {
      messageLogger('Push notification with attestation sent, will recieve on client in a moment')
github 3box / 3box-js / src / utils / id.js View on Github external
isClaim: async (claim, opts = {}) => {
    try {
      await didJWT.decodeJWT(claim, opts)
      return true
    } catch (e) {
      return false
    }
  },
github uport-project / uport-credentials / examples / requestcredential.js View on Github external
}).then(requestToken => {
    const uri = message.paramsToQueryString(message.messageToURI(requestToken), {callback_type: 'post'})
    messageLogger(requestToken, 'Encoded Request URI to send to uPort Client (Signed JWT Wrapped with URI)')
    messageLogger(decodeJWT(requestToken), 'Decoded Request Token')
    const qr =  transports.ui.getImageDataURI(uri)
    res.send(htmlTemplate(qr, uri))
  })
})

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 9 months ago

Package Health Score

75 / 100
Full package analysis

Similar packages