Skip to content

Commit d6b5ed0

Browse files
Googlerbojeil-google
authored andcommitted
[firebase-release] Prepares FirebaseUI-web for 2.5.0 release.
- Integrates one-tap sign-up with FirebaseUI-web. - Fixes missing dialog-polyfill in FirebaseUI-web npm build. PiperOrigin-RevId: 176553830 Change-Id: Ia6298906bebf78e924cf8888dc9e9517125e83ba
1 parent fd6083f commit d6b5ed0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+3048
-12059
lines changed

README.md

Lines changed: 76 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -367,17 +367,86 @@ FirebaseUI supports the following configuration parameters.
367367

368368
The role of a credential helper is to help your users sign into you website.
369369
When one is enabled, your users will be prompted with email addresses and
370-
usernames they have saved from your app or other applications. To achieve this,
371-
[accountchooser.com](https://www.accountchooser.com/learnmore.html) is
372-
available. Upon signing in or signing up with email, the user will be redirected
373-
to the accountchooser.com website and will be able to select one of their saved
374-
accounts. It is recommended to use this, but you can also disable it by
375-
specifying the value below. This feature is always disabled for non HTTP/HTTPS
376-
environments.
370+
usernames they have saved from your app or other applications.
371+
FirebaseUI supports the following credential helpers:
372+
373+
- [one-tap sign-up](https://developers.google.com/identity/one-tap/web/overview)
374+
- [accountchooser.com](https://www.accountchooser.com/learnmore.html)
375+
376+
#### accountchooser.com
377+
378+
When [accountchooser.com](https://www.accountchooser.com/learnmore.html) is
379+
enabled (enabled by default), upon signing in or
380+
signing up with email, the user will be redirected to the accountchooser.com
381+
website and will be able to select one of their saved accounts. You can
382+
disable it by specifying the value below. This feature is always disabled for
383+
non HTTP/HTTPS environments.
384+
385+
#### One-tap sign-up
386+
387+
[One-tap sign-up](https://developers.google.com/identity/one-tap/web/overview)
388+
provides seamless authentication flows to
389+
your users with Google's one tap sign-up and automatic sign-in APIs.
390+
With one tap sign-up, users are prompted to create an account with a dialog
391+
that's inline with FirebaseUI NASCAR screen. With just one tap, they get a
392+
secure, token-based, passwordless account with your service, protected by their
393+
Google Account. As the process is frictionless, users are much more likely to
394+
register.
395+
Returning users are signed in automatically, even when they switch devices or
396+
platforms, or after their session expires.
397+
One-tap sign-up integrates with FirebaseUI and if you request Google OAuth
398+
scopes, you will still get back the expected Google OAuth access token even if
399+
the user goes through the one-tap flow. However, in that case 'redirect' flow is
400+
always used even when 'popup' is specified.
401+
In addition, if you choose to force prompt for Google sign-in, one-tap auto
402+
sign-in will be automatically disabled.
403+
One-tap is an additive feature and is only supported in the latest evergreen
404+
modern browser environments.
405+
For more information on how to configure one-tap sign-up, refer to the
406+
[one-tap get started guide](https://developers.google.com/identity/one-tap/web/get-started).
407+
408+
The following example shows how to configure one-tap sign-up with FirebaseUI.
409+
Along with the corresponding one-tap `credentialHelper`, `clientId` and
410+
`authMethod` have to be provided with the Firebase Google provider:
411+
412+
```javascript
413+
ui.start('#firebaseui-auth-container', {
414+
signInOptions = [
415+
{
416+
// Google provider must be enabled in Firebase Console to support one-tap
417+
// sign-up.
418+
provider: firebase.auth.GoogleAuthProvider.PROVIDER_ID,
419+
// Required to enable this provider in one-tap sign-up.
420+
authMethod: 'https://accounts.google.com',
421+
// Required to enable ID token credentials for this provider.
422+
// This can be obtained from the Credentials page of the Google APIs
423+
// console.
424+
clientId: 'xxxxxxxxxxxxxxxxx.apps.googleusercontent.com'
425+
},
426+
firebase.auth.FacebookAuthProvider.PROVIDER_ID,
427+
firebase.auth.TwitterAuthProvider.PROVIDER_ID,
428+
firebase.auth.GithubAuthProvider.PROVIDER_ID,
429+
firebase.auth.EmailAuthProvider.PROVIDER_ID,
430+
],
431+
// Required to enable one-tap sign-up credential helper.
432+
credentialHelper: firebaseui.auth.CredentialHelper.GOOGLE_YOLO
433+
});
434+
// Auto sign-in for returning users is enabled by default except when prompt is
435+
// not 'none' in the Google provider custom parameters. To manually disable:
436+
ui.disableAutoSignIn();
437+
```
438+
439+
Auto sign-in for returning users can be disabled by calling
440+
`ui.disableAutoSignIn()`. This may be needed if the FirebaseUI sign-in page is
441+
being rendered after the user signs out.
442+
443+
To see FirebaseUI in action with one-tap sign-up, check out the FirebaseUI
444+
[demo app](https://fir-ui-demo-84a6c.firebaseapp.com/).
377445

378446
|Credential Helper |Value |
379447
|------------------|------------------------------------------------------|
380448
|accountchooser.com|`firebaseui.auth.CredentialHelper.ACCOUNT_CHOOSER_COM`|
449+
|One-tap sign-up |`firebaseui.auth.CredentialHelper.GOOGLE_YOLO` |
381450
|None (disable) |`firebaseui.auth.CredentialHelper.NONE` |
382451

383452
### Available providers

demo/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,17 @@ Then copy and paste the Web snippet code found in the console (either by clickin
4545
your web app" button in your Project overview, or clicking the "Web setup" button in the Auth page)
4646
in the `config.js` file.
4747

48+
## Integrate One-tap sign-up with FirebaseUI (optional)
49+
50+
If you want to integrate with
51+
[One-tap sign-up](https://developers.google.com/identity/one-tap/web/overview),
52+
you will also need the Google OAuth web client ID corresponding to that project
53+
which can be retrieved from the Google Cloud Console. This value will need to be
54+
populated in `CLIENT_ID`.
55+
The domain of the page has to also be whitelisted. Learn more on how to
56+
[get started with One-tap sign-up](https://developers.google.com/identity/one-tap/web/get-started).
57+
Skip this step, if you don't want to use One-tap sign-up with FirebaseUI.
58+
4859
## Deploy
4960

5061
### Option 1: Compile and use local FirebaseUI files

demo/public/app.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@ function getUiConfig() {
3535
// TODO(developer): Remove the providers you don't need for your app.
3636
{
3737
provider: firebase.auth.GoogleAuthProvider.PROVIDER_ID,
38-
scopes: ['https://www.googleapis.com/auth/plus.login']
38+
// Required to enable this provider in One-Tap Sign-up.
39+
authMethod: 'https://accounts.google.com',
40+
// Required to enable ID token credentials for this provider.
41+
clientId: CLIENT_ID
3942
},
4043
{
4144
provider: firebase.auth.FacebookAuthProvider.PROVIDER_ID,
@@ -61,12 +64,17 @@ function getUiConfig() {
6164
}
6265
],
6366
// Terms of service url.
64-
'tosUrl': 'https://www.google.com'
67+
'tosUrl': 'https://www.google.com',
68+
'credentialHelper': CLIENT_ID && CLIENT_ID != 'YOUR_OAUTH_CLIENT_ID' ?
69+
firebaseui.auth.CredentialHelper.GOOGLE_YOLO :
70+
firebaseui.auth.CredentialHelper.ACCOUNT_CHOOSER_COM
6571
};
6672
}
6773

6874
// Initialize the FirebaseUI Widget using Firebase.
6975
var ui = new firebaseui.auth.AuthUI(firebase.auth());
76+
// Disable auto-sign in.
77+
ui.disableAutoSignIn();
7078

7179

7280
/**

demo/public/sample-config.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,7 @@ var config = {
1919
storageBucket: "your-app.appspot.com",
2020
};
2121
firebase.initializeApp(config);
22+
23+
// Google OAuth Client ID, needed to support One-tap sign-up.
24+
// Set to null if One-tap sign-up is not supported.
25+
var CLIENT_ID = 'YOUR_OAUTH_CLIENT_ID';

demo/public/widget.html

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,13 @@
3434
},
3535
'signInOptions': [
3636
// TODO(developer): Remove the providers you don't need for your app.
37-
firebase.auth.GoogleAuthProvider.PROVIDER_ID,
37+
{
38+
provider: firebase.auth.GoogleAuthProvider.PROVIDER_ID,
39+
// Required to enable this provider in One-Tap Sign-up.
40+
authMethod: 'https://accounts.google.com',
41+
// Required to enable ID token credentials for this provider.
42+
clientId: CLIENT_ID
43+
},
3844
firebase.auth.FacebookAuthProvider.PROVIDER_ID,
3945
firebase.auth.TwitterAuthProvider.PROVIDER_ID,
4046
firebase.auth.GithubAuthProvider.PROVIDER_ID,
@@ -47,7 +53,10 @@
4753
}
4854
],
4955
// Terms of service url.
50-
'tosUrl': 'https://www.google.com'
56+
'tosUrl': 'https://www.google.com',
57+
'credentialHelper': CLIENT_ID && CLIENT_ID != 'YOUR_OAUTH_CLIENT_ID' ?
58+
firebaseui.auth.CredentialHelper.GOOGLE_YOLO :
59+
firebaseui.auth.CredentialHelper.ACCOUNT_CHOOSER_COM
5160
};
5261

5362
// Initialize the FirebaseUI Widget using Firebase.

gulpfile.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,16 @@ const OPTIMIZATION_LEVEL = util.env.compilation_level ||
3838
const OUTPUT_WRAPPER = OPTIMIZATION_LEVEL === 'WHITESPACE_ONLY' ?
3939
'%output%' : '(function() { %output% })();';
4040

41+
// Provides missing dialogPolyfill on window in npm environments.
42+
const DIALOG_POLYFILL = 'if(typeof window!==\'undefined\')' +
43+
'{window.dialogPolyfill=require(\'dialog-polyfill\');}';
44+
4145
// Adds the firebase module requirement and exports firebaseui.
4246
const NPM_MODULE_WRAPPER = OPTIMIZATION_LEVEL === 'WHITESPACE_ONLY' ?
43-
'var firebase=require(\'firebase/app\');require(\'firebase/auth\');%output%module.exports=firebaseui;' :
44-
'(function() { var firebase=require(\'firebase/app\');require(\'firebase/auth\');%output% })();' +
47+
'var firebase=require(\'firebase/app\');require(\'firebase/auth\');' +
48+
'%output%' + DIALOG_POLYFILL + 'module.exports=firebaseui;' :
49+
'(function() { var firebase=require(\'firebase/app\');' +
50+
'require(\'firebase/auth\');%output% ' + DIALOG_POLYFILL + '})();' +
4551
'module.exports=firebaseui;';
4652

4753
// The path to Closure Compiler.

javascript/externs/googleyolo.js

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
/**
2+
* Smart Lock API externs.
3+
*
4+
* @externs
5+
*/
6+
7+
/**
8+
* @record
9+
* @struct
10+
*/
11+
function SmartLockHintOptions() {}
12+
13+
/** @type {!Array<string>} */
14+
SmartLockHintOptions.prototype.supportedAuthMethods;
15+
16+
/** @type {!Array<!Object<string,string>>} */
17+
SmartLockHintOptions.prototype.supportedIdTokenProviders;
18+
19+
/** @type {?string|undefined} */
20+
SmartLockHintOptions.prototype.context;
21+
22+
/**
23+
* @record
24+
* @struct
25+
*/
26+
function SmartLockRequestOptions() {}
27+
28+
/** @type {!Array<string>} */
29+
SmartLockRequestOptions.prototype.supportedAuthMethods;
30+
31+
/** @type {!Array<!Object<string,string>>} */
32+
SmartLockRequestOptions.prototype.supportedIdTokenProviders;
33+
34+
/** @type {?string|undefined} */
35+
SmartLockRequestOptions.prototype.context;
36+
37+
/**
38+
* @record
39+
* @struct
40+
*/
41+
function SmartLockCredential() {}
42+
43+
/** @type {string} */
44+
SmartLockCredential.prototype.id;
45+
46+
/** @type {string} */
47+
SmartLockCredential.prototype.authMethod;
48+
49+
/** @type {string|undefined} */
50+
SmartLockCredential.prototype.authDomain;
51+
52+
/** @type {string|undefined} */
53+
SmartLockCredential.prototype.displayName;
54+
55+
/** @type {string|undefined} */
56+
SmartLockCredential.prototype.profilePicture;
57+
58+
/** @type {string|undefined} */
59+
SmartLockCredential.prototype.idToken;
60+
61+
/**
62+
* @record
63+
* @struct
64+
*/
65+
function SmartLockApi() {}
66+
67+
/**
68+
* Requests the credential provider whether hints are available or not for
69+
* the current user.
70+
*
71+
* @param {!SmartLockHintOptions} options
72+
* Describes the types of credentials that are supported by the origin.
73+
* @return {!Promise<boolean>}
74+
* A promise that resolves with true if at least one hint is available,
75+
* and resolves with false if none are available. The promise will not
76+
* reject: if an error happen, it should resolve with false.
77+
*/
78+
SmartLockApi.prototype.hintsAvailable = function(options) {};
79+
80+
/**
81+
* Attempts to retrieve a sign-up hint that can be used to create a new
82+
* user account.
83+
*
84+
* @param {!SmartLockHintOptions} options
85+
* Describes the types of credentials that are supported by the origin,
86+
* and customization properties for the display of any UI pertaining to
87+
* releasing this credential.
88+
* @return {!Promise<!SmartLockCredential>}
89+
* A promise for a credential hint. The promise will be rejected if the
90+
* user cancels the hint selection process, if there are no hints available,
91+
* or if an error happens.
92+
*/
93+
SmartLockApi.prototype.hint = function(options) {};
94+
95+
/**
96+
* Attempts to retrieve a credential for the current origin.
97+
*
98+
* @param {!SmartLockRequestOptions} options
99+
* Describes the types of credentials that are supported by the origin.
100+
* @return {!Promise<!SmartLockCredential>}
101+
* A promise for the credential, which will be rejected if there are no
102+
* credentials available or the user refuses to release the credential.
103+
* Otherwise, the promise will resolve with a credential that the app
104+
* can use.
105+
*/
106+
SmartLockApi.prototype.retrieve = function(options) {};
107+
108+
/**
109+
* Prevents the automatic release of a credential from the retrieve operation.
110+
* This should be invoked when the user signs out, in order to prevent an
111+
* automatic sign-in loop. This cannot be called while another operation is
112+
* pending so should be called before retrieve.
113+
* @return {!Promise<void>}
114+
* A promise for the completion of notifying the provider to disable
115+
* automatic sign-in.
116+
*/
117+
SmartLockApi.prototype.disableAutoSignIn = function() {};
118+
119+
/**
120+
* Cancels the last operation triggered.
121+
* @return {!Promise<void>}
122+
* A promise for the completion of the cancellation.
123+
*/
124+
SmartLockApi.prototype.cancelLastOperation = function() {};
125+
126+
/**
127+
* Sets a custom timeouts, in milliseconds, after which a request is
128+
* considered failed.
129+
* @param {number|null} timeoutMs The timeout in milliseconds.
130+
*/
131+
SmartLockApi.prototype.setTimeouts = function(timeoutMs) {};
132+
133+
/**
134+
* Sets the render mode of the credentials selector, or null if the default
135+
* should be used. Available render modes are: 'bottomSheet' and 'navPopout'.
136+
* @param {string|null} renderMode
137+
*/
138+
SmartLockApi.prototype.setRenderMode = function(renderMode) {};
139+
140+
/** @type {!SmartLockApi} */
141+
var googleyolo;
142+
143+
/** @type {function(!SmartLockApi)|undefined} */
144+
var onGoogleYoloLoad;

0 commit comments

Comments
 (0)