comparison src/browser/sat_browser/otrjs_wrapper.py @ 549:cd56f2b0e85b

browser_side: disable OTR if the browser is too old to offer crypto.getRandomValues (CSPRNG)
author souliane <souliane@mailoo.org>
date Wed, 17 Sep 2014 17:15:03 +0200
parents cd492c18b366
children 9877607c719a
comparison
equal deleted inserted replaced
548:530f3fc3e3d7 549:cd56f2b0e85b
39 # XXX: pyjamas can't probably import more than one JS file, it messes the order. 39 # XXX: pyjamas can't probably import more than one JS file, it messes the order.
40 # XXX: pyjamas needs the file to be in the compilation directory - no submodule. 40 # XXX: pyjamas needs the file to be in the compilation directory - no submodule.
41 # XXX: pyjamas needs the imported file to end with a empty line or semi-column. 41 # XXX: pyjamas needs the imported file to end with a empty line or semi-column.
42 # FIXME: fix these bugs upstream in Pyjamas 42 # FIXME: fix these bugs upstream in Pyjamas
43 import otr.min.js 43 import otr.min.js
44
45
46 def isSupported():
47 JS("""return (typeof OTR !== 'undefined');""")
48
49
50 if not isSupported():
51 # see https://developer.mozilla.org/en-US/docs/Web/API/window.crypto.getRandomValues#Browser_Compatibility
52 log.error('Your browser is not implementing CSPRNG: OTR has been disabled.')
53 raise ImportError('CSPRNG is not supported by your browser')
44 54
45 55
46 class context(object): 56 class context(object):
47 57
48 # Pre-declare these attributes to avoid the pylint "undefined variable" errors 58 # Pre-declare these attributes to avoid the pylint "undefined variable" errors