-
Notifications
You must be signed in to change notification settings - Fork 4.1k
feat(core): Add Recaptcha Site Key to FirebaseOptions #18334
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
11c3828
ebe835f
d192ad0
f9a527e
dc8d1b0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -63,6 +63,7 @@ private GeneratedAndroidFirebaseCore.CoreFirebaseOptions firebaseOptionsToMap( | |||||||||
| firebaseOptions.setDatabaseURL(options.getDatabaseUrl()); | ||||||||||
| firebaseOptions.setStorageBucket(options.getStorageBucket()); | ||||||||||
| firebaseOptions.setTrackingId(options.getGaTrackingId()); | ||||||||||
| // TODO(recaptchaSiteKey): Map recaptchaSiteKey if stored. | ||||||||||
|
|
||||||||||
| return firebaseOptions.build(); | ||||||||||
| } | ||||||||||
|
|
@@ -165,6 +166,8 @@ public void initializeApp( | |||||||||
| customAuthDomain.put(appName, initializeAppRequest.getAuthDomain()); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| // TODO(recaptchaSiteKey): Store or use recaptchaSiteKey if needed. | ||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To make the Please declare the static map at the class level: public static Map<String, String> customRecaptchaSiteKey = new HashMap<>();And store the key during initialization as shown in the suggestion.
Suggested change
|
||||||||||
|
|
||||||||||
| FirebaseApp firebaseApp = | ||||||||||
| FirebaseApp.initializeApp(applicationContext, options, appName); | ||||||||||
| taskCompletionSource.setResult(Tasks.await(firebaseAppToMap(firebaseApp))); | ||||||||||
|
|
||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -377,6 +377,16 @@ public void setAppGroupId(@Nullable String setterArg) { | |
| this.appGroupId = setterArg; | ||
| } | ||
|
|
||
| private @Nullable String recaptchaSiteKey; | ||
|
|
||
| public @Nullable String getRecaptchaSiteKey() { | ||
| return recaptchaSiteKey; | ||
| } | ||
|
|
||
| public void setRecaptchaSiteKey(@Nullable String setterArg) { | ||
| this.recaptchaSiteKey = setterArg; | ||
| } | ||
|
|
||
| /** Constructor is non-public to enforce null safety; use Builder. */ | ||
| CoreFirebaseOptions() {} | ||
|
|
||
|
|
@@ -402,7 +412,8 @@ && pigeonDeepEquals(deepLinkURLScheme, that.deepLinkURLScheme) | |
| && pigeonDeepEquals(androidClientId, that.androidClientId) | ||
| && pigeonDeepEquals(iosClientId, that.iosClientId) | ||
| && pigeonDeepEquals(iosBundleId, that.iosBundleId) | ||
| && pigeonDeepEquals(appGroupId, that.appGroupId); | ||
| && pigeonDeepEquals(appGroupId, that.appGroupId) | ||
| && pigeonDeepEquals(recaptchaSiteKey, that.recaptchaSiteKey); | ||
| } | ||
|
|
||
| @Override | ||
|
|
@@ -423,7 +434,8 @@ public int hashCode() { | |
| androidClientId, | ||
| iosClientId, | ||
| iosBundleId, | ||
| appGroupId | ||
| appGroupId, | ||
| recaptchaSiteKey | ||
| }; | ||
| return pigeonDeepHashCode(fields); | ||
| } | ||
|
|
@@ -542,6 +554,14 @@ public static final class Builder { | |
| return this; | ||
| } | ||
|
|
||
| private @Nullable String recaptchaSiteKey; | ||
|
|
||
| @CanIgnoreReturnValue | ||
| public @NonNull Builder setRecaptchaSiteKey(@Nullable String setterArg) { | ||
| this.recaptchaSiteKey = setterArg; | ||
| return this; | ||
| } | ||
|
|
||
| public @NonNull CoreFirebaseOptions build() { | ||
| CoreFirebaseOptions pigeonReturn = new CoreFirebaseOptions(); | ||
| pigeonReturn.setApiKey(apiKey); | ||
|
|
@@ -558,13 +578,14 @@ public static final class Builder { | |
| pigeonReturn.setIosClientId(iosClientId); | ||
| pigeonReturn.setIosBundleId(iosBundleId); | ||
| pigeonReturn.setAppGroupId(appGroupId); | ||
| pigeonReturn.setRecaptchaSiteKey(recaptchaSiteKey); | ||
| return pigeonReturn; | ||
| } | ||
| } | ||
|
|
||
| @NonNull | ||
| ArrayList<Object> toList() { | ||
| ArrayList<Object> toListResult = new ArrayList<>(14); | ||
| public ArrayList<Object> toList() { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this intentionally made public here?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the pigeon generated code, the updated pigeon version we had a few releases ago drives this change. |
||
| ArrayList<Object> toListResult = new ArrayList<>(15); | ||
| toListResult.add(apiKey); | ||
| toListResult.add(appId); | ||
| toListResult.add(messagingSenderId); | ||
|
|
@@ -579,6 +600,7 @@ ArrayList<Object> toList() { | |
| toListResult.add(iosClientId); | ||
| toListResult.add(iosBundleId); | ||
| toListResult.add(appGroupId); | ||
| toListResult.add(recaptchaSiteKey); | ||
| return toListResult; | ||
| } | ||
|
|
||
|
|
@@ -612,6 +634,8 @@ ArrayList<Object> toList() { | |
| pigeonResult.setIosBundleId((String) iosBundleId); | ||
| Object appGroupId = pigeonVar_list.get(13); | ||
| pigeonResult.setAppGroupId((String) appGroupId); | ||
| Object recaptchaSiteKey = pigeonVar_list.get(14); | ||
| pigeonResult.setRecaptchaSiteKey((String) recaptchaSiteKey); | ||
| return pigeonResult; | ||
| } | ||
| } | ||
|
|
@@ -740,7 +764,7 @@ public static final class Builder { | |
| } | ||
|
|
||
| @NonNull | ||
| ArrayList<Object> toList() { | ||
| public ArrayList<Object> toList() { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same question re: public |
||
| ArrayList<Object> toListResult = new ArrayList<>(4); | ||
| toListResult.add(name); | ||
| toListResult.add(options); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -93,6 +93,7 @@ - (CoreFirebaseOptions *)optionsFromFIROptions:(FIROptions *)options { | |
| pigeonOptions.iosBundleId = (id)options.bundleID ?: [NSNull null]; | ||
| pigeonOptions.iosClientId = (id)options.clientID ?: [NSNull null]; | ||
| pigeonOptions.appGroupId = (id)options.appGroupID ?: [NSNull null]; | ||
| // TODO(recaptchaSiteKey): Map recaptchaSiteKey if stored. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To resolve this - (CoreFirebaseOptions *)optionsFromFIROptions:(FIROptions *)options appName:(nullable NSString *)appName {
// ...
if (appName != nil && customRecaptchaSiteKeys[appName] != nil) {
pigeonOptions.recaptchaSiteKey = customRecaptchaSiteKeys[appName];
}
return pigeonOptions;
}Then update the call sites:
response.options = [self optionsFromFIROptions:firebaseApp.options appName:appNameDart];
// Pass nil or default app name if applicable |
||
| return pigeonOptions; | ||
| } | ||
|
|
||
|
|
@@ -178,6 +179,8 @@ - (void)initializeAppAppName:(nonnull NSString *)appName | |
| options.appGroupID = initializeAppRequest.appGroupId; | ||
| } | ||
|
|
||
| // TODO(recaptchaSiteKey): Store or use recaptchaSiteKey if needed. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To make the Please declare the static dictionary and a getter at the class level: static NSMutableDictionary<NSString *, NSString *> *customRecaptchaSiteKeys;
+ (void)initialize {
if (self == [FLTFirebaseCorePlugin self]) {
customAuthDomains = [[NSMutableDictionary alloc] init];
customRecaptchaSiteKeys = [[NSMutableDictionary alloc] init];
}
}
+ (NSString *)getCustomRecaptchaSiteKey:(NSString *)appName {
return customRecaptchaSiteKeys[appName];
}And store the key during initialization as shown in the suggestion. if (initializeAppRequest.recaptchaSiteKey != nil) {
customRecaptchaSiteKeys[appNameIos] = initializeAppRequest.recaptchaSiteKey;
} |
||
|
|
||
| if (initializeAppRequest.authDomain != nil) { | ||
| customAuthDomains[appNameIos] = initializeAppRequest.authDomain; | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To resolve this
TODOand map therecaptchaSiteKeyback when converting options, you can update the signature offirebaseOptionsToMapto accept the app name, allowing you to retrieve the stored key from the static map:Then update the call sites:
firebaseAppToMap:optionsFromResource: