@umituz/react-native-auth 3.0.0 → 3.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umituz/react-native-auth",
3
- "version": "3.0.0",
3
+ "version": "3.1.0",
4
4
  "description": "Authentication service for React Native apps - Secure, type-safe, and production-ready. Provider-agnostic design with dependency injection, configurable validation, and comprehensive error handling.",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -70,11 +70,11 @@
70
70
  "@typescript-eslint/parser": "^7.0.0",
71
71
  "@umituz/react-native-design-system": "^2.3.31",
72
72
  "@umituz/react-native-design-system-theme": "^1.12.3",
73
- "@umituz/react-native-firebase": "*",
73
+ "@umituz/react-native-firebase": "^1.13.23",
74
74
  "@umituz/react-native-haptics": "^1.0.2",
75
75
  "@umituz/react-native-localization": "*",
76
76
  "@umituz/react-native-sentry": "*",
77
- "@umituz/react-native-storage": "*",
77
+ "@umituz/react-native-storage": "^2.6.0",
78
78
  "@umituz/react-native-tanstack": "*",
79
79
  "@umituz/react-native-uuid": "^1.2.1",
80
80
  "@umituz/react-native-validation": "*",
@@ -107,4 +107,4 @@
107
107
  "README.md",
108
108
  "LICENSE"
109
109
  ]
110
- }
110
+ }
@@ -3,6 +3,8 @@
3
3
  * Provider-agnostic user representation
4
4
  */
5
5
 
6
+ export type AuthProviderType = "google.com" | "apple.com" | "password" | "anonymous" | "unknown";
7
+
6
8
  export interface AuthUser {
7
9
  uid: string;
8
10
  email: string | null;
@@ -10,4 +12,5 @@ export interface AuthUser {
10
12
  isAnonymous: boolean;
11
13
  emailVerified: boolean;
12
14
  photoURL: string | null;
15
+ provider: AuthProviderType;
13
16
  }
package/src/index.ts CHANGED
@@ -20,7 +20,7 @@
20
20
  // DOMAIN LAYER - Entities
21
21
  // =============================================================================
22
22
 
23
- export type { AuthUser } from './domain/entities/AuthUser';
23
+ export type { AuthUser, AuthProviderType } from './domain/entities/AuthUser';
24
24
 
25
25
  // =============================================================================
26
26
  // DOMAIN LAYER - Errors
@@ -3,7 +3,11 @@
3
3
  * Single Source of Truth for user object transformations
4
4
  */
5
5
 
6
- import type { AuthUser } from "../../domain/entities/AuthUser";
6
+ import type { AuthUser, AuthProviderType } from "../../domain/entities/AuthUser";
7
+
8
+ interface ProviderData {
9
+ providerId: string;
10
+ }
7
11
 
8
12
  interface FirebaseUserLike {
9
13
  uid: string;
@@ -12,6 +16,32 @@ interface FirebaseUserLike {
12
16
  isAnonymous: boolean;
13
17
  emailVerified: boolean;
14
18
  photoURL: string | null;
19
+ providerData?: ProviderData[];
20
+ }
21
+
22
+ /**
23
+ * Extract auth provider from Firebase user's providerData
24
+ */
25
+ function extractProvider(user: FirebaseUserLike): AuthProviderType {
26
+ if (user.isAnonymous) {
27
+ return "anonymous";
28
+ }
29
+
30
+ const providerData = user.providerData;
31
+ if (!providerData || providerData.length === 0) {
32
+ return "unknown";
33
+ }
34
+
35
+ const googleProvider = providerData.find((p) => p.providerId === "google.com");
36
+ if (googleProvider) return "google.com";
37
+
38
+ const appleProvider = providerData.find((p) => p.providerId === "apple.com");
39
+ if (appleProvider) return "apple.com";
40
+
41
+ const passwordProvider = providerData.find((p) => p.providerId === "password");
42
+ if (passwordProvider) return "password";
43
+
44
+ return "unknown";
15
45
  }
16
46
 
17
47
  export function mapToAuthUser(user: FirebaseUserLike | null): AuthUser | null {
@@ -23,5 +53,6 @@ export function mapToAuthUser(user: FirebaseUserLike | null): AuthUser | null {
23
53
  isAnonymous: user.isAnonymous,
24
54
  emailVerified: user.emailVerified,
25
55
  photoURL: user.photoURL,
56
+ provider: extractProvider(user),
26
57
  };
27
58
  }