2024-04-30 14:56:19 +01:00

18 lines
710 B
TypeScript

import ApiWebClient from './ApiWebClient';
import ApiNativeClient from './ApiNativeClient';
export interface Auth {
tokenSHA256: string;
keys?: { pubKey: string; encPrivKey: string };
}
export interface ApiClient {
post: (baseUrl: string, path: string, body: object, auth?: Auth) => Promise<object | undefined>;
put: (baseUrl: string, path: string, body: object, auth?: Auth) => Promise<object | undefined>;
get: (baseUrl: string, path: string, auth?: Auth) => Promise<object | undefined>;
delete: (baseUrl: string, path: string, auth?: Auth) => Promise<object | undefined>;
}
export const apiClient: ApiClient =
window.ReactNativeWebView != null ? new ApiNativeClient() : new ApiWebClient();