diff --git a/packages/vertexai/__tests__/api.test.ts b/packages/vertexai/__tests__/api.test.ts
index d38b0306c2..6b5d59e185 100644
--- a/packages/vertexai/__tests__/api.test.ts
+++ b/packages/vertexai/__tests__/api.test.ts
@@ -44,7 +44,7 @@ describe('Top level API', () => {
const app = firebase.app();
const auth = app.auth();
const appCheck = app.appCheck();
- // proves our limited internal auth and app check types are correct and allow them to be passed in
+
getVertexAI(app, undefined, appCheck, auth);
});
diff --git a/packages/vertexai/lib/index.ts b/packages/vertexai/lib/index.ts
index 3898e004e0..53e8f849ed 100644
--- a/packages/vertexai/lib/index.ts
+++ b/packages/vertexai/lib/index.ts
@@ -17,7 +17,6 @@
import './polyfills';
import { getApp, ReactNativeFirebase } from '@react-native-firebase/app';
-import { InternalAppCheck, InternalAuth } from './types/internal';
import { ModelParams, RequestOptions, VertexAIErrorCode } from './types';
import { DEFAULT_LOCATION } from './constants';
import { VertexAI, VertexAIOptions } from './public-types';
@@ -26,15 +25,13 @@ import { GenerativeModel } from './models/generative-model';
import { VertexAIService } from './service';
export { ChatSession } from './methods/chat-session';
export * from './requests/schema-builder';
+import { FirebaseAuthTypes } from '@react-native-firebase/auth';
+import { FirebaseAppCheckTypes } from '@react-native-firebase/app-check';
export { GenerativeModel };
export { VertexAIError };
-// We don't have access to RNFB auth and appCheck so we use only types for what we need (i.e get tokens)
-type AppCheck = InternalAppCheck;
-type Auth = InternalAuth;
-
/**
* Returns a {@link VertexAI}
instance for the given app.
*
@@ -48,8 +45,8 @@ type Auth = InternalAuth;
export function getVertexAI(
app: ReactNativeFirebase.FirebaseApp = getApp(),
options?: VertexAIOptions,
- appCheck?: AppCheck,
- auth?: Auth,
+ appCheck?: FirebaseAppCheckTypes.Module,
+ auth?: FirebaseAuthTypes.Module,
): VertexAI {
return {
app,
diff --git a/packages/vertexai/lib/service.ts b/packages/vertexai/lib/service.ts
index 4f184a94ae..b8ba390472 100644
--- a/packages/vertexai/lib/service.ts
+++ b/packages/vertexai/lib/service.ts
@@ -18,17 +18,18 @@
import { ReactNativeFirebase } from '@react-native-firebase/app';
import { VertexAI, VertexAIOptions } from './public-types';
import { DEFAULT_LOCATION } from './constants';
-import { InternalAppCheck, InternalAuth } from './types/internal';
+import { FirebaseAuthTypes } from '@react-native-firebase/auth';
+import { FirebaseAppCheckTypes } from '@react-native-firebase/app-check';
export class VertexAIService implements VertexAI {
- auth: InternalAuth | null;
- appCheck: InternalAppCheck | null;
+ auth: FirebaseAuthTypes.Module | null;
+ appCheck: FirebaseAppCheckTypes.Module | null;
location: string;
constructor(
public app: ReactNativeFirebase.FirebaseApp,
- auth?: InternalAuth,
- appCheck?: InternalAppCheck,
+ auth?: FirebaseAuthTypes.Module,
+ appCheck?: FirebaseAppCheckTypes.Module,
public options?: VertexAIOptions,
) {
this.auth = auth || null;
diff --git a/packages/vertexai/lib/types/internal.ts b/packages/vertexai/lib/types/internal.ts
index 5b48331d19..0dbf88efb1 100644
--- a/packages/vertexai/lib/types/internal.ts
+++ b/packages/vertexai/lib/types/internal.ts
@@ -14,62 +14,12 @@
* limitations under the License.
*
*/
+import { FirebaseAppCheckTypes } from '@react-native-firebase/app-check';
export interface ApiSettings {
apiKey: string;
project: string;
location: string;
getAuthToken?: () => Promise;
- getAppCheckToken?: () => Promise;
-}
-
-export interface InternalAppCheck {
- /**
- * Requests Firebase App Check token.
- * This method should only be used if you need to authorize requests to a non-Firebase backend.
- * Requests to Firebase backend are authorized automatically if configured.
- *
- * @param forceRefresh - If true, a new Firebase App Check token is requested and the token cache is ignored.
- * If false, the cached token is used if it exists and has not expired yet.
- * In most cases, false should be used. True should only be used if the server explicitly returns an error, indicating a revoked token.
- */
- getToken(forceRefresh?: boolean): Promise;
-}
-
-interface AppCheckTokenResult {
- /**
- * The token string in JWT format.
- */
- readonly token: string;
-}
-
-export interface InternalAuth {
- /**
- * Returns the currently signed-in user (or null if no user signed in). See the User interface documentation for detailed usage.
- *
- * #### Example
- *
- * ```js
- * const user = firebase.auth().currentUser;
- * ```
- *
- * > It is recommended to use {@link auth#onAuthStateChanged} to track whether the user is currently signed in.
- */
- currentUser: User | null;
-}
-
-export interface User {
- /**
- * Returns the users authentication token.
- *
- * #### Example
- *
- * ```js
- * // Force a token refresh
- * const idToken = await firebase.auth().currentUser.getIdToken(true);
- * ```
- *
- * @param forceRefresh A boolean value which forces Firebase to refresh the token.
- */
- getIdToken(forceRefresh?: boolean): Promise;
+ getAppCheckToken?: () => Promise;
}
diff --git a/packages/vertexai/tsconfig.json b/packages/vertexai/tsconfig.json
index 3a420fc518..f1d9865812 100644
--- a/packages/vertexai/tsconfig.json
+++ b/packages/vertexai/tsconfig.json
@@ -24,7 +24,9 @@
"strict": true,
"baseUrl": ".",
"paths": {
- "@react-native-firebase/app": ["../app/lib"]
+ "@react-native-firebase/app": ["../app/lib"],
+ "@react-native-firebase/auth": ["../auth/lib"],
+ "@react-native-firebase/app-check": ["../app-check/lib"],
}
}
}
diff --git a/tsconfig-jest.json b/tsconfig-jest.json
index 14fb61e3a3..0149111b06 100644
--- a/tsconfig-jest.json
+++ b/tsconfig-jest.json
@@ -3,7 +3,9 @@
"compilerOptions": {
"baseUrl": ".",
"paths": {
- "@react-native-firebase/app": ["packages/app/lib"]
+ "@react-native-firebase/app": ["packages/app/lib"],
+ "@react-native-firebase/auth": ["packages/auth/lib"],
+ "@react-native-firebase/app-check": ["packages/app-check/lib"],
}
}
}