File tree 1 file changed +8
-6
lines changed
packages/firestore/src/platform_browser
1 file changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -25,10 +25,6 @@ import { NoopConnectivityMonitor } from '../remote/connectivity_monitor_noop';
25
25
import { BrowserConnectivityMonitor } from './browser_connectivity_monitor' ;
26
26
import { WebChannelConnection } from './webchannel_connection' ;
27
27
28
- // Polyfill for IE and WebWorker
29
- // eslint-disable-next-line no-restricted-globals
30
- const crypto = window [ 'crypto' ] || window [ 'msCrypto' ] || self [ 'crypto' ] ;
31
-
32
28
// Implements the Platform API for browsers and some browser-like environments
33
29
// (including ReactNative).
34
30
export class BrowserPlatform implements Platform {
@@ -84,12 +80,18 @@ export class BrowserPlatform implements Platform {
84
80
return new Uint8Array ( ) ;
85
81
}
86
82
83
+ // Polyfill for IE and WebWorker
84
+ // eslint-disable-next-line no-restricted-globals
85
+ const crypto =
86
+ ( this . window &&
87
+ ( this . window . crypto || ( this . window as any ) [ 'msCrypto' ] ) ) ||
88
+ ( self && self . crypto ) ;
87
89
const v = new Uint8Array ( nBytes ) ;
88
- if ( ! ! crypto ) {
90
+ if ( ! ! crypto ) {
89
91
crypto . getRandomValues ( v ) ;
90
92
} else {
91
93
// Falls back to Math.random
92
- for ( let i = 0 ; i < nBytes ; i ++ ) {
94
+ for ( let i = 0 ; i < nBytes ; i ++ ) {
93
95
v [ i ] = Math . floor ( Math . random ( ) * 256 ) ;
94
96
}
95
97
}
You can’t perform that action at this time.
0 commit comments