GithubHelp home page GithubHelp logo

isabella232 / kotlin-common Goto Github PK

View Code? Open in Web Editor NEW

This project forked from uport-project/kotlin-common

0.0 0.0 0.0 328 KB

common libraries for kotlin implementations of uPort standards

License: Apache License 2.0

Kotlin 100.00%

kotlin-common's Introduction

uPort kotlin-common

CircleCI

Core interface definitions and default implementations for uPort kotlin SDK classes.

FAQ and helpdesk support

Modules

core

Contents
* definitions for the `HttpClient` used by all SDK methods,
* extension methods for dealing with base64,
* `ITimeProvider` and default implementation (`SystemTimeProvider`)
* `Networks` object and defaults for mainnet and the most used test networks
Usage
//use defaults
val registryAddress = Networks.mainnet.ethrDidRegistry //"0xdca7ef03e98e0dc2b855be647c39abe984fcf21b"

// register a testnet
Networks.registerNetwork(
    EthNetwork(
        name = "local",
        networkId = "0x1234",
        rpcUrl = "http://localhost:8545",
        ethrDidRegistry = "0xdca7ef03e98e0dc2b855be647c39abe984fcf21b"
    )
)

//register all popular public networks using your infura project ID
Networks.registerAllNetworksWithInfura("<YOUR INFURA ID>")

//use testnet
val net = Networks.get("0x1234")
or
val net = Networks.get("local")

// override defaults
Networks.registerNetwork(
    Networks.mainnet.copy(rpcUrl = "http://localhost:8545")
)
assertTrue(Networks.mainnet.rpcUrl == "http://localhost:8545")

jsonrpc

Contents

JSON RPC method wrappers used in the uPort SDK. This is not a complete set of methods and is meant to be internal. Use at your own risk.

signer-common

Contents

* `Signer` interface definition
* `KPSigner` default implementation. A `Signer` that uses a private key that lives in memory.
* extensions to provide coroutine functionality over callbacks
and to juggle with key and signature encodings

Usage

val signer :Signer = KPSigner("0x65fc670d9351cb87d1f56702fb56a7832ae2aab3427be944ab8c9f2a0ab87960")
//suspended call
val sigData = signer.signJWT("<some serialized JWT payload>")
val signatureString = sigData.getJoseEncoded()

test-helpers

Contents

Methods and extensions to ease testing with uPort SDK. coAssert extension for assertk isInstanceOf for multiple classes extension for assertk TestTimeProvider usable to juggle with time in JWT tests

Installation

These libraries are available through jitpack

In your main build.gradle file, add:

allprojects {
    repositories {
        maven { url 'https://jitpack.io' }
        //...
    }
}

In your module build.gradle file, add:

def uport_kotlin_common_version = "0.4.4"
dependencies {
    //...
    // core lib
    implementation "com.github.uport-project.kotlin-common:core:$uport_kotlin_common_version"
    //signer-common lib
    implementation "com.github.uport-project.kotlin-common:signer-common:$uport_kotlin_common_version"
}

NOTE while jitpack allows you to import the whole distribution like so: implementation "com.github.uport-project:kotlin-common:$uport_kotlin_common_version" it is NOT a good idea to import the whole distribution because it will bring assertk into your runtime and bloat your app/library.

Credits

This SDK depends on

kotlin-common's People

Contributors

beckkles avatar friedger avatar mirceanis avatar ugoamanoh avatar

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.