Convo SDK

SDK containing all the functions you'll need to build on theconvo.space

🌲 Tree Shaking Supported ✔️
🆓 Side Effect Free ✔️
🪨 Fully TypeScript Compatible ✔️
🤏 Just 8.16kB Minified (1.8kB Minified+GZipped)

Jump to Sample Projects Try it Out

Installation

NodeJs

yarn add @theconvospace/sdk

Browser

<script src="https://cdn.jsdelivr.net/npm/@theconvospace/sdk@0.1.9/dist/bundle.min.js"></script>

Setup

  1. Generate and Copy an API key from https://theconvo.space/dashboard/developer
  2. Import Convo in your own project.
    import { Convo } from '@theconvospace/sdk';
    // or
    import { Convo } from 'https://esm.run/@theconvospace/sdk';
    // or
    const { Convo } = require('@theconvospace/sdk');
  3. Setup an new instance of Convo using
    const convo = new Convo("apikey")
    Replace apikey with your newly generated key.

Auth

Authenticate Session

let resp = await convo.auth.authenticate(
signerAddress, // Ethereum Address or NEAR Public Key
signature, // Signed Data in Hex
timestampm // Signed Data in Hex
chain, // Name of the Chain
accountId: // Near Account Id
);

Example Usage,

let timestamp = Date.now();
let data = convo.auth.getSignatureData(accounts[0], timestamp);
let signature = await web3.send(
'personal_sign',
[ethers.utils.hexlify(ethers.utils.toUtf8Bytes(data)), accounts[0].toLowerCase()]
);
convo.auth.authenticate(accounts[0], signature, timestamp, "ethereum").then(console.log);

Validate Authentication

let resp = await convo.auth.validate(
signerAddress, // Ethereum Address or NEAR Public Key
token // JWT Auth Token
);

Example,

convo.auth.validate(
accounts[0],
""
).then(console.log);

Get Signature Data

let resp = convo.auth.getSignatureData(
signerAddress, // Ethereum Address or NEAR Public Key
timestamp // timestamp
);

Example,

let timestamp = Date.now();
console.log(convo.auth.getSignatureData(accounts[0], timestamp));

Comments

Create a Comment

convo.comments.create(
signerAddress, // Ethereum Address or NEAR Public Key
token, // JWT Auth Token
comment, // Comment text
threadId, // Unique threadId
url // Url of the page where the message is from.
)

Example,

let resp = await convo.comments.create(
accounts[0],
"",
"New",
"KIGZUnR4RzXDFheXoOwo",
encodeURIComponent('https://theconvo.space/')
);

Delete a Comment

convo.comments.delete(
signerAddress, // Ethereum Address or NEAR Public Key
token, // JWT Auth Token
commentId // Comment ID
)

Example,

let resp = await convo.comments.delete(
accounts[0],
"",
"KIGZUnR4RzXDFheXoOwo"
);

Toggle Upvote

convo.comments.toggleUpvote(
signerAddress, // Ethereum Address or NEAR Public Key
token, // JWT Auth Token
commentId // Comment ID
)

Example,

let resp = await convo.comments.toggleUpvote(
accounts[0],
"",
"KIGZUnR4RzXDFheXoOwo"
);

Toggle Downvote

convo.comments.toggleDownvote(
signerAddress, // Ethereum Address or NEAR Public Key
token, // JWT Auth Token
commentId // Comment ID
)

Example,

let resp = await convo.comments.toggleDownvote(
accounts[0],
"",
"KIGZUnR4RzXDFheXoOwo"
);

Query Comments

Threads

Identity

Get TrustScore for Address

convo.identity.getTrustScore(
signerAddress, // Ethereum Address
)

Example,

let resp = await convo.identity.getTrustScore(
"0x707aC3937A9B31C225D8C240F5917Be97cab9F20"
);

Utility

Log Internal Config

convo.logConfig()

Example,

let resp = await convo.logConfig();

Sample Projects

  1. NextJS/React Sample Project
    Code | Demo - convosdk-examples-nextjs.vercel.app

  2. Browser (Vanilla JS) Sample Project
    Code | Demo - convosdk-examples-browser.vercel.app

Comments