ssi-sdk icon indicating copy to clipboard operation
ssi-sdk copied to clipboard

Have the ability to cache / load local copies of referenced schemas

Open decentralgabe opened this issue 2 years ago • 3 comments

Some schemas, such as those for Credential Manifest rely on additional schemas using the $ref property.

Utilizing these schemas in the sdk resolves in network calls, to resolve the $ref values. It's possible some of these schema URIs may become unavailable. We should have a method to "locally" resolve such schema references. This is possible in ajv.

decentralgabe avatar Jul 05 '22 21:07 decentralgabe

Should be possible with loaders - https://github.com/xeipuuv/gojsonschema#loaders

decentralgabe avatar Jul 05 '22 21:07 decentralgabe

First part of this - https://github.com/TBD54566975/ssi-sdk/pull/221

nitro-neal avatar Oct 10 '22 15:10 nitro-neal

Added:

// DerefSchemas takes our known schemas and dereferences the schema's $ref http links to be a part of the json schema object. // This makes our code faster when doing validation checks and allows us to not ping outside sources for schemas refs which may go down or change. // TODO: (Neal) Currently we do not use these dereferenced schemas in code because there is more work to be done here. // Currently these dereferenced schemas are missing some information and fail validation with our known json objects // I believe some more work in the investigation library needs to be done and we need to handle circular dependencies

it could also be our logic to do validation is strange, it seems that these schemas + json objects with an online tool check out..

image

nitro-neal avatar Oct 10 '22 19:10 nitro-neal