Commit 45e5fad5 authored by Lisa (AI Assistant)'s avatar Lisa (AI Assistant)

Skip device signature on initial connect - use token auth only until paired

parent 31729b43
...@@ -272,7 +272,8 @@ class NodeClient() { ...@@ -272,7 +272,8 @@ class NodeClient() {
// Get the token from the response and reconnect // Get the token from the response and reconnect
val newToken = json.optJSONObject("payload")?.optString("token", "") ?: "" val newToken = json.optJSONObject("payload")?.optString("token", "") ?: ""
isPairingMode = false isPairingMode = false
sendConnectRequestWithChallenge(nodeId, newToken, capabilities) // After pairing, include device info for authenticated connection
sendConnectRequestWithChallenge(nodeId, newToken, capabilities, includeDevice = true)
} }
} }
} }
...@@ -365,7 +366,7 @@ class NodeClient() { ...@@ -365,7 +366,7 @@ class NodeClient() {
}) })
} }
private fun sendConnectRequest(nodeId: String, token: String, capabilities: NodeCapabilities) { private fun sendConnectRequest(nodeId: String, token: String, capabilities: NodeCapabilities, includeDevice: Boolean = false) {
pendingRequestId = "connect-${System.currentTimeMillis()}" pendingRequestId = "connect-${System.currentTimeMillis()}"
val connectParams = JSONObject().apply { val connectParams = JSONObject().apply {
...@@ -401,12 +402,15 @@ class NodeClient() { ...@@ -401,12 +402,15 @@ class NodeClient() {
put("auth", JSONObject().apply { put("auth", JSONObject().apply {
put("token", token) put("token", token)
}) })
put("device", JSONObject().apply { // Only include device info if explicitly requested (after pairing)
put("id", deviceId) if (includeDevice) {
put("publicKey", devicePublicKey) put("device", JSONObject().apply {
put("si", deviceId) // Service identity = device ID put("id", deviceId)
put("signature", signData(token)) // Sign the token put("publicKey", devicePublicKey)
}) put("si", deviceId) // Service identity = device ID
put("signature", signData(token)) // Sign the token
})
}
put("locale", "en-US") put("locale", "en-US")
put("userAgent", "openclaw-android/1.0.0") put("userAgent", "openclaw-android/1.0.0")
} }
...@@ -421,22 +425,26 @@ class NodeClient() { ...@@ -421,22 +425,26 @@ class NodeClient() {
sendJson(connectRequest) sendJson(connectRequest)
} }
private fun sendConnectRequestWithChallenge(nodeId: String, token: String, capabilities: NodeCapabilities) { private fun sendConnectRequestWithChallenge(nodeId: String, token: String, capabilities: NodeCapabilities, includeDevice: Boolean = false) {
pendingRequestId = "connect-${System.currentTimeMillis()}" pendingRequestId = "connect-${System.currentTimeMillis()}"
// Use v3 signature format // Use v3 signature format - only if including device info
val scopesArray = JSONArray() val scopesArray = JSONArray()
// Sign the v3 payload - clientId should be deviceId // Only generate signature if we're including device info
val signature = signV3Payload( val signature = if (includeDevice) {
nonce = challengeNonce, signV3Payload(
clientId = deviceId, // Use device ID for signature nonce = challengeNonce,
role = "node", clientId = deviceId, // Use device ID for signature
scopes = scopesArray, role = "node",
token = token, scopes = scopesArray,
platform = "android", token = token,
deviceFamily = "phone" platform = "android",
) deviceFamily = "phone"
)
} else {
""
}
val connectParams = JSONObject().apply { val connectParams = JSONObject().apply {
put("minProtocol", 3) put("minProtocol", 3)
...@@ -471,13 +479,16 @@ class NodeClient() { ...@@ -471,13 +479,16 @@ class NodeClient() {
put("auth", JSONObject().apply { put("auth", JSONObject().apply {
put("token", token) put("token", token)
}) })
put("device", JSONObject().apply { // Only include device info if explicitly requested (after pairing)
put("id", deviceId) if (includeDevice) {
put("publicKey", devicePublicKey) put("device", JSONObject().apply {
put("signature", signature) put("id", deviceId)
put("signedAt", challengeTimestamp) put("publicKey", devicePublicKey)
put("nonce", challengeNonce) put("signature", signature)
}) put("signedAt", challengeTimestamp)
put("nonce", challengeNonce)
})
}
put("locale", "en-US") put("locale", "en-US")
put("userAgent", "openclaw-android/1.0.0") put("userAgent", "openclaw-android/1.0.0")
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment