vanspod 0.4.16 → 0.5.1

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 CHANGED
@@ -38,7 +38,7 @@ npm run dist
38
38
  npm pack --pack-destination dist
39
39
  ```
40
40
 
41
- exe 產物為 `dist/VansPod.exe`,本機套件為 `dist/vanspod-0.4.16.tgz`;可在 Windows 用 `npm install -g <套件路徑>` 安裝測試。圖片、favicon、系統匣與移除腳本均包含在發佈產物中。更新 logo 後執行 `powershell.exe -NoProfile -File scripts/build-icon.ps1` 重建多尺寸 Windows icon。
41
+ exe 產物為 `dist/VansPod.exe`,本機套件為 `dist/vanspod-0.5.1.tgz`;可在 Windows 用 `npm install -g <套件路徑>` 安裝測試。圖片、favicon、系統匣與移除腳本均包含在發佈產物中。更新 logo 後執行 `powershell.exe -NoProfile -File scripts/build-icon.ps1` 重建多尺寸 Windows icon。
42
42
 
43
43
  exe 發佈管道為本專案 GitHub Releases,npm 為公開 registry 的 [`vanspod`](https://www.npmjs.com/package/vanspod) 套件。更新時不要執行完整移除,否則會清除課堂資料。
44
44
 
@@ -46,12 +46,12 @@ exe 發佈管道為本專案 GitHub Releases,npm 為公開 registry 的 [`vans
46
46
 
47
47
  一般 push 不發佈;推送 `v*` tag 會在 Windows runner 安裝 Node.js 24、檢查型別、執行測試、打包並驗證 exe/npm 生命週期,全部通過後才建立 GitHub Release,最後發佈 npm 套件。學生從 Release 下載 `VansPod.exe`,同頁提供 `SHA256SUMS.txt`。Release 另附 brotli 壓縮的 `VansPod.exe.br`(約三分之一大小),程式內更新只下載這份,解壓後再比對 `VansPod.exe` 的 SHA-256;SHA256SUMS 沒列出它的舊版 Release 則下載完整 exe。
48
48
 
49
- 發版前同步 `package.json`、`package-lock.json` 與 `src/version.ts` 的版本;tag 必須等於 `v` 加版本號,否則流程失敗。以 `0.4.16` 為例:
49
+ 發版前同步 `package.json`、`package-lock.json` 與 `src/version.ts` 的版本;tag 必須等於 `v` 加版本號,否則流程失敗。以 `0.5.1` 為例:
50
50
 
51
51
  ```powershell
52
52
  git push origin master
53
- git tag -a v0.4.16 -m "VansPod 0.4.16"
54
- git push origin v0.4.16
53
+ git tag -a v0.5.1 -m "VansPod 0.5.1"
54
+ git push origin v0.5.1
55
55
  ```
56
56
 
57
57
  新版本使用新的版本號與 tag。相同 tag 的 Actions 重跑會更新該 Release 的產物。
@@ -70,7 +70,7 @@ GitHub Release 建立後,同一流程以 npm Trusted Publishing(OIDC)發
70
70
 
71
71
  ## Classroom 上游 API
72
72
 
73
- 模型區提供各客戶端的上游 API 選項:Codex 可選 Responses/Chat,Claude Code 可選 Responses/Chat/Messages,兩者均預設 Responses。選擇保存在使用者目錄的 `.vanspod/settings.json`,與課堂憑證分開;重啟、切換模型、清除或重新兌換課堂不會移除偏好。此選項只影響 Classroom 模式的下一個請求。
73
+ 模型區提供各客戶端的上游 API 選項:Codex 可選 Responses/Chat,Claude Code 可選 Responses/Chat/Messages,兩者均預設 Responses。選擇保存在使用者目錄的 `.vanspod/settings.json`,與課堂憑證分開;重啟、切換模型、清除或重新連線課堂不會移除偏好。此選項只影響 Classroom 模式的下一個請求。
74
74
 
75
75
  共用 Adapter 介面下的三個實作負責請求、上游呼叫與回應轉換;所有程式都在 VansPod 內,不需要 opencodex 專案。支援多輪文字、圖片輸入、函式工具往返與串流/非串流;Chat 路徑沿用 Codex 自訂工具的文字包裝及 `apply_patch` 修復。
76
76
 
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ClassroomApp = exports.COPIED_KEY_NOTICE = exports.AUTO_APPROVAL_NEEDS_ACCESS = exports.AUTO_APPROVAL_DURATIONS = exports.ENVIRONMENT_LABEL = exports.ENVIRONMENT_TOOLS = void 0;
3
+ exports.ClassroomApp = exports.COPIED_KEY_NOTICE = exports.AUTO_APPROVAL_NEEDS_ACCESS = exports.AUTO_APPROVAL_DURATIONS = exports.ENVIRONMENT_LABEL = exports.ENVIRONMENT_TOOLS = exports.CONNECTION_CANCELLED = exports.CONNECT_TIMEOUT_MS = exports.OAUTH_CLIENT_ID = void 0;
4
+ const node_crypto_1 = require("node:crypto");
4
5
  const secureStorage_1 = require("./secureStorage");
5
6
  const storageErrors_1 = require("./storageErrors");
6
7
  const adapterSettings_1 = require("./adapterSettings");
@@ -10,6 +11,12 @@ const courseCatalog_1 = require("./courseCatalog");
10
11
  const modelProxy_1 = require("./modelProxy");
11
12
  const classroomKeyRejection_1 = require("./classroomKeyRejection");
12
13
  const localToolApproval_1 = require("./localToolApproval");
14
+ /** The public OAuth Client of VansPod on the Router. */
15
+ exports.OAUTH_CLIENT_ID = "vanspod";
16
+ /** After this long without a callback, the connection attempt ends by itself. */
17
+ exports.CONNECT_TIMEOUT_MS = 10 * 60_000;
18
+ exports.CONNECTION_CANCELLED = "連線已取消";
19
+ const CONNECTION_FAILED = "連線失敗,請再按一次「連線」。";
13
20
  const CLIENT_ROUTE_OF = { codex: "codex", claude: "claudeCode", vscode: "vsCodeChat" };
14
21
  // 新工具加在最後,不改既有 id。
15
22
  exports.ENVIRONMENT_TOOLS = ["uv", "git", "node", "pwsh", "vscode"];
@@ -25,13 +32,13 @@ exports.AUTO_APPROVAL_DURATIONS = {
25
32
  "30": { label: "30 分鐘", ms: 30 * 60_000 },
26
33
  until_off: { label: "直到關閉開關" },
27
34
  };
