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

@seneris/nextauth-moopy-provider

v1.0.0

Published

Moopy OAuth provider for NextAuth.js

Readme

@seneris/nextauth-moopy-provider

Moopy OAuth provider for NextAuth.js.

Features

  • 🔐 OAuth 2.0 authentication with Moopy
  • 🔒 PKCE support for enhanced security
  • 📦 TypeScript support with full type definitions
  • 🎨 Custom Moopy branding
  • 🔧 Support for Moopy-specific profile fields (subscription tier, authorized apps, preferences)
  • ✅ Type augmentation for Next-Auth session and JWT

Installation

npm install @seneris/nextauth-moopy-provider next-auth
# or
yarn add @seneris/nextauth-moopy-provider next-auth
# or
pnpm add @seneris/nextauth-moopy-provider next-auth

Prerequisites

  1. Register your application in the Moopy OAuth system
  2. Obtain your Client ID and Client Secret
  3. Configure redirect URIs:
    • Development: http://localhost:3000/api/auth/callback/moopy
    • Production: https://yourdomain.com/api/auth/callback/moopy

Usage

Basic Setup

import NextAuth, { NextAuthOptions } from "next-auth"
import { PrismaAdapter } from "@next-auth/prisma-adapter"
import MoopyProvider from "@seneris/nextauth-moopy-provider"
import { prisma } from "@/lib/prisma"

export const authOptions: NextAuthOptions = {
  adapter: PrismaAdapter(prisma),
  providers: [
    MoopyProvider({
      clientId: process.env.MOOPY_CLIENT_ID!,
      clientSecret: process.env.MOOPY_CLIENT_SECRET!,
      issuer: process.env.MOOPY_ISSUER_URL || 'https://moopy.nl',
    }),
  ],
  session: {
    strategy: "jwt"
  },
  callbacks: {
    async session({ session, token }) {
      if (token && session.user) {
        session.user.id = token.sub as string
        // Moopy-specific fields are automatically included
        session.user.subscription_tier = token.subscription_tier
        session.user.subscription_status = token.subscription_status
      }
      return session
    },
    async jwt({ token, user, account }) {
      if (user && account?.provider === 'moopy') {
        token.subscription_tier = user.subscription_tier
        token.subscription_status = user.subscription_status
        token.authorized_apps = user.authorized_apps
        token.preferences = user.preferences
      }
      return token
    },
  }
}

const handler = NextAuth(authOptions)
export { handler as GET, handler as POST }

Environment Variables

Add to your .env file:

MOOPY_CLIENT_ID=your-client-id-here
MOOPY_CLIENT_SECRET=your-client-secret-here
MOOPY_ISSUER_URL=https://moopy.nl

NEXTAUTH_URL=http://localhost:3000
NEXTAUTH_SECRET=generate-with-openssl-rand-base64-32

Custom Configuration

You can customize the OAuth scopes and other settings:

import { createMoopyProvider } from "@seneris/nextauth-moopy-provider"

const provider = createMoopyProvider({
  clientId: process.env.MOOPY_CLIENT_ID!,
  clientSecret: process.env.MOOPY_CLIENT_SECRET!,
  issuer: 'https://moopy.nl',
  scope: 'email profile custom-scope'
})

Moopy Profile Fields

The provider includes these Moopy-specific profile fields:

interface MoopyProfile {
  sub: string                    // User ID
  email?: string                 // Email address
  email_verified?: boolean       // Email verification status
  name?: string                  // Full name
  given_name?: string           // First name
  family_name?: string          // Last name
  picture?: string              // Profile picture URL
  updated_at?: number           // Last update timestamp
  subscription_tier?: string    // Subscription level (free, pro, enterprise)
  subscription_status?: string  // Status (active, cancelled, expired)
  authorized_apps?: Array<{     // Other apps user has authorized
    client_id: string
    name: string
  }>
  preferences?: Record<string, unknown>  // User preferences
}

TypeScript

The package includes full TypeScript support and automatically augments Next-Auth types to include Moopy-specific fields.

Accessing Moopy Fields

In your components:

import { useSession } from "next-auth/react"

export function MyComponent() {
  const { data: session } = useSession()

  // TypeScript knows about Moopy fields
  const tier = session?.user?.subscription_tier
  const status = session?.user?.subscription_status

  return (
    <div>
      <p>Subscription: {tier}</p>
      <p>Status: {status}</p>
    </div>
  )
}

In API routes:

import { getServerSession } from "next-auth"
import { authOptions } from "@/lib/auth"

export async function GET() {
  const session = await getServerSession(authOptions)

  if (!session) {
    return new Response("Unauthorized", { status: 401 })
  }

  // Access Moopy fields
  const tier = session.user.subscription_tier

  return Response.json({ tier })
}

Security

  • Uses PKCE (Proof Key for Code Exchange) for enhanced security
  • Supports state and nonce checks
  • Follows OAuth 2.0 best practices
  • Always use HTTPS in production

Examples

Sign In Button

"use client"

import { signIn } from "next-auth/react"
import { Button } from "@/components/ui/button"

export function SignInButton() {
  return (
    <Button onClick={() => signIn("moopy")}>
      Sign in with Moopy
    </Button>
  )
}

Protected API Route

import { NextRequest, NextResponse } from "next/server"
import { getServerSession } from "next-auth"
import { authOptions } from "@/lib/auth"

export async function GET(request: NextRequest) {
  const session = await getServerSession(authOptions)

  if (!session?.user?.id) {
    return NextResponse.json({ error: "Unauthorized" }, { status: 401 })
  }

  return NextResponse.json({
    userId: session.user.id,
    tier: session.user.subscription_tier
  })
}

Troubleshooting

Redirect URI Mismatch

Ensure your redirect URI in the Moopy OAuth app exactly matches:

http://localhost:3000/api/auth/callback/moopy

Session Not Persisting

  • Verify NEXTAUTH_SECRET is set
  • Check NEXTAUTH_URL matches your domain
  • Ensure cookies are enabled in browser

Custom Fields Not Available

Make sure you include the callbacks in your auth configuration to pass Moopy fields from the JWT to the session (see Usage example above).

License

MIT

Contributing

Contributions are welcome! Please open an issue or submit a pull request.

Support

For issues related to:

Links