edge-currency-plugins 3.8.10 → 3.9.0

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.
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
3
  var _memlet = require('memlet');
4
4
 
@@ -9,6 +9,7 @@ var _memlet = require('memlet');
9
9
 
10
10
 
11
11
 
12
+
12
13
  var _ServerScores = require('./ServerScores');
13
14
 
14
15
 
@@ -56,6 +57,43 @@ const SERVER_CACHE_FILE = 'serverCache.json'
56
57
  function makePluginState(settings) {
57
58
  const { defaultSettings, log, pluginDisklet, pluginId } = settings
58
59
 
60
+ const sanitizeServerUri = (uri) => {
61
+ // `dumpData()` is often copied into support logs.
62
+ // Strip anything that might accidentally contain credentials/tokens.
63
+ // Keep scheme/host/path, but drop username/password + query/hash.
64
+ // Avoid using the global `URL` class since it is not guaranteed to exist
65
+ // in all runtime environments.
66
+ const noQueryHash = uri.split(/[?#]/)[0]
67
+ return noQueryHash.replace(
68
+ /^([a-zA-Z][a-zA-Z0-9+.-]*:\/\/)([^@/]*@)(.*)$/,
69
+ '$1$3'
70
+ )
71
+ }
72
+
73
+ const sanitizeServerList = (serverList) => {
74
+ const out = {}
75
+
76
+ for (const [serverUri, serverInfo] of Object.entries(serverList)) {
77
+ const sanitizedUri = sanitizeServerUri(serverUri)
78
+ const sanitizedInfo = {
79
+ ...serverInfo,
80
+ serverUrl: sanitizeServerUri(serverInfo.serverUrl)
81
+ }
82
+
83
+ // In case sanitization causes collisions (ex: query string removed),
84
+ // preserve all entries by suffixing the key.
85
+ if (out[sanitizedUri] == null) {
86
+ out[sanitizedUri] = sanitizedInfo
87
+ } else {
88
+ let i = 2
89
+ while (out[`${sanitizedUri}#${i}`] != null) i++
90
+ out[`${sanitizedUri}#${i}`] = sanitizedInfo
91
+ }
92
+ }
93
+
94
+ return out
95
+ }
96
+
59
97
  let engines = []
60
98
  const memlet = _memlet.makeMemlet.call(void 0, pluginDisklet)
61
99
 
@@ -137,8 +175,18 @@ const SERVER_CACHE_FILE = 'serverCache.json'
137
175
  },
138
176
 
139
177
  dumpData() {
178
+ const selectedServerList = getSelectedServerList()
179
+ const infoServers = Object.keys(
180
+ _nullishCoalesce(_optionalChain([instance, 'access', _ => _.infoPayload, 'optionalAccess', _2 => _2.blockbookServers]), () => ( {}))
181
+ ).map(sanitizeServerUri)
182
+
140
183
  return {
141
- 'pluginState.servers_': getSelectedServerList()
184
+ 'pluginState.servers_': sanitizeServerList(selectedServerList),
185
+ infoServers,
186
+ customServers: Object.keys(serverCache.customServers).map(
187
+ sanitizeServerUri
188
+ ),
189
+ enableCustomServers: serverCache.enableCustomServers
142
190
  }
143
191
  },
144
192
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "edge-currency-plugins",
3
- "version": "3.8.10",
3
+ "version": "3.9.0",
4
4
  "description": "Edge currency plugins to fetch and process wallet accounts, balances and transactions.",
5
5
  "homepage": "https://edge.app/",
6
6
  "repository": "https://github.com/EdgeApp/edge-currency-plugins",