@contentauth/c2pa-wasm 0.4.4 → 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 +12 -4
- package/package.json +5 -1
- package/pkg/c2pa.d.ts +180 -174
- package/pkg/c2pa.js +941 -942
- package/pkg/c2pa_bg.wasm +0 -0
- package/pkg/c2pa_bg.wasm.d.ts +15 -15
package/README.md
CHANGED
|
@@ -10,9 +10,9 @@ npm install @contentauth/c2pa-wasm
|
|
|
10
10
|
|
|
11
11
|
## Development
|
|
12
12
|
|
|
13
|
-
###
|
|
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.
|
|
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.
|
|
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
|
+
"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
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
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
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
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
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
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
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
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;
|