Add generation of limited-use tokens with a TTL of 5 mins (#11)

This commit is contained in:
Andrew Heard authored and GitHub committed 2023-08-22 12:56:00 -04:00
1 parent 2b623874c9
commit 8d0bdd3f24
20 files changed
+482 -144

No files matched your search

@@ -101,11 +101,24 @@ static NSString *const kDebugTokenUserDefaultsKey = @"FIRAAppCheckDebugToken";
- (void)getTokenWithCompletion:(void (^)(GACAppCheckToken *_Nullable token,
NSError *_Nullable error))handler {
[self getTokenWithLimitedUse:NO completion:handler];
}
- (void)getLimitedUseTokenWithCompletion:(void (^)(GACAppCheckToken *_Nullable,
NSError *_Nullable))handler {
[self getTokenWithLimitedUse:YES completion:handler];
}
#pragma mark - Internal
- (void)getTokenWithLimitedUse:(BOOL)limitedUse
completion:(void (^)(GACAppCheckToken *_Nullable token,
NSError *_Nullable error))handler {
[FBLPromise do:^NSString * {
return [self currentDebugToken];
}]
.then(^FBLPromise<GACAppCheckToken *> *(NSString *debugToken) {
return [self.APIService appCheckTokenWithDebugToken:debugToken];
return [self.APIService appCheckTokenWithDebugToken:debugToken limitedUse:limitedUse];
})
.then(^id(GACAppCheckToken *appCheckToken) {
handler(appCheckToken, nil);