generated from TBD54566975/tbd-project-template
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3a95df4
commit 5a79dc7
Showing
13 changed files
with
177 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/bash | ||
|
||
for dir in */; do | ||
echo "Entering directory: $dir" | ||
(cd "$dir" && ./build) | ||
echo "Finished building in $dir" | ||
echo "------------------------" | ||
done | ||
|
||
echo "All builds completed" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
bound/kt/src/main/kotlin/web5/sdk/dids/methods/web/DidWeb.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package web5.sdk.dids.methods.web | ||
|
||
import kotlinx.coroutines.runBlocking | ||
import web5.sdk.crypto.keys.Jwk | ||
import web5.sdk.dids.Did | ||
import web5.sdk.dids.Document | ||
import web5.sdk.dids.ResolutionResult | ||
import web5.sdk.rust.SystemTarget | ||
|
||
import web5.sdk.rust.didWebResolve as rustCoreDidWebResolve | ||
import web5.sdk.rust.DidWeb as RustCoreDidWeb | ||
|
||
/** | ||
* A class representing a DID (Decentralized Identifier) using the Web method. | ||
* | ||
* @property did The DID associated with this instance. | ||
* @property document The DID document associated with this instance. | ||
*/ | ||
class DidWeb { | ||
init { | ||
SystemTarget.set() // ensure the sys arch is set for first-time loading | ||
} | ||
|
||
val did: Did | ||
val document: Document | ||
|
||
/** | ||
* Constructs a DidWeb instance using a DID URI. | ||
* | ||
* @param uri The DID URI. | ||
*/ | ||
constructor(uri: String) { | ||
val rustCoreDidWeb = runBlocking { | ||
RustCoreDidWeb.fromUri(uri) | ||
} | ||
|
||
this.did = rustCoreDidWeb.getData().did | ||
this.document = rustCoreDidWeb.getData().document | ||
} | ||
|
||
/** | ||
* Constructs a DidWeb instance using a domain and public key jwk | ||
* | ||
* @param domain The DID domain name. | ||
*/ | ||
constructor(domain: String, publicKey: Jwk) { | ||
val rustCoreDidWeb = runBlocking { | ||
RustCoreDidWeb.fromPublicJwk(domain, publicKey); | ||
} | ||
|
||
this.did = rustCoreDidWeb.getData().did | ||
this.document = rustCoreDidWeb.getData().document | ||
} | ||
|
||
companion object { | ||
/** | ||
* Resolves a DID URI to a DidResolutionResult. | ||
* | ||
* @param uri The DID URI to resolve. | ||
* @return DidResolutionResult The result of the DID resolution. | ||
*/ | ||
@JvmStatic | ||
fun resolve(uri: String): ResolutionResult { | ||
val rustCoreResolutionObject = | ||
runBlocking { | ||
rustCoreDidWebResolve(uri).getData() | ||
} | ||
return rustCoreResolutionObject | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+18.1 KB
(100%)
bound/kt/src/main/resources/libweb5_uniffi_aarch64_apple_darwin.dylib
Binary file not shown.
Binary file modified
BIN
+27.8 KB
(100%)
bound/kt/src/main/resources/libweb5_uniffi_x86_64_apple_darwin.dylib
Binary file not shown.
Binary file modified
BIN
-8.27 KB
(100%)
bound/kt/src/main/resources/libweb5_uniffi_x86_64_unknown_linux_gnu.so
Binary file not shown.
Binary file modified
BIN
-140 KB
(100%)
bound/kt/src/main/resources/libweb5_uniffi_x86_64_unknown_linux_musl.so
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
bound/kt/src/test/kotlin/web5/sdk/dids/methods/web/DidWebTests.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package web5.sdk.dids.methods.web | ||
|
||
import org.junit.jupiter.api.Assertions.* | ||
import org.junit.jupiter.api.Test | ||
import web5.sdk.rust.ed25519GeneratorGenerate | ||
|
||
class DidWebTests { | ||
|
||
@Test | ||
fun `can create did web`() { | ||
val domain = "example.com" | ||
val jwk = ed25519GeneratorGenerate(); | ||
|
||
val didWeb = DidWeb(domain, jwk) | ||
assertEquals(didWeb.did.uri, "did:web:example.com") | ||
assertEquals(didWeb.document.verificationMethod.get(0).publicKeyJwk, jwk) | ||
} | ||
|
||
@Test | ||
fun `can resolve did web uri`() { | ||
// Works if you host a local did web document You must host this json at http://localhost:1234/.well-known/did.json | ||
// val didDocumentJson = """ | ||
// { | ||
// "id":"did:web.tbd.website", | ||
// "@context":[ | ||
// "https://www.w3.org/ns/did/v1" | ||
// ], | ||
// "verificationMethod":[ | ||
// { | ||
// "id":"did:web:www.tbd.website#key-0", | ||
// "type":"JsonWebKey", | ||
// "controller":"did:web:www.tbd.website", | ||
// "publicKeyJwk":{ | ||
// "alg":"Ed25519", | ||
// "kty":"OKP", | ||
// "crv":"Ed25519", | ||
// "x":"gNFtgCZhOYv00p48FHQYt4edkoBPOyw0oGAB20LrT0c" | ||
// } | ||
// } | ||
// ] | ||
// } | ||
// """.trimIndent() | ||
// | ||
// val didUri = "did:web:localhost%3A1234" | ||
// val resolvedDid = DidWeb.resolve(didUri) | ||
// | ||
// assertEquals(resolvedDid.document!!.id, "did:web:www.tbd.website") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters