@contentauth/c2pa-wasm 0.11.1 → 0.11.3
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/README.md +5 -5
- package/package.json +1 -1
- package/pkg/c2pa.d.ts +26 -1
- package/pkg/c2pa.js +33 -3
- package/pkg/c2pa_bg.wasm +0 -0
- package/pkg/c2pa_bg.wasm.d.ts +2 -1
package/README.md
CHANGED
|
@@ -12,10 +12,10 @@ npm install @contentauth/c2pa-wasm
|
|
|
12
12
|
|
|
13
13
|
### Prerequisites
|
|
14
14
|
|
|
15
|
-
Ensure the repo-wide prerequisites are installed
|
|
15
|
+
Ensure the repo-wide prerequisites are installed:
|
|
16
16
|
|
|
17
17
|
- [Node.js](https://nodejs.org/) v22.22+
|
|
18
|
-
- [
|
|
18
|
+
- [Nx](https://nx.dev/getting-started/intro)
|
|
19
19
|
- [pnpm](https://pnpm.io/)
|
|
20
20
|
|
|
21
21
|
See the [c2pa-js README](../../README.md#prerequisites) for details.
|
|
@@ -46,7 +46,7 @@ rustup target add wasm32-unknown-unknown
|
|
|
46
46
|
|
|
47
47
|
#### wasm-bindgen-cli
|
|
48
48
|
|
|
49
|
-
The `wasm-bindgen-cli` provides options to tweak JavaScript generated by `wasm-
|
|
49
|
+
The `wasm-bindgen-cli` provides options to tweak JavaScript generated by `wasm-bindgen`.
|
|
50
50
|
|
|
51
51
|
For more information, see the [wasm-bindgen-cli documentation](https://wasm-bindgen.github.io/wasm-bindgen/reference/cli).
|
|
52
52
|
|
|
@@ -54,7 +54,7 @@ For more information, see the [wasm-bindgen-cli documentation](https://wasm-bind
|
|
|
54
54
|
cargo install wasm-bindgen-cli@0.2.122
|
|
55
55
|
```
|
|
56
56
|
|
|
57
|
-
> [!IMPORTANT]
|
|
57
|
+
> [!IMPORTANT]
|
|
58
58
|
> The version of `wasm-bindgen-cli` **must** match the version of the `wasm-bindgen` dependency in [`Cargo.toml`](https://github.com/contentauth/c2pa-js/blob/main/packages/c2pa-wasm/Cargo.toml). A version mismatch will cause build failures with errors like _"rust Wasm file schema version: X.X.X, this binary schema version: Y.Y.Y"_. If you encounter this, check `Cargo.toml` for the correct version and reinstall the CLI accordingly.
|
|
59
59
|
|
|
60
60
|
#### wasm-pack
|
|
@@ -83,6 +83,6 @@ The library relies on [`wasm-pack`](https://rustwasm.github.io/docs/wasm-pack/)
|
|
|
83
83
|
|
|
84
84
|
To run the tests:
|
|
85
85
|
|
|
86
|
-
```
|
|
86
|
+
```sh
|
|
87
87
|
nx test c2pa-wasm
|
|
88
88
|
```
|
package/package.json
CHANGED
package/pkg/c2pa.d.ts
CHANGED
|
@@ -139,6 +139,30 @@ export class WasmBuilder {
|
|
|
139
139
|
* "Save" a builder to an archive.
|
|
140
140
|
*/
|
|
141
141
|
toArchive(): Uint8Array;
|
|
142
|
+
/**
|
|
143
|
+
* Replaces the actions in the `c2pa.actions`/`c2pa.actions.v2` assertions with
|
|
144
|
+
* `action_groups`, computed on the JS side (see [`Self::filter_actions_at`]).
|
|
145
|
+
* `softwareAgents`/`allActionsIncluded`/`templates`/`metadata` are preserved as-is.
|
|
146
|
+
*
|
|
147
|
+
* A manifest can carry more than one actions assertion (the created-list and gathered-list
|
|
148
|
+
* entries are distinct assertions), so `action_groups` is a list-of-lists: one entry per
|
|
149
|
+
* actions assertion, in the same positional order this binding enumerates them.
|
|
150
|
+
*
|
|
151
|
+
* Each assertion is rewritten in place, which keeps its label, `created` flag, `kind`, and
|
|
152
|
+
* position in the assertion list — mirroring `Builder::filter_actions` in c2pa-rs. A group
|
|
153
|
+
* that is empty drops its assertion rather than writing an invalid empty actions array.
|
|
154
|
+
* No-op if there is no actions assertion. Use `add_action` for those.
|
|
155
|
+
*
|
|
156
|
+
* All fallible work runs before any mutation, so a failure never leaves a partially-rewritten
|
|
157
|
+
* builder. An existing but malformed actions assertion is surfaced as an error rather than
|
|
158
|
+
* silently replaced.
|
|
159
|
+
*
|
|
160
|
+
* The groups are written back verbatim: they are not validated or reordered, and unlike
|
|
161
|
+
* [`Self::filter_actions_at`] the inception action is not force-kept. A caller that drops
|
|
162
|
+
* `c2pa.created`/`c2pa.opened` or moves it out of first position can produce an actions
|
|
163
|
+
* array that fails validation at signing time.
|
|
164
|
+
*/
|
|
165
|
+
updateActionsAt(action_groups: any): void;
|
|
142
166
|
}
|
|
143
167
|
|
|
144
168
|
/**
|
|
@@ -217,9 +241,9 @@ export interface InitOutput {
|
|
|
217
241
|
readonly __wbg_wasmsigner_free: (a: number, b: number) => void;
|
|
218
242
|
readonly wasmsigner_fromDefinition: (a: any) => [number, number, number];
|
|
219
243
|
readonly loadSettings: (a: number, b: number) => [number, number];
|
|
220
|
-
readonly run: () => void;
|
|
221
244
|
readonly __wbg_wasmbuilder_free: (a: number, b: number) => void;
|
|
222
245
|
readonly __wbg_wasmreader_free: (a: number, b: number) => void;
|
|
246
|
+
readonly run: () => void;
|
|
223
247
|
readonly wasmbuilder_addAction: (a: number, b: any) => [number, number];
|
|
224
248
|
readonly wasmbuilder_addAssertion: (a: number, b: number, c: number, d: any) => [number, number];
|
|
225
249
|
readonly wasmbuilder_addIngredient: (a: number, b: number, c: number) => [number, number];
|
|
@@ -240,6 +264,7 @@ export interface InitOutput {
|
|
|
240
264
|
readonly wasmbuilder_sign: (a: number, b: any, c: number, d: number, e: any) => any;
|
|
241
265
|
readonly wasmbuilder_signAndGetManifestBytes: (a: number, b: any, c: number, d: number, e: any) => any;
|
|
242
266
|
readonly wasmbuilder_toArchive: (a: number) => [number, number, number];
|
|
267
|
+
readonly wasmbuilder_updateActionsAt: (a: number, b: any) => [number, number];
|
|
243
268
|
readonly wasmreader_activeLabel: (a: number) => [number, number];
|
|
244
269
|
readonly wasmreader_activeManifest: (a: number) => [number, number, number];
|
|
245
270
|
readonly wasmreader_crJson: (a: number) => [number, number];
|
package/pkg/c2pa.js
CHANGED
|
@@ -311,6 +311,36 @@ export class WasmBuilder {
|
|
|
311
311
|
}
|
|
312
312
|
return takeFromExternrefTable0(ret[0]);
|
|
313
313
|
}
|
|
314
|
+
/**
|
|
315
|
+
* Replaces the actions in the `c2pa.actions`/`c2pa.actions.v2` assertions with
|
|
316
|
+
* `action_groups`, computed on the JS side (see [`Self::filter_actions_at`]).
|
|
317
|
+
* `softwareAgents`/`allActionsIncluded`/`templates`/`metadata` are preserved as-is.
|
|
318
|
+
*
|
|
319
|
+
* A manifest can carry more than one actions assertion (the created-list and gathered-list
|
|
320
|
+
* entries are distinct assertions), so `action_groups` is a list-of-lists: one entry per
|
|
321
|
+
* actions assertion, in the same positional order this binding enumerates them.
|
|
322
|
+
*
|
|
323
|
+
* Each assertion is rewritten in place, which keeps its label, `created` flag, `kind`, and
|
|
324
|
+
* position in the assertion list — mirroring `Builder::filter_actions` in c2pa-rs. A group
|
|
325
|
+
* that is empty drops its assertion rather than writing an invalid empty actions array.
|
|
326
|
+
* No-op if there is no actions assertion. Use `add_action` for those.
|
|
327
|
+
*
|
|
328
|
+
* All fallible work runs before any mutation, so a failure never leaves a partially-rewritten
|
|
329
|
+
* builder. An existing but malformed actions assertion is surfaced as an error rather than
|
|
330
|
+
* silently replaced.
|
|
331
|
+
*
|
|
332
|
+
* The groups are written back verbatim: they are not validated or reordered, and unlike
|
|
333
|
+
* [`Self::filter_actions_at`] the inception action is not force-kept. A caller that drops
|
|
334
|
+
* `c2pa.created`/`c2pa.opened` or moves it out of first position can produce an actions
|
|
335
|
+
* array that fails validation at signing time.
|
|
336
|
+
* @param {any} action_groups
|
|
337
|
+
*/
|
|
338
|
+
updateActionsAt(action_groups) {
|
|
339
|
+
const ret = wasm.wasmbuilder_updateActionsAt(this.__wbg_ptr, action_groups);
|
|
340
|
+
if (ret[1]) {
|
|
341
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
314
344
|
}
|
|
315
345
|
if (Symbol.dispose) WasmBuilder.prototype[Symbol.dispose] = WasmBuilder.prototype.free;
|
|
316
346
|
|
|
@@ -1000,12 +1030,12 @@ function __wbg_get_imports() {
|
|
|
1000
1030
|
return ret;
|
|
1001
1031
|
},
|
|
1002
1032
|
__wbindgen_cast_0000000000000001: function(arg0, arg1) {
|
|
1003
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx:
|
|
1033
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 3077, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
1004
1034
|
const ret = makeMutClosure(arg0, arg1, wasm_bindgen_304c265eb9e6f0af___convert__closures_____invoke___wasm_bindgen_304c265eb9e6f0af___JsValue__core_9b3796e30d99ddb7___result__Result_____wasm_bindgen_304c265eb9e6f0af___JsError___true_);
|
|
1005
1035
|
return ret;
|
|
1006
1036
|
},
|
|
1007
1037
|
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
|
1008
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [], shim_idx:
|
|
1038
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [], shim_idx: 1847, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
1009
1039
|
const ret = makeMutClosure(arg0, arg1, wasm_bindgen_304c265eb9e6f0af___convert__closures_____invoke_______true_);
|
|
1010
1040
|
return ret;
|
|
1011
1041
|
},
|
|
@@ -1410,4 +1440,4 @@ async function __wbg_init(module_or_path) {
|
|
|
1410
1440
|
}
|
|
1411
1441
|
|
|
1412
1442
|
export { initSync, __wbg_init as default };
|
|
1413
|
-
export const WASM_SRI = "sha512
|
|
1443
|
+
export const WASM_SRI = "sha512-MqM7VL8b6NoK003EIdVNEV5gmt/a52dS+KYs96DK45qy5YfEQFKGDTDBJszTSSoGP7JoRfYqLw5ER1FQnnf1jw==";
|
package/pkg/c2pa_bg.wasm
CHANGED
|
Binary file
|
package/pkg/c2pa_bg.wasm.d.ts
CHANGED
|
@@ -4,9 +4,9 @@ export const memory: WebAssembly.Memory;
|
|
|
4
4
|
export const __wbg_wasmsigner_free: (a: number, b: number) => void;
|
|
5
5
|
export const wasmsigner_fromDefinition: (a: any) => [number, number, number];
|
|
6
6
|
export const loadSettings: (a: number, b: number) => [number, number];
|
|
7
|
-
export const run: () => void;
|
|
8
7
|
export const __wbg_wasmbuilder_free: (a: number, b: number) => void;
|
|
9
8
|
export const __wbg_wasmreader_free: (a: number, b: number) => void;
|
|
9
|
+
export const run: () => void;
|
|
10
10
|
export const wasmbuilder_addAction: (a: number, b: any) => [number, number];
|
|
11
11
|
export const wasmbuilder_addAssertion: (a: number, b: number, c: number, d: any) => [number, number];
|
|
12
12
|
export const wasmbuilder_addIngredient: (a: number, b: number, c: number) => [number, number];
|
|
@@ -27,6 +27,7 @@ export const wasmbuilder_setThumbnailFromBlob: (a: number, b: number, c: number,
|
|
|
27
27
|
export const wasmbuilder_sign: (a: number, b: any, c: number, d: number, e: any) => any;
|
|
28
28
|
export const wasmbuilder_signAndGetManifestBytes: (a: number, b: any, c: number, d: number, e: any) => any;
|
|
29
29
|
export const wasmbuilder_toArchive: (a: number) => [number, number, number];
|
|
30
|
+
export const wasmbuilder_updateActionsAt: (a: number, b: any) => [number, number];
|
|
30
31
|
export const wasmreader_activeLabel: (a: number) => [number, number];
|
|
31
32
|
export const wasmreader_activeManifest: (a: number) => [number, number, number];
|
|
32
33
|
export const wasmreader_crJson: (a: number) => [number, number];
|