
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
lhisp-oauth-client
Advanced tools
Bilingual README (Português / English) for the **lhisp-oauth-client** library.
Bilingual README (Português / English) for the lhisp-oauth-client library.
Cliente HTTP simples para consumir uma API protegida por OAuth2 (Client Credentials), cuidando automaticamente de:
access_token no endpoint de autenticaçãohttps.AgentObservação: refresh token ainda não está implementado (há um
TODOno código). Quando o token expira, um novo token é solicitado.
npm i lhisp-oauth-client
# ou
yarn add lhisp-oauth-client
import { LhispOauthClient } from "lhisp-oauth-client";
const client = new LhispOauthClient({
apiUrl: "https://api.exemplo.com",
authUrl: "https://auth.exemplo.com/oauth/token",
clientId: "SEU_CLIENT_ID",
clientSecret: "SEU_CLIENT_SECRET",
});
type StatusResponse = { status: string };
async function main() {
const resp = await client.get<StatusResponse>({
path: "/status",
params: { verbose: true },
});
console.log(resp.status);
}
main();
getAccessToken(): Promise<AccessToken>
getAuthToken(): string
"<token_type> <access_token>").executarRequest<ResponseType>(params): Promise<ResponseType>
get, post, put, patch, deletenew LhispOauthClient(params) aceita:
apiUrl (string, obrigatório): URL base da API (ex.: https://api.exemplo.com)authUrl (string, obrigatório): endpoint OAuth2 para obter tokenclientId (string, obrigatório)clientSecret (string, obrigatório)Opcionalmente:
certificado (string | Buffer): certificado cliente PFX
Buffer.from(certificado, "base64")senhaCertificado (string): senha do PFXauthScope (string): adiciona scope no request de tokengrantType (string): padrão client_credentialsauthContentType (ContentType): padrão application/x-www-form-urlencodedauthData (Record<string,string>): campos extras enviados ao endpoint de tokenheaders (object): headers aplicados nas requisições para a APIauthHeaders (object): headers extras somente na obtenção do tokenauthHeaderName (string): nome do header usado para credenciais Basic (padrão Authorization)tokenHeaderName (string): nome do header onde o token é enviado (padrão Authorization)sendAuthCredentialsOnRequestBody (boolean): envia client_id e client_secret também no bodyformatAccessToken ((token?) => string): personaliza o valor enviado no header do tokentimeout (number): timeout das requisições (ms). Padrão 60000logger (Logger): logger compatível (com .child() + métodos info/warn/error/debug)Você pode escolher o Content-Type das requisições para API via contentType:
import { ContentType } from "lhisp-oauth-client";
await client.post({
path: "/clientes",
contentType: ContentType.APPLICATION_JSON,
data: { name: "Maria" },
});
Nota: o
contentTypede autenticação (request do token) é controlado porauthContentType.
import { LhispOauthClient, ContentType } from "lhisp-oauth-client";
const client = new LhispOauthClient({
apiUrl: "https://api.exemplo.com",
authUrl: "https://auth.exemplo.com/oauth/token",
clientId: "SEU_CLIENT_ID",
clientSecret: "SEU_CLIENT_SECRET",
authContentType: ContentType.APPLICATION_JSON,
sendAuthCredentialsOnRequestBody: true,
});
await client.get({ path: "/status" });
import { LhispOauthClient } from "lhisp-oauth-client";
const client = new LhispOauthClient({
apiUrl: "https://api.exemplo.com",
authUrl: "https://auth.exemplo.com/oauth/token",
clientId: "SEU_CLIENT_ID",
clientSecret: "SEU_CLIENT_SECRET",
tokenHeaderName: "x-token",
});
await client.get({ path: "/status" });
import fs from "node:fs";
import { LhispOauthClient } from "lhisp-oauth-client";
const pfxBuffer = fs.readFileSync("./certificado.pfx");
const client = new LhispOauthClient({
apiUrl: "https://api.exemplo.com",
authUrl: "https://auth.exemplo.com/oauth/token",
clientId: "SEU_CLIENT_ID",
clientSecret: "SEU_CLIENT_SECRET",
certificado: pfxBuffer,
senhaCertificado: "SENHA_DO_PFX",
});
await client.get({ path: "/status" });
A lightweight HTTP client to consume an API protected by OAuth2 (Client Credentials). It automatically:
access_token from the auth endpointhttps.AgentNote: refresh token is not implemented yet (there is a
TODOin the code). When the token expires, a new token is requested.
npm i lhisp-oauth-client
# or
yarn add lhisp-oauth-client
import { LhispOauthClient } from "lhisp-oauth-client";
const client = new LhispOauthClient({
apiUrl: "https://api.example.com",
authUrl: "https://auth.example.com/oauth/token",
clientId: "YOUR_CLIENT_ID",
clientSecret: "YOUR_CLIENT_SECRET",
});
type StatusResponse = { status: string };
async function main() {
const resp = await client.get<StatusResponse>({
path: "/status",
params: { verbose: true },
});
console.log(resp.status);
}
main();
getAccessToken(): Promise<AccessToken>
getAuthToken(): string
"<token_type> <access_token>").executarRequest<ResponseType>(params): Promise<ResponseType>
get, post, put, patch, deletenew LhispOauthClient(params) accepts:
Required:
apiUrl (string): API base URL (e.g. https://api.example.com)authUrl (string): OAuth2 token endpointclientId (string)clientSecret (string)Optional:
certificado (string | Buffer): PFX client certificate
Buffer.from(certificado, "base64")senhaCertificado (string): PFX passwordauthScope (string): adds scope to the token requestgrantType (string): default client_credentialsauthContentType (ContentType): default application/x-www-form-urlencodedauthData (Record<string,string>): extra fields sent to the token endpointheaders (object): headers applied to API callsauthHeaders (object): extra headers only for token retrievalauthHeaderName (string): Basic credentials header name (default Authorization)tokenHeaderName (string): token header name (default Authorization)sendAuthCredentialsOnRequestBody (boolean): also sends client_id and client_secret in the request bodyformatAccessToken ((token?) => string): customize token header valuetimeout (number): request timeout in ms (default 60000)logger (Logger): compatible logger (must support .child() and info/warn/error/debug)You can set the API request Content-Type using contentType:
import { ContentType } from "lhisp-oauth-client";
await client.post({
path: "/customers",
contentType: ContentType.APPLICATION_JSON,
data: { name: "Alice" },
});
Note: the auth/token request content type is controlled by
authContentType.
import { LhispOauthClient, ContentType } from "lhisp-oauth-client";
const client = new LhispOauthClient({
apiUrl: "https://api.example.com",
authUrl: "https://auth.example.com/oauth/token",
clientId: "YOUR_CLIENT_ID",
clientSecret: "YOUR_CLIENT_SECRET",
authContentType: ContentType.APPLICATION_JSON,
sendAuthCredentialsOnRequestBody: true,
});
await client.get({ path: "/status" });
import { LhispOauthClient } from "lhisp-oauth-client";
const client = new LhispOauthClient({
apiUrl: "https://api.example.com",
authUrl: "https://auth.example.com/oauth/token",
clientId: "YOUR_CLIENT_ID",
clientSecret: "YOUR_CLIENT_SECRET",
tokenHeaderName: "x-token",
});
await client.get({ path: "/status" });
import fs from "node:fs";
import { LhispOauthClient } from "lhisp-oauth-client";
const pfxBuffer = fs.readFileSync("./certificate.pfx");
const client = new LhispOauthClient({
apiUrl: "https://api.example.com",
authUrl: "https://auth.example.com/oauth/token",
clientId: "YOUR_CLIENT_ID",
clientSecret: "YOUR_CLIENT_SECRET",
certificado: pfxBuffer,
senhaCertificado: "PFX_PASSWORD",
});
await client.get({ path: "/status" });
FAQs
Bilingual README (Português / English) for the **lhisp-oauth-client** library.
The npm package lhisp-oauth-client receives a total of 3 weekly downloads. As such, lhisp-oauth-client popularity was classified as not popular.
We found that lhisp-oauth-client demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.