import JSSHA from 'jssha/dist/sha1' ; import { pwnedPasswordRange } from './pwnedPasswordRange' ; param { string } password param options param { string } options . baseUrl param { string } options . userAgent returns { Promise < number > } example see https export function pwnedPassword ( password , options = { } ) { const sha1 = new JSSHA ( 'SHA-1' , 'TEXT' ) ; sha1 . update ( password ) ; const hash = sha1 . getHash ( 'HEX' , { outputUpper : true } ) ; const prefix = hash . slice ( 0 , 5 ) ; const suffix = hash . slice ( 5 ) ; return pwnedPasswordRange ( prefix , options ) . then ( ( range ) => range [ suffix ] || 0 ) ; }