@contentauth/c2pa-wasm 0.11.0 → 0.11.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 +1 -1
- package/pkg/c2pa.d.ts +37 -0
- package/pkg/c2pa.js +55 -3
- package/pkg/c2pa_bg.wasm +0 -0
- package/pkg/c2pa_bg.wasm.d.ts +2 -0
package/package.json
CHANGED
package/pkg/c2pa.d.ts
CHANGED
|
@@ -51,6 +51,17 @@ export class WasmBuilder {
|
|
|
51
51
|
* Add a [`Blob`] to the manifest as a resource. The ID must match an identifier in the manifest.
|
|
52
52
|
*/
|
|
53
53
|
addResourceFromBlob(id: string, blob: Blob): void;
|
|
54
|
+
/**
|
|
55
|
+
* Retains actions and ingredients together in one step, per
|
|
56
|
+
* `Builder::filter_actions_and_ingredients`. `action_indices`/`ingredient_indices` are
|
|
57
|
+
* 0-based indices into [`Self::get_definition`]'s `c2pa.actions` assertion / `ingredients`
|
|
58
|
+
* array, resolved on the JS side for the same reason as [`Self::filter_actions_at`].
|
|
59
|
+
*
|
|
60
|
+
* `rescue_ingredient` (driven by `ingredient_indices`) is evaluated for every ingredient
|
|
61
|
+
* first; any action referencing an ingredient it would rescue is force-kept regardless of
|
|
62
|
+
* `keep_action`.
|
|
63
|
+
*/
|
|
64
|
+
filterActionsAndIngredientsAt(action_indices: Uint32Array, ingredient_indices: Uint32Array): void;
|
|
54
65
|
/**
|
|
55
66
|
* Retains only the actions at the given 0-based indices into the actions currently returned
|
|
56
67
|
* by [`Self::get_definition`]'s `c2pa.actions` assertion.
|
|
@@ -128,6 +139,30 @@ export class WasmBuilder {
|
|
|
128
139
|
* "Save" a builder to an archive.
|
|
129
140
|
*/
|
|
130
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;
|
|
131
166
|
}
|
|
132
167
|
|
|
133
168
|
/**
|
|
@@ -215,6 +250,7 @@ export interface InitOutput {
|
|
|
215
250
|
readonly wasmbuilder_addIngredientFromBlob: (a: number, b: number, c: number, d: number, e: number, f: any) => any;
|
|
216
251
|
readonly wasmbuilder_addRedaction: (a: number, b: number, c: number, d: any) => [number, number];
|
|
217
252
|
readonly wasmbuilder_addResourceFromBlob: (a: number, b: number, c: number, d: any) => [number, number];
|
|
253
|
+
readonly wasmbuilder_filterActionsAndIngredientsAt: (a: number, b: number, c: number, d: number, e: number) => [number, number];
|
|
218
254
|
readonly wasmbuilder_filterActionsAt: (a: number, b: number, c: number) => [number, number];
|
|
219
255
|
readonly wasmbuilder_filterIngredientsAt: (a: number, b: number, c: number) => [number, number];
|
|
220
256
|
readonly wasmbuilder_fromArchive: (a: any, b: number, c: number) => [number, number, number];
|
|
@@ -228,6 +264,7 @@ export interface InitOutput {
|
|
|
228
264
|
readonly wasmbuilder_sign: (a: number, b: any, c: number, d: number, e: any) => any;
|
|
229
265
|
readonly wasmbuilder_signAndGetManifestBytes: (a: number, b: any, c: number, d: number, e: any) => any;
|
|
230
266
|
readonly wasmbuilder_toArchive: (a: number) => [number, number, number];
|
|
267
|
+
readonly wasmbuilder_updateActionsAt: (a: number, b: any) => [number, number];
|
|
231
268
|
readonly wasmreader_activeLabel: (a: number) => [number, number];
|
|
232
269
|
readonly wasmreader_activeManifest: (a: number) => [number, number, number];
|
|
233
270
|
readonly wasmreader_crJson: (a: number) => [number, number];
|
package/pkg/c2pa.js
CHANGED
|
@@ -107,6 +107,28 @@ export class WasmBuilder {
|
|
|
107
107
|
throw takeFromExternrefTable0(ret[0]);
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
|
+
/**
|
|
111
|
+
* Retains actions and ingredients together in one step, per
|
|
112
|
+
* `Builder::filter_actions_and_ingredients`. `action_indices`/`ingredient_indices` are
|
|
113
|
+
* 0-based indices into [`Self::get_definition`]'s `c2pa.actions` assertion / `ingredients`
|
|
114
|
+
* array, resolved on the JS side for the same reason as [`Self::filter_actions_at`].
|
|
115
|
+
*
|
|
116
|
+
* `rescue_ingredient` (driven by `ingredient_indices`) is evaluated for every ingredient
|
|
117
|
+
* first; any action referencing an ingredient it would rescue is force-kept regardless of
|
|
118
|
+
* `keep_action`.
|
|
119
|
+
* @param {Uint32Array} action_indices
|
|
120
|
+
* @param {Uint32Array} ingredient_indices
|
|
121
|
+
*/
|
|
122
|
+
filterActionsAndIngredientsAt(action_indices, ingredient_indices) {
|
|
123
|
+
const ptr0 = passArray32ToWasm0(action_indices, wasm.__wbindgen_malloc);
|
|
124
|
+
const len0 = WASM_VECTOR_LEN;
|
|
125
|
+
const ptr1 = passArray32ToWasm0(ingredient_indices, wasm.__wbindgen_malloc);
|
|
126
|
+
const len1 = WASM_VECTOR_LEN;
|
|
127
|
+
const ret = wasm.wasmbuilder_filterActionsAndIngredientsAt(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
128
|
+
if (ret[1]) {
|
|
129
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
110
132
|
/**
|
|
111
133
|
* Retains only the actions at the given 0-based indices into the actions currently returned
|
|
112
134
|
* by [`Self::get_definition`]'s `c2pa.actions` assertion.
|
|
@@ -289,6 +311,36 @@ export class WasmBuilder {
|
|
|
289
311
|
}
|
|
290
312
|
return takeFromExternrefTable0(ret[0]);
|
|
291
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
|
+
}
|
|
292
344
|
}
|
|
293
345
|
if (Symbol.dispose) WasmBuilder.prototype[Symbol.dispose] = WasmBuilder.prototype.free;
|
|
294
346
|
|
|
@@ -978,12 +1030,12 @@ function __wbg_get_imports() {
|
|
|
978
1030
|
return ret;
|
|
979
1031
|
},
|
|
980
1032
|
__wbindgen_cast_0000000000000001: function(arg0, arg1) {
|
|
981
|
-
// 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: 3103, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
982
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_);
|
|
983
1035
|
return ret;
|
|
984
1036
|
},
|
|
985
1037
|
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
|
986
|
-
// 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: 1861, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
987
1039
|
const ret = makeMutClosure(arg0, arg1, wasm_bindgen_304c265eb9e6f0af___convert__closures_____invoke_______true_);
|
|
988
1040
|
return ret;
|
|
989
1041
|
},
|
|
@@ -1388,4 +1440,4 @@ async function __wbg_init(module_or_path) {
|
|
|
1388
1440
|
}
|
|
1389
1441
|
|
|
1390
1442
|
export { initSync, __wbg_init as default };
|
|
1391
|
-
export const WASM_SRI = "sha512-
|
|
1443
|
+
export const WASM_SRI = "sha512-JDgJjxNbd/twwreFXlKMWAMvONRRKQot0lqVEL/GA4Uw5j4kTw1fSfLy14JE/mX1gyzDZdZsE+a8eg1QZkJ04Q==";
|
package/pkg/c2pa_bg.wasm
CHANGED
|
Binary file
|
package/pkg/c2pa_bg.wasm.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export const wasmbuilder_addIngredient: (a: number, b: number, c: number) => [nu
|
|
|
13
13
|
export const wasmbuilder_addIngredientFromBlob: (a: number, b: number, c: number, d: number, e: number, f: any) => any;
|
|
14
14
|
export const wasmbuilder_addRedaction: (a: number, b: number, c: number, d: any) => [number, number];
|
|
15
15
|
export const wasmbuilder_addResourceFromBlob: (a: number, b: number, c: number, d: any) => [number, number];
|
|
16
|
+
export const wasmbuilder_filterActionsAndIngredientsAt: (a: number, b: number, c: number, d: number, e: number) => [number, number];
|
|
16
17
|
export const wasmbuilder_filterActionsAt: (a: number, b: number, c: number) => [number, number];
|
|
17
18
|
export const wasmbuilder_filterIngredientsAt: (a: number, b: number, c: number) => [number, number];
|
|
18
19
|
export const wasmbuilder_fromArchive: (a: any, b: number, c: number) => [number, number, number];
|
|
@@ -26,6 +27,7 @@ export const wasmbuilder_setThumbnailFromBlob: (a: number, b: number, c: number,
|
|
|
26
27
|
export const wasmbuilder_sign: (a: number, b: any, c: number, d: number, e: any) => any;
|
|
27
28
|
export const wasmbuilder_signAndGetManifestBytes: (a: number, b: any, c: number, d: number, e: any) => any;
|
|
28
29
|
export const wasmbuilder_toArchive: (a: number) => [number, number, number];
|
|
30
|
+
export const wasmbuilder_updateActionsAt: (a: number, b: any) => [number, number];
|
|
29
31
|
export const wasmreader_activeLabel: (a: number) => [number, number];
|
|
30
32
|
export const wasmreader_activeManifest: (a: number) => [number, number, number];
|
|
31
33
|
export const wasmreader_crJson: (a: number) => [number, number];
|