@succinctlabs/react-native-zcam1 0.2.7 → 0.4.0-alpha.1
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/Zcam1Sdk.podspec +2 -2
- package/android/CMakeLists.txt +114 -0
- package/android/build.gradle +213 -0
- package/android/cpp-adapter-proving.cpp +35 -0
- package/android/cpp-adapter.cpp +35 -0
- package/android/src/main/AndroidManifest.xml +5 -0
- package/android/src/main/java/com/succinctlabs/zcam1sdk/Zcam1CaptureModule.kt +156 -0
- package/android/src/main/java/com/succinctlabs/zcam1sdk/Zcam1CapturePackage.kt +38 -0
- package/android/src/main/java/com/succinctlabs/zcam1sdk/Zcam1ProvingModule.kt +43 -0
- package/android/src/main/java/com/succinctlabs/zcam1sdk/Zcam1ProvingPackage.kt +34 -0
- package/android/src/main/java/com/succinctlabs/zcam1sdk/Zcam1SdkModule.kt +43 -0
- package/android/src/main/java/com/succinctlabs/zcam1sdk/Zcam1SdkPackage.kt +34 -0
- package/android/src/main/java/com/succinctlabs/zcam1sdk/camera/CameraUtils.kt +80 -0
- package/android/src/main/java/com/succinctlabs/zcam1sdk/camera/Zcam1CameraService.kt +588 -0
- package/android/src/main/java/com/succinctlabs/zcam1sdk/camera/Zcam1CameraView.kt +107 -0
- package/android/src/main/java/com/succinctlabs/zcam1sdk/camera/Zcam1CameraViewManager.kt +33 -0
- package/android/src/main/java/com/succinctlabs/zcam1sdk/camera/Zcam1OrientationManager.kt +73 -0
- package/cpp/generated/zcam1_c2pa_utils.cpp +170 -365
- package/cpp/generated/zcam1_c2pa_utils.hpp +0 -4
- package/cpp/generated/zcam1_certs_utils.cpp +121 -250
- package/cpp/generated/zcam1_common.cpp +1871 -0
- package/cpp/generated/zcam1_common.hpp +52 -0
- package/cpp/generated/zcam1_verify_utils.cpp +138 -265
- package/cpp/generated/zcam1_verify_utils.hpp +2 -2
- package/cpp/proving/generated/zcam1_common.cpp +1871 -0
- package/cpp/proving/generated/zcam1_common.hpp +52 -0
- package/cpp/proving/generated/zcam1_proving_utils.cpp +355 -417
- package/cpp/proving/generated/zcam1_proving_utils.hpp +13 -17
- package/cpp/proving/zcam1-proving.cpp +2 -0
- package/cpp/zcam1-sdk.cpp +2 -0
- package/lib/module/bindings.js +4 -0
- package/lib/module/bindings.js.map +1 -1
- package/lib/module/camera.js +71 -13
- package/lib/module/camera.js.map +1 -1
- package/lib/module/capture.js +115 -38
- package/lib/module/capture.js.map +1 -1
- package/lib/module/common.js +18 -2
- package/lib/module/common.js.map +1 -1
- package/lib/module/generated/zcam1_c2pa_utils-ffi.js +4 -0
- package/lib/module/generated/zcam1_c2pa_utils-ffi.js.map +1 -1
- package/lib/module/generated/zcam1_c2pa_utils.js +117 -9
- package/lib/module/generated/zcam1_c2pa_utils.js.map +1 -1
- package/lib/module/generated/zcam1_certs_utils-ffi.js +4 -0
- package/lib/module/generated/zcam1_certs_utils-ffi.js.map +1 -1
- package/lib/module/generated/zcam1_certs_utils.js +6 -2
- package/lib/module/generated/zcam1_certs_utils.js.map +1 -1
- package/lib/module/generated/zcam1_common-ffi.js +47 -0
- package/lib/module/generated/zcam1_common-ffi.js.map +1 -0
- package/lib/module/generated/zcam1_common.js +60 -0
- package/lib/module/generated/zcam1_common.js.map +1 -0
- package/lib/module/generated/zcam1_proving_utils-ffi.js +4 -0
- package/lib/module/generated/zcam1_proving_utils-ffi.js.map +1 -1
- package/lib/module/generated/zcam1_proving_utils.js +53 -46
- package/lib/module/generated/zcam1_proving_utils.js.map +1 -1
- package/lib/module/generated/zcam1_verify_utils-ffi.js +4 -0
- package/lib/module/generated/zcam1_verify_utils-ffi.js.map +1 -1
- package/lib/module/generated/zcam1_verify_utils.js +70 -22
- package/lib/module/generated/zcam1_verify_utils.js.map +1 -1
- package/lib/module/index.js +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/proving/NativeZcam1Proving.js +1 -1
- package/lib/module/proving/index.js +1 -1
- package/lib/module/proving/index.js.map +1 -1
- package/lib/module/proving/prove.js +14 -8
- package/lib/module/proving/prove.js.map +1 -1
- package/lib/module/utils.js +19 -14
- package/lib/module/utils.js.map +1 -1
- package/lib/module/verify.js +14 -22
- package/lib/module/verify.js.map +1 -1
- package/lib/typescript/src/bindings.d.ts +3 -0
- package/lib/typescript/src/bindings.d.ts.map +1 -1
- package/lib/typescript/src/camera.d.ts +15 -0
- package/lib/typescript/src/camera.d.ts.map +1 -1
- package/lib/typescript/src/capture.d.ts +40 -1
- package/lib/typescript/src/capture.d.ts.map +1 -1
- package/lib/typescript/src/common.d.ts.map +1 -1
- package/lib/typescript/src/generated/zcam1_c2pa_utils-ffi.d.ts +37 -46
- package/lib/typescript/src/generated/zcam1_c2pa_utils-ffi.d.ts.map +1 -1
- package/lib/typescript/src/generated/zcam1_c2pa_utils.d.ts +110 -8
- package/lib/typescript/src/generated/zcam1_c2pa_utils.d.ts.map +1 -1
- package/lib/typescript/src/generated/zcam1_certs_utils-ffi.d.ts +27 -32
- package/lib/typescript/src/generated/zcam1_certs_utils-ffi.d.ts.map +1 -1
- package/lib/typescript/src/generated/zcam1_certs_utils.d.ts.map +1 -1
- package/lib/typescript/src/generated/zcam1_common-ffi.d.ts +77 -0
- package/lib/typescript/src/generated/zcam1_common-ffi.d.ts.map +1 -0
- package/lib/typescript/src/generated/zcam1_common.d.ts +17 -0
- package/lib/typescript/src/generated/zcam1_common.d.ts.map +1 -0
- package/lib/typescript/src/generated/zcam1_proving_utils-ffi.d.ts +44 -51
- package/lib/typescript/src/generated/zcam1_proving_utils-ffi.d.ts.map +1 -1
- package/lib/typescript/src/generated/zcam1_proving_utils.d.ts +26 -26
- package/lib/typescript/src/generated/zcam1_proving_utils.d.ts.map +1 -1
- package/lib/typescript/src/generated/zcam1_verify_utils-ffi.d.ts +29 -34
- package/lib/typescript/src/generated/zcam1_verify_utils-ffi.d.ts.map +1 -1
- package/lib/typescript/src/generated/zcam1_verify_utils.d.ts +94 -14
- package/lib/typescript/src/generated/zcam1_verify_utils.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +1 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/proving/NativeZcam1Proving.d.ts +1 -1
- package/lib/typescript/src/proving/index.d.ts +1 -1
- package/lib/typescript/src/proving/index.d.ts.map +1 -1
- package/lib/typescript/src/proving/prove.d.ts +3 -3
- package/lib/typescript/src/proving/prove.d.ts.map +1 -1
- package/lib/typescript/src/utils.d.ts.map +1 -1
- package/lib/typescript/src/verify.d.ts +4 -3
- package/lib/typescript/src/verify.d.ts.map +1 -1
- package/package.json +13 -6
- package/react-native.config.js +11 -0
- package/src/bindings.tsx +4 -0
- package/src/camera.tsx +116 -11
- package/src/capture.tsx +150 -53
- package/src/common.tsx +22 -2
- package/src/generated/zcam1_c2pa_utils-ffi.ts +42 -56
- package/src/generated/zcam1_c2pa_utils.ts +224 -67
- package/src/generated/zcam1_certs_utils-ffi.ts +33 -36
- package/src/generated/zcam1_certs_utils.ts +27 -24
- package/src/generated/zcam1_common-ffi.ts +183 -0
- package/src/generated/zcam1_common.ts +116 -0
- package/src/generated/zcam1_proving_utils-ffi.ts +54 -67
- package/src/generated/zcam1_proving_utils.ts +133 -138
- package/src/generated/zcam1_verify_utils-ffi.ts +39 -40
- package/src/generated/zcam1_verify_utils.ts +109 -47
- package/src/index.ts +1 -1
- package/src/proving/NativeZcam1Proving.ts +2 -2
- package/src/proving/index.ts +1 -1
- package/src/proving/prove.tsx +22 -11
- package/src/utils.ts +26 -20
- package/src/verify.tsx +25 -42
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
// This file was autogenerated by some hot garbage in the `uniffi-bindgen-react-native` crate.
|
|
2
2
|
// Trust me, you don't want to mess with it!
|
|
3
3
|
|
|
4
|
+
/* tslint:disable */
|
|
5
|
+
/* eslint-disable */
|
|
6
|
+
// @ts-nocheck
|
|
7
|
+
|
|
4
8
|
import {
|
|
5
9
|
type StructuralEquality as UniffiStructuralEquality,
|
|
6
10
|
type UniffiForeignFuture as RuntimeUniffiForeignFuture,
|
|
7
11
|
type UniffiRustCallStatus,
|
|
8
|
-
type
|
|
12
|
+
type UniffiGcObject,
|
|
9
13
|
type UniffiRustFutureContinuationCallback as RuntimeUniffiRustFutureContinuationCallback,
|
|
10
14
|
type UniffiResult,
|
|
11
15
|
} from "uniffi-bindgen-react-native";
|
|
@@ -30,14 +34,16 @@ interface NativeModuleInterface {
|
|
|
30
34
|
production: number,
|
|
31
35
|
uniffi_out_err: UniffiRustCallStatus,
|
|
32
36
|
): number;
|
|
33
|
-
|
|
37
|
+
ubrn_uniffi_zcam1_verify_utils_fn_func_verify_proof_from_manifest(
|
|
34
38
|
proof: Uint8Array,
|
|
35
|
-
|
|
36
|
-
|
|
39
|
+
vkHash: Uint8Array,
|
|
40
|
+
photoHash: Uint8Array,
|
|
41
|
+
appId: Uint8Array,
|
|
42
|
+
platform: Uint8Array,
|
|
37
43
|
uniffi_out_err: UniffiRustCallStatus,
|
|
38
44
|
): number;
|
|
39
45
|
ubrn_uniffi_zcam1_verify_utils_checksum_func_verify_bindings_from_manifest(): number;
|
|
40
|
-
|
|
46
|
+
ubrn_uniffi_zcam1_verify_utils_checksum_func_verify_proof_from_manifest(): number;
|
|
41
47
|
ubrn_ffi_zcam1_verify_utils_uniffi_contract_version(): number;
|
|
42
48
|
}
|
|
43
49
|
|
|
@@ -51,114 +57,107 @@ export default getter;
|
|
|
51
57
|
|
|
52
58
|
// Structs and function types for calling back into Typescript from Rust.
|
|
53
59
|
export type UniffiRustFutureContinuationCallback = (data: bigint, pollResult: number) => void;
|
|
54
|
-
type
|
|
60
|
+
export type UniffiForeignFutureDroppedCallback = (handle: bigint) => void;
|
|
55
61
|
type UniffiCallbackInterfaceFree = (handle: bigint) => void;
|
|
56
|
-
|
|
62
|
+
type UniffiCallbackInterfaceClone = (handle: bigint) => UniffiResult<void>;
|
|
63
|
+
export type UniffiForeignFutureDroppedCallbackStruct = {
|
|
57
64
|
handle: bigint;
|
|
58
|
-
free:
|
|
65
|
+
free: UniffiForeignFutureDroppedCallback;
|
|
59
66
|
};
|
|
60
|
-
export type
|
|
67
|
+
export type UniffiForeignFutureResultU8 = {
|
|
61
68
|
returnValue: number;
|
|
62
69
|
callStatus: UniffiRustCallStatus;
|
|
63
70
|
};
|
|
64
71
|
export type UniffiForeignFutureCompleteU8 = (
|
|
65
72
|
callbackData: bigint,
|
|
66
|
-
result:
|
|
73
|
+
result: UniffiForeignFutureResultU8,
|
|
67
74
|
) => void;
|
|
68
|
-
export type
|
|
75
|
+
export type UniffiForeignFutureResultI8 = {
|
|
69
76
|
returnValue: number;
|
|
70
77
|
callStatus: UniffiRustCallStatus;
|
|
71
78
|
};
|
|
72
79
|
export type UniffiForeignFutureCompleteI8 = (
|
|
73
80
|
callbackData: bigint,
|
|
74
|
-
result:
|
|
81
|
+
result: UniffiForeignFutureResultI8,
|
|
75
82
|
) => void;
|
|
76
|
-
export type
|
|
83
|
+
export type UniffiForeignFutureResultU16 = {
|
|
77
84
|
returnValue: number;
|
|
78
85
|
callStatus: UniffiRustCallStatus;
|
|
79
86
|
};
|
|
80
87
|
export type UniffiForeignFutureCompleteU16 = (
|
|
81
88
|
callbackData: bigint,
|
|
82
|
-
result:
|
|
89
|
+
result: UniffiForeignFutureResultU16,
|
|
83
90
|
) => void;
|
|
84
|
-
export type
|
|
91
|
+
export type UniffiForeignFutureResultI16 = {
|
|
85
92
|
returnValue: number;
|
|
86
93
|
callStatus: UniffiRustCallStatus;
|
|
87
94
|
};
|
|
88
95
|
export type UniffiForeignFutureCompleteI16 = (
|
|
89
96
|
callbackData: bigint,
|
|
90
|
-
result:
|
|
97
|
+
result: UniffiForeignFutureResultI16,
|
|
91
98
|
) => void;
|
|
92
|
-
export type
|
|
99
|
+
export type UniffiForeignFutureResultU32 = {
|
|
93
100
|
returnValue: number;
|
|
94
101
|
callStatus: UniffiRustCallStatus;
|
|
95
102
|
};
|
|
96
103
|
export type UniffiForeignFutureCompleteU32 = (
|
|
97
104
|
callbackData: bigint,
|
|
98
|
-
result:
|
|
105
|
+
result: UniffiForeignFutureResultU32,
|
|
99
106
|
) => void;
|
|
100
|
-
export type
|
|
107
|
+
export type UniffiForeignFutureResultI32 = {
|
|
101
108
|
returnValue: number;
|
|
102
109
|
callStatus: UniffiRustCallStatus;
|
|
103
110
|
};
|
|
104
111
|
export type UniffiForeignFutureCompleteI32 = (
|
|
105
112
|
callbackData: bigint,
|
|
106
|
-
result:
|
|
113
|
+
result: UniffiForeignFutureResultI32,
|
|
107
114
|
) => void;
|
|
108
|
-
export type
|
|
115
|
+
export type UniffiForeignFutureResultU64 = {
|
|
109
116
|
returnValue: bigint;
|
|
110
117
|
callStatus: UniffiRustCallStatus;
|
|
111
118
|
};
|
|
112
119
|
export type UniffiForeignFutureCompleteU64 = (
|
|
113
120
|
callbackData: bigint,
|
|
114
|
-
result:
|
|
121
|
+
result: UniffiForeignFutureResultU64,
|
|
115
122
|
) => void;
|
|
116
|
-
export type
|
|
123
|
+
export type UniffiForeignFutureResultI64 = {
|
|
117
124
|
returnValue: bigint;
|
|
118
125
|
callStatus: UniffiRustCallStatus;
|
|
119
126
|
};
|
|
120
127
|
export type UniffiForeignFutureCompleteI64 = (
|
|
121
128
|
callbackData: bigint,
|
|
122
|
-
result:
|
|
129
|
+
result: UniffiForeignFutureResultI64,
|
|
123
130
|
) => void;
|
|
124
|
-
export type
|
|
131
|
+
export type UniffiForeignFutureResultF32 = {
|
|
125
132
|
returnValue: number;
|
|
126
133
|
callStatus: UniffiRustCallStatus;
|
|
127
134
|
};
|
|
128
135
|
export type UniffiForeignFutureCompleteF32 = (
|
|
129
136
|
callbackData: bigint,
|
|
130
|
-
result:
|
|
137
|
+
result: UniffiForeignFutureResultF32,
|
|
131
138
|
) => void;
|
|
132
|
-
export type
|
|
139
|
+
export type UniffiForeignFutureResultF64 = {
|
|
133
140
|
returnValue: number;
|
|
134
141
|
callStatus: UniffiRustCallStatus;
|
|
135
142
|
};
|
|
136
143
|
export type UniffiForeignFutureCompleteF64 = (
|
|
137
144
|
callbackData: bigint,
|
|
138
|
-
result:
|
|
139
|
-
) => void;
|
|
140
|
-
export type UniffiForeignFutureStructPointer = {
|
|
141
|
-
returnValue: bigint;
|
|
142
|
-
callStatus: UniffiRustCallStatus;
|
|
143
|
-
};
|
|
144
|
-
export type UniffiForeignFutureCompletePointer = (
|
|
145
|
-
callbackData: bigint,
|
|
146
|
-
result: UniffiForeignFutureStructPointer,
|
|
145
|
+
result: UniffiForeignFutureResultF64,
|
|
147
146
|
) => void;
|
|
148
|
-
export type
|
|
147
|
+
export type UniffiForeignFutureResultRustBuffer = {
|
|
149
148
|
returnValue: Uint8Array;
|
|
150
149
|
callStatus: UniffiRustCallStatus;
|
|
151
150
|
};
|
|
152
151
|
export type UniffiForeignFutureCompleteRustBuffer = (
|
|
153
152
|
callbackData: bigint,
|
|
154
|
-
result:
|
|
153
|
+
result: UniffiForeignFutureResultRustBuffer,
|
|
155
154
|
) => void;
|
|
156
|
-
export type
|
|
155
|
+
export type UniffiForeignFutureResultVoid = {
|
|
157
156
|
callStatus: UniffiRustCallStatus;
|
|
158
157
|
};
|
|
159
158
|
export type UniffiForeignFutureCompleteVoid = (
|
|
160
159
|
callbackData: bigint,
|
|
161
|
-
result:
|
|
160
|
+
result: UniffiForeignFutureResultVoid,
|
|
162
161
|
) => void;
|
|
163
162
|
|
|
164
163
|
// UniffiRustFutureContinuationCallback is generated as part of the component interface's
|
|
@@ -1,33 +1,36 @@
|
|
|
1
1
|
// This file was autogenerated by some hot garbage in the `uniffi-bindgen-react-native` crate.
|
|
2
2
|
// Trust me, you don't want to mess with it!
|
|
3
|
+
|
|
4
|
+
/* tslint:disable */
|
|
5
|
+
/* eslint-disable */
|
|
6
|
+
// @ts-nocheck
|
|
3
7
|
import nativeModule, {
|
|
4
8
|
type UniffiRustFutureContinuationCallback,
|
|
5
|
-
type
|
|
6
|
-
type
|
|
9
|
+
type UniffiForeignFutureDroppedCallback,
|
|
10
|
+
type UniffiForeignFutureDroppedCallbackStruct,
|
|
11
|
+
type UniffiForeignFutureResultU8,
|
|
7
12
|
type UniffiForeignFutureCompleteU8,
|
|
8
|
-
type
|
|
13
|
+
type UniffiForeignFutureResultI8,
|
|
9
14
|
type UniffiForeignFutureCompleteI8,
|
|
10
|
-
type
|
|
15
|
+
type UniffiForeignFutureResultU16,
|
|
11
16
|
type UniffiForeignFutureCompleteU16,
|
|
12
|
-
type
|
|
17
|
+
type UniffiForeignFutureResultI16,
|
|
13
18
|
type UniffiForeignFutureCompleteI16,
|
|
14
|
-
type
|
|
19
|
+
type UniffiForeignFutureResultU32,
|
|
15
20
|
type UniffiForeignFutureCompleteU32,
|
|
16
|
-
type
|
|
21
|
+
type UniffiForeignFutureResultI32,
|
|
17
22
|
type UniffiForeignFutureCompleteI32,
|
|
18
|
-
type
|
|
23
|
+
type UniffiForeignFutureResultU64,
|
|
19
24
|
type UniffiForeignFutureCompleteU64,
|
|
20
|
-
type
|
|
25
|
+
type UniffiForeignFutureResultI64,
|
|
21
26
|
type UniffiForeignFutureCompleteI64,
|
|
22
|
-
type
|
|
27
|
+
type UniffiForeignFutureResultF32,
|
|
23
28
|
type UniffiForeignFutureCompleteF32,
|
|
24
|
-
type
|
|
29
|
+
type UniffiForeignFutureResultF64,
|
|
25
30
|
type UniffiForeignFutureCompleteF64,
|
|
26
|
-
type
|
|
27
|
-
type UniffiForeignFutureCompletePointer,
|
|
28
|
-
type UniffiForeignFutureStructRustBuffer,
|
|
31
|
+
type UniffiForeignFutureResultRustBuffer,
|
|
29
32
|
type UniffiForeignFutureCompleteRustBuffer,
|
|
30
|
-
type
|
|
33
|
+
type UniffiForeignFutureResultVoid,
|
|
31
34
|
type UniffiForeignFutureCompleteVoid,
|
|
32
35
|
} from "./zcam1_verify_utils-ffi";
|
|
33
36
|
import { type DeviceBindings } from "./zcam1_c2pa_utils";
|
|
@@ -59,6 +62,9 @@ const uniffiIsDebug =
|
|
|
59
62
|
false;
|
|
60
63
|
// Public interface members begin here.
|
|
61
64
|
|
|
65
|
+
/**
|
|
66
|
+
* Verify Apple App Attest bindings from a C2PA manifest.
|
|
67
|
+
*/
|
|
62
68
|
export function verifyBindingsFromManifest(
|
|
63
69
|
bindings: DeviceBindings,
|
|
64
70
|
normalizedMetadata: string,
|
|
@@ -81,24 +87,23 @@ export function verifyBindingsFromManifest(
|
|
|
81
87
|
),
|
|
82
88
|
);
|
|
83
89
|
}
|
|
84
|
-
|
|
85
|
-
* Wrapper around [`sp1_verifier::Groth16Verifier::verify`].
|
|
86
|
-
*
|
|
87
|
-
* We hardcode the Groth16 VK bytes to only verify SP1 proofs.
|
|
88
|
-
*/
|
|
89
|
-
export function verifyGroth16(
|
|
90
|
+
export function verifyProofFromManifest(
|
|
90
91
|
proof: ArrayBuffer,
|
|
91
|
-
|
|
92
|
-
|
|
92
|
+
vkHash: string,
|
|
93
|
+
photoHash: ArrayBuffer,
|
|
94
|
+
appId: string,
|
|
95
|
+
platform: string,
|
|
93
96
|
): boolean /*throws*/ {
|
|
94
97
|
return FfiConverterBool.lift(
|
|
95
98
|
uniffiCaller.rustCallWithError(
|
|
96
99
|
/*liftError:*/ FfiConverterTypeVerifyError.lift.bind(FfiConverterTypeVerifyError),
|
|
97
100
|
/*caller:*/ (callStatus) => {
|
|
98
|
-
return nativeModule().
|
|
101
|
+
return nativeModule().ubrn_uniffi_zcam1_verify_utils_fn_func_verify_proof_from_manifest(
|
|
99
102
|
FfiConverterArrayBuffer.lower(proof),
|
|
100
|
-
|
|
101
|
-
|
|
103
|
+
FfiConverterString.lower(vkHash),
|
|
104
|
+
FfiConverterArrayBuffer.lower(photoHash),
|
|
105
|
+
FfiConverterString.lower(appId),
|
|
106
|
+
FfiConverterString.lower(platform),
|
|
102
107
|
callStatus,
|
|
103
108
|
);
|
|
104
109
|
},
|
|
@@ -127,10 +132,12 @@ const FfiConverterString = uniffiCreateFfiConverterString(stringConverter);
|
|
|
127
132
|
export enum VerifyError_Tags {
|
|
128
133
|
C2pa = "C2pa",
|
|
129
134
|
AppAttest = "AppAttest",
|
|
135
|
+
AndroidAttestation = "AndroidAttestation",
|
|
130
136
|
Base64 = "Base64",
|
|
131
137
|
Io = "Io",
|
|
132
138
|
Groth16 = "Groth16",
|
|
133
139
|
ProofNotFound = "ProofNotFound",
|
|
140
|
+
PlatformNotSupported = "PlatformNotSupported",
|
|
134
141
|
}
|
|
135
142
|
export const VerifyError = (() => {
|
|
136
143
|
class C2pa extends UniffiError {
|
|
@@ -145,7 +152,7 @@ export const VerifyError = (() => {
|
|
|
145
152
|
*/
|
|
146
153
|
readonly [variantOrdinalSymbol] = 1;
|
|
147
154
|
|
|
148
|
-
|
|
155
|
+
readonly tag = VerifyError_Tags.C2pa;
|
|
149
156
|
|
|
150
157
|
constructor(message: string) {
|
|
151
158
|
super("VerifyError", "C2pa", message);
|
|
@@ -167,7 +174,7 @@ export const VerifyError = (() => {
|
|
|
167
174
|
*/
|
|
168
175
|
readonly [variantOrdinalSymbol] = 2;
|
|
169
176
|
|
|
170
|
-
|
|
177
|
+
readonly tag = VerifyError_Tags.AppAttest;
|
|
171
178
|
|
|
172
179
|
constructor(message: string) {
|
|
173
180
|
super("VerifyError", "AppAttest", message);
|
|
@@ -177,7 +184,7 @@ export const VerifyError = (() => {
|
|
|
177
184
|
return instanceOf(e) && (e as any)[variantOrdinalSymbol] === 2;
|
|
178
185
|
}
|
|
179
186
|
}
|
|
180
|
-
class
|
|
187
|
+
class AndroidAttestation extends UniffiError {
|
|
181
188
|
/**
|
|
182
189
|
* @private
|
|
183
190
|
* This field is private and should not be used.
|
|
@@ -189,14 +196,36 @@ export const VerifyError = (() => {
|
|
|
189
196
|
*/
|
|
190
197
|
readonly [variantOrdinalSymbol] = 3;
|
|
191
198
|
|
|
192
|
-
|
|
199
|
+
readonly tag = VerifyError_Tags.AndroidAttestation;
|
|
200
|
+
|
|
201
|
+
constructor(message: string) {
|
|
202
|
+
super("VerifyError", "AndroidAttestation", message);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
static instanceOf(e: any): e is AndroidAttestation {
|
|
206
|
+
return instanceOf(e) && (e as any)[variantOrdinalSymbol] === 3;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
class Base64 extends UniffiError {
|
|
210
|
+
/**
|
|
211
|
+
* @private
|
|
212
|
+
* This field is private and should not be used.
|
|
213
|
+
*/
|
|
214
|
+
readonly [uniffiTypeNameSymbol]: string = "VerifyError";
|
|
215
|
+
/**
|
|
216
|
+
* @private
|
|
217
|
+
* This field is private and should not be used.
|
|
218
|
+
*/
|
|
219
|
+
readonly [variantOrdinalSymbol] = 4;
|
|
220
|
+
|
|
221
|
+
readonly tag = VerifyError_Tags.Base64;
|
|
193
222
|
|
|
194
223
|
constructor(message: string) {
|
|
195
224
|
super("VerifyError", "Base64", message);
|
|
196
225
|
}
|
|
197
226
|
|
|
198
227
|
static instanceOf(e: any): e is Base64 {
|
|
199
|
-
return instanceOf(e) && (e as any)[variantOrdinalSymbol] ===
|
|
228
|
+
return instanceOf(e) && (e as any)[variantOrdinalSymbol] === 4;
|
|
200
229
|
}
|
|
201
230
|
}
|
|
202
231
|
class Io extends UniffiError {
|
|
@@ -209,16 +238,16 @@ export const VerifyError = (() => {
|
|
|
209
238
|
* @private
|
|
210
239
|
* This field is private and should not be used.
|
|
211
240
|
*/
|
|
212
|
-
readonly [variantOrdinalSymbol] =
|
|
241
|
+
readonly [variantOrdinalSymbol] = 5;
|
|
213
242
|
|
|
214
|
-
|
|
243
|
+
readonly tag = VerifyError_Tags.Io;
|
|
215
244
|
|
|
216
245
|
constructor(message: string) {
|
|
217
246
|
super("VerifyError", "Io", message);
|
|
218
247
|
}
|
|
219
248
|
|
|
220
249
|
static instanceOf(e: any): e is Io {
|
|
221
|
-
return instanceOf(e) && (e as any)[variantOrdinalSymbol] ===
|
|
250
|
+
return instanceOf(e) && (e as any)[variantOrdinalSymbol] === 5;
|
|
222
251
|
}
|
|
223
252
|
}
|
|
224
253
|
class Groth16 extends UniffiError {
|
|
@@ -231,16 +260,16 @@ export const VerifyError = (() => {
|
|
|
231
260
|
* @private
|
|
232
261
|
* This field is private and should not be used.
|
|
233
262
|
*/
|
|
234
|
-
readonly [variantOrdinalSymbol] =
|
|
263
|
+
readonly [variantOrdinalSymbol] = 6;
|
|
235
264
|
|
|
236
|
-
|
|
265
|
+
readonly tag = VerifyError_Tags.Groth16;
|
|
237
266
|
|
|
238
267
|
constructor(message: string) {
|
|
239
268
|
super("VerifyError", "Groth16", message);
|
|
240
269
|
}
|
|
241
270
|
|
|
242
271
|
static instanceOf(e: any): e is Groth16 {
|
|
243
|
-
return instanceOf(e) && (e as any)[variantOrdinalSymbol] ===
|
|
272
|
+
return instanceOf(e) && (e as any)[variantOrdinalSymbol] === 6;
|
|
244
273
|
}
|
|
245
274
|
}
|
|
246
275
|
class ProofNotFound extends UniffiError {
|
|
@@ -253,16 +282,38 @@ export const VerifyError = (() => {
|
|
|
253
282
|
* @private
|
|
254
283
|
* This field is private and should not be used.
|
|
255
284
|
*/
|
|
256
|
-
readonly [variantOrdinalSymbol] =
|
|
285
|
+
readonly [variantOrdinalSymbol] = 7;
|
|
257
286
|
|
|
258
|
-
|
|
287
|
+
readonly tag = VerifyError_Tags.ProofNotFound;
|
|
259
288
|
|
|
260
289
|
constructor(message: string) {
|
|
261
290
|
super("VerifyError", "ProofNotFound", message);
|
|
262
291
|
}
|
|
263
292
|
|
|
264
293
|
static instanceOf(e: any): e is ProofNotFound {
|
|
265
|
-
return instanceOf(e) && (e as any)[variantOrdinalSymbol] ===
|
|
294
|
+
return instanceOf(e) && (e as any)[variantOrdinalSymbol] === 7;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
class PlatformNotSupported extends UniffiError {
|
|
298
|
+
/**
|
|
299
|
+
* @private
|
|
300
|
+
* This field is private and should not be used.
|
|
301
|
+
*/
|
|
302
|
+
readonly [uniffiTypeNameSymbol]: string = "VerifyError";
|
|
303
|
+
/**
|
|
304
|
+
* @private
|
|
305
|
+
* This field is private and should not be used.
|
|
306
|
+
*/
|
|
307
|
+
readonly [variantOrdinalSymbol] = 8;
|
|
308
|
+
|
|
309
|
+
readonly tag = VerifyError_Tags.PlatformNotSupported;
|
|
310
|
+
|
|
311
|
+
constructor(message: string) {
|
|
312
|
+
super("VerifyError", "PlatformNotSupported", message);
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
static instanceOf(e: any): e is PlatformNotSupported {
|
|
316
|
+
return instanceOf(e) && (e as any)[variantOrdinalSymbol] === 8;
|
|
266
317
|
}
|
|
267
318
|
}
|
|
268
319
|
|
|
@@ -273,10 +324,12 @@ export const VerifyError = (() => {
|
|
|
273
324
|
return {
|
|
274
325
|
C2pa,
|
|
275
326
|
AppAttest,
|
|
327
|
+
AndroidAttestation,
|
|
276
328
|
Base64,
|
|
277
329
|
Io,
|
|
278
330
|
Groth16,
|
|
279
331
|
ProofNotFound,
|
|
332
|
+
PlatformNotSupported,
|
|
280
333
|
instanceOf,
|
|
281
334
|
};
|
|
282
335
|
})();
|
|
@@ -300,17 +353,23 @@ const FfiConverterTypeVerifyError = (() => {
|
|
|
300
353
|
return new VerifyError.AppAttest(FfiConverterString.read(from));
|
|
301
354
|
|
|
302
355
|
case 3:
|
|
303
|
-
return new VerifyError.
|
|
356
|
+
return new VerifyError.AndroidAttestation(FfiConverterString.read(from));
|
|
304
357
|
|
|
305
358
|
case 4:
|
|
306
|
-
return new VerifyError.
|
|
359
|
+
return new VerifyError.Base64(FfiConverterString.read(from));
|
|
307
360
|
|
|
308
361
|
case 5:
|
|
309
|
-
return new VerifyError.
|
|
362
|
+
return new VerifyError.Io(FfiConverterString.read(from));
|
|
310
363
|
|
|
311
364
|
case 6:
|
|
365
|
+
return new VerifyError.Groth16(FfiConverterString.read(from));
|
|
366
|
+
|
|
367
|
+
case 7:
|
|
312
368
|
return new VerifyError.ProofNotFound(FfiConverterString.read(from));
|
|
313
369
|
|
|
370
|
+
case 8:
|
|
371
|
+
return new VerifyError.PlatformNotSupported(FfiConverterString.read(from));
|
|
372
|
+
|
|
314
373
|
default:
|
|
315
374
|
throw new UniffiInternalError.UnexpectedEnumCase();
|
|
316
375
|
}
|
|
@@ -339,7 +398,7 @@ const FfiConverterTypeVerifyError = (() => {
|
|
|
339
398
|
*/
|
|
340
399
|
function uniffiEnsureInitialized() {
|
|
341
400
|
// Get the bindings contract version from our ComponentInterface
|
|
342
|
-
const bindingsContractVersion =
|
|
401
|
+
const bindingsContractVersion = 30;
|
|
343
402
|
// Get the scaffolding contract version by calling the into the dylib
|
|
344
403
|
const scaffoldingContractVersion =
|
|
345
404
|
nativeModule().ubrn_ffi_zcam1_verify_utils_uniffi_contract_version();
|
|
@@ -351,15 +410,18 @@ function uniffiEnsureInitialized() {
|
|
|
351
410
|
}
|
|
352
411
|
if (
|
|
353
412
|
nativeModule().ubrn_uniffi_zcam1_verify_utils_checksum_func_verify_bindings_from_manifest() !==
|
|
354
|
-
|
|
413
|
+
22888
|
|
355
414
|
) {
|
|
356
415
|
throw new UniffiInternalError.ApiChecksumMismatch(
|
|
357
416
|
"uniffi_zcam1_verify_utils_checksum_func_verify_bindings_from_manifest",
|
|
358
417
|
);
|
|
359
418
|
}
|
|
360
|
-
if (
|
|
419
|
+
if (
|
|
420
|
+
nativeModule().ubrn_uniffi_zcam1_verify_utils_checksum_func_verify_proof_from_manifest() !==
|
|
421
|
+
49444
|
|
422
|
+
) {
|
|
361
423
|
throw new UniffiInternalError.ApiChecksumMismatch(
|
|
362
|
-
"
|
|
424
|
+
"uniffi_zcam1_verify_utils_checksum_func_verify_proof_from_manifest",
|
|
363
425
|
);
|
|
364
426
|
}
|
|
365
427
|
}
|
package/src/index.ts
CHANGED
|
@@ -47,7 +47,7 @@ export type {
|
|
|
47
47
|
} from "./camera";
|
|
48
48
|
export { ZCamera } from "./camera";
|
|
49
49
|
export type { CaptureInfo, DeviceOrientation } from "./capture";
|
|
50
|
-
export { initCapture, previewFile } from "./capture";
|
|
50
|
+
export { initCapture, previewFile, requestCameraPermission, requestLocationPermission, updateRegistration } from "./capture";
|
|
51
51
|
|
|
52
52
|
/**
|
|
53
53
|
* Core cryptographic key types and secure enclave utilities.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Generated by uniffi-bindgen-react-native
|
|
2
|
-
import type { TurboModule } from
|
|
3
|
-
import { TurboModuleRegistry } from
|
|
2
|
+
import type { TurboModule } from 'react-native';
|
|
3
|
+
import { TurboModuleRegistry } from 'react-native';
|
|
4
4
|
|
|
5
5
|
export interface Spec extends TurboModule {
|
|
6
6
|
installRustCrate(): boolean;
|
package/src/proving/index.ts
CHANGED
package/src/proving/prove.tsx
CHANGED
|
@@ -8,6 +8,8 @@ import React, {
|
|
|
8
8
|
useRef,
|
|
9
9
|
useState,
|
|
10
10
|
} from "react";
|
|
11
|
+
import { Platform } from "react-native";
|
|
12
|
+
import { isEmulator } from "react-native-device-info";
|
|
11
13
|
import { Dirs, Util } from "react-native-file-access";
|
|
12
14
|
|
|
13
15
|
import {
|
|
@@ -22,10 +24,10 @@ import { stripFileProtocol } from "../utils";
|
|
|
22
24
|
import {
|
|
23
25
|
FulfillmentStatus,
|
|
24
26
|
type Initialized,
|
|
25
|
-
IosProvingClient,
|
|
26
|
-
type IosProvingClientInterface,
|
|
27
27
|
ProofRequestStatus,
|
|
28
28
|
ProverNetworkMode,
|
|
29
|
+
ProvingClient as ProvingClientInner,
|
|
30
|
+
type ProvingClientInterface,
|
|
29
31
|
} from "./bindings";
|
|
30
32
|
|
|
31
33
|
export { ProverNetworkMode } from "./bindings";
|
|
@@ -57,7 +59,7 @@ async function createProvingClient(
|
|
|
57
59
|
onProofRequest?: (requestId: string, photoPath: string) => void,
|
|
58
60
|
): Promise<ProvingClient> {
|
|
59
61
|
let certChainPem: string;
|
|
60
|
-
let client:
|
|
62
|
+
let client: ProvingClientInterface;
|
|
61
63
|
const contentPublicKey = await getContentPublicKey();
|
|
62
64
|
|
|
63
65
|
if (contentPublicKey.kty !== "EC") {
|
|
@@ -76,9 +78,9 @@ async function createProvingClient(
|
|
|
76
78
|
|
|
77
79
|
if (settings.privateKey) {
|
|
78
80
|
const proverNetworkMode = settings.proverNetworkMode ?? ProverNetworkMode.Mainnet;
|
|
79
|
-
client = new
|
|
81
|
+
client = new ProvingClientInner(settings.privateKey, onInitialized, proverNetworkMode);
|
|
80
82
|
} else {
|
|
81
|
-
client =
|
|
83
|
+
client = ProvingClientInner.simulator(onInitialized);
|
|
82
84
|
}
|
|
83
85
|
|
|
84
86
|
return new ProvingClient(client, contentKeyId, certChainPem, settings.production, onProofRequest);
|
|
@@ -379,14 +381,14 @@ export function useProofRequestStatus(requestId: string | null): ProofRequestCon
|
|
|
379
381
|
}
|
|
380
382
|
|
|
381
383
|
export class ProvingClient {
|
|
382
|
-
client:
|
|
384
|
+
client: ProvingClientInterface;
|
|
383
385
|
contentKeyId: Uint8Array;
|
|
384
386
|
certChainPem: string;
|
|
385
387
|
production: boolean;
|
|
386
388
|
onProofRequest?: (requestId: string, photoPath: string) => void;
|
|
387
389
|
|
|
388
390
|
constructor(
|
|
389
|
-
client:
|
|
391
|
+
client: ProvingClientInterface,
|
|
390
392
|
contentKeyId: Uint8Array,
|
|
391
393
|
certChainPem: string,
|
|
392
394
|
production: boolean,
|
|
@@ -414,9 +416,7 @@ export class ProvingClient {
|
|
|
414
416
|
throw new Error(`Unsupported file format: ${originalPath}`);
|
|
415
417
|
}
|
|
416
418
|
|
|
417
|
-
const requestId = await this.client.requestProof(originalPath, format,
|
|
418
|
-
appAttestProduction: this.production,
|
|
419
|
-
});
|
|
419
|
+
const requestId = await this.client.requestProof(originalPath, format, this.production);
|
|
420
420
|
|
|
421
421
|
if (this.onProofRequest) {
|
|
422
422
|
this.onProofRequest(requestId, originalPath);
|
|
@@ -440,14 +440,24 @@ export class ProvingClient {
|
|
|
440
440
|
originalPath = stripFileProtocol(originalPath);
|
|
441
441
|
const format = formatFromPath(originalPath);
|
|
442
442
|
const ext = Util.extname(originalPath);
|
|
443
|
+
const isSimulator = await isEmulator();
|
|
443
444
|
|
|
444
445
|
if (format === undefined) {
|
|
445
446
|
throw new Error(`Unsupported file format: ${originalPath}`);
|
|
446
447
|
}
|
|
447
448
|
|
|
449
|
+
// On Android, pass the KeyStore alias so Rust signs via JNI.
|
|
450
|
+
// On iOS, pass the contentKeyId (SHA1 of public key) so Rust signs via Secure Enclave.
|
|
451
|
+
const keyTag =
|
|
452
|
+
Platform.OS === "android"
|
|
453
|
+
? new TextEncoder().encode(
|
|
454
|
+
isSimulator ? "ZCAM1_MOCK_CONTENT_KEY_TAG" : "ZCAM1_CONTENT_KEY_TAG",
|
|
455
|
+
)
|
|
456
|
+
: this.contentKeyId;
|
|
457
|
+
|
|
448
458
|
const manifestEditor = ManifestEditor.fromManifest(
|
|
449
459
|
originalPath,
|
|
450
|
-
|
|
460
|
+
keyTag.buffer as ArrayBuffer,
|
|
451
461
|
this.certChainPem,
|
|
452
462
|
);
|
|
453
463
|
|
|
@@ -459,6 +469,7 @@ export class ProvingClient {
|
|
|
459
469
|
JSON.stringify({
|
|
460
470
|
data: base64.encode(new Uint8Array(proof)),
|
|
461
471
|
vk_hash: vkHash,
|
|
472
|
+
platform: Platform.OS,
|
|
462
473
|
}),
|
|
463
474
|
);
|
|
464
475
|
|