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

@rsksmart/ipfs-cpinner-provider

Package Overview
Dependencies
Maintainers
3
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rsksmart/ipfs-cpinner-provider

RIF Identity - IPFS Centralized Pinner Provider

  • 0.1.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
7
increased by40%
Maintainers
3
Weekly downloads
 
Created
Source

logo

@rsksmart/ipfs-cpinner-provider

RIF Identity - IPFS Centralized Pinner Provider

docs npm

npm i @rsksmart/ipfs-cpinner-provider

A Centralized Data Vault provider compatible with RIF Data Vault standard interface. It stores content in an IPFS node associated to a given DID and key.

Basic instance

Plug and play configuration

import { ipfsPinnerProviderFactory, IpfsPinnedCid, IpfsMetadata } from '@rsksmart/ipfs-cpinner-provider'
import { createConnection } from 'typeorm'

const ipfsApiUrl = 'http://localhost:5001'
const maxStorage = 2000000 // 2 mb

const database = 'my-ipfs-pinner-provider.sqlite'
const Entities = [IpfsPinnedCid, IpfsMetadata]

const dbConnection = await createConnection({
  type: 'sqlite',
  database,
  entities: Entities,
  logging: false,
  dropSchema: true,
  synchronize: true
})

const ipfsPinnerProvider = await ipfsPinnerProviderFactory({ dbConnection, ipfsApiUrl, maxStorage })
// NOTE: ipfsApiUrl is optional. Default value is: 'http://localhost:5001'
// NOTE: maxStorage is optional. Default value is: 1000000 // 1 mb

Usage

const did = 'did:ethr:rsk:12345678'
const key = 'the key'
const content = 'the content'

const cid: string = await ipfsPinnerProvider.create(did, key, content)

const files: { id: string, content: string }[] = await ipfsPinnerProvider.get(did, key)

const keys: string[] = await ipfsPinnerProvider.getKeys(did)

const newCid: string = await ipfsPinnerProvider.swap(did, key, 'the new content')

const anotherCid: string = await ipfsPinnerProvider.swap(did, key, 'the new content', newCid) // cid can be specified if there is more than one content associated to the given did and key

const deleted: boolean = await ipfsPinnerProvider.delete(did, key)

const deleted: boolean = await ipfsPinnerProvider.delete(did, key, cid) // cid can be specified if there is more than one content associated to the given did and key

const availableStorage: number = await ipfsPinnerProvider.getAvailableStorage(did) // return the amount of bytes available to store value associated to the given did

const usedStorage: number = await ipfsPinnerProvider.getUsedStorage(did) // return the amount of bytes used to store value associated to the given did

const didBackup: Backup = await ipfsPinnerProvider.getBackup(did) // return an array containing all the keys and cids created by the given did

See our documentation for advanced usage.

Test

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

Keywords

FAQs

Package last updated on 11 May 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