@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.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,6 +828,10 @@ 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
+ }
818
835
  logger.debug("Initialized with config:", this.config);
819
836
  }
820
837
  /**
@@ -1479,11 +1496,22 @@ class PasskeymeAuth {
1479
1496
  }
1480
1497
  try {
1481
1498
  // 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
- });
1499
+ let appConfig;
1500
+ try {
1501
+ appConfig = await this.getAppConfig();
1502
+ logger.debug("App config loaded:", {
1503
+ discoverableCredentialsEnabled: appConfig.discoverableCredentialsEnabled,
1504
+ passkeyEnabled: appConfig.passkeyEnabled,
1505
+ });
1506
+ }
1507
+ catch (configError) {
1508
+ logger.debug("Failed to load app config, assuming passkeys enabled:", configError);
1509
+ // If we can't load config, assume passkeys are enabled and no discoverable credentials
1510
+ appConfig = {
1511
+ passkeyEnabled: true,
1512
+ discoverableCredentialsEnabled: false,
1513
+ };
1514
+ }
1487
1515
  // If passkeys are disabled at the app level, fallback to hosted auth
1488
1516
  if (!appConfig.passkeyEnabled) {
1489
1517
  logger.debug("Passkeys disabled for this app, falling back to hosted auth");
@@ -1507,7 +1535,10 @@ class PasskeymeAuth {
1507
1535
  }
1508
1536
  }
1509
1537
  // Try to get stored username for fallback
1510
- const storedUsername = await this.storage.getItem(`last_username_${this.config.appId}`);
1538
+ const storageKey = `last_username_${this.config.appId}`;
1539
+ logger.debug("Looking for stored username with key:", storageKey);
1540
+ const storedUsername = await this.storage.getItem(storageKey);
1541
+ logger.debug("Found stored username:", storedUsername);
1511
1542
  if (storedUsername) {
1512
1543
  logger.debug("Using stored username for targeted authentication:", storedUsername);
1513
1544
  authUsername = storedUsername;