Skip to content
This repository was archived by the owner on May 19, 2023. It is now read-only.

Commit d3f49bb

Browse files
authored
Bump version (#57)
* Update client README and bump versions * Improve storage test for sandbox
1 parent c861971 commit d3f49bb

File tree

5 files changed

+24
-15
lines changed

5 files changed

+24
-15
lines changed

modules/ipfs-cpinner-client/README.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,24 +26,29 @@ A Web Client to simplify the way the services provided by the IPFS Centralized D
2626
## Quick Usage
2727

2828
```typescript
29-
import DataVaultWebClient, { ClientKeyValueStorage } from '@rsksmart/ipfs-cpinner-client'
29+
import DataVaultWebClient from '@rsksmart/ipfs-cpinner-client'
3030

3131
const serviceUrl = 'http://your-ipfs-cpinner-service.com'
32-
const storage: ClientKeyValueStorage = myCustomStorage
3332

3433
// the following fields are required just to perform write operations
3534
const serviceDid = 'did:ethr:rsk:0x123456789....abc'
3635
const address = '0xabcdef....123' // user's address
3736
const did = `did:ethr:rsk:${address}`
3837

3938
// these are examples with Metamask
40-
const rpcPersonalSign = (data: string) => window.ethereum.request({ method: 'personal_sign', params: [address, data] })
39+
const personalSign = (data: string) => window.ethereum.request({ method: 'personal_sign', params: [address, data] })
4140
const decrypt = (hexCypher: string) => window.ethereum.request({ method: 'eth_decrypt', params: [hexCypher, address] })
4241
const getEncryptionPublicKey = () => window.ethereum.request.request({ method: 'eth_getEncryptionPublicKey', params: [address] })
4342

44-
const client = new DataVaultWebClient({ serviceUrl, did, rpcPersonalSign, serviceDid, storage, getEncryptionPublicKey, decrypt })
43+
const client = new DataVaultWebClient({
44+
serviceUrl,
45+
authManager: new AuthManager({ did, serviceUrl, personalSign }),
46+
encryptionManager: new EncryptionManager({ getEncryptionPublicKey, decrypt })
47+
})
4548
```
4649

50+
> Note: this approach use the browser `localStorage` as the package store. Please refer to the [documentation](https://developers.rsk.co/rif/identity/data-vault/architecture/client/) to check custom storage options.
51+
4752
### Get
4853

4954
```typescript
@@ -132,7 +137,7 @@ await client.delete({ key })
132137

133138
## Advanced usage
134139

135-
See our [documentation](https://rsksmart.github.io/rif-identity-docs/data-vault/cpinner/cpinner-client)
140+
See our [documentation](https://developers.rsk.co/rif/identity/data-vault/architecture/client/)
136141

137142
## Open work
138143

modules/ipfs-cpinner-client/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@rsksmart/ipfs-cpinner-client",
3-
"version": "0.1.1-beta.4",
3+
"version": "0.1.1-beta.5",
44
"description": "RIF Data Vault - IPFS centralized pinner client",
55
"main": "lib/index.js",
66
"types": "lib/index.d.ts",
@@ -24,8 +24,8 @@
2424
},
2525
"homepage": "https://github.com/rsksmart/rif-data-vault#readme",
2626
"devDependencies": {
27-
"@rsksmart/ipfs-cpinner-provider": "0.1.1-beta.3",
28-
"@rsksmart/ipfs-cpinner-service": "0.1.1-beta.3",
27+
"@rsksmart/ipfs-cpinner-provider": "0.1.1-beta.5",
28+
"@rsksmart/ipfs-cpinner-service": "0.1.1-beta.5",
2929
"@rsksmart/rif-id-ethr-did": "^0.1.0",
3030
"@rsksmart/rif-id-mnemonic": "^0.1.0",
3131
"@types/axios": "^0.14.0",

modules/ipfs-cpinner-client/test/sandbox-env.test.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ describe.skip('sandbox environment', function (this: {
1616
this.did = clientIdentity.did
1717

1818
// COMPLETE WITH YOUR SANDBOX ENVIRONMENT VALUES
19-
// const serviceDid = ''
2019
const serviceUrl = ''
2120

2221
return new DataVaultWebClient({
@@ -66,12 +65,17 @@ describe.skip('sandbox environment', function (this: {
6665
const key = 'AKey'
6766
const content = 'the content'
6867

68+
const storageBeforeCreate = await client.getStorageInformation()
69+
70+
expect(storageBeforeCreate.available).toEqual(1000000)
71+
expect(storageBeforeCreate.used).toEqual(0)
72+
6973
await client.create({ key, content })
7074

71-
const storage = await client.getStorageInformation()
75+
const storageAfterCreate = await client.getStorageInformation()
7276

73-
expect(storage.available).toEqual(1000000 - 11)
74-
expect(storage.used).toEqual(11)
77+
expect(storageAfterCreate.available).toBeLessThan(1000000)
78+
expect(storageAfterCreate.used).toBeGreaterThan(0)
7579
})
7680

7781
test('should get a content', async () => {

modules/ipfs-cpinner-provider/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@rsksmart/ipfs-cpinner-provider",
3-
"version": "0.1.1-beta.3",
3+
"version": "0.1.1-beta.5",
44
"description": "RIF Identity - IPFS Centralized Pinner Provider",
55
"main": "lib/index.js",
66
"types": "lib/index.d.ts",

modules/ipfs-cpinner-service/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@rsksmart/ipfs-cpinner-service",
3-
"version": "0.1.1-beta.3",
3+
"version": "0.1.1-beta.5",
44
"description": "RIF Identity - IPFS Centralized Pinner Service",
55
"private": true,
66
"main": "lib/index.js",
@@ -28,7 +28,7 @@
2828
},
2929
"homepage": "https://github.com/rsksmart/rif-data-vault#readme",
3030
"dependencies": {
31-
"@rsksmart/ipfs-cpinner-provider": "0.1.1-beta.3",
31+
"@rsksmart/ipfs-cpinner-provider": "0.1.1-beta.5",
3232
"@rsksmart/rif-id-ethr-did": "^0.1.0",
3333
"@rsksmart/rif-node-utils": "0.0.3",
3434
"@rsksmart/express-did-auth": "0.1.1",

0 commit comments

Comments
 (0)