Skip to content

Commit 408df2d

Browse files
committed
feat(app-check): implement AppCheck module
1 parent b710657 commit 408df2d

35 files changed

+1879
-30
lines changed

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+
---
+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
require 'json'
2+
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
3+
appPackage = JSON.parse(File.read(File.join('..', 'app', 'package.json')))
4+
5+
coreVersionDetected = appPackage['version']
6+
coreVersionRequired = package['peerDependencies'][appPackage['name']]
7+
firebase_sdk_version = appPackage['sdkVersions']['ios']['firebase']
8+
if coreVersionDetected != coreVersionRequired
9+
Pod::UI.warn "NPM package '#{package['name']}' depends on '#{appPackage['name']}' v#{coreVersionRequired} but found v#{coreVersionDetected}, this might cause build issues or runtime crashes."
10+
end
11+
12+
Pod::Spec.new do |s|
13+
s.name = "RNFBAppCheck"
14+
s.version = package["version"]
15+
s.description = package["description"]
16+
s.summary = <<-DESC
17+
A well tested feature rich Firebase implementation for React Native, supporting iOS & Android.
18+
DESC
19+
s.homepage = "http://invertase.io/oss/react-native-firebase"
20+
s.license = package['license']
21+
s.authors = "Invertase Limited"
22+
s.source = { :git => "https://github.com/invertase/react-native-firebase.git", :tag => "v#{s.version}" }
23+
s.social_media_url = 'http://twitter.com/invertaseio'
24+
s.ios.deployment_target = "11.0"
25+
s.source_files = 'ios/**/*.{h,m}'
26+
27+
# React Native dependencies
28+
s.dependency 'React-Core'
29+
s.dependency 'RNFBApp'
30+
31+
if defined?($FirebaseSDKVersion)
32+
Pod::UI.puts "#{s.name}: Using user specified Firebase SDK version '#{$FirebaseSDKVersion}'"
33+
firebase_sdk_version = $FirebaseSDKVersion
34+
end
35+
36+
# Firebase dependencies
37+
s.dependency 'Firebase/AppCheck', firebase_sdk_version
38+
39+
if defined?($RNFirebaseAsStaticFramework)
40+
Pod::UI.puts "#{s.name}: Using overridden static_framework value of '#{$RNFirebaseAsStaticFramework}'"
41+
s.static_framework = $RNFirebaseAsStaticFramework
42+
else
43+
s.static_framework = false
44+
end
45+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { firebase } from '../lib';
2+
3+
describe('appCheck()', function () {
4+
describe('namespace', function () {
5+
it('accessible from firebase.app()', function () {
6+
const app = firebase.app();
7+
expect(app.appCheck).toBeDefined();
8+
expect(app.appCheck().app).toEqual(app);
9+
});
10+
11+
// disabled as pending if module.options.hasMultiAppSupport = true
12+
xit('supports multiple apps', async function () {
13+
expect(firebase.appCheck().app.name).toEqual('[DEFAULT]');
14+
expect(firebase.appCheck(firebase.app('secondaryFromNative')).app.name).toEqual(
15+
'secondaryFromNative',
16+
);
17+
expect(firebase.app('secondaryFromNative').appCheck().app.name).toEqual(
18+
'secondaryFromNative',
19+
);
20+
});
21+
});
22+
});
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# editorconfig
2+
root = true
3+
4+
[*]
5+
indent_style = space
6+
indent_size = 2
7+
end_of_line = lf
8+
charset = utf-8
9+
trim_trailing_whitespace = true
10+
insert_final_newline = true
+101
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
import io.invertase.gradle.common.PackageJson
2+
3+
buildscript {
4+
// The Android Gradle plugin is only required when opening the android folder stand-alone.
5+
// This avoids unnecessary downloads and potential conflicts when the library is included as a
6+
// module dependency in an application project.
7+
if (project == rootProject) {
8+
repositories {
9+
google()
10+
mavenCentral()
11+
}
12+
13+
dependencies {
14+
classpath('com.android.tools.build:gradle:7.0.0')
15+
}
16+
}
17+
}
18+
19+
plugins {
20+
id 'io.invertase.gradle.build' version '1.5'
21+
}
22+
23+
def appProject
24+
if (findProject(':@react-native-firebase_app')) {
25+
appProject = project(':@react-native-firebase_app')
26+
} else if (findProject(':react-native-firebase_app')) {
27+
appProject = project(':react-native-firebase_app')
28+
} else {
29+
throw new GradleException('Could not find the react-native-firebase/app package, have you installed it?')
30+
}
31+
def packageJson = PackageJson.getForProject(project)
32+
def appPackageJson = PackageJson.getForProject(appProject)
33+
def firebaseBomVersion = appPackageJson['sdkVersions']['android']['firebase']
34+
def jsonMinSdk = appPackageJson['sdkVersions']['android']['minSdk']
35+
def jsonTargetSdk = appPackageJson['sdkVersions']['android']['targetSdk']
36+
def jsonCompileSdk = appPackageJson['sdkVersions']['android']['compileSdk']
37+
def jsonBuildTools = appPackageJson['sdkVersions']['android']['buildTools']
38+
def coreVersionDetected = appPackageJson['version']
39+
def coreVersionRequired = packageJson['peerDependencies'][appPackageJson['name']]
40+
// Only log after build completed so log warning appears at the end
41+
if (coreVersionDetected != coreVersionRequired) {
42+
gradle.buildFinished {
43+
project.logger.warn("ReactNativeFirebase WARNING: NPM package '${packageJson['name']}' depends on '${appPackageJson['name']}' v${coreVersionRequired} but found v${coreVersionDetected}, this might cause build issues or runtime crashes.")
44+
}
45+
}
46+
47+
project.ext {
48+
set('react-native', [
49+
versions: [
50+
android : [
51+
minSdk : jsonMinSdk,
52+
targetSdk : jsonTargetSdk,
53+
compileSdk: jsonCompileSdk,
54+
// optional as gradle.buildTools comes with one by default
55+
// overriding here though to match the version RN uses
56+
buildTools: jsonBuildTools
57+
],
58+
59+
firebase: [
60+
bom: firebaseBomVersion,
61+
],
62+
],
63+
])
64+
}
65+
66+
android {
67+
defaultConfig {
68+
multiDexEnabled true
69+
}
70+
lintOptions {
71+
disable 'GradleCompatible'
72+
abortOnError false
73+
}
74+
compileOptions {
75+
sourceCompatibility JavaVersion.VERSION_1_8
76+
targetCompatibility JavaVersion.VERSION_1_8
77+
}
78+
sourceSets {
79+
main {
80+
java.srcDirs = ['src/main/java', 'src/reactnative/java']
81+
}
82+
}
83+
}
84+
85+
repositories {
86+
google()
87+
mavenCentral()
88+
}
89+
90+
dependencies {
91+
api appProject
92+
implementation platform("com.google.firebase:firebase-bom:${ReactNative.ext.getVersion('firebase', 'bom')}")
93+
// These are beta, so they are not in the BoM yet. We have to specify the versions explicitly.
94+
implementation 'com.google.firebase:firebase-appcheck-safetynet:16.0.0-beta02'
95+
debugImplementation 'com.google.firebase:firebase-appcheck-debug:16.0.0-beta02'
96+
}
97+
98+
ReactNative.shared.applyPackageVersion()
99+
ReactNative.shared.applyDefaultExcludes()
100+
ReactNative.module.applyAndroidVersions()
101+
ReactNative.module.applyReactNativeDependency('api')

packages/app-check/android/lint.xml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<lint>
3+
<!-- Disable the given check in this project -->
4+
<issue id="GradleCompatible" severity="ignore" />
5+
</lint>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
rootProject.name = '@react-native-firebase_appCheck'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="io.invertase.firebase.appcheck">
3+
4+
<uses-permission android:name="android.permission.INTERNET" />
5+
<uses-permission android:name="android.permission.WAKE_LOCK" />
6+
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
7+
</manifest>

0 commit comments

Comments
 (0)