Skip to content
Merged
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
27 changes: 27 additions & 0 deletions packages/app-check/__tests__/appcheck.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ import {
setTokenAutoRefreshEnabled,
onTokenChanged,
CustomProvider,
ReactNativeFirebaseAppCheckProviderOptions,
ReactNativeFirebaseAppCheckProviderAndroidOptions,
ReactNativeFirebaseAppCheckProviderAppleOptions,
ReactNativeFirebaseAppCheckProviderWebOptions,
ReactNativeFirebaseAppCheckProvider,
} from '../lib';

describe('appCheck()', function () {
Expand Down Expand Up @@ -77,6 +82,28 @@ describe('appCheck()', function () {
it('`CustomProvider` function is properly exposed to end user', function () {
expect(CustomProvider).toBeDefined();
});

it('`ReactNativeAppCheckProvider objects are properly exposed to end user', function () {
expect(ReactNativeFirebaseAppCheckProvider).toBeDefined();
const provider = new ReactNativeFirebaseAppCheckProvider();
expect(provider.configure).toBeDefined();
const options = { debugToken: 'foo' } as ReactNativeFirebaseAppCheckProviderOptions;
const appleOptions = {
provider: 'debug',
...options,
} as ReactNativeFirebaseAppCheckProviderAppleOptions;
expect(appleOptions).toBeDefined();
const androidOptions = {
provider: 'debug',
...options,
} as ReactNativeFirebaseAppCheckProviderAndroidOptions;
expect(androidOptions).toBeDefined();
const webOptions = {
provider: 'debug',
...options,
} as ReactNativeFirebaseAppCheckProviderWebOptions;
expect(webOptions).toBeDefined();
});
});

describe('test `console.warn` is called for RNFB v8 API & not called for v9 API', function () {
Expand Down
58 changes: 58 additions & 0 deletions packages/app-check/lib/modular/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,61 @@ export function setTokenAutoRefreshEnabled(
export class CustomProvider implements AppCheckProvider {
constructor(customProviderOptions: CustomProviderOptions);
}

/**
* React-Native-Firebase AppCheckProvider that allows hot-swapping native AppCheck implementations
*/
export interface ReactNativeFirebaseAppCheckProviderOptions {
/**
* debug token to use, if any. Defaults to undefined, pre-configure tokens in firebase web console if needed
*/
debugToken?: string;
}

export interface ReactNativeFirebaseAppCheckProviderWebOptions
extends ReactNativeFirebaseAppCheckProviderOptions {
/**
* The web provider to use, either `reCaptchaV3` or `reCaptchaEnterprise`, defaults to `reCaptchaV3`
*/
provider?: 'debug' | 'reCaptchaV3' | 'reCaptchaEnterprise';

/**
* siteKey for use in web queries, defaults to `none`
*/
siteKey?: string;
}

export interface ReactNativeFirebaseAppCheckProviderAppleOptions
extends ReactNativeFirebaseAppCheckProviderOptions {
/**
* The apple provider to use, either `deviceCheck` or `appAttest`, or `appAttestWithDeviceCheckFallback`,
* defaults to `DeviceCheck`. `appAttest` requires iOS 14+ or will fail, `appAttestWithDeviceCheckFallback`
* will use `appAttest` for iOS14+ and fallback to `deviceCheck` on devices with ios13 and lower
*/
provider?: 'debug' | 'deviceCheck' | 'appAttest' | 'appAttestWithDeviceCheckFallback';
}

export interface ReactNativeFirebaseAppCheckProviderAndroidOptions
extends ReactNativeFirebaseAppCheckProviderOptions {
/**
* The android provider to use, either `debug` or `playIntegrity`. default is `playIntegrity`.
*/
provider?: 'debug' | 'playIntegrity';
}

export class ReactNativeFirebaseAppCheckProvider extends AppCheckProvider {
/**
* Specify how the app check provider should be configured. The new configuration is
* in effect when this call returns. You must call `getToken()`
* after this call to get a token using the new configuration.
* This custom provider allows for delayed configuration and re-configuration on all platforms
* so AppCheck has the same experience across all platforms, with the only difference being the native
* providers you choose to use on each platform.
*/
configure(options: {
web?: ReactNativeFirebaseAppCheckProviderWebOptions;
android?: ReactNativeFirebaseAppCheckProviderAndroidOptions;
apple?: ReactNativeFirebaseAppCheckProviderAppleOptions;
isTokenAutoRefreshEnabled?: boolean;
}): void;
}
Loading