simplex-chat 6.5.0-beta.4.1 → 6.5.0-beta.4.2

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.
Files changed (65) hide show
  1. package/README.md +1 -1
  2. package/cpp/simplex.cc +414 -0
  3. package/cpp/simplex.h +46 -0
  4. package/docs/Namespace.api.md +32 -0
  5. package/docs/Namespace.bot.md +20 -0
  6. package/docs/Namespace.core.md +48 -0
  7. package/docs/Namespace.util.md +25 -0
  8. package/docs/README.md +12 -0
  9. package/docs/api.Class.ChatApi.md +1602 -0
  10. package/docs/api.Class.ChatCommandError.md +205 -0
  11. package/docs/api.Enumeration.ConnReqType.md +27 -0
  12. package/docs/api.Interface.BotAddressSettings.md +60 -0
  13. package/docs/api.TypeAlias.EventSubscriberFunc.md +27 -0
  14. package/docs/api.TypeAlias.EventSubscribers.md +11 -0
  15. package/docs/api.Variable.defaultBotAddressSettings.md +11 -0
  16. package/docs/bot.Function.run.md +21 -0
  17. package/docs/bot.Interface.BotConfig.md +75 -0
  18. package/docs/bot.Interface.BotDbOpts.md +33 -0
  19. package/docs/bot.Interface.BotOptions.md +81 -0
  20. package/docs/core.Class.ChatAPIError.md +205 -0
  21. package/docs/core.Class.ChatInitError.md +205 -0
  22. package/docs/core.DBMigrationError.Interface.ErrorMigration.md +41 -0
  23. package/docs/core.DBMigrationError.Interface.ErrorNotADatabase.md +33 -0
  24. package/docs/core.DBMigrationError.Interface.ErrorSQL.md +41 -0
  25. package/docs/core.DBMigrationError.Interface.InvalidConfirmation.md +25 -0
  26. package/docs/core.DBMigrationError.TypeAlias.Tag.md +11 -0
  27. package/docs/core.Enumeration.MigrationConfirmation.md +43 -0
  28. package/docs/core.Function.chatCloseStore.md +23 -0
  29. package/docs/core.Function.chatDecryptFile.md +31 -0
  30. package/docs/core.Function.chatEncryptFile.md +31 -0
  31. package/docs/core.Function.chatMigrateInit.md +31 -0
  32. package/docs/core.Function.chatReadFile.md +27 -0
  33. package/docs/core.Function.chatRecvMsgWait.md +27 -0
  34. package/docs/core.Function.chatSendCmd.md +27 -0
  35. package/docs/core.Function.chatWriteFile.md +31 -0
  36. package/docs/core.Interface.APIResult.md +31 -0
  37. package/docs/core.Interface.CryptoArgs.md +27 -0
  38. package/docs/core.Interface.UpMigration.md +25 -0
  39. package/docs/core.MTRError.Interface.MTREDifferent.md +33 -0
  40. package/docs/core.MTRError.Interface.MTRENoDown.md +33 -0
  41. package/docs/core.MTRError.TypeAlias.Tag.md +11 -0
  42. package/docs/core.MigrationError.Interface.MEDowngrade.md +33 -0
  43. package/docs/core.MigrationError.Interface.MEUpgrade.md +33 -0
  44. package/docs/core.MigrationError.Interface.MigrationError.md +33 -0
  45. package/docs/core.MigrationError.TypeAlias.Tag.md +11 -0
  46. package/docs/core.Namespace.DBMigrationError.md +18 -0
  47. package/docs/core.Namespace.MTRError.md +16 -0
  48. package/docs/core.Namespace.MigrationError.md +17 -0
  49. package/docs/core.TypeAlias.DBMigrationError.md +11 -0
  50. package/docs/core.TypeAlias.MTRError.md +11 -0
  51. package/docs/core.TypeAlias.MigrationError.md +11 -0
  52. package/docs/util.Function.botAddressSettings.md +21 -0
  53. package/docs/util.Function.chatInfoName.md +21 -0
  54. package/docs/util.Function.chatInfoRef.md +21 -0
  55. package/docs/util.Function.ciBotCommand.md +21 -0
  56. package/docs/util.Function.ciContentText.md +21 -0
  57. package/docs/util.Function.contactAddressStr.md +21 -0
  58. package/docs/util.Function.fromLocalProfile.md +21 -0
  59. package/docs/util.Function.reactionText.md +21 -0
  60. package/docs/util.Function.senderName.md +25 -0
  61. package/docs/util.Interface.BotCommand.md +25 -0
  62. package/examples/squaring-bot-readme.js +17 -0
  63. package/examples/squaring-bot.ts +42 -0
  64. package/package.json +7 -3
  65. package/tsconfig.json +23 -0
