@succinctlabs/react-native-zcam1 0.2.5

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 (139) hide show
  1. package/README.md +61 -0
  2. package/Zcam1Sdk.podspec +157 -0
  3. package/app.plugin.js +11 -0
  4. package/cpp/generated/zcam1_c2pa_utils.cpp +4091 -0
  5. package/cpp/generated/zcam1_c2pa_utils.hpp +367 -0
  6. package/cpp/generated/zcam1_certs_utils.cpp +1799 -0
  7. package/cpp/generated/zcam1_certs_utils.hpp +72 -0
  8. package/cpp/generated/zcam1_verify_utils.cpp +1857 -0
  9. package/cpp/generated/zcam1_verify_utils.hpp +79 -0
  10. package/cpp/proving/generated/zcam1_proving_utils.cpp +3661 -0
  11. package/cpp/proving/generated/zcam1_proving_utils.hpp +275 -0
  12. package/cpp/proving/zcam1-proving.cpp +16 -0
  13. package/cpp/proving/zcam1-proving.h +15 -0
  14. package/cpp/zcam1-sdk.cpp +20 -0
  15. package/cpp/zcam1-sdk.h +15 -0
  16. package/ios/Zcam1Camera.swift +2945 -0
  17. package/ios/Zcam1CameraFilmStyle.swift +191 -0
  18. package/ios/Zcam1CameraViewManager.m +86 -0
  19. package/ios/Zcam1Capture.h +13 -0
  20. package/ios/Zcam1Capture.mm +500 -0
  21. package/ios/Zcam1DepthData.swift +417 -0
  22. package/ios/Zcam1Sdk.h +16 -0
  23. package/ios/Zcam1Sdk.mm +66 -0
  24. package/ios/proving/Zcam1Proving.h +16 -0
  25. package/ios/proving/Zcam1Proving.mm +66 -0
  26. package/lib/module/NativeZcam1Capture.js +12 -0
  27. package/lib/module/NativeZcam1Capture.js.map +1 -0
  28. package/lib/module/NativeZcam1Sdk.js +7 -0
  29. package/lib/module/NativeZcam1Sdk.js.map +1 -0
  30. package/lib/module/bindings.js +51 -0
  31. package/lib/module/bindings.js.map +1 -0
  32. package/lib/module/camera.js +522 -0
  33. package/lib/module/camera.js.map +1 -0
  34. package/lib/module/capture.js +120 -0
  35. package/lib/module/capture.js.map +1 -0
  36. package/lib/module/common.js +35 -0
  37. package/lib/module/common.js.map +1 -0
  38. package/lib/module/generated/zcam1_c2pa_utils-ffi.js +43 -0
  39. package/lib/module/generated/zcam1_c2pa_utils-ffi.js.map +1 -0
  40. package/lib/module/generated/zcam1_c2pa_utils.js +1202 -0
  41. package/lib/module/generated/zcam1_c2pa_utils.js.map +1 -0
  42. package/lib/module/generated/zcam1_certs_utils-ffi.js +43 -0
  43. package/lib/module/generated/zcam1_certs_utils-ffi.js.map +1 -0
  44. package/lib/module/generated/zcam1_certs_utils.js +399 -0
  45. package/lib/module/generated/zcam1_certs_utils.js.map +1 -0
  46. package/lib/module/generated/zcam1_proving_utils-ffi.js +43 -0
  47. package/lib/module/generated/zcam1_proving_utils-ffi.js.map +1 -0
  48. package/lib/module/generated/zcam1_proving_utils.js +515 -0
  49. package/lib/module/generated/zcam1_proving_utils.js.map +1 -0
  50. package/lib/module/generated/zcam1_verify_utils-ffi.js +43 -0
  51. package/lib/module/generated/zcam1_verify_utils-ffi.js.map +1 -0
  52. package/lib/module/generated/zcam1_verify_utils.js +252 -0
  53. package/lib/module/generated/zcam1_verify_utils.js.map +1 -0
  54. package/lib/module/index.js +31 -0
  55. package/lib/module/index.js.map +1 -0
  56. package/lib/module/package.json +1 -0
  57. package/lib/module/picker.js +222 -0
  58. package/lib/module/picker.js.map +1 -0
  59. package/lib/module/proving/NativeZcam1Proving.js +7 -0
  60. package/lib/module/proving/NativeZcam1Proving.js.map +1 -0
  61. package/lib/module/proving/bindings.js +46 -0
  62. package/lib/module/proving/bindings.js.map +1 -0
  63. package/lib/module/proving/index.js +5 -0
  64. package/lib/module/proving/index.js.map +1 -0
  65. package/lib/module/proving/prove.js +346 -0
  66. package/lib/module/proving/prove.js.map +1 -0
  67. package/lib/module/utils.js +27 -0
  68. package/lib/module/utils.js.map +1 -0
  69. package/lib/module/verify.js +82 -0
  70. package/lib/module/verify.js.map +1 -0
  71. package/lib/typescript/package.json +1 -0
  72. package/lib/typescript/src/NativeZcam1Capture.d.ts +280 -0
  73. package/lib/typescript/src/NativeZcam1Capture.d.ts.map +1 -0
  74. package/lib/typescript/src/NativeZcam1Sdk.d.ts +8 -0
  75. package/lib/typescript/src/NativeZcam1Sdk.d.ts.map +1 -0
  76. package/lib/typescript/src/bindings.d.ts +14 -0
  77. package/lib/typescript/src/bindings.d.ts.map +1 -0
  78. package/lib/typescript/src/camera.d.ts +300 -0
  79. package/lib/typescript/src/camera.d.ts.map +1 -0
  80. package/lib/typescript/src/capture.d.ts +59 -0
  81. package/lib/typescript/src/capture.d.ts.map +1 -0
  82. package/lib/typescript/src/common.d.ts +10 -0
  83. package/lib/typescript/src/common.d.ts.map +1 -0
  84. package/lib/typescript/src/generated/zcam1_c2pa_utils-ffi.d.ts +175 -0
  85. package/lib/typescript/src/generated/zcam1_c2pa_utils-ffi.d.ts.map +1 -0
  86. package/lib/typescript/src/generated/zcam1_c2pa_utils.d.ts +811 -0
  87. package/lib/typescript/src/generated/zcam1_c2pa_utils.d.ts.map +1 -0
  88. package/lib/typescript/src/generated/zcam1_certs_utils-ffi.d.ts +82 -0
  89. package/lib/typescript/src/generated/zcam1_certs_utils-ffi.d.ts.map +1 -0
  90. package/lib/typescript/src/generated/zcam1_certs_utils.d.ts +413 -0
  91. package/lib/typescript/src/generated/zcam1_certs_utils.d.ts.map +1 -0
  92. package/lib/typescript/src/generated/zcam1_proving_utils-ffi.d.ts +153 -0
  93. package/lib/typescript/src/generated/zcam1_proving_utils-ffi.d.ts.map +1 -0
  94. package/lib/typescript/src/generated/zcam1_proving_utils.d.ts +321 -0
  95. package/lib/typescript/src/generated/zcam1_proving_utils.d.ts.map +1 -0
  96. package/lib/typescript/src/generated/zcam1_verify_utils-ffi.d.ts +84 -0
  97. package/lib/typescript/src/generated/zcam1_verify_utils-ffi.d.ts.map +1 -0
  98. package/lib/typescript/src/generated/zcam1_verify_utils.d.ts +286 -0
  99. package/lib/typescript/src/generated/zcam1_verify_utils.d.ts.map +1 -0
  100. package/lib/typescript/src/index.d.ts +29 -0
  101. package/lib/typescript/src/index.d.ts.map +1 -0
  102. package/lib/typescript/src/picker.d.ts +103 -0
  103. package/lib/typescript/src/picker.d.ts.map +1 -0
  104. package/lib/typescript/src/proving/NativeZcam1Proving.d.ts +8 -0
  105. package/lib/typescript/src/proving/NativeZcam1Proving.d.ts.map +1 -0
  106. package/lib/typescript/src/proving/bindings.d.ts +8 -0
  107. package/lib/typescript/src/proving/bindings.d.ts.map +1 -0
  108. package/lib/typescript/src/proving/index.d.ts +3 -0
  109. package/lib/typescript/src/proving/index.d.ts.map +1 -0
  110. package/lib/typescript/src/proving/prove.d.ts +74 -0
  111. package/lib/typescript/src/proving/prove.d.ts.map +1 -0
  112. package/lib/typescript/src/utils.d.ts +2 -0
  113. package/lib/typescript/src/utils.d.ts.map +1 -0
  114. package/lib/typescript/src/verify.d.ts +45 -0
  115. package/lib/typescript/src/verify.d.ts.map +1 -0
  116. package/package.json +118 -0
  117. package/src/NativeZcam1Capture.ts +335 -0
  118. package/src/NativeZcam1Sdk.ts +10 -0
  119. package/src/bindings.tsx +49 -0
  120. package/src/camera.tsx +705 -0
  121. package/src/capture.tsx +165 -0
  122. package/src/common.tsx +46 -0
  123. package/src/generated/zcam1_c2pa_utils-ffi.ts +456 -0
  124. package/src/generated/zcam1_c2pa_utils.ts +1866 -0
  125. package/src/generated/zcam1_certs_utils-ffi.ts +187 -0
  126. package/src/generated/zcam1_certs_utils.ts +549 -0
  127. package/src/generated/zcam1_proving_utils-ffi.ts +374 -0
  128. package/src/generated/zcam1_proving_utils.ts +804 -0
  129. package/src/generated/zcam1_verify_utils-ffi.ts +196 -0
  130. package/src/generated/zcam1_verify_utils.ts +372 -0
  131. package/src/index.ts +73 -0
  132. package/src/picker.tsx +342 -0
  133. package/src/proving/NativeZcam1Proving.ts +10 -0
  134. package/src/proving/bindings.tsx +50 -0
  135. package/src/proving/index.ts +8 -0
  136. package/src/proving/prove.tsx +492 -0
  137. package/src/utils.ts +38 -0
  138. package/src/verify.tsx +119 -0
  139. package/turbo.json +27 -0
