Skip to content

Commit f08b687

Browse files
committed
fix(app-check, types): modular exports of ReactNativeFirebaseAppCheckProvider types
1 parent 8c631e1 commit f08b687

File tree

2 files changed

+85
-0
lines changed

2 files changed

+85
-0
lines changed

packages/app-check/__tests__/appcheck.test.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ import {
2020
setTokenAutoRefreshEnabled,
2121
onTokenChanged,
2222
CustomProvider,
23+
ReactNativeFirebaseAppCheckProviderOptions,
24+
ReactNativeFirebaseAppCheckProviderAndroidOptions,
25+
ReactNativeFirebaseAppCheckProviderAppleOptions,
26+
ReactNativeFirebaseAppCheckProviderWebOptions,
27+
ReactNativeFirebaseAppCheckProvider,
2328
} from '../lib';
2429

2530
describe('appCheck()', function () {
@@ -77,6 +82,28 @@ describe('appCheck()', function () {
7782
it('`CustomProvider` function is properly exposed to end user', function () {
7883
expect(CustomProvider).toBeDefined();
7984
});
85+
86+
it('`ReactNativeAppCheckProvider objects are properly exposed to end user', function () {
87+
expect(ReactNativeFirebaseAppCheckProvider).toBeDefined();
88+
const provider = new ReactNativeFirebaseAppCheckProvider();
89+
expect(provider.configure).toBeDefined();
90+
const options = { debugToken: 'foo' } as ReactNativeFirebaseAppCheckProviderOptions;
91+
const appleOptions = {
92+
provider: 'debug',
93+
...options,
94+
} as ReactNativeFirebaseAppCheckProviderAppleOptions;
95+
expect(appleOptions).toBeDefined();
96+
const androidOptions = {
97+
provider: 'debug',
98+
...options,
99+
} as ReactNativeFirebaseAppCheckProviderAndroidOptions;
100+
expect(androidOptions).toBeDefined();
101+
const webOptions = {
102+
provider: 'debug',
103+
...options,
104+
} as ReactNativeFirebaseAppCheckProviderWebOptions;
105+
expect(webOptions).toBeDefined();
106+
});
80107
});
81108

82109
describe('test `console.warn` is called for RNFB v8 API & not called for v9 API', function () {

packages/app-check/lib/modular/index.d.ts

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,61 @@ export function setTokenAutoRefreshEnabled(
9292
export class CustomProvider implements AppCheckProvider {
9393
constructor(customProviderOptions: CustomProviderOptions);
9494
}
95+
96+
/**
97+
* React-Native-Firebase AppCheckProvider that allows hot-swapping native AppCheck implementations
98+
*/
99+
export interface ReactNativeFirebaseAppCheckProviderOptions {
100+
/**
101+
* debug token to use, if any. Defaults to undefined, pre-configure tokens in firebase web console if needed
102+
*/
103+
debugToken?: string;
104+
}
105+
106+
export interface ReactNativeFirebaseAppCheckProviderWebOptions
107+
extends ReactNativeFirebaseAppCheckProviderOptions {
108+
/**
109+
* The web provider to use, either `reCaptchaV3` or `reCaptchaEnterprise`, defaults to `reCaptchaV3`
110+
*/
111+
provider?: 'debug' | 'reCaptchaV3' | 'reCaptchaEnterprise';
112+
113+
/**
114+
* siteKey for use in web queries, defaults to `none`
115+
*/
116+
siteKey?: string;
117+
}
118+
119+
export interface ReactNativeFirebaseAppCheckProviderAppleOptions
120+
extends ReactNativeFirebaseAppCheckProviderOptions {
121+
/**
122+
* The apple provider to use, either `deviceCheck` or `appAttest`, or `appAttestWithDeviceCheckFallback`,
123+
* defaults to `DeviceCheck`. `appAttest` requires iOS 14+ or will fail, `appAttestWithDeviceCheckFallback`
124+
* will use `appAttest` for iOS14+ and fallback to `deviceCheck` on devices with ios13 and lower
125+
*/
126+
provider?: 'debug' | 'deviceCheck' | 'appAttest' | 'appAttestWithDeviceCheckFallback';
127+
}
128+
129+
export interface ReactNativeFirebaseAppCheckProviderAndroidOptions
130+
extends ReactNativeFirebaseAppCheckProviderOptions {
131+
/**
132+
* The android provider to use, either `debug` or `playIntegrity`. default is `playIntegrity`.
133+
*/
134+
provider?: 'debug' | 'playIntegrity';
135+
}
136+
137+
export class ReactNativeFirebaseAppCheckProvider extends AppCheckProvider {
138+
/**
139+
* Specify how the app check provider should be configured. The new configuration is
140+
* in effect when this call returns. You must call `getToken()`
141+
* after this call to get a token using the new configuration.
142+
* This custom provider allows for delayed configuration and re-configuration on all platforms
143+
* so AppCheck has the same experience across all platforms, with the only difference being the native
144+
* providers you choose to use on each platform.
145+
*/
146+
configure(options: {
147+
web?: ReactNativeFirebaseAppCheckProviderWebOptions;
148+
android?: ReactNativeFirebaseAppCheckProviderAndroidOptions;
149+
apple?: ReactNativeFirebaseAppCheckProviderAppleOptions;
150+
isTokenAutoRefreshEnabled?: boolean;
151+
}): void;
152+
}

0 commit comments

Comments
 (0)