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

@mu-cabin/opms-permission

v0.9.29

Published

Frontend SDK for OPMS permission and auth management.

Readme

@mu-cabin/opms-permission

简介

@mu-cabin/opms-permission 是一个用于 OPMS 权限与认证管理的前端 SDK,支持资源、菜单、组织、用户信息的统一获取与本地缓存,适用于需要接入 OPMS 权限体系的前端项目。

安装

pnpm add @mu-cabin/opms-permission
# 或
yarn add @mu-cabin/opms-permission
# 或
npm install @mu-cabin/opms-permission

主要功能

  • SSO 单点登录/登出跳转
  • 用户信息获取与本地缓存
  • 资源、菜单、控件权限获取与处理
  • 组织树、公司信息查询
  • 本地存储自动过期管理

快速开始

import { OpmsPermission, jumpToSSOLogin, jumpToSSOLogout } from '@mu-cabin/opms-permission';

const permission = new OpmsPermission({
  systemId: 1001, // 系统ID
  baseUrl: 'https://your-api-domain/opms', // OPMS后端接口地址
  ssoBaseUrl: 'https://your-sso-domain', // SSO登录地址
});

// 登录(需URL带有code参数)
await permission.login();

// 获取用户信息
const userInfo = await permission.getUserInfo();

// 获取资源、菜单、控件权限
const { resources, menuList, widgetMap } = await permission.getResources(userInfo.account);

// 跳转到SSO登录
jumpToSSOLogin({ baseUrl: 'https://your-sso-domain' });

// 跳转到SSO登出
jumpToSSOLogout({ baseUrl: 'https://your-sso-domain', redirectToUrl: window.location.origin });

主要API

类:OpmsPermission

| 方法 | 说明 | | ---- | ---- | | login() | SSO登录,获取并缓存token | | logout() | 登出并清除本地缓存 | | getUserInfo() | 获取当前用户信息 | | getResources(uniAccount) | 获取资源、菜单、控件权限 | | queryOrgs() | 获取组织树 | | queryCompanies() | 获取公司信息 | | isLogin() | 判断当前是否已登录 | | getToken() | 获取当前token |

SSO 工具方法

  • jumpToSSOLogin({ baseUrl, redirectUrl?, clientId? }) 跳转到SSO登录页
  • jumpToSSOLogout({ baseUrl, redirectToUrl, clientId? }) 跳转到SSO登出页

类型说明

  • Resource 资源对象,包含资源ID、类型、路径、子节点等
  • MenuItem 菜单项对象,包含菜单路径、名称、子菜单等
  • UserInfo 用户信息对象,包含账号、姓名、工号、组织等
  • UserOrganization 用户组织信息

常见问题

  1. 为什么获取不到资源/菜单?
    • 请确保已正确登录(URL带有code参数),并且接口地址、systemId 配置正确。
  2. 本地缓存多久失效?
    • 资源、菜单等默认缓存24小时,超时会自动重新拉取。
  3. 如何自定义SSO clientId?
    • jumpToSSOLoginjumpToSSOLogout 方法均支持传入 clientId 参数。

License