﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
14917	"""generateToken()"": IE11 support + potential bug Safari 5-"	ARuben Consulting		"Hi,

'''I notice a potential bug in ""tools.generateToken()"" for Safari 5-:
'''
* according to ""developer.mozilla.org"", the typed array 'Uint8Array' is available in Safari 5.1+, and 'window.crypto.getRandomValues' in Safari 3.1+, but the function ""tools.generateToken()"" creates a 'New Uint8Array' array if 'getRandomValues' exist, assuming that the 2 are available.

* but according to ""caniuse.com"", there is no problem because 'getRandomValues' is available since Safari 6+.

I don't have a Safari 3.1 to 5 to test. So I don't confirm the bug.

''Solution:
''


Add the test: "" && typeof Uint8Array !== 'undefined' ""

Before:

{{{
if ( window.crypto && window.crypto.getRandomValues ) {
}}}


After:

{{{
if ( window.crypto && window.crypto.getRandomValues && typeof Uint8Array !== 'undefined' ) {
}}}




'''Enhancement for IE11:
'''

You can also support MS IE11 crypto librairy: msCrypto.

So, before:

{{{
if ( window.crypto && window.crypto.getRandomValues ) {
	randValues = new Uint8Array( length );
	window.crypto.getRandomValues( randValues );
} else {
}}}

and after:

{{{
var cryp = window.crypto || window.msCrypto;
if ( cryp && cryp.getRandomValues && typeof Uint8Array !== 'undefined' ) {
	randValues = new Uint8Array( length );
	cryp.getRandomValues( randValues );
} else {
}}}


Thanks,

ARuben"	Bug	closed	Normal		General		wontfix		
