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

@xsyx/xs-kylin-auth

v0.1.5-beta.2

Published

xsyx kylin auth class

Downloads

5

Readme

xs-kylin-auth

中后台接入kylin统一登陆授权包

环境要求
  • chrome V50+

默认接入方式

建议请在路由拦截器中实例化 KylinOidcAuth、PairRoutes

// kylin 授权
import {KylinOidcAuth,PairRoutes}  from '@xsyx/xs-kylin-auth';
// 实例化对象
window.$kylinOidcAuth = new KylinOidcAuth({
  platformKey:"xxxxx", // 平台key
  ssoBaseUrl:"xxxxx" // sso 授权服务地址
});
// 调用方式1: promise 
$kylinOidcAuth.readyPromise().then(function (token) {
  console.log('readyPromise:',token.length);
}).catch(e=>{
  console.log('readyPromise error:',e);
});
// 调用方式2: ready
$kylinOidcAuth.ready(function (token) {
    console.log('====$kylinOidcAuth ready!====',token.length);
});

CDN 接入方式

默认在window对象上挂载XsKylinAuth、$kylinOidcAuth(autoCall参数true的时候$kylinOidcAuth是函数,其他情况是实例)对象

// body 或者 head 引入 
<script src="http://front-prod-cdn.xsyx.xyz/common-lib/0.1.5/@xsyx/xs-kylin-auth/0.1.5/xs-kylin-auth.js"></script>

// 调用方式1:无new promise调用方式
$kylinOidcAuth({
  platformKey:"ec-after-sale-dev",
  ssoBaseUrl:"http://kylin.uat.xsyxsc.cn"
}).readyPromise().then(function (token) {
  console.log('token:',token.length);
}).catch(function (e) {
  console.log('e',e);
});

// 调用方式2:new 实例化方式
window.$kylinOidcAuth = new KylinOidcAuth({
    platformKey:"ec-after-sale-dev",
    ssoBaseUrl:"http://kylin.uat.xsyxsc.cn"
})
$kylinOidcAuth.readyPromise().then(function (token) {
    console.log('readyPromise:',token.length);
}).catch(e=>{
    console.log('readyPromise error:',e);
});

// 调用方式3:ready方式(只允许调用一次,并且只执行第一次)
// 配置优先注入式 window.$kylinAuthConfig,需要引用xs-kylin-auth.js之前引入
<script type="text/javascript">
window.$kylinAuthConfig={
  autoCall:true, // 必须为true
  platformKey:"",
  ssoBaseUrl:""
}
</script>

$kylinOidcAuth.ready(function (token){
  // this 指向的是 $kylinOidcAuth
  console.log('====$kylinOidcAuth ready !====',token.length);
  // 获取权限(菜单、用户、按钮)
  // Promise.all([this.oidcAuthMenu(),this.oidcUserInfo(),this.oidcAuthButton()]).then(data=>{
  //   console.log('===data===',data);
  // }).catch(e=>{
  //
  // })
})

安全退出登录

window.$globalOidc.signoutRedirect();

KylinOidcAuth 类

    new KylinOidcAuth(options)

入参 options (object)

|参数名称|类型|默认值| 说明 | |----|----|----|----| | platformKey | String |- |kylin 平台key| | ssoBaseUrl | String |- |kylin 服务请求地址| | saveCookie | Boolean |false|是否开启cookie存储token| | useStore | Boolean |false|是否开启cookie存储token| | userManagerConfig | Object |{}|oidc-client,UserManager类扩展入参数| | authCode | Number |1001|kylin请求成功code(请勿随意修改)| | expireCode | Number |401|kylin请求失败code(请勿随意修改)|

方法

isOidc

返回 window.$globalOidc ,判断oidc 是否实例化UserManager

ready

正常获取到token钩子函数(只执行一次),回调函数带回token

readyPromise

ready方法的promise调用,回调函数带回token

oidcAuthMenu

获取权限页面菜单

oidcUserInfo

获取当前登录用户信息

oidcAuthButton

获取所有按钮权限

  • 参数key 默认 'button_Code',用于筛选按钮组
checkSSOLogin

检测是否登陆kylin

signIn

跳转到登录页

signOut

退出登录

oidcLoginOut(旧)不推荐

手动退出登录

getAuthInfo(旧)不推荐

获取用户认证信息token

PairRoutes 类

后端菜单修改前端路由信息

  • asideMenu 平台服务器返回菜单
  • localRoute 本地路由信息
new PairRoutes(asideMenu,localRoute)
.output

获取后端菜单 映射前端的路由信息