28
- const LOCAL_TOOLS_NEED_CONNECTION = "請先兌換課堂連線,才能讓 Agent 使用這台電腦。";
35
+ const LOCAL_TOOLS_NEED_CONNECTION = "請先在「教室設定」按「連線」,才能讓 Agent 使用這台電腦。";
29
36
  exports.AUTO_APPROVAL_NEEDS_ACCESS = "請先打開「允許 Agent 使用這台電腦」,才能自動允許。";
30
37
  const LOCAL_LIST_NOTE = "這是本機清單。";
31
38
  exports.COPIED_KEY_NOTICE = "已複製 Classroom API Key。請勿分享給不信任的人。";
32
39
  const KEY_REJECTED_NOTICE = {
33
- expired: "Classroom API Key 已過期,請按「清除連線」,再用老師給的新邀請碼重新兌換。",
34
- invalid: "Classroom API Key 已失效,請按「清除連線」,再用老師給的新邀請碼重新兌換。",
40
+ expired: "Classroom API Key 已過期,請按「清除連線」,再按「連線」,用老師給的新邀請碼登入。",
41
+ invalid: "Classroom API Key 已失效,請按「清除連線」,再按「連線」,用老師給的新邀請碼登入。",
35
42
  };
36
43
  const MODELS_UNLOADED_NOTICE = "無法載入課堂模型,請按「↻ 更新」再試。";
37
44
  const VS_CODE_KEPT_NOTICE = "VS Code 的 VCRouter 已被修改,不再指向 VansPod,VansPod 沒有移除它。";
