Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .spellcheck.dict.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ Fastlane
FCM
firebase
Firebase
FirebaseApp
firebase-ios-sdk
Firestore
getIdToken
Expand Down
3 changes: 2 additions & 1 deletion docs/app/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@ for manually initializing secondary Firebase app instances.

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

- [AppCheck](/app-check/usage).
- [App Check](/app-check/usage).
- [Authentication](/auth/usage).
- [Realtime Database](/database/usage).
- [Cloud Firestore](/firestore/usage).
- [Cloud Functions](/functions/usage)
- [Cloud Storage](/storage/usage).
- [ML](/ml/usage).
- [Installations](/installations/usage),
- [Remote Config](/remote-config/usage).

## Initializing secondary apps
Expand Down
2 changes: 1 addition & 1 deletion docs/in-app-messaging/usage/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: In App Messaging
description: Installation and getting started with In App Messaging.
icon: //static.invertase.io/assets/firebase/in-app-messaging.svg
next: /ml/usage
next: /installations/usage
previous: /dynamic-links/usage
---

Expand Down
37 changes: 37 additions & 0 deletions docs/installations/usage/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
title: Installations
description: Installation and getting started with Installations.
icon: //static.invertase.io/assets/social/firebase-logo.png
next: /ml/usage
previous: /in-app-messaging/usage
---

# Installation

This module requires that the `@react-native-firebase/app` module is already setup and installed. To install the "app"
module, view the [Getting Started](/) documentation.

```bash
# Install & setup the app module
yarn add @react-native-firebase/app

# Install the installations module
yarn add @react-native-firebase/installations

# If you're developing your app using iOS, run this command
cd ios/ && pod install
```

# What does it do

The Firebase installations service:

- provides a unique identifier for a Firebase installation
- provides an auth token for a Firebase installation
- provides an API to perform GDPR-compliant deletion of a Firebase installation.

Each configured `FirebaseApp` has a corresponding single instance of Installations. An instance of the class provides access to the installation info for the FirebaseApp as well as the ability to delete it. A Firebase Installation is unique by `FirebaseApp.name` and `FirebaseApp.options.googleAppID`

# Usage

Please see the API Reference for detailed usage information on the available APIs
2 changes: 1 addition & 1 deletion docs/ml/usage/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: ML
description: Installation and getting started with ML.
icon: //static.invertase.io/assets/firebase/ml-kit.svg
next: /remote-config/usage
previous: /in-app-messaging/usage
previous: /installations/usage
---

# Installation
Expand Down
4 changes: 4 additions & 0 deletions docs/sidebar.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@
- - - Usage
- '/in-app-messaging/usage'
- '//static.invertase.io/assets/firebase/in-app-messaging.svg'
- - Installations
- - - Usage
- '/installations/usage'
- '//static.invertase.io/assets/social/firebase-logo.png'
- - ML
- - - Usage
- '/ml/usage'
Expand Down
14 changes: 9 additions & 5 deletions packages/app-check/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,14 @@

---

AppCheck description.
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:

