capacitor-auth-manager 0.0.1 → 1.0.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.
Files changed (62) hide show
  1. package/CapacitorAuthManager.podspec +36 -0
  2. package/LICENSE +1 -1
  3. package/Readme.md +577 -20
  4. package/android/build.gradle +79 -0
  5. package/android/gradle.properties +25 -0
  6. package/android/proguard-rules.pro +38 -0
  7. package/android/settings.gradle +2 -0
  8. package/android/src/main/AndroidManifest.xml +11 -0
  9. package/android/src/main/java/com/aoneahsan/capacitor_auth_manager/AuthLogger.java +117 -0
  10. package/android/src/main/java/com/aoneahsan/capacitor_auth_manager/AuthStorage.java +124 -0
  11. package/android/src/main/java/com/aoneahsan/capacitor_auth_manager/BaseAuthProvider.java +16 -0
  12. package/android/src/main/java/com/aoneahsan/capacitor_auth_manager/CapacitorAuthManager.java +385 -0
  13. package/android/src/main/java/com/aoneahsan/capacitor_auth_manager/CapacitorAuthManagerPlugin.java +469 -0
  14. package/dist/esm/definitions.d.ts +521 -0
  15. package/dist/esm/definitions.js +103 -1
  16. package/dist/esm/definitions.js.map +1 -1
  17. package/dist/esm/index.d.ts +4 -0
  18. package/dist/esm/index.js +6 -1
  19. package/dist/esm/index.js.map +1 -1
  20. package/dist/esm/providers/base-provider.d.ts +43 -0
  21. package/dist/esm/providers/base-provider.js +112 -0
  22. package/dist/esm/providers/base-provider.js.map +1 -0
  23. package/dist/esm/providers/oauth-provider.d.ts +30 -0
  24. package/dist/esm/providers/oauth-provider.js +255 -0
  25. package/dist/esm/providers/oauth-provider.js.map +1 -0
  26. package/dist/esm/providers/provider-factory.d.ts +7 -0
  27. package/dist/esm/providers/provider-factory.js +76 -0
  28. package/dist/esm/providers/provider-factory.js.map +1 -0
  29. package/dist/esm/providers/web/apple-provider.d.ts +33 -0
  30. package/dist/esm/providers/web/apple-provider.js +270 -0
  31. package/dist/esm/providers/web/apple-provider.js.map +1 -0
  32. package/dist/esm/providers/web/google-provider.d.ts +27 -0
  33. package/dist/esm/providers/web/google-provider.js +258 -0
  34. package/dist/esm/providers/web/google-provider.js.map +1 -0
  35. package/dist/esm/utils/auth-error.d.ts +16 -0
  36. package/dist/esm/utils/auth-error.js +53 -0
  37. package/dist/esm/utils/auth-error.js.map +1 -0
  38. package/dist/esm/utils/event-emitter.d.ts +9 -0
  39. package/dist/esm/utils/event-emitter.js +28 -0
  40. package/dist/esm/utils/event-emitter.js.map +1 -0
  41. package/dist/esm/utils/logger.d.ts +19 -0
  42. package/dist/esm/utils/logger.js +48 -0
  43. package/dist/esm/utils/logger.js.map +1 -0
  44. package/dist/esm/utils/storage.d.ts +16 -0
  45. package/dist/esm/utils/storage.js +86 -0
  46. package/dist/esm/utils/storage.js.map +1 -0
  47. package/dist/esm/web.d.ts +43 -0
  48. package/dist/esm/web.js +374 -1
  49. package/dist/esm/web.js.map +1 -1
  50. package/dist/plugin.cjs.js +1650 -0
  51. package/dist/plugin.cjs.js.map +1 -1
  52. package/dist/plugin.js +1652 -3
  53. package/dist/plugin.js.map +1 -1
  54. package/ios/Plugin/AuthLogger.swift +71 -0
  55. package/ios/Plugin/AuthStorage.swift +139 -0
  56. package/ios/Plugin/BaseAuthProvider.swift +33 -0
  57. package/ios/Plugin/CapacitorAuthManager.swift +406 -0
  58. package/ios/Plugin/Models.swift +376 -0
  59. package/ios/Plugin/Plugin.m +27 -0
  60. package/ios/Plugin/Plugin.swift +413 -0
  61. package/package.json +6 -2
  62. package/scripts/configure.js +295 -0
