diff --git a/packages/google_identity_services_web/CHANGELOG.md b/packages/google_identity_services_web/CHANGELOG.md index 7882c511d3801..22578cc44a967 100644 --- a/packages/google_identity_services_web/CHANGELOG.md +++ b/packages/google_identity_services_web/CHANGELOG.md @@ -1,3 +1,9 @@ +## 0.2.2 + +* Adds the following new fields to `IdConfiguration`: + * `login_hint`, `hd` as auto-select hints for users with multiple accounts/domains. + * `use_fedcm_for_prompt` so FedCM can be enabled. + ## 0.2.1+1 * Adds pub topics to package metadata. diff --git a/packages/google_identity_services_web/example/integration_test/js_interop_id_test.dart b/packages/google_identity_services_web/example/integration_test/js_interop_id_test.dart index 78a469435e26b..b7e911f60faef 100644 --- a/packages/google_identity_services_web/example/integration_test/js_interop_id_test.dart +++ b/packages/google_identity_services_web/example/integration_test/js_interop_id_test.dart @@ -8,6 +8,7 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:google_identity_services_web/id.dart'; import 'package:integration_test/integration_test.dart'; import 'package:js/js.dart'; +import 'package:js/js_util.dart' as js_util show getProperty; import 'src/dom.dart'; import 'utils.dart' as utils; @@ -31,6 +32,53 @@ void main() async { }); }); + group('IdConfig', () { + testWidgets('passes values from Dart to JS', (_) async { + final IdConfiguration config = IdConfiguration( + client_id: 'testing_1-2-3', + auto_select: false, + callback: allowInterop((_) {}), + login_uri: Uri.parse('https://www.example.com/login'), + native_callback: allowInterop((_) {}), + cancel_on_tap_outside: false, + prompt_parent_id: 'some_dom_id', + nonce: 's0m3_r4ndOM_vALu3', + context: OneTapContext.signin, + state_cookie_domain: 'subdomain.example.com', + ux_mode: UxMode.popup, + allowed_parent_origin: ['allowed', 'another'], + intermediate_iframe_close_callback: allowInterop((_) {}), + itp_support: true, + login_hint: 'login-hint@example.com', + hd: 'hd_value', + use_fedcm_for_prompt: true, + ); + + // Save some keystrokes below by partially applying to the 'config' above. + void expectConfigValue(String name, Object? matcher) { + expect(js_util.getProperty(config, name), matcher, reason: name); + } + + expectConfigValue('allowed_parent_origin', hasLength(2)); + expectConfigValue('auto_select', isFalse); + expectConfigValue('callback', isA()); + expectConfigValue('cancel_on_tap_outside', isFalse); + expectConfigValue('client_id', 'testing_1-2-3'); + expectConfigValue('context', isA()); + expectConfigValue('hd', 'hd_value'); + expectConfigValue('intermediate_iframe_close_callback', isA()); + expectConfigValue('itp_support', isTrue); + expectConfigValue('login_hint', 'login-hint@example.com'); + expectConfigValue('login_uri', isA()); + expectConfigValue('native_callback', isA()); + expectConfigValue('nonce', 's0m3_r4ndOM_vALu3'); + expectConfigValue('prompt_parent_id', 'some_dom_id'); + expectConfigValue('state_cookie_domain', 'subdomain.example.com'); + expectConfigValue('use_fedcm_for_prompt', isTrue); + expectConfigValue('ux_mode', isA()); + }); + }); + group('prompt', () { testWidgets('supports a moment notification callback', (_) async { id.initialize(IdConfiguration(client_id: 'testing_1-2-3')); diff --git a/packages/google_identity_services_web/example/lib/main.dart b/packages/google_identity_services_web/example/lib/main.dart index 1046826641a4c..a0b613ddb1716 100644 --- a/packages/google_identity_services_web/example/lib/main.dart +++ b/packages/google_identity_services_web/example/lib/main.dart @@ -22,6 +22,7 @@ void main() async { final IdConfiguration config = IdConfiguration( client_id: 'your-client_id.apps.googleusercontent.com', callback: allowInterop(onCredentialResponse), + use_fedcm_for_prompt: true, ); id.initialize(config); diff --git a/packages/google_identity_services_web/lib/src/js_interop/google_accounts_id.dart b/packages/google_identity_services_web/lib/src/js_interop/google_accounts_id.dart index 45a8e51a69c57..1c2670453135e 100644 --- a/packages/google_identity_services_web/lib/src/js_interop/google_accounts_id.dart +++ b/packages/google_identity_services_web/lib/src/js_interop/google_accounts_id.dart @@ -230,12 +230,40 @@ abstract class IdConfiguration { /// the callback is invoked. Function? intermediate_iframe_close_callback, - /// determines if the upgraded One Tap UX should be enabled on browsers + /// Determines if the upgraded One Tap UX should be enabled on browsers /// that support Intelligent Tracking Prevention (ITP). The default value /// is false. /// /// See: https://developers.google.com/identity/gsi/web/guides/features#upgraded_ux_on_itp_browsers bool? itp_support, + + /// If your application knows in advance which user should be signed-in, it + /// can provide a login hint to Google. + /// + /// When successful, account selection is skipped. Accepted values are: + /// * an email address or + /// * an ID token sub field value. + /// + /// For more information, see: + /// * https://developers.google.com/identity/protocols/oauth2/openid-connect#authenticationuriparameters + String? login_hint, + + /// When a user has multiple accounts and should only sign-in with their + /// Workspace account use this to provide a domain name hint to Google. + /// + /// When successful, user accounts displayed during account selection are + /// limited to the provided domain. + /// + /// A wildcard value: `*` offers only Workspace accounts to the user and + /// excludes consumer accounts (user@gmail.com) during account selection. + /// + /// For more information, see: + /// * https://developers.google.com/identity/protocols/oauth2/openid-connect#authenticationuriparameters + String? hd, + + /// Allow the browser to control user sign-in prompts and mediate the + /// sign-in flow between your website and Google. Defaults to false. + bool? use_fedcm_for_prompt, }); } diff --git a/packages/google_identity_services_web/pubspec.yaml b/packages/google_identity_services_web/pubspec.yaml index d98098c7c4d31..bd3186cb67d1d 100644 --- a/packages/google_identity_services_web/pubspec.yaml +++ b/packages/google_identity_services_web/pubspec.yaml @@ -2,7 +2,7 @@ name: google_identity_services_web description: A Dart JS-interop layer for Google Identity Services. Google's new sign-in SDK for Web that supports multiple types of credentials. repository: https://github.com/flutter/packages/tree/main/packages/google_identity_services_web issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+google_identiy_services_web%22 -version: 0.2.1+1 +version: 0.2.2 environment: sdk: ">=2.19.0 <4.0.0"