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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@softwarepatterns/am

v0.0.2

Published

Auth client SDK for AccountMaker (Am)

Readme

@softwarepatterns/am

Authentication client SDK for AccountMaker (Am).

This package provides a small, stable client for interacting with the AccountMaker authentication API. It is designed for Node.js applications and modern bundlers, with explicit support for both ESM and CommonJS consumers.

The SDK focuses on correctness, predictable behavior, and minimal surface area.


Features

  • ESM and CommonJS support
  • TypeScript-first API with bundled .d.ts
  • Explicit error modeling using Problem Details
  • Token-based authenticated sessions
  • Automatic access-token refresh
  • No runtime dependencies
  • No side effects on import

Requirements

  • Node.js ≥ 18
  • A runtime with a global fetch implementation (Node 18+, Bun, Deno, or a custom fetchFn)

Installation

npm install @softwarepatterns/am

Importing

ESM

import { Am } from "@softwarepatterns/am";

CommonJS

const { Am } = require("@softwarepatterns/am");

Basic usage

Create a client

import { Am } from "@softwarepatterns/am";

const am = new Am({
  baseUrl: "https://api.accountmaker.com"
});

If no configuration is provided, the client defaults to:

  • baseUrl: https://api.accountmaker.com
  • fetchFn: globalThis.fetch

Authentication flows

Login with email and password

const result = await am.login({
  email: "[email protected]",
  password: "password"
});

The result contains both session tokens and the authenticated profile.

result.session;
result.profile;

Create an authenticated session

const session = am.createAuthSession(result.session);

An AuthSession represents an authenticated user and handles token refresh automatically.


Fetch the current user

const me = await session.me();

Refresh tokens explicitly

await session.refresh();

Error handling

All API errors are surfaced as AuthError.

import { AuthError } from "@softwarepatterns/am";

try {
  await am.login({ email, password });
} catch (err) {
  if (err instanceof AuthError) {
    console.log(err.status);
    console.log(err.title);
    console.log(err.detail);
  }
}

Errors follow the Problem Details format (application/problem+json).

Unknown or unsupported error responses are converted into a generic problem shape without exposing raw response bodies.


Custom fetch implementation

If the runtime does not provide a global fetch, supply one explicitly.

const am = new Am({
  fetchFn: fetch,
  baseUrl: "https://api.accountmaker.com"
});

This is useful for:

  • Older Node versions
  • Instrumented HTTP clients
  • Testing

TypeScript support

This package ships with bundled type definitions.

import type { AuthenticationResult } from "@softwarepatterns/am";

The public API is fully typed. Internal implementation details are not exposed.


Browser support

This SDK does not currently claim browser runtime support.

However:

  • The package is free of Node-only runtime APIs
  • It can be bundled by modern tools (Vite, Rollup, Webpack)

Browser runtime support may be added in a future release, along with explicit guarantees and tests.


Stability guarantees

The following are guaranteed:

  • Stable ESM and CommonJS entry points
  • Stable TypeScript types for exported symbols
  • Compatibility with Node 18, 20, and 22
  • Deterministic build and publish artifacts

The following are not guaranteed yet:

  • Browser runtime behavior
  • Backward compatibility prior to 1.0.0

Versioning

This package follows semantic versioning.

  • 0.x releases may introduce breaking changes
  • 1.0.0 will mark a frozen public API

License

MIT