diff --git a/packages/firestore/src/platform_browser/browser_platform.ts b/packages/firestore/src/platform_browser/browser_platform.ts index d1dc1a75124..8ba09fe99a0 100644 --- a/packages/firestore/src/platform_browser/browser_platform.ts +++ b/packages/firestore/src/platform_browser/browser_platform.ts @@ -25,6 +25,10 @@ import { NoopConnectivityMonitor } from '../remote/connectivity_monitor_noop'; import { BrowserConnectivityMonitor } from './browser_connectivity_monitor'; import { WebChannelConnection } from './webchannel_connection'; +// Polyfill for IE +// eslint-disable-next-line @typescript-eslint/no-explicit-any +const crypto = window.crypto || (window as any).msCrypto; + export class BrowserPlatform implements Platform { readonly useProto3Json = true; readonly base64Available: boolean; diff --git a/packages/firestore/src/util/misc.ts b/packages/firestore/src/util/misc.ts index dd37a9d3b36..e8c52a4fd42 100644 --- a/packages/firestore/src/util/misc.ts +++ b/packages/firestore/src/util/misc.ts @@ -31,7 +31,7 @@ export class AutoId { let autoId = ''; while (autoId.length < 20) { const bytes = PlatformSupport.getPlatform().randomBytes(40); - bytes.forEach(b => { + for (const b of Array.from(bytes)) { // Length of `chars` is 62. We only take bytes between 0 and 62*4-1 // (both inclusive). The value is then evenly mapped to indices of `char` // via a modulo operation. @@ -39,7 +39,7 @@ export class AutoId { if (autoId.length < 20 && b <= maxValue) { autoId += chars.charAt(b % 62); } - }); + } } assert(autoId.length === 20, 'Invalid auto ID: ' + autoId); return autoId;