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

rum-sdk-browser

v2.0.18

Published

rum sdk for browser

Downloads

8

Readme

rum-sdk-browser

Rum SDK for browser

Install

$ npm install rum-sdk-browser

Usage

import SDK from 'rum-sdk-browser';
import { ethers } from 'ethers';

// create an ethereum wallet
const wallet = ethers.Wallet.createRandom();

// import group seed
const group = SDK.cache.Group.add('rum://...');

// sign data and send trx to group
SDK.chain.Trx.create({
  data: {
    type: "Create",
    object : {
      type: "Note",
      id: "1",
      content: "hello world",
    }
  },
  groupId: group.groupId,
  privateKey: wallet.privateKey
});

// get data from chain
const contents = await SDK.chain.Content.list({
  groupId: group.groupId,
});
console.log(contents);
// [{
//   "Data": {
//     "type": "Create",
//     "object" : {
//       "type": "Note",
//       "id": "1",
//       "content": "hello world",
//     }
//   },
//   "TrxId": "...",
//   "GroupId": "...",
//   "TimeStamp": "...",
//   "Version": "1.0.0",
//   "Expired": 1672284016463,
//   "Nonce": 1,
//   "SenderPubkey": "...",
//   "SenderSign": "..."
// }]

Examples

Add group

import SDK from 'rum-sdk-browser';
const result = SDK.cache.Group.add('rum://seed?xxx');
console.log(result);
// { groupId: '8136923b-8203-4e08-bfe7-50eb3b558e2c' }

Get group

import SDK from 'rum-sdk-browser';
const groupId = '8136923b-8203-4e08-bfe7-50eb3b558e2c';
const group = SDK.cache.Group.get(groupId);
console.log(group);
// {
//   appKey: "group_timeline",
//   chainAPIs: ['http://127.0.0.1:9003'],
//   cipherKey: "c0f3a84920c2c5b93ba308a92302789ca991cb2376c11b16d48fefb31666d5d2",
//   consensusType: "poa",
//   encryptionType: "public",
//   groupId: "8136923b-8203-4e08-bfe7-50eb3b558e2c",
//   groupName: "chat group",
//   ownerPubKey: "Aqa6ngNxgrVhf2kQc4nA-0Wr4tsWiaBrshZJPujT5B9g",
//   signature: "GDLJ+TcXuo95q+CsUFty7pvMIYZRFRQ3VwrparvjKy00wIYSmx5pl4xT4ALb6AVgNei/is5kn1MuXfh9b5wB+QE=",
// }

List groups

import SDK from 'rum-sdk-browser';
const groups = SDK.cache.Group.list();
console.log(groups);
// [{
//   appKey: "group_timeline",
//   chainAPIs: ['http://127.0.0.1:9003'],
//   cipherKey: "c0f3a84920c2c5b93ba308a92302789ca991cb2376c11b16d48fefb31666d5d2",
//   consensusType: "poa",
//   encryptionType: "public",
//   groupId: "8136923b-8203-4e08-bfe7-50eb3b558e2c",
//   groupName: "chat group",
//   ownerPubKey: "Aqa6ngNxgrVhf2kQc4nA-0Wr4tsWiaBrshZJPujT5B9g",
//   signature: "GDLJ+TcXuo95q+CsUFty7pvMIYZRFRQ3VwrparvjKy00wIYSmx5pl4xT4ALb6AVgNei/is5kn1MuXfh9b5wB+QE=",
// }]

Create trx

import SDK from 'rum-sdk-browser';
const ethers = require('ethers');
(async () => {
  const wallet = ethers.Wallet.createRandom();
  const result = await SDK.chain.Trx.create({
    data: {
      type: "Create",
      object : {
        type: "Note",
        id: "1",
        content: "hello world",
      }
    },
    groupId: '8136923b-8203-4e08-bfe7-50eb3b558e2c',
    privateKey: wallet.privateKey,
  });
  console.log(result);
})();
// { trx_id: '41f1e91e-5604-4539-8dee-7cf7e3ef5046' }

Get trx

import SDK from 'rum-sdk-browser';
(async () => {
  const groupId = '8136923b-8203-4e08-bfe7-50eb3b558e2c';
  const trxId = '41f1e91e-5604-4539-8dee-7cf7e3ef5046';
  const trx = await SDK.chain.Trx.get(groupId, trxId);
  console.log(trx);
})();
// {
//   Data: "SdujS8K8zv2E6X839+J3tvIzkpYJti44Bw0cZ0weaYA4sTm0Z1rV/raKoa6zBwrAZYM9Zs+QdLS06jCVcaIvZrDqZysuAbTA/0JPmWVcLRdoiipdjAe6ov35f7WgVps6iSKUrw==",
//   Expired: "1657279269056000000",
//   GroupId: "8136923b-8203-4e08-bfe7-50eb3b558e2c",
//   Nonce: "1",
//   ResendCount: "0",
//   SenderPubkey: "Ak0RxoYwYhkAfg0ImkLh-ukRIHkoQ-Kw6QCRr_o83bmq",
//   SenderSign: "Dz436tcTh+NSUjF38oUBjXkIezVfENb/pit9BY1v8jZrjzcwu66YE8OFO9/MzRNIkhgTK2wulfmk51mzJz/9Txs=",
//   StorageType: "CHAIN",
//   TimeStamp: "1657279239056000000",
//   TrxId: "41f1e91e-5604-4539-8dee-7cf7e3ef5046",
//   Type: "POST",
//   Version: "1.0.0",
// }

List contents

import SDK from 'rum-sdk-browser';
(async () => {
  const contents = await SDK.chain.Content.list({
    groupId: '8136923b-8203-4e08-bfe7-50eb3b558e2c',
  });
  console.log(contents);
})();
// [{
//   "Data": {
//     "type": "Create",
//     "object" : {
//       "type": "Note",
//       "id": "1",
//       "content": "hello world",
//     }
//   },
//   "TrxId": "...",
//   "GroupId": "...",
//   "TimeStamp": "...",
//   "Version": "1.0.0",
//   "Expired": 1672284016463,
//   "Nonce": 1,
//   "SenderPubkey": "...",
//   "SenderSign": "..."
// }]

More examples

You can check more real world examples in https://docs.rumsystem.net/docs/data-format-and-examples/