@@ -0,0 +1,549 @@
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
+ import nativeModule, {
4
+ type UniffiRustFutureContinuationCallback,
5
+ type UniffiForeignFuture,
6
+ type UniffiForeignFutureStructU8,
7
+ type UniffiForeignFutureCompleteU8,
8
+ type UniffiForeignFutureStructI8,
9
+ type UniffiForeignFutureCompleteI8,
10
+ type UniffiForeignFutureStructU16,
11
+ type UniffiForeignFutureCompleteU16,
12
+ type UniffiForeignFutureStructI16,
13
+ type UniffiForeignFutureCompleteI16,
14
+ type UniffiForeignFutureStructU32,
15
+ type UniffiForeignFutureCompleteU32,
16
+ type UniffiForeignFutureStructI32,
17
+ type UniffiForeignFutureCompleteI32,
18
+ type UniffiForeignFutureStructU64,
19
+ type UniffiForeignFutureCompleteU64,
20
+ type UniffiForeignFutureStructI64,
21
+ type UniffiForeignFutureCompleteI64,
22
+ type UniffiForeignFutureStructF32,
23
+ type UniffiForeignFutureCompleteF32,
24
+ type UniffiForeignFutureStructF64,
25
+ type UniffiForeignFutureCompleteF64,
26
+ type UniffiForeignFutureStructPointer,
27
+ type UniffiForeignFutureCompletePointer,
28
+ type UniffiForeignFutureStructRustBuffer,
29
+ type UniffiForeignFutureCompleteRustBuffer,
30
+ type UniffiForeignFutureStructVoid,
31
+ type UniffiForeignFutureCompleteVoid,
32
+ } from "./zcam1_certs_utils-ffi";
33
+ import {
34
+ type UniffiByteArray,
35
+ AbstractFfiConverterByteArray,
36
+ FfiConverterBool,
37
+ FfiConverterInt32,
38
+ FfiConverterOptional,
39
+ RustBuffer,
40
+ UniffiError,
41
+ UniffiInternalError,
42
+ UniffiRustCaller,
43
+ uniffiCreateFfiConverterString,
44
+ uniffiCreateRecord,
45
+ uniffiTypeNameSymbol,
46
+ variantOrdinalSymbol,
47
+ } from "uniffi-bindgen-react-native";
48
+
49
+ // Get converters from the other files, if any.
50
+ const uniffiCaller = new UniffiRustCaller(() => ({ code: 0 }));
51
+
52
+ const uniffiIsDebug =
53
+ // @ts-ignore -- The process global might not be defined
54
+ typeof process !== "object" ||
55
+ // @ts-ignore -- The process global might not be defined
56
+ process?.env?.NODE_ENV !== "production" ||
57
+ false;
58
+ // Public interface members begin here.
59
+
60
+ export function buildSelfSignedCertificate(
61
+ leafJwk: JwkEcKey,
62
+ certChainParams: SelfSignedCertChain | undefined = undefined,
63
+ ): string /*throws*/ {
64
+ return FfiConverterString.lift(
65
+ uniffiCaller.rustCallWithError(
66
+ /*liftError:*/ FfiConverterTypeCertsError.lift.bind(FfiConverterTypeCertsError),
67
+ /*caller:*/ (callStatus) => {
68
+ return nativeModule().ubrn_uniffi_zcam1_certs_utils_fn_func_build_self_signed_certificate(
69
+ FfiConverterTypeJwkEcKey.lower(leafJwk),
70
+ FfiConverterOptionalTypeSelfSignedCertChain.lower(certChainParams),
71
+ callStatus,
72
+ );
73
+ },
74
+ /*liftString:*/ FfiConverterString.lift,
75
+ ),
76
+ );
77
+ }
78
+
79
+ export type ExistingCertChain = {
80
+ pem: string;
81
+ };
82
+
83
+ /**
84
+ * Generated factory for {@link ExistingCertChain} record objects.
85
+ */
86
+ export const ExistingCertChain = (() => {
87
+ const defaults = () => ({});
88
+ const create = (() => {
89
+ return uniffiCreateRecord<ExistingCertChain, ReturnType<typeof defaults>>(defaults);
90
+ })();
91
+ return Object.freeze({
92
+ /**
93
+ * Create a frozen instance of {@link ExistingCertChain}, with defaults specified
94
+ * in Rust, in the {@link zcam1_certs_utils} crate.
95
+ */
96
+ create,
97
+
98
+ /**
99
+ * Create a frozen instance of {@link ExistingCertChain}, with defaults specified
100
+ * in Rust, in the {@link zcam1_certs_utils} crate.
101
+ */
102
+ new: create,
103
+
104
+ /**
105
+ * Defaults specified in the {@link zcam1_certs_utils} crate.
106
+ */
107
+ defaults: () => Object.freeze(defaults()) as Partial<ExistingCertChain>,
108
+ });
109
+ })();
110
+
111
+ const FfiConverterTypeExistingCertChain = (() => {
112
+ type TypeName = ExistingCertChain;
113
+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
114
+ read(from: RustBuffer): TypeName {
115
+ return {
116
+ pem: FfiConverterString.read(from),
117
+ };
118
+ }
119
+ write(value: TypeName, into: RustBuffer): void {
120
+ FfiConverterString.write(value.pem, into);
121
+ }
122
+ allocationSize(value: TypeName): number {
123
+ return FfiConverterString.allocationSize(value.pem);
124
+ }
125
+ }
126
+ return new FFIConverter();
127
+ })();
128
+
129
+ export type JwkEcKey = {
130
+ kty: string;
131
+ crv: string;
132
+ x: string;
133
+ y: string;
134
+ };
135
+
136
+ /**
137
+ * Generated factory for {@link JwkEcKey} record objects.
138
+ */
139
+ export const JwkEcKey = (() => {
140
+ const defaults = () => ({});
141
+ const create = (() => {
142
+ return uniffiCreateRecord<JwkEcKey, ReturnType<typeof defaults>>(defaults);
143
+ })();
144
+ return Object.freeze({
145
+ /**
146
+ * Create a frozen instance of {@link JwkEcKey}, with defaults specified
147
+ * in Rust, in the {@link zcam1_certs_utils} crate.
148
+ */
149
+ create,
150
+
151
+ /**
152
+ * Create a frozen instance of {@link JwkEcKey}, with defaults specified
153
+ * in Rust, in the {@link zcam1_certs_utils} crate.
154
+ */
155
+ new: create,
156
+
157
+ /**
158
+ * Defaults specified in the {@link zcam1_certs_utils} crate.
159
+ */
160
+ defaults: () => Object.freeze(defaults()) as Partial<JwkEcKey>,
161
+ });
162
+ })();
163
+
164
+ const FfiConverterTypeJwkEcKey = (() => {
165
+ type TypeName = JwkEcKey;
166
+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
167
+ read(from: RustBuffer): TypeName {
168
+ return {
169
+ kty: FfiConverterString.read(from),
170
+ crv: FfiConverterString.read(from),
171
+ x: FfiConverterString.read(from),
172
+ y: FfiConverterString.read(from),
173
+ };
174
+ }
175
+ write(value: TypeName, into: RustBuffer): void {
176
+ FfiConverterString.write(value.kty, into);
177
+ FfiConverterString.write(value.crv, into);
178
+ FfiConverterString.write(value.x, into);
179
+ FfiConverterString.write(value.y, into);
180
+ }
181
+ allocationSize(value: TypeName): number {
182
+ return (
183
+ FfiConverterString.allocationSize(value.kty) +
184
+ FfiConverterString.allocationSize(value.crv) +
185
+ FfiConverterString.allocationSize(value.x) +
186
+ FfiConverterString.allocationSize(value.y)
187
+ );
188
+ }
189
+ }
190
+ return new FFIConverter();
191
+ })();
192
+
193
+ export type SelfSignedCertChain = {
194
+ rootCertSubject: string;
195
+ intermediateCertSubject: string;
196
+ leafCertSubject: string;
197
+ leafOrganization: string;
198
+ };
199
+
200
+ /**
201
+ * Generated factory for {@link SelfSignedCertChain} record objects.
202
+ */
203
+ export const SelfSignedCertChain = (() => {
204
+ const defaults = () => ({});
205
+ const create = (() => {
206
+ return uniffiCreateRecord<SelfSignedCertChain, ReturnType<typeof defaults>>(defaults);
207
+ })();
208
+ return Object.freeze({
209
+ /**
210
+ * Create a frozen instance of {@link SelfSignedCertChain}, with defaults specified
211
+ * in Rust, in the {@link zcam1_certs_utils} crate.
212
+ */
213
+ create,
214
+
215
+ /**
216
+ * Create a frozen instance of {@link SelfSignedCertChain}, with defaults specified
217
+ * in Rust, in the {@link zcam1_certs_utils} crate.
218
+ */
219
+ new: create,
220
+
221
+ /**
222
+ * Defaults specified in the {@link zcam1_certs_utils} crate.
223
+ */
224
+ defaults: () => Object.freeze(defaults()) as Partial<SelfSignedCertChain>,
225
+ });
226
+ })();
227
+
228
+ const FfiConverterTypeSelfSignedCertChain = (() => {
229
+ type TypeName = SelfSignedCertChain;
230
+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
231
+ read(from: RustBuffer): TypeName {
232
+ return {
233
+ rootCertSubject: FfiConverterString.read(from),
234
+ intermediateCertSubject: FfiConverterString.read(from),
235
+ leafCertSubject: FfiConverterString.read(from),
236
+ leafOrganization: FfiConverterString.read(from),
237
+ };
238
+ }
239
+ write(value: TypeName, into: RustBuffer): void {
240
+ FfiConverterString.write(value.rootCertSubject, into);
241
+ FfiConverterString.write(value.intermediateCertSubject, into);
242
+ FfiConverterString.write(value.leafCertSubject, into);
243
+ FfiConverterString.write(value.leafOrganization, into);
244
+ }
245
+ allocationSize(value: TypeName): number {
246
+ return (
247
+ FfiConverterString.allocationSize(value.rootCertSubject) +
248
+ FfiConverterString.allocationSize(value.intermediateCertSubject) +
249
+ FfiConverterString.allocationSize(value.leafCertSubject) +
250
+ FfiConverterString.allocationSize(value.leafOrganization)
251
+ );
252
+ }
253
+ }
254
+ return new FFIConverter();
255
+ })();
256
+
257
+ const stringConverter = {
258
+ stringToBytes: (s: string) =>
259
+ uniffiCaller.rustCall((status) =>
260
+ nativeModule().ubrn_uniffi_internal_fn_func_ffi__string_to_arraybuffer(s, status),
261
+ ),
262
+ bytesToString: (ab: UniffiByteArray) =>
263
+ uniffiCaller.rustCall((status) =>
264
+ nativeModule().ubrn_uniffi_internal_fn_func_ffi__arraybuffer_to_string(ab, status),
265
+ ),
266
+ stringByteLength: (s: string) =>
267
+ uniffiCaller.rustCall((status) =>
268
+ nativeModule().ubrn_uniffi_internal_fn_func_ffi__string_to_byte_length(s, status),
269
+ ),
270
+ };
271
+ const FfiConverterString = uniffiCreateFfiConverterString(stringConverter);
272
+
273
+ // Flat error type: CertsError
274
+ export enum CertsError_Tags {
275
+ Json = "Json",
276
+ RcGen = "RcGen",
277
+ Der = "Der",
278
+ Spki = "Spki",
279
+ Pkcs8 = "Pkcs8",
280
+ EllipticCurve = "EllipticCurve",
281
+ X509Cert = "X509Cert",
282
+ }
283
+ export const CertsError = (() => {
284
+ class Json extends UniffiError {
285
+ /**
286
+ * @private
287
+ * This field is private and should not be used.
288
+ */
289
+ readonly [uniffiTypeNameSymbol]: string = "CertsError";
290
+ /**
291
+ * @private
292
+ * This field is private and should not be used.
293
+ */
294
+ readonly [variantOrdinalSymbol] = 1;
295
+
296
+ public readonly tag = CertsError_Tags.Json;
297
+
298
+ constructor(message: string) {
299
+ super("CertsError", "Json", message);
300
+ }
301
+
302
+ static instanceOf(e: any): e is Json {
303
+ return instanceOf(e) && (e as any)[variantOrdinalSymbol] === 1;
304
+ }
305
+ }
306
+ class RcGen extends UniffiError {
307
+ /**
308
+ * @private
309
+ * This field is private and should not be used.
310
+ */
311
+ readonly [uniffiTypeNameSymbol]: string = "CertsError";
312
+ /**
313
+ * @private
314
+ * This field is private and should not be used.
315
+ */
316
+ readonly [variantOrdinalSymbol] = 2;
317
+
318
+ public readonly tag = CertsError_Tags.RcGen;
319
+
320
+ constructor(message: string) {
321
+ super("CertsError", "RcGen", message);
322
+ }
323
+
324
+ static instanceOf(e: any): e is RcGen {
325
+ return instanceOf(e) && (e as any)[variantOrdinalSymbol] === 2;
326
+ }
327
+ }
328
+ class Der extends UniffiError {
329
+ /**
330
+ * @private
331
+ * This field is private and should not be used.
332
+ */
333
+ readonly [uniffiTypeNameSymbol]: string = "CertsError";
334
+ /**
335
+ * @private
336
+ * This field is private and should not be used.
337
+ */
338
+ readonly [variantOrdinalSymbol] = 3;
339
+
340
+ public readonly tag = CertsError_Tags.Der;
341
+
342
+ constructor(message: string) {
343
+ super("CertsError", "Der", message);
344
+ }
345
+
346
+ static instanceOf(e: any): e is Der {
347
+ return instanceOf(e) && (e as any)[variantOrdinalSymbol] === 3;
348
+ }
349
+ }
350
+ class Spki extends UniffiError {
351
+ /**
352
+ * @private
353
+ * This field is private and should not be used.
354
+ */
355
+ readonly [uniffiTypeNameSymbol]: string = "CertsError";
356
+ /**
357
+ * @private
358
+ * This field is private and should not be used.
359
+ */
360
+ readonly [variantOrdinalSymbol] = 4;
361
+
362
+ public readonly tag = CertsError_Tags.Spki;
363
+
364
+ constructor(message: string) {
365
+ super("CertsError", "Spki", message);
366
+ }
367
+
368
+ static instanceOf(e: any): e is Spki {
369
+ return instanceOf(e) && (e as any)[variantOrdinalSymbol] === 4;
370
+ }
371
+ }
372
+ class Pkcs8 extends UniffiError {
373
+ /**
374
+ * @private
375
+ * This field is private and should not be used.
376
+ */
377
+ readonly [uniffiTypeNameSymbol]: string = "CertsError";
378
+ /**
379
+ * @private
380
+ * This field is private and should not be used.
381
+ */
382
+ readonly [variantOrdinalSymbol] = 5;
383
+
384
+ public readonly tag = CertsError_Tags.Pkcs8;
385
+
386
+ constructor(message: string) {
387
+ super("CertsError", "Pkcs8", message);
388
+ }
389
+
390
+ static instanceOf(e: any): e is Pkcs8 {
391
+ return instanceOf(e) && (e as any)[variantOrdinalSymbol] === 5;
392
+ }
393
+ }
394
+ class EllipticCurve extends UniffiError {
395
+ /**
396
+ * @private
397
+ * This field is private and should not be used.
398
+ */
399
+ readonly [uniffiTypeNameSymbol]: string = "CertsError";
400
+ /**
401
+ * @private
402
+ * This field is private and should not be used.
403
+ */
404
+ readonly [variantOrdinalSymbol] = 6;
405
+
406
+ public readonly tag = CertsError_Tags.EllipticCurve;
407
+
408
+ constructor(message: string) {
409
+ super("CertsError", "EllipticCurve", message);
410
+ }
411
+
412
+ static instanceOf(e: any): e is EllipticCurve {
413
+ return instanceOf(e) && (e as any)[variantOrdinalSymbol] === 6;
414
+ }
415
+ }
416
+ class X509Cert extends UniffiError {
417
+ /**
418
+ * @private
419
+ * This field is private and should not be used.
420
+ */
421
+ readonly [uniffiTypeNameSymbol]: string = "CertsError";
422
+ /**
423
+ * @private
424
+ * This field is private and should not be used.
425
+ */
426
+ readonly [variantOrdinalSymbol] = 7;
427
+
428
+ public readonly tag = CertsError_Tags.X509Cert;
429
+
430
+ constructor(message: string) {
431
+ super("CertsError", "X509Cert", message);
432
+ }
433
+
434
+ static instanceOf(e: any): e is X509Cert {
435
+ return instanceOf(e) && (e as any)[variantOrdinalSymbol] === 7;
436
+ }
437
+ }
438
+
439
+ // Utility function which does not rely on instanceof.
440
+ function instanceOf(e: any): e is CertsError {
441
+ return (e as any)[uniffiTypeNameSymbol] === "CertsError";
442
+ }
443
+ return {
444
+ Json,
445
+ RcGen,
446
+ Der,
447
+ Spki,
448
+ Pkcs8,
449
+ EllipticCurve,
450
+ X509Cert,
451
+ instanceOf,
452
+ };
453
+ })();
454
+
455
+ // Union type for CertsError error type.
456
+
457
+ export type CertsError = InstanceType<
458
+ (typeof CertsError)[keyof Omit<typeof CertsError, "instanceOf">]
459
+ >;
460
+
461
+ const FfiConverterTypeCertsError = (() => {
462
+ const intConverter = FfiConverterInt32;
463
+ type TypeName = CertsError;
464
+ class FfiConverter extends AbstractFfiConverterByteArray<TypeName> {
465
+ read(from: RustBuffer): TypeName {
466
+ switch (intConverter.read(from)) {
467
+ case 1:
468
+ return new CertsError.Json(FfiConverterString.read(from));
469
+
470
+ case 2:
471
+ return new CertsError.RcGen(FfiConverterString.read(from));
472
+
473
+ case 3:
474
+ return new CertsError.Der(FfiConverterString.read(from));
475
+
476
+ case 4:
477
+ return new CertsError.Spki(FfiConverterString.read(from));
478
+
479
+ case 5:
480
+ return new CertsError.Pkcs8(FfiConverterString.read(from));
481
+
482
+ case 6:
483
+ return new CertsError.EllipticCurve(FfiConverterString.read(from));
484
+
485
+ case 7:
486
+ return new CertsError.X509Cert(FfiConverterString.read(from));
487
+
488
+ default:
489
+ throw new UniffiInternalError.UnexpectedEnumCase();
490
+ }
491
+ }
492
+ write(value: TypeName, into: RustBuffer): void {
493
+ const obj = value as any;
494
+ const index = obj[variantOrdinalSymbol] as number;
495
+ intConverter.write(index, into);
496
+ }
497
+ allocationSize(value: TypeName): number {
498
+ return intConverter.allocationSize(0);
499
+ }
500
+ }
501
+ return new FfiConverter();
502
+ })();
503
+
504
+ // FfiConverter for SelfSignedCertChain | undefined
505
+ const FfiConverterOptionalTypeSelfSignedCertChain = new FfiConverterOptional(
506
+ FfiConverterTypeSelfSignedCertChain,
507
+ );
508
+
509
+ /**
510
+ * This should be called before anything else.
511
+ *
512
+ * It is likely that this is being done for you by the library's `index.ts`.
513
+ *
514
+ * It checks versions of uniffi between when the Rust scaffolding was generated
515
+ * and when the bindings were generated.
516
+ *
517
+ * It also initializes the machinery to enable Rust to talk back to Javascript.
518
+ */
519
+ function uniffiEnsureInitialized() {
520
+ // Get the bindings contract version from our ComponentInterface
521
+ const bindingsContractVersion = 29;
522
+ // Get the scaffolding contract version by calling the into the dylib
523
+ const scaffoldingContractVersion =
524
+ nativeModule().ubrn_ffi_zcam1_certs_utils_uniffi_contract_version();
525
+ if (bindingsContractVersion !== scaffoldingContractVersion) {
526
+ throw new UniffiInternalError.ContractVersionMismatch(
527
+ scaffoldingContractVersion,
528
+ bindingsContractVersion,
529
+ );
530
+ }
531
+ if (
532
+ nativeModule().ubrn_uniffi_zcam1_certs_utils_checksum_func_build_self_signed_certificate() !==
533
+ 5154
534
+ ) {
535
+ throw new UniffiInternalError.ApiChecksumMismatch(
536
+ "uniffi_zcam1_certs_utils_checksum_func_build_self_signed_certificate",
537
+ );
538
+ }
539
+ }
540
+
541
+ export default Object.freeze({
542
+ initialize: uniffiEnsureInitialized,
543
+ converters: {
544
+ FfiConverterTypeCertsError,
545
+ FfiConverterTypeExistingCertChain,
546
+ FfiConverterTypeJwkEcKey,
547
+ FfiConverterTypeSelfSignedCertChain,
548
+ },
549
+ });