-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added checkConditionalUIAvailable on authentication_hook to enable passkey autofill * Remove debug code and added autocomplete="username webauthn" on aunthentication_live.html.heex * Added abort signal on registration hook to prevent error "A request is already pending" when sign up * Workaround to fix Conditional UI on iOS/Safari when user cancel the action * bump minor version to 0.7.0 --------- Co-authored-by: Owen Bickford <owen@owencode.com>
- Loading branch information
Showing
8 changed files
with
105 additions
and
7 deletions.
There are no files selected for viewing
This file contains 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 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 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 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,42 @@ | ||
class BaseAbortControllerService { | ||
/** | ||
* Prepare an abort signal that will help support multiple auth attempts without needing to | ||
* reload the page. | ||
*/ | ||
createNewAbortSignal() { | ||
// Abort any existing calls to navigator.credentials.create() or navigator.credentials.get() | ||
if (this.controller) { | ||
const abortError = new Error( | ||
"Cancelling existing WebAuthn API call for new one" | ||
); | ||
abortError.name = "AbortError"; | ||
this.controller.abort(abortError); | ||
} | ||
|
||
const newController = new AbortController(); | ||
|
||
this.controller = newController; | ||
return newController.signal; | ||
} | ||
|
||
/** | ||
* Manually cancel any active WebAuthn registration or authentication attempt. | ||
*/ | ||
cancelCeremony() { | ||
if (this.controller) { | ||
const abortError = new Error( | ||
"Manually cancelling existing WebAuthn API call" | ||
); | ||
abortError.name = "AbortError"; | ||
this.controller.abort(abortError); | ||
|
||
this.controller = undefined; | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* A service singleton to help ensure that only a single navigator.crendetials ceremony is active at a time. | ||
* | ||
*/ | ||
export const AbortControllerService = new BaseAbortControllerService(); |
This file contains 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 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,9 @@ | ||
export function browserSupportsPasskeyAutofill() { | ||
const globalPublicKeyCredential = window.PublicKeyCredential; | ||
|
||
if (globalPublicKeyCredential.isConditionalMediationAvailable === undefined) { | ||
return Promise.resolve(false); | ||
} | ||
|
||
return globalPublicKeyCredential.isConditionalMediationAvailable(); | ||
} |
This file contains 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 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