@succinctlabs/react-native-zcam1 0.3.0 → 0.3.13

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 (43) hide show
  1. package/ios/Zcam1Camera.swift +177 -9
  2. package/ios/Zcam1CameraFilmStyle.swift +18 -2
  3. package/ios/Zcam1CameraViewManager.m +4 -0
  4. package/ios/Zcam1DepthData.swift +219 -286
  5. package/lib/module/NativeZcam1Capture.js.map +1 -1
  6. package/lib/module/camera.js +113 -15
  7. package/lib/module/camera.js.map +1 -1
  8. package/lib/module/capture.js +21 -3
  9. package/lib/module/capture.js.map +1 -1
  10. package/lib/module/common.js +3 -2
  11. package/lib/module/common.js.map +1 -1
  12. package/lib/module/generated/zcam1_c2pa_utils.js +85 -6
  13. package/lib/module/generated/zcam1_c2pa_utils.js.map +1 -1
  14. package/lib/module/generated/zcam1_verify_utils.js +80 -3
  15. package/lib/module/generated/zcam1_verify_utils.js.map +1 -1
  16. package/lib/module/index.js +1 -1
  17. package/lib/module/index.js.map +1 -1
  18. package/lib/module/utils.js +5 -4
  19. package/lib/module/utils.js.map +1 -1
  20. package/lib/typescript/src/NativeZcam1Capture.d.ts +10 -0
  21. package/lib/typescript/src/NativeZcam1Capture.d.ts.map +1 -1
  22. package/lib/typescript/src/camera.d.ts +36 -0
  23. package/lib/typescript/src/camera.d.ts.map +1 -1
  24. package/lib/typescript/src/capture.d.ts +8 -1
  25. package/lib/typescript/src/capture.d.ts.map +1 -1
  26. package/lib/typescript/src/common.d.ts.map +1 -1
  27. package/lib/typescript/src/generated/zcam1_c2pa_utils.d.ts +60 -0
  28. package/lib/typescript/src/generated/zcam1_c2pa_utils.d.ts.map +1 -1
  29. package/lib/typescript/src/generated/zcam1_verify_utils.d.ts +134 -3
  30. package/lib/typescript/src/generated/zcam1_verify_utils.d.ts.map +1 -1
  31. package/lib/typescript/src/index.d.ts +2 -2
  32. package/lib/typescript/src/index.d.ts.map +1 -1
  33. package/lib/typescript/src/utils.d.ts +1 -1
  34. package/lib/typescript/src/utils.d.ts.map +1 -1
  35. package/package.json +2 -1
  36. package/src/NativeZcam1Capture.ts +12 -0
  37. package/src/camera.tsx +179 -9
  38. package/src/capture.tsx +30 -3
  39. package/src/common.tsx +3 -2
  40. package/src/generated/zcam1_c2pa_utils.ts +126 -3
  41. package/src/generated/zcam1_verify_utils.ts +92 -3
  42. package/src/index.ts +2 -1
  43. package/src/utils.ts +7 -3
@@ -59,6 +59,14 @@ const uniffiIsDebug =
59
59
  false;
60
60
  // Public interface members begin here.
61
61
 
