New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ipfs-cpinner-client-test

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ipfs-cpinner-client-test

RIF Data Vault - IPFS centralized pinner client

  • 0.1.1-beta.11
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6
decreased by-57.14%
Maintainers
1
Weekly downloads
 
Created
Source

logo

@rsksmart/ipfs-cpinner-client

RIF Identity - IPFS Centralized Pinner Client

docs

A Web Client to simplify the way the services provided by the IPFS Centralized Data Vault Service are consumed.

Features

  • Manage authentication according to the DID Auth protocol

  • CRUD operations over the RIF Data Vault

  • Stores the authentication credentials in the given storage

  • Encrypts/decrypts data prior to save/return using the user wallet provider

Quick Usage

import DataVaultWebClient from '@rsksmart/ipfs-cpinner-client'

const serviceUrl = 'http://your-ipfs-cpinner-service.com'

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

// these are examples with Metamask
const personalSign = (data: string) => window.ethereum.request({ method: 'personal_sign', params: [address, data] })
const decrypt = (hexCypher: string) => window.ethereum.request({ method: 'eth_decrypt', params: [hexCypher, address] })
const getEncryptionPublicKey = () => window.ethereum.request.request({ method: 'eth_getEncryptionPublicKey', params: [address] })

const client = new DataVaultWebClient({
  serviceUrl,
  authManager: new AuthManager({ did, serviceUrl, personalSign }),
  encryptionManager: new EncryptionManager({ getEncryptionPublicKey, decrypt  })
})

Note: this approach use the browser localStorage as the package store. Please refer to the documentation to check custom storage options.

Get

import DataVaultWebClient from '@rsksmart/ipfs-cpinner-client'

const client = new DataVaultWebClient({ serviceUrl, decrypt, did, rpcPersonalSign })

const key = 'EmailCredential'

const credentials = await client.get({ did, key })

Get keys

import DataVaultWebClient from '@rsksmart/ipfs-cpinner-client'

const client = new DataVaultWebClient({ serviceUrl, did, rpcPersonalSign, serviceDid })

const keys = await client.getKeys()

Get storage information

import DataVaultWebClient from '@rsksmart/ipfs-cpinner-client'

const client = new DataVaultWebClient({ serviceUrl, did, rpcPersonalSign, serviceDid })

const storage = await client.getStorageInformation()

console.log(`Used: ${storage.used}`)
console.log(`Available: ${storage.available}`)

Get backup information

import DataVaultWebClient from '@rsksmart/ipfs-cpinner-client'

const client = new DataVaultWebClient({ serviceUrl, did, rpcPersonalSign, serviceDid })

const backup = await client.getBackup()

console.log('This is the keys and cids you have stored in the DV')
console.log(backup)

Create

import DataVaultWebClient from '@rsksmart/ipfs-cpinner-client'

const client = new DataVaultWebClient({ serviceUrl, did, rpcPersonalSign, serviceDid, getEncryptionPublicKey })

const key = 'MyKey'
const content = 'this is my content'

const id = await client.create({ key, content })

Swap

import DataVaultWebClient from '@rsksmart/ipfs-cpinner-client'

const client = new DataVaultWebClient({ serviceUrl, did, rpcPersonalSign, serviceDid, getEncryptionPublicKey })

const key = 'MyKey'
const content = 'this is my content'

const id = await client.swap({ key, content })

Delete

import DataVaultWebClient from '@rsksmart/ipfs-cpinner-client'

const client = new DataVaultWebClient({ serviceUrl, did, rpcPersonalSign, serviceDid })

const key = 'MyKey'

await client.delete({ key })

Advanced usage

See our documentation

Open work

  • Encrypt/decrypt content prior to save or after retrieving it from the service

Test

From base repo directory run npm test or any of the described test script variants.

Keywords

FAQs

Package last updated on 06 Jan 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc