Giter Club home page Giter Club logo

slashtags's Introduction

slashtags

JavaScript implementation of the Slashtags protocol


⚠️ This SDK is still in beta. Please use at your own risk.⚠️


Overview

Reboot the Web with Slashtags.

Slashtags is an open-source protocol for creating scalable and secure P2P applications. What Bitcoin has done for money and payments, Slashtags seeks to achieve for the rest of our digital data and interactions.

Slashtags enables you to build applications and websites that give users control over their social profiles, contacts, payment preferences, and other data; allow them to find your server in a p2p fashion and authenticate with just a key; stream account data from slashtag-enabled services; and more.

All the key pairs generated within Slashtags are based on a BIP-39 series of mnemonic words.

The problem

The modern Web is commonly called the Web 2.0. As the term was originally intended, it refers to a Web with services that are marked by interactive, personalized, easy, and engaging user experiences, interoperability, and scalability. This in contrast to Web 1.0 services, which were instead much more static, isolated, and less scalable. Think your personal website on Geocities from 1997.

While the Web 2.0 has brought a vastly enriched user experience, it has also become synonymous with the oppressive dominance of a few large tech companies—such as Google, Facebook, Youtube, and Twitter—and governments, particularly those with pronounced authoritarian leanings. The modern Web is increasingly marked by censorship, including financial censorship; active, passive, and analytical data collection, which harms our privacy and security; centralized chokepoints for key services against which users are relatively powerless (e.g., drastic changes in a service's policies, interface, or even sunsetting the service) and which form central points of failure; and a highly inefficient use of our communication infrastructure.

At the core of these problems is that regular Web users cannot easily identify themselves in a trustworthy manner online, and that the machines of ordinary users cannot easily communicate directly.

Slashtags' solution

A slashtag is a key pair derived from a standard BIP-39 series of mnemonic words, which is also used to generate Bitcoin addresses in practically all modern hardware and software wallets. Typically slashtags are associated with hyperdrives, personal drives for storing data that can be shared within a peer to peer network.

Just as Bitcoin was able to decentralize money and payments with the clever use of cryptographic keys, Slashtags can potentially decentralize much of the rest of our digital data and interactions. It's a simple, yet powerful idea.

How it works

As already mentioned, at the core of Slashtags is a special type of file drive called a hyperdrive. Each hyperdrive is associated with an ed25519 private-public keypair derived from a BIP-39 master node and a name for the drive. What is known as the discovery key is a blake2b hash value of the public key.

Hyperdrives can be discovered, read, and seeded by peers on a network. The group of peers that stores some or all of the drive’s data is known as its swarm.

Members of the swarm are tracked within a Kademlia-based distributed hash table system on the basis of the hyperdrive’s discovery key. Connections with members of the swarm and DHT nodes are made on the basis of a highly robust UDP holepunching algorithm. The distributed hash table system is known as Hyperswarm.

Only the owner of the private key for a hyperdrive can make changes to it. Yet, other peers in the network can read and seed the data, as long as they have the discovery key. So in order to share a particular hyperdrive with a peer, one just has to hand over its public key. Schemas for particular data types help ensure efficient data retrieval and resolution, as well as interoperability between applications.

Hyperdrive data can be retrieved from any peer within the swarm. Slashtags relies on a digital signature procedure to ensure that peers can always determine the latest state of a particular hyperdrive. Specifically, all data is added to hyperdrives via blocks. Adding a block, requires making a valid signature over the merkle root of all the hash values of the existing blocks and the new block. Only when a valid signature is given will the block be added to the hyperdrive.

Hyperdrives are simple, yet powerful. For example, suppose that you created a profile with an e-mail address, website, twitter handle, and so on in a hyperdrive that you owned. Once you share the public key of the hyperdrive with a contact, they can always retrieve your latest contact information. No big tech company or authoritarian government can stop them. No company going out of business impacts easy data availability. This decentralized character can be extended to other types of data and features in applications.

While much of the power of Slashtags comes via these hyperdrives, the key pairs that can be generated with Slashtags also can have important utility on their own. Bi-lateral, peer to peer authentication between a user and a server can, for example, be realized just on the basis of key pairs.

Slashtags in action

The first showcase for Slashtags is the Bitkit wallet. The following features are powered by Slashtags: profiles, contacts, payment preferences, authentication, private feeds, and public feeds. Please consult our website and our Github repository for more information. The website includes a Playground for you to experiment.

We currently support three public data widgets that can be displayed within the wallet: a bitcoin price feed, a bitcoin news feed, a bitcoin block data feed.

Finally, we also have an authentication demo.

We are currently developing various other applications that implement Slashtags and are actively supporting others with their own Slashtags projects.

Structure

The SDK is offered as a single module in the sdk package. The other packages contain components of the SDK. These include the following:

Installation

npm install @synonymdev/slashtags-sdk,

To create a slashtag with the name 'alice' and to output the url, proceed as follows:

import SDK from '@synonymdev/slashtags-sdk';

const sdk = new SDK();
const alice = sdk.slashtag('alice');

console.log(alice.url.toString());
// slash:abc...xyz

Documentation

Documentation is a still work in progress. But you can start by reading the available specs, checking out the examples and read through the API documentation of any subpackage in its README.md.

Examples

Run npm install in the root directory first.

Look into the examples to learn how to see Slashtags in action.

Development

Requires Node LTS (v16.5.0). nvm is supported but not required

npm install

slashtags's People

Contributors

bitcoinerrorlog avatar coreyphillips avatar dependabot[bot] avatar duck1123 avatar dzdidi avatar escapedcat avatar git-sgmoore avatar jasonvdb avatar jwburgers avatar mikeobank avatar nuhvi avatar pablof7z avatar rbndg avatar varsnotwars avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

slashtags's Issues

sdk.drive(key) for an internal drive!

The normal way to read an internal drive is slashtag.drivestore.get(...) ... but sdk.drive(key) should work for internal drives too.. it should also avoid announcing the topic with srever: false option.

migrate to using keypear derivation

  • Update NS to use standard of hypercore namespace generation
crypto_generichash(out=NS, input=Buffer.from([0]), ns=Buffer.from('slashtags'))
  • Merge keychain branch to enable hyperdrive derivation with keychain

    • hash scalar before using as a tweak
  • Use device tweaks and figure out the UX around that

    • Show root URL to user?
    • maybe slash:<root key>:<tweak> ??

disallow registering slashprotocols after initialization

Since connections are cached, registering a protocol at an arbitrary point of the program sets the wrong expectation, namely that older connections will not have access to newer protocols.

slashtag.protocol() should then only be used for fetching protocol instances, but not registering new ones.

New name for this aspect?

Calling the each item a "slashtag" is okay, but referring to the whole use case as Slashtag feels awkward while calling the protocol Slashtags. Is this not "Slashtags"?

Should this be something more descriptive, like SlashID, or SlashNames, or Accounts? Or, what do you recommend?

@synonymdev/slashtags-docid not found in NPM registry

Root-level npm run install fails with:

npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/@synonymdev%2fslashtags-docid - Not found
npm ERR! 404 
npm ERR! 404  '@synonymdev/slashtags-docid@^0.1.0' is not in this registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)

