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 🙏

© 2025 – Pkg Stats / Ryan Hefner

sdk-web

v0.4.3

Published

本项目包含一些基础库.

Readme

sdk-web

本项目包含一些基础库.

Framework

  • 主前端使用此类驱动Luigi
// 初始化工具里诶, 配置app code及环境
// 此例子中的环境通是过配置中心注入的
const framework = new sdk.Framework({
    appCode: 'prc',
    env: window.configs.env
})

// 初始化luigi, 加载左侧导航等操作
await framework.init()

Auth

  • 运行时使用此工具类端进行登录, 登出, 权限验证等操作
  • 业务ui可以使用此工具类获取用户部分信息
// 初始化
const auth = new Auth({
    // 参见文档 https://github.com/IdentityModel/oidc-client-js/wiki
    // 下列参数均传入oidc-client库, 重要配置项目说明如下

    // 从dex登录成功后调回的地址, 每个服务都有自己的页面地址, 必须根据情况设置,
    // 比如从`//test.com/a/admin.html`跳转到dex的, 那么redirect_uri一般为`//test.com/a/admin.html`
    redirect_uri: "//localhost:8080",

    // 下述设置说明中的值为默认值, 如果有需要, 可以覆盖

    // dex登录页面地址
    authority: "//lmcp-app-dev.lcfuturecenter.com/dex",

    // 客户端ID, 目前统一定为"console"
    client_id: "console",

    // scope, 设置值如下即可
    scope: "audience:server:client_id:console openid profile email groups",

    // 在refreshtoken不过期的情况下, 自动更新token, 默认开启
    automaticSilentRenew: true,

    // 关闭自动获取oidc用户信息. 默认关闭
    loadUserInfo: false,
})

// 如果有验证信息则进行处理
// 其他后续操作必须在此方法resolve以后操作
await auth.init()

// 进行登录, 跳转至dex
await auth.login()

// 返回是否已登录, 返回布尔值
const logined = await auth.isLogin()

// 登出, 并重定向至dex, 等待登录
await auth.logout()

// 获取验证信息, 未登录返回falsy value, 否则返回有效字符串
const token = auth.getAuth()

// 获取额外信息, 未登录返回falsy value, 否则返回有效字符串
const meta = auth.getMeta()

// 返回一个新对象, 是web请求中需要设置的两种请求头
/* 
Axios.get(
  `http://lmcp-service${prefix}.lcfuturecenter.com/cloud-dev/framework-webproxy/proxy/`,
  {
    headers: {
      ...auth.getHeaders(),
      ExtraHeader: "extra value",
    }
  });
*/
const meta = auth.getHeaders()