npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@vercel/passport

v1.1.0

Published

Runtime Passport identity helpers intended for use with Vercel Functions

Downloads

106,642

Readme

@vercel/passport

Runtime helpers for reading and verifying Passport identity.

Usage

import { getIdentity } from '@vercel/passport';

export async function GET() {
  const identity = await getIdentity();

  if (!identity) {
    return Response.json({ authenticated: false }, { status: 401 });
  }

  return Response.json({
    authenticated: true,
    externalSubject: identity.externalSubject,
    subject: identity.subject,
  });
}

In local development, tests, or environments without Vercel request context, pass headers and cookies explicitly:

import { getIdentity } from '@vercel/passport';
import { cookies, headers } from 'next/headers';

export async function GET() {
  const identity = await getIdentity({
    cookies: await cookies(),
    headers: await headers(),
  });

  return Response.json({ identity });
}

getIdentity reads the x-vercel-oidc-passport-token header injected by Vercel after Passport validates the visitor. For tests and local debugging, you can also pass the _vercel_passport cookie explicitly. Both legacy single cookies and chunked Passport session cookies are supported.

By default, request tokens are verified against Vercel's OIDC JWKS. The helper only accepts the dedicated https://passport.vercel.com/{owner} issuer. It also validates the Passport-specific token shape so regular Vercel OIDC tokens are not accepted as Passport identities.

Verify forwarded tokens

Use verifyIdentity when a Passport-protected app forwards its Passport token to another backend. The helper accepts a token string or a request-like object with an Authorization: Bearer <token> header.

import { verifyIdentity } from '@vercel/passport';

export async function POST(request: Request) {
  const identity = await verifyIdentity(request, {
    ownerId: 'team_123',
    projectId: 'prj_123',
    environment: 'production',
  });

  return Response.json({
    externalSubject: identity.externalSubject,
    email: identity.email,
  });
}

If the token was minted by a different Vercel project than the backend that verifies it, pass the source project's projectId, environment, and optional ownerId explicitly.

Local development

Local development usually does not have a real _vercel_passport cookie or x-vercel-oidc-passport-token header, because those are created by Passport in Vercel's edge network. In local development, getIdentity() returns a hardcoded Passport-shaped test identity and logs a warning the first time it does so.

The default test identity uses:

externalSubject: test-user
email: [email protected]
name: Test User

Override individual fields with:

VERCEL_PASSPORT_DEV_OWNER=acme
VERCEL_PASSPORT_DEV_CONNECTOR_ID=scl_dev
VERCEL_PASSPORT_DEV_EXTERNAL_SUB=user_dev
VERCEL_PASSPORT_DEV_EXTERNAL_ISS=https://idp.example.com
VERCEL_PASSPORT_DEV_PROJECT=my-project
VERCEL_PASSPORT_DEV_PROJECT_ID=prj_local

Disable the local test identity with:

VERCEL_PASSPORT_DEV=0

or:

const identity = await getIdentity(undefined, { development: false });

Or provide the full payload yourself:

const identity = await getIdentity(undefined, {
  localIdentity: {
    typ: 'passport',
    iss: 'https://passport.vercel.com/local',
    owner: 'local',
    connector_id: 'local',
    external_sub: 'local-user',
    sub: 'owner:local:connector:local:principal:local-user',
  },
});

Development identities are ignored on Vercel unless VERCEL_ENV=development.

You can also copy a Passport token from a deployed request and pass it directly for debugging:

const identity = await getIdentity(
  { token: process.env.VERCEL_PASSPORT_TOKEN },
  { verify: false }
);

Only disable verification for local debugging. In deployed code, use verifyIdentity for explicit token verification.