Socket
Book a DemoInstallSign in
Socket

@onlabsorg/ipfs-store

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@onlabsorg/ipfs-store

olojs store backed by IPFS

0.5.1
latest
npmnpm
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

ipfs-store

This is an olojs document store based on IPFS.

Getting started

Install via npm:

npm install @onlabsorg/ipfs-store

Create an IPFS store:

const IPFS = require('ipfs-core');
const ipfs = await IPFS.create();

const {IPFSStore} = require('..');
const store = new IPFSStore(ipfs, CID);       // CID is a valid IPFS directory content id

Read the IPFS store content:

const source = await store.read('/path/to/doc');    // returns ipfs://<CID>/path/to/doc
const items = await store.list('/path/to/dir');     // returns the array of child names of ipfs://<CID>/path/to/dir/

Of course write, delete and deleteAll operations are not allowed, being the files stored on IPFS read-only. In order to modify an IPFS store, you can clone it to an olojs MemoryStore, modify it and add it again to IPFS.

const clone = await store.clone('/');    // you can clone just a subdir if you want
const newCID = await IPFSStore.create(ipfs, clone);

Notice that cloning+adding does not modify the original directory, but it creates a new one instead.

Use ipfs-store as stilo plugin

When installed as stilo plugin, this library adds the /ipfs route to your stilo hub.

In order to install olojs-cli as stilo plugin, type the following command from your stilo package root:

stilo install @onlabsorg/ipfs-store

Once you installed it, you can fetch, render or list the olojs documents stored on IPFS. Example:

stilo read /ipfs/QmQnEkNLoSHWDukHoW7J8gFbikx6eGWx2FGv5t1nxo8Wy7/helloworld
stilo list /ipfs/QmQnEkNLoSHWDukHoW7J8gFbikx6eGWx2FGv5t1nxo8Wy7
stilo render /ipfs/QmQnEkNLoSHWDukHoW7J8gFbikx6eGWx2FGv5t1nxo8Wy7/helloworld

Of course the ipfs: protocol will be available also in your olojs documents:

<% hw = import '/ipfs/QmQnEkNLoSHWDukHoW7J8gFbikx6eGWx2FGv5t1nxo8Wy7/helloworld'

License

This software is released under the ISC license.

  • olojs is a distributed content management system
  • [viewer] is a web client for rendering olojs documents in the browser
  • olowiki is a web interface that allows creating and modifying olojs documents
  • stilo is a command-line interface written in NodeJS that allows you to create and mange local olojs document repositories.

Keywords

olojs

FAQs

Package last updated on 01 Oct 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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.