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

@cregis/market-app-web-sdk

v1.0.15

Published

Reusable frontend integration layer for third-party app-market web applications.

Readme

market-app-web-sdk

@cregis/market-app-web-sdk is the reusable frontend integration layer for App Market third-party applications.

What it provides

  1. SSO bridge flow
  2. Local auth state storage
  3. HTTP auth interception and re-auth trigger
  4. Route guard and visible-menu navigation
  5. App shell layout helpers
  6. App-scoped permission helpers
  7. Third-party-mode route and permission adaptation

Install

npm install @cregis/market-app-web-sdk

Quick Start

1. Initialize the SDK

import { initCregisMarketAppConfig } from '@cregis/market-app-web-sdk'

initCregisMarketAppConfig({
  sdkServerUrl: import.meta.env.VITE_MARKET_APP_SERVER_URL || 'http://127.0.0.1:48088',
})

Notes:

  1. In third-party mode, sdkServerUrl should point to the real third-party backend
  2. In internal mode, the SDK automatically resolves the API base to {origin}/app-market-api/{appCode}
  3. Frontends must never hold appThirdId/appSecret
  4. If the backend wants to push API errors to marketing by default, set app-market.app-api-error-enabled=true in the server SDK config

2. Create an HTTP client

import { createMarketAppHttp } from '@cregis/market-app-web-sdk'

export const http = createMarketAppHttp()

The backend is expected to return the standard structure below on success:

{
  "code": 200,
  "msg": "success",
  "data": {}
}

Using MarketAppCommonResult<T> from marketing-app-security-sdk is recommended, but any backend response with the same JSON shape is also supported.

3. Install the route guard

import { installMarketAppRouteGuard } from '@cregis/market-app-web-sdk'

installMarketAppRouteGuard(router)

4. Use the SSO bridge

<template>
  <MarketAppSsoBridge
    :bootstrap-login="bootstrapLogin"
    :fetch-menu-access="getCurrentMenuAccess"
    :fetch-data-permission="getCurrentDataPermission"
    :fetch-menus="getCurrentMenus"
  />
</template>

Mode Detection

The SDK decides the runtime mode from the current path:

  1. /app-market/{appCode}/... -> internal mode
  2. Anything else -> third-party mode

In internal mode, the SDK automatically:

  1. Resolves the router base to /app-market/{appCode}
  2. Resolves the API base to {origin}/app-market-api/{appCode}

In third-party mode, the SDK uses the configured sdkServerUrl.

Permission Convention

Business pages are expected to declare permission suffixes, for example:

meta: { menuAccess: ['class:query'] }

The SDK automatically matches them against the current app-scoped permission set.

Environment Variable

Default env variable:

  1. VITE_MARKET_APP_SERVER_URL

Security Rules

  1. Do not expose appThirdId/appSecret to the frontend
  2. Do not call normal marketing admin APIs from the third-party frontend
  3. Keep backend authorization checks even when buttons are hidden in the UI
  4. Keep the backend allow-origins list aligned with the real page origins

Docs

Unified documents:

  1. docs/三方独立应用接入.md
  2. docs/三方独立应用架构设计文档.md