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

jiniu-byteda

v0.1.3

Published

Auth JS SDK for published H5 apps.

Readme

jiniu-byteda

Auth JS SDK for published H5 apps.

This package assumes a browser runtime and reads location, navigator, history, fetch, and localStorage from globalThis.

The package is built as a standard ESM library for Vite projects and publishes dist/index.js as its runtime entry.

Goals

  • Load appId and releaseId from the app link profile API
  • Handle WeChat silent login without manual configuration
  • Configure WeChat share-to-chat and share-to-timeline from the system service account
  • Read the API baseURL from the caller configuration
  • Use an app-scoped x-customer-token header for authenticated requests
  • Keep the public API small and framework-agnostic

Public API

import { ByteDa } from "jiniu-byteda"

const sdk = new ByteDa({
  baseURL: "https://api-test4.jiniutech.com/byte-da",
})

await sdk.init()

const token = sdk.getToken()
sdk.setToken("token-value")

Current public methods:

  • sdk.init()
  • sdk.getToken()
  • sdk.setToken(token)

Before init() finishes:

  • sdk.getToken() returns null
  • sdk.setToken(token) throws because the token storage is not ready yet

Runtime Behavior

ByteDa.init() currently works as an initialization side effect and should be called once before the app renders.

Current flow:

  1. Read API baseURL from new ByteDa({ baseURL })
  2. Send the current page link to /api/apps/link-profile
  3. Read appId, releaseId, name, logo, and description from the link profile response
  4. Fetch /api/apps/{appId}/config
  5. If the current browser is not WeChat, update the page title and favicon
  6. If the current browser is WeChat, run the default silent-login flow:
    • use callback code when present
    • otherwise validate the stored token with /customer-api/v1/auth/profile
    • if no valid token exists, redirect to the WeChat authorize URL
  7. After the WeChat login state is ready, reuse the cached profile for page branding and WeChat share configuration

Notes:

  • ByteDa.init() does not currently return a structured { appConfig, profile, share } object
  • the login_required branch is reserved for later work and is not yet implemented
  • WeChat share configuration only runs inside the WeChat browser
  • the SDK currently does not expose context

Current Scope

First implementation batch:

  • Runtime profile loading
  • Token session storage
  • WeChat authorize URL fetch
  • WeChat callback login
  • WeChat JS-SDK share config
  • App link profile lookup
  • App branding sync for title and favicon

agent-h5 Integration

Install the package:

pnpm add jiniu-byteda

Initialize it before rendering the app:

import { ByteDa } from "jiniu-byteda"
import { createRoot } from "react-dom/client"

import App from "./App.jsx"

const sdk = new ByteDa({
  baseURL: "https://api-test4.jiniutech.com/byte-da",
})

await sdk.init()

createRoot(document.getElementById("root")).render(<App />)

Configuration

baseURL is a required parameter of new ByteDa():

// Test environment
const sdk = new ByteDa({
  baseURL: "https://api-test4.jiniutech.com/byte-da",
})

// Production environment
const sdk = new ByteDa({
  baseURL: "https://api.jiniutech.com/byte-da",
})

You can use environment variables or build-time config to switch between environments:

const sdk = new ByteDa({
  baseURL: import.meta.env.VITE_BYTE_DA_BASE_URL,
})

Package Build

Build the published package output with:

npm run build

This emits the Vite-consumable ESM bundle at dist/index.js.