@react-native-firebase/app-check 26.4.0 → 27.1.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 +20 -0
- package/RNFBAppCheck.podspec +8 -2
- package/android/build.gradle +3 -0
- package/android/src/main/java/io/invertase/firebase/appcheck/RNFBAppCheckListenerRegistry.kt +72 -0
- package/dist/module/index.js +1 -2
- package/dist/module/index.js.map +1 -1
- package/dist/module/version.js +1 -1
- package/dist/typescript/lib/index.d.ts +1 -1
- package/dist/typescript/lib/index.d.ts.map +1 -1
- package/dist/typescript/lib/version.d.ts +1 -1
- package/ios/RNFBAppCheck/RNFBAppCheckHelper.h +61 -0
- package/ios/RNFBAppCheck/RNFBAppCheckHelper.m +213 -0
- package/ios/RNFBAppCheck/RNFBAppCheckModule.mm +22 -155
- package/ios/RNFBAppCheck/RNFBAppCheckRejectCodeMapper.swift +50 -0
- package/ios/RNFBAppCheck.xcodeproj/project.pbxproj +14 -0
- package/ios/RNFBAppCheckUnitTests/HostStubs/Firebase/FIRAppCheckHostStub.m +109 -0
- package/ios/RNFBAppCheckUnitTests/HostStubs/Firebase/Firebase.h +47 -0
- package/ios/RNFBAppCheckUnitTests/HostStubs/RNFBApp/RCTConvert+FIRApp.h +13 -0
- package/ios/RNFBAppCheckUnitTests/HostStubs/RNFBApp/RCTConvert+FIRAppHostStub.m +27 -0
- package/ios/RNFBAppCheckUnitTests/HostStubs/RNFBApp/RNFBSharedUtils.h +18 -0
- package/ios/RNFBAppCheckUnitTests/HostStubs/RNFBApp/RNFBSharedUtilsHostStub.m +18 -0
- package/ios/RNFBAppCheckUnitTests/HostStubs/RNFBAppCheck/RNFBAppCheckProviderHostStub.m +48 -0
- package/ios/RNFBAppCheckUnitTests/HostStubs/React/RCTBridgeModule.h +10 -0
- package/ios/RNFBAppCheckUnitTests/RNFBAppCheckHelperHostStubTests.m +197 -0
- package/ios/RNFBAppCheckUnitTests/RNFBAppCheckRejectCodeMapperTests.swift +85 -0
- package/ios/RNFBAppCheckUnitTests/RNFBAppCheckUnitTests.xcodeproj/project.pbxproj +277 -0
- package/ios/RNFBAppCheckUnitTests/RNFBAppCheckUnitTests.xcodeproj/xcshareddata/xcschemes/RNFBAppCheckUnitTests.xcscheme +69 -0
- package/lib/index.ts +1 -1
- package/lib/version.ts +1 -1
- package/package.json +4 -4
- package/plugin/build/ios/appDelegate.js +12 -13
- package/plugin/src/ios/appDelegate.ts +13 -14
- package/android/src/main/java/io/invertase/firebase/appcheck/RNFBAppCheckListenerRegistry.java +0 -76
|
@@ -112,21 +112,20 @@ function modifySwiftAppDelegate(contents) {
|
|
|
112
112
|
if (contents.includes('RNFBAppCheckModule.sharedInstance()')) {
|
|
113
113
|
return contents;
|
|
114
114
|
}
|
|
115
|
-
//
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
RNFBAppCheckModule.sharedInstance()
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
//
|
|
125
|
-
//
|
|
126
|
-
// (AppCheck-AD-3); do not reverse this order.
|
|
115
|
+
// App plugin (or an earlier pass) already calls configure. The provider factory must
|
|
116
|
+
// run before that call. Do not append a second FirebaseApp.configure().
|
|
117
|
+
const existingConfigure = /^([ \t]*)FirebaseApp\.configure\(\)/m.exec(contents);
|
|
118
|
+
if (existingConfigure) {
|
|
119
|
+
const indent = existingConfigure[1];
|
|
120
|
+
return contents.replace(existingConfigure[0], `${indent}RNFBAppCheckModule.sharedInstance()\n${existingConfigure[0]}`);
|
|
121
|
+
}
|
|
122
|
+
// No configure yet. Register the factory, then configure. Firebase requires the
|
|
123
|
+
// factory before configure (AppCheck-AD-3). Expo 58 scene AppDelegates start
|
|
124
|
+
// React Native from SceneDelegate, so the anchor is the didFinishLaunching return
|
|
125
|
+
// rather than factory.startReactNative.
|
|
127
126
|
const methodInvocationBlock = `RNFBAppCheckModule.sharedInstance()
|
|
128
127
|
FirebaseApp.configure()`;
|
|
129
|
-
const methodInvocationLineMatcher = /(?:factory\.startReactNative\()/;
|
|
128
|
+
const methodInvocationLineMatcher = /(?:factory\.startReactNative\()|(?:return\s+super\.application\(\s*application\s*,\s*didFinishLaunchingWithOptions:\s*launchOptions\s*\))/;
|
|
130
129
|
if (!methodInvocationLineMatcher.test(contents)) {
|
|
131
130
|
config_plugins_1.WarningAggregator.addWarningIOS('@react-native-firebase/app-check', 'Unable to determine correct insertion point in AppDelegate.swift. Skipping App Check addition.');
|
|
132
131
|
return contents;
|
|
@@ -127,27 +127,26 @@ export function modifySwiftAppDelegate(contents: string): string {
|
|
|
127
127
|
return contents;
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
-
//
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
if (
|
|
134
|
-
|
|
130
|
+
// App plugin (or an earlier pass) already calls configure. The provider factory must
|
|
131
|
+
// run before that call. Do not append a second FirebaseApp.configure().
|
|
132
|
+
const existingConfigure = /^([ \t]*)FirebaseApp\.configure\(\)/m.exec(contents);
|
|
133
|
+
if (existingConfigure) {
|
|
134
|
+
const indent = existingConfigure[1];
|
|
135
135
|
return contents.replace(
|
|
136
|
-
|
|
137
|
-
`${
|
|
138
|
-
RNFBAppCheckModule.sharedInstance()
|
|
139
|
-
FirebaseApp.configure()
|
|
140
|
-
`,
|
|
136
|
+
existingConfigure[0],
|
|
137
|
+
`${indent}RNFBAppCheckModule.sharedInstance()\n${existingConfigure[0]}`,
|
|
141
138
|
);
|
|
142
139
|
}
|
|
143
140
|
|
|
144
|
-
//
|
|
145
|
-
//
|
|
146
|
-
//
|
|
141
|
+
// No configure yet. Register the factory, then configure. Firebase requires the
|
|
142
|
+
// factory before configure (AppCheck-AD-3). Expo 58 scene AppDelegates start
|
|
143
|
+
// React Native from SceneDelegate, so the anchor is the didFinishLaunching return
|
|
144
|
+
// rather than factory.startReactNative.
|
|
147
145
|
const methodInvocationBlock = `RNFBAppCheckModule.sharedInstance()
|
|
148
146
|
FirebaseApp.configure()`;
|
|
149
147
|
|
|
150
|
-
const methodInvocationLineMatcher =
|
|
148
|
+
const methodInvocationLineMatcher =
|
|
149
|
+
/(?:factory\.startReactNative\()|(?:return\s+super\.application\(\s*application\s*,\s*didFinishLaunchingWithOptions:\s*launchOptions\s*\))/;
|
|
151
150
|
|
|
152
151
|
if (!methodInvocationLineMatcher.test(contents)) {
|
|
153
152
|
WarningAggregator.addWarningIOS(
|
package/android/src/main/java/io/invertase/firebase/appcheck/RNFBAppCheckListenerRegistry.java
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
package io.invertase.firebase.appcheck;
|
|
2
|
-
|
|
3
|
-
/*
|
|
4
|
-
* Copyright (c) 2016-present Invertase Limited & 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
|
-
* You may obtain a copy of the License at
|
|
9
|
-
*
|
|
10
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
-
*
|
|
12
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
-
* See the License for the specific language governing permissions and
|
|
16
|
-
* limitations under the License.
|
|
17
|
-
*
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
import io.invertase.firebase.common.RNFBHandleCollisionException;
|
|
21
|
-
import io.invertase.firebase.common.RNFBHandleMap;
|
|
22
|
-
import java.util.List;
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* App Check token listener map. Unique {@link #put} / {@link #putOrDiscard}; callers {@link #take}
|
|
26
|
-
* or {@link #takeAllAndRemove} then {@code remove()} outside the HandleMap lock. Skip-if-registered
|
|
27
|
-
* is {@code get(appName) != null}.
|
|
28
|
-
*/
|
|
29
|
-
final class RNFBAppCheckListenerRegistry {
|
|
30
|
-
private final RNFBHandleMap<String, AppCheckListenerHandle> map = new RNFBHandleMap<>();
|
|
31
|
-
|
|
32
|
-
void put(String appName, AppCheckListenerHandle handle) throws RNFBHandleCollisionException {
|
|
33
|
-
map.put(appName, handle);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Unique put. On collision, {@code remove()} the incoming handle and leave the existing mapping.
|
|
38
|
-
*
|
|
39
|
-
* @return true if stored
|
|
40
|
-
*/
|
|
41
|
-
boolean putOrDiscard(String appName, AppCheckListenerHandle handle) {
|
|
42
|
-
try {
|
|
43
|
-
map.put(appName, handle);
|
|
44
|
-
return true;
|
|
45
|
-
} catch (RNFBHandleCollisionException collision) {
|
|
46
|
-
if (handle != null) {
|
|
47
|
-
handle.remove();
|
|
48
|
-
}
|
|
49
|
-
return false;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
AppCheckListenerHandle get(String appName) {
|
|
54
|
-
return map.get(appName);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
AppCheckListenerHandle take(String appName) {
|
|
58
|
-
return map.take(appName);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
void takeAndRemove(String appName) {
|
|
62
|
-
AppCheckListenerHandle handle = map.take(appName);
|
|
63
|
-
if (handle != null) {
|
|
64
|
-
handle.remove();
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
void takeAllAndRemove() {
|
|
69
|
-
List<AppCheckListenerHandle> remaining = map.takeAll();
|
|
70
|
-
for (AppCheckListenerHandle handle : remaining) {
|
|
71
|
-
if (handle != null) {
|
|
72
|
-
handle.remove();
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|