@passkeyme/auth 1.1.2 → 1.1.3

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,6 +832,10 @@ 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
+ }
822
839
  logger.debug("Initialized with config:", this.config);
823
840
  }
824
841
  /**
@@ -1483,11 +1500,22 @@ class PasskeymeAuth {
1483
1500
  }
1484
1501
  try {
1485
1502
  // 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
- });
1503
+ let appConfig;
1504
+ try {
1505
+ appConfig = await this.getAppConfig();
1506
+ logger.debug("App config loaded:", {
1507
+ discoverableCredentialsEnabled: appConfig.discoverableCredentialsEnabled,
1508
+ passkeyEnabled: appConfig.passkeyEnabled,
1509
+ });
1510
+ }
1511
+ catch (configError) {
1512
+ logger.debug("Failed to load app config, assuming passkeys enabled:", configError);
1513
+ // If we can't load config, assume passkeys are enabled and no discoverable credentials
1514
+ appConfig = {
1515
+ passkeyEnabled: true,
1516
+ discoverableCredentialsEnabled: false,
1517
+ };
1518
+ }
1491
1519
  // If passkeys are disabled at the app level, fallback to hosted auth
1492
1520
  if (!appConfig.passkeyEnabled) {
1493
1521
  logger.debug("Passkeys disabled for this app, falling back to hosted auth");
@@ -1511,7 +1539,10 @@ class PasskeymeAuth {
1511
1539
  }
1512
1540
  }
1513
1541
  // Try to get stored username for fallback
1514
- const storedUsername = await this.storage.getItem(`last_username_${this.config.appId}`);
1542
+ const storageKey = `last_username_${this.config.appId}`;
1543
+ logger.debug("Looking for stored username with key:", storageKey);
1544
+ const storedUsername = await this.storage.getItem(storageKey);
1545
+ logger.debug("Found stored username:", storedUsername);
1515
1546
  if (storedUsername) {
1516
1547
  logger.debug("Using stored username for targeted authentication:", storedUsername);
1517
1548
  authUsername = storedUsername;