-
Notifications
You must be signed in to change notification settings - Fork 166
LG-11430: hide ft unlock unless has public credential support #9609
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
14 commits
Select commit
Hold shift + click to select a range
6bd5a80
ft unlock support fix
mdiarra3 3ad7bfa
ensure its valid
mdiarra3 b33381e
changelog: User-Facing Improvements, Authentication, Only show F/t Un…
mdiarra3 e7c1a75
fix spec
mdiarra3 fe8ba4a
refactor to make method async
mdiarra3 afb3809
Merge remote-tracking branch 'origin/main' into LG-11430-hide-ft-unlu…
mdiarra3 a37cd4d
fix javascript test
mdiarra3 77b2bf7
fix schema
mdiarra3 b1011d8
add public key credential supported in separate file
mdiarra3 8ae821a
update platform auth available spec
mdiarra3 8322a9e
Fix webauthn setup linting
mdiarra3 4b8147d
make sure to wait for async to pass before confirming test
mdiarra3 f076ca8
add hidden spec fix
mdiarra3 d66a337
fix capitalization
mdiarra3 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
47 changes: 47 additions & 0 deletions
47
app/javascript/packages/webauthn/is-webauthn-platform-authenticator-available.spec.ts
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,47 @@ | ||
| import { useDefineProperty } from '@18f/identity-test-helpers'; | ||
| import isWebauthnPlatformAuthenticatorAvailable from './is-webauthn-platform-authenticator-available'; | ||
|
|
||
| describe('isWebauthnPlatformAuthenticatorAvailable', () => { | ||
| const defineProperty = useDefineProperty(); | ||
|
|
||
| context('browser does not support webauthn', () => { | ||
| beforeEach(() => { | ||
| defineProperty(window, 'PublicKeyCredential', { | ||
| configurable: true, | ||
| value: undefined, | ||
| }); | ||
| }); | ||
|
|
||
| it('resolves to false', async () => { | ||
| await expect(isWebauthnPlatformAuthenticatorAvailable()).to.eventually.equal(false); | ||
| }); | ||
| }); | ||
|
|
||
| context('browser supports webauthn', () => { | ||
| context('device does not have platform authenticator available', () => { | ||
| beforeEach(() => { | ||
| defineProperty(window, 'PublicKeyCredential', { | ||
| configurable: true, | ||
| value: { isUserVerifyingPlatformAuthenticatorAvailable: () => Promise.resolve(false) }, | ||
| }); | ||
| }); | ||
|
|
||
| it('resolves to false', async () => { | ||
| await expect(isWebauthnPlatformAuthenticatorAvailable()).to.eventually.equal(false); | ||
| }); | ||
| }); | ||
|
|
||
| context('device has platform authenticator available', () => { | ||
| beforeEach(() => { | ||
| defineProperty(window, 'PublicKeyCredential', { | ||
| configurable: true, | ||
| value: { isUserVerifyingPlatformAuthenticatorAvailable: () => Promise.resolve(true) }, | ||
| }); | ||
| }); | ||
|
|
||
| it('resolves to false', async () => { | ||
| await expect(isWebauthnPlatformAuthenticatorAvailable()).to.eventually.equal(true); | ||
| }); | ||
| }); | ||
| }); | ||
| }); |
6 changes: 6 additions & 0 deletions
6
app/javascript/packages/webauthn/is-webauthn-platform-authenticator-available.ts
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,6 @@ | ||
| export type IsWebauthnPlatformAvailable = () => Promise<boolean>; | ||
|
|
||
| const isWebauthnPlatformAuthenticatorAvailable: IsWebauthnPlatformAvailable = async () => | ||
| !!(await window.PublicKeyCredential?.isUserVerifyingPlatformAuthenticatorAvailable()); | ||
|
|
||
| export default isWebauthnPlatformAuthenticatorAvailable; |
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
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oof, I'd forgot about needing this. I think it makes sense, though I'd be a little concerned about future maintainability if the connected callback has some side effects that might be doubled-up by calling it explicitly like this.
In the past I'd wondered if we could use the Chrome DevTools protocol support for WebAuthn to add a "virtual" authenticator, but it was experimental and I had a hard time getting it working. Might be something to reconsider in the future.