@bsv/overlay-express 2.0.2 → 2.1.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.
Files changed (52) hide show
  1. package/dist/cjs/mod.js +7 -1
  2. package/dist/cjs/mod.js.map +1 -1
  3. package/dist/cjs/package.json +3 -1
  4. package/dist/cjs/src/BanAwareLookupWrapper.js +76 -0
  5. package/dist/cjs/src/BanAwareLookupWrapper.js.map +1 -0
  6. package/dist/cjs/src/BanService.js +118 -0
  7. package/dist/cjs/src/BanService.js.map +1 -0
  8. package/dist/cjs/src/JanitorService.js +206 -93
  9. package/dist/cjs/src/JanitorService.js.map +1 -1
  10. package/dist/cjs/src/OverlayExpress.js +522 -71
  11. package/dist/cjs/src/OverlayExpress.js.map +1 -1
  12. package/dist/cjs/src/makeUserInterface.js +889 -217
  13. package/dist/cjs/src/makeUserInterface.js.map +1 -1
  14. package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
  15. package/dist/esm/mod.js +4 -1
  16. package/dist/esm/mod.js.map +1 -1
  17. package/dist/esm/src/BanAwareLookupWrapper.js +78 -0
  18. package/dist/esm/src/BanAwareLookupWrapper.js.map +1 -0
  19. package/dist/esm/src/BanService.js +115 -0
  20. package/dist/esm/src/BanService.js.map +1 -0
  21. package/dist/esm/src/JanitorService.js +199 -92
  22. package/dist/esm/src/JanitorService.js.map +1 -1
  23. package/dist/esm/src/OverlayExpress.js +528 -72
  24. package/dist/esm/src/OverlayExpress.js.map +1 -1
  25. package/dist/esm/src/makeUserInterface.js +889 -217
  26. package/dist/esm/src/makeUserInterface.js.map +1 -1
  27. package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
  28. package/dist/types/mod.d.ts +4 -1
  29. package/dist/types/mod.d.ts.map +1 -1
  30. package/dist/types/src/BanAwareLookupWrapper.d.ts +31 -0
  31. package/dist/types/src/BanAwareLookupWrapper.d.ts.map +1 -0
  32. package/dist/types/src/BanService.d.ts +81 -0
  33. package/dist/types/src/BanService.d.ts.map +1 -0
  34. package/dist/types/src/JanitorService.d.ts +69 -13
  35. package/dist/types/src/JanitorService.d.ts.map +1 -1
  36. package/dist/types/src/OverlayExpress.d.ts +28 -4
  37. package/dist/types/src/OverlayExpress.d.ts.map +1 -1
  38. package/dist/types/src/makeUserInterface.d.ts +2 -0
  39. package/dist/types/src/makeUserInterface.d.ts.map +1 -1
  40. package/dist/types/tsconfig.types.tsbuildinfo +1 -1
  41. package/mod.ts +4 -1
  42. package/package.json +3 -1
  43. package/src/BanAwareLookupWrapper.ts +95 -0
  44. package/src/BanService.ts +154 -0
  45. package/src/JanitorService.ts +277 -101
  46. package/src/OverlayExpress.ts +575 -76
  47. package/src/__tests__/BanAwareLookupWrapper.test.ts +255 -0
  48. package/src/__tests__/BanService.test.ts +310 -0
  49. package/src/__tests__/JanitorService.test.ts +342 -5
  50. package/src/__tests__/OverlayExpress.test.ts +19 -6
  51. package/src/__tests__/makeUserInterface.test.ts +4 -3
  52. package/src/makeUserInterface.ts +892 -217
package/dist/esm/mod.js CHANGED
@@ -1,2 +1,5 @@
1
- export { default } from "./src/OverlayExpress.js";
1
+ export { default } from './src/OverlayExpress.js';
2
+ export { BanService } from './src/BanService.js';
3
+ export { BanAwareLookupWrapper } from './src/BanAwareLookupWrapper.js';
4
+ export { JanitorService } from './src/JanitorService.js';
2
5
  //# sourceMappingURL=mod.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"mod.js","sourceRoot":"","sources":["../../mod.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAA"}
