@passkeyme/auth 2.0.1 → 2.0.2
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 +174 -174
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +174 -174
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +174 -174
- package/dist/index.umd.js.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
|
@@ -455,6 +455,179 @@
|
|
|
455
455
|
}
|
|
456
456
|
}
|
|
457
457
|
|
|
458
|
+
/**
|
|
459
|
+
* Platform SDK Interface for Passkeyme
|
|
460
|
+
*
|
|
461
|
+
* This interface abstracts platform-specific passkey operations,
|
|
462
|
+
* allowing the core SDK to work across web, React Native, and other platforms.
|
|
463
|
+
*/
|
|
464
|
+
/**
|
|
465
|
+
* No-op implementation for platforms without passkey support
|
|
466
|
+
*/
|
|
467
|
+
class NoOpPasskeySDK {
|
|
468
|
+
async register(_options) {
|
|
469
|
+
return {
|
|
470
|
+
success: false,
|
|
471
|
+
error: "Passkeys not supported on this platform",
|
|
472
|
+
};
|
|
473
|
+
}
|
|
474
|
+
async authenticate(_options) {
|
|
475
|
+
return {
|
|
476
|
+
success: false,
|
|
477
|
+
error: "Passkeys not supported on this platform",
|
|
478
|
+
};
|
|
479
|
+
}
|
|
480
|
+
isSupported() {
|
|
481
|
+
return false;
|
|
482
|
+
}
|
|
483
|
+
canUseDiscoverableCredentials() {
|
|
484
|
+
return false;
|
|
485
|
+
}
|
|
486
|
+
supportsBiometrics() {
|
|
487
|
+
return false;
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
/**
|
|
492
|
+
* Web Platform SDK Implementation
|
|
493
|
+
*
|
|
494
|
+
* Wraps the passkeyme-web-sdk to implement the PasskeySDK interface
|
|
495
|
+
*/
|
|
496
|
+
/**
|
|
497
|
+
* Web implementation of PasskeySDK using passkeyme-web-sdk
|
|
498
|
+
*
|
|
499
|
+
* This implementation should be used for web browsers that support WebAuthn.
|
|
500
|
+
* The actual passkeyme-web-sdk dependency should be provided by the consuming package.
|
|
501
|
+
*/
|
|
502
|
+
class WebPasskeySDK {
|
|
503
|
+
constructor(webSDK) {
|
|
504
|
+
this.webSDK = webSDK;
|
|
505
|
+
}
|
|
506
|
+
async register(options) {
|
|
507
|
+
try {
|
|
508
|
+
if (!this.webSDK) {
|
|
509
|
+
return {
|
|
510
|
+
success: false,
|
|
511
|
+
error: "Web SDK not available",
|
|
512
|
+
};
|
|
513
|
+
}
|
|
514
|
+
// Extract the challenge from the options
|
|
515
|
+
// The options object contains: { username, displayName, challenge, ...otherChallengeData }
|
|
516
|
+
const { username, displayName, challenge, ...otherData } = options;
|
|
517
|
+
// Pass the challenge data directly to the web SDK
|
|
518
|
+
const challengeData = challenge || otherData;
|
|
519
|
+
// Call the web SDK register method with the challenge
|
|
520
|
+
const result = await this.webSDK.passkeyRegister(challengeData);
|
|
521
|
+
return {
|
|
522
|
+
success: true,
|
|
523
|
+
credentialId: result.credentialId || result.id,
|
|
524
|
+
data: result,
|
|
525
|
+
};
|
|
526
|
+
}
|
|
527
|
+
catch (error) {
|
|
528
|
+
return {
|
|
529
|
+
success: false,
|
|
530
|
+
error: error.message || "Registration failed",
|
|
531
|
+
};
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
async authenticate(options) {
|
|
535
|
+
try {
|
|
536
|
+
if (!this.webSDK) {
|
|
537
|
+
return {
|
|
538
|
+
success: false,
|
|
539
|
+
error: "Web SDK not available",
|
|
540
|
+
};
|
|
541
|
+
}
|
|
542
|
+
// Extract the challenge from the options
|
|
543
|
+
// The options object contains: { username, challenge, ...otherChallengeData }
|
|
544
|
+
const { username, challenge, ...otherData } = options;
|
|
545
|
+
// Pass the challenge data directly to the web SDK
|
|
546
|
+
const challengeData = challenge || otherData;
|
|
547
|
+
// Call the web SDK authenticate method with the challenge
|
|
548
|
+
const result = await this.webSDK.passkeyAuthenticate(challengeData);
|
|
549
|
+
return {
|
|
550
|
+
success: true,
|
|
551
|
+
assertion: result,
|
|
552
|
+
data: result,
|
|
553
|
+
};
|
|
554
|
+
}
|
|
555
|
+
catch (error) {
|
|
556
|
+
return {
|
|
557
|
+
success: false,
|
|
558
|
+
error: error.message || "Authentication failed",
|
|
559
|
+
};
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
isSupported() {
|
|
563
|
+
// Check if we're in a browser environment with WebAuthn support
|
|
564
|
+
return (typeof window !== "undefined" &&
|
|
565
|
+
typeof navigator !== "undefined" &&
|
|
566
|
+
"credentials" in navigator &&
|
|
567
|
+
typeof navigator.credentials.create === "function");
|
|
568
|
+
}
|
|
569
|
+
async getAvailableAuthenticators() {
|
|
570
|
+
// This is a basic implementation - the web SDK might provide more detailed info
|
|
571
|
+
const authenticators = [];
|
|
572
|
+
if (this.isSupported()) {
|
|
573
|
+
// Basic platform authenticator info
|
|
574
|
+
authenticators.push({
|
|
575
|
+
type: "platform",
|
|
576
|
+
supportsBiometrics: true, // Assume platform authenticators support biometrics
|
|
577
|
+
supportsUserVerification: true,
|
|
578
|
+
});
|
|
579
|
+
// Basic cross-platform authenticator info
|
|
580
|
+
authenticators.push({
|
|
581
|
+
type: "cross-platform",
|
|
582
|
+
supportsBiometrics: false,
|
|
583
|
+
supportsUserVerification: true,
|
|
584
|
+
});
|
|
585
|
+
}
|
|
586
|
+
return authenticators;
|
|
587
|
+
}
|
|
588
|
+
canUseDiscoverableCredentials() {
|
|
589
|
+
// Check if the platform supports discoverable credentials (resident keys)
|
|
590
|
+
return this.isSupported();
|
|
591
|
+
}
|
|
592
|
+
supportsBiometrics() {
|
|
593
|
+
// On web, this depends on the platform authenticator availability
|
|
594
|
+
// This is a simplified check - a more sophisticated implementation
|
|
595
|
+
// would actually test for platform authenticator support
|
|
596
|
+
return (this.isSupported() &&
|
|
597
|
+
typeof window !== "undefined" &&
|
|
598
|
+
/Mac|Win|Linux/.test(navigator.platform));
|
|
599
|
+
}
|
|
600
|
+
async initialize(config) {
|
|
601
|
+
// Initialize the web SDK if it has an init method
|
|
602
|
+
if (this.webSDK && typeof this.webSDK.init === "function") {
|
|
603
|
+
await this.webSDK.init(config);
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
async cleanup() {
|
|
607
|
+
// Cleanup if the web SDK has a cleanup method
|
|
608
|
+
if (this.webSDK && typeof this.webSDK.cleanup === "function") {
|
|
609
|
+
await this.webSDK.cleanup();
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
/**
|
|
615
|
+
* Platform SDK exports
|
|
616
|
+
*/
|
|
617
|
+
// Conditionally export React Native SDK only in React Native environments
|
|
618
|
+
exports.ReactNativePasskeySDK = null;
|
|
619
|
+
try {
|
|
620
|
+
// Only try to load React Native SDK if we're actually in a React Native environment
|
|
621
|
+
if (typeof navigator !== "undefined" && navigator.product === "ReactNative") {
|
|
622
|
+
const { ReactNativePasskeySDK: RNPasskeySDK, } = require("./ReactNativePasskeySDK");
|
|
623
|
+
exports.ReactNativePasskeySDK = RNPasskeySDK;
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
catch (error) {
|
|
627
|
+
// React Native SDK not available or not in React Native environment
|
|
628
|
+
exports.ReactNativePasskeySDK = null;
|
|
629
|
+
}
|
|
630
|
+
|
|
458
631
|
/**
|
|
459
632
|
* Browser storage implementation using localStorage or sessionStorage
|
|
460
633
|
*/
|
|
@@ -631,179 +804,6 @@
|
|
|
631
804
|
TokenStorage.EXPIRES_AT_KEY = "passkeyme_expires_at";
|
|
632
805
|
TokenStorage.TOKEN_TYPE_KEY = "passkeyme_token_type";
|
|
633
806
|
|
|
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
807
|
/**
|
|
808
808
|
* Main Passkeyme Authentication SDK class
|
|
809
809
|
*/
|
|
@@ -824,7 +824,7 @@
|
|
|
824
824
|
? `${window.location.origin}/auth/callback`
|
|
825
825
|
: "http://localhost:3000/auth/callback";
|
|
826
826
|
// Support both baseUrl and apiUrl for flexibility
|
|
827
|
-
const serverUrl = config.
|
|
827
|
+
const serverUrl = config.baseUrl || "https://auth.passkeyme.com";
|
|
828
828
|
this.config = {
|
|
829
829
|
appId: config.appId,
|
|
830
830
|
baseUrl: serverUrl,
|