@react-native-firebase/app-check 23.7.0 → 23.8.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 +11 -0
- package/dist/commonjs/ReactNativeFirebaseAppCheckProvider.js +19 -0
- package/dist/commonjs/ReactNativeFirebaseAppCheckProvider.js.map +1 -0
- package/dist/commonjs/index.js +38 -0
- package/dist/commonjs/index.js.map +1 -0
- package/dist/commonjs/modular.js +124 -0
- package/dist/commonjs/modular.js.map +1 -0
- package/dist/commonjs/namespaced.js +212 -0
- package/dist/commonjs/namespaced.js.map +1 -0
- package/dist/commonjs/package.json +1 -0
- package/dist/commonjs/types/appcheck.js +93 -0
- package/dist/commonjs/types/appcheck.js.map +1 -0
- package/dist/commonjs/version.js +9 -0
- package/dist/commonjs/version.js.map +1 -0
- package/dist/commonjs/web/RNFBAppCheckModule.android.js +10 -0
- package/dist/commonjs/web/RNFBAppCheckModule.android.js.map +1 -0
- package/dist/commonjs/web/RNFBAppCheckModule.ios.js +10 -0
- package/dist/commonjs/web/RNFBAppCheckModule.ios.js.map +1 -0
- package/dist/commonjs/web/RNFBAppCheckModule.js +91 -0
- package/dist/commonjs/web/RNFBAppCheckModule.js.map +1 -0
- package/dist/module/ReactNativeFirebaseAppCheckProvider.js +14 -0
- package/dist/module/ReactNativeFirebaseAppCheckProvider.js.map +1 -0
- package/dist/module/index.js +28 -0
- package/dist/module/index.js.map +1 -0
- package/dist/module/modular.js +110 -0
- package/dist/module/modular.js.map +1 -0
- package/{lib/index.js → dist/module/namespaced.js} +50 -80
- package/dist/module/namespaced.js.map +1 -0
- package/dist/module/package.json +1 -0
- package/dist/module/types/appcheck.js +89 -0
- package/dist/module/types/appcheck.js.map +1 -0
- package/dist/module/version.js +5 -0
- package/dist/module/version.js.map +1 -0
- package/dist/module/web/RNFBAppCheckModule.android.js +6 -0
- package/dist/module/web/RNFBAppCheckModule.android.js.map +1 -0
- package/dist/module/web/RNFBAppCheckModule.ios.js +6 -0
- package/dist/module/web/RNFBAppCheckModule.ios.js.map +1 -0
- package/{lib → dist/module}/web/RNFBAppCheckModule.js +19 -27
- package/dist/module/web/RNFBAppCheckModule.js.map +1 -0
- package/dist/typescript/commonjs/lib/ReactNativeFirebaseAppCheckProvider.d.ts +8 -0
- package/dist/typescript/commonjs/lib/ReactNativeFirebaseAppCheckProvider.d.ts.map +1 -0
- package/dist/typescript/commonjs/lib/index.d.ts +5 -0
- package/dist/typescript/commonjs/lib/index.d.ts.map +1 -0
- package/dist/typescript/commonjs/lib/modular.d.ts +57 -0
- package/dist/typescript/commonjs/lib/modular.d.ts.map +1 -0
- package/dist/typescript/commonjs/lib/namespaced.d.ts +17 -0
- package/dist/typescript/commonjs/lib/namespaced.d.ts.map +1 -0
- package/{lib/index.d.ts → dist/typescript/commonjs/lib/types/appcheck.d.ts} +162 -221
- package/dist/typescript/commonjs/lib/types/appcheck.d.ts.map +1 -0
- package/dist/typescript/commonjs/lib/version.d.ts +2 -0
- package/dist/typescript/commonjs/lib/version.d.ts.map +1 -0
- package/dist/typescript/commonjs/lib/web/RNFBAppCheckModule.android.d.ts +3 -0
- package/dist/typescript/commonjs/lib/web/RNFBAppCheckModule.android.d.ts.map +1 -0
- package/dist/typescript/commonjs/lib/web/RNFBAppCheckModule.d.ts +18 -0
- package/dist/typescript/commonjs/lib/web/RNFBAppCheckModule.d.ts.map +1 -0
- package/dist/typescript/commonjs/lib/web/RNFBAppCheckModule.ios.d.ts +3 -0
- package/dist/typescript/commonjs/lib/web/RNFBAppCheckModule.ios.d.ts.map +1 -0
- package/dist/typescript/commonjs/package.json +1 -0
- package/dist/typescript/module/lib/ReactNativeFirebaseAppCheckProvider.d.ts +8 -0
- package/dist/typescript/module/lib/ReactNativeFirebaseAppCheckProvider.d.ts.map +1 -0
- package/dist/typescript/module/lib/index.d.ts +5 -0
- package/dist/typescript/module/lib/index.d.ts.map +1 -0
- package/dist/typescript/module/lib/modular.d.ts +57 -0
- package/dist/typescript/module/lib/modular.d.ts.map +1 -0
- package/dist/typescript/module/lib/namespaced.d.ts +17 -0
- package/dist/typescript/module/lib/namespaced.d.ts.map +1 -0
- package/dist/typescript/module/lib/types/appcheck.d.ts +299 -0
- package/dist/typescript/module/lib/types/appcheck.d.ts.map +1 -0
- package/dist/typescript/module/lib/version.d.ts +2 -0
- package/dist/typescript/module/lib/version.d.ts.map +1 -0
- package/dist/typescript/module/lib/web/RNFBAppCheckModule.android.d.ts +3 -0
- package/dist/typescript/module/lib/web/RNFBAppCheckModule.android.d.ts.map +1 -0
- package/dist/typescript/module/lib/web/RNFBAppCheckModule.d.ts +18 -0
- package/dist/typescript/module/lib/web/RNFBAppCheckModule.d.ts.map +1 -0
- package/dist/typescript/module/lib/web/RNFBAppCheckModule.ios.d.ts +3 -0
- package/dist/typescript/module/lib/web/RNFBAppCheckModule.ios.d.ts.map +1 -0
- package/dist/typescript/module/package.json +1 -0
- package/lib/ReactNativeFirebaseAppCheckProvider.ts +21 -0
- package/lib/index.ts +46 -0
- package/lib/modular.ts +157 -0
- package/lib/namespaced.ts +305 -0
- package/lib/types/appcheck.ts +386 -0
- package/lib/version.ts +2 -0
- package/lib/web/RNFBAppCheckModule.android.ts +4 -0
- package/lib/web/RNFBAppCheckModule.ios.ts +4 -0
- package/lib/web/RNFBAppCheckModule.ts +115 -0
- package/package.json +54 -8
- package/tsconfig.json +21 -0
- package/lib/ReactNativeFirebaseAppCheckProvider.js +0 -9
- package/lib/modular/index.d.ts +0 -149
- package/lib/modular/index.js +0 -102
- package/lib/version.js +0 -2
- package/lib/web/RNFBAppCheckModule.android.js +0 -2
- package/lib/web/RNFBAppCheckModule.ios.js +0 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"namespaced.d.ts","sourceRoot":"","sources":["../../../../lib/namespaced.ts"],"names":[],"mappings":"AAsCA,OAAO,KAAK,EACV,qBAAqB,EACrB,gBAAgB,EAKhB,QAAQ,EACR,eAAe,EAEhB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAMtE,qBAAa,cAAe,YAAW,gBAAgB;IACrD,OAAO,CAAC,sBAAsB,CAAwB;gBAE1C,sBAAsB,EAAE,qBAAqB;IAUnD,QAAQ;CAGf;AAmMD,eAAO,MAAM,WAAW,WAAU,CAAC;AAanC,KAAK,iBAAiB,GAAG,mBAAmB,CAAC,+BAA+B,CAC1E,QAAQ,EACR,eAAe,CAChB,GAAG;IACF,QAAQ,EAAE,mBAAmB,CAAC,+BAA+B,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC;IACzF,QAAQ,EAAE,mBAAmB,CAAC,MAAM,CAAC;IACrC,GAAG,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,mBAAmB,CAAC,WAAW,CAAC;CACrD,CAAC;wBAI6C,iBAAiB;AAAhE,wBAAiE;AAKjE,eAAO,MAAM,QAAQ,EACa,mBAAmB,CAAC,wBAAwB,CAC1E,UAAU,EACV,QAAQ,EACR,eAAe,EACf,KAAK,CACN,CAAC"}
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
import type { ReactNativeFirebase } from '@react-native-firebase/app';
|
|
2
|
+
/**
|
|
3
|
+
* An App Check provider. This can be either the built-in reCAPTCHA provider
|
|
4
|
+
* or a custom provider. For more on custom providers, see
|
|
5
|
+
* https://firebase.google.com/docs/app-check/web-custom-provider
|
|
6
|
+
*/
|
|
7
|
+
export interface AppCheckProvider {
|
|
8
|
+
/**
|
|
9
|
+
* Returns an AppCheck token.
|
|
10
|
+
*/
|
|
11
|
+
getToken(): Promise<AppCheckToken>;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Function to get an App Check token through a custom provider service.
|
|
15
|
+
*/
|
|
16
|
+
export interface CustomProviderOptions {
|
|
17
|
+
getToken: () => Promise<AppCheckToken>;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Custom provider class.
|
|
21
|
+
* @public
|
|
22
|
+
*/
|
|
23
|
+
export declare class CustomProvider implements AppCheckProvider {
|
|
24
|
+
constructor(customProviderOptions: CustomProviderOptions);
|
|
25
|
+
getToken(): Promise<AppCheckToken>;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Options for App Check initialization.
|
|
29
|
+
*/
|
|
30
|
+
export interface AppCheckOptions {
|
|
31
|
+
/**
|
|
32
|
+
* The App Check provider to use. This can be either the built-in reCAPTCHA provider
|
|
33
|
+
* or a custom provider. For convenience, you can also pass an object with providerOptions
|
|
34
|
+
* directly, which will be accepted by the runtime.
|
|
35
|
+
*/
|
|
36
|
+
provider: CustomProvider | ReactNativeFirebaseAppCheckProvider | ReactNativeFirebaseAppCheckProviderConfig;
|
|
37
|
+
/**
|
|
38
|
+
* If true, enables SDK to automatically
|
|
39
|
+
* refresh AppCheck token as needed. If undefined, the value will default
|
|
40
|
+
* to the value of `app.automaticDataCollectionEnabled`. That property
|
|
41
|
+
* defaults to false and can be set in the app config.
|
|
42
|
+
*/
|
|
43
|
+
isTokenAutoRefreshEnabled?: boolean;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* The token returned from an `AppCheckProvider`.
|
|
47
|
+
*/
|
|
48
|
+
export interface AppCheckToken {
|
|
49
|
+
/**
|
|
50
|
+
* The token string in JWT format.
|
|
51
|
+
*/
|
|
52
|
+
readonly token: string;
|
|
53
|
+
/**
|
|
54
|
+
* The local timestamp after which the token will expire.
|
|
55
|
+
*/
|
|
56
|
+
readonly expireTimeMillis: number;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Result returned by `getToken()`.
|
|
60
|
+
*/
|
|
61
|
+
export interface AppCheckTokenResult {
|
|
62
|
+
/**
|
|
63
|
+
* The token string in JWT format.
|
|
64
|
+
*/
|
|
65
|
+
readonly token: string;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* The result return from `onTokenChanged`
|
|
69
|
+
*/
|
|
70
|
+
export type AppCheckListenerResult = AppCheckToken & {
|
|
71
|
+
readonly appName: string;
|
|
72
|
+
};
|
|
73
|
+
export type NextFn<T> = (value: T) => void;
|
|
74
|
+
export type ErrorFn = (error: Error) => void;
|
|
75
|
+
export type CompleteFn = () => void;
|
|
76
|
+
export interface Observer<T> {
|
|
77
|
+
next: NextFn<T>;
|
|
78
|
+
error: ErrorFn;
|
|
79
|
+
complete: CompleteFn;
|
|
80
|
+
}
|
|
81
|
+
export type PartialObserver<T> = Partial<Observer<T>>;
|
|
82
|
+
/**
|
|
83
|
+
* A function that unsubscribes from token changes.
|
|
84
|
+
*/
|
|
85
|
+
export type Unsubscribe = () => void;
|
|
86
|
+
export interface ReactNativeFirebaseAppCheckProviderOptions {
|
|
87
|
+
/**
|
|
88
|
+
* debug token to use, if any. Defaults to undefined, pre-configure tokens in firebase web console if needed
|
|
89
|
+
*/
|
|
90
|
+
debugToken?: string;
|
|
91
|
+
}
|
|
92
|
+
export interface ReactNativeFirebaseAppCheckProviderWebOptions extends ReactNativeFirebaseAppCheckProviderOptions {
|
|
93
|
+
/**
|
|
94
|
+
* The web provider to use, either `reCaptchaV3` or `reCaptchaEnterprise`, defaults to `reCaptchaV3`
|
|
95
|
+
*/
|
|
96
|
+
provider?: 'debug' | 'reCaptchaV3' | 'reCaptchaEnterprise';
|
|
97
|
+
/**
|
|
98
|
+
* siteKey for use in web queries, defaults to `none`
|
|
99
|
+
*/
|
|
100
|
+
siteKey?: string;
|
|
101
|
+
}
|
|
102
|
+
export interface ReactNativeFirebaseAppCheckProviderAppleOptions extends ReactNativeFirebaseAppCheckProviderOptions {
|
|
103
|
+
/**
|
|
104
|
+
* The apple provider to use, either `deviceCheck` or `appAttest`, or `appAttestWithDeviceCheckFallback`,
|
|
105
|
+
* defaults to `DeviceCheck`. `appAttest` requires iOS 14+ or will fail, `appAttestWithDeviceCheckFallback`
|
|
106
|
+
* will use `appAttest` for iOS14+ and fallback to `deviceCheck` on devices with ios13 and lower
|
|
107
|
+
*/
|
|
108
|
+
provider?: 'debug' | 'deviceCheck' | 'appAttest' | 'appAttestWithDeviceCheckFallback';
|
|
109
|
+
}
|
|
110
|
+
export interface ReactNativeFirebaseAppCheckProviderAndroidOptions extends ReactNativeFirebaseAppCheckProviderOptions {
|
|
111
|
+
/**
|
|
112
|
+
* The android provider to use, either `debug` or `playIntegrity`. default is `playIntegrity`.
|
|
113
|
+
*/
|
|
114
|
+
provider?: 'debug' | 'playIntegrity';
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Platform-specific provider options configuration.
|
|
118
|
+
*/
|
|
119
|
+
export type ReactNativeFirebaseAppCheckProviderOptionsMap = {
|
|
120
|
+
web?: ReactNativeFirebaseAppCheckProviderWebOptions;
|
|
121
|
+
android?: ReactNativeFirebaseAppCheckProviderAndroidOptions;
|
|
122
|
+
apple?: ReactNativeFirebaseAppCheckProviderAppleOptions;
|
|
123
|
+
isTokenAutoRefreshEnabled?: boolean;
|
|
124
|
+
};
|
|
125
|
+
/**
|
|
126
|
+
* Configuration object for ReactNativeFirebaseAppCheckProvider
|
|
127
|
+
* that can be passed directly with providerOptions (for convenience in initialization).
|
|
128
|
+
* The runtime accepts objects with providerOptions even if they don't have
|
|
129
|
+
* getToken() and configure() methods.
|
|
130
|
+
*/
|
|
131
|
+
export interface ReactNativeFirebaseAppCheckProviderConfig {
|
|
132
|
+
providerOptions: ReactNativeFirebaseAppCheckProviderOptionsMap;
|
|
133
|
+
}
|
|
134
|
+
export interface ReactNativeFirebaseAppCheckProvider extends AppCheckProvider {
|
|
135
|
+
/**
|
|
136
|
+
* Provider options for platform-specific configuration.
|
|
137
|
+
* This is set when configure() is called.
|
|
138
|
+
*/
|
|
139
|
+
providerOptions?: ReactNativeFirebaseAppCheckProviderOptionsMap;
|
|
140
|
+
/**
|
|
141
|
+
* Specify how the app check provider should be configured. The new configuration is
|
|
142
|
+
* in effect when this call returns. You must call `getToken()`
|
|
143
|
+
* after this call to get a token using the new configuration.
|
|
144
|
+
* This custom provider allows for delayed configuration and re-configuration on all platforms
|
|
145
|
+
* so AppCheck has the same experience across all platforms, with the only difference being the native
|
|
146
|
+
* providers you choose to use on each platform.
|
|
147
|
+
*/
|
|
148
|
+
configure(options: ReactNativeFirebaseAppCheckProviderOptionsMap): void;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Type representing providers that have providerOptions.
|
|
152
|
+
* Used for type narrowing in runtime code.
|
|
153
|
+
*/
|
|
154
|
+
export type ProviderWithOptions = ReactNativeFirebaseAppCheckProvider | ReactNativeFirebaseAppCheckProviderConfig;
|
|
155
|
+
/**
|
|
156
|
+
* App Check module instance - returned from firebase.appCheck() or firebase.app().appCheck()
|
|
157
|
+
*/
|
|
158
|
+
export interface AppCheck extends ReactNativeFirebase.FirebaseModule {
|
|
159
|
+
/** The FirebaseApp this module is associated with */
|
|
160
|
+
app: ReactNativeFirebase.FirebaseApp;
|
|
161
|
+
/**
|
|
162
|
+
* Create a ReactNativeFirebaseAppCheckProvider option for use in react-native-firebase
|
|
163
|
+
*/
|
|
164
|
+
newReactNativeFirebaseAppCheckProvider(): ReactNativeFirebaseAppCheckProvider;
|
|
165
|
+
/**
|
|
166
|
+
* Initialize the AppCheck module. Note that in react-native-firebase AppCheckOptions must always
|
|
167
|
+
* be an object with a `provider` member containing `ReactNativeFirebaseAppCheckProvider` that has returned successfully
|
|
168
|
+
* from a call to the `configure` method, with sub-providers for the various platforms configured to meet your project
|
|
169
|
+
* requirements. This must be called prior to interacting with any firebase services protected by AppCheck
|
|
170
|
+
*
|
|
171
|
+
* @param options an AppCheckOptions with a configured ReactNativeFirebaseAppCheckProvider as the provider
|
|
172
|
+
*/
|
|
173
|
+
initializeAppCheck(options: AppCheckOptions): Promise<void>;
|
|
174
|
+
/**
|
|
175
|
+
* Activate App Check
|
|
176
|
+
* On iOS App Check is activated with DeviceCheck provider simply by including the module, using the token auto refresh default or
|
|
177
|
+
* the specific value (if configured) in firebase.json, but calling this does no harm.
|
|
178
|
+
* On Android if you call this it will install the PlayIntegrity provider in release builds, the Debug provider if debuggable.
|
|
179
|
+
* On both platforms you may use this method to alter the token refresh setting after startup.
|
|
180
|
+
* On iOS if you want to set a specific AppCheckProviderFactory (for instance to FIRAppCheckDebugProviderFactory or
|
|
181
|
+
* FIRAppAttestProvider) you must manually do that in your AppDelegate.m prior to calling [FIRApp configure]
|
|
182
|
+
*
|
|
183
|
+
* @deprecated use initializeAppCheck to gain access to all platform providers and firebase-js-sdk v9 compatibility
|
|
184
|
+
* @param siteKeyOrProvider - This is ignored, Android uses DebugProviderFactory if the app is debuggable (https://firebase.google.com/docs/app-check/android/debug-provider)
|
|
185
|
+
* Android uses PlayIntegrityProviderFactory for release builds.
|
|
186
|
+
* iOS uses DeviceCheckProviderFactory by default unless altered in AppDelegate.m manually
|
|
187
|
+
* @param isTokenAutoRefreshEnabled - If true, enables SDK to automatically
|
|
188
|
+
* refresh AppCheck token as needed. If undefined, the value will default
|
|
189
|
+
* to the value of `app.automaticDataCollectionEnabled`. That property
|
|
190
|
+
* defaults to false and can be set in the app config.
|
|
191
|
+
*/
|
|
192
|
+
activate(siteKeyOrProvider: string | AppCheckProvider, isTokenAutoRefreshEnabled?: boolean): Promise<void>;
|
|
193
|
+
/**
|
|
194
|
+
* Alter the token auto refresh setting. By default it will take the value of automaticDataCollectionEnabled from Info.plist / AndroidManifest.xml
|
|
195
|
+
* @param isTokenAutoRefreshEnabled - If true, the SDK automatically
|
|
196
|
+
* refreshes App Check tokens as needed. This overrides any value set
|
|
197
|
+
* during `activate()` or taken by default from automaticDataCollectionEnabled in plist / android manifest
|
|
198
|
+
*/
|
|
199
|
+
setTokenAutoRefreshEnabled(isTokenAutoRefreshEnabled: boolean): void;
|
|
200
|
+
/**
|
|
201
|
+
* Requests Firebase App Check token.
|
|
202
|
+
* This method should only be used if you need to authorize requests to a non-Firebase backend.
|
|
203
|
+
* Requests to Firebase backend are authorized automatically if configured.
|
|
204
|
+
*
|
|
205
|
+
* @param forceRefresh - If true, a new Firebase App Check token is requested and the token cache is ignored.
|
|
206
|
+
* If false, the cached token is used if it exists and has not expired yet.
|
|
207
|
+
* In most cases, false should be used. True should only be used if the server explicitly returns an error, indicating a revoked token.
|
|
208
|
+
*/
|
|
209
|
+
getToken(forceRefresh?: boolean): Promise<AppCheckTokenResult>;
|
|
210
|
+
/**
|
|
211
|
+
* Requests a Firebase App Check token. This method should be used only if you need to authorize requests
|
|
212
|
+
* to a non-Firebase backend. Returns limited-use tokens that are intended for use with your non-Firebase
|
|
213
|
+
* backend endpoints that are protected with Replay Protection (https://firebase.google.com/docs/app-check/custom-resource-backend#replay-protection).
|
|
214
|
+
* This method does not affect the token generation behavior of the getAppCheckToken() method.
|
|
215
|
+
*/
|
|
216
|
+
getLimitedUseToken(): Promise<AppCheckTokenResult>;
|
|
217
|
+
/**
|
|
218
|
+
* Registers a listener to changes in the token state. There can be more
|
|
219
|
+
* than one listener registered at the same time for one or more
|
|
220
|
+
* App Check instances. The listeners call back on the UI thread whenever
|
|
221
|
+
* the current token associated with this App Check instance changes.
|
|
222
|
+
*
|
|
223
|
+
* @returns A function that unsubscribes this listener.
|
|
224
|
+
*/
|
|
225
|
+
onTokenChanged(observer: PartialObserver<AppCheckListenerResult>): () => void;
|
|
226
|
+
/**
|
|
227
|
+
* Registers a listener to changes in the token state. There can be more
|
|
228
|
+
* than one listener registered at the same time for one or more
|
|
229
|
+
* App Check instances. The listeners call back on the UI thread whenever
|
|
230
|
+
* the current token associated with this App Check instance changes.
|
|
231
|
+
*
|
|
232
|
+
* Token listeners do not exist in the native SDK for iOS, no token change events will be emitted on that platform.
|
|
233
|
+
* This is not yet implemented on Android, no token change events will be emitted until implemented.
|
|
234
|
+
*
|
|
235
|
+
* NOTE: Although an `onError` callback can be provided, it will
|
|
236
|
+
* never be called, Android sdk code doesn't provide handling for onError function
|
|
237
|
+
*
|
|
238
|
+
* NOTE: Although an `onCompletion` callback can be provided, it will
|
|
239
|
+
* never be called because the token stream is never-ending.
|
|
240
|
+
*
|
|
241
|
+
* @returns A function that unsubscribes this listener.
|
|
242
|
+
*/
|
|
243
|
+
onTokenChanged(onNext: (tokenResult: AppCheckListenerResult) => void, onError?: (error: Error) => void, onCompletion?: () => void): () => void;
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Static properties available on firebase.appCheck
|
|
247
|
+
*/
|
|
248
|
+
export interface AppCheckStatics {
|
|
249
|
+
CustomProvider: new (customProviderOptions: CustomProviderOptions) => CustomProvider;
|
|
250
|
+
SDK_VERSION: string;
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* FirebaseApp type with appCheck() method.
|
|
254
|
+
* @deprecated Import FirebaseApp from '@react-native-firebase/app' instead.
|
|
255
|
+
* The appCheck() method is added via module augmentation.
|
|
256
|
+
*/
|
|
257
|
+
export type FirebaseApp = ReactNativeFirebase.FirebaseApp;
|
|
258
|
+
declare module '@react-native-firebase/app' {
|
|
259
|
+
namespace ReactNativeFirebase {
|
|
260
|
+
interface Module {
|
|
261
|
+
appCheck: FirebaseModuleWithStaticsAndApp<AppCheck, AppCheckStatics>;
|
|
262
|
+
}
|
|
263
|
+
interface FirebaseApp {
|
|
264
|
+
appCheck(): AppCheck;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
type _AppCheckProvider = AppCheckProvider;
|
|
269
|
+
type _CustomProviderOptions = CustomProviderOptions;
|
|
270
|
+
type _AppCheckOptions = AppCheckOptions;
|
|
271
|
+
type _AppCheckToken = AppCheckToken;
|
|
272
|
+
type _AppCheckTokenResult = AppCheckTokenResult;
|
|
273
|
+
type _AppCheckListenerResult = AppCheckListenerResult;
|
|
274
|
+
type _AppCheck = AppCheck;
|
|
275
|
+
type _AppCheckStatics = AppCheckStatics;
|
|
276
|
+
/**
|
|
277
|
+
* @deprecated Use the exported types directly instead.
|
|
278
|
+
* FirebaseAppCheckTypes namespace is kept for backwards compatibility.
|
|
279
|
+
*/
|
|
280
|
+
export declare namespace FirebaseAppCheckTypes {
|
|
281
|
+
type Provider = AppCheckProvider;
|
|
282
|
+
type ProviderOptions = CustomProviderOptions;
|
|
283
|
+
type Options = AppCheckOptions;
|
|
284
|
+
type Token = AppCheckToken;
|
|
285
|
+
type TokenResult = AppCheckTokenResult;
|
|
286
|
+
type ListenerResult = AppCheckListenerResult;
|
|
287
|
+
type Statics = AppCheckStatics;
|
|
288
|
+
type Module = AppCheck;
|
|
289
|
+
type AppCheckProvider = _AppCheckProvider;
|
|
290
|
+
type CustomProviderOptions = _CustomProviderOptions;
|
|
291
|
+
type AppCheckOptions = _AppCheckOptions;
|
|
292
|
+
type AppCheckToken = _AppCheckToken;
|
|
293
|
+
type AppCheckTokenResult = _AppCheckTokenResult;
|
|
294
|
+
type AppCheckListenerResult = _AppCheckListenerResult;
|
|
295
|
+
type AppCheck = _AppCheck;
|
|
296
|
+
type AppCheckStatics = _AppCheckStatics;
|
|
297
|
+
}
|
|
298
|
+
export {};
|
|
299
|
+
//# sourceMappingURL=appcheck.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"appcheck.d.ts","sourceRoot":"","sources":["../../../../../lib/types/appcheck.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAItE;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,QAAQ,IAAI,OAAO,CAAC,aAAa,CAAC,CAAC;CACpC;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,QAAQ,EAAE,MAAM,OAAO,CAAC,aAAa,CAAC,CAAC;CACxC;AAID;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,cAAe,YAAW,gBAAgB;gBACjD,qBAAqB,EAAE,qBAAqB;IACxD,QAAQ,IAAI,OAAO,CAAC,aAAa,CAAC;CACnC;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;;;OAIG;IACH,QAAQ,E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AS,GAAG,QAAQ,CAAC;AAC1B,KAAK,gBAAgB,GAAG,eAAe,CAAC;AAExC;;;GAGG;AAEH,yBAAiB,qBAAqB,CAAC;IAErC,KAAY,QAAQ,GAAG,gBAAgB,CAAC;IACxC,KAAY,eAAe,GAAG,qBAAqB,CAAC;IACpD,KAAY,OAAO,GAAG,eAAe,CAAC;IACtC,KAAY,KAAK,GAAG,aAAa,CAAC;IAClC,KAAY,WAAW,GAAG,mBAAmB,CAAC;IAC9C,KAAY,cAAc,GAAG,sBAAsB,CAAC;IACpD,KAAY,OAAO,GAAG,eAAe,CAAC;IACtC,KAAY,MAAM,GAAG,QAAQ,CAAC;IAI9B,KAAY,gBAAgB,GAAG,iBAAiB,CAAC;IACjD,KAAY,qBAAqB,GAAG,sBAAsB,CAAC;IAC3D,KAAY,eAAe,GAAG,gBAAgB,CAAC;IAC/C,KAAY,aAAa,GAAG,cAAc,CAAC;IAC3C,KAAY,mBAAmB,GAAG,oBAAoB,CAAC;IACvD,KAAY,sBAAsB,GAAG,uBAAuB,CAAC;IAC7D,KAAY,QAAQ,GAAG,SAAS,CAAC;IACjC,KAAY,eAAe,GAAG,gBAAgB,CAAC;CAChD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../../../lib/version.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,OAAO,WAAW,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RNFBAppCheckModule.android.d.ts","sourceRoot":"","sources":["../../../../../lib/web/RNFBAppCheckModule.android.ts"],"names":[],"mappings":"AACA,QAAA,MAAM,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAM,CAAC;AAEzC,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { FirebaseAppCheckTypes } from '../types/appcheck';
|
|
2
|
+
interface AppCheckModule {
|
|
3
|
+
initializeAppCheck(appName: string, options: FirebaseAppCheckTypes.AppCheckOptions): Promise<void>;
|
|
4
|
+
setTokenAutoRefreshEnabled(appName: string, isTokenAutoRefreshEnabled: boolean): Promise<void>;
|
|
5
|
+
getLimitedUseToken(appName: string): Promise<FirebaseAppCheckTypes.AppCheckTokenResult>;
|
|
6
|
+
getToken(appName: string, forceRefresh: boolean): Promise<FirebaseAppCheckTypes.AppCheckTokenResult>;
|
|
7
|
+
addAppCheckListener(appName: string): Promise<void>;
|
|
8
|
+
removeAppCheckListener(appName: string): Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* This is a 'NativeModule' for the web platform.
|
|
12
|
+
* Methods here are identical to the ones found in
|
|
13
|
+
* the native android/ios modules e.g. `@ReactMethod` annotated
|
|
14
|
+
* java methods on Android.
|
|
15
|
+
*/
|
|
16
|
+
declare const module: AppCheckModule;
|
|
17
|
+
export default module;
|
|
18
|
+
//# sourceMappingURL=RNFBAppCheckModule.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RNFBAppCheckModule.d.ts","sourceRoot":"","sources":["../../../../../lib/web/RNFBAppCheckModule.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAc/D,UAAU,cAAc;IACtB,kBAAkB,CAChB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,qBAAqB,CAAC,eAAe,GAC7C,OAAO,CAAC,IAAI,CAAC,CAAC;IACjB,0BAA0B,CAAC,OAAO,EAAE,MAAM,EAAE,yBAAyB,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/F,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC,mBAAmB,CAAC,CAAC;IACxF,QAAQ,CACN,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,OAAO,GACpB,OAAO,CAAC,qBAAqB,CAAC,mBAAmB,CAAC,CAAC;IACtD,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACpD,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACxD;AAED;;;;;GAKG;AACH,QAAA,MAAM,MAAM,EAAE,cAkEb,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RNFBAppCheckModule.ios.d.ts","sourceRoot":"","sources":["../../../../../lib/web/RNFBAppCheckModule.ios.ts"],"names":[],"mappings":"AACA,QAAA,MAAM,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAM,CAAC;AAEzC,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
AppCheckProvider,
|
|
3
|
+
AppCheckToken,
|
|
4
|
+
ReactNativeFirebaseAppCheckProviderOptionsMap as ProviderOptions,
|
|
5
|
+
} from './types/appcheck';
|
|
6
|
+
|
|
7
|
+
export default class ReactNativeFirebaseAppCheckProvider implements AppCheckProvider {
|
|
8
|
+
providerOptions?: ProviderOptions;
|
|
9
|
+
|
|
10
|
+
constructor() {}
|
|
11
|
+
|
|
12
|
+
configure(options: ProviderOptions): void {
|
|
13
|
+
this.providerOptions = options;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
async getToken(): Promise<AppCheckToken> {
|
|
17
|
+
// This is a placeholder - the actual implementation is handled by the native modules
|
|
18
|
+
// This method exists to satisfy the AppCheckProvider interface
|
|
19
|
+
throw new Error('getToken() must be called after configure() and is handled by native modules');
|
|
20
|
+
}
|
|
21
|
+
}
|
package/lib/index.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2016-present Invertase Limited & Contributors
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this library except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
// Export types from types/appcheck
|
|
19
|
+
export type {
|
|
20
|
+
AppCheckProvider,
|
|
21
|
+
CustomProviderOptions,
|
|
22
|
+
AppCheckOptions,
|
|
23
|
+
AppCheckToken,
|
|
24
|
+
AppCheckTokenResult,
|
|
25
|
+
AppCheckListenerResult,
|
|
26
|
+
PartialObserver,
|
|
27
|
+
Observer,
|
|
28
|
+
NextFn,
|
|
29
|
+
ErrorFn,
|
|
30
|
+
CompleteFn,
|
|
31
|
+
Unsubscribe,
|
|
32
|
+
ReactNativeFirebaseAppCheckProviderOptions,
|
|
33
|
+
ReactNativeFirebaseAppCheckProviderWebOptions,
|
|
34
|
+
ReactNativeFirebaseAppCheckProviderAppleOptions,
|
|
35
|
+
ReactNativeFirebaseAppCheckProviderAndroidOptions,
|
|
36
|
+
ReactNativeFirebaseAppCheckProvider,
|
|
37
|
+
AppCheck,
|
|
38
|
+
FirebaseAppCheckTypes,
|
|
39
|
+
} from './types/appcheck';
|
|
40
|
+
|
|
41
|
+
// Export modular API functions
|
|
42
|
+
export * from './modular';
|
|
43
|
+
|
|
44
|
+
// Export namespaced API
|
|
45
|
+
export * from './namespaced';
|
|
46
|
+
export { default } from './namespaced';
|
package/lib/modular.ts
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2016-present Invertase Limited & Contributors
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this library except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import { getApp, type ReactNativeFirebase } from '@react-native-firebase/app';
|
|
19
|
+
import { MODULAR_DEPRECATION_ARG } from '@react-native-firebase/app/lib/common';
|
|
20
|
+
import ReactNativeFirebaseAppCheckProvider from './ReactNativeFirebaseAppCheckProvider';
|
|
21
|
+
|
|
22
|
+
import type {
|
|
23
|
+
AppCheck,
|
|
24
|
+
AppCheckOptions,
|
|
25
|
+
AppCheckTokenResult,
|
|
26
|
+
PartialObserver,
|
|
27
|
+
Unsubscribe,
|
|
28
|
+
AppCheckListenerResult,
|
|
29
|
+
} from './types/appcheck';
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Activate App Check for the given app. Can be called only once per app.
|
|
33
|
+
* @param app - The app to initialize App Check for. Optional.
|
|
34
|
+
* @param options - App Check options.
|
|
35
|
+
* @returns Promise<AppCheck>
|
|
36
|
+
*/
|
|
37
|
+
export async function initializeAppCheck(
|
|
38
|
+
app?: ReactNativeFirebase.FirebaseApp,
|
|
39
|
+
options?: AppCheckOptions,
|
|
40
|
+
): Promise<AppCheck> {
|
|
41
|
+
if (app) {
|
|
42
|
+
const appInstance = getApp(app.name) as ReactNativeFirebase.FirebaseApp;
|
|
43
|
+
const appCheck = appInstance.appCheck();
|
|
44
|
+
// @ts-ignore - Extra arg used by deprecation proxy to detect modular calls
|
|
45
|
+
await appCheck.initializeAppCheck.call(appCheck, options, MODULAR_DEPRECATION_ARG);
|
|
46
|
+
return appCheck;
|
|
47
|
+
}
|
|
48
|
+
const appInstance = getApp() as ReactNativeFirebase.FirebaseApp;
|
|
49
|
+
const appCheck = appInstance.appCheck();
|
|
50
|
+
// @ts-ignore - Extra arg used by deprecation proxy to detect modular calls
|
|
51
|
+
await appCheck.initializeAppCheck.call(appCheck, options, MODULAR_DEPRECATION_ARG);
|
|
52
|
+
return appCheck;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Get the current App Check token. Attaches to the most recent in-flight request if one is present.
|
|
57
|
+
* Returns null if no token is present and no token requests are in-flight.
|
|
58
|
+
* @param appCheckInstance - The App Check instance.
|
|
59
|
+
* @param forceRefresh - Whether to force refresh the token. Optional
|
|
60
|
+
* @returns Promise<AppCheckTokenResult>
|
|
61
|
+
*/
|
|
62
|
+
export function getToken(
|
|
63
|
+
appCheckInstance: AppCheck,
|
|
64
|
+
forceRefresh?: boolean,
|
|
65
|
+
): Promise<AppCheckTokenResult> {
|
|
66
|
+
return appCheckInstance.getToken.call(
|
|
67
|
+
appCheckInstance,
|
|
68
|
+
forceRefresh,
|
|
69
|
+
// @ts-ignore - Extra arg used by deprecation proxy to detect modular calls
|
|
70
|
+
MODULAR_DEPRECATION_ARG,
|
|
71
|
+
) as Promise<AppCheckTokenResult>;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Get a limited-use (consumable) App Check token.
|
|
76
|
+
* For use with server calls to firebase functions or custom backends using the firebase admin SDK.
|
|
77
|
+
* @param appCheckInstance - The App Check instance.
|
|
78
|
+
* @returns Promise<AppCheckTokenResult>
|
|
79
|
+
*/
|
|
80
|
+
export function getLimitedUseToken(appCheckInstance: AppCheck): Promise<AppCheckTokenResult> {
|
|
81
|
+
return appCheckInstance.getLimitedUseToken.call(
|
|
82
|
+
appCheckInstance,
|
|
83
|
+
// @ts-ignore - Extra arg used by deprecation proxy to detect modular calls
|
|
84
|
+
MODULAR_DEPRECATION_ARG,
|
|
85
|
+
) as Promise<AppCheckTokenResult>;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Set whether App Check will automatically refresh tokens as needed.
|
|
90
|
+
* @param appCheckInstance - The App Check instance.
|
|
91
|
+
* @param isAutoRefreshEnabled - Whether to enable auto-refresh.
|
|
92
|
+
*/
|
|
93
|
+
export function setTokenAutoRefreshEnabled(
|
|
94
|
+
appCheckInstance: AppCheck,
|
|
95
|
+
isAutoRefreshEnabled: boolean,
|
|
96
|
+
): void {
|
|
97
|
+
appCheckInstance.setTokenAutoRefreshEnabled.call(
|
|
98
|
+
appCheckInstance,
|
|
99
|
+
isAutoRefreshEnabled,
|
|
100
|
+
// @ts-ignore - Extra arg used by deprecation proxy to detect modular calls
|
|
101
|
+
MODULAR_DEPRECATION_ARG,
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Registers a listener to changes in the token state. There can be more
|
|
107
|
+
* than one listener registered at the same time for one or more
|
|
108
|
+
* App Check instances. The listeners call back on the UI thread whenever
|
|
109
|
+
* the current token associated with this App Check instance changes.
|
|
110
|
+
*
|
|
111
|
+
* @param appCheckInstance - The App Check instance.
|
|
112
|
+
* @param listener - The listener to register.
|
|
113
|
+
* @returns Unsubscribe
|
|
114
|
+
*/
|
|
115
|
+
export function onTokenChanged(
|
|
116
|
+
appCheckInstance: AppCheck,
|
|
117
|
+
listener: PartialObserver<AppCheckTokenResult>,
|
|
118
|
+
): Unsubscribe;
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Registers a listener to changes in the token state. There can be more
|
|
122
|
+
* than one listener registered at the same time for one or more
|
|
123
|
+
* App Check instances. The listeners call back on the UI thread whenever
|
|
124
|
+
* the current token associated with this App Check instance changes.
|
|
125
|
+
*
|
|
126
|
+
* @param appCheckInstance - The App Check instance.
|
|
127
|
+
* @param onNext - The callback function for token changes.
|
|
128
|
+
* @param onError - Optional error callback.
|
|
129
|
+
* @param onCompletion - Optional completion callback.
|
|
130
|
+
* @returns Unsubscribe
|
|
131
|
+
*/
|
|
132
|
+
export function onTokenChanged(
|
|
133
|
+
appCheckInstance: AppCheck,
|
|
134
|
+
onNext: (tokenResult: AppCheckListenerResult) => void,
|
|
135
|
+
onError?: (error: Error) => void,
|
|
136
|
+
onCompletion?: () => void,
|
|
137
|
+
): Unsubscribe;
|
|
138
|
+
|
|
139
|
+
export function onTokenChanged(
|
|
140
|
+
appCheckInstance: AppCheck,
|
|
141
|
+
onNextOrObserver:
|
|
142
|
+
| PartialObserver<AppCheckTokenResult>
|
|
143
|
+
| ((tokenResult: AppCheckListenerResult) => void),
|
|
144
|
+
onError?: (error: Error) => void,
|
|
145
|
+
onCompletion?: () => void,
|
|
146
|
+
): Unsubscribe {
|
|
147
|
+
return appCheckInstance.onTokenChanged.call(
|
|
148
|
+
appCheckInstance,
|
|
149
|
+
onNextOrObserver,
|
|
150
|
+
onError,
|
|
151
|
+
onCompletion,
|
|
152
|
+
// @ts-ignore - Extra arg used by deprecation proxy to detect modular calls
|
|
153
|
+
MODULAR_DEPRECATION_ARG,
|
|
154
|
+
) as Unsubscribe;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export { ReactNativeFirebaseAppCheckProvider };
|