@robertying/thu-learn-lib 5.0.0 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +94 -227
- package/lib/auth.d.ts +15 -4
- package/lib/auth.d.ts.map +1 -1
- package/lib/auth.js +65 -55
- package/lib/auth.js.map +1 -1
- package/lib/calendar.d.ts +12 -5
- package/lib/calendar.d.ts.map +1 -1
- package/lib/calendar.js +118 -20
- package/lib/calendar.js.map +1 -1
- package/lib/contents.d.ts.map +1 -1
- package/lib/contents.js +10 -6
- package/lib/contents.js.map +1 -1
- package/lib/courses.d.ts.map +1 -1
- package/lib/courses.js +15 -29
- package/lib/courses.js.map +1 -1
- package/lib/discussions.d.ts.map +1 -1
- package/lib/discussions.js +8 -19
- package/lib/discussions.js.map +1 -1
- package/lib/favorites.d.ts +1 -0
- package/lib/favorites.d.ts.map +1 -1
- package/lib/favorites.js +25 -60
- package/lib/favorites.js.map +1 -1
- package/lib/files.d.ts +4 -4
- package/lib/files.d.ts.map +1 -1
- package/lib/files.js +112 -134
- package/lib/files.js.map +1 -1
- package/lib/homework.d.ts +35 -5
- package/lib/homework.d.ts.map +1 -1
- package/lib/homework.js +150 -92
- package/lib/homework.js.map +1 -1
- package/lib/index.d.ts +45 -20
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +52 -17
- package/lib/index.js.map +1 -1
- package/lib/notices.d.ts +4 -4
- package/lib/notices.d.ts.map +1 -1
- package/lib/notices.js +13 -33
- package/lib/notices.js.map +1 -1
- package/lib/questionnaires.d.ts +6 -3
- package/lib/questionnaires.d.ts.map +1 -1
- package/lib/questionnaires.js +26 -24
- package/lib/questionnaires.js.map +1 -1
- package/lib/request.d.ts +64 -20
- package/lib/request.d.ts.map +1 -1
- package/lib/request.js +174 -64
- package/lib/request.js.map +1 -1
- package/lib/timetable.d.ts +26 -0
- package/lib/timetable.d.ts.map +1 -0
- package/lib/timetable.js +110 -0
- package/lib/timetable.js.map +1 -0
- package/lib/types.d.ts +117 -76
- package/lib/types.d.ts.map +1 -1
- package/lib/types.js +3 -0
- package/lib/types.js.map +1 -1
- package/lib/urls.d.ts +10 -20
- package/lib/urls.d.ts.map +1 -1
- package/lib/urls.js +11 -56
- package/lib/urls.js.map +1 -1
- package/lib/user.d.ts +7 -2
- package/lib/user.d.ts.map +1 -1
- package/lib/user.js +20 -6
- package/lib/user.js.map +1 -1
- package/lib/utils.d.ts +42 -4
- package/lib/utils.d.ts.map +1 -1
- package/lib/utils.js +80 -29
- package/lib/utils.js.map +1 -1
- package/package.json +9 -8
- package/src/auth.ts +72 -70
- package/src/calendar.ts +136 -24
- package/src/contents.ts +13 -6
- package/src/courses.ts +21 -37
- package/src/discussions.ts +10 -21
- package/src/favorites.ts +44 -80
- package/src/files.ts +124 -142
- package/src/homework.ts +207 -135
- package/src/index.ts +79 -48
- package/src/notices.ts +29 -42
- package/src/questionnaires.ts +62 -45
- package/src/request.ts +192 -69
- package/src/timetable.ts +121 -0
- package/src/types.ts +123 -87
- package/src/urls.ts +13 -64
- package/src/user.ts +22 -7
- package/src/utils.ts +97 -29
package/README.md
CHANGED
|
@@ -7,40 +7,23 @@ This is a JavaScript library aimed to provide a program-friendly interface of [w
|
|
|
7
7
|
|
|
8
8
|
This is [robertying](https://github.com/robertying)'s fork of [Harry-Chen/thu-learn-lib](https://github.com/Harry-Chen/thu-learn-lib), maintained for [learnX](https://github.com/robertying/learnX) and published as `@robertying/thu-learn-lib`.
|
|
9
9
|
|
|
10
|
-
This project is licensed under MIT License.
|
|
10
|
+
This project is licensed under MIT License. See [CHANGELOG.md](CHANGELOG.md) for release notes and [CONTRIBUTING.md](CONTRIBUTING.md) for development, testing and releasing.
|
|
11
11
|
|
|
12
12
|
## Compatibility
|
|
13
13
|
|
|
14
14
|
The library is ESM-only and uses [node-fetch-native](https://github.com/unjs/node-fetch-native) with [fetch-cookie](https://github.com/valeriangalliat/fetch-cookie) for cookie and redirect support. It runs in Node and in React Native; you can also pass your own `fetch` in `HelperConfig`.
|
|
15
15
|
|
|
16
|
+
Browsers block these cross-origin requests (CORS), so run the library in Node.js or React Native.
|
|
17
|
+
|
|
16
18
|
## Installation
|
|
17
19
|
|
|
18
20
|
```bash
|
|
19
21
|
pnpm add @robertying/thu-learn-lib
|
|
20
22
|
```
|
|
21
23
|
|
|
22
|
-
## Development
|
|
23
|
-
|
|
24
|
-
```bash
|
|
25
|
-
pnpm install
|
|
26
|
-
pnpm typecheck
|
|
27
|
-
pnpm lint
|
|
28
|
-
pnpm format
|
|
29
|
-
pnpm test
|
|
30
|
-
pnpm build # emits ESM + .d.ts to lib/
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
The code is split by area under `src/`: `request.ts` (session, CSRF token, re-login), `auth.ts`, `courses.ts`, `notices.ts`, `files.ts`, `homework.ts`, `discussions.ts`, `questionnaires.ts`, `favorites.ts`, `calendar.ts`, `contents.ts` and `user.ts`. `index.ts` holds the public `Learn2018Helper` class, which passes its private session to those functions.
|
|
34
|
-
|
|
35
|
-
Linting uses type-aware [oxlint](https://oxc.rs/docs/guide/usage/linter) and formatting uses [oxfmt](https://oxc.rs/docs/guide/usage/formatter).
|
|
36
|
-
|
|
37
|
-
## Releasing
|
|
38
|
-
|
|
39
|
-
Bump `version` in `package.json`, merge, then push a matching tag (for example `git tag v4.1.0 && git push origin v4.1.0`). The Release workflow checks, builds, publishes to npm with provenance (npm trusted publishing, no token) and creates a GitHub release.
|
|
40
|
-
|
|
41
24
|
## Usage
|
|
42
25
|
|
|
43
|
-
###
|
|
26
|
+
### Logging in
|
|
44
27
|
|
|
45
28
|
```typescript
|
|
46
29
|
import { Learn2018Helper } from '@robertying/thu-learn-lib';
|
|
@@ -64,36 +47,43 @@ const helper = new Learn2018Helper({
|
|
|
64
47
|
|
|
65
48
|
// Without a CredentialProvider you must log in yourself. With one, the first request logs in.
|
|
66
49
|
try {
|
|
67
|
-
await helper.login(username, password, fingerPrint);
|
|
50
|
+
await helper.login({ username, password, fingerPrint });
|
|
68
51
|
} catch (e) {
|
|
69
52
|
// e is an ApiError: check e.reason (a FailReason) and e.extra
|
|
70
53
|
}
|
|
71
54
|
|
|
55
|
+
// When resuming with a saved CSRF token and cookie jar, ensureSession logs in again only if the
|
|
56
|
+
// session has expired.
|
|
57
|
+
helper.setCSRFToken(savedToken);
|
|
58
|
+
await helper.ensureSession();
|
|
59
|
+
|
|
72
60
|
// To reuse cookies elsewhere (e.g. for file download), pass your own cookie jar in the config.
|
|
73
61
|
|
|
74
62
|
// Logout if you want, but the cookie jar will not be cleared.
|
|
75
63
|
await helper.logout();
|
|
76
64
|
```
|
|
77
65
|
|
|
78
|
-
|
|
66
|
+
`HelperConfig` also takes `maxConcurrentRequests` (default 6) and `requestTimeout` (milliseconds, default 60000).
|
|
79
67
|
|
|
80
|
-
|
|
68
|
+
### Courses and content
|
|
69
|
+
|
|
70
|
+
We currently support both student and teacher (or TA) version of web learning. To keep backwards compatibility, the **default behavior of all APIs is to use the student version**. The following APIs take an optional `courseType`; pass `CourseType.TEACHER` to access the teacher version. You **should use them when you are the teacher / TA** of one course, for you will get nothing from the student version in that case.
|
|
81
71
|
|
|
82
72
|
We do not maintain a global type in `Learn2018Helper` class, for there can be the situation that one can be a student and teacher of the same course simultaneously, on which by using different `CourseType` you can get different results.
|
|
83
73
|
|
|
84
|
-
- `getCourseList`
|
|
85
|
-
- `getNotificationList
|
|
86
|
-
- `
|
|
74
|
+
- `getCourseList(semesterID, courseType, lang, options)`
|
|
75
|
+
- `getNotificationList(courseID, courseType, options)`, `getHomeworkList(courseID, courseType, options)`
|
|
76
|
+
- `getFileList/getFileCategoryList/getDiscussionList/getAnsweredQuestionList(courseID, courseType)`, `getFileListByCategory(courseID, categoryID, courseType)`
|
|
77
|
+
- `getNotificationAttachment(notification, courseType)`, `getUserInfo(courseType)`
|
|
78
|
+
- `getAllContents(courseIDs, type, { courseType })`
|
|
87
79
|
|
|
88
80
|
Note that currently fetching homework information from teacher version is **partially implemented**.
|
|
89
81
|
|
|
90
82
|
```typescript
|
|
91
|
-
import { ContentType, ApiError } from '@robertying/thu-learn-lib';
|
|
92
|
-
|
|
93
83
|
// get ids of all semesters that current account has access to
|
|
94
84
|
const semesters = await helper.getSemesterIdList();
|
|
95
85
|
|
|
96
|
-
// get
|
|
86
|
+
// get semester info
|
|
97
87
|
const semester = await helper.getCurrentSemester();
|
|
98
88
|
|
|
99
89
|
// get courses of this semester
|
|
@@ -106,215 +96,92 @@ const notifications = await helper.getNotificationList(course.id);
|
|
|
106
96
|
const files = await helper.getFileList(course.id);
|
|
107
97
|
const homework = await helper.getHomeworkList(course.id);
|
|
108
98
|
const questions = await helper.getAnsweredQuestionList(course.id);
|
|
99
|
+
// questionnaires fetch their questions (one request each) unless you pass { details: 'none' }
|
|
100
|
+
const questionnaires = await helper.getQuestionnaireList(course.id, { details: 'none' });
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Every time field is a `ServerTime`: an ISO 8601 string in Beijing time with its offset (`2026-11-07T18:28:00+08:00`), which `new Date()` reads as the right moment in any time zone.
|
|
104
|
+
|
|
105
|
+
The lists give `CourseNotification`, `CourseFile`, `Homework`, `Discussion`, `Question` and `Questionnaire` items. A type for an item without its on-demand detail ends in `Base` (`HomeworkBase`, `CourseNotificationBase`), and the detail alone in `Detail` (`HomeworkDetail`).
|
|
106
|
+
|
|
107
|
+
### Details on demand
|
|
109
108
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
109
|
+
Details cost extra requests per item, so they are opt-in; fetch the rest on demand.
|
|
110
|
+
|
|
111
|
+
```typescript
|
|
112
|
+
import { ContentType } from '@robertying/thu-learn-lib';
|
|
113
|
+
|
|
114
|
+
const withDetails = await helper.getHomeworkList(course.id, undefined, { details: (h) => !h.submitted });
|
|
115
|
+
const detail = await helper.getHomeworkDetail(homework[0]);
|
|
116
|
+
const attachment = await helper.getNotificationAttachment(notifications[0]);
|
|
117
|
+
|
|
118
|
+
// get one type of content from many courses; a course that fails is in `errors` instead of failing the rest
|
|
119
|
+
const { contents, errors } = await helper.getAllContents(
|
|
120
|
+
courses.map((c) => c.id),
|
|
121
|
+
ContentType.HOMEWORK,
|
|
122
|
+
{ details: 'none' },
|
|
123
|
+
);
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Calendar
|
|
127
|
+
|
|
128
|
+
```typescript
|
|
129
|
+
import { ApiError } from '@robertying/thu-learn-lib';
|
|
114
130
|
|
|
115
131
|
// get course calendar in a period (yyyymmdd, inclusive)
|
|
116
|
-
// ranges over 28 days are fetched in windows; windows that fail
|
|
132
|
+
// ranges over 28 days are fetched in windows; windows that still fail are in failedRanges
|
|
117
133
|
try {
|
|
118
134
|
const { events, failedRanges } = await helper.getCalendar('20191001', '20191201', { graduate: false });
|
|
119
135
|
} catch (e) {
|
|
120
|
-
// every window failed
|
|
136
|
+
// every window failed, or signing in to the registrar failed
|
|
121
137
|
const error = e as ApiError;
|
|
122
138
|
// check e.reason and e.extra for information
|
|
123
139
|
}
|
|
124
140
|
```
|
|
125
141
|
|
|
126
|
-
|
|
142
|
+
Off campus the registrar is reached through WebVPN, which reuses the id.tsinghua.edu.cn session of the last `login`. When that session has expired (e.g. in a session resumed from saved cookies), a helper with a `CredentialProvider` logs in again and tries once more.
|
|
143
|
+
|
|
144
|
+
### Timetable
|
|
145
|
+
|
|
146
|
+
The registrar's calendar knows about holidays and moved classes, but it fails now and then. A timetable can also be worked out from each course's time and location (`getCourseList(..., { timeAndLocation: true })`) and the term's first day:
|
|
147
|
+
|
|
148
|
+
```typescript
|
|
149
|
+
import { CLASS_PERIOD_TIMES, parseCourseMeeting, semesterWeek } from '@robertying/thu-learn-lib';
|
|
150
|
+
|
|
151
|
+
// '星期六第1节(9,11周),六教6A414' (or 'Section 1 of Sat (Week 9,11 ), 六教6A414' in English)
|
|
152
|
+
const meeting = parseCourseMeeting(course.timeAndLocation[0]);
|
|
153
|
+
// { weekday: 6, period: 1, weeks: [9, 11], location: '六教6A414' }; weeks is null for every week
|
|
154
|
+
const [start, end] = CLASS_PERIOD_TIMES[meeting.period]; // Beijing time, ['08:00', '09:35']
|
|
155
|
+
|
|
156
|
+
// the teaching week of a Beijing date; week 1 starts on the Monday after a weekend first day
|
|
157
|
+
const week = semesterWeek(semester.startDate, '2026-11-04');
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### Submitting homework
|
|
161
|
+
|
|
162
|
+
```typescript
|
|
163
|
+
import { homeworkContentHtml } from '@robertying/thu-learn-lib';
|
|
164
|
+
|
|
165
|
+
// the answer is HTML and replaces the submitted one; pass the submitted HTML to only change the attachment
|
|
166
|
+
await helper.submitHomework(homework.studentHomeworkId, homeworkContentHtml('my answer'), {
|
|
167
|
+
filename: 'answer.pdf',
|
|
168
|
+
content: blob, // in React Native: { uri, type }
|
|
169
|
+
});
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
`fetch` can't report upload progress. To send the submission with another HTTP client, get the request with `getHomeworkSubmitRequest` (it checks the session first) and read the answer with `checkHomeworkSubmitResponse`:
|
|
173
|
+
|
|
174
|
+
```typescript
|
|
175
|
+
import { checkHomeworkSubmitResponse } from '@robertying/thu-learn-lib';
|
|
176
|
+
|
|
177
|
+
const { url, body } = await helper.getHomeworkSubmitRequest(id, content, attachment);
|
|
178
|
+
const res = await axios.post(url, body, { onUploadProgress });
|
|
179
|
+
checkHomeworkSubmitResponse(res.data);
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### Errors
|
|
127
183
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
See `src/types.ts` for type definitions. Note that `ApiError` represents the type that will be used in rejected Promises.
|
|
131
|
-
|
|
132
|
-
## Testing
|
|
133
|
-
|
|
134
|
-
`pnpm test` runs the offline tests. They give the helper a fake `fetch` (`test/helpers/fake-server.ts`) that serves hand-written responses shaped like Web Learning's, simulates SSO login and session expiry, and records every request so tests can also check how many requests an API makes.
|
|
135
|
-
|
|
136
|
-
`pnpm test:live` runs the tests against the real server. It needs your own credentials: copy `test/live/template.env` to `test/live/.env` and fill it in.
|
|
137
|
-
|
|
138
|
-
## Changelog
|
|
139
|
-
|
|
140
|
-
- v4.1.0
|
|
141
|
-
- Published as `@robertying/thu-learn-lib`
|
|
142
|
-
- Tooling: pnpm, TypeScript 7 (`tsc` ESM + `.d.ts` build), oxlint + oxfmt, Vitest 5, Node 26
|
|
143
|
-
- (_BREAKING CHANGE_) Drop the IIFE browser build and the browser-extension demo
|
|
144
|
-
- Code split into modules, with offline tests
|
|
145
|
-
- No API changes
|
|
146
|
-
- v4.0.0
|
|
147
|
-
- Upgrade cheerio to 1.0
|
|
148
|
-
- Add support for questionnaire (add `getQuestionnaireList` API and some public types)
|
|
149
|
-
- Add support for managing favorite items
|
|
150
|
-
- Add support for sorting courses (i.e. manage the order on web learning)
|
|
151
|
-
- Add support for managing comments on content (e.g. files, notifications)
|
|
152
|
-
- (_BREAKING CHANGE_) Deprecate usage of `studentHomeworkId`
|
|
153
|
-
- v3.2.1
|
|
154
|
-
- Upgrade to eslint v9
|
|
155
|
-
- Add `setCSRFToken` function to manually reuse previous (maybe valid) token and prevent unnecessary re-login (see [#49](https://github.com/Harry-Chen/thu-learn-lib/issues/49))
|
|
156
|
-
_Note:_ To use this feature in Node.js, `cookieJar` should also be reused, otherwise it will not work. (not the case in browser env)
|
|
157
|
-
- Fix `CourseContent` type: default value for type param `T` (breaking change introduced in [#53](https://github.com/Harry-Chen/thu-learn-lib/issues/53))
|
|
158
|
-
- _(Breaking...?)_ Rename `File.id2` added in previous version to actual `id` and previously used `id` to `fileId` (see [#60](https://github.com/Harry-Chen/thu-learn-lib/issues/60))
|
|
159
|
-
- Upgrade dependencies
|
|
160
|
-
- v3.2.0
|
|
161
|
-
- Support file categories (see [#57](https://github.com/Harry-Chen/thu-learn-lib/issues/57)):
|
|
162
|
-
- Add `FileCategory` type and optional `category` field in `File` type
|
|
163
|
-
- Now `getFileList` function automatically fetches all categories and saves them in each `File` object
|
|
164
|
-
- Add `getFileCategoryList` function to fetch file categories
|
|
165
|
-
- Add `getFileListByCategory` function to get file list by category
|
|
166
|
-
- Fix content of file download url and visit count in for `CourseType.TEACHER`
|
|
167
|
-
- v3.1.4
|
|
168
|
-
- Allow and check for undefined credential in login (see [#52](https://github.com/Harry-Chen/thu-learn-lib/issues/52))
|
|
169
|
-
- Discriminate `getAllContents` return type based on input content type (see [#53](https://github.com/Harry-Chen/thu-learn-lib/issues/53))
|
|
170
|
-
- Use `searchParams` to set csrf token & add csrf token to `getCalendar` (see [#54](https://github.com/Harry-Chen/thu-learn-lib/issues/54))
|
|
171
|
-
- Update bunches of dependencies
|
|
172
|
-
- v3.1.3
|
|
173
|
-
- Fix empty time and location of course (see [#145](https://github.com/Harry-Chen/Learn-Helper/issues/145))
|
|
174
|
-
- v3.1.2
|
|
175
|
-
- Fix empty course name parsing
|
|
176
|
-
- (Maybe BEARKING) `Homework.gradeLevel` changed to `HomeworkGradeLevel` (a string enum) for better i18n
|
|
177
|
-
- Fix get language
|
|
178
|
-
- v3.1.1
|
|
179
|
-
- Remove `fetch-cookie` dependency in browser build, reducing bundle size
|
|
180
|
-
- Add `getUserInfo` interface (#48, thanks to @robertying)
|
|
181
|
-
- v3.1.0
|
|
182
|
-
- **Refactor**:
|
|
183
|
-
- Build tool: `webpack` -> `tsup`
|
|
184
|
-
- Development tool: `webpack` -> `vite`
|
|
185
|
-
- Test tool: `jest` -> `vitest`
|
|
186
|
-
- Fetch:
|
|
187
|
-
- `cross-fetch` -> `node-fetch-native` (Node.js now has native `fetch`)
|
|
188
|
-
- `real-isomorphic-fetch` -> `fetch-cookie` (`fetch-cookie` now can handle redirects)
|
|
189
|
-
- `tough-cookie-no-native` -> `tough-cookie` (`tough-cookie` is now native)
|
|
190
|
-
- **(BREAKING)** Updated library output structure, now everything exported in index, cannot use `/lib` or `/lib/types` anymore
|
|
191
|
-
- Added:
|
|
192
|
-
- Submit homework
|
|
193
|
-
- Language switching and related behaviour
|
|
194
|
-
- Get TA's homework info (partial support)
|
|
195
|
-
- Fixed:
|
|
196
|
-
- **Web Learning API update**
|
|
197
|
-
- Decode course name
|
|
198
|
-
- Other:
|
|
199
|
-
- Move `fake-parse5` to [a seperate library](https://github.com/AsakuraMizu/fake-parse5)
|
|
200
|
-
- v3.0.4
|
|
201
|
-
- No feature changes, upgrade dependencies
|
|
202
|
-
- v3.0.3
|
|
203
|
-
- No feature changes, upgrade dependencies
|
|
204
|
-
- v3.0.2
|
|
205
|
-
- No feature changes, upgrade dependencies to mitigate security vulnerabilities
|
|
206
|
-
- v3.0.1
|
|
207
|
-
- Add config `generatePreviewUrlForFirstPage` to switch preview URL type (default to `true`)
|
|
208
|
-
- v3.0.0
|
|
209
|
-
- (BREAKING CHANGE) Redesign exported types, use `RemoteFile` to represent a file on Web Learning
|
|
210
|
-
- Add support for parsing attachment sizes & preview URLs in homework & notifications (Harry-Chen/Learn-Helper#109)
|
|
211
|
-
- v2.5.4
|
|
212
|
-
- Fix (sometimes) incorrect publish time of notifications (#36)
|
|
213
|
-
- v2.5.3
|
|
214
|
-
- Add `allowFailure` in `getAllContents` for convenience
|
|
215
|
-
- v2.5.2
|
|
216
|
-
- Allow retrieving CSRF token via `getCSRFToken` method
|
|
217
|
-
- Export `addCSRFTokenToUrl` function as API for convenience
|
|
218
|
-
- v2.5.1
|
|
219
|
-
- No feature change, add support for direct `import` in Node.js
|
|
220
|
-
- v2.5.0
|
|
221
|
-
- Add transparent support for CSRF token (recently deployed) in all Web Learning APIs
|
|
222
|
-
- v2.4.2
|
|
223
|
-
- No functionality change, bump some dependencies to mitigate security concerns
|
|
224
|
-
- v2.4.1
|
|
225
|
-
- Replace `parse5` with `htmlparser2` in Cheerio and remove it from bundled file (replaced with `src/fake-parse5`)
|
|
226
|
-
- Replace TSLint with ESLint
|
|
227
|
-
- v2.4.0
|
|
228
|
-
- Upgrade to TypeScript 4.1 & Webpack 5.15
|
|
229
|
-
- Add more null checking for disabled functionalities (see [xxr3376/Learn-Project#90](https://github.com/xxr3376/Learn-Project/issues/90))
|
|
230
|
-
- v2.3.2
|
|
231
|
-
- Fix a problem in `v2.3.1` (not published) and `v2.3.0` that build output fails to be uploaded to npm
|
|
232
|
-
- v2.3.0
|
|
233
|
-
- Refine error detecting & handling by using `ApiError` in usage of `Promise.reject` (might be a breaking change)
|
|
234
|
-
- v2.2.3
|
|
235
|
-
- Add workaround for some strange behaviors in teacher mode (thanks to @MashPlant)
|
|
236
|
-
- v2.2.2
|
|
237
|
-
- Return error when API return any non-success result
|
|
238
|
-
- v2.2.1
|
|
239
|
-
- Fix a missing parameter in `previewUrl`
|
|
240
|
-
- v2.2.0
|
|
241
|
-
- Use ECMAScript private fields in `Learn2018Helper` class to protect credentials
|
|
242
|
-
- Add `previewUrl` to `File`
|
|
243
|
-
- Upgrade to TypeScript 3.8.2
|
|
244
|
-
- v2.1.2
|
|
245
|
-
- Fix problem in invoking JSONP callback (because some engines might do JIT)
|
|
246
|
-
- v2.1.1
|
|
247
|
-
- Remove usage of `eval` in `getCalendar`
|
|
248
|
-
- v2.1.0
|
|
249
|
-
- Catch errors returned by calendar API and throw user-defined error
|
|
250
|
-
- Add documentation for all public APIs
|
|
251
|
-
- v2.0.0
|
|
252
|
-
- Use ES2018 in generated library
|
|
253
|
-
- Add `FailReason` to represent all strings that will be used as the reason of rejected Promises
|
|
254
|
-
- `login` and `logout` no longer return Promises
|
|
255
|
-
- v1.2.2
|
|
256
|
-
- Fix a function signature to keep compatibility
|
|
257
|
-
- v1.2.1
|
|
258
|
-
- Support TA version of many APIs (see above for usage)
|
|
259
|
-
- Fix some wrong URLs in fetched data
|
|
260
|
-
- v1.2.0
|
|
261
|
-
- Support getting course calendars from academic.tsinghua.edu.cn (thanks to robertying)
|
|
262
|
-
- Automatic retry logging in when fetching failed and `CredentialProvider` is provided (thanks to mayeths)
|
|
263
|
-
- Add unit tests using `jest` (thanks to mayeths)
|
|
264
|
-
- Filter out `null` values in `getSemesterIdList` API
|
|
265
|
-
- Switch to `https://learn.tsinghua.edu.cn/` from `learn2018` permanently
|
|
266
|
-
- v1.1.4
|
|
267
|
-
- Return empty array if any content module is disabled
|
|
268
|
-
- Add `getTACourseList` to get TA's course list (temporarily can not be used by other functions)
|
|
269
|
-
- v1.1.3
|
|
270
|
-
- Emergency fix of wrongly decoded base64 string, add `js-base64` back
|
|
271
|
-
- v1.1.2
|
|
272
|
-
- Switch to `Base64.js` instead of `js-base64`, which uses evil `eval`
|
|
273
|
-
- v1.1.1
|
|
274
|
-
- Decode HTML entities in the title of disscussions (the last one, I promise!)
|
|
275
|
-
- v1.1.0
|
|
276
|
-
- Fix an typo in grade level mapping
|
|
277
|
-
- Bump to a new minor version
|
|
278
|
-
- v1.0.16 (no v1.0.15 due to some publishing issues)
|
|
279
|
-
- Switch to `yarn`
|
|
280
|
-
- Add parsing of grade levels of homework (A+/A/.../F)
|
|
281
|
-
- v1.0.14
|
|
282
|
-
- Add prefix for `attachmentUrl` filed of Notification
|
|
283
|
-
- Deprecate all old versions
|
|
284
|
-
- v1.0.13
|
|
285
|
-
- Decode HTML entities whenever possible
|
|
286
|
-
- v1.0.12
|
|
287
|
-
- Add `url` for Course
|
|
288
|
-
- Fix `url` for Question (to display correct section name)
|
|
289
|
-
- v1.0.11
|
|
290
|
-
- Fix `url` error in Question
|
|
291
|
-
- v1.0.10
|
|
292
|
-
- Decode the HTML entities in the `description` field of homework
|
|
293
|
-
- v1.0.9
|
|
294
|
-
- Use `entities` to decode HTML entities
|
|
295
|
-
- v1.0.8
|
|
296
|
-
- Export type CourseContent
|
|
297
|
-
- v1.0.7
|
|
298
|
-
- No change made to code, update README
|
|
299
|
-
- v1.0.6
|
|
300
|
-
- Add API to fetching content for a list of courses
|
|
301
|
-
- v1.0.5
|
|
302
|
-
- Fix HTML entity replacement.
|
|
303
|
-
- v1.0.4
|
|
304
|
-
- No change made to code
|
|
305
|
-
- Remove unused build commands
|
|
306
|
-
- Fix multiple typos in README
|
|
307
|
-
- v1.0.3
|
|
308
|
-
- Add real logout API (thank @zhaofeng-shu33)
|
|
309
|
-
- v1.0.2
|
|
310
|
-
- Add API to get IDs of all semesters (thank @jiegec)
|
|
311
|
-
- v1.0.1
|
|
312
|
-
- Expose CookieJar in helper class
|
|
313
|
-
- Fix some HTML entity decoding problems
|
|
314
|
-
- **Rename of some APIs** (break compatibility before we have actual users)
|
|
315
|
-
- v1.0.0
|
|
316
|
-
- First release
|
|
317
|
-
- Support parsing of notification, homework, file, discussion and **answered** questions
|
|
184
|
+
Rejected promises carry an `ApiError`: `reason` is a `FailReason` and `extra` holds what the server answered, when there is something useful. For example, a wrong password rejects with `BAD_CREDENTIAL`, an expired session without a `CredentialProvider` with `NOT_LOGGED_IN`, a request that gets no answer (offline, DNS or TLS failure) with `NETWORK_ERROR`, and a slow request with `REQUEST_TIMEOUT`; `isConnectionError(e)` is true for the last two, also for a login. See `src/types.ts` for every reason and the other type definitions.
|
|
318
185
|
|
|
319
186
|
## Projects using this library
|
|
320
187
|
|
package/lib/auth.d.ts
CHANGED
|
@@ -1,11 +1,22 @@
|
|
|
1
1
|
import type { Session } from './request.ts';
|
|
2
|
+
import type { Credential } from './types.ts';
|
|
3
|
+
/** a `Credential` with everything an SSO login needs */
|
|
4
|
+
export type CompleteCredential = Credential & {
|
|
5
|
+
username: string;
|
|
6
|
+
password: string;
|
|
7
|
+
fingerPrint: string;
|
|
8
|
+
};
|
|
9
|
+
/** whether `credential` has a username, a password and a fingerprint */
|
|
10
|
+
export declare const isComplete: (credential: Credential | undefined) => credential is CompleteCredential;
|
|
2
11
|
/**
|
|
3
12
|
* If using alternative cookie management systems,
|
|
4
13
|
* be sure to clear id.tsinghua.edu.cn cookies before calling this function
|
|
5
14
|
*/
|
|
6
|
-
export declare function getRoamingTicket(s: Session,
|
|
7
|
-
/**
|
|
8
|
-
export declare function
|
|
9
|
-
/**
|
|
15
|
+
export declare function getRoamingTicket(s: Session, credential: CompleteCredential): Promise<string>;
|
|
16
|
+
/** log in with the `CredentialProvider`; `NO_CREDENTIAL` without one, or when it gives an incomplete credential */
|
|
17
|
+
export declare function loginWithProvider(s: Session): Promise<void>;
|
|
18
|
+
/** log in through id.tsinghua.edu.cn, then read the CSRF token and the website language from the homepage */
|
|
19
|
+
export declare function login(s: Session, credential: CompleteCredential): Promise<void>;
|
|
20
|
+
/** logout (to make everyone happy); the CSRF token is cleared, so the next request logs in again */
|
|
10
21
|
export declare function logout(s: Session): Promise<void>;
|
|
11
22
|
//# sourceMappingURL=auth.d.ts.map
|
package/lib/auth.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAK7C,wDAAwD;AACxD,MAAM,MAAM,kBAAkB,GAAG,UAAU,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,CAAC;AAE1G,wEAAwE;AACxE,eAAO,MAAM,UAAU,eAAgB,UAAU,GAAG,SAAS,KAAG,UAAU,IAAI,kBACD,CAAC;AAE9E;;;GAGG;AACH,wBAAsB,gBAAgB,CAAC,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,kBAAkB,GAAG,OAAO,CAAC,MAAM,CAAC,CAmDlG;AAaD,mHAAmH;AACnH,wBAAsB,iBAAiB,CAAC,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAIjE;AAED,6GAA6G;AAC7G,wBAAsB,KAAK,CAAC,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAsBrF;AAED,qGAAqG;AACrG,wBAAsB,MAAM,CAAC,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAGtD"}
|
package/lib/auth.js
CHANGED
|
@@ -1,29 +1,27 @@
|
|
|
1
1
|
// Login to Web Learning through id.tsinghua.edu.cn (SSO) and logout.
|
|
2
2
|
import { sm2 } from 'sm-crypto';
|
|
3
|
-
import {
|
|
4
|
-
import { FailReason, Language } from './types.js';
|
|
3
|
+
import { discard, isConnectionError } from './request.js';
|
|
4
|
+
import { CourseType, FailReason, Language } from './types.js';
|
|
5
5
|
import * as URLS from './urls.js';
|
|
6
|
+
import { $, apiError } from './utils.js';
|
|
7
|
+
/** whether `credential` has a username, a password and a fingerprint */
|
|
8
|
+
export const isComplete = (credential) => !!credential?.username && !!credential.password && !!credential.fingerPrint;
|
|
6
9
|
/**
|
|
7
10
|
* If using alternative cookie management systems,
|
|
8
11
|
* be sure to clear id.tsinghua.edu.cn cookies before calling this function
|
|
9
12
|
*/
|
|
10
|
-
export async function getRoamingTicket(s,
|
|
11
|
-
|
|
12
|
-
//
|
|
13
|
-
// It won't be a problem if it is always the same user,
|
|
14
|
-
// but if the current cookies are from a different user than the one trying to log in,
|
|
15
|
-
// it will cause problems.
|
|
13
|
+
export async function getRoamingTicket(s, credential) {
|
|
14
|
+
const { username, password, fingerPrint, fingerGenPrint = '', fingerGenPrint3 = '' } = credential;
|
|
15
|
+
// start from the login form without an id.tsinghua.edu.cn session: one left in the cookies may be another user's
|
|
16
16
|
try {
|
|
17
17
|
await s.cookieJar.setCookie('JSESSIONID=; path=/; HttpOnly', URLS.ID_PREFIX);
|
|
18
18
|
}
|
|
19
19
|
catch (err) {
|
|
20
|
-
throw
|
|
21
|
-
reason: FailReason.ERROR_SETTING_COOKIES,
|
|
22
|
-
extra: err,
|
|
23
|
-
};
|
|
20
|
+
throw apiError(FailReason.ERROR_SETTING_COOKIES, err);
|
|
24
21
|
}
|
|
22
|
+
let page;
|
|
25
23
|
try {
|
|
26
|
-
const loginForm = await s.rawFetch(URLS.ID_LOGIN
|
|
24
|
+
const loginForm = await s.rawFetch(URLS.ID_LOGIN);
|
|
27
25
|
const body = $(await loginForm.text());
|
|
28
26
|
const sm2publicKey = body('#sm2publicKey').text().trim();
|
|
29
27
|
const formData = new FormData();
|
|
@@ -31,69 +29,81 @@ export async function getRoamingTicket(s, username, password, fingerPrint, finge
|
|
|
31
29
|
formData.append('i_pass', '04' + sm2.doEncrypt(password, sm2publicKey));
|
|
32
30
|
formData.append('singleLogin', 'on');
|
|
33
31
|
formData.append('fingerPrint', fingerPrint);
|
|
34
|
-
formData.append('fingerGenPrint', fingerGenPrint
|
|
35
|
-
formData.append('fingerGenPrint3', fingerGenPrint3
|
|
32
|
+
formData.append('fingerGenPrint', fingerGenPrint);
|
|
33
|
+
formData.append('fingerGenPrint3', fingerGenPrint3);
|
|
36
34
|
formData.append('i_captcha', '');
|
|
37
|
-
const checkResponse = await s.rawFetch(URLS.ID_LOGIN_CHECK
|
|
35
|
+
const checkResponse = await s.rawFetch(URLS.ID_LOGIN_CHECK, {
|
|
38
36
|
method: 'POST',
|
|
39
37
|
body: formData,
|
|
40
38
|
});
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
39
|
+
if (!checkResponse.ok) {
|
|
40
|
+
throw { code: checkResponse.status, text: checkResponse.statusText };
|
|
41
|
+
}
|
|
42
|
+
page = await checkResponse.text();
|
|
45
43
|
}
|
|
46
44
|
catch (err) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
45
|
+
// no answer at all: the device is offline or id.tsinghua.edu.cn is unreachable, not a refused login
|
|
46
|
+
if (isConnectionError(err))
|
|
47
|
+
throw err;
|
|
48
|
+
throw apiError(FailReason.ERROR_FETCH_FROM_ID, err);
|
|
51
49
|
}
|
|
50
|
+
// id.tsinghua.edu.cn answers with a page whose only link is the roaming URL (with the ticket), or with the login form
|
|
51
|
+
// again (with its links to the password reset, guides, phone and mail) for a wrong password
|
|
52
|
+
const body = $(page);
|
|
53
|
+
const ticket = ticketOf(body('a[href*="ticket="]').attr('href'));
|
|
54
|
+
if (ticket)
|
|
55
|
+
return ticket;
|
|
56
|
+
if (body('#theform, form[action*="/auth/login/check"]').length > 0 && body('#i_pass').length > 0) {
|
|
57
|
+
throw apiError(FailReason.BAD_CREDENTIAL, textOf(body('#msg_note, .alert-danger')) || undefined);
|
|
58
|
+
}
|
|
59
|
+
// something else, e.g. a second factor, a locked account or maintenance: not a wrong password
|
|
60
|
+
throw apiError(FailReason.ERROR_FETCH_FROM_ID, textOf(body('body').clone().find('script, style').remove().end()).slice(0, 200));
|
|
52
61
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
if (!
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
password = credential.password;
|
|
63
|
-
fingerPrint = credential.fingerPrint;
|
|
64
|
-
fingerGenPrint = credential.fingerGenPrint;
|
|
65
|
-
fingerGenPrint3 = credential.fingerGenPrint3;
|
|
66
|
-
if (!username || !password || !fingerPrint) {
|
|
67
|
-
return Promise.reject({
|
|
68
|
-
reason: FailReason.NO_CREDENTIAL,
|
|
69
|
-
});
|
|
70
|
-
}
|
|
62
|
+
const textOf = (el) => el.text().replace(/\s+/g, ' ').trim();
|
|
63
|
+
const ticketOf = (href) => {
|
|
64
|
+
if (!href)
|
|
65
|
+
return undefined;
|
|
66
|
+
try {
|
|
67
|
+
return new URL(href, URLS.ID_PREFIX).searchParams.get('ticket') || undefined;
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
return undefined;
|
|
71
71
|
}
|
|
72
|
-
|
|
73
|
-
|
|
72
|
+
};
|
|
73
|
+
/** log in with the `CredentialProvider`; `NO_CREDENTIAL` without one, or when it gives an incomplete credential */
|
|
74
|
+
export async function loginWithProvider(s) {
|
|
75
|
+
const credential = await s.provider?.();
|
|
76
|
+
if (!isComplete(credential))
|
|
77
|
+
throw apiError(FailReason.NO_CREDENTIAL);
|
|
78
|
+
return login(s, credential);
|
|
79
|
+
}
|
|
80
|
+
/** log in through id.tsinghua.edu.cn, then read the CSRF token and the website language from the homepage */
|
|
81
|
+
export async function login(s, credential) {
|
|
82
|
+
const ticket = await getRoamingTicket(s, credential);
|
|
83
|
+
const { fingerPrint, fingerGenPrint = '', fingerGenPrint3 = '' } = credential;
|
|
84
|
+
s.fingerprints = { fingerPrint, fingerGenPrint, fingerGenPrint3 };
|
|
74
85
|
const loginResponse = await s.rawFetch(URLS.LEARN_AUTH_ROAM(ticket));
|
|
86
|
+
// only the status matters
|
|
87
|
+
discard(loginResponse);
|
|
75
88
|
if (!loginResponse.ok) {
|
|
76
|
-
|
|
77
|
-
reason: FailReason.ERROR_ROAMING,
|
|
78
|
-
});
|
|
89
|
+
throw apiError(FailReason.ERROR_ROAMING);
|
|
79
90
|
}
|
|
80
|
-
const courseListPageSource = await (await s.rawFetch(URLS.
|
|
91
|
+
const courseListPageSource = await (await s.rawFetch(URLS.LEARN_HOMEPAGE(CourseType.STUDENT))).text();
|
|
81
92
|
const tokenRegex = /^.*&_csrf=(\S*)".*$/gm;
|
|
82
93
|
const tokenMatches = [...courseListPageSource.matchAll(tokenRegex)];
|
|
83
94
|
if (tokenMatches.length === 0) {
|
|
84
|
-
|
|
85
|
-
reason: FailReason.INVALID_RESPONSE,
|
|
86
|
-
extra: 'cannot fetch CSRF token from source',
|
|
87
|
-
});
|
|
95
|
+
throw apiError(FailReason.INVALID_RESPONSE, 'cannot fetch CSRF token from source');
|
|
88
96
|
}
|
|
89
97
|
s.csrfToken = tokenMatches[0][1];
|
|
90
|
-
|
|
98
|
+
// the homepage loads e.g. `/f/wlxt/common/languagejs?lang=zh_CN&v=845`
|
|
99
|
+
const langRegex = /\/f\/wlxt\/common\/languagejs\?lang=(zh|en)/g;
|
|
91
100
|
const langMatches = [...courseListPageSource.matchAll(langRegex)];
|
|
92
101
|
if (langMatches.length !== 0)
|
|
93
102
|
s.lang = langMatches[0][1] === 'en' ? Language.EN : Language.ZH;
|
|
94
103
|
}
|
|
95
|
-
/** logout (to make everyone happy) */
|
|
104
|
+
/** logout (to make everyone happy); the CSRF token is cleared, so the next request logs in again */
|
|
96
105
|
export async function logout(s) {
|
|
97
|
-
await s.rawFetch(URLS.LEARN_LOGOUT
|
|
106
|
+
discard(await s.rawFetch(URLS.LEARN_LOGOUT, { method: 'POST' }));
|
|
107
|
+
s.csrfToken = '';
|
|
98
108
|
}
|
|
99
109
|
//# sourceMappingURL=auth.js.map
|
package/lib/auth.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA,qEAAqE;AAErE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAGhC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA,qEAAqE;AAErE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAGhC,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAE1D,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC9D,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,CAAC,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAKzC,wEAAwE;AACxE,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,UAAkC,EAAoC,EAAE,CACjG,CAAC,CAAC,UAAU,EAAE,QAAQ,IAAI,CAAC,CAAC,UAAU,CAAC,QAAQ,IAAI,CAAC,CAAC,UAAU,CAAC,WAAW,CAAC;AAE9E;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC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