@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.umd.js
CHANGED
|
@@ -17,6 +17,19 @@
|
|
|
17
17
|
...config,
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* Update logger configuration
|
|
22
|
+
*/
|
|
23
|
+
setConfig(config) {
|
|
24
|
+
this.config = { ...this.config, ...config };
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Enable debug logging
|
|
28
|
+
*/
|
|
29
|
+
enableDebug() {
|
|
30
|
+
this.config.enabled = true;
|
|
31
|
+
this.config.level = "debug";
|
|
32
|
+
}
|
|
20
33
|
shouldLog(level) {
|
|
21
34
|
if (!this.config.enabled)
|
|
22
35
|
return false;
|
|
@@ -769,168 +782,21 @@
|
|
|
769
782
|
}
|
|
770
783
|
|
|
771
784
|
/**
|
|
772
|
-
*
|
|
773
|
-
*
|
|
774
|
-
* Bridges to native iOS (CocoaPods) and Android (Gradle) SDKs
|
|
775
|
-
*/
|
|
776
|
-
/**
|
|
777
|
-
* React Native implementation of PasskeySDK
|
|
778
|
-
*
|
|
779
|
-
* This implementation bridges to native iOS and Android SDKs:
|
|
780
|
-
* - iOS: https://cocoapods.org/pods/PasskeymeSDK
|
|
781
|
-
* - Android: https://maven.pkg.github.com/justincrosbie/passkeyme-android-sdk
|
|
785
|
+
* Platform SDK exports
|
|
782
786
|
*/
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
catch (error) {
|
|
791
|
-
console.warn("React Native environment not detected or PasskeymeNativeModule not available");
|
|
792
|
-
this.nativeModule = null;
|
|
793
|
-
}
|
|
794
|
-
}
|
|
795
|
-
async register(options) {
|
|
796
|
-
try {
|
|
797
|
-
if (!this.nativeModule) {
|
|
798
|
-
return {
|
|
799
|
-
success: false,
|
|
800
|
-
error: "Native module not available",
|
|
801
|
-
};
|
|
802
|
-
}
|
|
803
|
-
// Call the native module register method
|
|
804
|
-
const result = await this.nativeModule.register({
|
|
805
|
-
...options,
|
|
806
|
-
requireUserVerification: options.requireUserVerification || false,
|
|
807
|
-
});
|
|
808
|
-
return {
|
|
809
|
-
success: result.success,
|
|
810
|
-
credentialId: result.credentialId,
|
|
811
|
-
error: result.error,
|
|
812
|
-
data: result,
|
|
813
|
-
};
|
|
814
|
-
}
|
|
815
|
-
catch (error) {
|
|
816
|
-
return {
|
|
817
|
-
success: false,
|
|
818
|
-
error: error.message || "Registration failed",
|
|
819
|
-
};
|
|
820
|
-
}
|
|
821
|
-
}
|
|
822
|
-
async authenticate(options) {
|
|
823
|
-
try {
|
|
824
|
-
if (!this.nativeModule) {
|
|
825
|
-
return {
|
|
826
|
-
success: false,
|
|
827
|
-
error: "Native module not available",
|
|
828
|
-
};
|
|
829
|
-
}
|
|
830
|
-
// Call the native module authenticate method
|
|
831
|
-
const result = await this.nativeModule.authenticate({
|
|
832
|
-
...options,
|
|
833
|
-
requireUserVerification: options.requireUserVerification || false,
|
|
834
|
-
});
|
|
835
|
-
return {
|
|
836
|
-
success: result.success,
|
|
837
|
-
assertion: result.assertion,
|
|
838
|
-
error: result.error,
|
|
839
|
-
data: result,
|
|
840
|
-
};
|
|
841
|
-
}
|
|
842
|
-
catch (error) {
|
|
843
|
-
return {
|
|
844
|
-
success: false,
|
|
845
|
-
error: error.message || "Authentication failed",
|
|
846
|
-
};
|
|
847
|
-
}
|
|
848
|
-
}
|
|
849
|
-
isSupported() {
|
|
850
|
-
return this.nativeModule != null;
|
|
851
|
-
}
|
|
852
|
-
async getAvailableAuthenticators() {
|
|
853
|
-
try {
|
|
854
|
-
if (!this.nativeModule) {
|
|
855
|
-
return [];
|
|
856
|
-
}
|
|
857
|
-
// Call native method to get available authenticators
|
|
858
|
-
const authenticators = await this.nativeModule.getAvailableAuthenticators();
|
|
859
|
-
return authenticators || [];
|
|
860
|
-
}
|
|
861
|
-
catch (error) {
|
|
862
|
-
console.warn("Failed to get available authenticators:", error);
|
|
863
|
-
return [];
|
|
864
|
-
}
|
|
865
|
-
}
|
|
866
|
-
canUseDiscoverableCredentials() {
|
|
867
|
-
// Most modern mobile devices support discoverable credentials
|
|
868
|
-
return this.isSupported();
|
|
869
|
-
}
|
|
870
|
-
supportsBiometrics() {
|
|
871
|
-
// Mobile devices typically support biometric authentication
|
|
872
|
-
return this.isSupported();
|
|
873
|
-
}
|
|
874
|
-
async initialize(config) {
|
|
875
|
-
if (this.nativeModule &&
|
|
876
|
-
typeof this.nativeModule.initialize === "function") {
|
|
877
|
-
await this.nativeModule.initialize(config);
|
|
878
|
-
}
|
|
879
|
-
}
|
|
880
|
-
async cleanup() {
|
|
881
|
-
if (this.nativeModule && typeof this.nativeModule.cleanup === "function") {
|
|
882
|
-
await this.nativeModule.cleanup();
|
|
883
|
-
}
|
|
884
|
-
}
|
|
885
|
-
/**
|
|
886
|
-
* Check if the device supports Face ID (iOS) or Face Unlock (Android)
|
|
887
|
-
*/
|
|
888
|
-
async supportsFaceRecognition() {
|
|
889
|
-
try {
|
|
890
|
-
if (!this.nativeModule)
|
|
891
|
-
return false;
|
|
892
|
-
return await this.nativeModule.supportsFaceRecognition();
|
|
893
|
-
}
|
|
894
|
-
catch (_a) {
|
|
895
|
-
return false;
|
|
896
|
-
}
|
|
897
|
-
}
|
|
898
|
-
/**
|
|
899
|
-
* Check if the device supports Touch ID (iOS) or Fingerprint (Android)
|
|
900
|
-
*/
|
|
901
|
-
async supportsFingerprint() {
|
|
902
|
-
try {
|
|
903
|
-
if (!this.nativeModule)
|
|
904
|
-
return false;
|
|
905
|
-
return await this.nativeModule.supportsFingerprint();
|
|
906
|
-
}
|
|
907
|
-
catch (_a) {
|
|
908
|
-
return false;
|
|
909
|
-
}
|
|
910
|
-
}
|
|
911
|
-
/**
|
|
912
|
-
* Get detailed biometric capabilities
|
|
913
|
-
*/
|
|
914
|
-
async getBiometricCapabilities() {
|
|
915
|
-
try {
|
|
916
|
-
if (!this.nativeModule) {
|
|
917
|
-
return {
|
|
918
|
-
faceRecognition: false,
|
|
919
|
-
fingerprint: false,
|
|
920
|
-
voiceRecognition: false,
|
|
921
|
-
};
|
|
922
|
-
}
|
|
923
|
-
return await this.nativeModule.getBiometricCapabilities();
|
|
924
|
-
}
|
|
925
|
-
catch (_a) {
|
|
926
|
-
return {
|
|
927
|
-
faceRecognition: false,
|
|
928
|
-
fingerprint: false,
|
|
929
|
-
voiceRecognition: false,
|
|
930
|
-
};
|
|
931
|
-
}
|
|
787
|
+
// Conditionally export React Native SDK only in React Native environments
|
|
788
|
+
exports.ReactNativePasskeySDK = null;
|
|
789
|
+
try {
|
|
790
|
+
// Only try to load React Native SDK if we're actually in a React Native environment
|
|
791
|
+
if (typeof navigator !== "undefined" && navigator.product === "ReactNative") {
|
|
792
|
+
const { ReactNativePasskeySDK: RNPasskeySDK, } = require("./ReactNativePasskeySDK");
|
|
793
|
+
exports.ReactNativePasskeySDK = RNPasskeySDK;
|
|
932
794
|
}
|
|
933
795
|
}
|
|
796
|
+
catch (error) {
|
|
797
|
+
// React Native SDK not available or not in React Native environment
|
|
798
|
+
exports.ReactNativePasskeySDK = null;
|
|
799
|
+
}
|
|
934
800
|
|
|
935
801
|
/**
|
|
936
802
|
* Main PasskeyMe Authentication SDK class
|
|
@@ -968,6 +834,10 @@
|
|
|
968
834
|
this.tokenStorage = new TokenStorage(storage);
|
|
969
835
|
// Use provided passkey SDK or create default one
|
|
970
836
|
this.passkeySDK = config.passkeySDK || this.createDefaultPasskeySDK();
|
|
837
|
+
// Configure logger with debug setting from config
|
|
838
|
+
if (this.config.debug) {
|
|
839
|
+
logger.enableDebug();
|
|
840
|
+
}
|
|
971
841
|
logger.debug("Initialized with config:", this.config);
|
|
972
842
|
}
|
|
973
843
|
/**
|
|
@@ -1632,11 +1502,22 @@
|
|
|
1632
1502
|
}
|
|
1633
1503
|
try {
|
|
1634
1504
|
// Get app configuration to check discoverable credentials support
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1505
|
+
let appConfig;
|
|
1506
|
+
try {
|
|
1507
|
+
appConfig = await this.getAppConfig();
|
|
1508
|
+
logger.debug("App config loaded:", {
|
|
1509
|
+
discoverableCredentialsEnabled: appConfig.discoverableCredentialsEnabled,
|
|
1510
|
+
passkeyEnabled: appConfig.passkeyEnabled,
|
|
1511
|
+
});
|
|
1512
|
+
}
|
|
1513
|
+
catch (configError) {
|
|
1514
|
+
logger.debug("Failed to load app config, assuming passkeys enabled:", configError);
|
|
1515
|
+
// If we can't load config, assume passkeys are enabled and no discoverable credentials
|
|
1516
|
+
appConfig = {
|
|
1517
|
+
passkeyEnabled: true,
|
|
1518
|
+
discoverableCredentialsEnabled: false,
|
|
1519
|
+
};
|
|
1520
|
+
}
|
|
1640
1521
|
// If passkeys are disabled at the app level, fallback to hosted auth
|
|
1641
1522
|
if (!appConfig.passkeyEnabled) {
|
|
1642
1523
|
logger.debug("Passkeys disabled for this app, falling back to hosted auth");
|
|
@@ -1660,7 +1541,10 @@
|
|
|
1660
1541
|
}
|
|
1661
1542
|
}
|
|
1662
1543
|
// Try to get stored username for fallback
|
|
1663
|
-
const
|
|
1544
|
+
const storageKey = `last_username_${this.config.appId}`;
|
|
1545
|
+
logger.debug("Looking for stored username with key:", storageKey);
|
|
1546
|
+
const storedUsername = await this.storage.getItem(storageKey);
|
|
1547
|
+
logger.debug("Found stored username:", storedUsername);
|
|
1664
1548
|
if (storedUsername) {
|
|
1665
1549
|
logger.debug("Using stored username for targeted authentication:", storedUsername);
|
|
1666
1550
|
authUsername = storedUsername;
|
|
@@ -5669,7 +5553,6 @@
|
|
|
5669
5553
|
exports.PasskeymeApiClient = PasskeymeApiClient;
|
|
5670
5554
|
exports.PasskeymeAuth = PasskeymeAuth;
|
|
5671
5555
|
exports.PasskeymeError = PasskeymeError;
|
|
5672
|
-
exports.ReactNativePasskeySDK = ReactNativePasskeySDK;
|
|
5673
5556
|
exports.TokenStorage = TokenStorage;
|
|
5674
5557
|
exports.WebPasskeySDK = WebPasskeySDK;
|
|
5675
5558
|
exports.addAuthHeader = addAuthHeader;
|