@@ -0,0 +1,205 @@
1
+ [**simplex-chat**](README.md)
2
+
3
+ ***
4
+
5
+ [simplex-chat](README.md) / [api](Namespace.api.md) / ChatCommandError
6
+
7
+ # Class: ChatCommandError
8
+
9
+ Defined in: [src/api.ts:5](../src/api.ts#L5)
10
+
11
+ ## Extends
12
+
13
+ - `Error`
14
+
15
+ ## Constructors
16
+
17
+ ### Constructor
18
+
19
+ > **new ChatCommandError**(`message`, `response`): `ChatCommandError`
20
+
21
+ Defined in: [src/api.ts:6](../src/api.ts#L6)
22
+
23
+ #### Parameters
24
+
25
+ ##### message
26
+
27
+ `string`
28
+
29
+ ##### response
30
+
31
+ `ChatResponse`
32
+
33
+ #### Returns
34
+
35
+ `ChatCommandError`
36
+
37
+ #### Overrides
38
+
39
+ `Error.constructor`
40
+
41
+ ## Properties
42
+
43
+ ### message
44
+
45
+ > **message**: `string`
46
+
47
+ Defined in: [src/api.ts:6](../src/api.ts#L6)
48
+
49
+ #### Inherited from
50
+
51
+ `Error.message`
52
+
53
+ ***
54
+
55
+ ### name
56
+
57
+ > **name**: `string`
58
+
59
+ Defined in: [node\_modules/typescript/lib/lib.es5.d.ts:1076](../node_modules/typescript/lib/lib.es5.d.ts#L1076)
60
+
61
+ #### Inherited from
62
+
63
+ `Error.name`
64
+
65
+ ***
66
+
67
+ ### response
68
+
69
+ > **response**: `ChatResponse`
70
+
71
+ Defined in: [src/api.ts:6](../src/api.ts#L6)
72
+
73
+ ***
74
+
75
+ ### stack?
76
+
77
+ > `optional` **stack**: `string`
78
+
79
+ Defined in: [node\_modules/typescript/lib/lib.es5.d.ts:1078](../node_modules/typescript/lib/lib.es5.d.ts#L1078)
80
+
81
+ #### Inherited from
82
+
83
+ `Error.stack`
84
+
85
+ ***
86
+
87
+ ### stackTraceLimit
88
+
89
+ > `static` **stackTraceLimit**: `number`
90
+
91
+ Defined in: [node\_modules/@types/node/globals.d.ts:67](../node_modules/@types/node/globals.d.ts#L67)
92
+
93
+ The `Error.stackTraceLimit` property specifies the number of stack frames
94
+ collected by a stack trace (whether generated by `new Error().stack` or
95
+ `Error.captureStackTrace(obj)`).
96
+
97
+ The default value is `10` but may be set to any valid JavaScript number. Changes
98
+ will affect any stack trace captured _after_ the value has been changed.
99
+
100
+ If set to a non-number value, or set to a negative number, stack traces will
101
+ not capture any frames.
102
+
103
+ #### Inherited from
104
+
105
+ `Error.stackTraceLimit`
106
+
107
+ ## Methods
108
+
109
+ ### captureStackTrace()
110
+
111
+ > `static` **captureStackTrace**(`targetObject`, `constructorOpt?`): `void`
112
+
113
+ Defined in: [node\_modules/@types/node/globals.d.ts:51](../node_modules/@types/node/globals.d.ts#L51)
114
+
115
+ Creates a `.stack` property on `targetObject`, which when accessed returns
116
+ a string representing the location in the code at which
117
+ `Error.captureStackTrace()` was called.
118
+
119
+ ```js
120
+ const myObject = {};
121
+ Error.captureStackTrace(myObject);
122
+ myObject.stack; // Similar to `new Error().stack`
123
+ ```
124
+
125
+ The first line of the trace will be prefixed with
126
+ `${myObject.name}: ${myObject.message}`.
127
+
128
+ The optional `constructorOpt` argument accepts a function. If given, all frames
129
+ above `constructorOpt`, including `constructorOpt`, will be omitted from the
130
+ generated stack trace.
131
+
132
+ The `constructorOpt` argument is useful for hiding implementation
133
+ details of error generation from the user. For instance:
134
+
135
+ ```js
136
+ function a() {
137
+ b();
138
+ }
139
+
140
+ function b() {
141
+ c();
142
+ }
143
+
144
+ function c() {
145
+ // Create an error without stack trace to avoid calculating the stack trace twice.
146
+ const { stackTraceLimit } = Error;
147
+ Error.stackTraceLimit = 0;
148
+ const error = new Error();
149
+ Error.stackTraceLimit = stackTraceLimit;
150
+
151
+ // Capture the stack trace above function b
152
+ Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
153
+ throw error;
154
+ }
155
+
156
+ a();
157
+ ```
158
+
159
+ #### Parameters
160
+
161
+ ##### targetObject
162
+
163
+ `object`
164
+
165
+ ##### constructorOpt?
166
+
167
+ `Function`
168
+
169
+ #### Returns
170
+
171
+ `void`
172
+
173
+ #### Inherited from
174
+
175
+ `Error.captureStackTrace`
176
+
177
+ ***
178
+
179
+ ### prepareStackTrace()
180
+
181
+ > `static` **prepareStackTrace**(`err`, `stackTraces`): `any`
182
+
183
+ Defined in: [node\_modules/@types/node/globals.d.ts:55](../node_modules/@types/node/globals.d.ts#L55)
184
+
185
+ #### Parameters
186
+
187
+ ##### err
188
+
189
+ `Error`
190
+
191
+ ##### stackTraces
192
+
193
+ `CallSite`[]
194
+
195
+ #### Returns
196
+
197
+ `any`
198
+
199
+ #### See
200
+
201
+ https://v8.dev/docs/stack-trace-api#customizing-stack-traces
202
+
203
+ #### Inherited from
204
+
205
+ `Error.prepareStackTrace`
@@ -0,0 +1,27 @@
1
+ [**simplex-chat**](README.md)
2
+
3
+ ***
4
+
5
+ [simplex-chat](README.md) / [api](Namespace.api.md) / ConnReqType
6
+
7
+ # Enumeration: ConnReqType
8
+
9
+ Defined in: [src/api.ts:15](../src/api.ts#L15)
10
+
11
+ Connection request types.
12
+
13
+ ## Enumeration Members
14
+
15
+ ### Contact
16
+
17
+ > **Contact**: `"contact"`
18
+
19
+ Defined in: [src/api.ts:17](../src/api.ts#L17)
20
+
21
+ ***
22
+
23
+ ### Invitation
24
+
25
+ > **Invitation**: `"invitation"`
26
+
27
+ Defined in: [src/api.ts:16](../src/api.ts#L16)
@@ -0,0 +1,60 @@
1
+ [**simplex-chat**](README.md)
2
+
3
+ ***
4
+
5
+ [simplex-chat](README.md) / [api](Namespace.api.md) / BotAddressSettings
6
+
7
+ # Interface: BotAddressSettings
8
+
9
+ Defined in: [src/api.ts:23](../src/api.ts#L23)
10
+
11
+ Bot address settings.
12
+
13
+ ## Properties
14
+
15
+ ### autoAccept?
16
+
17
+ > `optional` **autoAccept**: `boolean`
18
+
19
+ Defined in: [src/api.ts:28](../src/api.ts#L28)
20
+
21
+ Automatically accept contact requests.
22
+
23
+ #### Default
24
+
25
+ ```ts
26
+ true
27
+ ```
28
+
29
+ ***
30
+
31
+ ### businessAddress?
32
+
33
+ > `optional` **businessAddress**: `boolean`
34
+
35
+ Defined in: [src/api.ts:41](../src/api.ts#L41)
36
+
37
+ Business contact address.
38
+ For all requests business chats will be created where other participants can be added.
39
+
40
+ #### Default
41
+
42
+ ```ts
43
+ false
44
+ ```
45
+
46
+ ***
47
+
48
+ ### welcomeMessage?
49
+
50
+ > `optional` **welcomeMessage**: `string` \| `MsgContent`
51
+
52
+ Defined in: [src/api.ts:34](../src/api.ts#L34)
53
+
54
+ Optional welcome message to show before connection to the users.
55
+
56
+ #### Default
57
+
58
+ ```ts
59
+ undefined (no welcome message)
60
+ ```
@@ -0,0 +1,27 @@
1
+ [**simplex-chat**](README.md)
2
+
3
+ ***
4
+
5
+ [simplex-chat](README.md) / [api](Namespace.api.md) / EventSubscriberFunc
6
+
7
+ # Type Alias: EventSubscriberFunc()\<K\>
8
+
9
+ > **EventSubscriberFunc**\<`K`\> = (`event`) => `void` \| `Promise`\<`void`\>
10
+
11
+ Defined in: [src/api.ts:50](../src/api.ts#L50)
12
+
13
+ ## Type Parameters
14
+
15
+ ### K
16
+
17
+ `K` *extends* `CEvt.Tag`
18
+
19
+ ## Parameters
20
+
21
+ ### event
22
+
23
+ `ChatEvent` & \{ `type`: `K`; \}
24
+
25
+ ## Returns
26
+
27
+ `void` \| `Promise`\<`void`\>
@@ -0,0 +1,11 @@
1
+ [**simplex-chat**](README.md)
2
+
3
+ ***
4
+
5
+ [simplex-chat](README.md) / [api](Namespace.api.md) / EventSubscribers
6
+
7
+ # Type Alias: EventSubscribers
8
+
9
+ > **EventSubscribers** = `{ [K in CEvt.Tag]?: EventSubscriberFunc<K> }`
10
+
11
+ Defined in: [src/api.ts:52](../src/api.ts#L52)
@@ -0,0 +1,11 @@
1
+ [**simplex-chat**](README.md)
2
+
3
+ ***
4
+
5
+ [simplex-chat](README.md) / [api](Namespace.api.md) / defaultBotAddressSettings
6
+
7
+ # Variable: defaultBotAddressSettings
8
+
9
+ > `const` **defaultBotAddressSettings**: [`BotAddressSettings`](api.Interface.BotAddressSettings.md)
10
+
11
+ Defined in: [src/api.ts:44](../src/api.ts#L44)
@@ -0,0 +1,21 @@
1
+ [**simplex-chat**](README.md)
2
+
3
+ ***
4
+
5
+ [simplex-chat](README.md) / [bot](Namespace.bot.md) / run
6
+
7
+ # Function: run()
8
+
9
+ > **run**(`__namedParameters`): `Promise`\<\[[`ChatApi`](api.Class.ChatApi.md), `User`, `UserContactLink` \| `undefined`\]\>
10
+
11
+ Defined in: [src/bot.ts:49](../src/bot.ts#L49)
12
+
13
+ ## Parameters
14
+
15
+ ### \_\_namedParameters
16
+
17
+ [`BotConfig`](bot.Interface.BotConfig.md)
18
+
19
+ ## Returns
20
+
21
+ `Promise`\<\[[`ChatApi`](api.Class.ChatApi.md), `User`, `UserContactLink` \| `undefined`\]\>
@@ -0,0 +1,75 @@
1
+ [**simplex-chat**](README.md)
2
+
3
+ ***
4
+
5
+ [simplex-chat](README.md) / [bot](Namespace.bot.md) / BotConfig
6
+
7
+ # Interface: BotConfig
8
+
9
+ Defined in: [src/bot.ts:37](../src/bot.ts#L37)
10
+
11
+ ## Properties
12
+
13
+ ### dbOpts
14
+
15
+ > **dbOpts**: [`BotDbOpts`](bot.Interface.BotDbOpts.md)
16
+
17
+ Defined in: [src/bot.ts:39](../src/bot.ts#L39)
18
+
19
+ ***
20
+
21
+ ### events?
22
+
23
+ > `optional` **events**: [`EventSubscribers`](api.TypeAlias.EventSubscribers.md)
24
+
25
+ Defined in: [src/bot.ts:46](../src/bot.ts#L46)
26
+
27
+ ***
28
+
29
+ ### onCommands?
30
+
31
+ > `optional` **onCommands**: \{\[`key`: `string`\]: (`chatItem`, `command`) => `void` \| `Promise`\<`void`\> \| `undefined`; \}
32
+
33
+ Defined in: [src/bot.ts:43](../src/bot.ts#L43)
34
+
35
+ #### Index Signature
36
+
37
+ \[`key`: `string`\]: (`chatItem`, `command`) => `void` \| `Promise`\<`void`\> \| `undefined`
38
+
39
+ ***
40
+
41
+ ### onMessage()?
42
+
43
+ > `optional` **onMessage**: (`chatItem`, `content`) => `void` \| `Promise`\<`void`\>
44
+
45
+ Defined in: [src/bot.ts:41](../src/bot.ts#L41)
46
+
47
+ #### Parameters
48
+
49
+ ##### chatItem
50
+
51
+ `AChatItem`
52
+
53
+ ##### content
54
+
55
+ `MsgContent`
56
+
57
+ #### Returns
58
+
59
+ `void` \| `Promise`\<`void`\>
60
+
61
+ ***
62
+
63
+ ### options
64
+
65
+ > **options**: [`BotOptions`](bot.Interface.BotOptions.md)
66
+
67
+ Defined in: [src/bot.ts:40](../src/bot.ts#L40)
68
+
69
+ ***
70
+
71
+ ### profile
72
+
73
+ > **profile**: `Profile`
74
+
75
+ Defined in: [src/bot.ts:38](../src/bot.ts#L38)
@@ -0,0 +1,33 @@
1
+ [**simplex-chat**](README.md)
2
+
3
+ ***
4
+
5
+ [simplex-chat](README.md) / [bot](Namespace.bot.md) / BotDbOpts
6
+
7
+ # Interface: BotDbOpts
8
+
9
+ Defined in: [src/bot.ts:7](../src/bot.ts#L7)
10
+
11
+ ## Properties
12
+
13
+ ### confirmMigrations?
14
+
15
+ > `optional` **confirmMigrations**: [`MigrationConfirmation`](core.Enumeration.MigrationConfirmation.md)
16
+
17
+ Defined in: [src/bot.ts:10](../src/bot.ts#L10)
18
+
19
+ ***
20
+
21
+ ### dbFilePrefix
22
+
23
+ > **dbFilePrefix**: `string`
24
+
25
+ Defined in: [src/bot.ts:8](../src/bot.ts#L8)
26
+
27
+ ***
28
+
29
+ ### dbKey?
30
+
31
+ > `optional` **dbKey**: `string`
32
+
33
+ Defined in: [src/bot.ts:9](../src/bot.ts#L9)
@@ -0,0 +1,81 @@
1
+ [**simplex-chat**](README.md)
2
+
3
+ ***
4
+
5
+ [simplex-chat](README.md) / [bot](Namespace.bot.md) / BotOptions
6
+
7
+ # Interface: BotOptions
8
+
9
+ Defined in: [src/bot.ts:13](../src/bot.ts#L13)
10
+
11
+ ## Properties
12
+
13
+ ### addressSettings?
14
+
15
+ > `optional` **addressSettings**: [`BotAddressSettings`](api.Interface.BotAddressSettings.md)
16
+
17
+ Defined in: [src/bot.ts:17](../src/bot.ts#L17)
18
+
19
+ ***
20
+
21
+ ### allowFiles?
22
+
23
+ > `optional` **allowFiles**: `boolean`
24
+
25
+ Defined in: [src/bot.ts:18](../src/bot.ts#L18)
26
+
27
+ ***
28
+
29
+ ### commands?
30
+
31
+ > `optional` **commands**: `ChatBotCommand`[]
32
+
33
+ Defined in: [src/bot.ts:19](../src/bot.ts#L19)
34
+
35
+ ***
36
+
37
+ ### createAddress?
38
+
39
+ > `optional` **createAddress**: `boolean`
40
+
41
+ Defined in: [src/bot.ts:14](../src/bot.ts#L14)
42
+
43
+ ***
44
+
45
+ ### logContacts?
46
+
47
+ > `optional` **logContacts**: `boolean`
48
+
49
+ Defined in: [src/bot.ts:21](../src/bot.ts#L21)
50
+
51
+ ***
52
+
53
+ ### logNetwork?
54
+
55
+ > `optional` **logNetwork**: `boolean`
56
+
57
+ Defined in: [src/bot.ts:22](../src/bot.ts#L22)
58
+
59
+ ***
60
+
61
+ ### updateAddress?
62
+
63
+ > `optional` **updateAddress**: `boolean`
64
+
65
+ Defined in: [src/bot.ts:15](../src/bot.ts#L15)
66
+
67
+ ***
68
+
69
+ ### updateProfile?
70
+
71
+ > `optional` **updateProfile**: `boolean`
72
+
73
+ Defined in: [src/bot.ts:16](../src/bot.ts#L16)
74
+
75
+ ***
76
+
77
+ ### useBotProfile?
78
+
79
+ > `optional` **useBotProfile**: `boolean`
80
+
81
+ Defined in: [src/bot.ts:20](../src/bot.ts#L20)