simplex-chat 0.2.1 → 6.5.0-beta.4
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 +69 -22
- package/dist/api.d.ts +371 -0
- package/dist/api.js +774 -0
- package/dist/api.js.map +1 -0
- package/dist/bot.d.ts +31 -0
- package/dist/bot.js +189 -0
- package/dist/bot.js.map +1 -0
- package/dist/core.d.ts +128 -0
- package/dist/core.js +121 -0
- package/dist/core.js.map +1 -0
- package/dist/index.d.ts +4 -2
- package/dist/index.js +5 -4
- package/dist/index.js.map +1 -1
- package/dist/simplex.d.ts +10 -0
- package/dist/simplex.js +1 -0
- package/dist/util.d.ts +15 -0
- package/dist/util.js +91 -0
- package/dist/util.js.map +1 -0
- package/package.json +29 -37
- package/src/api.ts +834 -0
- package/src/bot.ts +216 -0
- package/src/core.ts +210 -0
- package/src/download-libs.js +224 -0
- package/src/index.ts +22 -0
- package/src/simplex.d.ts +10 -0
- package/src/simplex.js +1 -0
- package/src/util.ts +92 -0
- package/dist/client.d.ts +0 -76
- package/dist/client.js +0 -329
- package/dist/client.js.map +0 -1
- package/dist/command.d.ts +0 -412
- package/dist/command.js +0 -186
- package/dist/command.js.map +0 -1
- package/dist/index-web.d.ts +0 -1
- package/dist/index-web.js +0 -6
- package/dist/index-web.js.map +0 -1
- package/dist/index.bundle.js +0 -11
- package/dist/queue.d.ts +0 -24
- package/dist/queue.js +0 -77
- package/dist/queue.js.map +0 -1
- package/dist/response.d.ts +0 -755
- package/dist/response.js +0 -21
- package/dist/response.js.map +0 -1
- package/dist/test.html +0 -7
- package/dist/transport.d.ts +0 -51
- package/dist/transport.js +0 -131
- package/dist/transport.js.map +0 -1
- package/dist/websocket.d.ts +0 -8
- package/dist/websocket.js +0 -4
- package/dist/websocket.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,42 +1,89 @@
|
|
|
1
|
-
# SimpleX Chat
|
|
1
|
+
# SimpleX Chat Node.js library
|
|
2
2
|
|
|
3
|
-
This
|
|
4
|
-
|
|
5
|
-
```bash
|
|
6
|
-
simplex-chat -p 5225
|
|
7
|
-
```
|
|
8
|
-
|
|
9
|
-
Client API provides types and functions to:
|
|
10
|
-
|
|
11
|
-
- create and change user profile (although, in most cases you can do it manually, via SimpleX Chat terminal app).
|
|
12
|
-
- create and accept invitations or connect with the contacts.
|
|
13
|
-
- create and manage long-term user address, accepting connection requests automatically.
|
|
14
|
-
- create, join and manage group.
|
|
15
|
-
- send and receive files.
|
|
3
|
+
This library replaced now deprecated [SimpleX Chat WebRTC TypeScript client](https://www.npmjs.com/package/@simplex-chat/webrtc-client).
|
|
16
4
|
|
|
17
5
|
## Use cases
|
|
18
6
|
|
|
19
|
-
- chat bots: you can implement any logic of connecting with and communicating with SimpleX Chat users. Using chat groups a chat bot can connect
|
|
7
|
+
- chat bots: you can implement any logic of connecting with and communicating with SimpleX Chat users. Using chat groups a chat bot can connect SimpleX Chat users with each other.
|
|
20
8
|
- control of the equipment: e.g. servers or home automation. SimpleX Chat provides secure and authorised connections, so this is more secure than using rest APIs.
|
|
9
|
+
- any scenarios of scripted message sending.
|
|
10
|
+
- chat and chat-based interfaces.
|
|
21
11
|
|
|
22
12
|
Please share your use cases and implementations.
|
|
23
13
|
|
|
24
|
-
## Quick start
|
|
14
|
+
## Quick start: a simple bot
|
|
15
|
+
|
|
16
|
+
```
|
|
17
|
+
npm i simplex-chat@6.5.0-beta.4
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Simple bot that replies with squares of numbers you send to it:
|
|
21
|
+
|
|
22
|
+
```javascript
|
|
23
|
+
(async () => {
|
|
24
|
+
const {bot} = await import("simplex-chat")
|
|
25
|
+
// if you are running from this GitHub repo:
|
|
26
|
+
// const {bot} = await import("../dist/index.js")
|
|
27
|
+
const [chat, _user, _address] = await bot.run({
|
|
28
|
+
profile: {displayName: "Squaring bot example", fullName: ""},
|
|
29
|
+
dbOpts: {dbFilePrefix: "./squaring_bot", dbKey: ""},
|
|
30
|
+
options: {
|
|
31
|
+
addressSettings: {welcomeMessage: "If you send me a number, I will calculate its square."},
|
|
32
|
+
},
|
|
33
|
+
onMessage: async (ci, content) => {
|
|
34
|
+
const n = +content.text
|
|
35
|
+
const reply = typeof n === "number" && !isNaN(n)
|
|
36
|
+
? `${n} * ${n} = ${n * n}`
|
|
37
|
+
: `this is not a number`
|
|
38
|
+
await chat.apiSendTextReply(ci, reply)
|
|
39
|
+
}
|
|
40
|
+
})
|
|
41
|
+
})()
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
If you installed this package as dependency, you can run this example with:
|
|
45
|
+
|
|
46
|
+
```sh
|
|
47
|
+
node ./node_modules/simplex-chat/examples/squaring-bot-readme.js`
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
If you cloned this repository, you can:
|
|
25
51
|
|
|
26
52
|
```
|
|
27
|
-
|
|
53
|
+
cd ./packages/simplex-chat-nodejs
|
|
54
|
+
npm install
|
|
28
55
|
npm run build
|
|
56
|
+
node ./examples/squaring-bot-readme.js
|
|
29
57
|
```
|
|
30
58
|
|
|
31
|
-
|
|
59
|
+
There is an example with more options in [./examples/squaring-bot.ts](./examples/squaring-bot.ts).
|
|
32
60
|
|
|
33
|
-
|
|
34
|
-
- run chatbot: `node examples/squaring-bot`
|
|
35
|
-
- connect to chatbot via SimpleX Chat client using the address of the chat bot
|
|
61
|
+
You can run it with: `npx ts-node ./examples/squaring-bot.ts`
|
|
36
62
|
|
|
37
63
|
## Documentation
|
|
38
64
|
|
|
39
|
-
|
|
65
|
+
The library docs are [here](./docs/README.md).
|
|
66
|
+
|
|
67
|
+
Library provides these modules:
|
|
68
|
+
- [bot](./docs/Namespace.bot.md): a simple declarative API to run a chat-bot with a single function call. It automates creating and updating of the bot profile, address and bot commands shown in the app UI.
|
|
69
|
+
- [api](./docs/Namespace.api.md): an API to send chat commands and receive chat events to/from chat core. You need to use it in bot event handlers, and for any other use cases.
|
|
70
|
+
- [core](./docs/Namespace.core.md): a low level API to the core library - the same that is used in desktop clients. You are unlikely to ever need to use this module directly.
|
|
71
|
+
- [util](./docs/Namespace.util.md): useful functions for chat events and types.
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
This library uses [@simplex-chat/types](https://www.npmjs.com/package/@simplex-chat/types) package with auto-generated [bot API types](../../bots/api/README.md).
|
|
75
|
+
|
|
76
|
+
## Supported chat functions
|
|
77
|
+
|
|
78
|
+
Library provides types and functions to:
|
|
79
|
+
|
|
80
|
+
- create and change user profile (although, in most cases you can do it manually, via SimpleX Chat terminal app).
|
|
81
|
+
- create and accept invitations or connect with the contacts.
|
|
82
|
+
- create and manage long-term user address, accepting connection requests automatically.
|
|
83
|
+
- send, receive, delete and update messages, and add message reactions.
|
|
84
|
+
- create, join and manage group.
|
|
85
|
+
- send and receive files.
|
|
86
|
+
- etc.
|
|
40
87
|
|
|
41
88
|
## License
|
|
42
89
|
|
package/dist/api.d.ts
ADDED
|
@@ -0,0 +1,371 @@
|
|
|
1
|
+
import { CEvt, ChatEvent, ChatResponse, T } from "@simplex-chat/types";
|
|
2
|
+
import * as core from "./core";
|
|
3
|
+
export declare class ChatCommandError extends Error {
|
|
4
|
+
message: string;
|
|
5
|
+
response: ChatResponse;
|
|
6
|
+
constructor(message: string, response: ChatResponse);
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Connection request types.
|
|
10
|
+
* @enum {string}
|
|
11
|
+
*/
|
|
12
|
+
export declare enum ConnReqType {
|
|
13
|
+
Invitation = "invitation",
|
|
14
|
+
Contact = "contact"
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Bot address settings.
|
|
18
|
+
*/
|
|
19
|
+
export interface BotAddressSettings {
|
|
20
|
+
/**
|
|
21
|
+
* Automatically accept contact requests.
|
|
22
|
+
* @default true
|
|
23
|
+
*/
|
|
24
|
+
autoAccept?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Optional welcome message to show before connection to the users.
|
|
27
|
+
* @default undefined (no welcome message)
|
|
28
|
+
*/
|
|
29
|
+
welcomeMessage?: T.MsgContent | string | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* Business contact address.
|
|
32
|
+
* For all requests business chats will be created where other participants can be added.
|
|
33
|
+
* @default false
|
|
34
|
+
*/
|
|
35
|
+
businessAddress?: boolean;
|
|
36
|
+
}
|
|
37
|
+
export declare const defaultBotAddressSettings: BotAddressSettings;
|
|
38
|
+
export type EventSubscriberFunc<K extends CEvt.Tag> = (event: ChatEvent & {
|
|
39
|
+
type: K;
|
|
40
|
+
}) => void | Promise<void>;
|
|
41
|
+
export type EventSubscribers = {
|
|
42
|
+
[K in CEvt.Tag]?: EventSubscriberFunc<K>;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Main API class for interacting with the chat core library.
|
|
46
|
+
*/
|
|
47
|
+
export declare class ChatApi {
|
|
48
|
+
protected ctrl_: bigint | undefined;
|
|
49
|
+
private receiveEvents;
|
|
50
|
+
private eventsLoop;
|
|
51
|
+
private subscribers;
|
|
52
|
+
private receivers;
|
|
53
|
+
private constructor();
|
|
54
|
+
/**
|
|
55
|
+
* Initializes the ChatApi.
|
|
56
|
+
* @param {string} dbFilePrefix - File prefix for the database files.
|
|
57
|
+
* @param {string} [dbKey=""] - Database encryption key.
|
|
58
|
+
* @param {core.MigrationConfirmation} [confirm=core.MigrationConfirmation.YesUp] - Migration confirmation mode.
|
|
59
|
+
*/
|
|
60
|
+
static init(dbFilePrefix: string, dbKey?: string, confirm?: core.MigrationConfirmation): Promise<ChatApi>;
|
|
61
|
+
/**
|
|
62
|
+
* Start chat controller. Must be called with the existing user profile.
|
|
63
|
+
*/
|
|
64
|
+
startChat(): Promise<void>;
|
|
65
|
+
/**
|
|
66
|
+
* Stop chat controller.
|
|
67
|
+
* Must be called before closing the database.
|
|
68
|
+
* Usually doesn't need to be called in chat bots.
|
|
69
|
+
*/
|
|
70
|
+
stopChat(): Promise<void>;
|
|
71
|
+
/**
|
|
72
|
+
* Close chat database.
|
|
73
|
+
* Usually doesn't need to be called in chat bots.
|
|
74
|
+
*/
|
|
75
|
+
close(): Promise<void>;
|
|
76
|
+
private runEventsLoop;
|
|
77
|
+
/**
|
|
78
|
+
* Subscribe multiple event handlers at once.
|
|
79
|
+
* @param subscribers - An object mapping event types (CEvt.Tag) to their subscriber functions.
|
|
80
|
+
* @throws {Error} If the same function is subscribed to event.
|
|
81
|
+
*/
|
|
82
|
+
on<K extends CEvt.Tag>(subscribers: EventSubscribers): void;
|
|
83
|
+
/**
|
|
84
|
+
* Subscribe a handler to a specific event.
|
|
85
|
+
* @param {CEvt.Tag} event - The event type to subscribe to.
|
|
86
|
+
* @param subscriber - The subscriber function for the event.
|
|
87
|
+
* @throws {Error} If the same function is subscribed to event.
|
|
88
|
+
*/
|
|
89
|
+
on<K extends CEvt.Tag>(event: K, subscriber: EventSubscriberFunc<K>): void;
|
|
90
|
+
private on_;
|
|
91
|
+
/**
|
|
92
|
+
* Subscribe a handler to any event.
|
|
93
|
+
* @param receiver - The receiver function for any event.
|
|
94
|
+
* @throws {Error} If the same function is subscribed to event.
|
|
95
|
+
*/
|
|
96
|
+
onAny(receiver: EventSubscriberFunc<CEvt.Tag>): void;
|
|
97
|
+
/**
|
|
98
|
+
* Subscribe a handler to a specific event to be delivered one time.
|
|
99
|
+
* @param {CEvt.Tag} event - The event type to subscribe to.
|
|
100
|
+
* @param subscriber - The subscriber function for the event.
|
|
101
|
+
* @throws {Error} If the same function is subscribed to event.
|
|
102
|
+
*/
|
|
103
|
+
once<K extends CEvt.Tag>(event: K, subscriber: EventSubscriberFunc<K>): void;
|
|
104
|
+
/**
|
|
105
|
+
* Waits for specific event, with an optional predicate.
|
|
106
|
+
* Returns `undefined` on timeout if specified.
|
|
107
|
+
*/
|
|
108
|
+
wait<K extends CEvt.Tag>(event: K): Promise<ChatEvent & {
|
|
109
|
+
type: K;
|
|
110
|
+
}>;
|
|
111
|
+
wait<K extends CEvt.Tag>(event: K, predicate: ((event: ChatEvent & {
|
|
112
|
+
type: K;
|
|
113
|
+
}) => boolean) | undefined): Promise<ChatEvent & {
|
|
114
|
+
type: K;
|
|
115
|
+
}>;
|
|
116
|
+
wait<K extends CEvt.Tag>(event: K, timeout: number): Promise<ChatEvent & {
|
|
117
|
+
type: K;
|
|
118
|
+
} | undefined>;
|
|
119
|
+
wait<K extends CEvt.Tag>(event: K, predicate: ((event: ChatEvent & {
|
|
120
|
+
type: K;
|
|
121
|
+
}) => boolean) | undefined, timeout: number): Promise<ChatEvent & {
|
|
122
|
+
type: K;
|
|
123
|
+
} | undefined>;
|
|
124
|
+
/**
|
|
125
|
+
* Unsubscribe all or a specific handler from a specific event.
|
|
126
|
+
* @param {CEvt.Tag} event - The event type to unsubscribe from.
|
|
127
|
+
* @param subscriber - An optional subscriber function for the event.
|
|
128
|
+
*/
|
|
129
|
+
off<K extends CEvt.Tag>(event: K, subscriber?: EventSubscriberFunc<K> | undefined): void;
|
|
130
|
+
/**
|
|
131
|
+
* Unsubscribe all or a specific handler from any events.
|
|
132
|
+
* @param receiver - An optional subscriber function for the event.
|
|
133
|
+
*/
|
|
134
|
+
offAny(receiver?: EventSubscriberFunc<CEvt.Tag> | undefined): void;
|
|
135
|
+
/**
|
|
136
|
+
* Chat controller is initialized
|
|
137
|
+
*/
|
|
138
|
+
get initialized(): boolean;
|
|
139
|
+
/**
|
|
140
|
+
* Chat controller is started
|
|
141
|
+
*/
|
|
142
|
+
get started(): boolean;
|
|
143
|
+
/**
|
|
144
|
+
* Chat controller reference
|
|
145
|
+
*/
|
|
146
|
+
get ctrl(): bigint;
|
|
147
|
+
sendChatCmd(cmd: string): Promise<ChatResponse>;
|
|
148
|
+
recvChatEvent(wait?: number): Promise<ChatEvent | undefined>;
|
|
149
|
+
/**
|
|
150
|
+
* Create bot address.
|
|
151
|
+
* Network usage: interactive.
|
|
152
|
+
*/
|
|
153
|
+
apiCreateUserAddress(userId: number): Promise<T.CreatedConnLink>;
|
|
154
|
+
/**
|
|
155
|
+
* Deletes a user address.
|
|
156
|
+
* Network usage: background.
|
|
157
|
+
*/
|
|
158
|
+
apiDeleteUserAddress(userId: number): Promise<void>;
|
|
159
|
+
/**
|
|
160
|
+
* Get bot address and settings.
|
|
161
|
+
* Network usage: no.
|
|
162
|
+
*/
|
|
163
|
+
apiGetUserAddress(userId: number): Promise<T.UserContactLink | undefined>;
|
|
164
|
+
/**
|
|
165
|
+
* Add address to bot profile.
|
|
166
|
+
* Network usage: interactive.
|
|
167
|
+
*/
|
|
168
|
+
apiSetProfileAddress(userId: number, enable: boolean): Promise<T.UserProfileUpdateSummary>;
|
|
169
|
+
/**
|
|
170
|
+
* Set bot address settings.
|
|
171
|
+
* Network usage: interactive.
|
|
172
|
+
*/
|
|
173
|
+
apiSetAddressSettings(userId: number, { autoAccept, welcomeMessage, businessAddress }: BotAddressSettings): Promise<void>;
|
|
174
|
+
/**
|
|
175
|
+
* Send messages.
|
|
176
|
+
* Network usage: background.
|
|
177
|
+
*/
|
|
178
|
+
apiSendMessages(chat: [T.ChatType, number] | T.ChatRef | T.ChatInfo, messages: T.ComposedMessage[], liveMessage?: boolean): Promise<T.AChatItem[]>;
|
|
179
|
+
/**
|
|
180
|
+
* Send text message.
|
|
181
|
+
* Network usage: background.
|
|
182
|
+
*/
|
|
183
|
+
apiSendTextMessage(chat: [T.ChatType, number] | T.ChatRef | T.ChatInfo, text: string, inReplyTo?: number): Promise<T.AChatItem[]>;
|
|
184
|
+
/**
|
|
185
|
+
* Send text message in reply to received message.
|
|
186
|
+
* Network usage: background.
|
|
187
|
+
*/
|
|
188
|
+
apiSendTextReply(chatItem: T.AChatItem, text: string): Promise<T.AChatItem[]>;
|
|
189
|
+
/**
|
|
190
|
+
* Update message.
|
|
191
|
+
* Network usage: background.
|
|
192
|
+
*/
|
|
193
|
+
apiUpdateChatItem(chatType: T.ChatType, chatId: number, chatItemId: number, msgContent: T.MsgContent, liveMessage: false): Promise<T.ChatItem>;
|
|
194
|
+
/**
|
|
195
|
+
* Delete message.
|
|
196
|
+
* Network usage: background.
|
|
197
|
+
*/
|
|
198
|
+
apiDeleteChatItems(chatType: T.ChatType, chatId: number, chatItemIds: number[], deleteMode: T.CIDeleteMode): Promise<T.ChatItemDeletion[]>;
|
|
199
|
+
/**
|
|
200
|
+
* Moderate message. Requires Moderator role (and higher than message author's).
|
|
201
|
+
* Network usage: background.
|
|
202
|
+
*/
|
|
203
|
+
apiDeleteMemberChatItem(groupId: number, chatItemIds: number[]): Promise<T.ChatItemDeletion[]>;
|
|
204
|
+
/**
|
|
205
|
+
* Add/remove message reaction.
|
|
206
|
+
* Network usage: background.
|
|
207
|
+
*/
|
|
208
|
+
apiChatItemReaction(chatType: T.ChatType, chatId: number, chatItemId: number, add: boolean, reaction: T.MsgReaction): Promise<T.ChatItemDeletion[]>;
|
|
209
|
+
/**
|
|
210
|
+
* Receive file.
|
|
211
|
+
* Network usage: no.
|
|
212
|
+
*/
|
|
213
|
+
apiReceiveFile(fileId: number): Promise<T.AChatItem>;
|
|
214
|
+
/**
|
|
215
|
+
* Cancel file.
|
|
216
|
+
* Network usage: background.
|
|
217
|
+
*/
|
|
218
|
+
apiCancelFile(fileId: number): Promise<void>;
|
|
219
|
+
/**
|
|
220
|
+
* Add contact to group. Requires bot to have Admin role.
|
|
221
|
+
* Network usage: interactive.
|
|
222
|
+
*/
|
|
223
|
+
apiAddMember(groupId: number, contactId: number, memberRole: T.GroupMemberRole): Promise<T.GroupMember>;
|
|
224
|
+
/**
|
|
225
|
+
* Join group.
|
|
226
|
+
* Network usage: interactive.
|
|
227
|
+
*/
|
|
228
|
+
apiJoinGroup(groupId: number): Promise<T.GroupInfo>;
|
|
229
|
+
/**
|
|
230
|
+
* Accept group member. Requires Admin role.
|
|
231
|
+
* Network usage: background.
|
|
232
|
+
*/
|
|
233
|
+
apiAcceptMember(groupId: number, groupMemberId: number, memberRole: T.GroupMemberRole): Promise<T.GroupMember>;
|
|
234
|
+
/**
|
|
235
|
+
* Set members role. Requires Admin role.
|
|
236
|
+
* Network usage: background.
|
|
237
|
+
*/
|
|
238
|
+
apiSetMembersRole(groupId: number, groupMemberIds: number[], memberRole: T.GroupMemberRole): Promise<void>;
|
|
239
|
+
/**
|
|
240
|
+
* Block members. Requires Moderator role.
|
|
241
|
+
* Network usage: background.
|
|
242
|
+
*/
|
|
243
|
+
apiBlockMembersForAll(groupId: number, groupMemberIds: number[], blocked: boolean): Promise<void>;
|
|
244
|
+
/**
|
|
245
|
+
* Remove members. Requires Admin role.
|
|
246
|
+
* Network usage: background.
|
|
247
|
+
*/
|
|
248
|
+
apiRemoveMembers(groupId: number, memberIds: number[], withMessages?: boolean): Promise<T.GroupMember[]>;
|
|
249
|
+
/**
|
|
250
|
+
* Leave group.
|
|
251
|
+
* Network usage: background.
|
|
252
|
+
*/
|
|
253
|
+
apiLeaveGroup(groupId: number): Promise<T.GroupInfo>;
|
|
254
|
+
/**
|
|
255
|
+
* Get group members.
|
|
256
|
+
* Network usage: no.
|
|
257
|
+
*/
|
|
258
|
+
apiListMembers(groupId: number): Promise<T.GroupMember[]>;
|
|
259
|
+
/**
|
|
260
|
+
* Create group.
|
|
261
|
+
* Network usage: no.
|
|
262
|
+
*/
|
|
263
|
+
apiNewGroup(userId: number, groupProfile: T.GroupProfile): Promise<T.GroupInfo>;
|
|
264
|
+
/**
|
|
265
|
+
* Update group profile.
|
|
266
|
+
* Network usage: background.
|
|
267
|
+
*/
|
|
268
|
+
apiUpdateGroupProfile(groupId: number, groupProfile: T.GroupProfile): Promise<T.GroupInfo>;
|
|
269
|
+
/**
|
|
270
|
+
* Create group link.
|
|
271
|
+
* Network usage: interactive.
|
|
272
|
+
*/
|
|
273
|
+
apiCreateGroupLink(groupId: number, memberRole: T.GroupMemberRole): Promise<string>;
|
|
274
|
+
/**
|
|
275
|
+
* Set member role for group link.
|
|
276
|
+
* Network usage: no.
|
|
277
|
+
*/
|
|
278
|
+
apiSetGroupLinkMemberRole(groupId: number, memberRole: T.GroupMemberRole): Promise<void>;
|
|
279
|
+
/**
|
|
280
|
+
* Delete group link.
|
|
281
|
+
* Network usage: background.
|
|
282
|
+
*/
|
|
283
|
+
apiDeleteGroupLink(groupId: number): Promise<void>;
|
|
284
|
+
/**
|
|
285
|
+
* Get group link.
|
|
286
|
+
* Network usage: no.
|
|
287
|
+
*/
|
|
288
|
+
apiGetGroupLink(groupId: number): Promise<T.GroupLink>;
|
|
289
|
+
apiGetGroupLinkStr(groupId: number): Promise<string>;
|
|
290
|
+
/**
|
|
291
|
+
* Create 1-time invitation link.
|
|
292
|
+
* Network usage: interactive.
|
|
293
|
+
*/
|
|
294
|
+
apiCreateLink(userId: number): Promise<string>;
|
|
295
|
+
/**
|
|
296
|
+
* Determine SimpleX link type and if the bot is already connected via this link.
|
|
297
|
+
* Network usage: interactive.
|
|
298
|
+
*/
|
|
299
|
+
apiConnectPlan(userId: number, connectionLink: string): Promise<[T.ConnectionPlan, T.CreatedConnLink]>;
|
|
300
|
+
/**
|
|
301
|
+
* Connect via prepared SimpleX link. The link can be 1-time invitation link, contact address or group link
|
|
302
|
+
* Network usage: interactive.
|
|
303
|
+
*/
|
|
304
|
+
apiConnect(userId: number, incognito: boolean, preparedLink?: T.CreatedConnLink): Promise<ConnReqType>;
|
|
305
|
+
/**
|
|
306
|
+
* Connect via SimpleX link as string in the active user profile.
|
|
307
|
+
* Network usage: interactive.
|
|
308
|
+
*/
|
|
309
|
+
apiConnectActiveUser(connLink: string): Promise<ConnReqType>;
|
|
310
|
+
private handleConnectResult;
|
|
311
|
+
/**
|
|
312
|
+
* Accept contact request.
|
|
313
|
+
* Network usage: interactive.
|
|
314
|
+
*/
|
|
315
|
+
apiAcceptContactRequest(contactReqId: number): Promise<T.Contact>;
|
|
316
|
+
/**
|
|
317
|
+
* Reject contact request. The user who sent the request is **not notified**.
|
|
318
|
+
* Network usage: no.
|
|
319
|
+
*/
|
|
320
|
+
apiRejectContactRequest(contactReqId: number): Promise<void>;
|
|
321
|
+
/**
|
|
322
|
+
* Get contacts.
|
|
323
|
+
* Network usage: no.
|
|
324
|
+
*/
|
|
325
|
+
apiListContacts(userId: number): Promise<T.Contact[]>;
|
|
326
|
+
/**
|
|
327
|
+
* Get groups.
|
|
328
|
+
* Network usage: no.
|
|
329
|
+
*/
|
|
330
|
+
apiListGroups(userId: number, contactId?: number, search?: string): Promise<T.GroupInfo[]>;
|
|
331
|
+
/**
|
|
332
|
+
* Delete chat.
|
|
333
|
+
* Network usage: background.
|
|
334
|
+
*/
|
|
335
|
+
apiDeleteChat(chatType: T.ChatType, chatId: number, deleteMode?: T.ChatDeleteMode): Promise<void>;
|
|
336
|
+
/**
|
|
337
|
+
* Get active user profile
|
|
338
|
+
* Network usage: no.
|
|
339
|
+
*/
|
|
340
|
+
apiGetActiveUser(): Promise<T.User | undefined>;
|
|
341
|
+
/**
|
|
342
|
+
* Create new user profile
|
|
343
|
+
* Network usage: no.
|
|
344
|
+
*/
|
|
345
|
+
apiCreateActiveUser(profile?: T.Profile): Promise<T.User>;
|
|
346
|
+
/**
|
|
347
|
+
* Get all user profiles
|
|
348
|
+
* Network usage: no.
|
|
349
|
+
*/
|
|
350
|
+
apiListUsers(): Promise<T.UserInfo[]>;
|
|
351
|
+
/**
|
|
352
|
+
* Set active user profile
|
|
353
|
+
* Network usage: no.
|
|
354
|
+
*/
|
|
355
|
+
apiSetActiveUser(userId: number, viewPwd?: string): Promise<T.User>;
|
|
356
|
+
/**
|
|
357
|
+
* Delete user profile.
|
|
358
|
+
* Network usage: background.
|
|
359
|
+
*/
|
|
360
|
+
apiDeleteUser(userId: number, delSMPQueues: boolean, viewPwd?: string): Promise<void>;
|
|
361
|
+
/**
|
|
362
|
+
* Update user profile.
|
|
363
|
+
* Network usage: background.
|
|
364
|
+
*/
|
|
365
|
+
apiUpdateProfile(userId: number, profile: T.Profile): Promise<T.UserProfileUpdateSummary | undefined>;
|
|
366
|
+
/**
|
|
367
|
+
* Configure chat preference overrides for the contact.
|
|
368
|
+
* Network usage: background.
|
|
369
|
+
*/
|
|
370
|
+
apiSetContactPrefs(contactId: number, preferences: T.Preferences): Promise<void>;
|
|
371
|
+
}
|