Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a "Delete All" option from Wallet page #17

Open
varadgit opened this issue Jul 8, 2021 · 16 comments
Open

Add a "Delete All" option from Wallet page #17

varadgit opened this issue Jul 8, 2021 · 16 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@varadgit
Copy link
Contributor

varadgit commented Jul 8, 2021

When a user sets up a new Fabric Test network the old identities that are stored as part of Local Storage aren't valid anymore. Need an easy way to clear all the current Identities from wallet.

I think for this particular use case where new components are imported where the wallet items are stale, we can keep the functionally in settings area. Something like the following screen
image

and when the user click on the button open up the side panel with a text something like "Are you sure you want to delete all items from Wallet? Enter "Delete All" to proceed.
Add a "Delete All" button that will get enabled only after entering the text "Delete All" in the text box to remove the items from local storage.

You should be able to see the side panel pattern in a lot of places. You would add the button here...
https://github.com/hyperledger-labs/fabric-operations-console/blob/main/packages/apollo/src/components/Settings/Settings.js#L467

You should be able to follow the "Import" button pattern to put up a side panel with the message and a prompt.

Add a method in the following file clearAllIdentities
https://github.com/hyperledger-labs/fabric-operations-console/blob/main/packages/apollo/src/rest/IdentityApi.js
delete the following two keys for the currently logged in user
image

You can use the following method to get an idea of the keys
IdentityApi.getKey();

@varadgit varadgit added the good first issue Good for newcomers label Jul 8, 2021
@alexcfyung
Copy link
Contributor

I would like to work on this issue

@varadgit
Copy link
Contributor Author

varadgit commented Sep 29, 2021

@alexcfyung thanks for your interest!

updated the description with what we might want to do

@alexcfyung
Copy link
Contributor

alexcfyung commented Oct 8, 2021

@varadgit thanks for the added detail! Just curious would a feature to switch network like in metamask be useful in this situation? so the user can switch network without removing all the wallet? or the console only support 1 concurrent network?

@varadgit
Copy link
Contributor Author

varadgit commented Oct 8, 2021

Well, network is slightly an overused term in some cases. From console perspective, you can have unrelated peers/orderers imported into the same console. We have talked about tagging the different components to get some sort of logical view of a network. You could tag the peer, orderers and CAs that are related so that you can filter the view based on you need. But that's a new feature. Let me know if this is what you were thinking.

@alexcfyung
Copy link
Contributor

I was thinking that network is like a blockchain, like ethereum, in metamask, user can change the network, for example, from ethereum to BSC without the need to remove their local ethereum wallet as they can change the network back to ethereum. I could have misunderstood as I am still learning about hyperledger, but I assume "sets up a new Fabric Test network" mean setup a new blockchain, and this feature is to remove the wallet/identities local data when user want to change network, so I wonder if the console can allow the user to switch network without deleting data from old network would be useful.

@varadgit
Copy link
Contributor Author

varadgit commented Oct 8, 2021

ah! I was afraid you would say that :-) The console only supports Hyperledger Fabric at the moment... in the future when we look to expand we can consider switching the wallet

@alexcfyung
Copy link
Contributor

If I understand correctly, hyperledger fabric is a framework so there could be multiple fabric blockchain network, does the console support multiple fabric network so user can switch between them? As I assume one reason a user want to use the delete all feature is to switch to another fabric network

@varadgit
Copy link
Contributor Author

@alexcfyung console does not support other flavors of Blockchain. It only supports Hyperledger Fabric since there isn't any sort of standard that we can use from the UI...
The "Delete All" feature is this following use case

  1. Let's say for development you have provisioned console as part of test network
  2. You have enrolled identities from the UI which results in items in the wallet
  3. Now, you destroyed the test network and recreated new set of peers/orderers/CAs

At this point all the identities in the wallet are no longer valid and you will need to delete them one at a time which might take a bit of time. It would be nice to clear the wallet with one button click.

@alexcfyung
Copy link
Contributor

Thanks for the explanation. I understand It only support Fabric, I was wondering that since there could be multiple Fabric blockchain used by different client, can the console help the user manage all Fabric blockchain by allowing user to "switch" between each Fabric blockchain?

Also currently I am having trouble setup the dev environment, the setupNetwork.sh and setupConsole.sh script works and I can see the console in port 3000, but when I tried to setup the dev environment by lerna, I have some issue connecting to couchdb, I tried 2 method to setup the couchdb: to use the couchdb from setupNetwork.sh script; and start a couchdb image directly with command docker run -e COUCHDB_USER=admin -e COUCHDB_PASSWORD=password -d -p 5984:5984 -v $PWD/couchdb:/opt/couchdb/data couchdb but when I run lerna run dev:apollo it gives the error

error: [db] problem creating databases - {"error":"unauthorized","reason":"You are not a server admin.","statusCode":401}
error: [db] problem creating databases - {"error":"not_found","reason":"Database does not exist.","statusCode":404}
...

this is my packages/athena/env/dev.js

{
    "DB_CONNECTION_STRING": "http://localhost:5984",
    "DB_SYSTEM": "athena_system",
    "CONFIGURE_FILE": "./env/my_config.yaml"
}

and packages/athena/env/my_config.yaml

