Registry / security / nestjs-google-auth-guard

nestjs-google-auth-guard

JSON →
library0.1.4jsnpmunverified

A NestJS guard for Google OAuth2 token validation using google-auth-library. Version 0.1.4 supports Node >=22 and relies on Async Local Storage for context management. Provides a decorator to inject verified token payload. Lightweight alternative to passport with no schema coupling. Likely early-stage (pre-1.0).

npm install nestjs-google-auth-guard
INSTALL
IMPORT
SIG · NESTJS-GOOGLE-AUTH
N
nestjs-google-auth-guard
securityjavascriptv0.1.4
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

GoogleAuthGuard
import { GoogleAuthGuard } from 'nestjs-google-auth-guard'
const { GoogleAuthGuard } = require('nestjs-google-auth-guard')
ESM only. CJS require may throw.
AuthenticatedGoogleUser
import { AuthenticatedGoogleUser } from 'nestjs-google-auth-guard'
import AuthenticatedGoogleUser from 'nestjs-google-auth-guard'
Named export, not default.
GoogleAuthGuardModule
import { GoogleAuthGuardModule } from 'nestjs-google-auth-guard'
Module to register in NestJS app.
GoogleUser
import { GoogleUser } from 'nestjs-google-auth-guard'
Type/interface for the decoded token payload.

Registers the GoogleAuthGuard globally in NestJS to protect all routes via bearer token verification.

import { Module } from '@nestjs/common'; import { GoogleAuthGuardModule } from 'nestjs-google-auth-guard'; import { APP_GUARD } from '@nestjs/core'; import { GoogleAuthGuard } from 'nestjs-google-auth-guard'; @Module({ imports: [GoogleAuthGuardModule], providers: [ { provide: APP_GUARD, useClass: GoogleAuthGuard, }, ], }) export class AppModule {}
Debug
Known issues
breakingRequires Node >=22. Older Node versions not supported.
fix
Upgrade Node to version 22 or later.
affects: >=0.1.0
gotchaThe guard expects a valid Google-signed bearer token in the Authorization header. Custom tokens will fail.
fix
Ensure clients send properly obtained Google OAuth2 tokens.
affects: >=0.1.0
gotchaAsyncLocalStorage context may not be available in all NestJS execution contexts (e.g., WebSocket, GraphQL subscriptions).
fix
Check decorator usage within proper HTTP request contexts.
affects: >=0.1.0
deprecatedNo known deprecations yet. This is an early release.
fix
Monitor GitHub releases for updates.
affects: >=0.1.0
Errors
Common errors & fixes
Cannot find module 'nestjs-google-auth-guard'
Package not installed or ESM import used instead of require in CJS project.
fix
Run npm install nestjs-google-auth-guard and ensure your project is ESM (type: module in package.json) or use dynamic import().
Guard not executing: no token provided
Requests missing Authorization: Bearer <token> header.
fix
Attach a valid Google OAuth2 access token to the request header.
TypeError: GoogleAuthGuard is not a constructor
Incorrect import style (default vs named) or CJS require with ESM package.
fix
Use named import: import { GoogleAuthGuard } from 'nestjs-google-auth-guard'.
Upgrade
Version history
0.1.4latest on npm
Audit
Dependencies
google-auth-libraryrequiredVerifies Google OAuth2 tokens
rxjsrequiredPeer dependency for NestJS reactive streams
Agent activity
9 hits · last 30 days
node
8
OpenAI (training)
1
Resources
nestjs-google-auth-guard — npm install nestjs-google-auth-guard · libregistry