Coder Social home page Coder Social logo

capsulesocial / capsule-near Goto Github PK

View Code? Open in Web Editor NEW
7.0 3.0 1.0 236 KB

Blogchain's NEAR smart contracts

Home Page: https://explorer.near.org/accounts/blogchain.near

License: GNU Affero General Public License v3.0

TypeScript 99.86% JavaScript 0.14%
blogchain near web3 capsulesocial

capsule-near's Introduction

Capsule NEAR

A repository to store NEAR smart contracts used by Blogchain

Requirements

  • NEAR CLI - to deploy the smart contract
    • npm install -g near-cli (globally installs NEAR CLI)

Installation

yarn install - Installs all dependencies

Warning: One of the indirect dependencies of this repo -- near-vm does not support Darwin ARM64, so this repo can't be installed in your M1 as of today (20th October, 2021)

Build Smart Contract

To build the contract, run yarn asb or yarn asb build. The .wasm file after successful build is located at: build/release/capsule-near.wasm

Deploy Smart Contract

Make sure you have installed NEAR CLI before moving any further.

For purposes of testing, you can create a dev-account on NEAR testnet and deploy the smart contract. To do this, simply run: near dev-deploy build/release/capsule-near.wasm

If you want to deploy it on a named testnet or mainnet account, run:

  1. near login - login to the account you want to deploy the contract in. On successful login, a full access key is stored in ~/.near-credentials/ directory.
  2. near deploy --contractName=<your_NEAR_account_id> --keyPath=<absolute_path_to_near_credentials_file> --wasmFile=<wasm_file_to_deploy>

Example: near deploy --contractName=dev-1627894343033-9726641 --keyPath=/home/tomash/.near-credentials/testnet/dev-1627894343033-9726641.json --wasmFile=./build/release/capsule-near.json

Legend: return values from setUserInfo

When a user registers their account on capsule, the client calls setUserInfo function of the contract. setUserInfo returns an integer between 1 and 5, where each integer means the following:

Return value Description
1 Successful user-info update / registration
2 Length of given username is less than the minimum permissible length = 3
3 Username already exists, and is owned by a different NEAR account
4 Length of given username exceeds maximum permissible length = 18
5 NEAR account associated with the transaction is already linked to another username
6 AccountID does not have a valid invite code
7 Invalid username; username is blocklisted
8 Invalid username; username contains invalid characters

Legend: return values from onboardAccount

Return value Description
0 Transaction sender not permitted to onboard account
1 Successfully onboarded an accountId, they can proceed with registration ie. setUserInfo
2 Invalid accountId
3 accountId has already been onboarded

Legend: return values from requestSetUserInfo

Return value Description
1 Successful user-info update / registration request
2 Length of given username is less than the minimum permissible length = 3
3 Username already exists, and is owned by a different NEAR account
4 Length of given username exceeds maximum permissible length = 18
5 NEAR account associated with the transaction is already linked to another username
6 AccountID does not have a valid invite code
7 Invalid username; username is not blocklisted
8 Invalid username; username contains invalid characters

Legend: return values from verifySetUserInfo

Return value Description
0 Transaction sender not permitted to onboard account
1 Successful user-info update / registration
2 Input username doesn't exist in the list of requested usernames to register
3 Username already exists, and is owned by a different NEAR account
5 NEAR account associated with the input username is already linked to another username

Legend: classification code for banning

