From 90d3634486489724595d66bb512c940c23125aa3 Mon Sep 17 00:00:00 2001
From: be beet <63141491+beetcb@users.noreply.github.com>
Date: Sun, 21 Feb 2021 12:11:59 +0800
Subject: [PATCH] fix(tcb): store configs on the cloud
---
README.md | 4 ++--
serverless/cea/index.js | 4 +---
serverless/cea/package.json | 2 +-
3 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/README.md b/README.md
index 8692266..49f0304 100644
--- a/README.md
+++ b/README.md
@@ -6,7 +6,7 @@
c
ampusphere-e
legant-a
uth
- 交互式的配置程序 + 学工系统快速登录
+ 交互式的配置程序 + 学工系统快速登录 + 云端部署及缓存
其返回的 cookie 可直接用于学工系统或今日校园相关验证
@@ -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`,降低出错率;同时,为加快国内访问速度,下载节点托管于码云
diff --git a/serverless/cea/index.js b/serverless/cea/index.js
index d9f2552..b3c658b 100644
--- a/serverless/cea/index.js
+++ b/serverless/cea/index.js
@@ -1,5 +1,3 @@
-// Reset $XDG_CONFIG_HOME
-process.env.XDG_CONFIG_HOME = '/tmp'
const cea = require('@beetcb/cea')
async function signIn(usersWithTask) {
@@ -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
diff --git a/serverless/cea/package.json b/serverless/cea/package.json
index 1526db4..f1e06f7 100644
--- a/serverless/cea/package.json
+++ b/serverless/cea/package.json
@@ -10,6 +10,6 @@
"author": "",
"license": "ISC",
"dependencies": {
- "@beetcb/cea": "^2.0.4"
+ "@beetcb/cea": "^2.0.5"
}
}