Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Philip Welber
committed
Jun 18, 2018
1 parent
ba5caa7
commit fe60899
Showing
5 changed files
with
84 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
packages/blockchain-wallet-v4-frontend/src/modals/SfoxExchangeData/sift-science.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import React, { Component } from 'react' | ||
import { connect } from 'react-redux' | ||
import { bindActionCreators } from 'redux' | ||
import { actions, selectors } from 'data' | ||
import { path } from 'ramda' | ||
|
||
class ISignThisContainer extends Component { | ||
constructor (props) { | ||
super(props) | ||
this.state = { enabled: false } | ||
} | ||
componentDidMount () { | ||
let receiveMessage = (e) => { | ||
const helperDomain = path(['domains', 'walletHelper'], this.propswalletOptions) | ||
if (!e.data.command) return | ||
if (e.data.from !== 'sift-science') return | ||
if (e.data.to !== 'exchange') return | ||
if (e.origin !== helperDomain) return | ||
switch (e.data.command) { | ||
case 'done': | ||
// Remove Sift Science iframe: | ||
this.props.sfoxFrontendActions.disableSiftScience() | ||
break | ||
default: | ||
return null | ||
} | ||
|
||
}; | ||
window.addEventListener('message', receiveMessage, false) | ||
} | ||
|
||
render () { | ||
const { options, userId, siftScienceEnabled } = this.props | ||
const walletOptions = options || path(['data'], this.props.walletOptions) | ||
const helperDomain = path(['domains', 'walletHelper'], walletOptions) | ||
const sfoxSiftScience = path(['platforms', 'web', 'sfox', 'config', 'siftScience'], walletOptions) | ||
|
||
let url = `${helperDomain}/wallet-helper/sift-science/#/key/${sfoxSiftScience}/user/${userId}` | ||
// url += scope.tradeId ? `/trade/${scope.tradeId}` : ''; | ||
|
||
if (userId) { | ||
return null | ||
} | ||
|
||
if (siftScienceEnabled) { | ||
return ( | ||
<iframe | ||
src={url} | ||
sandbox='allow-same-origin allow-scripts' | ||
scrolling='no' | ||
id='sift-science-iframe' | ||
/> | ||
) | ||
} | ||
} | ||
} | ||
|
||
const mapStateToProps = (state) => ({ | ||
walletOptions: path(['walletOptionsPath'], state), | ||
userId: selectors.core.kvStore.buySell.getSfoxUser(state), | ||
siftScienceEnabled: path(['sfoxSignup', 'siftScienceEnabled'], state) | ||
}) | ||
|
||
const mapDispatchToProps = (dispatch) => ({ | ||
sfoxFrontendActions: bindActionCreators(actions.modules.sfox, dispatch) | ||
}) | ||
|
||
export default connect(mapStateToProps, mapDispatchToProps)(ISignThisContainer) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters