aboutsummaryrefslogblamecommitdiffhomepage
path: root/server/helpers/custom-jsonld-signature.ts
blob: e4f28018e0767806f452ab72cb5b2471fd7d6fbf (plain) (tree)
1
2
3
4
                                     
                                 

                                         












                                                        

                          
               
import * as AsyncLRU from 'async-lru'
import * as jsonld from 'jsonld/'
import * as jsig from 'jsonld-signatures'

const nodeDocumentLoader = jsonld.documentLoaders.node()

const lru = new AsyncLRU({
  max: 10,
  load: (key, cb) => {
    nodeDocumentLoader(key, cb)
  }
})

jsonld.documentLoader = (url, cb) => {
  lru.get(url, cb)
}

jsig.use('jsonld', jsonld)

export { jsig }