---
initial_admin: admin
default_user_password_initial: password
auth_scheme: couchdb
enforce_backend_ssl: false
host_url: http://localhost:3000
support_key: admin
support_password: password
region: local
proxy_tls_fabric_reqs: true
proxy_tls_ws_url: http://localhost:3000
proxy_tls_http_url: ./
environment: dev
system_channel_id: testchainid

@varadgit
Copy link
Contributor Author

cool! you should be able to pass the userid/password as part of the connection string like here...

{
    "DB_CONNECTION_STRING": "http://admin:password@localhost:5984",
    "DB_SYSTEM": "athena_system",
    "CONFIGURE_FILE": "./env/my_config.yaml"
}

@alexcfyung
Copy link
Contributor

I added the change of the issues I encountered while setting up, I have submit a PR for that while I was working on the delete all feature.

@alexcfyung
Copy link
Contributor

@varadgit is there a way to setup testing identities without a CA? it seems like the console have import enable only and may need to be on IBM cloud or actual deployment to register a CA, or is there a way to setup testing CA without the deployment work?

@varadgit
Copy link
Contributor Author

@alexcfyung if you have an existing identity JSON you can keep importing the same... Here is a sample in case you need it... also if you have a valid cert, you can create a JSON also...

{
    "name": "myca Admin",
    "type": "identity",
    "private_key": "LS0tLS1CRUdJTiBQUklWQVRFIEtFWS0tLS0tCk1JR0hBZ0VBTUJNR0J5cUdTTTQ5QWdFR0NDcUdTTTQ5QXdFSEJHMHdhd0lCQVFRZzFCV3g2NTBPSGNxK0xqUVcKVjR4SUJHK3p3TnNKRG5NeU5uN21xMjBSY0JpaFJBTkNBQVFTVDAyZTdlVGFHRU96T2JGdHVuSldPOWg4M2d2dApCMTdqSmEzSEFMVzREQzVaUjMxcjg0V0dIUU5OS25DN3IzL2NTRXpTSmxlWXYrSEk3Z1lGVjc0aAotLS0tLUVORCBQUklWQVRFIEtFWS0tLS0tCg==",
    "cert": "LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUI1VENDQVl1Z0F3SUJBZ0lVVXpPczI0S2RLeXcwYXdBQU5hSS9LQTdyUXVjd0NnWUlLb1pJemowRUF3SXcKWWpFTE1Ba0dBMVVFQmhNQ1ZWTXhGekFWQmdOVkJBZ1REazV2Y25Sb0lFTmhjbTlzYVc1aE1SUXdFZ1lEVlFRSwpFd3RJZVhCbGNteGxaR2RsY2pFUE1BMEdBMVVFQ3hNR1JtRmljbWxqTVJNd0VRWURWUVFERXdwMllYSmhaR05oCkxXTmhNQjRYRFRJeE1UQXlOekV5TkRNd01Gb1hEVEl5TVRBeU56RXlOVEF3TUZvd0lURVBNQTBHQTFVRUN4TUcKWTJ4cFpXNTBNUTR3REFZRFZRUURFd1ZoWkcxcGJqQlpNQk1HQnlxR1NNNDlBZ0VHQ0NxR1NNNDlBd0VIQTBJQQpCQkpQVFo3dDVOb1lRN001c1cyNmNsWTcySHplQyswSFh1TWxyY2NBdGJnTUxsbEhmV3Z6aFlZZEEwMHFjTHV2CmY5eElUTkltVjVpLzRjanVCZ1ZYdmlHallEQmVNQTRHQTFVZER3RUIvd1FFQXdJSGdEQU1CZ05WSFJNQkFmOEUKQWpBQU1CMEdBMVVkRGdRV0JCUmQrMkk2U1loTXVpbTZZeFRzNlZvWGlrNktkekFmQmdOVkhTTUVHREFXZ0JScwpuSnAwNGhtNjc1UThuR1NYNDhFanpDeVdNakFLQmdncWhrak9QUVFEQWdOSUFEQkZBaUVBays3aVRvZHV0VS9TCmpYak91SjJMS2hpRzJmYVNqN3lnaXU3WmJaS2JkRklDSUdsYXlySlRmbER1M2J1a2Q3azVFVFREN1pTZlRYWGsKa3JDcmJnM3p1Q1VqCi0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K"
}

@alexcfyung
Copy link
Contributor

I cannot create the identity with your provided JSON as I received the "Unable to add identity" message, when I check the console log it show

stitch-dependencies.min.js:72 addIdentityModal:TypeError: Cannot read properties of undefined (reading 'generateKey')

image
Currently I am simply running a docker couchdb image and run npm start on athena. Do I need to fully setup a test fabric network to develop this feature or is there a way to add test identities?

@varadgit
Copy link
Contributor Author

@alexcfyung What URL are you using to access the console? I just recreated the issue locally by accessing the URL using something other than localhost when using http...

There is a crypto library console uses that will only work with TLS except the following case

  • access console using localhost or 127.0.0.1

https://developer.mozilla.org/en-US/docs/Web/API/Crypto/subtle
https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts#when_is_a_context_considered_secure

Can you try using localhost?

@dshuffma-ibm
Copy link
Contributor

fyi - i've added the secure context info to a new doc. https://github.com/hyperledger-labs/fabric-operations-console/blob/main/FAQ.md#error-help

@dshuffma-ibm dshuffma-ibm added the enhancement New feature or request label Nov 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants