ffi-bindings 1.0.0 → 1.0.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.
- package/package.json +23 -4
- package/src/generated/matrix_sdk.ts +1843 -0
- package/src/generated/matrix_sdk_base.ts +252 -0
- package/src/generated/matrix_sdk_common.ts +370 -0
- package/src/generated/matrix_sdk_crypto.ts +1280 -0
- package/src/generated/matrix_sdk_ffi.ts +65263 -0
- package/src/generated/matrix_sdk_ui.ts +816 -0
- package/src/generated/wasm-bindgen/index.d.ts +5455 -0
- package/src/generated/wasm-bindgen/index.js +14223 -0
- package/src/generated/wasm-bindgen/index_bg.wasm +0 -0
- package/src/generated/wasm-bindgen/index_bg.wasm.d.ts +2840 -0
- package/src/generated-compat/matrix_sdk.js +454 -395
- package/src/generated-compat/matrix_sdk_base.js +39 -34
- package/src/generated-compat/matrix_sdk_common.js +245 -35
- package/src/generated-compat/matrix_sdk_crypto.js +547 -128
- package/src/generated-compat/matrix_sdk_ffi.js +3057 -2696
- package/src/generated-compat/matrix_sdk_ui.js +580 -46
- package/src/generated-compat/wasm-bindgen/index.d.js +66 -0
- package/src/generated-compat/wasm-bindgen/index.d.ts +5455 -0
- package/src/generated-compat/wasm-bindgen/index.js +10572 -8359
- package/src/generated-compat/wasm-bindgen/index_bg.wasm +0 -0
- package/src/generated-compat/wasm-bindgen/index_bg.wasm.d.ts +2840 -0
- package/src/index.web.js +126 -34
- package/src/index.web.js.bak +132 -0
- package/src/index.web.ts +46 -0
- package/src/index.web.ts.bak +46 -0
|
@@ -0,0 +1,1280 @@
|
|
|
1
|
+
// This file was autogenerated by some hot garbage in the `uniffi-bindgen-react-native` crate.
|
|
2
|
+
// Trust me, you don't want to mess with it!
|
|
3
|
+
|
|
4
|
+
/* tslint:disable */
|
|
5
|
+
/* eslint-disable */
|
|
6
|
+
// @ts-nocheck
|
|
7
|
+
import * as wasmBundle from "./wasm-bindgen/index.js";
|
|
8
|
+
import {
|
|
9
|
+
type FfiConverter,
|
|
10
|
+
type UniffiByteArray,
|
|
11
|
+
type UniffiGcObject,
|
|
12
|
+
type UniffiHandle,
|
|
13
|
+
type UniffiObjectFactory,
|
|
14
|
+
AbstractFfiConverterByteArray,
|
|
15
|
+
FfiConverterInt32,
|
|
16
|
+
FfiConverterObject,
|
|
17
|
+
FfiConverterUInt64,
|
|
18
|
+
RustBuffer,
|
|
19
|
+
UniffiAbstractObject,
|
|
20
|
+
UniffiError,
|
|
21
|
+
UniffiInternalError,
|
|
22
|
+
UniffiRustCaller,
|
|
23
|
+
destructorGuardSymbol,
|
|
24
|
+
pointerLiteralSymbol,
|
|
25
|
+
uniffiCreateFfiConverterString,
|
|
26
|
+
uniffiCreateRecord,
|
|
27
|
+
uniffiTypeNameSymbol,
|
|
28
|
+
variantOrdinalSymbol } from "uniffi-bindgen-react-native";
|
|
29
|
+
|
|
30
|
+
// Get converters from the other files, if any.
|
|
31
|
+
const nativeModule = () => wasmBundle;
|
|
32
|
+
const uniffiCaller = new UniffiRustCaller(() => new wasmBundle.RustCallStatus());
|
|
33
|
+
|
|
34
|
+
const uniffiIsDebug =
|
|
35
|
+
// @ts-ignore -- The process global might not be defined
|
|
36
|
+
typeof process !== "object" ||
|
|
37
|
+
// @ts-ignore -- The process global might not be defined
|
|
38
|
+
process?.env?.NODE_ENV !== "production" ||
|
|
39
|
+
false;
|
|
40
|
+
// Public interface members begin here.
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Settings for decrypting messages
|
|
48
|
+
*/
|
|
49
|
+
export type DecryptionSettings = {
|
|
50
|
+
/**
|
|
51
|
+
* The trust level in the sender's device that is required to decrypt the
|
|
52
|
+
* event. If the sender's device is not sufficiently trusted,
|
|
53
|
+
* [`MegolmError::SenderIdentityNotTrusted`] will be returned.
|
|
54
|
+
*/
|
|
55
|
+
senderDeviceTrustRequirement: TrustRequirement
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Generated factory for {@link DecryptionSettings} record objects.
|
|
60
|
+
*/
|
|
61
|
+
export const DecryptionSettings = (() => {
|
|
62
|
+
const defaults = () => ({
|
|
63
|
+
});
|
|
64
|
+
const create = (() => {
|
|
65
|
+
return uniffiCreateRecord<DecryptionSettings, ReturnType<typeof defaults>>(defaults);
|
|
66
|
+
})();
|
|
67
|
+
return Object.freeze({
|
|
68
|
+
create,
|
|
69
|
+
new: create,
|
|
70
|
+
defaults: () => Object.freeze(defaults()) as Partial<DecryptionSettings>,
|
|
71
|
+
|
|
72
|
+
});
|
|
73
|
+
})();
|
|
74
|
+
|
|
75
|
+
const FfiConverterTypeDecryptionSettings = (() => {
|
|
76
|
+
type TypeName = DecryptionSettings;
|
|
77
|
+
class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
|
|
78
|
+
read(from: RustBuffer): TypeName {
|
|
79
|
+
return {
|
|
80
|
+
senderDeviceTrustRequirement: FfiConverterTypeTrustRequirement.read(from)
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
write(value: TypeName, into: RustBuffer): void {
|
|
84
|
+
FfiConverterTypeTrustRequirement.write(value.senderDeviceTrustRequirement, into);
|
|
85
|
+
}
|
|
86
|
+
allocationSize(value: TypeName): number {
|
|
87
|
+
return FfiConverterTypeTrustRequirement.allocationSize(value.senderDeviceTrustRequirement);
|
|
88
|
+
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
return new FFIConverter();
|
|
92
|
+
})();
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
const stringConverter = (() => {
|
|
96
|
+
const encoder = new TextEncoder();
|
|
97
|
+
const decoder = new TextDecoder();
|
|
98
|
+
return {
|
|
99
|
+
stringToBytes: (s: string) => encoder.encode(s),
|
|
100
|
+
bytesToString: (ab: UniffiByteArray) => decoder.decode(ab),
|
|
101
|
+
stringByteLength: (s: string) => encoder.encode(s).byteLength,
|
|
102
|
+
};
|
|
103
|
+
})();
|
|
104
|
+
const FfiConverterString = uniffiCreateFfiConverterString(stringConverter);
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Strategy to collect the devices that should receive room keys for the
|
|
111
|
+
* current discussion.
|
|
112
|
+
*/
|
|
113
|
+
export enum CollectStrategy {
|
|
114
|
+
/**
|
|
115
|
+
* Share with all (unblacklisted) devices.
|
|
116
|
+
*
|
|
117
|
+
* Not recommended, per the guidance of [MSC4153].
|
|
118
|
+
*
|
|
119
|
+
* (Used by Element X and Element Web in the legacy, non-"exclude insecure
|
|
120
|
+
* devices" mode.)
|
|
121
|
+
*
|
|
122
|
+
* [MSC4153]: https://github.com/matrix-org/matrix-doc/pull/4153
|
|
123
|
+
*/
|
|
124
|
+
AllDevices,
|
|
125
|
+
/**
|
|
126
|
+
* Share with all devices, except errors for *verified* users cause sharing
|
|
127
|
+
* to fail with an error.
|
|
128
|
+
*
|
|
129
|
+
* In this strategy, if a verified user has an unsigned device,
|
|
130
|
+
* key sharing will fail with a
|
|
131
|
+
* [`SessionRecipientCollectionError::VerifiedUserHasUnsignedDevice`].
|
|
132
|
+
* If a verified user has replaced their identity, key
|
|
133
|
+
* sharing will fail with a
|
|
134
|
+
* [`SessionRecipientCollectionError::VerifiedUserChangedIdentity`].
|
|
135
|
+
*
|
|
136
|
+
* Otherwise, keys are shared with unsigned devices as normal.
|
|
137
|
+
*
|
|
138
|
+
* Once the problematic devices are blacklisted or whitelisted the
|
|
139
|
+
* caller can retry to share a second time.
|
|
140
|
+
*
|
|
141
|
+
* Not recommended, per the guidance of [MSC4153].
|
|
142
|
+
*
|
|
143
|
+
* [MSC4153]: https://github.com/matrix-org/matrix-doc/pull/4153
|
|
144
|
+
*/
|
|
145
|
+
ErrorOnVerifiedUserProblem,
|
|
146
|
+
/**
|
|
147
|
+
* Share based on identity. Only distribute to devices signed by their
|
|
148
|
+
* owner. If a user has no published identity he will not receive
|
|
149
|
+
* any room keys.
|
|
150
|
+
*
|
|
151
|
+
* This is the recommended strategy: it is compliant with the guidance of
|
|
152
|
+
* [MSC4153].
|
|
153
|
+
*
|
|
154
|
+
* (Used by Element Web and Element X in the "exclude insecure devices"
|
|
155
|
+
* mode.)
|
|
156
|
+
*
|
|
157
|
+
* [MSC4153]: https://github.com/matrix-org/matrix-doc/pull/4153
|
|
158
|
+
*/
|
|
159
|
+
IdentityBasedStrategy,
|
|
160
|
+
/**
|
|
161
|
+
* Only share keys with devices that we "trust". A device is trusted if any
|
|
162
|
+
* of the following is true:
|
|
163
|
+
* - It was manually marked as trusted.
|
|
164
|
+
* - It was marked as verified via interactive verification.
|
|
165
|
+
* - It is signed by its owner identity, and this identity has been
|
|
166
|
+
* trusted via interactive verification.
|
|
167
|
+
* - It is the current own device of the user.
|
|
168
|
+
*
|
|
169
|
+
* This strategy is compliant with [MSC4153], but is probably too strict
|
|
170
|
+
* for normal use.
|
|
171
|
+
*
|
|
172
|
+
* (Used by Element Web when "only send messages to verified users" is
|
|
173
|
+
* enabled.)
|
|
174
|
+
*
|
|
175
|
+
* [MSC4153]: https://github.com/matrix-org/matrix-doc/pull/4153
|
|
176
|
+
*/
|
|
177
|
+
OnlyTrustedDevices
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
const FfiConverterTypeCollectStrategy = (() => {
|
|
181
|
+
const ordinalConverter = FfiConverterInt32;
|
|
182
|
+
type TypeName = CollectStrategy;
|
|
183
|
+
class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
|
|
184
|
+
read(from: RustBuffer): TypeName {
|
|
185
|
+
switch (ordinalConverter.read(from)) {
|
|
186
|
+
case 1: return CollectStrategy.AllDevices;
|
|
187
|
+
case 2: return CollectStrategy.ErrorOnVerifiedUserProblem;
|
|
188
|
+
case 3: return CollectStrategy.IdentityBasedStrategy;
|
|
189
|
+
case 4: return CollectStrategy.OnlyTrustedDevices;
|
|
190
|
+
default: throw new UniffiInternalError.UnexpectedEnumCase();
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
write(value: TypeName, into: RustBuffer): void {
|
|
194
|
+
switch (value) {
|
|
195
|
+
case CollectStrategy.AllDevices: return ordinalConverter.write(1, into);
|
|
196
|
+
case CollectStrategy.ErrorOnVerifiedUserProblem: return ordinalConverter.write(2, into);
|
|
197
|
+
case CollectStrategy.IdentityBasedStrategy: return ordinalConverter.write(3, into);
|
|
198
|
+
case CollectStrategy.OnlyTrustedDevices: return ordinalConverter.write(4, into);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
allocationSize(value: TypeName): number {
|
|
202
|
+
return ordinalConverter.allocationSize(0);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
return new FFIConverter();
|
|
206
|
+
})();
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* The state of an identity - verified, pinned etc.
|
|
214
|
+
*/
|
|
215
|
+
export enum IdentityState {
|
|
216
|
+
/**
|
|
217
|
+
* The user is verified with us
|
|
218
|
+
*/
|
|
219
|
+
Verified,
|
|
220
|
+
/**
|
|
221
|
+
* Either this is the first identity we have seen for this user, or the
|
|
222
|
+
* user has acknowledged a change of identity explicitly e.g. by
|
|
223
|
+
* clicking OK on a notification.
|
|
224
|
+
*/
|
|
225
|
+
Pinned,
|
|
226
|
+
/**
|
|
227
|
+
* The user's identity has changed since it was pinned. The user should be
|
|
228
|
+
* notified about this and given the opportunity to acknowledge the
|
|
229
|
+
* change, which will make the new identity pinned.
|
|
230
|
+
* When the user acknowledges the change, the app should call
|
|
231
|
+
* [`crate::OtherUserIdentity::pin_current_master_key`].
|
|
232
|
+
*/
|
|
233
|
+
PinViolation,
|
|
234
|
+
/**
|
|
235
|
+
* The user's identity has changed, and before that it was verified. This
|
|
236
|
+
* is a serious problem. The user can either verify again to make this
|
|
237
|
+
* identity verified, or withdraw verification
|
|
238
|
+
* [`UserIdentity::withdraw_verification`] to make it pinned.
|
|
239
|
+
*/
|
|
240
|
+
VerificationViolation
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
const FfiConverterTypeIdentityState = (() => {
|
|
244
|
+
const ordinalConverter = FfiConverterInt32;
|
|
245
|
+
type TypeName = IdentityState;
|
|
246
|
+
class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
|
|
247
|
+
read(from: RustBuffer): TypeName {
|
|
248
|
+
switch (ordinalConverter.read(from)) {
|
|
249
|
+
case 1: return IdentityState.Verified;
|
|
250
|
+
case 2: return IdentityState.Pinned;
|
|
251
|
+
case 3: return IdentityState.PinViolation;
|
|
252
|
+
case 4: return IdentityState.VerificationViolation;
|
|
253
|
+
default: throw new UniffiInternalError.UnexpectedEnumCase();
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
write(value: TypeName, into: RustBuffer): void {
|
|
257
|
+
switch (value) {
|
|
258
|
+
case IdentityState.Verified: return ordinalConverter.write(1, into);
|
|
259
|
+
case IdentityState.Pinned: return ordinalConverter.write(2, into);
|
|
260
|
+
case IdentityState.PinViolation: return ordinalConverter.write(3, into);
|
|
261
|
+
case IdentityState.VerificationViolation: return ordinalConverter.write(4, into);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
allocationSize(value: TypeName): number {
|
|
265
|
+
return ordinalConverter.allocationSize(0);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
return new FFIConverter();
|
|
269
|
+
})();
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* The local trust state of a device.
|
|
277
|
+
*/
|
|
278
|
+
export enum LocalTrust {
|
|
279
|
+
/**
|
|
280
|
+
* The device has been verified and is trusted.
|
|
281
|
+
*/
|
|
282
|
+
Verified,
|
|
283
|
+
/**
|
|
284
|
+
* The device been blacklisted from communicating.
|
|
285
|
+
*/
|
|
286
|
+
BlackListed,
|
|
287
|
+
/**
|
|
288
|
+
* The trust state of the device is being ignored.
|
|
289
|
+
*/
|
|
290
|
+
Ignored,
|
|
291
|
+
/**
|
|
292
|
+
* The trust state is unset.
|
|
293
|
+
*/
|
|
294
|
+
Unset
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
const FfiConverterTypeLocalTrust = (() => {
|
|
298
|
+
const ordinalConverter = FfiConverterInt32;
|
|
299
|
+
type TypeName = LocalTrust;
|
|
300
|
+
class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
|
|
301
|
+
read(from: RustBuffer): TypeName {
|
|
302
|
+
switch (ordinalConverter.read(from)) {
|
|
303
|
+
case 1: return LocalTrust.Verified;
|
|
304
|
+
case 2: return LocalTrust.BlackListed;
|
|
305
|
+
case 3: return LocalTrust.Ignored;
|
|
306
|
+
case 4: return LocalTrust.Unset;
|
|
307
|
+
default: throw new UniffiInternalError.UnexpectedEnumCase();
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
write(value: TypeName, into: RustBuffer): void {
|
|
311
|
+
switch (value) {
|
|
312
|
+
case LocalTrust.Verified: return ordinalConverter.write(1, into);
|
|
313
|
+
case LocalTrust.BlackListed: return ordinalConverter.write(2, into);
|
|
314
|
+
case LocalTrust.Ignored: return ordinalConverter.write(3, into);
|
|
315
|
+
case LocalTrust.Unset: return ordinalConverter.write(4, into);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
allocationSize(value: TypeName): number {
|
|
319
|
+
return ordinalConverter.allocationSize(0);
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
return new FFIConverter();
|
|
323
|
+
})();
|
|
324
|
+
|
|
325
|
+
|
|
326
|
+
|
|
327
|
+
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
// Flat error type: LoginQrCodeDecodeError
|
|
331
|
+
export enum LoginQrCodeDecodeError_Tags {
|
|
332
|
+
NotEnoughData = "NotEnoughData",
|
|
333
|
+
NotUtf8 = "NotUtf8",
|
|
334
|
+
UrlParse = "UrlParse",
|
|
335
|
+
InvalidIntent = "InvalidIntent",
|
|
336
|
+
InvalidType = "InvalidType",
|
|
337
|
+
Base64 = "Base64",
|
|
338
|
+
InvalidPrefix = "InvalidPrefix"
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Error type for the decoding of the [`QrCodeData`].
|
|
342
|
+
*/
|
|
343
|
+
export const LoginQrCodeDecodeError = (() => {
|
|
344
|
+
/**
|
|
345
|
+
* The QR code data is no long enough, it's missing some fields.
|
|
346
|
+
*/
|
|
347
|
+
class NotEnoughData extends UniffiError {
|
|
348
|
+
/**
|
|
349
|
+
* @private
|
|
350
|
+
* This field is private and should not be used.
|
|
351
|
+
*/
|
|
352
|
+
readonly [uniffiTypeNameSymbol]: string = "LoginQrCodeDecodeError";
|
|
353
|
+
/**
|
|
354
|
+
* @private
|
|
355
|
+
* This field is private and should not be used.
|
|
356
|
+
*/
|
|
357
|
+
readonly [variantOrdinalSymbol] = 1;
|
|
358
|
+
|
|
359
|
+
readonly tag = LoginQrCodeDecodeError_Tags.NotEnoughData;
|
|
360
|
+
|
|
361
|
+
constructor(message: string) {
|
|
362
|
+
super("LoginQrCodeDecodeError", "NotEnoughData", message);
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
static instanceOf(e: any): e is NotEnoughData {
|
|
366
|
+
return (
|
|
367
|
+
instanceOf(e) && (e as any)[variantOrdinalSymbol] === 1
|
|
368
|
+
);
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* One of the URLs in the QR code data is not a valid UTF-8 encoded string.
|
|
373
|
+
*/
|
|
374
|
+
class NotUtf8 extends UniffiError {
|
|
375
|
+
/**
|
|
376
|
+
* @private
|
|
377
|
+
* This field is private and should not be used.
|
|
378
|
+
*/
|
|
379
|
+
readonly [uniffiTypeNameSymbol]: string = "LoginQrCodeDecodeError";
|
|
380
|
+
/**
|
|
381
|
+
* @private
|
|
382
|
+
* This field is private and should not be used.
|
|
383
|
+
*/
|
|
384
|
+
readonly [variantOrdinalSymbol] = 2;
|
|
385
|
+
|
|
386
|
+
readonly tag = LoginQrCodeDecodeError_Tags.NotUtf8;
|
|
387
|
+
|
|
388
|
+
constructor(message: string) {
|
|
389
|
+
super("LoginQrCodeDecodeError", "NotUtf8", message);
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
static instanceOf(e: any): e is NotUtf8 {
|
|
393
|
+
return (
|
|
394
|
+
instanceOf(e) && (e as any)[variantOrdinalSymbol] === 2
|
|
395
|
+
);
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
/**
|
|
399
|
+
* One of the URLs in the QR code data could not be parsed.
|
|
400
|
+
*/
|
|
401
|
+
class UrlParse extends UniffiError {
|
|
402
|
+
/**
|
|
403
|
+
* @private
|
|
404
|
+
* This field is private and should not be used.
|
|
405
|
+
*/
|
|
406
|
+
readonly [uniffiTypeNameSymbol]: string = "LoginQrCodeDecodeError";
|
|
407
|
+
/**
|
|
408
|
+
* @private
|
|
409
|
+
* This field is private and should not be used.
|
|
410
|
+
*/
|
|
411
|
+
readonly [variantOrdinalSymbol] = 3;
|
|
412
|
+
|
|
413
|
+
readonly tag = LoginQrCodeDecodeError_Tags.UrlParse;
|
|
414
|
+
|
|
415
|
+
constructor(message: string) {
|
|
416
|
+
super("LoginQrCodeDecodeError", "UrlParse", message);
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
static instanceOf(e: any): e is UrlParse {
|
|
420
|
+
return (
|
|
421
|
+
instanceOf(e) && (e as any)[variantOrdinalSymbol] === 3
|
|
422
|
+
);
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
/**
|
|
426
|
+
* The QR code data contains an invalid intent, we expect the login
|
|
427
|
+
* intent or the reciprocate intent.
|
|
428
|
+
*/
|
|
429
|
+
class InvalidIntent extends UniffiError {
|
|
430
|
+
/**
|
|
431
|
+
* @private
|
|
432
|
+
* This field is private and should not be used.
|
|
433
|
+
*/
|
|
434
|
+
readonly [uniffiTypeNameSymbol]: string = "LoginQrCodeDecodeError";
|
|
435
|
+
/**
|
|
436
|
+
* @private
|
|
437
|
+
* This field is private and should not be used.
|
|
438
|
+
*/
|
|
439
|
+
readonly [variantOrdinalSymbol] = 4;
|
|
440
|
+
|
|
441
|
+
readonly tag = LoginQrCodeDecodeError_Tags.InvalidIntent;
|
|
442
|
+
|
|
443
|
+
constructor(message: string) {
|
|
444
|
+
super("LoginQrCodeDecodeError", "InvalidIntent", message);
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
static instanceOf(e: any): e is InvalidIntent {
|
|
448
|
+
return (
|
|
449
|
+
instanceOf(e) && (e as any)[variantOrdinalSymbol] === 4
|
|
450
|
+
);
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
/**
|
|
454
|
+
* The QR code data contains an unsupported type.
|
|
455
|
+
*/
|
|
456
|
+
class InvalidType extends UniffiError {
|
|
457
|
+
/**
|
|
458
|
+
* @private
|
|
459
|
+
* This field is private and should not be used.
|
|
460
|
+
*/
|
|
461
|
+
readonly [uniffiTypeNameSymbol]: string = "LoginQrCodeDecodeError";
|
|
462
|
+
/**
|
|
463
|
+
* @private
|
|
464
|
+
* This field is private and should not be used.
|
|
465
|
+
*/
|
|
466
|
+
readonly [variantOrdinalSymbol] = 5;
|
|
467
|
+
|
|
468
|
+
readonly tag = LoginQrCodeDecodeError_Tags.InvalidType;
|
|
469
|
+
|
|
470
|
+
constructor(message: string) {
|
|
471
|
+
super("LoginQrCodeDecodeError", "InvalidType", message);
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
static instanceOf(e: any): e is InvalidType {
|
|
475
|
+
return (
|
|
476
|
+
instanceOf(e) && (e as any)[variantOrdinalSymbol] === 5
|
|
477
|
+
);
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
/**
|
|
481
|
+
* The base64 encoded variant of the QR code data is not a valid base64
|
|
482
|
+
* string.
|
|
483
|
+
*/
|
|
484
|
+
class Base64 extends UniffiError {
|
|
485
|
+
/**
|
|
486
|
+
* @private
|
|
487
|
+
* This field is private and should not be used.
|
|
488
|
+
*/
|
|
489
|
+
readonly [uniffiTypeNameSymbol]: string = "LoginQrCodeDecodeError";
|
|
490
|
+
/**
|
|
491
|
+
* @private
|
|
492
|
+
* This field is private and should not be used.
|
|
493
|
+
*/
|
|
494
|
+
readonly [variantOrdinalSymbol] = 6;
|
|
495
|
+
|
|
496
|
+
readonly tag = LoginQrCodeDecodeError_Tags.Base64;
|
|
497
|
+
|
|
498
|
+
constructor(message: string) {
|
|
499
|
+
super("LoginQrCodeDecodeError", "Base64", message);
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
static instanceOf(e: any): e is Base64 {
|
|
503
|
+
return (
|
|
504
|
+
instanceOf(e) && (e as any)[variantOrdinalSymbol] === 6
|
|
505
|
+
);
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
/**
|
|
509
|
+
* The QR code data doesn't contain the expected `MATRIX` prefix.
|
|
510
|
+
*/
|
|
511
|
+
class InvalidPrefix extends UniffiError {
|
|
512
|
+
/**
|
|
513
|
+
* @private
|
|
514
|
+
* This field is private and should not be used.
|
|
515
|
+
*/
|
|
516
|
+
readonly [uniffiTypeNameSymbol]: string = "LoginQrCodeDecodeError";
|
|
517
|
+
/**
|
|
518
|
+
* @private
|
|
519
|
+
* This field is private and should not be used.
|
|
520
|
+
*/
|
|
521
|
+
readonly [variantOrdinalSymbol] = 7;
|
|
522
|
+
|
|
523
|
+
readonly tag = LoginQrCodeDecodeError_Tags.InvalidPrefix;
|
|
524
|
+
|
|
525
|
+
constructor(message: string) {
|
|
526
|
+
super("LoginQrCodeDecodeError", "InvalidPrefix", message);
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
static instanceOf(e: any): e is InvalidPrefix {
|
|
530
|
+
return (
|
|
531
|
+
instanceOf(e) && (e as any)[variantOrdinalSymbol] === 7
|
|
532
|
+
);
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
// Utility function which does not rely on instanceof.
|
|
537
|
+
function instanceOf(e: any): e is LoginQrCodeDecodeError {
|
|
538
|
+
return (e as any)[uniffiTypeNameSymbol] === "LoginQrCodeDecodeError";
|
|
539
|
+
}
|
|
540
|
+
return {
|
|
541
|
+
NotEnoughData,
|
|
542
|
+
NotUtf8,
|
|
543
|
+
UrlParse,
|
|
544
|
+
InvalidIntent,
|
|
545
|
+
InvalidType,
|
|
546
|
+
Base64,
|
|
547
|
+
InvalidPrefix,
|
|
548
|
+
instanceOf,
|
|
549
|
+
};
|
|
550
|
+
})();
|
|
551
|
+
|
|
552
|
+
// Union type for LoginQrCodeDecodeError error type.
|
|
553
|
+
|
|
554
|
+
/**
|
|
555
|
+
* Error type for the decoding of the [`QrCodeData`].
|
|
556
|
+
*/
|
|
557
|
+
|
|
558
|
+
export type LoginQrCodeDecodeError = InstanceType<
|
|
559
|
+
typeof LoginQrCodeDecodeError[keyof Omit<typeof LoginQrCodeDecodeError, 'instanceOf'>]
|
|
560
|
+
>;
|
|
561
|
+
|
|
562
|
+
const FfiConverterTypeLoginQrCodeDecodeError = (() => {
|
|
563
|
+
const intConverter = FfiConverterInt32;
|
|
564
|
+
type TypeName = LoginQrCodeDecodeError;
|
|
565
|
+
class FfiConverter extends AbstractFfiConverterByteArray<TypeName> {
|
|
566
|
+
read(from: RustBuffer): TypeName {
|
|
567
|
+
switch (intConverter.read(from)) {
|
|
568
|
+
case 1: return new LoginQrCodeDecodeError.NotEnoughData(FfiConverterString.read(from)
|
|
569
|
+
);
|
|
570
|
+
|
|
571
|
+
case 2: return new LoginQrCodeDecodeError.NotUtf8(FfiConverterString.read(from)
|
|
572
|
+
);
|
|
573
|
+
|
|
574
|
+
case 3: return new LoginQrCodeDecodeError.UrlParse(FfiConverterString.read(from)
|
|
575
|
+
);
|
|
576
|
+
|
|
577
|
+
case 4: return new LoginQrCodeDecodeError.InvalidIntent(FfiConverterString.read(from)
|
|
578
|
+
);
|
|
579
|
+
|
|
580
|
+
case 5: return new LoginQrCodeDecodeError.InvalidType(FfiConverterString.read(from)
|
|
581
|
+
);
|
|
582
|
+
|
|
583
|
+
case 6: return new LoginQrCodeDecodeError.Base64(FfiConverterString.read(from)
|
|
584
|
+
);
|
|
585
|
+
|
|
586
|
+
case 7: return new LoginQrCodeDecodeError.InvalidPrefix(FfiConverterString.read(from)
|
|
587
|
+
);
|
|
588
|
+
|
|
589
|
+
default: throw new UniffiInternalError.UnexpectedEnumCase();
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
write(value: TypeName, into: RustBuffer): void {
|
|
593
|
+
const obj = value as any;
|
|
594
|
+
const index = obj[variantOrdinalSymbol] as number;
|
|
595
|
+
intConverter.write(index, into);
|
|
596
|
+
}
|
|
597
|
+
allocationSize(value: TypeName): number {
|
|
598
|
+
return intConverter.allocationSize(0);
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
return new FfiConverter();
|
|
602
|
+
})();
|
|
603
|
+
|
|
604
|
+
|
|
605
|
+
/**
|
|
606
|
+
* The intent of the device that generated/displayed the QR code.
|
|
607
|
+
*
|
|
608
|
+
* The QR code login mechanism supports both, the new device, as well as the
|
|
609
|
+
* existing device to display the QR code.
|
|
610
|
+
*
|
|
611
|
+
* The different intents have an explicit one-byte identifier which gets added
|
|
612
|
+
* to the QR code data.
|
|
613
|
+
*/
|
|
614
|
+
export enum QrCodeIntent {
|
|
615
|
+
/**
|
|
616
|
+
* Enum variant for the case where the new device is displaying the QR
|
|
617
|
+
* code.
|
|
618
|
+
*/
|
|
619
|
+
Login,
|
|
620
|
+
/**
|
|
621
|
+
* Enum variant for the case where the existing device is displaying the QR
|
|
622
|
+
* code.
|
|
623
|
+
*/
|
|
624
|
+
Reciprocate
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
const FfiConverterTypeQrCodeIntent = (() => {
|
|
628
|
+
const ordinalConverter = FfiConverterInt32;
|
|
629
|
+
type TypeName = QrCodeIntent;
|
|
630
|
+
class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
|
|
631
|
+
read(from: RustBuffer): TypeName {
|
|
632
|
+
switch (ordinalConverter.read(from)) {
|
|
633
|
+
case 1: return QrCodeIntent.Login;
|
|
634
|
+
case 2: return QrCodeIntent.Reciprocate;
|
|
635
|
+
default: throw new UniffiInternalError.UnexpectedEnumCase();
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
write(value: TypeName, into: RustBuffer): void {
|
|
639
|
+
switch (value) {
|
|
640
|
+
case QrCodeIntent.Login: return ordinalConverter.write(1, into);
|
|
641
|
+
case QrCodeIntent.Reciprocate: return ordinalConverter.write(2, into);
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
allocationSize(value: TypeName): number {
|
|
645
|
+
return ordinalConverter.allocationSize(0);
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
return new FFIConverter();
|
|
649
|
+
})();
|
|
650
|
+
|
|
651
|
+
|
|
652
|
+
|
|
653
|
+
|
|
654
|
+
|
|
655
|
+
/**
|
|
656
|
+
* The result of a signature check.
|
|
657
|
+
*/
|
|
658
|
+
export enum SignatureState {
|
|
659
|
+
/**
|
|
660
|
+
* The signature is missing.
|
|
661
|
+
*/
|
|
662
|
+
Missing,
|
|
663
|
+
/**
|
|
664
|
+
* The signature is invalid.
|
|
665
|
+
*/
|
|
666
|
+
Invalid,
|
|
667
|
+
/**
|
|
668
|
+
* The signature is valid but the device or user identity that created the
|
|
669
|
+
* signature is not trusted.
|
|
670
|
+
*/
|
|
671
|
+
ValidButNotTrusted,
|
|
672
|
+
/**
|
|
673
|
+
* The signature is valid and the device or user identity that created the
|
|
674
|
+
* signature is trusted.
|
|
675
|
+
*/
|
|
676
|
+
ValidAndTrusted
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
const FfiConverterTypeSignatureState = (() => {
|
|
680
|
+
const ordinalConverter = FfiConverterInt32;
|
|
681
|
+
type TypeName = SignatureState;
|
|
682
|
+
class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
|
|
683
|
+
read(from: RustBuffer): TypeName {
|
|
684
|
+
switch (ordinalConverter.read(from)) {
|
|
685
|
+
case 1: return SignatureState.Missing;
|
|
686
|
+
case 2: return SignatureState.Invalid;
|
|
687
|
+
case 3: return SignatureState.ValidButNotTrusted;
|
|
688
|
+
case 4: return SignatureState.ValidAndTrusted;
|
|
689
|
+
default: throw new UniffiInternalError.UnexpectedEnumCase();
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
write(value: TypeName, into: RustBuffer): void {
|
|
693
|
+
switch (value) {
|
|
694
|
+
case SignatureState.Missing: return ordinalConverter.write(1, into);
|
|
695
|
+
case SignatureState.Invalid: return ordinalConverter.write(2, into);
|
|
696
|
+
case SignatureState.ValidButNotTrusted: return ordinalConverter.write(3, into);
|
|
697
|
+
case SignatureState.ValidAndTrusted: return ordinalConverter.write(4, into);
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
allocationSize(value: TypeName): number {
|
|
701
|
+
return ordinalConverter.allocationSize(0);
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
return new FFIConverter();
|
|
705
|
+
})();
|
|
706
|
+
|
|
707
|
+
|
|
708
|
+
|
|
709
|
+
|
|
710
|
+
|
|
711
|
+
/**
|
|
712
|
+
* The trust level in the sender's device that is required to decrypt an
|
|
713
|
+
* event.
|
|
714
|
+
*/
|
|
715
|
+
export enum TrustRequirement {
|
|
716
|
+
/**
|
|
717
|
+
* Decrypt events from everyone regardless of trust.
|
|
718
|
+
*
|
|
719
|
+
* Not recommended, per the guidance of [MSC4153].
|
|
720
|
+
*
|
|
721
|
+
* [MSC4153]: https://github.com/matrix-org/matrix-doc/pull/4153
|
|
722
|
+
*/
|
|
723
|
+
Untrusted,
|
|
724
|
+
/**
|
|
725
|
+
* Only decrypt events from cross-signed devices or legacy sessions (Megolm
|
|
726
|
+
* sessions created before we started collecting trust information).
|
|
727
|
+
*/
|
|
728
|
+
CrossSignedOrLegacy,
|
|
729
|
+
/**
|
|
730
|
+
* Only decrypt events from cross-signed devices.
|
|
731
|
+
*/
|
|
732
|
+
CrossSigned
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
const FfiConverterTypeTrustRequirement = (() => {
|
|
736
|
+
const ordinalConverter = FfiConverterInt32;
|
|
737
|
+
type TypeName = TrustRequirement;
|
|
738
|
+
class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
|
|
739
|
+
read(from: RustBuffer): TypeName {
|
|
740
|
+
switch (ordinalConverter.read(from)) {
|
|
741
|
+
case 1: return TrustRequirement.Untrusted;
|
|
742
|
+
case 2: return TrustRequirement.CrossSignedOrLegacy;
|
|
743
|
+
case 3: return TrustRequirement.CrossSigned;
|
|
744
|
+
default: throw new UniffiInternalError.UnexpectedEnumCase();
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
write(value: TypeName, into: RustBuffer): void {
|
|
748
|
+
switch (value) {
|
|
749
|
+
case TrustRequirement.Untrusted: return ordinalConverter.write(1, into);
|
|
750
|
+
case TrustRequirement.CrossSignedOrLegacy: return ordinalConverter.write(2, into);
|
|
751
|
+
case TrustRequirement.CrossSigned: return ordinalConverter.write(3, into);
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
allocationSize(value: TypeName): number {
|
|
755
|
+
return ordinalConverter.allocationSize(0);
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
return new FFIConverter();
|
|
759
|
+
})();
|
|
760
|
+
|
|
761
|
+
|
|
762
|
+
|
|
763
|
+
|
|
764
|
+
|
|
765
|
+
/**
|
|
766
|
+
* Our best guess at the reason why an event can't be decrypted.
|
|
767
|
+
*/
|
|
768
|
+
export enum UtdCause {
|
|
769
|
+
/**
|
|
770
|
+
* We don't have an explanation for why this UTD happened - it is probably
|
|
771
|
+
* a bug, or a network split between the two homeservers.
|
|
772
|
+
*
|
|
773
|
+
* For example:
|
|
774
|
+
*
|
|
775
|
+
* - the keys for this event are missing, but a key storage backup exists
|
|
776
|
+
* and is working, so we should be able to find the keys in the backup.
|
|
777
|
+
*
|
|
778
|
+
* - the keys for this event are missing, and a key storage backup exists
|
|
779
|
+
* on the server, but that backup is not working on this client even
|
|
780
|
+
* though this device is verified.
|
|
781
|
+
*/
|
|
782
|
+
Unknown,
|
|
783
|
+
/**
|
|
784
|
+
* We are missing the keys for this event, and the event was sent when we
|
|
785
|
+
* were not a member of the room (or invited).
|
|
786
|
+
*/
|
|
787
|
+
SentBeforeWeJoined,
|
|
788
|
+
/**
|
|
789
|
+
* The message was sent by a user identity we have not verified, but the
|
|
790
|
+
* user was previously verified.
|
|
791
|
+
*/
|
|
792
|
+
VerificationViolation,
|
|
793
|
+
/**
|
|
794
|
+
* The [`crate::TrustRequirement`] requires that the sending device be
|
|
795
|
+
* signed by its owner, and it was not.
|
|
796
|
+
*/
|
|
797
|
+
UnsignedDevice,
|
|
798
|
+
/**
|
|
799
|
+
* The [`crate::TrustRequirement`] requires that the sending device be
|
|
800
|
+
* signed by its owner, and we were unable to securely find the device.
|
|
801
|
+
*
|
|
802
|
+
* This could be because the device has since been deleted, because we
|
|
803
|
+
* haven't yet downloaded it from the server, or because the session
|
|
804
|
+
* data was obtained from an insecure source (imported from a file,
|
|
805
|
+
* obtained from a legacy (asymmetric) backup, unsafe key forward, etc.)
|
|
806
|
+
*/
|
|
807
|
+
UnknownDevice,
|
|
808
|
+
/**
|
|
809
|
+
* We are missing the keys for this event, but it is a "device-historical"
|
|
810
|
+
* message and there is no key storage backup on the server, presumably
|
|
811
|
+
* because the user has turned it off.
|
|
812
|
+
*
|
|
813
|
+
* Device-historical means that the message was sent before the current
|
|
814
|
+
* device existed (but the current user was probably a member of the room
|
|
815
|
+
* at the time the message was sent). Not to
|
|
816
|
+
* be confused with pre-join or pre-invite messages (see
|
|
817
|
+
* [`UtdCause::SentBeforeWeJoined`] for that).
|
|
818
|
+
*
|
|
819
|
+
* Expected message to user: "History is not available on this device".
|
|
820
|
+
*/
|
|
821
|
+
HistoricalMessageAndBackupIsDisabled,
|
|
822
|
+
/**
|
|
823
|
+
* The keys for this event are intentionally withheld.
|
|
824
|
+
*
|
|
825
|
+
* The sender has refused to share the key because our device does not meet
|
|
826
|
+
* the sender's security requirements.
|
|
827
|
+
*/
|
|
828
|
+
WithheldForUnverifiedOrInsecureDevice,
|
|
829
|
+
/**
|
|
830
|
+
* The keys for this event are missing, likely because the sender was
|
|
831
|
+
* unable to share them (e.g., failure to establish an Olm 1:1
|
|
832
|
+
* channel). Alternatively, the sender may have deliberately excluded
|
|
833
|
+
* this device by cherry-picking and blocking it, in which case, no action
|
|
834
|
+
* can be taken on our side.
|
|
835
|
+
*/
|
|
836
|
+
WithheldBySender,
|
|
837
|
+
/**
|
|
838
|
+
* We are missing the keys for this event, but it is a "device-historical"
|
|
839
|
+
* message, and even though a key storage backup does exist, we can't use
|
|
840
|
+
* it because our device is unverified.
|
|
841
|
+
*
|
|
842
|
+
* Device-historical means that the message was sent before the current
|
|
843
|
+
* device existed (but the current user was probably a member of the room
|
|
844
|
+
* at the time the message was sent). Not to
|
|
845
|
+
* be confused with pre-join or pre-invite messages (see
|
|
846
|
+
* [`UtdCause::SentBeforeWeJoined`] for that).
|
|
847
|
+
*
|
|
848
|
+
* Expected message to user: "You need to verify this device".
|
|
849
|
+
*/
|
|
850
|
+
HistoricalMessageAndDeviceIsUnverified
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
const FfiConverterTypeUtdCause = (() => {
|
|
854
|
+
const ordinalConverter = FfiConverterInt32;
|
|
855
|
+
type TypeName = UtdCause;
|
|
856
|
+
class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
|
|
857
|
+
read(from: RustBuffer): TypeName {
|
|
858
|
+
switch (ordinalConverter.read(from)) {
|
|
859
|
+
case 1: return UtdCause.Unknown;
|
|
860
|
+
case 2: return UtdCause.SentBeforeWeJoined;
|
|
861
|
+
case 3: return UtdCause.VerificationViolation;
|
|
862
|
+
case 4: return UtdCause.UnsignedDevice;
|
|
863
|
+
case 5: return UtdCause.UnknownDevice;
|
|
864
|
+
case 6: return UtdCause.HistoricalMessageAndBackupIsDisabled;
|
|
865
|
+
case 7: return UtdCause.WithheldForUnverifiedOrInsecureDevice;
|
|
866
|
+
case 8: return UtdCause.WithheldBySender;
|
|
867
|
+
case 9: return UtdCause.HistoricalMessageAndDeviceIsUnverified;
|
|
868
|
+
default: throw new UniffiInternalError.UnexpectedEnumCase();
|
|
869
|
+
}
|
|
870
|
+
}
|
|
871
|
+
write(value: TypeName, into: RustBuffer): void {
|
|
872
|
+
switch (value) {
|
|
873
|
+
case UtdCause.Unknown: return ordinalConverter.write(1, into);
|
|
874
|
+
case UtdCause.SentBeforeWeJoined: return ordinalConverter.write(2, into);
|
|
875
|
+
case UtdCause.VerificationViolation: return ordinalConverter.write(3, into);
|
|
876
|
+
case UtdCause.UnsignedDevice: return ordinalConverter.write(4, into);
|
|
877
|
+
case UtdCause.UnknownDevice: return ordinalConverter.write(5, into);
|
|
878
|
+
case UtdCause.HistoricalMessageAndBackupIsDisabled: return ordinalConverter.write(6, into);
|
|
879
|
+
case UtdCause.WithheldForUnverifiedOrInsecureDevice: return ordinalConverter.write(7, into);
|
|
880
|
+
case UtdCause.WithheldBySender: return ordinalConverter.write(8, into);
|
|
881
|
+
case UtdCause.HistoricalMessageAndDeviceIsUnverified: return ordinalConverter.write(9, into);
|
|
882
|
+
}
|
|
883
|
+
}
|
|
884
|
+
allocationSize(value: TypeName): number {
|
|
885
|
+
return ordinalConverter.allocationSize(0);
|
|
886
|
+
}
|
|
887
|
+
}
|
|
888
|
+
return new FFIConverter();
|
|
889
|
+
})();
|
|
890
|
+
|
|
891
|
+
|
|
892
|
+
|
|
893
|
+
|
|
894
|
+
|
|
895
|
+
/**
|
|
896
|
+
* Enum for the algorithm-specific secrets for the room key backup.
|
|
897
|
+
*/
|
|
898
|
+
export interface BackupSecretsLike {
|
|
899
|
+
|
|
900
|
+
}
|
|
901
|
+
/**
|
|
902
|
+
* @deprecated Use `BackupSecretsLike` instead.
|
|
903
|
+
*/
|
|
904
|
+
export type BackupSecretsInterface = BackupSecretsLike;
|
|
905
|
+
|
|
906
|
+
|
|
907
|
+
/**
|
|
908
|
+
* Enum for the algorithm-specific secrets for the room key backup.
|
|
909
|
+
*/
|
|
910
|
+
export class BackupSecrets extends UniffiAbstractObject implements BackupSecretsLike {
|
|
911
|
+
|
|
912
|
+
readonly [uniffiTypeNameSymbol] = "BackupSecrets";
|
|
913
|
+
readonly [destructorGuardSymbol]: UniffiGcObject;
|
|
914
|
+
readonly [pointerLiteralSymbol]: UniffiHandle;
|
|
915
|
+
// No primary constructor declared for this class.
|
|
916
|
+
private constructor(pointer: UniffiHandle) {
|
|
917
|
+
super();
|
|
918
|
+
this[pointerLiteralSymbol] = pointer;
|
|
919
|
+
this[destructorGuardSymbol] = uniffiTypeBackupSecretsObjectFactory.bless(pointer);
|
|
920
|
+
}
|
|
921
|
+
|
|
922
|
+
|
|
923
|
+
|
|
924
|
+
|
|
925
|
+
|
|
926
|
+
/**
|
|
927
|
+
* {@inheritDoc uniffi-bindgen-react-native#UniffiAbstractObject.uniffiDestroy}
|
|
928
|
+
*/
|
|
929
|
+
uniffiDestroy(): void {
|
|
930
|
+
const ptr = (this as any)[destructorGuardSymbol];
|
|
931
|
+
if (ptr !== undefined) {
|
|
932
|
+
const pointer = uniffiTypeBackupSecretsObjectFactory.pointer(this);
|
|
933
|
+
uniffiTypeBackupSecretsObjectFactory.freePointer(pointer);
|
|
934
|
+
uniffiTypeBackupSecretsObjectFactory.unbless(ptr);
|
|
935
|
+
delete (this as any)[destructorGuardSymbol];
|
|
936
|
+
}
|
|
937
|
+
}
|
|
938
|
+
|
|
939
|
+
static instanceOf(obj: any): obj is BackupSecrets {
|
|
940
|
+
return uniffiTypeBackupSecretsObjectFactory.isConcreteType(obj);
|
|
941
|
+
}
|
|
942
|
+
|
|
943
|
+
|
|
944
|
+
}
|
|
945
|
+
|
|
946
|
+
const uniffiTypeBackupSecretsObjectFactory: UniffiObjectFactory<BackupSecretsLike> = (() => {
|
|
947
|
+
|
|
948
|
+
/// <reference lib="es2021" />
|
|
949
|
+
const registry = typeof FinalizationRegistry !== 'undefined' ? new FinalizationRegistry<UniffiHandle>((heldValue: UniffiHandle) => {
|
|
950
|
+
uniffiTypeBackupSecretsObjectFactory.freePointer(heldValue);
|
|
951
|
+
}) : null;
|
|
952
|
+
|
|
953
|
+
return {
|
|
954
|
+
create(pointer: UniffiHandle): BackupSecretsLike {
|
|
955
|
+
const instance = Object.create(BackupSecrets.prototype);
|
|
956
|
+
instance[pointerLiteralSymbol] = pointer;
|
|
957
|
+
instance[destructorGuardSymbol] = this.bless(pointer);
|
|
958
|
+
instance[uniffiTypeNameSymbol] = "BackupSecrets";
|
|
959
|
+
return instance;
|
|
960
|
+
},
|
|
961
|
+
|
|
962
|
+
|
|
963
|
+
bless(p: UniffiHandle): UniffiGcObject {
|
|
964
|
+
const ptr = {
|
|
965
|
+
p, // make sure this object doesn't get optimized away.
|
|
966
|
+
markDestroyed: () => undefined,
|
|
967
|
+
};
|
|
968
|
+
if (registry) {
|
|
969
|
+
registry.register(ptr, p, ptr);
|
|
970
|
+
}
|
|
971
|
+
return ptr;
|
|
972
|
+
},
|
|
973
|
+
|
|
974
|
+
unbless(ptr: UniffiGcObject) {
|
|
975
|
+
if (registry) {
|
|
976
|
+
registry.unregister(ptr);
|
|
977
|
+
}
|
|
978
|
+
},
|
|
979
|
+
|
|
980
|
+
pointer(obj: BackupSecretsLike): UniffiHandle {
|
|
981
|
+
if ((obj as any)[destructorGuardSymbol] === undefined) {
|
|
982
|
+
throw new UniffiInternalError.UnexpectedNullPointer();
|
|
983
|
+
}
|
|
984
|
+
return (obj as any)[pointerLiteralSymbol];
|
|
985
|
+
},
|
|
986
|
+
|
|
987
|
+
clonePointer(obj: BackupSecretsLike): UniffiHandle {
|
|
988
|
+
const pointer = this.pointer(obj);
|
|
989
|
+
return uniffiCaller.rustCall(
|
|
990
|
+
/*caller:*/ (callStatus) => nativeModule().ubrn_uniffi_matrix_sdk_crypto_fn_clone_backupsecrets(pointer, callStatus),
|
|
991
|
+
/*liftString:*/ FfiConverterString.lift
|
|
992
|
+
);
|
|
993
|
+
},
|
|
994
|
+
|
|
995
|
+
freePointer(pointer: UniffiHandle): void {
|
|
996
|
+
uniffiCaller.rustCall(
|
|
997
|
+
/*caller:*/ (callStatus) => nativeModule().ubrn_uniffi_matrix_sdk_crypto_fn_free_backupsecrets(pointer, callStatus),
|
|
998
|
+
/*liftString:*/ FfiConverterString.lift
|
|
999
|
+
);
|
|
1000
|
+
},
|
|
1001
|
+
|
|
1002
|
+
isConcreteType(obj: any): obj is BackupSecretsLike {
|
|
1003
|
+
return obj[destructorGuardSymbol] && obj[uniffiTypeNameSymbol] === "BackupSecrets";
|
|
1004
|
+
},
|
|
1005
|
+
}})();
|
|
1006
|
+
// FfiConverter for BackupSecretsLike
|
|
1007
|
+
const FfiConverterTypeBackupSecrets = new FfiConverterObject(uniffiTypeBackupSecretsObjectFactory);
|
|
1008
|
+
|
|
1009
|
+
|
|
1010
|
+
/**
|
|
1011
|
+
* Data for the secrets bundle containing the cross-signing keys.
|
|
1012
|
+
*/
|
|
1013
|
+
export interface CrossSigningSecretsLike {
|
|
1014
|
+
|
|
1015
|
+
}
|
|
1016
|
+
/**
|
|
1017
|
+
* @deprecated Use `CrossSigningSecretsLike` instead.
|
|
1018
|
+
*/
|
|
1019
|
+
export type CrossSigningSecretsInterface = CrossSigningSecretsLike;
|
|
1020
|
+
|
|
1021
|
+
|
|
1022
|
+
/**
|
|
1023
|
+
* Data for the secrets bundle containing the cross-signing keys.
|
|
1024
|
+
*/
|
|
1025
|
+
export class CrossSigningSecrets extends UniffiAbstractObject implements CrossSigningSecretsLike {
|
|
1026
|
+
|
|
1027
|
+
readonly [uniffiTypeNameSymbol] = "CrossSigningSecrets";
|
|
1028
|
+
readonly [destructorGuardSymbol]: UniffiGcObject;
|
|
1029
|
+
readonly [pointerLiteralSymbol]: UniffiHandle;
|
|
1030
|
+
// No primary constructor declared for this class.
|
|
1031
|
+
private constructor(pointer: UniffiHandle) {
|
|
1032
|
+
super();
|
|
1033
|
+
this[pointerLiteralSymbol] = pointer;
|
|
1034
|
+
this[destructorGuardSymbol] = uniffiTypeCrossSigningSecretsObjectFactory.bless(pointer);
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1037
|
+
|
|
1038
|
+
|
|
1039
|
+
|
|
1040
|
+
|
|
1041
|
+
/**
|
|
1042
|
+
* {@inheritDoc uniffi-bindgen-react-native#UniffiAbstractObject.uniffiDestroy}
|
|
1043
|
+
*/
|
|
1044
|
+
uniffiDestroy(): void {
|
|
1045
|
+
const ptr = (this as any)[destructorGuardSymbol];
|
|
1046
|
+
if (ptr !== undefined) {
|
|
1047
|
+
const pointer = uniffiTypeCrossSigningSecretsObjectFactory.pointer(this);
|
|
1048
|
+
uniffiTypeCrossSigningSecretsObjectFactory.freePointer(pointer);
|
|
1049
|
+
uniffiTypeCrossSigningSecretsObjectFactory.unbless(ptr);
|
|
1050
|
+
delete (this as any)[destructorGuardSymbol];
|
|
1051
|
+
}
|
|
1052
|
+
}
|
|
1053
|
+
|
|
1054
|
+
static instanceOf(obj: any): obj is CrossSigningSecrets {
|
|
1055
|
+
return uniffiTypeCrossSigningSecretsObjectFactory.isConcreteType(obj);
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
|
|
1059
|
+
}
|
|
1060
|
+
|
|
1061
|
+
const uniffiTypeCrossSigningSecretsObjectFactory: UniffiObjectFactory<CrossSigningSecretsLike> = (() => {
|
|
1062
|
+
|
|
1063
|
+
/// <reference lib="es2021" />
|
|
1064
|
+
const registry = typeof FinalizationRegistry !== 'undefined' ? new FinalizationRegistry<UniffiHandle>((heldValue: UniffiHandle) => {
|
|
1065
|
+
uniffiTypeCrossSigningSecretsObjectFactory.freePointer(heldValue);
|
|
1066
|
+
}) : null;
|
|
1067
|
+
|
|
1068
|
+
return {
|
|
1069
|
+
create(pointer: UniffiHandle): CrossSigningSecretsLike {
|
|
1070
|
+
const instance = Object.create(CrossSigningSecrets.prototype);
|
|
1071
|
+
instance[pointerLiteralSymbol] = pointer;
|
|
1072
|
+
instance[destructorGuardSymbol] = this.bless(pointer);
|
|
1073
|
+
instance[uniffiTypeNameSymbol] = "CrossSigningSecrets";
|
|
1074
|
+
return instance;
|
|
1075
|
+
},
|
|
1076
|
+
|
|
1077
|
+
|
|
1078
|
+
bless(p: UniffiHandle): UniffiGcObject {
|
|
1079
|
+
const ptr = {
|
|
1080
|
+
p, // make sure this object doesn't get optimized away.
|
|
1081
|
+
markDestroyed: () => undefined,
|
|
1082
|
+
};
|
|
1083
|
+
if (registry) {
|
|
1084
|
+
registry.register(ptr, p, ptr);
|
|
1085
|
+
}
|
|
1086
|
+
return ptr;
|
|
1087
|
+
},
|
|
1088
|
+
|
|
1089
|
+
unbless(ptr: UniffiGcObject) {
|
|
1090
|
+
if (registry) {
|
|
1091
|
+
registry.unregister(ptr);
|
|
1092
|
+
}
|
|
1093
|
+
},
|
|
1094
|
+
|
|
1095
|
+
pointer(obj: CrossSigningSecretsLike): UniffiHandle {
|
|
1096
|
+
if ((obj as any)[destructorGuardSymbol] === undefined) {
|
|
1097
|
+
throw new UniffiInternalError.UnexpectedNullPointer();
|
|
1098
|
+
}
|
|
1099
|
+
return (obj as any)[pointerLiteralSymbol];
|
|
1100
|
+
},
|
|
1101
|
+
|
|
1102
|
+
clonePointer(obj: CrossSigningSecretsLike): UniffiHandle {
|
|
1103
|
+
const pointer = this.pointer(obj);
|
|
1104
|
+
return uniffiCaller.rustCall(
|
|
1105
|
+
/*caller:*/ (callStatus) => nativeModule().ubrn_uniffi_matrix_sdk_crypto_fn_clone_crosssigningsecrets(pointer, callStatus),
|
|
1106
|
+
/*liftString:*/ FfiConverterString.lift
|
|
1107
|
+
);
|
|
1108
|
+
},
|
|
1109
|
+
|
|
1110
|
+
freePointer(pointer: UniffiHandle): void {
|
|
1111
|
+
uniffiCaller.rustCall(
|
|
1112
|
+
/*caller:*/ (callStatus) => nativeModule().ubrn_uniffi_matrix_sdk_crypto_fn_free_crosssigningsecrets(pointer, callStatus),
|
|
1113
|
+
/*liftString:*/ FfiConverterString.lift
|
|
1114
|
+
);
|
|
1115
|
+
},
|
|
1116
|
+
|
|
1117
|
+
isConcreteType(obj: any): obj is CrossSigningSecretsLike {
|
|
1118
|
+
return obj[destructorGuardSymbol] && obj[uniffiTypeNameSymbol] === "CrossSigningSecrets";
|
|
1119
|
+
},
|
|
1120
|
+
}})();
|
|
1121
|
+
// FfiConverter for CrossSigningSecretsLike
|
|
1122
|
+
const FfiConverterTypeCrossSigningSecrets = new FfiConverterObject(uniffiTypeCrossSigningSecretsObjectFactory);
|
|
1123
|
+
|
|
1124
|
+
|
|
1125
|
+
/**
|
|
1126
|
+
* Struct containing the bundle of secrets to fully activate a new devices for
|
|
1127
|
+
* end-to-end encryption.
|
|
1128
|
+
*/
|
|
1129
|
+
export interface SecretsBundleLike {
|
|
1130
|
+
|
|
1131
|
+
}
|
|
1132
|
+
/**
|
|
1133
|
+
* @deprecated Use `SecretsBundleLike` instead.
|
|
1134
|
+
*/
|
|
1135
|
+
export type SecretsBundleInterface = SecretsBundleLike;
|
|
1136
|
+
|
|
1137
|
+
|
|
1138
|
+
/**
|
|
1139
|
+
* Struct containing the bundle of secrets to fully activate a new devices for
|
|
1140
|
+
* end-to-end encryption.
|
|
1141
|
+
*/
|
|
1142
|
+
export class SecretsBundle extends UniffiAbstractObject implements SecretsBundleLike {
|
|
1143
|
+
|
|
1144
|
+
readonly [uniffiTypeNameSymbol] = "SecretsBundle";
|
|
1145
|
+
readonly [destructorGuardSymbol]: UniffiGcObject;
|
|
1146
|
+
readonly [pointerLiteralSymbol]: UniffiHandle;
|
|
1147
|
+
// No primary constructor declared for this class.
|
|
1148
|
+
private constructor(pointer: UniffiHandle) {
|
|
1149
|
+
super();
|
|
1150
|
+
this[pointerLiteralSymbol] = pointer;
|
|
1151
|
+
this[destructorGuardSymbol] = uniffiTypeSecretsBundleObjectFactory.bless(pointer);
|
|
1152
|
+
}
|
|
1153
|
+
|
|
1154
|
+
|
|
1155
|
+
|
|
1156
|
+
|
|
1157
|
+
|
|
1158
|
+
/**
|
|
1159
|
+
* {@inheritDoc uniffi-bindgen-react-native#UniffiAbstractObject.uniffiDestroy}
|
|
1160
|
+
*/
|
|
1161
|
+
uniffiDestroy(): void {
|
|
1162
|
+
const ptr = (this as any)[destructorGuardSymbol];
|
|
1163
|
+
if (ptr !== undefined) {
|
|
1164
|
+
const pointer = uniffiTypeSecretsBundleObjectFactory.pointer(this);
|
|
1165
|
+
uniffiTypeSecretsBundleObjectFactory.freePointer(pointer);
|
|
1166
|
+
uniffiTypeSecretsBundleObjectFactory.unbless(ptr);
|
|
1167
|
+
delete (this as any)[destructorGuardSymbol];
|
|
1168
|
+
}
|
|
1169
|
+
}
|
|
1170
|
+
|
|
1171
|
+
static instanceOf(obj: any): obj is SecretsBundle {
|
|
1172
|
+
return uniffiTypeSecretsBundleObjectFactory.isConcreteType(obj);
|
|
1173
|
+
}
|
|
1174
|
+
|
|
1175
|
+
|
|
1176
|
+
}
|
|
1177
|
+
|
|
1178
|
+
const uniffiTypeSecretsBundleObjectFactory: UniffiObjectFactory<SecretsBundleLike> = (() => {
|
|
1179
|
+
|
|
1180
|
+
/// <reference lib="es2021" />
|
|
1181
|
+
const registry = typeof FinalizationRegistry !== 'undefined' ? new FinalizationRegistry<UniffiHandle>((heldValue: UniffiHandle) => {
|
|
1182
|
+
uniffiTypeSecretsBundleObjectFactory.freePointer(heldValue);
|
|
1183
|
+
}) : null;
|
|
1184
|
+
|
|
1185
|
+
return {
|
|
1186
|
+
create(pointer: UniffiHandle): SecretsBundleLike {
|
|
1187
|
+
const instance = Object.create(SecretsBundle.prototype);
|
|
1188
|
+
instance[pointerLiteralSymbol] = pointer;
|
|
1189
|
+
instance[destructorGuardSymbol] = this.bless(pointer);
|
|
1190
|
+
instance[uniffiTypeNameSymbol] = "SecretsBundle";
|
|
1191
|
+
return instance;
|
|
1192
|
+
},
|
|
1193
|
+
|
|
1194
|
+
|
|
1195
|
+
bless(p: UniffiHandle): UniffiGcObject {
|
|
1196
|
+
const ptr = {
|
|
1197
|
+
p, // make sure this object doesn't get optimized away.
|
|
1198
|
+
markDestroyed: () => undefined,
|
|
1199
|
+
};
|
|
1200
|
+
if (registry) {
|
|
1201
|
+
registry.register(ptr, p, ptr);
|
|
1202
|
+
}
|
|
1203
|
+
return ptr;
|
|
1204
|
+
},
|
|
1205
|
+
|
|
1206
|
+
unbless(ptr: UniffiGcObject) {
|
|
1207
|
+
if (registry) {
|
|
1208
|
+
registry.unregister(ptr);
|
|
1209
|
+
}
|
|
1210
|
+
},
|
|
1211
|
+
|
|
1212
|
+
pointer(obj: SecretsBundleLike): UniffiHandle {
|
|
1213
|
+
if ((obj as any)[destructorGuardSymbol] === undefined) {
|
|
1214
|
+
throw new UniffiInternalError.UnexpectedNullPointer();
|
|
1215
|
+
}
|
|
1216
|
+
return (obj as any)[pointerLiteralSymbol];
|
|
1217
|
+
},
|
|
1218
|
+
|
|
1219
|
+
clonePointer(obj: SecretsBundleLike): UniffiHandle {
|
|
1220
|
+
const pointer = this.pointer(obj);
|
|
1221
|
+
return uniffiCaller.rustCall(
|
|
1222
|
+
/*caller:*/ (callStatus) => nativeModule().ubrn_uniffi_matrix_sdk_crypto_fn_clone_secretsbundle(pointer, callStatus),
|
|
1223
|
+
/*liftString:*/ FfiConverterString.lift
|
|
1224
|
+
);
|
|
1225
|
+
},
|
|
1226
|
+
|
|
1227
|
+
freePointer(pointer: UniffiHandle): void {
|
|
1228
|
+
uniffiCaller.rustCall(
|
|
1229
|
+
/*caller:*/ (callStatus) => nativeModule().ubrn_uniffi_matrix_sdk_crypto_fn_free_secretsbundle(pointer, callStatus),
|
|
1230
|
+
/*liftString:*/ FfiConverterString.lift
|
|
1231
|
+
);
|
|
1232
|
+
},
|
|
1233
|
+
|
|
1234
|
+
isConcreteType(obj: any): obj is SecretsBundleLike {
|
|
1235
|
+
return obj[destructorGuardSymbol] && obj[uniffiTypeNameSymbol] === "SecretsBundle";
|
|
1236
|
+
},
|
|
1237
|
+
}})();
|
|
1238
|
+
// FfiConverter for SecretsBundleLike
|
|
1239
|
+
const FfiConverterTypeSecretsBundle = new FfiConverterObject(uniffiTypeSecretsBundleObjectFactory);
|
|
1240
|
+
|
|
1241
|
+
|
|
1242
|
+
|
|
1243
|
+
/**
|
|
1244
|
+
* This should be called before anything else.
|
|
1245
|
+
*
|
|
1246
|
+
* It is likely that this is being done for you by the library's `index.ts`.
|
|
1247
|
+
*
|
|
1248
|
+
* It checks versions of uniffi between when the Rust scaffolding was generated
|
|
1249
|
+
* and when the bindings were generated.
|
|
1250
|
+
*
|
|
1251
|
+
* It also initializes the machinery to enable Rust to talk back to Javascript.
|
|
1252
|
+
*/
|
|
1253
|
+
function uniffiEnsureInitialized() {
|
|
1254
|
+
// Get the bindings contract version from our ComponentInterface
|
|
1255
|
+
const bindingsContractVersion = 30;
|
|
1256
|
+
// Get the scaffolding contract version by calling the into the dylib
|
|
1257
|
+
const scaffoldingContractVersion = nativeModule().ubrn_ffi_matrix_sdk_crypto_uniffi_contract_version();
|
|
1258
|
+
if (bindingsContractVersion !== scaffoldingContractVersion) {
|
|
1259
|
+
throw new UniffiInternalError.ContractVersionMismatch(scaffoldingContractVersion, bindingsContractVersion);
|
|
1260
|
+
}
|
|
1261
|
+
|
|
1262
|
+
}
|
|
1263
|
+
|
|
1264
|
+
export default Object.freeze({
|
|
1265
|
+
initialize: uniffiEnsureInitialized,
|
|
1266
|
+
converters: {
|
|
1267
|
+
FfiConverterTypeBackupSecrets,
|
|
1268
|
+
FfiConverterTypeCollectStrategy,
|
|
1269
|
+
FfiConverterTypeCrossSigningSecrets,
|
|
1270
|
+
FfiConverterTypeDecryptionSettings,
|
|
1271
|
+
FfiConverterTypeIdentityState,
|
|
1272
|
+
FfiConverterTypeLocalTrust,
|
|
1273
|
+
FfiConverterTypeLoginQrCodeDecodeError,
|
|
1274
|
+
FfiConverterTypeQrCodeIntent,
|
|
1275
|
+
FfiConverterTypeSecretsBundle,
|
|
1276
|
+
FfiConverterTypeSignatureState,
|
|
1277
|
+
FfiConverterTypeTrustRequirement,
|
|
1278
|
+
FfiConverterTypeUtdCause,
|
|
1279
|
+
}
|
|
1280
|
+
});
|