@passkeyme/auth 1.1.2 → 1.1.4

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 CHANGED
@@ -11,6 +11,19 @@ class Logger {
11
11
  ...config,
12
12
  };
13
13
  }
14
+ /**
15
+ * Update logger configuration
16
+ */
17
+ setConfig(config) {
18
+ this.config = { ...this.config, ...config };
19
+ }
20
+ /**
21
+ * Enable debug logging
22
+ */
23
+ enableDebug() {
24
+ this.config.enabled = true;
25
+ this.config.level = "debug";
26
+ }
14
27
  shouldLog(level) {
15
28
  if (!this.config.enabled)
16
29
  return false;
@@ -815,7 +828,14 @@ class PasskeymeAuth {
815
828
  this.tokenStorage = new TokenStorage(storage);
816
829
  // Use provided passkey SDK or create default one
817
830
  this.passkeySDK = config.passkeySDK || this.createDefaultPasskeySDK();
831
+ // Configure logger with debug setting from config
832
+ if (this.config.debug) {
833
+ logger.enableDebug();
834
+ console.log("[DEBUG] Logger debug mode enabled, testing logger...");
835
+ logger.debug("Logger test message - if you see this, logger is working");
836
+ }
818
837
  logger.debug("Initialized with config:", this.config);
838
+ console.log("[DEBUG] Constructor completed, config.debug:", this.config.debug);
819
839
  }
820
840
  /**
821
841
  * Create default passkey SDK based on environment
@@ -1463,27 +1483,45 @@ class PasskeymeAuth {
1463
1483
  * 4. Fallback to hosted auth if all passkey attempts fail
1464
1484
  */
1465
1485
  async smartLogin(username, apiKey) {
1486
+ console.log("[DEBUG] smartLogin called with:", {
1487
+ username,
1488
+ hasApiKey: !!apiKey,
1489
+ });
1466
1490
  logger.debug("smartLogin called with:", {
1467
1491
  username,
1468
1492
  hasApiKey: !!apiKey,
1469
1493
  });
1470
1494
  // Use provided API key or fall back to config
1471
1495
  const effectiveApiKey = apiKey || this.getPasskeyApiKey();
1496
+ console.log("[DEBUG] effectiveApiKey:", !!effectiveApiKey);
1472
1497
  // Check if passkeys are supported and we have an API key
1473
1498
  const isSupported = this.isPasskeySupported();
1499
+ console.log("[DEBUG] Passkey support check:", isSupported);
1474
1500
  logger.debug("Passkey support check:", isSupported);
1475
1501
  if (!isSupported || !effectiveApiKey) {
1502
+ console.log("[DEBUG] Conditions not met, redirecting to hosted auth. isSupported:", isSupported, "hasApiKey:", !!effectiveApiKey);
1476
1503
  logger.debug("Conditions not met, redirecting to hosted auth. isSupported:", isSupported, "hasApiKey:", !!effectiveApiKey);
1477
1504
  this.redirectToLogin();
1478
1505
  return { method: "redirect" };
1479
1506
  }
1480
1507
  try {
1481
1508
  // Get app configuration to check discoverable credentials support
1482
- const appConfig = await this.getAppConfig();
1483
- logger.debug("App config loaded:", {
1484
- discoverableCredentialsEnabled: appConfig.discoverableCredentialsEnabled,
1485
- passkeyEnabled: appConfig.passkeyEnabled,
1486
- });
1509
+ let appConfig;
1510
+ try {
1511
+ appConfig = await this.getAppConfig();
1512
+ logger.debug("App config loaded:", {
1513
+ discoverableCredentialsEnabled: appConfig.discoverableCredentialsEnabled,
1514
+ passkeyEnabled: appConfig.passkeyEnabled,
1515
+ });
1516
+ }
1517
+ catch (configError) {
1518
+ logger.debug("Failed to load app config, assuming passkeys enabled:", configError);
1519
+ // If we can't load config, assume passkeys are enabled and no discoverable credentials
1520
+ appConfig = {
1521
+ passkeyEnabled: true,
1522
+ discoverableCredentialsEnabled: false,
1523
+ };
1524
+ }
1487
1525
  // If passkeys are disabled at the app level, fallback to hosted auth
1488
1526
  if (!appConfig.passkeyEnabled) {
1489
1527
  logger.debug("Passkeys disabled for this app, falling back to hosted auth");
@@ -1507,7 +1545,10 @@ class PasskeymeAuth {
1507
1545
  }
1508
1546
  }
1509
1547
  // Try to get stored username for fallback
1510
- const storedUsername = await this.storage.getItem(`last_username_${this.config.appId}`);
1548
+ const storageKey = `last_username_${this.config.appId}`;
1549
+ logger.debug("Looking for stored username with key:", storageKey);
1550
+ const storedUsername = await this.storage.getItem(storageKey);
1551
+ logger.debug("Found stored username:", storedUsername);
1511
1552
  if (storedUsername) {
1512
1553
  logger.debug("Using stored username for targeted authentication:", storedUsername);
1513
1554
  authUsername = storedUsername;