generated from TBD54566975/tbd-project-template
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removing
did-common-java
dependency (#248)
* removing did common java dep * adding new types. wip - some difference between web5-go and did-common-java in comments * adding ktdocs. changing out id of type URI for id of type String in diddoc verif method and service types * removing todos and just using string for id instead of uri * pulling in Json from tbdex-kt for stringifying instead of relying on jsonldobject inherited methods from did common java. replacing didurl with a verificationMethodId splitting on # * goodbye didion. cleaning up diddocument. renaming some methods. more questions as todos * cleaning up. pulling documentmetadata back in from previously deleted didion stuff * changing Did to BaseDid to reduce confusion between the Did that all did methods inherit from, and the new DID type * using verificationMethod() in the builder class, removing all purpose specific methods in favor of the generic one * addressing some todos * reverting renaming, to be done later * removing duplicate documentmetadata * hella kt docs * stuff from pairing * fixing tests * pulling in work done in PR#225 by @grahnj as part of removing did ion reference. in the middle of refactoring did dht slightly. only 7-8 tests failing now... * wrote tests for diddocument * renaming Did.kt file to DidUri.kt to be consistent with current naming. making verificationMethod a set to avoid duplication. 1 test remains to be fixed * wrote tostring for service. moving util method to dids package. added a todo to fix a test * removing todos, pulled out util method to separate file * addressing code review comments * fixing test vectors * added tests for service verification and did uri. one test failing for did uri * fixed a test, but with a todo to discuss * removed printlns * adding more invalid did test cases * addressing tests * quietly committing this before the tests find out they actually wanted to fail * addressing code review comments * adding more tests to please codecov * moving Json out to commons package * fixing import errors * changing context field to be a list, changing test vectors to comply with this change * update web5-spec commit to be latest in main Co-authored-by: Moe Jangda <[email protected]>
- Loading branch information
Showing
53 changed files
with
1,797 additions
and
2,546 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package web5.sdk.common | ||
|
||
import com.fasterxml.jackson.annotation.JsonInclude | ||
import com.fasterxml.jackson.databind.ObjectMapper | ||
import com.fasterxml.jackson.databind.ObjectWriter | ||
import com.fasterxml.jackson.databind.SerializationFeature | ||
import com.fasterxml.jackson.module.kotlin.registerKotlinModule | ||
|
||
/** | ||
* A singleton for json serialization/deserialization, shared across the SDK as ObjectMapper instantiation | ||
* is an expensive operation. | ||
* - Serialize ([stringify]) | ||
* | ||
* ### Example Usage: | ||
* ```kotlin | ||
* val offering = Json.objectMapper.readValue<Offering>(payload) | ||
* | ||
* val jsonString = Json.stringify(myObject) | ||
* | ||
* val node = Json.parse(payload) | ||
* ``` | ||
*/ | ||
public object Json { | ||
/** | ||
* The Jackson object mapper instance, shared across the lib. | ||
* | ||
* It must be public in order for typed parsing to work as we cannot use reified types for Java interop. | ||
*/ | ||
public val jsonMapper: ObjectMapper = ObjectMapper() | ||
.registerKotlinModule() | ||
.findAndRegisterModules() | ||
.setSerializationInclusion(JsonInclude.Include.NON_NULL) | ||
.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) | ||
|
||
private val objectWriter: ObjectWriter = jsonMapper.writer() | ||
|
||
/** | ||
* Converts a kotlin object to a json string. | ||
* | ||
* @param obj The object to stringify. | ||
* @return json string. | ||
*/ | ||
public fun stringify(obj: Any): String { | ||
return objectWriter.writeValueAsString(obj) | ||
} | ||
} |
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
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
Oops, something went wrong.