lhisp-oauth-client/src/lhisp-oauth-client.t.ts

47 lines
1.2 KiB
TypeScript

import { AxiosRequestConfig } from "axios";
export interface Headers {
[name: string]: any;
}
export interface LhispOauthClientConstructorParams {
authUrl: string;
apiUrl: string;
clientId: string;
clientSecret: string;
certificado?: string | Buffer;
senhaCertificado?: string;
authScope?: string;
authHeaderName?: string;
tokenHeaderName?: string;
headers?: Headers;
authHeaders?: Headers;
grantType?: string;
authContentType?: ContentType;
authData: Record<string, string>;
sendAuthCredentialsOnRequestBody?: boolean;
formatAccessToken?: (accessToken?: AccessToken) => string;
debug?: boolean;
}
export interface ExecutarRequestParams extends AxiosRequestConfig {
path: string;
contentType?: ContentType;
}
export interface AccessToken {
token_type: string;
access_token: string;
expires_in: number;
scope?: string;
}
export enum ContentType {
APPLICATION_JSON = "application/json",
APPLICATION_X_WWW_FORM_URLENCODED = "application/x-www-form-urlencoded",
}
export const defaultGrantType = "client_credentials";
export const defaultAuthContentType = ContentType.APPLICATION_X_WWW_FORM_URLENCODED;
export const defaultAuthHeaderName = "Authorization";
export const defaultTokenHeaderName = "Authorization";