Socket
Socket
Sign inDemoInstall

rss3-next

Package Overview
Dependencies
85
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    rss3-next

JavaScript SDK for [RSS3-Hub](https://github.com/NaturalSelectionLabs/RSS3-Hub)


Version published
Weekly downloads
2K
increased by4.27%
Maintainers
1
Install size
19.0 MB
Created
Weekly downloads
 

Readme

Source

RSS3 SDK JavaScript

JavaScript SDK for RSS3-Hub

Install

npm install rss3 --save

or

yarn add rss3
import RSS3 from 'rss3';

or

const RSS3 = require('rss3').default;

API

Initialization

interface IOptions {
    endpoint: string;
    agentSign?: boolean;
}

interface IOptionsMnemonic extends IOptions {
    mnemonic?: string;
    mnemonicPath?: string;
}

interface IOptionsPrivateKey extends IOptions {
    privateKey: string;
}

interface IOptionsSign extends IOptions {
    address: string;
    sign: (data: string) => Promise<string>;
}

new RSS3(options: IOptionsMnemonic | IOptionsPrivateKey | IOptionsSign);

Example:

New

const rss3 = new RSS3({
    endpoint: 'https://rss3-hub-playground-6raed.ondigitalocean.app',
});

Mnemonic

const rss3 = new RSS3({
    endpoint: 'https://rss3-hub-playground-6raed.ondigitalocean.app',
});

PrivateKey

const rss3 = new RSS3({
    endpoint: 'https://rss3-hub-playground-6raed.ondigitalocean.app',
    privateKey: '0x47e18d6c386898b424025cd9db446f779ef24ad33a26c499c87bb3d9372540ba',
});

MetaMask

const metaMaskWeb3 = new Web3(window.ethereum);
window.ethereum
    .request({
        method: 'eth_requestAccounts',
    })
    .then(async (accounts) => {
        const address = metaMaskWeb3.utils.toChecksumAddress(accounts[0]);
        const rss3 = new RSS3({
            endpoint: 'https://rss3-hub-playground-6raed.ondigitalocean.app',
            address,
            sign: async (data) => await metaMaskWeb3.eth.personal.sign(data, address),
        });
        rss3.files.set(await rss3.files.get(address));
        await rss3.files.sync();
    });

Account

account.mnemonic

If initialized with privateKey or custom sign function, then this value is undefined

account.mnemonic: string | undefined

account.privateKey

If initialized with custom sign function, then this value is undefined

account.privateKey: string | undefined

account.address

account.address: string

Files

files.sync()

Please note that changes will only be synced to the node after files.sync() is successfully executed

files.sync(): string[]

Example:

const changedFiles = rss3.files.sync();

files.get()

files.get(fileID: string): Promise<RSS3Content>

Example:

const file = await rss3.files.get(rss3.account.address);

Profile

profile.get()

profile.get(personaID: string = account.address): Promise<RSS3Profile>

Example:

const profile = rss3.profile.get();

profile.patch()

profile.patch(profile: RSS3Profile): Promise<RSS3Profile>

Example:

const newProfile = await rss3.profile.patch({
    name: 'RSS3',
    avatar: 'https://cloudflare-ipfs.com/ipfs/QmZWWSspbyFtWpLZtoAK35AjEYK75woNawqLgKC4DRpqxu',
    bio: 'RSS3 is an open protocol designed for content and social networks in the Web 3.0 era.',
});

Items

items.get()

items.get(fileID: string = account.address): Promise<{
    items: RSS3Item[],
    items_next?: string,
}>

Example:

const list1 = await rss3.items.get();
const items1 = list1.items;
const list2 = await rss3.items.get(list1.items_next);
const items2 = list2.items;

Item

item.get

item.get(itemID: string): Promise<RSS3Item>

Example:

const item = await rss3.item.get('0x47e18d6c386898b424025cd9db446f779ef24ad33a26c499c87bb3d9372540ba-item-0');

item.post

item.post(item: RSS3ItemInput): Promise<RSS3ItemInput>

Example:

const item = await rss3.item.post({
    title: 'Hello RSS3',
    summary: 'RSS3 is an open protocol designed for content and social networks in the Web 3.0 era.',
});

item.patch

item.patch(item: RSS3ItemInput): Promise<RSS3ItemInput>

Example:

const newItem = await rss3.item.patch({
    title: 'Hi RSS3',
});

links.get

links.get(fileID: string): Promise<RSS3Links[]>;
links.get(fileID: string, type: string): Promise<RSS3Links>;

Example:

const following = await rss3.links.get(rss3.account.address, 'following');

links.post

links.post(links: RSS3LinksInput): Promise<RSS3Links>

Example:

const following = await rss3.links.post({
    type: 'following',
    list: ['0xd0B85A7bB6B602f63B020256654cBE73A753DFC4'],
});

links.delete

links.delete(type: string): Promise<RSS3Links>

Example:

const following = await rss3.links.delete('following');

links.patch

links.patch(links: RSS3LinksInput): Promise<RSS3Links>

Example:

const following = await rss3.links.patch({
    type: 'following',
    tags: ['test'],
    list: ['0xd0B85A7bB6B602f63B020256654cBE73A753DFC4', '0xC8b960D09C0078c18Dcbe7eB9AB9d816BcCa8944'],
});

link.post

link.post(type: string, personaID: string): Promise<RSS3Links>

Example:

const following = await rss3.link.post('following', '0xd0B85A7bB6B602f63B020256654cBE73A753DFC4');

link.delete

link.delete(type: string, personaID: string): Promise<RSS3Links>

Example:

const following = await rss3.link.delete('following', '0xd0B85A7bB6B602f63B020256654cBE73A753DFC4');

backlinks.get

backlinks.get(personaID?: string): Promise<RSS3Backlink[]>
backlinks.get(personaID: string, type: string): Promise<string[]>

Example:

const followers = await rss3.backlinks.get(rss3.account.address, 'following');

Accounts

accounts.post

accounts.post(account: RSS3Account): Promise<RSS3Account>

Example:

const account = await rss3.accounts.post(account);

accounts.delete

accounts.delete(account: {
    platform: string;
    identity: string;
}): Promise<RSS3Account>

Example:

const account = await rss3.accounts.delete(account);

accounts.getSigMessage

accounts.getSigMessage(account): string;

Example:

const sigMessage = await rss3.accounts.getSigMessage(account);

Assets

assets.patchTags

assets.patchTags(asset: RSS3Asset, tags: string[]): Promise<RSS3Asset>

Example:

const account = await rss3.ssets.patchTags(asset, tags);

Keywords

FAQs

Last updated on 23 Oct 2021

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc