From 3824d9f4db68c44ef21b76a5777ee6502eb64f68 Mon Sep 17 00:00:00 2001 From: DennisHouterman Date: Thu, 9 May 2019 15:52:30 +0200 Subject: [PATCH] Read from QR-string in wallet and write to screen --- validator-frontend/screens/ScanScreen.js | 10 +++- validator-frontend/screens/WalletScreen.js | 69 ++++++++-------------- 2 files changed, 33 insertions(+), 46 deletions(-) diff --git a/validator-frontend/screens/ScanScreen.js b/validator-frontend/screens/ScanScreen.js index cc8a36a..1a43092 100644 --- a/validator-frontend/screens/ScanScreen.js +++ b/validator-frontend/screens/ScanScreen.js @@ -22,7 +22,7 @@ class ScanScreen extends React.Component { async componentDidMount() { const { status } = await Permissions.askAsync(Permissions.CAMERA); this.setState({ hasCameraPermission: status === 'granted' }); - } + } _storeData = async (data) => { try { @@ -52,6 +52,8 @@ class ScanScreen extends React.Component { } handleBarCodeScanned = ({ type, data }) => { + this._storeData(data) + console.log(data); this.props.navigation.navigate('Validating', {qrString: data}) } } @@ -102,6 +104,12 @@ class ValidatingScreen extends Component { ' eyB5 ' + ' -----END CERTIFICATE----- ' + ' ' ; + let documentJson = JSON.parse(qrString); + let claimWithLink = Object.values(documentJson)[0][0]; + let claimData = Object.values(claimWithLink)[0]; + let tempdata = claimData[0]; + let moredata = Object.values(tempdata)[0]; + console.log(moredata); paperWallet.getCore().registerConnector('ephemeral', new EphemeralConnector()) let attestorSsid = await (await paperWallet.getCore().getConnector('ephemeral')).newIdentity({'cert': cert}) let validatorSsid = await paperWallet.getCore().newSsid('ephemeral') diff --git a/validator-frontend/screens/WalletScreen.js b/validator-frontend/screens/WalletScreen.js index b61f3de..165a90b 100644 --- a/validator-frontend/screens/WalletScreen.js +++ b/validator-frontend/screens/WalletScreen.js @@ -30,8 +30,6 @@ class WalletScreen extends React.Component { {item.key} - - @@ -46,53 +44,23 @@ class UitrekselScreen extends Component { static navigationOptions = { headerTitle: 'Uitreksel screen', }; + + constructor(props){ + super(props) + this.state = {} + } + + async componentDidMount() { + let displayData = await this._readData(); + this.setState({displayData: displayData}) + }; + _retrieveData = async () => { try { const value = await AsyncStorage.getItem("BRP1"); if (value !== null) { - let cert = ' -----BEGIN CERTIFICATE----- ' + - ' MIIFzzCCA7egAwIBAgIUBDAnPgMV5iH+LkMfm6h5E8jWVOswDQYJKoZIhvcNAQEN ' + - ' BQAwXzELMAkGA1UEBhMCTkwxFjAUBgNVBAgTDU5vb3JkLUhvbGxhbmQxEjAQBgNV ' + - ' BAcTCUFtc3RlcmRhbTEWMBQGA1UEChMNQ29tbW9uIEdyb3VuZDEMMAoGA1UECxMD ' + - ' TkxYMB4XDTE5MDExMDEyMTIwMFoXDTIwMDExMDEyMTIwMFowYzELMAkGA1UEBhMC ' + - ' TkwxFTATBgNVBAgTDFp1aWQtSG9sbGFuZDERMA8GA1UEBxMIRGVuIEhhYWcxDTAL ' + - ' BgNVBAoTBElDVFUxGzAZBgNVBAsTElN5c3RlbSBUZXN0IFRyYXZpczCCAiIwDQYJ ' + - ' KoZIhvcNAQEBBQADggIPADCCAgoCggIBAK/9d/G5sOy4JQ6mqp/YG/jRo5KFytLe ' + - ' K4i5sIPFviP9TixolyF1YrrVpOvYtJOI7mVcfsSuNvB4WRX4zMw559oLH1WOBfye ' + - ' Tr3Y1t8uGNlb0v0nqN/DDpT9LyFm+rMw/AiA3XwInPPB80cZ6jOoABb2KX/MJj3D ' + - ' 4AS0osnW9uY91iYsyMXiCaEl84f/MMXQLGgRfK9PKLbWGIm0OJVScOtz3ZuppK9N ' + - ' VIJWnhVpJZciVUhlb3b2uxM8oAz7WcuayUv1tlKrxSMnG3/Bhm7HfuF9jhmUoiOH ' + - ' N7rOSCWlOL5YB9rz+I4kQFe/g2gOVWk1jPk1N8Fa+R57Hdcn12zCD91zVGCZH23x ' + - ' 2SirPHauhvetrsbNwMyQDXeA7pM5f3mLqavMGb55m8VHl1hA+nbwvIOEBwlSTvLu ' + - ' 9ajM7tS8rm8Pic2g5eJM2klArdkrvtdW6RAK33TbsqTKZl+/IxUppZah5X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z79zhlaWTbdLMpW6VdgQty3Ua9LEOuKzK2dSsPrd4YEXSc4AywuqJ ' + - ' 5sdnzFa4dJKrDcBws5JmetneJpaote4Hqicj5t4leOutIFFwb7J/8xDzpc9qgFvE ' + - ' eyB5 ' + - ' -----END CERTIFICATE----- ' + - ' ' ; // We have data!! - console.log(value); - paperWallet.getCore().registerConnector('ephemeral', new EphemeralConnector()) - let attestorSsid = await (await paperWallet.getCore().getConnector('ephemeral')).newIdentity({'cert': cert}) - let validatorSsid = await paperWallet.getCore().newSsid('ephemeral') - console.log("I was Here") - let result = await paperWallet.validate(attestorSsid.did, value, validatorSsid.did) - console.log(result) + return value; } else if (value == null) { console.log("value was null") @@ -102,7 +70,18 @@ class UitrekselScreen extends Component { } } + _readData = async () => { + let displayData = await this._retrieveData(); + let documentJson = JSON.parse(displayData); + let claimWithLink = Object.values(documentJson)[0][0]; + let claimData = Object.values(claimWithLink)[0]; + let tempdata = claimData[0]; + let moredata = Object.values(tempdata)[0]; + return moredata; + } + render() { + const displayData = this.state.displayData; return ( this._retrieveData()}> - {item.key} + {displayData}