Code Description
1 Content that is deemed illegal under United States law or Delaware state law, where Capsule Social, Inc. is based. This includes terrorism, fraud, extortion, and many types of pornography or non-consensual intimate imagery (NCII)
2 Specifically targeted, real threats of violence or incitement to violence, including wishing or hoping that someone experiences physical harm. Persistent, malicious, targeted harassment or incitement to harassment. Promoting or encouraging suicide
3 Pornography or sexually exploitative content. We do allow depictions of nudity for artistic, journalistic, or related purposes, as well as erotic literature. Users may be asked to self-identify non-porn adult content and may have their accounts locked if they do not identify content correctly
4 Extremely gruesome, violent content, or content glorifying violence
5 Non-consensually posting an individual’s confidential personal information such as, for example, home address, passport number, or social security number (”doxxing”)
6 Any content that is the result of a software or platform error or vulnerability
7 Plagiarism or the impersonation of any individual, group, or organization
8 Spam is also considered delistable content. Spam may take many forms, including but not limited to: repeated, unwanted, and/or unsolicited actions, automated or manual, that negatively affect users, groups, and/or the Blogchain platform itself; Content that is designed to further unlawful acts (such as phishing) or mislead recipients as to the source of the material (such as spoofing); Commercially-motivated spam that typically aims to drive traffic from Blogchain over to another website, service or initiative through backlinking or other inauthentic methods; Inauthentic engagements that try to make channels or content appear more popular than they are; Coordinated activity that attempts to artificially influence opinion through the use of multiple accounts, fake accounts, and/or scripting or automation

Legend: return values from setPrivateSub

When a user sets up a subscription on capsule, capsule-server calls setPrivateSub function of the contract. setPrivateSub returns an integer between 0 and 2, where each integer means the following:

Return value Description
0 Transaction sender not permitted to initiate private subscription
1 Successfully initiated private subscription for a username
2 User does not exist

License

GNU AFFERO GENERAL PUBLIC LICENSE 3

capsule-near's People

Contributors

ashutosh1206 avatar chrispanag avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

haikukoten

capsule-near's Issues

Store subscription-capability-related information of an author on-chain

We need a place to store information related to an author's subscription capability, which access controllers in OrbitDB nodes can query to see if an author has set up a paid subscription or not. Nodes will replicate paid-subscription content by author only if the author has paid-subscription capability.

Why store this on NEAR, and not in some centralised server?
The idea is that in the event of failure of capsule-server (shutdown, unreachable from the network etc.), nodes should still be able to replicate paid-subscription content.

Who should be able to set and unset values related to an author's subscription capability on NEAR?
A set of Capsule-owned accounts

These capsule-owned accounts will be able to control who is / is not allowed to have paid subscriptions

No need to install asbuild separately

There's a direct dependency on asbuild in package.json, hence there should be no need to install asbuild separately. Find out if there's some issue with yarn.lock file that it's not installing asbuild. If not, then update README accordingly.

Minor issue.

CAP-01-017 WP2-4: Absence of Capsule user block functionality (Low)

During the assessment of the Capsule software complex’s backend repositories, the observation was made that the system lacks functionality to revoke or block users. This functionality is vital to software solutions that incorporate cryptographic primitives for user identification, such as via a public and private key pair as is the case for Capsule.

Without such a mechanism in place, the impact of a stolen key becomes significant for the victim user, since the software does not provide any means to block an attacker from impersonating the victim.

Recommendation:

It is recommended to implement a blocking or revocation mechanism for Capsule which effectively blocks a user from interacting with Capsule when access is revoked. As Capsule utilizes NEAR, it is advisable to block or remove the stolen key material from the smart contract so that the attacker cannot post content on behalf of the victim user.

Find which username wants to sign-in, without a username field

Currently, we can't directly and efficiently lookup a capsule-username corresponding to a NEAR public key or NEAR account, with the current on-chain structure. So if we choose to have a password-less login (no username or password field. eg. torus), there needs to be some way to find username corresponding to a NEAR accountId or NEAR public key.

To tackle this, we came up with a solution that requires modifying how we store data on NEAR: https://www.notion.so/capsulesocial/Username-namespacing-on-NEAR-c737c5b54ec34fe8afb367655ed31709#981b8275e5d84eeab21e8d5d5d45f264

Deadline: 27th October, 2021

modify block list to include cid of offending content and a classification (nunber) code for the block reason

As per this doc: https://www.notion.so/capsulesocial/Content-Policy-Roadmap-52fc5b42fdba47bfb70765d5a8739af4

Content may only be delisted through a smart contract call, which must include the following information:

  • The username that is being locked.
  • The IPFS CID of the post that led to the delisting.
  • A timestamp.
  • Classification code for delisting reason.

The CID should be optional, the classification code could be any integer.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.