Skip to content

Commit

Permalink
Merge pull request #1225 from jolocom/feature/#1222-demo-ceredential-…
Browse files Browse the repository at this point in the history
…exchange

Feature/#1222 demo ceredential exchange
  • Loading branch information
chunningham authored Feb 18, 2019
2 parents 42cce76 + ac7e6d3 commit 6d6a768
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
15 changes: 13 additions & 2 deletions src/actions/payment/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,20 @@ export const clearPaymentRequest = () => {
}

export const cancelPaymentRequest = () => {
return (dispatch: Dispatch<AnyAction>) => {
return (dispatch: Dispatch<AnyAction>, getState: Function) => {
const { callbackURL } = getState().payment.activePaymentRequest
dispatch(clearPaymentRequest())
dispatch(navigationActions.navigatorReset({ routeName: routeList.Home }))

/**
* This needs to be cleaned up after demo
* TODO: consolidate routing back to callbackURL for deep linking for payment & sso
*/
if (callbackURL.includes('http')) {
dispatch(navigationActions.navigatorReset({ routeName: routeList.Home }))
} else {
const url = callbackURL + Buffer.from(JSON.stringify({token: false})).toString('base64')
Linking.openURL(url)
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/actions/sso/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,11 @@ interface AttributeSummary {

export const consumeCredentialRequest = (decodedCredentialRequest: JSONWebToken<CredentialRequest>) => {
return async (dispatch: Dispatch<AnyAction>, getState: Function, backendMiddleware: BackendMiddleware) => {
const { storageLib, identityWallet } = backendMiddleware
const { storageLib } = backendMiddleware
const { did } = getState().account.did.toJS()

try {
await identityWallet.validateJWT(decodedCredentialRequest)
// await identityWallet.validateJWT(decodedCredentialRequest)
const requestedTypes = decodedCredentialRequest.interactionToken.requestedCredentialTypes
const attributesForType = await Promise.all<AttributeSummary>(requestedTypes.map(storageLib.get.attributesByType))

Expand Down

0 comments on commit 6d6a768

Please sign in to comment.