Skip to content
This repository has been archived by the owner on Nov 7, 2023. It is now read-only.

Update datavault endpoint #64

Merged
merged 3 commits into from
Feb 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "rif-identity-manager",
"version": "0.0.1",
"private": true,
"homepage": ".",
"license": "MIT",
"scripts": {
"start": "react-scripts start",
Expand Down
25 changes: 11 additions & 14 deletions src/app/state/operations/datavault.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ import { Backup, CreateContentResponse } from '@rsksmart/ipfs-cpinner-client/lib
import { getProviderName, PROVIDERS } from '../../../ethrpc'
import { IEncryptionManager } from '@rsksmart/ipfs-cpinner-client/lib/encryption-manager/types'

/**
* Helper function that returns the correct encryption method
* @param provider web3 provider
*/
const getEncryptionManager = async (provider: any) =>
getProviderName(provider) === PROVIDERS.METAMASK
? await AsymmetricEncryptionManager.fromWeb3Provider(provider)
: await SignerEncryptionManager.fromWeb3Provider(provider)

/**
* Create DataVault Clinet
* @param provider web3 provider
Expand All @@ -20,21 +29,9 @@ export const createClient = (provider: any, address: string, chainId: number) =>
const personalSign = (data: string) => provider.request({ method: 'personal_sign', params: [data, address] })
const authManager = new AuthManager({ did, serviceUrl, personalSign })

if (getProviderName(provider) === PROVIDERS.METAMASK) {
return Promise.resolve(new DataVaultWebClient({
serviceUrl,
authManager,
encryptionManager: new AsymmetricEncryptionManager(provider)
}))
}

return SignerEncryptionManager.fromWeb3Provider(provider)
return getEncryptionManager(provider)
.then((encryptionManager: IEncryptionManager) =>
new DataVaultWebClient({
serviceUrl,
authManager,
encryptionManager
}))
new DataVaultWebClient({ serviceUrl, authManager, encryptionManager }))
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/config/config.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"dataVaultUrl": "https://identity.staging.rifcomputing.net"
"dataVaultUrl": "https://identity-data-vault.testnet.rifos.org"
}