Skip to content
This repository has been archived by the owner on Jun 3, 2021. It is now read-only.

Commit

Permalink
fix(tcb): store configs on the cloud
Browse files Browse the repository at this point in the history
  • Loading branch information
beetcb committed Feb 21, 2021
1 parent eb666a3 commit 90d3634
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<strong><p align="center"><code>c</code>ampusphere-<code>e</code>legant-<code>a</code>uth</p></strong>

<p align="center">
交互式的配置程序 + 学工系统快速登录
交互式的配置程序 + 学工系统快速登录 + 云端部署及缓存
<br>
其返回的 <strong>cookie</strong> 可直接用于学工系统或今日校园相关验证
<br>
Expand Down Expand Up @@ -162,7 +162,7 @@

- 交互式配置: `campusphere-elegant-auth` 提供交互式的命令行完成 用户 及 学校 的配置,同时也支持使用 `toml` 文件来配置

- 验证持久化: 缓存验证信息于内存, 只在失效时更新
- 验证持久化: 缓存验证信息于内存, 只在失效时登录并更新;云端和本地缓存能力来源于我的另一个项目 [sstore](https://github.com/beetcb/sstore)

- 兼容云服务的 OCR:很多云服务(如云函数)的文件系统并不都是可写入的,我们将 OCR 验证码识别用到的 [tesseract.js](https://github.com/naptha/tesseract.js) 数据包和训练缓存包暂存到了 `/tmp`,降低出错率;同时,为加快国内访问速度,下载节点托管于码云

Expand Down
4 changes: 1 addition & 3 deletions serverless/cea/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// Reset $XDG_CONFIG_HOME
process.env.XDG_CONFIG_HOME = '/tmp'
const cea = require('@beetcb/cea')

async function signIn(usersWithTask) {
Expand All @@ -16,7 +14,7 @@ async function signIn(usersWithTask) {

async function handler() {
// load config from toml or env
await cea.load()
await cea.init()
// Log in and save cookie to cea, using cea.get('cookie') to get them (this function resolve with an users array)
const usersWithTask = await cea.handleCookie()
// Sign in
Expand Down
2 changes: 1 addition & 1 deletion serverless/cea/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
"author": "",
"license": "ISC",
"dependencies": {
"@beetcb/cea": "^2.0.4"
"@beetcb/cea": "^2.0.5"
}
}

0 comments on commit 90d3634

Please sign in to comment.