Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
}
})
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))
}
}
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))
}
}
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 })
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 })
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
})
}).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')
isClaim: async (claim, opts = {}) => {
try {
await didJWT.decodeJWT(claim, opts)
return true
} catch (e) {
return false
}
},
}).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))
})
})