@ocap/tx-pipeline 1.18.128 → 1.18.130
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/index.js +2 -0
- package/lib/pipes/anti-land-attack.js +12 -6
- package/lib/pipes/verify-blocked.js +14 -0
- package/package.json +9 -9
package/lib/index.js
CHANGED
@@ -13,6 +13,7 @@ const VerifyListSize = require('./pipes/verify-list-size');
|
|
13
13
|
const VerifyMultiSig = require('./pipes/verify-multisig');
|
14
14
|
const VerifyMultiSigV2 = require('./pipes/verify-multisig-v2');
|
15
15
|
const VerifySender = require('./pipes/verify-sender');
|
16
|
+
const VerifyBlocked = require('./pipes/verify-blocked');
|
16
17
|
const VerifyServiceFee = require('./pipes/verify-service-fee');
|
17
18
|
const VerifySignature = require('./pipes/verify-signature');
|
18
19
|
const VerifySigner = require('./pipes/verify-signer');
|
@@ -41,6 +42,7 @@ module.exports = {
|
|
41
42
|
VerifyMultiSigV2,
|
42
43
|
VerifyUpdater,
|
43
44
|
VerifySender,
|
45
|
+
VerifyBlocked,
|
44
46
|
VerifyServiceFee,
|
45
47
|
VerifySignature,
|
46
48
|
VerifySigner,
|
@@ -1,23 +1,29 @@
|
|
1
1
|
/* eslint-disable no-restricted-syntax */
|
2
2
|
const get = require('lodash/get');
|
3
|
+
const { isSameDid } = require('@ocap/util');
|
3
4
|
const { CustomError: Error } = require('@ocap/util/lib/error');
|
4
5
|
|
5
6
|
module.exports = function CreateAntiLandAttackPipe({
|
6
7
|
senderState = 'senderState',
|
7
8
|
receiverState = 'receiverState',
|
8
|
-
receiverAddress = 'receiver',
|
9
9
|
} = {}) {
|
10
10
|
return function AntiLandAttack(context, next) {
|
11
11
|
const sender = get(context, senderState);
|
12
12
|
const receiver = get(context, receiverState);
|
13
13
|
|
14
|
-
|
15
|
-
|
14
|
+
const senders = (Array.isArray(sender) ? sender : [sender]).filter(Boolean);
|
15
|
+
const receivers = (Array.isArray(receiver) ? receiver : [receiver]).filter(Boolean);
|
16
|
+
|
17
|
+
for (const s of senders) {
|
18
|
+
if (receivers.some((r) => isSameDid(r.address, s.address))) {
|
19
|
+
return next(new Error('INVALID_TX', `Sender should not exist in receiver list: ${s.address}`));
|
20
|
+
}
|
16
21
|
}
|
17
22
|
|
18
|
-
const
|
19
|
-
|
20
|
-
|
23
|
+
for (const r of receivers) {
|
24
|
+
if (senders.some((s) => isSameDid(s.address, r.address))) {
|
25
|
+
return next(new Error('INVALID_TX', `Receiver should not exist in sender list: ${r.address}`));
|
26
|
+
}
|
21
27
|
}
|
22
28
|
|
23
29
|
next();
|
@@ -0,0 +1,14 @@
|
|
1
|
+
const { CustomError: Error } = require('@ocap/util/lib/error');
|
2
|
+
|
3
|
+
module.exports = function CreatedVerifyBlockedPipe(filter) {
|
4
|
+
return async function VerifyTx(context, next) {
|
5
|
+
if (typeof filter?.isBlocked === 'function' && context.tx?.from) {
|
6
|
+
const blocked = await filter.isBlocked(context.tx.from);
|
7
|
+
if (blocked) {
|
8
|
+
return next(new Error('FORBIDDEN', 'Sender blocked'));
|
9
|
+
}
|
10
|
+
}
|
11
|
+
|
12
|
+
next();
|
13
|
+
};
|
14
|
+
};
|
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.130",
|
7
7
|
"description": "Pipeline runner and common pipelines to process transactions",
|
8
8
|
"main": "lib/index.js",
|
9
9
|
"files": [
|
@@ -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.
|
32
|
+
"@arcblock/did": "1.18.130",
|
33
|
+
"@arcblock/did-util": "1.18.130",
|
34
|
+
"@ocap/mcrypto": "1.18.130",
|
35
|
+
"@ocap/message": "1.18.130",
|
36
|
+
"@ocap/state": "1.18.130",
|
37
|
+
"@ocap/util": "1.18.130",
|
38
|
+
"@ocap/wallet": "1.18.130",
|
39
39
|
"debug": "^4.3.4",
|
40
40
|
"empty-value": "^1.0.1",
|
41
41
|
"lodash": "^4.17.21"
|
42
42
|
},
|
43
|
-
"gitHead": "
|
43
|
+
"gitHead": "d4846249beb92ef45faad7a23781f631523f288e"
|
44
44
|
}
|