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

@oneaccount/express

v0.2.10

Published

OneAccount SDK for Express.js - Authentication, entitlements, and Stripe Connect

Readme

@oneaccount/express

Express.js SDK for OneAccount - Authentication, entitlements, and Stripe Connect integration.

Installation

npm install @oneaccount/express

Quick Start

import express from 'express';
import { oneAccount } from '@oneaccount/express';

const app = express();
app.use(express.json());

// Initialize SDK
const oa = oneAccount({
  apiKey: process.env.ONEACCOUNT_API_KEY,
  accountProUrl: 'https://accountpro.replit.app', // optional
  debug: true, // optional - logs auth errors
});

// Add auth middleware to all routes
app.use(oa.middleware);

// Mount Stripe Connect routes
oa.mountRoutes(app, '/api/connect');

// Protected route - requires authentication
app.get('/api/profile', oa.requireAuth, (req, res) => {
  res.json({ user: req.oneAccount.user });
});

// Protected route - requires specific entitlement
app.get('/api/classes', oa.requireEntitlement('classy'), (req, res) => {
  res.json({ message: 'Welcome to Classy!' });
});

// Admin-only route
app.get('/api/admin', oa.requireSuperAdmin, (req, res) => {
  res.json({ message: 'Admin access granted' });
});

app.listen(3000);

Configuration

| Option | Type | Default | Description | |--------|------|---------|-------------| | apiKey | string | required | Your OneAccount API key | | accountProUrl | string | https://accountpro.replit.app | OneAccount server URL | | jwksUrl | string | auto | JWKS endpoint URL (auto-derived from accountProUrl) | | debug | boolean | false | Log authentication errors |

Middleware

oa.middleware

Parses JWT from Authorization: Bearer <token> header and populates req.oneAccount.user.

oa.requireAuth

Returns 401 if no authenticated user.

oa.requireEntitlement(entitlement)

Returns 403 if user doesn't have the specified entitlement (sweetcart or classy).

oa.requireSuperAdmin

Returns 403 if user is not a super admin.

Stripe Connect Routes

When you call oa.mountRoutes(app, '/api/connect'), the following routes are available:

| Method | Path | Description | |--------|------|-------------| | GET | /api/connect/account | Get Stripe Connect status | | POST | /api/connect/account | Create Stripe Express account | | POST | /api/connect/onboarding-link | Get Stripe onboarding URL | | POST | /api/connect/dashboard-link | Get Stripe Express dashboard URL | | GET | /api/connect/transactions | List transactions | | GET | /api/connect/balance | Get account balance | | POST | /api/connect/payment | Create marketplace payment | | POST | /api/connect/refund | Refund a payment |

Buyer Authentication

For marketplace apps where sellers have their own customers (buyers), the SDK provides buyer authentication:

import type { BuyerAuthRequest } from '@oneaccount/express';

// Mount buyer auth routes
oa.mountBuyerRoutes(app, '/api/buyer');

// Add buyer middleware to routes that need buyer auth
app.use('/api/customer', oa.buyerMiddleware);

// Protected buyer route - use BuyerAuthRequest for typing
app.get('/api/customer/orders', oa.requireBuyerAuth, (req: BuyerAuthRequest, res) => {
  const buyer = req.buyer!; // Non-null after requireBuyerAuth
  res.json({ buyerId: buyer.buyerId, sellerId: buyer.sellerId });
});

// Restrict to specific seller's buyers
app.get('/api/customer/classes', oa.requireBuyerForSeller('seller-uuid'), (req: BuyerAuthRequest, res) => {
  res.json({ message: 'Welcome!' });
});

Buyer Auth Routes

When you call oa.mountBuyerRoutes(app, '/api/buyer'):

| Method | Path | Description | |--------|------|-------------| | POST | /api/buyer/magic/request | Request magic login link (email or SMS) | | GET | /api/buyer/magic/verify | Verify magic token and get JWT | | GET | /api/buyer/profile | Get buyer profile (requires auth) |

Magic Link Request Body

{
  "email": "[email protected]",
  "sellerId": "seller-uuid",
  "channel": "email"
}

Or for SMS:

{
  "phone": "+15551234567",
  "sellerId": "seller-uuid", 
  "channel": "sms"
}

Buyer Middleware

  • oa.buyerMiddleware - Parses buyer JWT from Authorization: Bearer <token> header
  • oa.requireBuyerAuth - Returns 401 if no authenticated buyer
  • oa.requireBuyerForSeller(sellerId) - Returns 403 if buyer doesn't belong to seller

TypeScript

The SDK is fully typed. Import types as needed:

import type { 
  OneAccountRequest, 
  OneAccountUser, 
  Entitlements,
  BuyerAuthRequest,
  BuyerUser,
} from '@oneaccount/express';

License

MIT