OAuth Delegation Module
Composable outbound OAuth 2.0 delegation module. Handles the Authorization Code flow with PKCE, HMAC-signed state cookies, durable per-user token storage, and automatic refresh-before-expiry. Ships reference adapters for Notion, Google (Drive/Calendar/Analytics), Atlassian (Confluence), Slack, and HubSpot, plus in-memory and DynamoDB+KMS envelope-encrypted storage backends. Complements module-auth-ts — that verifies inbound requests, this delegates outbound calls on a user's behalf.
| Name | module-oauth-delegation-ts |
| Version | 0.1.0 |
| Category | composable-modules |
| License | Apache-2.0 |
| Persona | engineering |
| Tags | oauth, oauth2, pkce, delegation, integrations, typescript, security |
| Source | templates/module-oauth-delegation-ts |
Render it
Three front doors, one catalog. Pick whichever suits the caller.
# CLI
npx @nanohype/sdk render module-oauth-delegation-ts --out ./my-app
# SDK
import { LocalSource, renderTemplate } from "@nanohype/sdk";
const result = await renderTemplate(source, "module-oauth-delegation-ts", variables);
# MCP — from an agent
get_template({ name: "module-oauth-delegation-ts" })Prerequisites
| Tool | Version | Why |
|---|---|---|
node | >=22 | Node.js runtime for the OAuth delegation module |
aws-cli (optional) | — | Provision the DynamoDB table and KMS key used by DDBKmsTokenStorage |
Variables
Required
ProjectNamestring- Kebab-case project name, used as package name and directory Must be lowercase kebab-case starting with a letter.
Optional
Descriptionstring — defaults toPer-user OAuth 2.0 delegation with PKCE, token storage, and automatic refresh- Short project description for package.json and README
What it produces
46 files. Placeholder names such as __APP_NAME__ are what the renderer substitutes into.
.env.example
.gitignore
biome.json
package.json
README.md
src/oauth/__tests__/logger-redaction.test.ts
src/oauth/__tests__/pkce.test.ts
src/oauth/__tests__/providers/atlassian.test.ts
src/oauth/__tests__/providers/google.test.ts
src/oauth/__tests__/providers/hubspot.test.ts
src/oauth/__tests__/providers/notion.test.ts
src/oauth/__tests__/providers/slack.test.ts
src/oauth/__tests__/refresh.test.ts
src/oauth/__tests__/router.test.ts
src/oauth/__tests__/state.test.ts
src/oauth/__tests__/storage/ddb-kms.test.ts
src/oauth/__tests__/storage/memory.test.ts
src/oauth/errors.ts
src/oauth/handlers/callback.ts
src/oauth/handlers/errorMapping.ts
src/oauth/handlers/refresh.ts
src/oauth/handlers/revoke.ts
src/oauth/handlers/shared.ts
src/oauth/handlers/start.ts
src/oauth/index.ts
src/oauth/logger.ts
src/oauth/pkce.ts
src/oauth/providers/atlassian.ts
src/oauth/providers/google.ts
src/oauth/providers/hubspot.ts
src/oauth/providers/index.ts
src/oauth/providers/notion.ts
src/oauth/providers/registry.ts
src/oauth/providers/shared.ts
src/oauth/providers/slack.ts
src/oauth/providers/types.ts
src/oauth/refresh.ts
src/oauth/router.ts
src/oauth/state.ts
src/oauth/storage/ddb-kms.ts
src/oauth/storage/memory.ts
src/oauth/storage/types.ts
src/oauth/types.ts
tsconfig.build.json
tsconfig.json
vitest.config.tsComposes with
- Pairs with
ts-service - Pairs with
mcp-server-ts - Nests inside
monorepo