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

heb-auth-unofficial

v0.1.1

Published

HEB mobile OAuth helpers (PKCE + token exchange)

Readme

heb-auth-unofficial

OAuth/PKCE helpers for H-E-B mobile authentication. Generates bearer tokens for use with heb-sdk-unofficial.

📖 Full Documentation

Install

npm install heb-auth-unofficial
# or
pnpm add heb-auth-unofficial

Quick Start

Create a PKCE context and build the auth URL.

import { buildAuthUrl, createOAuthContext } from 'heb-auth-unofficial';

const context = createOAuthContext();
const authUrl = buildAuthUrl(context);

console.log(authUrl.toString());
// Open this URL in a browser, sign in, and capture the `code` from the redirect

Exchange the code for tokens and upsert the mobile profile.

import { exchangeCode, upsertUser } from 'heb-auth-unofficial';

const tokens = await exchangeCode({
  code: 'code-from-redirect',
  codeVerifier: context.codeVerifier,
});

// Optional: register the user profile with H-E-B's mobile API
if (tokens.id_token) {
  await upsertUser({
    accessToken: tokens.access_token,
    idToken: tokens.id_token,
  });
}

console.log(tokens.access_token, tokens.refresh_token);

Token Refresh

Access tokens expire in ~30 minutes. Use the refresh token to get new tokens.

import { refreshTokens } from 'heb-auth-unofficial';

const tokens = await refreshTokens({
  refreshToken: 'your-refresh-token',
});

console.log(tokens.access_token); // new access token
console.log(tokens.refresh_token); // new refresh token (if rotated)

Integration with heb-sdk-unofficial

Use tokens to create a bearer session for the SDK.

import { createTokenSession, HEBClient, updateTokenSession } from 'heb-sdk-unofficial';
import { refreshTokens } from 'heb-auth-unofficial';

const session = createTokenSession({
  accessToken: tokens.access_token,
  refreshToken: tokens.refresh_token,
  idToken: tokens.id_token,
  expiresIn: tokens.expires_in,
});

// Enable automatic token refresh
session.refresh = async () => {
  const newTokens = await refreshTokens({ refreshToken: session.refreshToken! });
  updateTokenSession(session, newTokens);
};

const heb = new HEBClient(session);
await heb.setStore('790');
const results = await heb.search('milk');

API Reference

PKCE

| Function | Description | |----------|-------------| | createPkceVerifier() | Generate a random PKCE code verifier | | createPkceChallenge(verifier) | Create S256 challenge from verifier | | createPkcePair() | Generate both verifier and challenge | | createOAuthContext() | Full OAuth context with state, nonce, and device IDs |

OAuth Flow

| Function | Description | |----------|-------------| | buildAuthUrl(context, options?) | Build the H-E-B authorization URL | | exchangeCode(options) | Exchange authorization code for tokens | | refreshTokens(options) | Refresh access token using refresh token | | upsertUser(options) | Register user profile with mobile API |

Types

  • HebOAuthConfig - OAuth client configuration
  • HebOAuthContext - PKCE context with state and device IDs
  • HebTokenResponse - Token response from H-E-B

Configuration

Override default config by passing a partial config to any function.

const authUrl = buildAuthUrl(context, {
  config: {
    clientId: 'custom-client-id',
    redirectUri: 'com.myapp://oauth2redirect',
  },
});

Default config:

const DEFAULT_HEB_OAUTH_CONFIG = {
  clientId: 'myheb-ios-prd',
  redirectUri: 'com.heb.myheb://oauth2redirect',
  scope: 'openid profile email',
  authUrl: 'https://accounts.heb.com/oidc/auth',
  tokenUrl: 'https://accounts.heb.com/oidc/token',
  userAgent: 'MyHEB/5.9.0.60733 (iOS 18.7.2; iPhone16,2) CFNetwork/1.0 Darwin/24.6.0',
};

Why heb-auth-unofficial?

Bearer tokens from this package enable:

  • Mobile GraphQL API access - Required for search, orders, account, and weekly ad
  • Server-side token refresh - No active browser session needed
  • Better bot protection resilience - Tokens don't rely on cookies that can go stale

Cookie sessions from the browser work for cart operations but require an active browser session and can be blocked by bot protection.


License

MIT