@passkeyme/react-auth 2.3.0 → 2.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js
CHANGED
|
@@ -2249,7 +2249,7 @@ const PasskeymeAuthPanel = ({
|
|
|
2249
2249
|
providers = ["google", "github", "apple", "microsoft"], enablePasskeys = true, enableUsernamePassword: _enableUsernamePassword = false, // Reserved for future implementation
|
|
2250
2250
|
redirectUri, state: _state, // Reserved for future implementation
|
|
2251
2251
|
// Layout & behavior
|
|
2252
|
-
layout = "vertical", spacing = "normal", passkeyFirst = true, hideProvidersInitially = false, autoTriggerPasskey = true, detectDeviceCredentials = true,
|
|
2252
|
+
layout = "vertical", spacing = "normal", passkeyFirst = true, hideProvidersInitially = false, autoTriggerPasskey = true, detectDeviceCredentials = true, detectUsingLocalStorage = true, localStorageKey = "passkeyme_initialized",
|
|
2253
2253
|
// Content customization
|
|
2254
2254
|
title = "Sign In", subtitle = "Choose your preferred authentication method", passkeyButtonText = "🔐 Sign in with Passkey", passkeyLoadingText = "⏳ Authenticating...", dividerText = "or continue with", successTitle = "✅ Welcome back!", successSubtitle, logoutButtonText = "Sign Out",
|
|
2255
2255
|
// Visibility controls
|
|
@@ -2280,30 +2280,51 @@ debugMode = false, passkeyOptions = {}, }) => {
|
|
|
2280
2280
|
};
|
|
2281
2281
|
// Detect device credentials silently on mount
|
|
2282
2282
|
React.useEffect(() => {
|
|
2283
|
-
if (!
|
|
2283
|
+
if (!isPasskeySupported())
|
|
2284
2284
|
return;
|
|
2285
2285
|
const detectCredentials = async () => {
|
|
2286
2286
|
var _a;
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
setHasDeviceCredentials(!!credentials);
|
|
2287
|
+
let hasCredentials = false;
|
|
2288
|
+
// Check localStorage if enabled
|
|
2289
|
+
if (detectUsingLocalStorage) {
|
|
2290
|
+
const localStorageValue = localStorage.getItem(localStorageKey);
|
|
2291
|
+
if (localStorageValue === "true" || localStorageValue === "1") {
|
|
2292
|
+
hasCredentials = true;
|
|
2294
2293
|
if (debugMode) {
|
|
2295
|
-
console.log("🔐 PasskeymeAuthPanel:
|
|
2294
|
+
console.log("🔐 PasskeymeAuthPanel: Passkey setup detected in localStorage");
|
|
2296
2295
|
}
|
|
2297
2296
|
}
|
|
2298
2297
|
}
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2298
|
+
// Also check device credentials silently if enabled
|
|
2299
|
+
if (detectDeviceCredentials && !hasCredentials) {
|
|
2300
|
+
try {
|
|
2301
|
+
if (typeof ((_a = navigator.credentials) === null || _a === void 0 ? void 0 : _a.get) === "function") {
|
|
2302
|
+
const credentials = await navigator.credentials.get({
|
|
2303
|
+
mediation: "silent",
|
|
2304
|
+
publicKey: {},
|
|
2305
|
+
});
|
|
2306
|
+
hasCredentials = !!credentials;
|
|
2307
|
+
if (debugMode) {
|
|
2308
|
+
console.log("🔐 PasskeymeAuthPanel: Device credentials detected:", !!credentials);
|
|
2309
|
+
}
|
|
2310
|
+
}
|
|
2311
|
+
}
|
|
2312
|
+
catch (error) {
|
|
2313
|
+
if (debugMode) {
|
|
2314
|
+
console.log("🔐 PasskeymeAuthPanel: Silent credential detection skipped (expected in some contexts)");
|
|
2315
|
+
}
|
|
2302
2316
|
}
|
|
2303
2317
|
}
|
|
2318
|
+
setHasDeviceCredentials(hasCredentials);
|
|
2304
2319
|
};
|
|
2305
2320
|
detectCredentials();
|
|
2306
|
-
}, [
|
|
2321
|
+
}, [
|
|
2322
|
+
detectDeviceCredentials,
|
|
2323
|
+
detectUsingLocalStorage,
|
|
2324
|
+
localStorageKey,
|
|
2325
|
+
isPasskeySupported,
|
|
2326
|
+
debugMode,
|
|
2327
|
+
]);
|
|
2307
2328
|
// Auto-trigger passkey on mount if enabled and device has credentials
|
|
2308
2329
|
React.useEffect(() => {
|
|
2309
2330
|
if (autoTriggerPasskey &&
|
|
@@ -2343,6 +2364,13 @@ debugMode = false, passkeyOptions = {}, }) => {
|
|
|
2343
2364
|
onSuccess: (user, method) => {
|
|
2344
2365
|
if (debugMode)
|
|
2345
2366
|
console.log("✅ PasskeymeAuthPanel: Success via", method, user);
|
|
2367
|
+
// Auto-set localStorage flag when passkey is used
|
|
2368
|
+
if (method === "passkey" && detectUsingLocalStorage) {
|
|
2369
|
+
localStorage.setItem(localStorageKey, "true");
|
|
2370
|
+
if (debugMode) {
|
|
2371
|
+
console.log("💾 PasskeymeAuthPanel: Passkey setup flag saved to localStorage");
|
|
2372
|
+
}
|
|
2373
|
+
}
|
|
2346
2374
|
setShowOAuthOptions(false);
|
|
2347
2375
|
setInternalError(null);
|
|
2348
2376
|
onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(user, method);
|