strophe.js
Version:
Strophe.js is an XMPP library for JavaScript
24 lines (18 loc) • 755 B
text/typescript
import type Connection from './connection';
import SASLMechanism from './sasl';
import scram from './scram';
class SASLSHA1 extends SASLMechanism {
constructor(mechname = 'SCRAM-SHA-1', isClientFirst = true, priority = 60) {
super(mechname, isClientFirst, priority);
}
test(connection: Connection): boolean {
return connection.authcid !== null && scram.supported();
}
async onChallenge(connection: Connection, challenge?: string): Promise<string | false> {
return await scram.scramResponse(connection, challenge, 'SHA-1', 160);
}
clientChallenge(connection: Connection, test_cnonce?: string): string {
return scram.clientChallenge(connection, test_cnonce);
}
}
export default SASLSHA1;