@passkeyme/auth 2.0.12 → 2.0.13
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.esm.js +34 -11
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +34 -11
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +34 -11
- package/dist/index.umd.js.map +1 -1
- package/dist/src/passkeyme-auth.d.ts +5 -1
- package/dist/src/passkeyme-auth.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.umd.js
CHANGED
|
@@ -1054,6 +1054,25 @@
|
|
|
1054
1054
|
});
|
|
1055
1055
|
}
|
|
1056
1056
|
}
|
|
1057
|
+
/**
|
|
1058
|
+
* Internal helper: Redirect to login in hosted mode, or throw error in direct mode
|
|
1059
|
+
*/
|
|
1060
|
+
redirectOrThrow(userMessage, technicalMessage) {
|
|
1061
|
+
if (this.config.mode === "hosted") {
|
|
1062
|
+
this.redirectToLogin();
|
|
1063
|
+
return { method: "redirect" };
|
|
1064
|
+
}
|
|
1065
|
+
else {
|
|
1066
|
+
throw new PasskeymeError({
|
|
1067
|
+
code: exports.PasskeymeErrorCode.PASSKEY_NOT_SUPPORTED,
|
|
1068
|
+
message: technicalMessage,
|
|
1069
|
+
userMessage: userMessage,
|
|
1070
|
+
recoverable: true,
|
|
1071
|
+
retryable: false,
|
|
1072
|
+
suggestedAction: "Use OAuth sign-in instead",
|
|
1073
|
+
});
|
|
1074
|
+
}
|
|
1075
|
+
}
|
|
1057
1076
|
/**
|
|
1058
1077
|
* Handle authentication callback from hosted auth page
|
|
1059
1078
|
*/
|
|
@@ -1520,7 +1539,7 @@
|
|
|
1520
1539
|
* 1. Check app config for discoverable credentials support
|
|
1521
1540
|
* 2. If supported: attempt discoverable credentials first (no username)
|
|
1522
1541
|
* 3. If not supported or fails: use stored username or prompt for username
|
|
1523
|
-
* 4. Fallback to hosted auth if all passkey attempts fail
|
|
1542
|
+
* 4. Fallback to hosted auth if all passkey attempts fail (unless mode is 'direct')
|
|
1524
1543
|
*/
|
|
1525
1544
|
async smartLogin(username, apiKey) {
|
|
1526
1545
|
logger.debug("[DEBUG] smartLogin called with:", {
|
|
@@ -1535,8 +1554,9 @@
|
|
|
1535
1554
|
logger.debug("[DEBUG] Passkey support check:", isSupported);
|
|
1536
1555
|
if (!isSupported || !effectiveApiKey) {
|
|
1537
1556
|
logger.debug("Conditions not met, redirecting to hosted auth. isSupported:", isSupported, "hasApiKey:", !!effectiveApiKey);
|
|
1538
|
-
this.
|
|
1539
|
-
|
|
1557
|
+
return this.redirectOrThrow(isSupported
|
|
1558
|
+
? "API key is required for passkey authentication."
|
|
1559
|
+
: "Your device doesn't support passkeys.", "Passkey authentication not available");
|
|
1540
1560
|
}
|
|
1541
1561
|
try {
|
|
1542
1562
|
// Get app configuration to check discoverable credentials support
|
|
@@ -1559,8 +1579,7 @@
|
|
|
1559
1579
|
// If passkeys are disabled at the app level, fallback to hosted auth
|
|
1560
1580
|
if (!appConfig.passkeyEnabled) {
|
|
1561
1581
|
logger.debug("Passkeys disabled for this app, falling back to hosted auth");
|
|
1562
|
-
this.
|
|
1563
|
-
return { method: "redirect" };
|
|
1582
|
+
return this.redirectOrThrow("Passkey authentication is not available for this app.", "Passkeys are disabled for this application");
|
|
1564
1583
|
}
|
|
1565
1584
|
let authUsername = username;
|
|
1566
1585
|
// Smart username resolution following industry best practices
|
|
@@ -1582,15 +1601,13 @@
|
|
|
1582
1601
|
const storageKey = `last_username_${this.config.appId}`;
|
|
1583
1602
|
logger.debug("Looking for stored username with key:", storageKey);
|
|
1584
1603
|
const storedUsername = await this.storage.getItem(storageKey);
|
|
1585
|
-
logger.debug("Found stored username:", storedUsername);
|
|
1586
1604
|
if (storedUsername) {
|
|
1587
1605
|
logger.debug("Using stored username for targeted authentication:", storedUsername);
|
|
1588
1606
|
authUsername = storedUsername;
|
|
1589
1607
|
}
|
|
1590
1608
|
else {
|
|
1591
1609
|
logger.debug("No username available and discoverable auth failed/unsupported, falling back to hosted auth");
|
|
1592
|
-
this.
|
|
1593
|
-
return { method: "redirect" };
|
|
1610
|
+
return this.redirectOrThrow("Unable to authenticate with passkey. Please sign in with another method.", "No username available for passkey authentication");
|
|
1594
1611
|
}
|
|
1595
1612
|
}
|
|
1596
1613
|
// Attempt passkey authentication with username
|
|
@@ -1609,9 +1626,15 @@
|
|
|
1609
1626
|
if (this.config.debug) {
|
|
1610
1627
|
logger.error("[PasskeymeAuth] Passkey authentication error details:", error);
|
|
1611
1628
|
}
|
|
1612
|
-
// Fallback to hosted auth for any passkey failures
|
|
1613
|
-
|
|
1614
|
-
|
|
1629
|
+
// Fallback to hosted auth for any passkey failures (unless mode is 'direct')
|
|
1630
|
+
// In direct mode, re-throw the original error for the caller to handle
|
|
1631
|
+
if (this.config.mode === "hosted") {
|
|
1632
|
+
this.redirectToLogin();
|
|
1633
|
+
return { method: "redirect" };
|
|
1634
|
+
}
|
|
1635
|
+
else {
|
|
1636
|
+
throw error;
|
|
1637
|
+
}
|
|
1615
1638
|
}
|
|
1616
1639
|
}
|
|
1617
1640
|
/**
|