📦 deps(thirdparty): update snapshots
This commit is contained in:
@@ -74,7 +74,7 @@ const config: CapacitorConfig = {
|
||||
|
||||
```typescript
|
||||
import { Camera, CameraResultType } from '@capacitor/camera';
|
||||
import { Preferences } from '@capacitor/preferences';
|
||||
import { SecureStorage } from '@aparajita/capacitor-secure-storage';
|
||||
import { PushNotifications } from '@capacitor/push-notifications';
|
||||
import { Geolocation } from '@capacitor/geolocation';
|
||||
|
||||
@@ -107,8 +107,8 @@ const initPush = async () => {
|
||||
if (permission.receive === 'granted') {
|
||||
await PushNotifications.register();
|
||||
}
|
||||
PushNotifications.addListener('registration', ({ value: token }) => {
|
||||
console.log('FCM Token:', token);
|
||||
PushNotifications.addListener('registration', () => {
|
||||
console.log('Push registration succeeded');
|
||||
});
|
||||
};
|
||||
```
|
||||
|
||||
@@ -67,24 +67,27 @@ export const RootNavigator = () => {
|
||||
// Store secrets with a platform-backed module such as react-native-keychain
|
||||
// or expo-secure-store, and persist only non-sensitive UI state here.
|
||||
interface AuthState {
|
||||
token: string | null;
|
||||
isLoggedIn: boolean;
|
||||
setToken: (token: string) => void;
|
||||
setLoggedIn: (value: boolean) => void;
|
||||
logout: () => void;
|
||||
}
|
||||
|
||||
export const useAuthStore = create<AuthState>()(
|
||||
persist(
|
||||
(set) => ({
|
||||
token: null,
|
||||
isLoggedIn: false,
|
||||
setToken: (token) => set({ token, isLoggedIn: true }),
|
||||
logout: () => set({ token: null, isLoggedIn: false }),
|
||||
setLoggedIn: (value) => set({ isLoggedIn: value }),
|
||||
logout: () => set({ isLoggedIn: false }),
|
||||
}),
|
||||
{ name: 'auth-ui-storage', storage: createJSONStorage(() => mmkvStorage) }
|
||||
)
|
||||
);
|
||||
|
||||
// Keep tokens outside persisted app state.
|
||||
const getSecureToken = () => Keychain.getGenericPassword().then((r) => (r ? r.password : null));
|
||||
const saveSecureToken = (token: string) => Keychain.setGenericPassword('auth', token);
|
||||
const clearSecureToken = () => Keychain.resetGenericPassword();
|
||||
|
||||
// Server state — React Query
|
||||
export const useItems = () =>
|
||||
useQuery({
|
||||
@@ -142,8 +145,8 @@ const apiClient = axios.create({
|
||||
});
|
||||
|
||||
// Auth token injection
|
||||
apiClient.interceptors.request.use((config) => {
|
||||
const token = useAuthStore.getState().token;
|
||||
apiClient.interceptors.request.use(async (config) => {
|
||||
const token = await getSecureToken();
|
||||
if (token) config.headers.Authorization = `Bearer ${token}`;
|
||||
return config;
|
||||
});
|
||||
@@ -155,9 +158,11 @@ apiClient.interceptors.response.use(
|
||||
if (error.response?.status === 401) {
|
||||
const newToken = await refreshToken();
|
||||
if (newToken) {
|
||||
useAuthStore.getState().setToken(newToken);
|
||||
await saveSecureToken(newToken);
|
||||
useAuthStore.getState().setLoggedIn(true);
|
||||
return apiClient(error.config!);
|
||||
}
|
||||
await clearSecureToken();
|
||||
useAuthStore.getState().logout();
|
||||
}
|
||||
return Promise.reject(error);
|
||||
@@ -196,6 +201,7 @@ const getItems = async (): Promise<Item[]> => {
|
||||
"zustand": "^4.5.4",
|
||||
"axios": "^1.7.2",
|
||||
"zod": "^3.23.8",
|
||||
"react-native-keychain": "^8.2.0",
|
||||
"react-native-mmkv": "^2.12.2",
|
||||
"react-native-safe-area-context": "^4.10.1",
|
||||
"react-native-screens": "^3.32.0"
|
||||
|
||||
Reference in New Issue
Block a user