import sasl from 'stanza/lib/sasl/index.js'; // Public constructor selects the existing browser backend's supported hash alias. // The delegate name never goes on the wire. No private field is read or changed. export class Sha512Mechanism { name = 'SCRAM-SHA-512'; providesMutualAuthentication = true; #delegate; constructor(name) { if (name !== this.name) throw new Error('Unsupported mechanism'); this.#delegate = new sasl.SCRAM('SCRAM-SHA512'); } getExpectedCredentials() { return this.#delegate.getExpectedCredentials(); } // Keep derived credentials attempt-local; no cache leaves this boundary. getCacheableCredentials() { return null; } createResponse(credentials) { if (credentials.tlsUnique) throw new Error('Channel binding unavailable'); return this.#delegate.createResponse(credentials); } processChallenge(value) { this.#delegate.processChallenge(value); } processSuccess(value) { this.#delegate.processSuccess(value); } finalize() { return this.#delegate.finalize(); } } export function registerSha512(client) { client.sasl.disable('SCRAM-SHA-512'); client.sasl.register('SCRAM-SHA-512', Sha512Mechanism, 1000); }