simplex-chat 7.1.0-beta.2 → 7.1.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 (64) hide show
  1. package/README.md +4 -2
  2. package/binding.gyp +2 -0
  3. package/cpp/simplex.cc +265 -29
  4. package/cpp/simplex.h +2 -0
  5. package/dist/api.d.ts +9 -6
  6. package/dist/api.js +37 -19
  7. package/dist/api.js.map +1 -1
  8. package/dist/bot.d.ts +6 -2
  9. package/dist/bot.js +17 -34
  10. package/dist/bot.js.map +1 -1
  11. package/dist/core.d.ts +11 -7
  12. package/dist/core.js +5 -2
  13. package/dist/core.js.map +1 -1
  14. package/dist/simplex.d.ts +3 -2
  15. package/dist/util.js +1 -1
  16. package/dist/util.js.map +1 -1
  17. package/docs/Namespace.bot.md +1 -0
  18. package/docs/api.Class.ChatApi.md +122 -78
  19. package/docs/api.TypeAlias.EventSubscriberFunc.md +5 -1
  20. package/docs/bot.Function.run.md +1 -1
  21. package/docs/bot.Function.subscribeChatItems.md +27 -0
  22. package/docs/bot.Interface.BotConfig.md +13 -9
  23. package/docs/bot.Interface.BotOptions.md +10 -10
  24. package/docs/bot.TypeAlias.BotDbOpts.md +4 -0
  25. package/docs/core.Class.ChatAPIError.md +4 -4
  26. package/docs/core.Class.ChatInitError.md +4 -4
  27. package/docs/core.DBMigrationError.Interface.ErrorMigration.md +4 -4
  28. package/docs/core.DBMigrationError.Interface.ErrorNotADatabase.md +3 -3
  29. package/docs/core.DBMigrationError.Interface.ErrorSQL.md +4 -4
  30. package/docs/core.DBMigrationError.Interface.InvalidConfirmation.md +2 -2
  31. package/docs/core.DBMigrationError.Interface.InvalidQueueSize.md +25 -0
  32. package/docs/core.DBMigrationError.TypeAlias.Tag.md +2 -2
  33. package/docs/core.Enumeration.MigrationConfirmation.md +5 -5
  34. package/docs/core.Function.chatCloseStore.md +1 -1
  35. package/docs/core.Function.chatDecryptFile.md +1 -1
  36. package/docs/core.Function.chatEncryptFile.md +1 -1
  37. package/docs/core.Function.chatMigrateInit.md +8 -2
  38. package/docs/core.Function.chatReadFile.md +3 -3
  39. package/docs/core.Function.chatRecvMsgWait.md +1 -1
  40. package/docs/core.Function.chatSendCmd.md +1 -1
  41. package/docs/core.Function.chatWriteFile.md +2 -2
  42. package/docs/core.Interface.APIResult.md +3 -3
  43. package/docs/core.Interface.CryptoArgs.md +3 -3
  44. package/docs/core.Interface.UpMigration.md +3 -3
  45. package/docs/core.MTRError.Interface.MTREDifferent.md +3 -3
  46. package/docs/core.MTRError.Interface.MTRENoDown.md +10 -10
  47. package/docs/core.MTRError.TypeAlias.Tag.md +1 -1
  48. package/docs/core.MigrationError.Interface.MEDowngrade.md +3 -3
  49. package/docs/core.MigrationError.Interface.MEUpgrade.md +4 -4
  50. package/docs/core.MigrationError.Interface.MigrationError.md +3 -3
  51. package/docs/core.MigrationError.TypeAlias.Tag.md +1 -1
  52. package/docs/core.Namespace.DBMigrationError.md +1 -0
  53. package/docs/core.TypeAlias.DBMigrationError.md +2 -2
  54. package/docs/core.TypeAlias.MTRError.md +1 -1
  55. package/docs/core.TypeAlias.MigrationError.md +1 -1
  56. package/examples/squaring-bot-readme.js +2 -2
  57. package/examples/squaring-bot.ts +4 -4
  58. package/package.json +2 -2
  59. package/src/api.ts +54 -25
  60. package/src/bot.ts +43 -37
  61. package/src/core.ts +15 -7
  62. package/src/download-libs.js +28 -1
  63. package/src/simplex.d.ts +3 -2
  64. package/src/util.ts +3 -3
@@ -4,8 +4,12 @@ const path = require('path');
4
4
  const extract = require('extract-zip');
5
5
 
6
6
  const GITHUB_REPO = 'simplex-chat/simplex-chat-libs';
7
- const RELEASE_TAG = 'v7.1.0-beta.2';
7
+ const RELEASE_TAG = 'v7.1.0-beta.4';
8
8
  const BACKEND = (process.env.SIMPLEX_BACKEND || process.env.npm_config_simplex_backend || 'sqlite').toLowerCase();
9
+ // A locally built libsimplex, copied into libs/ rather than loaded in place:
10
+ // the addon's RUNPATH is $ORIGIN/../../libs.
11
+ const LIBS_DIR_OVERRIDE = process.env.SIMPLEX_LIBS_DIR || process.env.npm_config_simplex_libs_dir;
12
+ const LIB_NAMES = ['libsimplex.so', 'libsimplex.dylib', 'libsimplex.dll'];
9
13
 
