@contentauth/c2pa-web 0.14.6 → 0.15.0
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 +64 -9
- package/dist/c2pa-Pcrzki0G.js +826 -0
- package/dist/c2pa_worker.js +84 -89
- package/dist/common.d.ts +3 -3
- package/dist/common.d.ts.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +26 -21
- package/dist/inline.d.ts +5 -3
- package/dist/inline.d.ts.map +1 -1
- package/dist/inline.js +12 -9
- package/dist/lib/builder.d.ts +83 -50
- package/dist/lib/builder.d.ts.map +1 -1
- package/dist/lib/c2pa.d.ts +22 -9
- package/dist/lib/c2pa.d.ts.map +1 -1
- package/dist/lib/reader.d.ts +52 -34
- package/dist/lib/reader.d.ts.map +1 -1
- package/dist/lib/worker/rpc.d.ts +2 -2
- package/dist/lib/worker/rpc.d.ts.map +1 -1
- package/dist/lib/worker/workerManager.d.ts +0 -2
- package/dist/lib/worker/workerManager.d.ts.map +1 -1
- package/dist/resources/c2pa_bg.wasm +0 -0
- package/package.json +3 -3
- package/dist/c2pa-BK_gbEns.js +0 -522
|
@@ -0,0 +1,826 @@
|
|
|
1
|
+
var ee = Object.defineProperty;
|
|
2
|
+
var $ = (n) => {
|
|
3
|
+
throw TypeError(n);
|
|
4
|
+
};
|
|
5
|
+
var te = (n, e, t) => e in n ? ee(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
|
|
6
|
+
var O = (n, e, t) => te(n, typeof e != "symbol" ? e + "" : e, t), P = (n, e, t) => e.has(n) || $("Cannot " + t);
|
|
7
|
+
var i = (n, e, t) => (P(n, e, "read from private field"), t ? t.call(n) : e.get(n)), v = (n, e, t) => e.has(n) ? $("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(n) : e.set(n, t), x = (n, e, t, r) => (P(n, e, "write to private field"), r ? r.call(n, t) : e.set(n, t), t);
|
|
8
|
+
import { channel as G, transfer as ne } from "highgain";
|
|
9
|
+
const { createTx: re, rx: Oe } = G(), { createTx: Ue, rx: ie } = G("worker"), K = '(function(){"use strict";class p{static __wrap(e){const t=Object.create(p.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 d(t[0])}addAssertion(e,t){const n=b(e,o.__wbindgen_malloc,o.__wbindgen_realloc),_=a,c=o.wasmbuilder_addAssertion(this.__wbg_ptr,n,_,t);if(c[1])throw d(c[0])}addIngredient(e){const t=b(e,o.__wbindgen_malloc,o.__wbindgen_realloc),n=a,_=o.wasmbuilder_addIngredient(this.__wbg_ptr,t,n);if(_[1])throw d(_[0])}addIngredientFromBlob(e,t,n){const _=b(e,o.__wbindgen_malloc,o.__wbindgen_realloc),c=a,i=b(t,o.__wbindgen_malloc,o.__wbindgen_realloc),s=a;return o.wasmbuilder_addIngredientFromBlob(this.__wbg_ptr,_,c,i,s,n)}addRedaction(e,t){const n=b(e,o.__wbindgen_malloc,o.__wbindgen_realloc),_=a,c=o.wasmbuilder_addRedaction(this.__wbg_ptr,n,_,t);if(c[1])throw d(c[0])}addResourceFromBlob(e,t){const n=b(e,o.__wbindgen_malloc,o.__wbindgen_realloc),_=a,c=o.wasmbuilder_addResourceFromBlob(this.__wbg_ptr,n,_,t);if(c[1])throw d(c[0])}filterActionsAndIngredientsAt(e,t){const n=E(e,o.__wbindgen_malloc),_=a,c=E(t,o.__wbindgen_malloc),i=a,s=o.wasmbuilder_filterActionsAndIngredientsAt(this.__wbg_ptr,n,_,c,i);if(s[1])throw d(s[0])}filterActionsAt(e){const t=E(e,o.__wbindgen_malloc),n=a,_=o.wasmbuilder_filterActionsAt(this.__wbg_ptr,t,n);if(_[1])throw d(_[0])}filterIngredientsAt(e){const t=E(e,o.__wbindgen_malloc),n=a,_=o.wasmbuilder_filterIngredientsAt(this.__wbg_ptr,t,n);if(_[1])throw d(_[0])}static fromArchive(e,t){var n=g(t)?0:b(t,o.__wbindgen_malloc,o.__wbindgen_realloc),_=a;const c=o.wasmbuilder_fromArchive(e,n,_);if(c[2])throw d(c[1]);return p.__wrap(c[0])}static fromJson(e,t){const n=b(e,o.__wbindgen_malloc,o.__wbindgen_realloc),_=a;var c=g(t)?0:b(t,o.__wbindgen_malloc,o.__wbindgen_realloc),i=a;const s=o.wasmbuilder_fromJson(n,_,c,i);if(s[2])throw d(s[1]);return p.__wrap(s[0])}getDefinition(){const e=o.wasmbuilder_getDefinition(this.__wbg_ptr);if(e[2])throw d(e[1]);return d(e[0])}static new(e){var t=g(e)?0:b(e,o.__wbindgen_malloc,o.__wbindgen_realloc),n=a;const _=o.wasmbuilder_new(t,n);if(_[2])throw d(_[1]);return p.__wrap(_[0])}setIntent(e){const t=o.wasmbuilder_setIntent(this.__wbg_ptr,e);if(t[1])throw d(t[0])}setNoEmbed(e){o.wasmbuilder_setNoEmbed(this.__wbg_ptr,e)}setRemoteUrl(e){const t=b(e,o.__wbindgen_malloc,o.__wbindgen_realloc),n=a;o.wasmbuilder_setRemoteUrl(this.__wbg_ptr,t,n)}setThumbnailFromBlob(e,t){const n=b(e,o.__wbindgen_malloc,o.__wbindgen_realloc),_=a,c=o.wasmbuilder_setThumbnailFromBlob(this.__wbg_ptr,n,_,t);if(c[1])throw d(c[0])}sign(e,t,n){const _=b(t,o.__wbindgen_malloc,o.__wbindgen_realloc),c=a;return o.wasmbuilder_sign(this.__wbg_ptr,e,_,c,n)}signAndGetManifestBytes(e,t,n){const _=b(t,o.__wbindgen_malloc,o.__wbindgen_realloc),c=a;return o.wasmbuilder_signAndGetManifestBytes(this.__wbg_ptr,e,_,c,n)}toArchive(){const e=o.wasmbuilder_toArchive(this.__wbg_ptr);if(e[2])throw d(e[1]);return d(e[0])}updateActionsAt(e){const t=o.wasmbuilder_updateActionsAt(this.__wbg_ptr,e);if(t[1])throw d(t[0])}}Symbol.dispose&&(p.prototype[Symbol.dispose]=p.prototype.free);class v{static __wrap(e){const t=Object.create(v.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=y(e[0],e[1]).slice(),o.__wbindgen_free(e[0],e[1]*1,1)),t}activeManifest(){const e=o.wasmreader_activeManifest(this.__wbg_ptr);if(e[2])throw d(e[1]);return d(e[0])}crJson(){let e,t;try{const n=o.wasmreader_crJson(this.__wbg_ptr);return e=n[0],t=n[1],y(n[0],n[1])}finally{o.__wbindgen_free(e,t,1)}}static fromBlob(e,t,n){const _=b(e,o.__wbindgen_malloc,o.__wbindgen_realloc),c=a;var i=g(n)?0:b(n,o.__wbindgen_malloc,o.__wbindgen_realloc),s=a;return o.wasmreader_fromBlob(_,c,t,i,s)}static fromBlobFragment(e,t,n,_){const c=b(e,o.__wbindgen_malloc,o.__wbindgen_realloc),i=a;var s=g(_)?0:b(_,o.__wbindgen_malloc,o.__wbindgen_realloc),u=a;return o.wasmreader_fromBlobFragment(c,i,t,n,s,u)}json(){let e,t;try{const n=o.wasmreader_json(this.__wbg_ptr);return e=n[0],t=n[1],y(n[0],n[1])}finally{o.__wbindgen_free(e,t,1)}}manifestStore(){const e=o.wasmreader_manifestStore(this.__wbg_ptr);if(e[2])throw d(e[1]);return d(e[0])}resourceToBytes(e){const t=b(e,o.__wbindgen_malloc,o.__wbindgen_realloc),n=a,_=o.wasmreader_resourceToBytes(this.__wbg_ptr,t,n);if(_[2])throw d(_[1]);return d(_[0])}}Symbol.dispose&&(v.prototype[Symbol.dispose]=v.prototype.free);function C(){return{__proto__:null,"./c2pa_bg.js":{__proto__:null,__wbg_Error_ef53bc310eb298a0:function(e,t){return Error(y(e,t))},__wbg_Number_6b506e6536831eaa:function(e){return Number(e)},__wbg___wbindgen_bigint_get_as_i64_38130e98eecd467d:function(e,t){const n=t,_=typeof n=="bigint"?n:void 0;m().setBigInt64(e+8,g(_)?BigInt(0):_,!0),m().setInt32(e+0,!g(_),!0)},__wbg___wbindgen_boolean_get_1a45e2c38d4d41b9:function(e){const t=e,n=typeof t=="boolean"?t:void 0;return g(n)?16777215:n?1:0},__wbg___wbindgen_debug_string_0accd80f45e5faa2:function(e,t){const n=U(t),_=b(n,o.__wbindgen_malloc,o.__wbindgen_realloc),c=a;m().setInt32(e+4,c,!0),m().setInt32(e+0,_,!0)},__wbg___wbindgen_in_70a403a56e771704:function(e,t){return e in t},__wbg___wbindgen_is_bigint_6ffd6468a9bc44b9:function(e){return typeof e=="bigint"},__wbg___wbindgen_is_function_754e9f305ff6029e:function(e){return typeof e=="function"},__wbg___wbindgen_is_object_56732c2bc353f41d:function(e){const t=e;return typeof t=="object"&&t!==null},__wbg___wbindgen_is_string_c236cabd84a4d769:function(e){return typeof e=="string"},__wbg___wbindgen_is_undefined_67b456be8673d3d7:function(e){return e===void 0},__wbg___wbindgen_jsval_eq_1068e624fa87f6ab:function(e,t){return e===t},__wbg___wbindgen_jsval_loose_eq_2c56564c75129511:function(e,t){return e==t},__wbg___wbindgen_number_get_9bb1761122181af2:function(e,t){const n=t,_=typeof n=="number"?n:void 0;m().setFloat64(e+8,g(_)?0:_,!0),m().setInt32(e+0,!g(_),!0)},__wbg___wbindgen_string_get_72bdf95d3ae505b1:function(e,t){const n=t,_=typeof n=="string"?n:void 0;var c=g(_)?0:b(_,o.__wbindgen_malloc,o.__wbindgen_realloc),i=a;m().setInt32(e+4,i,!0),m().setInt32(e+0,c,!0)},__wbg___wbindgen_throw_1506f2235d1bdba0:function(e,t){throw new Error(y(e,t))},__wbg__wbg_cb_unref_61db23ac97f16c31:function(e){e._wbg_cb_unref()},__wbg_abort_2ec46222bf378517:function(e){e.abort()},__wbg_abort_b29d719932441c95:function(e,t){e.abort(t)},__wbg_append_e1746995edcb0170:function(){return l(function(e,t,n,_,c){e.append(y(t,n),y(_,c))},arguments)},__wbg_arrayBuffer_05927079aabe6d46:function(){return l(function(e){return e.arrayBuffer()},arguments)},__wbg_byteLength_2c6dc3b4b85d3547:function(e){return e.byteLength},__wbg_call_8a89609d89f6608a:function(){return l(function(e,t){return e.call(t)},arguments)},__wbg_call_9c758de292015997:function(){return l(function(e,t,n){return e.call(t,n)},arguments)},__wbg_clearTimeout_6b8d9a38b9263d65:function(e){return clearTimeout(e)},__wbg_crypto_38df2bab126b63dc:function(e){return e.crypto},__wbg_done_60cf307fcc680536:function(e){return e.done},__wbg_entries_04b37a02507f1713:function(e){return Object.entries(e)},__wbg_error_a6fa202b58aa1cd3:function(e,t){let n,_;try{n=e,_=t,console.error(y(e,t))}finally{o.__wbindgen_free(n,_,1)}},__wbg_fetch_344c8d3849002659:function(e,t){return e.fetch(t)},__wbg_fetch_9dad4fe911207b37:function(e){return fetch(e)},__wbg_from_d300fe49deab18f5:function(e){return Array.from(e)},__wbg_getRandomValues_3f44b700395062e5:function(){return l(function(e,t){globalThis.crypto.getRandomValues(A(e,t))},arguments)},__wbg_getRandomValues_76dfc69825c9c552:function(){return l(function(e,t){globalThis.crypto.getRandomValues(A(e,t))},arguments)},__wbg_getRandomValues_8aa3112c6615eef6: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_00b3f7db575e4ef5:function(e){return e.getTime()},__wbg_get_1f8f054ddbaa7db2:function(){return l(function(e,t){return Reflect.get(e,t)},arguments)},__wbg_get_2b48c7d0d006a781:function(e,t){return e[t>>>0]},__wbg_get_de6a0f7d4d18a304:function(){return l(function(e,t){return Reflect.get(e,t)},arguments)},__wbg_get_unchecked_33f6e5c9e2f2d6b2:function(e,t){return e[t>>>0]},__wbg_get_with_ref_key_6412cf3094599694:function(e,t){return e[t]},__wbg_has_73740b27f436fed3:function(){return l(function(e,t){return Reflect.has(e,t)},arguments)},__wbg_headers_0feb63d2d374b44a:function(e){return e.headers},__wbg_instanceof_ArrayBuffer_8f49811467741499:function(e){let t;try{t=e instanceof ArrayBuffer}catch{t=!1}return t},__wbg_instanceof_Map_9fc06d9a951bcee6:function(e){let t;try{t=e instanceof Map}catch{t=!1}return t},__wbg_instanceof_Promise_d0db99486956c8e8:function(e){let t;try{t=e instanceof Promise}catch{t=!1}return t},__wbg_instanceof_Response_cb984bd66d7bd408:function(e){let t;try{t=e instanceof Response}catch{t=!1}return t},__wbg_instanceof_Uint8Array_86f30649f63ef9c2:function(e){let t;try{t=e instanceof Uint8Array}catch{t=!1}return t},__wbg_isArray_67c2c9c4313f4448:function(e){return Array.isArray(e)},__wbg_isSafeInteger_66acec27e09e99a7:function(e){return Number.isSafeInteger(e)},__wbg_iterator_8732428d309e270e:function(){return Symbol.iterator},__wbg_length_4a591ecaa01354d9:function(e){return e.length},__wbg_length_66f1a4b2e9026940:function(e){return e.length},__wbg_msCrypto_bd5a034af96bcba6:function(e){return e.msCrypto},__wbg_new_0_445c13a750296eb6:function(){return new Date},__wbg_new_0d09705104e164af:function(){return l(function(){return new AbortController},arguments)},__wbg_new_227d7c05414eb861:function(){return new Error},__wbg_new_578aeef4b6b94378:function(e){return new Uint8Array(e)},__wbg_new_622fc80556be2e26:function(){return new Map},__wbg_new_a1b9f645bba64f0f:function(){return l(function(){return new FileReaderSync},arguments)},__wbg_new_ce1ab61c1c2b300d:function(){return new Object},__wbg_new_d90091b82fdf5b91:function(){return new Array},__wbg_new_e436d06bc8e77460:function(){return l(function(){return new Headers},arguments)},__wbg_new_from_slice_18fa1f71286d66b8:function(e,t){return new Uint8Array(A(e,t))},__wbg_new_typed_bf31d18f92484486:function(e,t){try{var n={a:e,b:t},_=(i,s)=>{const u=n.a;n.a=0;try{return $(u,n.b,i,s)}finally{n.a=u}};return new Promise(_)}finally{n.a=0}},__wbg_new_with_length_36a4998e27b014c5:function(e){return new Uint8Array(e>>>0)},__wbg_new_with_str_and_init_bcd02b79a793d27f:function(){return l(function(e,t,n){return new Request(y(e,t),n)},arguments)},__wbg_next_9e03acdf51c4960d:function(e){return e.next},__wbg_next_eb8ca7351fa27906:function(){return l(function(e){return e.next()},arguments)},__wbg_node_84ea875411254db1:function(e){return e.node},__wbg_now_190933fa139cc119:function(){return Date.now()},__wbg_process_44c7a14e11e9f69e:function(e){return e.process},__wbg_prototypesetcall_3249fc62a0fafa30:function(e,t,n){Uint8Array.prototype.set.call(A(e,t),n)},__wbg_queueMicrotask_35c611f4a14830b2:function(e){queueMicrotask(e)},__wbg_queueMicrotask_404ed0a58e0b63cc:function(e){return e.queueMicrotask},__wbg_randomFillSync_6c25eac9869eb53c:function(){return l(function(e,t){e.randomFillSync(t)},arguments)},__wbg_readAsArrayBuffer_f1b8da05559618d9:function(){return l(function(e,t){return e.readAsArrayBuffer(t)},arguments)},__wbg_require_b4edbdcf3e2a1ef0:function(){return l(function(){return module.require},arguments)},__wbg_resolve_25a7e548d5881dca:function(e){return Promise.resolve(e)},__wbg_setTimeout_f757f00851f76c42:function(e,t){return setTimeout(e,t)},__wbg_set_29c99a8aac1c01e5:function(e,t,n){e.set(A(t,n))},__wbg_set_52b1e1eb5bed906a:function(e,t,n){return e.set(t,n)},__wbg_set_6be42768c690e380:function(e,t,n){e[t]=n},__wbg_set_body_36614c7e61546809:function(e,t){e.body=t},__wbg_set_cache_488ea16c11cbf20d:function(e,t){e.cache=H[t]},__wbg_set_credentials_fa9c491a27c4bdf0:function(e,t){e.credentials=X[t]},__wbg_set_dca99999bba88a9a:function(e,t,n){e[t>>>0]=n},__wbg_set_headers_7c1e39ece7826bec:function(e,t){e.headers=t},__wbg_set_method_7a6811dec7a4feff:function(e,t,n){e.method=y(t,n)},__wbg_set_mode_c90e3667002857d4:function(e,t){e.mode=Y[t]},__wbg_set_signal_d9da62b3f215c821:function(e,t){e.signal=t},__wbg_signal_e03304a84df9ed09:function(e){return e.signal},__wbg_size_9970092b88b1094c:function(e){return e.size},__wbg_slice_02bb778501725738:function(){return l(function(e,t,n){return e.slice(t,n)},arguments)},__wbg_stack_3b0d974bbf31e44f:function(e,t){const n=t.stack,_=b(n,o.__wbindgen_malloc,o.__wbindgen_realloc),c=a;m().setInt32(e+4,c,!0),m().setInt32(e+0,_,!0)},__wbg_static_accessor_GLOBAL_9d53f2689e622ca1:function(){const e=typeof global>"u"?null:global;return g(e)?0:R(e)},__wbg_static_accessor_GLOBAL_THIS_a1a35cec07001a8a:function(){const e=typeof globalThis>"u"?null:globalThis;return g(e)?0:R(e)},__wbg_static_accessor_SELF_4c59f6c7ea29a144:function(){const e=typeof self>"u"?null:self;return g(e)?0:R(e)},__wbg_static_accessor_WINDOW_e70ae9f2eb052253:function(){const e=typeof window>"u"?null:window;return g(e)?0:R(e)},__wbg_status_00549d55b78d949e:function(e){return e.status},__wbg_stringify_8286df6dcc591521:function(){return l(function(e){return JSON.stringify(e)},arguments)},__wbg_subarray_4aa221f6a4f5ab22:function(e,t,n){return e.subarray(t>>>0,n>>>0)},__wbg_then_18f476d590e58992:function(e,t,n){return e.then(t,n)},__wbg_then_ac7b025999b52837:function(e,t){return e.then(t)},__wbg_url_6808f1c468f2d0cd:function(e,t){const n=t.url,_=b(n,o.__wbindgen_malloc,o.__wbindgen_realloc),c=a;m().setInt32(e+4,c,!0),m().setInt32(e+0,_,!0)},__wbg_valueOf_41ae57308c1f031c:function(e){return e.valueOf()},__wbg_value_f3625092ee4b37f4:function(e){return e.value},__wbg_versions_276b2795b1c6a219:function(e){return e.versions},__wbg_wasmreader_new:function(e){return v.__wrap(e)},__wbindgen_cast_0000000000000001:function(e,t){return J(e,t,G)},__wbindgen_cast_0000000000000002:function(e,t){return J(e,t,P)},__wbindgen_cast_0000000000000003:function(e){return e},__wbindgen_cast_0000000000000004:function(e){return e},__wbindgen_cast_0000000000000005:function(e,t){return A(e,t)},__wbindgen_cast_0000000000000006:function(e,t){return y(e,t)},__wbindgen_cast_0000000000000007:function(e){return BigInt.asUintN(64,e)},__wbindgen_cast_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 P(r,e){o.wasm_bindgen_4d7940e3be85a6dc___convert__closures_____invoke_______true_(r,e)}function G(r,e,t){const n=o.wasm_bindgen_4d7940e3be85a6dc___convert__closures_____invoke___wasm_bindgen_4d7940e3be85a6dc___JsValue__core_ed718c3d60ebd546___result__Result_____wasm_bindgen_4d7940e3be85a6dc___JsError___true_(r,e,t);if(n[1])throw d(n[0])}function $(r,e,t,n){o.wasm_bindgen_4d7940e3be85a6dc___convert__closures_____invoke___js_sys_a576b80f2209464___Function_fn_wasm_bindgen_4d7940e3be85a6dc___JsValue_____wasm_bindgen_4d7940e3be85a6dc___sys__Undefined___js_sys_a576b80f2209464___Function_fn_wasm_bindgen_4d7940e3be85a6dc___JsValue_____wasm_bindgen_4d7940e3be85a6dc___sys__Undefined_______true_(r,e,t,n)}const H=["default","no-store","reload","no-cache","force-cache","only-if-cached"],X=["omit","same-origin","include"],Y=["same-origin","no-cors","cors","navigate"],k=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 z=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 i=1;i<_;i++)c+=", "+U(r[i]);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,T().subarray(r/1,r/1+e)}let I=null;function m(){return(I===null||I.buffer.detached===!0||I.buffer.detached===void 0&&I.buffer!==o.memory.buffer)&&(I=new DataView(o.memory.buffer)),I}function y(r,e){return Z(r>>>0,e)}let B=null;function K(){return(B===null||B.byteLength===0)&&(B=new Uint32Array(o.memory.buffer)),B}let S=null;function T(){return(S===null||S.byteLength===0)&&(S=new Uint8Array(o.memory.buffer)),S}function l(r,e){try{return r.apply(this,e)}catch(t){const n=R(t);o.__wbindgen_exn_store(n)}}function g(r){return r==null}function J(r,e,t){const n={a:r,b:e,cnt:1},_=(...c)=>{n.cnt++;const i=n.a;n.a=0;try{return t(i,n.b,...c)}finally{n.a=i,_._wbg_cb_unref()}};return _._wbg_cb_unref=()=>{--n.cnt===0&&(o.__wbindgen_destroy_closure(n.a,n.b),n.a=0,z.unregister(n))},z.register(_,n,n),_}function E(r,e){const t=e(r.length*4,4)>>>0;return K().set(r,t/4),a=r.length,t}function b(r,e,t){if(t===void 0){const s=j.encode(r),u=e(s.length,1)>>>0;return T().subarray(u,u+s.length).set(s),a=s.length,u}let n=r.length,_=e(n,1)>>>0;const c=T();let i=0;for(;i<n;i++){const s=r.charCodeAt(i);if(s>127)break;c[_+i]=s}if(i!==n){i!==0&&(r=r.slice(i)),_=t(_,n,n=i+r.length*3,1)>>>0;const s=T().subarray(_+i,_+n),u=j.encodeInto(r,s);i+=u.written,_=t(_,n,i,1)>>>0}return a=i,_}function d(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 Q=2146435072;let x=0;function Z(r,e){return x+=e,x>=Q&&(O=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),O.decode(),x=e),O.decode(T().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 ee(r,e){return o=r.exports,I=null,B=null,S=null,o.__wbindgen_start(),o}function te(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=C();r instanceof WebAssembly.Module||(r=new WebAssembly.Module(r));const t=new WebAssembly.Instance(r,e);return ee(t)}function L(){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 V=Symbol("transfer");function F(r,e){return{type:V,value:r,transfer:e?Array.isArray(e)?e:[e]:[r]}}function D(r){return!!(r&&typeof r=="object"&&Reflect.get(r,"type")===V)}function q(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:i,result:s,error:u}=c,w=t.get(i);w&&(u?w.reject(u):w.resolve(s),t.delete(i))}),new Proxy({},{get(_,c){return(...i)=>{const s=ne(),u=[],w=[];return i.forEach(M=>{D(M)?(u.push(M.value),w.push(...M.transfer)):u.push(M)}),n.postMessage({method:c,args:u,id:s,channelName:r},{transfer:w}),new Promise((M,ie)=>{t.set(s,{resolve:M,reject:ie})})}}})},rx(e,t){const n=t??self;n.addEventListener("message",async _=>{const{data:c}=_;if(c.channelName!==r)return;const{method:i,args:s,id:u}=c;try{const w=await e[i](...s);D(w)?n.postMessage({result:w.value,id:u,channelName:r},{transfer:w.transfer}):n.postMessage({result:w,id:u,channelName:r})}catch(w){n.postMessage({error:w,id:u,channelName:r})}})}}}function ne(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}const{rx:re}=q(),{createTx:_e}=q("worker");function oe(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=L(),f=L(),W=_e();re(ce({async initWorker(r){te({module:r})},async reader_fromBlob(r,e,t){const n=await v.fromBlob(r,e,t);return h.add(n)},async reader_fromBlobFragment(r,e,t,n){const _=await v.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 oe(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 F(n,n.buffer)},reader_free(r){h.get(r).free(),h.remove(r)},builder_new(r){const e=p.new(r);return f.add(e)},builder_fromJson(r,e){const t=p.fromJson(r,e);return f.add(t)},builder_fromArchive(r,e){const t=p.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_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_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 F(t,t.buffer)},async builder_sign(r,e,t,n,_){const i=await f.get(r).sign({reserveSize:t.reserveSize,alg:t.alg,sign:async s=>await W.sign(e,F(s,s.buffer),t.reserveSize)},n,_);return F(i,i.buffer)},async builder_signAndGetManifestBytes(r,e,t,n,_){const c=f.get(r),{manifest:i,asset:s}=await c.signAndGetManifestBytes({reserveSize:t.reserveSize,alg:t.alg,sign:async u=>await W.sign(e,F(u,u.buffer),t.reserveSize)},n,_);return F({manifest:i,asset:s},[i.buffer,s.buffer])},builder_free(r){f.get(r).free(),f.remove(r)}}));function ce(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', k = typeof self < "u" && self.Blob && new Blob([K], { type: "text/javascript;charset=utf-8" });
|
|
10
|
+
function oe(n) {
|
|
11
|
+
let e;
|
|
12
|
+
try {
|
|
13
|
+
if (e = k && (self.URL || self.webkitURL).createObjectURL(k), !e) throw "";
|
|
14
|
+
const t = new Worker(e, {
|
|
15
|
+
name: n == null ? void 0 : n.name
|
|
16
|
+
});
|
|
17
|
+
return t.addEventListener("error", () => {
|
|
18
|
+
(self.URL || self.webkitURL).revokeObjectURL(e);
|
|
19
|
+
}), t;
|
|
20
|
+
} catch {
|
|
21
|
+
return new Worker(
|
|
22
|
+
"data:text/javascript;charset=utf-8," + encodeURIComponent(K),
|
|
23
|
+
{
|
|
24
|
+
name: n == null ? void 0 : n.name
|
|
25
|
+
}
|
|
26
|
+
);
|
|
27
|
+
} finally {
|
|
28
|
+
e && (self.URL || self.webkitURL).revokeObjectURL(e);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
function se(n) {
|
|
32
|
+
if (n.protocol !== "https:")
|
|
33
|
+
throw new Error(
|
|
34
|
+
`Worker source URL must use https, but got ${n.protocol}`
|
|
35
|
+
);
|
|
36
|
+
return n.toString();
|
|
37
|
+
}
|
|
38
|
+
async function _e(n) {
|
|
39
|
+
const { wasm: e, workerSrc: t } = n;
|
|
40
|
+
let r = 0;
|
|
41
|
+
const _ = t ? new Worker(se(t), { type: "module" }) : new oe(), o = re(_), s = /* @__PURE__ */ new Map();
|
|
42
|
+
ie(
|
|
43
|
+
{
|
|
44
|
+
sign: async (u, d, h) => {
|
|
45
|
+
const b = s.get(u);
|
|
46
|
+
if (s.delete(u), !b)
|
|
47
|
+
throw new Error("No signer registered for request");
|
|
48
|
+
const l = await b(d, h);
|
|
49
|
+
return ne(l, l.buffer);
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
_
|
|
53
|
+
);
|
|
54
|
+
function a(u) {
|
|
55
|
+
const d = r++;
|
|
56
|
+
return s.set(d, u), d;
|
|
57
|
+
}
|
|
58
|
+
return await o.initWorker(e), {
|
|
59
|
+
tx: o,
|
|
60
|
+
registerSignReceiver: a,
|
|
61
|
+
terminate: () => _.terminate()
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
typeof FinalizationRegistry > "u" || new FinalizationRegistry((n) => B.__wbg_wasmbuilder_free(n, 1));
|
|
65
|
+
typeof FinalizationRegistry > "u" || new FinalizationRegistry((n) => B.__wbg_wasmreader_free(n, 1));
|
|
66
|
+
typeof FinalizationRegistry > "u" || new FinalizationRegistry((n) => B.__wbg_wasmsigner_free(n, 1));
|
|
67
|
+
typeof FinalizationRegistry > "u" || new FinalizationRegistry((n) => B.__wbindgen_destroy_closure(n.a, n.b));
|
|
68
|
+
let ae = new TextDecoder("utf-8", { ignoreBOM: !0, fatal: !0 });
|
|
69
|
+
ae.decode();
|
|
70
|
+
const U = new TextEncoder();
|
|
71
|
+
"encodeInto" in U || (U.encodeInto = function(n, e) {
|
|
72
|
+
const t = U.encode(n);
|
|
73
|
+
return e.set(t), {
|
|
74
|
+
read: n.length,
|
|
75
|
+
written: t.length
|
|
76
|
+
};
|
|
77
|
+
});
|
|
78
|
+
let B;
|
|
79
|
+
const ce = "sha512-sY8Kfs0hgY1uKvgI9KwU9YMZUUQmQ+76LLbFfkRmkB0r/EAVr6B/fJNYEP2Ej/6gT5qQrTYJZYaFJ4KFNUOrwA==", I = (n) => {
|
|
80
|
+
if (typeof n == "object" && n !== null) {
|
|
81
|
+
if (typeof Object.getPrototypeOf == "function") {
|
|
82
|
+
const e = Object.getPrototypeOf(n);
|
|
83
|
+
return e === Object.prototype || e === null;
|
|
84
|
+
}
|
|
85
|
+
return Object.prototype.toString.call(n) === "[object Object]";
|
|
86
|
+
}
|
|
87
|
+
return !1;
|
|
88
|
+
}, ue = /* @__PURE__ */ new Set([
|
|
89
|
+
"__proto__",
|
|
90
|
+
"constructor",
|
|
91
|
+
"prototype",
|
|
92
|
+
"toString",
|
|
93
|
+
"valueOf",
|
|
94
|
+
"hasOwnProperty",
|
|
95
|
+
"isPrototypeOf",
|
|
96
|
+
"propertyIsEnumerable",
|
|
97
|
+
"toLocaleString"
|
|
98
|
+
]), g = (...n) => n.reduce((e, t) => {
|
|
99
|
+
if (t === void 0)
|
|
100
|
+
return e;
|
|
101
|
+
if (Array.isArray(t))
|
|
102
|
+
throw new TypeError("Arguments provided to ts-deepmerge must be objects, not arrays.");
|
|
103
|
+
return Object.keys(t).forEach((r) => {
|
|
104
|
+
ue.has(r) || (Array.isArray(e[r]) && Array.isArray(t[r]) ? e[r] = g.options.mergeArrays ? g.options.uniqueArrayItems ? Array.from(new Set(e[r].concat(t[r]))) : [...e[r], ...t[r]] : t[r] : I(e[r]) && I(t[r]) ? e[r] = g(e[r], t[r]) : !I(e[r]) && I(t[r]) ? e[r] = g(t[r], void 0) : e[r] = t[r] === void 0 ? g.options.allowUndefinedOverrides ? t[r] : e[r] : t[r]);
|
|
105
|
+
}), e;
|
|
106
|
+
}, {}), D = {
|
|
107
|
+
allowUndefinedOverrides: !0,
|
|
108
|
+
mergeArrays: !0,
|
|
109
|
+
uniqueArrayItems: !0
|
|
110
|
+
};
|
|
111
|
+
g.options = D;
|
|
112
|
+
g.withOptions = (n, ...e) => {
|
|
113
|
+
g.options = Object.assign(Object.assign({}, D), n);
|
|
114
|
+
const t = g(...e);
|
|
115
|
+
return g.options = D, t;
|
|
116
|
+
};
|
|
117
|
+
const fe = 1 * 1024 * 1024, de = 2, be = 200, le = 2e3, ge = 3e4;
|
|
118
|
+
function we(n) {
|
|
119
|
+
return n === 429 || n >= 500;
|
|
120
|
+
}
|
|
121
|
+
function me(n) {
|
|
122
|
+
return n instanceof Error && n.name === "AbortError";
|
|
123
|
+
}
|
|
124
|
+
function he(n, e, t) {
|
|
125
|
+
const r = Math.min(e * 2 ** n, t), _ = Math.floor(Math.random() * 200);
|
|
126
|
+
return Math.min(r + _, t);
|
|
127
|
+
}
|
|
128
|
+
function ye(n) {
|
|
129
|
+
if (!n)
|
|
130
|
+
return null;
|
|
131
|
+
const e = Number(n);
|
|
132
|
+
if (!Number.isNaN(e))
|
|
133
|
+
return e * 1e3;
|
|
134
|
+
const t = Date.parse(n);
|
|
135
|
+
return Number.isNaN(t) ? null : t - Date.now();
|
|
136
|
+
}
|
|
137
|
+
function Ae(n) {
|
|
138
|
+
try {
|
|
139
|
+
new URL(n);
|
|
140
|
+
} catch {
|
|
141
|
+
throw new Error(`Invalid URL: ${n}`);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
async function X(n, e, t) {
|
|
145
|
+
Ae(n);
|
|
146
|
+
const r = (t == null ? void 0 : t.maxRetries) ?? de, _ = (t == null ? void 0 : t.initialRetryDelayMs) ?? be, o = (t == null ? void 0 : t.maxRetryDelayMs) ?? le, s = (t == null ? void 0 : t.maxRetryAfterMs) ?? ge, a = (t == null ? void 0 : t.isRetryableStatus) ?? we, u = (t == null ? void 0 : t.isRetryableError) ?? (() => !0), d = (t == null ? void 0 : t.fetch) ?? fetch, h = (b) => he(b, _, o);
|
|
147
|
+
for (let b = 0; ; b++) {
|
|
148
|
+
let l;
|
|
149
|
+
try {
|
|
150
|
+
l = await d(n, e);
|
|
151
|
+
} catch (A) {
|
|
152
|
+
if (!me(A) && u(A) && b < r) {
|
|
153
|
+
await new Promise((R) => setTimeout(R, h(b)));
|
|
154
|
+
continue;
|
|
155
|
+
}
|
|
156
|
+
const p = A instanceof Error ? A.message : String(A);
|
|
157
|
+
throw new Error(`Network error fetching ${n}: ${p}`, {
|
|
158
|
+
cause: A
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
if (!l.ok) {
|
|
162
|
+
if (a(l.status)) {
|
|
163
|
+
const p = ye(l.headers.get("retry-after"));
|
|
164
|
+
if (p !== null) {
|
|
165
|
+
if (p > s)
|
|
166
|
+
throw new Error(`Failed to fetch ${n}: server requested a Retry-After delay of ${Math.ceil(p / 1e3)}s, which exceeds the maximum allowed delay of ${s / 1e3}s`);
|
|
167
|
+
if (b < r) {
|
|
168
|
+
await new Promise((R) => setTimeout(R, Math.max(p, 0)));
|
|
169
|
+
continue;
|
|
170
|
+
}
|
|
171
|
+
throw new Error(`Failed to fetch ${n}: ${l.status} ${l.statusText}`);
|
|
172
|
+
}
|
|
173
|
+
if (b < r) {
|
|
174
|
+
await new Promise((R) => setTimeout(R, h(b)));
|
|
175
|
+
continue;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
throw new Error(`Failed to fetch ${n}: ${l.status} ${l.statusText}`);
|
|
179
|
+
}
|
|
180
|
+
return l;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
async function W(n, e) {
|
|
184
|
+
const t = (e == null ? void 0 : e.maxResponseBytes) ?? fe, r = await X(n, void 0, e), _ = r.headers.get("content-length");
|
|
185
|
+
if (_ !== null && Number(_) > t)
|
|
186
|
+
throw new Error(`Response from ${n} is too large. Max size is ${t} bytes.`);
|
|
187
|
+
const o = await r.text();
|
|
188
|
+
if (o.length > t)
|
|
189
|
+
throw new Error(`Response from ${n} is too large. Max size is ${t} bytes.`);
|
|
190
|
+
return o;
|
|
191
|
+
}
|
|
192
|
+
function z(n) {
|
|
193
|
+
return Object.entries(n).reduce((t, [r, _]) => (t[pe(r)] = Z(_), t), {});
|
|
194
|
+
}
|
|
195
|
+
function Z(n) {
|
|
196
|
+
return Array.isArray(n) ? n.map(Z) : typeof n == "object" && n !== null ? z(n) : n;
|
|
197
|
+
}
|
|
198
|
+
function pe(n) {
|
|
199
|
+
return n.replace(/[A-Z]/g, (e) => `_${e.toLowerCase()}`);
|
|
200
|
+
}
|
|
201
|
+
const Re = Object.freeze({
|
|
202
|
+
builder: Object.freeze({
|
|
203
|
+
generateC2paArchive: !0
|
|
204
|
+
})
|
|
205
|
+
});
|
|
206
|
+
function ve(n) {
|
|
207
|
+
return g(Re, n ?? {});
|
|
208
|
+
}
|
|
209
|
+
async function xe(n, e) {
|
|
210
|
+
const t = ve(n), r = [];
|
|
211
|
+
return t.trust && r.push(C(t.trust, e)), t.cawgTrust && r.push(C(t.cawgTrust, e)), await Promise.all(r), JSON.stringify(z(t));
|
|
212
|
+
}
|
|
213
|
+
function Ne(n) {
|
|
214
|
+
return { trust: { ...n } };
|
|
215
|
+
}
|
|
216
|
+
function Le(n) {
|
|
217
|
+
return { cawgTrust: { ...n } };
|
|
218
|
+
}
|
|
219
|
+
function Je(n) {
|
|
220
|
+
return { verify: { ...n } };
|
|
221
|
+
}
|
|
222
|
+
function S(...n) {
|
|
223
|
+
return g(...n);
|
|
224
|
+
}
|
|
225
|
+
function De(n) {
|
|
226
|
+
return JSON.stringify(z(n));
|
|
227
|
+
}
|
|
228
|
+
async function ze(n, e) {
|
|
229
|
+
return await (await X(n, void 0, e)).text();
|
|
230
|
+
}
|
|
231
|
+
const Se = [
|
|
232
|
+
"userAnchors",
|
|
233
|
+
"trustAnchors",
|
|
234
|
+
"trustConfig",
|
|
235
|
+
"allowedList"
|
|
236
|
+
];
|
|
237
|
+
async function C(n, e) {
|
|
238
|
+
const t = (o) => ["userAnchors", "trustAnchors"].includes(o), r = (o) => o.includes("-----BEGIN CERTIFICATE-----"), _ = (o) => o.startsWith("http");
|
|
239
|
+
try {
|
|
240
|
+
const o = Object.entries(n).filter(([s]) => Se.includes(s)).map(async ([s, a]) => {
|
|
241
|
+
if (a && typeof a == "object" && Array.isArray(a)) {
|
|
242
|
+
const u = a.map(async (b) => {
|
|
243
|
+
if (typeof b != "string")
|
|
244
|
+
throw new Error("Expected a string value for array item");
|
|
245
|
+
const l = await W(b, e);
|
|
246
|
+
if (t(s) && !r(l))
|
|
247
|
+
throw new Error(`Error parsing PEM file at: ${b}`);
|
|
248
|
+
return l;
|
|
249
|
+
}), h = (await Promise.all(u)).join("");
|
|
250
|
+
n[s] = h;
|
|
251
|
+
} else if (a && typeof a == "string" && _(a)) {
|
|
252
|
+
const u = await W(a, e);
|
|
253
|
+
if (t(s) && !r(u))
|
|
254
|
+
throw new Error(`Error parsing PEM file at: ${a}`);
|
|
255
|
+
n[s] = u;
|
|
256
|
+
} else
|
|
257
|
+
return a;
|
|
258
|
+
});
|
|
259
|
+
await Promise.all(o);
|
|
260
|
+
} catch (o) {
|
|
261
|
+
const s = o instanceof Error ? o.message : String(o);
|
|
262
|
+
throw new Error(`Failed to resolve trust settings. ${s}`, {
|
|
263
|
+
cause: o
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
class y {
|
|
268
|
+
constructor(e) {
|
|
269
|
+
O(this, "_settings");
|
|
270
|
+
O(this, "_jsonPromise");
|
|
271
|
+
this._settings = e;
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* The settings currently attached to this `Context`, if any.
|
|
275
|
+
*
|
|
276
|
+
* To derive a new `Context` with different settings, construct one with `new Context(settings)`.
|
|
277
|
+
* To combine this `Context`'s settings with more settings, merge them with {@link mergeSettings}
|
|
278
|
+
* first and pass the single, merged result to the constructor.
|
|
279
|
+
*/
|
|
280
|
+
get settings() {
|
|
281
|
+
return this._settings;
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Resolves this `Context`'s settings (fetching any embedded trust-anchor URLs) and serializes
|
|
285
|
+
* the result for consumption by the WASM/native boundary. A successful result is memoized, so
|
|
286
|
+
* resolution of this Context's settings only happens once. If different fetch-with-retry
|
|
287
|
+
* options need to be provided, callers should create a separate `Context` and then call
|
|
288
|
+
* `toJson()` with the desired options.
|
|
289
|
+
*
|
|
290
|
+
* A failed resolution is not memoized: the next call to `toJson()` tries again from scratch,
|
|
291
|
+
* so a transient failure (e.g. a network error while fetching a trust-anchor URL) doesn't
|
|
292
|
+
* permanently break this `Context`.
|
|
293
|
+
*
|
|
294
|
+
* @param options Optional configurations for fetch-with-retry, used when resolving trust-anchor
|
|
295
|
+
* URLs. Only consulted on the first call, or the first call after a previous failure.
|
|
296
|
+
* @returns A JSON-serialized string of the resolved settings.
|
|
297
|
+
*/
|
|
298
|
+
toJson(e) {
|
|
299
|
+
return this._jsonPromise ?? (this._jsonPromise = xe(this.settings, e).catch((t) => {
|
|
300
|
+
throw this._jsonPromise = void 0, t;
|
|
301
|
+
})), this._jsonPromise;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
const Ee = 10 ** 9;
|
|
305
|
+
function H(n) {
|
|
306
|
+
return Number.isFinite(n) && n > 0 ? n : Ee;
|
|
307
|
+
}
|
|
308
|
+
class Fe extends Error {
|
|
309
|
+
/**
|
|
310
|
+
* @param sizeInBytes Size of the asset, in bytes.
|
|
311
|
+
* @param maxSizeInBytes Maximum allowed size, in bytes. `0` (or any other
|
|
312
|
+
* non-finite/negative value) resolves to {@link DEFAULT_MAX_SIZE_IN_BYTES}.
|
|
313
|
+
*/
|
|
314
|
+
constructor(e, t) {
|
|
315
|
+
const r = H(t);
|
|
316
|
+
super(`The provided asset was too large. Size: ${e} bytes. Maximum: ${r}.`), this.name = "AssetTooLargeError";
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
function N(n, e) {
|
|
320
|
+
if (!Number.isFinite(n) || n < 0)
|
|
321
|
+
throw new RangeError(`sizeInBytes must be a finite, non-negative number. Received: ${n}.`);
|
|
322
|
+
if (!Number.isFinite(e) || e < 0)
|
|
323
|
+
throw new RangeError(`maxSizeInBytes must be a finite, non-negative number. Received: ${e}.`);
|
|
324
|
+
const t = H(e);
|
|
325
|
+
if (n > t)
|
|
326
|
+
throw new Fe(n, t);
|
|
327
|
+
}
|
|
328
|
+
const L = 10 ** 9, J = new FinalizationRegistry(
|
|
329
|
+
async ({ worker: n, id: e }) => {
|
|
330
|
+
await n.tx.reader_free(e);
|
|
331
|
+
}
|
|
332
|
+
);
|
|
333
|
+
var w, m;
|
|
334
|
+
const j = class j {
|
|
335
|
+
constructor(e, t) {
|
|
336
|
+
v(this, w);
|
|
337
|
+
v(this, m);
|
|
338
|
+
x(this, w, e), x(this, m, t);
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Create a {@link Reader} from an asset's format and a blob of its bytes.
|
|
342
|
+
*
|
|
343
|
+
* @param c2pa The `C2pa` instance (from {@link createC2pa}) to create this reader on.
|
|
344
|
+
* @param format Asset format.
|
|
345
|
+
* @param blob Blob of asset bytes.
|
|
346
|
+
* @param context Optional `Context` configuring this reader's behavior.
|
|
347
|
+
* @returns A {@link Reader} object or null if no C2PA metadata was found.
|
|
348
|
+
* @throws If the asset is too large.
|
|
349
|
+
*/
|
|
350
|
+
static async fromBlob(e, t, r, _ = new y()) {
|
|
351
|
+
N(r.size, L);
|
|
352
|
+
try {
|
|
353
|
+
const o = await _.toJson(), { worker: s } = e, a = await s.tx.reader_fromBlob(t, r, o), u = new j(s, a);
|
|
354
|
+
return J.register(u, { worker: s, id: a }, u), u;
|
|
355
|
+
} catch (o) {
|
|
356
|
+
return q(o);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
/**
|
|
360
|
+
* Create a {@link Reader} from an initial fragment and a subsequent fragment.
|
|
361
|
+
*
|
|
362
|
+
* @param c2pa The `C2pa` instance (from {@link createC2pa}) to create this reader on.
|
|
363
|
+
* @param format Asset format.
|
|
364
|
+
* @param init Blob of initial fragment bytes.
|
|
365
|
+
* @param fragment Blob of fragment bytes.
|
|
366
|
+
* @param context Optional `Context` configuring this reader's behavior.
|
|
367
|
+
* @returns A {@link Reader} object or null if no C2PA metadata was found.
|
|
368
|
+
* @throws If the asset is too large.
|
|
369
|
+
*/
|
|
370
|
+
static async fromBlobFragment(e, t, r, _, o = new y()) {
|
|
371
|
+
N(r.size, L), N(_.size, L);
|
|
372
|
+
try {
|
|
373
|
+
const s = await o.toJson(), { worker: a } = e, u = await a.tx.reader_fromBlobFragment(
|
|
374
|
+
t,
|
|
375
|
+
r,
|
|
376
|
+
_,
|
|
377
|
+
s
|
|
378
|
+
), d = new j(a, u);
|
|
379
|
+
return J.register(d, { worker: a, id: u }, d), d;
|
|
380
|
+
} catch (s) {
|
|
381
|
+
return q(s);
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* @returns The label of the active manifest.
|
|
386
|
+
*/
|
|
387
|
+
async activeLabel() {
|
|
388
|
+
return await i(this, w).tx.reader_activeLabel(i(this, m));
|
|
389
|
+
}
|
|
390
|
+
/**
|
|
391
|
+
* @returns The asset's full {@link ManifestStore} containing all its manifests, validation statuses, and the URI of the active manifest.
|
|
392
|
+
*/
|
|
393
|
+
async manifestStore() {
|
|
394
|
+
return await i(this, w).tx.reader_manifestStore(i(this, m));
|
|
395
|
+
}
|
|
396
|
+
/**
|
|
397
|
+
* @returns The asset's active {@link Manifest}.
|
|
398
|
+
*/
|
|
399
|
+
async activeManifest() {
|
|
400
|
+
return await i(this, w).tx.reader_activeManifest(i(this, m));
|
|
401
|
+
}
|
|
402
|
+
/**
|
|
403
|
+
* @returns The asset's full {@link ManifestStore}.
|
|
404
|
+
*
|
|
405
|
+
* @deprecated Use {@link manifestStore} instead.
|
|
406
|
+
*/
|
|
407
|
+
async json() {
|
|
408
|
+
const e = await i(this, w).tx.reader_json(i(this, m));
|
|
409
|
+
return JSON.parse(e);
|
|
410
|
+
}
|
|
411
|
+
/**
|
|
412
|
+
* @returns The asset's manifest store as crJSON.
|
|
413
|
+
*/
|
|
414
|
+
async crJson() {
|
|
415
|
+
const e = await i(this, w).tx.reader_crJson(i(this, m));
|
|
416
|
+
return JSON.parse(e);
|
|
417
|
+
}
|
|
418
|
+
/**
|
|
419
|
+
* Resolves a URI reference to a binary object (e.g. a thumbnail) in the resource store.
|
|
420
|
+
*
|
|
421
|
+
* @param uri URI of the binary object to resolve.
|
|
422
|
+
* @returns A Uint8Array of the resource's bytes.
|
|
423
|
+
*
|
|
424
|
+
* @example Retrieving a thumbnail from the resource store:
|
|
425
|
+
* ```
|
|
426
|
+
* const reader = await Reader.fromBlob(c2pa, blob.type, blob);
|
|
427
|
+
* const activeManifest = await reader.activeManifest();
|
|
428
|
+
* const thumbnailBuffer = await reader.resourceToBytes(activeManifest.thumbnail!.identifier);
|
|
429
|
+
* ```
|
|
430
|
+
*/
|
|
431
|
+
async resourceToBytes(e) {
|
|
432
|
+
return await i(this, w).tx.reader_resourceToBytes(i(this, m), e);
|
|
433
|
+
}
|
|
434
|
+
/**
|
|
435
|
+
* Dispose of this Reader, freeing the memory it occupied and preventing further use.
|
|
436
|
+
* Call this whenever the Reader is no longer needed.
|
|
437
|
+
*/
|
|
438
|
+
async free() {
|
|
439
|
+
J.unregister(this), await i(this, w).tx.reader_free(i(this, m));
|
|
440
|
+
}
|
|
441
|
+
};
|
|
442
|
+
w = new WeakMap(), m = new WeakMap();
|
|
443
|
+
let M = j;
|
|
444
|
+
function Ie(n, e = {}) {
|
|
445
|
+
return {
|
|
446
|
+
fromBlob: (t, r, _ = {}) => M.fromBlob(
|
|
447
|
+
n,
|
|
448
|
+
t,
|
|
449
|
+
r,
|
|
450
|
+
new y(S(e, _))
|
|
451
|
+
),
|
|
452
|
+
fromBlobFragment: (t, r, _, o = {}) => M.fromBlobFragment(
|
|
453
|
+
n,
|
|
454
|
+
t,
|
|
455
|
+
r,
|
|
456
|
+
_,
|
|
457
|
+
new y(S(e, o))
|
|
458
|
+
)
|
|
459
|
+
};
|
|
460
|
+
}
|
|
461
|
+
function q(n) {
|
|
462
|
+
if (n instanceof Error && n.message === "C2pa(JumbfNotFound)")
|
|
463
|
+
return null;
|
|
464
|
+
throw n;
|
|
465
|
+
}
|
|
466
|
+
async function V(n) {
|
|
467
|
+
const { alg: e } = n;
|
|
468
|
+
return {
|
|
469
|
+
reserveSize: await n.reserveSize(),
|
|
470
|
+
alg: e
|
|
471
|
+
};
|
|
472
|
+
}
|
|
473
|
+
function Y(n) {
|
|
474
|
+
return Q(n).flat();
|
|
475
|
+
}
|
|
476
|
+
function Q(n) {
|
|
477
|
+
return (n.assertions ?? []).filter((e) => e.label.startsWith("c2pa.actions")).map((e) => {
|
|
478
|
+
const t = e.data;
|
|
479
|
+
return (t == null ? void 0 : t.actions) ?? [];
|
|
480
|
+
});
|
|
481
|
+
}
|
|
482
|
+
const T = new FinalizationRegistry(
|
|
483
|
+
({ worker: n, id: e }) => {
|
|
484
|
+
n.tx.builder_free(e);
|
|
485
|
+
}
|
|
486
|
+
);
|
|
487
|
+
var c, f;
|
|
488
|
+
const F = class F {
|
|
489
|
+
constructor(e, t) {
|
|
490
|
+
v(this, c);
|
|
491
|
+
v(this, f);
|
|
492
|
+
x(this, c, e), x(this, f, t);
|
|
493
|
+
}
|
|
494
|
+
/**
|
|
495
|
+
* Create a {@link Builder} with a minimal manifest definition as its initial state.
|
|
496
|
+
*
|
|
497
|
+
* @param c2pa The `C2pa` instance (from {@link createC2pa}) to create this builder on.
|
|
498
|
+
* @param context Optional `Context` configuring this builder's behavior.
|
|
499
|
+
* @returns A {@link Builder} object.
|
|
500
|
+
*/
|
|
501
|
+
static async new(e, t = new y()) {
|
|
502
|
+
const r = await t.toJson(), { worker: _ } = e, o = await _.tx.builder_new(r), s = new F(_, o);
|
|
503
|
+
return T.register(s, { worker: _, id: o }, s), s;
|
|
504
|
+
}
|
|
505
|
+
/**
|
|
506
|
+
* Create a {@link Builder} from a {@link ManifestDefinition}.
|
|
507
|
+
*
|
|
508
|
+
* @param c2pa The `C2pa` instance (from {@link createC2pa}) to create this builder on.
|
|
509
|
+
* @param definition The {@link ManifestDefinition} to be used as the builder's initial state.
|
|
510
|
+
* @param context Optional `Context` configuring this builder's behavior.
|
|
511
|
+
* @returns A {@link Builder} object.
|
|
512
|
+
*/
|
|
513
|
+
static async fromDefinition(e, t, r = new y()) {
|
|
514
|
+
const _ = JSON.stringify(t), o = await r.toJson(), { worker: s } = e, a = await s.tx.builder_fromJson(_, o), u = new F(s, a);
|
|
515
|
+
return T.register(u, { worker: s, id: a }, u), u;
|
|
516
|
+
}
|
|
517
|
+
/**
|
|
518
|
+
* Create a {@link Builder} from a builder archive (created from {@link Builder.toArchive}).
|
|
519
|
+
*
|
|
520
|
+
* @param c2pa The `C2pa` instance (from {@link createC2pa}) to create this builder on.
|
|
521
|
+
* @param archive Builder archive as a blob.
|
|
522
|
+
* @param context Optional `Context` configuring this builder's behavior.
|
|
523
|
+
* @returns A {@link Builder} object.
|
|
524
|
+
*/
|
|
525
|
+
static async fromArchive(e, t, r = new y()) {
|
|
526
|
+
const _ = await r.toJson(), { worker: o } = e, s = await o.tx.builder_fromArchive(t, _), a = new F(o, s);
|
|
527
|
+
return T.register(a, { worker: o, id: s }, a), a;
|
|
528
|
+
}
|
|
529
|
+
/**
|
|
530
|
+
* Sets the builder "intent."
|
|
531
|
+
*
|
|
532
|
+
* @todo Additional documentation coming soon.
|
|
533
|
+
*
|
|
534
|
+
* @param intent
|
|
535
|
+
*/
|
|
536
|
+
async setIntent(e) {
|
|
537
|
+
await i(this, c).tx.builder_setIntent(i(this, f), e);
|
|
538
|
+
}
|
|
539
|
+
/**
|
|
540
|
+
* Add an action to the manifest's actions assertion.
|
|
541
|
+
*
|
|
542
|
+
* @param action Object representing the action to be added.
|
|
543
|
+
*/
|
|
544
|
+
async addAction(e) {
|
|
545
|
+
await i(this, c).tx.builder_addAction(i(this, f), e);
|
|
546
|
+
}
|
|
547
|
+
/**
|
|
548
|
+
* Add an assertion to the manifest under the given label.
|
|
549
|
+
*
|
|
550
|
+
* @param label The assertion label (reverse-domain format).
|
|
551
|
+
* @param data The assertion data (any JSON-serializable value).
|
|
552
|
+
*/
|
|
553
|
+
async addAssertion(e, t) {
|
|
554
|
+
await i(this, c).tx.builder_addAssertion(i(this, f), e, t);
|
|
555
|
+
}
|
|
556
|
+
/**
|
|
557
|
+
* Redact an assertion from an ingredient manifest.
|
|
558
|
+
*
|
|
559
|
+
* Adds the URI to the builder's redaction list and appends a `c2pa.redacted` action
|
|
560
|
+
* with the given reason, as required by the C2PA spec.
|
|
561
|
+
*
|
|
562
|
+
* @param uri JUMBF URI of the assertion to redact.
|
|
563
|
+
* @param reason The {@link C2paReason} for the redaction.
|
|
564
|
+
*/
|
|
565
|
+
async addRedaction(e, t) {
|
|
566
|
+
await i(this, c).tx.builder_addRedaction(i(this, f), e, t);
|
|
567
|
+
}
|
|
568
|
+
/**
|
|
569
|
+
* Sets the remote URL for a remote manifest. The manifest is expected to be available at this location.
|
|
570
|
+
*
|
|
571
|
+
* @param url URL pointing to the location the remote manifest will be stored.
|
|
572
|
+
*/
|
|
573
|
+
async setRemoteUrl(e) {
|
|
574
|
+
await i(this, c).tx.builder_setRemoteUrl(i(this, f), e);
|
|
575
|
+
}
|
|
576
|
+
/**
|
|
577
|
+
* Sets the state of the no_embed flag.
|
|
578
|
+
* To skip embedding a manifest (e.g. for the remote-only case), set this to `true`.
|
|
579
|
+
*
|
|
580
|
+
* @param noEmbed Value to set the no_embed flag.
|
|
581
|
+
*/
|
|
582
|
+
async setNoEmbed(e) {
|
|
583
|
+
await i(this, c).tx.builder_setNoEmbed(i(this, f), e);
|
|
584
|
+
}
|
|
585
|
+
/**
|
|
586
|
+
* Set a thumbnail from a blob to be included in the manifest. The blob should represent the asset being signed.
|
|
587
|
+
*
|
|
588
|
+
* @param format Format of the thumbnail
|
|
589
|
+
* @param blob Blob of the thumbnail bytes
|
|
590
|
+
*/
|
|
591
|
+
async setThumbnailFromBlob(e, t) {
|
|
592
|
+
await i(this, c).tx.builder_setThumbnailFromBlob(i(this, f), e, t);
|
|
593
|
+
}
|
|
594
|
+
/**
|
|
595
|
+
* Experimental.
|
|
596
|
+
* Retains only the actions for which `keep` returns true.
|
|
597
|
+
*
|
|
598
|
+
* The inception action, `c2pa.created` or `c2pa.opened`, is always kept regardless of `keep`,
|
|
599
|
+
* and is moved to index 0 if needed, so the manifest stays valid per the C2PA spec. Sets
|
|
600
|
+
* `allActionsIncluded = false` when anything is removed. This does not touch ingredients.
|
|
601
|
+
* Call {@link Builder.filterIngredients}, using `filterIngredients(() => false)` to drop all
|
|
602
|
+
* orphans, afterwards if you also want to drop ingredients now orphaned by the removed
|
|
603
|
+
* actions.
|
|
604
|
+
*
|
|
605
|
+
* Unlike the Node binding, Neon, which can invoke the JS predicate synchronously from Rust,
|
|
606
|
+
* the WASM builder lives in a Web Worker. A predicate closure can't be called across the
|
|
607
|
+
* worker boundary, so we evaluate it here on the main thread and send the resulting indices
|
|
608
|
+
* to the worker, where WASM applies the equivalent index-based filter. The action/ingredient
|
|
609
|
+
* ordering here must match what WASM iterates. See `filterActionsAt` and `filterIngredientsAt`.
|
|
610
|
+
*
|
|
611
|
+
* @param keep The action is retained when the predicate returns true.
|
|
612
|
+
*/
|
|
613
|
+
async filterActions(e) {
|
|
614
|
+
const t = await i(this, c).tx.builder_getDefinition(
|
|
615
|
+
i(this, f)
|
|
616
|
+
), _ = Y(t).reduce((o, s, a) => (e(s) && o.push(a), o), []);
|
|
617
|
+
await i(this, c).tx.builder_filterActionsAt(i(this, f), _);
|
|
618
|
+
}
|
|
619
|
+
/**
|
|
620
|
+
* Experimental.
|
|
621
|
+
* Retains ingredients, then rewrites positional ingredient references so linked actions
|
|
622
|
+
* stay valid.
|
|
623
|
+
*
|
|
624
|
+
* An ingredient is kept if it is referenced by a current action, is a `parentOf` ingredient,
|
|
625
|
+
* or `rescue` returns true for it. `rescue` therefore only ever rescues an otherwise-orphaned
|
|
626
|
+
* ingredient. It can never drop a referenced or lineage ingredient. Call
|
|
627
|
+
* {@link Builder.filterActions} first if you are also removing actions: the keep-set is
|
|
628
|
+
* computed from whatever actions currently remain.
|
|
629
|
+
*
|
|
630
|
+
* @param rescue Can rescue an otherwise-orphaned ingredient by returning true.
|
|
631
|
+
*/
|
|
632
|
+
async filterIngredients(e) {
|
|
633
|
+
const _ = ((await i(this, c).tx.builder_getDefinition(
|
|
634
|
+
i(this, f)
|
|
635
|
+
)).ingredients ?? []).reduce((o, s, a) => (e(s) && o.push(a), o), []);
|
|
636
|
+
await i(this, c).tx.builder_filterIngredientsAt(i(this, f), _);
|
|
637
|
+
}
|
|
638
|
+
/**
|
|
639
|
+
* Experimental.
|
|
640
|
+
* Retains actions and ingredients together in one step.
|
|
641
|
+
*
|
|
642
|
+
* `rescueIngredient` is evaluated for every ingredient first; any action referencing an
|
|
643
|
+
* ingredient it would rescue is force-kept regardless of `keepAction`.
|
|
644
|
+
*
|
|
645
|
+
* @param keepAction The action is retained when the predicate returns true.
|
|
646
|
+
* @param rescueIngredient Can rescue an otherwise-orphaned ingredient (and the action
|
|
647
|
+
* referencing it) by returning true.
|
|
648
|
+
*/
|
|
649
|
+
async filterActionsAndIngredients(e, t) {
|
|
650
|
+
const r = await i(this, c).tx.builder_getDefinition(
|
|
651
|
+
i(this, f)
|
|
652
|
+
), o = Y(r).reduce((u, d, h) => (e(d) && u.push(h), u), []), a = (r.ingredients ?? []).reduce(
|
|
653
|
+
(u, d, h) => (t(d) && u.push(h), u),
|
|
654
|
+
[]
|
|
655
|
+
);
|
|
656
|
+
await i(this, c).tx.builder_filterActionsAndIngredientsAt(
|
|
657
|
+
i(this, f),
|
|
658
|
+
o,
|
|
659
|
+
a
|
|
660
|
+
);
|
|
661
|
+
}
|
|
662
|
+
/**
|
|
663
|
+
* Replaces the actions in the `c2pa.actions`/`c2pa.actions.v2` assertions.
|
|
664
|
+
*
|
|
665
|
+
* A manifest can carry more than one actions assertion (the created-list and
|
|
666
|
+
* gathered-list entries are distinct assertions). `transform` is therefore
|
|
667
|
+
* invoked once per actions assertion, in positional order, with that
|
|
668
|
+
* assertion's own actions.
|
|
669
|
+
*
|
|
670
|
+
* A no-op if there is no actions assertion. Use `addAction` for those.
|
|
671
|
+
*
|
|
672
|
+
* The returned list is written back as is.
|
|
673
|
+
* `transform` can therefore produce an actions array that fails
|
|
674
|
+
* validation at signing time, for example by removing the inception action
|
|
675
|
+
* (`c2pa.created`/`c2pa.opened`) or moving it out of first position.
|
|
676
|
+
*
|
|
677
|
+
* @param transform Receives one assertion's actions and returns its full replacement list.
|
|
678
|
+
*/
|
|
679
|
+
async updateActions(e) {
|
|
680
|
+
const t = await i(this, c).tx.builder_getDefinition(
|
|
681
|
+
i(this, f)
|
|
682
|
+
), _ = Q(t).map((o) => e(o));
|
|
683
|
+
await i(this, c).tx.builder_updateActionsAt(i(this, f), _);
|
|
684
|
+
}
|
|
685
|
+
/**
|
|
686
|
+
* Add an ingredient to the builder from a definition only.
|
|
687
|
+
*
|
|
688
|
+
* @param ingredientDefinition {@link Ingredient} definition.
|
|
689
|
+
*/
|
|
690
|
+
async addIngredient(e) {
|
|
691
|
+
const t = JSON.stringify(e);
|
|
692
|
+
await i(this, c).tx.builder_addIngredient(i(this, f), t);
|
|
693
|
+
}
|
|
694
|
+
/**
|
|
695
|
+
* Add an ingredient to the builder from a definition, format, and blob.
|
|
696
|
+
* Values specified in the ingredient definition will be merged with the ingredient, and these values take precendence.
|
|
697
|
+
*
|
|
698
|
+
* @param ingredientDefinition {@link Ingredient} definition.
|
|
699
|
+
* @param format Format of the ingredient.
|
|
700
|
+
* @param blob Blob of the ingredient's bytes.
|
|
701
|
+
*/
|
|
702
|
+
async addIngredientFromBlob(e, t, r) {
|
|
703
|
+
const _ = JSON.stringify(e);
|
|
704
|
+
await i(this, c).tx.builder_addIngredientFromBlob(i(this, f), _, t, r);
|
|
705
|
+
}
|
|
706
|
+
/**
|
|
707
|
+
* Add a resource to the builder's resource store with an ID and blob of the resource's bytes.
|
|
708
|
+
*
|
|
709
|
+
* @param resourceId ID associated with the resource being added.
|
|
710
|
+
* @param blob Blob of the resource's bytes.
|
|
711
|
+
*/
|
|
712
|
+
async addResourceFromBlob(e, t) {
|
|
713
|
+
await i(this, c).tx.builder_addResourceFromBlob(i(this, f), e, t);
|
|
714
|
+
}
|
|
715
|
+
/**
|
|
716
|
+
* Gets the current manifest definition held by the builder.
|
|
717
|
+
*
|
|
718
|
+
* @returns The {@link ManifestDefinition} held by the builder.
|
|
719
|
+
*/
|
|
720
|
+
async getDefinition() {
|
|
721
|
+
return await i(this, c).tx.builder_getDefinition(i(this, f));
|
|
722
|
+
}
|
|
723
|
+
/**
|
|
724
|
+
* Save the builder into .c2pa format.
|
|
725
|
+
* This "archive" can be added to as an ingredient with {@link addIngredientFromBlob}
|
|
726
|
+
*
|
|
727
|
+
* @returns A builder archive in application/c2pa format.
|
|
728
|
+
*/
|
|
729
|
+
async toArchive() {
|
|
730
|
+
return await i(this, c).tx.builder_toArchive(i(this, f));
|
|
731
|
+
}
|
|
732
|
+
/**
|
|
733
|
+
* Sign an asset.
|
|
734
|
+
*
|
|
735
|
+
* @todo Docs coming soon
|
|
736
|
+
*/
|
|
737
|
+
async sign(e, t, r) {
|
|
738
|
+
const _ = await V(e), o = i(this, c).registerSignReceiver(e.sign);
|
|
739
|
+
return await i(this, c).tx.builder_sign(
|
|
740
|
+
i(this, f),
|
|
741
|
+
o,
|
|
742
|
+
_,
|
|
743
|
+
t,
|
|
744
|
+
r
|
|
745
|
+
);
|
|
746
|
+
}
|
|
747
|
+
/**
|
|
748
|
+
* Sign an asset and get both the signed asset bytes and the manifest bytes.
|
|
749
|
+
*
|
|
750
|
+
* @todo Docs coming soon
|
|
751
|
+
*/
|
|
752
|
+
async signAndGetManifestBytes(e, t, r) {
|
|
753
|
+
const _ = await V(e), o = i(this, c).registerSignReceiver(e.sign);
|
|
754
|
+
return await i(this, c).tx.builder_signAndGetManifestBytes(
|
|
755
|
+
i(this, f),
|
|
756
|
+
o,
|
|
757
|
+
_,
|
|
758
|
+
t,
|
|
759
|
+
r
|
|
760
|
+
);
|
|
761
|
+
}
|
|
762
|
+
/**
|
|
763
|
+
* Dispose of this Builder, freeing the memory it occupied and preventing further use. Call this whenever the Builder is no longer needed.
|
|
764
|
+
*/
|
|
765
|
+
async free() {
|
|
766
|
+
T.unregister(this), await i(this, c).tx.builder_free(i(this, f));
|
|
767
|
+
}
|
|
768
|
+
};
|
|
769
|
+
c = new WeakMap(), f = new WeakMap();
|
|
770
|
+
let E = F;
|
|
771
|
+
function Te(n, e = {}) {
|
|
772
|
+
return {
|
|
773
|
+
new: (t = {}) => E.new(n, new y(S(e, t))),
|
|
774
|
+
fromDefinition: (t, r = {}) => E.fromDefinition(
|
|
775
|
+
n,
|
|
776
|
+
t,
|
|
777
|
+
new y(S(e, r))
|
|
778
|
+
),
|
|
779
|
+
fromArchive: (t, r = {}) => E.fromArchive(
|
|
780
|
+
n,
|
|
781
|
+
t,
|
|
782
|
+
new y(S(e, r))
|
|
783
|
+
)
|
|
784
|
+
};
|
|
785
|
+
}
|
|
786
|
+
async function $e(n) {
|
|
787
|
+
const { wasmSrc: e, workerSrc: t, settings: r } = n, _ = typeof e == "string" ? await Me(e) : e, o = await _e({ wasm: _, workerSrc: t }), s = {
|
|
788
|
+
worker: o,
|
|
789
|
+
reader: void 0,
|
|
790
|
+
builder: void 0,
|
|
791
|
+
dispose: o.terminate
|
|
792
|
+
};
|
|
793
|
+
return s.reader = Ie(s, r), s.builder = Te(s, r), s;
|
|
794
|
+
}
|
|
795
|
+
async function Me(n) {
|
|
796
|
+
const e = await fetch(n, { integrity: ce });
|
|
797
|
+
return await WebAssembly.compileStreaming(e);
|
|
798
|
+
}
|
|
799
|
+
export {
|
|
800
|
+
Fe as A,
|
|
801
|
+
E as B,
|
|
802
|
+
y as C,
|
|
803
|
+
be as D,
|
|
804
|
+
M as R,
|
|
805
|
+
fe as a,
|
|
806
|
+
de as b,
|
|
807
|
+
ge as c,
|
|
808
|
+
le as d,
|
|
809
|
+
Ee as e,
|
|
810
|
+
Re as f,
|
|
811
|
+
$e as g,
|
|
812
|
+
Le as h,
|
|
813
|
+
Ne as i,
|
|
814
|
+
Je as j,
|
|
815
|
+
we as k,
|
|
816
|
+
W as l,
|
|
817
|
+
X as m,
|
|
818
|
+
ze as n,
|
|
819
|
+
S as o,
|
|
820
|
+
C as p,
|
|
821
|
+
z as q,
|
|
822
|
+
xe as r,
|
|
823
|
+
De as s,
|
|
824
|
+
N as v,
|
|
825
|
+
ve as w
|
|
826
|
+
};
|