@passkeyme/auth 2.0.1 → 2.0.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 +177 -175
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +177 -175
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +177 -175
- package/dist/index.umd.js.map +1 -1
- package/dist/src/api-client.d.ts +1 -1
- package/dist/src/api-client.d.ts.map +1 -1
- package/dist/src/passkeyme-auth.d.ts +1 -1
- package/dist/src/passkeyme-auth.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.umd.js
CHANGED
|
@@ -269,10 +269,11 @@
|
|
|
269
269
|
this.appId = appId;
|
|
270
270
|
this.baseUrl = baseUrl.replace(/\/$/, ""); // Remove trailing slash
|
|
271
271
|
this.debug = debug;
|
|
272
|
+
this.log("API Client initialized with baseUrl:", this.baseUrl);
|
|
272
273
|
}
|
|
273
274
|
log(...args) {
|
|
274
275
|
if (this.debug) {
|
|
275
|
-
logger.debug("[
|
|
276
|
+
logger.debug("[PasskeymeApiClient]", ...args);
|
|
276
277
|
}
|
|
277
278
|
}
|
|
278
279
|
async request(endpoint, options = {}) {
|
|
@@ -455,6 +456,179 @@
|
|
|
455
456
|
}
|
|
456
457
|
}
|
|
457
458
|
|
|
459
|
+
/**
|
|
460
|
+
* Platform SDK Interface for Passkeyme
|
|
461
|
+
*
|
|
462
|
+
* This interface abstracts platform-specific passkey operations,
|
|
463
|
+
* allowing the core SDK to work across web, React Native, and other platforms.
|
|
464
|
+
*/
|
|
465
|
+
/**
|
|
466
|
+
* No-op implementation for platforms without passkey support
|
|
467
|
+
*/
|
|
468
|
+
class NoOpPasskeySDK {
|
|
469
|
+
async register(_options) {
|
|
470
|
+
return {
|
|
471
|
+
success: false,
|
|
472
|
+
error: "Passkeys not supported on this platform",
|
|
473
|
+
};
|
|
474
|
+
}
|
|
475
|
+
async authenticate(_options) {
|
|
476
|
+
return {
|
|
477
|
+
success: false,
|
|
478
|
+
error: "Passkeys not supported on this platform",
|
|
479
|
+
};
|
|
480
|
+
}
|
|
481
|
+
isSupported() {
|
|
482
|
+
return false;
|
|
483
|
+
}
|
|
484
|
+
canUseDiscoverableCredentials() {
|
|
485
|
+
return false;
|
|
486
|
+
}
|
|
487
|
+
supportsBiometrics() {
|
|
488
|
+
return false;
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
/**
|
|
493
|
+
* Web Platform SDK Implementation
|
|
494
|
+
*
|
|
495
|
+
* Wraps the passkeyme-web-sdk to implement the PasskeySDK interface
|
|
496
|
+
*/
|
|
497
|
+
/**
|
|
498
|
+
* Web implementation of PasskeySDK using passkeyme-web-sdk
|
|
499
|
+
*
|
|
500
|
+
* This implementation should be used for web browsers that support WebAuthn.
|
|
501
|
+
* The actual passkeyme-web-sdk dependency should be provided by the consuming package.
|
|
502
|
+
*/
|
|
503
|
+
class WebPasskeySDK {
|
|
504
|
+
constructor(webSDK) {
|
|
505
|
+
this.webSDK = webSDK;
|
|
506
|
+
}
|
|
507
|
+
async register(options) {
|
|
508
|
+
try {
|
|
509
|
+
if (!this.webSDK) {
|
|
510
|
+
return {
|
|
511
|
+
success: false,
|
|
512
|
+
error: "Web SDK not available",
|
|
513
|
+
};
|
|
514
|
+
}
|
|
515
|
+
// Extract the challenge from the options
|
|
516
|
+
// The options object contains: { username, displayName, challenge, ...otherChallengeData }
|
|
517
|
+
const { username, displayName, challenge, ...otherData } = options;
|
|
518
|
+
// Pass the challenge data directly to the web SDK
|
|
519
|
+
const challengeData = challenge || otherData;
|
|
520
|
+
// Call the web SDK register method with the challenge
|
|
521
|
+
const result = await this.webSDK.passkeyRegister(challengeData);
|
|
522
|
+
return {
|
|
523
|
+
success: true,
|
|
524
|
+
credentialId: result.credentialId || result.id,
|
|
525
|
+
data: result,
|
|
526
|
+
};
|
|
527
|
+
}
|
|
528
|
+
catch (error) {
|
|
529
|
+
return {
|
|
530
|
+
success: false,
|
|
531
|
+
error: error.message || "Registration failed",
|
|
532
|
+
};
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
async authenticate(options) {
|
|
536
|
+
try {
|
|
537
|
+
if (!this.webSDK) {
|
|
538
|
+
return {
|
|
539
|
+
success: false,
|
|
540
|
+
error: "Web SDK not available",
|
|
541
|
+
};
|
|
542
|
+
}
|
|
543
|
+
// Extract the challenge from the options
|
|
544
|
+
// The options object contains: { username, challenge, ...otherChallengeData }
|
|
545
|
+
const { username, challenge, ...otherData } = options;
|
|
546
|
+
// Pass the challenge data directly to the web SDK
|
|
547
|
+
const challengeData = challenge || otherData;
|
|
548
|
+
// Call the web SDK authenticate method with the challenge
|
|
549
|
+
const result = await this.webSDK.passkeyAuthenticate(challengeData);
|
|
550
|
+
return {
|
|
551
|
+
success: true,
|
|
552
|
+
assertion: result,
|
|
553
|
+
data: result,
|
|
554
|
+
};
|
|
555
|
+
}
|
|
556
|
+
catch (error) {
|
|
557
|
+
return {
|
|
558
|
+
success: false,
|
|
559
|
+
error: error.message || "Authentication failed",
|
|
560
|
+
};
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
isSupported() {
|
|
564
|
+
// Check if we're in a browser environment with WebAuthn support
|
|
565
|
+
return (typeof window !== "undefined" &&
|
|
566
|
+
typeof navigator !== "undefined" &&
|
|
567
|
+
"credentials" in navigator &&
|
|
568
|
+
typeof navigator.credentials.create === "function");
|
|
569
|
+
}
|
|
570
|
+
async getAvailableAuthenticators() {
|
|
571
|
+
// This is a basic implementation - the web SDK might provide more detailed info
|
|
572
|
+
const authenticators = [];
|
|
573
|
+
if (this.isSupported()) {
|
|
574
|
+
// Basic platform authenticator info
|
|
575
|
+
authenticators.push({
|
|
576
|
+
type: "platform",
|
|
577
|
+
supportsBiometrics: true, // Assume platform authenticators support biometrics
|
|
578
|
+
supportsUserVerification: true,
|
|
579
|
+
});
|
|
580
|
+
// Basic cross-platform authenticator info
|
|
581
|
+
authenticators.push({
|
|
582
|
+
type: "cross-platform",
|
|
583
|
+
supportsBiometrics: false,
|
|
584
|
+
supportsUserVerification: true,
|
|
585
|
+
});
|
|
586
|
+
}
|
|
587
|
+
return authenticators;
|
|
588
|
+
}
|
|
589
|
+
canUseDiscoverableCredentials() {
|
|
590
|
+
// Check if the platform supports discoverable credentials (resident keys)
|
|
591
|
+
return this.isSupported();
|
|
592
|
+
}
|
|
593
|
+
supportsBiometrics() {
|
|
594
|
+
// On web, this depends on the platform authenticator availability
|
|
595
|
+
// This is a simplified check - a more sophisticated implementation
|
|
596
|
+
// would actually test for platform authenticator support
|
|
597
|
+
return (this.isSupported() &&
|
|
598
|
+
typeof window !== "undefined" &&
|
|
599
|
+
/Mac|Win|Linux/.test(navigator.platform));
|
|
600
|
+
}
|
|
601
|
+
async initialize(config) {
|
|
602
|
+
// Initialize the web SDK if it has an init method
|
|
603
|
+
if (this.webSDK && typeof this.webSDK.init === "function") {
|
|
604
|
+
await this.webSDK.init(config);
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
async cleanup() {
|
|
608
|
+
// Cleanup if the web SDK has a cleanup method
|
|
609
|
+
if (this.webSDK && typeof this.webSDK.cleanup === "function") {
|
|
610
|
+
await this.webSDK.cleanup();
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
/**
|
|
616
|
+
* Platform SDK exports
|
|
617
|
+
*/
|
|
618
|
+
// Conditionally export React Native SDK only in React Native environments
|
|
619
|
+
exports.ReactNativePasskeySDK = null;
|
|
620
|
+
try {
|
|
621
|
+
// Only try to load React Native SDK if we're actually in a React Native environment
|
|
622
|
+
if (typeof navigator !== "undefined" && navigator.product === "ReactNative") {
|
|
623
|
+
const { ReactNativePasskeySDK: RNPasskeySDK, } = require("./ReactNativePasskeySDK");
|
|
624
|
+
exports.ReactNativePasskeySDK = RNPasskeySDK;
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
catch (error) {
|
|
628
|
+
// React Native SDK not available or not in React Native environment
|
|
629
|
+
exports.ReactNativePasskeySDK = null;
|
|
630
|
+
}
|
|
631
|
+
|
|
458
632
|
/**
|
|
459
633
|
* Browser storage implementation using localStorage or sessionStorage
|
|
460
634
|
*/
|
|
@@ -631,179 +805,6 @@
|
|
|
631
805
|
TokenStorage.EXPIRES_AT_KEY = "passkeyme_expires_at";
|
|
632
806
|
TokenStorage.TOKEN_TYPE_KEY = "passkeyme_token_type";
|
|
633
807
|
|
|
634
|
-
/**
|
|
635
|
-
* Platform SDK Interface for Passkeyme
|
|
636
|
-
*
|
|
637
|
-
* This interface abstracts platform-specific passkey operations,
|
|
638
|
-
* allowing the core SDK to work across web, React Native, and other platforms.
|
|
639
|
-
*/
|
|
640
|
-
/**
|
|
641
|
-
* No-op implementation for platforms without passkey support
|
|
642
|
-
*/
|
|
643
|
-
class NoOpPasskeySDK {
|
|
644
|
-
async register(_options) {
|
|
645
|
-
return {
|
|
646
|
-
success: false,
|
|
647
|
-
error: "Passkeys not supported on this platform",
|
|
648
|
-
};
|
|
649
|
-
}
|
|
650
|
-
async authenticate(_options) {
|
|
651
|
-
return {
|
|
652
|
-
success: false,
|
|
653
|
-
error: "Passkeys not supported on this platform",
|
|
654
|
-
};
|
|
655
|
-
}
|
|
656
|
-
isSupported() {
|
|
657
|
-
return false;
|
|
658
|
-
}
|
|
659
|
-
canUseDiscoverableCredentials() {
|
|
660
|
-
return false;
|
|
661
|
-
}
|
|
662
|
-
supportsBiometrics() {
|
|
663
|
-
return false;
|
|
664
|
-
}
|
|
665
|
-
}
|
|
666
|
-
|
|
667
|
-
/**
|
|
668
|
-
* Web Platform SDK Implementation
|
|
669
|
-
*
|
|
670
|
-
* Wraps the passkeyme-web-sdk to implement the PasskeySDK interface
|
|
671
|
-
*/
|
|
672
|
-
/**
|
|
673
|
-
* Web implementation of PasskeySDK using passkeyme-web-sdk
|
|
674
|
-
*
|
|
675
|
-
* This implementation should be used for web browsers that support WebAuthn.
|
|
676
|
-
* The actual passkeyme-web-sdk dependency should be provided by the consuming package.
|
|
677
|
-
*/
|
|
678
|
-
class WebPasskeySDK {
|
|
679
|
-
constructor(webSDK) {
|
|
680
|
-
this.webSDK = webSDK;
|
|
681
|
-
}
|
|
682
|
-
async register(options) {
|
|
683
|
-
try {
|
|
684
|
-
if (!this.webSDK) {
|
|
685
|
-
return {
|
|
686
|
-
success: false,
|
|
687
|
-
error: "Web SDK not available",
|
|
688
|
-
};
|
|
689
|
-
}
|
|
690
|
-
// Extract the challenge from the options
|
|
691
|
-
// The options object contains: { username, displayName, challenge, ...otherChallengeData }
|
|
692
|
-
const { username, displayName, challenge, ...otherData } = options;
|
|
693
|
-
// Pass the challenge data directly to the web SDK
|
|
694
|
-
const challengeData = challenge || otherData;
|
|
695
|
-
// Call the web SDK register method with the challenge
|
|
696
|
-
const result = await this.webSDK.passkeyRegister(challengeData);
|
|
697
|
-
return {
|
|
698
|
-
success: true,
|
|
699
|
-
credentialId: result.credentialId || result.id,
|
|
700
|
-
data: result,
|
|
701
|
-
};
|
|
702
|
-
}
|
|
703
|
-
catch (error) {
|
|
704
|
-
return {
|
|
705
|
-
success: false,
|
|
706
|
-
error: error.message || "Registration failed",
|
|
707
|
-
};
|
|
708
|
-
}
|
|
709
|
-
}
|
|
710
|
-
async authenticate(options) {
|
|
711
|
-
try {
|
|
712
|
-
if (!this.webSDK) {
|
|
713
|
-
return {
|
|
714
|
-
success: false,
|
|
715
|
-
error: "Web SDK not available",
|
|
716
|
-
};
|
|
717
|
-
}
|
|
718
|
-
// Extract the challenge from the options
|
|
719
|
-
// The options object contains: { username, challenge, ...otherChallengeData }
|
|
720
|
-
const { username, challenge, ...otherData } = options;
|
|
721
|
-
// Pass the challenge data directly to the web SDK
|
|
722
|
-
const challengeData = challenge || otherData;
|
|
723
|
-
// Call the web SDK authenticate method with the challenge
|
|
724
|
-
const result = await this.webSDK.passkeyAuthenticate(challengeData);
|
|
725
|
-
return {
|
|
726
|
-
success: true,
|
|
727
|
-
assertion: result,
|
|
728
|
-
data: result,
|
|
729
|
-
};
|
|
730
|
-
}
|
|
731
|
-
catch (error) {
|
|
732
|
-
return {
|
|
733
|
-
success: false,
|
|
734
|
-
error: error.message || "Authentication failed",
|
|
735
|
-
};
|
|
736
|
-
}
|
|
737
|
-
}
|
|
738
|
-
isSupported() {
|
|
739
|
-
// Check if we're in a browser environment with WebAuthn support
|
|
740
|
-
return (typeof window !== "undefined" &&
|
|
741
|
-
typeof navigator !== "undefined" &&
|
|
742
|
-
"credentials" in navigator &&
|
|
743
|
-
typeof navigator.credentials.create === "function");
|
|
744
|
-
}
|
|
745
|
-
async getAvailableAuthenticators() {
|
|
746
|
-
// This is a basic implementation - the web SDK might provide more detailed info
|
|
747
|
-
const authenticators = [];
|
|
748
|
-
if (this.isSupported()) {
|
|
749
|
-
// Basic platform authenticator info
|
|
750
|
-
authenticators.push({
|
|
751
|
-
type: "platform",
|
|
752
|
-
supportsBiometrics: true, // Assume platform authenticators support biometrics
|
|
753
|
-
supportsUserVerification: true,
|
|
754
|
-
});
|
|
755
|
-
// Basic cross-platform authenticator info
|
|
756
|
-
authenticators.push({
|
|
757
|
-
type: "cross-platform",
|
|
758
|
-
supportsBiometrics: false,
|
|
759
|
-
supportsUserVerification: true,
|
|
760
|
-
});
|
|
761
|
-
}
|
|
762
|
-
return authenticators;
|
|
763
|
-
}
|
|
764
|
-
canUseDiscoverableCredentials() {
|
|
765
|
-
// Check if the platform supports discoverable credentials (resident keys)
|
|
766
|
-
return this.isSupported();
|
|
767
|
-
}
|
|
768
|
-
supportsBiometrics() {
|
|
769
|
-
// On web, this depends on the platform authenticator availability
|
|
770
|
-
// This is a simplified check - a more sophisticated implementation
|
|
771
|
-
// would actually test for platform authenticator support
|
|
772
|
-
return (this.isSupported() &&
|
|
773
|
-
typeof window !== "undefined" &&
|
|
774
|
-
/Mac|Win|Linux/.test(navigator.platform));
|
|
775
|
-
}
|
|
776
|
-
async initialize(config) {
|
|
777
|
-
// Initialize the web SDK if it has an init method
|
|
778
|
-
if (this.webSDK && typeof this.webSDK.init === "function") {
|
|
779
|
-
await this.webSDK.init(config);
|
|
780
|
-
}
|
|
781
|
-
}
|
|
782
|
-
async cleanup() {
|
|
783
|
-
// Cleanup if the web SDK has a cleanup method
|
|
784
|
-
if (this.webSDK && typeof this.webSDK.cleanup === "function") {
|
|
785
|
-
await this.webSDK.cleanup();
|
|
786
|
-
}
|
|
787
|
-
}
|
|
788
|
-
}
|
|
789
|
-
|
|
790
|
-
/**
|
|
791
|
-
* Platform SDK exports
|
|
792
|
-
*/
|
|
793
|
-
// Conditionally export React Native SDK only in React Native environments
|
|
794
|
-
exports.ReactNativePasskeySDK = null;
|
|
795
|
-
try {
|
|
796
|
-
// Only try to load React Native SDK if we're actually in a React Native environment
|
|
797
|
-
if (typeof navigator !== "undefined" && navigator.product === "ReactNative") {
|
|
798
|
-
const { ReactNativePasskeySDK: RNPasskeySDK, } = require("./ReactNativePasskeySDK");
|
|
799
|
-
exports.ReactNativePasskeySDK = RNPasskeySDK;
|
|
800
|
-
}
|
|
801
|
-
}
|
|
802
|
-
catch (error) {
|
|
803
|
-
// React Native SDK not available or not in React Native environment
|
|
804
|
-
exports.ReactNativePasskeySDK = null;
|
|
805
|
-
}
|
|
806
|
-
|
|
807
808
|
/**
|
|
808
809
|
* Main Passkeyme Authentication SDK class
|
|
809
810
|
*/
|
|
@@ -824,7 +825,7 @@
|
|
|
824
825
|
? `${window.location.origin}/auth/callback`
|
|
825
826
|
: "http://localhost:3000/auth/callback";
|
|
826
827
|
// Support both baseUrl and apiUrl for flexibility
|
|
827
|
-
const serverUrl = config.
|
|
828
|
+
const serverUrl = config.baseUrl || "https://auth.passkeyme.com";
|
|
828
829
|
this.config = {
|
|
829
830
|
appId: config.appId,
|
|
830
831
|
baseUrl: serverUrl,
|
|
@@ -845,6 +846,7 @@
|
|
|
845
846
|
logger.enableDebug();
|
|
846
847
|
logger.debug("[DEBUG] Logger debug mode enabled, testing logger...");
|
|
847
848
|
logger.debug("[DEBUG] Logger config after enableDebug:", logger.getConfig());
|
|
849
|
+
logger.debug("config.baseUrl:", this.config.baseUrl);
|
|
848
850
|
logger.debug("Logger test message - if you see this, logger is working");
|
|
849
851
|
}
|
|
850
852
|
logger.debug("Initialized with config:", this.config);
|