@dittolive/ditto 4.6.0 → 4.7.0-rc.3

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 (69) hide show
  1. package/README.md +2 -2
  2. package/node/ditto.cjs.js +479 -128
  3. package/node/ditto.darwin-arm64.node +0 -0
  4. package/node/ditto.darwin-x64.node +0 -0
  5. package/node/ditto.linux-arm.node +0 -0
  6. package/node/ditto.linux-arm64.node +0 -0
  7. package/node/ditto.linux-x64.node +0 -0
  8. package/node/ditto.win32-x64.node +0 -0
  9. package/node/transports.darwin-arm64.node +0 -0
  10. package/node/transports.darwin-x64.node +0 -0
  11. package/package.json +1 -1
  12. package/react-native/android/.project +34 -0
  13. package/react-native/android/bin/.project +34 -0
  14. package/react-native/android/bin/src/main/java/com/dittolive/rnsdk/DittoRNSDKModule.class +0 -0
  15. package/react-native/android/bin/src/main/java/com/dittolive/rnsdk/DittoRNSDKPackage.class +0 -0
  16. package/react-native/android/build/intermediates/cxx/abi_configuration_4i3a4k2a.json +14 -0
  17. package/react-native/android/build/intermediates/cxx/abi_configuration_4i3a4k2a.log +1 -0
  18. package/react-native/android/build/intermediates/cxx/abi_configuration_4i3a4k2a_key.json +23 -0
  19. package/react-native/android/build/intermediates/cxx/create_cxx_tasks_371_timing.txt +5 -0
  20. package/react-native/android/build/intermediates/cxx/ndk_locator_record_4q2c3f1f.json +11 -0
  21. package/react-native/android/build/intermediates/cxx/ndk_locator_record_4q2c3f1f.log +72 -0
  22. package/react-native/android/build/intermediates/cxx/ndk_locator_record_4q2c3f1f_key.json +10 -0
  23. package/react-native/android/build.gradle +1 -1
  24. package/react-native/android/cpp-adapter.cpp +39 -43
  25. package/react-native/android/src/main/java/com/dittolive/rnsdk/DittoRNSDKModule.java +1 -1
  26. package/react-native/cpp/include/Arc.hpp +18 -0
  27. package/react-native/cpp/include/ConnectionRequest.h +18 -0
  28. package/react-native/cpp/include/FFIUtils.h +2 -0
  29. package/react-native/cpp/include/Misc.h +1 -1
  30. package/react-native/cpp/include/Presence.h +4 -0
  31. package/react-native/cpp/include/Utils.h +14 -3
  32. package/react-native/cpp/src/Attachment.cpp +5 -6
  33. package/react-native/cpp/src/Authentication.cpp +1 -1
  34. package/react-native/cpp/src/Collection.cpp +2 -0
  35. package/react-native/cpp/src/ConnectionRequest.cpp +123 -0
  36. package/react-native/cpp/src/DQL.cpp +1 -1
  37. package/react-native/cpp/src/FFIUtils.cpp +58 -0
  38. package/react-native/cpp/src/Identity.cpp +2 -3
  39. package/react-native/cpp/src/LiveQuery.cpp +3 -3
  40. package/react-native/cpp/src/Misc.cpp +14 -23
  41. package/react-native/cpp/src/Presence.cpp +87 -0
  42. package/react-native/cpp/src/Utils.cpp +104 -99
  43. package/react-native/cpp/src/main.cpp +15 -2
  44. package/react-native/dittoffi/dittoffi.h +375 -252
  45. package/react-native/ios/DittoRNSDK.mm +3 -3
  46. package/react-native/src/ditto.rn.ts +12 -4
  47. package/react-native/src/index.ts +2 -2
  48. package/react-native/src/sources/bridge.ts +6 -2
  49. package/react-native/src/sources/connection-request.ts +139 -0
  50. package/react-native/src/sources/ditto.ts +31 -28
  51. package/react-native/src/sources/epilogue.ts +4 -2
  52. package/react-native/src/sources/error-codes.ts +37 -3
  53. package/react-native/src/sources/error.ts +30 -1
  54. package/react-native/src/sources/essentials.ts +6 -0
  55. package/react-native/src/sources/ffi-error.ts +20 -9
  56. package/react-native/src/sources/ffi.ts +206 -111
  57. package/react-native/src/sources/main.ts +1 -0
  58. package/react-native/src/sources/pending-collections-operation.ts +1 -1
  59. package/react-native/src/sources/presence.ts +189 -0
  60. package/react-native/src/sources/query-result-item.ts +4 -4
  61. package/react-native/src/sources/query-result.ts +6 -6
  62. package/react-native/src/sources/small-peer-info.ts +1 -12
  63. package/react-native/src/sources/store-observer.ts +6 -15
  64. package/react-native/src/sources/store.ts +5 -13
  65. package/react-native/src/sources/sync.ts +2 -3
  66. package/types/ditto.d.ts +265 -28
  67. package/web/ditto.es6.js +1 -1
  68. package/web/ditto.umd.js +1 -1
  69. package/web/ditto.wasm +0 -0
