-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
[js] Add Federated Credential Management support #15008
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
6a5bd64
[js] Add commands
pujagani 374092b
[js] Add test skeleton
pujagani 4f0fbf3
[js] Add tests and update test setup
pujagani 8718f6c
Fix formatting
pujagani 1e4f440
[js] Add Edge for tests
pujagani d0ce11a
[js] Remove redundant commands
pujagani cd9cc71
Fix build
pujagani 662e81a
Fix imports
pujagani 1e6c0a2
Fix build
pujagani 3495fa0
Fix import
pujagani File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| <!DOCTYPE html> | ||
| <html> | ||
| <head> | ||
| <title>FedCM Example</title> | ||
| </head> | ||
| <body> | ||
| <button id="triggerButton" onclick="triggerFedCm()">Trigger FedCM</button> | ||
| <div id="result"></div> | ||
|
|
||
| <script> | ||
| // Use a relative path for the configURL | ||
| let configURL = `http://${location.host}/common/fedcm/config.json`; | ||
| console.log(configURL) | ||
| let result = null; | ||
|
|
||
| async function triggerFedCm() { | ||
| console.log("Config URL:", configURL); | ||
| try { | ||
| let promise = await navigator.credentials.get({ | ||
| identity: { | ||
| providers: [{ | ||
| configURL: configURL, | ||
| clientId: '1', | ||
| }] | ||
| } | ||
| }); | ||
| result = promise; | ||
|
|
||
| console.log("Promised!") | ||
| console.log(result) | ||
| document.getElementById('result').innerText = JSON.stringify(result); | ||
| } catch (error) { | ||
| console.error("FedCM Error:", error); | ||
| result = { error: error.message }; | ||
| document.getElementById('result').innerText = JSON.stringify(result); | ||
| } | ||
| } | ||
| </script> | ||
| </body> | ||
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| // Licensed to the Software Freedom Conservancy (SFC) under one | ||
| // or more contributor license agreements. See the NOTICE file | ||
| // distributed with this work for additional information | ||
| // regarding copyright ownership. The SFC licenses this file | ||
| // to you under the Apache License, Version 2.0 (the | ||
| // "License"); you may not use this file except in compliance | ||
| // with the License. You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, | ||
| // software distributed under the License is distributed on an | ||
| // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| // KIND, either express or implied. See the License for the | ||
| // specific language governing permissions and limitations | ||
| // under the License. | ||
|
|
||
| class Account { | ||
| constructor( | ||
| accountId, | ||
| email, | ||
| name, | ||
| givenName, | ||
| pictureUrl, | ||
| idpConfigUrl, | ||
| loginState, | ||
| termsOfServiceUrl, | ||
| privacyPolicyUrl, | ||
| ) { | ||
| this._accountId = accountId | ||
| this._email = email | ||
| this._name = name | ||
| this._givenName = givenName | ||
| this._pictureUrl = pictureUrl | ||
| this._idpConfigUrl = idpConfigUrl | ||
| this._loginState = loginState | ||
| this._termsOfServiceUrl = termsOfServiceUrl | ||
| this._privacyPolicyUrl = privacyPolicyUrl | ||
| } | ||
|
|
||
| get accountId() { | ||
| return this._accountId | ||
| } | ||
|
|
||
| get email() { | ||
| return this._email | ||
| } | ||
|
|
||
| get name() { | ||
| return this._name | ||
| } | ||
|
|
||
| get givenName() { | ||
| return this._givenName | ||
| } | ||
|
|
||
| get pictureUrl() { | ||
| return this._pictureUrl | ||
| } | ||
|
|
||
| get idpConfigUrl() { | ||
| return this._idpConfigUrl | ||
| } | ||
|
|
||
| get loginState() { | ||
| return this._loginState | ||
| } | ||
|
|
||
| get termsOfServiceUrl() { | ||
| return this._termsOfServiceUrl | ||
| } | ||
|
|
||
| get privacyPolicyUrl() { | ||
| return this._privacyPolicyUrl | ||
| } | ||
| } | ||
|
|
||
| module.exports = Account |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| // Licensed to the Software Freedom Conservancy (SFC) under one | ||
| // or more contributor license agreements. See the NOTICE file | ||
| // distributed with this work for additional information | ||
| // regarding copyright ownership. The SFC licenses this file | ||
| // to you under the Apache License, Version 2.0 (the | ||
| // "License"); you may not use this file except in compliance | ||
| // with the License. You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, | ||
| // software distributed under the License is distributed on an | ||
| // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| // KIND, either express or implied. See the License for the | ||
| // specific language governing permissions and limitations | ||
| // under the License. | ||
|
|
||
| const command = require('../command') | ||
| const Account = require('./account') | ||
|
|
||
| class Dialog { | ||
| constructor(driver) { | ||
| this._driver = driver | ||
| } | ||
|
|
||
| async title() { | ||
| const result = await this._driver.execute(new command.Command(command.Name.GET_FEDCM_TITLE)) | ||
|
|
||
| return result.title | ||
| } | ||
|
|
||
| subtitle() { | ||
| return this._driver.execute(new command.Command(command.Name.GET_FEDCM_TITLE)) | ||
| } | ||
|
|
||
| type() { | ||
| return this._driver.execute(new command.Command(command.Name.GET_FEDCM_DIALOG_TYPE)) | ||
| } | ||
|
|
||
| async accounts() { | ||
| const result = await this._driver.execute(new command.Command(command.Name.GET_ACCOUNTS)) | ||
|
|
||
| const accountArray = [] | ||
|
|
||
| result.forEach((account) => { | ||
| const acc = new Account( | ||
| account.accountId, | ||
| account.email, | ||
| account.name, | ||
| account.givenName, | ||
| account.pictureUrl, | ||
| account.idpConfigUrl, | ||
| account.loginState, | ||
| account.termsOfServiceUrl, | ||
| account.privacyPolicyUrl, | ||
| ) | ||
| accountArray.push(acc) | ||
| }) | ||
|
|
||
| return accountArray | ||
| } | ||
|
|
||
| selectAccount(index) { | ||
| return this._driver.execute(new command.Command(command.Name.SELECT_ACCOUNT).setParameter('accountIndex', index)) | ||
| } | ||
|
|
||
| accept() { | ||
| return this._driver.execute(new command.Command(command.Name.CLICK_DIALOG_BUTTON)) | ||
| } | ||
|
|
||
| dismiss() { | ||
| return this._driver.execute(new command.Command(command.Name.CANCEL_DIALOG)) | ||
| } | ||
| } | ||
|
|
||
| module.exports = Dialog |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.