@react-native-firebase/app-check 24.1.1 → 25.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +29 -0
- package/dist/module/index.js +1 -0
- package/dist/module/index.js.map +1 -1
- package/dist/module/modular.js +7 -24
- package/dist/module/modular.js.map +1 -1
- package/dist/module/namespaced.js +2 -16
- package/dist/module/namespaced.js.map +1 -1
- package/dist/module/providers.js +39 -0
- package/dist/module/providers.js.map +1 -0
- package/dist/module/types/appcheck.js +1 -86
- package/dist/module/types/appcheck.js.map +1 -1
- package/dist/module/types/internal.js +4 -0
- package/dist/module/types/internal.js.map +1 -0
- package/dist/module/types/namespaced.js +60 -0
- package/dist/module/types/namespaced.js.map +1 -0
- package/dist/module/version.js +1 -1
- package/dist/module/web/RNFBAppCheckModule.android.js +2 -2
- package/dist/module/web/RNFBAppCheckModule.android.js.map +1 -1
- package/dist/module/web/RNFBAppCheckModule.ios.js +2 -2
- package/dist/module/web/RNFBAppCheckModule.ios.js.map +1 -1
- package/dist/module/web/RNFBAppCheckModule.js +5 -2
- package/dist/module/web/RNFBAppCheckModule.js.map +1 -1
- package/dist/typescript/lib/index.d.ts +2 -1
- package/dist/typescript/lib/index.d.ts.map +1 -1
- package/dist/typescript/lib/modular.d.ts +7 -8
- package/dist/typescript/lib/modular.d.ts.map +1 -1
- package/dist/typescript/lib/namespaced.d.ts +5 -10
- package/dist/typescript/lib/namespaced.d.ts.map +1 -1
- package/dist/typescript/lib/providers.d.ts +19 -0
- package/dist/typescript/lib/providers.d.ts.map +1 -0
- package/dist/typescript/lib/types/appcheck.d.ts +53 -204
- package/dist/typescript/lib/types/appcheck.d.ts.map +1 -1
- package/dist/typescript/lib/types/internal.d.ts +125 -0
- package/dist/typescript/lib/types/internal.d.ts.map +1 -0
- package/dist/typescript/lib/types/namespaced.d.ts +358 -0
- package/dist/typescript/lib/types/namespaced.d.ts.map +1 -0
- package/dist/typescript/lib/version.d.ts +1 -1
- package/dist/typescript/lib/web/RNFBAppCheckModule.android.d.ts +2 -2
- package/dist/typescript/lib/web/RNFBAppCheckModule.android.d.ts.map +1 -1
- package/dist/typescript/lib/web/RNFBAppCheckModule.d.ts +6 -6
- package/dist/typescript/lib/web/RNFBAppCheckModule.d.ts.map +1 -1
- package/dist/typescript/lib/web/RNFBAppCheckModule.ios.d.ts +2 -2
- package/dist/typescript/lib/web/RNFBAppCheckModule.ios.d.ts.map +1 -1
- package/lib/index.ts +2 -21
- package/lib/modular.ts +39 -39
- package/lib/namespaced.ts +17 -36
- package/lib/providers.ts +49 -0
- package/lib/types/appcheck.ts +56 -258
- package/lib/types/internal.ts +162 -0
- package/lib/types/namespaced.ts +422 -0
- package/lib/version.ts +1 -1
- package/lib/web/RNFBAppCheckModule.android.ts +2 -2
- package/lib/web/RNFBAppCheckModule.ios.ts +2 -2
- package/lib/web/RNFBAppCheckModule.ts +17 -22
- package/package.json +6 -6
- package/plugin/tsconfig.json +2 -1
- package/plugin/tsconfig.tsbuildinfo +1 -1
- package/tsconfig.json +2 -2
- package/typedoc.json +1 -11
- package/dist/module/ReactNativeFirebaseAppCheckProvider.js +0 -14
- package/dist/module/ReactNativeFirebaseAppCheckProvider.js.map +0 -1
- package/dist/typescript/lib/ReactNativeFirebaseAppCheckProvider.d.ts +0 -8
- package/dist/typescript/lib/ReactNativeFirebaseAppCheckProvider.d.ts.map +0 -1
- package/lib/ReactNativeFirebaseAppCheckProvider.ts +0 -21
package/lib/namespaced.ts
CHANGED
|
@@ -20,7 +20,6 @@ import {
|
|
|
20
20
|
isIOS,
|
|
21
21
|
isString,
|
|
22
22
|
isObject,
|
|
23
|
-
isFunction,
|
|
24
23
|
isUndefined,
|
|
25
24
|
isOther,
|
|
26
25
|
parseListenerOrObserver,
|
|
@@ -32,45 +31,24 @@ import {
|
|
|
32
31
|
} from '@react-native-firebase/app/dist/module/internal';
|
|
33
32
|
import type { ModuleConfig } from '@react-native-firebase/app/dist/module/internal';
|
|
34
33
|
import { Platform } from 'react-native';
|
|
35
|
-
import ReactNativeFirebaseAppCheckProvider from './ReactNativeFirebaseAppCheckProvider';
|
|
36
34
|
import { setReactNativeModule } from '@react-native-firebase/app/dist/module/internal/nativeModule';
|
|
37
35
|
import fallBackModule from './web/RNFBAppCheckModule';
|
|
38
36
|
import { version } from './version';
|
|
39
37
|
import type {
|
|
40
|
-
|
|
38
|
+
AppCheckOptions,
|
|
41
39
|
AppCheckProvider,
|
|
42
40
|
AppCheckTokenResult,
|
|
43
|
-
AppCheckOptions,
|
|
44
|
-
AppCheckListenerResult,
|
|
45
41
|
PartialObserver,
|
|
46
|
-
AppCheck,
|
|
47
|
-
AppCheckStatics,
|
|
48
|
-
ProviderWithOptions,
|
|
49
42
|
} from './types/appcheck';
|
|
43
|
+
import type { ProviderWithOptions } from './types/internal';
|
|
44
|
+
import type { FirebaseAppCheckTypes } from './types/namespaced';
|
|
50
45
|
import type { ReactNativeFirebase } from '@react-native-firebase/app';
|
|
46
|
+
import { CustomProvider, ReactNativeFirebaseAppCheckProvider } from './providers';
|
|
51
47
|
|
|
52
48
|
const namespace = 'appCheck';
|
|
53
49
|
|
|
54
50
|
const nativeModuleName = 'RNFBAppCheckModule';
|
|
55
51
|
|
|
56
|
-
export class CustomProvider implements AppCheckProvider {
|
|
57
|
-
private _customProviderOptions: CustomProviderOptions;
|
|
58
|
-
|
|
59
|
-
constructor(_customProviderOptions: CustomProviderOptions) {
|
|
60
|
-
if (!isObject(_customProviderOptions)) {
|
|
61
|
-
throw new Error('Invalid configuration: no provider options defined.');
|
|
62
|
-
}
|
|
63
|
-
if (!isFunction(_customProviderOptions.getToken)) {
|
|
64
|
-
throw new Error('Invalid configuration: no getToken function defined.');
|
|
65
|
-
}
|
|
66
|
-
this._customProviderOptions = _customProviderOptions;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
async getToken() {
|
|
70
|
-
return this._customProviderOptions.getToken();
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
52
|
const statics = {
|
|
75
53
|
CustomProvider,
|
|
76
54
|
};
|
|
@@ -89,7 +67,7 @@ function hasProviderOptions(
|
|
|
89
67
|
);
|
|
90
68
|
}
|
|
91
69
|
|
|
92
|
-
class FirebaseAppCheckModule extends FirebaseModule {
|
|
70
|
+
class FirebaseAppCheckModule extends FirebaseModule<typeof nativeModuleName> {
|
|
93
71
|
_listenerCount: number;
|
|
94
72
|
|
|
95
73
|
constructor(
|
|
@@ -226,8 +204,8 @@ class FirebaseAppCheckModule extends FirebaseModule {
|
|
|
226
204
|
|
|
227
205
|
onTokenChanged(
|
|
228
206
|
onNextOrObserver:
|
|
229
|
-
| PartialObserver<AppCheckListenerResult>
|
|
230
|
-
| ((tokenResult: AppCheckListenerResult) => void),
|
|
207
|
+
| PartialObserver<FirebaseAppCheckTypes.AppCheckListenerResult>
|
|
208
|
+
| ((tokenResult: FirebaseAppCheckTypes.AppCheckListenerResult) => void),
|
|
231
209
|
_onError?: (error: Error) => void,
|
|
232
210
|
_onCompletion?: () => void,
|
|
233
211
|
): () => void {
|
|
@@ -239,8 +217,8 @@ class FirebaseAppCheckModule extends FirebaseModule {
|
|
|
239
217
|
}
|
|
240
218
|
const nextFn = parseListenerOrObserver(
|
|
241
219
|
onNextOrObserver as
|
|
242
|
-
| ((value: AppCheckListenerResult) => void)
|
|
243
|
-
| { next: (value: AppCheckListenerResult) => void },
|
|
220
|
+
| ((value: FirebaseAppCheckTypes.AppCheckListenerResult) => void)
|
|
221
|
+
| { next: (value: FirebaseAppCheckTypes.AppCheckListenerResult) => void },
|
|
244
222
|
);
|
|
245
223
|
// let errorFn = function () { };
|
|
246
224
|
// if (onNextOrObserver.error != null) {
|
|
@@ -278,10 +256,13 @@ const appCheckNamespace = createModuleNamespace({
|
|
|
278
256
|
});
|
|
279
257
|
|
|
280
258
|
type AppCheckNamespace = ReactNativeFirebase.FirebaseModuleWithStaticsAndApp<
|
|
281
|
-
|
|
282
|
-
|
|
259
|
+
FirebaseAppCheckTypes.Module,
|
|
260
|
+
FirebaseAppCheckTypes.Statics
|
|
283
261
|
> & {
|
|
284
|
-
appCheck: ReactNativeFirebase.FirebaseModuleWithStaticsAndApp<
|
|
262
|
+
appCheck: ReactNativeFirebase.FirebaseModuleWithStaticsAndApp<
|
|
263
|
+
FirebaseAppCheckTypes.Module,
|
|
264
|
+
FirebaseAppCheckTypes.Statics
|
|
265
|
+
>;
|
|
285
266
|
firebase: ReactNativeFirebase.Module;
|
|
286
267
|
app(name?: string): ReactNativeFirebase.FirebaseApp;
|
|
287
268
|
};
|
|
@@ -296,8 +277,8 @@ export default appCheckNamespace as unknown as AppCheckNamespace;
|
|
|
296
277
|
export const firebase =
|
|
297
278
|
getFirebaseRoot() as unknown as ReactNativeFirebase.FirebaseNamespacedExport<
|
|
298
279
|
'appCheck',
|
|
299
|
-
|
|
300
|
-
|
|
280
|
+
FirebaseAppCheckTypes.Module,
|
|
281
|
+
FirebaseAppCheckTypes.Statics,
|
|
301
282
|
false
|
|
302
283
|
>;
|
|
303
284
|
|
package/lib/providers.ts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
AppCheckProvider,
|
|
3
|
+
AppCheckToken,
|
|
4
|
+
CustomProviderOptions,
|
|
5
|
+
ReactNativeFirebaseAppCheckProviderOptionsMap as ProviderOptions,
|
|
6
|
+
} from './types/appcheck';
|
|
7
|
+
import { isFunction, isObject } from '@react-native-firebase/app/dist/module/common';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @public Use this to configure providers for android, iOS and "other" platforms.
|
|
11
|
+
*/
|
|
12
|
+
export class ReactNativeFirebaseAppCheckProvider implements AppCheckProvider {
|
|
13
|
+
providerOptions?: ProviderOptions;
|
|
14
|
+
|
|
15
|
+
constructor(options?: ProviderOptions) {
|
|
16
|
+
this.providerOptions = options;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
configure(options: ProviderOptions): void {
|
|
20
|
+
this.providerOptions = options;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
async getToken(): Promise<AppCheckToken> {
|
|
24
|
+
// This is a placeholder - the actual implementation is handled by the native modules
|
|
25
|
+
// This method exists to satisfy the AppCheckProvider interface
|
|
26
|
+
throw new Error('getToken() must be called after configure() and is handled by native modules');
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* @public Use this to configure a Custom Provider on "other" platform. This will not work on iOS and android.
|
|
32
|
+
*/
|
|
33
|
+
export class CustomProvider implements AppCheckProvider {
|
|
34
|
+
private _customProviderOptions: CustomProviderOptions;
|
|
35
|
+
|
|
36
|
+
constructor(_customProviderOptions: CustomProviderOptions) {
|
|
37
|
+
if (!isObject(_customProviderOptions)) {
|
|
38
|
+
throw new Error('Invalid configuration: no provider options defined.');
|
|
39
|
+
}
|
|
40
|
+
if (!isFunction(_customProviderOptions.getToken)) {
|
|
41
|
+
throw new Error('Invalid configuration: no getToken function defined.');
|
|
42
|
+
}
|
|
43
|
+
this._customProviderOptions = _customProviderOptions;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
async getToken() {
|
|
47
|
+
return this._customProviderOptions.getToken();
|
|
48
|
+
}
|
|
49
|
+
}
|
package/lib/types/appcheck.ts
CHANGED
|
@@ -15,42 +15,43 @@
|
|
|
15
15
|
*
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
import type {
|
|
19
|
-
|
|
20
|
-
// ============ Provider Types ============
|
|
18
|
+
import type { FirebaseApp } from '@react-native-firebase/app';
|
|
19
|
+
import type { CustomProvider, ReactNativeFirebaseAppCheckProvider } from '../providers';
|
|
21
20
|
|
|
21
|
+
export type {
|
|
22
|
+
Unsubscribe,
|
|
23
|
+
PartialObserver,
|
|
24
|
+
} from '@react-native-firebase/app/dist/module/types/common';
|
|
22
25
|
/**
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
+
* The Firebase App Check service interface.
|
|
27
|
+
*
|
|
28
|
+
* @public
|
|
26
29
|
*/
|
|
27
|
-
export interface
|
|
30
|
+
export interface AppCheck {
|
|
28
31
|
/**
|
|
29
|
-
*
|
|
32
|
+
* this `AppCheck` instance is associated with this FirebaseApp.
|
|
30
33
|
*/
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Function to get an App Check token through a custom provider service.
|
|
36
|
-
*/
|
|
37
|
-
export interface CustomProviderOptions {
|
|
38
|
-
getToken: () => Promise<AppCheckToken>;
|
|
34
|
+
app: FirebaseApp;
|
|
39
35
|
}
|
|
40
36
|
|
|
41
|
-
// ============ Options & Result Types ============
|
|
42
|
-
|
|
43
37
|
/**
|
|
44
|
-
*
|
|
38
|
+
* The token returned from an `AppCheckProvider`.
|
|
45
39
|
* @public
|
|
46
40
|
*/
|
|
47
|
-
export
|
|
48
|
-
|
|
49
|
-
|
|
41
|
+
export interface AppCheckToken {
|
|
42
|
+
/**
|
|
43
|
+
* The token string in JWT format.
|
|
44
|
+
*/
|
|
45
|
+
readonly token: string;
|
|
46
|
+
/**
|
|
47
|
+
* The local timestamp after which the token will expire.
|
|
48
|
+
*/
|
|
49
|
+
readonly expireTimeMillis: number;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
/**
|
|
53
53
|
* Options for App Check initialization.
|
|
54
|
+
* @public
|
|
54
55
|
*/
|
|
55
56
|
export interface AppCheckOptions {
|
|
56
57
|
/**
|
|
@@ -73,21 +74,21 @@ export interface AppCheckOptions {
|
|
|
73
74
|
}
|
|
74
75
|
|
|
75
76
|
/**
|
|
76
|
-
*
|
|
77
|
+
* Function to get an App Check token through a custom provider service. This is for
|
|
78
|
+
* "other" platform only, this is not supported on iOS and android.
|
|
79
|
+
* @public
|
|
77
80
|
*/
|
|
78
|
-
export interface
|
|
79
|
-
/**
|
|
80
|
-
* The token string in JWT format.
|
|
81
|
-
*/
|
|
82
|
-
readonly token: string;
|
|
81
|
+
export interface CustomProviderOptions {
|
|
83
82
|
/**
|
|
84
|
-
*
|
|
83
|
+
* Function to get an App Check token through a custom provider
|
|
84
|
+
* service.
|
|
85
85
|
*/
|
|
86
|
-
|
|
86
|
+
getToken: () => Promise<AppCheckToken>;
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
/**
|
|
90
90
|
* Result returned by `getToken()`.
|
|
91
|
+
* @public
|
|
91
92
|
*/
|
|
92
93
|
export interface AppCheckTokenResult {
|
|
93
94
|
/**
|
|
@@ -97,31 +98,22 @@ export interface AppCheckTokenResult {
|
|
|
97
98
|
}
|
|
98
99
|
|
|
99
100
|
/**
|
|
100
|
-
*
|
|
101
|
+
* An App Check provider. This can be either the built-in reCAPTCHA provider
|
|
102
|
+
* or a custom provider. For more on custom providers, see
|
|
103
|
+
* https://firebase.google.com/docs/app-check/web-custom-provider
|
|
104
|
+
* @public
|
|
101
105
|
*/
|
|
102
|
-
export
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
export type ErrorFn = (error: Error) => void;
|
|
108
|
-
export type CompleteFn = () => void;
|
|
109
|
-
|
|
110
|
-
export interface Observer<T> {
|
|
111
|
-
next: NextFn<T>;
|
|
112
|
-
error: ErrorFn;
|
|
113
|
-
complete: CompleteFn;
|
|
106
|
+
export interface AppCheckProvider {
|
|
107
|
+
/**
|
|
108
|
+
* Returns an AppCheck token.
|
|
109
|
+
*/
|
|
110
|
+
getToken(): Promise<AppCheckToken>;
|
|
114
111
|
}
|
|
115
112
|
|
|
116
|
-
export type PartialObserver<T> = Partial<Observer<T>>;
|
|
117
|
-
|
|
118
113
|
/**
|
|
119
|
-
*
|
|
114
|
+
* Options for ReactNativeFirebaseAppCheckProvider.
|
|
115
|
+
* @public
|
|
120
116
|
*/
|
|
121
|
-
export type Unsubscribe = () => void;
|
|
122
|
-
|
|
123
|
-
// ============ ReactNativeFirebaseAppCheckProvider Types ============
|
|
124
|
-
|
|
125
117
|
export interface ReactNativeFirebaseAppCheckProviderOptions {
|
|
126
118
|
/**
|
|
127
119
|
* debug token to use, if any. Defaults to undefined, pre-configure tokens in firebase web console if needed
|
|
@@ -129,6 +121,10 @@ export interface ReactNativeFirebaseAppCheckProviderOptions {
|
|
|
129
121
|
debugToken?: string;
|
|
130
122
|
}
|
|
131
123
|
|
|
124
|
+
/**
|
|
125
|
+
* Options for ReactNativeFirebaseAppCheckProvider on web.
|
|
126
|
+
* @public
|
|
127
|
+
*/
|
|
132
128
|
export interface ReactNativeFirebaseAppCheckProviderWebOptions extends ReactNativeFirebaseAppCheckProviderOptions {
|
|
133
129
|
/**
|
|
134
130
|
* The web provider to use, either `reCaptchaV3` or `reCaptchaEnterprise`, defaults to `reCaptchaV3`
|
|
@@ -141,6 +137,10 @@ export interface ReactNativeFirebaseAppCheckProviderWebOptions extends ReactNati
|
|
|
141
137
|
siteKey?: string;
|
|
142
138
|
}
|
|
143
139
|
|
|
140
|
+
/**
|
|
141
|
+
* Options for ReactNativeFirebaseAppCheckProvider on apple.
|
|
142
|
+
* @public
|
|
143
|
+
*/
|
|
144
144
|
export interface ReactNativeFirebaseAppCheckProviderAppleOptions extends ReactNativeFirebaseAppCheckProviderOptions {
|
|
145
145
|
/**
|
|
146
146
|
* The apple provider to use, either `deviceCheck` or `appAttest`, or `appAttestWithDeviceCheckFallback`,
|
|
@@ -150,6 +150,10 @@ export interface ReactNativeFirebaseAppCheckProviderAppleOptions extends ReactNa
|
|
|
150
150
|
provider?: 'debug' | 'deviceCheck' | 'appAttest' | 'appAttestWithDeviceCheckFallback';
|
|
151
151
|
}
|
|
152
152
|
|
|
153
|
+
/**
|
|
154
|
+
* Options for ReactNativeFirebaseAppCheckProvider on android.
|
|
155
|
+
* @public
|
|
156
|
+
*/
|
|
153
157
|
export interface ReactNativeFirebaseAppCheckProviderAndroidOptions extends ReactNativeFirebaseAppCheckProviderOptions {
|
|
154
158
|
/**
|
|
155
159
|
* The android provider to use, either `debug` or `playIntegrity`. default is `playIntegrity`.
|
|
@@ -159,6 +163,7 @@ export interface ReactNativeFirebaseAppCheckProviderAndroidOptions extends React
|
|
|
159
163
|
|
|
160
164
|
/**
|
|
161
165
|
* Platform-specific provider options configuration.
|
|
166
|
+
* @public
|
|
162
167
|
*/
|
|
163
168
|
export type ReactNativeFirebaseAppCheckProviderOptionsMap = {
|
|
164
169
|
web?: ReactNativeFirebaseAppCheckProviderWebOptions;
|
|
@@ -172,215 +177,8 @@ export type ReactNativeFirebaseAppCheckProviderOptionsMap = {
|
|
|
172
177
|
* that can be passed directly with providerOptions (for convenience in initialization).
|
|
173
178
|
* The runtime accepts objects with providerOptions even if they don't have
|
|
174
179
|
* getToken() and configure() methods.
|
|
180
|
+
* @public
|
|
175
181
|
*/
|
|
176
182
|
export interface ReactNativeFirebaseAppCheckProviderConfig {
|
|
177
183
|
providerOptions: ReactNativeFirebaseAppCheckProviderOptionsMap;
|
|
178
184
|
}
|
|
179
|
-
|
|
180
|
-
export interface ReactNativeFirebaseAppCheckProvider extends AppCheckProvider {
|
|
181
|
-
/**
|
|
182
|
-
* Provider options for platform-specific configuration.
|
|
183
|
-
* This is set when configure() is called.
|
|
184
|
-
*/
|
|
185
|
-
providerOptions?: ReactNativeFirebaseAppCheckProviderOptionsMap;
|
|
186
|
-
|
|
187
|
-
/**
|
|
188
|
-
* Specify how the app check provider should be configured. The new configuration is
|
|
189
|
-
* in effect when this call returns. You must call `getToken()`
|
|
190
|
-
* after this call to get a token using the new configuration.
|
|
191
|
-
* This custom provider allows for delayed configuration and re-configuration on all platforms
|
|
192
|
-
* so AppCheck has the same experience across all platforms, with the only difference being the native
|
|
193
|
-
* providers you choose to use on each platform.
|
|
194
|
-
*/
|
|
195
|
-
configure(options: ReactNativeFirebaseAppCheckProviderOptionsMap): void;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
/**
|
|
199
|
-
* Type representing providers that have providerOptions.
|
|
200
|
-
* Used for type narrowing in runtime code.
|
|
201
|
-
*/
|
|
202
|
-
export type ProviderWithOptions =
|
|
203
|
-
| ReactNativeFirebaseAppCheckProvider
|
|
204
|
-
| ReactNativeFirebaseAppCheckProviderConfig;
|
|
205
|
-
|
|
206
|
-
// ============ Module Interface ============
|
|
207
|
-
|
|
208
|
-
/**
|
|
209
|
-
* App Check module instance - returned from firebase.appCheck() or firebase.app().appCheck()
|
|
210
|
-
*/
|
|
211
|
-
export interface AppCheck extends ReactNativeFirebase.FirebaseModule {
|
|
212
|
-
/** The FirebaseApp this module is associated with */
|
|
213
|
-
app: ReactNativeFirebase.FirebaseApp;
|
|
214
|
-
|
|
215
|
-
/**
|
|
216
|
-
* Create a ReactNativeFirebaseAppCheckProvider option for use in react-native-firebase
|
|
217
|
-
*/
|
|
218
|
-
newReactNativeFirebaseAppCheckProvider(): ReactNativeFirebaseAppCheckProvider;
|
|
219
|
-
|
|
220
|
-
/**
|
|
221
|
-
* Initialize the AppCheck module. Note that in react-native-firebase AppCheckOptions must always
|
|
222
|
-
* be an object with a `provider` member containing `ReactNativeFirebaseAppCheckProvider` that has returned successfully
|
|
223
|
-
* from a call to the `configure` method, with sub-providers for the various platforms configured to meet your project
|
|
224
|
-
* requirements. This must be called prior to interacting with any firebase services protected by AppCheck
|
|
225
|
-
*
|
|
226
|
-
* @param options an AppCheckOptions with a configured ReactNativeFirebaseAppCheckProvider as the provider
|
|
227
|
-
*/
|
|
228
|
-
initializeAppCheck(options: AppCheckOptions): Promise<void>;
|
|
229
|
-
|
|
230
|
-
/**
|
|
231
|
-
* Activate App Check
|
|
232
|
-
* On iOS App Check is activated with DeviceCheck provider simply by including the module, using the token auto refresh default or
|
|
233
|
-
* the specific value (if configured) in firebase.json, but calling this does no harm.
|
|
234
|
-
* On Android if you call this it will install the PlayIntegrity provider in release builds, the Debug provider if debuggable.
|
|
235
|
-
* On both platforms you may use this method to alter the token refresh setting after startup.
|
|
236
|
-
* On iOS if you want to set a specific AppCheckProviderFactory (for instance to FIRAppCheckDebugProviderFactory or
|
|
237
|
-
* FIRAppAttestProvider) you must manually do that in your AppDelegate.m prior to calling [FIRApp configure]
|
|
238
|
-
*
|
|
239
|
-
* @deprecated use initializeAppCheck to gain access to all platform providers and firebase-js-sdk v9 compatibility
|
|
240
|
-
* @param siteKeyOrProvider - This is ignored, Android uses DebugProviderFactory if the app is debuggable (https://firebase.google.com/docs/app-check/android/debug-provider)
|
|
241
|
-
* Android uses PlayIntegrityProviderFactory for release builds.
|
|
242
|
-
* iOS uses DeviceCheckProviderFactory by default unless altered in AppDelegate.m manually
|
|
243
|
-
* @param isTokenAutoRefreshEnabled - If true, enables SDK to automatically
|
|
244
|
-
* refresh AppCheck token as needed. If undefined, the value will default
|
|
245
|
-
* to the value of `app.automaticDataCollectionEnabled`. That property
|
|
246
|
-
* defaults to false and can be set in the app config.
|
|
247
|
-
*/
|
|
248
|
-
activate(
|
|
249
|
-
siteKeyOrProvider: string | AppCheckProvider,
|
|
250
|
-
isTokenAutoRefreshEnabled?: boolean,
|
|
251
|
-
): Promise<void>;
|
|
252
|
-
|
|
253
|
-
/**
|
|
254
|
-
* Alter the token auto refresh setting. By default it will take the value of automaticDataCollectionEnabled from Info.plist / AndroidManifest.xml
|
|
255
|
-
* @param isTokenAutoRefreshEnabled - If true, the SDK automatically
|
|
256
|
-
* refreshes App Check tokens as needed. This overrides any value set
|
|
257
|
-
* during `activate()` or taken by default from automaticDataCollectionEnabled in plist / android manifest
|
|
258
|
-
*/
|
|
259
|
-
setTokenAutoRefreshEnabled(isTokenAutoRefreshEnabled: boolean): void;
|
|
260
|
-
|
|
261
|
-
/**
|
|
262
|
-
* Requests Firebase App Check token.
|
|
263
|
-
* This method should only be used if you need to authorize requests to a non-Firebase backend.
|
|
264
|
-
* Requests to Firebase backend are authorized automatically if configured.
|
|
265
|
-
*
|
|
266
|
-
* @param forceRefresh - If true, a new Firebase App Check token is requested and the token cache is ignored.
|
|
267
|
-
* If false, the cached token is used if it exists and has not expired yet.
|
|
268
|
-
* In most cases, false should be used. True should only be used if the server explicitly returns an error, indicating a revoked token.
|
|
269
|
-
*/
|
|
270
|
-
getToken(forceRefresh?: boolean): Promise<AppCheckTokenResult>;
|
|
271
|
-
|
|
272
|
-
/**
|
|
273
|
-
* Requests a Firebase App Check token. This method should be used only if you need to authorize requests
|
|
274
|
-
* to a non-Firebase backend. Returns limited-use tokens that are intended for use with your non-Firebase
|
|
275
|
-
* backend endpoints that are protected with Replay Protection (https://firebase.google.com/docs/app-check/custom-resource-backend#replay-protection).
|
|
276
|
-
* This method does not affect the token generation behavior of the getAppCheckToken() method.
|
|
277
|
-
*/
|
|
278
|
-
getLimitedUseToken(): Promise<AppCheckTokenResult>;
|
|
279
|
-
|
|
280
|
-
/**
|
|
281
|
-
* Registers a listener to changes in the token state. There can be more
|
|
282
|
-
* than one listener registered at the same time for one or more
|
|
283
|
-
* App Check instances. The listeners call back on the UI thread whenever
|
|
284
|
-
* the current token associated with this App Check instance changes.
|
|
285
|
-
*
|
|
286
|
-
* @returns A function that unsubscribes this listener.
|
|
287
|
-
*/
|
|
288
|
-
onTokenChanged(observer: PartialObserver<AppCheckListenerResult>): () => void;
|
|
289
|
-
|
|
290
|
-
/**
|
|
291
|
-
* Registers a listener to changes in the token state. There can be more
|
|
292
|
-
* than one listener registered at the same time for one or more
|
|
293
|
-
* App Check instances. The listeners call back on the UI thread whenever
|
|
294
|
-
* the current token associated with this App Check instance changes.
|
|
295
|
-
*
|
|
296
|
-
* Token listeners do not exist in the native SDK for iOS, no token change events will be emitted on that platform.
|
|
297
|
-
* This is not yet implemented on Android, no token change events will be emitted until implemented.
|
|
298
|
-
*
|
|
299
|
-
* NOTE: Although an `onError` callback can be provided, it will
|
|
300
|
-
* never be called, Android sdk code doesn't provide handling for onError function
|
|
301
|
-
*
|
|
302
|
-
* NOTE: Although an `onCompletion` callback can be provided, it will
|
|
303
|
-
* never be called because the token stream is never-ending.
|
|
304
|
-
*
|
|
305
|
-
* @returns A function that unsubscribes this listener.
|
|
306
|
-
*/
|
|
307
|
-
onTokenChanged(
|
|
308
|
-
onNext: (tokenResult: AppCheckListenerResult) => void,
|
|
309
|
-
onError?: (error: Error) => void,
|
|
310
|
-
onCompletion?: () => void,
|
|
311
|
-
): () => void;
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
// ============ Statics Interface ============
|
|
315
|
-
|
|
316
|
-
/**
|
|
317
|
-
* Static properties available on firebase.appCheck
|
|
318
|
-
*/
|
|
319
|
-
export interface AppCheckStatics {
|
|
320
|
-
CustomProvider: new (customProviderOptions: CustomProviderOptions) => CustomProvider;
|
|
321
|
-
SDK_VERSION: string;
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
/**
|
|
325
|
-
* FirebaseApp type with appCheck() method.
|
|
326
|
-
* @deprecated Import FirebaseApp from '@react-native-firebase/app' instead.
|
|
327
|
-
* The appCheck() method is added via module augmentation.
|
|
328
|
-
*/
|
|
329
|
-
export type FirebaseApp = ReactNativeFirebase.FirebaseApp;
|
|
330
|
-
|
|
331
|
-
// ============ Module Augmentation ============
|
|
332
|
-
|
|
333
|
-
/* eslint-disable @typescript-eslint/no-namespace */
|
|
334
|
-
declare module '@react-native-firebase/app' {
|
|
335
|
-
namespace ReactNativeFirebase {
|
|
336
|
-
interface Module {
|
|
337
|
-
appCheck: FirebaseModuleWithStaticsAndApp<AppCheck, AppCheckStatics>;
|
|
338
|
-
}
|
|
339
|
-
interface FirebaseApp {
|
|
340
|
-
appCheck(): AppCheck;
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
/* eslint-enable @typescript-eslint/no-namespace */
|
|
345
|
-
|
|
346
|
-
// ============ Backwards Compatibility Namespace ============
|
|
347
|
-
|
|
348
|
-
// Helper types to reference outer scope types within the namespace
|
|
349
|
-
// These are needed because TypeScript can't directly alias types with the same name
|
|
350
|
-
type _AppCheckProvider = AppCheckProvider;
|
|
351
|
-
type _CustomProviderOptions = CustomProviderOptions;
|
|
352
|
-
type _AppCheckOptions = AppCheckOptions;
|
|
353
|
-
type _AppCheckToken = AppCheckToken;
|
|
354
|
-
type _AppCheckTokenResult = AppCheckTokenResult;
|
|
355
|
-
type _AppCheckListenerResult = AppCheckListenerResult;
|
|
356
|
-
type _AppCheck = AppCheck;
|
|
357
|
-
type _AppCheckStatics = AppCheckStatics;
|
|
358
|
-
|
|
359
|
-
/**
|
|
360
|
-
* @deprecated Use the exported types directly instead.
|
|
361
|
-
* FirebaseAppCheckTypes namespace is kept for backwards compatibility.
|
|
362
|
-
*/
|
|
363
|
-
/* eslint-disable @typescript-eslint/no-namespace */
|
|
364
|
-
export namespace FirebaseAppCheckTypes {
|
|
365
|
-
// Short name aliases referencing top-level types
|
|
366
|
-
export type Provider = AppCheckProvider;
|
|
367
|
-
export type ProviderOptions = CustomProviderOptions;
|
|
368
|
-
export type Options = AppCheckOptions;
|
|
369
|
-
export type Token = AppCheckToken;
|
|
370
|
-
export type TokenResult = AppCheckTokenResult;
|
|
371
|
-
export type ListenerResult = AppCheckListenerResult;
|
|
372
|
-
export type Statics = AppCheckStatics;
|
|
373
|
-
export type Module = AppCheck;
|
|
374
|
-
|
|
375
|
-
// AppCheck* aliases that reference the exported types above via helper types
|
|
376
|
-
// These provide backwards compatibility for code using FirebaseAppCheckTypes.AppCheckProvider
|
|
377
|
-
export type AppCheckProvider = _AppCheckProvider;
|
|
378
|
-
export type CustomProviderOptions = _CustomProviderOptions;
|
|
379
|
-
export type AppCheckOptions = _AppCheckOptions;
|
|
380
|
-
export type AppCheckToken = _AppCheckToken;
|
|
381
|
-
export type AppCheckTokenResult = _AppCheckTokenResult;
|
|
382
|
-
export type AppCheckListenerResult = _AppCheckListenerResult;
|
|
383
|
-
export type AppCheck = _AppCheck;
|
|
384
|
-
export type AppCheckStatics = _AppCheckStatics;
|
|
385
|
-
}
|
|
386
|
-
/* eslint-enable @typescript-eslint/no-namespace */
|