@react-native-firebase/app-check 17.0.0 → 17.2.0

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 CHANGED
@@ -3,6 +3,22 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [17.2.0](https://github.com/invertase/react-native-firebase/compare/v17.1.0...v17.2.0) (2023-02-15)
7
+
8
+ ### Features
9
+
10
+ - **app, android:** firebase-android-sdk 31.2.0 ([87156e7](https://github.com/invertase/react-native-firebase/commit/87156e75e16775db14ef8f9bf6b0049b15ee1277))
11
+
12
+ ### Bug Fixes
13
+
14
+ - **app-check, ios:** debugToken in config on iOS works now ([04615e5](https://github.com/invertase/react-native-firebase/commit/04615e5568af549fb79d8b1ed59dbbce29ddb5f9))
15
+ - **app-check, types:** add `newReactNativeFirebaseAppCheckProvider` function type ([9f5f231](https://github.com/invertase/react-native-firebase/commit/9f5f231e06ebe3f75e553b898eef173395954ae8))
16
+ - **app-check:** better validation of configuration ([df60d83](https://github.com/invertase/react-native-firebase/commit/df60d834c897e55c7c62b4850be12a2a396ac21f))
17
+
18
+ ## [17.1.0](https://github.com/invertase/react-native-firebase/compare/v17.0.0...v17.1.0) (2023-02-09)
19
+
20
+ **Note:** Version bump only for package @react-native-firebase/app-check
21
+
6
22
  ## [17.0.0](https://github.com/invertase/react-native-firebase/compare/v16.7.0...v17.0.0) (2023-02-02)
7
23
 
8
24
  ### Features
@@ -20,4 +20,10 @@ describe('appCheck()', function () {
20
20
  );
21
21
  });
22
22
  });
23
+
24
+ describe('react-native-firebase provider', function () {
25
+ it('correctly creates a provider instance', function () {
26
+ expect(firebase.appCheck().newReactNativeFirebaseAppCheckProvider()).toBeDefined();
27
+ });
28
+ });
23
29
  });
@@ -18,15 +18,19 @@ package io.invertase.firebase.appcheck;
18
18
  */
19
19
 
20
20
  import android.util.Log;
21
+ import androidx.annotation.NonNull;
21
22
  import com.google.android.gms.tasks.Task;
22
23
  import com.google.firebase.FirebaseApp;
23
24
  import com.google.firebase.appcheck.AppCheckProvider;
24
- import com.google.firebase.appcheck.AppCheckProviderFactory;
25
25
  import com.google.firebase.appcheck.AppCheckToken;
26
26
  import com.google.firebase.appcheck.debug.DebugAppCheckProviderFactory;
27
+ import com.google.firebase.appcheck.debug.InternalDebugSecretProvider;
28
+ import com.google.firebase.appcheck.debug.internal.DebugAppCheckProvider;
27
29
  import com.google.firebase.appcheck.playintegrity.PlayIntegrityAppCheckProviderFactory;
28
30
  import com.google.firebase.appcheck.safetynet.SafetyNetAppCheckProviderFactory;
29
- import java.lang.reflect.Constructor;
31
+ import com.google.firebase.inject.Provider;
32
+ import java.util.concurrent.ExecutorService;
33
+ import java.util.concurrent.Executors;
30
34
 
31
35
  // Facade for all possible provider factory delegates,
32
36
  // configurable dynamically instead of at startup
@@ -35,6 +39,7 @@ public class ReactNativeFirebaseAppCheckProvider implements AppCheckProvider {
35
39
 
36
40
  AppCheckProvider delegateProvider;
37
41
 
42
+ @NonNull
38
43
  @Override
39
44
  public Task<AppCheckToken> getToken() {
40
45
  Log.d(LOGTAG, "Provider::getToken - delegating to native provider");
@@ -58,13 +63,25 @@ public class ReactNativeFirebaseAppCheckProvider implements AppCheckProvider {
58
63
 
59
64
  // the debug configuration may have a token, or may not
60
65
  if (debugToken != null) {
61
- // Create a debug provider using hidden factory constructor and our debug token
62
- Class<DebugAppCheckProviderFactory> debugACFactoryClass =
63
- DebugAppCheckProviderFactory.class;
64
- Class<?>[] argType = {String.class};
65
- Constructor c = debugACFactoryClass.getDeclaredConstructor(argType);
66
- Object[] cArgs = {debugToken};
67
- delegateProvider = ((AppCheckProviderFactory) c.newInstance(cArgs)).create(app);
66
+ // To use this token, create debug provider using local secret provider + standard thread
67
+ // pool
68
+ ExecutorService executor = Executors.newCachedThreadPool();
69
+ delegateProvider =
70
+ new DebugAppCheckProvider(
71
+ app,
72
+ new Provider<InternalDebugSecretProvider>() {
73
+ public InternalDebugSecretProvider get() {
74
+ return new InternalDebugSecretProvider() {
75
+ public String getDebugSecret() {
76
+ return debugToken;
77
+ }
78
+ };
79
+ }
80
+ },
81
+ executor,
82
+ executor,
83
+ executor);
84
+
68
85
  } else {
69
86
  delegateProvider = DebugAppCheckProviderFactory.getInstance().create(app);
70
87
  }
@@ -18,17 +18,17 @@ package io.invertase.firebase.appcheck;
18
18
  */
19
19
 
20
20
  import android.util.Log;
21
+ import androidx.annotation.NonNull;
21
22
  import com.google.firebase.FirebaseApp;
22
23
  import com.google.firebase.appcheck.AppCheckProvider;
23
24
  import com.google.firebase.appcheck.AppCheckProviderFactory;
24
25
  import java.util.HashMap;
25
- import java.util.Map;
26
26
 
27
27
  public class ReactNativeFirebaseAppCheckProviderFactory implements AppCheckProviderFactory {
28
28
  private static final String LOGTAG = "RNFBAppCheck";
29
29
 
30
30
  // This object has one job - create + maintain control over one provider per app
31
- public Map<String, ReactNativeFirebaseAppCheckProvider> providers = new HashMap();
31
+ public HashMap<String, ReactNativeFirebaseAppCheckProvider> providers = new HashMap<>();
32
32
 
33
33
  // Our provider will serve as a facade to all the supported native providers,
34
34
  // we will just pass through configuration calls to it
@@ -41,7 +41,7 @@ public class ReactNativeFirebaseAppCheckProviderFactory implements AppCheckProvi
41
41
  + providerName
42
42
  + (debugToken != null ? "/(not shown)" : "/null"));
43
43
 
44
- ReactNativeFirebaseAppCheckProvider provider = null;
44
+ ReactNativeFirebaseAppCheckProvider provider;
45
45
 
46
46
  // Look up the correct provider for the given appName, create it if not created
47
47
  provider = providers.get(appName);
@@ -52,6 +52,7 @@ public class ReactNativeFirebaseAppCheckProviderFactory implements AppCheckProvi
52
52
  provider.configure(appName, providerName, debugToken);
53
53
  }
54
54
 
55
+ @NonNull
55
56
  public AppCheckProvider create(FirebaseApp firebaseApp) {
56
57
  String appName = firebaseApp.getName();
57
58
  Log.d(LOGTAG, "ProviderFactory::create - fetching provider for app " + appName);
@@ -38,18 +38,14 @@
38
38
 
39
39
  // - determine if debugToken is provided via nullable arg
40
40
  if ([providerName isEqualToString:@"debug"]) {
41
- // TODO: Currently not handling debugToken argument, relying on existing environment
42
- // variable configuration style.
43
- // - maybe directly setting an environment variable could work?
44
- // https://stackoverflow.com/questions/27139589/whats-the-idiomatic-way-of-setting-an-environment-variable-in-objective-c-coco
45
- // - ...otherwise if env var does not work
46
- // - subclass style: RNFBAppCheckDebugProvider, and we should print local token
47
- // - if a debugToken parameter was supplied, set
48
- // RNFBAppCheckDebugProvider.configuredDebugToken
49
- // - print local token
50
- // https://github.com/firebase/firebase-ios-sdk/blob/c7e95996ff/FirebaseAppCheck/Sources/DebugProvider/FIRAppCheckDebugProviderFactory.m
51
- // - print if current token in provided by configuration, by environment variable, or local
52
- // token?
41
+ // The firebase-ios-sdk debug app check provider will take a token from environment if it
42
+ // exists:
43
+ if (debugToken != nil) {
44
+ // We have a debug token, so just need to stuff it in the environment and it will hook up
45
+ char *key = "FIRAAppCheckDebugToken", *value = [debugToken UTF8String];
46
+ int overwrite = 1;
47
+ setenv(key, value, overwrite);
48
+ }
53
49
 
54
50
  self.delegateProvider = [[FIRAppCheckDebugProvider new] initWithApp:app];
55
51
  }
package/lib/index.d.ts CHANGED
@@ -193,6 +193,11 @@ export namespace FirebaseAppCheckTypes {
193
193
  *
194
194
  */
195
195
  export class Module extends FirebaseModule {
196
+ /**
197
+ * create a ReactNativeFirebaseAppCheckProvider option for use in react-native-firebase
198
+ */
199
+ newReactNativeFirebaseAppCheckProvider(): ReactNativeFirebaseAppCheckProvider;
200
+
196
201
  /**
197
202
  * initialize the AppCheck module. Note that in react-native-firebase AppCheckOptions must always
198
203
  * be an object with a `provider` member containing `ReactNativeFirebaseAppCheckProvider` that has returned successfully
package/lib/index.js CHANGED
@@ -61,13 +61,26 @@ class FirebaseAppCheckModule extends FirebaseModule {
61
61
  }
62
62
  this.native.setTokenAutoRefreshEnabled(options.isTokenAutoRefreshEnabled);
63
63
 
64
+ if (options.provider === undefined || options.provider.providerOptions === undefined) {
65
+ throw new Error('Invalid configuration: no provider or no provider options defined.');
66
+ }
64
67
  if (Platform.OS === 'android') {
68
+ if (!isString(options.provider.providerOptions.android.provider)) {
69
+ throw new Error(
70
+ 'Invalid configuration: no android provider configured while on android platform.',
71
+ );
72
+ }
65
73
  return this.native.configureProvider(
66
74
  options.provider.providerOptions.android.provider,
67
75
  options.provider.providerOptions.android.debugToken,
68
76
  );
69
77
  }
70
78
  if (Platform.OS === 'ios' || Platform.OS === 'macos') {
79
+ if (!isString(options.provider.providerOptions.apple.provider)) {
80
+ throw new Error(
81
+ 'Invalid configuration: no apple provider configured while on apple platform.',
82
+ );
83
+ }
71
84
  return this.native.configureProvider(
72
85
  options.provider.providerOptions.apple.provider,
73
86
  options.provider.providerOptions.apple.debugToken,
package/lib/version.js CHANGED
@@ -1,2 +1,2 @@
1
1
  // Generated by genversion.
2
- module.exports = '17.0.0';
2
+ module.exports = '17.2.0';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-native-firebase/app-check",
3
- "version": "17.0.0",
3
+ "version": "17.2.0",
4
4
  "author": "Invertase <oss@invertase.io> (http://invertase.io)",
5
5
  "description": "React Native Firebase - App Check",
6
6
  "main": "lib/index.js",
@@ -23,10 +23,10 @@
23
23
  "appCheck"
24
24
  ],
25
25
  "peerDependencies": {
26
- "@react-native-firebase/app": "17.0.0"
26
+ "@react-native-firebase/app": "17.2.0"
27
27
  },
28
28
  "publishConfig": {
29
29
  "access": "public"
30
30
  },
31
- "gitHead": "53a436278f3c4cb23e1ddb7d2c9f14a65ce4abc1"
31
+ "gitHead": "57666670bd7fa4121a6598c639c4b2a24b9d181c"
32
32
  }