aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/custom-jsonld-signature.ts
blob: 27a187db1d35e3da55eacf864d61092f16e04799 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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, jsonld }