From 6e39870e2e059aa60062da38afd3d4dd2f593d88 Mon Sep 17 00:00:00 2001 From: merlindru Date: Thu, 7 Dec 2023 11:47:04 +0100 Subject: [PATCH] packages/js: next-auth-provider 0.2.0 --- .../js/passkeys-next-auth-provider/client.ts | 16 +++++++++++++++- .../dist/package.json | 2 +- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/packages/js/passkeys-next-auth-provider/client.ts b/packages/js/passkeys-next-auth-provider/client.ts index 48058ec..c2724f4 100644 --- a/packages/js/passkeys-next-auth-provider/client.ts +++ b/packages/js/passkeys-next-auth-provider/client.ts @@ -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", @@ -88,3 +98,7 @@ export async function clientFirstPasskeyLogin(config: ClientFirstLoginConfig): P return data.token; }); } + +function isConditionalMediationAvailable() { + return typeof window !== "undefined" && window.PublicKeyCredential?.isConditionalMediationAvailable?.(); +} diff --git a/packages/js/passkeys-next-auth-provider/dist/package.json b/packages/js/passkeys-next-auth-provider/dist/package.json index 5018f5a..aae7ea3 100644 --- a/packages/js/passkeys-next-auth-provider/dist/package.json +++ b/packages/js/passkeys-next-auth-provider/dist/package.json @@ -3,7 +3,7 @@ "license": "MIT", "private": false, "type": "module", - "version": "0.1.11", + "version": "0.2.0", "exports": { ".": "./index.js", "./client": "./client.js"