├── .github
├── ISSUE_TEMPLATE
│ ├── bug_report.md
│ └── feature_request.md
└── workflows
│ └── test.yml
├── .gitignore
├── .opensource
└── project.json
├── CHANGELOG.md
├── CONTRIBUTING.md
├── LANGUAGES.md
├── LICENSE
├── README.md
├── STYLEGUIDE.md
├── bower.json
├── buildtools
├── all_tests.html
├── common.py
├── container
│ ├── Dockerfile
│ └── cloudbuild.yaml
├── country_data
│ ├── README.md
│ ├── compress_pngs.js
│ ├── css.hbs
│ ├── filter_country_data.js
│ ├── full_country_data.json
│ ├── generate_country_data.sh
│ ├── get_directory_args.js
│ ├── make_country_list_for_readme.js
│ ├── make_flag_pngs.js
│ ├── make_flag_sprite.js
│ └── package.json
├── gen_all_tests_js.py
├── gen_test_html.py
├── generate_test_files.sh
├── publish.sh
├── publish
│ ├── cloudbuild.yaml
│ ├── deploy_key.enc
│ ├── hub.enc
│ ├── npmrc.enc
│ └── twitter.json.enc
├── run_demo.sh
├── run_tests.sh
├── sauce_connect.sh
├── test_template.html
└── tweet.js
├── cut
├── demo
├── README.md
├── database.rules.json
├── firebase.json
├── public
│ ├── app.js
│ ├── common.js
│ ├── index.html
│ ├── manifest.json
│ ├── sample-config.js
│ ├── style.css
│ └── widget.html
└── screenshot.png
├── externs
└── firebaseui-externs.js
├── firebase-externs
├── firebase-app-externs.js
├── firebase-auth-externs.js
└── firebase-client-auth-externs.js
├── firebaseuihandler
└── README.md
├── gulpfile.js
├── image
├── anonymous.png
├── apple.png
├── facebook.svg
├── flags_sprite.png
├── flags_sprite_2x.png
├── github.svg
├── google.svg
├── mail.svg
├── microsoft.svg
├── oidc.svg
├── phone.svg
├── saml.svg
├── success_status.png
├── test
│ └── recaptcha-widget.png
├── twitter.svg
└── yahoo.svg
├── javascript
├── data
│ ├── README.md
│ ├── country.js
│ └── country_test.js
├── externs
│ ├── accountchooser.js
│ ├── dialog_polyfill.js
│ ├── googleyolo.js
│ └── recaptcha.js
├── testing
│ ├── acclient.js
│ ├── appclient.js
│ ├── auth.js
│ ├── auth_test.js
│ ├── cookiestorage.js
│ ├── mockhelper.js
│ ├── mockhelper_test.js
│ ├── recaptchaverifier.js
│ ├── recaptchaverifier_test.js
│ └── util.js
├── ui
│ ├── element
│ │ ├── common.js
│ │ ├── common_test.js
│ │ ├── dialog.js
│ │ ├── dialog_test.js
│ │ ├── elementtesthelper.js
│ │ ├── email.js
│ │ ├── emailtesthelper.js
│ │ ├── form.js
│ │ ├── formtesthelper.js
│ │ ├── idps.js
│ │ ├── idpstesthelper.js
│ │ ├── infobar.js
│ │ ├── infobartesthelper.js
│ │ ├── listboxdialog.js
│ │ ├── listboxdialog_test.js
│ │ ├── name.js
│ │ ├── nametesthelper.js
│ │ ├── newpassword.js
│ │ ├── newpasswordtesthelper.js
│ │ ├── password.js
│ │ ├── passwordtesthelper.js
│ │ ├── phoneconfirmationcode.js
│ │ ├── phoneconfirmationcodetesthelper.js
│ │ ├── phonenumber.js
│ │ ├── phonenumbertesthelper.js
│ │ ├── progressdialog.js
│ │ ├── recaptcha.js
│ │ ├── recaptchatesthelper.js
│ │ ├── resend.js
│ │ ├── resendtesthelper.js
│ │ ├── tospp.js
│ │ └── tospptesthelper.js
│ ├── mdl.js
│ ├── mdl_test.js
│ ├── mdl_test_dom.html
│ └── page
│ │ ├── anonymoususermismatch.js
│ │ ├── anonymoususermismatch_test.js
│ │ ├── base.js
│ │ ├── blank.js
│ │ ├── blank_test.js
│ │ ├── callback.js
│ │ ├── callback_test.js
│ │ ├── differentdeviceerror.js
│ │ ├── differentdeviceerror_test.js
│ │ ├── emailchangerevoke.js
│ │ ├── emailchangerevoke_test.js
│ │ ├── emaillinksigninconfirmation.js
│ │ ├── emaillinksigninconfirmation_test.js
│ │ ├── emaillinksigninlinking.js
│ │ ├── emaillinksigninlinking_test.js
│ │ ├── emaillinksigninlinkingdifferentdevice.js
│ │ ├── emaillinksigninlinkingdifferentdevice_test.js
│ │ ├── emaillinksigninsent.js
│ │ ├── emaillinksigninsent_test.js
│ │ ├── emailmismatch.js
│ │ ├── emailmismatch_test.js
│ │ ├── emailnotreceived.js
│ │ ├── emailnotreceived_test.js
│ │ ├── federatedlinking.js
│ │ ├── federatedlinking_test.js
│ │ ├── notice.js
│ │ ├── notice_test.js
│ │ ├── pagetesthelper.js
│ │ ├── passwordlinking.js
│ │ ├── passwordlinking_test.js
│ │ ├── passwordrecovery.js
│ │ ├── passwordrecovery_test.js
│ │ ├── passwordreset.js
│ │ ├── passwordreset_test.js
│ │ ├── passwordsignin.js
│ │ ├── passwordsignin_test.js
│ │ ├── passwordsignup.js
│ │ ├── passwordsignup_test.js
│ │ ├── phonesigninfinish.js
│ │ ├── phonesigninfinish_test.js
│ │ ├── phonesigninstart.js
│ │ ├── phonesigninstart_test.js
│ │ ├── providermatchbyemail.js
│ │ ├── providermatchbyemail_test.js
│ │ ├── providersignin.js
│ │ ├── providersignin_test.js
│ │ ├── revertsecondfactoradditionsuccess.js
│ │ ├── revertsecondfactoradditionsuccess_test.js
│ │ ├── selecttenant.js
│ │ ├── selecttenant_test.js
│ │ ├── signin.js
│ │ ├── signin_test.js
│ │ ├── spinner.js
│ │ ├── spinner_test.js
│ │ ├── unauthorizeduser.js
│ │ ├── unauthorizeduser_test.js
│ │ ├── unsupportedprovider.js
│ │ └── unsupportedprovider_test.js
├── utils
│ ├── acclient.js
│ ├── acclient_test.js
│ ├── account.js
│ ├── account_test.js
│ ├── actioncodeurlbuilder.js
│ ├── actioncodeurlbuilder_test.js
│ ├── config.js
│ ├── config_test.js
│ ├── cookiemechanism.js
│ ├── cookiemechanism_test.js
│ ├── crypt.js
│ ├── crypt_test.js
│ ├── eventregister.js
│ ├── eventregister_test.js
│ ├── googleyolo.js
│ ├── googleyolo_test.js
│ ├── idp.js
│ ├── idp_test.js
│ ├── log.js
│ ├── pendingemailcredential.js
│ ├── pendingemailcredential_test.js
│ ├── phoneauthresult.js
│ ├── phoneauthresult_test.js
│ ├── phonenumber.js
│ ├── phonenumber_test.js
│ ├── redirectstatus.js
│ ├── redirectstatus_test.js
│ ├── sni.js
│ ├── sni_test.js
│ ├── storage.js
│ ├── storage_test.js
│ ├── util.js
│ └── util_test.js
└── widgets
│ ├── authui.js
│ ├── authui_test.js
│ ├── authuierror.js
│ ├── authuierror_test.js
│ ├── config.js
│ ├── config_test.js
│ ├── dispatcher.js
│ ├── dispatcher_test.js
│ ├── exports_app.js
│ ├── firebaseuihandler.js
│ ├── firebaseuihandler_test.js
│ ├── handler
│ ├── actioncode.js
│ ├── actioncode_test.js
│ ├── anonymoususermismatch.js
│ ├── anonymoususermismatch_test.js
│ ├── callback.js
│ ├── callback_test.js
│ ├── common.js
│ ├── common_test.js
│ ├── differentdeviceerror.js
│ ├── differentdeviceerror_test.js
│ ├── emaillinkconfirmation.js
│ ├── emaillinkconfirmation_test.js
│ ├── emaillinknewdevicelinking.js
│ ├── emaillinknewdevicelinking_test.js
│ ├── emaillinksignincallback.js
│ ├── emaillinksignincallback_test.js
│ ├── emaillinksigninlinking.js
│ ├── emaillinksigninlinking_test.js
│ ├── emaillinksigninsent.js
│ ├── emaillinksigninsent_test.js
│ ├── emailmismatch.js
│ ├── emailmismatch_test.js
│ ├── emailnotreceived.js
│ ├── emailnotreceived_test.js
│ ├── federatedlinking.js
│ ├── federatedlinking_test.js
│ ├── federatedredirect.js
│ ├── federatedredirect_test.js
│ ├── federatedsignin.js
│ ├── federatedsignin_test.js
│ ├── handler.js
│ ├── handler_test.js
│ ├── passwordlinking.js
│ ├── passwordlinking_test.js
│ ├── passwordrecovery.js
│ ├── passwordrecovery_test.js
│ ├── passwordsignin.js
│ ├── passwordsignin_test.js
│ ├── passwordsignup.js
│ ├── passwordsignup_test.js
│ ├── phonesigninfinish.js
│ ├── phonesigninfinish_test.js
│ ├── phonesigninstart.js
│ ├── phonesigninstart_test.js
│ ├── prefilledemailsignin.js
│ ├── prefilledemailsignin_test.js
│ ├── providersignin.js
│ ├── providersignin_test.js
│ ├── sendemaillinkforsignin.js
│ ├── sendemaillinkforsignin_test.js
│ ├── signin.js
│ ├── signin_test.js
│ ├── starter.js
│ ├── starter_test.js
│ ├── testhelper.js
│ ├── unauthorizeduser.js
│ ├── unauthorizeduser_test.js
│ ├── unsupportedprovider.js
│ └── unsupportedprovider_test.js
│ ├── uihandlerconfig.js
│ └── uihandlerconfig_test.js
├── package-lock.json
├── package.json
├── protractor.conf.js
├── protractor_spec.js
├── sauce_browsers.json
├── soy
├── elements.soy
├── elements_test.js
├── elements_test_dom.html
├── pages.soy
├── pages_test.js
├── pages_test_dom.html
├── strings.soy
└── viewhelper.js
├── stylesheet
├── firebase-ui.css
├── flags.css
├── imports.css
└── mdl.scss
├── translations
├── ar-XB.xtb
├── ar.xtb
├── bg.xtb
├── ca.xtb
├── cs.xtb
├── da.xtb
├── de.xtb
├── el.xtb
├── en-GB.xtb
├── en-XA.xtb
├── es-419.xtb
├── es.xtb
├── fa.xtb
├── fi.xtb
├── fil.xtb
├── fr.xtb
├── hi.xtb
├── hr.xtb
├── hu.xtb
├── id.xtb
├── it.xtb
├── iw.xtb
├── ja.xtb
├── ko.xtb
├── lt.xtb
├── lv.xtb
├── nl.xtb
├── no.xtb
├── pl.xtb
├── pt-BR.xtb
├── pt-PT.xtb
├── pt.xtb
├── ro.xtb
├── ru.xtb
├── sk.xtb
├── sl.xtb
├── sr.xtb
├── sv.xtb
├── th.xtb
├── tr.xtb
├── uk.xtb
├── vi.xtb
├── zh-CN.xtb
└── zh-TW.xtb
└── types
└── index.d.ts
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a report to help us improve
4 |
5 | ---
6 |
7 |
8 |
21 |
22 |
23 |
24 | ### [REQUIRED] Describe your environment
25 |
26 | * Operating System version: _____
27 | * Browser version: _____
28 | * Firebase UI version: _____
29 | * Firebase SDK version: _____
30 |
31 |
32 |
33 | ### [REQUIRED] Describe the problem
34 |
35 | #### Steps to reproduce:
36 |
40 | #### Relevant Code:
41 |
42 |
46 | https://stackblitz.com/fork/firebase-issue-sandbox
47 |
48 | ```javascript
49 | // TODO(you): code here to reproduce the problem
50 | ```
51 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an idea for this project
4 |
5 | ---
6 |
7 | **Is your feature request related to a problem? Please describe.**
8 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
9 |
10 | **Describe the solution you'd like**
11 | A clear and concise description of what you want to happen.
12 |
13 | **Describe alternatives you've considered**
14 | A clear and concise description of any alternative solutions or features you've considered.
15 |
16 | **Additional context**
17 | Add any other context or screenshots about the feature request here.
18 |
--------------------------------------------------------------------------------
/.github/workflows/test.yml:
--------------------------------------------------------------------------------
1 | name: Test
2 |
3 | on:
4 | push:
5 | branches:
6 | - master
7 | pull_request:
8 | branches:
9 | - "**"
10 |
11 | env:
12 | SAUCE_USERNAME: ${{secrets.SAUCE_USERNAME}}
13 | SAUCE_ACCESS_KEY: ${{secrets.SAUCE_ACCESS_KEY}}
14 |
15 | jobs:
16 | test:
17 | runs-on: ubuntu-latest
18 | steps:
19 | - name: Checkout
20 | uses: actions/checkout@v2
21 | - name: Setup node
22 | uses: actions/setup-node@v2-beta
23 | with:
24 | node-version: '18'
25 | check-latest: true
26 | - name: node_modules cache
27 | id: node_modules_cache
28 | uses: actions/cache@v2
29 | with:
30 | path: ./node_modules
31 | key: ${{ runner.os }}-18-node_modules-${{ hashFiles('package-lock.json') }}
32 | restore-keys: |
33 | ${{ runner.os }}-18-node_modules-
34 | - name: NPM install
35 | if: steps.node_modules_cache.outputs.cache-hit != 'true'
36 | run: npm ci
37 | - name: Build & run tests
38 | run: npm run test
39 | - name: Run tests in Saucelabs
40 | run: |
41 | ./buildtools/sauce_connect.sh &
42 | ./buildtools/run_tests.sh --saucelabs
43 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Node modules.
2 | node_modules/
3 |
4 | # Generated directories.
5 | generated/
6 | out/
7 | dist/
8 | .firebase
9 |
10 | # Generated files.
11 | *.log
12 | *.pyc
13 | .DS_Store
14 | *~
15 | *.swp
16 |
17 | #Local config.
18 | **/.firebaserc
19 | demo/public/config.js
20 |
--------------------------------------------------------------------------------
/.opensource/project.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "FirebaseUI for Web",
3 |
4 | "platforms": [
5 | "Web"
6 | ],
7 |
8 | "content": "README.md",
9 |
10 | "pages" : {
11 | "LANGUAGES.md": "Supported Languages"
12 | },
13 |
14 | "related": [
15 | "firebase/firebaseui-android",
16 | "firebase/firebaseui-ios",
17 | "firebase/firebaseui-web-react"
18 | ]
19 | }
20 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | * Fix password policy error message handling in password reset flow (#1047)
2 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | Want to contribute? Great! First, read this page (including the small print at
2 | the end).
3 |
4 | ### Before you contribute
5 |
6 | Before we can use your code, you must sign the [Google Individual Contributor
7 | License Agreement](https://cla.developers.google.com/about/google-individual)
8 | (CLA), which you can do online. The CLA is necessary mainly because you own the
9 | copyright to your changes, even after your contribution becomes part of our
10 | codebase, so we need your permission to use and distribute your code. We also
11 | need to be sure of various other things—for instance that you'll tell us if you
12 | know that your code infringes on other people's patents. You don't have to sign
13 | the CLA until after you've submitted your code for review and a member has
14 | approved it, but you must do it before we can put your code into our codebase.
15 |
16 | ### Adding new features
17 |
18 | Before you start working on a larger contribution, you should get in touch with
19 | us first through the issue tracker with your idea so that we can help out and
20 | possibly guide you. Coordinating up front makes it much easier to avoid
21 | frustration later on.
22 |
23 | If this has been discussed in an issue, make sure to mention the issue number.
24 | If not, go file an issue about this to make sure this is a desirable change.
25 |
26 | If this is a new feature please co-ordinate with someone on
27 | [FirebaseUI-Android](https://github.com/firebase/FirebaseUI-Android) and someone
28 | on [FirebaseUI-iOS](https://github.com/firebase/FirebaseUI-iOS)
29 | to make sure that we can implement this on all platforms and maintain feature
30 | parity. Feature parity (where it makes sense) is a strict requirement for
31 | feature development in FirebaseUI.
32 |
33 | ### Code reviews
34 |
35 | All submissions, including submissions by project members, require review. We
36 | use Github pull requests for this purpose. Please refer to the
37 | [Style Guide](STYLEGUIDE.md) and ensure you respect it before submitting a PR.
38 |
39 | ### The small print
40 |
41 | Contributions made by corporations are covered by a different agreement than the
42 | one above, the [Software Grant and Corporate Contributor License
43 | Agreement](https://cla.developers.google.com/about/google-corporate).
44 |
--------------------------------------------------------------------------------
/LANGUAGES.md:
--------------------------------------------------------------------------------
1 | # Supported Languages
2 |
3 | | Code | Language |
4 | | ---- | -------- |
5 | | ar | Arabic |
6 | | bg | Bulgarian |
7 | | ca | Catalan |
8 | | zh_cn | Chinese (Simplified) |
9 | | zh_tw | Chinese (Traditional) |
10 | | hr | Croatian |
11 | | cs | Czech |
12 | | da | Danish |
13 | | nl | Dutch |
14 | | en | English |
15 | | en_gb | English (UK) |
16 | | fa | Farsi |
17 | | fil | Filipino |
18 | | fi | Finnish |
19 | | fr | French |
20 | | de | German |
21 | | el | Greek |
22 | | iw | Hebrew |
23 | | hi | Hindi |
24 | | hu | Hungarian |
25 | | id | Indonesian |
26 | | it | Italian |
27 | | ja | Japanese |
28 | | ko | Korean |
29 | | lv | Latvian |
30 | | lt | Lithuanian |
31 | | no | Norwegian (Bokmal) |
32 | | pl | Polish |
33 | | pt_br | Portuguese (Brazil) |
34 | | pt_pt | Portuguese (Portugal) |
35 | | ro | Romanian |
36 | | ru | Russian |
37 | | sr | Serbian |
38 | | sk | Slovak |
39 | | sl | Slovenian |
40 | | es | Spanish |
41 | | es_419 | Spanish (Latin America) |
42 | | sv | Swedish |
43 | | th | Thai |
44 | | tr | Turkish |
45 | | uk | Ukrainian |
46 | | vi | Vietnamese |
47 |
--------------------------------------------------------------------------------
/STYLEGUIDE.md:
--------------------------------------------------------------------------------
1 | # FirebaseUI Web Style Guide
2 |
3 | Here are the style rules to follow for FirebaseUI:
4 |
5 | ## #1 Be consistent with the rest of the codebase
6 |
7 | This is the number one rule and should help determine what to do in most cases.
8 |
9 | ## #2 Respect Google JavaScript style guide
10 |
11 | The style guide accessible
12 | [here](https://google.github.io/styleguide/javascriptguide.xml) has to be fully
13 | respected.
14 |
15 | ## #3 Follow these grammar rules
16 |
17 | - Functions descriptions have to start with a verb using the third person of the
18 | singular.
19 | - *Ex: `/** Tests the validity of the input. */`*
20 | - Inline comments within procedures should always use the imperative.
21 | - *Ex: `// Check whether the value is true.`*
22 | - Acronyms have to be uppercased in comments.
23 | - *Ex: `// IP, DOM, CORS, URL...`*
24 | - *Exception: Identity Provider = IdP*
25 | - Acronyms have to be capitalized (but not uppercased) in variable names.
26 | - *Ex: `redirectUrl()`, `signInIdp()`*
27 | - Never use login/log in in comments. Use “sign-in” if it’s a noun, “sign in” if
28 | it’s a verb. The same goes for the variable name. Never use `login`; always use
29 | `signIn`.
30 | - *Ex: `// The sign-in method.`*
31 | - *Ex: `// Signs in the user.`*
32 | - Always start an inline comment with a capital (unless referring to the name of
33 | a variable/function), and end it with a period.
34 | - *Ex: `// This is a valid inline comment.`*
35 | - Always refer to FirebaseUI as “FirebaseUI” in comments (not Firebase UI,
36 | firebase…).
37 |
--------------------------------------------------------------------------------
/bower.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "firebaseui",
3 | "version": "6.0.0",
4 | "description": "Javascript library for customizable UI on top of Firebase SDK",
5 | "main": [
6 | "./dist/firebaseui.js",
7 | "./dist/firebaseui.css"
8 | ],
9 | "authors": [
10 | "Google"
11 | ],
12 | "license": "Apache-2.0",
13 | "keywords": [
14 | "Firebase",
15 | "authentication"
16 | ],
17 | "homepage": "https://github.com/firebase/firebaseui-web",
18 | "ignore": [
19 | "**/.*",
20 | "node_modules",
21 | "generated",
22 | "out"
23 | ],
24 | "dependencies": {
25 | "firebase": "^9.1.3 || ^10.0.0"
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/buildtools/all_tests.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | FirebaseUI Auth Tests
6 |
8 |
9 |
10 |
13 |
14 |
15 | FirebaseUI Auth Tests
16 |
17 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/buildtools/common.py:
--------------------------------------------------------------------------------
1 | # Copyright 2016 Google Inc. All Rights Reserved.
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS-IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | """Common methods and constants for generating test files."""
16 | import os
17 |
18 |
19 | # The directory in which test HTML files are generated.
20 | TESTS_BASE_PATH = "./generated/tests/"
21 |
22 |
23 | def cd_to_firebaseui_root():
24 | """Changes the current directory to the FirebaseUI root directory.
25 |
26 | This method assumes that this script is in the buildtools/ directory, which is
27 | a direct child of the root directory.
28 |
29 | This allows us to avoid writing to the wrong files.
30 | """
31 | root_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
32 | os.chdir(root_dir)
33 |
34 |
35 | def get_files_with_suffix(root, suffix):
36 | """Yields file names under a directory with a given suffix.
37 |
38 | Args:
39 | root: The path to the directory where we wish to search.
40 | suffix: The suffix we wish to search for.
41 |
42 | Yields:
43 | The paths to files under the directory that have the given suffix.
44 | """
45 | for root, _, files in os.walk(root):
46 | for file_name in files:
47 | if file_name.endswith(suffix):
48 | yield os.path.join(root, file_name)
49 |
--------------------------------------------------------------------------------
/buildtools/container/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM ubuntu:latest
2 |
3 | # Install dependencies: curl, git, jq, python2 and jre8.
4 | RUN apt-get update && \
5 | apt-get install -y curl git jq python-is-python3 openjdk-11-jre-headless nodejs npm wget
6 |
7 | # Print Node version and npm version
8 | RUN node -v
9 | RUN npm -v
10 |
11 | # Install hub
12 | RUN curl -fsSL --output hub.tgz https://github.com/github/hub/releases/download/v2.11.2/hub-linux-amd64-2.11.2.tgz
13 | RUN tar --strip-components=2 -C /usr/bin -xf hub.tgz hub-linux-amd64-2.11.2/bin/hub
14 |
15 | # Install the lastest Chrome stable version.
16 | # RUN wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
17 | # RUN dpkg -i google-chrome-stable_current_amd64.deb; apt-get -fy install
18 |
19 | # Pin Chrome v119 because we're pinning this version in CI.
20 | # TODO: Install the lastest Chrome stable version once we unpin chrome version in CI.
21 | RUN wget https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/119.0.6045.105/linux64/chrome-linux64.zip
22 | RUN dpkg -i google-chrome-stable_119.0.6045.105_amd64.deb; apt-get -fy install
23 |
--------------------------------------------------------------------------------
/buildtools/container/cloudbuild.yaml:
--------------------------------------------------------------------------------
1 | steps:
2 | - name: 'gcr.io/cloud-builders/docker'
3 | args: ['build', '-t', 'gcr.io/$PROJECT_ID/package-builder', '.']
4 | images: ['gcr.io/$PROJECT_ID/package-builder']
5 |
--------------------------------------------------------------------------------
/buildtools/country_data/README.md:
--------------------------------------------------------------------------------
1 | # Country data generator for FirebaseUI
2 |
3 | This generates the list of countries used for the phone number input, including
4 | country names, calling codes, and flags.
5 |
6 | ## Usage
7 | ```
8 | $ npm install
9 | $ npm run build
10 | ```
11 |
12 | This will output the generated files to ./generated. It generates the files:
13 | - country_data.js - A JS object of country data. This should be copied into
14 | firebaseui.auth.data.country.COUNTRY_LIST in javascript/data/country.js.
15 | - sprite.png - The sprite of country flags.
16 | - sprite@2x.png - The sprite of country flags, hi-res.
17 | - flags.css - The CSS that maps countries to the positions in the sprite.
18 |
--------------------------------------------------------------------------------
/buildtools/country_data/compress_pngs.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 | /*
3 | * Copyright 2016 Google Inc. All Rights Reserved.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License. You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software distributed under the
11 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12 | * express or implied. See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | */
15 |
16 | /*
17 | * Compresses all PNGs in a given directory using optipng. Optipng reduces
18 | * the file size of PNGs losslessly.
19 | *
20 | * Usage:
21 | * It is recommended to just run generate_country_data.sh. However, you can run
22 | * this on its own with:
23 | * $ ./compress_pngs.js ./source_images_dir ./output_images_dir
24 | */
25 |
26 | var fs = require('fs');
27 | var getDirectoryArgs = require('./get_directory_args.js');
28 | var imagemin = require('imagemin');
29 | var imageminOptipng = require('imagemin-optipng');
30 | var path = require('path');
31 |
32 | var dirs = getDirectoryArgs();
33 |
34 | var files = fs.readdirSync(dirs.from)
35 | .filter(function(file) {
36 | return file.endsWith('.png');
37 | })
38 | .map(function(file) {
39 | return path.join(dirs.from, file);
40 | });
41 | imagemin(files, dirs.to, {
42 | use: [
43 | imageminOptipng()
44 | ]
45 | });
46 |
--------------------------------------------------------------------------------
/buildtools/country_data/css.hbs:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Google Inc. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | {{#each layouts}}
15 | {{#each layout.items}}
16 | .firebaseui-flag-{{meta.name}} {
17 | background-position: -{{baseDim x}}px -{{baseDim y}}px;
18 | }
19 | {{/each}}
20 | {{/each}}
21 |
--------------------------------------------------------------------------------
/buildtools/country_data/generate_country_data.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # Copyright 2016 Google Inc. All Rights Reserved.
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License");
5 | # you may not use this file except in compliance with the License.
6 | # You may obtain a copy of the License at
7 | #
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS-IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 |
16 | #
17 | # Creates a CSS sprite of world flags.
18 | # Usage (outputting to directory ./out):
19 | # $ ./generate_country_data.sh ./out
20 | #
21 |
22 | if [[ $# -eq 0 ]] ; then
23 | echo "Usage: $0 /path/to/output/directory"
24 | exit 1
25 | fi
26 |
27 | # Retrieve flag source images from Github.
28 | TMP_DIR=$(mktemp -d)
29 | FLAGS_DIR="$TMP_DIR/region-flags"
30 | git clone https://github.com/googlei18n/region-flags.git "$FLAGS_DIR"
31 |
32 | # Convert SVGs to PNGs of the desired size.
33 | RENDERED_PNG_DIR="$TMP_DIR/png"
34 | mkdir "$RENDERED_PNG_DIR"
35 | ./make_flag_pngs.js "$FLAGS_DIR/svg" "$RENDERED_PNG_DIR"
36 | ls "$RENDERED_PNG_DIR"
37 |
38 | # Make the PNGs into a CSS sprite.
39 | SPRITE_DIR="$TMP_DIR/sprite"
40 | mkdir "$SPRITE_DIR"
41 | ./make_flag_sprite.js "$RENDERED_PNG_DIR" "$SPRITE_DIR"
42 |
43 | # Compress the images and write to the output directory.
44 | OUT_DIR="$1"
45 | mkdir -p "$OUT_DIR"
46 | cp "$SPRITE_DIR/flags.css" "$OUT_DIR"
47 | ./compress_pngs.js "$SPRITE_DIR" "$OUT_DIR"
48 |
49 | # Generate the country data JS.
50 | ./filter_country_data.js > "$OUT_DIR/country_data.js"
51 |
52 | # Generate the country data Markdown.
53 | ./make_country_list_for_readme.js > "$OUT_DIR/country_data.md"
54 |
--------------------------------------------------------------------------------
/buildtools/country_data/get_directory_args.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Google Inc. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | /*
16 | * Utilities for parsing command line arguments.
17 | */
18 |
19 | var fs = require('fs');
20 | var path = require('path');
21 |
22 | /**
23 | * Asserts that the given path points to a directory and exits otherwise.
24 | * @param {string} path
25 | */
26 | function assertIsDirectory(path) {
27 | try {
28 | if (!fs.lstatSync(path).isDirectory()) {
29 | console.log('Path "' + path + '" is not a directory.');
30 | process.exit();
31 | }
32 | } catch (e) {
33 | console.log('Directory "' + path + '" could not be found.');
34 | process.exit();
35 | }
36 | }
37 |
38 | /**
39 | * Gets the input and output directories from the script arguments.
40 | * @return {!Object}
41 | */
42 | module.exports = function() {
43 | // The file name of the script using this library.
44 | var currentScript = path.parse(process.argv[1]).base;
45 |
46 | if (process.argv.length !== 4) {
47 | console.log('Usage: ' + currentScript + ' /path/to/input /path/to/output');
48 | process.exit();
49 | }
50 |
51 | var args = process.argv.slice(2);
52 | var fromDir = args[0];
53 | var toDir = args[1];
54 |
55 | assertIsDirectory(fromDir);
56 | assertIsDirectory(toDir);
57 |
58 | return {
59 | from: fromDir,
60 | to: toDir
61 | };
62 | };
63 |
--------------------------------------------------------------------------------
/buildtools/country_data/make_country_list_for_readme.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 | /*
3 | * Copyright 2016 Google Inc. All Rights Reserved.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License. You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software distributed under the
11 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12 | * express or implied. See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | */
15 |
16 | /*
17 | * Converts the data in full_country_data to a Markdown table.
18 | *
19 | * Usage:
20 | * It is recommended to just run generate_country_data.sh. However, you can run
21 | * this on its own with:
22 | * $ ./make_country_list_for_readme.js
23 | *
24 | * Then, take the output and put it between the START COPIED TABLE and END
25 | * COPIED TABLE markers in javascript/data/README.md.
26 | */
27 |
28 | var fullCountryData = require('./full_country_data.json');
29 |
30 | // Keep track of seen country codes to eliminate duplicates.
31 | var seenCountryCodes = {};
32 |
33 | // Print the table header.
34 | console.log('| Code | Country |');
35 | console.log('| ---- | ------- |');
36 |
37 | for (var i = 0; i < fullCountryData.length; i++) {
38 | var country = fullCountryData[i];
39 |
40 | // Don't print duplicate entries.
41 | if (seenCountryCodes[country.iso2_cc]) {
42 | continue;
43 | }
44 | seenCountryCodes[country.iso2_cc] = true;
45 |
46 | // Replace square brackets with parentheses, for Markdown support.
47 | var normalizedName = country.name.replace(/\[/g, '(').replace(/\]/g, ')');
48 |
49 | // Print the Markdown table row.
50 | console.log('| ' + country.iso2_cc + ' | ' + normalizedName + ' |');
51 | }
52 |
--------------------------------------------------------------------------------
/buildtools/country_data/make_flag_pngs.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 | /*
3 | * Copyright 2016 Google Inc. All Rights Reserved.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License. You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software distributed under the
11 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12 | * express or implied. See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | */
15 |
16 | /*
17 | * Converts all SVGs in a directory to PNGs.
18 | *
19 | * Usage:
20 | * It is recommended to just run generate_country_data.sh. However, you can run
21 | * this on its own with:
22 | * $ ./make_flag_pngs.js ./svg_images_dir ./png_images_dir
23 | */
24 |
25 | var fs = require('fs');
26 | var getDirectoryArgs = require('./get_directory_args.js');
27 | var path = require('path');
28 | var svgexport = require('svgexport');
29 |
30 | var dirs = getDirectoryArgs();
31 |
32 | /* The desired resolution of each PNG. */
33 | var OUTPUT_RESOLUTION = '48:28';
34 |
35 | var files = fs.readdirSync(dirs.from);
36 | var svgExportInput = files.filter(function(file) {
37 | // Ignore non-top-level flags (e.g. USA state flags).
38 | return file.match(/^[A-Z][A-Z]\.svg$/);
39 | }).map(function(file) {
40 | var fromPath = path.join(dirs.from, file);
41 | var toPath = path.join(dirs.to, path.parse(file).name + '.png');
42 |
43 | return {
44 | input: [fromPath, 'pad', OUTPUT_RESOLUTION],
45 | output: [toPath]
46 | };
47 | });
48 | svgexport.render(svgExportInput);
49 |
--------------------------------------------------------------------------------
/buildtools/country_data/make_flag_sprite.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 | /*
3 | * Copyright 2016 Google Inc. All Rights Reserved.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License. You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software distributed under the
11 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12 | * express or implied. See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | */
15 |
16 | /*
17 | * Creates a CSS sprite of the images in the given directory.
18 | * The CSS is generated according to the template css.hbs.
19 | *
20 | * Usage:
21 | * It is recommended to just run generate_country_data.sh. However, you can run
22 | * this on its own with:
23 | * $ ./make_flag_sprite.js ./source_images_dir ./out_dir
24 | */
25 |
26 | var fs = require('fs');
27 | var getDirectoryArgs = require('./get_directory_args.js');
28 | var path = require('path');
29 | var sprity = require('sprity');
30 |
31 | var dirs = getDirectoryArgs();
32 |
33 | var options = {
34 | out: dirs.to,
35 | src: dirs.from + '/*',
36 | style: 'flags.css',
37 | margin: 0,
38 | // Generate both standard-res and high-res images.
39 | dimension: [{
40 | ratio: 1, dpi: 72
41 | }, {
42 | ratio: 2, dpi: 192
43 | }],
44 | template: 'css.hbs'
45 | };
46 | sprity.create(options);
47 |
--------------------------------------------------------------------------------
/buildtools/country_data/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "firebaseui-phone-auth-config-generator",
3 | "version": "1.0.0",
4 | "description": "Generates data and a flag sprite for countries for use in FirebaseUI.",
5 | "scripts": {
6 | "build": "./generate_country_data.sh ./generated"
7 | },
8 | "license": "Apache-2.0",
9 | "devDependencies": {
10 | "imagemin": "^5.2.2",
11 | "imagemin-optipng": "^5.2.1",
12 | "sprity": "^1.0.8",
13 | "svgexport": "^0.3.2"
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/buildtools/gen_all_tests_js.py:
--------------------------------------------------------------------------------
1 | # Copyright 2016 Google Inc. All Rights Reserved.
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS-IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | """Generates the all_tests.js file.
16 |
17 | all_tests.js tells all_tests.html the paths to the files to test.
18 |
19 | Usage:
20 | $ python ./buildtools/gen_all_tests_js.py > generated/all_tests.js
21 | """
22 |
23 | import common
24 |
25 |
26 | def main():
27 | common.cd_to_firebaseui_root()
28 | print("var allTests = [")
29 | _print_test_files_under_root(common.TESTS_BASE_PATH)
30 | print("];")
31 | # The following is required in the context of protractor.
32 | print("if (typeof module !== 'undefined' && module.exports) {")
33 | print(" module.exports = allTests;")
34 | print("}")
35 |
36 |
37 | def _print_test_files_under_root(root):
38 | """Prints all test HTML files found under a given directory (recursively).
39 |
40 | Args:
41 | root: The path to the directory.
42 | """
43 | for file_name in common.get_files_with_suffix(root, "_test.html"):
44 | print(" '%s'," % file_name[2:]) # Ignore the beginning './'.
45 |
46 |
47 | if __name__ == "__main__":
48 | main()
49 |
--------------------------------------------------------------------------------
/buildtools/generate_test_files.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # Copyright 2016 Google Inc. All Rights Reserved.
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License");
5 | # you may not use this file except in compliance with the License.
6 | # You may obtain a copy of the License at
7 | #
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS-IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 |
16 | # Generates the temporary files needed for tests to run, putting them in the
17 | # generated/ directory.
18 | #
19 | # Usage:
20 | # $ buildtools/generate_test_files.sh
21 |
22 | # CD to the root FirebaseUI directory, which should be the parent directory of
23 | # buildtools/.
24 | cd "$(dirname $(dirname "$0"))"
25 |
26 | echo "Compiling templates..."
27 | npm run build-soy
28 | mkdir -p ./generated
29 | cp -r ./out/soy/* ./generated
30 |
31 | echo "Generating dependency file..."
32 | node node_modules/.bin/closure-make-deps \
33 | --closure-path="node_modules/google-closure-library/closure/goog" \
34 | --file="node_modules/google-closure-library/closure/goog/deps.js" \
35 | --root="soy" \
36 | --root="generated" \
37 | --root="javascript" \
38 | --root="node_modules/google-closure-templates/javascript" \
39 | --exclude="generated/all_tests.js" \
40 | --exclude="generated/deps.js" \
41 | --exclude="javascript/externs" \
42 | > generated/deps.js
43 |
44 | echo "Generating test HTML files..."
45 | python ./buildtools/gen_test_html.py
46 | python ./buildtools/gen_all_tests_js.py > generated/all_tests.js
47 |
48 | echo "Done."
49 |
--------------------------------------------------------------------------------
/buildtools/publish/cloudbuild.yaml:
--------------------------------------------------------------------------------
1 | steps:
2 | # Decrypt the SSH key.
3 | - name: 'gcr.io/cloud-builders/gcloud'
4 | args: ['kms', 'decrypt', '--ciphertext-file=deploy_key.enc', '--plaintext-file=/root/.ssh/id_rsa', '--location=global', '--keyring=${_KEY_RING}', '--key=${_KEY_NAME}']
5 |
6 | # Decrypt the Twitter credentials.
7 | - name: 'gcr.io/cloud-builders/gcloud'
8 | args: ['kms', 'decrypt', '--ciphertext-file=twitter.json.enc', '--plaintext-file=twitter.json', '--location=global', '--keyring=${_KEY_RING}', '--key=${_KEY_NAME}']
9 |
10 | # Decrypt the npm credentials.
11 | - name: 'gcr.io/cloud-builders/gcloud'
12 | args: ['kms', 'decrypt', '--ciphertext-file=npmrc.enc', '--plaintext-file=npmrc', '--location=global', '--keyring=${_KEY_RING}', '--key=${_KEY_NAME}']
13 |
14 | # Decrypt the hub (GitHub) credentials.
15 | - name: 'gcr.io/cloud-builders/gcloud'
16 | args: ['kms', 'decrypt', '--ciphertext-file=hub.enc', '--plaintext-file=hub', '--location=global', '--keyring=${_KEY_RING}', '--key=${_KEY_NAME}']
17 |
18 | # Set up git with key and domain.
19 | - name: 'gcr.io/cloud-builders/git'
20 | entrypoint: 'bash'
21 | args:
22 | - '-c'
23 | - |
24 | chmod 600 /root/.ssh/id_rsa
25 | cat </root/.ssh/config
26 | Hostname github.com
27 | IdentityFile /root/.ssh/id_rsa
28 | EOF
29 | ssh-keyscan github.com >> /root/.ssh/known_hosts
30 |
31 | # Clone the repository.
32 | - name: 'gcr.io/cloud-builders/git'
33 | args: ['clone', 'git@github.com:${_REPOSITORY_ORG}/${_REPOSITORY_NAME}']
34 |
35 | # Set up the Git configuration.
36 | - name: 'gcr.io/cloud-builders/git'
37 | dir: '${_REPOSITORY_NAME}'
38 | args: ['config', '--global', 'user.email', 'firebase-oss-bot@google.com']
39 | - name: 'gcr.io/cloud-builders/git'
40 | dir: '${_REPOSITORY_NAME}'
41 | args: ['config', '--global', 'user.name', 'Google Open Source Bot']
42 |
43 | # Set up the Twitter credentials.
44 | - name: 'gcr.io/$PROJECT_ID/package-builder'
45 | entrypoint: 'cp'
46 | args: ['-v', 'twitter.json', '${_REPOSITORY_NAME}/buildtools/twitter.json']
47 |
48 | # Set up the npm credentials.
49 | - name: 'gcr.io/$PROJECT_ID/package-builder'
50 | entrypoint: 'bash'
51 | args: ['-c', 'cp -v npmrc ~/.npmrc']
52 |
53 | # Set up the hub credentials.
54 | - name: 'gcr.io/$PROJECT_ID/package-builder'
55 | entrypoint: 'bash'
56 | args: ['-c', 'mkdir -vp ~/.config && cp -v hub ~/.config/hub']
57 |
58 | # Publish the package.
59 | - name: 'gcr.io/$PROJECT_ID/package-builder'
60 | dir: '${_REPOSITORY_NAME}'
61 | args: ['bash', './buildtools/publish.sh', '${_VERSION}']
62 | env:
63 | - 'REPOSITORY_ORG=${_REPOSITORY_ORG}'
64 | - 'REPOSITORY_NAME=${_REPOSITORY_NAME}'
65 |
66 | timeout: 1800s
67 |
68 | options:
69 | volumes:
70 | - name: 'ssh'
71 | path: /root/.ssh
72 |
73 | substitutions:
74 | _VERSION: ''
75 | _KEY_RING: 'cloud-build-ring'
76 | _KEY_NAME: 'publish'
77 | _REPOSITORY_ORG: 'firebase'
78 | _REPOSITORY_NAME: 'firebaseui-web'
79 |
--------------------------------------------------------------------------------
/buildtools/publish/deploy_key.enc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/firebase/firebaseui-web/33ee99f44947bbf2f8e66763b5a2df850a7d1a1c/buildtools/publish/deploy_key.enc
--------------------------------------------------------------------------------
/buildtools/publish/hub.enc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/firebase/firebaseui-web/33ee99f44947bbf2f8e66763b5a2df850a7d1a1c/buildtools/publish/hub.enc
--------------------------------------------------------------------------------
/buildtools/publish/npmrc.enc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/firebase/firebaseui-web/33ee99f44947bbf2f8e66763b5a2df850a7d1a1c/buildtools/publish/npmrc.enc
--------------------------------------------------------------------------------
/buildtools/publish/twitter.json.enc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/firebase/firebaseui-web/33ee99f44947bbf2f8e66763b5a2df850a7d1a1c/buildtools/publish/twitter.json.enc
--------------------------------------------------------------------------------
/buildtools/run_demo.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # Copyright 2016 Google Inc. All Rights Reserved.
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License");
5 | # you may not use this file except in compliance with the License.
6 | # You may obtain a copy of the License at
7 | #
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS-IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 |
16 | # Runs the server for the demo page.
17 | #
18 | # Usage:
19 | # $ buildtools/run_demo.sh
20 |
21 | # CD to the root FirebaseUI directory, which should be the parent directory of
22 | # buildtools/.
23 | cd "$(dirname $(dirname "$0"))"
24 |
25 | cp -r dist demo/public
26 | cd demo
27 | firebase serve
28 |
--------------------------------------------------------------------------------
/buildtools/sauce_connect.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # Copyright 2016 Google Inc. All Rights Reserved.
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License");
5 | # you may not use this file except in compliance with the License.
6 | # You may obtain a copy of the License at
7 | #
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS-IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 |
16 | #
17 | # Download and install SauceConnect under Linux 64-bit. To be used when testing
18 | # with SauceLabs locally. See the instructions in protractor.conf.js file.
19 | #
20 | # Script copied from the Closure Library repository:
21 | # https://github.com/google/closure-library/blob/master/scripts/ci/sauce_connect.sh
22 | #
23 |
24 | # Setup and start Sauce Connect locally.
25 | if [[ $OSTYPE == 'darwin'* ]]; then
26 | CONNECT_URL="https://saucelabs.com/downloads/sc-4.9.2-osx.zip"
27 | else
28 | CONNECT_URL="https://saucelabs.com/downloads/sc-4.9.2-linux.tar.gz"
29 | fi
30 | CONNECT_DIR="/tmp/sauce-connect-$RANDOM"
31 | CONNECT_DOWNLOAD="sc-latest-linux.tar.gz"
32 |
33 | BROWSER_PROVIDER_READY_FILE="/tmp/sauce-connect-ready"
34 |
35 | # Get Connect and start it.
36 | mkdir -p $CONNECT_DIR
37 | cd $CONNECT_DIR
38 | curl $CONNECT_URL -o $CONNECT_DOWNLOAD 2> /dev/null 1> /dev/null
39 | mkdir sauce-connect
40 |
41 | if [[ $OSTYPE == 'darwin'* ]]; then
42 | unzip -d sauce-connect $CONNECT_DOWNLOAD &&
43 | f=(sauce-connect/*) &&
44 | mv sauce-connect/*/* sauce-connect &&
45 | rmdir "${f[@]}"
46 | else
47 | tar --extract --file=$CONNECT_DOWNLOAD --strip-components=1 \
48 | --directory=sauce-connect > /dev/null
49 | fi
50 |
51 | rm $CONNECT_DOWNLOAD
52 |
53 | function removeFiles() {
54 | echo "Removing SauceConnect files..."
55 | rm -rf $CONNECT_DIR
56 | }
57 |
58 | trap removeFiles EXIT
59 |
60 | # This will be used by Protractor to connect to SauceConnect
61 | if [[(! -z "$GITHUB_RUN_ID")]]; then
62 | TUNNEL_IDENTIFIER="$GITHUB_RUN_ID"
63 | else
64 | TUNNEL_IDENTIFIER="tunnelId-$RANDOM"
65 | fi
66 |
67 | echo ""
68 | echo "========================================================================="
69 | echo " Tunnel Identifier to pass to Protractor:"
70 | echo " $TUNNEL_IDENTIFIER"
71 | echo "========================================================================="
72 | echo ""
73 | echo ""
74 |
75 | echo "Starting Sauce Connect..."
76 |
77 | # Start SauceConnect.
78 | sauce-connect/bin/sc -u $SAUCE_USERNAME -k $SAUCE_ACCESS_KEY \
79 | -i $TUNNEL_IDENTIFIER -f $BROWSER_PROVIDER_READY_FILE
80 |
--------------------------------------------------------------------------------
/buildtools/test_template.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
12 |
13 |
14 | $dom
15 |
16 |
17 |
--------------------------------------------------------------------------------
/buildtools/tweet.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Google Inc. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | "use strict";
15 |
16 | const fs = require('fs');
17 | const Twitter = require('twitter');
18 |
19 | /**
20 | * Print the usage of the script.
21 | */
22 | function printUsage() {
23 | console.error(`
24 | Usage: tweet.js
25 |
26 | Credentials must be stored in "twitter.json" in this directory.
27 |
28 | Arguments:
29 | - version: Version of module that was released. e.g. "1.2.3"
30 | `);
31 | process.exit(1);
32 | }
33 |
34 | /**
35 | * Returns the URL of the release note.
36 | * @param {string} version The version number.
37 | * @return {string} The URL of the release note.
38 | */
39 | function getUrl(version) {
40 | return `https://github.com/firebase/firebaseui-web/releases/tag/v${version}`;
41 | }
42 |
43 | if (process.argv.length !== 3) {
44 | console.error('Missing arguments.');
45 | printUsage();
46 | }
47 |
48 | const version = process.argv.pop();
49 | if (!version.match(/^\d+\.\d+\.\d+$/)) {
50 | console.error(`Version "${version}" not a version number.`);
51 | printUsage();
52 | }
53 |
54 | // Check Twitter account credential.
55 | if (!fs.existsSync(`${__dirname}/twitter.json`)) {
56 | console.error('Missing credentials.');
57 | printUsage();
58 | }
59 | const creds = require('./twitter.json');
60 |
61 | const client = new Twitter(creds);
62 |
63 | // Send tweet with release note.
64 | client.post(
65 | 'statuses/update',
66 | {
67 | status: `v${version} of @Firebase FirebaseUI for Web is available. ` +
68 | `Release notes: ${getUrl(version)}`
69 | },
70 | (err) => {
71 | if (err) {
72 | console.error(err);
73 | process.exit(1);
74 | }
75 | }
76 | );
77 |
--------------------------------------------------------------------------------
/cut:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/firebase/firebaseui-web/33ee99f44947bbf2f8e66763b5a2df850a7d1a1c/cut
--------------------------------------------------------------------------------
/demo/database.rules.json:
--------------------------------------------------------------------------------
1 | // No Read/Write permitted.
2 | {
3 | "rules": {
4 | ".read": false,
5 | ".write": false
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/demo/firebase.json:
--------------------------------------------------------------------------------
1 | {
2 | "database": {
3 | "rules": "database.rules.json"
4 | },
5 | "hosting": {
6 | "public": "public",
7 | "rewrites": [
8 | {
9 | "source": "/widget",
10 | "destination": "/widget.html"
11 | },
12 | {
13 | "source": "**",
14 | "destination": "/index.html"
15 | }
16 | ]
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/demo/public/common.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Google Inc. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | /**
16 | * Common methods for both the main app page and standalone widget.
17 | */
18 |
19 | /**
20 | * @return {string} The reCAPTCHA rendering mode from the configuration.
21 | */
22 | function getRecaptchaMode() {
23 | var config = parseQueryString(location.hash);
24 | return config['recaptcha'] === 'invisible' ?
25 | 'invisible' : 'normal';
26 | }
27 |
28 |
29 | /**
30 | * @return {string} The email signInMethod from the configuration.
31 | */
32 | function getEmailSignInMethod() {
33 | var config = parseQueryString(location.hash);
34 | return config['emailSignInMethod'] === 'password' ?
35 | 'password' : 'emailLink';
36 | }
37 |
38 |
39 | /**
40 | * @return {boolean} The disable sign up status from the configuration.
41 | */
42 | function getDisableSignUpStatus() {
43 | var config = parseQueryString(location.hash);
44 | return config['disableEmailSignUpStatus'] === 'true';
45 | }
46 |
47 |
48 | /**
49 | * @return {boolean} The admin restricted operation status from the configuration.
50 | */
51 | function getAdminRestrictedOperationStatus() {
52 | var config = parseQueryString(location.hash);
53 | return config['adminRestrictedOperationStatus'] === 'true';
54 | }
55 |
56 |
57 | /**
58 | * @param {string} queryString The full query string.
59 | * @return {!Object} The parsed query parameters.
60 | */
61 | function parseQueryString(queryString) {
62 | // Remove first character if it is ? or #.
63 | if (queryString.length &&
64 | (queryString.charAt(0) == '#' || queryString.charAt(0) == '?')) {
65 | queryString = queryString.substring(1);
66 | }
67 | var config = {};
68 | var pairs = queryString.split('&');
69 | for (var i = 0; i < pairs.length; i++) {
70 | var pair = pairs[i].split('=');
71 | if (pair.length == 2) {
72 | config[pair[0]] = pair[1];
73 | }
74 | }
75 | return config;
76 | }
77 |
--------------------------------------------------------------------------------
/demo/public/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "FirebaseUI Demo",
3 | "short_name": "FirebaseUIDemo",
4 | "start_url": "/",
5 | "display": "standalone",
6 | "background_color": "#fff",
7 | "lang": "en-US",
8 | "description": "FirebaseUI Demo application.",
9 | "prefer_related_applications": false,
10 | "theme_color": "#fff",
11 | "scope": "/",
12 | "orientation": "portrait-primary"
13 | }
14 |
--------------------------------------------------------------------------------
/demo/public/sample-config.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Google Inc. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | var config = {
16 | apiKey: "YOUR_API_KEY",
17 | authDomain: "your-app.firebaseapp.com",
18 | databaseURL: "https://your-app.firebaseio.com",
19 | storageBucket: "your-app.appspot.com",
20 | };
21 | firebase.initializeApp(config);
22 |
23 |
24 | // Google OAuth Client ID, needed to support One-tap sign-up.
25 | // Set to null if One-tap sign-up is not supported.
26 | var CLIENT_ID =
27 | 'YOUR_OAUTH_CLIENT_ID';
28 |
--------------------------------------------------------------------------------
/demo/public/style.css:
--------------------------------------------------------------------------------
1 | * {
2 | box-sizing: border-box;
3 | }
4 |
5 | body {
6 | margin: 0;
7 | }
8 |
9 | #container {
10 | max-width: 600px;
11 | margin: 0 auto;
12 | text-align: center;
13 | }
14 |
15 | .clearfix {
16 | clear: both;
17 | }
18 |
19 | .hidden {
20 | display: none;
21 | }
22 |
23 | #user-info {
24 | border: 1px solid #CCC;
25 | clear: both;
26 | margin: 0 auto 20px;
27 | max-width: 400px;
28 | padding: 10px;
29 | text-align: left;
30 | }
31 |
32 | #photo-container {
33 | background-color: #EEE;
34 | border: 1px solid #CCC;
35 | float: left;
36 | height: 80px;
37 | margin-right: 10px;
38 | width: 80px;
39 | }
40 |
41 | #photo {
42 | height: 80px;
43 | margin: 0;
44 | width: 80px;
45 | }
46 |
47 | @media (max-width: 300px) {
48 | #photo-container,
49 | #photo {
50 | height: 40px;
51 | width: 40px;
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/demo/screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/firebase/firebaseui-web/33ee99f44947bbf2f8e66763b5a2df850a7d1a1c/demo/screenshot.png
--------------------------------------------------------------------------------
/image/anonymous.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/firebase/firebaseui-web/33ee99f44947bbf2f8e66763b5a2df850a7d1a1c/image/anonymous.png
--------------------------------------------------------------------------------
/image/apple.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/firebase/firebaseui-web/33ee99f44947bbf2f8e66763b5a2df850a7d1a1c/image/apple.png
--------------------------------------------------------------------------------
/image/facebook.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
17 |
--------------------------------------------------------------------------------
/image/flags_sprite.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/firebase/firebaseui-web/33ee99f44947bbf2f8e66763b5a2df850a7d1a1c/image/flags_sprite.png
--------------------------------------------------------------------------------
/image/flags_sprite_2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/firebase/firebaseui-web/33ee99f44947bbf2f8e66763b5a2df850a7d1a1c/image/flags_sprite_2x.png
--------------------------------------------------------------------------------
/image/google.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
22 |
--------------------------------------------------------------------------------
/image/mail.svg:
--------------------------------------------------------------------------------
1 |
2 |
6 |
--------------------------------------------------------------------------------
/image/microsoft.svg:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/image/oidc.svg:
--------------------------------------------------------------------------------
1 |
2 |
12 |
--------------------------------------------------------------------------------
/image/phone.svg:
--------------------------------------------------------------------------------
1 |
2 |
6 |
--------------------------------------------------------------------------------
/image/saml.svg:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/image/success_status.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/firebase/firebaseui-web/33ee99f44947bbf2f8e66763b5a2df850a7d1a1c/image/success_status.png
--------------------------------------------------------------------------------
/image/test/recaptcha-widget.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/firebase/firebaseui-web/33ee99f44947bbf2f8e66763b5a2df850a7d1a1c/image/test/recaptcha-widget.png
--------------------------------------------------------------------------------
/image/twitter.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
17 |
--------------------------------------------------------------------------------
/image/yahoo.svg:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/javascript/externs/accountchooser.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Google Inc. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | /**
16 | * @fileoverview Externs for accountchooser.com APIs.
17 | * @externs
18 | */
19 |
20 | /**
21 | * Namespace for accountchooser.com API.
22 | */
23 | var accountchooser = {};
24 |
25 | /**
26 | * @interface
27 | */
28 | accountchooser.Api = function() {};
29 |
30 | /**
31 | * @param {!Object} config
32 | * @return {!accountchooser.Api}
33 | */
34 | accountchooser.Api.init = function(config) {};
35 |
36 | /**
37 | * @param {!Array} accounts
38 | * @param {?Object=} opt_config
39 | */
40 | accountchooser.Api.prototype.store = function(accounts, opt_config) {};
41 |
42 | /**
43 | * @param {!Array} accounts
44 | * @param {?Object=} opt_config
45 | */
46 | accountchooser.Api.prototype.select = function(accounts, opt_config) {};
47 |
48 | /**
49 | * @param {!Object} account
50 | * @param {?Object=} opt_config
51 | */
52 | accountchooser.Api.prototype.update = function(account, opt_config) {};
53 |
54 | /**
55 | * @param {!function(boolean=, ?Object=)} callback
56 | */
57 | accountchooser.Api.prototype.checkDisabled = function(callback) {};
58 |
59 | /**
60 | * @param {!function(boolean=, ?Object=)} callback
61 | */
62 | accountchooser.Api.prototype.checkEmpty = function(callback) {};
63 |
64 | /**
65 | * @param {!Object} account
66 | * @param {!function(boolean=, ?Object=)} callback
67 | */
68 | accountchooser.Api.prototype.checkAccountExist = function(account, callback) {};
69 |
70 | /**
71 | * @param {!Object} account
72 | * @param {!function(boolean=, ?Object=)} callback
73 | */
74 | accountchooser.Api.prototype.checkShouldUpdate = function(account, callback) {};
75 |
--------------------------------------------------------------------------------
/javascript/externs/dialog_polyfill.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Google Inc. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | /**
16 | * @fileoverview Externs for dialog_polyfill. This is not the actual externs and
17 | * is needed to suppress compilation errors.
18 | * @externs
19 | */
20 |
21 | var define;
22 | var module;
23 |
--------------------------------------------------------------------------------
/javascript/externs/googleyolo.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Smart Lock API externs.
3 | * Note that this SDK is not dedicated to One-tap API. It seems to cover other
4 | * Google sign-in related functionality. We may want to consider renaming
5 | * these APIs to not be One-tap specific.
6 | * https://developers.google.com/identity/one-tap/web/reference/js-reference
7 | *
8 | * @externs
9 | */
10 |
11 | /**
12 | * @record
13 | * @struct
14 | */
15 | function SmartLockOptions() {}
16 |
17 | /** @type {string} */
18 | SmartLockOptions.prototype.client_id;
19 |
20 | /** @type {?boolean|undefined} */
21 | SmartLockOptions.prototype.auto_select;
22 |
23 | /** @type {function(SmartLockCredential)} */
24 | SmartLockOptions.prototype.callback;
25 |
26 |
27 | /**
28 | * @record
29 | * @struct
30 | */
31 | function SmartLockCredential() {}
32 |
33 | /** @type {string|undefined} */
34 | SmartLockCredential.prototype.credential;
35 |
36 | /** @type {string|undefined} */
37 | SmartLockCredential.prototype.clientId;
38 |
39 | /** @type {string|undefined} */
40 | SmartLockCredential.prototype.select_by;
41 |
42 | /**
43 | * @record
44 | * @struct
45 | */
46 | function SmartLockApi() {}
47 |
48 | /**
49 | * Initializes GSI sign in process.
50 | *
51 | * @param {!SmartLockOptions} options
52 | * Describes the types of credentials that are supported by the origin,
53 | * and customization properties for the display of any UI pertaining to
54 | * releasing this credential.
55 | */
56 | SmartLockApi.prototype.initialize = function(options) {};
57 |
58 | /**
59 | * Triggers the prompt to display.
60 | */
61 | SmartLockApi.prototype.prompt = function() {};
62 |
63 | /**
64 | * Cancels the last operation triggered.
65 | */
66 | SmartLockApi.prototype.cancel = function() {};
67 |
--------------------------------------------------------------------------------
/javascript/externs/recaptcha.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Google Inc. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | /**
16 | * @fileoverview Externs for reCAPTCHA.
17 | * @externs
18 | */
19 |
20 | var grecaptcha;
21 |
--------------------------------------------------------------------------------
/javascript/testing/appclient.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Google Inc. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | /**
16 | * @fileoverview Fake app client for testing.
17 | */
18 |
19 | goog.module('firebaseui.auth.testing.FakeAppClient');
20 | goog.module.declareLegacyNamespace();
21 | goog.setTestOnly();
22 |
23 | const Disposable = goog.require('goog.Disposable');
24 | const FakeAuthClient = goog.require('firebaseui.auth.testing.FakeAuthClient');
25 | const GoogPromise = goog.require('goog.Promise');
26 |
27 |
28 | /**
29 | * Fake App client class.
30 | */
31 | class FakeAppClient extends Disposable {
32 | /**
33 | * @param {!Object} options The app configuration.
34 | * @param {?string=} name The optional app name.
35 | */
36 | constructor(options, name) {
37 | super();
38 | this.options = options || {};
39 | this.name = name || '[DEFAULT]';
40 | // Initialize a fake auth client instance.
41 | this.auth_ = new FakeAuthClient(this);
42 | };
43 |
44 |
45 | /**
46 | * @return {!FakeAuthClient} The associated fake Auth client instance.
47 | */
48 | auth() {
49 | return this.auth_;
50 | }
51 |
52 |
53 | /**
54 | * Dummy app delete method.
55 | * @return {!GoogPromise} The promise that resolves upon deletion.
56 | */
57 | delete() {
58 | return GoogPromise.resolve();
59 | }
60 | }
61 |
62 |
63 | exports = FakeAppClient;
64 |
--------------------------------------------------------------------------------
/javascript/testing/recaptchaverifier_test.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Google Inc. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | /**
16 | * @fileoverview Tests for recaptchaverifier.js
17 | */
18 |
19 | goog.provide('firebaseui.auth.RecaptchaVerifierTest');
20 |
21 | goog.require('firebaseui.auth.testing.RecaptchaVerifier');
22 | goog.require('goog.testing.jsunit');
23 |
24 | goog.setTestOnly('firebaseui.auth.RecaptchaVerifierTest');
25 |
26 |
27 | function testRecaptchaVerifier_success() {
28 | var app = {};
29 | var unfilteredParams = {
30 | 'size': 'compact',
31 | 'callback': function(token) {},
32 | 'expired-callback': function() {}
33 | };
34 | var filteredParams = {'size': 'compact'};
35 | var myMock = new firebaseui.auth.testing.RecaptchaVerifier(
36 | 'id', unfilteredParams, app);
37 | myMock.install();
38 | myMock.render().then(function(widgetId) {
39 | assertEquals(widgetId, 10);
40 | return myMock.verify();
41 | }).then(function(response) {
42 | assertEquals('RECAPTCHA_TOKEN', response);
43 | myMock.clear();
44 | });
45 | return myMock.process().then(function() {
46 | // Callbacks should be filtered out.
47 | myMock.assertInitializedWithParameters(
48 | 'id', filteredParams, app);
49 | // Same parameters should be returned, including the 2 callbacks.
50 | assertObjectEquals(unfilteredParams, myMock.getParameters());
51 | myMock.assertRender([], 10);
52 | myMock.assertVerify([], 'RECAPTCHA_TOKEN');
53 | return myMock.process();
54 | }).then(function() {
55 | myMock.assertClear();
56 | return myMock.uninstall();
57 | });
58 | }
59 |
60 |
61 | function testRecaptchaVerifier_clearError() {
62 | var app = {};
63 | var myMock = new firebaseui.auth.testing.RecaptchaVerifier(
64 | 'id', {'size': 'compact'}, app);
65 | myMock.install();
66 | myMock.render().then(function(widgetId) {
67 | assertEquals(widgetId, 10);
68 | return myMock.verify();
69 | }).then(function(response) {
70 | assertEquals('RECAPTCHA_TOKEN', response);
71 | });
72 | return myMock.process().then(function() {
73 | myMock.assertInitializedWithParameters(
74 | 'id', {'size': 'compact'}, app);
75 | myMock.assertRender([], 10);
76 | myMock.assertVerify([], 'RECAPTCHA_TOKEN');
77 | myMock.assertNotClear();
78 | return myMock.process();
79 | }).then(function() {
80 | myMock.assertClear();
81 | }).thenCatch(function(error) {
82 | assertEquals('reCAPTCHA verifier not cleared!', error.message);
83 | });
84 | }
85 |
--------------------------------------------------------------------------------
/javascript/ui/element/form.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Google Inc. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | /**
16 | * @fileoverview Binds handlers for form (submit button and link) UI element.
17 | */
18 |
19 | goog.provide('firebaseui.auth.ui.element.form');
20 |
21 | goog.require('firebaseui.auth.ui.element');
22 | goog.require('goog.ui.Component');
23 |
24 |
25 | goog.scope(function() {
26 | var element = firebaseui.auth.ui.element;
27 |
28 |
29 | /**
30 | * @return {Element} The submit button.
31 | * @this {goog.ui.Component}
32 | */
33 | element.form.getSubmitElement = function() {
34 | return this.getElementByClass('firebaseui-id-submit');
35 | };
36 |
37 |
38 | /**
39 | * @return {Element} The secondary link.
40 | * @this {goog.ui.Component}
41 | */
42 | element.form.getSecondaryLinkElement = function() {
43 | return this.getElementByClass('firebaseui-id-secondary-link');
44 | };
45 |
46 |
47 | /**
48 | * Initializes the form element.
49 | * @param {function(?)} onSubmit Callback to invoke when the form is submitted
50 | * (the submit button is clicked).
51 | * @param {function(?)=} opt_onLinkClick Callback to invoke when the secondary
52 | * link (if there is one) in the form is clicked.
53 | * @this {goog.ui.Component}
54 | */
55 | element.form.initFormElement = function(onSubmit, opt_onLinkClick) {
56 | var submitElement = element.form.getSubmitElement.call(this);
57 | element.listenForActionEvent(this, submitElement, function(e) {
58 | onSubmit(e);
59 | });
60 | var linkElement = element.form.getSecondaryLinkElement.call(this);
61 | if (linkElement && opt_onLinkClick) {
62 | element.listenForActionEvent(this, linkElement, function(e) {
63 | opt_onLinkClick(e);
64 | });
65 | }
66 | };
67 | });
68 |
--------------------------------------------------------------------------------
/javascript/ui/element/idps.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Google Inc. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | /**
16 | * @fileoverview Binds handlers for IdP selection menu buttons UI element.
17 | */
18 |
19 | goog.provide('firebaseui.auth.ui.element.idps');
20 |
21 | goog.require('firebaseui.auth.ui.element');
22 | goog.require('goog.asserts');
23 | goog.require('goog.dom.dataset');
24 | goog.requireType('goog.ui.Component');
25 |
26 |
27 | /**
28 | * Initializes IdP selection menu buttons.
29 | * @param {function(string)} onClick Callback to invoke when an IdP button is
30 | * clicked.
31 | * @this {goog.ui.Component}
32 | */
33 | firebaseui.auth.ui.element.idps.initIdpList = function(onClick) {
34 | var buttons = this.getElementsByClass('firebaseui-id-idp-button');
35 | var cb = function(providerId, e) {
36 | onClick(providerId);
37 | };
38 | for (var i = 0; i < buttons.length; i++) {
39 | var button = buttons[i];
40 | var providerId = goog.asserts.assert(
41 | goog.dom.dataset.get(button, 'providerId'));
42 | firebaseui.auth.ui.element.listenForActionEvent(
43 | this, button, goog.partial(cb, providerId));
44 | }
45 | };
46 |
--------------------------------------------------------------------------------
/javascript/ui/element/infobar.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Google Inc. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | /**
16 | * @fileoverview Utilities for showing/hiding info bar.
17 | */
18 |
19 | goog.provide('firebaseui.auth.ui.element.infoBar');
20 |
21 | goog.require('firebaseui.auth.soy2.element');
22 | goog.require('firebaseui.auth.ui.element');
23 | goog.require('goog.dom');
24 | goog.require('goog.soy');
25 | goog.require('goog.ui.Component');
26 |
27 |
28 | /**
29 | * @param {string} message The message to show on the info bar.
30 | * @this {goog.ui.Component}
31 | */
32 | firebaseui.auth.ui.element.infoBar.showInfoBar = function(message) {
33 | // Dismiss previous info bar if it exists.
34 | firebaseui.auth.ui.element.infoBar.dismissInfoBar.call(this);
35 | var infoBar = goog.soy.renderAsElement(
36 | firebaseui.auth.soy2.element.infoBar,
37 | {'message': message},
38 | null,
39 | this.getDomHelper());
40 | this.getElement().appendChild(infoBar);
41 | // Handle dismiss link
42 | firebaseui.auth.ui.element.listenForActionEvent(
43 | this,
44 | firebaseui.auth.ui.element.infoBar.getInfoBarDismissLinkElement.call(
45 | this),
46 | function(e) {
47 | goog.dom.removeNode(infoBar);
48 | });
49 | };
50 |
51 |
52 | /**
53 | * Dismisses the info bar.
54 | * @this {goog.ui.Component}
55 | */
56 | firebaseui.auth.ui.element.infoBar.dismissInfoBar = function() {
57 | goog.dom.removeNode(
58 | firebaseui.auth.ui.element.infoBar.getInfoBarElement.call(this));
59 | };
60 |
61 |
62 | /**
63 | * @return {Element} The info bar.
64 | * @this {goog.ui.Component}
65 | */
66 | firebaseui.auth.ui.element.infoBar.getInfoBarElement = function() {
67 | return this.getElementByClass('firebaseui-id-info-bar');
68 | };
69 |
70 |
71 | /**
72 | * @return {Element} The info bar dismiss link.
73 | * @this {goog.ui.Component}
74 | */
75 | firebaseui.auth.ui.element.infoBar.getInfoBarDismissLinkElement = function() {
76 | return this.getElementByClass('firebaseui-id-dismiss-info-bar');
77 | };
78 |
--------------------------------------------------------------------------------
/javascript/ui/element/progressdialog.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Google Inc. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | /**
16 | * @fileoverview Manages progress dialog boxes.
17 | */
18 |
19 | goog.provide('firebaseui.auth.ui.element.progressDialog');
20 | goog.provide('firebaseui.auth.ui.element.progressDialog.Progress');
21 |
22 | goog.require('firebaseui.auth.soy2.element');
23 | goog.require('firebaseui.auth.ui.element');
24 | goog.require('firebaseui.auth.ui.element.dialog');
25 | goog.require('goog.soy');
26 | goog.require('goog.ui.Component');
27 |
28 |
29 | /**
30 | * Renders a dialog for showing progress.
31 | * @param {!firebaseui.auth.ui.element.progressDialog.State} state The
32 | * loading state that we wish to show, reflected in the icon of the dialog.
33 | * @param {string} message The message to show on the progress dialog.
34 | * @this {goog.ui.Component}
35 | */
36 | firebaseui.auth.ui.element.progressDialog.showProgressDialog = function(
37 | state, message) {
38 | var progressDialog = goog.soy.renderAsElement(
39 | firebaseui.auth.soy2.element.progressDialog,
40 | {
41 | iconClass: state,
42 | message: message,
43 | },
44 | null,
45 | this.getDomHelper());
46 | firebaseui.auth.ui.element.dialog.showDialog.call(this, progressDialog);
47 | };
48 |
49 |
50 | /**
51 | * The state of the dialog, which is reflected on the icon in the dialog.
52 | *
53 | * Internally, this is a map to the CSS class of the icon.
54 | * @enum {string}
55 | */
56 | firebaseui.auth.ui.element.progressDialog.State = {
57 | LOADING: 'mdl-spinner mdl-spinner--single-color mdl-js-spinner is-active ' +
58 | 'firebaseui-progress-dialog-loading-icon',
59 | DONE: 'firebaseui-icon-done'
60 | };
61 |
--------------------------------------------------------------------------------
/javascript/ui/element/recaptcha.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Google Inc. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | /**
16 | * @fileoverview Binds handlers for reCAPTCHA UI element.
17 | */
18 |
19 | goog.provide('firebaseui.auth.ui.element.recaptcha');
20 |
21 | goog.require('firebaseui.auth.ui.element');
22 | goog.requireType('goog.ui.Component');
23 |
24 |
25 | goog.scope(function() {
26 | var element = firebaseui.auth.ui.element;
27 |
28 |
29 | /**
30 | * @return {Element} The error element for reCAPTCHA.
31 | * @this {goog.ui.Component}
32 | */
33 | element.recaptcha.getRecaptchaErrorElement = function() {
34 | // Listener needs to be set on grecaptcha callback to hide this error when
35 | // triggered.
36 | return this.getElementByClass('firebaseui-id-recaptcha-error');
37 | };
38 |
39 |
40 |
41 | /**
42 | * @return {Element} The container element for reCAPTCHA.
43 | * @this {goog.ui.Component}
44 | */
45 | element.recaptcha.getRecaptchaElement = function() {
46 | return this.getElementByClass('firebaseui-recaptcha-container');
47 | };
48 | });
49 |
--------------------------------------------------------------------------------
/javascript/ui/element/recaptchatesthelper.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Google Inc. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | /**
16 | * @fileoverview Helper class for testing the visible reCAPTCHA UI element.
17 | */
18 |
19 | goog.provide('firebaseui.auth.ui.element.RecaptchaTestHelper');
20 | goog.setTestOnly('firebaseui.auth.ui.element.RecaptchaTestHelper');
21 |
22 | goog.require('firebaseui.auth.ui.element');
23 |
24 |
25 | goog.scope(function() {
26 | var element = firebaseui.auth.ui.element;
27 |
28 |
29 |
30 | /** @constructor */
31 | element.RecaptchaTestHelper = function() {
32 | element.RecaptchaTestHelper.base(this, 'constructor', 'Recaptcha');
33 | };
34 | goog.inherits(element.RecaptchaTestHelper, element.ElementTestHelper);
35 |
36 |
37 | /** @override */
38 | element.RecaptchaTestHelper.prototype.resetState = function() {
39 | element.hide(this.component.getRecaptchaErrorElement());
40 | };
41 |
42 |
43 | /** @private */
44 | element.RecaptchaTestHelper.prototype.testGetRecaptchaElement_ = function() {
45 | assertNotNull(this.component.getRecaptchaElement());
46 | };
47 |
48 |
49 | /** @private */
50 | element.RecaptchaTestHelper.prototype.testGetRecaptchaErrorElement_ =
51 | function() {
52 | assertNotNull(this.component.getRecaptchaErrorElement());
53 | };
54 | });
55 |
--------------------------------------------------------------------------------
/javascript/ui/element/resend.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Google Inc. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | * License for the specific language governing permissions and limitations under
14 | * the License.
15 | */
16 |
17 | /**
18 | * @fileoverview Binds handlers for resend UI element.
19 | */
20 |
21 | goog.provide('firebaseui.auth.ui.element.resend');
22 |
23 | goog.require('firebaseui.auth.soy2.strings');
24 | goog.require('firebaseui.auth.ui.element');
25 | goog.require('goog.dom');
26 | goog.require('goog.ui.Component');
27 |
28 |
29 | goog.scope(function() {
30 | var element = firebaseui.auth.ui.element;
31 |
32 |
33 | /**
34 | * @return {?Element} The resend countdown.
35 | * @this {goog.ui.Component}
36 | */
37 | element.resend.getResendCountdown = function() {
38 | return this.getElementByClass('firebaseui-id-resend-countdown');
39 | };
40 |
41 |
42 | /**
43 | * @return {?Element} The resend link.
44 | * @this {goog.ui.Component}
45 | */
46 | element.resend.getResendLink = function() {
47 | return this.getElementByClass('firebaseui-id-resend-link');
48 | };
49 |
50 |
51 | /**
52 | * Hide the resend countdown.
53 | * @this {goog.ui.Component}
54 | */
55 | element.resend.hideResendCountdown = function() {
56 | var el = this.getResendCountdown();
57 | element.hide(el);
58 | };
59 |
60 |
61 | /**
62 | * Show the resend link.
63 | * @this {goog.ui.Component}
64 | */
65 | element.resend.showResendLink = function() {
66 | var el = this.getResendLink();
67 | element.show(el);
68 | };
69 |
70 |
71 | /**
72 | * Updates the countdown.
73 | * @param {number} secondsRemaining The number of seconds remaining.
74 | * @this {goog.ui.Component}
75 | */
76 | element.resend.updateResendCountdown = function(secondsRemaining) {
77 | var countdown = element.resend.getResendCountdown.call(this);
78 | var prefix = secondsRemaining > 9 ? '0:' : '0:0';
79 | var text = firebaseui.auth.soy2.strings
80 | .resendCountdown({timeRemaining: prefix + secondsRemaining})
81 | .toString();
82 | goog.dom.setTextContent(countdown, text);
83 | };
84 |
85 |
86 | });
87 |
--------------------------------------------------------------------------------
/javascript/ui/element/resendtesthelper.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Google Inc. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | * License for the specific language governing permissions and limitations under
14 | * the License.
15 | */
16 |
17 | /**
18 | * @fileoverview Helper class for testing resend element.
19 | */
20 |
21 | goog.provide('firebaseui.auth.ui.element.ResendTestHelper');
22 | goog.setTestOnly('firebaseui.auth.ui.element.ResendTestHelper');
23 |
24 | goog.require('firebaseui.auth.soy2.strings');
25 | goog.require('firebaseui.auth.ui.element');
26 | goog.require('goog.dom');
27 | goog.require('goog.dom.classlist');
28 |
29 | goog.scope(function() {
30 | var element = firebaseui.auth.ui.element;
31 |
32 |
33 | /** @constructor */
34 | element.ResendTestHelper = function() {
35 | element.ResendTestHelper.base(this, 'constructor', 'Resend');
36 | };
37 | goog.inherits(element.ResendTestHelper, element.ElementTestHelper);
38 |
39 |
40 | /** @override */
41 | element.ResendTestHelper.prototype.resetState = function() {};
42 |
43 |
44 | /** @private */
45 | element.ResendTestHelper.prototype.testGetResendCountdown_ = function() {
46 | assertNotNull(this.component.getResendCountdown());
47 | };
48 |
49 |
50 | /** @private */
51 | element.ResendTestHelper.prototype.testGetResendLink_ = function() {
52 | assertNotNull(this.component.getResendLink());
53 | };
54 |
55 |
56 | /** @private */
57 | element.ResendTestHelper.prototype.testHideResendCountdown_ = function() {
58 | var el = this.component.getResendCountdown();
59 | assertEquals(false, goog.dom.classlist.contains(el, 'firebaseui-hidden'));
60 | this.component.hideResendCountdown();
61 | assertEquals(true, goog.dom.classlist.contains(el, 'firebaseui-hidden'));
62 | };
63 |
64 |
65 | /** @private */
66 | element.ResendTestHelper.prototype.testShowResendLink_ = function() {
67 | var el = this.component.getResendLink();
68 | assertEquals(true, goog.dom.classlist.contains(el, 'firebaseui-hidden'));
69 | this.component.showResendLink();
70 | assertEquals(false, goog.dom.classlist.contains(el, 'firebaseui-hidden'));
71 | };
72 |
73 |
74 | /** @private */
75 | element.ResendTestHelper.prototype.testUpdateResendCountdown_ = function() {
76 | // Double-digit rendering.
77 | this.component.updateResendCountdown(10);
78 | var expected =
79 | firebaseui.auth.soy2.strings.resendCountdown({timeRemaining: '0:10'})
80 | .toString();
81 | var actual = goog.dom.getTextContent(this.component.getResendCountdown());
82 | assertEquals(expected, actual);
83 | // Single-digit rendering.
84 | this.component.updateResendCountdown(5);
85 | expected =
86 | firebaseui.auth.soy2.strings.resendCountdown({timeRemaining: '0:05'})
87 | .toString();
88 | actual = goog.dom.getTextContent(this.component.getResendCountdown());
89 | assertEquals(expected, actual);
90 | };
91 |
92 |
93 | });
94 |
--------------------------------------------------------------------------------
/javascript/ui/element/tospp.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 Google Inc. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | /**
16 | * @fileoverview Binds handlers for Terms of Service and Privacy Policy UI
17 | * element.
18 | */
19 |
20 | goog.provide('firebaseui.auth.ui.element.tospp');
21 |
22 | goog.require('firebaseui.auth.ui.element');
23 | goog.require('goog.ui.Component');
24 |
25 |
26 | goog.scope(function() {
27 | var element = firebaseui.auth.ui.element;
28 |
29 | /**
30 | * @return {?Element} The Terms of Service and Privacy Policy element.
31 | * @this {goog.ui.Component}
32 | */
33 | element.tospp.getTosPpElement = function() {
34 | return this.getElementByClass('firebaseui-tos');
35 | };
36 |
37 |
38 | /**
39 | * @return {?Element} The Terms of Service hyperlink element.
40 | * @this {goog.ui.Component}
41 | */
42 | element.tospp.getTosLinkElement = function() {
43 | return this.getElementByClass('firebaseui-tos-link');
44 | };
45 |
46 |
47 | /**
48 | * @return {?Element} The Privacy Policy hyperlink element.
49 | * @this {goog.ui.Component}
50 | */
51 | element.tospp.getPpLinkElement = function() {
52 | return this.getElementByClass('firebaseui-pp-link');
53 | };
54 |
55 |
56 | /**
57 | * @return {?Element} The ToS Privacy Policy list element.
58 | * @this {goog.ui.Component}
59 | */
60 | element.tospp.getTosPpListElement = function() {
61 | return this.getElementByClass('firebaseui-tos-list');
62 | };
63 |
64 | });
65 |
--------------------------------------------------------------------------------
/javascript/ui/mdl.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Google Inc. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | /**
16 | * @fileoverview Provides utilities for working with Material Design Lite.
17 | */
18 |
19 | goog.provide('firebaseui.auth.ui.mdl');
20 |
21 | goog.require('goog.array');
22 | goog.require('goog.dom');
23 | goog.require('goog.dom.classlist');
24 |
25 |
26 | /**
27 | * Initializes MDL for the given element and all MDL-styled children. The MDL
28 | * library attaches event listeners and modifies the DOM as appropriate here.
29 | * @param {?Element} element
30 | */
31 | firebaseui.auth.ui.mdl.upgrade = function(element) {
32 | firebaseui.auth.ui.mdl.performOnMdlComponents_(element, 'upgradeElement');
33 | };
34 |
35 | /**
36 | * Removes MDL from the given element and all MDL-styled children. The MDL
37 | * library detaches event listeners and removes DOM modifications that it
38 | * previously did when upgrade()ing.
39 | * @param {?Element} element
40 | */
41 | firebaseui.auth.ui.mdl.downgrade = function(element) {
42 | firebaseui.auth.ui.mdl.performOnMdlComponents_(element, 'downgradeElements');
43 | };
44 |
45 |
46 | /**
47 | * The list of CSS classes to upgrade to MDL components.
48 | * @private @const {!Array}
49 | */
50 | firebaseui.auth.ui.mdl.MDL_COMPONENT_CLASSES_ = [
51 | 'mdl-js-textfield',
52 | 'mdl-js-progress',
53 | 'mdl-js-spinner',
54 | 'mdl-js-button'
55 | ];
56 |
57 |
58 | /**
59 | * Performs an operation on all MDL elements within a given element (e.g.
60 | * upgradeElement, downgradeElements), including the element itself.
61 | * @param {?Element} element
62 | * @param {string} operation
63 | * @private
64 | */
65 | firebaseui.auth.ui.mdl.performOnMdlComponents_ = function(element, operation) {
66 | if (!element || !window['componentHandler'] ||
67 | !window['componentHandler'][operation]) {
68 | return;
69 | }
70 | firebaseui.auth.ui.mdl.MDL_COMPONENT_CLASSES_.forEach(function(className) {
71 | if (goog.dom.classlist.contains(element, className)) {
72 | window['componentHandler'][operation](element);
73 | }
74 | var matchingElements = goog.dom.getElementsByClass(className, element);
75 | goog.array.forEach(matchingElements, function(mdlElement) {
76 | window['componentHandler'][operation](mdlElement);
77 | });
78 | });
79 | };
80 |
--------------------------------------------------------------------------------
/javascript/ui/mdl_test.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Google Inc. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | /**
16 | * @fileoverview Tests for MDL utilities.
17 | */
18 |
19 | goog.provide('firebaseui.auth.ui.mdlTest');
20 |
21 | goog.require('firebaseui.auth.ui.mdl');
22 | goog.require('goog.testing.MockControl');
23 | goog.require('goog.testing.jsunit');
24 |
25 | goog.setTestOnly('firebaseui.auth.ui.mdlTest');
26 |
27 | // Mocks
28 | var mockControl;
29 | var mockUpgradeElement;
30 | var mockDowngradeElements;
31 |
32 | // Page elements
33 | var testContainer;
34 |
35 |
36 | function setUp() {
37 | mockControl = new goog.testing.MockControl();
38 |
39 | window['componentHandler'] = {};
40 | mockUpgradeElement = window['componentHandler']['upgradeElement'] =
41 | mockControl.createFunctionMock('upgradeElement');
42 | mockDowngradeElements = window['componentHandler']['downgradeElements'] =
43 | mockControl.createFunctionMock('downgradeElements');
44 |
45 | testContainer = document.getElementById('mdl_test_container');
46 | }
47 |
48 |
49 | function tearDown() {
50 | mockControl.$verifyAll();
51 | mockControl.$resetAll();
52 | }
53 |
54 |
55 | function testMdlUpgrade() {
56 | // Order matters here, since MockControl doesn't have an easy way of ignoring
57 | // the order of calls. A possible workaround is to make many SaveArgument()s
58 | // and use assertSameElements.
59 | mockUpgradeElement(document.getElementById('mdl_test_textfield'));
60 | mockUpgradeElement(document.getElementById('mdl_test_progress'));
61 | mockUpgradeElement(document.getElementById('mdl_test_spinner'));
62 | mockUpgradeElement(document.getElementById('mdl_test_button'));
63 |
64 | mockControl.$replayAll();
65 |
66 | firebaseui.auth.ui.mdl.upgrade(testContainer);
67 | }
68 |
69 |
70 | function testMdlDowngrade() {
71 | mockDowngradeElements(document.getElementById('mdl_test_textfield'));
72 | mockDowngradeElements(document.getElementById('mdl_test_progress'));
73 | mockDowngradeElements(document.getElementById('mdl_test_spinner'));
74 | mockDowngradeElements(document.getElementById('mdl_test_button'));
75 |
76 | mockControl.$replayAll();
77 |
78 | firebaseui.auth.ui.mdl.downgrade(testContainer);
79 | }
80 |
81 |
82 | function testMdlUpgradeMdlInContainerItself() {
83 | var testContainer = document.getElementById('mdl_test_mdl_in_container');
84 | mockUpgradeElement(document.getElementById(
85 | 'mdl_test_mdl_in_container_textfield'));
86 | mockUpgradeElement(testContainer);
87 |
88 | mockControl.$replayAll();
89 |
90 | firebaseui.auth.ui.mdl.upgrade(testContainer);
91 | }
92 |
--------------------------------------------------------------------------------
/javascript/ui/mdl_test_dom.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
foo
9 |
10 |
11 |
12 |
16 |
--------------------------------------------------------------------------------
/javascript/ui/page/anonymoususermismatch.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 Google Inc. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | /**
16 | * @fileoverview UI component for the anonymous user mismatch error page.
17 | */
18 |
19 | goog.provide('firebaseui.auth.ui.page.AnonymousUserMismatch');
20 |
21 | goog.require('firebaseui.auth.soy2.page');
22 | goog.require('firebaseui.auth.ui.element');
23 | goog.require('firebaseui.auth.ui.element.form');
24 | goog.require('firebaseui.auth.ui.page.Base');
25 | goog.requireType('goog.dom.DomHelper');
26 |
27 |
28 | /**
29 | * Anonymous user mismatch error UI component.
30 | */
31 | firebaseui.auth.ui.page.AnonymousUserMismatch =
32 | class extends firebaseui.auth.ui.page.Base {
33 | /**
34 | * @param {function()} onDismissClick Callback to invoke when dismiss button
35 | * is clicked.
36 | * @param {?goog.dom.DomHelper=} opt_domHelper Optional DOM helper.
37 | */
38 | constructor(onDismissClick, opt_domHelper) {
39 | super(
40 | firebaseui.auth.soy2.page.anonymousUserMismatch, undefined,
41 | opt_domHelper, 'anonymousUserMismatch');
42 | this.onDismissClick_ = onDismissClick;
43 | }
44 |
45 | /** @override */
46 | enterDocument() {
47 | var self = this;
48 | // Handle action event for dismiss button.
49 | firebaseui.auth.ui.element.listenForActionEvent(
50 | this, this.getSecondaryLinkElement(), function(e) {
51 | self.onDismissClick_();
52 | });
53 | // Set initial focus on the dismiss button.
54 | this.getSecondaryLinkElement().focus();
55 | super.enterDocument();
56 | }
57 |
58 | /** @override */
59 | disposeInternal() {
60 | this.onDismissClick_ = null;
61 | super.disposeInternal();
62 | }
63 | };
64 |
65 |
66 | goog.mixin(
67 | firebaseui.auth.ui.page.AnonymousUserMismatch.prototype,
68 | /**
69 | * @lends {firebaseui.auth.ui.page.AnonymousUserMismatch.prototype}
70 | */
71 | {
72 | // For form.
73 | getSecondaryLinkElement:
74 | firebaseui.auth.ui.element.form.getSecondaryLinkElement
75 | });
76 |
--------------------------------------------------------------------------------
/javascript/ui/page/anonymoususermismatch_test.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 Google Inc. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | /**
16 | * @fileoverview Tests for the anonymous user mismatch error page.
17 | */
18 |
19 | goog.provide('firebaseui.auth.ui.page.AnonymousUserMismatchTest');
20 | goog.setTestOnly('firebaseui.auth.ui.page.AnonymousUserMismatchTest');
21 |
22 | goog.require('firebaseui.auth.ui.element.FormTestHelper');
23 | goog.require('firebaseui.auth.ui.page.AnonymousUserMismatch');
24 | goog.require('firebaseui.auth.ui.page.PageTestHelper');
25 | goog.require('goog.dom');
26 | goog.require('goog.dom.TagName');
27 | goog.require('goog.testing.MockClock');
28 | goog.require('goog.testing.jsunit');
29 |
30 |
31 | var mockClock;
32 | var root;
33 | var component;
34 | var formTestHelper = new firebaseui.auth.ui.element.FormTestHelper()
35 | .excludeTests(
36 | 'testGetSubmitElement_', 'testOnSubmitClick_', 'testOnSubmitEnter_')
37 | .registerTests();
38 | var pageTestHelper =
39 | new firebaseui.auth.ui.page.PageTestHelper().registerTests();
40 |
41 |
42 | function setUp() {
43 | // Set up clock.
44 | mockClock = new goog.testing.MockClock();
45 | mockClock.install();
46 | root = goog.dom.createDom(goog.dom.TagName.DIV);
47 | document.body.appendChild(root);
48 | component = new firebaseui.auth.ui.page.AnonymousUserMismatch(
49 | goog.bind(
50 | firebaseui.auth.ui.element.FormTestHelper.prototype.onLinkClick,
51 | formTestHelper));
52 | component.render(root);
53 | formTestHelper.setComponent(component);
54 | // Reset previous state of form helper.
55 | formTestHelper.resetState();
56 | pageTestHelper.setClock(mockClock).setComponent(component);
57 | }
58 |
59 |
60 | function tearDown() {
61 | // Tear down clock.
62 | mockClock.tick(Infinity);
63 | mockClock.reset();
64 | component.dispose();
65 | goog.dom.removeNode(root);
66 | }
67 |
68 |
69 | function testInitialFocus_dismissButton() {
70 | assertEquals(
71 | component.getSecondaryLinkElement(),
72 | goog.dom.getActiveElement(document));
73 | }
74 |
75 |
76 | function testAnonymousUserMismatch_pageEvents() {
77 | // Run page event tests.
78 | // Dispose previously created container since test must run before rendering
79 | // the component in document.
80 | component.dispose();
81 | // Initialize component.
82 | component = new firebaseui.auth.ui.page.AnonymousUserMismatch(
83 | goog.bind(
84 | firebaseui.auth.ui.element.FormTestHelper.prototype.onLinkClick,
85 | formTestHelper));
86 | // Run all page helper tests.
87 | pageTestHelper.runTests(component, root);
88 | }
89 |
90 |
91 | function testAnonymousUserMismatchError_getPageId() {
92 | assertEquals('anonymousUserMismatch', component.getPageId());
93 | }
94 |
--------------------------------------------------------------------------------
/javascript/ui/page/blank.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 Google Inc. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | /**
16 | * @fileoverview UI component for the blank page.
17 | */
18 |
19 | goog.provide('firebaseui.auth.ui.page.Blank');
20 |
21 | goog.require('firebaseui.auth.soy2.page');
22 | goog.require('firebaseui.auth.ui.page.Base');
23 | goog.requireType('goog.dom.DomHelper');
24 |
25 |
26 | /**
27 | * Blank page UI componenet.
28 | */
29 | firebaseui.auth.ui.page.Blank = class extends firebaseui.auth.ui.page.Base {
30 | /**
31 | * @param {?goog.dom.DomHelper=} opt_domHelper Optional DOM helper.
32 | */
33 | constructor(opt_domHelper) {
34 | super(firebaseui.auth.soy2.page.blank, undefined, opt_domHelper, 'blank');
35 | }
36 | };
37 |
--------------------------------------------------------------------------------
/javascript/ui/page/blank_test.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 Google Inc. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | /**
16 | * @fileoverview Tests for the blank page.
17 | */
18 |
19 | goog.provide('firebaseui.auth.ui.page.BlankTest');
20 | goog.setTestOnly('firebaseui.auth.ui.page.BlankTest');
21 |
22 | goog.require('firebaseui.auth.ui.page.Blank');
23 | goog.require('firebaseui.auth.ui.page.PageTestHelper');
24 | goog.require('goog.dom');
25 | goog.require('goog.dom.TagName');
26 | goog.require('goog.testing.MockClock');
27 | goog.require('goog.testing.jsunit');
28 |
29 |
30 | var mockClock;
31 | var root;
32 | var component;
33 | var pageTestHelper =
34 | new firebaseui.auth.ui.page.PageTestHelper().registerTests();
35 |
36 |
37 | function setUp() {
38 | // Set up clock.
39 | mockClock = new goog.testing.MockClock();
40 | mockClock.install();
41 | root = goog.dom.createDom(goog.dom.TagName.DIV);
42 | document.body.appendChild(root);
43 | component = new firebaseui.auth.ui.page.Blank();
44 | component.render(root);
45 | pageTestHelper.setClock(mockClock).setComponent(component);
46 | }
47 |
48 |
49 | function tearDown() {
50 | // Tear down clock.
51 | mockClock.tick(Infinity);
52 | mockClock.reset();
53 | component.dispose();
54 | goog.dom.removeNode(root);
55 | }
56 |
57 |
58 | function testBlank_getPageId() {
59 | assertEquals('blank', component.getPageId());
60 | }
61 |
62 |
63 | function testBlank_pageEvents() {
64 | // Run page event tests.
65 | // Dispose previously created container since test must run before rendering
66 | // the component in document.
67 | component.dispose();
68 | // Initialize component.
69 | component = new firebaseui.auth.ui.page.Blank();
70 | // Run all page helper tests.
71 | pageTestHelper.runTests(component, root);
72 | }
73 |
--------------------------------------------------------------------------------
/javascript/ui/page/callback.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Google Inc. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | /**
16 | * @fileoverview UI component for the callback page.
17 | */
18 |
19 | goog.provide('firebaseui.auth.ui.page.Callback');
20 |
21 | goog.require('firebaseui.auth.soy2.page');
22 | goog.require('firebaseui.auth.ui.page.Base');
23 | goog.requireType('goog.Promise');
24 | goog.requireType('goog.dom.DomHelper');
25 |
26 |
27 | /**
28 | * Callback page UI componenet.
29 | */
30 | firebaseui.auth.ui.page.Callback = class extends firebaseui.auth.ui.page.Base {
31 | /**
32 | * @param {goog.dom.DomHelper=} opt_domHelper Optional DOM helper.
33 | */
34 | constructor(opt_domHelper) {
35 | super(
36 | firebaseui.auth.soy2.page.callback, undefined, opt_domHelper,
37 | 'callback');
38 | }
39 |
40 | /**
41 | * Executes an API promise based request. This page already has a progress
42 | * bar, no need to show another progress bar when executing a promise.
43 | * @param {function(...):!goog.Promise} executor The request executor.
44 | * @param {!Array} parameters The API request array of parameters.
45 | * @param {function(*)} onSuccess The response handling success callback.
46 | * @param {function(*)} onError The response handling error callback.
47 | * @return {?goog.Promise} The pending promise.
48 | * @override
49 | */
50 | executePromiseRequest(executor, parameters, onSuccess, onError) {
51 | return executor.apply(null, parameters).then(onSuccess, onError);
52 | }
53 | };
54 |
--------------------------------------------------------------------------------
/javascript/ui/page/differentdeviceerror.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 Google Inc. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | /**
16 | * @fileoverview UI component for the different device error page.
17 | */
18 |
19 | goog.provide('firebaseui.auth.ui.page.DifferentDeviceError');
20 |
21 | goog.require('firebaseui.auth.soy2.page');
22 | goog.require('firebaseui.auth.ui.element');
23 | goog.require('firebaseui.auth.ui.element.form');
24 | goog.require('firebaseui.auth.ui.page.Base');
25 | goog.requireType('goog.dom.DomHelper');
26 |
27 |
28 | /**
29 | * Different device error UI component.
30 | */
31 | firebaseui.auth.ui.page.DifferentDeviceError =
32 | class extends firebaseui.auth.ui.page.Base {
33 | /**
34 | * @param {function()} onDismissClick Callback to invoke when dismiss button
35 | * is clicked.
36 | * @param {?goog.dom.DomHelper=} opt_domHelper Optional DOM helper.
37 | */
38 | constructor(onDismissClick, opt_domHelper) {
39 | super(
40 | firebaseui.auth.soy2.page.differentDeviceError, undefined,
41 | opt_domHelper, 'differentDeviceError');
42 | this.onDismissClick_ = onDismissClick;
43 | }
44 |
45 | /** @override */
46 | enterDocument() {
47 | var self = this;
48 | // Handle action event for dismiss button.
49 | firebaseui.auth.ui.element.listenForActionEvent(
50 | this, this.getSecondaryLinkElement(), function(e) {
51 | self.onDismissClick_();
52 | });
53 | // Set initial focus on the dismiss button.
54 | this.getSecondaryLinkElement().focus();
55 | super.enterDocument();
56 | }
57 |
58 | /** @override */
59 | disposeInternal() {
60 | this.onDismissClick_ = null;
61 | super.disposeInternal();
62 | }
63 | };
64 |
65 |
66 | goog.mixin(
67 | firebaseui.auth.ui.page.DifferentDeviceError.prototype,
68 | /**
69 | * @lends {firebaseui.auth.ui.page.DifferentDeviceError.prototype}
70 | */
71 | {
72 | // For form.
73 | getSecondaryLinkElement:
74 | firebaseui.auth.ui.element.form.getSecondaryLinkElement
75 | });
76 |
--------------------------------------------------------------------------------
/javascript/ui/page/differentdeviceerror_test.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 Google Inc. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | /**
16 | * @fileoverview Tests for the different device error page.
17 | */
18 |
19 | goog.provide('firebaseui.auth.ui.page.DifferentDeviceErrorTest');
20 | goog.setTestOnly('firebaseui.auth.ui.page.DifferentDeviceErrorTest');
21 |
22 | goog.require('firebaseui.auth.ui.element.FormTestHelper');
23 | goog.require('firebaseui.auth.ui.page.DifferentDeviceError');
24 | goog.require('firebaseui.auth.ui.page.PageTestHelper');
25 | goog.require('goog.dom');
26 | goog.require('goog.dom.TagName');
27 | goog.require('goog.testing.MockClock');
28 | goog.require('goog.testing.jsunit');
29 |
30 |
31 | var mockClock;
32 | var root;
33 | var component;
34 | var formTestHelper = new firebaseui.auth.ui.element.FormTestHelper()
35 | .excludeTests(
36 | 'testGetSubmitElement_', 'testOnSubmitClick_', 'testOnSubmitEnter_')
37 | .registerTests();
38 | var pageTestHelper =
39 | new firebaseui.auth.ui.page.PageTestHelper().registerTests();
40 |
41 |
42 | function setUp() {
43 | // Set up clock.
44 | mockClock = new goog.testing.MockClock();
45 | mockClock.install();
46 | root = goog.dom.createDom(goog.dom.TagName.DIV);
47 | document.body.appendChild(root);
48 | component = new firebaseui.auth.ui.page.DifferentDeviceError(
49 | goog.bind(
50 | firebaseui.auth.ui.element.FormTestHelper.prototype.onLinkClick,
51 | formTestHelper));
52 | component.render(root);
53 | formTestHelper.setComponent(component);
54 | // Reset previous state of form helper.
55 | formTestHelper.resetState();
56 | pageTestHelper.setClock(mockClock).setComponent(component);
57 | }
58 |
59 |
60 | function tearDown() {
61 | // Tear down clock.
62 | mockClock.tick(Infinity);
63 | mockClock.reset();
64 | component.dispose();
65 | goog.dom.removeNode(root);
66 | }
67 |
68 |
69 | function testInitialFocus_dismissButton() {
70 | assertEquals(
71 | component.getSecondaryLinkElement(),
72 | goog.dom.getActiveElement(document));
73 | }
74 |
75 |
76 | function testDifferentDeviceError_pageEvents() {
77 | // Run page event tests.
78 | // Dispose previously created container since test must run before rendering
79 | // the component in document.
80 | component.dispose();
81 | // Initialize component.
82 | component = new firebaseui.auth.ui.page.DifferentDeviceError(
83 | goog.bind(
84 | firebaseui.auth.ui.element.FormTestHelper.prototype.onLinkClick,
85 | formTestHelper));
86 | // Run all page helper tests.
87 | pageTestHelper.runTests(component, root);
88 | }
89 |
90 |
91 | function testDifferentDeviceError_getPageId() {
92 | assertEquals('differentDeviceError', component.getPageId());
93 | }
94 |
--------------------------------------------------------------------------------
/javascript/ui/page/emaillinksigninlinking.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 Google Inc. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | /**
16 | * @fileoverview UI component for the email link sign in linking page.
17 | */
18 |
19 | goog.provide('firebaseui.auth.ui.page.EmailLinkSignInLinking');
20 |
21 | goog.require('firebaseui.auth.soy2.page');
22 | goog.require('firebaseui.auth.ui.element.form');
23 | goog.require('firebaseui.auth.ui.page.Base');
24 | goog.requireType('goog.dom.DomHelper');
25 |
26 |
27 | /**
28 | * Email link sign in linking UI component.
29 | */
30 | firebaseui.auth.ui.page.EmailLinkSignInLinking =
31 | class extends firebaseui.auth.ui.page.Base {
32 | /**
33 | * @param {string} email The user's email.
34 | * @param {?} providerConfig The provider config of the IdP we should
35 | * use for sign in.
36 | * @param {function()} onSubmitClick Callback to invoke when the submit button
37 | * is clicked.
38 | * @param {?function()=} opt_tosCallback Callback to invoke when the ToS link
39 | * is clicked.
40 | * @param {?function()=} opt_privacyPolicyCallback Callback to invoke when the
41 | * Privacy Policy link is clicked.
42 | * @param {?goog.dom.DomHelper=} opt_domHelper Optional DOM helper.
43 | */
44 | constructor(
45 | email, providerConfig, onSubmitClick, opt_tosCallback,
46 | opt_privacyPolicyCallback, opt_domHelper) {
47 | // Extend base page class and render email link sign in linking soy
48 | // template.
49 | super(
50 | firebaseui.auth.soy2.page.emailLinkSignInLinking,
51 | {email: email, providerConfig: providerConfig}, opt_domHelper,
52 | 'emailLinkSignInLinking', {
53 | tosCallback: opt_tosCallback,
54 | privacyPolicyCallback: opt_privacyPolicyCallback
55 | });
56 | this.onSubmitClick_ = onSubmitClick;
57 | }
58 |
59 | /** @override */
60 | enterDocument() {
61 | this.initFormElement(this.onSubmitClick_);
62 | this.getSubmitElement().focus();
63 | super.enterDocument();
64 | }
65 |
66 | /** @override */
67 | disposeInternal() {
68 | this.onSubmitClick_ = null;
69 | super.disposeInternal();
70 | }
71 | };
72 |
73 |
74 | goog.mixin(
75 | firebaseui.auth.ui.page.EmailLinkSignInLinking.prototype,
76 | /** @lends {firebaseui.auth.ui.page.EmailLinkSignInLinking.prototype} */
77 | {
78 | // For form.
79 | getSubmitElement:
80 | firebaseui.auth.ui.element.form.getSubmitElement,
81 | initFormElement:
82 | firebaseui.auth.ui.element.form.initFormElement
83 | });
84 |
--------------------------------------------------------------------------------
/javascript/ui/page/emaillinksigninlinkingdifferentdevice.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 Google Inc. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | /**
16 | * @fileoverview UI component for the email link sign in linking different
17 | * device page.
18 | */
19 |
20 | goog.provide('firebaseui.auth.ui.page.EmailLinkSignInLinkingDifferentDevice');
21 |
22 | goog.require('firebaseui.auth.soy2.page');
23 | goog.require('firebaseui.auth.ui.element.form');
24 | goog.require('firebaseui.auth.ui.page.Base');
25 | goog.requireType('goog.dom.DomHelper');
26 |
27 |
28 | /**
29 | * Email link sign in linking different device UI component.
30 | */
31 | firebaseui.auth.ui.page.EmailLinkSignInLinkingDifferentDevice =
32 | class extends firebaseui.auth.ui.page.Base {
33 | /**
34 | * @param {?} providerConfig The provider config of the IdP we should
35 | * use for sign in.
36 | * @param {function()} onContinueClick Callback to invoke when the continue
37 | * button is clicked.
38 | * @param {?function()=} opt_tosCallback Callback to invoke when the ToS link
39 | * is clicked.
40 | * @param {?function()=} opt_privacyPolicyCallback Callback to invoke when the
41 | * Privacy Policy link is clicked.
42 | * @param {?goog.dom.DomHelper=} opt_domHelper Optional DOM helper.
43 | */
44 | constructor(
45 | providerConfig, onContinueClick, opt_tosCallback,
46 | opt_privacyPolicyCallback, opt_domHelper) {
47 | // Extend base page class and render Email link sign in linking different
48 | // device soy template.
49 | super(
50 | firebaseui.auth.soy2.page.emailLinkSignInLinkingDifferentDevice,
51 | {providerConfig: providerConfig}, opt_domHelper,
52 | 'emailLinkSignInLinkingDifferentDevice', {
53 | tosCallback: opt_tosCallback,
54 | privacyPolicyCallback: opt_privacyPolicyCallback
55 | });
56 | this.onContinueClick_ = onContinueClick;
57 | }
58 |
59 | /** @override */
60 | enterDocument() {
61 | this.initFormElement(this.onContinueClick_);
62 | this.getSubmitElement().focus();
63 | super.enterDocument();
64 | }
65 |
66 | /** @override */
67 | disposeInternal() {
68 | this.onContinueClick_ = null;
69 | super.disposeInternal();
70 | }
71 | };
72 |
73 |
74 | goog.mixin(
75 | firebaseui.auth.ui.page.EmailLinkSignInLinkingDifferentDevice.prototype,
76 | /**
77 | * @lends
78 | * {firebaseui.auth.ui.page.EmailLinkSignInLinkingDifferentDevice.prototype}
79 | */
80 | {
81 | // For form.
82 | getSubmitElement:
83 | firebaseui.auth.ui.element.form.getSubmitElement,
84 | initFormElement:
85 | firebaseui.auth.ui.element.form.initFormElement
86 | });
87 |
--------------------------------------------------------------------------------
/javascript/ui/page/federatedlinking.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Google Inc. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | /**
16 | * @fileoverview UI component for the federated account linking page.
17 | */
18 |
19 | goog.provide('firebaseui.auth.ui.page.FederatedLinking');
20 |
21 | goog.require('firebaseui.auth.soy2.page');
22 | goog.require('firebaseui.auth.ui.element');
23 | goog.require('firebaseui.auth.ui.element.form');
24 | goog.require('firebaseui.auth.ui.page.Base');
25 | goog.requireType('goog.dom.DomHelper');
26 |
27 |
28 | /**
29 | * Federated account linking UI component.
30 | */
31 | firebaseui.auth.ui.page.FederatedLinking =
32 | class extends firebaseui.auth.ui.page.Base {
33 | /**
34 | * @param {string} email The user's email.
35 | * @param {?} providerConfig The provider config of the IdP we should
36 | * use for sign in.
37 | * @param {function()} onSubmitClick Callback to invoke when the submit button
38 | * is clicked.
39 | * @param {?function()=} opt_tosCallback Callback to invoke when the ToS link
40 | * is clicked.
41 | * @param {?function()=} opt_privacyPolicyCallback Callback to invoke when the
42 | * Privacy Policy link is clicked.
43 | * @param {?goog.dom.DomHelper=} opt_domHelper Optional DOM helper.
44 | */
45 | constructor(
46 | email, providerConfig, onSubmitClick, opt_tosCallback,
47 | opt_privacyPolicyCallback, opt_domHelper) {
48 | super(
49 | firebaseui.auth.soy2.page.federatedLinking,
50 | {email: email, providerConfig: providerConfig}, opt_domHelper,
51 | 'federatedLinking', {
52 | tosCallback: opt_tosCallback,
53 | privacyPolicyCallback: opt_privacyPolicyCallback
54 | });
55 | this.onSubmitClick_ = onSubmitClick;
56 | }
57 |
58 | /** @override */
59 | enterDocument() {
60 | this.initFormElement(this.onSubmitClick_);
61 | this.getSubmitElement().focus();
62 | super.enterDocument();
63 | }
64 |
65 | /** @override */
66 | disposeInternal() {
67 | this.onSubmitClick_ = null;
68 | super.disposeInternal();
69 | }
70 | };
71 |
72 |
73 | goog.mixin(
74 | firebaseui.auth.ui.page.FederatedLinking.prototype,
75 | /** @lends {firebaseui.auth.ui.page.FederatedLinking.prototype} */
76 | {
77 | // For form.
78 | getSubmitElement:
79 | firebaseui.auth.ui.element.form.getSubmitElement,
80 | initFormElement:
81 | firebaseui.auth.ui.element.form.initFormElement
82 | });
83 |
--------------------------------------------------------------------------------
/javascript/ui/page/passwordreset.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Google Inc. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | /**
16 | * @fileoverview UI component for the password reset page.
17 | */
18 |
19 | goog.provide('firebaseui.auth.ui.page.PasswordReset');
20 |
21 | goog.require('firebaseui.auth.soy2.page');
22 | goog.require('firebaseui.auth.ui.element.form');
23 | goog.require('firebaseui.auth.ui.element.newPassword');
24 | goog.require('firebaseui.auth.ui.page.Base');
25 | goog.requireType('goog.dom.DomHelper');
26 |
27 |
28 | /**
29 | * Password reset UI component.
30 | */
31 | firebaseui.auth.ui.page.PasswordReset =
32 | class extends firebaseui.auth.ui.page.Base {
33 | /**
34 | * @param {string} email The email to prefill.
35 | * @param {function()} onSubmitClick Callback to invoke when the submit button
36 | * is clicked.
37 | * @param {goog.dom.DomHelper=} opt_domHelper Optional DOM helper.
38 | */
39 | constructor(email, onSubmitClick, opt_domHelper) {
40 | super(
41 | firebaseui.auth.soy2.page.passwordReset, {email: email}, opt_domHelper,
42 | 'passwordReset');
43 | this.onSubmitClick_ = onSubmitClick;
44 | }
45 |
46 | /** @override */
47 | enterDocument() {
48 | this.initNewPasswordElement();
49 | this.initFormElement(this.onSubmitClick_);
50 | this.submitOnEnter(this.getNewPasswordElement(), this.onSubmitClick_);
51 | this.getNewPasswordElement().focus();
52 | super.enterDocument();
53 | }
54 |
55 | /** @override */
56 | disposeInternal() {
57 | this.onSubmitClick_ = null;
58 | super.disposeInternal();
59 | }
60 | };
61 |
62 |
63 | goog.mixin(
64 | firebaseui.auth.ui.page.PasswordReset.prototype,
65 | /** @lends {firebaseui.auth.ui.page.PasswordReset.prototype} */
66 | {
67 | // For new password.
68 | getNewPasswordElement:
69 | firebaseui.auth.ui.element.newPassword.getNewPasswordElement,
70 | getNewPasswordErrorElement:
71 | firebaseui.auth.ui.element.newPassword.getNewPasswordErrorElement,
72 | getPasswordToggleElement:
73 | firebaseui.auth.ui.element.newPassword.getPasswordToggleElement,
74 | initNewPasswordElement:
75 | firebaseui.auth.ui.element.newPassword.initNewPasswordElement,
76 | checkAndGetNewPassword:
77 | firebaseui.auth.ui.element.newPassword.checkAndGetNewPassword,
78 |
79 | // For form.
80 | getSubmitElement:
81 | firebaseui.auth.ui.element.form.getSubmitElement,
82 | getSecondaryLinkElement:
83 | firebaseui.auth.ui.element.form.getSecondaryLinkElement,
84 | initFormElement:
85 | firebaseui.auth.ui.element.form.initFormElement
86 | });
87 |
--------------------------------------------------------------------------------
/javascript/ui/page/providersignin.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Google Inc. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | /** @fileoverview UI component for the list of supported identity providers. */
16 |
17 | goog.module('firebaseui.auth.ui.page.ProviderSignIn');
18 | goog.module.declareLegacyNamespace();
19 |
20 | const Base = goog.require('firebaseui.auth.ui.page.Base');
21 | const DomHelper = goog.requireType('goog.dom.DomHelper');
22 | const idps = goog.require('firebaseui.auth.ui.element.idps');
23 | const page = goog.require('firebaseui.auth.soy2.page');
24 |
25 | /** UI component that displays a list of supported identity providers. */
26 | class ProviderSignIn extends Base {
27 | /**
28 | * @param {function(string)} onIdpClick Callback to invoke when the user
29 | * clicks one IdP button.
30 | * @param {!Array} providerConfigs The provider configs of the IdPs
31 | * to display.
32 | * @param {?function()=} opt_tosCallback Callback to invoke when the ToS link
33 | * is clicked.
34 | * @param {?function()=} opt_privacyPolicyCallback Callback to invoke when
35 | * the Privacy Policy link is clicked.
36 | * @param {?DomHelper=} domHelper Optional DOM helper.
37 | */
38 | constructor(
39 | onIdpClick, providerConfigs, opt_tosCallback, opt_privacyPolicyCallback,
40 | domHelper = undefined) {
41 | super(
42 | page.providerSignIn,
43 | {providerConfigs: providerConfigs}, domHelper, 'providerSignIn', {
44 | tosCallback: opt_tosCallback,
45 | privacyPolicyCallback: opt_privacyPolicyCallback,
46 | });
47 | this.onIdpClick_ = onIdpClick;
48 | }
49 |
50 | /** @override */
51 | enterDocument() {
52 | this.initIdpList(this.onIdpClick_);
53 | super.enterDocument();
54 | }
55 |
56 | /** @override */
57 | disposeInternal() {
58 | this.onIdpClick_ = null;
59 | super.disposeInternal();
60 | }
61 | }
62 |
63 | goog.mixin(
64 | ProviderSignIn.prototype,
65 | /** @lends {ProviderSignIn.prototype} */
66 | {
67 | // For idps.
68 | initIdpList: idps.initIdpList,
69 | });
70 |
71 | exports = ProviderSignIn;
72 |
--------------------------------------------------------------------------------
/javascript/ui/page/selecttenant.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Google Inc. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | /** @fileoverview UI component for the list of tenants to select from. */
16 |
17 | goog.module('firebaseui.auth.ui.page.SelectTenant');
18 | goog.module.declareLegacyNamespace();
19 |
20 | const Base = goog.require('firebaseui.auth.ui.page.Base');
21 | const DomHelper = goog.requireType('goog.dom.DomHelper');
22 | const dataset = goog.require('goog.dom.dataset');
23 | const element = goog.require('firebaseui.auth.ui.element');
24 | const page = goog.require('firebaseui.auth.soy2.page');
25 |
26 | /** UI component that displays a list of tenants to select from. */
27 | class SelectTenant extends Base {
28 | /**
29 | * @param {function(?string)} onTenantClick Callback to invoke when the user
30 | * clicks one tenant selection button.
31 | * @param {!Array} tenantConfigs The button configs of the tenants
32 | * to display.
33 | * @param {?function()=} tosCallback Optional callback to invoke when the
34 | * ToS link is clicked.
35 | * @param {?function()=} privacyPolicyCallback Optional callback to invoke
36 | * when the Privacy Policy link is clicked.
37 | * @param {?DomHelper=} domHelper Optional DOM helper.
38 | */
39 | constructor(
40 | onTenantClick, tenantConfigs, tosCallback = undefined,
41 | privacyPolicyCallback = undefined, domHelper = undefined) {
42 | super(
43 | page.selectTenant,
44 | {
45 | tenantConfigs: tenantConfigs,
46 | },
47 | domHelper,
48 | 'selectTenant',
49 | {
50 | tosCallback: tosCallback,
51 | privacyPolicyCallback: privacyPolicyCallback,
52 | });
53 | this.onTenantClick_ = onTenantClick;
54 | }
55 |
56 | /** @override */
57 | enterDocument() {
58 | this.initTenantList_(this.onTenantClick_);
59 | super.enterDocument();
60 | }
61 |
62 | /** @override */
63 | disposeInternal() {
64 | this.onTenantClick_ = null;
65 | super.disposeInternal();
66 | }
67 |
68 | /**
69 | * Initializes tenant selection menu buttons.
70 | * @param {function(?string)} onClick Callback to invoke when the user clicks
71 | * one tenant selection button.
72 | * @private
73 | */
74 | initTenantList_(onClick) {
75 | const buttons =
76 | this.getElementsByClass('firebaseui-id-tenant-selection-button');
77 | const cb = (tenantId, e) => {
78 | onClick(tenantId);
79 | };
80 | for (let i = 0; i < buttons.length; i++) {
81 | const button = buttons[i];
82 | const tenantId = dataset.get(button, 'tenantId');
83 | element.listenForActionEvent(this, button, goog.partial(cb, tenantId));
84 | }
85 | }
86 | }
87 |
88 | exports = SelectTenant;
89 |
--------------------------------------------------------------------------------
/javascript/ui/page/spinner.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Google Inc. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | /**
16 | * @fileoverview UI component for the spinner page.
17 | */
18 |
19 | goog.provide('firebaseui.auth.ui.page.Spinner');
20 |
21 | goog.require('firebaseui.auth.soy2.page');
22 | goog.require('firebaseui.auth.ui.page.Base');
23 | goog.requireType('goog.dom.DomHelper');
24 |
25 |
26 | /**
27 | * Spinner page UI componenet.
28 | */
29 | firebaseui.auth.ui.page.Spinner = class extends firebaseui.auth.ui.page.Base {
30 | /**
31 | * @param {?goog.dom.DomHelper=} opt_domHelper Optional DOM helper.
32 | */
33 | constructor(opt_domHelper) {
34 | super(
35 | firebaseui.auth.soy2.page.spinner, undefined, opt_domHelper, 'spinner');
36 | }
37 | };
38 |
--------------------------------------------------------------------------------
/javascript/ui/page/spinner_test.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Google Inc. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | /**
16 | * @fileoverview Tests for the spinner page.
17 | */
18 |
19 | goog.provide('firebaseui.auth.ui.page.SpinnerTest');
20 | goog.setTestOnly('firebaseui.auth.ui.page.SpinnerTest');
21 |
22 | goog.require('firebaseui.auth.ui.page.PageTestHelper');
23 | goog.require('firebaseui.auth.ui.page.Spinner');
24 | goog.require('goog.dom');
25 | goog.require('goog.dom.TagName');
26 | goog.require('goog.testing.MockClock');
27 | goog.require('goog.testing.jsunit');
28 |
29 |
30 | var mockClock;
31 | var root;
32 | var component;
33 | var pageTestHelper = new firebaseui.auth.ui.page.PageTestHelper()
34 | // Spinner already has a progress bar. No need to use
35 | // executePromiseRequest.
36 | .excludeTests('testExecutePromiseRequest_')
37 | .registerTests();
38 |
39 |
40 | function setUp() {
41 | // Set up clock.
42 | mockClock = new goog.testing.MockClock();
43 | mockClock.install();
44 | root = goog.dom.createDom(goog.dom.TagName.DIV);
45 | document.body.appendChild(root);
46 | component = new firebaseui.auth.ui.page.Spinner();
47 | component.render(root);
48 | pageTestHelper.setClock(mockClock).setComponent(component);
49 | }
50 |
51 |
52 | function tearDown() {
53 | // Tear down clock.
54 | mockClock.tick(Infinity);
55 | mockClock.reset();
56 | component.dispose();
57 | goog.dom.removeNode(root);
58 | }
59 |
60 |
61 | function testSpinner_getPageId() {
62 | assertEquals('spinner', component.getPageId());
63 | }
64 |
65 |
66 | function testSpinner_pageEvents() {
67 | // Run page event tests.
68 | // Dispose previously created container since test must run before rendering
69 | // the component in document.
70 | component.dispose();
71 | // Initialize component.
72 | component = new firebaseui.auth.ui.page.Spinner();
73 | // Run all page helper tests.
74 | pageTestHelper.runTests(component, root);
75 | }
76 |
--------------------------------------------------------------------------------
/javascript/ui/page/unsupportedprovider.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Google Inc. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | /**
16 | * @fileoverview UI component for the unsupported provider page.
17 | */
18 |
19 | goog.provide('firebaseui.auth.ui.page.UnsupportedProvider');
20 |
21 | goog.require('firebaseui.auth.soy2.page');
22 | goog.require('firebaseui.auth.ui.element');
23 | goog.require('firebaseui.auth.ui.element.form');
24 | goog.require('firebaseui.auth.ui.page.Base');
25 | goog.requireType('goog.dom.DomHelper');
26 |
27 |
28 | /**
29 | * Unsupported provider UI component.
30 | */
31 | firebaseui.auth.ui.page.UnsupportedProvider =
32 | class extends firebaseui.auth.ui.page.Base {
33 | /**
34 | * @param {string} email The user's email.
35 | * @param {function()} onSubmitClick Callback to invoke when the submit button
36 | * is clicked.
37 | * @param {function()} onCancelClick Callback to invoke when the cancel button
38 | * is clicked.
39 | * @param {?function()=} opt_tosCallback Callback to invoke when the ToS link
40 | * is clicked.
41 | * @param {?function()=} opt_privacyPolicyCallback Callback to invoke when the
42 | * Privacy Policy link is clicked.
43 | * @param {?goog.dom.DomHelper=} opt_domHelper Optional DOM helper.
44 | */
45 | constructor(
46 | email, onSubmitClick, onCancelClick, opt_tosCallback,
47 | opt_privacyPolicyCallback, opt_domHelper) {
48 | super(
49 | firebaseui.auth.soy2.page.unsupportedProvider, {email: email},
50 | opt_domHelper, 'unsupportedProvider', {
51 | tosCallback: opt_tosCallback,
52 | privacyPolicyCallback: opt_privacyPolicyCallback
53 | });
54 | this.onSubmitClick_ = onSubmitClick;
55 | this.onCancelClick_ = onCancelClick;
56 | }
57 |
58 | /** @override */
59 | enterDocument() {
60 | this.initFormElement(this.onSubmitClick_, this.onCancelClick_);
61 | this.getSubmitElement().focus();
62 | super.enterDocument();
63 | }
64 |
65 | /** @override */
66 | disposeInternal() {
67 | this.onSubmitClick_ = null;
68 | this.onCancelClick_ = null;
69 | super.disposeInternal();
70 | }
71 | };
72 |
73 |
74 | goog.mixin(
75 | firebaseui.auth.ui.page.UnsupportedProvider.prototype,
76 | /** @lends {firebaseui.auth.ui.page.UnsupportedProvider.prototype} */
77 | {
78 | // For form.
79 | getSubmitElement:
80 | firebaseui.auth.ui.element.form.getSubmitElement,
81 | getSecondaryLinkElement:
82 | firebaseui.auth.ui.element.form.getSecondaryLinkElement,
83 | initFormElement:
84 | firebaseui.auth.ui.element.form.initFormElement
85 | });
86 |
--------------------------------------------------------------------------------
/javascript/utils/account.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Google Inc. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | /**
16 | * @fileoverview Defines account object.
17 | */
18 |
19 | goog.provide('firebaseui.auth.Account');
20 |
21 |
22 | firebaseui.auth.Account = class {
23 | /**
24 | * @param {string} email The email address.
25 | * @param {?string=} displayName The display name, defaulting to null.
26 | * @param {?string=} photoUrl The profile photo URL, defaulting to null.
27 | * @param {?string=} providerId The identity provider ID, defaulting to
28 | * null.
29 | */
30 | constructor(email, displayName, photoUrl, providerId) {
31 | this.email_ = email;
32 | this.displayName_ = displayName || null;
33 | this.photoUrl_ = photoUrl || null;
34 | this.providerId_ = providerId || null;
35 | }
36 |
37 |
38 | /** @return {string} The email address. */
39 | getEmail() {
40 | return this.email_;
41 | }
42 |
43 |
44 | /** @return {?string} The displayName. */
45 | getDisplayName() {
46 | return this.displayName_ || null;
47 | }
48 |
49 |
50 | /** @return {?string} The profile photo URL. */
51 | getPhotoUrl() {
52 | return this.photoUrl_ || null;
53 | }
54 |
55 |
56 | /** @return {?string} The identity provider ID. */
57 | getProviderId() {
58 | return this.providerId_ || null;
59 | }
60 |
61 |
62 | /**
63 | * @return {{
64 | * email: string,
65 | * displayName: ?string,
66 | * photoUrl: ?string,
67 | * providerId: ?string
68 | * }} The plain object representation for the account.
69 | */
70 | toPlainObject() {
71 | return {
72 | 'email': this.email_,
73 | 'displayName': this.displayName_,
74 | 'photoUrl': this.photoUrl_,
75 | 'providerId': this.providerId_
76 | };
77 | }
78 |
79 |
80 | /**
81 | * Converts a plain account object to `firebaseui.auth.Account`.
82 | * @param {!Object} account The plain object representation of an account.
83 | * @return {?firebaseui.auth.Account} The account.
84 | */
85 | static fromPlainObject(account) {
86 | return new firebaseui.auth.Account(
87 | account['email'], account['displayName'], account['photoUrl'],
88 | account['providerId']);
89 | }
90 | };
91 |
--------------------------------------------------------------------------------
/javascript/utils/account_test.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Google Inc. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | /**
16 | * @fileoverview Tests for account.js.
17 | */
18 |
19 | goog.provide('firebaseui.auth.AccountTest');
20 |
21 | goog.require('firebaseui.auth.Account');
22 | goog.require('goog.testing.jsunit');
23 |
24 | goog.setTestOnly('firebaseui.auth.AccountTest');
25 |
26 |
27 | var account = new firebaseui.auth.Account(
28 | 'user@example.com',
29 | 'John Doe',
30 | 'http://localhost/picture.png',
31 | 'google.com');
32 |
33 |
34 | var obj = {
35 | 'email': 'user@example.com',
36 | 'displayName': 'John Doe',
37 | 'photoUrl': 'http://localhost/picture.png',
38 | 'providerId': 'google.com'
39 | };
40 |
41 |
42 | function testAccountProperties() {
43 | assertEquals('user@example.com', account.getEmail());
44 | assertEquals('John Doe', account.getDisplayName());
45 | assertEquals('http://localhost/picture.png', account.getPhotoUrl());
46 | assertEquals('google.com', account.getProviderId());
47 | }
48 |
49 |
50 | function testToPlainObject() {
51 | assertObjectEquals(obj, account.toPlainObject());
52 | }
53 |
54 |
55 | function testFromPlainObject() {
56 | assertObjectEquals(account, firebaseui.auth.Account.fromPlainObject(obj));
57 | }
58 |
--------------------------------------------------------------------------------
/javascript/utils/config_test.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Google Inc. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | /**
16 | * @fileoverview Tests for config.js.
17 | */
18 |
19 | goog.provide('firebaseui.auth.ConfigTest');
20 |
21 | goog.require('firebaseui.auth.Config');
22 | goog.require('goog.testing.jsunit');
23 |
24 | goog.setTestOnly('firebaseui.auth.ConfigTest');
25 |
26 |
27 | var instance = null;
28 |
29 |
30 | function setUp() {
31 | instance = new firebaseui.auth.Config();
32 | }
33 |
34 | function testHasGetAndSet() {
35 | var name = 'name';
36 | assertFalse(instance.has_(name));
37 | instance.set_(name, 1);
38 | assertTrue(instance.has_(name));
39 | assertEquals(1, instance.get_(name));
40 | // Case insensitive.
41 | name = 'NaMe';
42 | assertTrue(instance.has_(name));
43 | assertEquals(1, instance.get_(name));
44 | }
45 |
46 | function testDefine_withoutValue() {
47 | var name = 'test';
48 | assertFalse(instance.has_(name));
49 | instance.define(name);
50 | assertTrue(instance.has_(name));
51 | assertUndefined(instance.get_(name));
52 | }
53 |
54 | function testDefine_withValue() {
55 | var name = 'test';
56 | assertFalse(instance.has_(name));
57 | instance.define(name, 1);
58 | assertTrue(instance.has_(name));
59 | assertEquals(1, instance.get_(name));
60 | }
61 |
62 | function testDefine_duplicated() {
63 | var name = 'test';
64 | instance.define(name);
65 | assertThrows(function() {instance.define(name);});
66 | }
67 |
68 | function testUpdate_nonDefined() {
69 | assertThrows(function() {instance.update('test', 1);});
70 | }
71 |
72 | function testUpdate() {
73 | var name = 'test';
74 | instance.define(name);
75 | assertUndefined(instance.get_(name));
76 | instance.update(name, 1);
77 | assertEquals(1, instance.get_(name));
78 | }
79 |
80 | function testGet_nonDefined() {
81 | assertThrows(function() {instance.get('test');});
82 | }
83 |
84 | function testGet() {
85 | var name = 'test';
86 | instance.define(name, 1);
87 | assertEquals(1, instance.get(name));
88 | }
89 |
90 | function testGetRequired_nonDefined() {
91 | assertThrows(function() {instance.getRequired('test');});
92 | }
93 |
94 | function testGetRequired_noValue() {
95 | var name = 'test';
96 | instance.define(name);
97 | assertThrows(function() {instance.getRequired(name);});
98 | }
99 |
100 | function testGetRequired() {
101 | var name = 'test';
102 | instance.define(name, 1);
103 | assertEquals(1, instance.get(name));
104 | }
105 |
--------------------------------------------------------------------------------
/javascript/utils/cookiemechanism.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 Google Inc. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | /**
16 | * @fileoverview Defines the goog.storage.mechanism.Mechanism implementation
17 | * for cookie storage.
18 | */
19 |
20 | goog.provide('firebaseui.auth.CookieMechanism');
21 |
22 | goog.require('goog.net.cookies');
23 | goog.require('goog.storage.mechanism.Mechanism');
24 |
25 |
26 | /**
27 | * Defines a goog.storage.mechanism.Mechanism implementation for storing
28 | * cookies.
29 | */
30 | firebaseui.auth.CookieMechanism =
31 | class extends goog.storage.mechanism.Mechanism {
32 | /**
33 | * @param {?number=} opt_maxAge The max age in seconds (from now). Use -1 to
34 | * set a session cookie. If not provided, the default is -1
35 | * (i.e. set a session cookie).
36 | * @param {?string=} opt_path The path of the cookie. If not present then
37 | * this uses the full request path.
38 | * @param {?string=} opt_domain The domain of the cookie, or null to not
39 | * specify a domain attribute (browser will use the full request host
40 | * name). If not provided, the default is null (i.e. let browser use full
41 | * request host name).
42 | * @param {boolean=} opt_secure Whether the cookie should only be sent over
43 | * a secure channel.
44 | */
45 | constructor(opt_maxAge, opt_path, opt_domain, opt_secure) {
46 | super();
47 | /** @const @private {number} The cookie max age in seconds. */
48 | this.maxAge_ = typeof opt_maxAge !== 'undefined' && opt_maxAge !== null ?
49 | opt_maxAge :
50 | -1;
51 | /** @const @private {?string} The cookie path. */
52 | this.path_ = opt_path || null;
53 | /** @const @private {?string} The cookie domain policy. */
54 | this.domain_ = opt_domain || null;
55 | /** @const @private {boolean} The cookie secure policy. */
56 | this.secure_ = !!opt_secure;
57 | }
58 |
59 | /**
60 | * Set a value for a key.
61 | *
62 | * @param {string} key The key to set.
63 | * @param {string} value The string to save.
64 | * @override
65 | */
66 | set(key, value) {
67 | goog.net.cookies.set(
68 | key, value, this.maxAge_, this.path_, this.domain_, this.secure_);
69 | }
70 |
71 | /**
72 | * Get the value stored under a key.
73 | *
74 | * @param {string} key The key to get.
75 | * @return {?string} The corresponding value, null if not found.
76 | * @override
77 | */
78 | get(key) {
79 | return goog.net.cookies.get(key) || null;
80 | }
81 |
82 | /**
83 | * Remove a key and its value.
84 | *
85 | * @param {string} key The key to remove.
86 | * @override
87 | */
88 | remove(key) {
89 | goog.net.cookies.remove(key, this.path_, this.domain_);
90 | }
91 | };
92 |
--------------------------------------------------------------------------------
/javascript/utils/cookiemechanism_test.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 Google Inc. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | /**
16 | * @fileoverview Tests for cookiemechanism.js.
17 | */
18 |
19 | goog.provide('firebaseui.auth.CookieMechanismTest');
20 |
21 | goog.require('firebaseui.auth.CookieMechanism');
22 | goog.require('goog.net.cookies');
23 | goog.require('goog.testing.MockControl');
24 | goog.require('goog.testing.jsunit');
25 | goog.require('goog.testing.mockmatchers');
26 |
27 | goog.setTestOnly('firebaseui.auth.CookieMechanismTest');
28 |
29 |
30 | var mockControl;
31 | var ignoreArgument;
32 |
33 |
34 | function setUp() {
35 | mockControl = new goog.testing.MockControl();
36 | ignoreArgument = goog.testing.mockmatchers.ignoreArgument;
37 | mockControl.$resetAll();
38 | }
39 |
40 |
41 | function tearDown() {
42 | try {
43 | mockControl.$verifyAll();
44 | } finally {
45 | mockControl.$tearDown();
46 | }
47 | }
48 |
49 |
50 | /** Test all CookieMechanism APIs call expected goog.net.cookies APIs. */
51 | function testCookieMechanism() {
52 | var cookiesSet = mockControl.createMethodMock(
53 | goog.net.cookies, 'set');
54 | var cookiesGet = mockControl.createMethodMock(
55 | goog.net.cookies, 'get');
56 | var cookiesRemove = mockControl.createMethodMock(
57 | goog.net.cookies, 'remove');
58 | cookiesSet('key1', 'value1', 3600, '/path', 'example.com', true).$once();
59 | cookiesSet('key2', 'value2', -1, '/', null, false).$once();
60 | cookiesSet('key3', 'value3', 3600, '/path', 'example.com', true).$once();
61 | cookiesGet('key1').$returns('value1').$once();
62 | cookiesGet('key3').$returns('value3').$once();
63 | cookiesGet('key2').$returns('value2').$once();
64 | cookiesRemove('key1', '/path', 'example.com').$once();
65 | cookiesRemove('key2', '/', null).$once();
66 | cookiesRemove('key4', '/', null).$once();
67 | mockControl.$replayAll();
68 |
69 | var cookieMechanism1 = new firebaseui.auth.CookieMechanism(
70 | 3600, '/path', 'example.com', true);
71 | var cookieMechanism2 = new firebaseui.auth.CookieMechanism(null, '/');
72 | cookieMechanism1.set('key1', 'value1');
73 | cookieMechanism2.set('key2', 'value2');
74 | cookieMechanism1.set('key3', 'value3');
75 | assertEquals('value1', cookieMechanism1.get('key1'));
76 | assertEquals('value3', cookieMechanism1.get('key3'));
77 | assertEquals('value2', cookieMechanism1.get('key2'));
78 | cookieMechanism1.remove('key1');
79 | cookieMechanism2.remove('key2');
80 | cookieMechanism2.remove('key4');
81 | }
82 |
--------------------------------------------------------------------------------
/javascript/utils/log.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Google Inc. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | /**
16 | * @fileoverview Logger for FirebaseUI widget which logs to the window console.
17 | */
18 |
19 | goog.provide('firebaseui.auth.log');
20 |
21 | goog.require('goog.debug.Console');
22 | goog.require('goog.log');
23 |
24 |
25 | /**
26 | * The logger name.
27 | *
28 | * @const {string}
29 | * @private
30 | */
31 | firebaseui.auth.log.NAME_ = 'firebaseui';
32 |
33 |
34 | /**
35 | * The global logger instance.
36 | *
37 | * @private
38 | */
39 | firebaseui.auth.log.logger_ = goog.log.getLogger(firebaseui.auth.log.NAME_);
40 |
41 |
42 | /**
43 | * Log console, used to capture all FirebaseUI log events in window console.
44 | *
45 | * @private
46 | */
47 | firebaseui.auth.log.logConsole_ = new goog.debug.Console();
48 | firebaseui.auth.log.logConsole_.setCapturing(true);
49 |
50 |
51 | /**
52 | * Logs the debug message and exception to the console.
53 | *
54 | * @param {string} message The debug message.
55 | * @param {Error=} opt_exception The debug exception.
56 | */
57 | firebaseui.auth.log.debug = function(message, opt_exception) {
58 | goog.log.fine(firebaseui.auth.log.logger_, message, opt_exception);
59 | };
60 |
61 |
62 | /**
63 | * Logs the info message and exception to the console.
64 | *
65 | * @param {string} message The info message.
66 | * @param {Error=} opt_exception The info exception.
67 | */
68 | firebaseui.auth.log.info = function(message, opt_exception) {
69 | goog.log.info(firebaseui.auth.log.logger_, message, opt_exception);
70 | };
71 |
72 |
73 | /**
74 | * Logs the warning message and exception to the console.
75 | *
76 | * @param {string} message The warning message.
77 | * @param {Error=} opt_exception The warning exception.
78 | */
79 | firebaseui.auth.log.warning = function(message, opt_exception) {
80 | goog.log.warning(firebaseui.auth.log.logger_, message, opt_exception);
81 | };
82 |
83 |
84 | /**
85 | * Logs the error message and exception to the console.
86 | *
87 | * @param {string} message The error message.
88 | * @param {Error=} opt_exception The error exception.
89 | */
90 | firebaseui.auth.log.error = function(message, opt_exception) {
91 | goog.log.error(firebaseui.auth.log.logger_, message, opt_exception);
92 | };
93 |
--------------------------------------------------------------------------------
/javascript/utils/pendingemailcredential.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Google Inc. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | /**
16 | * @fileoverview Defines the pending email credential object. This is used to
17 | * save the state of a sign-in attempt after a redirect. It holds the original
18 | * email a user is trying to sign in to and an optional auth credential
19 | * associated with that account if it is available (federated account).
20 | */
21 |
22 | goog.provide('firebaseui.auth.PendingEmailCredential');
23 |
24 |
25 | /**
26 | * The pending email credential.
27 | */
28 | firebaseui.auth.PendingEmailCredential = class {
29 | /**
30 | * @param {string} email The pending email.
31 | * @param {?firebase.auth.AuthCredential=} credential The pending auth
32 | * credential.
33 | */
34 | constructor(email, credential) {
35 | /** @const @private {string} The pending email. */
36 | this.email_ = email;
37 | /**
38 | * @const @private {?firebase.auth.AuthCredential} The pending credential.
39 | */
40 | this.credential_ = credential || null;
41 | }
42 |
43 |
44 | /** @return {string} The pending email. */
45 | getEmail() {
46 | return this.email_;
47 | }
48 |
49 |
50 | /** @return {?firebase.auth.AuthCredential} The pending credential. */
51 | getCredential() {
52 | return this.credential_;
53 | }
54 |
55 |
56 | /**
57 | * @return {!Object} The plain object representation of a pending email
58 | * credential.
59 | */
60 | toPlainObject() {
61 | return {
62 | 'email': this.email_,
63 | 'credential': this.credential_ && this.credential_['toJSON']()
64 | };
65 | }
66 | };
67 |
68 |
69 | /**
70 | * @param {?Object} response The plain object presentation of a potential
71 | * pending email credential object.
72 | * @return {?firebaseui.auth.PendingEmailCredential} The pending email
73 | * credential representation of the provided object.
74 | */
75 | firebaseui.auth.PendingEmailCredential.fromPlainObject = function(response) {
76 | if (response && response['email']) {
77 | var credentialObject = response['credential'] &&
78 | firebase.auth.AuthCredential['fromJSON'](response['credential']);
79 | return new firebaseui.auth.PendingEmailCredential(
80 | /** @type {string} */ (response['email']), credentialObject);
81 | }
82 | return null;
83 | };
84 |
--------------------------------------------------------------------------------
/javascript/utils/phoneauthresult.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 Google Inc. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | * License for the specific language governing permissions and limitations under
14 | * the License.
15 | */
16 |
17 | /**
18 | * @fileoverview FirebaseUI phone Auth result.
19 | */
20 |
21 | goog.provide('firebaseui.auth.PhoneAuthResult');
22 |
23 | goog.require('goog.Promise');
24 |
25 |
26 | /**
27 | * Wrapper object for firebase.auth.ConfirmationResult with additional error
28 | * handler for confirm method.
29 | */
30 | firebaseui.auth.PhoneAuthResult = class {
31 | /**
32 | * @param {!firebase.auth.ConfirmationResult} confirmationResult The
33 | * confirmation result from phone Auth.
34 | * @param {(function(!Error):!goog.Promise)=} errorHandler The error
35 | * handler for confirm method.
36 | */
37 | constructor(confirmationResult, errorHandler) {
38 | /**
39 | * @const @private {!firebase.auth.ConfirmationResult} The confirmation
40 | * result from a phone number sign-in or link.
41 | */
42 | this.confirmationResult_ = confirmationResult;
43 | /**
44 | * @const @private {function(*):*} The error handler for confirm method.
45 | * If not provided, the error will be rethrown.
46 | */
47 | this.errorHandler_ = errorHandler || (error => {throw error;});
48 | /** @const {string} The verification ID in confirmation result. */
49 | this.verificationId = confirmationResult['verificationId'];
50 | }
51 |
52 |
53 | /**
54 | * @param {string} verificationCode The verification code.
55 | * @return {!goog.Promise} The user credential.
56 | */
57 | confirm(verificationCode) {
58 | return goog.Promise
59 | .resolve(this.confirmationResult_.confirm(verificationCode))
60 | .thenCatch(this.errorHandler_);
61 | }
62 |
63 |
64 | /**
65 | * @return {!firebase.auth.ConfirmationResult} The confirmation result.
66 | */
67 | getConfirmationResult() {
68 | return this.confirmationResult_;
69 | }
70 | };
71 |
--------------------------------------------------------------------------------
/javascript/utils/redirectstatus.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Google Inc. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | /**
16 | * @fileoverview Defines the redirect status object. This is used to save the
17 | * state of a sign-in attempt before a redirect operation. It holds the
18 | * original tenant ID used to sign in with and also indicates there is a pending
19 | * redirect operation to be resolved.
20 | */
21 |
22 | goog.provide('firebaseui.auth.RedirectStatus');
23 |
24 |
25 | /**
26 | * The redirect status. It indicates there is a pending redirect operation to be
27 | * resolved.
28 | */
29 | firebaseui.auth.RedirectStatus = class {
30 | /**
31 | * The redirect status. It indicates there is a pending redirect operation to
32 | * be resolved.
33 | * @param {?string=} tenantId The optional tenant ID.
34 | */
35 | constructor(tenantId) {
36 | /** @const @private {?string} The tenant ID. */
37 | this.tenantId_ = tenantId || null;
38 | }
39 |
40 |
41 | /** @return {?string} The tenant ID. */
42 | getTenantId() {
43 | return this.tenantId_;
44 | }
45 |
46 |
47 | /**
48 | * @return {!Object} The plain object representation of redirect status.
49 | */
50 | toPlainObject() {
51 | return {'tenantId': this.tenantId_};
52 | }
53 |
54 |
55 | /**
56 | * @param {?Object} response The plain object presentation of a potential
57 | * redirect status object.
58 | * @return {?firebaseui.auth.RedirectStatus} The redirect status
59 | * representation of the provided object.
60 | */
61 | static fromPlainObject(response) {
62 | if (response && typeof response['tenantId'] !== 'undefined') {
63 | return new firebaseui.auth.RedirectStatus(response['tenantId']);
64 | }
65 | return null;
66 | }
67 | };
68 |
--------------------------------------------------------------------------------
/javascript/utils/redirectstatus_test.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Google Inc. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | /**
16 | * @fileoverview Tests for redirectstatus.js.
17 | */
18 |
19 | goog.provide('firebaseui.auth.RedirectStatusTest');
20 |
21 | goog.require('firebaseui.auth.RedirectStatus');
22 | goog.require('goog.testing.jsunit');
23 |
24 | goog.setTestOnly('firebaseui.auth.RedirectStatusTest');
25 |
26 |
27 | var redirectStatus1 = new firebaseui.auth.RedirectStatus('TENANT_ID');
28 | var redirectStatus2 = new firebaseui.auth.RedirectStatus();
29 | var obj1 = {
30 | 'tenantId': 'TENANT_ID'
31 | };
32 | var obj2 = {
33 | 'tenantId': null
34 | };
35 |
36 |
37 | function testRedirectStatus() {
38 | assertEquals('TENANT_ID', redirectStatus1.getTenantId());
39 | assertNull(redirectStatus2.getTenantId());
40 | }
41 |
42 |
43 | function testToPlainObject() {
44 | assertObjectEquals(obj1, redirectStatus1.toPlainObject());
45 | assertObjectEquals(obj2, redirectStatus2.toPlainObject());
46 | }
47 |
48 |
49 | function testFromPlainObject() {
50 | assertObjectEquals(redirectStatus1,
51 | firebaseui.auth.RedirectStatus.fromPlainObject(obj1));
52 | assertObjectEquals(redirectStatus2,
53 | firebaseui.auth.RedirectStatus.fromPlainObject(obj2));
54 | assertNull(firebaseui.auth.RedirectStatus.fromPlainObject({}));
55 | }
56 |
--------------------------------------------------------------------------------
/javascript/widgets/authuierror.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 Google Inc. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | /** @fileoverview FirebaseUI error. */
16 |
17 | goog.module('firebaseui.auth.AuthUIError');
18 | goog.module.declareLegacyNamespace();
19 |
20 | const strings = goog.require('firebaseui.auth.soy2.strings');
21 |
22 | /** Error that can be returned to the developer. */
23 | class AuthUIError extends Error {
24 | /**
25 | * @param {!AuthUIError.Error} code The short error code.
26 | * @param {?string=} opt_message The human-readable message.
27 | * @param {?firebase.auth.AuthCredential=} opt_credential The Auth credential
28 | * that failed to link to the anonymous user.
29 | */
30 | constructor(code, opt_message, opt_credential) {
31 | super();
32 | /** @export */
33 | this.code = AuthUIError.ERROR_CODE_PREFIX + code;
34 | /** @export */
35 | this.message = opt_message ||
36 | AuthUIError.getDefaultErrorMessage_(this.code) || '';
37 | /** @export */
38 | this.credential = opt_credential || null;
39 | }
40 |
41 | /** @return {!Object} The plain object form of the error. */
42 | toPlainObject() {
43 | return {
44 | 'code': this.code,
45 | 'message': this.message,
46 | };
47 | }
48 |
49 | /**
50 | * @return {!Object} The plain object form of the error. This is used by
51 | * JSON.stringify() to return the stringified representation of the error.
52 | * @override
53 | */
54 | toJSON() {
55 | return this.toPlainObject();
56 | }
57 |
58 | /**
59 | * Maps the error code to the default error message.
60 | * @param {string} code The error code.
61 | * @return {string} The display error message.
62 | * @private
63 | */
64 | static getDefaultErrorMessage_(code) {
65 | return strings.errorAuthUI({code: code}).toString();
66 | }
67 | }
68 |
69 | /**
70 | * The error prefix for AuthUIError.
71 | * @protected {string}
72 | */
73 | AuthUIError.ERROR_CODE_PREFIX = 'firebaseui/';
74 |
75 | /**
76 | * Developer facing FirebaseUI error codes.
77 | * @enum {string}
78 | */
79 | AuthUIError.Error = {
80 | MERGE_CONFLICT: 'anonymous-upgrade-merge-conflict',
81 | };
82 |
83 | exports = AuthUIError;
84 |
--------------------------------------------------------------------------------
/javascript/widgets/authuierror_test.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 Google Inc. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | /** @fileoverview Tests for authuierror.js */
16 |
17 | goog.module('firebaseui.auth.AuthUIErrorTest');
18 | goog.setTestOnly();
19 |
20 | const AuthUIError = goog.require('firebaseui.auth.AuthUIError');
21 | const strings = goog.require('firebaseui.auth.soy2.strings');
22 | const testSuite = goog.require('goog.testing.testSuite');
23 |
24 | testSuite({
25 | testAuthUIError() {
26 | const authCredential = {'accessToken': 'googleAccessToken',
27 | 'providerId': 'google.com'};
28 | const error = new AuthUIError(
29 | AuthUIError.Error.MERGE_CONFLICT, undefined,
30 | authCredential);
31 | assertEquals('firebaseui/anonymous-upgrade-merge-conflict', error.code);
32 | assertEquals(
33 | strings.errorAuthUI(
34 | {code: error.code}).toString(),
35 | error.message);
36 | // Test toJSON(). Do not expose credential in JSON object.
37 | assertObjectEquals({
38 | code: error.code,
39 | message: error.message,
40 | }, error.toJSON());
41 | // Make sure JSON.stringify works and uses underlying toJSON.
42 | assertEquals(JSON.stringify(error), JSON.stringify(error.toJSON()));
43 | },
44 |
45 | testAuthUIError_customMessage() {
46 | const authCredential = {'accessToken': 'googleAccessToken',
47 | 'providerId': 'google.com'};
48 | const error = new AuthUIError(
49 | AuthUIError.Error.MERGE_CONFLICT, 'merge conflict error',
50 | authCredential);
51 | assertEquals('firebaseui/anonymous-upgrade-merge-conflict', error.code);
52 | assertEquals('merge conflict error', error.message);
53 | // Test toJSON(). Do not expose credential in JSON object.
54 | assertObjectEquals({
55 | code: error.code,
56 | message: error.message,
57 | }, error.toJSON());
58 | // Make sure JSON.stringify works and uses underlying toJSON.
59 | assertEquals(JSON.stringify(error), JSON.stringify(error.toJSON()));
60 | },
61 | });
62 |
--------------------------------------------------------------------------------
/javascript/widgets/handler/anonymoususermismatch.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 Google Inc. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | /**
16 | * @fileoverview Anonymous user mismatch handler.
17 | */
18 |
19 | goog.provide('firebaseui.auth.widget.handler.handleAnonymousUserMismatch');
20 |
21 | goog.require('firebaseui.auth.ui.page.AnonymousUserMismatch');
22 | goog.require('firebaseui.auth.widget.HandlerName');
23 | goog.require('firebaseui.auth.widget.handler');
24 | goog.require('firebaseui.auth.widget.handler.common');
25 | goog.requireType('firebaseui.auth.widget.Handler');
26 |
27 |
28 | /**
29 | * Handles the anonymous user mismatch.
30 | * @param {!firebaseui.auth.AuthUI} app The current FirebaseUI instance whose
31 | * configuration is used.
32 | * @param {!Element} container The container DOM element.
33 | */
34 | firebaseui.auth.widget.handler.handleAnonymousUserMismatch = function(
35 | app, container) {
36 | // Render the UI.
37 | var component =
38 | new firebaseui.auth.ui.page.AnonymousUserMismatch(function() {
39 | component.dispose();
40 | firebaseui.auth.widget.handler.common.handleSignInStart(app, container);
41 | });
42 | component.render(container);
43 | // Set current UI component.
44 | app.setCurrentComponent(component);
45 | };
46 |
47 |
48 | // Register handler.
49 | firebaseui.auth.widget.handler.register(
50 | firebaseui.auth.widget.HandlerName.ANONYMOUS_USER_MISMATCH,
51 | /** @type {!firebaseui.auth.widget.Handler} */
52 | (firebaseui.auth.widget.handler.handleAnonymousUserMismatch));
53 |
--------------------------------------------------------------------------------
/javascript/widgets/handler/anonymoususermismatch_test.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 Google Inc. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | /**
16 | * @fileoverview Test for anonymous user mismatch handler.
17 | */
18 |
19 | goog.provide('firebaseui.auth.widget.handler.AnonymousUserMismatchTest');
20 | goog.setTestOnly('firebaseui.auth.widget.handler.AnonymousUserMismatchTest');
21 |
22 | goog.require('firebaseui.auth.widget.handler.handleAnonymousUserMismatch');
23 | /** @suppress {extraRequire} Required for accessing test helper utilities. */
24 | goog.require('firebaseui.auth.widget.handler.testHelper');
25 |
26 |
27 | function testHandleAnonymousUserMismatch() {
28 | firebaseui.auth.widget.handler.handleAnonymousUserMismatch(
29 | app, container);
30 | assertAnonymousUserMismatchPage();
31 | // Clicking dismiss button should redirect to the first page.
32 | clickSecondaryLink();
33 | assertProviderSignInPage();
34 | }
35 |
--------------------------------------------------------------------------------
/javascript/widgets/handler/differentdeviceerror.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 Google Inc. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | /**
16 | * @fileoverview Different device error handler.
17 | */
18 |
19 | goog.provide('firebaseui.auth.widget.handler.handleDifferentDeviceError');
20 |
21 | goog.require('firebaseui.auth.ui.page.DifferentDeviceError');
22 | goog.require('firebaseui.auth.widget.HandlerName');
23 | goog.require('firebaseui.auth.widget.handler');
24 | goog.require('firebaseui.auth.widget.handler.common');
25 | goog.requireType('firebaseui.auth.widget.Handler');
26 |
27 |
28 | /**
29 | * Handles the different device error.
30 | * @param {!firebaseui.auth.AuthUI} app The current FirebaseUI instance whose
31 | * configuration is used.
32 | * @param {!Element} container The container DOM element.
33 | */
34 | firebaseui.auth.widget.handler.handleDifferentDeviceError = function(
35 | app, container) {
36 | // Render the UI.
37 | var component = new firebaseui.auth.ui.page.DifferentDeviceError(function() {
38 | component.dispose();
39 | firebaseui.auth.widget.handler.common.handleSignInStart(app, container);
40 | });
41 | component.render(container);
42 | // Set current UI component.
43 | app.setCurrentComponent(component);
44 | };
45 |
46 |
47 | // Register handler.
48 | firebaseui.auth.widget.handler.register(
49 | firebaseui.auth.widget.HandlerName.DIFFERENT_DEVICE_ERROR,
50 | /** @type {!firebaseui.auth.widget.Handler} */
51 | (firebaseui.auth.widget.handler.handleDifferentDeviceError));
52 |
--------------------------------------------------------------------------------
/javascript/widgets/handler/differentdeviceerror_test.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 Google Inc. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | /**
16 | * @fileoverview Test for different device error handler.
17 | */
18 |
19 | goog.provide('firebaseui.auth.widget.handler.DifferentDeviceErrorTest');
20 | goog.setTestOnly('firebaseui.auth.widget.handler.DifferentDeviceErrorTest');
21 |
22 | goog.require('firebaseui.auth.widget.handler.handleDifferentDeviceError');
23 | /** @suppress {extraRequire} Required for accessing test helper utilities. */
24 | goog.require('firebaseui.auth.widget.handler.testHelper');
25 |
26 |
27 | function testHandleDifferentDeviceError() {
28 | firebaseui.auth.widget.handler.handleDifferentDeviceError(app, container);
29 | assertDifferentDeviceErrorPage();
30 | // Clicking dismiss button should redirect to the first page.
31 | clickSecondaryLink();
32 | assertProviderSignInPage();
33 | }
34 |
--------------------------------------------------------------------------------
/javascript/widgets/handler/emaillinknewdevicelinking_test.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 Google Inc. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | /**
16 | * @fileoverview Test for email linking on new device handler.
17 | */
18 |
19 | goog.provide('firebaseui.auth.widget.handler.EmailLinkNewDeviceLinkingTest');
20 | goog.setTestOnly('firebaseui.auth.widget.handler.EmailLinkNewDeviceLinkingTest');
21 |
22 | goog.require('firebaseui.auth.widget.handler.handleEmailLinkNewDeviceLinking');
23 | /** @suppress {extraRequire} Required for accessing test helper utilities. */
24 | goog.require('firebaseui.auth.widget.handler.testHelper');
25 | goog.require('goog.testing.recordFunction');
26 |
27 |
28 | function testHandleEmailLinkNewDeviceLinking() {
29 | var link = generateSignInLink('SESSIONID', null, 'facebook.com');
30 | var modifiedLink = generateSignInLink('SESSIONID', null);
31 | var onContinue = goog.testing.recordFunction();
32 |
33 | firebaseui.auth.widget.handler.handleEmailLinkNewDeviceLinking(
34 | app, container, link, onContinue);
35 |
36 | assertEmailLinkSignInLinkingDifferentDevicePage('Facebook');
37 | assertTosPpFooter(tosCallback, 'http://localhost/privacy_policy');
38 |
39 | submitForm();
40 |
41 | assertComponentDisposed();
42 | assertEquals(1, onContinue.getCallCount());
43 | assertEquals(app, onContinue.getLastCall().getArgument(0));
44 | assertEquals(container, onContinue.getLastCall().getArgument(1));
45 | assertEquals(modifiedLink, onContinue.getLastCall().getArgument(2));
46 | }
47 |
48 |
49 | function testHandleEmailLinkNewDeviceLinking_noProviderId() {
50 | var linkWithoutProviderId = generateSignInLink('SESSIONID', null);
51 | var onContinue = goog.testing.recordFunction();
52 |
53 | firebaseui.auth.widget.handler.handleEmailLinkNewDeviceLinking(
54 | app, container, linkWithoutProviderId, onContinue);
55 |
56 | assertProviderSignInPage();
57 | assertEquals(0, onContinue.getCallCount());
58 | }
59 |
--------------------------------------------------------------------------------
/javascript/widgets/handler/emaillinksigninsent.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 Google Inc. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | /**
16 | * @fileoverview Email link sign in sent handler.
17 | */
18 |
19 | goog.provide('firebaseui.auth.widget.handler.handleEmailLinkSignInSent');
20 |
21 | goog.require('firebaseui.auth.ui.page.EmailLinkSignInSent');
22 | goog.require('firebaseui.auth.widget.Handler');
23 | goog.require('firebaseui.auth.widget.HandlerName');
24 | goog.require('firebaseui.auth.widget.handler');
25 |
26 | /**
27 | * Handles email link sign in sent.
28 | *
29 | * @param {!firebaseui.auth.AuthUI} app The current Firebase UI instance whose
30 | * configuration is used.
31 | * @param {!Element} container The container DOM element.
32 | * @param {string} email The email address of the account.
33 | * @param {function()} onCancelClick Callback to invoke when the back button is
34 | * clicked.
35 | * @param {?firebaseui.auth.PendingEmailCredential=} opt_pendingCredential The
36 | * pending credential to link to a successfully signed in user.
37 | */
38 | firebaseui.auth.widget.handler.handleEmailLinkSignInSent = function(
39 | app, container, email, onCancelClick, opt_pendingCredential) {
40 | var component = new firebaseui.auth.ui.page.EmailLinkSignInSent(
41 | email,
42 | // On trouble getting email click.
43 | function() {
44 | component.dispose();
45 | firebaseui.auth.widget.handler.handle(
46 | firebaseui.auth.widget.HandlerName.EMAIL_NOT_RECEIVED,
47 | app,
48 | container,
49 | email,
50 | onCancelClick,
51 | opt_pendingCredential);
52 | },
53 | // On back button click.
54 | function() {
55 | component.dispose();
56 | onCancelClick();
57 | },
58 | app.getConfig().getTosUrl(),
59 | app.getConfig().getPrivacyPolicyUrl());
60 | component.render(container);
61 | // Set current UI component.
62 | app.setCurrentComponent(component);
63 | };
64 |
65 | // Register handler.
66 | firebaseui.auth.widget.handler.register(
67 | firebaseui.auth.widget.HandlerName.EMAIL_LINK_SIGN_IN_SENT,
68 | /** @type {!firebaseui.auth.widget.Handler} */
69 | (firebaseui.auth.widget.handler.handleEmailLinkSignInSent));
70 |
--------------------------------------------------------------------------------
/javascript/widgets/handler/emailnotreceived.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 Google Inc. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | /**
16 | * @fileoverview Email not received handler.
17 | */
18 |
19 | goog.provide('firebaseui.auth.widget.handler.handleEmailNotReceived');
20 |
21 | goog.require('firebaseui.auth.ui.page.EmailNotReceived');
22 | goog.require('firebaseui.auth.widget.Handler');
23 | goog.require('firebaseui.auth.widget.HandlerName');
24 | goog.require('firebaseui.auth.widget.handler');
25 | goog.require('firebaseui.auth.widget.handler.common');
26 | goog.requireType('firebaseui.auth.PendingEmailCredential');
27 |
28 |
29 | /**
30 | * Handles email not received.
31 | *
32 | * @param {!firebaseui.auth.AuthUI} app The current Firebase UI instance whose
33 | * configuration is used.
34 | * @param {!Element} container The container DOM element.
35 | * @param {string} email The email address of the account.
36 | * @param {function()} onCancelClick Callback to invoke when the back button is
37 | * clicked in email link sign in sent page.
38 | * @param {?firebaseui.auth.PendingEmailCredential=} opt_pendingCredential The
39 | * pending credential to link to a successfully signed in user.
40 | */
41 | firebaseui.auth.widget.handler.handleEmailNotReceived = function(
42 | app, container, email, onCancelClick, opt_pendingCredential) {
43 | var component = new firebaseui.auth.ui.page.EmailNotReceived(
44 | // On resend link click.
45 | function() {
46 | firebaseui.auth.widget.handler.common.sendEmailLinkForSignIn(
47 | app,
48 | component,
49 | email,
50 | onCancelClick,
51 | function(error) {
52 | // The email provided could be an invalid one or some other error
53 | // could occur.
54 | var errorMessage =
55 | firebaseui.auth.widget.handler.common.getErrorMessage(error);
56 | component.showInfoBar(errorMessage);
57 | },
58 | opt_pendingCredential);
59 | },
60 | // On back button click.
61 | function() {
62 | component.dispose();
63 | firebaseui.auth.widget.handler.common.handleSignInStart(
64 | app,
65 | container,
66 | email);
67 | },
68 | app.getConfig().getTosUrl(),
69 | app.getConfig().getPrivacyPolicyUrl());
70 | component.render(container);
71 | // Set current UI component.
72 | app.setCurrentComponent(component);
73 | };
74 |
75 |
76 | // Register handler.
77 | firebaseui.auth.widget.handler.register(
78 | firebaseui.auth.widget.HandlerName.EMAIL_NOT_RECEIVED,
79 | /** @type {!firebaseui.auth.widget.Handler} */
80 | (firebaseui.auth.widget.handler.handleEmailNotReceived));
81 |
--------------------------------------------------------------------------------
/javascript/widgets/handler/federatedredirect.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Google Inc. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | /**
16 | * @fileoverview Federated redirect handler.
17 | */
18 |
19 | goog.provide('firebaseui.auth.widget.handler.handleFederatedRedirect');
20 |
21 | goog.require('firebaseui.auth.ui.page.Blank');
22 | goog.require('firebaseui.auth.widget.Handler');
23 | goog.require('firebaseui.auth.widget.HandlerName');
24 | goog.require('firebaseui.auth.widget.handler');
25 | goog.require('firebaseui.auth.widget.handler.common');
26 | goog.require('goog.asserts');
27 |
28 |
29 | /**
30 | * Handles federated redirect sign in. This is intended to be used when there
31 | * is a single federated provider and instead of showing the ‘nascar’ buttons
32 | * sign-in screen, the developer would like to immediately redirect to the
33 | * provider’s site.
34 | *
35 | * @param {?firebaseui.auth.AuthUI} app The current Firebase UI instance whose
36 | * configuration is used.
37 | * @param {?Element} container The container DOM element.
38 | * @param {string=} email The optional prefilled email to pass to IdPs.
39 | * @throws {!goog.asserts.AssertionError} Thrown if there is more than one
40 | * provider.
41 | */
42 | firebaseui.auth.widget.handler.handleFederatedRedirect = function(
43 | app,
44 | container,
45 | email = undefined) {
46 | var component = new firebaseui.auth.ui.page.Blank();
47 | component.render(container);
48 | // Set current UI component.
49 | app.setCurrentComponent(component);
50 | // There should only be one federated provider here because this handler
51 | // is only designed to be called in this situation.
52 | goog.asserts.assert(
53 | app.getConfig().federatedProviderShouldImmediatelyRedirect());
54 | var providerId = app.getConfig().getProviders()[0];
55 | // Immediately start the redirect.
56 | firebaseui.auth.widget.handler.common.federatedSignIn(
57 | /** @type {!firebaseui.auth.AuthUI} */ (app),
58 | component,
59 | providerId,
60 | email);
61 | };
62 |
63 |
64 | // Register handler.
65 | firebaseui.auth.widget.handler.register(
66 | firebaseui.auth.widget.HandlerName.FEDERATED_REDIRECT,
67 | /** @type {!firebaseui.auth.widget.Handler} */
68 | (firebaseui.auth.widget.handler.handleFederatedRedirect));
69 |
--------------------------------------------------------------------------------
/javascript/widgets/handler/federatedsignin.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Google Inc. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | /**
16 | * @fileoverview Handles the case where the user had previously signed in with a
17 | * federated IdP but is now trying to sign in with email/password.
18 | */
19 |
20 | goog.provide('firebaseui.auth.widget.handler.handleFederatedSignIn');
21 |
22 | goog.require('firebaseui.auth.ui.page.FederatedLinking');
23 | goog.require('firebaseui.auth.widget.Handler');
24 | goog.require('firebaseui.auth.widget.HandlerName');
25 | goog.require('firebaseui.auth.widget.handler');
26 | goog.require('firebaseui.auth.widget.handler.common');
27 |
28 |
29 | /**
30 | * Handles the case where the user had previously signed in with a federated IdP
31 | * but is now trying to sign in with email/password.
32 | * @param {!firebaseui.auth.AuthUI} app The current Firebase UI instance whose
33 | * configuration is used.
34 | * @param {Element} container The container DOM element.
35 | * @param {string} email The email that was entered.
36 | * @param {string} providerId The providerId of the provider that should be used
37 | * instead of password.
38 | * @param {string=} opt_infoBarMessage The message to show on info bar.
39 | */
40 | firebaseui.auth.widget.handler.handleFederatedSignIn = function(
41 | app, container, email, providerId, opt_infoBarMessage) {
42 | var component = new firebaseui.auth.ui.page.FederatedLinking(
43 | email,
44 | app.getConfig().getConfigForProvider(providerId),
45 | // On submit.
46 | function() {
47 | // Pass the email since some OAuth providers support OAuth flow
48 | // with a specified email.
49 | firebaseui.auth.widget.handler.common.federatedSignIn(app, component,
50 | providerId, email);
51 | },
52 | app.getConfig().getTosUrl(),
53 | app.getConfig().getPrivacyPolicyUrl());
54 |
55 | component.render(container);
56 | // Set current UI component.
57 | app.setCurrentComponent(component);
58 | // Show info bar if necessary.
59 | if (opt_infoBarMessage) {
60 | component.showInfoBar(opt_infoBarMessage);
61 | }
62 | };
63 |
64 |
65 | // Register handler.
66 | firebaseui.auth.widget.handler.register(
67 | firebaseui.auth.widget.HandlerName.FEDERATED_SIGN_IN,
68 | /** @type {firebaseui.auth.widget.Handler} */
69 | (firebaseui.auth.widget.handler.handleFederatedSignIn));
70 |
--------------------------------------------------------------------------------
/javascript/widgets/handler/passwordsignin.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Google Inc. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | /**
16 | * @fileoverview Password sign in handler.
17 | */
18 |
19 | goog.provide('firebaseui.auth.widget.handler.handlePasswordSignIn');
20 |
21 | goog.require('firebaseui.auth.ui.page.PasswordSignIn');
22 | goog.require('firebaseui.auth.widget.Handler');
23 | goog.require('firebaseui.auth.widget.HandlerName');
24 | goog.require('firebaseui.auth.widget.handler');
25 | goog.require('firebaseui.auth.widget.handler.common');
26 |
27 |
28 | /**
29 | * Handles password sign in.
30 | *
31 | * @param {firebaseui.auth.AuthUI} app The current Firebase UI instance whose
32 | * configuration is used.
33 | * @param {Element} container The container DOM element.
34 | * @param {string=} opt_email The email address of the account.
35 | * @param {boolean=} opt_displayFullTosPpMessage Whether to display the full
36 | * message of Term of Service and Privacy Policy.
37 | */
38 | firebaseui.auth.widget.handler.handlePasswordSignIn = function(
39 | app, container, opt_email, opt_displayFullTosPpMessage) {
40 | // Render the UI.
41 | var component = new firebaseui.auth.ui.page.PasswordSignIn(
42 | // On submit.
43 | function() {
44 | firebaseui.auth.widget.handler.common.verifyPassword(app, component);
45 | },
46 | // On recover password link click.
47 | function() {
48 | var email = component.getEmail();
49 | component.dispose();
50 | firebaseui.auth.widget.handler.handle(
51 | firebaseui.auth.widget.HandlerName.PASSWORD_RECOVERY, app,
52 | container, email);
53 | },
54 | opt_email,
55 | app.getConfig().getTosUrl(),
56 | app.getConfig().getPrivacyPolicyUrl(),
57 | opt_displayFullTosPpMessage);
58 | component.render(container);
59 | // Set current UI component.
60 | app.setCurrentComponent(component);
61 | };
62 |
63 |
64 | // Register handler.
65 | firebaseui.auth.widget.handler.register(
66 | firebaseui.auth.widget.HandlerName.PASSWORD_SIGN_IN,
67 | /** @type {firebaseui.auth.widget.Handler} */
68 | (firebaseui.auth.widget.handler.handlePasswordSignIn));
69 |
--------------------------------------------------------------------------------
/javascript/widgets/handler/sendemaillinkforsignin.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 Google Inc. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | /**
16 | * @fileoverview Send email link for sign in handler.
17 | */
18 |
19 | goog.provide('firebaseui.auth.widget.handler.handleSendEmailLinkForSignIn');
20 |
21 | goog.require('firebaseui.auth.ui.page.Callback');
22 | goog.require('firebaseui.auth.widget.Handler');
23 | goog.require('firebaseui.auth.widget.HandlerName');
24 | goog.require('firebaseui.auth.widget.handler');
25 | goog.require('firebaseui.auth.widget.handler.common');
26 |
27 |
28 | /**
29 | * Handles send email link for sign in.
30 | *
31 | * @param {!firebaseui.auth.AuthUI} app The current Firebase UI instance whose
32 | * configuration is used.
33 | * @param {!Element} container The container DOM element.
34 | * @param {string} email The email address of the account.
35 | * @param {function()} onCancelClick Callback to invoke when the back button is
36 | * clicked in email link sign in sent page.
37 | */
38 | firebaseui.auth.widget.handler.handleSendEmailLinkForSignIn = function(
39 | app, container, email, onCancelClick) {
40 | // Render the UI.
41 | var component = new firebaseui.auth.ui.page.Callback();
42 | component.render(container);
43 | // Set current UI component.
44 | app.setCurrentComponent(component);
45 | firebaseui.auth.widget.handler.common.sendEmailLinkForSignIn(
46 | app,
47 | component,
48 | email,
49 | onCancelClick,
50 | function(error) {
51 | component.dispose();
52 | if (error && error['code'] == 'auth/admin-restricted-operation' &&
53 | app.getConfig().isAdminRestrictedOperationConfigured()) {
54 | firebaseui.auth.widget.handler.handle(
55 | firebaseui.auth.widget.HandlerName.UNAUTHORIZED_USER,
56 | app,
57 | container,
58 | email,
59 | firebase.auth.EmailAuthProvider.PROVIDER_ID);
60 | } else {
61 | // Error occurs while sending the email. Go back to the sign in page
62 | // with prefilled email and error message.
63 | const errorMessage =
64 | firebaseui.auth.widget.handler.common.getErrorMessage(error);
65 | firebaseui.auth.widget.handler.handle(
66 | firebaseui.auth.widget.HandlerName.SIGN_IN,
67 | app,
68 | container,
69 | email,
70 | errorMessage);
71 | }
72 | });
73 | };
74 |
75 |
76 | // Register handler.
77 | firebaseui.auth.widget.handler.register(
78 | firebaseui.auth.widget.HandlerName.SEND_EMAIL_LINK_FOR_SIGN_IN,
79 | /** @type {!firebaseui.auth.widget.Handler} */
80 | (firebaseui.auth.widget.handler.handleSendEmailLinkForSignIn));
81 |
--------------------------------------------------------------------------------
/javascript/widgets/handler/signin.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Google Inc. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | /**
16 | * @fileoverview Start sign in handler.
17 | */
18 |
19 | goog.provide('firebaseui.auth.widget.handler.handleSignIn');
20 |
21 | goog.require('firebaseui.auth.ui.page.SignIn');
22 | goog.require('firebaseui.auth.widget.Handler');
23 | goog.require('firebaseui.auth.widget.HandlerName');
24 | goog.require('firebaseui.auth.widget.handler');
25 | goog.require('firebaseui.auth.widget.handler.common');
26 |
27 |
28 | /**
29 | * Handles start sign in.
30 | *
31 | * @param {firebaseui.auth.AuthUI} app The current Firebase UI instance whose
32 | * configuration is used.
33 | * @param {Element} container The container DOM element.
34 | * @param {string=} opt_email The email to prefill.
35 | * @param {string=} opt_infoBarMessage The message to show on info bar.
36 | */
37 | firebaseui.auth.widget.handler.handleSignIn = function(
38 | app, container, opt_email, opt_infoBarMessage) {
39 | var isPasswordProviderOnly =
40 | firebaseui.auth.widget.handler.common.isPasswordProviderOnly(app);
41 | // Render the UI.
42 | var component = new firebaseui.auth.ui.page.SignIn(
43 | // On submit.
44 | function() {
45 | firebaseui.auth.widget.handler.onSignInEmailEnter_(app, component);
46 | },
47 | // On cancel.
48 | isPasswordProviderOnly ? null : function() {
49 | component.dispose();
50 | firebaseui.auth.widget.handler.common.handleSignInStart(
51 | app, container, opt_email);
52 | },
53 | opt_email,
54 | app.getConfig().getTosUrl(),
55 | app.getConfig().getPrivacyPolicyUrl(),
56 | isPasswordProviderOnly);
57 | component.render(container);
58 | // Set current UI component.
59 | app.setCurrentComponent(component);
60 | // Show info bar if necessary.
61 | if (opt_infoBarMessage) {
62 | component.showInfoBar(opt_infoBarMessage);
63 | }
64 | };
65 |
66 |
67 | /**
68 | * @param {firebaseui.auth.AuthUI} app The current Firebase UI instance whose
69 | * configuration is used.
70 | * @param {firebaseui.auth.ui.page.SignIn} component The UI component.
71 | * @private
72 | */
73 | firebaseui.auth.widget.handler.onSignInEmailEnter_ = function(app, component) {
74 | var email = component.checkAndGetEmail() || '';
75 | if (!email) {
76 | return;
77 | }
78 | firebaseui.auth.widget.handler.common.handleStartEmailFirstFlow(
79 | app, component, email);
80 | };
81 |
82 |
83 | // Register handler.
84 | firebaseui.auth.widget.handler.register(
85 | firebaseui.auth.widget.HandlerName.SIGN_IN,
86 | /** @type {firebaseui.auth.widget.Handler} */
87 | (firebaseui.auth.widget.handler.handleSignIn));
88 |
--------------------------------------------------------------------------------
/javascript/widgets/handler/starter.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Google Inc. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | /**
16 | * @fileoverview Handler for start sign in.
17 | */
18 |
19 | goog.provide('firebaseui.auth.widget.handler.startSignIn');
20 |
21 | goog.require('firebaseui.auth.util');
22 | goog.require('firebaseui.auth.widget.Config');
23 | goog.require('firebaseui.auth.widget.handler');
24 |
25 | goog.forwardDeclare('firebaseui.auth.AuthUI');
26 |
27 |
28 | /**
29 | * Triggers the sign in flow.
30 | *
31 | * @param {firebaseui.auth.AuthUI} app The current Firebase UI instance whose
32 | * configuration is used.
33 | */
34 | firebaseui.auth.widget.handler.startSignIn = function(app) {
35 | var selectUrl = app.getConfig().getRequiredWidgetUrl(
36 | firebaseui.auth.widget.Config.WidgetMode.SELECT);
37 | if (app.getConfig().getPopupMode()) {
38 | firebaseui.auth.util.popup(selectUrl);
39 | } else {
40 | firebaseui.auth.util.goTo(selectUrl);
41 | }
42 | };
43 |
--------------------------------------------------------------------------------
/javascript/widgets/handler/starter_test.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Google Inc. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | /**
16 | * @fileoverview Tests for sign in button handler.
17 | */
18 |
19 | goog.provide('firebaseui.auth.widget.handler.widgetSelectorTest');
20 | goog.setTestOnly('firebaseui.auth.widget.handler.widgetSelectorTest');
21 |
22 | /** @suppress {extraRequire} */
23 | goog.require('firebaseui.auth.AuthUI');
24 | goog.require('firebaseui.auth.util');
25 | goog.require('firebaseui.auth.widget.handler.startSignIn');
26 | /** @suppress {extraRequire} */
27 | goog.require('firebaseui.auth.widget.handler.testHelper');
28 |
29 |
30 | /** Tests startSignIn in redirect mode. */
31 | function testHandleStartSignIn_redirect() {
32 | // Set popup mode to false.
33 | app.setConfig({'popupMode': false});
34 | // Start sign in.
35 | firebaseui.auth.widget.handler.startSignIn(app);
36 | // This should redirect to sign in widget.
37 | testUtil.assertGoTo('http://localhost/firebaseui-widget?mode=select');
38 | }
39 |
40 |
41 | /** Tests startSignIn in popup mode. */
42 | function testHandleSignInButton_popup() {
43 | if (firebaseui.auth.util.isMobileBrowser()) {
44 | // Mobile browsers cannot use popup mode (it is enforced to false by the
45 | // config).
46 | return;
47 | }
48 | // Set popup mode to true.
49 | app.setConfig({'popupMode': true});
50 | // Start sign in.
51 | firebaseui.auth.widget.handler.startSignIn(app);
52 | // This should popup sign in widget.
53 | testUtil.assertPopupWindow('http://localhost/firebaseui-widget?mode=select');
54 | }
55 |
56 |
--------------------------------------------------------------------------------
/javascript/widgets/handler/unsupportedprovider.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Google Inc. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | /**
16 | * @fileoverview Unsupported provider handler.
17 | */
18 |
19 | goog.provide('firebaseui.auth.widget.handler.handleUnsupportedProvider');
20 |
21 | goog.require('firebaseui.auth.ui.page.UnsupportedProvider');
22 | goog.require('firebaseui.auth.widget.Handler');
23 | goog.require('firebaseui.auth.widget.HandlerName');
24 | goog.require('firebaseui.auth.widget.handler');
25 | goog.require('firebaseui.auth.widget.handler.common');
26 |
27 |
28 | /**
29 | * Handles unsupported provider.
30 | *
31 | * @param {!firebaseui.auth.AuthUI} app The current Firebase UI instance whose
32 | * configuration is used.
33 | * @param {!Element} container The container DOM element.
34 | * @param {string} email The email address of the account.
35 | */
36 | firebaseui.auth.widget.handler.handleUnsupportedProvider = function(
37 | app, container, email) {
38 | var component = new firebaseui.auth.ui.page.UnsupportedProvider(
39 | email,
40 | // On recover password button clicked.
41 | function() {
42 | component.dispose();
43 | firebaseui.auth.widget.handler.handle(
44 | firebaseui.auth.widget.HandlerName.PASSWORD_RECOVERY,
45 | app,
46 | container,
47 | email);
48 | },
49 | // On back button click.
50 | function() {
51 | component.dispose();
52 | firebaseui.auth.widget.handler.common.handleSignInStart(
53 | app,
54 | container,
55 | email);
56 | },
57 | app.getConfig().getTosUrl(),
58 | app.getConfig().getPrivacyPolicyUrl());
59 | component.render(container);
60 | // Set current UI component.
61 | app.setCurrentComponent(component);
62 | };
63 |
64 |
65 | // Register handler.
66 | firebaseui.auth.widget.handler.register(
67 | firebaseui.auth.widget.HandlerName.UNSUPPORTED_PROVIDER,
68 | /** @type {!firebaseui.auth.widget.Handler} */
69 | (firebaseui.auth.widget.handler.handleUnsupportedProvider));
70 |
--------------------------------------------------------------------------------
/javascript/widgets/handler/unsupportedprovider_test.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 Google Inc. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | /**
16 | * @fileoverview Test for unsupported provider handler.
17 | */
18 |
19 | goog.provide('firebaseui.auth.widget.handler.UnsupportedProviderTest');
20 | goog.setTestOnly('firebaseui.auth.widget.handler.UnsupportedProviderTest');
21 |
22 | goog.require('firebaseui.auth.widget.handler.handleUnsupportedProvider');
23 | /** @suppress {extraRequire} */
24 | goog.require('firebaseui.auth.widget.handler.testHelper');
25 |
26 |
27 | function testHandleUnsupportedProvider() {
28 | firebaseui.auth.widget.handler.handleUnsupportedProvider(
29 | app, container, 'user@example.com');
30 | assertUnsupportedProviderPage('user@example.com');
31 | // Click recover password button.
32 | submitForm();
33 | // Verify that password revover screen is dispalyed.
34 | assertPasswordRecoveryPage();
35 | submitForm();
36 |
37 | testAuth.assertSendPasswordResetEmail(
38 | [passwordAccount.getEmail()]);
39 | return testAuth.process().then(function() {
40 | assertPasswordRecoveryEmailSentPage();
41 | submitForm();
42 | assertProviderSignInPage();
43 | });
44 | }
45 |
46 |
47 | function testHandleUnsupportedProvider_back() {
48 | firebaseui.auth.widget.handler.handleUnsupportedProvider(
49 | app, container, 'user@example.com');
50 | assertUnsupportedProviderPage('user@example.com');
51 | // Click back button.
52 | clickSecondaryLink();
53 | // Verify that clicking back button goes back to the starting page.
54 | assertProviderSignInPage();
55 | }
56 |
57 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "firebaseui",
3 | "version": "6.1.0",
4 | "description": "Javascript library for customizable UI on top of Firebase SDK",
5 | "files": [
6 | "dist/firebaseui.js",
7 | "dist/firebaseui.css",
8 | "dist/npm.js",
9 | "dist/esm.js",
10 | "dist/index.d.ts",
11 | "dist/externs",
12 | "LICENSE",
13 | "README.md",
14 | "package.json"
15 | ],
16 | "main": "./dist/npm.js",
17 | "module": "./dist/esm.js",
18 | "types": "./dist/index.d.ts",
19 | "style": "dist/firebaseui.css",
20 | "scripts": {
21 | "build": "gulp",
22 | "build-all": "gulp build-all",
23 | "build-soy": "gulp build-soy",
24 | "demo": "npm run build && ./buildtools/run_demo.sh",
25 | "test": "npm run build && npm run generate-test-files && ./buildtools/run_tests.sh",
26 | "serve": "npm run build && npm run generate-test-files && gulp serve",
27 | "generate-test-files": "./buildtools/generate_test_files.sh",
28 | "prepublish": "npm run test && cp -r dist demo/public"
29 | },
30 | "test": "npm run test",
31 | "author": "Google",
32 | "repository": {
33 | "type": "git",
34 | "url": "https://github.com/firebase/firebaseui-web.git"
35 | },
36 | "publishConfig": {
37 | "registry": "https://wombat-dressing-room.appspot.com"
38 | },
39 | "license": "Apache-2.0",
40 | "devDependencies": {
41 | "closure-builder": "^2.3.7",
42 | "firebase": "^10.0.0",
43 | "firebase-tools": "^12.4.4",
44 | "fs-extra": "^3.0.1",
45 | "google-closure-compiler": "^20190415.0.0",
46 | "google-closure-deps": "^20210406.0.0",
47 | "google-closure-library": "^20190415.0.0",
48 | "google-closure-templates": "^20150410.0.0",
49 | "gulp": "^4.0.2",
50 | "gulp-clean-css": "^4.3.0",
51 | "gulp-closure-compiler": "^0.4.0",
52 | "gulp-concat-css": "^3.1.0",
53 | "gulp-connect": "^5.5.0",
54 | "gulp-css-flip": "^0.4.0",
55 | "gulp-css-inline-images": "^0.1.1",
56 | "gulp-sass": "^5.0.0",
57 | "gulp-util": "^3.0.7",
58 | "protractor": "^7.0.0",
59 | "sass": "^1.49.7",
60 | "streamqueue": "^1.1.1",
61 | "chromedriver": "^119.0.1"
62 | },
63 | "dependencies": {
64 | "dialog-polyfill": "^0.4.7",
65 | "material-design-lite": "^1.2.0"
66 | },
67 | "peerDependencies": {
68 | "firebase": "^9.1.3 || ^10.0.0"
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/sauce_browsers.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "browserName" : "firefox",
4 | "platform" : "OS X 10.11",
5 | "version": "59.0",
6 | "name": "firefox-latest-mac"
7 | },
8 | {
9 | "browserName" : "chrome",
10 | "platform" : "OS X 10.11",
11 | "timeZone": "Pacific",
12 | "version" : "65.0",
13 | "name": "chrome-latest-mac"
14 | },
15 | {
16 | "browserName" : "safari",
17 | "version" : "10.0",
18 | "platform" : "OS X 10.11",
19 | "timeZone": "Pacific",
20 | "name": "safari-10-mac"
21 | },
22 | {
23 | "deviceName": "iPhone 6 Simulator",
24 | "platformName": "iOS",
25 | "platformVersion": "11.2",
26 | "browserName": "Safari",
27 | "name": "ios-11-sim"
28 | },
29 | {
30 | "deviceName": "Android Emulator",
31 | "platformName": "Android",
32 | "platformVersion": "6.0",
33 | "browserName": "Chrome",
34 | "name": "android-6-sim"
35 | }
36 | ]
37 |
--------------------------------------------------------------------------------
/soy/viewhelper.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Google Inc. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | /**
16 | * @fileoverview Helpers for Soy viewer.
17 | */
18 |
19 | goog.provide('firebaseui.auth.soy2.viewHelper');
20 | goog.setTestOnly('firebaseui.auth.soy2.viewHelper');
21 |
22 | goog.require('goog.array');
23 | goog.require('goog.dom');
24 | goog.require('goog.dom.classlist');
25 | goog.require('goog.dom.safe');
26 | goog.require('goog.html.TrustedResourceUrl');
27 | goog.require('goog.string.Const');
28 |
29 |
30 | function isViewerMode() {
31 | return typeof thisIsRunningInSoyViewerMode != 'undefined' &&
32 | !!thisIsRunningInSoyViewerMode;
33 | }
34 |
35 |
36 | function isRtlMode() {
37 | return typeof thisIsRunningInRtlMode != 'undefined' &&
38 | !!thisIsRunningInRtlMode;
39 | }
40 |
41 |
42 | function loadCss(path) {
43 | var link = goog.dom.createElement('link');
44 | link.type = 'text/css';
45 | goog.dom.safe.setLinkHrefAndRel(
46 | link,
47 | goog.html.TrustedResourceUrl.fromConstant(goog.string.Const.from(path)),
48 | 'stylesheet');
49 | var head = goog.dom.getElementsByTagNameAndClass('head')[0];
50 | goog.dom.insertChildAt(head, link, 0);
51 | }
52 |
53 |
54 | /**
55 | * Simulates a reCAPTCHA being rendered for UI testing. This will just load a
56 | * mock visible reCAPTCHA in the reCAPTCHA element.
57 | * @param {Element} container The root container that holds the reCAPTCHA.
58 | */
59 | function loadRecaptcha(container) {
60 | var root = goog.dom.getElement(container);
61 | var recaptchaContainer =
62 | goog.dom.getElementByClass('firebaseui-recaptcha-container', root);
63 | recaptchaContainer.style.display = 'block';
64 | var img = goog.dom.createElement('img');
65 | img.src = '../image/test/recaptcha-widget.png';
66 | recaptchaContainer.appendChild(img);
67 | }
68 |
69 |
70 | function setInvalid(root, id) {
71 | var e = goog.dom.getElementByClass(goog.getCssName(id), root);
72 | goog.dom.classlist.addRemove(
73 | e, 'firebaseui-input', 'firebaseui-input-invalid');
74 | }
75 |
76 |
77 | function setError(root, id, message) {
78 | var e = goog.dom.getElementByClass(goog.getCssName(id), root);
79 | goog.dom.setTextContent(e, message);
80 | goog.dom.classlist.remove(e, 'firebaseui-hidden');
81 | }
82 |
83 | function initViewer(file) {
84 | if (isViewerMode()) {
85 | if (isRtlMode()) {
86 | loadCss('../stylesheet/firebase-ui_rtl.css');
87 | } else {
88 | loadCss('../stylesheet/firebase-ui_ltr.css');
89 | }
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/stylesheet/imports.css:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Google Inc. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 | * express or implied. See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | /**
16 | * CSS imports for FirebaseUI Javascript widget.
17 | */
18 |
19 | @import url(https://fonts.googleapis.com/css?family=Roboto:400,500,700&display=swap);
20 |
--------------------------------------------------------------------------------
/stylesheet/mdl.scss:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2016 Google Inc. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | // Bundles together required MDL CSS components.
18 | @import '../node_modules/material-design-lite/src/variables';
19 | @import '../node_modules/material-design-lite/src/mixins';
20 |
21 | @import '../node_modules/material-design-lite/src/button/button';
22 | @import '../node_modules/material-design-lite/src/card/card';
23 | @import '../node_modules/material-design-lite/src/dialog/dialog';
24 | @import '../node_modules/material-design-lite/src/progress/progress';
25 | @import '../node_modules/material-design-lite/src/shadow/shadow';
26 | @import '../node_modules/material-design-lite/src/spinner/spinner';
27 | @import '../node_modules/material-design-lite/src/textfield/textfield';
28 |
--------------------------------------------------------------------------------