πŸš€ Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more β†’
Socket
DemoInstallSign in
Socket

ipfs-repo

Package Overview
Dependencies
Maintainers
1
Versions
130
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ipfs-repo

IPFS Repo implementation

0.3.0
Source
npm
Version published
Weekly downloads
3.3K
-30.68%
Maintainers
1
Weekly downloads
Β 
Created
Source

js-ipfs-repo

Implementation of the IPFS repo spec (https://github.com/ipfs/specs/tree/master/repo) in JavaScript

Build Status Dependency Status js-standard-style

Description

This is the implementation of the IPFS repo spec in JavaScript.

Architecture

β”Œ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┐
  interface defined by Repo Spec
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                 β”‚                                  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                                 β”‚                                  β”‚ abstract-blob-store  β”‚
β”‚           IPFS REPO             │─────────────────────────────────▢│     interface        β”‚
β”‚                                 β”‚                                  β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                 β”‚                                  β”‚      locks           β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                                  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                 β”‚
      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
      β–Ό               β–Ό               β–Ό               β–Ό               β–Ό               β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ abstract  β”‚   β”‚ abstract  β”‚   β”‚ abstract  β”‚   β”‚ abstract  β”‚   β”‚ abstract  β”‚   β”‚ abstract  β”‚
β”‚ -blog     β”‚   β”‚ -blog     β”‚   β”‚ -blog     β”‚   β”‚ -blog     β”‚   β”‚ -blog     β”‚   β”‚ -blog     β”‚
β”‚ -store    β”‚   β”‚ -store    β”‚   β”‚ -store    β”‚   β”‚ -store    β”‚   β”‚ -store    β”‚   β”‚ -store    β”‚
β”‚ interface β”‚   β”‚ interface β”‚   β”‚ interface β”‚   β”‚ interface β”‚   β”‚ interface β”‚   β”‚ interface β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€   β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€   β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€   β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€   β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€   β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚           β”‚   β”‚           β”‚   β”‚           β”‚   β”‚           β”‚   β”‚           β”‚   β”‚           β”‚
β”‚   keys    β”‚   β”‚  config   β”‚   β”‚ datastore β”‚   β”‚ datastore β”‚   β”‚   logs    β”‚   β”‚  version  β”‚
β”‚           β”‚   β”‚           β”‚   β”‚           β”‚   β”‚ -legacy   β”‚   β”‚           β”‚   β”‚           β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

IPFS repo exposes a well defined interface by the Repo Spec. Each of the individual repos has an interface defined by abstract-blob-store, this enables us to make IPFS repo portable (running on Node.js vs the browser) and accept different types of storage mechanisms for each repo (fs, levelDB, etc).

Good to know (historical context)

  • The datastore folder holds the legacy version of datastore, still built in levelDB, there is a current endeavour of pushing it to fs completely.
  • The blocks folder is the current version of datastore.
  • The keys repo doesn't exist yet, as the private key is simply stored inside config

Usage

Install

Standard Node.js way.

$ npm i ipfs-repo

Repo

Constructor, accepts a path and options:

var IPFSRepo = require('js-ipfs-repo')
var repo = new IPFSRepo('/Users/someone/.ipfs', {
  stores: {
    keys: <something that implements abstract-blob-store>,
    config: <something that implements abstract-blob-store>,
    datastore: <something that implements abstract-blob-store>,
    logs: <something that implements abstract-blob-store>,
    locks: <something that implements abstract-blob-store>,
    version: <something that implements abstract-blob-store>
  }})

You can check if the repo you are going to access already exists on the path you passed to the constructor by:

repo.exists(function (err, exists) {
  // exists is a boolean value
})

If the repo doesn't exist yet, you can start it by executing the init cuntion

repo.init(opts, function (err) {})

version

Read/Write the version number of that repository.

repo.version.get(function (err, version) {
  console.log(err, num) // => 2
})

repo.version.set(3, function (err) {
  console.log(err)
})

config

Read/Write the JSON configuration for that repository.

repo.config.read(function (err, json) {
  console.log(err, json)
})

repo.config.write({foo: 'bar'}, function (err) {
  console.log(err)
})

keys

Read/Write keys inside the repo. This feature will be expanded once IPRS and KeyChain are finalized and implemented on go-ipfs.

repo.keys.get(function (err, privKey) {})

datastore

Store data on the block store.

repo.datastore.read('12200007d4e3a319cd8c7c9979280e150fc5dbaae1ce54e790f84ae5fd3c3c1a0475', function (err, buff) {
  console.log(err)
})
repo.datastore.write(buff, function (err, buffer) {
  console.log(buff.toString('utf-8'), err)
})

datastore legacy

WIP

repo.datastoreLegacy
repo.datastoreLegacy

locks

Note: You shouldn't need to use this. It is used internally

Read/Write the repo.lock file.

repo.locks.lock(function (err) {})

repo.locks.unlock(function (err) {})

logs

No longer supported, see https://github.com/ipfs/js-ipfs-repo/issues/8

Contribute

There is some ways you can make this module better:

  • You can consult our open issues and take on one of them
  • Make the tests better
  • Make the tests work in the Browser

Keywords

IPFS

FAQs

Package last updated on 15 Jan 2016

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