11import { isIndexedDBAvailable , generateSHA256HashBrowser , Deferred } from '@firebase/util' ;
22
3- import { type ConnectorConfig } from '../api/DataConnect' ;
3+ import { CacheProviderImpl , PublicIndexedDbProvider , type ConnectorConfig } from '../api/DataConnect' ;
44import { DataConnectError } from '../core/error' ;
55import { type AuthTokenProvider } from '../core/FirebaseAuthProvider' ;
66import { logDebug } from '../logger' ;
@@ -21,7 +21,7 @@ export type DataConnectStorage = typeof Memory | typeof Persistent;
2121 * CacheSettings
2222 */
2323export interface CacheSettings {
24- storage : DataConnectStorage ;
24+ storage : CacheProviderImpl ;
2525 maxSizeBytes : number ;
2626}
2727
@@ -57,7 +57,7 @@ export class DataConnectCache {
5757 }
5858
5959 async getIdentifier ( uid : string ) : Promise < string > {
60- const identifier = `${ this . cacheSettings ?. storage === Persistent ? 'persistent' : 'memory' } -${ this . projectId } -${ this . connectorConfig . service } -${ this . connectorConfig . connector } -${ this . connectorConfig . location } -${ uid } -${ this . host } ` ;
60+ const identifier = `${ this . cacheSettings ?. storage instanceof InMemoryCacheProvider ? 'persistent' : 'memory' } -${ this . projectId } -${ this . connectorConfig . service } -${ this . connectorConfig . connector } -${ this . connectorConfig . location } -${ uid } -${ this . host } ` ;
6161 const sha256 = await generateSHA256HashBrowser ( identifier ) ;
6262 return sha256 ;
6363 }
@@ -77,7 +77,7 @@ export class DataConnectCache {
7777 await this . cacheProvider ?. close ( ) ;
7878 let cacheProvider : CacheProvider ;
7979 const identifier = await this . getIdentifier ( this . uid ) ;
80- const isPersistenceEnabled = this . cacheSettings ?. storage === Persistent ;
80+ const isPersistenceEnabled = this . cacheSettings ?. storage instanceof PublicIndexedDbProvider ;
8181 if ( this . cacheSettings ) {
8282 cacheProvider = isPersistenceEnabled ? new IndexedDBCacheProvider ( identifier ) : new InMemoryCacheProvider ( identifier ) ;
8383 } else if ( ! isIndexedDBAvailable ( ) ) {
0 commit comments