Skip to content

Commit

Permalink
packages/js: next-auth-provider 0.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
merlindru committed Dec 7, 2023
1 parent f489512 commit 6e39870
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
16 changes: 15 additions & 1 deletion packages/js/passkeys-next-auth-provider/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,17 @@ export async function signInWithPasskey(config: SignInConfig) {
});
}

signInWithPasskey.autofill = async function (config: SignInConfig, signal?: AbortSignal) {
let warnedConditionalNotAvailable = false;

signInWithPasskey.conditional = async function (config: SignInConfig, signal?: AbortSignal) {
if (!isConditionalMediationAvailable()) {
if (!warnedConditionalNotAvailable) {
console.error("Conditional mediation is not available on this device.");
warnedConditionalNotAvailable = true;
}
return;
}

return signInWithPasskey({
...config,
mediation: "conditional",
Expand Down Expand Up @@ -88,3 +98,7 @@ export async function clientFirstPasskeyLogin(config: ClientFirstLoginConfig): P
return data.token;
});
}

function isConditionalMediationAvailable() {
return typeof window !== "undefined" && window.PublicKeyCredential?.isConditionalMediationAvailable?.();
}
2 changes: 1 addition & 1 deletion packages/js/passkeys-next-auth-provider/dist/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"license": "MIT",
"private": false,
"type": "module",
"version": "0.1.11",
"version": "0.2.0",
"exports": {
".": "./index.js",
"./client": "./client.js"
Expand Down

0 comments on commit 6e39870

Please sign in to comment.