yarn @nestjs/passport 12.0.0
Release 12.0.0

2 hours ago

What's Changed

@nestjs/passport is now a native ES module, and the major version is aligned with the Nest 12 release line.

ESM migration

The package is published as pure ESM ("type": "module", compiled with NodeNext) behind a proper exports map. The legacy root index.js / index.d.ts / index.ts shims are gone, and deep imports into build internals (e.g. @nestjs/passport/dist/auth.guard) are no longer resolvable — import from the package root:

import { AuthGuard, PassportModule, PassportStrategy } from '@nestjs/passport';

require(esm) — CommonJS still works

You do not need to convert your app to ESM. Thanks to Node's require(esm) support, a CommonJS app can keep doing:

const { AuthGuard, PassportModule } = require('@nestjs/passport');

This requires Node.js 20.19+ or 22.12+ (where require(esm) is enabled by default). On older Node versions you must either upgrade Node or move your app to ESM.

AuthGuard no longer forwards module options to passport.authenticate()

defaultStrategy and property — options that belong to PassportModule.register(), not to Passport itself — were being passed straight through to passport.authenticate(), where they could collide with strategy-level options. They are now stripped before the call, so a strategy only ever receives real AuthenticateOptions.

The signature of getAuthenticateOptions() changed accordingly:

// before
getAuthenticateOptions(
  context: ExecutionContext,
): Promise<IAuthModuleOptions> | IAuthModuleOptions | undefined;

// after
getAuthenticateOptions(
  context: ExecutionContext,
):
  | Promise<AuthGuardAuthenticateOptions>
  | AuthGuardAuthenticateOptions
  | undefined;

AuthGuardAuthenticateOptions is exported from the package root and is passport.AuthenticateOptions with defaultStrategy explicitly disallowed. If you override getAuthenticateOptions() and return defaultStrategy, TypeScript will now flag it — remove it and set it via PassportModule.register({ defaultStrategy: '...' }) instead.

Peer dependencies

"peerDependencies": {
  "@nestjs/common": "^11.0.0 || ^12.0.0",
  "passport": "^0.5.0 || ^0.6.0 || ^0.7.0"
}

Nest 10 is no longer supported. Nest 11 remains supported, so you can adopt this release before or after upgrading to Nest 12.

Upgrading

npm i @nestjs/passport@12

Checklist:

  • Node.js 20.19+ / 22.12+ (or an ESM app).
  • Replace any deep imports (@nestjs/passport/dist/...) with root imports.
  • Remove defaultStrategy / property from anything you return out of getAuthenticateOptions().
  • @nestjs/common on ^11 or ^12.

Don't miss a new passport release

NewReleases is sending notifications on new releases.