1 | import { ISPFXContext } from "./spfxcontextinterface.js";
|
2 | export interface IConfigOptions {
|
3 | headers?: string[][] | {
|
4 | [key: string]: string;
|
5 | } | Headers;
|
6 | mode?: "navigate" | "same-origin" | "no-cors" | "cors";
|
7 | credentials?: "omit" | "same-origin" | "include";
|
8 | cache?: "default" | "no-store" | "reload" | "no-cache" | "force-cache" | "only-if-cached";
|
9 | }
|
10 | export interface IFetchOptions extends IConfigOptions {
|
11 | method?: string;
|
12 | body?: any;
|
13 | }
|
14 | export interface IHttpClientImpl {
|
15 | fetch(url: string, options: IFetchOptions): Promise<Response>;
|
16 | }
|
17 | export interface IRequestClient {
|
18 | fetch(url: string, options?: IFetchOptions): Promise<Response>;
|
19 | fetchRaw(url: string, options?: IFetchOptions): Promise<Response>;
|
20 | get(url: string, options?: IFetchOptions): Promise<Response>;
|
21 | post(url: string, options?: IFetchOptions): Promise<Response>;
|
22 | patch(url: string, options?: IFetchOptions): Promise<Response>;
|
23 | delete(url: string, options?: IFetchOptions): Promise<Response>;
|
24 | }
|
25 | export declare function mergeHeaders(target: Headers, source: HeadersInit): void;
|
26 | export declare function mergeOptions(target: IConfigOptions, source: IConfigOptions): void;
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 | export declare function getADALResource(url: string): string;
|
33 |
|
34 |
|
35 |
|
36 | export declare class FetchClient implements IHttpClientImpl {
|
37 | fetch(url: string, options: IFetchOptions): Promise<Response>;
|
38 | }
|
39 |
|
40 |
|
41 |
|
42 | export declare class BearerTokenFetchClient extends FetchClient {
|
43 | token: string | null;
|
44 | constructor(token: string | null);
|
45 | fetch(url: string, options?: IFetchOptions): Promise<Response>;
|
46 | }
|
47 | export interface ILambdaTokenFactoryParams {
|
48 | |
49 |
|
50 |
|
51 | url: string;
|
52 | |
53 |
|
54 |
|
55 | options: IFetchOptions;
|
56 | }
|
57 | export declare class LambdaFetchClient extends BearerTokenFetchClient {
|
58 | private tokenFactory;
|
59 | constructor(tokenFactory: (parms: ILambdaTokenFactoryParams) => Promise<string>);
|
60 | /**
|
61 | * Executes a fetch request using the supplied url and options
|
62 | *
|
63 | * @param url Absolute url of the request
|
64 | * @param options Any options
|
65 | */
|
66 | fetch(url: string, options: IFetchOptions): Promise<Response>;
|
67 | }
|
68 | /**
|
69 | * Client wrapping the aadTokenProvider available from SPFx >= 1.6
|
70 | */
|
71 | export declare class SPFxAdalClient extends LambdaFetchClient {
|
72 | private context;
|
73 | |
74 |
|
75 |
|
76 |
|
77 | constructor(context: ISPFXContext);
|
78 | /**
|
79 | * Gets an AAD token for the provided resource using the SPFx AADTokenProvider
|
80 | *
|
81 | * @param resource Resource for which a token is to be requested (ex: https:
|
82 | */
|
83 | getToken(resource: string): Promise<string>;
|
84 | }
|
85 |
|
\ | No newline at end of file |