1
+ {"version":3,"file":"mod.js","sourceRoot":"","sources":["../../mod.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAA;AACjD,OAAO,EAAE,UAAU,EAAqB,MAAM,qBAAqB,CAAA;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAA;AACtE,OAAO,EAAE,cAAc,EAAiE,MAAM,yBAAyB,CAAA"}
@@ -0,0 +1,78 @@
1
+ import { PushDrop, Utils } from '@bsv/sdk';
2
+ /**
3
+ * Wraps a SHIP or SLAP LookupService to intercept outputAdmittedByTopic calls
4
+ * and block outputs whose domain or outpoint appears in the persistent ban list.
5
+ *
6
+ * This prevents GASP from re-syncing stale or banned tokens that were previously
7
+ * removed by the Janitor or an admin.
8
+ */
9
+ export class BanAwareLookupWrapper {
10
+ wrapped;
11
+ banService;
12
+ protocol;
13
+ logger;
14
+ admissionMode;
15
+ spendNotificationMode;
16
+ constructor(wrapped, banService, protocol, logger = console) {
17
+ this.wrapped = wrapped;
18
+ this.banService = banService;
19
+ this.protocol = protocol;
20
+ this.logger = logger;
21
+ this.admissionMode = wrapped.admissionMode;
22
+ this.spendNotificationMode = wrapped.spendNotificationMode;
23
+ }
24
+ /**
25
+ * Intercepts admission to check the ban list before delegating to the wrapped service.
26
+ * If the output's domain or outpoint is banned, the admission is silently blocked.
27
+ */
28
+ async outputAdmittedByTopic(payload) {
29
+ if (payload.mode === 'locking-script') {
30
+ const { txid, outputIndex, lockingScript } = payload;
31
+ // Check if the specific outpoint is banned
32
+ if (await this.banService.isOutpointBanned(txid, outputIndex)) {
33
+ this.logger.log(`[BAN] Blocked banned outpoint ${txid}.${outputIndex} from ${this.protocol}`);
34
+ return;
35
+ }
36
+ // Try to parse the domain from PushDrop fields and check domain ban
37
+ try {
38
+ const result = PushDrop.decode(lockingScript);
39
+ if (result.fields.length >= 3) {
40
+ const domain = Utils.toUTF8(result.fields[2]);
41
+ if (await this.banService.isDomainBanned(domain)) {
42
+ this.logger.log(`[BAN] Blocked banned domain ${domain} from ${this.protocol} (${txid}.${outputIndex})`);
43
+ return;
44
+ }
45
+ }
46
+ }
47
+ catch {
48
+ // If we can't parse PushDrop fields, let it through to the wrapped service
49
+ // which will apply its own validation
50
+ }
51
+ }
52
+ // Delegate to the wrapped service
53
+ return await this.wrapped.outputAdmittedByTopic(payload);
54
+ }
55
+ async outputSpent(payload) {
56
+ if (typeof this.wrapped.outputSpent === 'function') {
57
+ return await this.wrapped.outputSpent(payload);
58
+ }
59
+ }
60
+ async outputNoLongerRetainedInHistory(txid, outputIndex, topic) {
61
+ if (typeof this.wrapped.outputNoLongerRetainedInHistory === 'function') {
62
+ return await this.wrapped.outputNoLongerRetainedInHistory(txid, outputIndex, topic);
63
+ }
64
+ }
65
+ async outputEvicted(txid, outputIndex) {
66
+ return await this.wrapped.outputEvicted(txid, outputIndex);
67
+ }
68
+ async lookup(question) {
69
+ return await this.wrapped.lookup(question);
70
+ }
71
+ async getDocumentation() {
72
+ return await this.wrapped.getDocumentation();
73
+ }
74
+ async getMetaData() {
75
+ return await this.wrapped.getMetaData();
76
+ }
77
+ }
78
+ //# sourceMappingURL=BanAwareLookupWrapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BanAwareLookupWrapper.js","sourceRoot":"","sources":["../../../src/BanAwareLookupWrapper.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAkB,MAAM,UAAU,CAAA;AAG1D;;;;;;GAMG;AACH,MAAM,OAAO,qBAAqB;IAKb;IACA;IACA;IACA;IAPV,aAAa,CAAe;IAC5B,qBAAqB,CAAuB;IAErD,YACmB,OAAsB,EACtB,UAAsB,EACtB,QAAyB,EACzB,SAAyB,OAAO;QAHhC,YAAO,GAAP,OAAO,CAAe;QACtB,eAAU,GAAV,UAAU,CAAY;QACtB,aAAQ,GAAR,QAAQ,CAAiB;QACzB,WAAM,GAAN,MAAM,CAA0B;QAEjD,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC,aAAa,CAAA;QAC1C,IAAI,CAAC,qBAAqB,GAAG,OAAO,CAAC,qBAAqB,CAAA;IAC5D,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,qBAAqB,CAAE,OAA8B;QACzD,IAAI,OAAO,CAAC,IAAI,KAAK,gBAAgB,EAAE,CAAC;YACtC,MAAM,EAAE,IAAI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EAAE,WAAmB,EAAE,KAAa;QACrF,IAAI,OAAO,IAAI,CAAC,OAAO,CAAC,+BAA+B,KAAK,UAAU,EAAE,CAAC;YACvE,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC,+BAA+B,CAAC,IAAI,EAAE,WAAW,EAAE,KAAK,CAAC,CAAA;QACrF,CAAC;IACH,CAAC;IAED,KAAK,CAAC,aAAa,CAAE,IAAY,EAAE,WAAmB;QACpD,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,IAAI,EAAE,WAAW,CAAC,CAAA;IAC5D,CAAC;IAED,KAAK,CAAC,MAAM,CAAE,QAAwB;QACpC,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;IAC5C,CAAC;IAED,KAAK,CAAC,gBAAgB;QACpB,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE,CAAA;IAC9C,CAAC;IAED,KAAK,CAAC,WAAW;QACf,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,CAAA;IACzC,CAAC;CACF"}
@@ -0,0 +1,115 @@
1
+ /**
2
+ * BanService provides a persistent ban list stored in MongoDB.
3
+ *
4
+ * When the Janitor or an admin removes a SHIP/SLAP token, the associated
5
+ * domain or outpoint can be added to the ban list. The BanAwareLookupWrapper
6
+ * checks this list before admitting new outputs, preventing GASP from
7
+ * re-syncing previously removed stale tokens.
8
+ */
9
+ export class BanService {
10
+ bans;
11
+ constructor(db) {
12
+ this.bans = db.collection('bannedRecords');
13
+ }
14
+ /**
15
+ * Sanitizes a value for use in MongoDB queries, preventing NoSQL injection.
16
+ * Ensures the value is a plain string and rejects objects/arrays that could
17
+ * contain MongoDB operators like $ne, $gt, etc.
18
+ */
19
+ sanitize(value) {
20
+ if (typeof value !== 'string') {
21
+ throw new Error('Invalid input: expected a string value');
22
+ }
23
+ return value;
24
+ }
25
+ /**
26
+ * Creates indexes for efficient ban lookups.
27
+ */
28
+ async ensureIndexes() {
29
+ await this.bans.createIndex({ type: 1, value: 1 }, { unique: true });
30
+ await this.bans.createIndex({ bannedAt: -1 });
31
+ }
32
+ /**
33
+ * Bans a domain, preventing any SHIP/SLAP tokens referencing it from being stored.
34
+ */
35
+ async banDomain(domain, reason, bannedBy) {
36
+ const safeDomain = this.sanitize(domain);
37
+ await this.bans.updateOne({ type: 'domain', value: safeDomain }, {
38
+ $set: {
39
+ type: 'domain',
40
+ value: safeDomain,
41
+ reason: reason ?? 'Manually banned',
42
+ bannedAt: new Date(),
43
+ bannedBy
44
+ }
45
+ }, { upsert: true });
46
+ }
47
+ /**
48
+ * Removes a domain ban.
49
+ */
50
+ async unbanDomain(domain) {
51
+ await this.bans.deleteOne({ type: 'domain', value: this.sanitize(domain) });
52
+ }
53
+ /**
54
+ * Checks if a domain is banned.
55
+ */
56
+ async isDomainBanned(domain) {
57
+ const record = await this.bans.findOne({ type: 'domain', value: this.sanitize(domain) });
58
+ return record !== null;
59
+ }
60
+ /**
61
+ * Bans a specific outpoint (txid.outputIndex), preventing it from being re-admitted.
62
+ */
63
+ async banOutpoint(txid, outputIndex, reason, domain, bannedBy) {
64
+ const value = `${this.sanitize(txid)}.${Number(outputIndex)}`;
65
+ await this.bans.updateOne({ type: 'outpoint', value }, {
66
+ $set: {
67
+ type: 'outpoint',
68
+ value,
69
+ domain: domain !== undefined ? this.sanitize(domain) : undefined,
70
+ reason: reason ?? 'Manually banned',
71
+ bannedAt: new Date(),
72
+ bannedBy
73
+ }
74
+ }, { upsert: true });
75
+ }
76
+ /**
77
+ * Removes an outpoint ban.
78
+ */
79
+ async unbanOutpoint(txid, outputIndex) {
80
+ const value = `${this.sanitize(txid)}.${Number(outputIndex)}`;
81
+ await this.bans.deleteOne({ type: 'outpoint', value });
82
+ }
83
+ /**
84
+ * Checks if a specific outpoint is banned.
85
+ */
86
+ async isOutpointBanned(txid, outputIndex) {
87
+ const value = `${this.sanitize(txid)}.${Number(outputIndex)}`;
88
+ const record = await this.bans.findOne({ type: 'outpoint', value });
89
+ return record !== null;
90
+ }
91
+ /**
92
+ * Lists all bans, optionally filtered by type.
93
+ */
94
+ async listBans(type) {
95
+ const query = typeof type === 'string' ? { type } : {};
96
+ return await this.bans.find(query).sort({ bannedAt: -1 }).toArray();
97
+ }
98
+ /**
99
+ * Removes a ban by type and value.
100
+ */
101
+ async removeBan(type, value) {
102
+ await this.bans.deleteOne({ type: this.sanitize(type), value: this.sanitize(value) });
103
+ }
104
+ /**
105
+ * Returns ban statistics.
106
+ */
107
+ async getStats() {
108
+ const [domainBans, outpointBans] = await Promise.all([
109
+ this.bans.countDocuments({ type: 'domain' }),
110
+ this.bans.countDocuments({ type: 'outpoint' })
111
+ ]);
112
+ return { domainBans, outpointBans, totalBans: domainBans + outpointBans };
113
+ }
114
+ }
115
+ //# sourceMappingURL=BanService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BanService.js","sourceRoot":"","sources":["../../../src/BanService.ts"],"names":[],"mappings":"AAoBA;;;;;;;GAOG;AACH,MAAM,OAAO,UAAU;IACJ,IAAI,CAA0B;IAE/C,YAAa,EAAM;QACjB,IAAI,CAAC,IAAI,GAAG,EAAE,CAAC,UAAU,CAAe,eAAe,CAAC,CAAA;IAC1D,CAAC;IAED;;;;OAIG;IACK,QAAQ,CAAE,KAAc;QAC9B,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC9B,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAA;QAC3D,CAAC;QACD,OAAO,KAAK,CAAA;IACd,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,aAAa;QACjB,MAAM,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAA;QACpE,MAAM,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,QAAQ,EAAE,CAA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AC,KAAK,CAAC,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,OAAO,EAAE,CAAA;IACrE,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,SAAS,CAAE,IAA2B,EAAE,KAAa;QACzD,MAAM,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAA0B,EAAE,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;IAChH,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,QAAQ;QACZ,MAAM,CAAC,UAAU,EAAE,YAAY,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;YACnD,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;YAC5C,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;SAC/C,CAAC,CAAA;QACF,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,SAAS,EAAE,UAAU,GAAG,YAAY,EAAE,CAAA;IAC3E,CAAC;CACF"}
@@ -1,94 +1,235 @@
1
1
  import chalk from 'chalk';
2
2
  /**
3
- * JanitorService runs a single pass of health checks on SHIP and SLAP outputs.
3
+ * JanitorService runs health checks on SHIP and SLAP outputs.
4
4
  * It validates domain names and checks /health endpoints to ensure services are operational.
5
5
  *
6
6
  * When a service is down, it increments a "down" counter. When healthy, it decrements.
7
- * If the down counter reaches HOST_DOWN_REVOKE_SCORE, it deletes the output from the database.
8
- *
9
- * This service is designed to be run periodically via external schedulers (e.g., cron, docker-compose).
7
+ * If the down counter reaches hostDownRevokeScore, the output is deleted and optionally
8
+ * the domain is added to the persistent ban list to prevent GASP re-sync.
10
9
  */
11
10
  export class JanitorService {
12
11
  mongoDb;
13
12
  logger;
14
13
  requestTimeoutMs;
15
14
  hostDownRevokeScore;
15
+ banService;
16
+ autoBanOnRemoval;
16
17
  constructor(config) {
17
18
  this.mongoDb = config.mongoDb;
18
19
  this.logger = config.logger ?? console;
19
- this.requestTimeoutMs = config.requestTimeoutMs ?? 10000; // Default: 10 seconds
20
+ this.requestTimeoutMs = config.requestTimeoutMs ?? 10000;
20
21
  this.hostDownRevokeScore = config.hostDownRevokeScore ?? 3;
22
+ this.banService = config.banService;
23
+ this.autoBanOnRemoval = config.autoBanOnRemoval ?? true;
21
24
  }
22
25
  /**
23
- * Runs a single pass of health checks on all SHIP and SLAP outputs
26
+ * Runs a full pass of health checks on all SHIP and SLAP outputs.
27
+ * Returns a detailed report of the results.
24
28
  */
25
29
  async run() {
26
- this.logger.log(chalk.blue('🧹 Running janitor health checks...'));
30
+ const startedAt = new Date();
31
+ this.logger.log(chalk.blue('Running janitor health checks...'));
32
+ let shipResults = [];
33
+ let slapResults = [];
34
+ let removed = 0;
35
+ let banned = 0;
27
36
  try {
28
- // Check SHIP outputs
29
- await this.checkTopicOutputs('shipRecords');
30
- // Check SLAP outputs
31
- await this.checkTopicOutputs('slapRecords');
32
- this.logger.log(chalk.green('🧹 Janitor health checks completed'));
37
+ const shipCheckResult = await this.checkTopicOutputs('shipRecords', 'topic');
38
+ shipResults = shipCheckResult.results;
39
+ removed += shipCheckResult.removed;
40
+ banned += shipCheckResult.banned;
41
+ const slapCheckResult = await this.checkTopicOutputs('slapRecords', 'service');
42
+ slapResults = slapCheckResult.results;
43
+ removed += slapCheckResult.removed;
44
+ banned += slapCheckResult.banned;
45
+ this.logger.log(chalk.green('Janitor health checks completed'));
33
46
  }
34
47
  catch (error) {
35
- this.logger.error(chalk.red('❌ Error during health checks:'), error);
48
+ this.logger.error(chalk.red('Error during health checks:'), error);
36
49
  throw error;
37
50
  }
51
+ const completedAt = new Date();
52
+ const allResults = [...shipResults, ...slapResults];
53
+ return {
54
+ startedAt,
55
+ completedAt,
56
+ durationMs: completedAt.getTime() - startedAt.getTime(),
57
+ shipResults,
58
+ slapResults,
59
+ summary: {
60
+ totalChecked: allResults.length,
61
+ healthy: allResults.filter(r => r.healthy).length,
62
+ unhealthy: allResults.filter(r => !r.healthy).length,
63
+ removed,
64
+ banned
65
+ }
66
+ };
67
+ }
68
+ /**
69
+ * Checks a single URL's health endpoint. Used by the admin dashboard for on-demand checks.
70
+ */
71
+ async checkHost(url) {
72
+ const startTime = Date.now();
73
+ if (!this.isValidDomain(url)) {
74
+ return {
75
+ healthy: false,
76
+ responseTimeMs: Date.now() - startTime,
77
+ error: 'Invalid domain'
78
+ };
79
+ }
80
+ try {
81
+ const fullURL = url.startsWith('http') ? url : `https://${url}`;
82
+ const healthURL = new URL('/health', fullURL).toString();
83
+ const controller = new AbortController();
84
+ const timeout = setTimeout(() => controller.abort(), this.requestTimeoutMs);
85
+ try {
86
+ const response = await fetch(healthURL, {
87
+ method: 'GET',
88
+ signal: controller.signal,
89
+ headers: { Accept: 'application/json' }
90
+ });
91
+ clearTimeout(timeout);
92
+ const responseTimeMs = Date.now() - startTime;
93
+ if (!response.ok) {
94
+ return { healthy: false, responseTimeMs, statusCode: response.status, error: `HTTP ${response.status}` };
95
+ }
96
+ const data = await response.json();
97
+ const healthy = data?.status === 'ok';
98
+ return { healthy, responseTimeMs, statusCode: response.status, error: healthy ? undefined : 'Unexpected response' };
99
+ }
100
+ catch (error) {
101
+ clearTimeout(timeout);
102
+ const responseTimeMs = Date.now() - startTime;
103
+ if (error.name === 'AbortError') {
104
+ return { healthy: false, responseTimeMs, error: 'Timeout' };
105
+ }
106
+ return { healthy: false, responseTimeMs, error: error.message ?? 'Connection failed' };
107
+ }
108
+ }
109
+ catch (error) {
110
+ return { healthy: false, responseTimeMs: Date.now() - startTime, error: error.message ?? 'Invalid URL' };
111
+ }
112
+ }
113
+ /**
114
+ * Gets health status for all records without modifying them.
115
+ * Used by the dashboard to display current state.
116
+ */
117
+ async getHealthStatus() {
118
+ const shipCollection = this.mongoDb.collection('shipRecords');
119
+ const slapCollection = this.mongoDb.collection('slapRecords');
120
+ const [shipOutputs, slapOutputs] = await Promise.all([
121
+ shipCollection.find({}).toArray(),
122
+ slapCollection.find({}).toArray()
123
+ ]);
124
+ const shipResults = shipOutputs.map(output => ({
125
+ txid: output.txid,
126
+ outputIndex: output.outputIndex,
127
+ domain: this.extractURLFromOutput(output) ?? 'unknown',
128
+ topic: output.topic,
129
+ identityKey: output.identityKey,
130
+ createdAt: output.createdAt,
131
+ healthy: true, // Will be updated if health check is run
132
+ downCount: typeof output.down === 'number' ? output.down : 0
133
+ }));
134
+ const slapResults = slapOutputs.map(output => ({
135
+ txid: output.txid,
136
+ outputIndex: output.outputIndex,
137
+ domain: this.extractURLFromOutput(output) ?? 'unknown',
138
+ service: output.service,
139
+ identityKey: output.identityKey,
140
+ createdAt: output.createdAt,
141
+ healthy: true,
142
+ downCount: typeof output.down === 'number' ? output.down : 0
143
+ }));
144
+ return { ship: shipResults, slap: slapResults };
38
145
  }
39
146
  /**
40
- * Checks all outputs for a specific topic
147
+ * Checks all outputs for a specific collection and returns results.
41
148
  */
42
- async checkTopicOutputs(collectionName) {
149
+ async checkTopicOutputs(collectionName, typeField) {
150
+ const results = [];
151
+ let removed = 0;
152
+ let banned = 0;
43
153
  try {
44
154
  const collection = this.mongoDb.collection(collectionName);
45
155
  const outputs = await collection.find({}).toArray();
46
- this.logger.log(chalk.cyan(`🔍 Checking ${outputs.length} ${collectionName.toUpperCase()} outputs...`));
156
+ this.logger.log(chalk.cyan(`Checking ${outputs.length} ${collectionName} outputs...`));
47
157
  for (const output of outputs) {
48
- await this.checkOutput(output, collection);
158
+ const result = await this.checkOutput(output, collection, typeField);
159
+ results.push(result);
160
+ if (result.error === 'REMOVED') {
161
+ removed++;
162
+ }
163
+ }
164
+ // Count auto-bans that happened during this run
165
+ if (this.banService !== undefined && this.autoBanOnRemoval) {
166
+ banned = removed; // Each removal triggers a ban
49
167
  }
50
168
  }
51
169
  catch (error) {
52
- this.logger.error(chalk.red(`❌ Error checking ${collectionName.toUpperCase()} outputs:`), error);
170
+ this.logger.error(chalk.red(`Error checking ${collectionName} outputs:`), error);
53
171
  }
172
+ return { results, removed, banned };
54
173
  }
55
174
  /**
56
- * Checks a single output for health
175
+ * Checks a single output for health and returns the result.
57
176
  */
58
- async checkOutput(output, collection) {
177
+ async checkOutput(output, collection, typeField) {
178
+ const domain = this.extractURLFromOutput(output) ?? 'unknown';
179
+ const baseResult = {
180
+ txid: output.txid,
181
+ outputIndex: output.outputIndex,
182
+ domain,
183
+ identityKey: output.identityKey,
184
+ createdAt: output.createdAt,
185
+ healthy: false,
186
+ downCount: typeof output.down === 'number' ? output.down : 0
187
+ };
188
+ if (typeField === 'topic') {
189
+ baseResult.topic = output.topic;
190
+ }
191
+ else {
192
+ baseResult.service = output.service;
193
+ }
59
194
  try {
60
- // Extract the URL from the output
61
- const url = this.extractURLFromOutput(output);
62
- if (url === null) {
63
- return; // Skip if no valid URL
64
- }
65
- // Validate domain
66
- if (!this.isValidDomain(url)) {
67
- this.logger.log(chalk.yellow(`⚠️ Invalid domain for output ${String(output.txid)}:${String(output.outputIndex)}: ${url}`));
68
- await this.handleUnhealthyOutput(output, collection);
69
- return;
70
- }
71
- // Check health endpoint
72
- const isHealthy = await this.checkHealthEndpoint(url);
73
- if (isHealthy) {
195
+ if (domain === 'unknown') {
196
+ baseResult.error = 'No URL found';
197
+ await this.handleUnhealthyOutput(output, collection, domain);
198
+ return baseResult;
199
+ }
200
+ if (!this.isValidDomain(domain)) {
201
+ baseResult.error = 'Invalid domain';
202
+ await this.handleUnhealthyOutput(output, collection, domain);
203
+ return baseResult;
204
+ }
205
+ const healthResult = await this.checkHost(domain);
206
+ baseResult.healthy = healthResult.healthy;
207
+ baseResult.responseTimeMs = healthResult.responseTimeMs;
208
+ baseResult.statusCode = healthResult.statusCode;
209
+ baseResult.error = healthResult.error;
210
+ if (healthResult.healthy) {
74
211
  await this.handleHealthyOutput(output, collection);
212
+ baseResult.downCount = Math.max(0, baseResult.downCount - 1);
75
213
  }
76
214
  else {
77
- await this.handleUnhealthyOutput(output, collection);
215
+ const wasRemoved = await this.handleUnhealthyOutput(output, collection, domain);
216
+ baseResult.downCount++;
217
+ if (wasRemoved) {
218
+ baseResult.error = 'REMOVED';
219
+ }
78
220
  }
79
221
  }
80
222
  catch (error) {
81
- this.logger.error(chalk.red(`❌ Error checking output ${String(output.txid)}:${String(output.outputIndex)}:`), error);
82
- await this.handleUnhealthyOutput(output, collection).catch(() => { });
223
+ baseResult.error = error.message ?? 'Check failed';
224
+ await this.handleUnhealthyOutput(output, collection, domain).catch(() => { });
83
225
  }
226
+ return baseResult;
84
227
  }
85
228
  /**
86
229
  * Extracts URL from output record
87
230
  */
88
231
  extractURLFromOutput(output) {
89
232
  try {
90
- // SHIP and SLAP outputs typically have a domain field or URL field
91
- // Check for common field names
92
233
  if (typeof output.domain === 'string') {
93
234
  return output.domain;
94
235
  }
@@ -98,7 +239,6 @@ export class JanitorService {
98
239
  if (typeof output.serviceURL === 'string') {
99
240
  return output.serviceURL;
100
241
  }
101
- // SLAP outputs may have a protocols array with URLs
102
242
  if (Array.isArray(output.protocols) && output.protocols.length > 0) {
103
243
  const httpsProtocol = output.protocols.find((p) => typeof p === 'string' && p.startsWith('https://'));
104
244
  if (httpsProtocol !== undefined) {
@@ -116,11 +256,8 @@ export class JanitorService {
116
256
  */
117
257
  isValidDomain(url) {
118
258
  try {
119
- // Parse the URL
120
259
  const parsedURL = new URL(url.startsWith('http') ? url : `https://${url}`);
121
- // Check if hostname is valid
122
260
  const hostname = parsedURL.hostname;
123
- // Basic domain validation
124
261
  const domainRegex = /^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9][a-z0-9-]{0,61}[a-z0-9]$/i;
125
262
  const localhostRegex = /^localhost$/i;
126
263
  const ipv4Regex = /^(\d{1,3}\.){3}\d{1,3}$/;
@@ -130,44 +267,6 @@ export class JanitorService {
130
267
  return false;
131
268
  }
132
269
  }
133
- /**
134
- * Checks the /health endpoint of a service
135
- */
136
- async checkHealthEndpoint(url) {
137
- try {
138
- // Ensure URL has protocol
139
- const fullURL = url.startsWith('http') ? url : `https://${url}`;
140
- const healthURL = new URL('/health', fullURL).toString();
141
- // Create AbortController for timeout
142
- const controller = new AbortController();
143
- const timeout = setTimeout(() => controller.abort(), this.requestTimeoutMs);
144
- try {
145
- const response = await fetch(healthURL, {
146
- method: 'GET',
147
- signal: controller.signal,
148
- headers: {
149
- Accept: 'application/json'
150
- }
151
- });
152
- clearTimeout(timeout);
153
- if (!response.ok) {
154
- return false;
155
- }
156
- const data = await response.json();
157
- return data?.status === 'ok';
158
- }
159
- catch (error) {
160
- clearTimeout(timeout);
161
- if (error.name === 'AbortError') {
162
- this.logger.log(chalk.yellow(`⏱️ Health check timeout for ${healthURL}`));
163
- }
164
- return false;
165
- }
166
- }
167
- catch (error) {
168
- return false;
169
- }
170
- }
171
270
  /**
172
271
  * Handles a healthy output by decrementing its down counter
173
272
  */
@@ -175,36 +274,44 @@ export class JanitorService {
175
274
  try {
176
275
  const currentDown = typeof output.down === 'number' ? output.down : 0;
177
276
  if (currentDown > 0) {
178
- // Decrement the down counter
179
277
  await collection.updateOne({ _id: output._id }, { $inc: { down: -1 } });
180
- this.logger.log(chalk.green(`✅ Output ${String(output.txid)}:${String(output.outputIndex)} is healthy (down: ${currentDown} -> ${currentDown - 1})`));
181
278
  }
182
279
  }
183
280
  catch (error) {
184
- this.logger.error(chalk.red(`❌ Error handling healthy output ${String(output.txid)}:${String(output.outputIndex)}:`), error);
281
+ this.logger.error(chalk.red(`Error handling healthy output ${String(output.txid)}:${String(output.outputIndex)}:`), error);
185
282
  }
186
283
  }
187
284
  /**
188
- * Handles an unhealthy output by incrementing its down counter and deleting if threshold is reached
285
+ * Handles an unhealthy output by incrementing its down counter.
286
+ * If the threshold is reached, deletes the record and optionally bans the domain.
287
+ * Returns true if the record was removed.
189
288
  */
190
- async handleUnhealthyOutput(output, collection) {
289
+ async handleUnhealthyOutput(output, collection, domain) {
191
290
  try {
192
291
  const currentDown = typeof output.down === 'number' ? output.down : 0;
193
292
  const newDown = currentDown + 1;
194
- this.logger.log(chalk.yellow(`⚠️ Output ${String(output.txid)}:${String(output.outputIndex)} is unhealthy (down: ${currentDown} -> ${newDown})`));
195
- // Check if we should delete the record
196
293
  if (newDown >= this.hostDownRevokeScore) {
197
- this.logger.log(chalk.red(`🚫 Deleting output ${String(output.txid)}:${String(output.outputIndex)} (down count: ${newDown} >= ${this.hostDownRevokeScore})`));
294
+ this.logger.log(chalk.red(`Removing output ${String(output.txid)}:${String(output.outputIndex)} (down: ${newDown} >= ${this.hostDownRevokeScore})`));
198
295
  await collection.deleteOne({ _id: output._id });
199
- this.logger.log(chalk.green(`✅ Successfully deleted output ${String(output.txid)}:${String(output.outputIndex)}`));
296
+ // Auto-ban the domain and outpoint to prevent GASP re-sync
297
+ if (this.banService !== undefined && this.autoBanOnRemoval) {
298
+ const txid = output.txid;
299
+ const outputIndex = output.outputIndex;
300
+ await this.banService.banOutpoint(txid, outputIndex, `Auto-banned by janitor: host down ${newDown} consecutive checks`, domain);
301
+ if (typeof domain === 'string' && domain !== 'unknown') {
302
+ await this.banService.banDomain(domain, `Auto-banned by janitor: host unresponsive after ${newDown} checks`);
303
+ }
304
+ }
305
+ return true;
200
306
  }
201
307
  else {
202
- // Increment the down counter
203
308
  await collection.updateOne({ _id: output._id }, { $inc: { down: 1 } });
309
+ return false;
204
310
  }
205
311
  }
206
312
  catch (error) {
207
- this.logger.error(chalk.red(`❌ Error handling unhealthy output ${String(output.txid)}:${String(output.outputIndex)}:`), error);
313
+ this.logger.error(chalk.red(`Error handling unhealthy output ${String(output.txid)}:${String(output.outputIndex)}:`), error);
314
+ return false;
208
315
  }
209
316
  }
210
317
  }
@@ -1 +1 @@
1
- {"version":3,"file":"JanitorService.js","sourceRoot":"","sources":["../../../src/JanitorService.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAA;AAYzB;;;;;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