@@ -51,13 +58,15 @@ class ClassroomApp {
51
58
  connectionOperations = Promise.resolve();
52
59
  connected = false;
53
60
  classLabel;
54
- nickname;
61
+ displayName;
62
+ loginMethod;
55
63
  courseTitle;
56
64
  sessionTitle;
57
65
  detail = "";
58
66
  connectionError;
59
67
  connectionNotice;
60
- connectionDraft;
68
+ // The connection attempt that waits for the browser to come back.
69
+ pendingConnection;
61
70
  notice;
62
71
  projectFolder;
63
72
  folderError;
@@ -98,7 +107,7 @@ class ClassroomApp {
98
107
  mustRestart = [];
99
108
  modelRestart = [];
100
109
  allowlistError;
101
- // Router refused this Classroom API Key; only a new redeem or Clear resets it.
110
+ // Router refused this Classroom API Key; only a new connection or Clear resets it.
102
111
  keyRejection;
103
112
  // 啟動時抓不到 Session Model Allowlist 而暫時退回 Native 的 Client Route;設定檔仍保留 Classroom,
104
113
  // 「更新」抓到模型後切回去。學生自己切換或換堂後就不再代為恢復。
@@ -153,8 +162,10 @@ class ClassroomApp {
153
162
  if (this.deps.device) {
154
163
  const status = this.deps.device.status();
155
164
  const local = { on: status.on, state: status.state, device: status.device };
156
- if (this.nickname)
157
- local.nickname = this.nickname;
165
+ if (this.displayName)
166
+ local.displayName = this.displayName;
167
+ if (this.loginMethod)
168
+ local.loginMethod = this.loginMethod;
158
169
  // While it is off, the newest notice (from the student's last action) comes before the relay's reason.
159
170
  const message = status.on ? status.message : this.localToolsNotice ?? status.message;
160
171
  if (message)
@@ -187,14 +198,17 @@ class ClassroomApp {
187
198
  }
188
199
  if (this.notice && this.notice === this.connectionNotice)
189
200
  view.connectionNotice = this.connectionNotice;
190
- if (this.connectionDraft && !this.connected)
191
- view.connectionDraft = { ...this.connectionDraft };
201
+ if (this.pendingConnection) {
202
+ view.connecting = true;
203
+ view.authorizeUrl = this.pendingConnection.authorizeUrl;
204
+ }
192
205
  if (this.classLabel) {
193
206
  view.classLabel = this.classLabel;
194
207
  }
195
- if (this.nickname) {
196
- view.nickname = this.nickname;
197
- }
208
+ if (this.displayName)
209
+ view.displayName = this.displayName;
210
+ if (this.loginMethod)
211
+ view.loginMethod = this.loginMethod;
198
212
  if (this.courseTitle) {
199
213
  view.courseTitle = this.courseTitle;
200
214
  }
@@ -799,39 +813,74 @@ class ClassroomApp {
799
813
  this.pendingCommand = undefined;
800
814
  this.pendingActionId = undefined;
801
815
  }
802
- async redeem(inviteCode, nickname) {
803
- return this.serialConnectionOperation(() => this.redeemNow(inviteCode, nickname));
804
- }
805
- async redeemNow(inviteCode, nickname) {
806
- const invite = inviteCode.trim();
807
- const name = nickname.trim();
816
+ /** 連線: opens the Router's Authorization Page in the system browser and waits for the callback. */
817
+ async startConnection() {
818
+ this.endPendingConnection();
819
+ const verifier = (0, node_crypto_1.randomBytes)(32).toString("base64url");
820
+ const state = (0, node_crypto_1.randomBytes)(24).toString("base64url");
821
+ const redirectUri = `${this.deps.proxyBaseUrl}/oauth/callback`;
822
+ const timer = setTimeout(() => {
823
+ if (this.pendingConnection?.state === state)
824
+ this.pendingConnection = undefined;
825
+ }, exports.CONNECT_TIMEOUT_MS);
826
+ timer.unref?.();
808
827
  this.connectionError = undefined;
809
- this.connectionDraft = { inviteCode, nickname };
810
- if (!invite || !name) {
811
- this.connectionError = "請先輸入邀請碼與課堂暱稱,再按「連線」。";
812
- if (!this.connected)
813
- this.detail = "";
814
- this.notice = undefined;
815
- return;
816
- }
817
- let redeemed;
828
+ const url = new URL(this.deps.router.authorizeUrl);
829
+ url.search = new URLSearchParams({
830
+ response_type: "code",
831
+ client_id: exports.OAUTH_CLIENT_ID,
832
+ redirect_uri: redirectUri,
833
+ scope: "openid classroom",
834
+ state,
835
+ code_challenge: (0, node_crypto_1.createHash)("sha256").update(verifier).digest("base64url"),
836
+ code_challenge_method: "S256",
837
+ }).toString();
838
+ this.pendingConnection = { state, verifier, redirectUri, authorizeUrl: url.toString(), timer };
839
+ this.deps.openBrowser(url.toString());
840
+ }
841
+ /** 取消: stops waiting for the browser. A late callback is then ignored. */
842
+ cancelConnection() {
843
+ this.endPendingConnection();
844
+ }
845
+ endPendingConnection() {
846
+ if (this.pendingConnection)
847
+ clearTimeout(this.pendingConnection.timer);
848
+ this.pendingConnection = undefined;
849
+ }
850
+ /** The browser came back to `/oauth/callback`. A callback whose `state` does not match is ignored. */
851
+ async finishConnection(callback) {
852
+ const pending = this.pendingConnection;
853
+ if (!pending || !callback.state || callback.state !== pending.state)
854
+ return;
855
+ this.endPendingConnection();
856
+ if (callback.error || !callback.code) {
857
+ this.connectionError = exports.CONNECTION_CANCELLED;
858
+ return;
859
+ }
860
+ const code = callback.code;
861
+ return this.serialConnectionOperation(() => this.exchangeNow({ code, code_verifier: pending.verifier, redirect_uri: pending.redirectUri }));
862
+ }
863
+ async exchangeNow(exchange) {
864
+ this.connectionError = undefined;
865
+ let response;
818
866
  try {
819
- redeemed = await this.deps.router.redeemNickname({
820
- invite_code: invite,
821
- nickname: name,
822
- });
867
+ response = await this.deps.router.exchangeCode(exchange);
823
868
  }
824
869
  catch {
870
+ response = undefined;
871
+ }
872
+ const connection = response === undefined ? undefined : connectionFromTokens(response);
873
+ if (!connection) {
825
874
  if (!this.connected) {
826
- this.connectionError = "連線失敗,請確認邀請碼與課堂暱稱後再試。";
875
+ this.connectionError = CONNECTION_FAILED;
827
876
  this.detail = "";
828
877
  this.notice = undefined;
829
878
  }
830
- return;
831
- }
832
- const connection = { version: 1, apiKey: redeemed?.api_key, session: redeemed?.session, nickname: name };
833
- if (!(0, secureStorage_1.isClassroomConnection)(connection)) {
834
- this.notice = this.connectionNotice = "兌換回應資料格式不正確,已保留原有課堂連線。請稍後再試。";
879
+ else {
880
+ this.notice = this.connectionNotice = response === undefined
881
+ ? "連線失敗,已保留原有課堂連線。請稍後再試。"
882
+ : "連線回應資料格式不正確,已保留原有課堂連線。請稍後再試。";
883
+ }
835
884
  return;
836
885
  }
837
886
  this.hiddenKeys.add(connection.apiKey);
@@ -864,7 +913,6 @@ class ClassroomApp {
864
913
  this.pendingCommand = undefined;
865
914
  this.pendingActionId = undefined;
866
915
  this.applyConnectionIdentity(connection);
867
- this.connectionDraft = undefined;
868
916
  this.notice = undefined;
869
917
  // Storage is committed: publish its identity before any client-file operation can fail.
870
918
  if (desiredVsCodeMode === "classroom") {
@@ -889,7 +937,7 @@ class ClassroomApp {
889
937
  return;
890
938
  }
891
939
  await this.loadCatalog();
892
- await this.loadModels(redeemed.api_key);
940
+ await this.loadModels(connection.apiKey);
893
941
  if (desiredMode === "classroom" && this.modelIds.length > 0) {
894
942
  this.mode = "classroom";
895
943
  this.clientModes = desiredClientModes;
@@ -1226,7 +1274,7 @@ class ClassroomApp {
1226
1274
  this.showKeyRejection(this.keyRejection);
1227
1275
  });
1228
1276
  }
1229
- /** A refused Classroom API Key replaces any reload warning: the student has to redeem again. */
1277
+ /** A refused Classroom API Key replaces any reload warning: the student has to connect again. */
1230
1278
  showKeyRejection(rejection) {
1231
1279
  this.allowlistError = KEY_REJECTED_NOTICE[rejection];
1232
1280
  }
@@ -1828,7 +1876,7 @@ class ClassroomApp {
1828
1876
  this.localToolsNotice = undefined;
1829
1877
  this.applyConnectionIdentity(undefined);
1830
1878
  this.connectionError = undefined;
1831
- this.connectionDraft = undefined;
1879
+ this.endPendingConnection();
1832
1880
  this.notice = undefined;
1833
1881
  this.allowlistError = undefined;
1834
1882
  this.keyRejection = undefined;
@@ -1966,10 +2014,11 @@ class ClassroomApp {
1966
2014
  }
1967
2015
  applyConnectionIdentity(connection) {
1968
2016
  this.connected = connection !== undefined;
1969
- this.classLabel = connection && ([connection.session.class_name, connection.session.name].filter(Boolean).join(" · ") || undefined);
1970
- this.courseTitle = connection?.session.class_name || undefined;
1971
- this.sessionTitle = connection?.session.name || undefined;
1972
- this.nickname = connection?.nickname;
2017
+ this.classLabel = connection && ([connection.className, connection.sessionName].filter(Boolean).join(" · ") || undefined);
2018
+ this.courseTitle = connection?.className || undefined;
2019
+ this.sessionTitle = connection?.sessionName || undefined;
2020
+ this.displayName = connection?.displayName || undefined;
2021
+ this.loginMethod = connection?.loginMethod;
1973
2022
  this.detail = connection ? "Classroom API Key 已設定。" : "";
1974
2023
  }
1975
2024
  async restoreConnection() {
@@ -2208,3 +2257,39 @@ function catalogView(actions, snippets, source) {
2208
2257
  }
2209
2258
  return view;
2210
2259
  }
2260
+ /**
2261
+ * Reads the token response into a Classroom Connection. The Student ID Token payload is read without a
2262
+ * signature check: VansPod got it straight from the Router over HTTPS and uses it only for display (ADR 0015).
2263
+ * Returns undefined when the response has no usable Classroom API Key or Student ID Token.
2264
+ */
2265
+ function connectionFromTokens(response) {
2266
+ if (!response || typeof response !== "object")
2267
+ return undefined;
2268
+ const tokens = response;
2269
+ if (typeof tokens.access_token !== "string" || !tokens.access_token || typeof tokens.id_token !== "string")
2270
+ return undefined;
2271
+ let claims;
2272
+ try {
2273
+ const payload = JSON.parse(Buffer.from(tokens.id_token.split(".")[1] ?? "", "base64url").toString("utf8"));
2274
+ if (!payload || typeof payload !== "object" || Array.isArray(payload))
2275
+ return undefined;
2276
+ claims = payload;
2277
+ }
2278
+ catch {
2279
+ return undefined;
2280
+ }
2281
+ const fromClaims = {
2282
+ displayName: claims.name,
2283
+ className: claims.class_name,
2284
+ sessionName: claims.session_name,
2285
+ classSessionId: claims.class_session_id,
2286
+ loginMethod: claims.login_method,
2287
+ };
2288
+ const connection = {
2289
+ version: 2,
2290
+ apiKey: tokens.access_token,
2291
+ ...Object.fromEntries(Object.entries(fromClaims).filter(([, value]) => value !== undefined && value !== "")),
2292
+ };
2293
+ // A claim of the wrong type means a malformed Student ID Token: refuse it rather than guess.
2294
+ return (0, secureStorage_1.isClassroomConnection)(connection) ? connection : undefined;
2295
+ }
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ClassroomKeyRejectedError = void 0;
4
4
  exports.assertClassroomKeyAccepted = assertClassroomKeyAccepted;
5
- /** Router refused this Classroom API Key: the student has to redeem a new invite code. */
5
+ /** Router refused this Classroom API Key: the student has to connect again with a new invite code. */
6
6
  class ClassroomKeyRejectedError extends Error {
7
7
  reason;
8
8
  constructor(reason) {
package/dist/desktop.js CHANGED
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.browserCommand = browserCommand;
6
7
  exports.openBrowser = openBrowser;
7
8
  exports.asset = asset;
8
9
  exports.writeTool = writeTool;
@@ -13,12 +14,21 @@ const node_child_process_1 = require("node:child_process");
13
14
  const node_sea_1 = require("node:sea");
14
15
  const promises_1 = __importDefault(require("node:fs/promises"));
15
16
  const node_path_1 = __importDefault(require("node:path"));
17
+ /**
18
+ * The program that opens a URL in the system browser. On Windows it is not `cmd.exe /c start`:
19
+ * cmd reads `&`, `%` and `^` in the URL as its own syntax and cuts the Authorization Page URL.
20
+ * The URL handler of url.dll gets the URL as one unchanged argument.
21
+ */
22
+ function browserCommand(url, platform = process.platform) {
23
+ return platform === "win32"
24
+ ? { file: "rundll32.exe", args: ["url.dll,FileProtocolHandler", url] }
25
+ : { file: "open", args: [url] };
26
+ }
16
27
  function openBrowser(url) {
17
28
  if (process.env.CLASSROOM_APP_HEADLESS === "1")
18
29
  return;
19
- const child = process.platform === "win32"
20
- ? (0, node_child_process_1.spawn)("cmd.exe", ["/d", "/c", "start", "", url], { detached: true, stdio: "ignore", windowsHide: true })
21
- : (0, node_child_process_1.spawn)("open", [url], { detached: true, stdio: "ignore" });
30
+ const { file, args } = browserCommand(url);
31
+ const child = (0, node_child_process_1.spawn)(file, args, { detached: true, stdio: "ignore", windowsHide: true });
22
32
  child.on("error", () => process.stderr.write("請用瀏覽器開啟顯示的本機網址。\n"));
23
33
  child.unref();
24
34
  }
@@ -2,33 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createMigratingConnectionStorage = createMigratingConnectionStorage;
4
4
  const storageErrors_1 = require("./storageErrors");
5
- function legacyConnection(raw) {
6
- let value;
7
- try {
8
- value = JSON.parse(raw);
9
- }
10
- catch {
11
- return undefined;
12
- }
13
- if (!value || typeof value !== "object")
14
- return undefined;
15
- const legacy = value;
16
- if (legacy.secureStorage !== undefined || typeof legacy.apiKey !== "string" || !legacy.apiKey)
17
- return undefined;
18
- const session = {};
19
- if (legacy.session && typeof legacy.session === "object") {
20
- const oldSession = legacy.session;
21
- for (const field of ["class_name", "name", "invite_code", "expires_at"]) {
22
- if (typeof oldSession[field] === "string")
23
- session[field] = oldSession[field];
24
- }
25
- }
26
- const connection = { version: 1, apiKey: legacy.apiKey, session, mode: legacy.mode === "classroom" ? "classroom" : "native" };
27
- if (typeof legacy.nickname === "string")
28
- connection.nickname = legacy.nickname;
29
- return connection;
30
- }
31
- /** Startup migration is shared by all reads and settles before later mutations. */
5
+ /**
6
+ * The legacy extension saved its classroom connection as plaintext. VansPod does not convert it (ADR 0015):
7
+ * startup removes the plaintext file, so no key stays readable on disk, and VansPod starts not connected.
8
+ * The removal is shared by all reads and settles before later mutations.
9
+ */
32
10
  function createMigratingConnectionStorage(storage, filePath, files) {
33
11
  let loaded;
34
12
  async function migrate() {
@@ -40,25 +18,13 @@ function createMigratingConnectionStorage(storage, filePath, files) {
40
18
  throw error;
41
19
  }
42
20
  try {
43
- const legacy = legacyConnection(await files.read(filePath));
44
- if (!legacy)
45
- throw new storageErrors_1.StorageError("unavailable");
46
- // A strict save performs protect, decrypt verification, protected temp write and replacement.
47
- const result = await storage.setConnection(legacy);
48
- if (result.persistence !== "persistent")
49
- throw new storageErrors_1.StorageError("unavailable");
50
- return legacy;
21
+ await files.remove(filePath);
51
22
  }
52
- catch {
53
- try {
54
- await files.remove(filePath);
55
- }
56
- catch (error) {
57
- if (error?.code !== "ENOENT")
58
- throw new storageErrors_1.StorageError("legacy-cleanup-failed");
59
- }
60
- throw new storageErrors_1.StorageError("migration-failed");
23
+ catch (error) {
24
+ if (error?.code !== "ENOENT")
25
+ throw new storageErrors_1.StorageError("legacy-cleanup-failed");
61
26
  }
27
+ return undefined;
62
28
  }
63
29
  function initialize() {
64
30
  if (!loaded) {
@@ -15,6 +15,12 @@ exports.modelStatusScript = `
15
15
  setTimeout(refreshModelStatus, 1000);
16
16
  }
17
17
  function applyModelStatus(status) {
18
+ // The connection changed outside this page (browser callback, 取消, timeout): draw the new state.
19
+ var shownConnection = document.querySelector("[data-connection-key]");
20
+ if (shownConnection && typeof status.connection === "string" && shownConnection.getAttribute("data-connection-key") !== status.connection) {
21
+ location.reload();
22
+ return;
23
+ }
18
24
  if (status.localTools) {
19
25
  var statusBar = document.querySelector("[data-remote-status]");
20
26
  var remoteStatus = status.localTools.status;
package/dist/page.js CHANGED
@@ -9,6 +9,7 @@ exports.environmentStatus = environmentStatus;
9
9
  exports.renderPage = renderPage;
10
10
  exports.renderInspectorPage = renderInspectorPage;
11
11
  exports.renderRemoteAgentPage = renderRemoteAgentPage;
12
+ const node_crypto_1 = require("node:crypto");
12
13
  const version_1 = require("./version");
13
14
  const html_1 = require("./html");
14
15
  const appearance_1 = require("./appearance");
@@ -79,6 +80,12 @@ function connectionFeedback(view) {
79
80
  const feedback = `<div class="connection-feedback">${message ? `<div class="${view.connectionError ? "connection-error" : "connection-message"}" role="${view.connectionError ? "alert" : "status"}"><svg viewBox="0 0 24 24" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.8"><circle cx="12" cy="12" r="9"/><path d="M12 7v6M12 15v2"/></svg><p>${(0, html_1.escapeHtml)(message)}</p></div>` : ""}</div>`;
80
81
  return feedback;
81
82
  }
83
+ /** While VansPod waits for the browser: a link to the Authorization Page, for when the browser did not open. */
84
+ function authorizeLink(view) {
85
+ return view.connecting && view.authorizeUrl
86
+ ? `<p class="hint"><a href="${(0, html_1.escapeHtml)(view.authorizeUrl)}" target="_blank" rel="noopener">如果瀏覽器沒有打開,請點這裡</a></p>`
87
+ : "";
88
+ }
82
89
  function connectInner(view) {
83
90
  const feedback = connectionFeedback(view);
84
91
  if (view.canCopyKey) {
@@ -88,11 +95,17 @@ function connectInner(view) {
88
95
  </form>
89
96
  <form method="post" action="/clear">
90
97
  <button type="submit" class="quiet"${off}>清除連線</button>
91
- </form>${feedback}`;
98
+ </form>${authorizeLink(view)}${feedback}`;
99
+ }
100
+ if (view.connecting) {
101
+ return `<form class="stack" method="post" action="/connect-cancel">
102
+ <p class="connection-waiting" role="status">請在瀏覽器完成登入</p>
103
+ ${authorizeLink(view)}
104
+ ${feedback}
105
+ <button type="submit" class="quiet">取消</button>
106
+ </form>`;
92
107
  }
93
- return `<form class="stack" method="post" action="/redeem">
94
- <label>邀請碼 <input name="invite_code" autocomplete="off" value="${(0, html_1.escapeHtml)(view.connectionDraft?.inviteCode ?? "")}"${locked(view)}></label>
95
- <label>課堂暱稱 <input name="nickname" autocomplete="off" value="${(0, html_1.escapeHtml)(view.connectionDraft?.nickname ?? "")}"${locked(view)}></label>
108
+ return `<form class="stack" method="post" action="/connect">
96
109
  ${feedback}
97
110
  <button type="submit" class="go"${locked(view)}>連線</button>
98
111
  </form>`;
@@ -135,8 +148,19 @@ function clientLight(view, client) {
135
148
  const lightClass = health === "green" ? " detected" : health === "red" || health === "yellow" ? ` health-${health}` : "";
136
149
  return { health, className: `client-light${lightClass}`, status };
137
150
  }
151
+ /**
152
+ * The connection state the page shows. The browser callback, 取消 and the 10-minute timeout change it
153
+ * outside any page action, so the status poll reloads the page when it changes.
154
+ */
155
+ function connectionKey(view) {
156
+ const state = view.connected ? "connected" : view.connecting ? "connecting" : "none";
157
+ // The messages go in as a hash, so the page does not show their text twice.
158
+ const messages = (0, node_crypto_1.createHash)("sha256").update(JSON.stringify([view.connectionError ?? "", view.connectionNotice ?? ""])).digest("hex").slice(0, 12);
159
+ return `${state}:${messages}`;
160
+ }
138
161
  function modelStatus(view) {
139
162
  return {
163
+ connection: connectionKey(view),
140
164
  lights: { codex: clientLight(view, "codex"), claude: clientLight(view, "claude"), vscode: clientLight(view, "vscode") },
141
165
  restart: restartHtml(view),
142
166
  ...(view.localTools ? { localTools: { on: view.localTools.on, status: remoteStatus(view), approval: approvalStatus(view.localTools.approval, Boolean(view.localTools.autoApproval)), ...(view.localTools.log ? { log: (0, remoteAgentLogView_1.logListStatus)(view.localTools.log) } : {}) } } : {}),
@@ -216,6 +240,14 @@ function localToolsStateText(local) {
216
240
  return "已關閉,Agent 不能使用這台電腦。";
217
241
  }
218
242
  const LOCAL_TOOL_ACCESS = "允許 Agent 使用這台電腦";
243
+ // How to sign in on the Remote Agent's MCP Authorization Page: the same way as in VansPod (ADR 0013, ADR 0015).
244
+ function remoteSignInHint(local) {
245
+ if (local.loginMethod === "google")
246
+ return "在 Agent 的 MCP 授權頁,請選 Google,用同一個帳號登入。";
247
+ if (local.loginMethod === "nickname" && local.displayName)
248
+ return `在 Agent 的 MCP 授權頁,請選暱稱,輸入 <b>${(0, html_1.escapeHtml)(local.displayName)}</b>(大小寫要一樣)。`;
249
+ return "";
250
+ }
219
251
  // The status bar of the 遠端 Agent page: the connection, the names to match, and the
220
252
  // 允許 Agent 使用這台電腦 switch (Local Tool Access, ADR 0013). `key` changes only when the bar changes.
221
253
  function remoteStatus(view) {
@@ -223,12 +255,13 @@ function remoteStatus(view) {
223
255
  if (!local)
224
256
  return { key: "", html: `<section class="tile remote-status" data-remote-status data-status-key=""><p class="hint">這個 VansPod 不能讓 Agent 使用這台電腦。</p></section>` };
225
257
  const chip = (label, value) => `<span class="remote-chip">${label} <b>${(0, html_1.escapeHtml)(value)}</b></span>`;
226
- const chips = chip("電腦", local.device) + (local.nickname ? chip("暱稱", local.nickname) : "") + chip("資料夾", view.projectFolder ?? "還沒選");
258
+ const identity = local.displayName ? chip(local.loginMethod === "google" ? "Google" : "暱稱", local.displayName) : "";
259
+ const chips = chip("電腦", local.device) + identity + chip("資料夾", view.projectFolder ?? "還沒選");
227
260
  const lit = local.on && local.state === "connected";
228
261
  const guidance = !view.connected
229
- ? `<p class="remote-setup">請先到「教室設定」兌換課堂連線,才能讓 Agent 使用這台電腦。</p>`
262
+ ? `<p class="remote-setup">請先到「教室設定」按「連線」,才能讓 Agent 使用這台電腦。</p>`
230
263
  : local.on ? ""
231
- : `<p class="remote-setup">${local.nickname ? `在 Agent 的 MCP 授權頁選「暱稱」,輸入 <b>${(0, html_1.escapeHtml)(local.nickname)}</b>(大小寫要一樣)。` : ""}這台電腦會顯示為 <b>${(0, html_1.escapeHtml)(local.device)}</b>。每次啟動 VansPod,這個開關都會關閉。</p>`;
264
+ : `<p class="remote-setup">${remoteSignInHint(local)}這台電腦會顯示為 <b>${(0, html_1.escapeHtml)(local.device)}</b>。每次啟動 VansPod,這個開關都會關閉。</p>`;
232
265
  const auto = local.autoApproval;
233
266
  const main = `<div class="remote-status-main"><span class="remote-dot${lit ? " on" : ""}${auto ? " auto" : ""}"></span><div><strong role="status">${(0, html_1.escapeHtml)(localToolsStateText(local))}</strong><div class="remote-chips">${chips}</div></div></div>`;
234
267
  const toggle = `<form class="remote-switch-row" method="post" action="/local-tools"><span>${LOCAL_TOOL_ACCESS}</span><button type="submit" name="on" value="${local.on ? "0" : "1"}" role="switch" aria-checked="${local.on}" aria-label="${LOCAL_TOOL_ACCESS}" class="remote-switch" data-local-tools-switch></button></form>`;
@@ -823,6 +856,7 @@ function basePage(view) {
823
856
  <button type="button" data-appearance-toggle aria-label="切換外觀"></button>
824
857
  </header>
825
858
  <main>
859
+ <div hidden data-connection-key="${(0, html_1.escapeHtml)(connectionKey(view))}"></div>
826
860
  <p class="display">${(0, html_1.escapeHtml)(statusWord(view))}</p>
827
861
  ${notices(view)}
828
862
  <div class="modules">
@@ -988,16 +1022,18 @@ function organizeSettings(html, view) {
988
1022
  .replace('<div class="mascot-traveler">', `${speech}<div class="mascot-traveler">`);
989
1023
  }
990
1024
  if (!actions) {
991
- body = body.replace('action="/redeem"', 'action="/redeem" id="settings-redeem"');
1025
+ body = body.replace(/action="\/(connect|connect-cancel)"/, '$& id="settings-connect"');
992
1026
  body = body.replace(/<button[\s\S]*?<\/button>/, (button) => {
993
- actions = button.replace('<button ', '<button form="settings-redeem" ');
1027
+ actions = button.replace('<button ', '<button form="settings-connect" ');
994
1028
  return "";
995
1029
  });
996
1030
  const feedback = body.match(/<div class="connection-feedback">[\s\S]*?<\/div>(?=\s*<\/form>)/)?.[0] ?? '<div class="connection-feedback"></div>';
997
1031
  body = body.replace(feedback, "");
998
- const quote = view.connectionError === "請先輸入邀請碼與課堂暱稱,再按「連線」。"
999
- ? "我披風都穿好了,你的邀請碼跟暱稱呢?"
1000
- : "連線這關還沒過,披風倒是先上班了。照下面的提示再試一次!";
1032
+ const quote = view.connecting
1033
+ ? "我在這裡等你,去瀏覽器完成登入吧!"
1034
+ : !view.connectionError
1035
+ ? "我披風都穿好了,按「連線」去瀏覽器登入吧!"
1036
+ : "連線這關還沒過,披風倒是先上班了。照下面的提示再試一次!";
1001
1037
  const speech = `<div class="mascot-speech"><p class="mascot-quote">${(0, html_1.escapeHtml)(quote)}</p>${feedback}</div>`;
1002
1038
  body += connectionMascot_1.connectionMascot.replace('class="connection-mascot"', 'class="connection-mascot mascot-waiting"').replace('<div class="mascot-traveler">', `${speech}<div class="mascot-traveler">`);
1003
1039
  }
@@ -1070,7 +1106,7 @@ function renderPage(view) {
1070
1106
  const course = view.courseTitle
1071
1107
  ? `<p class="course-title">${(0, html_1.escapeHtml)(view.courseTitle)}</p>`
1072
1108
  : "";
1073
- const meta = [view.sessionTitle, view.nickname]
1109
+ const meta = [view.sessionTitle, view.displayName]
1074
1110
  .filter((value) => Boolean(value))
1075
1111
  .map((value) => `<span>${(0, html_1.escapeHtml)(value)}</span>`)
1076
1112
  .join('<span class="connection-separator" aria-hidden="true">·</span>');
@@ -6,7 +6,7 @@ const secureStorage_1 = require("./secureStorage");
6
6
  const windowsSecureStorage_1 = require("./windowsSecureStorage");
7
7
  const legacyMigration_1 = require("./legacyMigration");
8
8
  const storageLocation_1 = require("./storageLocation");
9
- /** Read once; unsuccessful reads remain distinguishable until a successful new redeem. */
9
+ /** Read once; unsuccessful reads remain distinguishable until a successful new connection. */
10
10
  function createPersistentConnectionStorage(persistent) {
11
11
  const memory = (0, secureStorage_1.createConnectionStorage)((0, secureStorage_1.createMemorySecureStorage)());
12
12
  let temporary = false;
@@ -1,10 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CONNECTION_KEY = void 0;
4
+ exports.isLoginMethod = isLoginMethod;
4
5
  exports.createMemorySecureStorage = createMemorySecureStorage;
5
6
  exports.createConnectionStorage = createConnectionStorage;
6
7
  exports.isClassroomConnection = isClassroomConnection;
7
8
  const storageErrors_1 = require("./storageErrors");
9
+ function isLoginMethod(value) {
10
+ return value === "nickname" || value === "google";
11
+ }
8
12
  /** One instance lives for one process; there is no disk fallback. */
9
13
  function createMemorySecureStorage() {
10
14
  const values = new Map();
@@ -31,6 +35,11 @@ function createConnectionStorage(storage) {
31
35
  catch {
32
36
  throw new storageErrors_1.StorageError("unreadable");
33
37
  }
38
+ // The v1 format (Nickname Redeem) is replaced, not converted (ADR 0015): it means "not connected".
39
+ if (isOldFormat(value)) {
40
+ await storage.delete(exports.CONNECTION_KEY);
41
+ return undefined;
42
+ }
34
43
  if (!isClassroomConnection(value))
35
44
  throw new storageErrors_1.StorageError("unreadable");
36
45
  return value;
@@ -43,6 +52,9 @@ function createConnectionStorage(storage) {
43
52
  async clearConnection() { await storage.delete(exports.CONNECTION_KEY); },
44
53
  };
45
54
  }
55
+ function isOldFormat(value) {
56
+ return Boolean(value) && typeof value === "object" && value.version === 1;
57
+ }
46
58
  function isClassroomConnection(value) {
47
59
  if (!value || typeof value !== "object")
48
60
  return false;
@@ -51,13 +63,13 @@ function isClassroomConnection(value) {
51
63
  !["native", "classroom"].includes(record.clientModes.codex) ||
52
64
  !["native", "classroom"].includes(record.clientModes.claude)))
53
65
  return false;
54
- if (record.version !== 1 || typeof record.apiKey !== "string" || !record.apiKey ||
66
+ if (record.version !== 2 || typeof record.apiKey !== "string" || !record.apiKey ||
55
67
  (record.mode !== undefined && record.mode !== "native" && record.mode !== "classroom") ||
56
- (record.nickname !== undefined && typeof record.nickname !== "string") ||
57
- !record.session || typeof record.session !== "object" || Array.isArray(record.session))
68
+ (record.loginMethod !== undefined && !isLoginMethod(record.loginMethod)) ||
69
+ (record.classSessionId !== undefined && !Number.isInteger(record.classSessionId)))
58
70
  return false;
59
- return ["class_name", "name", "invite_code", "expires_at"].every(field => {
60
- const item = record.session[field];
71
+ return ["displayName", "className", "sessionName"].every(field => {
72
+ const item = record[field];
61
73
  return item === undefined || typeof item === "string";
62
74
  });
63
75
  }
@@ -5,7 +5,7 @@ exports.settingsActionsScript = `
5
5
  var settingsBusy = false;
6
6
  document.addEventListener("submit", async function (event) {
7
7
  var form = event.target;
8
- if (!form?.matches?.('form[action="/redeem"], form[action="/copy"], form[action="/clear"], form[action="/project-folder"], form[action="/pick-folder"], form[action="/switch"], form[action="/adapter"], form[action="/reload"], form[action="/environment-check"], form[action="/environment"]')) return;
8
+ if (!form?.matches?.('form[action="/connect"], form[action="/connect-cancel"], form[action="/copy"], form[action="/clear"], form[action="/project-folder"], form[action="/pick-folder"], form[action="/switch"], form[action="/adapter"], form[action="/reload"], form[action="/environment-check"], form[action="/environment"]')) return;
9
9
  event.preventDefault();
10
10
  if (settingsBusy || installBusy || installOpening || document.querySelector(".confirm-dialog")) return;
11
11
  settingsBusy = true;
@@ -37,23 +37,15 @@ exports.settingsActionsScript = `
37
37
  if (copyAction && typeof updateCopyFeedback === "function" && updateCopyFeedback(updated)) return;
38
38
  var top = window.scrollY;
39
39
  var openDetails = Array.from(main.querySelectorAll("details"), function (detail) { return detail.open; });
40
- var redeemForm = main.querySelector?.('form[action="/redeem"]');
41
- var connectionDraft = redeemForm && !form.matches('form[action="/redeem"], form[action="/clear"]')
42
- ? Array.from(redeemForm.querySelectorAll('input'), function (input) { return { name: input.name, value: input.value }; }) : [];
43
40
  var folderDraft = !form.matches('form[action="/project-folder"], form[action="/pick-folder"]')
44
41
  ? main.querySelector?.('input[name="project_folder"]')?.value : undefined;
45
42
  var toolDraft = reloadAction ? Array.from(main.querySelectorAll('input[type="checkbox"]'), function (input) {
46
43
  return { name: input.name, value: input.value, checked: input.checked };
47
44
  }) : [];
48
- var mascotState = typeof mascotAnimationState === "function" && !form.matches('form[action="/redeem"], form[action="/clear"]') ? mascotAnimationState() : [];
45
+ var mascotState = typeof mascotAnimationState === "function" && !form.matches('form[action="/connect"], form[action="/connect-cancel"], form[action="/clear"]') ? mascotAnimationState() : [];
49
46
  if (form.matches('form[action="/copy"]')) mascotState.speechDismissed = false;
50
47
  if (typeof returnClassroomUpdateHome === "function") returnClassroomUpdateHome();
51
48
  main.replaceChildren(...updated.childNodes);
52
- var updatedRedeemForm = main.querySelector?.('form[action="/redeem"]');
53
- updatedRedeemForm?.querySelectorAll('input').forEach(function (input) {
54
- var draft = connectionDraft.find(function (entry) { return entry.name === input.name; });
55
- if (draft) input.value = draft.value;
56
- });
57
49
  var folderInput = main.querySelector?.('input[name="project_folder"]');
58
50
  if (folderInput && folderDraft !== undefined) folderInput.value = folderDraft;
59
51
  if (reloadAction) main.querySelectorAll('input[type="checkbox"]').forEach(function (input) {
package/dist/start.js CHANGED
@@ -117,21 +117,6 @@ async function writeCopilotProviders(doc) {
117
117
  async function fetchSessionModels(apiKey) {
118
118
  return (0, routerSessionModels_1.fetchSessionModelProviders)({ root: routerBaseUrl(), apiKey });
119
119
  }
120
- function isRedeemResult(value) {
121
- if (!value || typeof value !== "object") {
122
- return false;
123
- }
124
- const record = value;
125
- return (typeof record.api_key === "string" &&
126
- record.api_key.length > 0 &&
127
- !!record.session &&
128
- typeof record.session === "object" &&
129
- !Array.isArray(record.session) &&
130
- ["class_name", "name", "invite_code", "expires_at"].every(field => {
131
- const item = record.session[field];
132
- return item === undefined || typeof item === "string";
133
- }));
134
- }
135
120
  async function fetchCourseCatalog(apiKey) {
136
121
  return (0, routerCourseCatalog_1.fetchCourseCatalog)({ root: routerBaseUrl(), apiKey });
137
122
  }
@@ -143,28 +128,17 @@ async function readClassroomInstalls(folder) {
143
128
  return undefined;
144
129
  }
145
130
  }
146
- async function redeemNickname(body) {
147
- const root = routerBaseUrl();
148
- const response = await fetch(`${root}/extension/sessions/nickname-redeem`, {
149
- signal: AbortSignal.timeout(5_000),
131
+ /** The token request of the Authorization Page flow (ADR 0015). VansPod is a public client: no secret. */
132
+ async function exchangeCode(body) {
133
+ const response = await fetch(`${routerBaseUrl()}/oauth/token`, {
134
+ signal: AbortSignal.timeout(10_000),
150
135
  method: "POST",
151
- headers: {
152
- "Content-Type": "application/json",
153
- Accept: "application/json",
154
- },
155
- body: JSON.stringify({
156
- invite_code: body.invite_code,
157
- nickname: body.nickname,
158
- }),
136
+ headers: { "Content-Type": "application/x-www-form-urlencoded", Accept: "application/json" },
137
+ body: new URLSearchParams({ grant_type: "authorization_code", client_id: classroomApp_1.OAUTH_CLIENT_ID, ...body }).toString(),
159
138
  });
160
- if (!response.ok) {
161
- throw new Error("nickname redeem failed");
162
- }
163
- const json = await response.json();
164
- if (!isRedeemResult(json)) {
165
- throw new Error("nickname redeem failed");
166
- }
167
- return json;
139
+ if (!response.ok)
140
+ throw new Error("token exchange failed");
141
+ return response.json();
168
142
  }
169
143
  function isEnvironmentTool(value) {
170
144
  return classroomApp_1.ENVIRONMENT_TOOLS.includes(value);
@@ -427,7 +401,7 @@ async function main(instance) {
427
401
  legacyOrigins: [pageUrl.replace(/\/$/, ""), "http://127.0.0.1:47821"],
428
402
  userSettingsFile: routePaths().vsCode,
429
403
  }),
430
- router: { redeemNickname, fetchSessionModels },
404
+ router: { authorizeUrl: `${routerBaseUrl()}/oauth/authorize`, exchangeCode, fetchSessionModels },
431
405
  catalog: { fetchCourseCatalog },
432
406
  projectFiles: { readClassroomInstalls },
433
407
  clipboard: { write: clipboard_1.writeClipboard },
@@ -441,6 +415,7 @@ async function main(instance) {
441
415
  },
442
416
  },
443
417
  storage,
418
+ openBrowser: desktop_1.openBrowser,
444
419
  stopProcess() {
445
420
  // 關視窗不呼叫這裡。停止是頁面上的單獨動作。
446
421
  },
@@ -652,12 +627,25 @@ async function main(instance) {
652
627
  res.end(bytes);
653
628
  return;
654
629
  }
655
- if (req.method === "POST" && pathname === "/redeem") {
656
- const params = new URLSearchParams(await readBody(req));
657
- await app.redeem(params.get("invite_code") ?? "", params.get("nickname") ?? "");
630
+ if (req.method === "POST" && pathname === "/connect") {
631
+ await readBody(req);
632
+ await app.startConnection();
658
633
  goHome();
659
634
  return;
660
635
  }
636
+ if (req.method === "POST" && pathname === "/connect-cancel") {
637
+ await readBody(req);
638
+ app.cancelConnection();
639
+ goHome();
640
+ return;
641
+ }
642
+ // The Authorization Page sends the system browser back here (redirect_uri).
643
+ if (req.method === "GET" && pathname === "/oauth/callback") {
644
+ const value = (name) => parsed.searchParams.get(name) ?? undefined;
645
+ await app.finishConnection({ code: value("code"), state: value("state"), error: value("error") });
646
+ redirect(res);
647
+ return;
648
+ }
661
649
  if (req.method === "POST" && pathname === "/pick-folder") {
662
650
  const params = new URLSearchParams(await readBody(req));
663
651
  const picked = await (0, folderPicker_1.pickProjectFolder)();
@@ -5,11 +5,10 @@ class StorageError extends Error {
5
5
  code;
6
6
  constructor(code) {
7
7
  super(code === "invalid" ? "課堂連線資料格式不正確。請重新連線。" :
8
- code === "legacy" ? "課堂連線需要安全遷移。" :
9
- code === "migration-failed" ? "舊課堂連線無法安全遷移,已移除舊憑證。請重新連線。" :
10
- code === "legacy-cleanup-failed" ? "無法移除舊課堂憑證。請手動刪除 VansPod 的 connection.json,再重新連線。" :
11
- code === "clear-failed" ? "無法清除已保存的課堂連線。" :
12
- code === "unreadable" ? "課堂連線無法解密。請重新連線。" : "安全儲存暫時無法使用。");
8
+ code === "legacy" ? "找到舊版的明文課堂連線,需要移除。" :
9
+ code === "legacy-cleanup-failed" ? "無法移除舊課堂憑證。請手動刪除 VansPod 的 connection.json,再重新連線。" :
10
+ code === "clear-failed" ? "無法清除已保存的課堂連線。" :
11
+ code === "unreadable" ? "課堂連線無法解密。請重新連線。" : "安全儲存暫時無法使用。");
13
12
  this.code = code;
14
13
  this.name = "StorageError";
15
14
  }
package/dist/version.js CHANGED
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
- exports.VERSION = "0.4.16";
4
+ exports.VERSION = "0.5.1";
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "vanspod",
3
- "version": "0.4.16",
3
+ "version": "0.5.1",
4
4
  "bin": { "vanspod": "bin/vanspod.cjs" },
5
5
  "engines": { "node": ">=24" },
6
6
  "os": ["win32"],
7
7
  "files": ["bin/", "dist/**/*.js", "!dist/test/**", "!dist/sea-*.js", "media/brand-logo.png", "media/brand-icon.ico", "media/fadou-superhero.png", "media/fadou-superhero-blink.png", "scripts/tray.ps1", "scripts/uninstall.ps1", "scripts/update.ps1", "README.md"],
8
8
  "publishConfig": { "access": "public" },
9
- "description": "本機 VansPod。學生用系統瀏覽器兌換課堂連線。",
9
+ "description": "本機 VansPod。學生用系統瀏覽器連線課堂。",
10
10
  "repository": { "type": "git", "url": "git+https://github.com/mz038197/VansPod.git" },
11
11
  "scripts": {
12
12
  "test": "tsc -p . && node --test dist/test/*.test.js",