import { HttpHeaders, HttpParams } from '@angular/common/http'; import { InjectionToken } from '@angular/core'; import { Observable } from 'rxjs'; import { Region, Version } from './region.provider'; /** * Client Configuration * ============================================================================= * Users inject either a static or observable configuration which is then * handled internally as an observable anyhow. */ export interface Client { name: string; version: string; } export interface Tokens { account?: string; organisation?: string; team?: string; } export interface Config { client: Client; region: Region; tokens: Tokens; version?: Version; } /** * Client Tokens * ============================================================================= */ export declare const CLIENT_NAME = "D4H API CLIENT"; export declare const CLIENT_VERSION = "8.1.3"; export declare const CLIENT_CONFIG: InjectionToken>; export declare const CLIENT_DEFAULT_CONFIG: InjectionToken>; export declare const defaultConfig: Partial; /** * Client HttpClient Parameters * ============================================================================= * Taken from Angular HttpClient and wrapped up here for niceness. The idea is * that the client transparently extends the necessary interfaces of Angular's * HttpClient. * * @see https://angular.io/api/common/http/HttpClient */ export declare type Params = HttpParams | { [param: string]: string | Array; }; export declare type Headers = HttpHeaders | { [header: string]: string | Array; }; export interface HttpOptions { body?: any; headers?: Headers; observe?: 'body'; params?: Params; reportProgress?: boolean; responseType?: 'json'; withCredentials?: boolean; } /** * Client Requests and Sigining * ============================================================================= * Parse API requests to D4H. Various things have to be set: * * 1. Full resolved URL based on injected configuration. * 2. Authentication (bearer token) for authenticated routes. * 3. Assignation of other headers, such as client identication. * 4. Sanitization/handling of parameters. * * These are injected via the module to allow freedom of development later, and * to eventually open up wider configuration to developers. */ export interface ClientRequestParser { options(config: Config, url: string, options?: HttpOptions): HttpOptions; url(config: Config, url: string): string; } export interface ClientRequestAuth { bearerToken(tokens: Tokens, url: string, options: HttpOptions): { Authorization: string; }; }