feat(platform): Phase 112 relay signing and health decay
- Sign relay handoffs with guild-derived secret for webhook/smtp plugins - Verify signature on getLastDigestRelayHandoff (signatureValid) - Apply health decay in archive peer picker - Show signature status in server settings UI Co-authored-by: Cursor <[email protected]>
This commit is contained in:
@@ -52,6 +52,7 @@ const {
|
||||
buildDigestRelayHandoff,
|
||||
formatHookFailureDigestDmSummary,
|
||||
computeArchivePeerHealthScore,
|
||||
applyArchivePeerHealthDecay,
|
||||
computeArchiveFetchBackoffMs,
|
||||
HookFailureAlertStore
|
||||
} = require('pearcord-delivery-receipts')
|
||||
@@ -67,6 +68,7 @@ const {
|
||||
} = require('pearcord-integration-worker')
|
||||
const {
|
||||
applyRelayPluginToHandoff,
|
||||
verifyDigestRelayHandoff,
|
||||
listBuiltinDigestRelayPlugins
|
||||
} = require('pearcord-digest-relay-plugin')
|
||||
const { PearcordIntegrationWorker } = require('./integration-worker')
|
||||
@@ -2198,7 +2200,7 @@ class PearcordPlatform extends EventEmitter {
|
||||
presenceSeen.get(userId) || 0,
|
||||
stored?.lastSeenAt || 0
|
||||
) || null
|
||||
const health =
|
||||
const baseHealth =
|
||||
stored?.healthScore != null
|
||||
? {
|
||||
score: stored.healthScore,
|
||||
@@ -2209,6 +2211,7 @@ class PearcordPlatform extends EventEmitter {
|
||||
online: presenceOnline || (userId === selfId && meshLive),
|
||||
lastSeenAt
|
||||
})
|
||||
const health = applyArchivePeerHealthDecay(baseHealth, { lastSeenAt })
|
||||
options.push({
|
||||
memberId: userId,
|
||||
label: userId === selfId ? `${name} (you)` : name,
|
||||
@@ -2217,6 +2220,7 @@ class PearcordPlatform extends EventEmitter {
|
||||
lastSeenAt,
|
||||
healthScore: health.score,
|
||||
healthLabel: health.label,
|
||||
healthDecayed: !!health.decayed,
|
||||
isSelf: userId === selfId
|
||||
})
|
||||
}
|
||||
@@ -2672,7 +2676,12 @@ class PearcordPlatform extends EventEmitter {
|
||||
async getLastDigestRelayHandoff () {
|
||||
if (!this.guild?.guild) return null
|
||||
await this._initDeliveryReceipts(this.guild.guild.id)
|
||||
return this.deliveryReceipts.getLastDigestRelayHandoff()
|
||||
const handoff = await this.deliveryReceipts.getLastDigestRelayHandoff()
|
||||
if (!handoff?.signature) return handoff
|
||||
const verified = verifyDigestRelayHandoff(handoff, {
|
||||
relaySecret: this.guild.guild.id
|
||||
})
|
||||
return { ...handoff, signatureValid: verified.ok }
|
||||
}
|
||||
|
||||
async getAutomationDigestNotifyPrefs () {
|
||||
@@ -2823,7 +2832,11 @@ class PearcordPlatform extends EventEmitter {
|
||||
snapshot: snap
|
||||
})
|
||||
const plugin = await this.deliveryReceipts.getActiveDigestRelayPlugin()
|
||||
if (plugin) handoff = applyRelayPluginToHandoff(handoff, plugin)
|
||||
if (plugin) {
|
||||
handoff = applyRelayPluginToHandoff(handoff, plugin, {
|
||||
relaySecret: this.guild.guild.id
|
||||
})
|
||||
}
|
||||
await this.deliveryReceipts.appendDigestRelayHandoff(handoff)
|
||||
this.emit('digest-relay-handoff', handoff)
|
||||
return handoff
|
||||
|
||||
Reference in New Issue
Block a user