@@ -13,6 +13,9 @@
13
13
  extern "C" {
14
14
  #endif
15
15
 
16
+ /** <No documentation available> */
17
+ #define DITTOFFI_PRESENCE_PEER_METADATA_MAX_SIZE_IN_BYTES ((uint32_t) 4096)
18
+
16
19
 
17
20
  #include <stddef.h>
18
21
  #include <stdint.h>
@@ -1281,59 +1284,6 @@ CLoginProvider_t *
1281
1284
  void (*release)(void *),
1282
1285
  void (*expiring_cb)(void *, uint32_t));
1283
1286
 
1284
- /** \brief
1285
- * Represents the error code as returned by various FFI functions. It's a
1286
- * simple integer for now, the codes are specified by each FFI function
1287
- * individually (for now, we plan to introduce a proper error type in the near
1288
- * future).
1289
- * Beware that all errors are not captured here. It is encouraged to use this enum
1290
- * instead of explicit `status_code` -mostly 0 and 1-.
1291
- */
1292
- typedef enum DittoErrorCode {
1293
- /** <No documentation available> */
1294
- DITTO_ERROR_CODE_OK = 0,
1295
- /** <No documentation available> */
1296
- DITTO_ERROR_CODE_UNKNOWN = 1,
1297
- /** <No documentation available> */
1298
- DITTO_ERROR_CODE_NOT_IMPLEMENTED = 2,
1299
- /** \brief
1300
- * Fatal case that ought to never happen.
1301
- */
1302
- DITTO_ERROR_CODE_UNREACHABLE = 2989,
1303
- /** <No documentation available> */
1304
- DITTO_ERROR_CODE_FAILED_TO_ACQUIRE_LOCK_FILE = 16777217,
1305
- /** <No documentation available> */
1306
- DITTO_ERROR_CODE_INVALID_PASSPHRASE = 33554433,
1307
- /** <No documentation available> */
1308
- DITTO_ERROR_CODE_EXTRANEOUS_PASSPHRASE_GIVEN = 33554434,
1309
- /** <No documentation available> */
1310
- DITTO_ERROR_CODE_PASSPHRASE_NOT_GIVEN = 33554435,
1311
- /** <No documentation available> */
1312
- DITTO_ERROR_CODE_ALREADY_ENCRYPTED = 33554436,
1313
- /** <No documentation available> */
1314
- DITTO_ERROR_CODE_ENCRYPTION_FAILED = 33554437,
1315
- /** <No documentation available> */
1316
- DITTO_ERROR_CODE_CANNOT_BE_ENCRYPTED = 33554438,
1317
- /** <No documentation available> */
1318
- DITTO_ERROR_CODE_NOT_INITIALIZED = 33554439,
1319
- /** <No documentation available> */
1320
- DITTO_ERROR_CODE_SORT_FAILED = 50331649,
1321
- /** <No documentation available> */
1322
- DITTO_ERROR_CODE_DQL_FAILED_TO_COMPILE_QUERY = 50331650,
1323
- /** <No documentation available> */
1324
- DITTO_ERROR_CODE_DQL_UNSUPPORTED = 50331651,
1325
- /** <No documentation available> */
1326
- DITTO_ERROR_CODE_DQL_EXECUTION_FAILED = 50331652,
1327
- /** <No documentation available> */
1328
- DITTO_ERROR_CODE_PARAMETER_QUERY_FAILED = 50331653,
1329
- } DittoErrorCode_t;
1330
-
1331
- /** <No documentation available> */
1332
- DittoErrorCode_t
1333
- /* fn */ ditto_auth_client_set_peer_signed_info (
1334
- CDitto_t const * ditto,
1335
- slice_ref_uint8_t peer_info);
1336
-
1337
1287
  /** \brief
1338
1288
  * Set a validity listener.
1339
1289
  */
@@ -1585,6 +1535,53 @@ CBORPathResult_t
1585
1535
  char const * path,
1586
1536
  PathAccessorType_t path_type);
1587
1537
 