[> Learn More](https://firebase.google.com/products/app-check/)
- Requests originate from your authentic app
- Requests originate from an authentic, untampered device

This attestation is attached to every request your app makes to your Firebase backend resources.

[> Learn More](https://firebase.google.com/docs/app-check/)

## Installation

Expand All @@ -35,9 +40,8 @@ yarn add @react-native-firebase/app-check

## Documentation

- [Guides](#TODO)
- [Installation](#TODO)
- [Reference](#TODO)
- [Guides](https://rnfirebase.io/app-check/usage/)
- [Reference](https://rnfirebase.io/reference/app-check)

## License

Expand Down
15 changes: 14 additions & 1 deletion packages/app-check/e2e/appcheck.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,26 @@ describe('appCheck()', function () {
describe('getToken())', function () {
it('token fetch attempt should work', async function () {
// Our tests configure a debug provider with shared secret so we should get a valid token
const token = await firebase.appCheck().getToken(true);
const token = await firebase.appCheck().getToken();
token.should.not.equal('');
const decodedToken = jwt.decode(token);
decodedToken.aud[1].should.equal('projects/react-native-firebase-testing');
if (decodedToken.exp < Date.now()) {
Promise.reject('Token already expired');
}

// Force refresh should get a different token?
// TODO iOS tokens are stale because of https://github.com/firebase/firebase-ios-sdk/issues/8544
if (device.getPlatform() === 'android') {
const token2 = await firebase.appCheck().getToken(true);
token2.should.not.equal('');
const decodedToken2 = jwt.decode(token2);
decodedToken2.aud[1].should.equal('projects/react-native-firebase-testing');
if (decodedToken2.exp < Date.now()) {
Promise.reject('Token already expired');
}
(token === token2).should.be.false();
}
});
});
describe('activate())', function () {
Expand Down
3 changes: 2 additions & 1 deletion packages/app-check/ios/RNFBAppcheck/RNFBAppCheckModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ - (dispatch_queue_t)methodQueue {
: (RCTPromiseResolveBlock)resolve
: (RCTPromiseRejectBlock)reject) {
FIRAppCheck *appCheck = [FIRAppCheck appCheckWithApp:firebaseApp];
[appCheck tokenForcingRefresh:NO
[appCheck tokenForcingRefresh:NO // TODO Cannot use forceRefresh argument, if we send 'YES' in
// https://github.com/firebase/firebase-ios-sdk/issues/8544
completion:^(FIRAppCheckToken *_Nullable token, NSError *_Nullable error) {
if (error != nil) {
// Handle any errors if the token was not retrieved.
Expand Down
12 changes: 8 additions & 4 deletions packages/app-check/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,20 @@ class FirebaseAppCheckModule extends FirebaseModule {
}

getToken(forceRefresh) {
return this.native.getToken(forceRefresh);
if (!forceRefresh) {
return this.native.getToken(false);
} else {
return this.native.getToken(true);
}
}

onTokenChanged() {
// iOS does not provide any native listening feature
if (isIOS) {
return;
return () => {};
}
// TODO unimplemented on Android
return;
return () => {};
}
}

Expand All @@ -63,7 +67,7 @@ export default createModuleNamespace({
version,
namespace,
nativeModuleName,
nativeEvents: false, // TODO verify if this is interesting - token refresh listener perhaps?
nativeEvents: false, // TODO implement ['appcheck-token-changed'],
hasMultiAppSupport: true,
hasCustomUrlOrRegionSupport: false,
ModuleClass: FirebaseAppCheckModule,
Expand Down
1 change: 1 addition & 0 deletions packages/app/lib/internal/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const KNOWN_NAMESPACES = [
'crashlytics',
'database',
'inAppMessaging',
'installations',
'firestore',
'functions',
'indexing',
Expand Down
65 changes: 65 additions & 0 deletions packages/installations/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Built application files
android/*/build/

# Crashlytics configuations
android/com_crashlytics_export_strings.xml

# Local configuration file (sdk path, etc)
android/local.properties

# Gradle generated files
android/.gradle/

# Signing files
android/.signing/

# User-specific configurations
android/.idea/gradle.xml
android/.idea/libraries/
android/.idea/workspace.xml
android/.idea/tasks.xml
android/.idea/.name
android/.idea/compiler.xml
android/.idea/copyright/profiles_settings.xml
android/.idea/encodings.xml
android/.idea/misc.xml
android/.idea/modules.xml
android/.idea/scopes/scope_settings.xml
android/.idea/vcs.xml
android/*.iml

# Xcode
*.pbxuser
*.mode1v3
*.mode2v3
*.perspectivev3
*.xcuserstate
ios/Pods
ios/build
*project.xcworkspace*
*xcuserdata*

# OS-specific files
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.dbandroid/gradle
android/gradlew
android/build
android/gradlew.bat
android/gradle/

.idea
coverage
yarn.lock
e2e/
.github
.vscode
.nyc_output
android/.settings
*.coverage.json
.circleci
.eslintignore
32 changes: 32 additions & 0 deletions packages/installations/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
Apache-2.0 License
------------------

Copyright (c) 2016-present Invertase Limited <[email protected]> & Contributors

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this library except in compliance with the License.

You may obtain a copy of the Apache-2.0 License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.


Creative Commons Attribution 3.0 License
----------------------------------------

Copyright (c) 2016-present Invertase Limited <[email protected]> & Contributors

Documentation and other instructional materials provided for this project
(including on a separate documentation repository or it's documentation website) are
licensed under the Creative Commons Attribution 3.0 License. Code samples/blocks
contained therein are licensed under the Apache License, Version 2.0 (the "License"), as above.

You may obtain a copy of the Creative Commons Attribution 3.0 License at

https://creativecommons.org/licenses/by/3.0/
61 changes: 61 additions & 0 deletions packages/installations/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<p align="center">
<a href="https://rnfirebase.io">
<img width="160px" src="https://i.imgur.com/JIyBtKW.png"><br/>
</a>
<h2 align="center">React Native Firebase - Installations</h2>
</p>

<p align="center">
<a href="https://api.rnfirebase.io/coverage/installations/detail"><img src="https://api.rnfirebase.io/coverage/installations/badge?style=flat-square" alt="Coverage"></a>
<a href="https://www.npmjs.com/package/@react-native-firebase/installations"><img src="https://img.shields.io/npm/dm/@react-native-firebase/installations.svg?style=flat-square" alt="NPM downloads"></a>
<a href="https://www.npmjs.com/package/@react-native-firebase/installations"><img src="https://img.shields.io/npm/v/@react-native-firebase/installations.svg?style=flat-square" alt="NPM version"></a>
<a href="/LICENSE"><img src="https://img.shields.io/npm/l/react-native-firebase.svg?style=flat-square" alt="License"></a>
<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>
</p>

<p align="center">
<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>
<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>
<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>
</p>

----

Entry point for Firebase installations.

The Firebase installations service:

- provides a unique identifier for a Firebase installation
- provides an auth token for a Firebase installation
- provides a API to perform GDPR-compliant deletion of a Firebase installation.


[> Learn More](https://firebase.google.com/docs/projects/manage-installations)

## Installation

Requires `@react-native-firebase/app` to be installed.

```bash
yarn add @react-native-firebase/installations
```

## Documentation

- [Guides](https://rnfirebase.io/installations/usage/)
- [Reference](https://rnfirebase.io/reference/installations)

## License

- See [LICENSE](/LICENSE)

----

<p>
<img align="left" width="75px" src="https://static.invertase.io/assets/invertase-logo-small.png">
<p align="left">
Built and maintained with 💛 by <a href="https://invertase.io">Invertase</a>.
</p>
</p>

----
Loading