Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(app-check): type def fixes #8367

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions packages/app-check/lib/modular/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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>;

/**
Expand Down
14 changes: 7 additions & 7 deletions packages/app-check/lib/modular/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,28 @@
* 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 };

Check warning on line 41 in packages/app-check/lib/modular/index.js

View check run for this annotation

Codecov / codecov/patch

packages/app-check/lib/modular/index.js#L41

Added line #L41 was not covered by tests
}
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();
const appCheck = appCheckInstance.appCheck;

Check warning on line 56 in packages/app-check/lib/modular/index.js

View check run for this annotation

Codecov / codecov/patch

packages/app-check/lib/modular/index.js#L56

Added line #L56 was not covered by tests
return appCheck.getToken.call(appCheck, forceRefresh, MODULAR_DEPRECATION_ARG);
}

Expand All @@ -64,7 +64,7 @@
* @returns {Promise<AppCheckTokenResult>}
*/
export function getLimitedUseToken(appCheckInstance) {
const appCheck = appCheckInstance.app.appCheck();
const appCheck = appCheckInstance.appCheck;
return appCheck.getLimitedUseToken.call(appCheck, MODULAR_DEPRECATION_ARG);
}

Expand All @@ -74,7 +74,7 @@
* @param {boolean} isAutoRefreshEnabled - Whether to enable auto-refresh.
*/
export function setTokenAutoRefreshEnabled(appCheckInstance, isAutoRefreshEnabled) {
const appCheck = appCheckInstance.app.appCheck();
const appCheck = appCheckInstance.appCheck;
return appCheck.setTokenAutoRefreshEnabled.call(
appCheck,
isAutoRefreshEnabled,
Expand Down
Loading