Registry / auth-security / ag-common-next-auth

ag-common-next-auth

JSON →
library0.0.153jsnpmunverified

A set of reusable utilities for NextAuth.js, including OAuth callback handlers, session management, and Cognito integration. Current stable version 0.0.153. Released frequently (multiple versions per week) but still in early development. Key differentiators: provides pre-built NextAuth adapters and helpers for common providers, with TypeScript types included. Minimal documentation and limited community adoption; use with caution in production.

npm install ag-common-next-auth
INSTALL
IMPORT
SIG · AG-COMMON-NEXT-AUT
A
ag-common-next-auth
auth-securityjavascriptv0.0.153
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

OAuthCallback
import { OAuthCallback } from 'ag-common-next-auth'
import OAuthCallback from 'ag-common-next-auth'
Named export only; no default export.
checkEnvironment
import { checkEnvironment } from 'ag-common-next-auth'
const checkEnvironment = require('ag-common-next-auth').checkEnvironment
ESM-only; CommonJS require works but is discouraged.
CognitoProvider
import { CognitoProvider } from 'ag-common-next-auth/providers/cognito'
import { CognitoProvider } from 'ag-common-next-auth'
Subpath export; not available from main entry.

Shows how to use OAuthCallback handler with Cognito provider, including environment variable fallbacks.

import { OAuthCallback } from 'ag-common-next-auth'; export async function handler(req, res) { const result = await OAuthCallback(req, res, { clientId: process.env.COGNITO_CLIENT_ID ?? '', clientSecret: process.env.COGNITO_CLIENT_SECRET ?? '', redirectUri: 'https://example.com/api/auth/callback', }); console.log('OAuth result:', result); }
Debug
Known issues
gotchaEnvironment variables COGNITO_CLIENT_SECRET and NEXTAUTH_SECRET must be set, otherwise OAuthCallback will throw an error.
fix
Ensure both variables are defined in your deployment environment (Vercel, etc.).
affects: >=0.0.1
breakingVersion 0.0.150 renamed `OAuthHandler` to `OAuthCallback`. Old imports break.
fix
Update imports: replace `OAuthHandler` with `OAuthCallback`.
affects: <0.0.150
deprecatedFunction `validateSession` was deprecated in v0.0.130; use `checkEnvironment` instead.
fix
Replace `validateSession()` with `checkEnvironment()`.
affects: >=0.0.130
gotchaCognitoProvider is not exported from the main package entry; it requires a subpath import.
fix
Import from 'ag-common-next-auth/providers/cognito'.
affects: >=0.0.140
breakingIn v0.0.120, the package switched from CommonJS to ESM-only. `require()` still works but may cause issues with dynamic imports.
fix
Use ES import syntax; if using Node.js <14, upgrade or use dynamic import().
affects: >=0.0.120
Errors
Common errors & fixes
Error: OAuthCallback is not defined
Importing default export instead of named export.
fix
Use `import { OAuthCallback } from 'ag-common-next-auth'`
TypeError: Cannot read properties of undefined (reading 'clientId')
Environment variables COGNITO_CLIENT_ID or COGNITO_CLIENT_SECRET missing.
fix
Add them to your .env file or hosting environment.
Upgrade
Version history
0.0.153latest on npm
Audit
Dependencies
next-authrequiredPeer dependency for NextAuth.js types and session handling
Agent activity
67 hits · last 30 days
node
56
Amazon
1
Perplexity
1
OpenAI (training)
1
Resources
ag-common-next-auth — npm install ag-common-next-auth · libregistry