@contentauth/c2pa-web 0.16.1 → 0.17.1

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.
@@ -1,1086 +0,0 @@
1
- var Ae = Object.defineProperty;
2
- var W = (t) => {
3
- throw TypeError(t);
4
- };
5
- var pe = (t, e, n) => e in t ? Ae(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
6
- var S = (t, e, n) => pe(t, typeof e != "symbol" ? e + "" : e, n), V = (t, e, n) => e.has(t) || W("Cannot " + n);
7
- var o = (t, e, n) => (V(t, e, "read from private field"), n ? n.call(t) : e.get(t)), x = (t, e, n) => e.has(t) ? W("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, n), E = (t, e, n, r) => (V(t, e, "write to private field"), r ? r.call(t, n) : e.set(t, n), n);
8
- import { channel as _e, transfer as G } from "highgain";
9
- const { createTx: Re, rx: Xe } = _e(), { createTx: Ze, rx: ve } = _e("worker"), ae = '(function(){"use strict";class y{static __wrap(e){const t=Object.create(y.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_wasmbuilder_free(e,0)}addAction(e){const t=o.wasmbuilder_addAction(this.__wbg_ptr,e);if(t[1])throw b(t[0])}addAssertion(e,t){const n=d(e,o.__wbindgen_malloc,o.__wbindgen_realloc),_=a,c=o.wasmbuilder_addAssertion(this.__wbg_ptr,n,_,t);if(c[1])throw b(c[0])}addIngredientFromBlob(e,t,n){const _=d(e,o.__wbindgen_malloc,o.__wbindgen_realloc),c=a,s=d(t,o.__wbindgen_malloc,o.__wbindgen_realloc),i=a;return o.wasmbuilder_addIngredientFromBlob(this.__wbg_ptr,_,c,s,i,n)}addIngredient(e){const t=d(e,o.__wbindgen_malloc,o.__wbindgen_realloc),n=a,_=o.wasmbuilder_addIngredient(this.__wbg_ptr,t,n);if(_[1])throw b(_[0])}addRedaction(e,t){const n=d(e,o.__wbindgen_malloc,o.__wbindgen_realloc),_=a,c=o.wasmbuilder_addRedaction(this.__wbg_ptr,n,_,t);if(c[1])throw b(c[0])}addResourceFromBlob(e,t){const n=d(e,o.__wbindgen_malloc,o.__wbindgen_realloc),_=a,c=o.wasmbuilder_addResourceFromBlob(this.__wbg_ptr,n,_,t);if(c[1])throw b(c[0])}filterActionsAndIngredientsAt(e,t){const n=E(e,o.__wbindgen_malloc),_=a,c=E(t,o.__wbindgen_malloc),s=a,i=o.wasmbuilder_filterActionsAndIngredientsAt(this.__wbg_ptr,n,_,c,s);if(i[1])throw b(i[0])}filterActionsAt(e){const t=E(e,o.__wbindgen_malloc),n=a,_=o.wasmbuilder_filterActionsAt(this.__wbg_ptr,t,n);if(_[1])throw b(_[0])}filterIngredientsAt(e){const t=E(e,o.__wbindgen_malloc),n=a,_=o.wasmbuilder_filterIngredientsAt(this.__wbg_ptr,t,n);if(_[1])throw b(_[0])}static fromArchive(e,t){var n=w(t)?0:d(t,o.__wbindgen_malloc,o.__wbindgen_realloc),_=a;const c=o.wasmbuilder_fromArchive(e,n,_);if(c[2])throw b(c[1]);return y.__wrap(c[0])}static fromJson(e,t){const n=d(e,o.__wbindgen_malloc,o.__wbindgen_realloc),_=a;var c=w(t)?0:d(t,o.__wbindgen_malloc,o.__wbindgen_realloc),s=a;const i=o.wasmbuilder_fromJson(n,_,c,s);if(i[2])throw b(i[1]);return y.__wrap(i[0])}getDefinition(){const e=o.wasmbuilder_getDefinition(this.__wbg_ptr);if(e[2])throw b(e[1]);return b(e[0])}static new(e){var t=w(e)?0:d(e,o.__wbindgen_malloc,o.__wbindgen_realloc),n=a;const _=o.wasmbuilder_new(t,n);if(_[2])throw b(_[1]);return y.__wrap(_[0])}setIntent(e){const t=o.wasmbuilder_setIntent(this.__wbg_ptr,e);if(t[1])throw b(t[0])}setNoEmbed(e){o.wasmbuilder_setNoEmbed(this.__wbg_ptr,e)}setRemoteUrl(e){const t=d(e,o.__wbindgen_malloc,o.__wbindgen_realloc),n=a;o.wasmbuilder_setRemoteUrl(this.__wbg_ptr,t,n)}setThumbnailFromBlob(e,t){const n=d(e,o.__wbindgen_malloc,o.__wbindgen_realloc),_=a,c=o.wasmbuilder_setThumbnailFromBlob(this.__wbg_ptr,n,_,t);if(c[1])throw b(c[0])}signAndGetManifestBytes(e,t,n,_){const c=d(n,o.__wbindgen_malloc,o.__wbindgen_realloc),s=a;return o.wasmbuilder_signAndGetManifestBytes(this.__wbg_ptr,e,t,c,s,_)}sign(e,t,n,_){const c=d(n,o.__wbindgen_malloc,o.__wbindgen_realloc),s=a;return o.wasmbuilder_sign(this.__wbg_ptr,e,t,c,s,_)}toArchive(){const e=o.wasmbuilder_toArchive(this.__wbg_ptr);if(e[2])throw b(e[1]);return b(e[0])}updateActionsAt(e){const t=o.wasmbuilder_updateActionsAt(this.__wbg_ptr,e);if(t[1])throw b(t[0])}updateAssertionsAt(e,t){const n=d(e,o.__wbindgen_malloc,o.__wbindgen_realloc),_=a,c=o.wasmbuilder_updateAssertionsAt(this.__wbg_ptr,n,_,t);if(c[1])throw b(c[0])}updateManifestProperty(e,t){const n=d(e,o.__wbindgen_malloc,o.__wbindgen_realloc),_=a,c=o.wasmbuilder_updateManifestProperty(this.__wbg_ptr,n,_,t);if(c[1])throw b(c[0])}}Symbol.dispose&&(y.prototype[Symbol.dispose]=y.prototype.free);class F{static __wrap(e){const t=Object.create(F.prototype);return t.__wbg_ptr=e,N.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,N.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=p(e[0],e[1]),o.__wbindgen_free(e[0],e[1]*1,1)),t}activeManifest(){const e=o.wasmreader_activeManifest(this.__wbg_ptr);if(e[2])throw b(e[1]);return b(e[0])}crJson(){let e,t;try{const n=o.wasmreader_crJson(this.__wbg_ptr);return e=n[0],t=n[1],p(n[0],n[1])}finally{o.__wbindgen_free(e,t,1)}}static fromBlobFragment(e,t,n,_){const c=d(e,o.__wbindgen_malloc,o.__wbindgen_realloc),s=a;var i=w(_)?0:d(_,o.__wbindgen_malloc,o.__wbindgen_realloc),u=a;return o.wasmreader_fromBlobFragment(c,s,t,n,i,u)}static fromBlob(e,t,n){const _=d(e,o.__wbindgen_malloc,o.__wbindgen_realloc),c=a;var s=w(n)?0:d(n,o.__wbindgen_malloc,o.__wbindgen_realloc),i=a;return o.wasmreader_fromBlob(_,c,t,s,i)}static fromBytes(e,t,n){const _=d(e,o.__wbindgen_malloc,o.__wbindgen_realloc),c=a,s=ee(t,o.__wbindgen_malloc),i=a;var u=w(n)?0:d(n,o.__wbindgen_malloc,o.__wbindgen_realloc),g=a;return o.wasmreader_fromBytes(_,c,s,i,u,g)}json(){let e,t;try{const n=o.wasmreader_json(this.__wbg_ptr);return e=n[0],t=n[1],p(n[0],n[1])}finally{o.__wbindgen_free(e,t,1)}}manifestStore(){const e=o.wasmreader_manifestStore(this.__wbg_ptr);if(e[2])throw b(e[1]);return b(e[0])}resourceToBytes(e){const t=d(e,o.__wbindgen_malloc,o.__wbindgen_realloc),n=a,_=o.wasmreader_resourceToBytes(this.__wbg_ptr,t,n);if(_[2])throw b(_[1]);return b(_[0])}}Symbol.dispose&&(F.prototype[Symbol.dispose]=F.prototype.free);function C(r){const e=o.encodeSignerPayload(r);if(e[3])throw b(e[2]);var t=A(e[0],e[1]).slice();return o.__wbindgen_free(e[0],e[1]*1,1),t}function G(){return{__proto__:null,"./c2pa_bg.js":{__proto__:null,__wbg_Error_30c8987f7c2ed4e2:function(e,t){return Error(p(e,t))},__wbg_Number_14af1003b8dd5ead:function(e){return Number(e)},__wbg_String_8564e559799eccda:function(e,t){const n=String(t),_=d(n,o.__wbindgen_malloc,o.__wbindgen_realloc),c=a;m().setInt32(e+4,c,!0),m().setInt32(e+0,_,!0)},__wbg___wbindgen_bigint_get_as_i64_a2383202b9353e4c:function(e,t){const n=t,_=typeof n=="bigint"?n:void 0;m().setBigInt64(e+8,w(_)?BigInt(0):_,!0),m().setInt32(e+0,!w(_),!0)},__wbg___wbindgen_boolean_get_5b446f51afd21013:function(e){const t=e,n=typeof t=="boolean"?t:void 0;return w(n)?16777215:n?1:0},__wbg___wbindgen_debug_string_4687d8d8c2017d52:function(e,t){const n=U(t),_=d(n,o.__wbindgen_malloc,o.__wbindgen_realloc),c=a;m().setInt32(e+4,c,!0),m().setInt32(e+0,_,!0)},__wbg___wbindgen_in_92f62ee1427d9e49:function(e,t){return e in t},__wbg___wbindgen_is_bigint_b123553bed3bb382:function(e){return typeof e=="bigint"},__wbg___wbindgen_is_function_1f9d30630b8b1d3d:function(e){return typeof e=="function"},__wbg___wbindgen_is_null_e343b7d08827ba72:function(e){return e===null},__wbg___wbindgen_is_object_3c45d4f2dde4e749:function(e){const t=e;return typeof t=="object"&&t!==null},__wbg___wbindgen_is_string_90b56bc79aad6f6c:function(e){return typeof e=="string"},__wbg___wbindgen_is_undefined_8865fb403f8fe9d8:function(e){return e===void 0},__wbg___wbindgen_jsval_eq_02babf21faa37971:function(e,t){return e===t},__wbg___wbindgen_jsval_loose_eq_677f21e468d6b461:function(e,t){return e==t},__wbg___wbindgen_number_get_2e0e7dee9f701a71:function(e,t){const n=t,_=typeof n=="number"?n:void 0;m().setFloat64(e+8,w(_)?0:_,!0),m().setInt32(e+0,!w(_),!0)},__wbg___wbindgen_string_get_0380ccaa2f57f0d9:function(e,t){const n=t,_=typeof n=="string"?n:void 0;var c=w(_)?0:d(_,o.__wbindgen_malloc,o.__wbindgen_realloc),s=a;m().setInt32(e+4,s,!0),m().setInt32(e+0,c,!0)},__wbg___wbindgen_throw_41e9ee4f547fc59a:function(e,t){throw new Error(p(e,t))},__wbg__wbg_cb_unref_dcc1a90847f04c41:function(e){e._wbg_cb_unref()},__wbg_abort_334e7f918b7c5047:function(e,t){e.abort(t)},__wbg_abort_f78b99d80248bacb:function(e){e.abort()},__wbg_append_1938ed58fb5613b8:function(){return l(function(e,t,n,_,c){e.append(p(t,n),p(_,c))},arguments)},__wbg_arrayBuffer_f07be74819944ea2:function(){return l(function(e){return e.arrayBuffer()},arguments)},__wbg_byteLength_9f985b8373f1f3fe:function(e){return e.byteLength},__wbg_call_187d372bd5fdd4aa:function(){return l(function(e,t,n){return e.call(t,n)},arguments)},__wbg_call_6137034ef55c9d0f:function(){return l(function(e,t){return e.call(t)},arguments)},__wbg_clearTimeout_6b8d9a38b9263d65:function(e){return clearTimeout(e)},__wbg_crypto_38df2bab126b63dc:function(e){return e.crypto},__wbg_done_b41a1d26cdb37fb6:function(e){return e.done},__wbg_entries_fb6397112b1de25f:function(e){return Object.entries(e)},__wbg_error_757e9472f8410341:function(e,t){let n,_;try{n=e,_=t,console.error(p(e,t))}finally{o.__wbindgen_free(n,_,1)}},__wbg_fetch_9dad4fe911207b37:function(e){return fetch(e)},__wbg_fetch_efc64baf325b084d:function(e,t){return e.fetch(t)},__wbg_from_296ca31f8d0f1c52:function(e){return Array.from(e)},__wbg_getRandomValues_436a51d0629d84e1:function(){return l(function(e,t){globalThis.crypto.getRandomValues(A(e,t))},arguments)},__wbg_getRandomValues_a608c4436c19407a:function(){return l(function(e,t){globalThis.crypto.getRandomValues(A(e,t))},arguments)},__wbg_getRandomValues_a678b7300e8ed57f:function(){return l(function(e,t){globalThis.crypto.getRandomValues(A(e,t))},arguments)},__wbg_getRandomValues_c44a50d8cfdaebeb:function(){return l(function(e,t){e.getRandomValues(t)},arguments)},__wbg_getTime_f5a55efff2585d5d:function(e){return e.getTime()},__wbg_get_31af05bd4842a84f:function(){return l(function(e,t){return Reflect.get(e,t)},arguments)},__wbg_get_658f6698067d9515:function(){return l(function(e,t){return Reflect.get(e,t)},arguments)},__wbg_get_6c896e0571ddae51:function(e,t){return e[t>>>0]},__wbg_get_unchecked_288889d017702237:function(e,t){return e[t>>>0]},__wbg_get_with_ref_key_6412cf3094599694:function(e,t){return e[t]},__wbg_has_5d6706e5209576c1:function(){return l(function(e,t){return Reflect.has(e,t)},arguments)},__wbg_headers_eba93595f8944c2f:function(e){return e.headers},__wbg_instanceof_ArrayBuffer_a99f175873e5d9b8:function(e){let t;try{t=e instanceof ArrayBuffer}catch{t=!1}return t},__wbg_instanceof_Map_b2611749102d7ba3:function(e){let t;try{t=e instanceof Map}catch{t=!1}return t},__wbg_instanceof_Promise_e1dc6893aa1ece28:function(e){let t;try{t=e instanceof Promise}catch{t=!1}return t},__wbg_instanceof_Response_b8758567269c30b2:function(e){let t;try{t=e instanceof Response}catch{t=!1}return t},__wbg_instanceof_Uint8Array_828cef2aaacafc31:function(e){let t;try{t=e instanceof Uint8Array}catch{t=!1}return t},__wbg_isArray_e15a2ff68ffdbef2:function(e){return Array.isArray(e)},__wbg_isSafeInteger_717808ad6a54bd9e:function(e){return Number.isSafeInteger(e)},__wbg_iterator_e3c31c892080e444:function(){return Symbol.iterator},__wbg_length_7f3c00c40364105e:function(e){return e.length},__wbg_length_d4bdea10311bd9cf:function(e){return e.length},__wbg_msCrypto_bd5a034af96bcba6:function(e){return e.msCrypto},__wbg_new_0_72d020f0c63443d4:function(){return new Date},__wbg_new_1dbf7428bba60a42:function(e){return new Uint8Array(e)},__wbg_new_227d7c05414eb861:function(){return new Error},__wbg_new_28744009d011f847:function(){return new Map},__wbg_new_2e41357094e99294:function(){return l(function(){return new AbortController},arguments)},__wbg_new_617a8cdb8bb1130e:function(){return new Object},__wbg_new_83ca405eae412a62:function(){return l(function(){return new Headers},arguments)},__wbg_new_9ffe4dece67ce9fc:function(){return l(function(){return new FileReaderSync},arguments)},__wbg_new_ee2291f50781bf1d:function(){return new Array},__wbg_new_from_slice_9a868026ffa4208a:function(e,t){return new Uint8Array(A(e,t))},__wbg_new_typed_b01cb72a8af741a3:function(e,t){try{var n={a:e,b:t},_=(s,i)=>{const u=n.a;n.a=0;try{return X(u,n.b,s,i)}finally{n.a=u}};return new Promise(_)}finally{n.a=0}},__wbg_new_with_length_3da0ad195f6f63ba:function(e){return new Uint8Array(e>>>0)},__wbg_new_with_str_and_init_4618dee4e950224f:function(){return l(function(e,t,n){return new Request(p(e,t),n)},arguments)},__wbg_next_33784799010f1bbe:function(e){return e.next},__wbg_next_f4aac29c42af995c:function(){return l(function(e){return e.next()},arguments)},__wbg_node_84ea875411254db1:function(e){return e.node},__wbg_now_aa4ccb83129e9e55:function(){return Date.now()},__wbg_process_44c7a14e11e9f69e:function(e){return e.process},__wbg_prototypesetcall_bc27214492979395:function(e,t,n){Uint8Array.prototype.set.call(A(e,t),n)},__wbg_queueMicrotask_9833f9a49df95a49:function(e){return e.queueMicrotask},__wbg_queueMicrotask_a72f977e97f23c5f:function(e){queueMicrotask(e)},__wbg_randomFillSync_6c25eac9869eb53c:function(){return l(function(e,t){e.randomFillSync(t)},arguments)},__wbg_readAsArrayBuffer_14bc98cc9cdf7c0b:function(){return l(function(e,t){return e.readAsArrayBuffer(t)},arguments)},__wbg_require_b4edbdcf3e2a1ef0:function(){return l(function(){return module.require},arguments)},__wbg_resolve_0076e10020304ede:function(e){return Promise.resolve(e)},__wbg_setTimeout_f757f00851f76c42:function(e,t){return setTimeout(e,t)},__wbg_set_575d3ddb70fe831d:function(e,t,n){e.set(A(t,n))},__wbg_set_6ae97e73113c4f0b:function(e,t,n){return e.set(t,n)},__wbg_set_6be42768c690e380:function(e,t,n){e[t]=n},__wbg_set_bea140a88be9b277:function(e,t,n){e[t>>>0]=n},__wbg_set_body_1fb0f1008bfc7df6:function(e,t){e.body=t},__wbg_set_cache_7507c4cc5938ccc7:function(e,t){e.cache=Y[t]},__wbg_set_credentials_e0dcce31ca532b7d:function(e,t){e.credentials=K[t]},__wbg_set_headers_40ad33dcf016613f:function(e,t){e.headers=t},__wbg_set_method_dcb32343247ec427:function(e,t,n){e.method=p(t,n)},__wbg_set_mode_74e772635acb96ec:function(e,t){e.mode=Q[t]},__wbg_set_signal_2dbd377604627f26:function(e,t){e.signal=t},__wbg_signal_e5a49a2d9c65b7f6:function(e){return e.signal},__wbg_size_8f1c0b1a1fbb3810:function(e){return e.size},__wbg_slice_afd8274aed4149c0:function(){return l(function(e,t,n){return e.slice(t,n)},arguments)},__wbg_stack_3b0d974bbf31e44f:function(e,t){const n=t.stack,_=d(n,o.__wbindgen_malloc,o.__wbindgen_realloc),c=a;m().setInt32(e+4,c,!0),m().setInt32(e+0,_,!0)},__wbg_static_accessor_GLOBAL_266715b9d96ba635:function(){const e=typeof global>"u"?null:global;return w(e)?0:R(e)},__wbg_static_accessor_GLOBAL_THIS_10fb7dc1ae063179:function(){const e=typeof globalThis>"u"?null:globalThis;return w(e)?0:R(e)},__wbg_static_accessor_SELF_0b583911f537483a:function(){const e=typeof self>"u"?null:self;return w(e)?0:R(e)},__wbg_static_accessor_WINDOW_d7f903d1508cbdc4:function(){const e=typeof window>"u"?null:window;return w(e)?0:R(e)},__wbg_status_ce0a98d3c57125f3:function(e){return e.status},__wbg_stringify_52ff602c1cc4fbb6:function(){return l(function(e){return JSON.stringify(e)},arguments)},__wbg_subarray_002b94d5e13d1411:function(e,t,n){return e.subarray(t>>>0,n>>>0)},__wbg_then_c949d5a25a4e78f8:function(e,t,n){return e.then(t,n)},__wbg_then_e71170d78fcf8954:function(e,t){return e.then(t)},__wbg_url_8e28edeab4cd6bed:function(e,t){const n=t.url,_=d(n,o.__wbindgen_malloc,o.__wbindgen_realloc),c=a;m().setInt32(e+4,c,!0),m().setInt32(e+0,_,!0)},__wbg_valueOf_6abcff09c8156bb6:function(e){return e.valueOf()},__wbg_value_f3c585ee8f5ba40c:function(e){return e.value},__wbg_versions_276b2795b1c6a219:function(e){return e.versions},__wbg_wasmreader_new:function(e){return F.__wrap(e)},__wbindgen_generic_0000000000000001:function(e,t){return L(e,t,H)},__wbindgen_generic_0000000000000002:function(e,t){return L(e,t,$)},__wbindgen_generic_0000000000000003:function(e){return e},__wbindgen_generic_0000000000000004:function(e){return e},__wbindgen_generic_0000000000000005:function(e,t){return A(e,t)},__wbindgen_generic_0000000000000006:function(e,t){return p(e,t)},__wbindgen_generic_0000000000000007:function(e){return BigInt.asUintN(64,e)},__wbindgen_generic_0000000000000008:function(e,t){var n=A(e,t).slice();return o.__wbindgen_free(e,t*1,1),n},__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)}}}}function $(r,e){o.wasm_bindgen_255200e6d97c625a___convert__closures_____invoke_______true_(r,e)}function H(r,e,t){const n=o.wasm_bindgen_255200e6d97c625a___convert__closures_____invoke___wasm_bindgen_255200e6d97c625a___JsValue__core_37ee0ce0c4cd57d5___result__Result_____wasm_bindgen_255200e6d97c625a___JsError___true_(r,e,t);if(n[1])throw b(n[0])}function X(r,e,t,n){o.wasm_bindgen_255200e6d97c625a___convert__closures_____invoke___js_sys_bd80bcec31efc073___Function_fn_wasm_bindgen_255200e6d97c625a___JsValue_____wasm_bindgen_255200e6d97c625a___sys__Undefined___js_sys_bd80bcec31efc073___Function_fn_wasm_bindgen_255200e6d97c625a___JsValue_____wasm_bindgen_255200e6d97c625a___sys__Undefined_______true_(r,e,t,n)}const Y=["default","no-store","reload","no-cache","force-cache","only-if-cached"],K=["omit","same-origin","include"],Q=["same-origin","no-cors","cors","navigate"],z=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(r=>o.__wbg_wasmbuilder_free(r,1)),N=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(r=>o.__wbg_wasmreader_free(r,1));typeof FinalizationRegistry>"u"||new FinalizationRegistry(r=>o.__wbg_wasmsigner_free(r,1));function R(r){const e=o.__externref_table_alloc();return o.__wbindgen_externrefs.set(e,r),e}const J=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(r=>o.__wbindgen_destroy_closure(r.a,r.b));function U(r){const e=typeof r;if(e=="number"||e=="boolean"||r==null)return`${r}`;if(e=="string")return`"${r}"`;if(e=="symbol"){const _=r.description;return _==null?"Symbol":`Symbol(${_})`}if(e=="function"){const _=r.name;return typeof _=="string"&&_.length>0?`Function(${_})`:"Function"}if(Array.isArray(r)){const _=r.length;let c="[";_>0&&(c+=U(r[0]));for(let s=1;s<_;s++)c+=", "+U(r[s]);return c+="]",c}const t=/\\[object ([^\\]]+)\\]/.exec(toString.call(r));let n;if(t&&t.length>1)n=t[1];else return toString.call(r);if(n=="Object")try{return"Object("+JSON.stringify(r)+")"}catch{return"Object"}return r instanceof Error?`${r.name}: ${r.message}\n${r.stack}`:n}function A(r,e){return r=r>>>0,S().subarray(r/1,r/1+e)}let M=null;function m(){return(M===null||M.buffer.detached===!0||M.buffer.detached===void 0&&M.buffer!==o.memory.buffer)&&(M=new DataView(o.memory.buffer)),M}function p(r,e){return ne(r>>>0,e)}let B=null;function Z(){return(B===null||B.byteLength===0)&&(B=new Uint32Array(o.memory.buffer)),B}let T=null;function S(){return(T===null||T.byteLength===0)&&(T=new Uint8Array(o.memory.buffer)),T}function l(r,e){try{return r.apply(this,e)}catch(t){const n=R(t);o.__wbindgen_exn_store(n)}}function w(r){return r==null}function L(r,e,t){const n={a:r,b:e,cnt:1},_=(...c)=>{n.cnt++;const s=n.a;n.a=0;try{return t(s,n.b,...c)}finally{n.a=s,_._wbg_cb_unref()}};return _._wbg_cb_unref=()=>{--n.cnt===0&&(o.__wbindgen_destroy_closure(n.a,n.b),n.a=0,J.unregister(n))},J.register(_,n,n),_}function E(r,e){const t=e(r.length*4,4)>>>0;return Z().set(r,t/4),a=r.length,t}function ee(r,e){const t=e(r.length*1,1)>>>0;return S().set(r,t/1),a=r.length,t}function d(r,e,t){if(t===void 0){const i=j.encode(r),u=e(i.length,1)>>>0;return S().subarray(u,u+i.length).set(i),a=i.length,u}let n=r.length,_=e(n,1)>>>0;const c=S();let s=0;for(;s<n;s++){const i=r.charCodeAt(s);if(i>127)break;c[_+s]=i}if(s!==n){s!==0&&(r=r.slice(s)),_=t(_,n,n=s+r.length*3,1)>>>0;const i=S().subarray(_+s,_+n),u=j.encodeInto(r,i);s+=u.written,_=t(_,n,s,1)>>>0}return a=s,_}function b(r){const e=o.__wbindgen_externrefs.get(r);return o.__externref_table_dealloc(r),e}let O=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});O.decode();const te=2146435072;let x=0;function ne(r,e){return x+=e,x>=te&&(O=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),O.decode(),x=e),O.decode(S().subarray(r,r+e))}const j=new TextEncoder;"encodeInto"in j||(j.encodeInto=function(r,e){const t=j.encode(r);return e.set(t),{read:r.length,written:t.length}});let a=0,o;function re(r,e){return o=r.exports,M=null,B=null,T=null,o.__wbindgen_start(),o}function _e(r){if(o!==void 0)return o;r!==void 0&&(Object.getPrototypeOf(r)===Object.prototype?{module:r}=r:console.warn("using deprecated parameters for `initSync()`; pass a single object instead"));const e=G();r instanceof WebAssembly.Module||(r=new WebAssembly.Module(r));const t=new WebAssembly.Instance(r,e);return re(t)}function V(){let r=0;const e=new Map;return{add(t){const n=r++;return e.set(n,t),n},get(t){const n=e.get(t);if(!n)throw new Error("Attempted to use an object that has been freed");return n},remove(t){return e.delete(t)}}}const D=Symbol("transfer");function v(r,e){return{type:D,value:r,transfer:e?Array.isArray(e)?e:[e]:[r]}}function P(r){return!!(r&&typeof r=="object"&&Reflect.get(r,"type")===D)}function W(r="default"){return{createTx(e){const t=new Map,n=e??self;return n.addEventListener("message",_=>{const{data:c}=_;if(c.channelName!==r)return;const{id:s,result:i,error:u}=c,g=t.get(s);g&&(u?g.reject(u):g.resolve(i),t.delete(s))}),new Proxy({},{get(_,c){return(...s)=>{const i=oe(),u=[],g=[];return s.forEach(I=>{P(I)?(u.push(I.value),g.push(...I.transfer)):u.push(I)}),n.postMessage({method:c,args:u,id:i,channelName:r},{transfer:g}),new Promise((I,ue)=>{t.set(i,{resolve:I,reject:ue})})}}})},rx(e,t){const n=t??self;n.addEventListener("message",async _=>{const{data:c}=_;if(c.channelName!==r)return;const{method:s,args:i,id:u}=c;try{const g=await e[s](...i);P(g)?n.postMessage({result:g.value,id:u,channelName:r},{transfer:g.transfer}):n.postMessage({result:g,id:u,channelName:r})}catch(g){n.postMessage({error:g,id:u,channelName:r})}})}}}function oe(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}const{rx:ce}=W(),{createTx:se}=W("worker");function ie(r){if(!(r!=null&&r.manifests))return r;const e=r.manifests,t=Object.assign(Object.create(null),e),n=Object.getPrototypeOf(e);return n!==null&&n!==Object.prototype&&(t.__proto__=n),r.manifests=t,r}const h=V(),f=V(),k=se();function q(r){return r.map(e=>({sigType:e.sigType,reserveSize:e.reserveSize,referencedAssertions:e.referencedAssertions,roles:e.roles,sign:async t=>{const n=t.referencedAssertions.map(c=>c.hash.buffer);return await k.cawgSign(e.requestId,v(t,n))}}))}ce(ae({async initWorker(r){_e({module:r})},encodeSignerPayload(r){const e=C(r);return v(e,e.buffer)},async reader_fromBlob(r,e,t){const n=await F.fromBlob(r,e,t);return h.add(n)},async reader_fromBlobFragment(r,e,t,n){const _=await F.fromBlobFragment(r,e,t,n);return h.add(_)},reader_activeLabel(r){return h.get(r).activeLabel()??null},reader_manifestStore(r){const e=h.get(r);return ie(e.manifestStore())},reader_activeManifest(r){return h.get(r).activeManifest()},reader_json(r){return h.get(r).json()},reader_crJson(r){return h.get(r).crJson()},reader_resourceToBytes(r,e){const n=h.get(r).resourceToBytes(e);return v(n,n.buffer)},reader_free(r){h.get(r).free(),h.remove(r)},builder_new(r){const e=y.new(r);return f.add(e)},builder_fromJson(r,e){const t=y.fromJson(r,e);return f.add(t)},builder_fromArchive(r,e){const t=y.fromArchive(r,e);return f.add(t)},builder_setIntent(r,e){f.get(r).setIntent(e)},builder_addAction(r,e){f.get(r).addAction(e)},builder_addAssertion(r,e,t){f.get(r).addAssertion(e,t)},builder_updateAssertionsAt(r,e,t){f.get(r).updateAssertionsAt(e,t)},builder_addRedaction(r,e,t){f.get(r).addRedaction(e,t)},builder_filterActionsAt(r,e){f.get(r).filterActionsAt(Uint32Array.from(e))},builder_updateActionsAt(r,e){f.get(r).updateActionsAt(e)},builder_filterIngredientsAt(r,e){f.get(r).filterIngredientsAt(Uint32Array.from(e))},builder_filterActionsAndIngredientsAt(r,e,t){f.get(r).filterActionsAndIngredientsAt(Uint32Array.from(e),Uint32Array.from(t))},builder_setRemoteUrl(r,e){f.get(r).setRemoteUrl(e)},builder_setNoEmbed(r,e){f.get(r).setNoEmbed(e)},builder_updateManifestProperty(r,e,t){f.get(r).updateManifestProperty(e,t)},builder_setThumbnailFromBlob(r,e,t){f.get(r).setThumbnailFromBlob(e,t)},builder_addIngredient(r,e){f.get(r).addIngredient(e)},async builder_addIngredientFromBlob(r,e,t,n){await f.get(r).addIngredientFromBlob(e,t,n)},builder_addResourceFromBlob(r,e,t){f.get(r).addResourceFromBlob(e,t)},builder_getDefinition(r){return f.get(r).getDefinition()},builder_toArchive(r){const t=f.get(r).toArchive();return v(t,t.buffer)},async builder_sign(r,e,t,n,_,c){const i=await f.get(r).sign({reserveSize:t.reserveSize,alg:t.alg,sign:async u=>await k.sign(e,v(u,u.buffer),t.reserveSize)},q(n),_,c);return v(i,i.buffer)},async builder_signAndGetManifestBytes(r,e,t,n,_,c){const s=f.get(r),{manifest:i,asset:u}=await s.signAndGetManifestBytes({reserveSize:t.reserveSize,alg:t.alg,sign:async g=>await k.sign(e,v(g,g.buffer),t.reserveSize)},q(n),_,c);return v({manifest:i,asset:u},[i.buffer,u.buffer])},builder_free(r){f.get(r).free(),f.remove(r)}}));function ae(r){const e={};for(const[t,n]of Object.entries(r))e[t]=async(..._)=>{try{return await n(..._)}catch(c){throw typeof c=="string"?new Error(c):c}};return e}})();\n', H = typeof self < "u" && self.Blob && new Blob([ae], { type: "text/javascript;charset=utf-8" });
10
- function Se(t) {
11
- let e;
12
- try {
13
- if (e = H && (self.URL || self.webkitURL).createObjectURL(H), !e) throw "";
14
- const n = new Worker(e, {
15
- name: t == null ? void 0 : t.name
16
- });
17
- return n.addEventListener("error", () => {
18
- (self.URL || self.webkitURL).revokeObjectURL(e);
19
- }), n;
20
- } catch {
21
- return new Worker(
22
- "data:text/javascript;charset=utf-8," + encodeURIComponent(ae),
23
- {
24
- name: t == null ? void 0 : t.name
25
- }
26
- );
27
- } finally {
28
- e && (self.URL || self.webkitURL).revokeObjectURL(e);
29
- }
30
- }
31
- function xe(t) {
32
- if (t.protocol !== "https:")
33
- throw new Error(
34
- `Worker source URL must use https, but got ${t.protocol}`
35
- );
36
- return t.toString();
37
- }
38
- async function Ee(t) {
39
- const { wasm: e, workerSrc: n } = t;
40
- let r = 0;
41
- const s = n ? new Worker(xe(n), { type: "module" }) : new Se(), i = Re(s), _ = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map();
42
- ve(
43
- {
44
- sign: async (c, l, b) => {
45
- const g = _.get(c);
46
- if (_.delete(c), !g)
47
- throw new Error("No signer registered for request");
48
- const m = await g(l, b);
49
- return G(m, m.buffer);
50
- },
51
- // Reverse-RPC handler for a CAWG credential holder's `sign`, mirroring
52
- // `sign` above: the callback was registered on the main thread by
53
- // `Builder.sign`/`signAndGetManifestBytes` (see
54
- // `registerCredentialHolderReceiver`) and is looked up and run here,
55
- // never inside the worker.
56
- cawgSign: async (c, l) => {
57
- const b = a.get(c);
58
- if (a.delete(c), !b)
59
- throw new Error("No credential holder registered for request");
60
- const g = await b(l);
61
- return G(g, g.buffer);
62
- }
63
- },
64
- s
65
- );
66
- function u(c) {
67
- const l = r++;
68
- return _.set(l, c), l;
69
- }
70
- function w(c) {
71
- const l = r++;
72
- return a.set(l, c), l;
73
- }
74
- return await i.initWorker(e), {
75
- tx: i,
76
- registerSignReceiver: u,
77
- registerCredentialHolderReceiver: w,
78
- terminate: () => s.terminate()
79
- };
80
- }
81
- typeof FinalizationRegistry > "u" || new FinalizationRegistry((t) => N.__wbg_wasmbuilder_free(t, 1));
82
- typeof FinalizationRegistry > "u" || new FinalizationRegistry((t) => N.__wbg_wasmreader_free(t, 1));
83
- typeof FinalizationRegistry > "u" || new FinalizationRegistry((t) => N.__wbg_wasmsigner_free(t, 1));
84
- typeof FinalizationRegistry > "u" || new FinalizationRegistry((t) => N.__wbindgen_destroy_closure(t.a, t.b));
85
- let Te = new TextDecoder("utf-8", { ignoreBOM: !0, fatal: !0 });
86
- Te.decode();
87
- const D = new TextEncoder();
88
- "encodeInto" in D || (D.encodeInto = function(t, e) {
89
- const n = D.encode(t);
90
- return e.set(n), {
91
- read: t.length,
92
- written: n.length
93
- };
94
- });
95
- let N;
96
- const Ie = "sha512-8n+fD7p0Ub6oJZTuqCs9963t8zreMwliFGiAfr3DMETjZ4m8ai4kJmD2ITad/CvCUebhyB0IfHhFGn5OpY33dg==", M = (t) => {
97
- if (typeof t == "object" && t !== null) {
98
- if (typeof Object.getPrototypeOf == "function") {
99
- const e = Object.getPrototypeOf(t);
100
- return e === Object.prototype || e === null;
101
- }
102
- return Object.prototype.toString.call(t) === "[object Object]";
103
- }
104
- return !1;
105
- }, Fe = /* @__PURE__ */ new Set([
106
- "__proto__",
107
- "constructor",
108
- "prototype",
109
- "toString",
110
- "valueOf",
111
- "hasOwnProperty",
112
- "isPrototypeOf",
113
- "propertyIsEnumerable",
114
- "toLocaleString"
115
- ]), h = (...t) => t.reduce((e, n) => {
116
- if (n === void 0)
117
- return e;
118
- if (Array.isArray(n))
119
- throw new TypeError("Arguments provided to ts-deepmerge must be objects, not arrays.");
120
- return Object.keys(n).forEach((r) => {
121
- Fe.has(r) || (Array.isArray(e[r]) && Array.isArray(n[r]) ? e[r] = h.options.mergeArrays ? h.options.uniqueArrayItems ? Array.from(new Set(e[r].concat(n[r]))) : [...e[r], ...n[r]] : n[r] : M(e[r]) && M(n[r]) ? e[r] = h(e[r], n[r]) : !M(e[r]) && M(n[r]) ? e[r] = h(n[r], void 0) : e[r] = n[r] === void 0 ? h.options.allowUndefinedOverrides ? n[r] : e[r] : n[r]);
122
- }), e;
123
- }, {}), $ = {
124
- allowUndefinedOverrides: !0,
125
- mergeArrays: !0,
126
- uniqueArrayItems: !0
127
- };
128
- h.options = $;
129
- h.withOptions = (t, ...e) => {
130
- h.options = Object.assign(Object.assign({}, $), t);
131
- const n = h(...e);
132
- return h.options = $, n;
133
- };
134
- const ce = 1 * 1024 * 1024, ue = 2, fe = 200, de = 2e3, le = 3e4;
135
- function Me(t) {
136
- return t === 429 || t >= 500;
137
- }
138
- function be(t) {
139
- const e = [
140
- "maxResponseBytes",
141
- "maxRetries",
142
- "initialRetryDelayMs",
143
- "maxRetryDelayMs",
144
- "maxRetryAfterMs"
145
- ];
146
- for (const n of e) {
147
- const r = t == null ? void 0 : t[n];
148
- if (r !== void 0 && (!Number.isFinite(r) || r < 0))
149
- throw new Error(`${n} must be a non-negative finite number`);
150
- }
151
- if ((t == null ? void 0 : t.maxRetries) !== void 0 && !Number.isSafeInteger(t.maxRetries))
152
- throw new Error("maxRetries must be a non-negative safe integer");
153
- }
154
- function Be(t) {
155
- return t instanceof Error && t.name === "AbortError";
156
- }
157
- function q(t) {
158
- return t.reason ?? new DOMException("The operation was aborted", "AbortError");
159
- }
160
- function C(t) {
161
- if (t != null && t.aborted)
162
- throw q(t);
163
- }
164
- function z(t, e) {
165
- return C(e), new Promise((n, r) => {
166
- const s = setTimeout(() => {
167
- e == null || e.removeEventListener("abort", i), n();
168
- }, t), i = () => {
169
- clearTimeout(s), e == null || e.removeEventListener("abort", i), e && r(q(e));
170
- };
171
- e == null || e.addEventListener("abort", i, { once: !0 }), e != null && e.aborted && i();
172
- });
173
- }
174
- function je(t, e, n) {
175
- const r = Math.min(e * 2 ** t, n), s = Math.floor(Math.random() * 200);
176
- return Math.min(r + s, n);
177
- }
178
- function Oe(t) {
179
- if (!t)
180
- return null;
181
- const e = Number(t);
182
- if (!Number.isNaN(e))
183
- return e * 1e3;
184
- const n = Date.parse(t);
185
- return Number.isNaN(n) ? null : n - Date.now();
186
- }
187
- function Ue(t) {
188
- try {
189
- new URL(t);
190
- } catch {
191
- throw new Error(`Invalid URL: ${t}`);
192
- }
193
- }
194
- async function ge(t, e, n) {
195
- Ue(t), be(n);
196
- const r = (n == null ? void 0 : n.maxRetries) ?? ue, s = (n == null ? void 0 : n.initialRetryDelayMs) ?? fe, i = (n == null ? void 0 : n.maxRetryDelayMs) ?? de, _ = (n == null ? void 0 : n.maxRetryAfterMs) ?? le, a = (n == null ? void 0 : n.isRetryableStatus) ?? Me, u = (n == null ? void 0 : n.isRetryableError) ?? (() => !0), w = (n == null ? void 0 : n.fetch) ?? fetch, c = e != null && e.signal && (n != null && n.signal) && e.signal !== n.signal ? AbortSignal.any([e.signal, n.signal]) : (e == null ? void 0 : e.signal) ?? (n == null ? void 0 : n.signal), l = c ? { ...e, signal: c } : e, b = (g) => je(g, s, i);
197
- for (let g = 0; ; g++) {
198
- C(c);
199
- let m;
200
- try {
201
- m = await w(t, l);
202
- } catch (R) {
203
- if (c != null && c.aborted)
204
- throw q(c);
205
- if (!Be(R) && u(R) && g < r) {
206
- await z(b(g), c);
207
- continue;
208
- }
209
- const v = R instanceof Error ? R.message : String(R);
210
- throw new Error(`Network error fetching ${t}: ${v}`, {
211
- cause: R
212
- });
213
- }
214
- if (C(c), !m.ok) {
215
- if (a(m.status)) {
216
- const v = Oe(m.headers.get("retry-after"));
217
- if (v !== null) {
218
- if (v > _)
219
- throw new Error(`Failed to fetch ${t}: server requested a Retry-After delay of ${Math.ceil(v / 1e3)}s, which exceeds the maximum allowed delay of ${_ / 1e3}s`);
220
- if (g < r) {
221
- await z(Math.max(v, 0), c);
222
- continue;
223
- }
224
- throw new Error(`Failed to fetch ${t}: ${m.status} ${m.statusText}`);
225
- }
226
- if (g < r) {
227
- await z(b(g), c);
228
- continue;
229
- }
230
- }
231
- throw new Error(`Failed to fetch ${t}: ${m.status} ${m.statusText}`);
232
- }
233
- return m;
234
- }
235
- }
236
- async function Le(t, e) {
237
- const n = (e == null ? void 0 : e.maxResponseBytes) ?? ce, r = await ge(t, void 0, e), s = r.headers.get("content-length");
238
- if (s !== null && Number(s) > n)
239
- throw new Error(`Response from ${t} is too large. Max size is ${n} bytes.`);
240
- const i = await r.text();
241
- if (i.length > n)
242
- throw new Error(`Response from ${t} is too large. Max size is ${n} bytes.`);
243
- return i;
244
- }
245
- function k(t) {
246
- return Object.entries(t).reduce((n, [r, s]) => (n[Ne(r)] = we(s), n), {});
247
- }
248
- function we(t) {
249
- return Array.isArray(t) ? t.map(we) : typeof t == "object" && t !== null ? k(t) : t;
250
- }
251
- function Ne(t) {
252
- return t.replace(/[A-Z]/g, (e) => `_${e.toLowerCase()}`);
253
- }
254
- const De = Object.freeze({
255
- builder: Object.freeze({
256
- generateC2paArchive: !0
257
- })
258
- });
259
- function ze(t) {
260
- return h(De, t ?? {});
261
- }
262
- async function Je(t, e) {
263
- const n = ze(t), r = [];
264
- return n.trust && r.push(ee(n.trust, e)), n.cawgTrust && r.push(ee(n.cawgTrust, e)), await Promise.all(r), JSON.stringify(k(me(n)));
265
- }
266
- function me(t) {
267
- const { trust: e, cawgTrust: n, ...r } = t, s = [
268
- ...Y(e, "manifest"),
269
- ...Y(n, "cawg")
270
- ], i = r;
271
- return (s.length > 0 || e != null && e.trustConfig) && (i.trust = {
272
- ...s.length > 0 ? { anchors: s } : {},
273
- ...e != null && e.trustConfig ? { trustConfig: e.trustConfig } : {}
274
- }), i;
275
- }
276
- function Y(t, e) {
277
- if (!t || t.verifyTrustList === !1)
278
- return [];
279
- const n = t.trustConfig, r = t.allowedList, s = [];
280
- return t.userAnchors && s.push({
281
- trustAnchors: t.userAnchors,
282
- trustUri: `${e}_user_anchors`,
283
- trustKind: e,
284
- ...n ? { trustConfig: n } : {},
285
- ...r ? { allowedList: r } : {}
286
- }), t.trustAnchors && s.push({
287
- trustAnchors: t.trustAnchors,
288
- trustUri: `${e}_system_anchors`,
289
- trustKind: e,
290
- ...n ? { trustConfig: n } : {},
291
- ...r ? { allowedList: r } : {}
292
- }), s;
293
- }
294
- function Qe(t) {
295
- return { trust: { ...t } };
296
- }
297
- function et(t) {
298
- return { cawgTrust: { ...t } };
299
- }
300
- function tt(t) {
301
- return { verify: { ...t } };
302
- }
303
- function T(...t) {
304
- return h(...t);
305
- }
306
- function nt(t) {
307
- return JSON.stringify(k(me(t)));
308
- }
309
- async function rt(t, e) {
310
- return await (await ge(t, void 0, e)).text();
311
- }
312
- const Pe = [
313
- "userAnchors",
314
- "trustAnchors",
315
- "trustConfig",
316
- "allowedList"
317
- ], B = /* @__PURE__ */ new Map(), K = 3e4, X = /* @__PURE__ */ new WeakMap();
318
- let $e = 0;
319
- function j(t, e) {
320
- if (!t)
321
- return e;
322
- let n = X.get(t);
323
- return n === void 0 && (n = ++$e, X.set(t, n)), String(n);
324
- }
325
- function Ce(t, e) {
326
- const n = [
327
- (e == null ? void 0 : e.maxResponseBytes) ?? ce,
328
- (e == null ? void 0 : e.maxRetries) ?? ue,
329
- (e == null ? void 0 : e.initialRetryDelayMs) ?? fe,
330
- (e == null ? void 0 : e.maxRetryDelayMs) ?? de,
331
- (e == null ? void 0 : e.maxRetryAfterMs) ?? le,
332
- (e == null ? void 0 : e.requireHttps) ?? !1,
333
- j(e == null ? void 0 : e.isRetryableStatus, "default-status"),
334
- j(e == null ? void 0 : e.isRetryableError, "default-error"),
335
- j(e == null ? void 0 : e.signal, "no-signal"),
336
- j(globalThis.fetch, "global-fetch")
337
- ];
338
- return JSON.stringify([t, ...n]);
339
- }
340
- function Z(t, e) {
341
- be(e);
342
- const { deduplicateInFlight: n = !0, requireHttps: r = !1 } = e ?? {}, s = new URL(t);
343
- if (r && s.protocol !== "https:")
344
- return Promise.reject(new Error(`Trust resource URL must use HTTPS: ${t}`));
345
- if (e != null && e.fetch || !n)
346
- return Q(t, e);
347
- const i = Ce(t, e), _ = B.get(i);
348
- if (_)
349
- return _;
350
- const a = Q(t, e);
351
- B.set(i, a);
352
- const u = () => {
353
- B.get(i) === a && B.delete(i);
354
- };
355
- return a.then(u, u), a;
356
- }
357
- async function Q(t, e) {
358
- const n = new AbortController(), r = (e == null ? void 0 : e.fetch) ?? globalThis.fetch, s = e == null ? void 0 : e.signal, i = s ? AbortSignal.any([n.signal, s]) : n.signal;
359
- let _, a;
360
- const u = new Promise((c, l) => {
361
- _ = setTimeout(() => {
362
- const b = new DOMException(`Trust resource fetch timed out after ${K} ms: ${t}`, "TimeoutError");
363
- n.abort(b), l(b);
364
- }, K);
365
- }), w = s ? new Promise((c, l) => {
366
- const b = () => {
367
- l(s.reason ?? new DOMException("The operation was aborted", "AbortError"));
368
- };
369
- s.aborted ? b() : (s.addEventListener("abort", b, { once: !0 }), a = () => s.removeEventListener("abort", b));
370
- }) : void 0;
371
- try {
372
- const c = Le(t, {
373
- ...e,
374
- fetch: (l, b) => {
375
- const g = { ...b };
376
- return e != null && e.requireHttps && (g.redirect = "error"), r(l, g);
377
- },
378
- signal: i
379
- });
380
- return await Promise.race(w ? [c, u, w] : [c, u]);
381
- } finally {
382
- clearTimeout(_), a == null || a();
383
- }
384
- }
385
- async function ee(t, e) {
386
- const n = (i) => ["userAnchors", "trustAnchors"].includes(i), r = (i) => i.includes("-----BEGIN CERTIFICATE-----"), s = (i) => i.startsWith("http");
387
- try {
388
- const i = Object.entries(t).filter(([_]) => Pe.includes(_)).map(async ([_, a]) => {
389
- if (a && typeof a == "object" && Array.isArray(a)) {
390
- const u = a.map(async (l) => {
391
- if (typeof l != "string")
392
- throw new Error("Expected a string value for array item");
393
- const b = await Z(l, e);
394
- if (n(_) && !r(b))
395
- throw new Error(`Error parsing PEM file at: ${l}`);
396
- return b;
397
- }), c = (await Promise.all(u)).join("");
398
- t[_] = c;
399
- } else if (a && typeof a == "string" && s(a)) {
400
- const u = await Z(a, e);
401
- if (n(_) && !r(u))
402
- throw new Error(`Error parsing PEM file at: ${a}`);
403
- t[_] = u;
404
- } else
405
- return a;
406
- });
407
- await Promise.all(i);
408
- } catch (i) {
409
- const _ = i instanceof Error ? i.message : String(i), a = new Error(`Failed to resolve trust settings. ${_}`, {
410
- cause: i
411
- });
412
- throw (i instanceof Error || i instanceof DOMException) && i.name === "TimeoutError" && (a.name = "TimeoutError"), a;
413
- }
414
- }
415
- class p {
416
- /**
417
- * @param settings Core SDK settings.
418
- * @param sdkConfig JavaScript SDK configuration.
419
- * @param options JavaScript SDK behavior options, including trust-resource fetching controls.
420
- */
421
- constructor(e, n, r) {
422
- S(this, "_settings");
423
- S(this, "_sdkConfig");
424
- S(this, "_options");
425
- S(this, "_jsonPromise");
426
- this._settings = e, this._sdkConfig = n, this._options = r;
427
- }
428
- /**
429
- * The SDK config currently attached to this `Context`, if any.
430
- *
431
- * To derive a new `Context` with a different SDK config, construct one with
432
- * `new Context(settings, sdkConfig)`.
433
- */
434
- get sdkConfig() {
435
- return this._sdkConfig;
436
- }
437
- /**
438
- * The settings currently attached to this `Context`, if any.
439
- *
440
- * To derive a new `Context` with different settings, construct one with `new Context(settings)`.
441
- * To combine this `Context`'s settings with more settings, merge them with {@link mergeSettings}
442
- * first and pass the single, merged result to the constructor.
443
- */
444
- get settings() {
445
- return this._settings;
446
- }
447
- /**
448
- * Resolves this `Context`'s settings (fetching any embedded trust-anchor URLs) and serializes
449
- * the result for consumption by the WASM/native boundary. A successful result is memoized, so
450
- * resolution of this Context's settings only happens once. If different fetch-with-retry
451
- * options need to be provided after resolution succeeds, callers should create a separate
452
- * `Context` with the desired options.
453
- *
454
- * A failed resolution is not memoized: the next call to `toJson()` tries again from scratch,
455
- * so a transient failure (e.g. a network error while fetching a trust-anchor URL) doesn't
456
- * permanently break this `Context`.
457
- *
458
- * @param options Optional configurations for trust-resource fetching. These override the
459
- * corresponding options attached to this Context. Explicit `undefined` resets an option to
460
- * its SDK default; omitted properties retain the Context's option. This does not clear core
461
- * settings or a memoized successful result. Only consulted on the first call, or the first
462
- * call after a previous failure.
463
- * @returns A JSON-serialized string of the resolved settings.
464
- */
465
- toJson(e) {
466
- var r;
467
- const n = {
468
- ...(r = this._options) == null ? void 0 : r.trustFetch,
469
- ...e
470
- };
471
- return this._jsonPromise ?? (this._jsonPromise = Je(this.settings, n).catch((s) => {
472
- throw this._jsonPromise = void 0, s;
473
- })), this._jsonPromise;
474
- }
475
- }
476
- const qe = 10 ** 9;
477
- function he(t) {
478
- return Number.isFinite(t) && t > 0 ? t : qe;
479
- }
480
- function te(t, e) {
481
- const n = (t == null ? void 0 : t.maxSizeInBytes) ?? e;
482
- if (!Number.isFinite(n) || n <= 0)
483
- throw new RangeError(`maxSizeInBytes must be a finite, positive number. Received: ${n}.`);
484
- return n;
485
- }
486
- class ke extends Error {
487
- /**
488
- * @param sizeInBytes Size of the asset, in bytes.
489
- * @param maxSizeInBytes Maximum allowed size, in bytes. `0` (or any other
490
- * non-finite/negative value) resolves to {@link DEFAULT_MAX_SIZE_IN_BYTES}.
491
- */
492
- constructor(e, n) {
493
- const r = he(n);
494
- super(`The provided asset was too large. Size: ${e} bytes. Maximum: ${r}.`), this.name = "AssetTooLargeError";
495
- }
496
- }
497
- function J(t, e) {
498
- if (!Number.isFinite(t) || t < 0)
499
- throw new RangeError(`sizeInBytes must be a finite, non-negative number. Received: ${t}.`);
500
- if (!Number.isFinite(e) || e < 0)
501
- throw new RangeError(`maxSizeInBytes must be a finite, non-negative number. Received: ${e}.`);
502
- const n = he(e);
503
- if (t > n)
504
- throw new ke(t, n);
505
- }
506
- const ne = 10 ** 9, P = new FinalizationRegistry(
507
- async ({ worker: t, id: e }) => {
508
- await t.tx.reader_free(e);
509
- }
510
- );
511
- var y, A;
512
- const L = class L {
513
- constructor(e, n) {
514
- x(this, y);
515
- x(this, A);
516
- E(this, y, e), E(this, A, n);
517
- }
518
- /**
519
- * Create a {@link Reader} from an asset's format and a blob of its bytes.
520
- *
521
- * @param c2pa The `C2pa` instance (from {@link createC2pa}) to create this reader on.
522
- * @param format Asset format (MIME type or extension), typically `blob.type`. If omitted
523
- * or empty, the native library will attempt to detect the format from the asset's bytes instead.
524
- * Always provide the format if known, and only omit this when the caller has no way to determine
525
- * the asset's format otherwise.
526
- * @param blob Blob of asset bytes.
527
- * @param context Optional `Context` configuring this reader's behavior.
528
- * @returns A {@link Reader} object or null if no C2PA metadata was found.
529
- * @throws If the asset is too large, or if the `Context` sets an invalid `maxSizeInBytes`.
530
- */
531
- static async fromBlob(e, n, r, s = new p()) {
532
- J(
533
- r.size,
534
- te(s.sdkConfig, ne)
535
- );
536
- try {
537
- const i = await s.toJson(), { worker: _ } = e, a = await _.tx.reader_fromBlob(n ?? "", r, i), u = new L(_, a);
538
- return P.register(u, { worker: _, id: a }, u), u;
539
- } catch (i) {
540
- return re(i);
541
- }
542
- }
543
- /**
544
- * Create a {@link Reader} from an initial fragment and a subsequent fragment.
545
- *
546
- * @param c2pa The `C2pa` instance (from {@link createC2pa}) to create this reader on.
547
- * @param format Asset format (MIME type or extension). Unlike {@link fromBlob}, fragmented
548
- * assets cannot be auto-detected from their bytes, so a format must be supplied.
549
- * @param init Blob of initial fragment bytes.
550
- * @param fragment Blob of fragment bytes.
551
- * @param context Optional `Context` configuring this reader's behavior.
552
- * @returns A {@link Reader} object or null if no C2PA metadata was found.
553
- * @throws If the asset is too large, or if the `Context` sets an invalid `maxSizeInBytes`.
554
- */
555
- static async fromBlobFragment(e, n, r, s, i = new p()) {
556
- const _ = te(
557
- i.sdkConfig,
558
- ne
559
- );
560
- J(r.size, _), J(s.size, _);
561
- try {
562
- const a = await i.toJson(), { worker: u } = e, w = await u.tx.reader_fromBlobFragment(
563
- n,
564
- r,
565
- s,
566
- a
567
- ), c = new L(u, w);
568
- return P.register(c, { worker: u, id: w }, c), c;
569
- } catch (a) {
570
- return re(a);
571
- }
572
- }
573
- /**
574
- * @returns The label of the active manifest.
575
- */
576
- async activeLabel() {
577
- return await o(this, y).tx.reader_activeLabel(o(this, A));
578
- }
579
- /**
580
- * @returns The asset's full {@link ManifestStore} containing all its manifests, validation statuses, and the URI of the active manifest.
581
- */
582
- async manifestStore() {
583
- return await o(this, y).tx.reader_manifestStore(o(this, A));
584
- }
585
- /**
586
- * @returns The asset's active {@link Manifest}.
587
- */
588
- async activeManifest() {
589
- return await o(this, y).tx.reader_activeManifest(o(this, A));
590
- }
591
- /**
592
- * @returns The asset's full {@link ManifestStore}.
593
- *
594
- * @deprecated Use {@link manifestStore} instead.
595
- */
596
- async json() {
597
- const e = await o(this, y).tx.reader_json(o(this, A));
598
- return JSON.parse(e);
599
- }
600
- /**
601
- * @returns The asset's manifest store as crJSON.
602
- */
603
- async crJson() {
604
- const e = await o(this, y).tx.reader_crJson(o(this, A));
605
- return JSON.parse(e);
606
- }
607
- /**
608
- * Resolves a URI reference to a binary object (e.g. a thumbnail) in the resource store.
609
- *
610
- * @param uri URI of the binary object to resolve.
611
- * @returns A Uint8Array of the resource's bytes.
612
- *
613
- * @example Retrieving a thumbnail from the resource store:
614
- * ```
615
- * const reader = await Reader.fromBlob(c2pa, blob.type, blob);
616
- * const activeManifest = await reader.activeManifest();
617
- * const thumbnailBuffer = await reader.resourceToBytes(activeManifest.thumbnail!.identifier);
618
- * ```
619
- */
620
- async resourceToBytes(e) {
621
- return await o(this, y).tx.reader_resourceToBytes(o(this, A), e);
622
- }
623
- /**
624
- * Dispose of this Reader, freeing the memory it occupied and preventing further use.
625
- * Call this whenever the Reader is no longer needed.
626
- */
627
- async free() {
628
- P.unregister(this), await o(this, y).tx.reader_free(o(this, A));
629
- }
630
- };
631
- y = new WeakMap(), A = new WeakMap();
632
- let U = L;
633
- function We(t, e = {}) {
634
- return {
635
- fromBlob: (n, r, s = {}) => U.fromBlob(
636
- t,
637
- n,
638
- r,
639
- new p(T(e, s))
640
- ),
641
- fromBlobFragment: (n, r, s, i = {}) => U.fromBlobFragment(
642
- t,
643
- n,
644
- r,
645
- s,
646
- new p(T(e, i))
647
- )
648
- };
649
- }
650
- function re(t) {
651
- if (t instanceof Error && t.message === "C2pa(JumbfNotFound)")
652
- return null;
653
- throw t;
654
- }
655
- async function ie(t) {
656
- const { alg: e } = t;
657
- return {
658
- reserveSize: await t.reserveSize(),
659
- alg: e
660
- };
661
- }
662
- async function it(t, e) {
663
- return t.worker.tx.encodeSignerPayload(e);
664
- }
665
- function Ve(t, e) {
666
- const { credentialHolder: n, referencedAssertions: r, roles: s } = t;
667
- return {
668
- requestId: e,
669
- sigType: n.sigType,
670
- reserveSize: n.reserveSize,
671
- referencedAssertions: r ?? [],
672
- roles: s ?? []
673
- };
674
- }
675
- function se(t) {
676
- return ye(t).flat();
677
- }
678
- function ye(t) {
679
- return (t.assertions ?? []).filter((e) => e.label.startsWith("c2pa.actions")).map((e) => {
680
- const n = e.data;
681
- return (n == null ? void 0 : n.actions) ?? [];
682
- });
683
- }
684
- function oe(t, e) {
685
- const n = (e == null ? void 0 : e.identityAssertions) ?? [];
686
- if (n.length > 1)
687
- throw new Error(
688
- "Only one identity assertion is currently supported per signing operation."
689
- );
690
- return n.map((r) => {
691
- const s = t.registerCredentialHolderReceiver(
692
- r.credentialHolder.sign
693
- );
694
- return Ve(r, s);
695
- });
696
- }
697
- const O = new FinalizationRegistry(
698
- ({ worker: t, id: e }) => {
699
- t.tx.builder_free(e);
700
- }
701
- );
702
- var f, d;
703
- const F = class F {
704
- constructor(e, n) {
705
- x(this, f);
706
- x(this, d);
707
- E(this, f, e), E(this, d, n);
708
- }
709
- /**
710
- * Create a {@link Builder} with a minimal manifest definition as its initial state.
711
- *
712
- * @param c2pa The `C2pa` instance (from {@link createC2pa}) to create this builder on.
713
- * @param context Optional `Context` configuring this builder's behavior.
714
- * @returns A {@link Builder} object.
715
- */
716
- static async new(e, n = new p()) {
717
- const r = await n.toJson(), { worker: s } = e, i = await s.tx.builder_new(r), _ = new F(s, i);
718
- return O.register(_, { worker: s, id: i }, _), _;
719
- }
720
- /**
721
- * Create a {@link Builder} from a {@link ManifestDefinition}.
722
- *
723
- * @param c2pa The `C2pa` instance (from {@link createC2pa}) to create this builder on.
724
- * @param definition The {@link ManifestDefinition} to be used as the builder's initial state.
725
- * @param context Optional `Context` configuring this builder's behavior.
726
- * @returns A {@link Builder} object.
727
- */
728
- static async fromDefinition(e, n, r = new p()) {
729
- const s = JSON.stringify(n), i = await r.toJson(), { worker: _ } = e, a = await _.tx.builder_fromJson(s, i), u = new F(_, a);
730
- return O.register(u, { worker: _, id: a }, u), u;
731
- }
732
- /**
733
- * Create a {@link Builder} from a builder archive (created from {@link Builder.toArchive}).
734
- *
735
- * @param c2pa The `C2pa` instance (from {@link createC2pa}) to create this builder on.
736
- * @param archive Builder archive as a blob.
737
- * @param context Optional `Context` configuring this builder's behavior.
738
- * @returns A {@link Builder} object.
739
- */
740
- static async fromArchive(e, n, r = new p()) {
741
- const s = await r.toJson(), { worker: i } = e, _ = await i.tx.builder_fromArchive(n, s), a = new F(i, _);
742
- return O.register(a, { worker: i, id: _ }, a), a;
743
- }
744
- /**
745
- * Sets the builder "intent."
746
- *
747
- * @todo Additional documentation coming soon.
748
- *
749
- * @param intent
750
- */
751
- async setIntent(e) {
752
- await o(this, f).tx.builder_setIntent(o(this, d), e);
753
- }
754
- /**
755
- * Add an action to the manifest's actions assertion.
756
- *
757
- * @param action Object representing the action to be added.
758
- */
759
- async addAction(e) {
760
- await o(this, f).tx.builder_addAction(o(this, d), e);
761
- }
762
- /**
763
- * Add an assertion to the manifest under the given label.
764
- *
765
- * @param label The assertion label (reverse-domain format).
766
- * @param data The assertion data (any JSON-serializable value).
767
- */
768
- async addAssertion(e, n) {
769
- await o(this, f).tx.builder_addAssertion(o(this, d), e, n);
770
- }
771
- /**
772
- * Replaces the data of every assertion with an exact matching label.
773
- * `transform` runs once per matching assertion in manifest order. Other assertion
774
- * fields and positions are preserved. A missing label is a no-op.
775
- * Returning null or undefined leaves that assertion unchanged.
776
- * The replacement data must be JSON-serializable and may fail validation at signing time.
777
- *
778
- * @param label The exact assertion label to update.
779
- * @param transform Receives the current data and returns its replacement.
780
- */
781
- async updateAssertion(e, n) {
782
- const s = ((await this.getDefinition()).assertions ?? []).filter((i) => i.label === e).map((i) => n(i.data) ?? i.data);
783
- await o(this, f).tx.builder_updateAssertionsAt(o(this, d), e, s);
784
- }
785
- /**
786
- * Redact an assertion from an ingredient manifest.
787
- *
788
- * Adds the URI to the builder's redaction list and appends a `c2pa.redacted` action
789
- * with the given reason, as required by the C2PA spec.
790
- *
791
- * @param uri JUMBF URI of the assertion to redact.
792
- * @param reason The {@link C2paReason} for the redaction.
793
- */
794
- async addRedaction(e, n) {
795
- await o(this, f).tx.builder_addRedaction(o(this, d), e, n);
796
- }
797
- /**
798
- * Sets the remote URL for a remote manifest. The manifest is expected to be available at this location.
799
- *
800
- * @param url URL pointing to the location the remote manifest will be stored.
801
- */
802
- async setRemoteUrl(e) {
803
- await o(this, f).tx.builder_setRemoteUrl(o(this, d), e);
804
- }
805
- /**
806
- * Sets the state of the no_embed flag.
807
- * To skip embedding a manifest (e.g. for the remote-only case), set this to `true`.
808
- *
809
- * @param noEmbed Value to set the no_embed flag.
810
- */
811
- async setNoEmbed(e) {
812
- await o(this, f).tx.builder_setNoEmbed(o(this, d), e);
813
- }
814
- /**
815
- * Updates a (known) property in the manifest definition.
816
- * Rejects an unsupported property or value type,
817
- * or while a sign on this builder is pending.
818
- */
819
- async updateManifestProperty(e, n) {
820
- await o(this, f).tx.builder_updateManifestProperty(o(this, d), e, n);
821
- }
822
- /**
823
- * Set a thumbnail from a blob to be included in the manifest. The blob should represent the asset being signed.
824
- *
825
- * @param format Format of the thumbnail
826
- * @param blob Blob of the thumbnail bytes
827
- */
828
- async setThumbnailFromBlob(e, n) {
829
- await o(this, f).tx.builder_setThumbnailFromBlob(o(this, d), e, n);
830
- }
831
- /**
832
- * Experimental.
833
- * Retains only the actions for which `keep` returns true.
834
- *
835
- * The inception action, `c2pa.created` or `c2pa.opened`, is always kept regardless of `keep`,
836
- * and is moved to index 0 if needed, so the manifest stays valid per the C2PA spec. Sets
837
- * `allActionsIncluded = false` when anything is removed. This does not touch ingredients.
838
- * Call {@link Builder.filterIngredients}, using `filterIngredients(() => false)` to drop all
839
- * orphans, afterwards if you also want to drop ingredients now orphaned by the removed
840
- * actions.
841
- *
842
- * Unlike the Node binding, Neon, which can invoke the JS predicate synchronously from Rust,
843
- * the WASM builder lives in a Web Worker. A predicate closure can't be called across the
844
- * worker boundary, so we evaluate it here on the main thread and send the resulting indices
845
- * to the worker, where WASM applies the equivalent index-based filter. The action/ingredient
846
- * ordering here must match what WASM iterates. See `filterActionsAt` and `filterIngredientsAt`.
847
- *
848
- * @param keep The action is retained when the predicate returns true.
849
- */
850
- async filterActions(e) {
851
- const n = await o(this, f).tx.builder_getDefinition(
852
- o(this, d)
853
- ), s = se(n).reduce((i, _, a) => (e(_) && i.push(a), i), []);
854
- await o(this, f).tx.builder_filterActionsAt(o(this, d), s);
855
- }
856
- /**
857
- * Experimental.
858
- * Retains ingredients, then rewrites positional ingredient references so linked actions
859
- * stay valid.
860
- *
861
- * An ingredient is kept if it is referenced by a current action, is a `parentOf` ingredient,
862
- * or `rescue` returns true for it. `rescue` therefore only ever rescues an otherwise-orphaned
863
- * ingredient. It can never drop a referenced or lineage ingredient. Call
864
- * {@link Builder.filterActions} first if you are also removing actions: the keep-set is
865
- * computed from whatever actions currently remain.
866
- *
867
- * @param rescue Can rescue an otherwise-orphaned ingredient by returning true.
868
- */
869
- async filterIngredients(e) {
870
- const s = ((await o(this, f).tx.builder_getDefinition(
871
- o(this, d)
872
- )).ingredients ?? []).reduce((i, _, a) => (e(_) && i.push(a), i), []);
873
- await o(this, f).tx.builder_filterIngredientsAt(o(this, d), s);
874
- }
875
- /**
876
- * Experimental.
877
- * Retains actions and ingredients together in one step.
878
- *
879
- * `rescueIngredient` is evaluated for every ingredient first; any action referencing an
880
- * ingredient it would rescue is force-kept regardless of `keepAction`.
881
- *
882
- * @param keepAction The action is retained when the predicate returns true.
883
- * @param rescueIngredient Can rescue an otherwise-orphaned ingredient (and the action
884
- * referencing it) by returning true.
885
- */
886
- async filterActionsAndIngredients(e, n) {
887
- const r = await o(this, f).tx.builder_getDefinition(
888
- o(this, d)
889
- ), i = se(r).reduce((u, w, c) => (e(w) && u.push(c), u), []), a = (r.ingredients ?? []).reduce(
890
- (u, w, c) => (n(w) && u.push(c), u),
891
- []
892
- );
893
- await o(this, f).tx.builder_filterActionsAndIngredientsAt(
894
- o(this, d),
895
- i,
896
- a
897
- );
898
- }
899
- /**
900
- * Replaces the actions in the `c2pa.actions`/`c2pa.actions.v2` assertions.
901
- *
902
- * A manifest can carry more than one actions assertion (the created-list and
903
- * gathered-list entries are distinct assertions). `transform` is therefore
904
- * invoked once per actions assertion, in positional order, with that
905
- * assertion's own actions.
906
- *
907
- * A no-op if there is no actions assertion. Use `addAction` for those.
908
- *
909
- * The returned list is written back as is.
910
- * `transform` can therefore produce an actions array that fails
911
- * validation at signing time, for example by removing the inception action
912
- * (`c2pa.created`/`c2pa.opened`) or moving it out of first position.
913
- *
914
- * @param transform Receives one assertion's actions and returns its full replacement list.
915
- */
916
- async updateActions(e) {
917
- const n = await o(this, f).tx.builder_getDefinition(
918
- o(this, d)
919
- ), s = ye(n).map((i) => e(i));
920
- await o(this, f).tx.builder_updateActionsAt(o(this, d), s);
921
- }
922
- /**
923
- * Add an ingredient to the builder from a definition only.
924
- *
925
- * @param ingredientDefinition {@link Ingredient} definition.
926
- */
927
- async addIngredient(e) {
928
- const n = JSON.stringify(e);
929
- await o(this, f).tx.builder_addIngredient(o(this, d), n);
930
- }
931
- /**
932
- * Add an ingredient to the builder from a definition, format, and blob.
933
- * Values specified in the ingredient definition will be merged with the ingredient, and these values take precendence.
934
- *
935
- * @param ingredientDefinition {@link Ingredient} definition.
936
- * @param format Format of the ingredient.
937
- * @param blob Blob of the ingredient's bytes.
938
- */
939
- async addIngredientFromBlob(e, n, r) {
940
- const s = JSON.stringify(e);
941
- await o(this, f).tx.builder_addIngredientFromBlob(o(this, d), s, n, r);
942
- }
943
- /**
944
- * Add a resource to the builder's resource store with an ID and blob of the resource's bytes.
945
- *
946
- * @param resourceId ID associated with the resource being added.
947
- * @param blob Blob of the resource's bytes.
948
- */
949
- async addResourceFromBlob(e, n) {
950
- await o(this, f).tx.builder_addResourceFromBlob(o(this, d), e, n);
951
- }
952
- /**
953
- * Gets the current manifest definition held by the builder.
954
- *
955
- * @returns The {@link ManifestDefinition} held by the builder.
956
- */
957
- async getDefinition() {
958
- return await o(this, f).tx.builder_getDefinition(o(this, d));
959
- }
960
- /**
961
- * Save the builder into .c2pa format.
962
- * This "archive" can be added to as an ingredient with {@link addIngredientFromBlob}
963
- *
964
- * @returns A builder archive in application/c2pa format.
965
- */
966
- async toArchive() {
967
- return await o(this, f).tx.builder_toArchive(o(this, d));
968
- }
969
- /**
970
- * Sign an asset.
971
- *
972
- * @param signer The signer to use for the manifest's claim signature.
973
- * @param format The format (MIME type) of the asset.
974
- * @param blob The asset bytes.
975
- * @param options Optional {@link SignOptions}. `identityAssertions` attaches
976
- * one or more CAWG identity assertions (`cawg.identity`) to the manifest.
977
- *
978
- * @todo Docs coming soon
979
- */
980
- async sign(e, n, r, s) {
981
- const i = await ie(e), _ = o(this, f).registerSignReceiver(e.sign), a = oe(
982
- o(this, f),
983
- s
984
- );
985
- return await o(this, f).tx.builder_sign(
986
- o(this, d),
987
- _,
988
- i,
989
- a,
990
- n,
991
- r
992
- );
993
- }
994
- /**
995
- * Sign an asset and get both the signed asset bytes and the manifest bytes.
996
- *
997
- * @param signer The signer to use for the manifest's claim signature.
998
- * @param format The format (MIME type) of the asset.
999
- * @param blob The asset bytes.
1000
- * @param options Optional {@link SignOptions}. `identityAssertions` attaches
1001
- * one or more CAWG identity assertions (`cawg.identity`) to the manifest.
1002
- *
1003
- * @todo Docs coming soon
1004
- */
1005
- async signAndGetManifestBytes(e, n, r, s) {
1006
- const i = await ie(e), _ = o(this, f).registerSignReceiver(e.sign), a = oe(
1007
- o(this, f),
1008
- s
1009
- );
1010
- return await o(this, f).tx.builder_signAndGetManifestBytes(
1011
- o(this, d),
1012
- _,
1013
- i,
1014
- a,
1015
- n,
1016
- r
1017
- );
1018
- }
1019
- /**
1020
- * Dispose of this Builder, freeing the memory it occupied and preventing further use. Call this whenever the Builder is no longer needed.
1021
- */
1022
- async free() {
1023
- O.unregister(this), await o(this, f).tx.builder_free(o(this, d));
1024
- }
1025
- };
1026
- f = new WeakMap(), d = new WeakMap();
1027
- let I = F;
1028
- function Ge(t, e = {}) {
1029
- return {
1030
- new: (n = {}) => I.new(t, new p(T(e, n))),
1031
- fromDefinition: (n, r = {}) => I.fromDefinition(
1032
- t,
1033
- n,
1034
- new p(T(e, r))
1035
- ),
1036
- fromArchive: (n, r = {}) => I.fromArchive(
1037
- t,
1038
- n,
1039
- new p(T(e, r))
1040
- )
1041
- };
1042
- }
1043
- async function st(t) {
1044
- const { wasmSrc: e, workerSrc: n, settings: r } = t, s = typeof e == "string" ? await He(e) : e, i = await Ee({ wasm: s, workerSrc: n }), _ = {
1045
- worker: i,
1046
- reader: void 0,
1047
- builder: void 0,
1048
- dispose: i.terminate
1049
- };
1050
- return _.reader = We(_, r), _.builder = Ge(_, r), _;
1051
- }
1052
- async function He(t) {
1053
- const e = await fetch(t, { integrity: Ie });
1054
- return await WebAssembly.compileStreaming(e);
1055
- }
1056
- export {
1057
- ke as A,
1058
- I as B,
1059
- p as C,
1060
- fe as D,
1061
- U as R,
1062
- ce as a,
1063
- ue as b,
1064
- le as c,
1065
- de as d,
1066
- qe as e,
1067
- De as f,
1068
- st as g,
1069
- et as h,
1070
- Qe as i,
1071
- tt as j,
1072
- Me as k,
1073
- it as l,
1074
- Le as m,
1075
- ge as n,
1076
- rt as o,
1077
- T as p,
1078
- Je as q,
1079
- te as r,
1080
- ee as s,
1081
- nt as t,
1082
- k as u,
1083
- J as v,
1084
- be as w,
1085
- ze as x
1086
- };