UNPKG

5 kBTypeScriptView Raw
1import type { Plugin } from './definitions';
2import { WebPlugin } from './web-plugin';
3/******** WEB VIEW PLUGIN ********/
4export interface WebViewPlugin extends Plugin {
5 setServerBasePath(options: WebViewPath): Promise<void>;
6 getServerBasePath(): Promise<WebViewPath>;
7 persistServerBasePath(): Promise<void>;
8}
9export interface WebViewPath {
10 path: string;
11}
12export declare const WebView: WebViewPlugin;
13export interface CapacitorCookiesPlugin {
14 setCookie(options: SetCookieOptions): Promise<void>;
15 deleteCookie(options: DeleteCookieOptions): Promise<void>;
16 clearCookies(options: ClearCookieOptions): Promise<void>;
17 clearAllCookies(): Promise<void>;
18}
19interface HttpCookie {
20 url?: string;
21 key: string;
22 value: string;
23}
24interface HttpCookieExtras {
25 path?: string;
26 expires?: string;
27}
28export declare type SetCookieOptions = HttpCookie & HttpCookieExtras;
29export declare type DeleteCookieOptions = Omit<HttpCookie, 'value'>;
30export declare type ClearCookieOptions = Omit<HttpCookie, 'key' | 'value'>;
31export declare class CapacitorCookiesPluginWeb extends WebPlugin implements CapacitorCookiesPlugin {
32 setCookie(options: SetCookieOptions): Promise<void>;
33 deleteCookie(options: DeleteCookieOptions): Promise<void>;
34 clearCookies(): Promise<void>;
35 clearAllCookies(): Promise<void>;
36}
37export declare const CapacitorCookies: CapacitorCookiesPlugin;
38/******** END COOKIES PLUGIN ********/
39/******** HTTP PLUGIN ********/
40export interface CapacitorHttpPlugin {
41 request(options: HttpOptions): Promise<HttpResponse>;
42 get(options: HttpOptions): Promise<HttpResponse>;
43 post(options: HttpOptions): Promise<HttpResponse>;
44 put(options: HttpOptions): Promise<HttpResponse>;
45 patch(options: HttpOptions): Promise<HttpResponse>;
46 delete(options: HttpOptions): Promise<HttpResponse>;
47}
48export declare type HttpResponseType = 'arraybuffer' | 'blob' | 'json' | 'text' | 'document';
49export interface HttpOptions {
50 url: string;
51 method?: string;
52 params?: HttpParams;
53 data?: any;
54 headers?: HttpHeaders;
55 /**
56 * How long to wait to read additional data. Resets each time new
57 * data is received
58 */
59 readTimeout?: number;
60 /**
61 * How long to wait for the initial connection.
62 */
63 connectTimeout?: number;
64 /**
65 * Sets whether automatic HTTP redirects should be disabled
66 */
67 disableRedirects?: boolean;
68 /**
69 * Extra arguments for fetch when running on the web
70 */
71 webFetchExtra?: RequestInit;
72 /**
73 * This is used to parse the response appropriately before returning it to
74 * the requestee. If the response content-type is "json", this value is ignored.
75 */
76 responseType?: HttpResponseType;
77 /**
78 * Use this option if you need to keep the URL unencoded in certain cases
79 * (already encoded, azure/firebase testing, etc.). The default is _true_.
80 */
81 shouldEncodeUrlParams?: boolean;
82}
83export interface HttpParams {
84 [key: string]: string | string[];
85}
86export interface HttpHeaders {
87 [key: string]: string;
88}
89export interface HttpResponse {
90 data: any;
91 status: number;
92 headers: HttpHeaders;
93 url: string;
94}
95/**
96 * Read in a Blob value and return it as a base64 string
97 * @param blob The blob value to convert to a base64 string
98 */
99export declare const readBlobAsBase64: (blob: Blob) => Promise<string>;
100/**
101 * Build the RequestInit object based on the options passed into the initial request
102 * @param options The Http plugin options
103 * @param extra Any extra RequestInit values
104 */
105export declare const buildRequestInit: (options: HttpOptions, extra?: RequestInit) => RequestInit;
106export declare class CapacitorHttpPluginWeb extends WebPlugin implements CapacitorHttpPlugin {
107 /**
108 * Perform an Http request given a set of options
109 * @param options Options to build the HTTP request
110 */
111 request(options: HttpOptions): Promise<HttpResponse>;
112 /**
113 * Perform an Http GET request given a set of options
114 * @param options Options to build the HTTP request
115 */
116 get(options: HttpOptions): Promise<HttpResponse>;
117 /**
118 * Perform an Http POST request given a set of options
119 * @param options Options to build the HTTP request
120 */
121 post(options: HttpOptions): Promise<HttpResponse>;
122 /**
123 * Perform an Http PUT request given a set of options
124 * @param options Options to build the HTTP request
125 */
126 put(options: HttpOptions): Promise<HttpResponse>;
127 /**
128 * Perform an Http PATCH request given a set of options
129 * @param options Options to build the HTTP request
130 */
131 patch(options: HttpOptions): Promise<HttpResponse>;
132 /**
133 * Perform an Http DELETE request given a set of options
134 * @param options Options to build the HTTP request
135 */
136 delete(options: HttpOptions): Promise<HttpResponse>;
137}
138export declare const CapacitorHttp: CapacitorHttpPlugin;
139export {};
140/******** END HTTP PLUGIN ********/