@react-native-firebase/app-check 18.6.1 → 18.7.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 +10 -0
- package/android/src/main/java/io/invertase/firebase/appcheck/ReactNativeFirebaseAppCheckModule.java +29 -0
- package/ios/RNFBAppCheck/RNFBAppCheckModule.m +34 -0
- package/ios/RNFBAppCheck/RNFBAppCheckProvider.m +7 -1
- package/lib/index.d.ts +8 -0
- package/lib/index.js +5 -0
- package/lib/modular/index.js +10 -0
- package/lib/version.js +1 -1
- package/package.json +3 -3
- package/ios/RNFBAppCheck/RNFBAppCheckDebugProvider.h +0 -7
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,16 @@
|
|
|
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
|
+
## [18.7.0](https://github.com/invertase/react-native-firebase/compare/v18.6.2...v18.7.0) (2023-11-28)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
- **app-check:** implement getLimitedUseToken / Replay Protection ([#7424](https://github.com/invertase/react-native-firebase/issues/7424)) ([c6cd505](https://github.com/invertase/react-native-firebase/commit/c6cd50501a09855fe7253873549eabe869a24978))
|
|
11
|
+
|
|
12
|
+
## [18.6.2](https://github.com/invertase/react-native-firebase/compare/v18.6.1...v18.6.2) (2023-11-23)
|
|
13
|
+
|
|
14
|
+
**Note:** Version bump only for package @react-native-firebase/app-check
|
|
15
|
+
|
|
6
16
|
## [18.6.1](https://github.com/invertase/react-native-firebase/compare/v18.6.0...v18.6.1) (2023-11-01)
|
|
7
17
|
|
|
8
18
|
**Note:** Version bump only for package @react-native-firebase/app-check
|
package/android/src/main/java/io/invertase/firebase/appcheck/ReactNativeFirebaseAppCheckModule.java
CHANGED
|
@@ -206,6 +206,35 @@ public class ReactNativeFirebaseAppCheckModule extends ReactNativeFirebaseModule
|
|
|
206
206
|
});
|
|
207
207
|
}
|
|
208
208
|
|
|
209
|
+
@ReactMethod
|
|
210
|
+
public void getLimitedUseToken(String appName, Promise promise) {
|
|
211
|
+
Log.d(LOGTAG, "getLimitedUseToken appName: " + appName);
|
|
212
|
+
FirebaseApp firebaseApp = FirebaseApp.getInstance(appName);
|
|
213
|
+
|
|
214
|
+
Tasks.call(
|
|
215
|
+
getExecutor(),
|
|
216
|
+
() -> {
|
|
217
|
+
return Tasks.await(
|
|
218
|
+
FirebaseAppCheck.getInstance(firebaseApp).getLimitedUseAppCheckToken());
|
|
219
|
+
})
|
|
220
|
+
.addOnCompleteListener(
|
|
221
|
+
getExecutor(),
|
|
222
|
+
(task) -> {
|
|
223
|
+
if (task.isSuccessful()) {
|
|
224
|
+
WritableMap tokenResultMap = Arguments.createMap();
|
|
225
|
+
tokenResultMap.putString("token", task.getResult().getToken());
|
|
226
|
+
promise.resolve(tokenResultMap);
|
|
227
|
+
} else {
|
|
228
|
+
Log.e(
|
|
229
|
+
LOGTAG,
|
|
230
|
+
"Unknown error while fetching limited-use AppCheck token "
|
|
231
|
+
+ task.getException().getMessage());
|
|
232
|
+
rejectPromiseWithCodeAndMessage(
|
|
233
|
+
promise, "token-error", task.getException().getMessage());
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
|
|
209
238
|
/** Add a new token change listener - if one doesn't exist already */
|
|
210
239
|
@ReactMethod
|
|
211
240
|
public void addAppCheckListener(final String appName) {
|
|
@@ -134,4 +134,38 @@ RCT_EXPORT_METHOD(getToken
|
|
|
134
134
|
}];
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
+
RCT_EXPORT_METHOD(getLimitedUseToken
|
|
138
|
+
: (FIRApp *)firebaseApp
|
|
139
|
+
: (RCTPromiseResolveBlock)resolve
|
|
140
|
+
: (RCTPromiseRejectBlock)reject) {
|
|
141
|
+
FIRAppCheck *appCheck = [FIRAppCheck appCheckWithApp:firebaseApp];
|
|
142
|
+
DLog(@"appName %@", firebaseApp.name);
|
|
143
|
+
[appCheck limitedUseTokenWithCompletion:^(FIRAppCheckToken *_Nullable token,
|
|
144
|
+
NSError *_Nullable error) {
|
|
145
|
+
if (error != nil) {
|
|
146
|
+
// Handle any errors if the token was not retrieved.
|
|
147
|
+
DLog(@"RNFBAppCheck - getLimitedUseToken - Unable to retrieve App Check token: %@", error);
|
|
148
|
+
[RNFBSharedUtils rejectPromiseWithUserInfo:reject
|
|
149
|
+
userInfo:(NSMutableDictionary *)@{
|
|
150
|
+
@"code" : @"token-error",
|
|
151
|
+
@"message" : [error localizedDescription],
|
|
152
|
+
}];
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
if (token == nil) {
|
|
156
|
+
DLog(@"RNFBAppCheck - getLimitedUseToken - Unable to retrieve App Check token.");
|
|
157
|
+
[RNFBSharedUtils rejectPromiseWithUserInfo:reject
|
|
158
|
+
userInfo:(NSMutableDictionary *)@{
|
|
159
|
+
@"code" : @"token-null",
|
|
160
|
+
@"message" : @"no token fetched",
|
|
161
|
+
}];
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
NSMutableDictionary *tokenResultDictionary = [NSMutableDictionary new];
|
|
166
|
+
tokenResultDictionary[@"token"] = token.token;
|
|
167
|
+
resolve(tokenResultDictionary);
|
|
168
|
+
}];
|
|
169
|
+
}
|
|
170
|
+
|
|
137
171
|
@end
|
|
@@ -76,8 +76,14 @@
|
|
|
76
76
|
|
|
77
77
|
- (void)getTokenWithCompletion:(nonnull void (^)(FIRAppCheckToken *_Nullable,
|
|
78
78
|
NSError *_Nullable))handler {
|
|
79
|
-
DLog(@"proxying to delegateProvider...");
|
|
79
|
+
DLog(@"proxying getTokenWithCompletion to delegateProvider...");
|
|
80
80
|
[self.delegateProvider getTokenWithCompletion:handler];
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
+
- (void)getLimitedUseTokenWithCompletion:(nonnull void (^)(FIRAppCheckToken *_Nullable,
|
|
84
|
+
NSError *_Nullable))handler {
|
|
85
|
+
DLog(@"proxying getLimitedUseTokenWithCompletion to delegateProvider...");
|
|
86
|
+
[self.delegateProvider getLimitedUseTokenWithCompletion:handler];
|
|
87
|
+
}
|
|
88
|
+
|
|
83
89
|
@end
|
package/lib/index.d.ts
CHANGED
|
@@ -266,6 +266,14 @@ export namespace FirebaseAppCheckTypes {
|
|
|
266
266
|
*/
|
|
267
267
|
getToken(forceRefresh?: boolean): Promise<AppCheckTokenResult>;
|
|
268
268
|
|
|
269
|
+
/**
|
|
270
|
+
* Requests a Firebase App Check token. This method should be used only if you need to authorize requests
|
|
271
|
+
* to a non-Firebase backend. Returns limited-use tokens that are intended for use with your non-Firebase
|
|
272
|
+
* backend endpoints that are protected with Replay Protection (https://firebase.google.com/docs/app-check/custom-resource-backend#replay-protection).
|
|
273
|
+
* This method does not affect the token generation behavior of the getAppCheckToken() method.
|
|
274
|
+
*/
|
|
275
|
+
getLimitedUseToken(): Promise<AppCheckTokenResult>;
|
|
276
|
+
|
|
269
277
|
/**
|
|
270
278
|
* Registers a listener to changes in the token state. There can be more
|
|
271
279
|
* than one listener registered at the same time for one or more
|
package/lib/index.js
CHANGED
|
@@ -29,6 +29,7 @@ import version from './version';
|
|
|
29
29
|
export {
|
|
30
30
|
addTokenListener,
|
|
31
31
|
getToken,
|
|
32
|
+
getLimitedUseToken,
|
|
32
33
|
initializeAppCheck,
|
|
33
34
|
setTokenAutoRefreshEnabled,
|
|
34
35
|
} from './modular/index';
|
|
@@ -141,6 +142,10 @@ class FirebaseAppCheckModule extends FirebaseModule {
|
|
|
141
142
|
}
|
|
142
143
|
}
|
|
143
144
|
|
|
145
|
+
getLimitedUseToken() {
|
|
146
|
+
return this.native.getLimitedUseToken();
|
|
147
|
+
}
|
|
148
|
+
|
|
144
149
|
_parseListener(listenerOrObserver) {
|
|
145
150
|
return typeof listenerOrObserver === 'object'
|
|
146
151
|
? listenerOrObserver.next.bind(listenerOrObserver)
|
package/lib/modular/index.js
CHANGED
|
@@ -45,6 +45,16 @@ export function getToken(appCheckInstance, forceRefresh) {
|
|
|
45
45
|
return appCheckInstance.app.appCheck().getToken(forceRefresh);
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
+
/**
|
|
49
|
+
* Get a limited-use (consumable) App Check token.
|
|
50
|
+
* For use with server calls to firebase functions or custom backends using the firebase admin SDK
|
|
51
|
+
* @param appCheckInstance - AppCheck
|
|
52
|
+
* @returns {Promise<AppCheckTokenResult>}
|
|
53
|
+
*/
|
|
54
|
+
export function getLimitedUseToken(appCheckInstance) {
|
|
55
|
+
return appCheckInstance.app.appCheck().getLimitedUseToken();
|
|
56
|
+
}
|
|
57
|
+
|
|
48
58
|
/**
|
|
49
59
|
* Registers a listener to changes in the token state.
|
|
50
60
|
* There can be more than one listener registered at the same time for one or more App Check instances.
|
package/lib/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Generated by genversion.
|
|
2
|
-
module.exports = '18.
|
|
2
|
+
module.exports = '18.7.0';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-native-firebase/app-check",
|
|
3
|
-
"version": "18.
|
|
3
|
+
"version": "18.7.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": "18.
|
|
26
|
+
"@react-native-firebase/app": "18.7.0"
|
|
27
27
|
},
|
|
28
28
|
"publishConfig": {
|
|
29
29
|
"access": "public"
|
|
30
30
|
},
|
|
31
|
-
"gitHead": "
|
|
31
|
+
"gitHead": "02f1a2e1f32032b187b94316584e5b70abb47477"
|
|
32
32
|
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
// Subclass FIRAppCheckDebugProvider here
|
|
2
|
-
// https://developer.apple.com/library/archive/documentation/General/Conceptual/DevPedia-CocoaCore/MethodOverriding.html
|
|
3
|
-
|
|
4
|
-
// 1. have a new nullable configuredDebugToken property
|
|
5
|
-
// 2. override implementation of currentDebutToken to:
|
|
6
|
-
// - return configuredDebugToken if it exists,
|
|
7
|
-
// - else return [super currentDebugToken] if not
|