@poppinss/oauth-client
Version:
A framework agnostic package to implement "Login with" flow using OAuth compliant authorization servers.
86 lines (85 loc) • 1.97 kB
TypeScript
import type { ApiRequestContract } from './types.js';
/**
* An HTTP client abstraction we need for making OAuth requests
*/
export declare class HttpClient implements ApiRequestContract {
#private;
constructor(baseUrl: string);
/**
* Get access to request query params
*/
getParams(): Record<string, any>;
/**
* Get access to request headers
*/
getHeaders(): Record<string, any>;
/**
* Get access to request body fields
*/
getFields(): Record<string, any>;
/**
* Get access to request oAuth1 params
*/
getOauth1Params(): Record<string, any>;
/**
* Get the request type
*/
getRequestType(): "json" | "urlencoded";
/**
* Get the type of the desired response type
*/
getResponseType(): "json" | "text";
/**
* Define query string param
*/
param(key: string, value: any): this;
/**
* Remove a named param
*/
clearParam(key: string): this;
/**
* Define an oauth1 param that makes it way to the Authorization
* header
*/
oauth1Param(key: string, value: any): this;
/**
* Remove a named oauth1Param
*/
clearOauth1Param(key: string): this;
/**
* Define request body
*/
field(key: string, value: any): this;
/**
* Remove a field by its name
*/
clearField(key: string): this;
/**
* Define request header
*/
header(key: string, value: any): this;
/**
* Remove a header by its name
*/
clearHeader(key: string): this;
/**
* Set the request content type.
*/
sendAs(type: 'json' | 'urlencoded'): this;
/**
* Define how to parse the response
*/
parseAs(type: 'json' | 'text'): this;
/**
* Reset the client state
*/
clear(): this;
/**
* Make a post request
*/
post(): Promise<any>;
/**
* Make a get request
*/
get(): Promise<any>;
}