1538
+ /** \brief
1539
+ * Represents the error code as returned by various FFI functions. It's a
1540
+ * simple integer for now, the codes are specified by each FFI function
1541
+ * individually (for now, we plan to introduce a proper error type in the near
1542
+ * future).
1543
+ * Beware that all errors are not captured here. It is encouraged to use this enum
1544
+ * instead of explicit `status_code` -mostly 0 and 1-.
1545
+ */
1546
+ typedef enum DittoErrorCode {
1547
+ /** <No documentation available> */
1548
+ DITTO_ERROR_CODE_OK = 0,
1549
+ /** <No documentation available> */
1550
+ DITTO_ERROR_CODE_UNKNOWN = 1,
1551
+ /** <No documentation available> */
1552
+ DITTO_ERROR_CODE_NOT_IMPLEMENTED = 2,
1553
+ /** \brief
1554
+ * Fatal case that ought to never happen.
1555
+ */
1556
+ DITTO_ERROR_CODE_UNREACHABLE = 2989,
1557
+ /** <No documentation available> */
1558
+ DITTO_ERROR_CODE_FAILED_TO_ACQUIRE_LOCK_FILE = 16777217,
1559
+ /** <No documentation available> */
1560
+ DITTO_ERROR_CODE_INVALID_PASSPHRASE = 33554433,
1561
+ /** <No documentation available> */
1562
+ DITTO_ERROR_CODE_EXTRANEOUS_PASSPHRASE_GIVEN = 33554434,
1563
+ /** <No documentation available> */
1564
+ DITTO_ERROR_CODE_PASSPHRASE_NOT_GIVEN = 33554435,
1565
+ /** <No documentation available> */
1566
+ DITTO_ERROR_CODE_ALREADY_ENCRYPTED = 33554436,
1567
+ /** <No documentation available> */
1568
+ DITTO_ERROR_CODE_ENCRYPTION_FAILED = 33554437,
1569
+ /** <No documentation available> */
1570
+ DITTO_ERROR_CODE_CANNOT_BE_ENCRYPTED = 33554438,
1571
+ /** <No documentation available> */
1572
+ DITTO_ERROR_CODE_NOT_INITIALIZED = 33554439,
1573
+ /** <No documentation available> */
1574
+ DITTO_ERROR_CODE_SORT_FAILED = 50331649,
1575
+ /** <No documentation available> */
1576
+ DITTO_ERROR_CODE_DQL_FAILED_TO_COMPILE_QUERY = 50331650,
1577
+ /** <No documentation available> */
1578
+ DITTO_ERROR_CODE_DQL_UNSUPPORTED = 50331651,
1579
+ /** <No documentation available> */
1580
+ DITTO_ERROR_CODE_DQL_EXECUTION_FAILED = 50331652,
1581
+ /** <No documentation available> */
1582
+ DITTO_ERROR_CODE_PARAMETER_QUERY_FAILED = 50331653,
1583
+ } DittoErrorCode_t;
1584
+
1588
1585
  /** \brief
1589
1586
  * Changes the passphrase and re-encrypts all data. This can take a while,
1590
1587
  * progress is reported via the progress callback. Returns a progress token
@@ -2433,26 +2430,6 @@ char *
2433
2430
  char *
2434
2431
  /* fn */ ditto_get_sdk_version (void);
2435
2432
 
2436
- /** \brief
2437
- * This is a handle to a tokio oneshot sender that will act as a cross-FFI medium for the
2438
- * onConnecting API, as the SDK side can send a signal to the with the connection decision
2439
- * asynchronously, and independently of the the SDK is written in.
2440
- *
2441
- * It's used as the "token" which the SDK can pass back to `ditto_handle_on_connecting_response`
2442
- * so that the handshake can unblock and react to the decision.
2443
- */
2444
- typedef struct OnConnectingResponseHandle OnConnectingResponseHandle_t;
2445
-
2446
- /** \brief
2447
- * This is the asynchronous response companion to [`ditto_register_on_connecting`]. It takes the
2448
- * [`OnConnectingResponseHandle`] given in the [`OnConnectingCallback`] callback and consumes the
2449
- * handle to send a message to the Ditto core with the user's decision to connect or reject a peer.
2450
- */
2451
- void
2452
- /* fn */ ditto_handle_on_connecting_response (
2453
- OnConnectingResponseHandle_t * handle,
2454
- bool response);
2455
-
2456
2433
  /** <No documentation available> */
2457
2434
  typedef struct IdentityConfigResult {
2458
2435
  /** <No documentation available> */
@@ -2820,157 +2797,6 @@ CDitto_t *
2820
2797
  CIdentityConfig_t * identity_config,
2821
2798
  HistoryTracking_t history_tracking);
2822
2799
 
