core: support contact addresses with DR keys, service requests (#7310)

* core: use double ratchet keys in contact address (#7278)

* core: use double ratchet keys in contact address

* use PQ from the first message

* query plans

* update simplexmq

* api to rotate keys, option to show full links in CLI

* shorter description

* ui: add error parameters

* disable DR in addresses

* core: parameter for create address command to configure ratchet keys

* add pqRatchet param to address-related commands

* query plan

* fix parser

* fix kotlin

---------

Co-authored-by: Evgeny @ SimpleX Chat <259188159+evgeny-simplex@users.noreply.github.com>

* core: contact request rejection and service requests (#7292)

* update simplexmq

* implement service requests and rejections

* tests

* migration

* fix migration

* add api event and response

* bot api, postgres migration

* nix shas

* bot types, rename property

* update bot type

* sign service requests

* update bots api

* query plan

* update plan

* update simplexmq

* fix test, update bot api

* fix bot api

* resolve name for service request

* refactor

---------

Co-authored-by: Evgeny @ SimpleX Chat <259188159+evgeny-simplex@users.noreply.github.com>

* update simplexmq

* update simplexmq

* test delays

---------

Co-authored-by: Evgeny @ SimpleX Chat <259188159+evgeny-simplex@users.noreply.github.com>
This commit is contained in:
Evgeny
2026-08-01 12:51:03 +01:00
committed by GitHub
co-authored by Evgeny @ SimpleX Chat <259188159+evgeny-simplex@users.noreply.github.com>
parent 61012d208e
commit e1a349b90f
55 changed files with 1229 additions and 248 deletions
+66 -7
View File
@@ -68,6 +68,9 @@ This file is generated automatically.
- [APIUpdateProfile](#apiupdateprofile)
- [APISetContactPrefs](#apisetcontactprefs)
[Service commands](#service-commands)
- [APISendServiceResponse](#apisendserviceresponse)
[Chat management](#chat-management)
- [StartChat](#startchat)
- [APIStopChat](#apistopchat)
@@ -88,19 +91,20 @@ Create bot address.
**Parameters**:
- userId: int64
- pqRatchet: bool?
**Syntax**:
```
/_address <userId>
/_address <userId>[ pq_ratchet=on|off]
```
```javascript
'/_address ' + userId // JavaScript
'/_address ' + userId + (typeof pqRatchet == 'boolean' ? ' pq_ratchet=' + (pqRatchet ? 'on' : 'off') : '') // JavaScript
```
```python
'/_address ' + str(userId) # Python
'/_address ' + str(userId) + ((' pq_ratchet=' + ('on' if pqRatchet else 'off')) if pqRatchet is not None else '') # Python
```
**Responses**:
@@ -238,20 +242,21 @@ Set bot address settings.
**Parameters**:
- userId: int64
- pqRatchet: bool?
- settings: [AddressSettings](./TYPES.md#addresssettings)
**Syntax**:
```
/_address_settings <userId> <json(settings)>
/_address_settings <userId>[ pq_ratchet=on|off] <json(settings)>
```
```javascript
'/_address_settings ' + userId + ' ' + JSON.stringify(settings) // JavaScript
'/_address_settings ' + userId + (typeof pqRatchet == 'boolean' ? ' pq_ratchet=' + (pqRatchet ? 'on' : 'off') : '') + ' ' + JSON.stringify(settings) // JavaScript
```
```python
'/_address_settings ' + str(userId) + ' ' + json.dumps(settings) # Python
'/_address_settings ' + str(userId) + ((' pq_ratchet=' + ('on' if pqRatchet else 'off')) if pqRatchet is not None else '') + ' ' + json.dumps(settings) # Python
```
**Responses**:
@@ -1551,6 +1556,7 @@ Reject contact request. The user who sent the request is **not notified**.
**Parameters**:
- contactReqId: int64
- notify: bool
**Syntax**:
@@ -2118,6 +2124,50 @@ ChatCmdError: Command error (only used in WebSockets API).
---
## Service commands
Bots with a double ratchet address can answer service requests.
### APISendServiceResponse
Send a reply to a received service request. Returns the connection ID that correlates the reply delivery event.
*Network usage*: background.
**Parameters**:
- userId: int64
- requestId: string
- responseData: JSONObject
**Syntax**:
```
/_service_response <userId> <requestId> <json(responseData)>
```
```javascript
'/_service_response ' + userId + ' ' + requestId + ' ' + JSON.stringify(responseData) // JavaScript
```
```python
'/_service_response ' + str(userId) + ' ' + requestId + ' ' + json.dumps(responseData) # Python
```
**Responses**:
ServiceReplyAccepted: Service reply accepted for delivery. `connectionId` correlates the reply delivery event..
- type: "serviceReplyAccepted"
- user: [User](./TYPES.md#user)
- connectionId: string
ChatCmdError: Command error (only used in WebSockets API).
- type: "chatCmdError"
- chatError: [ChatError](./TYPES.md#chaterror)
---
## Chat management
These commands should not be used with CLI-based bots
@@ -2132,11 +2182,20 @@ Start chat controller.
**Parameters**:
- mainApp: bool
- enableSndFiles: bool
- serviceRequests: bool
**Syntax**:
```
/_start
/_start main=on|off[ snd_files=off][ service_requests=on]
```
```javascript
'/_start main=' + (mainApp ? 'on' : 'off') + (!enableSndFiles ? ' snd_files=off' : '') + (serviceRequests ? ' service_requests=on' : '') // JavaScript
```
```python
'/_start' + ' main=' + ('on' if mainApp else 'off') + (' snd_files=off' if not enableSndFiles else '') + (' service_requests=on' if serviceRequests else '') # Python
```
**Responses**:
+38
View File
@@ -68,6 +68,10 @@ This file is generated automatically.
- [HostDisconnected](#hostdisconnected)
- [SubscriptionStatus](#subscriptionstatus)
[Service events](#service-events)
- [ServiceRequest](#servicerequest)
- [ServiceReplySent](#servicereplysent)
[Error events](#error-events)
- [MessageError](#messageerror)
- [ChatError](#chaterror)
@@ -755,6 +759,40 @@ Messaging subscription status changed
---
## Service events
Bots with a double ratchet address, started with service request processing enabled, can answer service requests - a single request with a single response (RPC).
### ServiceRequest
Service request received.
The request needs to be answered using [APISendServiceResponse](./COMMANDS.md#apisendserviceresponse) command.
**Record type**:
- type: "serviceRequest"
- user: [User](./TYPES.md#user)
- requestId: string
- signerKey: string?
- requestData: JSONObject
---
### ServiceReplySent
Service reply was sent (delivered to the server).
Correlate `connectionId` with the connection ID from the response to [APISendServiceResponse](./COMMANDS.md#apisendserviceresponse) to learn when the reply is delivered.
**Record type**:
- type: "serviceReplySent"
- connectionId: string
---
## Error events
Bots may log these events for debugging. There will be many error events - this does NOT indicate a malfunction - e.g., they may happen because of bad network connectivity, or because messages may be delivered to deleted chats for a short period of time (they will be ignored).
+41
View File
@@ -9,6 +9,7 @@ This file is generated automatically.
- [AddressSettings](#addresssettings)
- [AgentCryptoError](#agentcryptoerror)
- [AgentErrorType](#agenterrortype)
- [AgentServiceError](#agentserviceerror)
- [AutoAccept](#autoaccept)
- [BadgeInfo](#badgeinfo)
- [BadgeProof](#badgeproof)
@@ -206,6 +207,7 @@ This file is generated automatically.
- [UserContact](#usercontact)
- [UserContactLink](#usercontactlink)
- [UserContactRequest](#usercontactrequest)
- [UserContactRequestRef](#usercontactrequestref)
- [UserInfo](#userinfo)
- [UserProfileUpdateSummary](#userprofileupdatesummary)
- [UserPwdHash](#userpwdhash)
@@ -360,6 +362,29 @@ INACTIVE:
- type: "INACTIVE"
---
## AgentServiceError
**Discriminated union type**:
Rejected:
- type: "rejected"
- rejectReason: string
Timeout:
- type: "timeout"
NoPendingRequest:
- type: "noPendingRequest"
NotDRAddress:
- type: "notDRAddress"
BadSignature:
- type: "badSignature"
---
## AutoAccept
@@ -1782,6 +1807,7 @@ Error:
- chatTs: UTCTime?
- preparedContact: [PreparedContact](#preparedcontact)?
- contactRequestId: int64?
- contactRequest: [UserContactRequestRef](#usercontactrequestref)?
- contactGroupMemberId: int64?
- contactGrpInvSent: bool
- groupDirectInv: [GroupDirectInvitation](#groupdirectinvitation)?
@@ -1841,6 +1867,7 @@ ContactViaAddress:
- "active"
- "deleted"
- "deletedByUser"
- "rejected"
---
@@ -3585,6 +3612,10 @@ A_QUEUE:
- type: "A_QUEUE"
- queueErr: string
A_SERVICE:
- type: "A_SERVICE"
- serviceError: [AgentServiceError](#agentserviceerror)
---
@@ -4397,6 +4428,16 @@ Handshake:
- pqSupport: bool
- welcomeSharedMsgId: string?
- requestSharedMsgId: string?
- rejectionSupported: bool
---
## UserContactRequestRef
**Record type**:
- contactRequestId: int64
- rejectionSupported: bool
---