10
14
  if (BACKEND !== 'sqlite' && BACKEND !== 'postgres') {
11
15
  console.error(`✗ Invalid SIMPLEX_BACKEND: "${BACKEND}". Must be "sqlite" or "postgres".`);
@@ -83,8 +87,31 @@ function isAlreadyInstalled() {
83
87
  }
84
88
  }
85
89
 
90
+ // No version check: the files behind SIMPLEX_LIBS_DIR change on every rebuild.
91
+ function installFromOverride() {
92
+ if (!fs.existsSync(LIBS_DIR_OVERRIDE)) {
93
+ throw new Error(`SIMPLEX_LIBS_DIR does not exist: ${LIBS_DIR_OVERRIDE}`);
94
+ }
95
+ const lib = LIB_NAMES.find((name) => fs.existsSync(path.join(LIBS_DIR_OVERRIDE, name)));
96
+ if (!lib) {
97
+ throw new Error(`No ${LIB_NAMES.join(' / ')} in SIMPLEX_LIBS_DIR: ${LIBS_DIR_OVERRIDE}`);
98
+ }
99
+ console.log(`Using libraries from SIMPLEX_LIBS_DIR: ${LIBS_DIR_OVERRIDE}`);
100
+ cleanLibsDirectory();
101
+ copyDirSync(LIBS_DIR_OVERRIDE, LIBS_DIR);
102
+ // Not a release tag: a later install without the variable sees a mismatch
103
+ // and replaces these files with the released ones.
104
+ fs.writeFileSync(INSTALLED_FILE, `${LIBS_DIR_OVERRIDE}:${BACKEND}`, 'utf-8');
105
+ console.log(`✓ Installed ${lib} and its runtime libraries from ${LIBS_DIR_OVERRIDE}`);
106
+ }
107
+
86
108
  async function install() {
87
109
  try {
110
+ if (LIBS_DIR_OVERRIDE) {
111
+ installFromOverride();
112
+ return;
113
+ }
114
+
88
115
  // Check if already installed
89
116
  if (isAlreadyInstalled()) {
90
117
  return;
package/src/simplex.d.ts CHANGED
@@ -1,10 +1,11 @@
1
1
  // These functions are defined in CPP add-on ../cpp/simplex.cc
2
2
 
3
3
  export function chat_migrate_init(dbPath: string, dbKey: string, confirm: string): Promise<[bigint, string]>
4
+ export function chat_migrate_init_queue(dbPath: string, dbKey: string, confirm: string, queueSize: number): Promise<[bigint, string]>
4
5
  export function chat_close_store(ctrl: bigint): Promise<string>
5
6
  export function chat_send_cmd(ctrl: bigint, cmd: string): Promise<string>
6
7
  export function chat_recv_msg_wait(ctrl: bigint, wait: number): Promise<string>
7
- export function chat_write_file(ctrl: bigint, path: string, buffer: ArrayBuffer): Promise<string>
8
- export function chat_read_file(path: string, key: string, nonce: string): Promise<ArrayBuffer>
8
+ export function chat_write_file(ctrl: bigint, path: string, buffer: ArrayBuffer | Uint8Array): Promise<string>
9
+ export function chat_read_file(path: string, key: string, nonce: string): Promise<Buffer>
9
10
  export function chat_encrypt_file(ctrl: bigint, fromPath: string, toPath: string): Promise<string>
10
11
  export function chat_decrypt_file(fromPath: string, key: string, nonce: string, toPath: string): Promise<string>
package/src/util.ts CHANGED
@@ -53,8 +53,8 @@ export function botAddressSettings({addressSettings}: T.UserContactLink): BotAdd
53
53
  }
54
54
  }
55
55
 
56
- export function fromLocalProfile({displayName, fullName, shortDescr, image, contactLink, preferences, peerType}: T.LocalProfile): T.Profile {
57
- const profile = {displayName, fullName, shortDescr, image, contactLink, preferences, peerType}
56
+ export function fromLocalProfile({displayName, fullName, shortDescr, image, contactLink, preferences, peerType, contactDomain}: T.LocalProfile): T.Profile {
57
+ const profile = {displayName, fullName, shortDescr, image, contactLink, preferences, peerType, contactDomain: contactDomain && {domain: contactDomain.domain}}
58
58
  for (const key in profile) {
59
59
  if (typeof (profile as any)[key] === "undefined") delete (profile as any)[key]
60
60
  }
@@ -78,7 +78,7 @@ export interface BotCommand {
78
78
  export function ciBotCommand(chatItem: T.ChatItem): BotCommand | undefined {
79
79
  const msg = ciContentText(chatItem)?.trim()
80
80
  if (msg) {
81
- const r = msg.match(/^\/([^\s]+)(.*)/)
81
+ const r = msg.match(/^\/([^\s]+)([\s\S]*)/)
82
82
  if (r && r.length >= 3) {
83
83
  return {keyword: r[1], params: r[2].trim()}
84
84
  }