2823
- /** <No documentation available> */
2824
- typedef struct Erased Erased_t;
2825
-
2826
- /** \brief
2827
- * An FFI-safe `Poll<()>`.
2828
- */
2829
- /** \remark Has the same ABI as `int8_t` **/
2830
- #ifdef DOXYGEN
2831
- typedef
2832
- #endif
2833
- enum PollFuture {
2834
- /** <No documentation available> */
2835
- POLL_FUTURE_COMPLETED = 0,
2836
- /** <No documentation available> */
2837
- POLL_FUTURE_PENDING = -1,
2838
- }
2839
- #ifndef DOXYGEN
2840
- ; typedef int8_t
2841
- #endif
2842
- PollFuture_t;
2843
-
2844
- /** \brief
2845
- * The layout of `core::task::wake::Context` is opaque/subject to changes.
2846
- */
2847
- typedef struct Opaque_Context Opaque_Context_t;
2848
-
2849
- /** <No documentation available> */
2850
- typedef struct FfiFutureVTable {
2851
- /** <No documentation available> */
2852
- void (*release_vptr)(Erased_t *);
2853
-
2854
- /** <No documentation available> */
2855
- PollFuture_t (*dyn_poll)(Erased_t *, Opaque_Context_t *);
2856
- } FfiFutureVTable_t;
2857
-
2858
- /** <No documentation available> */
2859
- typedef struct VirtualPtr__Erased_ptr_FfiFutureVTable {
2860
- /** <No documentation available> */
2861
- Erased_t * ptr;
2862
-
2863
- /** <No documentation available> */
2864
- FfiFutureVTable_t vtable;
2865
- } VirtualPtr__Erased_ptr_FfiFutureVTable_t;
2866
-
2867
- /** \brief
2868
- * `Box<dyn 'static + Send + FnMut() -> Ret>`
2869
- */
2870
- typedef struct BoxDynFnMut0_void {
2871
- /** <No documentation available> */
2872
- void * env_ptr;
2873
-
2874
- /** <No documentation available> */
2875
- void (*call)(void *);
2876
-
2877
- /** <No documentation available> */
2878
- void (*free)(void *);
2879
- } BoxDynFnMut0_void_t;
2880
-
2881
- /** <No documentation available> */
2882
- typedef struct DropGlueVTable {
2883
- /** <No documentation available> */
2884
- void (*release_vptr)(Erased_t *);
2885
- } DropGlueVTable_t;
2886
-
2887
- /** <No documentation available> */
2888
- typedef struct VirtualPtr__Erased_ptr_DropGlueVTable {
2889
- /** <No documentation available> */
2890
- Erased_t * ptr;
2891
-
2892
- /** <No documentation available> */
2893
- DropGlueVTable_t vtable;
2894
- } VirtualPtr__Erased_ptr_DropGlueVTable_t;
2895
-
2896
- /** <No documentation available> */
2897
- typedef struct FfiFutureExecutorVTable {
2898
- /** <No documentation available> */
2899
- void (*release_vptr)(Erased_t *);
2900
-
2901
- /** <No documentation available> */
2902
- Erased_t * (*retain_vptr)(Erased_t const *);
2903
-
2904
- /** <No documentation available> */
2905
- VirtualPtr__Erased_ptr_FfiFutureVTable_t (*dyn_spawn)(Erased_t const *, VirtualPtr__Erased_ptr_FfiFutureVTable_t);
2906
-
2907
- /** <No documentation available> */
2908
- VirtualPtr__Erased_ptr_FfiFutureVTable_t (*dyn_spawn_blocking)(Erased_t const *, BoxDynFnMut0_void_t);
2909
-
2910
- /** <No documentation available> */
2911
- void (*dyn_block_on)(Erased_t const *, VirtualPtr__Erased_ptr_FfiFutureVTable_t);
2912
-
2913
- /** <No documentation available> */
2914
- VirtualPtr__Erased_ptr_DropGlueVTable_t (*dyn_enter)(Erased_t const *);
2915
- } FfiFutureExecutorVTable_t;
2916
-
2917
- /** <No documentation available> */
2918
- typedef struct VirtualPtr__Erased_ptr_FfiFutureExecutorVTable {
2919
- /** <No documentation available> */
2920
- Erased_t * ptr;
2921
-
2922
- /** <No documentation available> */
2923
- FfiFutureExecutorVTable_t vtable;
2924
- } VirtualPtr__Erased_ptr_FfiFutureExecutorVTable_t;
2925
-
2926
- /** <No documentation available> */
2927
- typedef struct StaticDropGlueVTable {
2928
- /** <No documentation available> */
2929
- void (*release_vptr)(Erased_t *);
2930
-
2931
- /** <No documentation available> */
2932
- Erased_t * (*retain_vptr)(Erased_t const *);
2933
- } StaticDropGlueVTable_t;
2934
-
2935
- /** <No documentation available> */
2936
- typedef struct VirtualPtr__Erased_ptr_StaticDropGlueVTable {
2937
- /** <No documentation available> */
2938
- Erased_t * ptr;
2939
-
2940
- /** <No documentation available> */
2941
- StaticDropGlueVTable_t vtable;
2942
- } VirtualPtr__Erased_ptr_StaticDropGlueVTable_t;
2943
-
2944
- /** \brief
2945
- * A `dyn` type-erased (and thus completely layout agnostic
2946
- * (_e.g._, tokio-agnostic)) and yet FFI-compatible version of an `async`
2947
- * runtime executor.
2948
- *
2949
- * Keep it in sync with `rust/dittolive-ditto-sys/lib.rs`!
2950
- */
2951
- typedef struct DynExecutor {
2952
- /** \brief
2953
- * The main object used to spawn futures and whatnot.
2954
- */
2955
- VirtualPtr__Erased_ptr_FfiFutureExecutorVTable_t handle;
2956
-
2957
- /** \brief
2958
- * The drop glue potentially driving the shutdown of the runtime.
2959
- */
2960
- VirtualPtr__Erased_ptr_StaticDropGlueVTable_t _runtime;
2961
- } DynExecutor_t;
2962
-
2963
- /** \brief
2964
- * See docs for `ditto_make`. The only difference with that function is that you must also provide
2965
- * an executor when calling this function.
2966
- */
2967
- CDitto_t *
2968
- /* fn */ ditto_make_with_executor (
2969
- char const * working_dir,
2970
- CIdentityConfig_t * identity_config,
2971
- DynExecutor_t executor,
2972
- HistoryTracking_t history_tracking);
2973
-
2974
2800
  /** <No documentation available> */
