import { toBase64Url } from 'utils/string' ; param length return export function getRandomString ( length = 128 ) { const randomValues = window . crypto . getRandomValues ( new Uint8Array ( length ) ) ; const randomString = Array . prototype . map . call ( randomValues , ( value ) => String . fromCharCode ( value ) ) . join ( '' ) ; return toBase64Url ( btoa ( randomString ) ) . substring ( 0 , length ) ; }