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

@shopplus/membership-sdk

v0.7.0

Published

会员中台 Data SDK - 请求、类型、业务模型(零运行时依赖,gzip <30KB)

Readme

@shopplus/membership-sdk

Membership platform Data SDK for ShopPlus / Shopify / ShopLine stores. Zero runtime dependencies, gzip < 5KB.

Features

  • Token exchange, auto-refresh, and session management
  • Email/password, SMS, OAuth, and platform token login
  • Member profile, level, and points queries
  • Loyalty discount calculation
  • Points exchange store
  • Referral / invite system
  • Full TypeScript types with L1 anti-corruption layer (camelCase models)
  • Event bus for reactive state updates
  • i18n-ready error codes (106 error codes mapped to message keys)

Install

npm install @shopplus/membership-sdk

Quick Start

import { MembershipClient } from '@shopplus/membership-sdk';

const client = new MembershipClient({
  baseUrl: 'https://api.membership.example.com',
  tenantId: 'your_tenant_id',
});

// Auth: exchange platform token
await client.exchangeToken(platformToken, 'shopplus');

// Or: email login
const result = await client.auth.login({ email: '[email protected]', password: '...' });
// result.token.accessToken, result.user.userMemberId

// Query member profile
const user = await client.member.getProfile();
console.log(user.nickname, user.activePoints, user.currentLevel);

// Query points balance
const balance = await client.points.getBalance();
console.log(balance.available, balance.pending);

Authentication

Four login methods are supported:

// 1. Email + password
await client.auth.login({ email, password });

// 2. SMS verification code
await client.auth.sendSmsCode({ phone: '1234567890', countryCode: '+1' });
await client.auth.smsLogin({ phone: '1234567890', countryCode: '+1', code: '123456' });

// 3. OAuth (Google / Facebook / Apple / Line)
const url = await client.auth.getOAuthUrl('google');
// redirect user to url, then handle callback:
await client.auth.handleOAuthCallback('google', { code, state });

// 4. Platform token exchange
await client.exchangeToken(platformToken, 'shopify');

Token auto-refresh is built-in. Subscribe to token changes:

client.events.on('token-refreshed', (token) => {
  // persist token externally
});

API Modules

All modules are accessible via the client instance:

| Module | Methods | |---|---| | client.member | getProfile(), getLevel() | | client.points | getBalance(), getTransactions() | | client.loyalty | calculateDiscount() | | client.exchange | getProducts(), redeem() | | client.referral | getStats(), getLink(), getInvitees(), bindReferrer() | | client.auth | login(), register(), verifyEmail(), smsLogin(), getOAuthUrl(), ... |

Error Handling

import { MembershipError, SDKErrorCode } from '@shopplus/membership-sdk';

try {
  await client.points.getBalance();
} catch (err) {
  if (err instanceof MembershipError) {
    err.code;          // Business code (210xxx/211xxx) or SDK code (1xxx)
    err.messageKey;    // i18n key, e.g. 'sdk.error.210956'
    err.httpStatus;    // HTTP status
    err.serverMessage; // Raw server message (fallback)

    if (err.isNetworkError) { /* timeout, offline, etc. */ }
    if (err.isBusinessError) { /* server-side business error */ }
  }
}

Configuration

interface MembershipClientConfig {
  baseUrl: string;           // API base URL
  tenantId: string;          // Tenant identifier
  language?: string;         // Preferred locale (default: navigator.language)
  timeout?: number;          // Request timeout in ms (default: 10000)
  tokenProvider?: () => string | null;  // External token provider
}

Module Formats

| Format | File | Usage | |---|---|---| | ESM | dist/index.es.js | import in bundlers | | UMD | dist/index.umd.js | <script> tag or RequireJS | | Types | dist/index.d.ts | TypeScript support |

Browser Support

ES2017+ (Chrome 61+, Firefox 60+, Safari 11+, Edge 79+)

License

MIT