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