@ocap/tx-pipeline 1.18.131 → 1.18.133
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/pipes/verify-blocked.js +24 -5
- package/package.json +11 -11
|
@@ -1,11 +1,30 @@
|
|
|
1
|
+
/* eslint-disable no-await-in-loop */
|
|
2
|
+
const get = require('lodash/get');
|
|
1
3
|
const { CustomError: Error } = require('@ocap/util/lib/error');
|
|
4
|
+
const { getRelatedAddresses } = require('@ocap/util/lib/get-related-addr');
|
|
2
5
|
|
|
3
|
-
module.exports = function CreatedVerifyBlockedPipe(filter) {
|
|
6
|
+
module.exports = function CreatedVerifyBlockedPipe({ filter = null, stateKeys = ['tx.from'] } = {}) {
|
|
4
7
|
return async function VerifyTx(context, next) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
const f = filter || context.filter;
|
|
9
|
+
if (typeof f?.isBlocked === 'function') {
|
|
10
|
+
const suspects = [];
|
|
11
|
+
stateKeys.forEach((stateKey) => {
|
|
12
|
+
const state = get(context, stateKey);
|
|
13
|
+
if (state) {
|
|
14
|
+
if (typeof state === 'string') {
|
|
15
|
+
suspects.push(state);
|
|
16
|
+
} else {
|
|
17
|
+
const states = Array.isArray(state) ? state : [state];
|
|
18
|
+
states.forEach((x) => suspects.push(...getRelatedAddresses(x)));
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
for (const suspect of suspects) {
|
|
24
|
+
const blocked = await f.isBlocked(suspect);
|
|
25
|
+
if (blocked) {
|
|
26
|
+
return next(new Error('FORBIDDEN', `Account blocked: ${suspect}`));
|
|
27
|
+
}
|
|
9
28
|
}
|
|
10
29
|
}
|
|
11
30
|
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.18.
|
|
6
|
+
"version": "1.18.133",
|
|
7
7
|
"description": "Pipeline runner and common pipelines to process transactions",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"files": [
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"author": "wangshijun <wangshijun2010@gmail.com> (http://github.com/wangshijun)",
|
|
22
22
|
"license": "MIT",
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"jest": "^
|
|
24
|
+
"jest": "^29.7.0",
|
|
25
25
|
"start-server-and-test": "^1.14.0"
|
|
26
26
|
},
|
|
27
27
|
"resolutions": {
|
|
@@ -29,16 +29,16 @@
|
|
|
29
29
|
"elliptic": "6.5.3"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@arcblock/did": "1.18.
|
|
33
|
-
"@arcblock/did-util": "1.18.
|
|
34
|
-
"@ocap/mcrypto": "1.18.
|
|
35
|
-
"@ocap/message": "1.18.
|
|
36
|
-
"@ocap/state": "1.18.
|
|
37
|
-
"@ocap/util": "1.18.
|
|
38
|
-
"@ocap/wallet": "1.18.
|
|
39
|
-
"debug": "^4.3.
|
|
32
|
+
"@arcblock/did": "1.18.133",
|
|
33
|
+
"@arcblock/did-util": "1.18.133",
|
|
34
|
+
"@ocap/mcrypto": "1.18.133",
|
|
35
|
+
"@ocap/message": "1.18.133",
|
|
36
|
+
"@ocap/state": "1.18.133",
|
|
37
|
+
"@ocap/util": "1.18.133",
|
|
38
|
+
"@ocap/wallet": "1.18.133",
|
|
39
|
+
"debug": "^4.3.6",
|
|
40
40
|
"empty-value": "^1.0.1",
|
|
41
41
|
"lodash": "^4.17.21"
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "cd4b69aef69b4e30265c3897a22fb63c902c5d4e"
|
|
44
44
|
}
|