@contentauth/c2pa-wasm 0.4.3 → 0.4.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.
package/README.md CHANGED
@@ -10,9 +10,9 @@ npm install @contentauth/c2pa-wasm
10
10
 
11
11
  ## Development
12
12
 
13
- ### Prerequsities
13
+ ### Prerequisites
14
14
 
15
- Ensure the repo-wide prerequisites [NX](https://nx.dev/getting-started/intro) and [pnpm](https://pnpm.io/) are installed.
15
+ Ensure the repo-wide prerequisites ([Node.js](https://nodejs.org/) v22+, [NX](https://nx.dev/getting-started/intro), and [pnpm](https://pnpm.io/)) are installed. See the [top-level README](https://github.com/contentauth/c2pa-js#prerequisites) for details.
16
16
 
17
17
  Then, all of the following prerequisites must be installed before `c2pa-wasm` can be built:
18
18
 
@@ -20,7 +20,13 @@ Then, all of the following prerequisites must be installed before `c2pa-wasm` ca
20
20
 
21
21
  [Installation instructions](https://www.rust-lang.org/tools/install)
22
22
 
23
- Minimum supported Rust version: **1.86.0**.
23
+ Minimum supported Rust version: **1.88.0**.
24
+
25
+ To install Rust via [rustup](https://rustup.rs/):
26
+
27
+ ```sh
28
+ curl https://sh.rustup.rs -sSf | sh
29
+ ```
24
30
 
25
31
  Additionally, the `wasm32-unknown-unknown` target must be installed:
26
32
 
@@ -33,9 +39,11 @@ rustup target add wasm32-unknown-unknown
33
39
  [Documentation](https://wasm-bindgen.github.io/wasm-bindgen/reference/cli)
34
40
 
35
41
  ```sh
36
- cargo install wasm-bindgen-cli@0.2.106
42
+ cargo install wasm-bindgen-cli@0.2.108
37
43
  ```
38
44
 
45
+ > **Important:** The version of `wasm-bindgen-cli` **must** match the version of the `wasm-bindgen` dependency in [`Cargo.toml`](./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.
46
+
39
47
  #### wasm-pack
40
48
 
41
49
  [Documentation](https://rustwasm.github.io/docs/wasm-pack/)
package/package.json CHANGED
@@ -1,7 +1,11 @@
1
1
  {
2
2
  "name": "@contentauth/c2pa-wasm",
3
- "version": "0.4.3",
3
+ "version": "0.4.5",
4
4
  "license": "MIT",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/contentauth/c2pa-js"
8
+ },
5
9
  "type": "module",
6
10
  "module": "./pkg/c2pa.js",
7
11
  "types": "./pkg/c2pa.d.ts",
package/pkg/c2pa.d.ts CHANGED
@@ -9,131 +9,137 @@ interface SignerDefinition {
9
9
 
10
10
 
11
11
 
12
+ /**
13
+ * Wraps a `c2pa::Builder`.
14
+ */
12
15
  export class WasmBuilder {
13
- private constructor();
14
- free(): void;
15
- [Symbol.dispose](): void;
16
- /**
17
- * Add an action to the manifest's `Actions` assertion.
18
- */
19
- addAction(action: any): void;
20
- /**
21
- * Sets the builder "intent."
22
- */
23
- setIntent(json_intent: any): void;
24
- /**
25
- * "Save" a builder to an archive.
26
- */
27
- toArchive(): Uint8Array;
28
- /**
29
- * Attempts to create a new `WasmBuilder` from a builder archive.
30
- * Optionally accepts a context JSON string to configure the builder.
31
- */
32
- static fromArchive(archive: Blob, _context_json?: string | null): WasmBuilder;
33
- /**
34
- * Sets the state of the no_embed flag.
35
- */
36
- setNoEmbed(no_embed: boolean): void;
37
- /**
38
- * Add an ingredient to the manifest from a JSON ingredient definition without a blob
39
- *
40
- * # Arguments
41
- * * `ingredient_json` - A JSON string representing the ingredient.
42
- */
43
- addIngredient(json: string): void;
44
- /**
45
- * Get the current manifest definition.
46
- */
47
- getDefinition(): string;
48
- /**
49
- * Sets the remote_url for a remote manifest.
50
- *
51
- * The URL must return the manifest data and is injected into the destination asset when signing.
52
- * For remote-only manifests, set the `no_embed` flag to `true`.
53
- */
54
- setRemoteUrl(url: string): void;
55
- /**
56
- * Add a [`Blob`] to the manifest as a resource. The ID must match an identifier in the manifest.
57
- */
58
- addResourceFromBlob(id: string, blob: Blob): void;
59
- /**
60
- * Sets a thumbnail from a [`Blob`] to be included in the manifest. The thumbnail should represent the asset being signed.
61
- */
62
- setThumbnailFromBlob(format: string, blob: Blob): void;
63
- /**
64
- * Add an ingredient to the manifest from a JSON ingredient definition and a [`Blob`].
65
- *
66
- * # Arguments
67
- * * `ingredient_json` - A JSON string representing the ingredient. This ingredient is merged with the ingredient specified in the `stream` argument, and these values take precedence.
68
- * * `format` - The format of the ingredient.
69
- * * `blob` - A [`Blob`] representing an asset which should be included as an ingredient.
70
- */
71
- addIngredientFromBlob(json: string, format: string, blob: Blob): void;
72
- /**
73
- * Sign an asset using the provided SignerDefinition, format, and source Blob.
74
- * Use this method to get both the manifest bytes and the bytes of the signed asset.
75
- */
76
- signAndGetManifestBytes(signer_definition: SignerDefinition, format: string, source: Blob): Promise<any>;
77
- /**
78
- * Creates a new `WasmBuilder` with a minimal manifest definition.
79
- * Optionally accepts a context JSON string to configure the builder.
80
- */
81
- static new(context_json?: string | null): WasmBuilder;
82
- /**
83
- * Sign an asset using the provided SignerDefinition, format, and source Blob.
84
- */
85
- sign(signer_definition: SignerDefinition, format: string, source: Blob): Promise<Uint8Array>;
86
- /**
87
- * Attempts to create a new `WasmBuilder` from a JSON ManifestDefinition string.
88
- * Optionally accepts a context JSON string to configure the builder.
89
- */
90
- static fromJson(json: string, context_json?: string | null): WasmBuilder;
16
+ private constructor();
17
+ free(): void;
18
+ [Symbol.dispose](): void;
19
+ /**
20
+ * Add an action to the manifest's `Actions` assertion.
21
+ */
22
+ addAction(action: any): void;
23
+ /**
24
+ * Add an ingredient to the manifest from a JSON ingredient definition without a blob
25
+ *
26
+ * # Arguments
27
+ * * `ingredient_json` - A JSON string representing the ingredient.
28
+ */
29
+ addIngredient(json: string): void;
30
+ /**
31
+ * Add an ingredient to the manifest from a JSON ingredient definition and a [`Blob`].
32
+ *
33
+ * # Arguments
34
+ * * `ingredient_json` - A JSON string representing the ingredient. This ingredient is merged with the ingredient specified in the `stream` argument, and these values take precedence.
35
+ * * `format` - The format of the ingredient.
36
+ * * `blob` - A [`Blob`] representing an asset which should be included as an ingredient.
37
+ */
38
+ addIngredientFromBlob(json: string, format: string, blob: Blob): void;
39
+ /**
40
+ * Add a [`Blob`] to the manifest as a resource. The ID must match an identifier in the manifest.
41
+ */
42
+ addResourceFromBlob(id: string, blob: Blob): void;
43
+ /**
44
+ * Attempts to create a new `WasmBuilder` from a builder archive.
45
+ * Optionally accepts a context JSON string to configure the builder.
46
+ */
47
+ static fromArchive(archive: Blob, context_json?: string | null): WasmBuilder;
48
+ /**
49
+ * Attempts to create a new `WasmBuilder` from a JSON ManifestDefinition string.
50
+ * Optionally accepts a context JSON string to configure the builder.
51
+ */
52
+ static fromJson(json: string, context_json?: string | null): WasmBuilder;
53
+ /**
54
+ * Get the current manifest definition.
55
+ */
56
+ getDefinition(): string;
57
+ /**
58
+ * Creates a new `WasmBuilder` with a minimal manifest definition.
59
+ * Optionally accepts a context JSON string to configure the builder.
60
+ */
61
+ static new(context_json?: string | null): WasmBuilder;
62
+ /**
63
+ * Sets the builder "intent."
64
+ */
65
+ setIntent(json_intent: any): void;
66
+ /**
67
+ * Sets the state of the no_embed flag.
68
+ */
69
+ setNoEmbed(no_embed: boolean): void;
70
+ /**
71
+ * Sets the remote_url for a remote manifest.
72
+ *
73
+ * The URL must return the manifest data and is injected into the destination asset when signing.
74
+ * For remote-only manifests, set the `no_embed` flag to `true`.
75
+ */
76
+ setRemoteUrl(url: string): void;
77
+ /**
78
+ * Sets a thumbnail from a [`Blob`] to be included in the manifest. The thumbnail should represent the asset being signed.
79
+ */
80
+ setThumbnailFromBlob(format: string, blob: Blob): void;
81
+ /**
82
+ * Sign an asset using the provided SignerDefinition, format, and source Blob.
83
+ */
84
+ sign(signer_definition: SignerDefinition, format: string, source: Blob): Promise<Uint8Array>;
85
+ /**
86
+ * Sign an asset using the provided SignerDefinition, format, and source Blob.
87
+ * Use this method to get both the manifest bytes and the bytes of the signed asset.
88
+ */
89
+ signAndGetManifestBytes(signer_definition: SignerDefinition, format: string, source: Blob): Promise<any>;
90
+ /**
91
+ * "Save" a builder to an archive.
92
+ */
93
+ toArchive(): Uint8Array;
91
94
  }
92
95
 
96
+ /**
97
+ * Wraps a `c2pa::Reader`.
98
+ */
93
99
  export class WasmReader {
94
- private constructor();
95
- free(): void;
96
- [Symbol.dispose](): void;
97
- /**
98
- * Returns the label of the asset's active manifest.
99
- */
100
- activeLabel(): string | undefined;
101
- /**
102
- * Returns the asset's manifest store.
103
- */
104
- manifestStore(): any;
105
- /**
106
- * Returns the asset's active manifest.
107
- */
108
- activeManifest(): any;
109
- /**
110
- * Accepts a URI reference to a binary object in the resource store and returns a `js_sys::Uint8Array` containing the resource's bytes.
111
- */
112
- resourceToBytes(uri: string): Uint8Array;
113
- /**
114
- * Attempts to create a new `WasmReader` from an asset format, a `Blob` of the bytes of the initial segment, and a fragment `Blob`.
115
- * Optionally accepts a context JSON string to configure the reader.
116
- */
117
- static fromBlobFragment(format: string, init: Blob, fragment: Blob, context_json?: string | null): Promise<WasmReader>;
118
- /**
119
- * Returns a JSON representation of the asset's manifest store.
120
- */
121
- json(): string;
122
- /**
123
- * Attempts to create a new `WasmReader` from an asset format and `Blob` of the asset's bytes.
124
- * Optionally accepts a context JSON string to configure the reader.
125
- */
126
- static fromBlob(format: string, blob: Blob, context_json?: string | null): Promise<WasmReader>;
100
+ private constructor();
101
+ free(): void;
102
+ [Symbol.dispose](): void;
103
+ /**
104
+ * Returns the label of the asset's active manifest.
105
+ */
106
+ activeLabel(): string | undefined;
107
+ /**
108
+ * Returns the asset's active manifest.
109
+ */
110
+ activeManifest(): any;
111
+ /**
112
+ * Attempts to create a new `WasmReader` from an asset format and `Blob` of the asset's bytes.
113
+ * Optionally accepts a context JSON string to configure the reader.
114
+ */
115
+ static fromBlob(format: string, blob: Blob, context_json?: string | null): Promise<WasmReader>;
116
+ /**
117
+ * Attempts to create a new `WasmReader` from an asset format, a `Blob` of the bytes of the initial segment, and a fragment `Blob`.
118
+ * Optionally accepts a context JSON string to configure the reader.
119
+ */
120
+ static fromBlobFragment(format: string, init: Blob, fragment: Blob, context_json?: string | null): Promise<WasmReader>;
121
+ /**
122
+ * Returns a JSON representation of the asset's manifest store.
123
+ */
124
+ json(): string;
125
+ /**
126
+ * Returns the asset's manifest store.
127
+ */
128
+ manifestStore(): any;
129
+ /**
130
+ * Accepts a URI reference to a binary object in the resource store and returns a `js_sys::Uint8Array` containing the resource's bytes.
131
+ */
132
+ resourceToBytes(uri: string): Uint8Array;
127
133
  }
128
134
 
129
135
  export class WasmSigner {
130
- private constructor();
131
- free(): void;
132
- [Symbol.dispose](): void;
133
- /**
134
- * Attempt to create a new [`WasmSigner`] from a SignerDefinition.
135
- */
136
- static fromDefinition(def: SignerDefinition): WasmSigner;
136
+ private constructor();
137
+ free(): void;
138
+ [Symbol.dispose](): void;
139
+ /**
140
+ * Attempt to create a new [`WasmSigner`] from a SignerDefinition.
141
+ */
142
+ static fromDefinition(def: SignerDefinition): WasmSigner;
137
143
  }
138
144
 
139
145
  /**
@@ -149,69 +155,69 @@ export function run(): void;
149
155
  export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
150
156
 
151
157
  export interface InitOutput {
152
- readonly memory: WebAssembly.Memory;
153
- readonly __wbg_wasmsigner_free: (a: number, b: number) => void;
154
- readonly wasmsigner_fromDefinition: (a: any) => [number, number, number];
155
- readonly __wbg_wasmbuilder_free: (a: number, b: number) => void;
156
- readonly loadSettings: (a: number, b: number) => [number, number];
157
- readonly wasmbuilder_addAction: (a: number, b: any) => [number, number];
158
- readonly wasmbuilder_addIngredient: (a: number, b: number, c: number) => [number, number];
159
- readonly wasmbuilder_addIngredientFromBlob: (a: number, b: number, c: number, d: number, e: number, f: any) => [number, number];
160
- readonly wasmbuilder_addResourceFromBlob: (a: number, b: number, c: number, d: any) => [number, number];
161
- readonly wasmbuilder_fromArchive: (a: any, b: number, c: number) => [number, number, number];
162
- readonly wasmbuilder_fromJson: (a: number, b: number, c: number, d: number) => [number, number, number];
163
- readonly wasmbuilder_getDefinition: (a: number) => [number, number, number];
164
- readonly wasmbuilder_new: (a: number, b: number) => [number, number, number];
165
- readonly wasmbuilder_setIntent: (a: number, b: any) => [number, number];
166
- readonly wasmbuilder_setNoEmbed: (a: number, b: number) => void;
167
- readonly wasmbuilder_setRemoteUrl: (a: number, b: number, c: number) => void;
168
- readonly wasmbuilder_setThumbnailFromBlob: (a: number, b: number, c: number, d: any) => [number, number];
169
- readonly wasmbuilder_sign: (a: number, b: any, c: number, d: number, e: any) => any;
170
- readonly wasmbuilder_signAndGetManifestBytes: (a: number, b: any, c: number, d: number, e: any) => any;
171
- readonly wasmbuilder_toArchive: (a: number) => [number, number, number];
172
- readonly __wbg_wasmreader_free: (a: number, b: number) => void;
173
- readonly run: () => void;
174
- readonly wasmreader_activeLabel: (a: number) => [number, number];
175
- readonly wasmreader_activeManifest: (a: number) => [number, number, number];
176
- readonly wasmreader_fromBlob: (a: number, b: number, c: any, d: number, e: number) => any;
177
- readonly wasmreader_fromBlobFragment: (a: number, b: number, c: any, d: any, e: number, f: number) => any;
178
- readonly wasmreader_json: (a: number) => [number, number];
179
- readonly wasmreader_manifestStore: (a: number) => [number, number, number];
180
- readonly wasmreader_resourceToBytes: (a: number, b: number, c: number) => [number, number, number];
181
- readonly wasm_bindgen__convert__closures_____invoke__hbb62da5b17229099: (a: number, b: number) => void;
182
- readonly wasm_bindgen__closure__destroy__h4cef5599c1857d46: (a: number, b: number) => void;
183
- readonly wasm_bindgen__convert__closures_____invoke__h6e57fd9fec4e535c: (a: number, b: number, c: any) => void;
184
- readonly wasm_bindgen__closure__destroy__h1529e0ff12464e8c: (a: number, b: number) => void;
185
- readonly wasm_bindgen__convert__closures_____invoke__ha15b80997070ee79: (a: number, b: number, c: any, d: any) => void;
186
- readonly __wbindgen_malloc: (a: number, b: number) => number;
187
- readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
188
- readonly __wbindgen_exn_store: (a: number) => void;
189
- readonly __externref_table_alloc: () => number;
190
- readonly __wbindgen_externrefs: WebAssembly.Table;
191
- readonly __wbindgen_free: (a: number, b: number, c: number) => void;
192
- readonly __externref_table_dealloc: (a: number) => void;
193
- readonly __wbindgen_start: () => void;
158
+ readonly memory: WebAssembly.Memory;
159
+ readonly __wbg_wasmreader_free: (a: number, b: number) => void;
160
+ readonly wasmreader_activeLabel: (a: number) => [number, number];
161
+ readonly wasmreader_activeManifest: (a: number) => [number, number, number];
162
+ readonly wasmreader_fromBlob: (a: number, b: number, c: any, d: number, e: number) => any;
163
+ readonly wasmreader_fromBlobFragment: (a: number, b: number, c: any, d: any, e: number, f: number) => any;
164
+ readonly wasmreader_json: (a: number) => [number, number];
165
+ readonly wasmreader_manifestStore: (a: number) => [number, number, number];
166
+ readonly wasmreader_resourceToBytes: (a: number, b: number, c: number) => [number, number, number];
167
+ readonly __wbg_wasmbuilder_free: (a: number, b: number) => void;
168
+ readonly wasmbuilder_addAction: (a: number, b: any) => [number, number];
169
+ readonly wasmbuilder_addIngredient: (a: number, b: number, c: number) => [number, number];
170
+ readonly wasmbuilder_addIngredientFromBlob: (a: number, b: number, c: number, d: number, e: number, f: any) => [number, number];
171
+ readonly wasmbuilder_addResourceFromBlob: (a: number, b: number, c: number, d: any) => [number, number];
172
+ readonly wasmbuilder_fromArchive: (a: any, b: number, c: number) => [number, number, number];
173
+ readonly wasmbuilder_fromJson: (a: number, b: number, c: number, d: number) => [number, number, number];
174
+ readonly wasmbuilder_getDefinition: (a: number) => [number, number, number];
175
+ readonly wasmbuilder_new: (a: number, b: number) => [number, number, number];
176
+ readonly wasmbuilder_setIntent: (a: number, b: any) => [number, number];
177
+ readonly wasmbuilder_setNoEmbed: (a: number, b: number) => void;
178
+ readonly wasmbuilder_setRemoteUrl: (a: number, b: number, c: number) => void;
179
+ readonly wasmbuilder_setThumbnailFromBlob: (a: number, b: number, c: number, d: any) => [number, number];
180
+ readonly wasmbuilder_sign: (a: number, b: any, c: number, d: number, e: any) => any;
181
+ readonly wasmbuilder_signAndGetManifestBytes: (a: number, b: any, c: number, d: number, e: any) => any;
182
+ readonly wasmbuilder_toArchive: (a: number) => [number, number, number];
183
+ readonly __wbg_wasmsigner_free: (a: number, b: number) => void;
184
+ readonly wasmsigner_fromDefinition: (a: any) => [number, number, number];
185
+ readonly loadSettings: (a: number, b: number) => [number, number];
186
+ readonly run: () => void;
187
+ readonly wasm_bindgen__closure__destroy__h6c572eed28725b35: (a: number, b: number) => void;
188
+ readonly wasm_bindgen__closure__destroy__hdc14e87eb7e60d10: (a: number, b: number) => void;
189
+ readonly wasm_bindgen__convert__closures_____invoke__h1ab8f2c4d39167e4: (a: number, b: number, c: any, d: any) => void;
190
+ readonly wasm_bindgen__convert__closures_____invoke__ha319c5c448ef8efe: (a: number, b: number, c: any) => void;
191
+ readonly wasm_bindgen__convert__closures_____invoke__h6d7af91d7cf01ed3: (a: number, b: number) => void;
192
+ readonly __wbindgen_malloc: (a: number, b: number) => number;
193
+ readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
194
+ readonly __wbindgen_exn_store: (a: number) => void;
195
+ readonly __externref_table_alloc: () => number;
196
+ readonly __wbindgen_externrefs: WebAssembly.Table;
197
+ readonly __wbindgen_free: (a: number, b: number, c: number) => void;
198
+ readonly __externref_table_dealloc: (a: number) => void;
199
+ readonly __wbindgen_start: () => void;
194
200
  }
195
201
 
196
202
  export type SyncInitInput = BufferSource | WebAssembly.Module;
197
203
 
198
204
  /**
199
- * Instantiates the given `module`, which can either be bytes or
200
- * a precompiled `WebAssembly.Module`.
201
- *
202
- * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
203
- *
204
- * @returns {InitOutput}
205
- */
205
+ * Instantiates the given `module`, which can either be bytes or
206
+ * a precompiled `WebAssembly.Module`.
207
+ *
208
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
209
+ *
210
+ * @returns {InitOutput}
211
+ */
206
212
  export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
207
213
 
208
214
  /**
209
- * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
210
- * for everything else, calls `WebAssembly.instantiate` directly.
211
- *
212
- * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
213
- *
214
- * @returns {Promise<InitOutput>}
215
- */
215
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
216
+ * for everything else, calls `WebAssembly.instantiate` directly.
217
+ *
218
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
219
+ *
220
+ * @returns {Promise<InitOutput>}
221
+ */
216
222
  export default function __wbg_init (module_or_path: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
217
223
  export declare const WASM_SRI: string;