Skip to content

Commit

Permalink
chore: Switch Cheqd registrar to newer version
Browse files Browse the repository at this point in the history
  • Loading branch information
waltkb committed May 30, 2023
1 parent 49b6fe8 commit 285bcc9
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ object CheqdService {

private const val verificationMethod = "Ed25519VerificationKey2020"
private const val methodSpecificIdAlgo = "uuid"
private const val registrarUrl = "https://registrar.walt.id/cheqd"

//private const val registrarUrl = "https://registrar.walt.id/cheqd"
private const val registrarUrl = "https://did-registrar.cheqd.net"
private const val registrarApiVersion = "1.0"
private const val didCreateUrl =
"$registrarUrl/$registrarApiVersion/did-document?verificationMethod=%s&methodSpecificIdAlgo=%s&network=%s&publicKeyHex=%s"
Expand Down Expand Up @@ -73,7 +75,7 @@ object CheqdService {
} ?: throw IllegalArgumentException("Failed to fetch the did document from cheqd registrar helper")
}

fun deactivateDid(did: String){
fun deactivateDid(did: String) {
val job = initiateDidJob(didCreateUrl, KlaxonWithConverters().toJsonString(JobDeactivateRequest(did)))
?: throw Exception("Failed to initialize the did onboarding process")
val signatures = signPayload(KeyId(""), job)
Expand All @@ -86,11 +88,11 @@ object CheqdService {
?: throw Exception("Failed to finalize the did onboarding process")
}

fun updateDid(did: String){
fun updateDid(did: String) {
TODO()
}

private fun initiateDidJob(url: String, body: String) = let{
private fun initiateDidJob(url: String, body: String) = let {
val response = runBlocking {
client.post(url) {
contentType(ContentType.Application.Json)
Expand All @@ -100,7 +102,7 @@ object CheqdService {
KlaxonWithConverters().parse<JobActionResponse>(response)
}

private fun finalizeDidJob(url: String, jobId: String, verificationMethodId: String, signatures: List<String>) = let{
private fun finalizeDidJob(url: String, jobId: String, verificationMethodId: String, signatures: List<String>) = let {
val actionResponse = runBlocking {
client.post(url) {
contentType(ContentType.Application.Json)
Expand Down

0 comments on commit 285bcc9

Please sign in to comment.