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

@motion-key/server

v0.1.0

Published

Server-side library for Motion Key 2FA — route handlers, SDK, push/email providers, Prisma schema fragment.

Downloads

88

Readme

@motion-key/server

Server-side library for Motion Key 2FA — drop into any Node app (Next.js, Hono, Express, Bun…) to add iPhone-as-2nd-factor login.

What you get

  • Route handlers for QR enrollment, account management, mobile push-token updates, and the iPhone-facing challenge approve/reject endpoints.
  • createMotionKey(config).sdk — call this from your existing login flow:
    • isUserEnrolled(userId) — does this user have a phone enrolled?
    • createChallenge({ userId, ipAddress?, userAgent? })
    • sendChallengePush(challengeId, { browser, os })
    • getChallengeStatus(challengeId)
    • claimApprovedChallenge(challengeId) → set your own session cookie on success
  • Push providers: APNsPushProvider (token auth, from env), ConsolePushProvider (dev fallback). Implement PushProvider for FCM / OneSignal / your own.
  • Email providers: ResendEmailProvider, ConsoleEmailProvider. Implement EmailProvider for others.
  • Prisma schema fragment at @motion-key/server/prisma/motion-key.prisma — copy it into your prisma/schema/ folder (multi-file schemas are Prisma 6+ GA).

Install

pnpm add @motion-key/server @motion-key/core @prisma/client
# Optional, only if you actually use APNs push:
pnpm add apn

Minimum integration (Next.js example)

  1. Add the schema fragment — copy node_modules/@motion-key/server/prisma/motion-key.prisma into your prisma/schema/, then prisma migrate dev.

  2. Wire the librarylib/motion-key.ts:

    import {
      apnsProviderFromEnv,
      ConsolePushProvider,
      createMotionKey,
      emailProviderFromEnv,
    } from "@motion-key/server";
    import { prisma } from "./db";
    import { getSession } from "./session"; // your existing cookie session
    import { publish } from "./websocket";  // your existing WS bridge (optional)
    
    export const motionKey = createMotionKey({
      prisma,
      baseURL: process.env.APP_BASE_URL!,
      push: apnsProviderFromEnv() ?? new ConsolePushProvider(),
      email: emailProviderFromEnv(),
      getCurrentUser: async () => {
        const s = await getSession();
        return s ? { id: s.userId, email: s.email } : null;
      },
      publish,
    });
  3. Mount the catch-allapp/api/motion-key/[...path]/route.ts:

    import { motionKey } from "@/lib/motion-key";
    export const GET    = motionKey.handlers.GET;
    export const POST   = motionKey.handlers.POST;
    export const DELETE = motionKey.handlers.DELETE;
  4. Use the SDK from your login flow:

    if (await motionKey.sdk.isUserEnrolled(user.id)) {
      const { challengeId } = await motionKey.sdk.createChallenge({ userId: user.id });
      await motionKey.sdk.sendChallengePush(challengeId, { browser, os });
      return Response.json({ mode: "2fa_required", challengeId });
    }
    // else: set your session cookie and return logged_in
  5. Pair with @motion-key/react for the QR + waiting screens, or roll your own — the wire types are in @motion-key/core.

Endpoints exposed by the catch-all

POST   /enroll/start                  (authed via getCurrentUser)
GET    /enroll/info?token=...         (unauthed, token-scoped)
POST   /enroll/complete               (unauthed, token-scoped)
GET    /accounts                      (authed)
DELETE /accounts/:id                  (authed)
POST   /mobile/push-token             (x-account-id)
GET    /mobile/challenges/pending     (x-account-id)
GET    /mobile/challenges/:id         (x-account-id)
POST   /mobile/challenges/approve     (x-account-id + Ed25519 signature)
POST   /mobile/challenges/reject      (x-account-id)
GET    /challenges/status?challengeId=...

License

MIT