ffi-bindings 1.0.0

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.
@@ -0,0 +1,947 @@
1
+ var _process;
2
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
3
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
4
+ function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
5
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
6
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
7
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
8
+ function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
9
+ function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
10
+ function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
11
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
12
+ function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
13
+ function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
14
+ function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
15
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
16
+ // This file was autogenerated by some hot garbage in the `uniffi-bindgen-react-native` crate.
17
+ // Trust me, you don't want to mess with it!
18
+ /* tslint:disable */
19
+ /* eslint-disable */
20
+ // @ts-nocheck
21
+ import * as wasmBundle from "./wasm-bindgen/index.js";
22
+ import { AbstractFfiConverterByteArray, FfiConverterInt32, UniffiError, UniffiInternalError, UniffiRustCaller, uniffiCreateFfiConverterString, uniffiCreateRecord, uniffiTypeNameSymbol, variantOrdinalSymbol } from "uniffi-bindgen-react-native";
23
+ // Get converters from the other files, if any.
24
+ var nativeModule = function nativeModule() {
25
+ return wasmBundle;
26
+ };
27
+ var uniffiCaller = new UniffiRustCaller(function () {
28
+ return new wasmBundle.RustCallStatus();
29
+ });
30
+ var uniffiIsDebug =
31
+ // @ts-ignore -- The process global might not be defined
32
+ (typeof process === "undefined" ? "undefined" : _typeof(process)) !== "object" ||
33
+ // @ts-ignore -- The process global might not be defined
34
+ ((_process = process) === null || _process === void 0 || (_process = _process.env) === null || _process === void 0 ? void 0 : _process.NODE_ENV) !== "production" || false;
35
+ /**
36
+ * Generated factory for {@link DecryptionSettings} record objects.
37
+ */
38
+ export var DecryptionSettings = function () {
39
+ var _defaults = function defaults() {
40
+ return {};
41
+ };
42
+ var create = function () {
43
+ return uniffiCreateRecord(_defaults);
44
+ }();
45
+ return Object.freeze({
46
+ /**
47
+ * Create a frozen instance of {@link DecryptionSettings}, with defaults specified
48
+ * in Rust, in the {@link matrix_sdk_crypto} crate.
49
+ */
50
+ create: create,
51
+ /**
52
+ * Create a frozen instance of {@link DecryptionSettings}, with defaults specified
53
+ * in Rust, in the {@link matrix_sdk_crypto} crate.
54
+ */
55
+ "new": create,
56
+ /**
57
+ * Defaults specified in the {@link matrix_sdk_crypto} crate.
58
+ */
59
+ defaults: function defaults() {
60
+ return Object.freeze(_defaults());
61
+ }
62
+ });
63
+ }();
64
+ var FfiConverterTypeDecryptionSettings = function () {
65
+ var FFIConverter = /*#__PURE__*/function (_AbstractFfiConverter) {
66
+ function FFIConverter() {
67
+ _classCallCheck(this, FFIConverter);
68
+ return _callSuper(this, FFIConverter, arguments);
69
+ }
70
+ _inherits(FFIConverter, _AbstractFfiConverter);
71
+ return _createClass(FFIConverter, [{
72
+ key: "read",
73
+ value: function read(from) {
74
+ return {
75
+ senderDeviceTrustRequirement: FfiConverterTypeTrustRequirement.read(from)
76
+ };
77
+ }
78
+ }, {
79
+ key: "write",
80
+ value: function write(value, into) {
81
+ FfiConverterTypeTrustRequirement.write(value.senderDeviceTrustRequirement, into);
82
+ }
83
+ }, {
84
+ key: "allocationSize",
85
+ value: function allocationSize(value) {
86
+ return FfiConverterTypeTrustRequirement.allocationSize(value.senderDeviceTrustRequirement);
87
+ }
88
+ }]);
89
+ }(AbstractFfiConverterByteArray);
90
+ ;
91
+ return new FFIConverter();
92
+ }();
93
+ var stringConverter = function () {
94
+ var encoder = new TextEncoder();
95
+ var decoder = new TextDecoder();
96
+ return {
97
+ stringToBytes: function stringToBytes(s) {
98
+ return encoder.encode(s);
99
+ },
100
+ bytesToString: function bytesToString(ab) {
101
+ return decoder.decode(ab);
102
+ },
103
+ stringByteLength: function stringByteLength(s) {
104
+ return encoder.encode(s).byteLength;
105
+ }
106
+ };
107
+ }();
108
+ var FfiConverterString = uniffiCreateFfiConverterString(stringConverter);
109
+ /**
110
+ * Strategy to collect the devices that should receive room keys for the
111
+ * current discussion.
112
+ */
113
+ export var CollectStrategy;
114
+ (function (CollectStrategy) {
115
+ /**
116
+ * Share with all (unblacklisted) devices.
117
+ */
118
+ CollectStrategy[CollectStrategy["AllDevices"] = 0] = "AllDevices";
119
+ /**
120
+ * Share with all devices, except errors for *verified* users cause sharing
121
+ * to fail with an error.
122
+ *
123
+ * In this strategy, if a verified user has an unsigned device,
124
+ * key sharing will fail with a
125
+ * [`SessionRecipientCollectionError::VerifiedUserHasUnsignedDevice`].
126
+ * If a verified user has replaced their identity, key
127
+ * sharing will fail with a
128
+ * [`SessionRecipientCollectionError::VerifiedUserChangedIdentity`].
129
+ *
130
+ * Otherwise, keys are shared with unsigned devices as normal.
131
+ *
132
+ * Once the problematic devices are blacklisted or whitelisted the
133
+ * caller can retry to share a second time.
134
+ */
135
+ CollectStrategy[CollectStrategy["ErrorOnVerifiedUserProblem"] = 1] = "ErrorOnVerifiedUserProblem";
136
+ /**
137
+ * Share based on identity. Only distribute to devices signed by their
138
+ * owner. If a user has no published identity he will not receive
139
+ * any room keys.
140
+ */
141
+ CollectStrategy[CollectStrategy["IdentityBasedStrategy"] = 2] = "IdentityBasedStrategy";
142
+ /**
143
+ * Only share keys with devices that we "trust". A device is trusted if any
144
+ * of the following is true:
145
+ * - It was manually marked as trusted.
146
+ * - It was marked as verified via interactive verification.
147
+ * - It is signed by its owner identity, and this identity has been
148
+ * trusted via interactive verification.
149
+ * - It is the current own device of the user.
150
+ */
151
+ CollectStrategy[CollectStrategy["OnlyTrustedDevices"] = 3] = "OnlyTrustedDevices";
152
+ })(CollectStrategy || (CollectStrategy = {}));
153
+ var FfiConverterTypeCollectStrategy = function () {
154
+ var ordinalConverter = FfiConverterInt32;
155
+ var FFIConverter = /*#__PURE__*/function (_AbstractFfiConverter2) {
156
+ function FFIConverter() {
157
+ _classCallCheck(this, FFIConverter);
158
+ return _callSuper(this, FFIConverter, arguments);
159
+ }
160
+ _inherits(FFIConverter, _AbstractFfiConverter2);
161
+ return _createClass(FFIConverter, [{
162
+ key: "read",
163
+ value: function read(from) {
164
+ switch (ordinalConverter.read(from)) {
165
+ case 1:
166
+ return CollectStrategy.AllDevices;
167
+ case 2:
168
+ return CollectStrategy.ErrorOnVerifiedUserProblem;
169
+ case 3:
170
+ return CollectStrategy.IdentityBasedStrategy;
171
+ case 4:
172
+ return CollectStrategy.OnlyTrustedDevices;
173
+ default:
174
+ throw new UniffiInternalError.UnexpectedEnumCase();
175
+ }
176
+ }
177
+ }, {
178
+ key: "write",
179
+ value: function write(value, into) {
180
+ switch (value) {
181
+ case CollectStrategy.AllDevices:
182
+ return ordinalConverter.write(1, into);
183
+ case CollectStrategy.ErrorOnVerifiedUserProblem:
184
+ return ordinalConverter.write(2, into);
185
+ case CollectStrategy.IdentityBasedStrategy:
186
+ return ordinalConverter.write(3, into);
187
+ case CollectStrategy.OnlyTrustedDevices:
188
+ return ordinalConverter.write(4, into);
189
+ }
190
+ }
191
+ }, {
192
+ key: "allocationSize",
193
+ value: function allocationSize(value) {
194
+ return ordinalConverter.allocationSize(0);
195
+ }
196
+ }]);
197
+ }(AbstractFfiConverterByteArray);
198
+ return new FFIConverter();
199
+ }();
200
+ /**
201
+ * The state of an identity - verified, pinned etc.
202
+ */
203
+ export var IdentityState;
204
+ (function (IdentityState) {
205
+ /**
206
+ * The user is verified with us
207
+ */
208
+ IdentityState[IdentityState["Verified"] = 0] = "Verified";
209
+ /**
210
+ * Either this is the first identity we have seen for this user, or the
211
+ * user has acknowledged a change of identity explicitly e.g. by
212
+ * clicking OK on a notification.
213
+ */
214
+ IdentityState[IdentityState["Pinned"] = 1] = "Pinned";
215
+ /**
216
+ * The user's identity has changed since it was pinned. The user should be
217
+ * notified about this and given the opportunity to acknowledge the
218
+ * change, which will make the new identity pinned.
219
+ * When the user acknowledges the change, the app should call
220
+ * [`crate::OtherUserIdentity::pin_current_master_key`].
221
+ */
222
+ IdentityState[IdentityState["PinViolation"] = 2] = "PinViolation";
223
+ /**
224
+ * The user's identity has changed, and before that it was verified. This
225
+ * is a serious problem. The user can either verify again to make this
226
+ * identity verified, or withdraw verification
227
+ * [`UserIdentity::withdraw_verification`] to make it pinned.
228
+ */
229
+ IdentityState[IdentityState["VerificationViolation"] = 3] = "VerificationViolation";
230
+ })(IdentityState || (IdentityState = {}));
231
+ var FfiConverterTypeIdentityState = function () {
232
+ var ordinalConverter = FfiConverterInt32;
233
+ var FFIConverter = /*#__PURE__*/function (_AbstractFfiConverter3) {
234
+ function FFIConverter() {
235
+ _classCallCheck(this, FFIConverter);
236
+ return _callSuper(this, FFIConverter, arguments);
237
+ }
238
+ _inherits(FFIConverter, _AbstractFfiConverter3);
239
+ return _createClass(FFIConverter, [{
240
+ key: "read",
241
+ value: function read(from) {
242
+ switch (ordinalConverter.read(from)) {
243
+ case 1:
244
+ return IdentityState.Verified;
245
+ case 2:
246
+ return IdentityState.Pinned;
247
+ case 3:
248
+ return IdentityState.PinViolation;
249
+ case 4:
250
+ return IdentityState.VerificationViolation;
251
+ default:
252
+ throw new UniffiInternalError.UnexpectedEnumCase();
253
+ }
254
+ }
255
+ }, {
256
+ key: "write",
257
+ value: function write(value, into) {
258
+ switch (value) {
259
+ case IdentityState.Verified:
260
+ return ordinalConverter.write(1, into);
261
+ case IdentityState.Pinned:
262
+ return ordinalConverter.write(2, into);
263
+ case IdentityState.PinViolation:
264
+ return ordinalConverter.write(3, into);
265
+ case IdentityState.VerificationViolation:
266
+ return ordinalConverter.write(4, into);
267
+ }
268
+ }
269
+ }, {
270
+ key: "allocationSize",
271
+ value: function allocationSize(value) {
272
+ return ordinalConverter.allocationSize(0);
273
+ }
274
+ }]);
275
+ }(AbstractFfiConverterByteArray);
276
+ return new FFIConverter();
277
+ }();
278
+ /**
279
+ * The local trust state of a device.
280
+ */
281
+ export var LocalTrust;
282
+ (function (LocalTrust) {
283
+ /**
284
+ * The device has been verified and is trusted.
285
+ */
286
+ LocalTrust[LocalTrust["Verified"] = 0] = "Verified";
287
+ /**
288
+ * The device been blacklisted from communicating.
289
+ */
290
+ LocalTrust[LocalTrust["BlackListed"] = 1] = "BlackListed";
291
+ /**
292
+ * The trust state of the device is being ignored.
293
+ */
294
+ LocalTrust[LocalTrust["Ignored"] = 2] = "Ignored";
295
+ /**
296
+ * The trust state is unset.
297
+ */
298
+ LocalTrust[LocalTrust["Unset"] = 3] = "Unset";
299
+ })(LocalTrust || (LocalTrust = {}));
300
+ var FfiConverterTypeLocalTrust = function () {
301
+ var ordinalConverter = FfiConverterInt32;
302
+ var FFIConverter = /*#__PURE__*/function (_AbstractFfiConverter4) {
303
+ function FFIConverter() {
304
+ _classCallCheck(this, FFIConverter);
305
+ return _callSuper(this, FFIConverter, arguments);
306
+ }
307
+ _inherits(FFIConverter, _AbstractFfiConverter4);
308
+ return _createClass(FFIConverter, [{
309
+ key: "read",
310
+ value: function read(from) {
311
+ switch (ordinalConverter.read(from)) {
312
+ case 1:
313
+ return LocalTrust.Verified;
314
+ case 2:
315
+ return LocalTrust.BlackListed;
316
+ case 3:
317
+ return LocalTrust.Ignored;
318
+ case 4:
319
+ return LocalTrust.Unset;
320
+ default:
321
+ throw new UniffiInternalError.UnexpectedEnumCase();
322
+ }
323
+ }
324
+ }, {
325
+ key: "write",
326
+ value: function write(value, into) {
327
+ switch (value) {
328
+ case LocalTrust.Verified:
329
+ return ordinalConverter.write(1, into);
330
+ case LocalTrust.BlackListed:
331
+ return ordinalConverter.write(2, into);
332
+ case LocalTrust.Ignored:
333
+ return ordinalConverter.write(3, into);
334
+ case LocalTrust.Unset:
335
+ return ordinalConverter.write(4, into);
336
+ }
337
+ }
338
+ }, {
339
+ key: "allocationSize",
340
+ value: function allocationSize(value) {
341
+ return ordinalConverter.allocationSize(0);
342
+ }
343
+ }]);
344
+ }(AbstractFfiConverterByteArray);
345
+ return new FFIConverter();
346
+ }();
347
+ // Flat error type: LoginQrCodeDecodeError
348
+ export var LoginQrCodeDecodeError_Tags;
349
+ (function (LoginQrCodeDecodeError_Tags) {
350
+ LoginQrCodeDecodeError_Tags["NotEnoughData"] = "NotEnoughData";
351
+ LoginQrCodeDecodeError_Tags["NotUtf8"] = "NotUtf8";
352
+ LoginQrCodeDecodeError_Tags["UrlParse"] = "UrlParse";
353
+ LoginQrCodeDecodeError_Tags["InvalidMode"] = "InvalidMode";
354
+ LoginQrCodeDecodeError_Tags["InvalidVersion"] = "InvalidVersion";
355
+ LoginQrCodeDecodeError_Tags["Base64"] = "Base64";
356
+ LoginQrCodeDecodeError_Tags["InvalidPrefix"] = "InvalidPrefix";
357
+ })(LoginQrCodeDecodeError_Tags || (LoginQrCodeDecodeError_Tags = {}));
358
+ /**
359
+ * Error type for the decoding of the [`QrCodeData`].
360
+ */
361
+ export var LoginQrCodeDecodeError = function () {
362
+ /**
363
+ * The QR code data is no long enough, it's missing some fields.
364
+ */
365
+ var NotEnoughData = /*#__PURE__*/function (_UniffiError) {
366
+ function NotEnoughData(message) {
367
+ var _this;
368
+ _classCallCheck(this, NotEnoughData);
369
+ _this = _callSuper(this, NotEnoughData, ["LoginQrCodeDecodeError", "NotEnoughData", message]);
370
+ /**
371
+ * @private
372
+ * This field is private and should not be used.
373
+ */
374
+ _defineProperty(_this, uniffiTypeNameSymbol, "LoginQrCodeDecodeError");
375
+ /**
376
+ * @private
377
+ * This field is private and should not be used.
378
+ */
379
+ _defineProperty(_this, variantOrdinalSymbol, 1);
380
+ _defineProperty(_this, "tag", LoginQrCodeDecodeError_Tags.NotEnoughData);
381
+ return _this;
382
+ }
383
+ _inherits(NotEnoughData, _UniffiError);
384
+ return _createClass(NotEnoughData, null, [{
385
+ key: "instanceOf",
386
+ value: function instanceOf(e) {
387
+ return _instanceOf(e) && e[variantOrdinalSymbol] === 1;
388
+ }
389
+ }]);
390
+ }(UniffiError);
391
+ /**
392
+ * One of the URLs in the QR code data is not a valid UTF-8 encoded string.
393
+ */
394
+ var NotUtf8 = /*#__PURE__*/function (_UniffiError2) {
395
+ function NotUtf8(message) {
396
+ var _this2;
397
+ _classCallCheck(this, NotUtf8);
398
+ _this2 = _callSuper(this, NotUtf8, ["LoginQrCodeDecodeError", "NotUtf8", message]);
399
+ /**
400
+ * @private
401
+ * This field is private and should not be used.
402
+ */
403
+ _defineProperty(_this2, uniffiTypeNameSymbol, "LoginQrCodeDecodeError");
404
+ /**
405
+ * @private
406
+ * This field is private and should not be used.
407
+ */
408
+ _defineProperty(_this2, variantOrdinalSymbol, 2);
409
+ _defineProperty(_this2, "tag", LoginQrCodeDecodeError_Tags.NotUtf8);
410
+ return _this2;
411
+ }
412
+ _inherits(NotUtf8, _UniffiError2);
413
+ return _createClass(NotUtf8, null, [{
414
+ key: "instanceOf",
415
+ value: function instanceOf(e) {
416
+ return _instanceOf(e) && e[variantOrdinalSymbol] === 2;
417
+ }
418
+ }]);
419
+ }(UniffiError);
420
+ /**
421
+ * One of the URLs in the QR code data could not be parsed.
422
+ */
423
+ var UrlParse = /*#__PURE__*/function (_UniffiError3) {
424
+ function UrlParse(message) {
425
+ var _this3;
426
+ _classCallCheck(this, UrlParse);
427
+ _this3 = _callSuper(this, UrlParse, ["LoginQrCodeDecodeError", "UrlParse", message]);
428
+ /**
429
+ * @private
430
+ * This field is private and should not be used.
431
+ */
432
+ _defineProperty(_this3, uniffiTypeNameSymbol, "LoginQrCodeDecodeError");
433
+ /**
434
+ * @private
435
+ * This field is private and should not be used.
436
+ */
437
+ _defineProperty(_this3, variantOrdinalSymbol, 3);
438
+ _defineProperty(_this3, "tag", LoginQrCodeDecodeError_Tags.UrlParse);
439
+ return _this3;
440
+ }
441
+ _inherits(UrlParse, _UniffiError3);
442
+ return _createClass(UrlParse, null, [{
443
+ key: "instanceOf",
444
+ value: function instanceOf(e) {
445
+ return _instanceOf(e) && e[variantOrdinalSymbol] === 3;
446
+ }
447
+ }]);
448
+ }(UniffiError);
449
+ /**
450
+ * The QR code data contains an invalid mode, we expect the login (0x03)
451
+ * mode or the reciprocate mode (0x04).
452
+ */
453
+ var InvalidMode = /*#__PURE__*/function (_UniffiError4) {
454
+ function InvalidMode(message) {
455
+ var _this4;
456
+ _classCallCheck(this, InvalidMode);
457
+ _this4 = _callSuper(this, InvalidMode, ["LoginQrCodeDecodeError", "InvalidMode", message]);
458
+ /**
459
+ * @private
460
+ * This field is private and should not be used.
461
+ */
462
+ _defineProperty(_this4, uniffiTypeNameSymbol, "LoginQrCodeDecodeError");
463
+ /**
464
+ * @private
465
+ * This field is private and should not be used.
466
+ */
467
+ _defineProperty(_this4, variantOrdinalSymbol, 4);
468
+ _defineProperty(_this4, "tag", LoginQrCodeDecodeError_Tags.InvalidMode);
469
+ return _this4;
470
+ }
471
+ _inherits(InvalidMode, _UniffiError4);
472
+ return _createClass(InvalidMode, null, [{
473
+ key: "instanceOf",
474
+ value: function instanceOf(e) {
475
+ return _instanceOf(e) && e[variantOrdinalSymbol] === 4;
476
+ }
477
+ }]);
478
+ }(UniffiError);
479
+ /**
480
+ * The QR code data contains an unsupported version.
481
+ */
482
+ var InvalidVersion = /*#__PURE__*/function (_UniffiError5) {
483
+ function InvalidVersion(message) {
484
+ var _this5;
485
+ _classCallCheck(this, InvalidVersion);
486
+ _this5 = _callSuper(this, InvalidVersion, ["LoginQrCodeDecodeError", "InvalidVersion", message]);
487
+ /**
488
+ * @private
489
+ * This field is private and should not be used.
490
+ */
491
+ _defineProperty(_this5, uniffiTypeNameSymbol, "LoginQrCodeDecodeError");
492
+ /**
493
+ * @private
494
+ * This field is private and should not be used.
495
+ */
496
+ _defineProperty(_this5, variantOrdinalSymbol, 5);
497
+ _defineProperty(_this5, "tag", LoginQrCodeDecodeError_Tags.InvalidVersion);
498
+ return _this5;
499
+ }
500
+ _inherits(InvalidVersion, _UniffiError5);
501
+ return _createClass(InvalidVersion, null, [{
502
+ key: "instanceOf",
503
+ value: function instanceOf(e) {
504
+ return _instanceOf(e) && e[variantOrdinalSymbol] === 5;
505
+ }
506
+ }]);
507
+ }(UniffiError);
508
+ /**
509
+ * The base64 encoded variant of the QR code data is not a valid base64
510
+ * string.
511
+ */
512
+ var Base64 = /*#__PURE__*/function (_UniffiError6) {
513
+ function Base64(message) {
514
+ var _this6;
515
+ _classCallCheck(this, Base64);
516
+ _this6 = _callSuper(this, Base64, ["LoginQrCodeDecodeError", "Base64", message]);
517
+ /**
518
+ * @private
519
+ * This field is private and should not be used.
520
+ */
521
+ _defineProperty(_this6, uniffiTypeNameSymbol, "LoginQrCodeDecodeError");
522
+ /**
523
+ * @private
524
+ * This field is private and should not be used.
525
+ */
526
+ _defineProperty(_this6, variantOrdinalSymbol, 6);
527
+ _defineProperty(_this6, "tag", LoginQrCodeDecodeError_Tags.Base64);
528
+ return _this6;
529
+ }
530
+ _inherits(Base64, _UniffiError6);
531
+ return _createClass(Base64, null, [{
532
+ key: "instanceOf",
533
+ value: function instanceOf(e) {
534
+ return _instanceOf(e) && e[variantOrdinalSymbol] === 6;
535
+ }
536
+ }]);
537
+ }(UniffiError);
538
+ /**
539
+ * The QR code data doesn't contain the expected `MATRIX` prefix.
540
+ */
541
+ var InvalidPrefix = /*#__PURE__*/function (_UniffiError7) {
542
+ function InvalidPrefix(message) {
543
+ var _this7;
544
+ _classCallCheck(this, InvalidPrefix);
545
+ _this7 = _callSuper(this, InvalidPrefix, ["LoginQrCodeDecodeError", "InvalidPrefix", message]);
546
+ /**
547
+ * @private
548
+ * This field is private and should not be used.
549
+ */
550
+ _defineProperty(_this7, uniffiTypeNameSymbol, "LoginQrCodeDecodeError");
551
+ /**
552
+ * @private
553
+ * This field is private and should not be used.
554
+ */
555
+ _defineProperty(_this7, variantOrdinalSymbol, 7);
556
+ _defineProperty(_this7, "tag", LoginQrCodeDecodeError_Tags.InvalidPrefix);
557
+ return _this7;
558
+ }
559
+ _inherits(InvalidPrefix, _UniffiError7);
560
+ return _createClass(InvalidPrefix, null, [{
561
+ key: "instanceOf",
562
+ value: function instanceOf(e) {
563
+ return _instanceOf(e) && e[variantOrdinalSymbol] === 7;
564
+ }
565
+ }]);
566
+ }(UniffiError); // Utility function which does not rely on instanceof.
567
+ function _instanceOf(e) {
568
+ return e[uniffiTypeNameSymbol] === "LoginQrCodeDecodeError";
569
+ }
570
+ return {
571
+ NotEnoughData: NotEnoughData,
572
+ NotUtf8: NotUtf8,
573
+ UrlParse: UrlParse,
574
+ InvalidMode: InvalidMode,
575
+ InvalidVersion: InvalidVersion,
576
+ Base64: Base64,
577
+ InvalidPrefix: InvalidPrefix,
578
+ instanceOf: _instanceOf
579
+ };
580
+ }();
581
+ var FfiConverterTypeLoginQrCodeDecodeError = function () {
582
+ var intConverter = FfiConverterInt32;
583
+ var FfiConverter = /*#__PURE__*/function (_AbstractFfiConverter5) {
584
+ function FfiConverter() {
585
+ _classCallCheck(this, FfiConverter);
586
+ return _callSuper(this, FfiConverter, arguments);
587
+ }
588
+ _inherits(FfiConverter, _AbstractFfiConverter5);
589
+ return _createClass(FfiConverter, [{
590
+ key: "read",
591
+ value: function read(from) {
592
+ switch (intConverter.read(from)) {
593
+ case 1:
594
+ return new LoginQrCodeDecodeError.NotEnoughData(FfiConverterString.read(from));
595
+ case 2:
596
+ return new LoginQrCodeDecodeError.NotUtf8(FfiConverterString.read(from));
597
+ case 3:
598
+ return new LoginQrCodeDecodeError.UrlParse(FfiConverterString.read(from));
599
+ case 4:
600
+ return new LoginQrCodeDecodeError.InvalidMode(FfiConverterString.read(from));
601
+ case 5:
602
+ return new LoginQrCodeDecodeError.InvalidVersion(FfiConverterString.read(from));
603
+ case 6:
604
+ return new LoginQrCodeDecodeError.Base64(FfiConverterString.read(from));
605
+ case 7:
606
+ return new LoginQrCodeDecodeError.InvalidPrefix(FfiConverterString.read(from));
607
+ default:
608
+ throw new UniffiInternalError.UnexpectedEnumCase();
609
+ }
610
+ }
611
+ }, {
612
+ key: "write",
613
+ value: function write(value, into) {
614
+ var obj = value;
615
+ var index = obj[variantOrdinalSymbol];
616
+ intConverter.write(index, into);
617
+ }
618
+ }, {
619
+ key: "allocationSize",
620
+ value: function allocationSize(value) {
621
+ return intConverter.allocationSize(0);
622
+ }
623
+ }]);
624
+ }(AbstractFfiConverterByteArray);
625
+ return new FfiConverter();
626
+ }();
627
+ /**
628
+ * The result of a signature check.
629
+ */
630
+ export var SignatureState;
631
+ (function (SignatureState) {
632
+ /**
633
+ * The signature is missing.
634
+ */
635
+ SignatureState[SignatureState["Missing"] = 0] = "Missing";
636
+ /**
637
+ * The signature is invalid.
638
+ */
639
+ SignatureState[SignatureState["Invalid"] = 1] = "Invalid";
640
+ /**
641
+ * The signature is valid but the device or user identity that created the
642
+ * signature is not trusted.
643
+ */
644
+ SignatureState[SignatureState["ValidButNotTrusted"] = 2] = "ValidButNotTrusted";
645
+ /**
646
+ * The signature is valid and the device or user identity that created the
647
+ * signature is trusted.
648
+ */
649
+ SignatureState[SignatureState["ValidAndTrusted"] = 3] = "ValidAndTrusted";
650
+ })(SignatureState || (SignatureState = {}));
651
+ var FfiConverterTypeSignatureState = function () {
652
+ var ordinalConverter = FfiConverterInt32;
653
+ var FFIConverter = /*#__PURE__*/function (_AbstractFfiConverter6) {
654
+ function FFIConverter() {
655
+ _classCallCheck(this, FFIConverter);
656
+ return _callSuper(this, FFIConverter, arguments);
657
+ }
658
+ _inherits(FFIConverter, _AbstractFfiConverter6);
659
+ return _createClass(FFIConverter, [{
660
+ key: "read",
661
+ value: function read(from) {
662
+ switch (ordinalConverter.read(from)) {
663
+ case 1:
664
+ return SignatureState.Missing;
665
+ case 2:
666
+ return SignatureState.Invalid;
667
+ case 3:
668
+ return SignatureState.ValidButNotTrusted;
669
+ case 4:
670
+ return SignatureState.ValidAndTrusted;
671
+ default:
672
+ throw new UniffiInternalError.UnexpectedEnumCase();
673
+ }
674
+ }
675
+ }, {
676
+ key: "write",
677
+ value: function write(value, into) {
678
+ switch (value) {
679
+ case SignatureState.Missing:
680
+ return ordinalConverter.write(1, into);
681
+ case SignatureState.Invalid:
682
+ return ordinalConverter.write(2, into);
683
+ case SignatureState.ValidButNotTrusted:
684
+ return ordinalConverter.write(3, into);
685
+ case SignatureState.ValidAndTrusted:
686
+ return ordinalConverter.write(4, into);
687
+ }
688
+ }
689
+ }, {
690
+ key: "allocationSize",
691
+ value: function allocationSize(value) {
692
+ return ordinalConverter.allocationSize(0);
693
+ }
694
+ }]);
695
+ }(AbstractFfiConverterByteArray);
696
+ return new FFIConverter();
697
+ }();
698
+ /**
699
+ * The trust level in the sender's device that is required to decrypt an
700
+ * event.
701
+ */
702
+ export var TrustRequirement;
703
+ (function (TrustRequirement) {
704
+ /**
705
+ * Decrypt events from everyone regardless of trust.
706
+ */
707
+ TrustRequirement[TrustRequirement["Untrusted"] = 0] = "Untrusted";
708
+ /**
709
+ * Only decrypt events from cross-signed devices or legacy sessions (Megolm
710
+ * sessions created before we started collecting trust information).
711
+ */
712
+ TrustRequirement[TrustRequirement["CrossSignedOrLegacy"] = 1] = "CrossSignedOrLegacy";
713
+ /**
714
+ * Only decrypt events from cross-signed devices.
715
+ */
716
+ TrustRequirement[TrustRequirement["CrossSigned"] = 2] = "CrossSigned";
717
+ })(TrustRequirement || (TrustRequirement = {}));
718
+ var FfiConverterTypeTrustRequirement = function () {
719
+ var ordinalConverter = FfiConverterInt32;
720
+ var FFIConverter = /*#__PURE__*/function (_AbstractFfiConverter7) {
721
+ function FFIConverter() {
722
+ _classCallCheck(this, FFIConverter);
723
+ return _callSuper(this, FFIConverter, arguments);
724
+ }
725
+ _inherits(FFIConverter, _AbstractFfiConverter7);
726
+ return _createClass(FFIConverter, [{
727
+ key: "read",
728
+ value: function read(from) {
729
+ switch (ordinalConverter.read(from)) {
730
+ case 1:
731
+ return TrustRequirement.Untrusted;
732
+ case 2:
733
+ return TrustRequirement.CrossSignedOrLegacy;
734
+ case 3:
735
+ return TrustRequirement.CrossSigned;
736
+ default:
737
+ throw new UniffiInternalError.UnexpectedEnumCase();
738
+ }
739
+ }
740
+ }, {
741
+ key: "write",
742
+ value: function write(value, into) {
743
+ switch (value) {
744
+ case TrustRequirement.Untrusted:
745
+ return ordinalConverter.write(1, into);
746
+ case TrustRequirement.CrossSignedOrLegacy:
747
+ return ordinalConverter.write(2, into);
748
+ case TrustRequirement.CrossSigned:
749
+ return ordinalConverter.write(3, into);
750
+ }
751
+ }
752
+ }, {
753
+ key: "allocationSize",
754
+ value: function allocationSize(value) {
755
+ return ordinalConverter.allocationSize(0);
756
+ }
757
+ }]);
758
+ }(AbstractFfiConverterByteArray);
759
+ return new FFIConverter();
760
+ }();
761
+ /**
762
+ * Our best guess at the reason why an event can't be decrypted.
763
+ */
764
+ export var UtdCause;
765
+ (function (UtdCause) {
766
+ /**
767
+ * We don't have an explanation for why this UTD happened - it is probably
768
+ * a bug, or a network split between the two homeservers.
769
+ *
770
+ * For example:
771
+ *
772
+ * - the keys for this event are missing, but a key storage backup exists
773
+ * and is working, so we should be able to find the keys in the backup.
774
+ *
775
+ * - the keys for this event are missing, and a key storage backup exists
776
+ * on the server, but that backup is not working on this client even
777
+ * though this device is verified.
778
+ */
779
+ UtdCause[UtdCause["Unknown"] = 0] = "Unknown";
780
+ /**
781
+ * We are missing the keys for this event, and the event was sent when we
782
+ * were not a member of the room (or invited).
783
+ */
784
+ UtdCause[UtdCause["SentBeforeWeJoined"] = 1] = "SentBeforeWeJoined";
785
+ /**
786
+ * The message was sent by a user identity we have not verified, but the
787
+ * user was previously verified.
788
+ */
789
+ UtdCause[UtdCause["VerificationViolation"] = 2] = "VerificationViolation";
790
+ /**
791
+ * The [`crate::TrustRequirement`] requires that the sending device be
792
+ * signed by its owner, and it was not.
793
+ */
794
+ UtdCause[UtdCause["UnsignedDevice"] = 3] = "UnsignedDevice";
795
+ /**
796
+ * The [`crate::TrustRequirement`] requires that the sending device be
797
+ * signed by its owner, and we were unable to securely find the device.
798
+ *
799
+ * This could be because the device has since been deleted, because we
800
+ * haven't yet downloaded it from the server, or because the session
801
+ * data was obtained from an insecure source (imported from a file,
802
+ * obtained from a legacy (asymmetric) backup, unsafe key forward, etc.)
803
+ */
804
+ UtdCause[UtdCause["UnknownDevice"] = 4] = "UnknownDevice";
805
+ /**
806
+ * We are missing the keys for this event, but it is a "device-historical"
807
+ * message and there is no key storage backup on the server, presumably
808
+ * because the user has turned it off.
809
+ *
810
+ * Device-historical means that the message was sent before the current
811
+ * device existed (but the current user was probably a member of the room
812
+ * at the time the message was sent). Not to
813
+ * be confused with pre-join or pre-invite messages (see
814
+ * [`UtdCause::SentBeforeWeJoined`] for that).
815
+ *
816
+ * Expected message to user: "History is not available on this device".
817
+ */
818
+ UtdCause[UtdCause["HistoricalMessageAndBackupIsDisabled"] = 5] = "HistoricalMessageAndBackupIsDisabled";
819
+ /**
820
+ * The keys for this event are intentionally withheld.
821
+ *
822
+ * The sender has refused to share the key because our device does not meet
823
+ * the sender's security requirements.
824
+ */
825
+ UtdCause[UtdCause["WithheldForUnverifiedOrInsecureDevice"] = 6] = "WithheldForUnverifiedOrInsecureDevice";
826
+ /**
827
+ * The keys for this event are missing, likely because the sender was
828
+ * unable to share them (e.g., failure to establish an Olm 1:1
829
+ * channel). Alternatively, the sender may have deliberately excluded
830
+ * this device by cherry-picking and blocking it, in which case, no action
831
+ * can be taken on our side.
832
+ */
833
+ UtdCause[UtdCause["WithheldBySender"] = 7] = "WithheldBySender";
834
+ /**
835
+ * We are missing the keys for this event, but it is a "device-historical"
836
+ * message, and even though a key storage backup does exist, we can't use
837
+ * it because our device is unverified.
838
+ *
839
+ * Device-historical means that the message was sent before the current
840
+ * device existed (but the current user was probably a member of the room
841
+ * at the time the message was sent). Not to
842
+ * be confused with pre-join or pre-invite messages (see
843
+ * [`UtdCause::SentBeforeWeJoined`] for that).
844
+ *
845
+ * Expected message to user: "You need to verify this device".
846
+ */
847
+ UtdCause[UtdCause["HistoricalMessageAndDeviceIsUnverified"] = 8] = "HistoricalMessageAndDeviceIsUnverified";
848
+ })(UtdCause || (UtdCause = {}));
849
+ var FfiConverterTypeUtdCause = function () {
850
+ var ordinalConverter = FfiConverterInt32;
851
+ var FFIConverter = /*#__PURE__*/function (_AbstractFfiConverter8) {
852
+ function FFIConverter() {
853
+ _classCallCheck(this, FFIConverter);
854
+ return _callSuper(this, FFIConverter, arguments);
855
+ }
856
+ _inherits(FFIConverter, _AbstractFfiConverter8);
857
+ return _createClass(FFIConverter, [{
858
+ key: "read",
859
+ value: function read(from) {
860
+ switch (ordinalConverter.read(from)) {
861
+ case 1:
862
+ return UtdCause.Unknown;
863
+ case 2:
864
+ return UtdCause.SentBeforeWeJoined;
865
+ case 3:
866
+ return UtdCause.VerificationViolation;
867
+ case 4:
868
+ return UtdCause.UnsignedDevice;
869
+ case 5:
870
+ return UtdCause.UnknownDevice;
871
+ case 6:
872
+ return UtdCause.HistoricalMessageAndBackupIsDisabled;
873
+ case 7:
874
+ return UtdCause.WithheldForUnverifiedOrInsecureDevice;
875
+ case 8:
876
+ return UtdCause.WithheldBySender;
877
+ case 9:
878
+ return UtdCause.HistoricalMessageAndDeviceIsUnverified;
879
+ default:
880
+ throw new UniffiInternalError.UnexpectedEnumCase();
881
+ }
882
+ }
883
+ }, {
884
+ key: "write",
885
+ value: function write(value, into) {
886
+ switch (value) {
887
+ case UtdCause.Unknown:
888
+ return ordinalConverter.write(1, into);
889
+ case UtdCause.SentBeforeWeJoined:
890
+ return ordinalConverter.write(2, into);
891
+ case UtdCause.VerificationViolation:
892
+ return ordinalConverter.write(3, into);
893
+ case UtdCause.UnsignedDevice:
894
+ return ordinalConverter.write(4, into);
895
+ case UtdCause.UnknownDevice:
896
+ return ordinalConverter.write(5, into);
897
+ case UtdCause.HistoricalMessageAndBackupIsDisabled:
898
+ return ordinalConverter.write(6, into);
899
+ case UtdCause.WithheldForUnverifiedOrInsecureDevice:
900
+ return ordinalConverter.write(7, into);
901
+ case UtdCause.WithheldBySender:
902
+ return ordinalConverter.write(8, into);
903
+ case UtdCause.HistoricalMessageAndDeviceIsUnverified:
904
+ return ordinalConverter.write(9, into);
905
+ }
906
+ }
907
+ }, {
908
+ key: "allocationSize",
909
+ value: function allocationSize(value) {
910
+ return ordinalConverter.allocationSize(0);
911
+ }
912
+ }]);
913
+ }(AbstractFfiConverterByteArray);
914
+ return new FFIConverter();
915
+ }();
916
+ /**
917
+ * This should be called before anything else.
918
+ *
919
+ * It is likely that this is being done for you by the library's `index.ts`.
920
+ *
921
+ * It checks versions of uniffi between when the Rust scaffolding was generated
922
+ * and when the bindings were generated.
923
+ *
924
+ * It also initializes the machinery to enable Rust to talk back to Javascript.
925
+ */
926
+ function uniffiEnsureInitialized() {
927
+ // Get the bindings contract version from our ComponentInterface
928
+ var bindingsContractVersion = 29;
929
+ // Get the scaffolding contract version by calling the into the dylib
930
+ var scaffoldingContractVersion = nativeModule().ubrn_ffi_matrix_sdk_crypto_uniffi_contract_version();
931
+ if (bindingsContractVersion !== scaffoldingContractVersion) {
932
+ throw new UniffiInternalError.ContractVersionMismatch(scaffoldingContractVersion, bindingsContractVersion);
933
+ }
934
+ }
935
+ export default Object.freeze({
936
+ initialize: uniffiEnsureInitialized,
937
+ converters: {
938
+ FfiConverterTypeCollectStrategy: FfiConverterTypeCollectStrategy,
939
+ FfiConverterTypeDecryptionSettings: FfiConverterTypeDecryptionSettings,
940
+ FfiConverterTypeIdentityState: FfiConverterTypeIdentityState,
941
+ FfiConverterTypeLocalTrust: FfiConverterTypeLocalTrust,
942
+ FfiConverterTypeLoginQrCodeDecodeError: FfiConverterTypeLoginQrCodeDecodeError,
943
+ FfiConverterTypeSignatureState: FfiConverterTypeSignatureState,
944
+ FfiConverterTypeTrustRequirement: FfiConverterTypeTrustRequirement,
945
+ FfiConverterTypeUtdCause: FfiConverterTypeUtdCause
946
+ }
947
+ });