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

add App Check #430

Merged
merged 7 commits into from
Sep 1, 2021
Merged

add App Check #430

merged 7 commits into from
Sep 1, 2021

Conversation

jhuleatt
Copy link
Collaborator

@jhuleatt jhuleatt commented Aug 26, 2021

Description

Add support for App Check.

fixes #406

Code sample

import { initializeAppCheck, ReCaptchaV3Provider } from "firebase/app-check";
import { useFirebaseApp, AppCheckProvider } from 'reactfire';

// Create your reCAPTCHA v3 site key in the 
// "Project Settings > App Check" section of the Firebase console
const APP_CHECK_TOKEN = 'abcdefghijklmnopqrstuvwxy-1234567890abcd';

function FirebaseComponents({ children }) {
  const app = useFirebaseApp(); // a parent component contains a `FirebaseAppProvider`

  const appCheck = initializeAppCheck(app, {
    provider: new ReCaptchaV3Provider(APP_CHECK_TOKEN),
    isTokenAutoRefreshEnabled: true
  });

  // Activate App Check at the top level before any component talks to an App-Check-compatible Firebase service
  return (
    <AppCheckProvider>
      <DatabaseProvider sdk={database}>
        <MyCoolApp/>
      </DatabaseProvider>
    </AppCheckProvider>
  );
}

@google-cla google-cla bot added the cla: yes label Aug 26, 2021
@jhuleatt
Copy link
Collaborator Author

cc @sujishpatel

@jhuleatt jhuleatt changed the title App Check add App Check Aug 26, 2021
Copy link
Contributor

@justjish justjish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think adding in the 'useInitAppCheck' might be worthwhile here for api consistency and concurrent mode purposes.

export const useInitAppCheck: InitSdkHook<AppCheck> = (initializer, options) => useInitSdk<AppCheck>('appcheck', AppCheckSdkContext, initializer, options);

docs/use.md Outdated Show resolved Hide resolved
@jhuleatt
Copy link
Collaborator Author

jhuleatt commented Sep 1, 2021

I think adding in the 'useInitAppCheck' might be worthwhile here for api consistency and concurrent mode purposes.

export const useInitAppCheck: InitSdkHook<AppCheck> = (initializer, options) => useInitSdk<AppCheck>('appcheck', AppCheckSdkContext, initializer, options);

Definitely, I've added that, thanks!

Copy link
Contributor

@justjish justjish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@jhuleatt jhuleatt merged commit 6fa717e into main Sep 1, 2021
@jhuleatt jhuleatt deleted the jhuleatt-app-check branch September 1, 2021 21:11
@FirebaseExtended FirebaseExtended locked and limited conversation to collaborators Oct 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

useAppCheck and/or preloadAppCheck
3 participants