Skip to content

Commit

Permalink
feat(Jumio): parse postMessage and continue flow
Browse files Browse the repository at this point in the history
  • Loading branch information
plondon committed Jul 20, 2018
1 parent bd7722c commit c9965b5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react'
import { connect } from 'react-redux'
import { bindActionCreators, compose } from 'redux'
import { path } from 'ramda'
import { actions } from 'data'

import { getData } from './selectors'
Expand All @@ -12,8 +13,20 @@ class JumioContainer extends React.PureComponent {
this.onFinish = this.onFinish.bind(this)
}

componentWillMount () {
componentDidMount () {
this.props.sfoxActions.getJumioToken()

let receiveMessage = e => {
const jumioWhitelist = ['done']
if (!e.data.command) return
if (e.data.from !== 'jumio') return
if (e.data.to !== 'exchange') return
if (e.origin !== this.props.jumioBaseUrl) return
if (jumioWhitelist.indexOf(e.data.command) < 0) return

if (e.data.command === 'done') this.onFinish()
}
window.addEventListener('message', receiveMessage, false)
}

onFinish () {
Expand Down Expand Up @@ -42,7 +55,11 @@ class JumioContainer extends React.PureComponent {
}

const mapStateToProps = state => ({
data: getData(state)
data: getData(state),
jumioBaseUrl: path(
['walletOptionsPath', 'data', 'domains', 'walletHelper'],
state
)
})

const mapDispatchToProps = dispatch => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,9 @@ const JumioFrame = styled.iframe`
border-style: solid;
border-color: ${props => props.theme['gray-1']};
`
const LinkContainer = styled.div`
width: 80%;
margin-top: 5px;
text-align: right;
`
const Link = styled.span`
cursor: pointer;
font-size: 13px;
text-decoration: underline;
color: ${props => props.theme['brand-secondary']};
`

const Success = props => {
const { options, token, onFinish } = props
const { options, token } = props
const { authorizationToken } = token
const walletHelperRoot = path(['domains', 'walletHelper'], options)
const jumioUrl = `${walletHelperRoot}/wallet-helper/jumio/#/key/${authorizationToken}`
Expand All @@ -42,9 +31,6 @@ const Success = props => {
scrolling='yes'
id='jumio'
/>
<LinkContainer>
<Link onClick={onFinish}>Next</Link>
</LinkContainer>
</Container>
)
}
Expand Down

0 comments on commit c9965b5

Please sign in to comment.