diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-11-17 15:20:42 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-11-27 19:40:52 +0100 |
commit | 9a27cdc27c900feaae5f6db4315c4ccdfc0c4493 (patch) | |
tree | f91fcfa0fa1a2e45aae1c5333ef2f7ec60e56ef0 /server/helpers/custom-jsonld-signature.ts | |
parent | 975e6e0e44e2f2b25f804cd48a62e2a8d9e8117a (diff) | |
download | PeerTube-9a27cdc27c900feaae5f6db4315c4ccdfc0c4493.tar.gz PeerTube-9a27cdc27c900feaae5f6db4315c4ccdfc0c4493.tar.zst PeerTube-9a27cdc27c900feaae5f6db4315c4ccdfc0c4493.zip |
Optimize signature verification
Diffstat (limited to 'server/helpers/custom-jsonld-signature.ts')
-rw-r--r-- | server/helpers/custom-jsonld-signature.ts | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/server/helpers/custom-jsonld-signature.ts b/server/helpers/custom-jsonld-signature.ts new file mode 100644 index 000000000..afb960618 --- /dev/null +++ b/server/helpers/custom-jsonld-signature.ts | |||
@@ -0,0 +1,20 @@ | |||
1 | import * as AsyncLRU from 'async-lru' | ||
2 | import * as jsonld from 'jsonld' | ||
3 | import * as jsig from 'jsonld-signatures' | ||
4 | |||
5 | jsig.use('jsonld', jsonld) | ||
6 | |||
7 | const nodeDocumentLoader = jsonld.documentLoaders.node() | ||
8 | |||
9 | const lru = new AsyncLRU({ | ||
10 | max: 10, | ||
11 | load: (key, cb) => { | ||
12 | nodeDocumentLoader(key, cb) | ||
13 | } | ||
14 | }) | ||
15 | |||
16 | jsonld.documentLoader = (url, cb) => { | ||
17 | lru.get(url, cb) | ||
18 | } | ||
19 | |||
20 | export { jsig } | ||