@umituz/react-native-auth 3.4.5 → 3.4.7
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.4.
|
|
3
|
+
"version": "3.4.7",
|
|
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",
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* User Data Migration Utilities
|
|
3
|
+
* Handles migrating data when anonymous user converts to authenticated user
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export interface MigrationConfig {
|
|
7
|
+
onMigrationStart?: (anonymousId: string, authId: string) => void;
|
|
8
|
+
onMigrationComplete?: (anonymousId: string, authId: string) => void;
|
|
9
|
+
onMigrationError?: (error: Error) => void;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
let migrationConfig: MigrationConfig = {};
|
|
13
|
+
|
|
14
|
+
export const configureMigration = (config: MigrationConfig): void => {
|
|
15
|
+
migrationConfig = config;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const migrateUserData = async (
|
|
19
|
+
anonymousId: string,
|
|
20
|
+
authId: string
|
|
21
|
+
): Promise<void> => {
|
|
22
|
+
if (__DEV__) {
|
|
23
|
+
console.log(`[Migration] Starting migration from ${anonymousId} to ${authId}`);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
try {
|
|
27
|
+
migrationConfig.onMigrationStart?.(anonymousId, authId);
|
|
28
|
+
|
|
29
|
+
// App-specific migration logic handled via callbacks
|
|
30
|
+
// This keeps the package generic and flexible
|
|
31
|
+
|
|
32
|
+
migrationConfig.onMigrationComplete?.(anonymousId, authId);
|
|
33
|
+
|
|
34
|
+
if (__DEV__) {
|
|
35
|
+
console.log(`[Migration] Successfully migrated data for ${authId}`);
|
|
36
|
+
}
|
|
37
|
+
} catch (error) {
|
|
38
|
+
if (__DEV__) {
|
|
39
|
+
console.error(`[Migration] Failed to migrate user data:`, error);
|
|
40
|
+
}
|
|
41
|
+
migrationConfig.onMigrationError?.(error as Error);
|
|
42
|
+
// Silent fail - don't block auth flow
|
|
43
|
+
}
|
|
44
|
+
};
|
package/src/index.ts
CHANGED
|
@@ -171,6 +171,10 @@ export type { UserProfile, UpdateProfileParams } from './domain/entities/UserPro
|
|
|
171
171
|
export { generateAnonymousName, getAnonymousDisplayName } from './domain/utils/anonymousNameGenerator';
|
|
172
172
|
export type { AnonymousNameConfig } from './domain/utils/anonymousNameGenerator';
|
|
173
173
|
|
|
174
|
+
// Domain Utils - Migration
|
|
175
|
+
export { migrateUserData, configureMigration } from './domain/utils/migration';
|
|
176
|
+
export type { MigrationConfig } from './domain/utils/migration';
|
|
177
|
+
|
|
174
178
|
// =============================================================================
|
|
175
179
|
// PRESENTATION LAYER - Screens & Navigation
|
|
176
180
|
// =============================================================================
|