Skip to content
This repository has been archived by the owner on Sep 3, 2021. It is now read-only.

Commit

Permalink
Merge pull request #124 from felleslosninger/structure
Browse files Browse the repository at this point in the history
Structure
  • Loading branch information
junibugge authored Aug 5, 2021
2 parents 5787e27 + 5dff218 commit 97e58b8
Show file tree
Hide file tree
Showing 25 changed files with 128 additions and 204 deletions.
4 changes: 2 additions & 2 deletions wallet/wallet-app/App.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react';
import { Provider } from 'react-redux';
import { LogBox } from 'react-native';
import store from './redux/configureStore';
import AppWrapper from './AppWrapper';
import store from './src/redux/configureStore';
import AppWrapper from './src/AppWrapper';

export default function App() {
LogBox.ignoreAllLogs(true);
Expand Down
120 changes: 54 additions & 66 deletions wallet/wallet-app/DOCUMENTATION.md
Original file line number Diff line number Diff line change
@@ -1,117 +1,105 @@
## Components
Components
----------

**App.js**
**src\components\frames\Onboarding.jsx**

### 1. App
### 1. Onboarding

---

**components\ConsentButton.jsx**

### 1. ConsentButton

Toggle button that changes between true/false depending on if you want/not want to share information
@returns Toggle button and text describing the status of the button (boolean)
-----
**src\components\frames\ProfileMenu.jsx**

---
### 1. ProfileMenuSlide

**components\Proof.jsx**
A profile site for administrativ changes on the profile
@returns A new site, A logout button and a delete button

### 1. Proof

A proof object/card with info about the issuer, validity, shared with and deletion option.
@param {string} props
From the ProofOverviewFrame a proof object is sent with corresponding prop values.
@returns A proof card/object

---

**components\QRcode.jsx**
-----
**src\components\frames\ProofOverviewFrame.jsx**

### 1. CreateQR
### 1. ProofOverviewFrame

A frame with an overview of every proof the wallet has
@returns

Making a QR code that takes in a jwt string that will be the information in the QR code
@param {string} props
@returns qr code containing string information (string: jwt)

---

**components\Verifier.jsx**

### 1. Verifier
-----
**src\components\frames\RequestFrame.jsx**

A card for a verifier
(VerifierLogFrame shows all Verifier cards that belong to a proof)
@param {string} props props is from VerifierLogFrame with corresponding props
@returns A card for a verifier
### 1. RequestFrame

---
Page to request new proof, retrieve and save new proof
@returns Buttons and menus to select the issuer and type of proof

**components\frames\VerifyFrame.jsx**

### 1. VerifyFrame

A frame with a botton to send proof to a verifier if you choose to share
@returns A frame, sending the proof

---
-----
**src\components\frames\StartPage.jsx**

**components\frames\Onboarding.jsx**
### 1. StartPage

### 1. Onboarding
The intro page to the app, choose between log in or create a user
@returns Two buttons/options: "access control" or "create user"

Here we are going to add the onboarding
@returns

---

**components\frames\ProofOverviewFrame.jsx**

### 1. ProofOverviewFrame
-----
**src\components\frames\VerifierLogFrame.jsx**

A frame with an overview of every proof the wallet has
@returns
### 1. VerifierLogFrame

Page with an overview of which verifiers who have access to a specific proof
@param {proof} param0 a spesific proof
@returns Page with a list of all verifiers a proof is shared with

---

**components\frames\RequestFrame.jsx**

### 1. RequestFrame

Page to request new proof, retrieve and save new proof
@returns Buttons and menus to select the issuer and type of proof
-----
**src\components\frames\VerifyFrame.jsx**

---
### 1. VerifyFrame

**components\frames\StartPage.jsx**
A frame with a botton to send proof to a verifier if you choose to share
@returns A frame, sending the proof

### 1. StartPage

The intro page to the app, choose between log in or create a user
@returns Two buttons/options: "access control" or "create user"

---

**components\frames\VerifierLogFrame.jsx**
-----
**src\components\other\QRCode.jsx**

### 1. VerifierLogFrame
### 1. CreateQR

Page with an overview of which verifiers who have access to a specific proof
@param {proof} param0 a spesific proof
@returns Page with a list of all verifiers a proof is shared with
Making a QR code that takes in a jwt string that will be the information in the QR code
@param {string} props
@returns qr code containing string information (string: jwt)

---

**utils\storage\StorageExample.jsx**

### 1. Storage

---
-----
**src\components\views\ProofView.jsx**

### 1. Proof

A proof object/card with info about the issuer, validity, shared with and deletion option.
@param {string} props
From the ProofOverviewFrame a proof object is sent with corresponding prop values.
@returns A proof card/object


**utils\storage\WriteToFile.jsx**

### 1. RequestFrame

---
-----

<sub>This document was generated by the <a href="https://github.com/marborkowski/react-doc-generator" target="_blank">**React DOC Generator v1.2.5**</a>.</sub>
3 changes: 2 additions & 1 deletion wallet/wallet-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web",
"eject": "expo eject"
"eject": "expo eject",
"doc": "react-doc-generator ./src -o DOCUMENTATION.md"
},
"dependencies": {
"@ant-design/icons": "^4.6.2",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
/* eslint-disable react/prop-types */
// import 'react-native-gesture-handler';
import React from 'react';
import { useSelector } from 'react-redux';
import Icon from 'react-native-vector-icons/FontAwesome';

// import Test from './components/test'
// import { generateKeyPair, signing } from './utils/signing';
// import {sign} from './utils.sign';
// import { signDemo } from './utils/sign' ;
import { NavigationContainer } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import React, { useState, useEffect } from 'react';
import { View, StyleSheet, Button, TouchableOpacity } from 'react-native';
import { View, StyleSheet, Button, SafeAreaView } from 'react-native';
import { BarCodeScanner } from 'expo-barcode-scanner';
import jwtDecode from 'jwt-decode';
import AsyncStorage from '@react-native-async-storage/async-storage';
import { useNavigation } from '@react-navigation/native';
import { Text } from 'react-native-ui-lib';
import SafeAreaView from 'react-native-safe-area-view';
import Icon from 'react-native-vector-icons/FontAwesome';
import { useDispatch, useSelector } from 'react-redux';
import Spinner from 'react-native-loading-spinner-overlay';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-alert */
import React, { useState } from 'react';
import Icon from 'react-native-vector-icons/FontAwesome';
import { SafeAreaView, View, StyleSheet, Alert, Platform } from 'react-native';
Expand All @@ -7,7 +8,6 @@ import AsyncStorage from '@react-native-async-storage/async-storage';
import jwtDecode from 'jwt-decode';
import { Button, Text } from 'react-native-ui-lib';
import { signIn } from '../../redux/SignedInSlice';
import { getWalletID } from '../../utils/sign';

/**
* A profile site for administrativ changes on the profile
Expand All @@ -29,7 +29,6 @@ export default function ProfileMenuSlide() {

const getWalletId = async () => {
const walletId = await AsyncStorage.getItem('walletID');
console.log(walletId);
setWalletID(walletId);
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-alert */
/* eslint-disable no-unused-expressions */
import React, { useState, useEffect } from 'react';
import { SafeAreaView, StyleSheet, View } from 'react-native';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/* eslint-disable react/prop-types */
import React from 'react';
import { View } from 'react-native';
import SafeAreaView from 'react-native-safe-area-view';
import { useSelector, useDispatch } from 'react-redux';
import { useNavigation } from '@react-navigation/native';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
/* eslint-disable no-plusplus */
/* eslint-disable no-alert */
import React, { useState } from 'react';
import { View, StyleSheet, Alert } from 'react-native';
import SafeAreaView from 'react-native-safe-area-view';
import { useDispatch, useSelector } from 'react-redux';
import { BarCodeScanner } from 'expo-barcode-scanner';
import { useNavigation } from '@react-navigation/native';
import { Text } from 'react-native-ui-lib';
import Icon from 'react-native-vector-icons/FontAwesome';
import { addCredentialShare } from '../../redux/CredentialShareSlice';
Expand All @@ -15,11 +16,9 @@ import createVerifiablePresentationJWT from '../../utils/sign';
* @returns A frame, sending the proof
*/
export default function VerifyFrame() {
const [status, setStatus] = useState(false);
const [scanned, setScanned] = useState(false);

const dispatch = useDispatch();
const navigation = useNavigation();
const { cred } = useSelector((state) => state.credentials);

async function sendPresentation(creds, audience, user) {
Expand All @@ -41,7 +40,6 @@ export default function VerifyFrame() {
} else {
alert('Bevis ble ikke sendt');
}
setStatus(verified);
return verified;
}

Expand All @@ -51,7 +49,6 @@ export default function VerifyFrame() {
const vc = data.split('|')[1];

const userID = data.split('|')[2];
console.log(userID);
let proof = '';
for (let i = 0; i < cred.length; i++) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default function CreateQR(props) {
color="#1e2b3c"
backgroundColor="white"
// eslint-disable-next-line global-require
logo={require('../../assets/digdir-logo.jpg')} // digdir logo in the middle :)
logo={require('../../../assets/digdir-logo.jpg')} // digdir logo in the middle :)
logoSize={30} // 32 is also good
/>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,5 @@
import { createSlice } from '@reduxjs/toolkit';

/*
const credentialsReducer = createReducer([], (builder) => {
builder
.addCase('ADD_CREDENTIAL', (state, action) => {
state.push(action.payload);
})
.addCase('REMOVE_CREDENTIAL', (state, action) => {
return filter((credential, i) => i !== action.payload.index);
});
});
*/
export const credentialSlice = createSlice({
name: 'credentials',
initialState: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import forge from 'node-forge';

import AsyncStorage from '@react-native-async-storage/async-storage';
import uuid from 'react-native-uuid';
import { exampleCredentialToken, httpPostPublicKey } from './httpRequests';
import { httpPostPublicKey } from './httpRequests';

export async function generateKeys() {
// Generates a RSA keypair, should perhaps be moved to global state
console.log('keys generating...');
const walletID = `wallet-id${uuid.v4()}`;
await AsyncStorage.setItem('walletID', walletID);
const keys = forge.pki.rsa.generateKeyPair(1024);
Expand Down
63 changes: 63 additions & 0 deletions wallet/wallet-app/src/utils/storage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/* eslint-disable no-alert */
import AsyncStorage from '@react-native-async-storage/async-storage';

export const saveProof = async (cred) => {
if (cred.jti !== undefined) {
try {
await AsyncStorage.setItem(cred.jti, cred.token);
return true;
} catch (error) {
alert(error);
}
}
return false;
};

/**
* Adds the keys and the associated information into a list
*/
export const getProofs = async (keys) => {
const proofs = [];
try {
keys.forEach(async (key) => {
const value = await AsyncStorage.getItem(key);
if (value !== null) {
if (!proofs.some((item) => item.id === key)) {
// Makes sure that there are no duplicates
proofs.push({ id: key, proof: value });
// dispatch(addCredential(JSON.parse(value)));
}
}
});
} catch (error) {
alert(error);
}
return proofs;
};

/**
* Gets all the proof keys in AsyncStorage
* Adds the keys into a list
*/
export const getProofKeys = async () => {
const keys = [];
try {
const allKeys = await AsyncStorage.getAllKeys();
if (allKeys !== null) {
allKeys.forEach((key) => {
if (
!keys.includes(key) &&
key !== 'pin' &&
key !== 'baseId' &&
key !== 'privateKey' &&
key !== 'walletID'
) {
keys.push(key);
}
});
}
} catch (error) {
alert(error);
}
return keys;
};
Loading

0 comments on commit 97e58b8

Please sign in to comment.