The url package depends on @synonymdev/slashtags-docid which is not found in NPM.

The wallet demo in demo/auth/wallet similarly fails on npm install, as its dependency @synonymdev/slashtags-url expects @synonymdev/slashtags-docid.

Typescript errors: can't use namespaces as types

Errors in building a TS project that consumes Slashtags Auth.

tsconfig.json

TODO

Errors:

$ tsc
node_modules/@synonymdev/slashtags-auth/types/packages/auth/src/auth.d.ts(27,67): error TS2694: Namespace '"*"' has no exported member 'JsonLdObject'.
node_modules/@synonymdev/slashtags-auth/types/packages/auth/src/interfaces.d.ts(5,31): error TS2709: Cannot use namespace 'WithContext' as a type.
node_modules/@synonymdev/slashtags-auth/types/packages/auth/src/interfaces.d.ts(5,43): error TS2709: Cannot use namespace 'Thing' as a type.
node_modules/@synonymdev/slashtags-auth/types/packages/auth/src/interfaces.d.ts(10,14): error TS2709: Cannot use namespace 'KeyPair' as a type.
node_modules/@synonymdev/slashtags-auth/types/packages/auth/src/interfaces.d.ts(15,23): error TS2709: Cannot use namespace 'JsonLdObject' as a type.
node_modules/@synonymdev/slashtags-auth/types/packages/auth/src/interfaces.d.ts(19,23): error TS2709: Cannot use namespace 'JsonLdObject' as a type.
node_modules/@synonymdev/slashtags-auth/types/packages/auth/src/interfaces.d.ts(24,21): error TS2709: Cannot use namespace 'JsonLdObject' as a type.
node_modules/@synonymdev/slashtags-rpc/types/packages/rpc/src/interfaces.d.ts(21,48): error TS2709: Cannot use namespace 'JSONElement' as a type.
node_modules/@synonymdev/slashtags-rpc/types/packages/rpc/src/interfaces.d.ts(29,68): error TS2709: Cannot use namespace 'JSONElement' as a type.
node_modules/@synonymdev/slashtags-rpc/types/packages/rpc/src/interfaces.d.ts(29,83): error TS2709: Cannot use namespace 'JSONElement' as a type.
node_modules/@synonymdev/slashtags-rpc/types/packages/rpc/src/interfaces.d.ts(34,15): error TS2709: Cannot use namespace 'JSONElement' as a type.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

