CAS-SDK (@cqut-openproject/cas-sdk) is a zero-dependency, cross-runtime TypeScript client SDK for CQUT UIS / CAS authentication, supporting Node.js, Cloudflare Workers, Vercel Edge, Bun, and modern browsers.
- Stack: Node.js 18+, TypeScript 7+ (ESM + CJS, strict,
verbatimModuleSyntax,erasableSyntaxOnly),tsup,tsx - Package Manager:
pnpm(10+) - Structure:
src/client/: High-level CAS client (cas-client.ts), endpoint resolvers (endpoints.ts), branded types & result types (types.ts)src/cookie/: RFC 6265 disposable in-memory cookie jar (cookie-jar.ts)src/crypto/: Zero-dependency RSA PKCS#1 v1.5 with nativeBigInt(rsa.ts), password chunk encryptor (encryptor.ts)src/errors/: Strongly-typedCasErrorand type guards (cas-error.ts)src/http/: IoC fetcher abstraction & Web Standard Fetch adapter (default-fetcher.ts)src/parser/: Safe XML ticket parser with anti-XXE & Doctype defenses (cas-xml.ts)src/polyfill.ts: Polyfill forSymbol.disposeandSymbol.asyncDisposesrc/index.ts: Unified SDK exportssrc/**/*.test.ts: Modular unit tests located near source.github/workflows/: CI testing (ci.yml) and package/release distribution (publish.yml)
pnpm install: Install dependenciespnpm dev: Start build in watch mode (tsup --watch)pnpm test: Run all unit tests via Node test runner (tsx --test src/**/*.test.ts); run a single test:npx tsx --test <path-to-test.ts>pnpm lint: Run TypeScript type check (tsc --noEmit)pnpm build: Build dual ESM/CJS bundles and emit.d.tsdeclaration files (dist/)pnpm format: Format codebase with Prettier
- Plan first; do NOT rush to code.
- Zero external production dependencies: SDK runtime logic must rely purely on standard ECMAScript / TypeScript.
- Strict TypeScript 7+ & ES Modules with 2-space indentation.
- Adhere to
erasableSyntaxOnly(noenum, no parameter properties, no runtimenamespace) for 100% Type Stripping compliance. - Keep domain logic isolated in its corresponding module (
client/,cookie/,crypto/,errors/,http/,parser/). - Implement
Disposable/AsyncDisposableon resource-holding entities to prevent sensitive credential retention in memory. - Never commit build artifacts (
dist/). - Add regression tests for changes touching auth flows, XML parsing, crypto, or cookie management. All tests must pass locally before completing tasks.
Be concise. Do not write unsolicited "WHY" explanations.
Use Gitmoji format: <emoji> <concise Chinese> (no feat:/fix: prefix). e.g., ✨ 新增 Result 模式安全登录 or 🐛 修复 XML 标签解析边界.