signal-cli-rest-api icon indicating copy to clipboard operation
signal-cli-rest-api copied to clipboard

JSON-RPC: Group IDs different in CreateGroup result vs Receive payload

Open kxait opened this issue 1 year ago • 1 comments

The problem

I created a group, and received in response a group ID cURwZ0ZOYmNRd...oSGVyS2JQQzgxST0=. When receiving messages from that group, the ID is different: qDpgFNbcQv0W...hHerKbPC81I=. I dug around a bit and found that the result for CreateGroup is passed through a function:

func convertInternalGroupIdToGroupId(internalId string) string {
	return groupPrefix + base64.StdEncoding.EncodeToString([]byte(internalId))
}

When I plugged that into the code for my application, it turns out that the first result is just the second encoded to base64...

It seems the fix for this would be to either return the group IDs as they come (potentially breaking functionality), or returning the encoded group ID in Api.handleSignalReceive

Are you using the latest released version?

  • [X] Yes

Have you read the troubleshooting page?

  • [X] Yes

What type of installation are you running?

signal-cli-rest-api Docker Container

In which mode are you using the docker container?

JSON-RPC Mode

What's the architecture of your host system?

arm64

Additional information

No response

kxait avatar Nov 11 '23 18:11 kxait

Ran into this too. What is the reason for base64-encoding the already base64-encoded group-id? I understand the prefix but I do not see any advantages to double encoding. In the implementation the UTF-8 bytes of the base64-encoded group-id are again encoded in base-64 so the id also increases in length unnecessarily. Maybe the intention was to decode it (from base64) and encode it (to base64) (?) but that would obviously do nothing.

Because of this conversion, the group-ids are no longer portable. In any Signal messaging setup, be it with signal-cli or signal-cli-rest-api, I would expect the group-ids to be the same but they are not. I can simply convert it beforehand but this might still be worth investigating.

Ps. My question/concern is not about JSON-RPC but about the concept of the group-id and internal group-id in general, I am using native mode.

Joelius300 avatar Jan 23 '24 16:01 Joelius300