CommonJS compatibility

Hi

I can't use slashtags packages in my Zerologin project as is. Zerologin is developed using AdonisJS framework version 5 which uses CommonJS (next version 6 should be ESM first)
Is there a possibility to add CommonJS compilation next to ESM?

Thanks

react-native Unable to resolve module ws

Hi guys, after installing slashtags-sdk via npm, i get the following error:

Screen Shot 2022-12-15 at 13 06 03

included postinstall-slashtags.js used in BitKit app but fail on esbuild

== postInstallSlashtags.js
✘ [ERROR] Unexpected "typeof"

Thanks in advance.

Demos link is a deadend link

Can you fix the dead link from this sentence in the readme.md file?

Currently the best way to get familiar with the existing features is to check the Demos.

I get the image below when I click on "demos" link.
image

Demo does not work (missing imports, dht-relay version not fixed)

I get the following error when I start the wallet:
TypeError: Cannot read properties of undefined (reading 'fromTransport')

Looking at dht-relay, their API has changed.

In packages/auth/package.json, it seems the following import is needed:
"@synonymdev/slashtags-core": "^0.1.1",

In packages/rpc/package.json, I updated to use this specific version of dht-relay:
"@hyperswarm/dht-relay": "github:hyperswarm/dht-relay#v0.0.0",
and also added ws:
"ws": "^8.5.0"

After making the changes I still couldn't run the demo. It looks like the demo is pulling the synonymdev dependencies from npm rather than the locally built packages. Is this right?

https://slashtags.netlify.app/ and https://slashtags-wallet.netlify.app/ are working fine.

Linting

Any plans for adding ESLint?

add drivestore.closed getter

checking if the drivestore is closed before drivestore.get() is very useful to avoid errors thrown by the corestore.

Add roadmap summary

After we polish the existing text, I'd like to add a section that lists features / use cases that are upcoming, just so we can fill out the vision for the reader (like the role WoT can play).

Revert turning url to lower case on parsing

In core-data we have driveKey and encryptionKey and possibly other future query params that need case sensitivity.

The current implementation depends on having a / at the end of the ID part of the url. Maybe it is not worth it at all.

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.