w3c-ccg / universal-wallet-interop-spec

A data model and abstract interfaces for digital wallets
http://w3id.org/wallet
Other
56 stars 13 forks source link

New data model - JSON-LD Schema #93

Open sudeshrshetty opened 3 years ago

sudeshrshetty commented 3 years ago

A proposal to introduce new data model for caching JSON-LD context documents locally in wallet.

If a wallet is aware of list of JSON LD contexts it is going to encounter more often, then those context documents can be added/cached locally. This will help wallet in many ways like offline access to contexts, resolving performance bottleneck of loading context each time from network etc.

sudeshrshetty commented 3 years ago

ping @OR13

OR13 commented 3 years ago

I love this idea, we have a similar issue with all types returned by a documentLoader.

This will take some thought to sort out, but I will try and add my thoughts on how we have been doing this with our documentLoaders.

OR13 commented 3 years ago

We have a documentLoader pattern we use that looks like this:

export const getDocumentLoader = (wallet: UniversalWallet) => {
  return async (iri: string) =>{
    if (iri in cached contexts){
      return wallet.get(iri);
    }
    if (iri in wallet cache for dids){
      return wallet.get(iri);
    }
    if (iri in allowed did methods){
      return wallet.resolve(iri);
    }
  }
}

This proposal would essentially be to allow different wallet instances to produce different cache enabled document loaders.

sudeshrshetty commented 3 years ago

We have similar document loader cache in aries.

I agree with the plan of having different cache enabled document loader for different wallet instances. Wallet should be able to import the added context directly into cached document loader. I will push a PR shortly.