@passkeyme/auth 1.1.1 → 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 +49 -165
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +49 -166
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +49 -166
- package/dist/index.umd.js.map +1 -1
- package/dist/src/passkeyme-auth.d.ts.map +1 -1
- package/dist/src/platform/index.d.ts +2 -1
- package/dist/src/platform/index.d.ts.map +1 -1
- package/dist/src/utils/logger.d.ts +8 -0
- package/dist/src/utils/logger.d.ts.map +1 -1
- package/package.json +1 -1
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;
|
|
@@ -767,168 +780,21 @@ class WebPasskeySDK {
|
|
|
767
780
|
}
|
|
768
781
|
|
|
769
782
|
/**
|
|
770
|
-
*
|
|
771
|
-
*
|
|
772
|
-
* Bridges to native iOS (CocoaPods) and Android (Gradle) SDKs
|
|
773
|
-
*/
|
|
774
|
-
/**
|
|
775
|
-
* React Native implementation of PasskeySDK
|
|
776
|
-
*
|
|
777
|
-
* This implementation bridges to native iOS and Android SDKs:
|
|
778
|
-
* - iOS: https://cocoapods.org/pods/PasskeymeSDK
|
|
779
|
-
* - Android: https://maven.pkg.github.com/justincrosbie/passkeyme-android-sdk
|
|
783
|
+
* Platform SDK exports
|
|
780
784
|
*/
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
catch (error) {
|
|
789
|
-
console.warn("React Native environment not detected or PasskeymeNativeModule not available");
|
|
790
|
-
this.nativeModule = null;
|
|
791
|
-
}
|
|
792
|
-
}
|
|
793
|
-
async register(options) {
|
|
794
|
-
try {
|
|
795
|
-
if (!this.nativeModule) {
|
|
796
|
-
return {
|
|
797
|
-
success: false,
|
|
798
|
-
error: "Native module not available",
|
|
799
|
-
};
|
|
800
|
-
}
|
|
801
|
-
// Call the native module register method
|
|
802
|
-
const result = await this.nativeModule.register({
|
|
803
|
-
...options,
|
|
804
|
-
requireUserVerification: options.requireUserVerification || false,
|
|
805
|
-
});
|
|
806
|
-
return {
|
|
807
|
-
success: result.success,
|
|
808
|
-
credentialId: result.credentialId,
|
|
809
|
-
error: result.error,
|
|
810
|
-
data: result,
|
|
811
|
-
};
|
|
812
|
-
}
|
|
813
|
-
catch (error) {
|
|
814
|
-
return {
|
|
815
|
-
success: false,
|
|
816
|
-
error: error.message || "Registration failed",
|
|
817
|
-
};
|
|
818
|
-
}
|
|
819
|
-
}
|
|
820
|
-
async authenticate(options) {
|
|
821
|
-
try {
|
|
822
|
-
if (!this.nativeModule) {
|
|
823
|
-
return {
|
|
824
|
-
success: false,
|
|
825
|
-
error: "Native module not available",
|
|
826
|
-
};
|
|
827
|
-
}
|
|
828
|
-
// Call the native module authenticate method
|
|
829
|
-
const result = await this.nativeModule.authenticate({
|
|
830
|
-
...options,
|
|
831
|
-
requireUserVerification: options.requireUserVerification || false,
|
|
832
|
-
});
|
|
833
|
-
return {
|
|
834
|
-
success: result.success,
|
|
835
|
-
assertion: result.assertion,
|
|
836
|
-
error: result.error,
|
|
837
|
-
data: result,
|
|
838
|
-
};
|
|
839
|
-
}
|
|
840
|
-
catch (error) {
|
|
841
|
-
return {
|
|
842
|
-
success: false,
|
|
843
|
-
error: error.message || "Authentication failed",
|
|
844
|
-
};
|
|
845
|
-
}
|
|
846
|
-
}
|
|
847
|
-
isSupported() {
|
|
848
|
-
return this.nativeModule != null;
|
|
849
|
-
}
|
|
850
|
-
async getAvailableAuthenticators() {
|
|
851
|
-
try {
|
|
852
|
-
if (!this.nativeModule) {
|
|
853
|
-
return [];
|
|
854
|
-
}
|
|
855
|
-
// Call native method to get available authenticators
|
|
856
|
-
const authenticators = await this.nativeModule.getAvailableAuthenticators();
|
|
857
|
-
return authenticators || [];
|
|
858
|
-
}
|
|
859
|
-
catch (error) {
|
|
860
|
-
console.warn("Failed to get available authenticators:", error);
|
|
861
|
-
return [];
|
|
862
|
-
}
|
|
863
|
-
}
|
|
864
|
-
canUseDiscoverableCredentials() {
|
|
865
|
-
// Most modern mobile devices support discoverable credentials
|
|
866
|
-
return this.isSupported();
|
|
867
|
-
}
|
|
868
|
-
supportsBiometrics() {
|
|
869
|
-
// Mobile devices typically support biometric authentication
|
|
870
|
-
return this.isSupported();
|
|
871
|
-
}
|
|
872
|
-
async initialize(config) {
|
|
873
|
-
if (this.nativeModule &&
|
|
874
|
-
typeof this.nativeModule.initialize === "function") {
|
|
875
|
-
await this.nativeModule.initialize(config);
|
|
876
|
-
}
|
|
877
|
-
}
|
|
878
|
-
async cleanup() {
|
|
879
|
-
if (this.nativeModule && typeof this.nativeModule.cleanup === "function") {
|
|
880
|
-
await this.nativeModule.cleanup();
|
|
881
|
-
}
|
|
882
|
-
}
|
|
883
|
-
/**
|
|
884
|
-
* Check if the device supports Face ID (iOS) or Face Unlock (Android)
|
|
885
|
-
*/
|
|
886
|
-
async supportsFaceRecognition() {
|
|
887
|
-
try {
|
|
888
|
-
if (!this.nativeModule)
|
|
889
|
-
return false;
|
|
890
|
-
return await this.nativeModule.supportsFaceRecognition();
|
|
891
|
-
}
|
|
892
|
-
catch (_a) {
|
|
893
|
-
return false;
|
|
894
|
-
}
|
|
895
|
-
}
|
|
896
|
-
/**
|
|
897
|
-
* Check if the device supports Touch ID (iOS) or Fingerprint (Android)
|
|
898
|
-
*/
|
|
899
|
-
async supportsFingerprint() {
|
|
900
|
-
try {
|
|
901
|
-
if (!this.nativeModule)
|
|
902
|
-
return false;
|
|
903
|
-
return await this.nativeModule.supportsFingerprint();
|
|
904
|
-
}
|
|
905
|
-
catch (_a) {
|
|
906
|
-
return false;
|
|
907
|
-
}
|
|
908
|
-
}
|
|
909
|
-
/**
|
|
910
|
-
* Get detailed biometric capabilities
|
|
911
|
-
*/
|
|
912
|
-
async getBiometricCapabilities() {
|
|
913
|
-
try {
|
|
914
|
-
if (!this.nativeModule) {
|
|
915
|
-
return {
|
|
916
|
-
faceRecognition: false,
|
|
917
|
-
fingerprint: false,
|
|
918
|
-
voiceRecognition: false,
|
|
919
|
-
};
|
|
920
|
-
}
|
|
921
|
-
return await this.nativeModule.getBiometricCapabilities();
|
|
922
|
-
}
|
|
923
|
-
catch (_a) {
|
|
924
|
-
return {
|
|
925
|
-
faceRecognition: false,
|
|
926
|
-
fingerprint: false,
|
|
927
|
-
voiceRecognition: false,
|
|
928
|
-
};
|
|
929
|
-
}
|
|
785
|
+
// Conditionally export React Native SDK only in React Native environments
|
|
786
|
+
exports.ReactNativePasskeySDK = null;
|
|
787
|
+
try {
|
|
788
|
+
// Only try to load React Native SDK if we're actually in a React Native environment
|
|
789
|
+
if (typeof navigator !== "undefined" && navigator.product === "ReactNative") {
|
|
790
|
+
const { ReactNativePasskeySDK: RNPasskeySDK, } = require("./ReactNativePasskeySDK");
|
|
791
|
+
exports.ReactNativePasskeySDK = RNPasskeySDK;
|
|
930
792
|
}
|
|
931
793
|
}
|
|
794
|
+
catch (error) {
|
|
795
|
+
// React Native SDK not available or not in React Native environment
|
|
796
|
+
exports.ReactNativePasskeySDK = null;
|
|
797
|
+
}
|
|
932
798
|
|
|
933
799
|
/**
|
|
934
800
|
* Main PasskeyMe Authentication SDK class
|
|
@@ -966,6 +832,10 @@ class PasskeymeAuth {
|
|
|
966
832
|
this.tokenStorage = new TokenStorage(storage);
|
|
967
833
|
// Use provided passkey SDK or create default one
|
|
968
834
|
this.passkeySDK = config.passkeySDK || this.createDefaultPasskeySDK();
|
|
835
|
+
// Configure logger with debug setting from config
|
|
836
|
+
if (this.config.debug) {
|
|
837
|
+
logger.enableDebug();
|
|
838
|
+
}
|
|
969
839
|
logger.debug("Initialized with config:", this.config);
|
|
970
840
|
}
|
|
971
841
|
/**
|
|
@@ -1630,11 +1500,22 @@ class PasskeymeAuth {
|
|
|
1630
1500
|
}
|
|
1631
1501
|
try {
|
|
1632
1502
|
// Get app configuration to check discoverable credentials support
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
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
|
+
}
|
|
1638
1519
|
// If passkeys are disabled at the app level, fallback to hosted auth
|
|
1639
1520
|
if (!appConfig.passkeyEnabled) {
|
|
1640
1521
|
logger.debug("Passkeys disabled for this app, falling back to hosted auth");
|
|
@@ -1658,7 +1539,10 @@ class PasskeymeAuth {
|
|
|
1658
1539
|
}
|
|
1659
1540
|
}
|
|
1660
1541
|
// Try to get stored username for fallback
|
|
1661
|
-
const
|
|
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);
|
|
1662
1546
|
if (storedUsername) {
|
|
1663
1547
|
logger.debug("Using stored username for targeted authentication:", storedUsername);
|
|
1664
1548
|
authUsername = storedUsername;
|
|
@@ -5667,7 +5551,6 @@ exports.NoOpPasskeySDK = NoOpPasskeySDK;
|
|
|
5667
5551
|
exports.PasskeymeApiClient = PasskeymeApiClient;
|
|
5668
5552
|
exports.PasskeymeAuth = PasskeymeAuth;
|
|
5669
5553
|
exports.PasskeymeError = PasskeymeError;
|
|
5670
|
-
exports.ReactNativePasskeySDK = ReactNativePasskeySDK;
|
|
5671
5554
|
exports.TokenStorage = TokenStorage;
|
|
5672
5555
|
exports.WebPasskeySDK = WebPasskeySDK;
|
|
5673
5556
|
exports.addAuthHeader = addAuthHeader;
|