@oxyhq/services
Version:
Reusable OxyHQ module to handle authentication, user management, karma system, device-based session management and more 🚀
42 lines • 1.76 kB
TypeScript
import React, { ReactNode } from 'react';
import { OxyServices } from '../../core';
import { User } from '../../models/interfaces';
import { SecureClientSession, MinimalUserData } from '../../models/secureSession';
export interface OxyContextState {
user: User | null;
minimalUser: MinimalUserData | null;
sessions: SecureClientSession[];
activeSessionId: string | null;
isAuthenticated: boolean;
isLoading: boolean;
error: string | null;
login: (username: string, password: string, deviceName?: string) => Promise<User>;
logout: (targetSessionId?: string) => Promise<void>;
logoutAll: () => Promise<void>;
signUp: (username: string, email: string, password: string) => Promise<User>;
switchSession: (sessionId: string) => Promise<void>;
removeSession: (sessionId: string) => Promise<void>;
refreshSessions: () => Promise<void>;
getDeviceSessions: () => Promise<any[]>;
logoutAllDeviceSessions: () => Promise<void>;
updateDeviceName: (deviceName: string) => Promise<void>;
oxyServices: OxyServices;
bottomSheetRef?: React.RefObject<any>;
showBottomSheet?: (screenOrConfig?: string | {
screen: string;
props?: Record<string, any>;
}) => void;
hideBottomSheet?: () => void;
}
declare const OxyContext: React.Context<OxyContextState | null>;
export interface OxyContextProviderProps {
children: ReactNode;
oxyServices: OxyServices;
storageKeyPrefix?: string;
onAuthStateChange?: (user: User | null) => void;
bottomSheetRef?: React.RefObject<any>;
}
export declare const OxyContextProvider: React.FC<OxyContextProviderProps>;
export declare const useOxy: () => OxyContextState;
export default OxyContext;
//# sourceMappingURL=OxyContext.d.ts.map