Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
rss3-next
Advanced tools
Readme
JavaScript SDK for RSS3-Hub
npm install rss3 --save
or
yarn add rss3
import RSS3 from 'rss3';
or
const RSS3 = require('rss3').default;
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.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.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.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.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.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.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.patchTags
assets.patchTags(asset: RSS3Asset, tags: string[]): Promise<RSS3Asset>
Example:
const account = await rss3.ssets.patchTags(asset, tags);
FAQs
JavaScript SDK for [RSS3-Hub](https://github.com/NaturalSelectionLabs/RSS3-Hub)
The npm package rss3-next receives a total of 1,870 weekly downloads. As such, rss3-next popularity was classified as popular.
We found that rss3-next demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.