@ocap/state 1.18.148 → 1.18.150

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.
@@ -4,7 +4,14 @@ const { CustomError: Error } = require('@ocap/util/lib/error');
4
4
  const { BloomFilter } = require('bloom-filters');
5
5
 
6
6
  class Blacklist {
7
- constructor({ size = 256, numHashFns = 4, dumpPath = '', dumpInterval = 0, getBlockedAccounts = null } = {}) {
7
+ constructor({
8
+ size = 256,
9
+ numHashFns = 4,
10
+ dumpPath = '',
11
+ dumpInterval = 0,
12
+ getBlockedAccounts = null,
13
+ getTrustedAccounts = null,
14
+ } = {}) {
8
15
  let filter;
9
16
 
10
17
  if (dumpPath && fs.existsSync(dumpPath)) {
@@ -23,6 +30,7 @@ class Blacklist {
23
30
  this.dumpPath = dumpPath;
24
31
  this.filter = filter;
25
32
  this.getBlockedAccounts = getBlockedAccounts;
33
+ this.getTrustedAccounts = getTrustedAccounts;
26
34
 
27
35
  if (dumpPath && dumpInterval > 0) {
28
36
  this.timer = setTimeout(() => {
@@ -61,6 +69,17 @@ class Blacklist {
61
69
  return false;
62
70
  }
63
71
 
72
+ async isTrusted(address) {
73
+ if (typeof this.getTrustedAccounts === 'function') {
74
+ const trustedAccounts = await this.getTrustedAccounts();
75
+ if (trustedAccounts.length) {
76
+ return trustedAccounts.some((b) => isSameDid(b, address));
77
+ }
78
+ }
79
+
80
+ return false;
81
+ }
82
+
64
83
  dump() {
65
84
  try {
66
85
  const exported = this.filter.saveAsJSON();
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.18.148",
6
+ "version": "1.18.150",
7
7
  "description": "",
8
8
  "main": "lib/index.js",
9
9
  "files": [
@@ -18,13 +18,13 @@
18
18
  "coverage": "start-server-and-test start http://127.0.0.1:4001 test:ci"
19
19
  },
20
20
  "dependencies": {
21
- "@arcblock/did": "1.18.148",
22
- "@arcblock/validator": "1.18.148",
23
- "@ocap/contract": "1.18.148",
24
- "@ocap/mcrypto": "1.18.148",
25
- "@ocap/message": "1.18.148",
26
- "@ocap/util": "1.18.148",
27
- "@ocap/wallet": "1.18.148",
21
+ "@arcblock/did": "1.18.150",
22
+ "@arcblock/validator": "1.18.150",
23
+ "@ocap/contract": "1.18.150",
24
+ "@ocap/mcrypto": "1.18.150",
25
+ "@ocap/message": "1.18.150",
26
+ "@ocap/util": "1.18.150",
27
+ "@ocap/wallet": "1.18.150",
28
28
  "bloom-filters": "^1.3.9",
29
29
  "lodash": "^4.17.21"
30
30
  },
@@ -35,5 +35,5 @@
35
35
  "keywords": [],
36
36
  "author": "wangshijun <wangshijun2010@gmail.com> (http://github.com/wangshijun)",
37
37
  "license": "MIT",
38
- "gitHead": "5ba096b17be4f24fb47efce520525c96f8ff9660"
38
+ "gitHead": "700ffd83b7fbb781d68ef761aa9b1b004a961d9f"
39
39
  }