Skip to content

Commit

Permalink
Read from QR-string in wallet and write to screen
Browse files Browse the repository at this point in the history
  • Loading branch information
DennisHouterman committed May 9, 2019
1 parent c8b782a commit 3824d9f
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 46 deletions.
10 changes: 9 additions & 1 deletion validator-frontend/screens/ScanScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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})
}
}
Expand Down Expand Up @@ -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')
Expand Down
69 changes: 24 additions & 45 deletions validator-frontend/screens/WalletScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ class WalletScreen extends React.Component {

<View>
<Text style={styles.item}>{item.key}</Text>
<Octicons name="verified" size={48} color="#33ff33" />
<Octicons name="alert" size={48} color="#FF0000" />
</View>

</TouchableWithoutFeedback>
Expand All @@ -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+/IxUppZah5XbAdljp ' +
' 2Q6cFmpvcGSwVBfk2Av9XD8ggpZ9L6+ph2k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a4dJKrDcBws5JmetneJpaote4Hqicj5t4leOutIFFwb7J/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")
Expand All @@ -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 (
<View style={styles.container}>
<FlatList
Expand All @@ -114,7 +93,7 @@ class UitrekselScreen extends Component {
<TouchableWithoutFeedback onPress={ () => this._retrieveData()}>

<View>
<Text style={styles.item}>{item.key}</Text>
<Text style={styles.item}>{displayData}</Text>
</View>

</TouchableWithoutFeedback>
Expand Down

0 comments on commit 3824d9f

Please sign in to comment.