diff --git a/packages/app-check/lib/modular/index.d.ts b/packages/app-check/lib/modular/index.d.ts index 80026ec2b2..a03dfe78eb 100644 --- a/packages/app-check/lib/modular/index.d.ts +++ b/packages/app-check/lib/modular/index.d.ts @@ -14,23 +14,20 @@ import CustomProviderOptions = FirebaseAppCheckTypes.CustomProviderOptions; * Activate App Check for the given app. Can be called only once per app. * @param app - FirebaseApp. Optional. * @param options - AppCheckOptions - * @returns {Promise<{ app: FirebaseApp }>} + * @returns {Promise<AppCheck>} */ -export function initializeAppCheck( - app?: FirebaseApp, - options?: AppCheckOptions, -): Promise<{ app: FirebaseApp }>; +export function initializeAppCheck(app?: FirebaseApp, options?: AppCheckOptions): Promise<AppCheck>; /** * Get the current App Check token. Attaches to the most recent in-flight request if one is present. * Returns null if no token is present and no token requests are in-flight. * @param appCheckInstance - AppCheck - * @param forceRefresh - boolean + * @param forceRefresh - If true, will always try to fetch a fresh token. If false, will use a cached token if found in storage. * @returns {Promise<AppCheckTokenResult>} */ export function getToken( appCheckInstance: AppCheck, - forceRefresh: boolean, + forceRefresh?: boolean, ): Promise<AppCheckTokenResult>; /** diff --git a/packages/app-check/lib/modular/index.js b/packages/app-check/lib/modular/index.js index 25238f93b2..e2a4363685 100644 --- a/packages/app-check/lib/modular/index.js +++ b/packages/app-check/lib/modular/index.js @@ -32,29 +32,28 @@ import CustomProvider from '../ReactNativeFirebaseAppCheckProvider'; * Activate App Check for the given app. Can be called only once per app. * @param {FirebaseApp} [app] - The app to initialize App Check for. Optional. * @param {AppCheckOptions} options - App Check options. - * @returns {Promise<{ app: FirebaseApp }>} + * @returns {Promise<AppCheck>} */ export async function initializeAppCheck(app, options) { if (app) { const appCheck = getApp(app.name).appCheck(); await appCheck.initializeAppCheck.call(appCheck, options, MODULAR_DEPRECATION_ARG); - return { app: getApp(app.name) }; + return appCheck; } const appCheck = getApp().appCheck(); await appCheck.initializeAppCheck.call(appCheck, options, MODULAR_DEPRECATION_ARG); - return { app: getApp() }; + return appCheck; } /** * Get the current App Check token. Attaches to the most recent in-flight request if one is present. * Returns null if no token is present and no token requests are in-flight. * @param {AppCheck} appCheckInstance - The App Check instance. - * @param {boolean} forceRefresh - Whether to force refresh the token. + * @param {boolean} forceRefresh - Whether to force refresh the token. Optional * @returns {Promise<AppCheckTokenResult>} */ export function getToken(appCheckInstance, forceRefresh) { - const appCheck = appCheckInstance.app.appCheck(); - return appCheck.getToken.call(appCheck, forceRefresh, MODULAR_DEPRECATION_ARG); + return appCheckInstance.getToken.call(appCheckInstance, forceRefresh, MODULAR_DEPRECATION_ARG); } /** @@ -64,8 +63,7 @@ export function getToken(appCheckInstance, forceRefresh) { * @returns {Promise<AppCheckTokenResult>} */ export function getLimitedUseToken(appCheckInstance) { - const appCheck = appCheckInstance.app.appCheck(); - return appCheck.getLimitedUseToken.call(appCheck, MODULAR_DEPRECATION_ARG); + return appCheckInstance.getLimitedUseToken.call(appCheckInstance, MODULAR_DEPRECATION_ARG); } /** @@ -74,9 +72,8 @@ export function getLimitedUseToken(appCheckInstance) { * @param {boolean} isAutoRefreshEnabled - Whether to enable auto-refresh. */ export function setTokenAutoRefreshEnabled(appCheckInstance, isAutoRefreshEnabled) { - const appCheck = appCheckInstance.app.appCheck(); - return appCheck.setTokenAutoRefreshEnabled.call( - appCheck, + return appCheckInstance.setTokenAutoRefreshEnabled.call( + appCheckInstance, isAutoRefreshEnabled, MODULAR_DEPRECATION_ARG, ); @@ -93,9 +90,8 @@ export function setTokenAutoRefreshEnabled(appCheckInstance, isAutoRefreshEnable * @returns {Unsubscribe} */ export function onTokenChanged(appCheckInstance, onNextOrObserver, onError, onCompletion) { - const appCheck = appCheckInstance.app.appCheck(); - return appCheck.onTokenChanged.call( - appCheck, + return appCheckInstance.onTokenChanged.call( + appCheckInstance, onNextOrObserver, onError, onCompletion,