Skip to main content

flutter_chaoxing 0.1.2 copy "flutter_chaoxing: ^0.1.2" to clipboard
flutter_chaoxing: ^0.1.2 copied to clipboard

Typed Chaoxing (学习通) protocol clients, request signing, and classroom sign-in for Dart.

flutter_chaoxing #

pub package pub points GitHub stars license

Typed Chaoxing (学习通) protocol clients, request signing, and classroom sign-in for Dart and Flutter. Every routine is a byte-exact port of the official Android client 7.0.2, recovered from the decompiled sources in the chaoxing-re research repo; the inline citations in the source give the exact file:line each constant and algorithm came from.

This package is an independent community project and is not affiliated with Chaoxing, 超星, or any 学习通 operator.

Features #

  • Three request-signing schemes, ported exactly and never interchanged:
    • inf_enc query signing (both the declared-order jui.V/W variant and the sorted-key OkHttp interceptor variant).
    • cxsign / signToken header signing (sorted key + value concatenation plus a per-installation secret).
    • webRequestSign — the RSA-SHA256 half of the CLIENT_FORM_SIGN JS bridge, with the obfuscated private key extracted from libsecuritylib.so.
  • Device registration: CxDevice.getDeviceInfo / decryptDeviceInfo (chunked RSA, jsoncpp FastWriter alignment, millisecond timestamps).
  • Login: passport2 password and SMS flows, AES-ECB logininfo, manual SSO redirect walking, and clientId harvest.
  • Classroom sign-in: the activity/mission surface, the native Fanya usersign/addsign endpoint, and a full CLIENT_FORM_SIGN implementation.
  • Student data API: notices, grades, homework feed, live classes, course content, timetable, messages, and discussions.
  • Typed domain models mirroring the official StudentMission, Course, and Clazz schemas, plus the activeType dispatch table.

The load-bearing finding #

The official Android client has no native sign-submit endpoint. StudentMissionFragment.H9 dispatches a handful of activeTypes natively and sends everything else — all sign flavours — to a WebView pointed at the server-supplied mission.url. The words otherId, ifphoto, ifopenAddress, ifrefreshewm, and signCode appear nowhere in the 69,685 recovered classes: they belong to the H5 page's own protocol, not to the app.

