@umituz/react-native-auth 4.3.20 → 4.3.22

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": "4.3.20",
3
+ "version": "4.3.22",
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",
@@ -27,9 +27,9 @@ export class AnonymousModeService {
27
27
  }
28
28
  }
29
29
 
30
- private async save(storageProvider: IStorageProvider): Promise<boolean> {
30
+ private async save(storageProvider: IStorageProvider, value: boolean): Promise<boolean> {
31
31
  try {
32
- await storageProvider.set(this.storageKey, this.isAnonymousMode.toString());
32
+ await storageProvider.set(this.storageKey, value.toString());
33
33
  return true;
34
34
  } catch {
35
35
  return false;
@@ -49,17 +49,15 @@ export class AnonymousModeService {
49
49
  }
50
50
 
51
51
  async enable(storageProvider: IStorageProvider): Promise<void> {
52
- // Save to storage first, then update memory to maintain consistency
53
- const previousState = this.isAnonymousMode;
54
- this.isAnonymousMode = true;
55
- const saveSuccess = await this.save(storageProvider);
52
+ // Save to storage first, then update memory to maintain consistency.
53
+ // This prevents TOCTOU: memory is never set to true unless storage confirms the write.
54
+ const saveSuccess = await this.save(storageProvider, true);
56
55
 
57
56
  if (!saveSuccess) {
58
- // Rollback on failure
59
- this.isAnonymousMode = previousState;
60
57
  throw new Error('Failed to save anonymous mode state');
61
58
  }
62
59
 
60
+ this.isAnonymousMode = true;
63
61
  emitAnonymousModeEnabled();
64
62
  }
65
63