@yu_robotics/remote-cli-router 1.6.223 → 1.6.225
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 +33 -0
- package/dist/binding/BindingManager.d.ts +2 -0
- package/dist/binding/BindingManager.d.ts.map +1 -1
- package/dist/binding/BindingManager.js +11 -0
- package/dist/binding/BindingManager.js.map +1 -1
- package/dist/feishu/FeishuLongConnHandler.d.ts +1 -0
- package/dist/feishu/FeishuLongConnHandler.d.ts.map +1 -1
- package/dist/feishu/FeishuLongConnHandler.js +12 -0
- package/dist/feishu/FeishuLongConnHandler.js.map +1 -1
- package/dist/files/AutomaticFileEnrollment.d.ts +32 -0
- package/dist/files/AutomaticFileEnrollment.d.ts.map +1 -0
- package/dist/files/AutomaticFileEnrollment.js +187 -0
- package/dist/files/AutomaticFileEnrollment.js.map +1 -0
- package/dist/output/OutputFileCards.d.ts +10 -0
- package/dist/output/OutputFileCards.d.ts.map +1 -0
- package/dist/output/OutputFileCards.js +86 -0
- package/dist/output/OutputFileCards.js.map +1 -0
- package/dist/output/OutputTransfers.d.ts.map +1 -1
- package/dist/output/OutputTransfers.js +4 -11
- package/dist/output/OutputTransfers.js.map +1 -1
- package/dist/server.d.ts +1 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +41 -1
- package/dist/server.js.map +1 -1
- package/package.json +1 -1
package/dist/server.js
CHANGED
|
@@ -16,6 +16,7 @@ const TipService_1 = require("./tips/TipService");
|
|
|
16
16
|
const TipCatalog_1 = require("./tips/TipCatalog");
|
|
17
17
|
const TipImages_1 = require("./tips/TipImages");
|
|
18
18
|
const DeviceAuth_1 = require("./files/DeviceAuth");
|
|
19
|
+
const AutomaticFileEnrollment_1 = require("./files/AutomaticFileEnrollment");
|
|
19
20
|
const FileTransfers_1 = require("./files/FileTransfers");
|
|
20
21
|
const path_1 = __importDefault(require("path"));
|
|
21
22
|
const os_1 = __importDefault(require("os"));
|
|
@@ -79,6 +80,7 @@ class RouterServer {
|
|
|
79
80
|
selections;
|
|
80
81
|
threadInventoryRequests = new Map();
|
|
81
82
|
deviceAuth;
|
|
83
|
+
automaticFileEnrollment;
|
|
82
84
|
fileTransfers;
|
|
83
85
|
outputTransfers;
|
|
84
86
|
outputsAvailable = false;
|
|
@@ -183,6 +185,14 @@ class RouterServer {
|
|
|
183
185
|
this.outputTransfers.disconnect(deviceId);
|
|
184
186
|
this.outputSessions.delete(deviceId);
|
|
185
187
|
};
|
|
188
|
+
this.automaticFileEnrollment = new AutomaticFileEnrollment_1.AutomaticFileEnrollment(path_1.default.join(path_1.default.dirname(config.getConfigPath()
|
|
189
|
+
|| path_1.default.join(os_1.default.homedir(), '.remote-cli-router', 'config.json')), 'automatic-file-enrollment', 'requests.json'), {
|
|
190
|
+
bindings: this.bindingManager, auth: this.deviceAuth,
|
|
191
|
+
create: (openId, content, uuid) => this.feishuLongConnHandler.createOutputCard(openId, content, uuid),
|
|
192
|
+
approve: (openId, deviceId, key) => this.feishuLongConnHandler.onApproveDeviceKey(openId, deviceId, key),
|
|
193
|
+
});
|
|
194
|
+
this.feishuLongConnHandler.onAutomaticFileEnrollment = (openId, cardId, payload) => this.fileTransfers.enabled
|
|
195
|
+
? this.automaticFileEnrollment.click(openId, cardId, payload) : Promise.resolve('File access is disabled by the Router administrator.');
|
|
186
196
|
this.feishuLongConnHandler.onRevokeDevice = async (deviceId) => {
|
|
187
197
|
const owner = await this.bindingManager.getDeviceBinding(deviceId);
|
|
188
198
|
if (owner?.openId)
|
|
@@ -571,6 +581,9 @@ class RouterServer {
|
|
|
571
581
|
let subscriptionInspectionEnabled = false;
|
|
572
582
|
let bankedResetReminderEnabled = false;
|
|
573
583
|
let authenticationPending = false;
|
|
584
|
+
let automaticEnrollmentEnabled = false;
|
|
585
|
+
let automaticEnrollmentAuthority;
|
|
586
|
+
let automaticEnrollmentRequestPending = false;
|
|
574
587
|
let challengeTimer;
|
|
575
588
|
let heartbeatTimeout = null;
|
|
576
589
|
// Reset heartbeat timeout
|
|
@@ -605,6 +618,24 @@ class RouterServer {
|
|
|
605
618
|
return;
|
|
606
619
|
// Update heartbeat on any message
|
|
607
620
|
resetHeartbeat();
|
|
621
|
+
if (message.type === 'automatic_file_enrollment') {
|
|
622
|
+
const current = () => registered && !this.stopping && this.connectionHub.isCurrentConnection(deviceId, ws) && ws.readyState === ws_1.WebSocket.OPEN;
|
|
623
|
+
if (!deviceId || !automaticEnrollmentEnabled || !automaticEnrollmentAuthority || !this.fileTransfers.enabled
|
|
624
|
+
|| automaticEnrollmentRequestPending || !current())
|
|
625
|
+
return;
|
|
626
|
+
automaticEnrollmentRequestPending = true;
|
|
627
|
+
let status = 'unavailable';
|
|
628
|
+
try {
|
|
629
|
+
status = await this.automaticFileEnrollment.request(deviceId, message.data, automaticEnrollmentAuthority, current);
|
|
630
|
+
}
|
|
631
|
+
catch { /* Enrollment must not interrupt text tasks. */ }
|
|
632
|
+
finally {
|
|
633
|
+
automaticEnrollmentRequestPending = false;
|
|
634
|
+
}
|
|
635
|
+
if (current())
|
|
636
|
+
ws.send(JSON.stringify({ type: 'automatic_file_enrollment_status', data: { status } }));
|
|
637
|
+
return;
|
|
638
|
+
}
|
|
608
639
|
if (message.type === 'status' && this.threadInventoryRequests.has(message.messageId)) {
|
|
609
640
|
await this.handleThreadInventoryResponse(message, deviceId, ws);
|
|
610
641
|
return;
|
|
@@ -866,6 +897,13 @@ class RouterServer {
|
|
|
866
897
|
if (outputsEnabled)
|
|
867
898
|
this.outputSessions.set(deviceId, { id: (0, crypto_1.randomUUID)(), openId: authenticatedOwner });
|
|
868
899
|
const filesEnabled = Boolean(this.fileTransfers.enabled && authenticatedOwner && message.data.capabilities?.fileTransferV1 === true);
|
|
900
|
+
const enrollmentBinding = this.fileTransfers.enabled && !authenticatedOwner
|
|
901
|
+
&& message.data.capabilities?.automaticFileEnrollmentV1 === true
|
|
902
|
+
? await this.bindingManager.getDeviceBinding(requestedId) : null;
|
|
903
|
+
const enrollmentEpoch = enrollmentBinding && this.bindingManager.getCardThreadEpoch(enrollmentBinding.openId, requestedId);
|
|
904
|
+
automaticEnrollmentAuthority = enrollmentBinding && enrollmentEpoch
|
|
905
|
+
? Object.freeze({ openId: enrollmentBinding.openId, epoch: enrollmentEpoch }) : undefined;
|
|
906
|
+
automaticEnrollmentEnabled = Boolean(automaticEnrollmentAuthority);
|
|
869
907
|
if (filesEnabled)
|
|
870
908
|
this.connectionHub.setFileSession(deviceId, { id: (0, crypto_1.randomUUID)(), openId: authenticatedOwner });
|
|
871
909
|
this.fileTransfers.disconnect(deviceId);
|
|
@@ -907,7 +945,8 @@ class RouterServer {
|
|
|
907
945
|
success: true,
|
|
908
946
|
routerVersion: types_1.ROUTER_VERSION,
|
|
909
947
|
minCliVersion: types_1.MIN_SUPPORTED_CLI_VERSION,
|
|
910
|
-
...((taskRecoveryEnabled || approvalCardsEnabled || delegationProgressEnabled || streamingContextEnabled || activityProgressEnabled || filesEnabled || outputsEnabled || updateNoticeEnabled || subscriptionInspectionEnabled || settingsCardsEnabled) ? { capabilities: {
|
|
948
|
+
...((taskRecoveryEnabled || approvalCardsEnabled || delegationProgressEnabled || streamingContextEnabled || activityProgressEnabled || filesEnabled || outputsEnabled || updateNoticeEnabled || subscriptionInspectionEnabled || settingsCardsEnabled || automaticEnrollmentEnabled) ? { capabilities: {
|
|
949
|
+
...(automaticEnrollmentEnabled ? { automaticFileEnrollmentV1: true } : {}),
|
|
911
950
|
...(activityProgressEnabled ? { activityProgress: true } : {}),
|
|
912
951
|
...(updateNoticeEnabled ? { updateNotice: true } : {}),
|
|
913
952
|
...(subscriptionInspectionEnabled ? { subscriptionInspection: true } : {}),
|
|
@@ -2521,6 +2560,7 @@ class RouterServer {
|
|
|
2521
2560
|
this.maintenanceCards.destroy();
|
|
2522
2561
|
this.maintenanceConnections.clear();
|
|
2523
2562
|
await attempt('Error destroying output transfers', () => this.outputTransfers.destroy());
|
|
2563
|
+
await attempt('Error draining automatic enrollment', () => this.automaticFileEnrollment.destroy());
|
|
2524
2564
|
await attempt('Error destroying file transfers', () => this.fileTransfers.destroy());
|
|
2525
2565
|
if (this.cleanupInterval) {
|
|
2526
2566
|
clearInterval(this.cleanupInterval);
|