@contentauth/c2pa-web 0.5.5 → 0.5.7
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 +156 -0
- package/dist/c2pa-Cwy5okL8.js +365 -0
- package/dist/common.d.ts +1 -1
- package/dist/common.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/inline.js +3 -3
- package/dist/lib/builder.d.ts +7 -3
- package/dist/lib/builder.d.ts.map +1 -1
- package/dist/lib/reader.d.ts +5 -2
- package/dist/lib/reader.d.ts.map +1 -1
- package/dist/lib/settings.d.ts +49 -0
- package/dist/lib/settings.d.ts.map +1 -1
- package/dist/lib/worker/rpc.d.ts +10 -10
- package/dist/lib/worker/rpc.d.ts.map +1 -1
- package/dist/resources/c2pa_bg.wasm +0 -0
- package/package.json +2 -2
- package/dist/c2pa-BXFwWMSz.js +0 -359
package/README.md
CHANGED
|
@@ -55,6 +55,8 @@ const c2pa = await createC2pa();
|
|
|
55
55
|
|
|
56
56
|
### Use
|
|
57
57
|
|
|
58
|
+
#### Reading C2PA Manifests
|
|
59
|
+
|
|
58
60
|
Fetch an image and provide it to the `Reader`:
|
|
59
61
|
|
|
60
62
|
```typescript
|
|
@@ -73,6 +75,160 @@ console.log(manifestStore);
|
|
|
73
75
|
await reader.free();
|
|
74
76
|
```
|
|
75
77
|
|
|
78
|
+
#### Building C2PA Manifests with Ingredients
|
|
79
|
+
|
|
80
|
+
The `Builder` API allows you to create C2PA manifests and add ingredients (source assets) to document the provenance chain.
|
|
81
|
+
|
|
82
|
+
##### Setting Builder Intent
|
|
83
|
+
|
|
84
|
+
The builder intent describes the type of operation being performed on the asset. This influences how the manifest is structured and what assertions are automatically added.
|
|
85
|
+
|
|
86
|
+
`create`: This is a new digital creation, a DigitalSourceType is required. The Manifest must not have have a parent ingredient. A `c2pa.created` action will be added if not provided.
|
|
87
|
+
|
|
88
|
+
`edit`: This is an edit of a pre-existing parent asset. The Manifest must have a parent ingredient. A parent ingredient will be generated from the source stream if not otherwise provided. A `c2pa.opened action will be tied to the parent ingredient.
|
|
89
|
+
|
|
90
|
+
`update`: A restricted version of Edit for non-editorial changes. There must be only one ingredient, as a parent. No changes can be made to the hashed content of the parent. There are additional restrictions on the types of changes that can be made.
|
|
91
|
+
|
|
92
|
+
```typescript
|
|
93
|
+
const builder = await c2pa.builder.new();
|
|
94
|
+
|
|
95
|
+
await builder.setIntent({
|
|
96
|
+
create: 'http://cv.iptc.org/newscodes/digitalsourcetype/trainedAlgorithmicMedia',
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
await builder.setIntent('edit');
|
|
100
|
+
|
|
101
|
+
await builder.setIntent('update');
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
The `create` intent accepts a `DigitalSourceType` that describes the origin of the asset. Common values include:
|
|
105
|
+
|
|
106
|
+
- `'http://cv.iptc.org/newscodes/digitalsourcetype/trainedAlgorithmicMedia'` - AI-generated content
|
|
107
|
+
- `'http://cv.iptc.org/newscodes/digitalsourcetype/digitalCapture'` - Digital camera capture
|
|
108
|
+
- `'http://cv.iptc.org/newscodes/digitalsourcetype/composite'` - Composite of multiple sources
|
|
109
|
+
|
|
110
|
+
For a complete list of digital source types, see the [C2PA specification](https://c2pa.org/specifications/specifications/2.2/specs/C2PA_Specification.html#_digital_source_type) and [IPTC digital source type vocabulary](https://cv.iptc.org/newscodes/digitalsourcetype).
|
|
111
|
+
|
|
112
|
+
For more details on builder intents, see the [c2pa-rs Builder documentation](https://docs.rs/c2pa/latest/c2pa/struct.Builder.html).
|
|
113
|
+
|
|
114
|
+
##### Adding Ingredients from Blobs
|
|
115
|
+
|
|
116
|
+
When you have access to the ingredient asset, use `addIngredientFromBlob` to include both the metadata and the asset data:
|
|
117
|
+
|
|
118
|
+
```typescript
|
|
119
|
+
// Fetch or load the ingredient asset
|
|
120
|
+
const ingredientResponse = await fetch('path/to/source-image.jpg');
|
|
121
|
+
const ingredientBlob = await ingredientResponse.blob();
|
|
122
|
+
|
|
123
|
+
// Create a builder
|
|
124
|
+
const builder = await c2pa.builder.new();
|
|
125
|
+
|
|
126
|
+
// Add the ingredient with its blob
|
|
127
|
+
await builder.addIngredientFromBlob(
|
|
128
|
+
{
|
|
129
|
+
title: 'source-image.jpg',
|
|
130
|
+
format: 'image/jpeg',
|
|
131
|
+
instance_id: 'ingredient-123',
|
|
132
|
+
relationship: 'parentOf',
|
|
133
|
+
},
|
|
134
|
+
'image/jpeg', // Format
|
|
135
|
+
ingredientBlob // The actual asset bytes
|
|
136
|
+
);
|
|
137
|
+
|
|
138
|
+
const definition = await builder.getDefinition();
|
|
139
|
+
console.log(definition.ingredients); // Contains the ingredient with embedded data
|
|
140
|
+
|
|
141
|
+
await builder.free();
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
##### Adding Multiple Ingredients
|
|
145
|
+
|
|
146
|
+
You can add multiple ingredients to document complex provenance chains:
|
|
147
|
+
|
|
148
|
+
```typescript
|
|
149
|
+
const builder = await c2pa.builder.new();
|
|
150
|
+
|
|
151
|
+
// Fetch ingredient assets
|
|
152
|
+
const background = await fetch('background.jpg').then((r) => r.blob());
|
|
153
|
+
const overlay = await fetch('overlay.png').then((r) => r.blob());
|
|
154
|
+
|
|
155
|
+
// Add first ingredient
|
|
156
|
+
await builder.addIngredientFromBlob(
|
|
157
|
+
{
|
|
158
|
+
title: 'background.jpg',
|
|
159
|
+
format: 'image/jpeg',
|
|
160
|
+
instance_id: 'background-001',
|
|
161
|
+
relationship: 'componentOf',
|
|
162
|
+
},
|
|
163
|
+
'image/jpeg',
|
|
164
|
+
background
|
|
165
|
+
);
|
|
166
|
+
|
|
167
|
+
// Add second ingredient
|
|
168
|
+
await builder.addIngredientFromBlob(
|
|
169
|
+
{
|
|
170
|
+
title: 'overlay.png',
|
|
171
|
+
format: 'image/png',
|
|
172
|
+
instance_id: 'overlay-002',
|
|
173
|
+
relationship: 'componentOf',
|
|
174
|
+
},
|
|
175
|
+
'image/png',
|
|
176
|
+
overlay
|
|
177
|
+
);
|
|
178
|
+
|
|
179
|
+
const definition = await builder.getDefinition();
|
|
180
|
+
console.log(definition.ingredients.length); // 2
|
|
181
|
+
|
|
182
|
+
await builder.free();
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
##### Creating and Reusing Builder Archives
|
|
186
|
+
|
|
187
|
+
Builder archives allow you to save a builder's state (including ingredients) and reuse it later:
|
|
188
|
+
|
|
189
|
+
```typescript
|
|
190
|
+
// Create a builder with ingredients
|
|
191
|
+
const builder = await c2pa.builder.new();
|
|
192
|
+
|
|
193
|
+
const ingredientBlob = await fetch('source.jpg').then((r) => r.blob());
|
|
194
|
+
await builder.addIngredientFromBlob(
|
|
195
|
+
{
|
|
196
|
+
title: 'source.jpg',
|
|
197
|
+
format: 'image/jpeg',
|
|
198
|
+
instance_id: 'source-123',
|
|
199
|
+
},
|
|
200
|
+
'image/jpeg',
|
|
201
|
+
ingredientBlob
|
|
202
|
+
);
|
|
203
|
+
|
|
204
|
+
// Save as an archive
|
|
205
|
+
const archive = await builder.toArchive();
|
|
206
|
+
await builder.free();
|
|
207
|
+
|
|
208
|
+
// Later, recreate the builder from the archive
|
|
209
|
+
const restoredBuilder = await c2pa.builder.fromArchive(new Blob([archive]));
|
|
210
|
+
|
|
211
|
+
// The ingredients are preserved
|
|
212
|
+
const definition = await restoredBuilder.getDefinition();
|
|
213
|
+
console.log(definition.ingredients); // Contains the ingredient
|
|
214
|
+
|
|
215
|
+
await restoredBuilder.free();
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
##### Ingredient Properties
|
|
219
|
+
|
|
220
|
+
The `Ingredient` type supports the following properties:
|
|
221
|
+
|
|
222
|
+
- `title`: Human-readable title for the ingredient
|
|
223
|
+
- `format`: MIME type of the ingredient asset (e.g., `'image/jpeg'`)
|
|
224
|
+
- `instance_id`: Unique identifier for this specific instance
|
|
225
|
+
- `document_id` (optional): Identifier for the source document
|
|
226
|
+
- `relationship` (optional): Relationship to the parent asset (`'parentOf'`, `'componentOf'`, etc.)
|
|
227
|
+
- `thumbnail` (optional): Thumbnail reference for the ingredient
|
|
228
|
+
- `validation_status` (optional): Validation results if the ingredient has C2PA data
|
|
229
|
+
|
|
230
|
+
For complete type definitions, see the [API reference](https://contentauth.github.io/c2pa-js/modules/_contentauth_c2pa-web.html).
|
|
231
|
+
|
|
76
232
|
## Api reference
|
|
77
233
|
|
|
78
234
|
API docs are available [here](https://contentauth.github.io/c2pa-js/modules/_contentauth_c2pa-web.html).
|
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
import { channel as I, transfer as O } from "highgain";
|
|
2
|
+
import { merge as T } from "ts-deepmerge";
|
|
3
|
+
const { createTx: z, rx: H } = I(), { createTx: X, rx: N } = I("worker"), E = '(function(){"use strict";let o;function S(n){const e=o.__externref_table_alloc();return o.__wbindgen_externrefs.set(e,n),e}const O=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>n.dtor(n.a,n.b));function j(n){const e=typeof n;if(e=="number"||e=="boolean"||n==null)return`${n}`;if(e=="string")return`"${n}"`;if(e=="symbol"){const _=n.description;return _==null?"Symbol":`Symbol(${_})`}if(e=="function"){const _=n.name;return typeof _=="string"&&_.length>0?`Function(${_})`:"Function"}if(Array.isArray(n)){const _=n.length;let c="[";_>0&&(c+=j(n[0]));for(let i=1;i<_;i++)c+=", "+j(n[i]);return c+="]",c}const t=/\\[object ([^\\]]+)\\]/.exec(toString.call(n));let r;if(t&&t.length>1)r=t[1];else return toString.call(n);if(r=="Object")try{return"Object("+JSON.stringify(n)+")"}catch{return"Object"}return n instanceof Error?`${n.name}: ${n.message}\n${n.stack}`:r}function v(n,e){return n=n>>>0,R().subarray(n/1,n/1+e)}let A=null;function m(){return(A===null||A.buffer.detached===!0||A.buffer.detached===void 0&&A.buffer!==o.memory.buffer)&&(A=new DataView(o.memory.buffer)),A}function y(n,e){return n=n>>>0,V(n,e)}let M=null;function R(){return(M===null||M.byteLength===0)&&(M=new Uint8Array(o.memory.buffer)),M}function d(n,e){try{return n.apply(this,e)}catch(t){const r=S(t);o.__wbindgen_exn_store(r)}}function w(n){return n==null}function N(n,e,t,r){const _={a:n,b:e,cnt:1,dtor:t},c=(...i)=>{_.cnt++;const s=_.a;_.a=0;try{return r(s,_.b,...i)}finally{_.a=s,c._wbg_cb_unref()}};return c._wbg_cb_unref=()=>{--_.cnt===0&&(_.dtor(_.a,_.b),_.a=0,O.unregister(_))},O.register(c,_,_),c}function u(n,e,t){if(t===void 0){const s=T.encode(n),b=e(s.length,1)>>>0;return R().subarray(b,b+s.length).set(s),a=s.length,b}let r=n.length,_=e(r,1)>>>0;const c=R();let i=0;for(;i<r;i++){const s=n.charCodeAt(i);if(s>127)break;c[_+i]=s}if(i!==r){i!==0&&(n=n.slice(i)),_=t(_,r,r=i+n.length*3,1)>>>0;const s=R().subarray(_+i,_+r),b=T.encodeInto(n,s);i+=b.written,_=t(_,r,i,1)>>>0}return a=i,_}function f(n){const e=o.__wbindgen_externrefs.get(n);return o.__externref_table_dealloc(n),e}let E=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});E.decode();const C=2146435072;let x=0;function V(n,e){return x+=e,x>=C&&(E=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),E.decode(),x=e),E.decode(R().subarray(n,n+e))}const T=new TextEncoder;"encodeInto"in T||(T.encodeInto=function(n,e){const t=T.encode(n);return e.set(t),{read:n.length,written:t.length}});let a=0;function G(n,e,t){o.wasm_bindgen__convert__closures_____invoke__hfa979f81ae70afaa(n,e,t)}function P(n,e){o.wasm_bindgen__convert__closures_____invoke__h6743aa07e10cb0d4(n,e)}function $(n,e,t,r){o.wasm_bindgen__convert__closures_____invoke__h536d005b97d28fdb(n,e,t,r)}const J=["default","no-store","reload","no-cache","force-cache","only-if-cached"],H=["omit","same-origin","include"],X=["same-origin","no-cors","cors","navigate"],k=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>o.__wbg_wasmbuilder_free(n>>>0,1)),z=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>o.__wbg_wasmreader_free(n>>>0,1));typeof FinalizationRegistry>"u"||new FinalizationRegistry(n=>o.__wbg_wasmsigner_free(n>>>0,1));class h{static __wrap(e){e=e>>>0;const t=Object.create(h.prototype);return t.__wbg_ptr=e,k.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,k.unregister(this),e}free(){const e=this.__destroy_into_raw();o.__wbg_wasmbuilder_free(e,0)}addAction(e){const t=o.wasmbuilder_addAction(this.__wbg_ptr,e);if(t[1])throw f(t[0])}setIntent(e){const t=o.wasmbuilder_setIntent(this.__wbg_ptr,e);if(t[1])throw f(t[0])}toArchive(){const e=o.wasmbuilder_toArchive(this.__wbg_ptr);if(e[2])throw f(e[1]);return f(e[0])}static fromArchive(e,t){var r=w(t)?0:u(t,o.__wbindgen_malloc,o.__wbindgen_realloc),_=a;const c=o.wasmbuilder_fromArchive(e,r,_);if(c[2])throw f(c[1]);return h.__wrap(c[0])}setNoEmbed(e){o.wasmbuilder_setNoEmbed(this.__wbg_ptr,e)}addIngredient(e){const t=u(e,o.__wbindgen_malloc,o.__wbindgen_realloc),r=a,_=o.wasmbuilder_addIngredient(this.__wbg_ptr,t,r);if(_[1])throw f(_[0])}getDefinition(){const e=o.wasmbuilder_getDefinition(this.__wbg_ptr);if(e[2])throw f(e[1]);return f(e[0])}setRemoteUrl(e){const t=u(e,o.__wbindgen_malloc,o.__wbindgen_realloc),r=a;o.wasmbuilder_setRemoteUrl(this.__wbg_ptr,t,r)}addResourceFromBlob(e,t){const r=u(e,o.__wbindgen_malloc,o.__wbindgen_realloc),_=a,c=o.wasmbuilder_addResourceFromBlob(this.__wbg_ptr,r,_,t);if(c[1])throw f(c[0])}setThumbnailFromBlob(e,t){const r=u(e,o.__wbindgen_malloc,o.__wbindgen_realloc),_=a,c=o.wasmbuilder_setThumbnailFromBlob(this.__wbg_ptr,r,_,t);if(c[1])throw f(c[0])}addIngredientFromBlob(e,t,r){const _=u(e,o.__wbindgen_malloc,o.__wbindgen_realloc),c=a,i=u(t,o.__wbindgen_malloc,o.__wbindgen_realloc),s=a,b=o.wasmbuilder_addIngredientFromBlob(this.__wbg_ptr,_,c,i,s,r);if(b[1])throw f(b[0])}signAndGetManifestBytes(e,t,r){const _=u(t,o.__wbindgen_malloc,o.__wbindgen_realloc),c=a;return o.wasmbuilder_signAndGetManifestBytes(this.__wbg_ptr,e,_,c,r)}static new(e){var t=w(e)?0:u(e,o.__wbindgen_malloc,o.__wbindgen_realloc),r=a;const _=o.wasmbuilder_new(t,r);if(_[2])throw f(_[1]);return h.__wrap(_[0])}sign(e,t,r){const _=u(t,o.__wbindgen_malloc,o.__wbindgen_realloc),c=a;return o.wasmbuilder_sign(this.__wbg_ptr,e,_,c,r)}static fromJson(e,t){const r=u(e,o.__wbindgen_malloc,o.__wbindgen_realloc),_=a;var c=w(t)?0:u(t,o.__wbindgen_malloc,o.__wbindgen_realloc),i=a;const s=o.wasmbuilder_fromJson(r,_,c,i);if(s[2])throw f(s[1]);return h.__wrap(s[0])}}Symbol.dispose&&(h.prototype[Symbol.dispose]=h.prototype.free);class I{static __wrap(e){e=e>>>0;const t=Object.create(I.prototype);return t.__wbg_ptr=e,z.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,z.unregister(this),e}free(){const e=this.__destroy_into_raw();o.__wbg_wasmreader_free(e,0)}activeLabel(){const e=o.wasmreader_activeLabel(this.__wbg_ptr);let t;return e[0]!==0&&(t=y(e[0],e[1]).slice(),o.__wbindgen_free(e[0],e[1]*1,1)),t}manifestStore(){const e=o.wasmreader_manifestStore(this.__wbg_ptr);if(e[2])throw f(e[1]);return f(e[0])}activeManifest(){const e=o.wasmreader_activeManifest(this.__wbg_ptr);if(e[2])throw f(e[1]);return f(e[0])}resourceToBytes(e){const t=u(e,o.__wbindgen_malloc,o.__wbindgen_realloc),r=a,_=o.wasmreader_resourceToBytes(this.__wbg_ptr,t,r);if(_[2])throw f(_[1]);return f(_[0])}static fromBlobFragment(e,t,r,_){const c=u(e,o.__wbindgen_malloc,o.__wbindgen_realloc),i=a;var s=w(_)?0:u(_,o.__wbindgen_malloc,o.__wbindgen_realloc),b=a;return o.wasmreader_fromBlobFragment(c,i,t,r,s,b)}json(){let e,t;try{const r=o.wasmreader_json(this.__wbg_ptr);return e=r[0],t=r[1],y(r[0],r[1])}finally{o.__wbindgen_free(e,t,1)}}static fromBlob(e,t,r){const _=u(e,o.__wbindgen_malloc,o.__wbindgen_realloc),c=a;var i=w(r)?0:u(r,o.__wbindgen_malloc,o.__wbindgen_realloc),s=a;return o.wasmreader_fromBlob(_,c,t,i,s)}}Symbol.dispose&&(I.prototype[Symbol.dispose]=I.prototype.free);function Y(n){const e=u(n,o.__wbindgen_malloc,o.__wbindgen_realloc),t=a,r=o.loadSettings(e,t);if(r[1])throw f(r[0])}function K(){const n={};return n.wbg={},n.wbg.__wbg_Error_52673b7de5a0ca89=function(e,t){return Error(y(e,t))},n.wbg.__wbg_Number_2d1dcfcf4ec51736=function(e){return Number(e)},n.wbg.__wbg___wbindgen_bigint_get_as_i64_6e32f5e6aff02e1d=function(e,t){const r=t,_=typeof r=="bigint"?r:void 0;m().setBigInt64(e+8,w(_)?BigInt(0):_,!0),m().setInt32(e+0,!w(_),!0)},n.wbg.__wbg___wbindgen_boolean_get_dea25b33882b895b=function(e){const t=e,r=typeof t=="boolean"?t:void 0;return w(r)?16777215:r?1:0},n.wbg.__wbg___wbindgen_debug_string_adfb662ae34724b6=function(e,t){const r=j(t),_=u(r,o.__wbindgen_malloc,o.__wbindgen_realloc),c=a;m().setInt32(e+4,c,!0),m().setInt32(e+0,_,!0)},n.wbg.__wbg___wbindgen_in_0d3e1e8f0c669317=function(e,t){return e in t},n.wbg.__wbg___wbindgen_is_bigint_0e1a2e3f55cfae27=function(e){return typeof e=="bigint"},n.wbg.__wbg___wbindgen_is_function_8d400b8b1af978cd=function(e){return typeof e=="function"},n.wbg.__wbg___wbindgen_is_object_ce774f3490692386=function(e){const t=e;return typeof t=="object"&&t!==null},n.wbg.__wbg___wbindgen_is_string_704ef9c8fc131030=function(e){return typeof e=="string"},n.wbg.__wbg___wbindgen_is_undefined_f6b95eab589e0269=function(e){return e===void 0},n.wbg.__wbg___wbindgen_jsval_eq_b6101cc9cef1fe36=function(e,t){return e===t},n.wbg.__wbg___wbindgen_jsval_loose_eq_766057600fdd1b0d=function(e,t){return e==t},n.wbg.__wbg___wbindgen_number_get_9619185a74197f95=function(e,t){const r=t,_=typeof r=="number"?r:void 0;m().setFloat64(e+8,w(_)?0:_,!0),m().setInt32(e+0,!w(_),!0)},n.wbg.__wbg___wbindgen_string_get_a2a31e16edf96e42=function(e,t){const r=t,_=typeof r=="string"?r:void 0;var c=w(_)?0:u(_,o.__wbindgen_malloc,o.__wbindgen_realloc),i=a;m().setInt32(e+4,i,!0),m().setInt32(e+0,c,!0)},n.wbg.__wbg___wbindgen_throw_dd24417ed36fc46e=function(e,t){throw new Error(y(e,t))},n.wbg.__wbg__wbg_cb_unref_87dfb5aaa0cbcea7=function(e){e._wbg_cb_unref()},n.wbg.__wbg_abort_07646c894ebbf2bd=function(e){e.abort()},n.wbg.__wbg_abort_399ecbcfd6ef3c8e=function(e,t){e.abort(t)},n.wbg.__wbg_append_c5cbdf46455cc776=function(){return d(function(e,t,r,_,c){e.append(y(t,r),y(_,c))},arguments)},n.wbg.__wbg_arrayBuffer_c04af4fce566092d=function(){return d(function(e){return e.arrayBuffer()},arguments)},n.wbg.__wbg_byteLength_faa9938885bdeee6=function(e){return e.byteLength},n.wbg.__wbg_call_3020136f7a2d6e44=function(){return d(function(e,t,r){return e.call(t,r)},arguments)},n.wbg.__wbg_call_abb4ff46ce38be40=function(){return d(function(e,t){return e.call(t)},arguments)},n.wbg.__wbg_clearTimeout_7a42b49784aea641=function(e){return clearTimeout(e)},n.wbg.__wbg_crypto_574e78ad8b13b65f=function(e){return e.crypto},n.wbg.__wbg_done_62ea16af4ce34b24=function(e){return e.done},n.wbg.__wbg_entries_83c79938054e065f=function(e){return Object.entries(e)},n.wbg.__wbg_error_7534b8e9a36f1ab4=function(e,t){let r,_;try{r=e,_=t,console.error(y(e,t))}finally{o.__wbindgen_free(r,_,1)}},n.wbg.__wbg_fetch_74a3e84ebd2c9a0e=function(e){return fetch(e)},n.wbg.__wbg_fetch_90447c28cc0b095e=function(e,t){return e.fetch(t)},n.wbg.__wbg_from_29a8414a7a7cd19d=function(e){return Array.from(e)},n.wbg.__wbg_getRandomValues_1c61fac11405ffdc=function(){return d(function(e,t){globalThis.crypto.getRandomValues(v(e,t))},arguments)},n.wbg.__wbg_getRandomValues_38a1ff1ea09f6cc7=function(){return d(function(e,t){globalThis.crypto.getRandomValues(v(e,t))},arguments)},n.wbg.__wbg_getRandomValues_b8f5dbd5f3995a9e=function(){return d(function(e,t){e.getRandomValues(t)},arguments)},n.wbg.__wbg_getTime_ad1e9878a735af08=function(e){return e.getTime()},n.wbg.__wbg_get_6b7bd52aca3f9671=function(e,t){return e[t>>>0]},n.wbg.__wbg_get_af9dab7e9603ea93=function(){return d(function(e,t){return Reflect.get(e,t)},arguments)},n.wbg.__wbg_get_with_ref_key_1dc361bd10053bfe=function(e,t){return e[t]},n.wbg.__wbg_has_0e670569d65d3a45=function(){return d(function(e,t){return Reflect.has(e,t)},arguments)},n.wbg.__wbg_headers_654c30e1bcccc552=function(e){return e.headers},n.wbg.__wbg_instanceof_ArrayBuffer_f3320d2419cd0355=function(e){let t;try{t=e instanceof ArrayBuffer}catch{t=!1}return t},n.wbg.__wbg_instanceof_Map_084be8da74364158=function(e){let t;try{t=e instanceof Map}catch{t=!1}return t},n.wbg.__wbg_instanceof_Promise_eca6c43a2610558d=function(e){let t;try{t=e instanceof Promise}catch{t=!1}return t},n.wbg.__wbg_instanceof_Response_cd74d1c2ac92cb0b=function(e){let t;try{t=e instanceof Response}catch{t=!1}return t},n.wbg.__wbg_instanceof_Uint8Array_da54ccc9d3e09434=function(e){let t;try{t=e instanceof Uint8Array}catch{t=!1}return t},n.wbg.__wbg_isArray_51fd9e6422c0a395=function(e){return Array.isArray(e)},n.wbg.__wbg_isSafeInteger_ae7d3f054d55fa16=function(e){return Number.isSafeInteger(e)},n.wbg.__wbg_iterator_27b7c8b35ab3e86b=function(){return Symbol.iterator},n.wbg.__wbg_length_22ac23eaec9d8053=function(e){return e.length},n.wbg.__wbg_length_d45040a40c570362=function(e){return e.length},n.wbg.__wbg_msCrypto_a61aeb35a24c1329=function(e){return e.msCrypto},n.wbg.__wbg_new_0_23cedd11d9b40c9d=function(){return new Date},n.wbg.__wbg_new_1ba21ce319a06297=function(){return new Object},n.wbg.__wbg_new_25f239778d6112b9=function(){return new Array},n.wbg.__wbg_new_3c79b3bb1b32b7d3=function(){return d(function(){return new Headers},arguments)},n.wbg.__wbg_new_6421f6084cc5bc5a=function(e){return new Uint8Array(e)},n.wbg.__wbg_new_881a222c65f168fc=function(){return d(function(){return new AbortController},arguments)},n.wbg.__wbg_new_8a6f238a6ece86ea=function(){return new Error},n.wbg.__wbg_new_b546ae120718850e=function(){return new Map},n.wbg.__wbg_new_bd4ee84941f474fa=function(){return d(function(){return new FileReaderSync},arguments)},n.wbg.__wbg_new_df1173567d5ff028=function(e,t){return new Error(y(e,t))},n.wbg.__wbg_new_ff12d2b041fb48f1=function(e,t){try{var r={a:e,b:t},_=(i,s)=>{const b=r.a;r.a=0;try{return $(b,r.b,i,s)}finally{r.a=b}};return new Promise(_)}finally{r.a=r.b=0}},n.wbg.__wbg_new_from_slice_f9c22b9153b26992=function(e,t){return new Uint8Array(v(e,t))},n.wbg.__wbg_new_no_args_cb138f77cf6151ee=function(e,t){return new Function(y(e,t))},n.wbg.__wbg_new_with_length_aa5eaf41d35235e5=function(e){return new Uint8Array(e>>>0)},n.wbg.__wbg_new_with_str_and_init_c5748f76f5108934=function(){return d(function(e,t,r){return new Request(y(e,t),r)},arguments)},n.wbg.__wbg_next_138a17bbf04e926c=function(e){return e.next},n.wbg.__wbg_next_3cfe5c0fe2a4cc53=function(){return d(function(e){return e.next()},arguments)},n.wbg.__wbg_node_905d3e251edff8a2=function(e){return e.node},n.wbg.__wbg_now_69d776cd24f5215b=function(){return Date.now()},n.wbg.__wbg_process_dc0fbacc7c1c06f7=function(e){return e.process},n.wbg.__wbg_prototypesetcall_dfe9b766cdc1f1fd=function(e,t,r){Uint8Array.prototype.set.call(v(e,t),r)},n.wbg.__wbg_queueMicrotask_9b549dfce8865860=function(e){return e.queueMicrotask},n.wbg.__wbg_queueMicrotask_fca69f5bfad613a5=function(e){queueMicrotask(e)},n.wbg.__wbg_randomFillSync_ac0988aba3254290=function(){return d(function(e,t){e.randomFillSync(t)},arguments)},n.wbg.__wbg_readAsArrayBuffer_5a7ad12aa99daa2f=function(){return d(function(e,t){return e.readAsArrayBuffer(t)},arguments)},n.wbg.__wbg_require_60cc747a6bc5215a=function(){return d(function(){return module.require},arguments)},n.wbg.__wbg_resolve_fd5bfbaa4ce36e1e=function(e){return Promise.resolve(e)},n.wbg.__wbg_setTimeout_7bb3429662ab1e70=function(e,t){return setTimeout(e,t)},n.wbg.__wbg_set_169e13b608078b7b=function(e,t,r){e.set(v(t,r))},n.wbg.__wbg_set_3f1d0b984ed272ed=function(e,t,r){e[t]=r},n.wbg.__wbg_set_7df433eea03a5c14=function(e,t,r){e[t>>>0]=r},n.wbg.__wbg_set_body_8e743242d6076a4f=function(e,t){e.body=t},n.wbg.__wbg_set_cache_0e437c7c8e838b9b=function(e,t){e.cache=J[t]},n.wbg.__wbg_set_credentials_55ae7c3c106fd5be=function(e,t){e.credentials=H[t]},n.wbg.__wbg_set_efaaf145b9377369=function(e,t,r){return e.set(t,r)},n.wbg.__wbg_set_headers_5671cf088e114d2b=function(e,t){e.headers=t},n.wbg.__wbg_set_method_76c69e41b3570627=function(e,t,r){e.method=y(t,r)},n.wbg.__wbg_set_mode_611016a6818fc690=function(e,t){e.mode=X[t]},n.wbg.__wbg_set_signal_e89be862d0091009=function(e,t){e.signal=t},n.wbg.__wbg_signal_3c14fbdc89694b39=function(e){return e.signal},n.wbg.__wbg_size_82fbdb656de23326=function(e){return e.size},n.wbg.__wbg_slice_3518c924243cda3a=function(){return d(function(e,t,r){return e.slice(t,r)},arguments)},n.wbg.__wbg_stack_0ed75d68575b0f3c=function(e,t){const r=t.stack,_=u(r,o.__wbindgen_malloc,o.__wbindgen_realloc),c=a;m().setInt32(e+4,c,!0),m().setInt32(e+0,_,!0)},n.wbg.__wbg_static_accessor_GLOBAL_769e6b65d6557335=function(){const e=typeof global>"u"?null:global;return w(e)?0:S(e)},n.wbg.__wbg_static_accessor_GLOBAL_THIS_60cf02db4de8e1c1=function(){const e=typeof globalThis>"u"?null:globalThis;return w(e)?0:S(e)},n.wbg.__wbg_static_accessor_SELF_08f5a74c69739274=function(){const e=typeof self>"u"?null:self;return w(e)?0:S(e)},n.wbg.__wbg_static_accessor_WINDOW_a8924b26aa92d024=function(){const e=typeof window>"u"?null:window;return w(e)?0:S(e)},n.wbg.__wbg_status_9bfc680efca4bdfd=function(e){return e.status},n.wbg.__wbg_stringify_655a6390e1f5eb6b=function(){return d(function(e){return JSON.stringify(e)},arguments)},n.wbg.__wbg_subarray_845f2f5bce7d061a=function(e,t,r){return e.subarray(t>>>0,r>>>0)},n.wbg.__wbg_then_429f7caf1026411d=function(e,t,r){return e.then(t,r)},n.wbg.__wbg_then_4f95312d68691235=function(e,t){return e.then(t)},n.wbg.__wbg_url_b6d11838a4f95198=function(e,t){const r=t.url,_=u(r,o.__wbindgen_malloc,o.__wbindgen_realloc),c=a;m().setInt32(e+4,c,!0),m().setInt32(e+0,_,!0)},n.wbg.__wbg_valueOf_17c63ed1b225597a=function(e){return e.valueOf()},n.wbg.__wbg_value_57b7b035e117f7ee=function(e){return e.value},n.wbg.__wbg_versions_c01dfd4722a88165=function(e){return e.versions},n.wbg.__wbg_wasmreader_new=function(e){return I.__wrap(e)},n.wbg.__wbindgen_cast_0bcf4d5a20a2764c=function(e,t){return N(e,t,o.wasm_bindgen__closure__destroy__h9cd45bdf09c25ec5,P)},n.wbg.__wbindgen_cast_2241b6af4c4b2941=function(e,t){return y(e,t)},n.wbg.__wbindgen_cast_2ddd8a25ff58642a=function(e,t){return BigInt.asUintN(64,e)|t<<BigInt(64)},n.wbg.__wbindgen_cast_4625c577ab2ec9ee=function(e){return BigInt.asUintN(64,e)},n.wbg.__wbindgen_cast_77bc3e92745e9a35=function(e,t){var r=v(e,t).slice();return o.__wbindgen_free(e,t*1,1),r},n.wbg.__wbindgen_cast_815cc8b6fd6cc840=function(e,t){return N(e,t,o.wasm_bindgen__closure__destroy__h628fe959fcf32094,G)},n.wbg.__wbindgen_cast_9ae0607507abb057=function(e){return e},n.wbg.__wbindgen_cast_cb9088102bce6b30=function(e,t){return v(e,t)},n.wbg.__wbindgen_cast_d6cd19b81560fd6e=function(e){return e},n.wbg.__wbindgen_init_externref_table=function(){const e=o.__wbindgen_externrefs,t=e.grow(4);e.set(0,void 0),e.set(t+0,void 0),e.set(t+1,null),e.set(t+2,!0),e.set(t+3,!1)},n}function Q(n,e){return o=n.exports,A=null,M=null,o.__wbindgen_start(),o}function Z(n){if(o!==void 0)return o;typeof n<"u"&&(Object.getPrototypeOf(n)===Object.prototype?{module:n}=n:console.warn("using deprecated parameters for `initSync()`; pass a single object instead"));const e=K();n instanceof WebAssembly.Module||(n=new WebAssembly.Module(n));const t=new WebAssembly.Instance(n,e);return Q(t)}function D(){let n=0;const e=new Map;return{add(t){const r=n++;return e.set(r,t),r},get(t){const r=e.get(t);if(!r)throw new Error("Attempted to use an object that has been freed");return r},remove(t){return e.delete(t)}}}const L=Symbol("transfer");function F(n,e){return{type:L,value:n,transfer:e?Array.isArray(e)?e:[e]:[n]}}function U(n){return!!(n&&typeof n=="object"&&Reflect.get(n,"type")===L)}function q(n="default"){return{createTx(e){const t=new Map,r=e??self;return r.addEventListener("message",_=>{const{data:c}=_;if(c.channelName!==n)return;const{id:i,result:s,error:b}=c,l=t.get(i);l&&(b?l.reject(b):l.resolve(s),t.delete(i))}),new Proxy({},{get(_,c){return(...i)=>{const s=ee(),b=[],l=[];return i.forEach(B=>{U(B)?(b.push(B.value),l.push(...B.transfer)):b.push(B)}),r.postMessage({method:c,args:b,id:s,channelName:n},{transfer:l}),new Promise((B,re)=>{t.set(s,{resolve:B,reject:re})})}}})},rx(e,t){const r=t??self;r.addEventListener("message",async _=>{const{data:c}=_;if(c.channelName!==n)return;const{method:i,args:s,id:b}=c;try{const l=await e[i](...s);U(l)?r.postMessage({result:l.value,id:b,channelName:n},{transfer:l.transfer}):r.postMessage({result:l,id:b,channelName:n})}catch(l){r.postMessage({error:l,id:b,channelName:n})}})}}}function ee(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}const{rx:te}=q(),{createTx:ne}=q("worker"),p=D(),g=D(),W=ne();te({async initWorker(n,e){Z({module:n}),e&&Y(e)},async reader_fromBlob(n,e,t){const r=await I.fromBlob(n,e,t);return p.add(r)},async reader_fromBlobFragment(n,e,t,r){const _=await I.fromBlobFragment(n,e,t,r);return p.add(_)},reader_activeLabel(n){return p.get(n).activeLabel()??null},reader_manifestStore(n){return p.get(n).manifestStore()},reader_activeManifest(n){return p.get(n).activeManifest()},reader_json(n){return p.get(n).json()},reader_resourceToBytes(n,e){const r=p.get(n).resourceToBytes(e);return F(r,r.buffer)},reader_free(n){p.get(n).free(),p.remove(n)},builder_new(n){const e=h.new(n);return g.add(e)},builder_fromJson(n,e){const t=h.fromJson(n,e);return g.add(t)},builder_fromArchive(n,e){const t=h.fromArchive(n,e);return g.add(t)},builder_setIntent(n,e){g.get(n).setIntent(e)},builder_addAction(n,e){g.get(n).addAction(e)},builder_setRemoteUrl(n,e){g.get(n).setRemoteUrl(e)},builder_setNoEmbed(n,e){g.get(n).setNoEmbed(e)},builder_setThumbnailFromBlob(n,e,t){g.get(n).setThumbnailFromBlob(e,t)},builder_addIngredient(n,e){g.get(n).addIngredient(e)},builder_addIngredientFromBlob(n,e,t,r){g.get(n).addIngredientFromBlob(e,t,r)},builder_addResourceFromBlob(n,e,t){g.get(n).addResourceFromBlob(e,t)},builder_getDefinition(n){return g.get(n).getDefinition()},builder_toArchive(n){const t=g.get(n).toArchive();return F(t,t.buffer)},async builder_sign(n,e,t,r,_){const i=await g.get(n).sign({reserveSize:t.reserveSize,alg:t.alg,sign:async s=>await W.sign(e,F(s,s.buffer),t.reserveSize)},r,_);return F(i,i.buffer)},async builder_signAndGetManifestBytes(n,e,t,r,_){const c=g.get(n),{manifest:i,asset:s}=await c.signAndGetManifestBytes({reserveSize:t.reserveSize,alg:t.alg,sign:async b=>await W.sign(e,F(b,b.buffer),t.reserveSize)},r,_);return F({manifest:i,asset:s},[i.buffer,s.buffer])},builder_free(n){g.get(n).free(),g.remove(n)}})})();\n', p = typeof self < "u" && self.Blob && new Blob([E], { type: "text/javascript;charset=utf-8" });
|
|
4
|
+
function U(n) {
|
|
5
|
+
let e;
|
|
6
|
+
try {
|
|
7
|
+
if (e = p && (self.URL || self.webkitURL).createObjectURL(p), !e) throw "";
|
|
8
|
+
const _ = new Worker(e, {
|
|
9
|
+
name: n == null ? void 0 : n.name
|
|
10
|
+
});
|
|
11
|
+
return _.addEventListener("error", () => {
|
|
12
|
+
(self.URL || self.webkitURL).revokeObjectURL(e);
|
|
13
|
+
}), _;
|
|
14
|
+
} catch {
|
|
15
|
+
return new Worker(
|
|
16
|
+
"data:text/javascript;charset=utf-8," + encodeURIComponent(E),
|
|
17
|
+
{
|
|
18
|
+
name: n == null ? void 0 : n.name
|
|
19
|
+
}
|
|
20
|
+
);
|
|
21
|
+
} finally {
|
|
22
|
+
e && (self.URL || self.webkitURL).revokeObjectURL(e);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
async function L(n) {
|
|
26
|
+
const { wasm: e, settingsString: _ } = n;
|
|
27
|
+
let r = 0;
|
|
28
|
+
const t = new U(), o = z(t), i = /* @__PURE__ */ new Map();
|
|
29
|
+
N(
|
|
30
|
+
{
|
|
31
|
+
sign: async (c, s, M) => {
|
|
32
|
+
const m = i.get(c);
|
|
33
|
+
if (i.delete(c), !m)
|
|
34
|
+
throw new Error("No signer registered for request");
|
|
35
|
+
const y = await m(s, M);
|
|
36
|
+
return O(y, y.buffer);
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
t
|
|
40
|
+
);
|
|
41
|
+
function a(c) {
|
|
42
|
+
const s = r++;
|
|
43
|
+
return i.set(s, c), s;
|
|
44
|
+
}
|
|
45
|
+
return await o.initWorker(e, _), {
|
|
46
|
+
tx: o,
|
|
47
|
+
registerSignReceiver: a,
|
|
48
|
+
terminate: () => t.terminate()
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
class h extends Error {
|
|
52
|
+
constructor(e) {
|
|
53
|
+
super(
|
|
54
|
+
`The provided asset was too large. Size: ${e} bytes. Maximum: ${w}.`
|
|
55
|
+
), this.name = "AssetTooLargeError";
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
class v extends Error {
|
|
59
|
+
constructor(e) {
|
|
60
|
+
super(`Unsupported format: ${e}.`), this.name = "UnsupportedFormatError";
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
const k = [
|
|
64
|
+
"jpg",
|
|
65
|
+
"video/mp4",
|
|
66
|
+
"image/heif",
|
|
67
|
+
"video/x-msvideo",
|
|
68
|
+
"pdf",
|
|
69
|
+
"image/png",
|
|
70
|
+
"application/c2pa",
|
|
71
|
+
"video/quicktime",
|
|
72
|
+
"video/avi",
|
|
73
|
+
"image/gif",
|
|
74
|
+
"application/xml",
|
|
75
|
+
"text/xml",
|
|
76
|
+
"application/xhtml+xml",
|
|
77
|
+
"tiff",
|
|
78
|
+
"audio/wave",
|
|
79
|
+
"mp4",
|
|
80
|
+
"image/avif",
|
|
81
|
+
"image/dng",
|
|
82
|
+
"png",
|
|
83
|
+
"dng",
|
|
84
|
+
"image/svg+xml",
|
|
85
|
+
"image/heic",
|
|
86
|
+
"application/mp4",
|
|
87
|
+
"image/x-nikon-nef",
|
|
88
|
+
"video/msvideo",
|
|
89
|
+
"tif",
|
|
90
|
+
"wav",
|
|
91
|
+
"xml",
|
|
92
|
+
"audio/vnd.wave",
|
|
93
|
+
"xhtml",
|
|
94
|
+
"gif",
|
|
95
|
+
"application/x-troff-msvideo",
|
|
96
|
+
"webp",
|
|
97
|
+
"heic",
|
|
98
|
+
"application/pdf",
|
|
99
|
+
"audio/mpeg",
|
|
100
|
+
"application/x-c2pa-manifest-store",
|
|
101
|
+
"jpeg",
|
|
102
|
+
"image/x-adobe-dng",
|
|
103
|
+
"audio/wav",
|
|
104
|
+
"mp3",
|
|
105
|
+
"mov",
|
|
106
|
+
"image/tiff",
|
|
107
|
+
"audio/mp4",
|
|
108
|
+
"application/svg+xml",
|
|
109
|
+
"arw",
|
|
110
|
+
"c2pa",
|
|
111
|
+
"svg",
|
|
112
|
+
"avi",
|
|
113
|
+
"audio/x-wav",
|
|
114
|
+
"m4a",
|
|
115
|
+
"image/x-sony-arw",
|
|
116
|
+
"image/jpeg",
|
|
117
|
+
"avif",
|
|
118
|
+
"image/webp",
|
|
119
|
+
"nef",
|
|
120
|
+
"heif"
|
|
121
|
+
];
|
|
122
|
+
function A(n) {
|
|
123
|
+
return k.includes(n);
|
|
124
|
+
}
|
|
125
|
+
const j = {
|
|
126
|
+
builder: {
|
|
127
|
+
generateC2paArchive: !0
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
async function b(n) {
|
|
131
|
+
const e = T(j, n), _ = [];
|
|
132
|
+
return e.trust && _.push(u(e.trust)), e.cawgTrust && _.push(u(e.cawgTrust)), await Promise.all(_), JSON.stringify(d(e));
|
|
133
|
+
}
|
|
134
|
+
async function J(n) {
|
|
135
|
+
const e = T(j, n), _ = [];
|
|
136
|
+
return e.trust && _.push(u(e.trust)), e.cawgTrust && _.push(u(e.cawgTrust)), await Promise.all(_), JSON.stringify(d(e));
|
|
137
|
+
}
|
|
138
|
+
function d(n) {
|
|
139
|
+
return Object.entries(n).reduce(
|
|
140
|
+
(_, [r, t]) => (_[W(r)] = typeof t == "object" ? d(t) : t, _),
|
|
141
|
+
{}
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
function W(n) {
|
|
145
|
+
return n.replace(/[A-Z]/g, (e) => `_${e.toLowerCase()}`);
|
|
146
|
+
}
|
|
147
|
+
async function u(n) {
|
|
148
|
+
try {
|
|
149
|
+
const e = Object.entries(n).map(async ([_, r]) => {
|
|
150
|
+
if (Array.isArray(r)) {
|
|
151
|
+
const t = r.map(async (a) => {
|
|
152
|
+
const s = await (await fetch(a)).text();
|
|
153
|
+
if (R(_) && !S(s))
|
|
154
|
+
throw new Error(`Error parsing PEM file at: ${a}`);
|
|
155
|
+
return s;
|
|
156
|
+
}), i = (await Promise.all(t)).join("");
|
|
157
|
+
n[_] = i;
|
|
158
|
+
} else if (r && C(r)) {
|
|
159
|
+
const o = await (await fetch(r)).text();
|
|
160
|
+
if (R(_) && !S(o))
|
|
161
|
+
throw new Error(`Error parsing PEM file at: ${r}`);
|
|
162
|
+
n[_] = o;
|
|
163
|
+
} else
|
|
164
|
+
return r;
|
|
165
|
+
});
|
|
166
|
+
await Promise.all(e);
|
|
167
|
+
} catch (e) {
|
|
168
|
+
throw new Error("Failed to resolve trust settings.", { cause: e });
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
const R = (n) => ["userAnchors", "trustAnchors"].includes(n), S = (n) => n.includes("-----BEGIN CERTIFICATE-----"), C = (n) => n.startsWith("http"), w = 10 ** 9;
|
|
172
|
+
function D(n) {
|
|
173
|
+
const { tx: e } = n, _ = new FinalizationRegistry(async (r) => {
|
|
174
|
+
await e.reader_free(r);
|
|
175
|
+
});
|
|
176
|
+
return {
|
|
177
|
+
async fromBlob(r, t, o) {
|
|
178
|
+
if (!A(r))
|
|
179
|
+
throw new v(r);
|
|
180
|
+
if (t.size > w)
|
|
181
|
+
throw new h(t.size);
|
|
182
|
+
try {
|
|
183
|
+
const i = o ? await b(o) : void 0, a = await e.reader_fromBlob(r, t, i), c = x(n, a, () => {
|
|
184
|
+
_.unregister(c);
|
|
185
|
+
});
|
|
186
|
+
return _.register(c, a, c), c;
|
|
187
|
+
} catch (i) {
|
|
188
|
+
return B(i);
|
|
189
|
+
}
|
|
190
|
+
},
|
|
191
|
+
async fromBlobFragment(r, t, o, i) {
|
|
192
|
+
if (!A(r))
|
|
193
|
+
throw new v(r);
|
|
194
|
+
if (t.size > w)
|
|
195
|
+
throw new h(t.size);
|
|
196
|
+
try {
|
|
197
|
+
const a = i ? await b(i) : void 0, c = await e.reader_fromBlobFragment(
|
|
198
|
+
r,
|
|
199
|
+
t,
|
|
200
|
+
o,
|
|
201
|
+
a
|
|
202
|
+
), s = x(n, c, () => {
|
|
203
|
+
_.unregister(s);
|
|
204
|
+
});
|
|
205
|
+
return _.register(s, c, s), s;
|
|
206
|
+
} catch (a) {
|
|
207
|
+
return B(a);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
function B(n) {
|
|
213
|
+
if (n instanceof Error && n.message === "C2pa(JumbfNotFound)")
|
|
214
|
+
return null;
|
|
215
|
+
throw n;
|
|
216
|
+
}
|
|
217
|
+
function x(n, e, _) {
|
|
218
|
+
const { tx: r } = n;
|
|
219
|
+
return {
|
|
220
|
+
async activeLabel() {
|
|
221
|
+
return await r.reader_activeLabel(e);
|
|
222
|
+
},
|
|
223
|
+
async manifestStore() {
|
|
224
|
+
return await r.reader_manifestStore(e);
|
|
225
|
+
},
|
|
226
|
+
async activeManifest() {
|
|
227
|
+
return await r.reader_activeManifest(e);
|
|
228
|
+
},
|
|
229
|
+
async json() {
|
|
230
|
+
const t = await r.reader_json(e);
|
|
231
|
+
return JSON.parse(t);
|
|
232
|
+
},
|
|
233
|
+
async resourceToBytes(t) {
|
|
234
|
+
return await r.reader_resourceToBytes(e, t);
|
|
235
|
+
},
|
|
236
|
+
async free() {
|
|
237
|
+
_(), await r.reader_free(e);
|
|
238
|
+
}
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
let l;
|
|
242
|
+
typeof FinalizationRegistry > "u" || new FinalizationRegistry((n) => n.dtor(n.a, n.b));
|
|
243
|
+
let P = new TextDecoder("utf-8", { ignoreBOM: !0, fatal: !0 });
|
|
244
|
+
P.decode();
|
|
245
|
+
const g = new TextEncoder();
|
|
246
|
+
"encodeInto" in g || (g.encodeInto = function(n, e) {
|
|
247
|
+
const _ = g.encode(n);
|
|
248
|
+
return e.set(_), {
|
|
249
|
+
read: n.length,
|
|
250
|
+
written: _.length
|
|
251
|
+
};
|
|
252
|
+
});
|
|
253
|
+
typeof FinalizationRegistry > "u" || new FinalizationRegistry((n) => l.__wbg_wasmbuilder_free(n >>> 0, 1));
|
|
254
|
+
typeof FinalizationRegistry > "u" || new FinalizationRegistry((n) => l.__wbg_wasmreader_free(n >>> 0, 1));
|
|
255
|
+
typeof FinalizationRegistry > "u" || new FinalizationRegistry((n) => l.__wbg_wasmsigner_free(n >>> 0, 1));
|
|
256
|
+
const q = "sha512-emM3xZBux5bBdEv6EFS+y5SmKnxnEVbNgsjbsOLnC/YYm55pviVrgdOxU8iQUisOISQvXrTj7H8vvsgYVlpeLg==";
|
|
257
|
+
async function F(n) {
|
|
258
|
+
const { alg: e } = n;
|
|
259
|
+
return {
|
|
260
|
+
reserveSize: await n.reserveSize(),
|
|
261
|
+
alg: e
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
function $(n) {
|
|
265
|
+
const { tx: e } = n, _ = new FinalizationRegistry((r) => {
|
|
266
|
+
e.builder_free(r);
|
|
267
|
+
});
|
|
268
|
+
return {
|
|
269
|
+
async new(r) {
|
|
270
|
+
const t = r ? await b(r) : void 0, o = await e.builder_new(t), i = f(n, o, () => {
|
|
271
|
+
_.unregister(i);
|
|
272
|
+
});
|
|
273
|
+
return _.register(i, o, i), i;
|
|
274
|
+
},
|
|
275
|
+
async fromDefinition(r, t) {
|
|
276
|
+
const o = JSON.stringify(r), i = t ? await b(t) : void 0, a = await e.builder_fromJson(o, i), c = f(n, a, () => {
|
|
277
|
+
_.unregister(c);
|
|
278
|
+
});
|
|
279
|
+
return _.register(c, a, c), c;
|
|
280
|
+
},
|
|
281
|
+
async fromArchive(r, t) {
|
|
282
|
+
const o = t ? await b(t) : void 0, i = await e.builder_fromArchive(r, o), a = f(n, i, () => {
|
|
283
|
+
_.unregister(a);
|
|
284
|
+
});
|
|
285
|
+
return _.register(a, i, a), a;
|
|
286
|
+
}
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
function f(n, e, _) {
|
|
290
|
+
const { tx: r } = n;
|
|
291
|
+
return {
|
|
292
|
+
async setIntent(t) {
|
|
293
|
+
await r.builder_setIntent(e, t);
|
|
294
|
+
},
|
|
295
|
+
async addAction(t) {
|
|
296
|
+
await r.builder_addAction(e, t);
|
|
297
|
+
},
|
|
298
|
+
async setRemoteUrl(t) {
|
|
299
|
+
await r.builder_setRemoteUrl(e, t);
|
|
300
|
+
},
|
|
301
|
+
async setNoEmbed(t) {
|
|
302
|
+
await r.builder_setNoEmbed(e, t);
|
|
303
|
+
},
|
|
304
|
+
async setThumbnailFromBlob(t, o) {
|
|
305
|
+
await r.builder_setThumbnailFromBlob(e, t, o);
|
|
306
|
+
},
|
|
307
|
+
async addIngredient(t) {
|
|
308
|
+
const o = JSON.stringify(t);
|
|
309
|
+
await r.builder_addIngredient(e, o);
|
|
310
|
+
},
|
|
311
|
+
async addIngredientFromBlob(t, o, i) {
|
|
312
|
+
const a = JSON.stringify(t);
|
|
313
|
+
await r.builder_addIngredientFromBlob(e, a, o, i);
|
|
314
|
+
},
|
|
315
|
+
async addResourceFromBlob(t, o) {
|
|
316
|
+
await r.builder_addResourceFromBlob(e, t, o);
|
|
317
|
+
},
|
|
318
|
+
async getDefinition() {
|
|
319
|
+
return await r.builder_getDefinition(e);
|
|
320
|
+
},
|
|
321
|
+
async toArchive() {
|
|
322
|
+
return await r.builder_toArchive(e);
|
|
323
|
+
},
|
|
324
|
+
async sign(t, o, i) {
|
|
325
|
+
const a = await F(t), c = n.registerSignReceiver(t.sign);
|
|
326
|
+
return await r.builder_sign(
|
|
327
|
+
e,
|
|
328
|
+
c,
|
|
329
|
+
a,
|
|
330
|
+
o,
|
|
331
|
+
i
|
|
332
|
+
);
|
|
333
|
+
},
|
|
334
|
+
async signAndGetManifestBytes(t, o, i) {
|
|
335
|
+
const a = await F(t), c = n.registerSignReceiver(t.sign);
|
|
336
|
+
return await r.builder_signAndGetManifestBytes(
|
|
337
|
+
e,
|
|
338
|
+
c,
|
|
339
|
+
a,
|
|
340
|
+
o,
|
|
341
|
+
i
|
|
342
|
+
);
|
|
343
|
+
},
|
|
344
|
+
async free() {
|
|
345
|
+
_(), await r.builder_free(e);
|
|
346
|
+
}
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
async function Z(n) {
|
|
350
|
+
const { wasmSrc: e, settings: _ } = n, r = typeof e == "string" ? await G(e) : e, t = _ ? await J(_) : void 0, o = await L({ wasm: r, settingsString: t });
|
|
351
|
+
return {
|
|
352
|
+
reader: D(o),
|
|
353
|
+
builder: $(o),
|
|
354
|
+
dispose: o.terminate
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
async function G(n) {
|
|
358
|
+
const e = await fetch(n, { integrity: q });
|
|
359
|
+
return await WebAssembly.compileStreaming(e);
|
|
360
|
+
}
|
|
361
|
+
export {
|
|
362
|
+
k as R,
|
|
363
|
+
Z as c,
|
|
364
|
+
A as i
|
|
365
|
+
};
|
package/dist/common.d.ts
CHANGED
|
@@ -11,6 +11,6 @@ export type { Reader, ReaderFactory } from './lib/reader.js';
|
|
|
11
11
|
export type { Builder, BuilderFactory, ManifestAndAssetBytes, } from './lib/builder.js';
|
|
12
12
|
export type { Signer, SigningAlg } from './lib/signer.js';
|
|
13
13
|
export { isSupportedReaderFormat, READER_SUPPORTED_FORMATS, } from './lib/supportedFormats.js';
|
|
14
|
-
export type { Settings, VerifySettings, TrustSettings, BuilderSettings, CawgTrustSettings, } from './lib/settings.js';
|
|
14
|
+
export type { SettingsContext, Settings, VerifySettings, TrustSettings, BuilderSettings, BuilderThumbnailSettings, CawgTrustSettings, } from './lib/settings.js';
|
|
15
15
|
export type * from '@contentauth/c2pa-types';
|
|
16
16
|
//# sourceMappingURL=common.d.ts.map
|
package/dist/common.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../src/common.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,mBAAmB,eAAe,CAAC;AAEnC,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAE7D,YAAY,EACV,OAAO,EACP,cAAc,EACd,qBAAqB,GACtB,MAAM,kBAAkB,CAAC;AAE1B,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE1D,OAAO,EACL,uBAAuB,EACvB,wBAAwB,GACzB,MAAM,2BAA2B,CAAC;AAEnC,YAAY,EACV,QAAQ,EACR,cAAc,EACd,aAAa,EACb,eAAe,EACf,iBAAiB,GAClB,MAAM,mBAAmB,CAAC;AAG3B,mBAAmB,yBAAyB,CAAC"}
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../src/common.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,mBAAmB,eAAe,CAAC;AAEnC,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAE7D,YAAY,EACV,OAAO,EACP,cAAc,EACd,qBAAqB,GACtB,MAAM,kBAAkB,CAAC;AAE1B,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE1D,OAAO,EACL,uBAAuB,EACvB,wBAAwB,GACzB,MAAM,2BAA2B,CAAC;AAEnC,YAAY,EACV,eAAe,EACf,QAAQ,EACR,cAAc,EACd,aAAa,EACb,eAAe,EACf,wBAAwB,EACxB,iBAAiB,GAClB,MAAM,mBAAmB,CAAC;AAG3B,mBAAmB,yBAAyB,CAAC"}
|
package/dist/index.js
CHANGED