What the app does contribute to a sign is two JS bridges — CLIENT_FORM_SIGN (RSA-signs the page's form fields) and CLIENT_USER_LOCATION (supplies GPS). An implementation that wants official parity therefore drives the H5 page and answers those bridges rather than inventing a submit URL. ChaoxingSignService.handleFormSign is that bridge.

The one exception is the scanned Fanya code, which the client submits natively via usersign/addsign — see submitFanyaSign.

Installation #

dart pub add flutter_chaoxing

For Flutter applications:

flutter pub add flutter_chaoxing

The package is pure Dart (no Flutter SDK dependency) and uses dio for HTTP, so it runs on Android, iOS, Linux, macOS, Windows, and the web (subject to CORS for the web).

Usage #

Log in #

import 'package:flutter_chaoxing/flutter_chaoxing.dart';

final auth = ChaoxingAuthService();
final session = await auth.login(
  const ChaoxingCredentials(account: 'student', password: 'secret'),
);
// session.cookieHeader is replayed on every later call.

SMS login reuses the same call after auth.sendSmsCode(phone), with the code in the password field and mode: ChaoxingLoginMode.sms.

When the server demands interactive verification it raises ChaoxingCaptchaRequired; there is no headless bypass.

Device identity #

The cxsign secret is not a constant in the APK — it is issued per installation. To obtain it, post a deviceInfo payload with the SSO follow so the server returns a clientId, then resolve it:

final uniqueId = ChaoxingSignCrypto.newUniqueId(); // persist this!
final payload = ChaoxingSignService.buildDeviceInfoPayload(
  ChaoxingDeviceProfile(deviceId: uniqueId, /* …hardware fields… */),
);
final session = await auth.login(credentials, deviceInfo: payload);
if (session.hasDeviceIdentity) {
  final identity =
      ChaoxingSignService.resolveDeviceIdentity(session.clientId);
  // identity.cxcid / identity.sc feed cxsign and CLIENT_FORM_SIGN.
}

uniqueId is a dashless UUID v4 that the official client generates once and reuses forever. Persist it (secure storage) and never rotate it — changing it makes the server see a "new device".

List courses and sign-in activities #

final sign = ChaoxingSignService();
final courses = await sign.listCourses(session);
final missions = await sign.listMissions(
  session,
  courseId: courses.first.courseId,
  classId: courses.first.classId,
);
final signIns = missions.where((m) => m.isWebViewDriven);

Answer the CLIENT_FORM_SIGN bridge #

When driving the H5 sign page in a WebView, intercept the bridge and return handleFormSignJson verbatim:

final tokens = sign.handleFormSignJson(
  rawJsonFromPage,
  identity, // ChaoxingDeviceIdentity from resolveDeviceIdentity
);
// hand `tokens` back to the page's JS callback

Student data API #

final api = ChaoxingApiService();
final notices = await api.fetchNotices(session, pageSize: 20);
final unread = await api.fetchUnreadNoticeCount(session);
final tasks = await api.fetchTaskFeed(session, userid: session.puid);
final live = await api.fetchOngoingLive(session);

See lib/src/chaoxing_api_service.dart for the full surface: grades (fetchSelfScoreDetail, fetchExamList, fetchWorkList), homework (fetchUnfinishedJobs), live classes (fetchLiveDetail), course content (fetchChapterTree, fetchKnowledgeCards), timetable (fetchLesson), messages, and discussions.

API Overview #

Type Purpose
ChaoxingAuthService passport2 login, SMS, SSO cookie harvest
ChaoxingSignService Classroom activities, sign-in, CLIENT_FORM_SIGN, Fanya submit
ChaoxingApiService Notices, grades, homework, live, courses, timetable, messages
ChaoxingSignCrypto The three signing schemes, device RSA, jsoncpp alignment
ChaoxingSession Cookie jar + parsed identity + clientId
ChaoxingCredentials Account/password or phone/SMS pair
ChaoxingCourse / ChaoxingMission Official course and activity schemas
ChaoxingDeviceProfile / ChaoxingDeviceIdentity Device registration in, cxcid/sc out
ChaoxingFormSignRequest / ChaoxingFormSignTokens The CLIENT_FORM_SIGN bridge contract
ChaoxingFanyaSignResult / ChaoxingFanyaSignCode Native Fanya submit outcome
ChaoxingLogger Injectable diagnostics sink (replaces debugPrint)

Integration boundary #

The package owns the protocol: HTTP, signing, parsing, and typed models. The host application owns everything stateful:

  • Credential/session persistence — store ChaoxingSession in secure storage; the package never touches disk.
  • uniqueId persistence — generate once via ChaoxingSignCrypto .newUniqueId(), persist, and pass it into device registration and Fanya signs.
  • Dependency injection — construct the services yourself (or wire them into Riverpod/Bloc/providers as you see fit).
  • Logging — inject a ChaoxingLogger (e.g. debugPrint) into ChaoxingAuthService and ChaoxingSignService.
  • WebView driving — the H5 sign page and the CLIENT_FORM_SIGN / CLIENT_USER_LOCATION bridges are the host's responsibility.

Security And Compatibility #

  • Do not commit passwords, cookies, clientId, or the cxcid/sc pair.
  • The cxsign secret is per-installation; never hardcode a captured one.
  • Endpoints and constants are pinned to client 7.0.2. Chaoxing rotates these periodically — re-verify against a current capture before relying on them.
  • Several device-fingerprint fields (mediaDrmId, cdtype, cdid, platform/os_name) are built inside JNI and were not recoverable; they are modelled as caller-supplied and omitted when unset, never faked.
  • Test against a disposable account before enabling any write path.

Development #

dart format lib test example
dart analyze
dart test
dart pub publish --dry-run

Publishing #

The repository is private, so pub.dev's GitHub-Actions OIDC trusted-publishing (which requires a public repo) is not used. Releases are published manually with an authenticated dart pub login session:

dart pub publish --force   # after bumping version in pubspec.yaml + CHANGELOG.md

The first release of a new package must be published by a logged-in user (pub.dev rejects new-package uploads from CI/OIDC); later releases could use the tag workflow if the repo is made public.

License #

MIT. See LICENSE.

0
likes
0
points
483
downloads

Publisher

verified publisherwhu.sb

Weekly Downloads

Typed Chaoxing (学习通) protocol clients, request signing, and classroom sign-in for Dart.

Repository (GitHub)
View/report issues

Topics

#chaoxing #xuexitong #sign-in #education

License

unknown (license)

Dependencies

crypto, dio, pointycastle

More

Packages that depend on flutter_chaoxing