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

@aoctech/auth-client

v1.1.0

Published

Shared browser OAuth 2.0 / PKCE client for apps built on the ctech-account identity provider.

Downloads

639

Readme

@aoctech/auth-client

CI npm

Shared browser OAuth 2.0 + PKCE client for apps built on the ctech-account identity provider. One OAuthClient instance per app, config-only — no server, no framework dependency.

Repo name is ctech-oauth-client on GitHub; published to npm as @aoctech/auth-client. Searching by either name should land here.

Why this exists

Three SPAs (accounts, ctech-dfe, ctech-wallet) each carried their own ~200-line copy of the same OAuth flow. They drifted: two of the three checked whether a session could plausibly exist (via the ctech_auth hint cookie or a local revoked-flag) before firing a silent refresh — the third fired unconditionally on every mount, including the very first visit of a browser that never had a session. That's a guaranteed POST /v1.0/token failure on every cold visit, and it burns the same shared brute-force rate limit that protects login and client-secret guessing on the IdP.

This package is the single implementation. OAuthClient.refresh() always checks the hint cookie and a local revoked-state before touching the network, and de-duplicates concurrent calls (boot-time init and a 401 retry interceptor calling refresh() at the same instant share one request instead of firing two).

Install

npm install @aoctech/auth-client

Usage

import { OAuthClient } from "@aoctech/auth-client";

export const oauth = new OAuthClient({
  baseUrl: process.env.NEXT_PUBLIC_CTECH_URL!,
  clientId: process.env.NEXT_PUBLIC_CTECH_CLIENT_ID!,
  redirectUri: `${window.location.origin}/callback`,
  scope: "openid profile",
});

// Kick off login
await oauth.startOAuthFlow("/dashboard");

// On the /callback page
const { accessToken, idToken, returnTo } = await oauth.exchangeCode(code, state);

// Silent refresh — safe to call from app boot AND a 401 interceptor at once
const result = await oauth.refresh(); // null if not worth attempting or it failed

// Logout
await oauth.revoke();
oauth.endSessionRedirect("/login");

API

  • hasAuthHint(cookieString?) / clearAuthHint() — read/clear the ctech_auth marker cookie.
  • startOAuthFlow(returnTo?) — redirects to /v1.0/authorize with a fresh PKCE pair.
  • exchangeCode(code, state)authorization_code grant.
  • refresh() — guarded, single-flight refresh_token grant. Never throws.
  • revoke() — best-effort POST /v1.0/revoke.
  • endSessionRedirect(returnTo?) — RP-initiated logout via /v1.0/auth/end-session.
  • decodeIdToken(idToken) — unverified payload decode, for display-only name claims.

Also exported standalone: generatePKCE(), generateState(), decodeIdToken().

Development

npm run build   # tsc -> dist/
npm test        # build + node's built-in test runner

Releasing

publish.yml only fires on a published GitHub Release — a push to main alone never publishes (it only runs ci.yml, which tests). Publishing uses npm's OIDC trusted publishing, so there's no NPM_TOKEN secret to manage; provenance is generated automatically.

# 1. Bump "version" in package.json, then commit and push as usual
git commit -am "chore: release vX.Y.Z"
git push

# 2. Tag it and push the tag
git tag vX.Y.Z
git push --tags

# 3. Cut the release — this is what actually triggers the publish workflow
gh release create vX.Y.Z --generate-notes

License

MIT