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

seiue-c3-session

v0.0.6

Published

Seiue Chalk 3.0 Session

Downloads

1

Readme

Seiue Chalk3.0 Session

Seiue Chalk 3 登录机制,目前,可以通过这个包获取到在 Seiue Passport 登录过的用户的信息。

Get Started

import { SeiueSession } from '@seiue/session'

// 首先设置环境变量
SeiueSession.setEnv({
  SERVER_PASSPORT: 'Pssport 服务地址',
  CLIENT_WEB_CLIENT_ID: "客户端 ID"
})

SeiueSession.create().then(res => {
  // 登录成功后,res 将会返回登录信息
})

登录方式

Passport 登录

通过访问 线上登录地址开发登录地址 并进行登录。登录成功后,再次访问接入了 SeiueSession 的应用,即能获取到登录信息。

其他登录形式等待支持。

修改 Hosts

由于各浏览器强制要求 SameSite policy,与 Cookie 相关的 same-site 将会被默认的设置为 lax。这使得我们从 passport 登陆并获取到的 cookie 无法发送给 localhost,在本地调试时会无法保持登录的 cookie。

因此我们需要修改 /etc/hosts 文件将 localhost 映射为与开发服务器相同的域名:

# 在 hosts 中添加:

127.0.0.1 local.seiue.com

然后在开发中请用 http://local.seiue.com:{port} 替代 localhost:{port}。

如果你在访问 local.seiue.com 时 Chrome 总是自动将 http 修改为 https 导致访问失败,请在 chrome://net-internals/#hsts 中找到 Delete domain security policies,然后输入 local.seiue.com 并点击删除。

如果仍不行,注意一下自己是否使用了魔法上网。如果关闭魔法上网后可以正常访问,那么可以将 local.seiue.com 加入到「系统偏好设置 - 网络 - 代理 - 忽略这些主机和代理设置」当中(此时魔法上网可以开启)

SeiueSession Apis

SeiueSession.setEnv(envs) 配置环境变量

在使用其他 Api 前,请先完整配置环境变量。

参数

  1. envs - Oeject,envs.SERVER_PASSPORT: string, envs.CLIENT_WEB_CLIENT_ID: string - 环境变量

返回值

void

SeiueSession.create 获取身份信息

参数

void

返回值

登录信息,数据结构为

{
  // 登录方式
  authType: string | null
  // Token 信息
  oAuthToken: {
    /**
     * Token 类型,目前仅支持 Bearer
     */
    tokenType: string
    /**
     * Token 过期时间,单位为秒
     */
    expiresIn: number
    /**
     * 请求应该携带的 Access Token
     */
    accessToken: string
    /**
     * 用于刷新 Access Token 的 Refresh Token,有效期为 30 天, 仅 password 授权类型存在此字段。
     */
    refreshToken: string | undefined
  } | null
  // 用户 Reflection id
  rid: number | null
  // 用户 User id
  uid: number | null
  // 用户学校 id
  schoolId: number | null
  // 获取 Token 的时间
  oAuthTokenFetchedAt: number
}

SeiueSession.getSessionState 登录后,直接获取身份信息

在登录后,可以通过该方法再次获取缓存的登录信息。

参数

void

返回值

SeiueSession.create

SeiueSession.destroy 退出登录

参数

void

返回值

void

SeiueSession.refreshOAuthTokenIfNeeded 刷新 Token

判断缓存的 Token 是否过期,然后重新获取新的 Token。

参数

void

返回值

若刷新成功,则返回 token 信息,同 oAuthToken

Notes

  • 目前仅适用于会部署在希悦内部的项目

Bug and Discussions

如果你遇到 bug,可以通过相关微信群或者联系 [email protected]