@ocap/resolver 1.6.3 → 1.6.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/hooks.js +308 -0
- package/lib/index.js +719 -177
- package/lib/token-cache.js +38 -0
- package/package.json +15 -10
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 缓存 token 到内存
|
|
3
|
+
*/
|
|
4
|
+
class Cache {
|
|
5
|
+
constructor(dbAdapter) {
|
|
6
|
+
this.dbAdapter = dbAdapter;
|
|
7
|
+
this.cache = new Map();
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
async get(address) {
|
|
11
|
+
if (this.cache.has(address)) {
|
|
12
|
+
return this.cache.get(address);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const token = await this.dbAdapter.get(address);
|
|
16
|
+
this.cache.set(address, token);
|
|
17
|
+
|
|
18
|
+
return token;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
set(address, token) {
|
|
22
|
+
this.cache.set(address, token);
|
|
23
|
+
return token;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
let cache = null;
|
|
28
|
+
|
|
29
|
+
module.exports = {
|
|
30
|
+
getInstance: (dbAdapter) => {
|
|
31
|
+
if (cache !== null) {
|
|
32
|
+
return cache;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
cache = new Cache(dbAdapter);
|
|
36
|
+
return cache;
|
|
37
|
+
},
|
|
38
|
+
};
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.6.
|
|
6
|
+
"version": "1.6.10",
|
|
7
7
|
"description": "GraphQL resolver built upon ocap statedb and GQL layer",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"files": [
|
|
@@ -12,23 +12,28 @@
|
|
|
12
12
|
"scripts": {
|
|
13
13
|
"lint": "eslint tests lib",
|
|
14
14
|
"lint:fix": "eslint --fix tests lib",
|
|
15
|
-
"test": "
|
|
15
|
+
"test": "jest --forceExit --detectOpenHandles",
|
|
16
16
|
"coverage": "npm run test -- --coverage"
|
|
17
17
|
},
|
|
18
18
|
"keywords": [],
|
|
19
19
|
"author": "wangshijun <wangshijun2010@gmail.com> (http://github.com/wangshijun)",
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"jest": "^
|
|
22
|
+
"jest": "^27.3.1"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@arcblock/did": "
|
|
26
|
-
"@
|
|
27
|
-
"@
|
|
28
|
-
"@ocap/
|
|
29
|
-
"@ocap/
|
|
30
|
-
"
|
|
25
|
+
"@arcblock/did": "1.6.10",
|
|
26
|
+
"@arcblock/did-util": "1.6.10",
|
|
27
|
+
"@arcblock/validator": "1.6.10",
|
|
28
|
+
"@ocap/config": "1.6.10",
|
|
29
|
+
"@ocap/indexdb": "1.6.10",
|
|
30
|
+
"@ocap/mcrypto": "1.6.10",
|
|
31
|
+
"@ocap/message": "1.6.10",
|
|
32
|
+
"@ocap/state": "1.6.10",
|
|
33
|
+
"@ocap/tx-protocols": "1.6.10",
|
|
34
|
+
"@ocap/util": "1.6.10",
|
|
35
|
+
"debug": "^4.3.3",
|
|
31
36
|
"lodash": "^4.17.21"
|
|
32
37
|
},
|
|
33
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "ab272e8db3a15c6571cc7fae7cc3d3e0fdd4bdb1"
|
|
34
39
|
}
|