2975
2801
  typedef struct CAttachment {
2976
2802
  /** <No documentation available> */
@@ -3165,19 +2991,6 @@ int32_t
3165
2991
  void (*auth_cb)(void *, CAuthServerAuthRequest_t *, slice_ref_uint8_t),
3166
2992
  void (*refresh_cb)(void *, CAuthServerRefreshRequest_t *, slice_ref_uint8_t));
3167
2993
 
3168
- /** \brief
3169
- * Register a function that will be called every time a peer connection attempt is made.
3170
- * The function can return true to continue connecting, and false to reject the connection,
3171
- * based on the supplied metadata about the peer.
3172
- */
3173
- void
3174
- /* fn */ ditto_register_on_connecting (
3175
- CDitto_t const * ditto,
3176
- void * ctx,
3177
- void (*retain)(void *),
3178
- void (*release)(void *),
3179
- void (*c_cb)(void *, slice_ref_uint8_t, OnConnectingResponseHandle_t *));
3180
-
3181
2994
  /** \brief
3182
2995
  * Register a function that will be called every time the connection state
3183
2996
  * of remote peers changes.
@@ -3255,13 +3068,6 @@ void
3255
3068
  /* fn */ ditto_release_disk_usage_callback (
3256
3069
  DiskUsageObserver_t * _handle);
3257
3070
 
3258
- /** \brief
3259
- * Release the disk usage observer obtained from `ditto_register_disk_usage_callback`
3260
- */
3261
- void
3262
- /* fn */ ditto_release_response_handle (
3263
- OnConnectingResponseHandle_t * _handle);
3264
-
3265
3071
  /** <No documentation available> */
3266
3072
  void
3267
3073
  /* fn */ ditto_remove_multicast_transport (
@@ -3476,6 +3282,7 @@ void
3476
3282
  /** <No documentation available> */
3477
3283
  void
3478
3284
  /* fn */ ditto_set_max_outgoing_ble_peers (
3285
+ CDitto_t const * ditto,
3479
3286
  uint32_t count);
3480
3287
 
3481
3288
  /** <No documentation available> */
@@ -4021,15 +3828,135 @@ BoolResult_t
4021
3828
  slice_ref_uint8_t document_cbor,
4022
3829
  slice_ref_uint8_t provided_cbor);
4023
3830
 
3831
+ /** \brief
3832
+ * Opaque type encapsulating the different args provided to the `.on_connecting()`
3833
+ * callback in a future-proof fashion.
3834
+ *
3835
+ * This is the lowest-level "wrapped" callback, i.e. the most convenient set of types for
3836
+ * passing across the FFI barrier.
3837
+ *
3838
+ * Typically, SDKs will have a wrapping method that does the (de)serialization to/from CBOR
3839
+ * to create a more user-friendly function signature for `connecting_peer`.
3840
+ */
3841
+ typedef struct dittoffi_connection_request dittoffi_connection_request_t;
3842
+
3843
+ /** <No documentation available> */
3844
+ typedef enum dittoffi_connection_request_authorization {
3845
+ /** <No documentation available> */
3846
+ DITTOFFI_CONNECTION_REQUEST_AUTHORIZATION_DENY,
3847
+ /** <No documentation available> */
3848
+ DITTOFFI_CONNECTION_REQUEST_AUTHORIZATION_ALLOW,
3849
+ } dittoffi_connection_request_authorization_t;
3850
+
3851
+ /** \brief
3852
+ * Answer/output of the `connection_request_handler`, communicated through the `connection_request`
3853
+ * object.
3854
+ * `true` allows the connection, `false` rejects it.
3855
+ */
3856
+ void
3857
+ /* fn */ dittoffi_connection_request_authorize (
3858
+ dittoffi_connection_request_t const * r,
3859
+ dittoffi_connection_request_authorization_t authorized);
3860
+
3861
+ /** \brief
3862
+ * A simplified [`ConnectionType`] exposed to the SDKs
3863
+ */
3864
+ typedef enum dittoffi_connection_type {
3865
+ /** <No documentation available> */
3866
+ DITTOFFI_CONNECTION_TYPE_BLUETOOTH,
3867
+ /** <No documentation available> */
3868
+ DITTOFFI_CONNECTION_TYPE_ACCESS_POINT,
3869
+ /** <No documentation available> */
3870
+ DITTOFFI_CONNECTION_TYPE_P2_P_WI_FI,
3871
+ /** <No documentation available> */
3872
+ DITTOFFI_CONNECTION_TYPE_WEB_SOCKET,
3873
+ } dittoffi_connection_type_t;
3874
+
3875
+ /** \brief
3876
+ * The connecting peer's (pub) key (empty for legacy peers).
3877
+ */
3878
+ dittoffi_connection_type_t
3879
+ /* fn */ dittoffi_connection_request_connection_type (
3880
+ dittoffi_connection_request_t const * r);
3881
+
3882
+ /** <No documentation available> */
3883
+ void
3884
+ /* fn */ dittoffi_connection_request_free (
3885
+ dittoffi_connection_request_t * __arg_0);
3886
+
3887
+ /** \brief
3888
+ * Getter for the `identity_service` as a JSON (string / UTF-8 data).
3889
+ */
3890
+ slice_ref_uint8_t
3891
+ /* fn */ dittoffi_connection_request_identity_service_metadata_json (
3892
+ dittoffi_connection_request_t const * r);
3893
+
3894
+ /** \brief
3895
+ * The connecting peer's (pub) key (empty for legacy peers), hex-encoded as a string
3896
+ */
3897
+ char *
3898
+ /* fn */ dittoffi_connection_request_peer_key_string (
3899
+ dittoffi_connection_request_t const * r);
3900
+
3901
+ /** \brief
3902
+ * Getter for the `peer_metadata` as a JSON (string / UTF-8 data).
3903
+ */
3904
+ slice_ref_uint8_t
3905
+ /* fn */ dittoffi_connection_request_peer_metadata_json (
3906
+ dittoffi_connection_request_t const * r);
3907
+
4024
3908
  /** \brief
4025
3909
  * The ditto error type, opaque.
4026
3910
  */
