npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

js-fstorm-http-client

v0.0.1-alpha.4

Published

javascript client for filestorm nodes.

Downloads

6

Readme

js-fstorm-http-client

This is an alpha version

安装

npm install js-fstorm-http-client

使用

const FStormHttpClient = require('js-fstorm-http-client');

实例化一个新的 FStormHttpClient 对象

const fStormHttpClient = new FStormHttpClient(options);

参数
  • options 必选
    • options.IPFSProvider - any 必选 IPFS服务端配置,支持 ipfs-http-client 的设置方式
    • options.chainProvider - any 可选 链服务端配置,可动态设置,支持 storm3 的设置方式
    • chainAccount - object 可选 发送到链交易的地址信息,可动态设置
      • chainAccount.privateKey - string 可选 地址私钥(如果提供 privateKey 则无需提供 keystore 和 密码)
      • chainAccount.keystore - object | string 可选 keystore(如果未提供 privateKey,则必须提供 keystore 和 密码)
      • chainAccount.password - string 可选 密码
例子
 const fStorm = new FStormHttpClient({
    IPFSProvider:  'http://localhost:5001',
    chainProvider:  'http://localhost:8645',
    chainAccount: {
      privateKey: ''
    },
  });
或者使用 keystore + 密码的方式
 const fStorm = new FStormHttpClient({
   IPFSProvider: config.IPFSProvider,
   chainProvider: config.chainProvider,
   chainAccount: {
     keystore: {},
     password: ''
   }
});
动态设置链
  fStorm.setChainProvider(chainProvider);
动态设置链交易的账号
  fStorm.setChainAccount({
    keystore: {},
    password: ''
  });
  // 或者
  fStorm.setChainAccount({
    privateKey: ''
  });

API

Files
  • Regular Files API
    • fStorm.add(data, [options])
    • fStorm.get(ipfsPath, [options])
Graph
  • pin
    • fStorm.pin.add(hash, [options])
    • fStorm.pin.rm(hash, [options])
加密
  • fStorm.encrypt(filePath, [password])

    • 说明:对文件进行加密
    • 参数
      • filePath - string 本地文件路径
      • password - string 密码,默认使用私钥
    • 返回值
      • Promise
        • resolve => encryptFilePath - string 加密后文件存放的路径
        • reject => error - object 错误对象
  • fStorm.decrypt(filePath, [password])

    • 说明:对文件进行解密
    • 参数
      • filePath - string 本地文件路径
      • password - string 密码,默认使用私钥
    • 返回值
      • Promise
        • resolve => encryptFilePath - string 解密后文件存放的路径
        • reject => error - object 错误对象
例子

Regular Files API

  • fStorm.add
  const fs = require('fs');
  let files = await fStorm.add(fs.readFileSync(filePath));
  for await (let res of files) {
    console.log(res);
  }
  • fStorm.get
  let files = fStorm.get('QmNWM9kwgnsskedBMNm7U2T9MXg2Cd4KkwRhMJNuD5UFXt');;
  for await (let res of files) {
    console.log(res);
  }

Graph

  • fStorm.pin.add
  let cids = await fStorm.pin.add([
   'QmQ2r6iMNpky5f1m4cnm3Yqw8VSvjuKpTcK1X7dBR1LkJF'
  ]);
  cids.forEach(item => {
    console.log(item.cid.toString());
  });
  • fStorm.pin.rm
  let cids = await fStorm.pin.rm([
   'QmQ2r6iMNpky5f1m4cnm3Yqw8VSvjuKpTcK1X7dBR1LkJF'
  ]);
  cids.forEach(item => {
    console.log(item.cid.toString());
  });

加密文件

  • fStorm.encrypt
  fStorm.encrypt('D:\\test\\1.wmv')
    .then(filePath => {
      console.log(filePath); // D:\test\1.wmv.enc
    })
    .catch(err => {
      console.log(err);
    });
  • fStorm.decrypt
  fStorm.decrypt('D:\\test\\1.wmv.enc')
    .then(filePath => {
      console.log(filePath); // D:\\test\\1.wmv
    })
    .catch(err => {
      console.log(err);
    });