openwallet-foundation / credo-ts

Typescript framework for building decentralized identity and verifiable credential solutions
https://credo.js.org
Apache License 2.0
275 stars 202 forks source link

Need help on backup and restore functionality #1464

Closed Sshovon closed 1 year ago

Sshovon commented 1 year ago

I am working on a project requiring backing up and restoring the wallet with all its previous connections and credentials. Are there any workable functionalities to implement backup and restore in Aries Bifold wallet?

TimoGlastra commented 1 year ago

There are two methods available: import and export, which you can use to make an export/import of your wallet.

agent.wallet.export

Is this what you're looking for?

Sshovon commented 1 year ago

Yes, I am looking for this one. I found export import method in /packages/core/src/wallet/Wallet.ts . Are you talking about these methods? If not, could you let me know which file these two methods are written in? It would be much helpful.

TimoGlastra commented 1 year ago

It's in the IndySdkWallet or AskarWallet (dependant on which wallet you use).

However, you can access it from the wallet api directly (using agent.wallet.export):

https://github.com/hyperledger/aries-framework-javascript/blob/11366e540421517ce21e8cca8781741fc482be8e/packages/core/src/wallet/WalletApi.ts#L112-L118

Sshovon commented 1 year ago

I have worked on import and export modules. After export a new file is generated which is used to import the wallet. The import functions also works. But the problem arises after importing, new wallet doesn't set automatically. Even walletConfig.id doesn't change. For import, I have delete the wallet using agent.wallet.delete() and called agent.wallet.import() afterward. I have also tried to initialize the wallet after import using agent.wallet.initialize(). Still didn't worked. Can you help me this regard?

image

TimoGlastra commented 1 year ago

What wallet are you using? AskarWallet or IndySdkWallet?

For import, I have delete the wallet using agent.wallet.delete() and called agent.wallet.import() afterward

I think this is to prevent from overwriting a local wallet

Still didn't worked.

What do you mean exactly with still doesn't work? Are you getting an error?

Sshovon commented 1 year ago

I am using IndySdkWallet. For import, I am deleting the current wallet and creating a new wallet. After import I am getting no error. The import functionality creates sqlite.db,sqlite.db-shm,sqlite.db-wal files in mobile storage. I am attaching a screenshot of after and before importing wallet. But the problem is after import the wallet doesn't load credentials or connections from the export file. And also it loses the pin related information of the wallet as I deleted the wallet. So I can't login using the same pin. It gives incorrect pin in the app though the salt remains same. In short,

Sshovon commented 1 year ago

I have bypassed the pin authentication mechanism to enter the wallet. And the import function worked. Yet need some testing to check every functionality of the wallet. After deleting the previous wallet and importing a new one, the pin mechanism fails to verify the pin and always shows an incorrect pin alert.

PenguinTaro commented 1 year ago

Hi @Sshovon @TimoGlastra , I have been trying to implement the export and import functionality. But when I tried to set the path for export using react-native-fs. I want to know how you have set the path for the data to get exported and are you saving the data in local device or the cloud storage?