4027
3911
  typedef struct dittoffi_error dittoffi_error_t;
4028
3912
 
3913
+ /** <No documentation available> */
3914
+ typedef struct dittoffi_result_CDitto_ptr {
3915
+ /** \brief
3916
+ * Non-`NULL` pointer to opaque object on error, `NULL` otherwise.
3917
+ */
3918
+ dittoffi_error_t * error;
3919
+
3920
+ /** \brief
3921
+ * When no error occurred, the success value payload can be retrieved here.
3922
+ *
3923
+ * Otherwise, the value is to be ignored.
3924
+ */
3925
+ CDitto_t * success;
3926
+ } dittoffi_result_CDitto_ptr_t;
3927
+
3928
+ /** \brief
3929
+ * Same as `ditto_make`, but properly fallible (but not yet `async`).
3930
+ */
3931
+ dittoffi_result_CDitto_ptr_t
3932
+ /* fn */ dittoffi_ditto_try_new_blocking (
3933
+ char const * working_dir,
3934
+ CIdentityConfig_t * identity_config,
3935
+ HistoryTracking_t history_tracking,
3936
+ char const * experimental_passphrase);
3937
+
4029
3938
  /** \brief
4030
3939
  * The error codes for `ditto_error_t`
4031
3940
  */
4032
3941
  typedef enum dittoffi_error_code {
3942
+ /** \brief
3943
+ * The license signature failed verification. This could be due to incorrectly
3944
+ * encoded/truncated data or could indicate tampering.
3945
+ */
3946
+ DITTOFFI_ERROR_CODE_ACTIVATION_LICENSE_TOKEN_INVALID,
3947
+ /** \brief
3948
+ * The license is valid but expired.
3949
+ */
3950
+ DITTOFFI_ERROR_CODE_ACTIVATION_LICENSE_TOKEN_EXPIRED,
3951
+ /** \brief
3952
+ * The provided license data was from a future version of Ditto and is incompatible with this
3953
+ * version.
3954
+ */
3955
+ DITTOFFI_ERROR_CODE_ACTIVATION_LICENSE_UNSUPPORTED_FUTURE_VERSION,
3956
+ /** \brief
3957
+ * The operation failed because the Ditto instance is not yet activated.
3958
+ */
3959
+ DITTOFFI_ERROR_CODE_ACTIVATION_NOT_ACTIVATED,
4033
3960
  /** \brief
4034
3961
  * Invalid CBOR-encoded input.
4035
3962
  */
@@ -4075,10 +4002,43 @@ typedef enum dittoffi_error_code {
4075
4002
  * Unsupported features were used in a DQL statement or query.
4076
4003
  */
4077
4004
  DITTOFFI_ERROR_CODE_DQL_UNSUPPORTED,
4005
+ /** \brief
4006
+ * Exceeded a depth limit.
4007
+ */
4008
+ DITTOFFI_ERROR_CODE_VALIDATION_DEPTH_LIMIT_EXCEEDED,
4009
+ /** \brief
4010
+ * The value was not a map.
4011
+ */
4012
+ DITTOFFI_ERROR_CODE_VALIDATION_NOT_A_MAP,
4013
+ /** \brief
4014
+ * Exceeded the size limit.
4015
+ */
4016
+ DITTOFFI_ERROR_CODE_VALIDATION_SIZE_LIMIT_EXCEEDED,
4017
+ /** \brief
4018
+ * Invalid JSON provided.
4019
+ */
4020
+ DITTOFFI_ERROR_CODE_VALIDATION_INVALID_JSON,
4021
+ /** \brief
4022
+ * Invalid CBOR provided.
4023
+ */
4024
+ DITTOFFI_ERROR_CODE_VALIDATION_INVALID_CBOR,
4078
4025
  /** \brief
4079
4026
  * Invalid input provided for base64 decoding.
4080
4027
  */
4081
4028
  DITTOFFI_ERROR_CODE_BASE64_INVALID,
4029
+ /** \brief
4030
+ * Outstanding usage of ditto's working directory detected when trying to instantiate a new
4031
+ * `Ditto`, which would have lead to concurrent usage of the backing database files.
4032
+ */
4033
+ DITTOFFI_ERROR_CODE_LOCKED_DITTO_WORKING_DIRECTORY,
4034
+ /** \brief
4035
+ * An error occurred accessing the filesystem.
4036
+ */
4037
+ DITTOFFI_ERROR_CODE_FILESYSTEM_ERROR,
4038
+ /** \brief
4039
+ * Some not-yet-categorized error occurred.
4040
+ */
4041
+ DITTOFFI_ERROR_CODE_INTERNAL,
4082
4042
  } dittoffi_error_code_t;
4083
4043
 
4084
4044
  /** <No documentation available> */
@@ -4105,6 +4065,66 @@ void
4105
4065
  char *
4106
4066
  /* fn */ dittoffi_get_sdk_semver (void);
4107
4067
 
4068
+ /** \brief
4069
+ * Getter for the `peer_metadata` as a JSON (string / UTF-8 data).
4070
+ */
4071
+ slice_boxed_uint8_t
4072
+ /* fn */ dittoffi_presence_peer_metadata_json (
4073
+ CDitto_t const * ditto);
4074
+
4075
+ /** <No documentation available> */
4076
+ typedef struct Erased Erased_t;
4077
+
4078
+ /** <No documentation available> */
4079
+ typedef struct FfiConnectionRequestHandlerVTable {
4080
+ /** <No documentation available> */
4081
+ void (*release_vptr)(Erased_t *);
4082
+
4083
+ /** <No documentation available> */
4084
+ Erased_t * (*retain_vptr)(Erased_t const *);
4085
+
4086
+ /** <No documentation available> */
4087
+ void (*on_connecting)(Erased_t const *, dittoffi_connection_request_t *);
4088
+ } FfiConnectionRequestHandlerVTable_t;
4089
+
4090
+ /** <No documentation available> */
4091
+ typedef struct VirtualPtr__Erased_ptr_FfiConnectionRequestHandlerVTable {
4092
+ /** <No documentation available> */
4093
+ Erased_t * ptr;
4094
+
4095
+ /** <No documentation available> */
4096
+ FfiConnectionRequestHandlerVTable_t vtable;
4097
+ } VirtualPtr__Erased_ptr_FfiConnectionRequestHandlerVTable_t;
4098
+
4099
+ /** \brief
4100
+ * Register a function that will be called every time a peer connection attempt is made.
4101
+ * The function can return true to continue connecting, and false to reject the connection,
4102
+ * based on the supplied metadata about the peer.
4103
+ */
4104
+ void
4105
+ /* fn */ dittoffi_presence_set_connection_request_handler (
4106
+ CDitto_t const * ditto,
4107
+ VirtualPtr__Erased_ptr_FfiConnectionRequestHandlerVTable_t ffi_handler);
4108
+
4109
+ /** <No documentation available> */
4110
+ typedef struct dittoffi_result_void {
4111
+ /** \brief
4112
+ * Non-`NULL` pointer to opaque object on error, `NULL` otherwise.
4113
+ */
4114
+ dittoffi_error_t * error;
4115
+ } dittoffi_result_void_t;
4116
+
4117
+ /** \brief
4118
+ * Sets the signed peer info / peer metadata to which the `on_connecting` /
4119
+ * `connectionRequestHandler` callback shall have access.
4120
+ *
4121
+ * The `peer_info` is expected to represent the UTF-8 bytes of a serialized JSON instead of CBOR.
4122
+ */
4123
+ dittoffi_result_void_t
4124
+ /* fn */ dittoffi_presence_try_set_peer_metadata_json (
4125
+ CDitto_t const * ditto,
4126
+ slice_ref_uint8_t peer_info);
4127
+
4108
4128
  /** <No documentation available> */
4109
4129
  typedef struct dittoffi_query_result dittoffi_query_result_t;
4110
4130
 
@@ -4153,14 +4173,6 @@ size_t
4153
4173
  /* fn */ dittoffi_query_result_mutated_document_id_count (
4154
4174
  dittoffi_query_result_t const * result);
4155
4175
 
4156
- /** <No documentation available> */
4157
- typedef struct dittoffi_result_void {
4158
- /** \brief
4159
- * Non-`NULL` pointer to opaque object on error, `NULL` otherwise.
4160
- */
4161
- dittoffi_error_t * error;
4162
- } dittoffi_result_void_t;
4163
-
4164
4176
  /** <No documentation available> */
4165
4177
  dittoffi_result_void_t
4166
4178
  /* fn */ dittoffi_try_add_subscription (
@@ -4607,6 +4619,17 @@ dittoffi_result_void_t
4607
4619
  char const * query,
4608
4620
  slice_ref_uint8_t query_args_cbor);
4609
4621
 
4622
+ /** \brief
4623
+ * Verify a base64 encoded license string.
4624
+ *
4625
+ * # Parameters
4626
+ * - `license`: A base64 encoded license string. This should be the output of
4627
+ * `ditto_licenser::license_mgr::generate()`.
4628
+ */
4629
+ dittoffi_result_void_t
4630
+ /* fn */ dittoffi_try_verify_license (
4631
+ char const * license);
4632
+
4610
4633
  /** <No documentation available> */
4611
4634
  void
4612
4635
  /* fn */ free_c_string_vec (
@@ -4692,6 +4715,106 @@ void
4692
4715
  Vec_char_ptr_t *
4693
4716
  /* fn */ new_c_string_vec (void);
4694
4717
 
4718
+ /** \brief
4719
+ * An FFI-safe `Poll<()>`.
4720
+ */
4721
+ /** \remark Has the same ABI as `int8_t` **/
4722
+ #ifdef DOXYGEN
4723
+ typedef
4724
+ #endif
4725
+ enum PollFuture {
4726
+ /** <No documentation available> */
4727
+ POLL_FUTURE_COMPLETED = 0,
4728
+ /** <No documentation available> */
4729
+ POLL_FUTURE_PENDING = -1,
4730
+ }
4731
+ #ifndef DOXYGEN
4732
+ ; typedef int8_t
4733
+ #endif
4734
+ PollFuture_t;
4735
+
4736
+ /** \brief
4737
+ * The layout of `core::task::wake::Context` is opaque/subject to changes.
4738
+ */
4739
+ typedef struct Opaque_Context Opaque_Context_t;
4740
+
4741
+ /** <No documentation available> */
4742
+ typedef struct FfiFutureVTable {
4743
+ /** <No documentation available> */
4744
+ void (*release_vptr)(Erased_t *);
4745
+
4746
+ /** <No documentation available> */
4747
+ PollFuture_t (*dyn_poll)(Erased_t *, Opaque_Context_t *);
4748
+ } FfiFutureVTable_t;
4749
+
4750
+ /** <No documentation available> */
4751
+ typedef struct VirtualPtr__Erased_ptr_FfiFutureVTable {
4752
+ /** <No documentation available> */
4753
+ Erased_t * ptr;
4754
+
4755
+ /** <No documentation available> */
4756
+ FfiFutureVTable_t vtable;
4757
+ } VirtualPtr__Erased_ptr_FfiFutureVTable_t;
4758
+
4759
+ /** \brief
4760
+ * `Box<dyn 'static + Send + FnMut() -> Ret>`
4761
+ */
4762
+ typedef struct BoxDynFnMut0_void {
4763
+ /** <No documentation available> */
4764
+ void * env_ptr;
4765
+
4766
+ /** <No documentation available> */
4767
+ void (*call)(void *);
4768
+
4769
+ /** <No documentation available> */
4770
+ void (*free)(void *);
4771
+ } BoxDynFnMut0_void_t;
4772
+
4773
+ /** <No documentation available> */
4774
+ typedef struct DropGlueVTable {
4775
+ /** <No documentation available> */
4776
+ void (*release_vptr)(Erased_t *);
4777
+ } DropGlueVTable_t;
4778
+
4779
+ /** <No documentation available> */
4780
+ typedef struct VirtualPtr__Erased_ptr_DropGlueVTable {
4781
+ /** <No documentation available> */
4782
+ Erased_t * ptr;
4783
+
4784
+ /** <No documentation available> */
4785
+ DropGlueVTable_t vtable;
4786
+ } VirtualPtr__Erased_ptr_DropGlueVTable_t;
4787
+
4788
+ /** <No documentation available> */
4789
+ typedef struct FfiFutureExecutorVTable {
4790
+ /** <No documentation available> */
4791
+ void (*release_vptr)(Erased_t *);
4792
+
4793
+ /** <No documentation available> */
4794
+ Erased_t * (*retain_vptr)(Erased_t const *);
4795
+
4796
+ /** <No documentation available> */
4797
+ VirtualPtr__Erased_ptr_FfiFutureVTable_t (*dyn_spawn)(Erased_t const *, VirtualPtr__Erased_ptr_FfiFutureVTable_t);
4798
+
4799
+ /** <No documentation available> */
4800
+ VirtualPtr__Erased_ptr_FfiFutureVTable_t (*dyn_spawn_blocking)(Erased_t const *, BoxDynFnMut0_void_t);
4801
+
4802
+ /** <No documentation available> */
4803
+ void (*dyn_block_on)(Erased_t const *, VirtualPtr__Erased_ptr_FfiFutureVTable_t);
4804
+
4805
+ /** <No documentation available> */
4806
+ VirtualPtr__Erased_ptr_DropGlueVTable_t (*dyn_enter)(Erased_t const *);
4807
+ } FfiFutureExecutorVTable_t;
4808
+
4809
+ /** <No documentation available> */
4810
+ typedef struct VirtualPtr__Erased_ptr_FfiFutureExecutorVTable {
4811
+ /** <No documentation available> */
4812
+ Erased_t * ptr;
4813
+
4814
+ /** <No documentation available> */
4815
+ FfiFutureExecutorVTable_t vtable;
4816
+ } VirtualPtr__Erased_ptr_FfiFutureExecutorVTable_t;
4817
+
4695
4818
  /** <No documentation available> */
4696
4819
  typedef struct FfiFnMutVTable {
4697
4820
  /** <No documentation available> */