PeerTube/server/helpers/custom-jsonld-signature.ts

21 lines
378 B
TypeScript
Raw Normal View History

2017-11-17 15:20:42 +01:00
import * as AsyncLRU from 'async-lru'
import * as jsonld from 'jsonld'
import * as jsig from 'jsonld-signatures'
jsig.use('jsonld', jsonld)
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)
}
export { jsig }