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

21 lines
386 B
TypeScript
Raw Normal View History

2017-11-17 08:20:42 -06:00
import * as AsyncLRU from 'async-lru'
import * as jsonld from 'jsonld'
2017-11-17 08:20:42 -06:00
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)
}
2017-12-18 04:53:04 -06:00
jsig.use('jsonld', jsonld)
export { jsig, jsonld }