@umituz/react-native-auth 4.3.12 → 4.3.14
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.
|
|
3
|
+
"version": "4.3.14",
|
|
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",
|
|
@@ -13,11 +13,11 @@ export interface StorageLike {
|
|
|
13
13
|
getString?: (
|
|
14
14
|
key: string,
|
|
15
15
|
defaultValue?: string | null
|
|
16
|
-
) => Promise<{ value
|
|
17
|
-
getItem?: (key: string) => Promise<string | null>;
|
|
18
|
-
setString?: (key: string, value: string) => Promise<
|
|
19
|
-
setItem?: (key: string, value:
|
|
20
|
-
removeItem?: (key: string) => Promise<
|
|
16
|
+
) => Promise<{ value?: string | null; data?: string | null; success?: boolean } | null>;
|
|
17
|
+
getItem?: (key: string, defaultValue?: unknown) => Promise<string | { data?: unknown; success?: boolean } | null>;
|
|
18
|
+
setString?: (key: string, value: string) => Promise<unknown>;
|
|
19
|
+
setItem?: (key: string, value: unknown) => Promise<unknown>;
|
|
20
|
+
removeItem?: (key: string) => Promise<unknown>;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
export class StorageProviderAdapter implements IStorageProvider {
|
|
@@ -31,9 +31,14 @@ export class StorageProviderAdapter implements IStorageProvider {
|
|
|
31
31
|
try {
|
|
32
32
|
if (typeof this.storage.getString === "function") {
|
|
33
33
|
const result = await this.storage.getString(key, null);
|
|
34
|
-
|
|
34
|
+
if (!result) return null;
|
|
35
|
+
return result.value ?? result.data ?? null;
|
|
35
36
|
} else if (typeof this.storage.getItem === "function") {
|
|
36
|
-
|
|
37
|
+
const result = await this.storage.getItem(key);
|
|
38
|
+
if (!result) return null;
|
|
39
|
+
if (typeof result === "string") return result;
|
|
40
|
+
if (result.data != null) return String(result.data);
|
|
41
|
+
return null;
|
|
37
42
|
} else {
|
|
38
43
|
throw new Error("Unsupported storage implementation");
|
|
39
44
|
}
|