vanspod 0.4.15 → 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 +5 -5
- package/dist/classroomApp.js +185 -56
- package/dist/classroomKeyRejection.js +1 -1
- package/dist/codexWebSearch.js +1 -1
- package/dist/desktop.js +13 -3
- package/dist/deviceConnection.js +13 -2
- package/dist/html.js +12 -0
- package/dist/legacyMigration.js +10 -44
- package/dist/localCommands.js +82 -119
- package/dist/localToolApproval.js +81 -4
- package/dist/localTools.js +31 -8
- package/dist/modelStatus.js +14 -12
- package/dist/page.js +322 -132
- package/dist/platformStorage.js +1 -1
- package/dist/remoteAgentLog.js +126 -0
- package/dist/remoteAgentLogView.js +421 -0
- package/dist/saveImage.js +26 -0
- package/dist/secureStorage.js +17 -5
- package/dist/settingsActions.js +2 -10
- package/dist/start.js +86 -49
- package/dist/storageErrors.js +4 -5
- package/dist/trayChannel.js +25 -6
- package/dist/version.js +1 -1
- package/package.json +2 -2
- package/scripts/tray.ps1 +141 -11
package/dist/secureStorage.js
CHANGED
|
@@ -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 !==
|
|
66
|
+
if (record.version !== 2 || typeof record.apiKey !== "string" || !record.apiKey ||
|
|
55
67
|
(record.mode !== undefined && record.mode !== "native" && record.mode !== "classroom") ||
|
|
56
|
-
(record.
|
|
57
|
-
|
|
68
|
+
(record.loginMethod !== undefined && !isLoginMethod(record.loginMethod)) ||
|
|
69
|
+
(record.classSessionId !== undefined && !Number.isInteger(record.classSessionId)))
|
|
58
70
|
return false;
|
|
59
|
-
return ["
|
|
60
|
-
const item = record
|
|
71
|
+
return ["displayName", "className", "sessionName"].every(field => {
|
|
72
|
+
const item = record[field];
|
|
61
73
|
return item === undefined || typeof item === "string";
|
|
62
74
|
});
|
|
63
75
|
}
|
package/dist/settingsActions.js
CHANGED
|
@@ -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="/
|
|
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="/
|
|
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
|
@@ -9,8 +9,8 @@ const clientDetection_1 = require("./clientDetection");
|
|
|
9
9
|
const runtimeOptions_1 = require("./runtimeOptions");
|
|
10
10
|
const deviceConnection_1 = require("./deviceConnection");
|
|
11
11
|
const localTools_1 = require("./localTools");
|
|
12
|
+
const remoteAgentLog_1 = require("./remoteAgentLog");
|
|
12
13
|
const localToolApproval_1 = require("./localToolApproval");
|
|
13
|
-
const localCommands_1 = require("./localCommands");
|
|
14
14
|
const trayChannel_1 = require("./trayChannel");
|
|
15
15
|
const node_async_hooks_1 = require("node:async_hooks");
|
|
16
16
|
const node_child_process_1 = require("node:child_process");
|
|
@@ -19,6 +19,7 @@ const node_os_1 = __importDefault(require("node:os"));
|
|
|
19
19
|
const node_path_1 = __importDefault(require("node:path"));
|
|
20
20
|
const classroomApp_1 = require("./classroomApp");
|
|
21
21
|
const page_1 = require("./page");
|
|
22
|
+
const saveImage_1 = require("./saveImage");
|
|
22
23
|
const promptCapture_1 = require("./promptCapture");
|
|
23
24
|
const clipboard_1 = require("./clipboard");
|
|
24
25
|
const folderPicker_1 = require("./folderPicker");
|
|
@@ -116,21 +117,6 @@ async function writeCopilotProviders(doc) {
|
|
|
116
117
|
async function fetchSessionModels(apiKey) {
|
|
117
118
|
return (0, routerSessionModels_1.fetchSessionModelProviders)({ root: routerBaseUrl(), apiKey });
|
|
118
119
|
}
|
|
119
|
-
function isRedeemResult(value) {
|
|
120
|
-
if (!value || typeof value !== "object") {
|
|
121
|
-
return false;
|
|
122
|
-
}
|
|
123
|
-
const record = value;
|
|
124
|
-
return (typeof record.api_key === "string" &&
|
|
125
|
-
record.api_key.length > 0 &&
|
|
126
|
-
!!record.session &&
|
|
127
|
-
typeof record.session === "object" &&
|
|
128
|
-
!Array.isArray(record.session) &&
|
|
129
|
-
["class_name", "name", "invite_code", "expires_at"].every(field => {
|
|
130
|
-
const item = record.session[field];
|
|
131
|
-
return item === undefined || typeof item === "string";
|
|
132
|
-
}));
|
|
133
|
-
}
|
|
134
120
|
async function fetchCourseCatalog(apiKey) {
|
|
135
121
|
return (0, routerCourseCatalog_1.fetchCourseCatalog)({ root: routerBaseUrl(), apiKey });
|
|
136
122
|
}
|
|
@@ -142,28 +128,17 @@ async function readClassroomInstalls(folder) {
|
|
|
142
128
|
return undefined;
|
|
143
129
|
}
|
|
144
130
|
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
const response = await fetch(`${
|
|
148
|
-
signal: AbortSignal.timeout(
|
|
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),
|
|
149
135
|
method: "POST",
|
|
150
|
-
headers: {
|
|
151
|
-
|
|
152
|
-
Accept: "application/json",
|
|
153
|
-
},
|
|
154
|
-
body: JSON.stringify({
|
|
155
|
-
invite_code: body.invite_code,
|
|
156
|
-
nickname: body.nickname,
|
|
157
|
-
}),
|
|
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(),
|
|
158
138
|
});
|
|
159
|
-
if (!response.ok)
|
|
160
|
-
throw new Error("
|
|
161
|
-
|
|
162
|
-
const json = await response.json();
|
|
163
|
-
if (!isRedeemResult(json)) {
|
|
164
|
-
throw new Error("nickname redeem failed");
|
|
165
|
-
}
|
|
166
|
-
return json;
|
|
139
|
+
if (!response.ok)
|
|
140
|
+
throw new Error("token exchange failed");
|
|
141
|
+
return response.json();
|
|
167
142
|
}
|
|
168
143
|
function isEnvironmentTool(value) {
|
|
169
144
|
return classroomApp_1.ENVIRONMENT_TOOLS.includes(value);
|
|
@@ -411,8 +386,8 @@ async function main(instance) {
|
|
|
411
386
|
});
|
|
412
387
|
// One Local Tool Approval queue for this Device. The page and the Approval Popup (tray) decide here.
|
|
413
388
|
const approvals = (0, localToolApproval_1.createApprovalQueue)();
|
|
414
|
-
// The
|
|
415
|
-
const
|
|
389
|
+
// The Remote Agent Log of this VansPod run. Only memory: a restart starts an empty log.
|
|
390
|
+
const remoteAgentLog = (0, remoteAgentLog_1.createRemoteAgentLog)();
|
|
416
391
|
let trayChannel;
|
|
417
392
|
approvals.subscribe(() => trayChannel?.update());
|
|
418
393
|
app = new classroomApp_1.ClassroomApp({
|
|
@@ -426,7 +401,7 @@ async function main(instance) {
|
|
|
426
401
|
legacyOrigins: [pageUrl.replace(/\/$/, ""), "http://127.0.0.1:47821"],
|
|
427
402
|
userSettingsFile: routePaths().vsCode,
|
|
428
403
|
}),
|
|
429
|
-
router: {
|
|
404
|
+
router: { authorizeUrl: `${routerBaseUrl()}/oauth/authorize`, exchangeCode, fetchSessionModels },
|
|
430
405
|
catalog: { fetchCourseCatalog },
|
|
431
406
|
projectFiles: { readClassroomInstalls },
|
|
432
407
|
clipboard: { write: clipboard_1.writeClipboard },
|
|
@@ -440,6 +415,7 @@ async function main(instance) {
|
|
|
440
415
|
},
|
|
441
416
|
},
|
|
442
417
|
storage,
|
|
418
|
+
openBrowser: desktop_1.openBrowser,
|
|
443
419
|
stopProcess() {
|
|
444
420
|
// 關視窗不呼叫這裡。停止是頁面上的單獨動作。
|
|
445
421
|
},
|
|
@@ -454,11 +430,11 @@ async function main(instance) {
|
|
|
454
430
|
device: (0, deviceConnection_1.createDeviceConnection)({
|
|
455
431
|
url: process.env.CLASSROOM_DEVICE_RELAY_URL ?? "wss://mcp.vanscoding.com/device",
|
|
456
432
|
device: node_os_1.default.hostname(),
|
|
457
|
-
handle: (0, localTools_1.createLocalTools)({ projectFolder: () => app.view().projectFolder, system: localTools_1.localSystem, approver: approvals,
|
|
433
|
+
handle: (0, localTools_1.createLocalTools)({ projectFolder: () => app.view().projectFolder, system: localTools_1.localSystem, approver: approvals, log: remoteAgentLog }),
|
|
458
434
|
onChange: () => trayChannel?.update(),
|
|
459
435
|
}),
|
|
460
436
|
approvals,
|
|
461
|
-
|
|
437
|
+
remoteAgentLog,
|
|
462
438
|
});
|
|
463
439
|
dispatch = async (accepted, req, res) => {
|
|
464
440
|
if (!/^(127\.0\.0\.1|localhost):\d+$/.test(req.headers.host ?? "")) {
|
|
@@ -477,6 +453,19 @@ async function main(instance) {
|
|
|
477
453
|
}
|
|
478
454
|
redirect(res);
|
|
479
455
|
};
|
|
456
|
+
const sendRemoteAgentPage = () => {
|
|
457
|
+
res.writeHead(200, { "Content-Type": "text/html; charset=utf-8", "Cache-Control": "no-store" });
|
|
458
|
+
const html = (0, page_1.renderRemoteAgentPage)(app.view());
|
|
459
|
+
res.end(instance ? (0, lifecyclePage_1.lifecyclePage)(html, instance.token) : html);
|
|
460
|
+
};
|
|
461
|
+
// The Local Tool Access actions live on the 遠端 Agent page; its script posts them with X-Remote-Agent.
|
|
462
|
+
const goRemoteAgent = () => {
|
|
463
|
+
if (req.headers["x-remote-agent"] === "1") {
|
|
464
|
+
sendRemoteAgentPage();
|
|
465
|
+
return;
|
|
466
|
+
}
|
|
467
|
+
redirect(res, "/remote-agent");
|
|
468
|
+
};
|
|
480
469
|
try {
|
|
481
470
|
if (instance && pathname.startsWith("/_vanspod/")) {
|
|
482
471
|
if (req.headers.authorization !== `Bearer ${instance.token}` || (req.headers.origin && req.headers.origin !== instance.origin)) {
|
|
@@ -567,6 +556,24 @@ async function main(instance) {
|
|
|
567
556
|
res.end(JSON.stringify(answer.body));
|
|
568
557
|
return;
|
|
569
558
|
}
|
|
559
|
+
if (req.method === "GET" && pathname === "/remote-agent-log-entry") {
|
|
560
|
+
const answer = (0, page_1.remoteAgentLogEntryResponse)(app.view(), parsed.searchParams.get("id") ?? "");
|
|
561
|
+
res.writeHead(answer.status, { "Content-Type": "application/json; charset=utf-8", "Cache-Control": "no-store" });
|
|
562
|
+
res.end(JSON.stringify(answer.body));
|
|
563
|
+
return;
|
|
564
|
+
}
|
|
565
|
+
// A saved image of the Remote Agent Log, read from the disk: only from images/ in the Project Folder.
|
|
566
|
+
if (req.method === "GET" && pathname === "/remote-agent-image") {
|
|
567
|
+
const image = await (0, saveImage_1.readProjectImage)(app.view().projectFolder, parsed.searchParams.get("path") ?? "");
|
|
568
|
+
if (!image) {
|
|
569
|
+
res.writeHead(404, { "Cache-Control": "no-store" });
|
|
570
|
+
res.end();
|
|
571
|
+
return;
|
|
572
|
+
}
|
|
573
|
+
res.writeHead(200, { "Content-Type": image.mimeType, "Cache-Control": "no-store", "X-Content-Type-Options": "nosniff" });
|
|
574
|
+
res.end(image.bytes);
|
|
575
|
+
return;
|
|
576
|
+
}
|
|
570
577
|
if (req.method === "GET" && pathname === "/model-status") {
|
|
571
578
|
res.writeHead(200, {
|
|
572
579
|
"Content-Type": "application/json; charset=utf-8",
|
|
@@ -589,6 +596,10 @@ async function main(instance) {
|
|
|
589
596
|
res.end(JSON.stringify({ recording: promptCapture.recording, ...promptCapture.list() }));
|
|
590
597
|
return;
|
|
591
598
|
}
|
|
599
|
+
if (req.method === "GET" && pathname === "/remote-agent") {
|
|
600
|
+
sendRemoteAgentPage();
|
|
601
|
+
return;
|
|
602
|
+
}
|
|
592
603
|
if (req.method === "GET" && pathname === "/prompt-inspector") {
|
|
593
604
|
const html = (0, page_1.renderInspectorPage)({ recording: promptCapture.recording, ...promptCapture.list() });
|
|
594
605
|
res.writeHead(200, { "Content-Type": "text/html; charset=utf-8", "Cache-Control": "no-store" });
|
|
@@ -616,12 +627,25 @@ async function main(instance) {
|
|
|
616
627
|
res.end(bytes);
|
|
617
628
|
return;
|
|
618
629
|
}
|
|
619
|
-
if (req.method === "POST" && pathname === "/
|
|
620
|
-
|
|
621
|
-
await app.
|
|
630
|
+
if (req.method === "POST" && pathname === "/connect") {
|
|
631
|
+
await readBody(req);
|
|
632
|
+
await app.startConnection();
|
|
622
633
|
goHome();
|
|
623
634
|
return;
|
|
624
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
|
+
}
|
|
625
649
|
if (req.method === "POST" && pathname === "/pick-folder") {
|
|
626
650
|
const params = new URLSearchParams(await readBody(req));
|
|
627
651
|
const picked = await (0, folderPicker_1.pickProjectFolder)();
|
|
@@ -735,7 +759,7 @@ async function main(instance) {
|
|
|
735
759
|
if (req.method === "POST" && pathname === "/local-tools") {
|
|
736
760
|
const params = new URLSearchParams(await readBody(req));
|
|
737
761
|
await app.setLocalToolAccess(params.get("on") === "1");
|
|
738
|
-
|
|
762
|
+
goRemoteAgent();
|
|
739
763
|
return;
|
|
740
764
|
}
|
|
741
765
|
if (req.method === "POST" && pathname === "/local-tool-approval") {
|
|
@@ -743,13 +767,26 @@ async function main(instance) {
|
|
|
743
767
|
const decision = params.get("decision");
|
|
744
768
|
if (decision === "approve" || decision === "deny")
|
|
745
769
|
app.decideLocalToolApproval(params.get("id") ?? "", decision);
|
|
746
|
-
|
|
770
|
+
goRemoteAgent();
|
|
747
771
|
return;
|
|
748
772
|
}
|
|
749
|
-
if (req.method === "POST" && pathname === "/
|
|
773
|
+
if (req.method === "POST" && pathname === "/auto-approval-start") {
|
|
750
774
|
const params = new URLSearchParams(await readBody(req));
|
|
751
|
-
|
|
752
|
-
|
|
775
|
+
const duration = params.get("duration");
|
|
776
|
+
if (duration && Object.hasOwn(classroomApp_1.AUTO_APPROVAL_DURATIONS, duration))
|
|
777
|
+
app.startAutoApproval(duration);
|
|
778
|
+
goRemoteAgent();
|
|
779
|
+
return;
|
|
780
|
+
}
|
|
781
|
+
if (req.method === "POST" && pathname === "/auto-approval-stop") {
|
|
782
|
+
app.stopAutoApproval();
|
|
783
|
+
goRemoteAgent();
|
|
784
|
+
return;
|
|
785
|
+
}
|
|
786
|
+
if (req.method === "POST" && pathname === "/remote-agent-log-stop") {
|
|
787
|
+
const params = new URLSearchParams(await readBody(req));
|
|
788
|
+
app.stopRemoteAgentCommand(params.get("id") ?? "");
|
|
789
|
+
goRemoteAgent();
|
|
753
790
|
return;
|
|
754
791
|
}
|
|
755
792
|
if (req.method === "POST" && pathname === "/clear") {
|
package/dist/storageErrors.js
CHANGED
|
@@ -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 === "
|
|
10
|
-
code === "
|
|
11
|
-
code === "
|
|
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/trayChannel.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TRAY_BODY_CHARS = void 0;
|
|
3
|
+
exports.TRAY_BODY_CHARS = exports.AUTO_APPROVAL_NEEDS_ACCESS = void 0;
|
|
4
4
|
exports.createTrayChannel = createTrayChannel;
|
|
5
|
+
const classroomApp_1 = require("./classroomApp");
|
|
6
|
+
Object.defineProperty(exports, "AUTO_APPROVAL_NEEDS_ACCESS", { enumerable: true, get: function () { return classroomApp_1.AUTO_APPROVAL_NEEDS_ACCESS; } });
|
|
5
7
|
/** The popup shows this much of the body. On the page, 「顯示全部」 shows all of it. */
|
|
6
8
|
exports.TRAY_BODY_CHARS = 2_000;
|
|
7
9
|
function trayText(value, max) {
|
|
@@ -24,12 +26,13 @@ function createTrayChannel(options) {
|
|
|
24
26
|
}
|
|
25
27
|
catch { /* the tray has gone */ }
|
|
26
28
|
};
|
|
27
|
-
const state = () => {
|
|
28
|
-
const local = app.view().localTools;
|
|
29
|
+
const state = (local) => {
|
|
29
30
|
const shown = local?.approval;
|
|
31
|
+
const auto = local?.autoApproval;
|
|
30
32
|
return {
|
|
31
33
|
type: "state",
|
|
32
34
|
access: local?.on ?? false,
|
|
35
|
+
autoApproval: auto ? { label: auto.label, ...(auto.endsAt === undefined ? {} : { endsAt: auto.endsAt, secondsLeft: auto.secondsLeft }) } : null,
|
|
33
36
|
approval: shown ? {
|
|
34
37
|
id: shown.id,
|
|
35
38
|
tool: shown.tool,
|
|
@@ -39,15 +42,22 @@ function createTrayChannel(options) {
|
|
|
39
42
|
device: shown.device,
|
|
40
43
|
secondsLeft: shown.secondsLeft,
|
|
41
44
|
waiting: shown.waiting,
|
|
45
|
+
...(shown.exception ? { exception: shown.exception } : {}),
|
|
42
46
|
} : null,
|
|
43
47
|
};
|
|
44
48
|
};
|
|
45
49
|
const update = () => {
|
|
46
50
|
if (closed)
|
|
47
51
|
return;
|
|
48
|
-
const
|
|
52
|
+
const local = app.view().localTools;
|
|
53
|
+
const current = state(local);
|
|
49
54
|
// secondsLeft alone does not make a new state: the tray counts down itself.
|
|
50
|
-
|
|
55
|
+
// A new end time of Auto Approval does.
|
|
56
|
+
const key = JSON.stringify({
|
|
57
|
+
...current,
|
|
58
|
+
autoApproval: current.autoApproval && { ...current.autoApproval, secondsLeft: 0 },
|
|
59
|
+
approval: current.approval && { ...current.approval, secondsLeft: 0 },
|
|
60
|
+
});
|
|
51
61
|
if (key === lastState)
|
|
52
62
|
return;
|
|
53
63
|
lastState = key;
|
|
@@ -63,7 +73,7 @@ function createTrayChannel(options) {
|
|
|
63
73
|
}
|
|
64
74
|
if (!message || typeof message !== "object")
|
|
65
75
|
return;
|
|
66
|
-
const { type, id, decision, on } = message;
|
|
76
|
+
const { type, id, decision, on, duration } = message;
|
|
67
77
|
if (type === "decide" && typeof id === "string" && (decision === "approve" || decision === "deny")) {
|
|
68
78
|
app.decideLocalToolApproval(id, decision);
|
|
69
79
|
update();
|
|
@@ -80,6 +90,15 @@ function createTrayChannel(options) {
|
|
|
80
90
|
send({ type: "refused", message: local.message });
|
|
81
91
|
update();
|
|
82
92
|
}
|
|
93
|
+
else if (type === "auto_approval_start" && typeof duration === "string" && Object.hasOwn(classroomApp_1.AUTO_APPROVAL_DURATIONS, duration)) {
|
|
94
|
+
if (!app.startAutoApproval(duration))
|
|
95
|
+
send({ type: "refused", message: classroomApp_1.AUTO_APPROVAL_NEEDS_ACCESS });
|
|
96
|
+
update();
|
|
97
|
+
}
|
|
98
|
+
else if (type === "auto_approval_stop") {
|
|
99
|
+
app.stopAutoApproval();
|
|
100
|
+
update();
|
|
101
|
+
}
|
|
83
102
|
};
|
|
84
103
|
const onData = (chunk) => {
|
|
85
104
|
if (closed)
|
package/dist/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vanspod",
|
|
3
|
-
"version": "0.
|
|
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",
|