@yu_robotics/remote-cli-router 1.6.221 → 1.6.223
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 +11 -1
- package/dist/binding/BindingManager.d.ts +5 -1
- package/dist/binding/BindingManager.d.ts.map +1 -1
- package/dist/binding/BindingManager.js +43 -10
- package/dist/binding/BindingManager.js.map +1 -1
- package/dist/feishu/FeishuLongConnHandler.d.ts +2 -1
- package/dist/feishu/FeishuLongConnHandler.d.ts.map +1 -1
- package/dist/feishu/FeishuLongConnHandler.js +11 -2
- package/dist/feishu/FeishuLongConnHandler.js.map +1 -1
- package/dist/files/DeviceAuth.d.ts +1 -0
- package/dist/files/DeviceAuth.d.ts.map +1 -1
- package/dist/files/DeviceAuth.js +36 -3
- package/dist/files/DeviceAuth.js.map +1 -1
- package/dist/server.d.ts +1 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +35 -0
- package/dist/server.js.map +1 -1
- package/dist/storage/JsonStore.d.ts.map +1 -1
- package/dist/storage/JsonStore.js +2 -1
- package/dist/storage/JsonStore.js.map +1 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/package.json +1 -1
package/dist/server.js
CHANGED
|
@@ -83,6 +83,7 @@ class RouterServer {
|
|
|
83
83
|
outputTransfers;
|
|
84
84
|
outputsAvailable = false;
|
|
85
85
|
outputSessions = new Map();
|
|
86
|
+
deviceEnrollments = new Set();
|
|
86
87
|
constructor(config, store) {
|
|
87
88
|
this.config = config;
|
|
88
89
|
this.store = store;
|
|
@@ -162,6 +163,15 @@ class RouterServer {
|
|
|
162
163
|
this.feishuLongConnHandler.onOutputFileAction = (openId, cardId, payload) => this.outputTransfers.click(openId, cardId, payload);
|
|
163
164
|
this.feishuLongConnHandler.onFileMessage = input => this.fileTransfers.receive(input);
|
|
164
165
|
this.feishuLongConnHandler.onResolveFile = (openId, sourceId) => this.fileTransfers.resolve(openId, sourceId);
|
|
166
|
+
this.feishuLongConnHandler.onDeviceEnrollmentBoundary = (deviceId, phase) => {
|
|
167
|
+
if (phase === 'end') {
|
|
168
|
+
this.deviceEnrollments.delete(deviceId);
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
// Exclude credentialless registrations before the pending marker reaches disk.
|
|
172
|
+
this.deviceEnrollments.add(deviceId);
|
|
173
|
+
this.connectionHub.disconnectDevice(deviceId);
|
|
174
|
+
};
|
|
165
175
|
this.feishuLongConnHandler.onApproveDeviceKey = async (openId, deviceId, publicKey) => {
|
|
166
176
|
if ((await this.bindingManager.getDeviceBinding(deviceId))?.openId !== openId)
|
|
167
177
|
throw new Error('Device ownership changed.');
|
|
@@ -757,7 +767,19 @@ class RouterServer {
|
|
|
757
767
|
const requestedId = message.data.deviceId;
|
|
758
768
|
let authenticatedOwner;
|
|
759
769
|
try {
|
|
770
|
+
if (this.deviceEnrollments.has(requestedId)) {
|
|
771
|
+
ws.send(JSON.stringify({ type: 'error', data: { code: 'DEVICE_AUTH_REQUIRED', message: 'Device key enrollment is in progress. Retry after approval.' } }));
|
|
772
|
+
ws.close();
|
|
773
|
+
break;
|
|
774
|
+
}
|
|
760
775
|
const enrolled = await this.deviceAuth.get(requestedId);
|
|
776
|
+
const binding = await this.bindingManager.getDeviceBinding(requestedId);
|
|
777
|
+
const requiresAuthentication = binding?.devices?.some(device => device.deviceId === requestedId && device.requiresDeviceAuth);
|
|
778
|
+
if (requiresAuthentication && !enrolled) {
|
|
779
|
+
ws.send(JSON.stringify({ type: 'error', data: { code: 'DEVICE_AUTH_REQUIRED', message: 'Device key enrollment is incomplete. Approve the device key and retry.' } }));
|
|
780
|
+
ws.close();
|
|
781
|
+
break;
|
|
782
|
+
}
|
|
761
783
|
if (enrolled) {
|
|
762
784
|
if (!message.data.deviceSignature && !enrolled.revoked) {
|
|
763
785
|
if (this.stopping || socketClosed || !admission.active() || ws.readyState !== ws_1.WebSocket.OPEN)
|
|
@@ -780,6 +802,16 @@ class RouterServer {
|
|
|
780
802
|
}
|
|
781
803
|
if (this.stopping || socketClosed || !admission.active() || ws.readyState !== ws_1.WebSocket.OPEN)
|
|
782
804
|
break;
|
|
805
|
+
if (!authenticatedOwner) {
|
|
806
|
+
const current = await this.bindingManager.getDeviceBinding(requestedId);
|
|
807
|
+
const pending = current?.devices?.some(device => device.deviceId === requestedId && device.requiresDeviceAuth);
|
|
808
|
+
const enrolledAfterLookup = await this.deviceAuth.get(requestedId);
|
|
809
|
+
if (this.deviceEnrollments.has(requestedId) || pending || enrolledAfterLookup) {
|
|
810
|
+
ws.send(JSON.stringify({ type: 'error', data: { code: 'DEVICE_AUTH_REQUIRED', message: 'Device authentication is required. Reconnect and retry.' } }));
|
|
811
|
+
ws.close();
|
|
812
|
+
break;
|
|
813
|
+
}
|
|
814
|
+
}
|
|
783
815
|
}
|
|
784
816
|
catch {
|
|
785
817
|
ws.send(JSON.stringify({ type: 'error', data: { code: 'DEVICE_AUTH_REQUIRED', message: 'Device authentication is unavailable. Ask the Router administrator to check the authentication store.' } }));
|
|
@@ -789,6 +821,9 @@ class RouterServer {
|
|
|
789
821
|
finally {
|
|
790
822
|
authenticationPending = false;
|
|
791
823
|
}
|
|
824
|
+
// Authentication lookups may outlive the socket or its admission lease.
|
|
825
|
+
if (this.stopping || socketClosed || !admission.active() || ws.readyState !== ws_1.WebSocket.OPEN)
|
|
826
|
+
break;
|
|
792
827
|
if (challengeTimer)
|
|
793
828
|
clearTimeout(challengeTimer);
|
|
794
829
|
// Version check: missing protocolVersion defaults to 1 (current baseline)
|