@@ -0,0 +1,36 @@
1
+ require 'json'
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
4
+
5
+ Pod::Spec.new do |s|
6
+ s.name = 'CapacitorAuthManager'
7
+ s.version = package['version']
8
+ s.summary = package['description']
9
+ s.license = package['license']
10
+ s.homepage = package['repository']['url']
11
+ s.author = package['author']
12
+ s.source = { :git => package['repository']['url'], :tag => s.version.to_s }
13
+ s.source_files = 'ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}'
14
+ s.ios.deployment_target = '13.0'
15
+ s.swift_version = '5.9'
16
+ s.dependency 'Capacitor'
17
+
18
+ # Auth Provider Dependencies
19
+ s.dependency 'GoogleSignIn', '~> 7.0'
20
+ s.dependency 'FBSDKLoginKit', '~> 17.0'
21
+
22
+ # Apple Sign In is built into iOS
23
+
24
+ # Microsoft Authentication Library
25
+ s.dependency 'MSAL', '~> 1.5'
26
+
27
+ # Firebase Auth (optional, can be added when needed)
28
+ # s.dependency 'Firebase/Auth'
29
+
30
+ s.static_framework = true
31
+
32
+ # Required for Google Sign In
33
+ s.pod_target_xcconfig = {
34
+ 'SWIFT_OBJC_BRIDGING_HEADER' => '$(PODS_TARGET_SRCROOT)/ios/Plugin/Plugin-Bridging-Header.h'
35
+ }
36
+ end
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2024 Zaions
3
+ Copyright (c) 2024 Ahsan Mahmood
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/Readme.md CHANGED
@@ -1,31 +1,588 @@
1
1
  # Capacitor Auth Manager
2
2
 
3
- A comprehensive "Auth Manager" plugin for Capacitor that provides secure, type-safe, and framework-independent implementation for authentication using "Firebase Auth, Google Auth, Apple Auth, Microsoft Auth, Facebook Auth, Github Auth, Slack Auth, Linkedin Auth, Email Magic Link Auth, SMS Auth, Email/Phone/Username + Password Auth, Email Code Auth, Biometric Auth (for biometric auth make sure to use our plugin 'https://www.npmjs.com/package/capacitor-biometric-authentication', mean use this to get th biometric functionality which we have implemented for android, ios and web and rest handle here that we need to handle for this plugin)" access across Android, iOS and Web platforms.
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
- ## Main Requirements
5
+ ## Features
6
6
 
7
- need to implement, authentication using "Firebase Auth, Google Auth, Apple Auth, Microsoft Auth, Facebook Auth, Github Auth, Slack Auth, Linkedin Auth, Email Magic Link Auth, SMS Auth, Email/Phone/Username + Password Auth, Email Code Auth, Biometric Auth" for android, IOS and web app using capacitor framework and native sdks/apis, like for google use google direct api, for slack use slack api, for linkedin use linkedin api, so on and so forth.
8
- we should not use any unofficial package for any of it, and keep it as much framework independant as possible
9
- and we should provide a "Subscribable Auth state" & provide all the options for each and every auth that their providers provide through their native sdk/api to end user
7
+ - 🔐 **13+ Authentication Providers**: Google, Apple, Microsoft, Facebook, GitHub, Slack, LinkedIn, Firebase, Email Magic Link, SMS, Email/Phone/Username + Password, Email Code, and Biometric Auth
8
+ - 📱 **Cross-Platform**: Works seamlessly on iOS, Android, and Web
9
+ - 🔄 **Subscribable Auth State**: Real-time authentication state updates
10
+ - 🎯 **Type-Safe**: Full TypeScript support with comprehensive type definitions
11
+ - 🏗️ **Framework Independent**: Works with any JavaScript framework
12
+ - 🔒 **Secure**: Uses only official SDKs and follows security best practices
13
+ - ⚡ **Performant**: Optimized for minimal overhead and fast authentication flows
14
+ - 🔧 **Highly Configurable**: Each provider can be configured with all available options
10
15
 
11
- each and every mentioned auth service/option, should be easily configurable and with all the options that their provider provides
16
+ ## Installation
12
17
 
13
- the solution should be fully type safe, framework independant, secure, highly performant, and should use all the bst coding practices and standards.
18
+ ```bash
19
+ npm install capacitor-auth-manager
20
+ npx cap sync
21
+ ```
14
22
 
