Coder Social home page Coder Social logo

uport-project / kotlin-did-jwt Goto Github PK

View Code? Open in Web Editor NEW
8.0 8.0 6.0 592 KB

Create and verify uPort and DID compliant JWTs in Kotlin

Home Page: https://developer.uport.me

License: Apache License 2.0

Kotlin 100.00%
did jwt uport ethereum erc1056 resolver kotlin sign verify did-resolver

kotlin-did-jwt's People

Contributors

beckkles avatar friedger avatar mirceanis avatar ugoamanoh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

kotlin-did-jwt's Issues

keys in ethr-did documents should list `controller` instead of `owner`

The DID spec mentions a controller property for DID public key entries.
Our resolver uses owner to describe a similar concept.

There is a slight difference in semantics. When the owner of an identity is changed in the ERC1056 registry, this should be reflected in the DID document entry in the controller field of the root key.

More specifically, if keyA calls changeOwner, listing keyB as the new owner, the DID document entry now looks like this:

{
    id: 'did:ethr:0xkeyA#owner',
    type: 'Secp256k1VerificationKey2018',
    owner: 'did:ethr:0xkeyA',
    ethereumAddress: '0xkeyB'
}

A correction should be made to the did-resolver such that the public key entry should appear like so:

{
    id: 'did:ethr:0xkeyA#owner',
    type: 'Secp256k1VerificationKey2018',
    controller: 'did:ethr:0xkeyB',
    ethereumAddress: '0xkeyB'
}

This mirrors [ #168401735 ] in PT

Better management for StatusEntry an related errors

accept and use an optional StatusEntry param for checkStatus() to deduplicate parsing of credentials and to support verification of credentials that don't necessarily embed a status entry.

rethink exceptional cases to accommodate credentials that don't embed status, and create more informative errors for misconfigured status methods or malformed entries.

create and use a CredentialStatus implementation that is only used to signal a credential that doesn't declare a status checking method.

Allow for . (dot) and - (minus) charaters in did ethr-network (method-specific-id)

There are some regular expression that only allow \\w (ALPHA / DIGIT / "_") in the the ethr-network part of the ethr-did.

Examples I found:

"^(did:)?((\\w+):)?((\\w+):)?((0x)([0-9a-fA-F]{40}))".toRegex()

private val identityExtractPattern = "^did:ethr:((\\w+):)?(0x[0-9a-fA-F]{40})".toRegex()

private val didParsePattern = "^(did:)?((\\w+):)?((\\w+):)?(0x[0-9a-fA-F]{40})".toRegex()

Although the ethr-method only specifies a fixed set of networks in its spec, the more general did-core allows for ALPHA / DIGIT / "." / "-" / "_". I want this lib to be future proof for new networks with dot and minus in their network name!

I'm planning to add a network to the spec if a - in the name.

Documentation for Revocations

Add documentation about how to use credential-status and ethr-status methods

perhaps revisit the names of classes along the way to make sure the API is intuitive.

deprecate the `UniversalDID` singleton

Development checklist

  • 1. deprecate the UniversalDID object
  • 2. in the universal-did module, create a DIDResolverImpl internal class with the same functionality as UniversalDID, just not a singleton
  • 3. create builder pattern for DIDResolver that returns a DIDResolverImpl instance
    example usage:
    val resolver : DIDResolver = DIDResolver.Builder
    .addResolver(ethrDidResolver)
    .addResolver(/*...*/)
    .build()
  • 4. remove UniversalDID initialization code from JWTTools constructor.
  • 5. create a module called uport-defaults
    • 5.1 Create a fun DIDResolver.configureDefaultsWithInfura(infuraProjectId : String) : DIDResolver extension method
    • 5.2 This method should call a DIDResolver.Builder that uses the provided infuraProjectId to configure all the common networks and resolvers in a manner similar to the UniversalDID initialization done in the current JWTTools constructor.
    • 5.3 remove now unused dependencies from the jwt module. It should no longer depend on ethr-did, web-did, uport-did
  • 6. Update documentation to reflect new usage patterns

Upgrade kotlin serialization

The package for serialization has changed to
org.jetbrains.kotlinx:kotlinx-serialization-json:1.2.1

Having both the json (new package) and the runtime (user by this project) library in the project causes the compiler to fail with NullPointerException

add support for `did:web:*`

The discussion here indicates that the https did method name is too broad and it should be renamed to web.
For compatibility reasons the old method name should still be supported but deprecated.

  • canResolve(<web did>) allows did:web:example.com as well as did:https:example.com
  • resolve(<web-did | https-did>) resolves the same DID doc
  • rename HttpsDID and related classes to WebDID, etc
  • rename module to web-did

Use a local universal Resolver instance instead of a global object

This universal Resolver object would have its own resolve method which can take any did and use the correct method specific resolver.

This local Resolver instance should be used during jwt verification instead of the global.
For this to happen correctly, the already configured uni-resolver should be injected into JWTTools during construction.

This mirrors [ #167845321 ] on PT

Acceptance

  • new verifyJWT method that also accepts a Resolver
  • old method should be marked as deprecated

attribute changed events with null chars in name are not counted

Scenario

val resolver = EthrDidResolver.Builder().addNetwork(Networks.mainnet).build()
val ddo = resolver.resolve("0xE6Fe788d8ca214A080b0f6aC7F48480b2AEfa9a6")

Expected behavior

ddo should contain a PublicKeyEntry of type secp256k1VerificationKey2018 with a publicKeyHex value of 0x0295dda1dca7f80e308ef60155ddeac00e46b797fd40ef407f422e88d2467a27eb according to this tx: 0x9d770e99da67685f7af83a2743962b5f02335c8abb069ef511cc982864aa8bee

Actual behavior

The default DID document is returned, without that key entry.

Support network configuration and offline testing

offline tests - there should be no instantiation of JsonRPC during a check so that it can be mocked out during tests.

constructor configuration of the CredentialStatus aggregator class (as opposed to registerResolver)

use lower case kethereum dependencies

gradle gets confused if the two dependencies are in a gradle project:

implementation "com.github.walleth.kethereum:wallet:$kethereum_version"
implementation "com.github.uport-project.kotlin-did-jwt:jwt:$did_jwt_version"

due to upper case letter of KEtherum in build.gradle file.

Exception in thread "main" java.lang.NoClassDefFoundError: okhttp3/Request$Builder

This happens in a project that is not explicitly importing the okhttp dependency.
This is signaling a dependency declaration issue.

When fixed this would also negate the need to declare testImplementation("com.squareup.okhttp3:okhttp:3.14.1") in projects that use it for testing.

Workaround

dependencies {
  //...
  implementation("com.squareup.okhttp3:okhttp:3.14.1")
}

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.