capacitor-auth-manager 0.0.2 → 1.1.0
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/LICENSE +1 -1
- package/Readme.md +245 -1
- package/android/build.gradle +1 -1
- package/android/proguard-rules.pro +1 -1
- package/android/src/main/java/com/{zaions/cap_auth_manager → aoneahsan/capacitor_auth_manager}/AuthLogger.java +1 -1
- package/android/src/main/java/com/{zaions/cap_auth_manager → aoneahsan/capacitor_auth_manager}/AuthStorage.java +1 -1
- package/android/src/main/java/com/{zaions/cap_auth_manager → aoneahsan/capacitor_auth_manager}/BaseAuthProvider.java +1 -1
- package/android/src/main/java/com/{zaions/cap_auth_manager → aoneahsan/capacitor_auth_manager}/CapacitorAuthManager.java +1 -1
- package/android/src/main/java/com/{zaions/cap_auth_manager → aoneahsan/capacitor_auth_manager}/CapacitorAuthManagerPlugin.java +1 -1
- package/dist/esm/definitions.d.ts +5 -5
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/providers/oauth-provider.d.ts +38 -7
- package/dist/esm/providers/oauth-provider.js +17 -12
- package/dist/esm/providers/oauth-provider.js.map +1 -1
- package/dist/esm/providers/web/apple-provider.d.ts +32 -5
- package/dist/esm/providers/web/apple-provider.js +15 -16
- package/dist/esm/providers/web/apple-provider.js.map +1 -1
- package/dist/esm/providers/web/google-provider.d.ts +98 -7
- package/dist/esm/providers/web/google-provider.js +19 -9
- package/dist/esm/providers/web/google-provider.js.map +1 -1
- package/dist/esm/utils/auth-error.d.ts +5 -5
- package/dist/esm/utils/auth-error.js +10 -3
- package/dist/esm/utils/auth-error.js.map +1 -1
- package/dist/esm/utils/event-emitter.d.ts +2 -2
- package/dist/esm/utils/logger.d.ts +4 -4
- package/dist/esm/utils/logger.js.map +1 -1
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +69 -43
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +69 -43
- package/dist/plugin.js.map +1 -1
- package/package.json +9 -9
package/LICENSE
CHANGED
package/Readme.md
CHANGED
|
@@ -2,6 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
A comprehensive authentication plugin for Capacitor that provides secure, type-safe, and framework-independent authentication implementations across Android, iOS, and Web platforms.
|
|
4
4
|
|
|
5
|
+
## 📚 Documentation
|
|
6
|
+
|
|
7
|
+
- [**Installation Guide**](./docs/installation.md) - Get started with Capacitor Auth Manager
|
|
8
|
+
- [**Configuration Options**](./docs/configuration.md) - Complete list of all configuration options
|
|
9
|
+
- [**Provider Guides**](./docs/providers/) - Detailed setup guides for each authentication provider
|
|
10
|
+
- [Google Auth](./docs/providers/google.md)
|
|
11
|
+
- [Apple Auth](./docs/providers/apple.md)
|
|
12
|
+
- [Microsoft Auth](./docs/providers/microsoft.md)
|
|
13
|
+
- [Facebook Auth](./docs/providers/facebook.md)
|
|
14
|
+
- [GitHub Auth](./docs/providers/github.md)
|
|
15
|
+
- [And more...](./docs/providers/)
|
|
16
|
+
- [**API Reference**](./docs/api/) - Complete API documentation
|
|
17
|
+
- [**Examples**](./docs/examples/) - Sample implementations and use cases
|
|
18
|
+
- [**Migration Guide**](./docs/migration.md) - Upgrading from previous versions
|
|
19
|
+
- [**Troubleshooting**](./docs/troubleshooting.md) - Common issues and solutions
|
|
20
|
+
|
|
5
21
|
## Features
|
|
6
22
|
|
|
7
23
|
- 🔐 **13+ Authentication Providers**: Google, Apple, Microsoft, Facebook, GitHub, Slack, LinkedIn, Firebase, Email Magic Link, SMS, Email/Phone/Username + Password, Email Code, and Biometric Auth
|
|
@@ -455,6 +471,169 @@ const token = await CapacitorAuthManager.getIdToken({
|
|
|
455
471
|
});
|
|
456
472
|
```
|
|
457
473
|
|
|
474
|
+
## Configuration Options
|
|
475
|
+
|
|
476
|
+
### Global Configuration
|
|
477
|
+
|
|
478
|
+
All configuration options available when initializing the auth manager:
|
|
479
|
+
|
|
480
|
+
```typescript
|
|
481
|
+
interface AuthManagerInitOptions {
|
|
482
|
+
providers: AuthProviderConfig[]; // Required: Array of provider configurations
|
|
483
|
+
persistence?: AuthPersistence; // 'local' | 'session' | 'none' (default: 'local')
|
|
484
|
+
autoRefreshToken?: boolean; // Auto-refresh tokens before expiry (default: true)
|
|
485
|
+
tokenRefreshBuffer?: number; // Ms before expiry to refresh (default: 300000 - 5 min)
|
|
486
|
+
enableLogging?: boolean; // Enable debug logging (default: false)
|
|
487
|
+
logLevel?: LogLevel; // 'debug' | 'info' | 'warn' | 'error' (default: 'info')
|
|
488
|
+
}
|
|
489
|
+
```
|
|
490
|
+
|
|
491
|
+
### Provider-Specific Options
|
|
492
|
+
|
|
493
|
+
Each provider supports all options provided by their official SDKs:
|
|
494
|
+
|
|
495
|
+
#### Google Auth Options
|
|
496
|
+
```typescript
|
|
497
|
+
interface GoogleAuthOptions {
|
|
498
|
+
clientId: string; // Required: Your Google Client ID
|
|
499
|
+
serverClientId?: string; // Android: Server client ID for offline access
|
|
500
|
+
scopes?: string[]; // OAuth scopes (default: ['openid', 'email', 'profile'])
|
|
501
|
+
offlineAccess?: boolean; // Request refresh token (default: false)
|
|
502
|
+
hostedDomain?: string; // Restrict to G Suite domain
|
|
503
|
+
forceCodeForRefreshToken?: boolean; // Force auth code flow (default: false)
|
|
504
|
+
}
|
|
505
|
+
```
|
|
506
|
+
|
|
507
|
+
#### Apple Auth Options
|
|
508
|
+
```typescript
|
|
509
|
+
interface AppleAuthOptions {
|
|
510
|
+
clientId: string; // Required: Your Service ID
|
|
511
|
+
redirectUri: string; // Required: Your redirect URI
|
|
512
|
+
scopes?: AppleAuthScope[]; // [EMAIL, NAME] (default: [])
|
|
513
|
+
usePopup?: boolean; // Use popup instead of redirect (default: true)
|
|
514
|
+
state?: string; // OAuth state parameter
|
|
515
|
+
nonce?: string; // OAuth nonce for security
|
|
516
|
+
}
|
|
517
|
+
```
|
|
518
|
+
|
|
519
|
+
#### Microsoft Auth Options
|
|
520
|
+
```typescript
|
|
521
|
+
interface MicrosoftAuthOptions {
|
|
522
|
+
clientId: string; // Required: Your Azure AD Client ID
|
|
523
|
+
redirectUri?: string; // Redirect URI (default: current URL)
|
|
524
|
+
scopes?: string[]; // OAuth scopes
|
|
525
|
+
tenantId?: string; // Azure AD tenant ID
|
|
526
|
+
prompt?: string; // 'login' | 'consent' | 'select_account'
|
|
527
|
+
loginHint?: string; // Pre-fill email
|
|
528
|
+
domainHint?: string; // 'consumers' | 'organizations'
|
|
529
|
+
responseType?: string; // OAuth response type
|
|
530
|
+
responseMode?: string; // 'query' | 'fragment'
|
|
531
|
+
codeChallenge?: string; // PKCE code challenge
|
|
532
|
+
codeChallengeMethod?: string; // PKCE method
|
|
533
|
+
state?: string; // OAuth state
|
|
534
|
+
nonce?: string; // OAuth nonce
|
|
535
|
+
}
|
|
536
|
+
```
|
|
537
|
+
|
|
538
|
+
#### Facebook Auth Options
|
|
539
|
+
```typescript
|
|
540
|
+
interface FacebookAuthOptions {
|
|
541
|
+
appId: string; // Required: Your Facebook App ID
|
|
542
|
+
permissions?: string[]; // Facebook permissions
|
|
543
|
+
version?: string; // API version (default: 'v12.0')
|
|
544
|
+
loginBehavior?: string; // iOS: 'browser' | 'native' | 'system'
|
|
545
|
+
limitedLogin?: boolean; // iOS 14.5+: Use limited login
|
|
546
|
+
nonce?: string; // Security nonce
|
|
547
|
+
}
|
|
548
|
+
```
|
|
549
|
+
|
|
550
|
+
#### Sign In Options
|
|
551
|
+
|
|
552
|
+
Additional options available when calling `signIn()`:
|
|
553
|
+
|
|
554
|
+
```typescript
|
|
555
|
+
interface SignInProviderOptions {
|
|
556
|
+
scopes?: string[]; // Override default scopes
|
|
557
|
+
customParameters?: Record<string, string>; // Provider-specific parameters
|
|
558
|
+
loginHint?: string; // Pre-fill username/email
|
|
559
|
+
prompt?: string; // UI behavior
|
|
560
|
+
display?: string; // UI display mode
|
|
561
|
+
accessType?: string; // 'online' | 'offline'
|
|
562
|
+
includeGrantedScopes?: boolean; // Include previously granted scopes
|
|
563
|
+
state?: string; // OAuth state
|
|
564
|
+
nonce?: string; // OAuth nonce
|
|
565
|
+
pkceEnabled?: boolean; // Enable PKCE (default: true where supported)
|
|
566
|
+
}
|
|
567
|
+
```
|
|
568
|
+
|
|
569
|
+
### Complete Example with All Options
|
|
570
|
+
|
|
571
|
+
```typescript
|
|
572
|
+
await CapacitorAuthManager.initialize({
|
|
573
|
+
// Global options
|
|
574
|
+
persistence: 'local',
|
|
575
|
+
autoRefreshToken: true,
|
|
576
|
+
tokenRefreshBuffer: 300000,
|
|
577
|
+
enableLogging: true,
|
|
578
|
+
logLevel: 'debug',
|
|
579
|
+
|
|
580
|
+
// Provider configurations
|
|
581
|
+
providers: [
|
|
582
|
+
{
|
|
583
|
+
provider: AuthProvider.GOOGLE,
|
|
584
|
+
options: {
|
|
585
|
+
clientId: 'YOUR_GOOGLE_CLIENT_ID',
|
|
586
|
+
serverClientId: 'YOUR_SERVER_CLIENT_ID',
|
|
587
|
+
scopes: ['email', 'profile', 'https://www.googleapis.com/auth/calendar'],
|
|
588
|
+
offlineAccess: true,
|
|
589
|
+
hostedDomain: 'company.com',
|
|
590
|
+
forceCodeForRefreshToken: true
|
|
591
|
+
}
|
|
592
|
+
},
|
|
593
|
+
{
|
|
594
|
+
provider: AuthProvider.APPLE,
|
|
595
|
+
options: {
|
|
596
|
+
clientId: 'com.company.service',
|
|
597
|
+
redirectUri: 'https://company.com/auth/callback',
|
|
598
|
+
scopes: [AppleAuthScope.EMAIL, AppleAuthScope.NAME],
|
|
599
|
+
usePopup: true,
|
|
600
|
+
state: crypto.randomUUID(),
|
|
601
|
+
nonce: crypto.randomUUID()
|
|
602
|
+
}
|
|
603
|
+
},
|
|
604
|
+
{
|
|
605
|
+
provider: AuthProvider.MICROSOFT,
|
|
606
|
+
options: {
|
|
607
|
+
clientId: 'YOUR_AZURE_CLIENT_ID',
|
|
608
|
+
redirectUri: 'https://company.com/auth/callback',
|
|
609
|
+
scopes: ['openid', 'profile', 'email', 'User.Read'],
|
|
610
|
+
tenantId: 'YOUR_TENANT_ID',
|
|
611
|
+
prompt: 'select_account',
|
|
612
|
+
responseType: 'code',
|
|
613
|
+
responseMode: 'query',
|
|
614
|
+
codeChallenge: 'YOUR_CODE_CHALLENGE',
|
|
615
|
+
codeChallengeMethod: 'S256'
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
]
|
|
619
|
+
});
|
|
620
|
+
|
|
621
|
+
// Sign in with custom options
|
|
622
|
+
const result = await CapacitorAuthManager.signIn({
|
|
623
|
+
provider: AuthProvider.GOOGLE,
|
|
624
|
+
options: {
|
|
625
|
+
scopes: ['email', 'profile', 'https://www.googleapis.com/auth/drive'],
|
|
626
|
+
loginHint: 'user@company.com',
|
|
627
|
+
prompt: 'consent',
|
|
628
|
+
accessType: 'offline',
|
|
629
|
+
includeGrantedScopes: true,
|
|
630
|
+
customParameters: {
|
|
631
|
+
'approval_prompt': 'force'
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
});
|
|
635
|
+
```
|
|
636
|
+
|
|
458
637
|
## Error Handling
|
|
459
638
|
|
|
460
639
|
The plugin provides detailed error codes for different scenarios:
|
|
@@ -534,6 +713,71 @@ const result = await CapacitorAuthManager.signIn({
|
|
|
534
713
|
});
|
|
535
714
|
```
|
|
536
715
|
|
|
716
|
+
## 📚 Documentation
|
|
717
|
+
|
|
718
|
+
For comprehensive documentation, examples, and guides, visit our [Documentation](./docs/README.md):
|
|
719
|
+
|
|
720
|
+
### 🚀 Getting Started
|
|
721
|
+
- [Installation Guide](./docs/getting-started/installation.md) - Step-by-step setup instructions
|
|
722
|
+
- [Quick Start](./docs/getting-started/quick-start.md) - Get up and running in minutes
|
|
723
|
+
- [Platform Setup](./docs/getting-started/platform-setup.md) - Platform-specific configuration
|
|
724
|
+
|
|
725
|
+
### 🔧 API Reference
|
|
726
|
+
- [Core API](./docs/api-reference/core-api.md) - Complete method reference
|
|
727
|
+
- [Authentication State](./docs/api-reference/auth-state.md) - Understanding auth state
|
|
728
|
+
- [Error Handling](./docs/api-reference/error-handling.md) - Handle errors gracefully
|
|
729
|
+
|
|
730
|
+
### 🏢 Provider Guides
|
|
731
|
+
- [Google Auth](./docs/providers/google.md) - Google Sign-In implementation
|
|
732
|
+
- [Apple Auth](./docs/providers/apple.md) - Sign in with Apple
|
|
733
|
+
- [Facebook Auth](./docs/providers/facebook.md) - Facebook Login
|
|
734
|
+
- [Microsoft Auth](./docs/providers/microsoft.md) - Microsoft identity platform
|
|
735
|
+
- [GitHub Auth](./docs/providers/github.md) - GitHub OAuth
|
|
736
|
+
- [Firebase Auth](./docs/providers/firebase.md) - Firebase Authentication
|
|
737
|
+
- [More providers...](./docs/providers/) - All 13+ supported providers
|
|
738
|
+
|
|
739
|
+
### 💡 Framework Examples
|
|
740
|
+
- [React Integration](./docs/examples/react.md) - Complete React implementation
|
|
741
|
+
- [Angular Example](./docs/examples/angular.md) - Angular integration
|
|
742
|
+
- [Vue Example](./docs/examples/vue.md) - Vue.js implementation
|
|
743
|
+
- [Ionic Example](./docs/examples/ionic.md) - Ionic Framework integration
|
|
744
|
+
|
|
745
|
+
### 📖 Advanced Guides
|
|
746
|
+
- [Best Practices](./docs/guides/best-practices.md) - Authentication best practices
|
|
747
|
+
- [Security Guide](./docs/guides/security.md) - Security considerations
|
|
748
|
+
- [Token Management](./docs/guides/token-management.md) - Handling tokens
|
|
749
|
+
- [Multi-Factor Auth](./docs/guides/mfa.md) - Implementing MFA
|
|
750
|
+
|
|
751
|
+
## Platform Compatibility
|
|
752
|
+
|
|
753
|
+
### Supported Platforms
|
|
754
|
+
|
|
755
|
+
| Provider | iOS | Android | Web |
|
|
756
|
+
|----------|-----|---------|-----|
|
|
757
|
+
| Google | ✅ | ✅ | ✅ |
|
|
758
|
+
| Apple | ✅ | ✅ | ✅ |
|
|
759
|
+
| Microsoft | ✅ | ✅ | ✅ |
|
|
760
|
+
| Facebook | ✅ | ✅ | ✅ |
|
|
761
|
+
| GitHub | ✅ | ✅ | ✅ |
|
|
762
|
+
| Slack | ✅ | ✅ | ✅ |
|
|
763
|
+
| LinkedIn | ✅ | ✅ | ✅ |
|
|
764
|
+
| Firebase | ✅ | ✅ | ✅ |
|
|
765
|
+
| Email Magic Link | ✅ | ✅ | ✅ |
|
|
766
|
+
| SMS | ✅ | ✅ | ✅ |
|
|
767
|
+
| Email/Phone/Username + Password | ✅ | ✅ | ✅ |
|
|
768
|
+
| Email Code | ✅ | ✅ | ✅ |
|
|
769
|
+
| Biometric | ✅ | ✅ | ❌ |
|
|
770
|
+
|
|
771
|
+
### Platform Requirements
|
|
772
|
+
|
|
773
|
+
- **iOS**: iOS 13.0+
|
|
774
|
+
- **Android**: Android 5.0 (API 21)+
|
|
775
|
+
- **Web**: Modern browsers with ES2017 support
|
|
776
|
+
|
|
777
|
+
### Capacitor Version
|
|
778
|
+
|
|
779
|
+
- Capacitor 7.0.0+
|
|
780
|
+
|
|
537
781
|
## Contributing
|
|
538
782
|
|
|
539
783
|
Contributions are welcome! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
|
|
@@ -550,4 +794,4 @@ MIT
|
|
|
550
794
|
|
|
551
795
|
## Credits
|
|
552
796
|
|
|
553
|
-
Created by [Ahsan Mahmood](https://aoneahsan.com)
|
|
797
|
+
Created by [Ahsan Mahmood](https://aoneahsan.com) - Open source for the community
|
package/android/build.gradle
CHANGED
|
@@ -18,7 +18,7 @@ buildscript {
|
|
|
18
18
|
apply plugin: 'com.android.library'
|
|
19
19
|
|
|
20
20
|
android {
|
|
21
|
-
namespace "com.
|
|
21
|
+
namespace "com.aoneahsan.capacitor_auth_manager"
|
|
22
22
|
compileSdk project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 35
|
|
23
23
|
defaultConfig {
|
|
24
24
|
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 23
|
|
@@ -290,7 +290,7 @@ export interface OAuthCredentials {
|
|
|
290
290
|
nonce?: string;
|
|
291
291
|
}
|
|
292
292
|
export interface CustomCredentials {
|
|
293
|
-
[key: string]:
|
|
293
|
+
[key: string]: string | number | boolean | null | undefined;
|
|
294
294
|
}
|
|
295
295
|
export type SignInProviderOptions = {
|
|
296
296
|
scopes?: string[];
|
|
@@ -328,7 +328,7 @@ export interface AuthUser {
|
|
|
328
328
|
providerData: UserInfo[];
|
|
329
329
|
metadata: UserMetadata;
|
|
330
330
|
refreshToken?: string;
|
|
331
|
-
customClaims?: Record<string,
|
|
331
|
+
customClaims?: Record<string, string | number | boolean | null>;
|
|
332
332
|
}
|
|
333
333
|
export interface UserInfo {
|
|
334
334
|
providerId: string;
|
|
@@ -357,7 +357,7 @@ export interface AuthCredential {
|
|
|
357
357
|
export interface AdditionalUserInfo {
|
|
358
358
|
isNewUser: boolean;
|
|
359
359
|
providerId: string;
|
|
360
|
-
profile?: Record<string,
|
|
360
|
+
profile?: Record<string, string | number | boolean | null | undefined>;
|
|
361
361
|
username?: string;
|
|
362
362
|
}
|
|
363
363
|
export interface RefreshTokenOptions {
|
|
@@ -425,7 +425,7 @@ export interface UpdateProfileOptions {
|
|
|
425
425
|
displayName?: string | null;
|
|
426
426
|
photoURL?: string | null;
|
|
427
427
|
phoneNumber?: string | null;
|
|
428
|
-
customClaims?: Record<string,
|
|
428
|
+
customClaims?: Record<string, string | number | boolean | null>;
|
|
429
429
|
}
|
|
430
430
|
export interface DeleteAccountOptions {
|
|
431
431
|
requireReauthentication?: boolean;
|
|
@@ -451,7 +451,7 @@ export declare enum AuthPersistence {
|
|
|
451
451
|
}
|
|
452
452
|
export interface AuthError extends Error {
|
|
453
453
|
code: string;
|
|
454
|
-
details?:
|
|
454
|
+
details?: Record<string, unknown>;
|
|
455
455
|
provider?: AuthProvider;
|
|
456
456
|
}
|
|
457
457
|
export declare enum AuthErrorCode {
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -2,3 +2,5 @@ import type { CapacitorAuthManagerPlugin } from './definitions';
|
|
|
2
2
|
declare const CapacitorAuthManager: CapacitorAuthManagerPlugin;
|
|
3
3
|
export * from './definitions';
|
|
4
4
|
export { CapacitorAuthManager };
|
|
5
|
+
export { AuthError, isAuthError } from './utils/auth-error';
|
|
6
|
+
export type { LogLevel } from './utils/logger';
|
package/dist/esm/index.js
CHANGED
|
@@ -4,4 +4,6 @@ const CapacitorAuthManager = registerPlugin('CapacitorAuthManager', {
|
|
|
4
4
|
});
|
|
5
5
|
export * from './definitions';
|
|
6
6
|
export { CapacitorAuthManager };
|
|
7
|
+
// Export useful utilities for end users
|
|
8
|
+
export { AuthError, isAuthError } from './utils/auth-error';
|
|
7
9
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD,MAAM,oBAAoB,GAAG,cAAc,CACzC,sBAAsB,EACtB;IACE,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,uBAAuB,EAAE,CAAC;CACtE,CACF,CAAC;AAEF,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,oBAAoB,EAAE,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD,MAAM,oBAAoB,GAAG,cAAc,CACzC,sBAAsB,EACtB;IACE,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,uBAAuB,EAAE,CAAC;CACtE,CACF,CAAC;AAEF,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,oBAAoB,EAAE,CAAC;AAEhC,wCAAwC;AACxC,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -1,5 +1,27 @@
|
|
|
1
|
-
import { AuthResult, SignInOptions, AuthErrorCode, AuthCredential, RefreshTokenOptions } from '../definitions';
|
|
1
|
+
import { AuthResult, SignInOptions, AuthErrorCode, AuthCredential, RefreshTokenOptions, AuthUser } from '../definitions';
|
|
2
2
|
import { BaseAuthProvider } from './base-provider';
|
|
3
|
+
export interface OAuthTokenResponse {
|
|
4
|
+
access_token: string;
|
|
5
|
+
token_type: string;
|
|
6
|
+
expires_in?: number;
|
|
7
|
+
refresh_token?: string;
|
|
8
|
+
id_token?: string;
|
|
9
|
+
scope?: string;
|
|
10
|
+
[key: string]: string | number | undefined;
|
|
11
|
+
}
|
|
12
|
+
export interface OAuthUserInfo {
|
|
13
|
+
id?: string;
|
|
14
|
+
sub?: string;
|
|
15
|
+
email?: string;
|
|
16
|
+
email_verified?: boolean;
|
|
17
|
+
name?: string;
|
|
18
|
+
displayName?: string;
|
|
19
|
+
picture?: string;
|
|
20
|
+
photoURL?: string;
|
|
21
|
+
phone_number?: string;
|
|
22
|
+
isNewUser?: boolean;
|
|
23
|
+
[key: string]: string | boolean | undefined;
|
|
24
|
+
}
|
|
3
25
|
export interface OAuthConfig {
|
|
4
26
|
clientId: string;
|
|
5
27
|
clientSecret?: string;
|
|
@@ -15,16 +37,25 @@ export interface OAuthConfig {
|
|
|
15
37
|
}
|
|
16
38
|
export declare abstract class OAuthProvider extends BaseAuthProvider {
|
|
17
39
|
protected abstract getOAuthConfig(): OAuthConfig;
|
|
18
|
-
protected abstract parseUserFromTokenResponse(response:
|
|
40
|
+
protected abstract parseUserFromTokenResponse(response: OAuthTokenResponse): Promise<OAuthUserInfo>;
|
|
19
41
|
protected performOAuthFlow(options?: SignInOptions): Promise<AuthResult>;
|
|
20
42
|
protected buildAuthorizationUrl(config: OAuthConfig, state: string, nonce: string, options?: SignInOptions): string;
|
|
21
|
-
protected abstract openAuthorizationUrl(url: string): Promise<
|
|
22
|
-
|
|
23
|
-
|
|
43
|
+
protected abstract openAuthorizationUrl(url: string): Promise<{
|
|
44
|
+
code?: string;
|
|
45
|
+
state?: string;
|
|
46
|
+
error?: string;
|
|
47
|
+
}>;
|
|
48
|
+
protected validateOAuthResponse(response: {
|
|
49
|
+
code?: string;
|
|
50
|
+
state?: string;
|
|
51
|
+
error?: string;
|
|
52
|
+
error_description?: string;
|
|
53
|
+
}, expectedState: string, _expectedNonce: string): Promise<void>;
|
|
54
|
+
protected exchangeCodeForTokens(code: string, config: OAuthConfig): Promise<OAuthTokenResponse>;
|
|
24
55
|
refreshToken(_options?: RefreshTokenOptions): Promise<AuthResult>;
|
|
25
56
|
revokeAccess(token?: string): Promise<void>;
|
|
26
|
-
protected createOAuthCredential(tokenResponse:
|
|
27
|
-
protected createAuthUser(userInfo:
|
|
57
|
+
protected createOAuthCredential(tokenResponse: OAuthTokenResponse): AuthCredential;
|
|
58
|
+
protected createAuthUser(userInfo: OAuthUserInfo, tokenResponse: OAuthTokenResponse): AuthUser;
|
|
28
59
|
protected mapOAuthError(error: string): AuthErrorCode;
|
|
29
60
|
protected generateSecureRandomString(length?: number): string;
|
|
30
61
|
}
|
|
@@ -18,6 +18,9 @@ export class OAuthProvider extends BaseAuthProvider {
|
|
|
18
18
|
// Validate response
|
|
19
19
|
await this.validateOAuthResponse(authResponse, state, nonce);
|
|
20
20
|
// Exchange authorization code for tokens
|
|
21
|
+
if (!authResponse.code) {
|
|
22
|
+
throw new AuthError(AuthErrorCode.INVALID_GRANT, 'No authorization code received', this.provider);
|
|
23
|
+
}
|
|
21
24
|
const tokenResponse = await this.exchangeCodeForTokens(authResponse.code, config);
|
|
22
25
|
// Parse user information
|
|
23
26
|
const userInfo = await this.parseUserFromTokenResponse(tokenResponse);
|
|
@@ -27,7 +30,7 @@ export class OAuthProvider extends BaseAuthProvider {
|
|
|
27
30
|
// Save user and credential
|
|
28
31
|
await this.setCurrentUser(user);
|
|
29
32
|
await this.saveCredential(credential);
|
|
30
|
-
return this.createAuthResult(user, credential, userInfo.isNewUser);
|
|
33
|
+
return this.createAuthResult(user, credential, userInfo.isNewUser || false);
|
|
31
34
|
}
|
|
32
35
|
catch (error) {
|
|
33
36
|
this.logger.error(`OAuth flow failed for ${this.provider}`, error);
|
|
@@ -93,7 +96,8 @@ export class OAuthProvider extends BaseAuthProvider {
|
|
|
93
96
|
});
|
|
94
97
|
const data = await response.json();
|
|
95
98
|
if (!response.ok) {
|
|
96
|
-
|
|
99
|
+
const errorData = data;
|
|
100
|
+
throw new AuthError(this.mapOAuthError(errorData.error), errorData.error_description || 'Token exchange failed', this.provider, errorData);
|
|
97
101
|
}
|
|
98
102
|
return data;
|
|
99
103
|
}
|
|
@@ -129,7 +133,8 @@ export class OAuthProvider extends BaseAuthProvider {
|
|
|
129
133
|
});
|
|
130
134
|
const data = await response.json();
|
|
131
135
|
if (!response.ok) {
|
|
132
|
-
|
|
136
|
+
const errorData = data;
|
|
137
|
+
throw new AuthError(this.mapOAuthError(errorData.error), errorData.error_description || 'Token refresh failed', this.provider, errorData);
|
|
133
138
|
}
|
|
134
139
|
// Update credential with new tokens
|
|
135
140
|
const newCredential = this.createOAuthCredential(data);
|
|
@@ -202,20 +207,20 @@ export class OAuthProvider extends BaseAuthProvider {
|
|
|
202
207
|
createAuthUser(userInfo, tokenResponse) {
|
|
203
208
|
return {
|
|
204
209
|
uid: userInfo.id || userInfo.sub || this.generateUniqueId(),
|
|
205
|
-
email: userInfo.email,
|
|
210
|
+
email: userInfo.email || null,
|
|
206
211
|
emailVerified: userInfo.email_verified || false,
|
|
207
|
-
displayName: userInfo.name || userInfo.displayName,
|
|
208
|
-
photoURL: userInfo.picture || userInfo.photoURL,
|
|
209
|
-
phoneNumber: userInfo.phone_number,
|
|
212
|
+
displayName: userInfo.name || userInfo.displayName || null,
|
|
213
|
+
photoURL: userInfo.picture || userInfo.photoURL || null,
|
|
214
|
+
phoneNumber: userInfo.phone_number || null,
|
|
210
215
|
isAnonymous: false,
|
|
211
216
|
tenantId: null,
|
|
212
217
|
providerData: [{
|
|
213
218
|
providerId: this.provider,
|
|
214
|
-
uid: userInfo.id || userInfo.sub,
|
|
215
|
-
displayName: userInfo.name,
|
|
216
|
-
email: userInfo.email,
|
|
217
|
-
phoneNumber: userInfo.phone_number,
|
|
218
|
-
photoURL: userInfo.picture,
|
|
219
|
+
uid: userInfo.id || userInfo.sub || '',
|
|
220
|
+
displayName: userInfo.name || null,
|
|
221
|
+
email: userInfo.email || null,
|
|
222
|
+
phoneNumber: userInfo.phone_number || null,
|
|
223
|
+
photoURL: userInfo.picture || null,
|
|
219
224
|
}],
|
|
220
225
|
metadata: {
|
|
221
226
|
creationTime: new Date().toISOString(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oauth-provider.js","sourceRoot":"","sources":["../../../src/providers/oauth-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,aAAa,
|
|
1
|
+
{"version":3,"file":"oauth-provider.js","sourceRoot":"","sources":["../../../src/providers/oauth-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,aAAa,GAId,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAwChD,MAAM,OAAgB,aAAc,SAAQ,gBAAgB;IAIhD,KAAK,CAAC,gBAAgB,CAAC,OAAuB;QACtD,MAAM,MAAM,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC;QAErC,IAAI,CAAC;YACH,wCAAwC;YACxC,MAAM,KAAK,GAAG,IAAI,CAAC,0BAA0B,EAAE,CAAC;YAChD,MAAM,KAAK,GAAG,IAAI,CAAC,0BAA0B,EAAE,CAAC;YAEhD,uCAAuC;YACvC,MAAM,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,I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CAAC,uBAAuB;YAChE,eAAe,EAAE,aAAa,CAAC,aAAa;YAC5C,gBAAgB,EAAE,aAAa,CAAC,gBAAgB;YAChD,sBAAsB,EAAE,aAAa,CAAC,oBAAoB;YAC1D,gBAAgB,EAAE,aAAa,CAAC,cAAc;YAC9C,kBAAkB,EAAE,aAAa,CAAC,gBAAgB;SACnD,CAAC;QAEF,OAAO,QAAQ,CAAC,KAAK,CAAC,IAAI,aAAa,CAAC,cAAc,CAAC;IACzD,CAAC;IAES,0BAA0B,CAAC,MAAM,GAAG,EAAE;QAC9C,MAAM,KAAK,GAAG,gEAAgE,CAAC;QAC/E,IAAI,MAAM,GAAG,EAAE,CAAC;QAChB,MAAM,YAAY,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC;QAC5C,MAAM,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;QAErC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAChC,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;QAClD,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
|
|
@@ -1,12 +1,34 @@
|
|
|
1
1
|
import { SignInOptions, SignOutOptions, LinkAccountOptions, UnlinkAccountOptions, AuthResult } from '../../definitions';
|
|
2
|
-
import { OAuthProvider, OAuthConfig } from '../oauth-provider';
|
|
2
|
+
import { OAuthProvider, OAuthConfig, OAuthTokenResponse, OAuthUserInfo } from '../oauth-provider';
|
|
3
3
|
import { BaseProviderConfig } from '../base-provider';
|
|
4
|
+
interface AppleSignInResponse {
|
|
5
|
+
authorization: {
|
|
6
|
+
code: string;
|
|
7
|
+
id_token: string;
|
|
8
|
+
state: string;
|
|
9
|
+
};
|
|
10
|
+
user?: {
|
|
11
|
+
email?: string;
|
|
12
|
+
name?: {
|
|
13
|
+
firstName?: string;
|
|
14
|
+
lastName?: string;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
interface AppleSignInConfig {
|
|
19
|
+
clientId: string;
|
|
20
|
+
scope: string;
|
|
21
|
+
redirectURI: string;
|
|
22
|
+
state: string;
|
|
23
|
+
nonce?: string;
|
|
24
|
+
usePopup?: boolean;
|
|
25
|
+
}
|
|
4
26
|
declare global {
|
|
5
27
|
interface Window {
|
|
6
28
|
AppleID?: {
|
|
7
29
|
auth: {
|
|
8
|
-
init: (config:
|
|
9
|
-
signIn: (config?:
|
|
30
|
+
init: (config: AppleSignInConfig) => void;
|
|
31
|
+
signIn: (config?: AppleSignInConfig) => Promise<AppleSignInResponse>;
|
|
10
32
|
};
|
|
11
33
|
};
|
|
12
34
|
}
|
|
@@ -22,8 +44,12 @@ export declare class AppleAuthProviderWeb extends OAuthProvider {
|
|
|
22
44
|
isSupported(): Promise<boolean>;
|
|
23
45
|
linkAccount(options: LinkAccountOptions): Promise<AuthResult>;
|
|
24
46
|
unlinkAccount(_options: UnlinkAccountOptions): Promise<void>;
|
|
25
|
-
protected openAuthorizationUrl(_url: string): Promise<
|
|
26
|
-
|
|
47
|
+
protected openAuthorizationUrl(_url: string): Promise<{
|
|
48
|
+
code?: string;
|
|
49
|
+
state?: string;
|
|
50
|
+
error?: string;
|
|
51
|
+
}>;
|
|
52
|
+
protected parseUserFromTokenResponse(_response: OAuthTokenResponse): Promise<OAuthUserInfo>;
|
|
27
53
|
private loadAppleSDK;
|
|
28
54
|
private mapAppleScopes;
|
|
29
55
|
private validateAppleResponse;
|
|
@@ -31,3 +57,4 @@ export declare class AppleAuthProviderWeb extends OAuthProvider {
|
|
|
31
57
|
private createAppleCredential;
|
|
32
58
|
private mapAppleError;
|
|
33
59
|
}
|
|
60
|
+
export {};
|