@superfunctions/oauth-http
v0.2.1
Published
OAuth HTTP transport contracts for Superfunctions
Readme
@superfunctions/oauth-http
Reusable OAuth token transport for code exchange, refresh, revocation, retries, and normalized upstream errors.
Install
npm install @superfunctions/oauth-http @superfunctions/oauth-core @superfunctions/oauth-providersQuick Start
import { DefaultOAuthTokenHttpClient } from "@superfunctions/oauth-http";
import { getOAuthProviderDescriptor } from "@superfunctions/oauth-providers";
const client = new DefaultOAuthTokenHttpClient();
const github = getOAuthProviderDescriptor("github");
const tokenSet = await client.exchangeToken({
provider: github,
grantType: "authorization_code",
clientId: process.env.GITHUB_CLIENT_ID!,
clientSecret: process.env.GITHUB_CLIENT_SECRET!,
code: "oauth-code",
redirectUri: "https://app.example/oauth/github/callback",
});Package Boundary
@superfunctions/oauth-http owns OAuth HTTP transport only:
- token endpoint exchange
- refresh exchange
- revocation requests
- retry policy and normalized transport errors
It does not own state validation, token persistence, or route generation. Pair it with:
@superfunctions/oauth-corefor callback invariants@superfunctions/oauth-flowfor full lifecycle orchestration@superfunctions/oauth-routerfor route exposure
Production Notes
- Provide secrets through
clientSecretResolverwhen your platform resolves secrets dynamically. - Tune retries for provider-specific 429/5xx behavior instead of wrapping token calls with ad hoc fetch logic.
- Treat provider revocation as best effort unless your product contract requires remote confirmation before local cleanup.
Release validation
Run npm run typecheck, npm run build, npm run lint, and npm test in a
standalone package checkout with registry-backed dependencies. The transport
requires the OAuth core descriptor additions released in 0.2.0; a workspace
source alias cannot substitute for that published prerequisite. The nested-token
tests exercise user-versus-bot selection, missing-user failures, JSON request
encoding with Basic authentication, provider headers, and JSON revocation errors.
Related Packages
- OAuth core primitives: ../oauth-core/README.md
- Provider descriptors: ../oauth-providers/README.md
- Route factories: ../oauth-router/README.md
