uport-appuser
TypeScript icon, indicating that this package has built-in type declarations

0.2.2 • Public • Published

title: "uPort AppUser" index: 0 category: "appuser" type: "reference" source: "https://github.com/uport-project/appuser/blob/develop/README.md"

uPort AppUser

uPort AppUser allows you to build a User model for your decentralized or wannabe decentralized app. It brings back some of the niceties of running a centralized app, while protecting both you and your users from accidental leaking private data.

Features:

  • Actionable usage metrics such as DAU, browser distribution etc without relying on Google
  • Strictly partition and interactions into the following buckets
    • Private to your user
    • Shared between you and your user
    • Meta data for permissioned tracking
  • Share usage metrics with your community and investors
  • Strong Encryption
  • Extremely Lightweight (20kb)

Web Sites

Quick Script Tag installation

If you are familiar with installing traditional analytics platforms all you have to do is add the following snippet at the bottom of your html page.

<script language=“javascript” src=“https://unpkg.com/uport-appuser” />
<script language="javascript">
window.user = AppUser.init()
user.track('buy.tokens', {private: {address: '0x...'}, claims: {success: true}, shared: {amount: 123})
</script>

That’s it. Once you’ve deployed it go to https://metrics.uport.me/ enter your domain name and watch the data come in.

Share your results on social media to your community.

Advanced JavaScript Installation

In your web project add the uport-appuser package to your project.

npm install --save uport-appuser

Initialize the framework with:

import AppUser from 'uport-appuser'
 
// Wherever you initialize your app initialize the tracker
const user = new AppUser()
 
// This will automatically track page visits,
 
// Track specific events within your app and add optional data along. Don’t worry only your customer and you can access this
user.track('buy.tokens', {private: {address: '0x...'}, claims: {success: true}, shared: {amount: 123})

Setup Application Identity

All user data is encrypted and can only be accessed by your users. To access the raw data yourself you need to publish a Decentralized Identifiers (DIDs) Document containing your encryption public key.

DID Document

Create a DID document and place it in the following directory on your website:

https://example.com/.well-known/did.json

A minimal DID Document might contain the following information:

{
  "@context": 'https://w3id.org/did/v1',
  "id": 'did:https:example.com',
  "publicKey": [{
       id: 'did:https:example.com#owner',
       type: 'Secp256k1VerificationKey2018',
       owner: 'did:https:example.com',
       ethereumAddress: '0xb9c5714089478a327f09197987f16f9e5d936e8a'},
       {
    "id": "did:https:example.com#encrypt",
   "type": 'Curve25519EncryptionPublicKey',
"publicKeyBase58":"H3C2AVvLMv6gmMNam3uVAjZpfkcJCwDwnZn6z3wXmqPV"
    }],
  authentication: [{
       type: 'Secp256k1SignatureAuthentication2018',
       publicKey: 'did:https:example.com#owner'}]
  },
  "services": [{
    "id": "did:https:example.com;events",
    "type": "EventService",
    "serviceEndpoint": "https://appuser.uport.me/api/v1/events"
  }]
}

Note this has to have a public key using Curve25519EncryptionPublicKey.

Encryption is performed using tweetnacl. The Public key is created using box.keyPair() and Base64 encoded.

Create a DDO document easily

npm install --save appuser
./node_modules/.bin/create-appuser-ddo https://example.com > did.json

It will display a private key that you should store somewhere safe.

Readme

Keywords

none

Package Sidebar

Install

npm i uport-appuser

Weekly Downloads

4

Version

0.2.2

License

Apache-2.0

Unpacked Size

245 kB

Total Files

26

Last publish

Collaborators

  • pelleb