@contentauth/c2pa-web 0.15.5 → 0.16.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 +4 -63
- package/dist/c2pa-CqMzdYCb.js +968 -0
- package/dist/c2pa_worker.js +154 -130
- package/dist/common.d.ts +2 -1
- package/dist/common.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +26 -24
- package/dist/inline.d.ts +1 -1
- package/dist/inline.d.ts.map +1 -1
- package/dist/inline.js +5 -4
- package/dist/lib/builder.d.ts +10 -0
- package/dist/lib/builder.d.ts.map +1 -1
- package/dist/lib/reader.d.ts +2 -2
- package/dist/lib/reader.d.ts.map +1 -1
- package/dist/lib/signer.d.ts +24 -0
- package/dist/lib/signer.d.ts.map +1 -1
- package/dist/lib/worker/rpc.d.ts +5 -1
- package/dist/lib/worker/rpc.d.ts.map +1 -1
- package/dist/resources/c2pa_bg.wasm +0 -0
- package/package.json +5 -5
- package/dist/c2pa-DX8BGA0J.js +0 -932
|
@@ -0,0 +1,968 @@
|
|
|
1
|
+
var se = Object.defineProperty;
|
|
2
|
+
var J = (n) => {
|
|
3
|
+
throw TypeError(n);
|
|
4
|
+
};
|
|
5
|
+
var oe = (n, e, t) => e in n ? se(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
|
|
6
|
+
var T = (n, e, t) => oe(n, typeof e != "symbol" ? e + "" : e, t), P = (n, e, t) => e.has(n) || J("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) ? J("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(n) : e.set(n, t), S = (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 Z, transfer as C } from "highgain";
|
|
9
|
+
const { createTx: _e, rx: De } = Z(), { createTx: Je, rx: ae } = Z("worker"), Q = '(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', $ = typeof self < "u" && self.Blob && new Blob([Q], { type: "text/javascript;charset=utf-8" });
|
|
10
|
+
function ce(n) {
|
|
11
|
+
let e;
|
|
12
|
+
try {
|
|
13
|
+
if (e = $ && (self.URL || self.webkitURL).createObjectURL($), !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(Q),
|
|
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 ue(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 fe(n) {
|
|
39
|
+
const { wasm: e, workerSrc: t } = n;
|
|
40
|
+
let r = 0;
|
|
41
|
+
const o = t ? new Worker(ue(t), { type: "module" }) : new ce(), s = _e(o), _ = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map();
|
|
42
|
+
ae(
|
|
43
|
+
{
|
|
44
|
+
sign: async (d, l, b) => {
|
|
45
|
+
const g = _.get(d);
|
|
46
|
+
if (_.delete(d), !g)
|
|
47
|
+
throw new Error("No signer registered for request");
|
|
48
|
+
const A = await g(l, b);
|
|
49
|
+
return C(A, A.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 (d, l) => {
|
|
57
|
+
const b = a.get(d);
|
|
58
|
+
if (a.delete(d), !b)
|
|
59
|
+
throw new Error("No credential holder registered for request");
|
|
60
|
+
const g = await b(l);
|
|
61
|
+
return C(g, g.buffer);
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
o
|
|
65
|
+
);
|
|
66
|
+
function f(d) {
|
|
67
|
+
const l = r++;
|
|
68
|
+
return _.set(l, d), l;
|
|
69
|
+
}
|
|
70
|
+
function m(d) {
|
|
71
|
+
const l = r++;
|
|
72
|
+
return a.set(l, d), l;
|
|
73
|
+
}
|
|
74
|
+
return await s.initWorker(e), {
|
|
75
|
+
tx: s,
|
|
76
|
+
registerSignReceiver: f,
|
|
77
|
+
registerCredentialHolderReceiver: m,
|
|
78
|
+
terminate: () => o.terminate()
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
typeof FinalizationRegistry > "u" || new FinalizationRegistry((n) => O.__wbg_wasmbuilder_free(n, 1));
|
|
82
|
+
typeof FinalizationRegistry > "u" || new FinalizationRegistry((n) => O.__wbg_wasmreader_free(n, 1));
|
|
83
|
+
typeof FinalizationRegistry > "u" || new FinalizationRegistry((n) => O.__wbg_wasmsigner_free(n, 1));
|
|
84
|
+
typeof FinalizationRegistry > "u" || new FinalizationRegistry((n) => O.__wbindgen_destroy_closure(n.a, n.b));
|
|
85
|
+
let de = new TextDecoder("utf-8", { ignoreBOM: !0, fatal: !0 });
|
|
86
|
+
de.decode();
|
|
87
|
+
const U = new TextEncoder();
|
|
88
|
+
"encodeInto" in U || (U.encodeInto = function(n, e) {
|
|
89
|
+
const t = U.encode(n);
|
|
90
|
+
return e.set(t), {
|
|
91
|
+
read: n.length,
|
|
92
|
+
written: t.length
|
|
93
|
+
};
|
|
94
|
+
});
|
|
95
|
+
let O;
|
|
96
|
+
const le = "sha512-8n+fD7p0Ub6oJZTuqCs9963t8zreMwliFGiAfr3DMETjZ4m8ai4kJmD2ITad/CvCUebhyB0IfHhFGn5OpY33dg==", F = (n) => {
|
|
97
|
+
if (typeof n == "object" && n !== null) {
|
|
98
|
+
if (typeof Object.getPrototypeOf == "function") {
|
|
99
|
+
const e = Object.getPrototypeOf(n);
|
|
100
|
+
return e === Object.prototype || e === null;
|
|
101
|
+
}
|
|
102
|
+
return Object.prototype.toString.call(n) === "[object Object]";
|
|
103
|
+
}
|
|
104
|
+
return !1;
|
|
105
|
+
}, be = /* @__PURE__ */ new Set([
|
|
106
|
+
"__proto__",
|
|
107
|
+
"constructor",
|
|
108
|
+
"prototype",
|
|
109
|
+
"toString",
|
|
110
|
+
"valueOf",
|
|
111
|
+
"hasOwnProperty",
|
|
112
|
+
"isPrototypeOf",
|
|
113
|
+
"propertyIsEnumerable",
|
|
114
|
+
"toLocaleString"
|
|
115
|
+
]), w = (...n) => n.reduce((e, t) => {
|
|
116
|
+
if (t === void 0)
|
|
117
|
+
return e;
|
|
118
|
+
if (Array.isArray(t))
|
|
119
|
+
throw new TypeError("Arguments provided to ts-deepmerge must be objects, not arrays.");
|
|
120
|
+
return Object.keys(t).forEach((r) => {
|
|
121
|
+
be.has(r) || (Array.isArray(e[r]) && Array.isArray(t[r]) ? e[r] = w.options.mergeArrays ? w.options.uniqueArrayItems ? Array.from(new Set(e[r].concat(t[r]))) : [...e[r], ...t[r]] : t[r] : F(e[r]) && F(t[r]) ? e[r] = w(e[r], t[r]) : !F(e[r]) && F(t[r]) ? e[r] = w(t[r], void 0) : e[r] = t[r] === void 0 ? w.options.allowUndefinedOverrides ? t[r] : e[r] : t[r]);
|
|
122
|
+
}), e;
|
|
123
|
+
}, {}), z = {
|
|
124
|
+
allowUndefinedOverrides: !0,
|
|
125
|
+
mergeArrays: !0,
|
|
126
|
+
uniqueArrayItems: !0
|
|
127
|
+
};
|
|
128
|
+
w.options = z;
|
|
129
|
+
w.withOptions = (n, ...e) => {
|
|
130
|
+
w.options = Object.assign(Object.assign({}, z), n);
|
|
131
|
+
const t = w(...e);
|
|
132
|
+
return w.options = z, t;
|
|
133
|
+
};
|
|
134
|
+
const ge = 1 * 1024 * 1024, we = 2, me = 200, he = 2e3, ye = 3e4;
|
|
135
|
+
function pe(n) {
|
|
136
|
+
return n === 429 || n >= 500;
|
|
137
|
+
}
|
|
138
|
+
function Ae(n) {
|
|
139
|
+
return n instanceof Error && n.name === "AbortError";
|
|
140
|
+
}
|
|
141
|
+
function Re(n, e, t) {
|
|
142
|
+
const r = Math.min(e * 2 ** n, t), o = Math.floor(Math.random() * 200);
|
|
143
|
+
return Math.min(r + o, t);
|
|
144
|
+
}
|
|
145
|
+
function ve(n) {
|
|
146
|
+
if (!n)
|
|
147
|
+
return null;
|
|
148
|
+
const e = Number(n);
|
|
149
|
+
if (!Number.isNaN(e))
|
|
150
|
+
return e * 1e3;
|
|
151
|
+
const t = Date.parse(n);
|
|
152
|
+
return Number.isNaN(t) ? null : t - Date.now();
|
|
153
|
+
}
|
|
154
|
+
function Se(n) {
|
|
155
|
+
try {
|
|
156
|
+
new URL(n);
|
|
157
|
+
} catch {
|
|
158
|
+
throw new Error(`Invalid URL: ${n}`);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
async function ee(n, e, t) {
|
|
162
|
+
Se(n);
|
|
163
|
+
const r = (t == null ? void 0 : t.maxRetries) ?? we, o = (t == null ? void 0 : t.initialRetryDelayMs) ?? me, s = (t == null ? void 0 : t.maxRetryDelayMs) ?? he, _ = (t == null ? void 0 : t.maxRetryAfterMs) ?? ye, a = (t == null ? void 0 : t.isRetryableStatus) ?? pe, f = (t == null ? void 0 : t.isRetryableError) ?? (() => !0), m = (t == null ? void 0 : t.fetch) ?? fetch, d = (l) => Re(l, o, s);
|
|
164
|
+
for (let l = 0; ; l++) {
|
|
165
|
+
let b;
|
|
166
|
+
try {
|
|
167
|
+
b = await m(n, e);
|
|
168
|
+
} catch (g) {
|
|
169
|
+
if (!Ae(g) && f(g) && l < r) {
|
|
170
|
+
await new Promise((R) => setTimeout(R, d(l)));
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
const A = g instanceof Error ? g.message : String(g);
|
|
174
|
+
throw new Error(`Network error fetching ${n}: ${A}`, {
|
|
175
|
+
cause: g
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
if (!b.ok) {
|
|
179
|
+
if (a(b.status)) {
|
|
180
|
+
const A = ve(b.headers.get("retry-after"));
|
|
181
|
+
if (A !== null) {
|
|
182
|
+
if (A > _)
|
|
183
|
+
throw new Error(`Failed to fetch ${n}: server requested a Retry-After delay of ${Math.ceil(A / 1e3)}s, which exceeds the maximum allowed delay of ${_ / 1e3}s`);
|
|
184
|
+
if (l < r) {
|
|
185
|
+
await new Promise((R) => setTimeout(R, Math.max(A, 0)));
|
|
186
|
+
continue;
|
|
187
|
+
}
|
|
188
|
+
throw new Error(`Failed to fetch ${n}: ${b.status} ${b.statusText}`);
|
|
189
|
+
}
|
|
190
|
+
if (l < r) {
|
|
191
|
+
await new Promise((R) => setTimeout(R, d(l)));
|
|
192
|
+
continue;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
throw new Error(`Failed to fetch ${n}: ${b.status} ${b.statusText}`);
|
|
196
|
+
}
|
|
197
|
+
return b;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
async function k(n, e) {
|
|
201
|
+
const t = (e == null ? void 0 : e.maxResponseBytes) ?? ge, r = await ee(n, void 0, e), o = r.headers.get("content-length");
|
|
202
|
+
if (o !== null && Number(o) > t)
|
|
203
|
+
throw new Error(`Response from ${n} is too large. Max size is ${t} bytes.`);
|
|
204
|
+
const s = await r.text();
|
|
205
|
+
if (s.length > t)
|
|
206
|
+
throw new Error(`Response from ${n} is too large. Max size is ${t} bytes.`);
|
|
207
|
+
return s;
|
|
208
|
+
}
|
|
209
|
+
function D(n) {
|
|
210
|
+
return Object.entries(n).reduce((t, [r, o]) => (t[xe(r)] = te(o), t), {});
|
|
211
|
+
}
|
|
212
|
+
function te(n) {
|
|
213
|
+
return Array.isArray(n) ? n.map(te) : typeof n == "object" && n !== null ? D(n) : n;
|
|
214
|
+
}
|
|
215
|
+
function xe(n) {
|
|
216
|
+
return n.replace(/[A-Z]/g, (e) => `_${e.toLowerCase()}`);
|
|
217
|
+
}
|
|
218
|
+
const Ie = Object.freeze({
|
|
219
|
+
builder: Object.freeze({
|
|
220
|
+
generateC2paArchive: !0
|
|
221
|
+
})
|
|
222
|
+
});
|
|
223
|
+
function Ee(n) {
|
|
224
|
+
return w(Ie, n ?? {});
|
|
225
|
+
}
|
|
226
|
+
async function Te(n, e) {
|
|
227
|
+
const t = Ee(n), r = [];
|
|
228
|
+
return t.trust && r.push(q(t.trust, e)), t.cawgTrust && r.push(q(t.cawgTrust, e)), await Promise.all(r), JSON.stringify(D(ne(t)));
|
|
229
|
+
}
|
|
230
|
+
function ne(n) {
|
|
231
|
+
const { trust: e, cawgTrust: t, ...r } = n, o = [
|
|
232
|
+
...W(e, "manifest"),
|
|
233
|
+
...W(t, "cawg")
|
|
234
|
+
], s = r;
|
|
235
|
+
return (o.length > 0 || e != null && e.trustConfig) && (s.trust = {
|
|
236
|
+
...o.length > 0 ? { anchors: o } : {},
|
|
237
|
+
...e != null && e.trustConfig ? { trustConfig: e.trustConfig } : {}
|
|
238
|
+
}), s;
|
|
239
|
+
}
|
|
240
|
+
function W(n, e) {
|
|
241
|
+
if (!n || n.verifyTrustList === !1)
|
|
242
|
+
return [];
|
|
243
|
+
const t = n.trustConfig, r = n.allowedList, o = [];
|
|
244
|
+
return n.userAnchors && o.push({
|
|
245
|
+
trustAnchors: n.userAnchors,
|
|
246
|
+
trustUri: `${e}_user_anchors`,
|
|
247
|
+
trustKind: e,
|
|
248
|
+
...t ? { trustConfig: t } : {},
|
|
249
|
+
...r ? { allowedList: r } : {}
|
|
250
|
+
}), n.trustAnchors && o.push({
|
|
251
|
+
trustAnchors: n.trustAnchors,
|
|
252
|
+
trustUri: `${e}_system_anchors`,
|
|
253
|
+
trustKind: e,
|
|
254
|
+
...t ? { trustConfig: t } : {},
|
|
255
|
+
...r ? { allowedList: r } : {}
|
|
256
|
+
}), o;
|
|
257
|
+
}
|
|
258
|
+
function Pe(n) {
|
|
259
|
+
return { trust: { ...n } };
|
|
260
|
+
}
|
|
261
|
+
function Ce(n) {
|
|
262
|
+
return { cawgTrust: { ...n } };
|
|
263
|
+
}
|
|
264
|
+
function $e(n) {
|
|
265
|
+
return { verify: { ...n } };
|
|
266
|
+
}
|
|
267
|
+
function x(...n) {
|
|
268
|
+
return w(...n);
|
|
269
|
+
}
|
|
270
|
+
function ke(n) {
|
|
271
|
+
return JSON.stringify(D(ne(n)));
|
|
272
|
+
}
|
|
273
|
+
async function We(n, e) {
|
|
274
|
+
return await (await ee(n, void 0, e)).text();
|
|
275
|
+
}
|
|
276
|
+
const Fe = [
|
|
277
|
+
"userAnchors",
|
|
278
|
+
"trustAnchors",
|
|
279
|
+
"trustConfig",
|
|
280
|
+
"allowedList"
|
|
281
|
+
];
|
|
282
|
+
async function q(n, e) {
|
|
283
|
+
const t = (s) => ["userAnchors", "trustAnchors"].includes(s), r = (s) => s.includes("-----BEGIN CERTIFICATE-----"), o = (s) => s.startsWith("http");
|
|
284
|
+
try {
|
|
285
|
+
const s = Object.entries(n).filter(([_]) => Fe.includes(_)).map(async ([_, a]) => {
|
|
286
|
+
if (a && typeof a == "object" && Array.isArray(a)) {
|
|
287
|
+
const f = a.map(async (l) => {
|
|
288
|
+
if (typeof l != "string")
|
|
289
|
+
throw new Error("Expected a string value for array item");
|
|
290
|
+
const b = await k(l, e);
|
|
291
|
+
if (t(_) && !r(b))
|
|
292
|
+
throw new Error(`Error parsing PEM file at: ${l}`);
|
|
293
|
+
return b;
|
|
294
|
+
}), d = (await Promise.all(f)).join("");
|
|
295
|
+
n[_] = d;
|
|
296
|
+
} else if (a && typeof a == "string" && o(a)) {
|
|
297
|
+
const f = await k(a, e);
|
|
298
|
+
if (t(_) && !r(f))
|
|
299
|
+
throw new Error(`Error parsing PEM file at: ${a}`);
|
|
300
|
+
n[_] = f;
|
|
301
|
+
} else
|
|
302
|
+
return a;
|
|
303
|
+
});
|
|
304
|
+
await Promise.all(s);
|
|
305
|
+
} catch (s) {
|
|
306
|
+
const _ = s instanceof Error ? s.message : String(s);
|
|
307
|
+
throw new Error(`Failed to resolve trust settings. ${_}`, {
|
|
308
|
+
cause: s
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
class p {
|
|
313
|
+
constructor(e, t) {
|
|
314
|
+
T(this, "_settings");
|
|
315
|
+
T(this, "_sdkConfig");
|
|
316
|
+
T(this, "_jsonPromise");
|
|
317
|
+
this._settings = e, this._sdkConfig = t;
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* The SDK config currently attached to this `Context`, if any.
|
|
321
|
+
*
|
|
322
|
+
* To derive a new `Context` with a different SDK config, construct one with
|
|
323
|
+
* `new Context(settings, sdkConfig)`.
|
|
324
|
+
*/
|
|
325
|
+
get sdkConfig() {
|
|
326
|
+
return this._sdkConfig;
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* The settings currently attached to this `Context`, if any.
|
|
330
|
+
*
|
|
331
|
+
* To derive a new `Context` with different settings, construct one with `new Context(settings)`.
|
|
332
|
+
* To combine this `Context`'s settings with more settings, merge them with {@link mergeSettings}
|
|
333
|
+
* first and pass the single, merged result to the constructor.
|
|
334
|
+
*/
|
|
335
|
+
get settings() {
|
|
336
|
+
return this._settings;
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* Resolves this `Context`'s settings (fetching any embedded trust-anchor URLs) and serializes
|
|
340
|
+
* the result for consumption by the WASM/native boundary. A successful result is memoized, so
|
|
341
|
+
* resolution of this Context's settings only happens once. If different fetch-with-retry
|
|
342
|
+
* options need to be provided, callers should create a separate `Context` and then call
|
|
343
|
+
* `toJson()` with the desired options.
|
|
344
|
+
*
|
|
345
|
+
* A failed resolution is not memoized: the next call to `toJson()` tries again from scratch,
|
|
346
|
+
* so a transient failure (e.g. a network error while fetching a trust-anchor URL) doesn't
|
|
347
|
+
* permanently break this `Context`.
|
|
348
|
+
*
|
|
349
|
+
* @param options Optional configurations for fetch-with-retry, used when resolving trust-anchor
|
|
350
|
+
* URLs. Only consulted on the first call, or the first call after a previous failure.
|
|
351
|
+
* @returns A JSON-serialized string of the resolved settings.
|
|
352
|
+
*/
|
|
353
|
+
toJson(e) {
|
|
354
|
+
return this._jsonPromise ?? (this._jsonPromise = Te(this.settings, e).catch((t) => {
|
|
355
|
+
throw this._jsonPromise = void 0, t;
|
|
356
|
+
})), this._jsonPromise;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
const Me = 10 ** 9;
|
|
360
|
+
function re(n) {
|
|
361
|
+
return Number.isFinite(n) && n > 0 ? n : Me;
|
|
362
|
+
}
|
|
363
|
+
function V(n, e) {
|
|
364
|
+
const t = (n == null ? void 0 : n.maxSizeInBytes) ?? e;
|
|
365
|
+
if (!Number.isFinite(t) || t <= 0)
|
|
366
|
+
throw new RangeError(`maxSizeInBytes must be a finite, positive number. Received: ${t}.`);
|
|
367
|
+
return t;
|
|
368
|
+
}
|
|
369
|
+
class Be extends Error {
|
|
370
|
+
/**
|
|
371
|
+
* @param sizeInBytes Size of the asset, in bytes.
|
|
372
|
+
* @param maxSizeInBytes Maximum allowed size, in bytes. `0` (or any other
|
|
373
|
+
* non-finite/negative value) resolves to {@link DEFAULT_MAX_SIZE_IN_BYTES}.
|
|
374
|
+
*/
|
|
375
|
+
constructor(e, t) {
|
|
376
|
+
const r = re(t);
|
|
377
|
+
super(`The provided asset was too large. Size: ${e} bytes. Maximum: ${r}.`), this.name = "AssetTooLargeError";
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
function N(n, e) {
|
|
381
|
+
if (!Number.isFinite(n) || n < 0)
|
|
382
|
+
throw new RangeError(`sizeInBytes must be a finite, non-negative number. Received: ${n}.`);
|
|
383
|
+
if (!Number.isFinite(e) || e < 0)
|
|
384
|
+
throw new RangeError(`maxSizeInBytes must be a finite, non-negative number. Received: ${e}.`);
|
|
385
|
+
const t = re(e);
|
|
386
|
+
if (n > t)
|
|
387
|
+
throw new Be(n, t);
|
|
388
|
+
}
|
|
389
|
+
const G = 10 ** 9, L = new FinalizationRegistry(
|
|
390
|
+
async ({ worker: n, id: e }) => {
|
|
391
|
+
await n.tx.reader_free(e);
|
|
392
|
+
}
|
|
393
|
+
);
|
|
394
|
+
var h, y;
|
|
395
|
+
const j = class j {
|
|
396
|
+
constructor(e, t) {
|
|
397
|
+
v(this, h);
|
|
398
|
+
v(this, y);
|
|
399
|
+
S(this, h, e), S(this, y, t);
|
|
400
|
+
}
|
|
401
|
+
/**
|
|
402
|
+
* Create a {@link Reader} from an asset's format and a blob of its bytes.
|
|
403
|
+
*
|
|
404
|
+
* @param c2pa The `C2pa` instance (from {@link createC2pa}) to create this reader on.
|
|
405
|
+
* @param format Asset format (MIME type or extension), typically `blob.type`. If omitted
|
|
406
|
+
* or empty, the native library will attempt to detect the format from the asset's bytes instead.
|
|
407
|
+
* Always provide the format if known, and only omit this when the caller has no way to determine
|
|
408
|
+
* the asset's format otherwise.
|
|
409
|
+
* @param blob Blob of asset bytes.
|
|
410
|
+
* @param context Optional `Context` configuring this reader's behavior.
|
|
411
|
+
* @returns A {@link Reader} object or null if no C2PA metadata was found.
|
|
412
|
+
* @throws If the asset is too large, or if the `Context` sets an invalid `maxSizeInBytes`.
|
|
413
|
+
*/
|
|
414
|
+
static async fromBlob(e, t, r, o = new p()) {
|
|
415
|
+
N(
|
|
416
|
+
r.size,
|
|
417
|
+
V(o.sdkConfig, G)
|
|
418
|
+
);
|
|
419
|
+
try {
|
|
420
|
+
const s = await o.toJson(), { worker: _ } = e, a = await _.tx.reader_fromBlob(t ?? "", r, s), f = new j(_, a);
|
|
421
|
+
return L.register(f, { worker: _, id: a }, f), f;
|
|
422
|
+
} catch (s) {
|
|
423
|
+
return Y(s);
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
/**
|
|
427
|
+
* Create a {@link Reader} from an initial fragment and a subsequent fragment.
|
|
428
|
+
*
|
|
429
|
+
* @param c2pa The `C2pa` instance (from {@link createC2pa}) to create this reader on.
|
|
430
|
+
* @param format Asset format (MIME type or extension). Unlike {@link fromBlob}, fragmented
|
|
431
|
+
* assets cannot be auto-detected from their bytes, so a format must be supplied.
|
|
432
|
+
* @param init Blob of initial fragment bytes.
|
|
433
|
+
* @param fragment Blob of fragment bytes.
|
|
434
|
+
* @param context Optional `Context` configuring this reader's behavior.
|
|
435
|
+
* @returns A {@link Reader} object or null if no C2PA metadata was found.
|
|
436
|
+
* @throws If the asset is too large, or if the `Context` sets an invalid `maxSizeInBytes`.
|
|
437
|
+
*/
|
|
438
|
+
static async fromBlobFragment(e, t, r, o, s = new p()) {
|
|
439
|
+
const _ = V(
|
|
440
|
+
s.sdkConfig,
|
|
441
|
+
G
|
|
442
|
+
);
|
|
443
|
+
N(r.size, _), N(o.size, _);
|
|
444
|
+
try {
|
|
445
|
+
const a = await s.toJson(), { worker: f } = e, m = await f.tx.reader_fromBlobFragment(
|
|
446
|
+
t,
|
|
447
|
+
r,
|
|
448
|
+
o,
|
|
449
|
+
a
|
|
450
|
+
), d = new j(f, m);
|
|
451
|
+
return L.register(d, { worker: f, id: m }, d), d;
|
|
452
|
+
} catch (a) {
|
|
453
|
+
return Y(a);
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
/**
|
|
457
|
+
* @returns The label of the active manifest.
|
|
458
|
+
*/
|
|
459
|
+
async activeLabel() {
|
|
460
|
+
return await i(this, h).tx.reader_activeLabel(i(this, y));
|
|
461
|
+
}
|
|
462
|
+
/**
|
|
463
|
+
* @returns The asset's full {@link ManifestStore} containing all its manifests, validation statuses, and the URI of the active manifest.
|
|
464
|
+
*/
|
|
465
|
+
async manifestStore() {
|
|
466
|
+
return await i(this, h).tx.reader_manifestStore(i(this, y));
|
|
467
|
+
}
|
|
468
|
+
/**
|
|
469
|
+
* @returns The asset's active {@link Manifest}.
|
|
470
|
+
*/
|
|
471
|
+
async activeManifest() {
|
|
472
|
+
return await i(this, h).tx.reader_activeManifest(i(this, y));
|
|
473
|
+
}
|
|
474
|
+
/**
|
|
475
|
+
* @returns The asset's full {@link ManifestStore}.
|
|
476
|
+
*
|
|
477
|
+
* @deprecated Use {@link manifestStore} instead.
|
|
478
|
+
*/
|
|
479
|
+
async json() {
|
|
480
|
+
const e = await i(this, h).tx.reader_json(i(this, y));
|
|
481
|
+
return JSON.parse(e);
|
|
482
|
+
}
|
|
483
|
+
/**
|
|
484
|
+
* @returns The asset's manifest store as crJSON.
|
|
485
|
+
*/
|
|
486
|
+
async crJson() {
|
|
487
|
+
const e = await i(this, h).tx.reader_crJson(i(this, y));
|
|
488
|
+
return JSON.parse(e);
|
|
489
|
+
}
|
|
490
|
+
/**
|
|
491
|
+
* Resolves a URI reference to a binary object (e.g. a thumbnail) in the resource store.
|
|
492
|
+
*
|
|
493
|
+
* @param uri URI of the binary object to resolve.
|
|
494
|
+
* @returns A Uint8Array of the resource's bytes.
|
|
495
|
+
*
|
|
496
|
+
* @example Retrieving a thumbnail from the resource store:
|
|
497
|
+
* ```
|
|
498
|
+
* const reader = await Reader.fromBlob(c2pa, blob.type, blob);
|
|
499
|
+
* const activeManifest = await reader.activeManifest();
|
|
500
|
+
* const thumbnailBuffer = await reader.resourceToBytes(activeManifest.thumbnail!.identifier);
|
|
501
|
+
* ```
|
|
502
|
+
*/
|
|
503
|
+
async resourceToBytes(e) {
|
|
504
|
+
return await i(this, h).tx.reader_resourceToBytes(i(this, y), e);
|
|
505
|
+
}
|
|
506
|
+
/**
|
|
507
|
+
* Dispose of this Reader, freeing the memory it occupied and preventing further use.
|
|
508
|
+
* Call this whenever the Reader is no longer needed.
|
|
509
|
+
*/
|
|
510
|
+
async free() {
|
|
511
|
+
L.unregister(this), await i(this, h).tx.reader_free(i(this, y));
|
|
512
|
+
}
|
|
513
|
+
};
|
|
514
|
+
h = new WeakMap(), y = new WeakMap();
|
|
515
|
+
let B = j;
|
|
516
|
+
function je(n, e = {}) {
|
|
517
|
+
return {
|
|
518
|
+
fromBlob: (t, r, o = {}) => B.fromBlob(
|
|
519
|
+
n,
|
|
520
|
+
t,
|
|
521
|
+
r,
|
|
522
|
+
new p(x(e, o))
|
|
523
|
+
),
|
|
524
|
+
fromBlobFragment: (t, r, o, s = {}) => B.fromBlobFragment(
|
|
525
|
+
n,
|
|
526
|
+
t,
|
|
527
|
+
r,
|
|
528
|
+
o,
|
|
529
|
+
new p(x(e, s))
|
|
530
|
+
)
|
|
531
|
+
};
|
|
532
|
+
}
|
|
533
|
+
function Y(n) {
|
|
534
|
+
if (n instanceof Error && n.message === "C2pa(JumbfNotFound)")
|
|
535
|
+
return null;
|
|
536
|
+
throw n;
|
|
537
|
+
}
|
|
538
|
+
async function H(n) {
|
|
539
|
+
const { alg: e } = n;
|
|
540
|
+
return {
|
|
541
|
+
reserveSize: await n.reserveSize(),
|
|
542
|
+
alg: e
|
|
543
|
+
};
|
|
544
|
+
}
|
|
545
|
+
async function qe(n, e) {
|
|
546
|
+
return n.worker.tx.encodeSignerPayload(e);
|
|
547
|
+
}
|
|
548
|
+
function Oe(n, e) {
|
|
549
|
+
const { credentialHolder: t, referencedAssertions: r, roles: o } = n;
|
|
550
|
+
return {
|
|
551
|
+
requestId: e,
|
|
552
|
+
sigType: t.sigType,
|
|
553
|
+
reserveSize: t.reserveSize,
|
|
554
|
+
referencedAssertions: r ?? [],
|
|
555
|
+
roles: o ?? []
|
|
556
|
+
};
|
|
557
|
+
}
|
|
558
|
+
function X(n) {
|
|
559
|
+
return ie(n).flat();
|
|
560
|
+
}
|
|
561
|
+
function ie(n) {
|
|
562
|
+
return (n.assertions ?? []).filter((e) => e.label.startsWith("c2pa.actions")).map((e) => {
|
|
563
|
+
const t = e.data;
|
|
564
|
+
return (t == null ? void 0 : t.actions) ?? [];
|
|
565
|
+
});
|
|
566
|
+
}
|
|
567
|
+
function K(n, e) {
|
|
568
|
+
const t = (e == null ? void 0 : e.identityAssertions) ?? [];
|
|
569
|
+
if (t.length > 1)
|
|
570
|
+
throw new Error(
|
|
571
|
+
"Only one identity assertion is currently supported per signing operation."
|
|
572
|
+
);
|
|
573
|
+
return t.map((r) => {
|
|
574
|
+
const o = n.registerCredentialHolderReceiver(
|
|
575
|
+
r.credentialHolder.sign
|
|
576
|
+
);
|
|
577
|
+
return Oe(r, o);
|
|
578
|
+
});
|
|
579
|
+
}
|
|
580
|
+
const M = new FinalizationRegistry(
|
|
581
|
+
({ worker: n, id: e }) => {
|
|
582
|
+
n.tx.builder_free(e);
|
|
583
|
+
}
|
|
584
|
+
);
|
|
585
|
+
var c, u;
|
|
586
|
+
const E = class E {
|
|
587
|
+
constructor(e, t) {
|
|
588
|
+
v(this, c);
|
|
589
|
+
v(this, u);
|
|
590
|
+
S(this, c, e), S(this, u, t);
|
|
591
|
+
}
|
|
592
|
+
/**
|
|
593
|
+
* Create a {@link Builder} with a minimal manifest definition as its initial state.
|
|
594
|
+
*
|
|
595
|
+
* @param c2pa The `C2pa` instance (from {@link createC2pa}) to create this builder on.
|
|
596
|
+
* @param context Optional `Context` configuring this builder's behavior.
|
|
597
|
+
* @returns A {@link Builder} object.
|
|
598
|
+
*/
|
|
599
|
+
static async new(e, t = new p()) {
|
|
600
|
+
const r = await t.toJson(), { worker: o } = e, s = await o.tx.builder_new(r), _ = new E(o, s);
|
|
601
|
+
return M.register(_, { worker: o, id: s }, _), _;
|
|
602
|
+
}
|
|
603
|
+
/**
|
|
604
|
+
* Create a {@link Builder} from a {@link ManifestDefinition}.
|
|
605
|
+
*
|
|
606
|
+
* @param c2pa The `C2pa` instance (from {@link createC2pa}) to create this builder on.
|
|
607
|
+
* @param definition The {@link ManifestDefinition} to be used as the builder's initial state.
|
|
608
|
+
* @param context Optional `Context` configuring this builder's behavior.
|
|
609
|
+
* @returns A {@link Builder} object.
|
|
610
|
+
*/
|
|
611
|
+
static async fromDefinition(e, t, r = new p()) {
|
|
612
|
+
const o = JSON.stringify(t), s = await r.toJson(), { worker: _ } = e, a = await _.tx.builder_fromJson(o, s), f = new E(_, a);
|
|
613
|
+
return M.register(f, { worker: _, id: a }, f), f;
|
|
614
|
+
}
|
|
615
|
+
/**
|
|
616
|
+
* Create a {@link Builder} from a builder archive (created from {@link Builder.toArchive}).
|
|
617
|
+
*
|
|
618
|
+
* @param c2pa The `C2pa` instance (from {@link createC2pa}) to create this builder on.
|
|
619
|
+
* @param archive Builder archive as a blob.
|
|
620
|
+
* @param context Optional `Context` configuring this builder's behavior.
|
|
621
|
+
* @returns A {@link Builder} object.
|
|
622
|
+
*/
|
|
623
|
+
static async fromArchive(e, t, r = new p()) {
|
|
624
|
+
const o = await r.toJson(), { worker: s } = e, _ = await s.tx.builder_fromArchive(t, o), a = new E(s, _);
|
|
625
|
+
return M.register(a, { worker: s, id: _ }, a), a;
|
|
626
|
+
}
|
|
627
|
+
/**
|
|
628
|
+
* Sets the builder "intent."
|
|
629
|
+
*
|
|
630
|
+
* @todo Additional documentation coming soon.
|
|
631
|
+
*
|
|
632
|
+
* @param intent
|
|
633
|
+
*/
|
|
634
|
+
async setIntent(e) {
|
|
635
|
+
await i(this, c).tx.builder_setIntent(i(this, u), e);
|
|
636
|
+
}
|
|
637
|
+
/**
|
|
638
|
+
* Add an action to the manifest's actions assertion.
|
|
639
|
+
*
|
|
640
|
+
* @param action Object representing the action to be added.
|
|
641
|
+
*/
|
|
642
|
+
async addAction(e) {
|
|
643
|
+
await i(this, c).tx.builder_addAction(i(this, u), e);
|
|
644
|
+
}
|
|
645
|
+
/**
|
|
646
|
+
* Add an assertion to the manifest under the given label.
|
|
647
|
+
*
|
|
648
|
+
* @param label The assertion label (reverse-domain format).
|
|
649
|
+
* @param data The assertion data (any JSON-serializable value).
|
|
650
|
+
*/
|
|
651
|
+
async addAssertion(e, t) {
|
|
652
|
+
await i(this, c).tx.builder_addAssertion(i(this, u), e, t);
|
|
653
|
+
}
|
|
654
|
+
/**
|
|
655
|
+
* Replaces the data of every assertion with an exact matching label.
|
|
656
|
+
* `transform` runs once per matching assertion in manifest order. Other assertion
|
|
657
|
+
* fields and positions are preserved. A missing label is a no-op.
|
|
658
|
+
* Returning null or undefined leaves that assertion unchanged.
|
|
659
|
+
* The replacement data must be JSON-serializable and may fail validation at signing time.
|
|
660
|
+
*
|
|
661
|
+
* @param label The exact assertion label to update.
|
|
662
|
+
* @param transform Receives the current data and returns its replacement.
|
|
663
|
+
*/
|
|
664
|
+
async updateAssertion(e, t) {
|
|
665
|
+
const o = ((await this.getDefinition()).assertions ?? []).filter((s) => s.label === e).map((s) => t(s.data) ?? s.data);
|
|
666
|
+
await i(this, c).tx.builder_updateAssertionsAt(i(this, u), e, o);
|
|
667
|
+
}
|
|
668
|
+
/**
|
|
669
|
+
* Redact an assertion from an ingredient manifest.
|
|
670
|
+
*
|
|
671
|
+
* Adds the URI to the builder's redaction list and appends a `c2pa.redacted` action
|
|
672
|
+
* with the given reason, as required by the C2PA spec.
|
|
673
|
+
*
|
|
674
|
+
* @param uri JUMBF URI of the assertion to redact.
|
|
675
|
+
* @param reason The {@link C2paReason} for the redaction.
|
|
676
|
+
*/
|
|
677
|
+
async addRedaction(e, t) {
|
|
678
|
+
await i(this, c).tx.builder_addRedaction(i(this, u), e, t);
|
|
679
|
+
}
|
|
680
|
+
/**
|
|
681
|
+
* Sets the remote URL for a remote manifest. The manifest is expected to be available at this location.
|
|
682
|
+
*
|
|
683
|
+
* @param url URL pointing to the location the remote manifest will be stored.
|
|
684
|
+
*/
|
|
685
|
+
async setRemoteUrl(e) {
|
|
686
|
+
await i(this, c).tx.builder_setRemoteUrl(i(this, u), e);
|
|
687
|
+
}
|
|
688
|
+
/**
|
|
689
|
+
* Sets the state of the no_embed flag.
|
|
690
|
+
* To skip embedding a manifest (e.g. for the remote-only case), set this to `true`.
|
|
691
|
+
*
|
|
692
|
+
* @param noEmbed Value to set the no_embed flag.
|
|
693
|
+
*/
|
|
694
|
+
async setNoEmbed(e) {
|
|
695
|
+
await i(this, c).tx.builder_setNoEmbed(i(this, u), e);
|
|
696
|
+
}
|
|
697
|
+
/**
|
|
698
|
+
* Updates a (known) property in the manifest definition.
|
|
699
|
+
* Rejects an unsupported property or value type,
|
|
700
|
+
* or while a sign on this builder is pending.
|
|
701
|
+
*/
|
|
702
|
+
async updateManifestProperty(e, t) {
|
|
703
|
+
await i(this, c).tx.builder_updateManifestProperty(i(this, u), e, t);
|
|
704
|
+
}
|
|
705
|
+
/**
|
|
706
|
+
* Set a thumbnail from a blob to be included in the manifest. The blob should represent the asset being signed.
|
|
707
|
+
*
|
|
708
|
+
* @param format Format of the thumbnail
|
|
709
|
+
* @param blob Blob of the thumbnail bytes
|
|
710
|
+
*/
|
|
711
|
+
async setThumbnailFromBlob(e, t) {
|
|
712
|
+
await i(this, c).tx.builder_setThumbnailFromBlob(i(this, u), e, t);
|
|
713
|
+
}
|
|
714
|
+
/**
|
|
715
|
+
* Experimental.
|
|
716
|
+
* Retains only the actions for which `keep` returns true.
|
|
717
|
+
*
|
|
718
|
+
* The inception action, `c2pa.created` or `c2pa.opened`, is always kept regardless of `keep`,
|
|
719
|
+
* and is moved to index 0 if needed, so the manifest stays valid per the C2PA spec. Sets
|
|
720
|
+
* `allActionsIncluded = false` when anything is removed. This does not touch ingredients.
|
|
721
|
+
* Call {@link Builder.filterIngredients}, using `filterIngredients(() => false)` to drop all
|
|
722
|
+
* orphans, afterwards if you also want to drop ingredients now orphaned by the removed
|
|
723
|
+
* actions.
|
|
724
|
+
*
|
|
725
|
+
* Unlike the Node binding, Neon, which can invoke the JS predicate synchronously from Rust,
|
|
726
|
+
* the WASM builder lives in a Web Worker. A predicate closure can't be called across the
|
|
727
|
+
* worker boundary, so we evaluate it here on the main thread and send the resulting indices
|
|
728
|
+
* to the worker, where WASM applies the equivalent index-based filter. The action/ingredient
|
|
729
|
+
* ordering here must match what WASM iterates. See `filterActionsAt` and `filterIngredientsAt`.
|
|
730
|
+
*
|
|
731
|
+
* @param keep The action is retained when the predicate returns true.
|
|
732
|
+
*/
|
|
733
|
+
async filterActions(e) {
|
|
734
|
+
const t = await i(this, c).tx.builder_getDefinition(
|
|
735
|
+
i(this, u)
|
|
736
|
+
), o = X(t).reduce((s, _, a) => (e(_) && s.push(a), s), []);
|
|
737
|
+
await i(this, c).tx.builder_filterActionsAt(i(this, u), o);
|
|
738
|
+
}
|
|
739
|
+
/**
|
|
740
|
+
* Experimental.
|
|
741
|
+
* Retains ingredients, then rewrites positional ingredient references so linked actions
|
|
742
|
+
* stay valid.
|
|
743
|
+
*
|
|
744
|
+
* An ingredient is kept if it is referenced by a current action, is a `parentOf` ingredient,
|
|
745
|
+
* or `rescue` returns true for it. `rescue` therefore only ever rescues an otherwise-orphaned
|
|
746
|
+
* ingredient. It can never drop a referenced or lineage ingredient. Call
|
|
747
|
+
* {@link Builder.filterActions} first if you are also removing actions: the keep-set is
|
|
748
|
+
* computed from whatever actions currently remain.
|
|
749
|
+
*
|
|
750
|
+
* @param rescue Can rescue an otherwise-orphaned ingredient by returning true.
|
|
751
|
+
*/
|
|
752
|
+
async filterIngredients(e) {
|
|
753
|
+
const o = ((await i(this, c).tx.builder_getDefinition(
|
|
754
|
+
i(this, u)
|
|
755
|
+
)).ingredients ?? []).reduce((s, _, a) => (e(_) && s.push(a), s), []);
|
|
756
|
+
await i(this, c).tx.builder_filterIngredientsAt(i(this, u), o);
|
|
757
|
+
}
|
|
758
|
+
/**
|
|
759
|
+
* Experimental.
|
|
760
|
+
* Retains actions and ingredients together in one step.
|
|
761
|
+
*
|
|
762
|
+
* `rescueIngredient` is evaluated for every ingredient first; any action referencing an
|
|
763
|
+
* ingredient it would rescue is force-kept regardless of `keepAction`.
|
|
764
|
+
*
|
|
765
|
+
* @param keepAction The action is retained when the predicate returns true.
|
|
766
|
+
* @param rescueIngredient Can rescue an otherwise-orphaned ingredient (and the action
|
|
767
|
+
* referencing it) by returning true.
|
|
768
|
+
*/
|
|
769
|
+
async filterActionsAndIngredients(e, t) {
|
|
770
|
+
const r = await i(this, c).tx.builder_getDefinition(
|
|
771
|
+
i(this, u)
|
|
772
|
+
), s = X(r).reduce((f, m, d) => (e(m) && f.push(d), f), []), a = (r.ingredients ?? []).reduce(
|
|
773
|
+
(f, m, d) => (t(m) && f.push(d), f),
|
|
774
|
+
[]
|
|
775
|
+
);
|
|
776
|
+
await i(this, c).tx.builder_filterActionsAndIngredientsAt(
|
|
777
|
+
i(this, u),
|
|
778
|
+
s,
|
|
779
|
+
a
|
|
780
|
+
);
|
|
781
|
+
}
|
|
782
|
+
/**
|
|
783
|
+
* Replaces the actions in the `c2pa.actions`/`c2pa.actions.v2` assertions.
|
|
784
|
+
*
|
|
785
|
+
* A manifest can carry more than one actions assertion (the created-list and
|
|
786
|
+
* gathered-list entries are distinct assertions). `transform` is therefore
|
|
787
|
+
* invoked once per actions assertion, in positional order, with that
|
|
788
|
+
* assertion's own actions.
|
|
789
|
+
*
|
|
790
|
+
* A no-op if there is no actions assertion. Use `addAction` for those.
|
|
791
|
+
*
|
|
792
|
+
* The returned list is written back as is.
|
|
793
|
+
* `transform` can therefore produce an actions array that fails
|
|
794
|
+
* validation at signing time, for example by removing the inception action
|
|
795
|
+
* (`c2pa.created`/`c2pa.opened`) or moving it out of first position.
|
|
796
|
+
*
|
|
797
|
+
* @param transform Receives one assertion's actions and returns its full replacement list.
|
|
798
|
+
*/
|
|
799
|
+
async updateActions(e) {
|
|
800
|
+
const t = await i(this, c).tx.builder_getDefinition(
|
|
801
|
+
i(this, u)
|
|
802
|
+
), o = ie(t).map((s) => e(s));
|
|
803
|
+
await i(this, c).tx.builder_updateActionsAt(i(this, u), o);
|
|
804
|
+
}
|
|
805
|
+
/**
|
|
806
|
+
* Add an ingredient to the builder from a definition only.
|
|
807
|
+
*
|
|
808
|
+
* @param ingredientDefinition {@link Ingredient} definition.
|
|
809
|
+
*/
|
|
810
|
+
async addIngredient(e) {
|
|
811
|
+
const t = JSON.stringify(e);
|
|
812
|
+
await i(this, c).tx.builder_addIngredient(i(this, u), t);
|
|
813
|
+
}
|
|
814
|
+
/**
|
|
815
|
+
* Add an ingredient to the builder from a definition, format, and blob.
|
|
816
|
+
* Values specified in the ingredient definition will be merged with the ingredient, and these values take precendence.
|
|
817
|
+
*
|
|
818
|
+
* @param ingredientDefinition {@link Ingredient} definition.
|
|
819
|
+
* @param format Format of the ingredient.
|
|
820
|
+
* @param blob Blob of the ingredient's bytes.
|
|
821
|
+
*/
|
|
822
|
+
async addIngredientFromBlob(e, t, r) {
|
|
823
|
+
const o = JSON.stringify(e);
|
|
824
|
+
await i(this, c).tx.builder_addIngredientFromBlob(i(this, u), o, t, r);
|
|
825
|
+
}
|
|
826
|
+
/**
|
|
827
|
+
* Add a resource to the builder's resource store with an ID and blob of the resource's bytes.
|
|
828
|
+
*
|
|
829
|
+
* @param resourceId ID associated with the resource being added.
|
|
830
|
+
* @param blob Blob of the resource's bytes.
|
|
831
|
+
*/
|
|
832
|
+
async addResourceFromBlob(e, t) {
|
|
833
|
+
await i(this, c).tx.builder_addResourceFromBlob(i(this, u), e, t);
|
|
834
|
+
}
|
|
835
|
+
/**
|
|
836
|
+
* Gets the current manifest definition held by the builder.
|
|
837
|
+
*
|
|
838
|
+
* @returns The {@link ManifestDefinition} held by the builder.
|
|
839
|
+
*/
|
|
840
|
+
async getDefinition() {
|
|
841
|
+
return await i(this, c).tx.builder_getDefinition(i(this, u));
|
|
842
|
+
}
|
|
843
|
+
/**
|
|
844
|
+
* Save the builder into .c2pa format.
|
|
845
|
+
* This "archive" can be added to as an ingredient with {@link addIngredientFromBlob}
|
|
846
|
+
*
|
|
847
|
+
* @returns A builder archive in application/c2pa format.
|
|
848
|
+
*/
|
|
849
|
+
async toArchive() {
|
|
850
|
+
return await i(this, c).tx.builder_toArchive(i(this, u));
|
|
851
|
+
}
|
|
852
|
+
/**
|
|
853
|
+
* Sign an asset.
|
|
854
|
+
*
|
|
855
|
+
* @param signer The signer to use for the manifest's claim signature.
|
|
856
|
+
* @param format The format (MIME type) of the asset.
|
|
857
|
+
* @param blob The asset bytes.
|
|
858
|
+
* @param options Optional {@link SignOptions}. `identityAssertions` attaches
|
|
859
|
+
* one or more CAWG identity assertions (`cawg.identity`) to the manifest.
|
|
860
|
+
*
|
|
861
|
+
* @todo Docs coming soon
|
|
862
|
+
*/
|
|
863
|
+
async sign(e, t, r, o) {
|
|
864
|
+
const s = await H(e), _ = i(this, c).registerSignReceiver(e.sign), a = K(
|
|
865
|
+
i(this, c),
|
|
866
|
+
o
|
|
867
|
+
);
|
|
868
|
+
return await i(this, c).tx.builder_sign(
|
|
869
|
+
i(this, u),
|
|
870
|
+
_,
|
|
871
|
+
s,
|
|
872
|
+
a,
|
|
873
|
+
t,
|
|
874
|
+
r
|
|
875
|
+
);
|
|
876
|
+
}
|
|
877
|
+
/**
|
|
878
|
+
* Sign an asset and get both the signed asset bytes and the manifest bytes.
|
|
879
|
+
*
|
|
880
|
+
* @param signer The signer to use for the manifest's claim signature.
|
|
881
|
+
* @param format The format (MIME type) of the asset.
|
|
882
|
+
* @param blob The asset bytes.
|
|
883
|
+
* @param options Optional {@link SignOptions}. `identityAssertions` attaches
|
|
884
|
+
* one or more CAWG identity assertions (`cawg.identity`) to the manifest.
|
|
885
|
+
*
|
|
886
|
+
* @todo Docs coming soon
|
|
887
|
+
*/
|
|
888
|
+
async signAndGetManifestBytes(e, t, r, o) {
|
|
889
|
+
const s = await H(e), _ = i(this, c).registerSignReceiver(e.sign), a = K(
|
|
890
|
+
i(this, c),
|
|
891
|
+
o
|
|
892
|
+
);
|
|
893
|
+
return await i(this, c).tx.builder_signAndGetManifestBytes(
|
|
894
|
+
i(this, u),
|
|
895
|
+
_,
|
|
896
|
+
s,
|
|
897
|
+
a,
|
|
898
|
+
t,
|
|
899
|
+
r
|
|
900
|
+
);
|
|
901
|
+
}
|
|
902
|
+
/**
|
|
903
|
+
* Dispose of this Builder, freeing the memory it occupied and preventing further use. Call this whenever the Builder is no longer needed.
|
|
904
|
+
*/
|
|
905
|
+
async free() {
|
|
906
|
+
M.unregister(this), await i(this, c).tx.builder_free(i(this, u));
|
|
907
|
+
}
|
|
908
|
+
};
|
|
909
|
+
c = new WeakMap(), u = new WeakMap();
|
|
910
|
+
let I = E;
|
|
911
|
+
function Ue(n, e = {}) {
|
|
912
|
+
return {
|
|
913
|
+
new: (t = {}) => I.new(n, new p(x(e, t))),
|
|
914
|
+
fromDefinition: (t, r = {}) => I.fromDefinition(
|
|
915
|
+
n,
|
|
916
|
+
t,
|
|
917
|
+
new p(x(e, r))
|
|
918
|
+
),
|
|
919
|
+
fromArchive: (t, r = {}) => I.fromArchive(
|
|
920
|
+
n,
|
|
921
|
+
t,
|
|
922
|
+
new p(x(e, r))
|
|
923
|
+
)
|
|
924
|
+
};
|
|
925
|
+
}
|
|
926
|
+
async function Ve(n) {
|
|
927
|
+
const { wasmSrc: e, workerSrc: t, settings: r } = n, o = typeof e == "string" ? await Ne(e) : e, s = await fe({ wasm: o, workerSrc: t }), _ = {
|
|
928
|
+
worker: s,
|
|
929
|
+
reader: void 0,
|
|
930
|
+
builder: void 0,
|
|
931
|
+
dispose: s.terminate
|
|
932
|
+
};
|
|
933
|
+
return _.reader = je(_, r), _.builder = Ue(_, r), _;
|
|
934
|
+
}
|
|
935
|
+
async function Ne(n) {
|
|
936
|
+
const e = await fetch(n, { integrity: le });
|
|
937
|
+
return await WebAssembly.compileStreaming(e);
|
|
938
|
+
}
|
|
939
|
+
export {
|
|
940
|
+
Be as A,
|
|
941
|
+
I as B,
|
|
942
|
+
p as C,
|
|
943
|
+
me as D,
|
|
944
|
+
B as R,
|
|
945
|
+
ge as a,
|
|
946
|
+
we as b,
|
|
947
|
+
ye as c,
|
|
948
|
+
he as d,
|
|
949
|
+
Me as e,
|
|
950
|
+
Ie as f,
|
|
951
|
+
Ve as g,
|
|
952
|
+
Ce as h,
|
|
953
|
+
Pe as i,
|
|
954
|
+
$e as j,
|
|
955
|
+
pe as k,
|
|
956
|
+
qe as l,
|
|
957
|
+
k as m,
|
|
958
|
+
ee as n,
|
|
959
|
+
We as o,
|
|
960
|
+
x as p,
|
|
961
|
+
Te as q,
|
|
962
|
+
V as r,
|
|
963
|
+
q as s,
|
|
964
|
+
ke as t,
|
|
965
|
+
D as u,
|
|
966
|
+
N as v,
|
|
967
|
+
Ee as w
|
|
968
|
+
};
|