62
+ /**
63
+ * Verifies device bindings against a photo hash and its normalized capture metadata.
64
+ *
65
+ * Hashes `normalized_metadata` and `photo_hash` together as client data, then
66
+ * validates the Apple attestation certificate and the assertion signature.
67
+ * Returns `Err(SimulatorNotAllowed)` if a simulator mock attestation is presented
68
+ * with `production` set to `true`.
69
+ */
62
70
  export function verifyBindingsFromManifest(
63
71
  bindings: DeviceBindings,
64
72
  normalizedMetadata: string,
@@ -130,7 +138,10 @@ export enum VerifyError_Tags {
130
138
  Base64 = "Base64",
131
139
  Io = "Io",
132
140
  Groth16 = "Groth16",
141
+ BindingsNotFound = "BindingsNotFound",
133
142
  ProofNotFound = "ProofNotFound",
143
+ MetadataNotFound = "MetadataNotFound",
144
+ SimulatorNotAllowed = "SimulatorNotAllowed",
134
145
  }
135
146
  export const VerifyError = (() => {
136
147
  class C2pa extends UniffiError {
@@ -243,7 +254,7 @@ export const VerifyError = (() => {
243
254
  return instanceOf(e) && (e as any)[variantOrdinalSymbol] === 5;
244
255
  }
245
256
  }
246
- class ProofNotFound extends UniffiError {
257
+ class BindingsNotFound extends UniffiError {
247
258
  /**
248
259
  * @private
249
260
  * This field is private and should not be used.
@@ -255,6 +266,28 @@ export const VerifyError = (() => {
255
266
  */
256
267
  readonly [variantOrdinalSymbol] = 6;
257
268
 
269
+ public readonly tag = VerifyError_Tags.BindingsNotFound;
270
+
271
+ constructor(message: string) {
272
+ super("VerifyError", "BindingsNotFound", message);
273
+ }
274
+
275
+ static instanceOf(e: any): e is BindingsNotFound {
276
+ return instanceOf(e) && (e as any)[variantOrdinalSymbol] === 6;
277
+ }
278
+ }
279
+ class ProofNotFound extends UniffiError {
280
+ /**
281
+ * @private
282
+ * This field is private and should not be used.
283
+ */
284
+ readonly [uniffiTypeNameSymbol]: string = "VerifyError";
285
+ /**
286
+ * @private
287
+ * This field is private and should not be used.
288
+ */
289
+ readonly [variantOrdinalSymbol] = 7;
290
+
258
291
  public readonly tag = VerifyError_Tags.ProofNotFound;
259
292
 
260
293
  constructor(message: string) {
@@ -262,7 +295,51 @@ export const VerifyError = (() => {
262
295
  }
263
296
 
264
297
  static instanceOf(e: any): e is ProofNotFound {
265
- return instanceOf(e) && (e as any)[variantOrdinalSymbol] === 6;
298
+ return instanceOf(e) && (e as any)[variantOrdinalSymbol] === 7;
299
+ }
300
+ }
301
+ class MetadataNotFound extends UniffiError {
302
+ /**
303
+ * @private
304
+ * This field is private and should not be used.
305
+ */
306
+ readonly [uniffiTypeNameSymbol]: string = "VerifyError";
307
+ /**
308
+ * @private
309
+ * This field is private and should not be used.
310
+ */
311
+ readonly [variantOrdinalSymbol] = 8;
312
+
313
+ public readonly tag = VerifyError_Tags.MetadataNotFound;
314
+
315
+ constructor(message: string) {
316
+ super("VerifyError", "MetadataNotFound", message);
317
+ }
318
+
319
+ static instanceOf(e: any): e is MetadataNotFound {
320
+ return instanceOf(e) && (e as any)[variantOrdinalSymbol] === 8;
321
+ }
322
+ }
323
+ class SimulatorNotAllowed extends UniffiError {
324
+ /**
325
+ * @private
326
+ * This field is private and should not be used.
327
+ */
328
+ readonly [uniffiTypeNameSymbol]: string = "VerifyError";
329
+ /**
330
+ * @private
331
+ * This field is private and should not be used.
332
+ */
333
+ readonly [variantOrdinalSymbol] = 9;
334
+
335
+ public readonly tag = VerifyError_Tags.SimulatorNotAllowed;
336
+
337
+ constructor(message: string) {
338
+ super("VerifyError", "SimulatorNotAllowed", message);
339
+ }
340
+
341
+ static instanceOf(e: any): e is SimulatorNotAllowed {
342
+ return instanceOf(e) && (e as any)[variantOrdinalSymbol] === 9;
266
343
  }
267
344
  }
268
345
 
@@ -276,7 +353,10 @@ export const VerifyError = (() => {
276
353
  Base64,
277
354
  Io,
278
355
  Groth16,
356
+ BindingsNotFound,
279
357
  ProofNotFound,
358
+ MetadataNotFound,
359
+ SimulatorNotAllowed,
280
360
  instanceOf,
281
361
  };
282
362
  })();
@@ -309,8 +389,17 @@ const FfiConverterTypeVerifyError = (() => {
309
389
  return new VerifyError.Groth16(FfiConverterString.read(from));
310
390
 
311
391
  case 6:
392
+ return new VerifyError.BindingsNotFound(FfiConverterString.read(from));
393
+
394
+ case 7:
312
395
  return new VerifyError.ProofNotFound(FfiConverterString.read(from));
313
396
 
397
+ case 8:
398
+ return new VerifyError.MetadataNotFound(FfiConverterString.read(from));
399
+
400
+ case 9:
401
+ return new VerifyError.SimulatorNotAllowed(FfiConverterString.read(from));
402
+
314
403
  default:
315
404
  throw new UniffiInternalError.UnexpectedEnumCase();
316
405
  }
@@ -351,7 +440,7 @@ function uniffiEnsureInitialized() {
351
440
  }
352
441
  if (
353
442
  nativeModule().ubrn_uniffi_zcam1_verify_utils_checksum_func_verify_bindings_from_manifest() !==
354
- 62750
443
+ 5253
355
444
  ) {
356
445
  throw new UniffiInternalError.ApiChecksumMismatch(
357
446
  "uniffi_zcam1_verify_utils_checksum_func_verify_bindings_from_manifest",
package/src/index.ts CHANGED
@@ -39,6 +39,7 @@ export type {
39
39
  CaptureFormat,
40
40
  FilmStyleEffect,
41
41
  FilmStyleRecipe,
42
+ HardwareShutterAction,
42
43
  HighlightShadowConfig,
43
44
  MonochromeConfig,
44
45
  TakePhotoOptions,
@@ -47,7 +48,7 @@ export type {
47
48
  } from "./camera";
48
49
  export { ZCamera } from "./camera";
49
50
  export type { CaptureInfo, DeviceOrientation } from "./capture";
50
- export { initCapture, previewFile } from "./capture";
51
+ export { initCapture, previewFile, requestLocationPermission, updateRegistration } from "./capture";
51
52
 
52
53
  /**
53
54
  * Core cryptographic key types and secure enclave utilities.
package/src/utils.ts CHANGED
@@ -17,6 +17,7 @@ export async function generateAppAttestAssertion(
17
17
  dataHash: ArrayBuffer,
18
18
  normalizedMetadata: string,
19
19
  deviceKeyId: string,
20
+ production: boolean,
20
21
  ): Promise<string> {
21
22
  let assertion: string;
22
23
 
@@ -30,11 +31,14 @@ export async function generateAppAttestAssertion(
30
31
  } catch (error: unknown) {
31
32
  const err = error as { code?: string; message?: string } | undefined;
32
33
  if (err?.code === "-1" || err?.message?.includes("UNSUPPORTED_SERVICE")) {
34
+ if (production) {
35
+ throw new Error(
36
+ "ZCAM: Simulator is not supported in production mode. Set production: false for development.",
37
+ );
38
+ }
33
39
  console.warn(
34
- "[ZCAMs] Running in simulator - using mock attestation. This is for development only.",
40
+ "[ZCAM] Running in simulator - using mock assertion. This is for development only.",
35
41
  );
36
- // Use a mock attestation for simulator testing
37
- // In production, this would need to be rejected by the backend
38
42
  assertion = `SIMULATOR_MOCK_${deviceKeyId}_${Date.now()}`;
39
43
  } else {
40
44
  throw error;