Skip to content

Commit 8cd4fa3

Browse files
committed
feat(app-check): implement AppCheck module
1 parent 8d14b21 commit 8cd4fa3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+2001
-34
lines changed

.spellcheck.dict.txt

+8
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ Analytics
66
analytics
77
APIs
88
APIs.
9+
AppAttest
10+
AppCheck
911
APNs
1012
AirPods
1113
async
@@ -42,7 +44,9 @@ Deprecations
4244
Detox
4345
DEVEX
4446
Diarmid
47+
DeviceCheck
4548
dropdown
49+
e2e
4650
EEA
4751
Ehesp
4852
enum
@@ -55,6 +59,7 @@ firebase-ios-sdk
5559
Firestore
5660
getIdToken
5761
GDPR
62+
GDPR-compliant
5863
globals
5964
Gradle
6065
gradle
@@ -90,6 +95,7 @@ namespaced
9095
natively
9196
NDK
9297
Node.js
98+
non-firebase
9399
NoSQL
94100
Notifee
95101
NPE
@@ -121,6 +127,7 @@ RN60
121127
RN61
122128
RNFB
123129
RNFirebase
130+
SafetyNet
124131
Salakar
125132
scalable
126133
scrollable
@@ -150,6 +157,7 @@ uid
150157
uncomment
151158
unhandled
152159
unsubscriber
160+
untampered
153161
utils
154162
Utils
155163
v5

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ The main package that you interface with is `App` (`@react-native-firebase/app`)
4444
| -------------------------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
4545
| [Analytics](/packages/analytics) | [![badge](https://img.shields.io/npm/dm/@react-native-firebase/analytics.svg?style=for-the-badge&logo=npm)](https://www.npmjs.com/package/@react-native-firebase/analytics) |
4646
| [App](/packages/app) | [![badge](https://img.shields.io/npm/dm/@react-native-firebase/app.svg?style=for-the-badge&logo=npm)](https://www.npmjs.com/package/@react-native-firebase/app) |
47+
| [AppCheck](/packages/app-check) | [![badge](https://img.shields.io/npm/dm/@react-native-firebase/app-check.svg?style=for-the-badge&logo=npm)](https://www.npmjs.com/package/@react-native-firebase/app-check) |
4748
| [Authentication](/packages/auth) | [![badge](https://img.shields.io/npm/dm/@react-native-firebase/auth.svg?style=for-the-badge&logo=npm)](https://www.npmjs.com/package/@react-native-firebase/auth) |
4849
| [Cloud Firestore](/packages/firestore) | [![badge](https://img.shields.io/npm/dm/@react-native-firebase/firestore.svg?style=for-the-badge&logo=npm)](https://www.npmjs.com/package/@react-native-firebase/firestore) |
4950
| [Cloud Functions](/packages/functions) | [![badge](https://img.shields.io/npm/dm/@react-native-firebase/functions.svg?style=for-the-badge&logo=npm)](https://www.npmjs.com/package/@react-native-firebase/functions) |

docs/analytics/screen-tracking.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Screen Tracking
33
description: Setup Firebase Analytics to track your in-app screen flow.
44
previous: /analytics/usage
5-
next: /
5+
next: /app-check/usage
66
---
77

88
Standard React Native applications run inside a single `Activity`/`ViewController`, meaning any screen changes won't be

docs/app-check/usage/index.md

+94
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
---
2+
title: App Check
3+
description: Installation and getting started with App Check.
4+
icon: //static.invertase.io/assets/social/firebase-logo.png
5+
next: /auth/usage
6+
previous: /analytics/screen-tracking
7+
---
8+
9+
# Installation
10+
11+
This module requires that the `@react-native-firebase/app` module is already setup and installed. To install the "app"
12+
module, view the [Getting Started](/) documentation.
13+
14+
```bash
15+
# Install & setup the app module
16+
yarn add @react-native-firebase/app
17+
18+
# Install the app-check module
19+
yarn add @react-native-firebase/app-check
20+
21+
# If you're developing your app using iOS, run this command
22+
cd ios/ && pod install
23+
```
24+
25+
App Check requires you set the minimum iOS Deployment version in `ios/Podfile` to `11.0` or greater.
26+
27+
You may have Xcode compiler errors after including the App Check module, specifically referencing linker problems and missing directories.
28+
29+
You may find excluding the `i386` architecture via an addition to the `ios/Podfile` `post_install` hook like the below works:
30+
31+
```ruby
32+
installer.aggregate_targets.each do |aggregate_target|
33+
aggregate_target.user_project.native_targets.each do |target|
34+
target.build_configurations.each do |config|
35+
config.build_settings['ONLY_ACTIVE_ARCH'] = 'NO'
36+
config.build_settings['EXCLUDED_ARCHS'] = 'i386'
37+
end
38+
end
39+
aggregate_target.user_project.save
40+
end
41+
```
42+
43+
# What does it do
44+
45+
App Check works alongside other Firebase services to help protect your backend resources from abuse, such as billing fraud or phishing. With App Check, devices running your app will use an app or device attestation provider that attests to one or both of the following:
46+
47+
- Requests originate from your authentic app
48+
- Requests originate from an authentic, untampered device
49+
50+
This attestation is attached to every request your app makes to your Firebase backend resources.
51+
52+
<Youtube id="Fjj4fmr2t04" />
53+
54+
This App Check module has built-in support for using the following services as attestation providers:
55+
56+
- DeviceCheck on iOS
57+
- SafetyNet on Android
58+
59+
App Check currently works with the following Firebase products:
60+
61+
- Realtime Database
62+
- Cloud Storage
63+
- Cloud Functions (callable functions)
64+
65+
The [official Firebase App Check documentation](https://firebase.google.com/docs/app-check) has more information, including about the iOS AppAttest provider, and testing/ CI integration, it is worth a read.
66+
67+
# Usage
68+
69+
## Activate
70+
71+
On iOS if you include the App Check package, it is activated by default. The only configuration possible is the token auto refresh. When you call activate, the provider (DeviceCheck by default) stays the same but the token auto refresh setting will be changed based on the argument provided.
72+
73+
On Android, App Check is not activated until you call the activate method. The provider is not configurable here either but if your app is "debuggable", then the Debug app check provider will be installed, otherwise the SafetyNet provider will be installed.
74+
75+
You must call activate prior to calling any firebase back-end services for App Check to function.
76+
77+
## Automatic Data Collection
78+
79+
App Check has an "tokenAutoRefreshEnabled" setting. This may cause App Check to attempt a remote App Check token fetch prior to user consent. In certain scenarios, like those that exist in GDPR-compliant apps running for the first time, this may be unwanted.
80+
81+
If unset, the "tokenAutoRefreshEnabled" setting will defer to the app's "automatic data collection" setting, which may be set in the Info.plist or AndroidManifest.xml
82+
83+
## Using App Check tokens for non-firebase services
84+
85+
The [official documentation](https://firebase.google.com/docs/app-check/web/custom-resource) shows how to use `getToken` to access the current App Check token and then verify it in external services.
86+
87+
## Testing Environments / CI
88+
89+
App Check may be used in CI environments by following the upstream documentation to configure a debug token shared with your app in the CI environment.
90+
91+
In certain react-native testing scenarios it may be difficult to access the shared secret, but the react-native-firebase testing app for e2e testing does successfully fetch App Check tokens via:
92+
93+
- including the App Check debug test helper in the test app, along with a change to `DetoxTest` for Android
94+
- by setting an environment variable and initializing the debug provider before firebase configure in `AppDelegate.m` for iOS.

docs/app/usage.md

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ for manually initializing secondary Firebase app instances.
2121

2222
Currently, the native Firebase SDKs only provide functionality for creating secondary apps on the following services:
2323

24+
- [AppCheck](/app-check/usage).
2425
- [Authentication](/auth/usage).
2526
- [Realtime Database](/database/usage).
2627
- [Cloud Firestore](/firestore/usage).

docs/auth/usage/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Authentication
33
description: Installation and getting started with Authentication.
44
icon: //static.invertase.io/assets/firebase/authentication.svg
55
next: /auth/social-auth
6-
previous: /analytics/screen-tracking
6+
previous: /app-check/usage
77
---
88

99
# Installation

docs/releases/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ From version `v6.5.0` until `10.0.0`; all React Native Firebase packages were in
1515

1616
| Package | | |
1717
| ---------------------- | :------------------------------------------------------------------------------------------------------------------: | :---------------------------------------------------------------------------------------------------------------------------------: |
18-
| AdMob | ![hide:badge](https://img.shields.io/npm/v/@react-native-firebase/admob.svg?style=for-the-badge&logo=npm) | [View Release Notes &raquo;](https://github.com/invertase/react-native-firebase/tree/master/packages/admob/CHANGELOG.md) |
1918
| Analytics | ![hide:badge](https://img.shields.io/npm/v/@react-native-firebase/analytics.svg?style=for-the-badge&logo=npm) | [View Release Notes &raquo;](https://github.com/invertase/react-native-firebase/tree/master/packages/analytics/CHANGELOG.md) |
2019
| App | ![hide:badge](https://img.shields.io/npm/v/@react-native-firebase/app.svg?style=for-the-badge&logo=npm) | [View Release Notes &raquo;](https://github.com/invertase/react-native-firebase/tree/master/packages/app/CHANGELOG.md) |
20+
| AppCheck | ![hide:badge](https://img.shields.io/npm/v/@react-native-firebase/app-check.svg?style=for-the-badge&logo=npm) | [View Release Notes &raquo;](https://github.com/invertase/react-native-firebase/tree/master/packages/app-check/CHANGELOG.md) |
2121
| Authentication | ![hide:badge](https://img.shields.io/npm/v/@react-native-firebase/auth.svg?style=for-the-badge&logo=npm) | [View Release Notes &raquo;](https://github.com/invertase/react-native-firebase/tree/master/packages/auth/CHANGELOG.md) |
2222
| Cloud Firestore | ![hide:badge](https://img.shields.io/npm/v/@react-native-firebase/firestore.svg?style=for-the-badge&logo=npm) | [View Release Notes &raquo;](https://github.com/invertase/react-native-firebase/tree/master/packages/firestore/CHANGELOG.md) |
2323
| Cloud Functions | ![hide:badge](https://img.shields.io/npm/v/@react-native-firebase/functions.svg?style=for-the-badge&logo=npm) | [View Release Notes &raquo;](https://github.com/invertase/react-native-firebase/tree/master/packages/functions/CHANGELOG.md) |

docs/sidebar.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
- - Building an Analytics Funnel
2424
- 'https://blog.theodo.com/2018/01/building-google-analytics-funnel-firebase-react-native'
2525
- '//static.invertase.io/assets/firebase/analytics.svg'
26+
- - App Check
27+
- - - Usage
28+
- '/app-check/usage'
29+
- '//static.invertase.io/assets/social/firebase-logo.png'
2630
- - Authentication
2731
- - - Usage
2832
- '/auth/usage'

package.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@
3434
"tests:android:test:jacoco-report": "cd tests/android && ./gradlew jacocoAndroidTestReport",
3535
"tests:ios:build": "cd tests && ./node_modules/.bin/detox build --configuration ios.sim.debug",
3636
"tests:ios:build-release": "cd tests && ./node_modules/.bin/detox build --configuration ios.sim.release",
37-
"tests:ios:test": "cd tests && ./node_modules/.bin/detox test --configuration ios.sim.debug --loglevel warn",
38-
"tests:ios:test:debug": "cd tests && ./node_modules/.bin/detox test --configuration ios.sim.debug --loglevel warn --inspect",
39-
"tests:ios:test-reuse": "cd tests && ./node_modules/.bin/detox test --configuration ios.sim.debug --reuse --loglevel warn",
40-
"tests:ios:test-cover": "cd tests && ./node_modules/.bin/nyc ./node_modules/.bin/detox test --configuration ios.sim.debug --loglevel warn",
41-
"tests:ios:test-cover-reuse": "cd tests && node_modules/.bin/nyc ./node_modules/.bin/detox test --configuration ios.sim.debug --reuse --loglevel warn",
37+
"tests:ios:test": "cd tests && SIMCTL_CHILD_FIRAAppCheckDebugToken=698956B2-187B-49C6-9E25-C3F3530EEBAF ./node_modules/.bin/detox test --configuration ios.sim.debug --loglevel warn",
38+
"tests:ios:test:debug": "cd tests && SIMCTL_CHILD_FIRAAppCheckDebugToken=698956B2-187B-49C6-9E25-C3F3530EEBAF ./node_modules/.bin/detox test --configuration ios.sim.debug --loglevel warn --inspect",
39+
"tests:ios:test-reuse": "cd tests && SIMCTL_CHILD_FIRAAppCheckDebugToken=\"698956B2-187B-49C6-9E25-C3F3530EEBAF\" ./node_modules/.bin/detox test --configuration ios.sim.debug --reuse --loglevel warn",
40+
"tests:ios:test-cover": "cd tests && SIMCTL_CHILD_FIRAAppCheckDebugToken=698956B2-187B-49C6-9E25-C3F3530EEBAF ./node_modules/.bin/nyc ./node_modules/.bin/detox test --configuration ios.sim.debug --loglevel warn",
41+
"tests:ios:test-cover-reuse": "cd tests && SIMCTL_CHILD_FIRAAppCheckDebugToken=698956B2-187B-49C6-9E25-C3F3530EEBAF node_modules/.bin/nyc ./node_modules/.bin/detox test --configuration ios.sim.debug --reuse --loglevel warn",
4242
"tests:ios:pod:install": "cd tests && cd ios && rm -rf ReactNativeFirebaseDemo.xcworkspace && rm -f Podfile.lock && pod install --repo-update && cd ..",
4343
"format:markdown": "prettier --write \"docs/**/*.md\""
4444
},

packages/app-check/.npmignore

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Built application files
2+
android/*/build/
3+
4+
# Crashlytics configuations
5+
android/com_crashlytics_export_strings.xml
6+
7+
# Local configuration file (sdk path, etc)
8+
android/local.properties
9+
10+
# Gradle generated files
11+
android/.gradle/
12+
13+
# Signing files
14+
android/.signing/
15+
16+
# User-specific configurations
17+
android/.idea/gradle.xml
18+
android/.idea/libraries/
19+
android/.idea/workspace.xml
20+
android/.idea/tasks.xml
21+
android/.idea/.name
22+
android/.idea/compiler.xml
23+
android/.idea/copyright/profiles_settings.xml
24+
android/.idea/encodings.xml
25+
android/.idea/misc.xml
26+
android/.idea/modules.xml
27+
android/.idea/scopes/scope_settings.xml
28+
android/.idea/vcs.xml
29+
android/*.iml
30+
31+
# Xcode
32+
*.pbxuser
33+
*.mode1v3
34+
*.mode2v3
35+
*.perspectivev3
36+
*.xcuserstate
37+
ios/Pods
38+
ios/build
39+
*project.xcworkspace*
40+
*xcuserdata*
41+
42+
# OS-specific files
43+
.DS_Store
44+
.DS_Store?
45+
._*
46+
.Spotlight-V100
47+
.Trashes
48+
ehthumbs.db
49+
Thumbs.dbandroid/gradle
50+
android/gradlew
51+
android/build
52+
android/gradlew.bat
53+
android/gradle/
54+
55+
.idea
56+
coverage
57+
yarn.lock
58+
e2e/
59+
.github
60+
.vscode
61+
.nyc_output
62+
android/.settings
63+
*.coverage.json
64+
.circleci
65+
.eslintignore

packages/app-check/LICENSE

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
Apache-2.0 License
2+
------------------
3+
4+
Copyright (c) 2016-present Invertase Limited <[email protected]> & Contributors
5+
6+
Licensed under the Apache License, Version 2.0 (the "License");
7+
you may not use this library except in compliance with the License.
8+
9+
You may obtain a copy of the Apache-2.0 License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing, software
14+
distributed under the License is distributed on an "AS IS" BASIS,
15+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
See the License for the specific language governing permissions and
17+
limitations under the License.
18+
19+
20+
Creative Commons Attribution 3.0 License
21+
----------------------------------------
22+
23+
Copyright (c) 2016-present Invertase Limited <[email protected]> & Contributors
24+
25+
Documentation and other instructional materials provided for this project
26+
(including on a separate documentation repository or it's documentation website) are
27+
licensed under the Creative Commons Attribution 3.0 License. Code samples/blocks
28+
contained therein are licensed under the Apache License, Version 2.0 (the "License"), as above.
29+
30+
You may obtain a copy of the Creative Commons Attribution 3.0 License at
31+
32+
https://creativecommons.org/licenses/by/3.0/

packages/app-check/README.md

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<p align="center">
2+
<a href="https://rnfirebase.io">
3+
<img width="160px" src="https://i.imgur.com/JIyBtKW.png"><br/>
4+
</a>
5+
<h2 align="center">React Native Firebase - AppCheck</h2>
6+
</p>
7+
8+
<p align="center">
9+
<a href="https://api.rnfirebase.io/coverage/app-check/detail"><img src="https://api.rnfirebase.io/coverage/app-check/badge?style=flat-square" alt="Coverage"></a>
10+
<a href="https://www.npmjs.com/package/@react-native-firebase/app-check"><img src="https://img.shields.io/npm/dm/@react-native-firebase/app-check.svg?style=flat-square" alt="NPM downloads"></a>
11+
<a href="https://www.npmjs.com/package/@react-native-firebase/app-check"><img src="https://img.shields.io/npm/v/@react-native-firebase/app-check.svg?style=flat-square" alt="NPM version"></a>
12+
<a href="/LICENSE"><img src="https://img.shields.io/npm/l/react-native-firebase.svg?style=flat-square" alt="License"></a>
13+
<a href="https://lerna.js.org/"><img src="https://img.shields.io/badge/maintained%20with-lerna-cc00ff.svg?style=flat-square" alt="Maintained with Lerna"></a>
14+
</p>
15+
16+
<p align="center">
17+
<a href="https://invertase.link/discord"><img src="https://img.shields.io/discord/295953187817521152.svg?style=flat-square&colorA=7289da&label=Chat%20on%20Discord" alt="Chat on Discord"></a>
18+
<a href="https://twitter.com/rnfirebase"><img src="https://img.shields.io/twitter/follow/rnfirebase.svg?style=flat-square&colorA=1da1f2&colorB=&label=Follow%20on%20Twitter" alt="Follow on Twitter"></a>
19+
<a href="https://www.facebook.com/groups/rnfirebase"><img src="https://img.shields.io/badge/Follow%20on%20Facebook-4172B8?logo=facebook&style=flat-square&logoColor=fff" alt="Follow on Facebook"></a>
20+
</p>
21+
22+
---
23+
24+
AppCheck description.
25+
26+
[> Learn More](https://firebase.google.com/products/app-check/)
27+
28+
## Installation
29+
30+
Requires `@react-native-firebase/app` to be installed.
31+
32+
```bash
33+
yarn add @react-native-firebase/app-check
34+
```
35+
36+
## Documentation
37+
38+
- [Guides](#TODO)
39+
- [Installation](#TODO)
40+
- [Reference](#TODO)
41+
42+
## License
43+
44+
- See [LICENSE](/LICENSE)
45+
46+
---
47+
48+
<p>
49+
<img align="left" width="75px" src="https://static.invertase.io/assets/invertase-logo-small.png">
50+
<p align="left">
51+
Built and maintained with 💛 by <a href="https://invertase.io">Invertase</a>.
52+
</p>
53+
</p>
54+
55+
---

0 commit comments

Comments
 (0)