15
- ### Package Info
23
+ ## Quick Start
16
24
 
17
- package id: com.zaions.cap_auth_manager
25
+ ```typescript
26
+ import { CapacitorAuthManager, AuthProvider } from 'capacitor-auth-manager';
18
27
 
19
- package name: capacitor auth manager
28
+ // Initialize the auth manager
29
+ await CapacitorAuthManager.initialize({
30
+ providers: [
31
+ {
32
+ provider: AuthProvider.GOOGLE,
33
+ options: {
34
+ clientId: 'YOUR_GOOGLE_CLIENT_ID',
35
+ scopes: ['email', 'profile']
36
+ }
37
+ },
38
+ {
39
+ provider: AuthProvider.APPLE,
40
+ options: {
41
+ clientId: 'YOUR_APPLE_CLIENT_ID',
42
+ redirectUri: 'YOUR_REDIRECT_URI'
43
+ }
44
+ }
45
+ ],
46
+ persistence: 'local', // 'local' | 'session' | 'none'
47
+ autoRefreshToken: true,
48
+ enableLogging: true
49
+ });
20
50
 
21
- ### developer and company info
51
+ // Sign in with Google
52
+ const result = await CapacitorAuthManager.signIn({
53
+ provider: AuthProvider.GOOGLE
54
+ });
22
55
 
23
- name: Ahsan Mahmood
24
- developer website: https://aoneahsan.com
25
- company: Zaions
26
- company website: https://zaions.com
27
- github repo url: https://github.com/aoneahsan/capacitor-auth-manager
28
- npm package url: https://www.npmjs.com/package/capacitor-auth-manager
29
- developer linkedin profile: https://linkedin.com/in/aoneahsan
30
- email: aoneahsan@gmail.com
31
- phone: +923046619706
56
+ console.log('Signed in user:', result.user);
57
+
58
+ // Listen to auth state changes
59
+ const listener = await CapacitorAuthManager.addAuthStateListener((user) => {
60
+ console.log('Auth state changed:', user);
61
+ });
62
+
63
+ // Sign out
64
+ await CapacitorAuthManager.signOut();
65
+ ```
66
+
67
+ ## Configuration
68
+
69
+ ### Platform-Specific Setup
70
+
71
+ #### iOS Setup
72
+
73
+ 1. Add required capabilities in Xcode:
74
+ - Sign in with Apple (if using Apple Auth)
75
+ - Keychain Sharing (for secure credential storage)
76
+
77
+ 2. Update your `Info.plist`:
78
+ ```xml
79
+ <!-- For Google Sign-In -->
80
+ <key>CFBundleURLTypes</key>
81
+ <array>
82
+ <dict>
83
+ <key>CFBundleURLSchemes</key>
84
+ <array>
85
+ <string>YOUR_REVERSED_CLIENT_ID</string>
86
+ </array>
87
+ </dict>
88
+ </array>
89
+
90
+ <!-- For Facebook Login -->
91
+ <key>FacebookAppID</key>
92
+ <string>YOUR_FACEBOOK_APP_ID</string>
93
+ <key>FacebookClientToken</key>
94
+ <string>YOUR_FACEBOOK_CLIENT_TOKEN</string>
95
+ <key>FacebookDisplayName</key>
96
+ <string>YOUR_APP_NAME</string>
97
+
98
+ <!-- For OAuth redirects -->
99
+ <key>LSApplicationQueriesSchemes</key>
100
+ <array>
101
+ <string>fbapi</string>
102
+ <string>fb-messenger-share-api</string>
103
+ <string>fbauth2</string>
104
+ <string>fbshareextension</string>
105
+ </array>
106
+ ```
107
+
108
+ #### Android Setup
109
+
110
+ 1. Add to your `android/app/build.gradle`:
111
+ ```gradle
112
+ android {
113
+ defaultConfig {
114
+ manifestPlaceholders = [
115
+ appAuthRedirectScheme: 'com.yourcompany.yourapp'
116
+ ]
117
+ }
118
+ }
119
+ ```
120
+
121
+ 2. Update your `AndroidManifest.xml`:
122
+ ```xml
123
+ <!-- For Google Sign-In -->
124
+ <meta-data
125
+ android:name="com.google.android.gms.auth.api.signin.GoogleSignInOptions"
126
+ android:value="@string/default_web_client_id" />
127
+
128
+ <!-- For Facebook Login -->
129
+ <meta-data
130
+ android:name="com.facebook.sdk.ApplicationId"
131
+ android:value="@string/facebook_app_id"/>
132
+ <meta-data
133
+ android:name="com.facebook.sdk.ClientToken"
134
+ android:value="@string/facebook_client_token"/>
135
+ ```
136
+
137
+ #### Web Setup
138
+
139
+ For web platform, make sure your redirect URIs are properly configured in each provider's console:
140
+
141
+ - **Google**: Add your domain to authorized JavaScript origins
142
+ - **Apple**: Configure your Service ID with proper domains and redirect URLs
143
+ - **Facebook**: Add your domain to valid OAuth redirect URIs
144
+ - **Microsoft**: Configure redirect URIs in Azure AD
145
+
146
+ ## Authentication Providers
147
+
148
+ ### Google Authentication
149
+
150
+ ```typescript
151
+ await CapacitorAuthManager.initialize({
152
+ providers: [{
153
+ provider: AuthProvider.GOOGLE,
154
+ options: {
155
+ clientId: 'YOUR_GOOGLE_CLIENT_ID',
156
+ scopes: ['email', 'profile'],
157
+ serverClientId: 'YOUR_SERVER_CLIENT_ID', // For Android
158
+ offlineAccess: true, // To get refresh token
159
+ hostedDomain: 'yourdomain.com', // Restrict to domain
160
+ forceCodeForRefreshToken: true
161
+ }
162
+ }]
163
+ });
164
+
165
+ const result = await CapacitorAuthManager.signIn({
166
+ provider: AuthProvider.GOOGLE,
167
+ options: {
168
+ loginHint: 'user@example.com', // Pre-fill email
169
+ prompt: 'select_account' // Force account selection
170
+ }
171
+ });
172
+ ```
173
+
174
+ ### Apple Authentication
175
+
176
+ ```typescript
177
+ await CapacitorAuthManager.initialize({
178
+ providers: [{
179
+ provider: AuthProvider.APPLE,
180
+ options: {
181
+ clientId: 'YOUR_SERVICE_ID',
182
+ redirectUri: 'https://yourapp.com/auth/callback',
183
+ scopes: [AppleAuthScope.EMAIL, AppleAuthScope.NAME],
184
+ usePopup: true,
185
+ state: 'YOUR_STATE', // Optional state parameter
186
+ nonce: 'YOUR_NONCE' // Optional nonce for security
187
+ }
188
+ }]
189
+ });
190
+
191
+ const result = await CapacitorAuthManager.signIn({
192
+ provider: AuthProvider.APPLE
193
+ });
194
+ ```
195
+
196
+ ### Microsoft Authentication
197
+
198
+ ```typescript
199
+ await CapacitorAuthManager.initialize({
200
+ providers: [{
201
+ provider: AuthProvider.MICROSOFT,
202
+ options: {
203
+ clientId: 'YOUR_AZURE_CLIENT_ID',
204
+ tenantId: 'YOUR_TENANT_ID', // or 'common' for multi-tenant
205
+ redirectUri: 'https://yourapp.com/auth/callback',
206
+ scopes: ['openid', 'profile', 'email'],
207
+ authority: 'https://login.microsoftonline.com/YOUR_TENANT_ID'
208
+ }
209
+ }]
210
+ });
211
+ ```
212
+
213
+ ### Firebase Authentication
214
+
215
+ ```typescript
216
+ await CapacitorAuthManager.initialize({
217
+ providers: [{
218
+ provider: AuthProvider.FIREBASE,
219
+ options: {
220
+ apiKey: 'YOUR_FIREBASE_API_KEY',
221
+ authDomain: 'your-app.firebaseapp.com',
222
+ projectId: 'your-project-id',
223
+ storageBucket: 'your-app.appspot.com',
224
+ messagingSenderId: 'YOUR_SENDER_ID',
225
+ appId: 'YOUR_APP_ID'
226
+ }
227
+ }]
228
+ });
229
+ ```
230
+
231
+ ### Email/Password Authentication
232
+
233
+ ```typescript
234
+ await CapacitorAuthManager.initialize({
235
+ providers: [{
236
+ provider: AuthProvider.EMAIL_PASSWORD,
237
+ options: {
238
+ strengthRequirements: {
239
+ minLength: 8,
240
+ requireUppercase: true,
241
+ requireNumbers: true,
242
+ requireSpecialCharacters: true
243
+ },
244
+ allowPasswordReset: true,
245
+ requireEmailVerification: true
246
+ }
247
+ }]
248
+ });
249
+
250
+ // Sign up
251
+ const result = await CapacitorAuthManager.signIn({
252
+ provider: AuthProvider.EMAIL_PASSWORD,
253
+ credentials: {
254
+ email: 'user@example.com',
255
+ password: 'SecurePassword123!'
256
+ }
257
+ });
258
+
259
+ // Password reset
260
+ await CapacitorAuthManager.sendPasswordResetEmail({
261
+ email: 'user@example.com'
262
+ });
263
+ ```
264
+
265
+ ### SMS Authentication
266
+
267
+ ```typescript
268
+ await CapacitorAuthManager.initialize({
269
+ providers: [{
270
+ provider: AuthProvider.SMS,
271
+ options: {
272
+ provider: 'twilio', // or 'firebase', 'custom'
273
+ twilioConfig: {
274
+ accountSid: 'YOUR_ACCOUNT_SID',
275
+ authToken: 'YOUR_AUTH_TOKEN',
276
+ fromNumber: '+1234567890'
277
+ },
278
+ codeLength: 6,
279
+ codeExpiration: 300000, // 5 minutes
280
+ maxAttempts: 3
281
+ }
282
+ }]
283
+ });
284
+
285
+ // Send SMS code
286
+ await CapacitorAuthManager.sendSmsCode({
287
+ phoneNumber: '+1234567890'
288
+ });
289
+
290
+ // Verify SMS code
291
+ const result = await CapacitorAuthManager.verifySmsCode({
292
+ phoneNumber: '+1234567890',
293
+ code: '123456'
294
+ });
295
+ ```
296
+
297
+ ### Biometric Authentication
298
+
299
+ Note: For biometric authentication, this plugin integrates with [capacitor-biometric-authentication](https://www.npmjs.com/package/capacitor-biometric-authentication).
300
+
301
+ ```typescript
302
+ await CapacitorAuthManager.initialize({
303
+ providers: [{
304
+ provider: AuthProvider.BIOMETRIC,
305
+ options: {
306
+ fallbackToPasscode: true,
307
+ title: 'Authenticate',
308
+ subtitle: 'Use your biometric to sign in',
309
+ description: 'Place your finger on the sensor',
310
+ negativeButtonText: 'Cancel',
311
+ maxAttempts: 3
312
+ }
313
+ }]
314
+ });
315
+
316
+ const result = await CapacitorAuthManager.signIn({
317
+ provider: AuthProvider.BIOMETRIC
318
+ });
319
+ ```
320
+
321
+ ## API Reference
322
+
323
+ ### Core Methods
324
+
325
+ #### initialize(options)
326
+ Initializes the auth manager with provider configurations.
327
+
328
+ ```typescript
329
+ interface AuthManagerInitOptions {
330
+ providers: AuthProviderConfig[];
331
+ persistence?: 'local' | 'session' | 'none';
332
+ autoRefreshToken?: boolean;
333
+ tokenRefreshBuffer?: number; // ms before token expiry
334
+ enableLogging?: boolean;
335
+ logLevel?: 'debug' | 'info' | 'warn' | 'error';
336
+ }
337
+ ```
338
+
339
+ #### signIn(options)
340
+ Signs in a user with the specified provider.
341
+
342
+ ```typescript
343
+ interface SignInOptions {
344
+ provider: AuthProvider;
345
+ credentials?: AuthCredentials;
346
+ options?: SignInProviderOptions;
347
+ }
348
+ ```
349
+
350
+ #### signOut(options?)
351
+ Signs out the current user or a specific provider.
352
+
353
+ ```typescript
354
+ interface SignOutOptions {
355
+ provider?: AuthProvider;
356
+ revokeToken?: boolean;
357
+ clearCache?: boolean;
358
+ redirectUrl?: string;
359
+ }
360
+ ```
361
+
362
+ #### getCurrentUser()
363
+ Returns the currently authenticated user.
364
+
365
+ ```typescript
366
+ const user = await CapacitorAuthManager.getCurrentUser();
367
+ ```
368
+
369
+ #### addAuthStateListener(callback)
370
+ Subscribes to authentication state changes.
371
+
372
+ ```typescript
373
+ const listener = await CapacitorAuthManager.addAuthStateListener((user) => {
374
+ if (user) {
375
+ console.log('User signed in:', user);
376
+ } else {
377
+ console.log('User signed out');
378
+ }
379
+ });
380
+
381
+ // Remove listener
382
+ await listener.remove();
383
+ ```
384
+
385
+ #### refreshToken(options?)
386
+ Manually refreshes the authentication token.
387
+
388
+ ```typescript
389
+ const result = await CapacitorAuthManager.refreshToken({
390
+ provider: AuthProvider.GOOGLE,
391
+ forceRefresh: true
392
+ });
393
+ ```
394
+
395
+ ### Account Management
396
+
397
+ #### linkAccount(options)
398
+ Links an additional authentication provider to the current user.
399
+
400
+ ```typescript
401
+ await CapacitorAuthManager.linkAccount({
402
+ provider: AuthProvider.GOOGLE
403
+ });
404
+ ```
405
+
406
+ #### unlinkAccount(options)
407
+ Unlinks an authentication provider from the current user.
408
+
409
+ ```typescript
410
+ await CapacitorAuthManager.unlinkAccount({
411
+ provider: AuthProvider.GOOGLE
412
+ });
413
+ ```
414
+
415
+ #### updateProfile(options)
416
+ Updates the user's profile information.
417
+
418
+ ```typescript
419
+ await CapacitorAuthManager.updateProfile({
420
+ displayName: 'John Doe',
421
+ photoURL: 'https://example.com/photo.jpg'
422
+ });
423
+ ```
424
+
425
+ #### deleteAccount(options?)
426
+ Deletes the current user's account.
427
+
428
+ ```typescript
429
+ await CapacitorAuthManager.deleteAccount({
430
+ requireReauthentication: true
431
+ });
432
+ ```
433
+
434
+ ### Utility Methods
435
+
436
+ #### isSupported(options)
437
+ Checks if a provider is supported on the current platform.
438
+
439
+ ```typescript
440
+ const result = await CapacitorAuthManager.isSupported({
441
+ provider: AuthProvider.APPLE
442
+ });
443
+
444
+ if (result.isSupported) {
445
+ // Provider is available
446
+ }
447
+ ```
448
+
449
+ #### getIdToken(options?)
450
+ Gets the current ID token for the authenticated user.
451
+
452
+ ```typescript
453
+ const token = await CapacitorAuthManager.getIdToken({
454
+ forceRefresh: true
455
+ });
456
+ ```
457
+
458
+ ## Error Handling
459
+
460
+ The plugin provides detailed error codes for different scenarios:
461
+
462
+ ```typescript
463
+ try {
464
+ await CapacitorAuthManager.signIn({
465
+ provider: AuthProvider.GOOGLE
466
+ });
467
+ } catch (error) {
468
+ switch (error.code) {
469
+ case 'auth/user-cancelled':
470
+ // User cancelled the sign-in flow
471
+ break;
472
+ case 'auth/network-error':
473
+ // Network error occurred
474
+ break;
475
+ case 'auth/invalid-credentials':
476
+ // Invalid credentials provided
477
+ break;
478
+ case 'auth/popup-blocked':
479
+ // Popup was blocked by browser
480
+ break;
481
+ default:
482
+ // Other error
483
+ console.error('Auth error:', error);
484
+ }
485
+ }
486
+ ```
487
+
488
+ ## Security Considerations
489
+
490
+ 1. **Client IDs and Secrets**: Never expose client secrets in your client-side code
491
+ 2. **Token Storage**: Tokens are securely stored using platform-specific secure storage
492
+ 3. **HTTPS Required**: Always use HTTPS in production for web implementations
493
+ 4. **Validate Tokens**: Always validate tokens on your backend before trusting them
494
+ 5. **Biometric Security**: Biometric data never leaves the device
495
+
496
+ ## Migration Guide
497
+
498
+ If you're migrating from other authentication solutions:
499
+
500
+ ### From Firebase Auth
501
+
502
+ ```typescript
503
+ // Before (Firebase Auth)
504
+ import { getAuth, signInWithPopup, GoogleAuthProvider } from 'firebase/auth';
505
+ const auth = getAuth();
506
+ const provider = new GoogleAuthProvider();
507
+ const result = await signInWithPopup(auth, provider);
508
+
509
+ // After (Capacitor Auth Manager)
510
+ import { CapacitorAuthManager, AuthProvider } from 'capacitor-auth-manager';
511
+ const result = await CapacitorAuthManager.signIn({
512
+ provider: AuthProvider.GOOGLE
513
+ });
514
+ ```
515
+
516
+ ### From Capacitor Google Auth
517
+
518
+ ```typescript
519
+ // Before
520
+ import { GoogleAuth } from '@codetrix-studio/capacitor-google-auth';
521
+ await GoogleAuth.initialize();
522
+ const user = await GoogleAuth.signIn();
523
+
524
+ // After
525
+ import { CapacitorAuthManager, AuthProvider } from 'capacitor-auth-manager';
526
+ await CapacitorAuthManager.initialize({
527
+ providers: [{
528
+ provider: AuthProvider.GOOGLE,
529
+ options: { clientId: 'YOUR_CLIENT_ID' }
530
+ }]
531
+ });
532
+ const result = await CapacitorAuthManager.signIn({
533
+ provider: AuthProvider.GOOGLE
534
+ });
535
+ ```
536
+
537
+ ## 📚 Documentation
538
+
539
+ For comprehensive documentation, examples, and guides, visit our [Documentation](./docs/README.md):
540
+
541
+ ### 🚀 Getting Started
542
+ - [Installation Guide](./docs/getting-started/installation.md) - Step-by-step setup instructions
543
+ - [Quick Start](./docs/getting-started/quick-start.md) - Get up and running in minutes
544
+ - [Platform Setup](./docs/getting-started/platform-setup.md) - Platform-specific configuration
545
+
546
+ ### 🔧 API Reference
547
+ - [Core API](./docs/api-reference/core-api.md) - Complete method reference
548
+ - [Authentication State](./docs/api-reference/auth-state.md) - Understanding auth state
549
+ - [Error Handling](./docs/api-reference/error-handling.md) - Handle errors gracefully
550
+
551
+ ### 🏢 Provider Guides
552
+ - [Google Auth](./docs/providers/google.md) - Google Sign-In implementation
553
+ - [Apple Auth](./docs/providers/apple.md) - Sign in with Apple
554
+ - [Facebook Auth](./docs/providers/facebook.md) - Facebook Login
555
+ - [Microsoft Auth](./docs/providers/microsoft.md) - Microsoft identity platform
556
+ - [GitHub Auth](./docs/providers/github.md) - GitHub OAuth
557
+ - [Firebase Auth](./docs/providers/firebase.md) - Firebase Authentication
558
+ - [More providers...](./docs/providers/) - All 13+ supported providers
559
+
560
+ ### 💡 Framework Examples
561
+ - [React Integration](./docs/examples/react.md) - Complete React implementation
562
+ - [Angular Example](./docs/examples/angular.md) - Angular integration
563
+ - [Vue Example](./docs/examples/vue.md) - Vue.js implementation
564
+ - [Ionic Example](./docs/examples/ionic.md) - Ionic Framework integration
565
+
566
+ ### 📖 Advanced Guides
567
+ - [Best Practices](./docs/guides/best-practices.md) - Authentication best practices
568
+ - [Security Guide](./docs/guides/security.md) - Security considerations
569
+ - [Token Management](./docs/guides/token-management.md) - Handling tokens
570
+ - [Multi-Factor Auth](./docs/guides/mfa.md) - Implementing MFA
571
+
572
+ ## Contributing
573
+
574
+ Contributions are welcome! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
575
+
576
+ ## License
577
+
578
+ MIT
579
+
580
+ ## Support
581
+
582
+ - 📧 Email: aoneahsan@gmail.com
583
+ - 🐛 Issues: [GitHub Issues](https://github.com/aoneahsan/capacitor-auth-manager/issues)
584
+ - 💬 Discussions: [GitHub Discussions](https://github.com/aoneahsan/capacitor-auth-manager/discussions)
585
+
586
+ ## Credits
587
+
588
+ Created by [Ahsan Mahmood](https://aoneahsan.com) - Open source for the community