diff --git a/src/services/provider/Firebase.ts b/src/services/provider/Firebase.ts index 019a9ce5..33e030e8 100644 --- a/src/services/provider/Firebase.ts +++ b/src/services/provider/Firebase.ts @@ -52,14 +52,14 @@ import { IDeviceInformation } from '../hid/Hid'; import * as crypto from 'crypto'; import { IBootloaderType } from '../firmware/Types'; -const config = { - apiKey: import.meta.env.REACT_APP_FIREBASE_API_KEY, - authDomain: import.meta.env.REACT_APP_FIREBASE_AUTH_DOMAIN, - projectId: import.meta.env.REACT_APP_FIREBASE_PROJECT_ID, - storageBucket: import.meta.env.REACT_APP_FIREBASE_STORAGE_BUCKET, - messagingSenderId: import.meta.env.REACT_APP_FIREBASE_MESSAGE_SENDER_ID, - appId: import.meta.env.REACT_APP_FIREBASE_APP_ID, - measurementId: import.meta.env.REACT_APP_FIREBASE_MEASUREMENT_ID, +export type IFirebaseConfiguration = { + apiKey: string; + authDomain: string; + projectId: string; + storageBucket: string; + messagingSenderId: string; + appId: string; + measurementId: string; }; const FUNCTIONS_REGION = 'asia-northeast1'; @@ -71,7 +71,7 @@ export class FirebaseProvider implements IStorage, IAuth { private functions: firebase.functions.Functions; private unsubscribeAuthStateChanged?: firebase.Unsubscribe; - constructor() { + constructor(config: IFirebaseConfiguration) { firebase.initializeApp(config); firebase.analytics(); const app = firebase.app(); diff --git a/src/services/provider/FirebaseConfiguration.ts b/src/services/provider/FirebaseConfiguration.ts new file mode 100644 index 00000000..48cd9e76 --- /dev/null +++ b/src/services/provider/FirebaseConfiguration.ts @@ -0,0 +1,11 @@ +import { IFirebaseConfiguration } from './Firebase'; + +export const firebaseConfiguration: IFirebaseConfiguration = { + apiKey: import.meta.env.REACT_APP_FIREBASE_API_KEY, + authDomain: import.meta.env.REACT_APP_FIREBASE_AUTH_DOMAIN, + projectId: import.meta.env.REACT_APP_FIREBASE_PROJECT_ID, + storageBucket: import.meta.env.REACT_APP_FIREBASE_STORAGE_BUCKET, + messagingSenderId: import.meta.env.REACT_APP_FIREBASE_MESSAGE_SENDER_ID, + appId: import.meta.env.REACT_APP_FIREBASE_APP_ID, + measurementId: import.meta.env.REACT_APP_FIREBASE_MEASUREMENT_ID, +}; diff --git a/src/store/state.ts b/src/store/state.ts index 631ce660..da75e20d 100644 --- a/src/store/state.ts +++ b/src/store/state.ts @@ -35,6 +35,7 @@ import { IFirmwareWriter } from '../services/firmware/FirmwareWriter'; import { FirmwareWriterWebApiImpl } from '../services/firmware/FirmwareWriterWebApiImpl'; import { IBootloaderType } from '../services/firmware/Types'; import { getLocalAuthenticationUid } from '../utils/AuthUtils'; +import { firebaseConfiguration } from '../services/provider/FirebaseConfiguration'; export type ISetupPhase = | 'init' @@ -488,7 +489,7 @@ export type RootState = { let firebaseProvider; try { - firebaseProvider = new FirebaseProvider(); + firebaseProvider = new FirebaseProvider(firebaseConfiguration); } catch (cause) { if (import.meta.env.NODE_ENV === 'production') { throw cause;