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

iiot-sso

v0.0.9

Published

sso adapter for iiot platform

Readme

SSO adapter for IIOT platform

安装iiot-sso包到项目中

npm install iiot-sso
 # 如果使用yarn安装
yarn add iiot-sso

使用 iiot-sso库

  1. 配置和初始化,sso库会自动检测当前浏览器上是否有效的登录信息,如果设置checksso为true, 当没有找到登录信息时会自动跳转到用户中心的登录界面

sso库会自动在后台自动刷新token, 若token过期了,authenticated会被设置为false

import { MiniSSO  } from "iiot-sso";

// authServerUrl指定鉴权服务器地址
const miniSso = new MiniSSO({ authServerUrl: 'https://user.example.com' });

// init 会自动验证当前是否有用户登录过。
// checksso 指定是否自动跳转登录页
miniSso.init({ checksso: true }).then((auth: boolean) => {
  if (auth) {
    // Vue.prototype.$miniSso = miniSso;
    console.log('Authenticated');
    console.log('当前登录的用户名:', miniSso.parsedToken.label);
    console.log('当前登录的手机号:', miniSso.parsedToken.phone);
    console.log('当前登录的租户:', miniSso.parsedToken.tenant);
    console.log('当前登录的权限:', miniSso.parsedToken.role)

  }

//   new Vue({
//     render: h => h(App),
//   }).$mount('#app')

}

).catch(error => {
  console.log('Authenticated Failed ------->', error)
})
  1. 跳转到登录页
// redirectUri指定登录成功后的跳转地址
miniSso.login({ redirectUri: location.href  })
  1. 登出
// redirectUri指定登出后的跳转地址
// 注意:登出后会清除用户在此浏览器的token
miniSso.logout({ redirectUri: '/'  })
  1. 获取token信息

miniSso解析了token中的信息,存放在miniSso.parsedToken中,具体格式如下

export interface SSOToken {
    [key: string]: any;
    /**
     * token字符串,调用用户中心的API时需要在请求头中带上此信息,如下
     *   Authorization: Bearer ${token}
     *
     *  token的合法性需要应用后台向中户中心校验
     */
    token: string | null | undefined;
    /**
     * 过期时间,单位:ms
     */
    expired: number;
    /**
     * 用户id
     */
    id: number;
    /**
     * 租户id
     */
    tenant: number;
    /**
     * 可用来显示的用户名称, 如果用户未设置, 可能为空
     */
    label?: string;
    /**
     * 用户手机号,也是用户的登录名
     */
    phone: number;
    /**
     * 用户角色
     * 其中 { meta: ["ADMIN"] } 表示当前用户为租户管理员
     */
    role: {
        [key: string]: string[];
    };
    /**
     * 用户域,即行业应用角色 
     */
    realm: string[]
}