Files
Luma/Sources/Shared/XMPP/LumaSaslChallengeModule.swift
T
wt 1650145d4d
iOS CI / Build and Test SwiftUI App (push) Canceled after 0s
Build Unsigned iOS and macOS Apps / Build Unsigned iOS IPA (push) Canceled after 0s
Build Unsigned iOS and macOS Apps / Build macOS ZIP (push) Canceled after 0s
serverinfoview
2026-09-03 12:42:20 +07:00

27 lines
926 B
Swift

import Foundation
import Martin
/// Observes the raw SASL `<challenge/>` stanzas before `SaslModule` consumes
/// them, so Luma can detect the XEP-0474 downgrade-protection hash (`h=`
/// attribute in the SCRAM server-first message) regardless of which SCRAM
/// mechanism implementation actually runs the exchange. Registered before
/// `SaslModule` in the module list.
final class LumaSaslChallengeModule: XmppModuleBase, XmppModule {
static let ID = "lumaSaslChallenge"
static let saslXMLNS = "urn:ietf:params:xml:ns:xmpp-sasl"
let criteria = Criteria.name("challenge", xmlns: LumaSaslChallengeModule.saslXMLNS)
let features: [String] = []
private let onChallenge: (String) -> Void
init(onChallenge: @escaping (String) -> Void) {
self.onChallenge = onChallenge
super.init()
}
func process(stanza: Stanza) throws {
onChallenge(stanza.element.value ?? "")
}
}